18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * dvb_frontend.h
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * The Digital TV Frontend kABI defines a driver-internal interface for
58c2ecf20Sopenharmony_ci * registering low-level, hardware specific driver to a hardware independent
68c2ecf20Sopenharmony_ci * frontend layer.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Copyright (C) 2001 convergence integrated media GmbH
98c2ecf20Sopenharmony_ci * Copyright (C) 2004 convergence GmbH
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * Written by Ralph Metzler
128c2ecf20Sopenharmony_ci * Overhauled by Holger Waechtler
138c2ecf20Sopenharmony_ci * Kernel I2C stuff by Michael Hunold <hunold@convergence.de>
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or
168c2ecf20Sopenharmony_ci * modify it under the terms of the GNU Lesser General Public License
178c2ecf20Sopenharmony_ci * as published by the Free Software Foundation; either version 2.1
188c2ecf20Sopenharmony_ci * of the License, or (at your option) any later version.
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful,
218c2ecf20Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
228c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
238c2ecf20Sopenharmony_ci * GNU General Public License for more details.
248c2ecf20Sopenharmony_ci *
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci * You should have received a copy of the GNU Lesser General Public License
278c2ecf20Sopenharmony_ci * along with this program; if not, write to the Free Software
288c2ecf20Sopenharmony_ci * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
298c2ecf20Sopenharmony_ci *
308c2ecf20Sopenharmony_ci */
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#ifndef _DVB_FRONTEND_H_
338c2ecf20Sopenharmony_ci#define _DVB_FRONTEND_H_
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#include <linux/types.h>
368c2ecf20Sopenharmony_ci#include <linux/sched.h>
378c2ecf20Sopenharmony_ci#include <linux/ioctl.h>
388c2ecf20Sopenharmony_ci#include <linux/i2c.h>
398c2ecf20Sopenharmony_ci#include <linux/module.h>
408c2ecf20Sopenharmony_ci#include <linux/errno.h>
418c2ecf20Sopenharmony_ci#include <linux/delay.h>
428c2ecf20Sopenharmony_ci#include <linux/mutex.h>
438c2ecf20Sopenharmony_ci#include <linux/slab.h>
448c2ecf20Sopenharmony_ci#include <linux/bitops.h>
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#include <linux/dvb/frontend.h>
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#include <media/dvbdev.h>
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci/*
518c2ecf20Sopenharmony_ci * Maximum number of Delivery systems per frontend. It
528c2ecf20Sopenharmony_ci * should be smaller or equal to 32
538c2ecf20Sopenharmony_ci */
548c2ecf20Sopenharmony_ci#define MAX_DELSYS	8
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/* Helper definitions to be used at frontend drivers */
578c2ecf20Sopenharmony_ci#define kHz 1000UL
588c2ecf20Sopenharmony_ci#define MHz 1000000UL
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci/**
618c2ecf20Sopenharmony_ci * struct dvb_frontend_tune_settings - parameters to adjust frontend tuning
628c2ecf20Sopenharmony_ci *
638c2ecf20Sopenharmony_ci * @min_delay_ms:	minimum delay for tuning, in ms
648c2ecf20Sopenharmony_ci * @step_size:		step size between two consecutive frequencies
658c2ecf20Sopenharmony_ci * @max_drift:		maximum drift
668c2ecf20Sopenharmony_ci *
678c2ecf20Sopenharmony_ci * NOTE: step_size is in Hz, for terrestrial/cable or kHz for satellite
688c2ecf20Sopenharmony_ci */
698c2ecf20Sopenharmony_cistruct dvb_frontend_tune_settings {
708c2ecf20Sopenharmony_ci	int min_delay_ms;
718c2ecf20Sopenharmony_ci	int step_size;
728c2ecf20Sopenharmony_ci	int max_drift;
738c2ecf20Sopenharmony_ci};
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_cistruct dvb_frontend;
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci/**
788c2ecf20Sopenharmony_ci * struct dvb_tuner_info - Frontend name and min/max ranges/bandwidths
798c2ecf20Sopenharmony_ci *
808c2ecf20Sopenharmony_ci * @name:		name of the Frontend
818c2ecf20Sopenharmony_ci * @frequency_min_hz:	minimal frequency supported in Hz
828c2ecf20Sopenharmony_ci * @frequency_max_hz:	maximum frequency supported in Hz
838c2ecf20Sopenharmony_ci * @frequency_step_hz:	frequency step in Hz
848c2ecf20Sopenharmony_ci * @bandwidth_min:	minimal frontend bandwidth supported
858c2ecf20Sopenharmony_ci * @bandwidth_max:	maximum frontend bandwidth supported
868c2ecf20Sopenharmony_ci * @bandwidth_step:	frontend bandwidth step
878c2ecf20Sopenharmony_ci */
888c2ecf20Sopenharmony_cistruct dvb_tuner_info {
898c2ecf20Sopenharmony_ci	char name[128];
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci	u32 frequency_min_hz;
928c2ecf20Sopenharmony_ci	u32 frequency_max_hz;
938c2ecf20Sopenharmony_ci	u32 frequency_step_hz;
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci	u32 bandwidth_min;
968c2ecf20Sopenharmony_ci	u32 bandwidth_max;
978c2ecf20Sopenharmony_ci	u32 bandwidth_step;
988c2ecf20Sopenharmony_ci};
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci/**
1018c2ecf20Sopenharmony_ci * struct analog_parameters - Parameters to tune into an analog/radio channel
1028c2ecf20Sopenharmony_ci *
1038c2ecf20Sopenharmony_ci * @frequency:	Frequency used by analog TV tuner (either in 62.5 kHz step,
1048c2ecf20Sopenharmony_ci *		for TV, or 62.5 Hz for radio)
1058c2ecf20Sopenharmony_ci * @mode:	Tuner mode, as defined on enum v4l2_tuner_type
1068c2ecf20Sopenharmony_ci * @audmode:	Audio mode as defined for the rxsubchans field at videodev2.h,
1078c2ecf20Sopenharmony_ci *		e. g. V4L2_TUNER_MODE_*
1088c2ecf20Sopenharmony_ci * @std:	TV standard bitmap as defined at videodev2.h, e. g. V4L2_STD_*
1098c2ecf20Sopenharmony_ci *
1108c2ecf20Sopenharmony_ci * Hybrid tuners should be supported by both V4L2 and DVB APIs. This
1118c2ecf20Sopenharmony_ci * struct contains the data that are used by the V4L2 side. To avoid
1128c2ecf20Sopenharmony_ci * dependencies from V4L2 headers, all enums here are declared as integers.
1138c2ecf20Sopenharmony_ci */
1148c2ecf20Sopenharmony_cistruct analog_parameters {
1158c2ecf20Sopenharmony_ci	unsigned int frequency;
1168c2ecf20Sopenharmony_ci	unsigned int mode;
1178c2ecf20Sopenharmony_ci	unsigned int audmode;
1188c2ecf20Sopenharmony_ci	u64 std;
1198c2ecf20Sopenharmony_ci};
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci/**
1228c2ecf20Sopenharmony_ci * enum dvbfe_algo - defines the algorithm used to tune into a channel
1238c2ecf20Sopenharmony_ci *
1248c2ecf20Sopenharmony_ci * @DVBFE_ALGO_HW: Hardware Algorithm -
1258c2ecf20Sopenharmony_ci *	Devices that support this algorithm do everything in hardware
1268c2ecf20Sopenharmony_ci *	and no software support is needed to handle them.
1278c2ecf20Sopenharmony_ci *	Requesting these devices to LOCK is the only thing required,
1288c2ecf20Sopenharmony_ci *	device is supposed to do everything in the hardware.
1298c2ecf20Sopenharmony_ci *
1308c2ecf20Sopenharmony_ci * @DVBFE_ALGO_SW: Software Algorithm -
1318c2ecf20Sopenharmony_ci * These are dumb devices, that require software to do everything
1328c2ecf20Sopenharmony_ci *
1338c2ecf20Sopenharmony_ci * @DVBFE_ALGO_CUSTOM: Customizable Agorithm -
1348c2ecf20Sopenharmony_ci *	Devices having this algorithm can be customized to have specific
1358c2ecf20Sopenharmony_ci *	algorithms in the frontend driver, rather than simply doing a
1368c2ecf20Sopenharmony_ci *	software zig-zag. In this case the zigzag maybe hardware assisted
1378c2ecf20Sopenharmony_ci *	or it maybe completely done in hardware. In all cases, usage of
1388c2ecf20Sopenharmony_ci *	this algorithm, in conjunction with the search and track
1398c2ecf20Sopenharmony_ci *	callbacks, utilizes the driver specific algorithm.
1408c2ecf20Sopenharmony_ci *
1418c2ecf20Sopenharmony_ci * @DVBFE_ALGO_RECOVERY: Recovery Algorithm -
1428c2ecf20Sopenharmony_ci *	These devices have AUTO recovery capabilities from LOCK failure
1438c2ecf20Sopenharmony_ci */
1448c2ecf20Sopenharmony_cienum dvbfe_algo {
1458c2ecf20Sopenharmony_ci	DVBFE_ALGO_HW			= BIT(0),
1468c2ecf20Sopenharmony_ci	DVBFE_ALGO_SW			= BIT(1),
1478c2ecf20Sopenharmony_ci	DVBFE_ALGO_CUSTOM		= BIT(2),
1488c2ecf20Sopenharmony_ci	DVBFE_ALGO_RECOVERY		= BIT(31),
1498c2ecf20Sopenharmony_ci};
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci/**
1528c2ecf20Sopenharmony_ci * enum dvbfe_search - search callback possible return status
1538c2ecf20Sopenharmony_ci *
1548c2ecf20Sopenharmony_ci * @DVBFE_ALGO_SEARCH_SUCCESS:
1558c2ecf20Sopenharmony_ci *	The frontend search algorithm completed and returned successfully
1568c2ecf20Sopenharmony_ci *
1578c2ecf20Sopenharmony_ci * @DVBFE_ALGO_SEARCH_ASLEEP:
1588c2ecf20Sopenharmony_ci *	The frontend search algorithm is sleeping
1598c2ecf20Sopenharmony_ci *
1608c2ecf20Sopenharmony_ci * @DVBFE_ALGO_SEARCH_FAILED:
1618c2ecf20Sopenharmony_ci *	The frontend search for a signal failed
1628c2ecf20Sopenharmony_ci *
1638c2ecf20Sopenharmony_ci * @DVBFE_ALGO_SEARCH_INVALID:
1648c2ecf20Sopenharmony_ci *	The frontend search algorithm was probably supplied with invalid
1658c2ecf20Sopenharmony_ci *	parameters and the search is an invalid one
1668c2ecf20Sopenharmony_ci *
1678c2ecf20Sopenharmony_ci * @DVBFE_ALGO_SEARCH_ERROR:
1688c2ecf20Sopenharmony_ci *	The frontend search algorithm failed due to some error
1698c2ecf20Sopenharmony_ci *
1708c2ecf20Sopenharmony_ci * @DVBFE_ALGO_SEARCH_AGAIN:
1718c2ecf20Sopenharmony_ci *	The frontend search algorithm was requested to search again
1728c2ecf20Sopenharmony_ci */
1738c2ecf20Sopenharmony_cienum dvbfe_search {
1748c2ecf20Sopenharmony_ci	DVBFE_ALGO_SEARCH_SUCCESS	= BIT(0),
1758c2ecf20Sopenharmony_ci	DVBFE_ALGO_SEARCH_ASLEEP	= BIT(1),
1768c2ecf20Sopenharmony_ci	DVBFE_ALGO_SEARCH_FAILED	= BIT(2),
1778c2ecf20Sopenharmony_ci	DVBFE_ALGO_SEARCH_INVALID	= BIT(3),
1788c2ecf20Sopenharmony_ci	DVBFE_ALGO_SEARCH_AGAIN		= BIT(4),
1798c2ecf20Sopenharmony_ci	DVBFE_ALGO_SEARCH_ERROR		= BIT(31),
1808c2ecf20Sopenharmony_ci};
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci/**
1838c2ecf20Sopenharmony_ci * struct dvb_tuner_ops - Tuner information and callbacks
1848c2ecf20Sopenharmony_ci *
1858c2ecf20Sopenharmony_ci * @info:		embedded &struct dvb_tuner_info with tuner properties
1868c2ecf20Sopenharmony_ci * @release:		callback function called when frontend is detached.
1878c2ecf20Sopenharmony_ci *			drivers should free any allocated memory.
1888c2ecf20Sopenharmony_ci * @init:		callback function used to initialize the tuner device.
1898c2ecf20Sopenharmony_ci * @sleep:		callback function used to put the tuner to sleep.
1908c2ecf20Sopenharmony_ci * @suspend:		callback function used to inform that the Kernel will
1918c2ecf20Sopenharmony_ci *			suspend.
1928c2ecf20Sopenharmony_ci * @resume:		callback function used to inform that the Kernel is
1938c2ecf20Sopenharmony_ci *			resuming from suspend.
1948c2ecf20Sopenharmony_ci * @set_params:		callback function used to inform the tuner to tune
1958c2ecf20Sopenharmony_ci *			into a digital TV channel. The properties to be used
1968c2ecf20Sopenharmony_ci *			are stored at &struct dvb_frontend.dtv_property_cache.
1978c2ecf20Sopenharmony_ci *			The tuner demod can change the parameters to reflect
1988c2ecf20Sopenharmony_ci *			the changes needed for the channel to be tuned, and
1998c2ecf20Sopenharmony_ci *			update statistics. This is the recommended way to set
2008c2ecf20Sopenharmony_ci *			the tuner parameters and should be used on newer
2018c2ecf20Sopenharmony_ci *			drivers.
2028c2ecf20Sopenharmony_ci * @set_analog_params:	callback function used to tune into an analog TV
2038c2ecf20Sopenharmony_ci *			channel on hybrid tuners. It passes @analog_parameters
2048c2ecf20Sopenharmony_ci *			to the driver.
2058c2ecf20Sopenharmony_ci * @set_config:		callback function used to send some tuner-specific
2068c2ecf20Sopenharmony_ci *			parameters.
2078c2ecf20Sopenharmony_ci * @get_frequency:	get the actual tuned frequency
2088c2ecf20Sopenharmony_ci * @get_bandwidth:	get the bandwidth used by the low pass filters
2098c2ecf20Sopenharmony_ci * @get_if_frequency:	get the Intermediate Frequency, in Hz. For baseband,
2108c2ecf20Sopenharmony_ci *			should return 0.
2118c2ecf20Sopenharmony_ci * @get_status:		returns the frontend lock status
2128c2ecf20Sopenharmony_ci * @get_rf_strength:	returns the RF signal strength. Used mostly to support
2138c2ecf20Sopenharmony_ci *			analog TV and radio. Digital TV should report, instead,
2148c2ecf20Sopenharmony_ci *			via DVBv5 API (&struct dvb_frontend.dtv_property_cache).
2158c2ecf20Sopenharmony_ci * @get_afc:		Used only by analog TV core. Reports the frequency
2168c2ecf20Sopenharmony_ci *			drift due to AFC.
2178c2ecf20Sopenharmony_ci * @calc_regs:		callback function used to pass register data settings
2188c2ecf20Sopenharmony_ci *			for simple tuners.  Shouldn't be used on newer drivers.
2198c2ecf20Sopenharmony_ci * @set_frequency:	Set a new frequency. Shouldn't be used on newer drivers.
2208c2ecf20Sopenharmony_ci * @set_bandwidth:	Set a new frequency. Shouldn't be used on newer drivers.
2218c2ecf20Sopenharmony_ci *
2228c2ecf20Sopenharmony_ci * NOTE: frequencies used on @get_frequency and @set_frequency are in Hz for
2238c2ecf20Sopenharmony_ci * terrestrial/cable or kHz for satellite.
2248c2ecf20Sopenharmony_ci *
2258c2ecf20Sopenharmony_ci */
2268c2ecf20Sopenharmony_cistruct dvb_tuner_ops {
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_ci	struct dvb_tuner_info info;
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_ci	void (*release)(struct dvb_frontend *fe);
2318c2ecf20Sopenharmony_ci	int (*init)(struct dvb_frontend *fe);
2328c2ecf20Sopenharmony_ci	int (*sleep)(struct dvb_frontend *fe);
2338c2ecf20Sopenharmony_ci	int (*suspend)(struct dvb_frontend *fe);
2348c2ecf20Sopenharmony_ci	int (*resume)(struct dvb_frontend *fe);
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ci	/* This is the recommended way to set the tuner */
2378c2ecf20Sopenharmony_ci	int (*set_params)(struct dvb_frontend *fe);
2388c2ecf20Sopenharmony_ci	int (*set_analog_params)(struct dvb_frontend *fe, struct analog_parameters *p);
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_ci	int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_ci	int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency);
2438c2ecf20Sopenharmony_ci	int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
2448c2ecf20Sopenharmony_ci	int (*get_if_frequency)(struct dvb_frontend *fe, u32 *frequency);
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ci#define TUNER_STATUS_LOCKED 1
2478c2ecf20Sopenharmony_ci#define TUNER_STATUS_STEREO 2
2488c2ecf20Sopenharmony_ci	int (*get_status)(struct dvb_frontend *fe, u32 *status);
2498c2ecf20Sopenharmony_ci	int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength);
2508c2ecf20Sopenharmony_ci	int (*get_afc)(struct dvb_frontend *fe, s32 *afc);
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_ci	/*
2538c2ecf20Sopenharmony_ci	 * This is support for demods like the mt352 - fills out the supplied
2548c2ecf20Sopenharmony_ci	 * buffer with what to write.
2558c2ecf20Sopenharmony_ci	 *
2568c2ecf20Sopenharmony_ci	 * Don't use on newer drivers.
2578c2ecf20Sopenharmony_ci	 */
2588c2ecf20Sopenharmony_ci	int (*calc_regs)(struct dvb_frontend *fe, u8 *buf, int buf_len);
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_ci	/*
2618c2ecf20Sopenharmony_ci	 * These are provided separately from set_params in order to
2628c2ecf20Sopenharmony_ci	 * facilitate silicon tuners which require sophisticated tuning loops,
2638c2ecf20Sopenharmony_ci	 * controlling each parameter separately.
2648c2ecf20Sopenharmony_ci	 *
2658c2ecf20Sopenharmony_ci	 * Don't use on newer drivers.
2668c2ecf20Sopenharmony_ci	 */
2678c2ecf20Sopenharmony_ci	int (*set_frequency)(struct dvb_frontend *fe, u32 frequency);
2688c2ecf20Sopenharmony_ci	int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
2698c2ecf20Sopenharmony_ci};
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci/**
2728c2ecf20Sopenharmony_ci * struct analog_demod_info - Information struct for analog TV part of the demod
2738c2ecf20Sopenharmony_ci *
2748c2ecf20Sopenharmony_ci * @name:	Name of the analog TV demodulator
2758c2ecf20Sopenharmony_ci */
2768c2ecf20Sopenharmony_cistruct analog_demod_info {
2778c2ecf20Sopenharmony_ci	char *name;
2788c2ecf20Sopenharmony_ci};
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci/**
2818c2ecf20Sopenharmony_ci * struct analog_demod_ops  - Demodulation information and callbacks for
2828c2ecf20Sopenharmony_ci *			      analog TV and radio
2838c2ecf20Sopenharmony_ci *
2848c2ecf20Sopenharmony_ci * @info:		pointer to struct analog_demod_info
2858c2ecf20Sopenharmony_ci * @set_params:		callback function used to inform the demod to set the
2868c2ecf20Sopenharmony_ci *			demodulator parameters needed to decode an analog or
2878c2ecf20Sopenharmony_ci *			radio channel. The properties are passed via
2888c2ecf20Sopenharmony_ci *			&struct analog_params.
2898c2ecf20Sopenharmony_ci * @has_signal:		returns 0xffff if has signal, or 0 if it doesn't.
2908c2ecf20Sopenharmony_ci * @get_afc:		Used only by analog TV core. Reports the frequency
2918c2ecf20Sopenharmony_ci *			drift due to AFC.
2928c2ecf20Sopenharmony_ci * @tuner_status:	callback function that returns tuner status bits, e. g.
2938c2ecf20Sopenharmony_ci *			%TUNER_STATUS_LOCKED and %TUNER_STATUS_STEREO.
2948c2ecf20Sopenharmony_ci * @standby:		set the tuner to standby mode.
2958c2ecf20Sopenharmony_ci * @release:		callback function called when frontend is detached.
2968c2ecf20Sopenharmony_ci *			drivers should free any allocated memory.
2978c2ecf20Sopenharmony_ci * @i2c_gate_ctrl:	controls the I2C gate. Newer drivers should use I2C
2988c2ecf20Sopenharmony_ci *			mux support instead.
2998c2ecf20Sopenharmony_ci * @set_config:		callback function used to send some tuner-specific
3008c2ecf20Sopenharmony_ci *			parameters.
3018c2ecf20Sopenharmony_ci */
3028c2ecf20Sopenharmony_cistruct analog_demod_ops {
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_ci	struct analog_demod_info info;
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_ci	void (*set_params)(struct dvb_frontend *fe,
3078c2ecf20Sopenharmony_ci			   struct analog_parameters *params);
3088c2ecf20Sopenharmony_ci	int  (*has_signal)(struct dvb_frontend *fe, u16 *signal);
3098c2ecf20Sopenharmony_ci	int  (*get_afc)(struct dvb_frontend *fe, s32 *afc);
3108c2ecf20Sopenharmony_ci	void (*tuner_status)(struct dvb_frontend *fe);
3118c2ecf20Sopenharmony_ci	void (*standby)(struct dvb_frontend *fe);
3128c2ecf20Sopenharmony_ci	void (*release)(struct dvb_frontend *fe);
3138c2ecf20Sopenharmony_ci	int  (*i2c_gate_ctrl)(struct dvb_frontend *fe, int enable);
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_ci	/** This is to allow setting tuner-specific configuration */
3168c2ecf20Sopenharmony_ci	int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
3178c2ecf20Sopenharmony_ci};
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_cistruct dtv_frontend_properties;
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_ci/**
3228c2ecf20Sopenharmony_ci * struct dvb_frontend_internal_info - Frontend properties and capabilities
3238c2ecf20Sopenharmony_ci *
3248c2ecf20Sopenharmony_ci * @name:			Name of the frontend
3258c2ecf20Sopenharmony_ci * @frequency_min_hz:		Minimal frequency supported by the frontend.
3268c2ecf20Sopenharmony_ci * @frequency_max_hz:		Minimal frequency supported by the frontend.
3278c2ecf20Sopenharmony_ci * @frequency_stepsize_hz:	All frequencies are multiple of this value.
3288c2ecf20Sopenharmony_ci * @frequency_tolerance_hz:	Frequency tolerance.
3298c2ecf20Sopenharmony_ci * @symbol_rate_min:		Minimal symbol rate, in bauds
3308c2ecf20Sopenharmony_ci *				(for Cable/Satellite systems).
3318c2ecf20Sopenharmony_ci * @symbol_rate_max:		Maximal symbol rate, in bauds
3328c2ecf20Sopenharmony_ci *				(for Cable/Satellite systems).
3338c2ecf20Sopenharmony_ci * @symbol_rate_tolerance:	Maximal symbol rate tolerance, in ppm
3348c2ecf20Sopenharmony_ci *				(for Cable/Satellite systems).
3358c2ecf20Sopenharmony_ci * @caps:			Capabilities supported by the frontend,
3368c2ecf20Sopenharmony_ci *				as specified in &enum fe_caps.
3378c2ecf20Sopenharmony_ci */
3388c2ecf20Sopenharmony_cistruct dvb_frontend_internal_info {
3398c2ecf20Sopenharmony_ci	char	name[128];
3408c2ecf20Sopenharmony_ci	u32	frequency_min_hz;
3418c2ecf20Sopenharmony_ci	u32	frequency_max_hz;
3428c2ecf20Sopenharmony_ci	u32	frequency_stepsize_hz;
3438c2ecf20Sopenharmony_ci	u32	frequency_tolerance_hz;
3448c2ecf20Sopenharmony_ci	u32	symbol_rate_min;
3458c2ecf20Sopenharmony_ci	u32	symbol_rate_max;
3468c2ecf20Sopenharmony_ci	u32	symbol_rate_tolerance;
3478c2ecf20Sopenharmony_ci	enum fe_caps caps;
3488c2ecf20Sopenharmony_ci};
3498c2ecf20Sopenharmony_ci
3508c2ecf20Sopenharmony_ci/**
3518c2ecf20Sopenharmony_ci * struct dvb_frontend_ops - Demodulation information and callbacks for
3528c2ecf20Sopenharmony_ci *			      ditialt TV
3538c2ecf20Sopenharmony_ci *
3548c2ecf20Sopenharmony_ci * @info:		embedded &struct dvb_tuner_info with tuner properties
3558c2ecf20Sopenharmony_ci * @delsys:		Delivery systems supported by the frontend
3568c2ecf20Sopenharmony_ci * @detach:		callback function called when frontend is detached.
3578c2ecf20Sopenharmony_ci *			drivers should clean up, but not yet free the &struct
3588c2ecf20Sopenharmony_ci *			dvb_frontend allocation.
3598c2ecf20Sopenharmony_ci * @release:		callback function called when frontend is ready to be
3608c2ecf20Sopenharmony_ci *			freed.
3618c2ecf20Sopenharmony_ci *			drivers should free any allocated memory.
3628c2ecf20Sopenharmony_ci * @release_sec:	callback function requesting that the Satellite Equipment
3638c2ecf20Sopenharmony_ci *			Control (SEC) driver to release and free any memory
3648c2ecf20Sopenharmony_ci *			allocated by the driver.
3658c2ecf20Sopenharmony_ci * @init:		callback function used to initialize the tuner device.
3668c2ecf20Sopenharmony_ci * @sleep:		callback function used to put the tuner to sleep.
3678c2ecf20Sopenharmony_ci * @write:		callback function used by some demod legacy drivers to
3688c2ecf20Sopenharmony_ci *			allow other drivers to write data into their registers.
3698c2ecf20Sopenharmony_ci *			Should not be used on new drivers.
3708c2ecf20Sopenharmony_ci * @tune:		callback function used by demod drivers that use
3718c2ecf20Sopenharmony_ci *			@DVBFE_ALGO_HW to tune into a frequency.
3728c2ecf20Sopenharmony_ci * @get_frontend_algo:	returns the desired hardware algorithm.
3738c2ecf20Sopenharmony_ci * @set_frontend:	callback function used to inform the demod to set the
3748c2ecf20Sopenharmony_ci *			parameters for demodulating a digital TV channel.
3758c2ecf20Sopenharmony_ci *			The properties to be used are stored at &struct
3768c2ecf20Sopenharmony_ci *			dvb_frontend.dtv_property_cache. The demod can change
3778c2ecf20Sopenharmony_ci *			the parameters to reflect the changes needed for the
3788c2ecf20Sopenharmony_ci *			channel to be decoded, and update statistics.
3798c2ecf20Sopenharmony_ci * @get_tune_settings:	callback function
3808c2ecf20Sopenharmony_ci * @get_frontend:	callback function used to inform the parameters
3818c2ecf20Sopenharmony_ci *			actuall in use. The properties to be used are stored at
3828c2ecf20Sopenharmony_ci *			&struct dvb_frontend.dtv_property_cache and update
3838c2ecf20Sopenharmony_ci *			statistics. Please notice that it should not return
3848c2ecf20Sopenharmony_ci *			an error code if the statistics are not available
3858c2ecf20Sopenharmony_ci *			because the demog is not locked.
3868c2ecf20Sopenharmony_ci * @read_status:	returns the locking status of the frontend.
3878c2ecf20Sopenharmony_ci * @read_ber:		legacy callback function to return the bit error rate.
3888c2ecf20Sopenharmony_ci *			Newer drivers should provide such info via DVBv5 API,
3898c2ecf20Sopenharmony_ci *			e. g. @set_frontend;/@get_frontend, implementing this
3908c2ecf20Sopenharmony_ci *			callback only if DVBv3 API compatibility is wanted.
3918c2ecf20Sopenharmony_ci * @read_signal_strength: legacy callback function to return the signal
3928c2ecf20Sopenharmony_ci *			strength. Newer drivers should provide such info via
3938c2ecf20Sopenharmony_ci *			DVBv5 API, e. g. @set_frontend/@get_frontend,
3948c2ecf20Sopenharmony_ci *			implementing this callback only if DVBv3 API
3958c2ecf20Sopenharmony_ci *			compatibility is wanted.
3968c2ecf20Sopenharmony_ci * @read_snr:		legacy callback function to return the Signal/Noise
3978c2ecf20Sopenharmony_ci *			rate. Newer drivers should provide such info via
3988c2ecf20Sopenharmony_ci *			DVBv5 API, e. g. @set_frontend/@get_frontend,
3998c2ecf20Sopenharmony_ci *			implementing this callback only if DVBv3 API
4008c2ecf20Sopenharmony_ci *			compatibility is wanted.
4018c2ecf20Sopenharmony_ci * @read_ucblocks:	legacy callback function to return the Uncorrected Error
4028c2ecf20Sopenharmony_ci *			Blocks. Newer drivers should provide such info via
4038c2ecf20Sopenharmony_ci *			DVBv5 API, e. g. @set_frontend/@get_frontend,
4048c2ecf20Sopenharmony_ci *			implementing this callback only if DVBv3 API
4058c2ecf20Sopenharmony_ci *			compatibility is wanted.
4068c2ecf20Sopenharmony_ci * @diseqc_reset_overload: callback function to implement the
4078c2ecf20Sopenharmony_ci *			FE_DISEQC_RESET_OVERLOAD() ioctl (only Satellite)
4088c2ecf20Sopenharmony_ci * @diseqc_send_master_cmd: callback function to implement the
4098c2ecf20Sopenharmony_ci *			FE_DISEQC_SEND_MASTER_CMD() ioctl (only Satellite).
4108c2ecf20Sopenharmony_ci * @diseqc_recv_slave_reply: callback function to implement the
4118c2ecf20Sopenharmony_ci *			FE_DISEQC_RECV_SLAVE_REPLY() ioctl (only Satellite)
4128c2ecf20Sopenharmony_ci * @diseqc_send_burst:	callback function to implement the
4138c2ecf20Sopenharmony_ci *			FE_DISEQC_SEND_BURST() ioctl (only Satellite).
4148c2ecf20Sopenharmony_ci * @set_tone:		callback function to implement the
4158c2ecf20Sopenharmony_ci *			FE_SET_TONE() ioctl (only Satellite).
4168c2ecf20Sopenharmony_ci * @set_voltage:	callback function to implement the
4178c2ecf20Sopenharmony_ci *			FE_SET_VOLTAGE() ioctl (only Satellite).
4188c2ecf20Sopenharmony_ci * @enable_high_lnb_voltage: callback function to implement the
4198c2ecf20Sopenharmony_ci *			FE_ENABLE_HIGH_LNB_VOLTAGE() ioctl (only Satellite).
4208c2ecf20Sopenharmony_ci * @dishnetwork_send_legacy_command: callback function to implement the
4218c2ecf20Sopenharmony_ci *			FE_DISHNETWORK_SEND_LEGACY_CMD() ioctl (only Satellite).
4228c2ecf20Sopenharmony_ci *			Drivers should not use this, except when the DVB
4238c2ecf20Sopenharmony_ci *			core emulation fails to provide proper support (e.g.
4248c2ecf20Sopenharmony_ci *			if @set_voltage takes more than 8ms to work), and
4258c2ecf20Sopenharmony_ci *			when backward compatibility with this legacy API is
4268c2ecf20Sopenharmony_ci *			required.
4278c2ecf20Sopenharmony_ci * @i2c_gate_ctrl:	controls the I2C gate. Newer drivers should use I2C
4288c2ecf20Sopenharmony_ci *			mux support instead.
4298c2ecf20Sopenharmony_ci * @ts_bus_ctrl:	callback function used to take control of the TS bus.
4308c2ecf20Sopenharmony_ci * @set_lna:		callback function to power on/off/auto the LNA.
4318c2ecf20Sopenharmony_ci * @search:		callback function used on some custom algo search algos.
4328c2ecf20Sopenharmony_ci * @tuner_ops:		pointer to &struct dvb_tuner_ops
4338c2ecf20Sopenharmony_ci * @analog_ops:		pointer to &struct analog_demod_ops
4348c2ecf20Sopenharmony_ci */
4358c2ecf20Sopenharmony_cistruct dvb_frontend_ops {
4368c2ecf20Sopenharmony_ci	struct dvb_frontend_internal_info info;
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_ci	u8 delsys[MAX_DELSYS];
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_ci	void (*detach)(struct dvb_frontend *fe);
4418c2ecf20Sopenharmony_ci	void (*release)(struct dvb_frontend* fe);
4428c2ecf20Sopenharmony_ci	void (*release_sec)(struct dvb_frontend* fe);
4438c2ecf20Sopenharmony_ci
4448c2ecf20Sopenharmony_ci	int (*init)(struct dvb_frontend* fe);
4458c2ecf20Sopenharmony_ci	int (*sleep)(struct dvb_frontend* fe);
4468c2ecf20Sopenharmony_ci
4478c2ecf20Sopenharmony_ci	int (*write)(struct dvb_frontend* fe, const u8 buf[], int len);
4488c2ecf20Sopenharmony_ci
4498c2ecf20Sopenharmony_ci	/* if this is set, it overrides the default swzigzag */
4508c2ecf20Sopenharmony_ci	int (*tune)(struct dvb_frontend* fe,
4518c2ecf20Sopenharmony_ci		    bool re_tune,
4528c2ecf20Sopenharmony_ci		    unsigned int mode_flags,
4538c2ecf20Sopenharmony_ci		    unsigned int *delay,
4548c2ecf20Sopenharmony_ci		    enum fe_status *status);
4558c2ecf20Sopenharmony_ci
4568c2ecf20Sopenharmony_ci	/* get frontend tuning algorithm from the module */
4578c2ecf20Sopenharmony_ci	enum dvbfe_algo (*get_frontend_algo)(struct dvb_frontend *fe);
4588c2ecf20Sopenharmony_ci
4598c2ecf20Sopenharmony_ci	/* these two are only used for the swzigzag code */
4608c2ecf20Sopenharmony_ci	int (*set_frontend)(struct dvb_frontend *fe);
4618c2ecf20Sopenharmony_ci	int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);
4628c2ecf20Sopenharmony_ci
4638c2ecf20Sopenharmony_ci	int (*get_frontend)(struct dvb_frontend *fe,
4648c2ecf20Sopenharmony_ci			    struct dtv_frontend_properties *props);
4658c2ecf20Sopenharmony_ci
4668c2ecf20Sopenharmony_ci	int (*read_status)(struct dvb_frontend *fe, enum fe_status *status);
4678c2ecf20Sopenharmony_ci	int (*read_ber)(struct dvb_frontend* fe, u32* ber);
4688c2ecf20Sopenharmony_ci	int (*read_signal_strength)(struct dvb_frontend* fe, u16* strength);
4698c2ecf20Sopenharmony_ci	int (*read_snr)(struct dvb_frontend* fe, u16* snr);
4708c2ecf20Sopenharmony_ci	int (*read_ucblocks)(struct dvb_frontend* fe, u32* ucblocks);
4718c2ecf20Sopenharmony_ci
4728c2ecf20Sopenharmony_ci	int (*diseqc_reset_overload)(struct dvb_frontend* fe);
4738c2ecf20Sopenharmony_ci	int (*diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);
4748c2ecf20Sopenharmony_ci	int (*diseqc_recv_slave_reply)(struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply);
4758c2ecf20Sopenharmony_ci	int (*diseqc_send_burst)(struct dvb_frontend *fe,
4768c2ecf20Sopenharmony_ci				 enum fe_sec_mini_cmd minicmd);
4778c2ecf20Sopenharmony_ci	int (*set_tone)(struct dvb_frontend *fe, enum fe_sec_tone_mode tone);
4788c2ecf20Sopenharmony_ci	int (*set_voltage)(struct dvb_frontend *fe,
4798c2ecf20Sopenharmony_ci			   enum fe_sec_voltage voltage);
4808c2ecf20Sopenharmony_ci	int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg);
4818c2ecf20Sopenharmony_ci	int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
4828c2ecf20Sopenharmony_ci	int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);
4838c2ecf20Sopenharmony_ci	int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire);
4848c2ecf20Sopenharmony_ci	int (*set_lna)(struct dvb_frontend *);
4858c2ecf20Sopenharmony_ci
4868c2ecf20Sopenharmony_ci	/*
4878c2ecf20Sopenharmony_ci	 * These callbacks are for devices that implement their own
4888c2ecf20Sopenharmony_ci	 * tuning algorithms, rather than a simple swzigzag
4898c2ecf20Sopenharmony_ci	 */
4908c2ecf20Sopenharmony_ci	enum dvbfe_search (*search)(struct dvb_frontend *fe);
4918c2ecf20Sopenharmony_ci
4928c2ecf20Sopenharmony_ci	struct dvb_tuner_ops tuner_ops;
4938c2ecf20Sopenharmony_ci	struct analog_demod_ops analog_ops;
4948c2ecf20Sopenharmony_ci};
4958c2ecf20Sopenharmony_ci
4968c2ecf20Sopenharmony_ci#ifdef __DVB_CORE__
4978c2ecf20Sopenharmony_ci#define MAX_EVENT 8
4988c2ecf20Sopenharmony_ci
4998c2ecf20Sopenharmony_ci/* Used only internally at dvb_frontend.c */
5008c2ecf20Sopenharmony_cistruct dvb_fe_events {
5018c2ecf20Sopenharmony_ci	struct dvb_frontend_event events[MAX_EVENT];
5028c2ecf20Sopenharmony_ci	int			  eventw;
5038c2ecf20Sopenharmony_ci	int			  eventr;
5048c2ecf20Sopenharmony_ci	int			  overflow;
5058c2ecf20Sopenharmony_ci	wait_queue_head_t	  wait_queue;
5068c2ecf20Sopenharmony_ci	struct mutex		  mtx;
5078c2ecf20Sopenharmony_ci};
5088c2ecf20Sopenharmony_ci#endif
5098c2ecf20Sopenharmony_ci
5108c2ecf20Sopenharmony_ci/**
5118c2ecf20Sopenharmony_ci * struct dtv_frontend_properties - contains a list of properties that are
5128c2ecf20Sopenharmony_ci *				    specific to a digital TV standard.
5138c2ecf20Sopenharmony_ci *
5148c2ecf20Sopenharmony_ci * @frequency:		frequency in Hz for terrestrial/cable or in kHz for
5158c2ecf20Sopenharmony_ci *			Satellite
5168c2ecf20Sopenharmony_ci * @modulation:		Frontend modulation type
5178c2ecf20Sopenharmony_ci * @voltage:		SEC voltage (only Satellite)
5188c2ecf20Sopenharmony_ci * @sectone:		SEC tone mode (only Satellite)
5198c2ecf20Sopenharmony_ci * @inversion:		Spectral inversion
5208c2ecf20Sopenharmony_ci * @fec_inner:		Forward error correction inner Code Rate
5218c2ecf20Sopenharmony_ci * @transmission_mode:	Transmission Mode
5228c2ecf20Sopenharmony_ci * @bandwidth_hz:	Bandwidth, in Hz. A zero value means that userspace
5238c2ecf20Sopenharmony_ci *			wants to autodetect.
5248c2ecf20Sopenharmony_ci * @guard_interval:	Guard Interval
5258c2ecf20Sopenharmony_ci * @hierarchy:		Hierarchy
5268c2ecf20Sopenharmony_ci * @symbol_rate:	Symbol Rate
5278c2ecf20Sopenharmony_ci * @code_rate_HP:	high priority stream code rate
5288c2ecf20Sopenharmony_ci * @code_rate_LP:	low priority stream code rate
5298c2ecf20Sopenharmony_ci * @pilot:		Enable/disable/autodetect pilot tones
5308c2ecf20Sopenharmony_ci * @rolloff:		Rolloff factor (alpha)
5318c2ecf20Sopenharmony_ci * @delivery_system:	FE delivery system (e. g. digital TV standard)
5328c2ecf20Sopenharmony_ci * @interleaving:	interleaving
5338c2ecf20Sopenharmony_ci * @isdbt_partial_reception: ISDB-T partial reception (only ISDB standard)
5348c2ecf20Sopenharmony_ci * @isdbt_sb_mode:	ISDB-T Sound Broadcast (SB) mode (only ISDB standard)
5358c2ecf20Sopenharmony_ci * @isdbt_sb_subchannel:	ISDB-T SB subchannel (only ISDB standard)
5368c2ecf20Sopenharmony_ci * @isdbt_sb_segment_idx:	ISDB-T SB segment index (only ISDB standard)
5378c2ecf20Sopenharmony_ci * @isdbt_sb_segment_count:	ISDB-T SB segment count (only ISDB standard)
5388c2ecf20Sopenharmony_ci * @isdbt_layer_enabled:	ISDB Layer enabled (only ISDB standard)
5398c2ecf20Sopenharmony_ci * @layer:		ISDB per-layer data (only ISDB standard)
5408c2ecf20Sopenharmony_ci * @layer.segment_count: Segment Count;
5418c2ecf20Sopenharmony_ci * @layer.fec:		per layer code rate;
5428c2ecf20Sopenharmony_ci * @layer.modulation:	per layer modulation;
5438c2ecf20Sopenharmony_ci * @layer.interleaving:	 per layer interleaving.
5448c2ecf20Sopenharmony_ci * @stream_id:		If different than zero, enable substream filtering, if
5458c2ecf20Sopenharmony_ci *			hardware supports (DVB-S2 and DVB-T2).
5468c2ecf20Sopenharmony_ci * @scrambling_sequence_index:	Carries the index of the DVB-S2 physical layer
5478c2ecf20Sopenharmony_ci *				scrambling sequence.
5488c2ecf20Sopenharmony_ci * @atscmh_fic_ver:	Version number of the FIC (Fast Information Channel)
5498c2ecf20Sopenharmony_ci *			signaling data (only ATSC-M/H)
5508c2ecf20Sopenharmony_ci * @atscmh_parade_id:	Parade identification number (only ATSC-M/H)
5518c2ecf20Sopenharmony_ci * @atscmh_nog:		Number of MH groups per MH subframe for a designated
5528c2ecf20Sopenharmony_ci *			parade (only ATSC-M/H)
5538c2ecf20Sopenharmony_ci * @atscmh_tnog:	Total number of MH groups including all MH groups
5548c2ecf20Sopenharmony_ci *			belonging to all MH parades in one MH subframe
5558c2ecf20Sopenharmony_ci *			(only ATSC-M/H)
5568c2ecf20Sopenharmony_ci * @atscmh_sgn:		Start group number (only ATSC-M/H)
5578c2ecf20Sopenharmony_ci * @atscmh_prc:		Parade repetition cycle (only ATSC-M/H)
5588c2ecf20Sopenharmony_ci * @atscmh_rs_frame_mode:	Reed Solomon (RS) frame mode (only ATSC-M/H)
5598c2ecf20Sopenharmony_ci * @atscmh_rs_frame_ensemble:	RS frame ensemble (only ATSC-M/H)
5608c2ecf20Sopenharmony_ci * @atscmh_rs_code_mode_pri:	RS code mode pri (only ATSC-M/H)
5618c2ecf20Sopenharmony_ci * @atscmh_rs_code_mode_sec:	RS code mode sec (only ATSC-M/H)
5628c2ecf20Sopenharmony_ci * @atscmh_sccc_block_mode:	Series Concatenated Convolutional Code (SCCC)
5638c2ecf20Sopenharmony_ci *				Block Mode (only ATSC-M/H)
5648c2ecf20Sopenharmony_ci * @atscmh_sccc_code_mode_a:	SCCC code mode A (only ATSC-M/H)
5658c2ecf20Sopenharmony_ci * @atscmh_sccc_code_mode_b:	SCCC code mode B (only ATSC-M/H)
5668c2ecf20Sopenharmony_ci * @atscmh_sccc_code_mode_c:	SCCC code mode C (only ATSC-M/H)
5678c2ecf20Sopenharmony_ci * @atscmh_sccc_code_mode_d:	SCCC code mode D (only ATSC-M/H)
5688c2ecf20Sopenharmony_ci * @lna:		Power ON/OFF/AUTO the Linear Now-noise Amplifier (LNA)
5698c2ecf20Sopenharmony_ci * @strength:		DVBv5 API statistics: Signal Strength
5708c2ecf20Sopenharmony_ci * @cnr:		DVBv5 API statistics: Signal to Noise ratio of the
5718c2ecf20Sopenharmony_ci *			(main) carrier
5728c2ecf20Sopenharmony_ci * @pre_bit_error:	DVBv5 API statistics: pre-Viterbi bit error count
5738c2ecf20Sopenharmony_ci * @pre_bit_count:	DVBv5 API statistics: pre-Viterbi bit count
5748c2ecf20Sopenharmony_ci * @post_bit_error:	DVBv5 API statistics: post-Viterbi bit error count
5758c2ecf20Sopenharmony_ci * @post_bit_count:	DVBv5 API statistics: post-Viterbi bit count
5768c2ecf20Sopenharmony_ci * @block_error:	DVBv5 API statistics: block error count
5778c2ecf20Sopenharmony_ci * @block_count:	DVBv5 API statistics: block count
5788c2ecf20Sopenharmony_ci *
5798c2ecf20Sopenharmony_ci * NOTE: derivated statistics like Uncorrected Error blocks (UCE) are
5808c2ecf20Sopenharmony_ci * calculated on userspace.
5818c2ecf20Sopenharmony_ci *
5828c2ecf20Sopenharmony_ci * Only a subset of the properties are needed for a given delivery system.
5838c2ecf20Sopenharmony_ci * For more info, consult the media_api.html with the documentation of the
5848c2ecf20Sopenharmony_ci * Userspace API.
5858c2ecf20Sopenharmony_ci */
5868c2ecf20Sopenharmony_cistruct dtv_frontend_properties {
5878c2ecf20Sopenharmony_ci	u32			frequency;
5888c2ecf20Sopenharmony_ci	enum fe_modulation	modulation;
5898c2ecf20Sopenharmony_ci
5908c2ecf20Sopenharmony_ci	enum fe_sec_voltage	voltage;
5918c2ecf20Sopenharmony_ci	enum fe_sec_tone_mode	sectone;
5928c2ecf20Sopenharmony_ci	enum fe_spectral_inversion inversion;
5938c2ecf20Sopenharmony_ci	enum fe_code_rate	fec_inner;
5948c2ecf20Sopenharmony_ci	enum fe_transmit_mode	transmission_mode;
5958c2ecf20Sopenharmony_ci	u32			bandwidth_hz;	/* 0 = AUTO */
5968c2ecf20Sopenharmony_ci	enum fe_guard_interval	guard_interval;
5978c2ecf20Sopenharmony_ci	enum fe_hierarchy	hierarchy;
5988c2ecf20Sopenharmony_ci	u32			symbol_rate;
5998c2ecf20Sopenharmony_ci	enum fe_code_rate	code_rate_HP;
6008c2ecf20Sopenharmony_ci	enum fe_code_rate	code_rate_LP;
6018c2ecf20Sopenharmony_ci
6028c2ecf20Sopenharmony_ci	enum fe_pilot		pilot;
6038c2ecf20Sopenharmony_ci	enum fe_rolloff		rolloff;
6048c2ecf20Sopenharmony_ci
6058c2ecf20Sopenharmony_ci	enum fe_delivery_system	delivery_system;
6068c2ecf20Sopenharmony_ci
6078c2ecf20Sopenharmony_ci	enum fe_interleaving	interleaving;
6088c2ecf20Sopenharmony_ci
6098c2ecf20Sopenharmony_ci	/* ISDB-T specifics */
6108c2ecf20Sopenharmony_ci	u8			isdbt_partial_reception;
6118c2ecf20Sopenharmony_ci	u8			isdbt_sb_mode;
6128c2ecf20Sopenharmony_ci	u8			isdbt_sb_subchannel;
6138c2ecf20Sopenharmony_ci	u32			isdbt_sb_segment_idx;
6148c2ecf20Sopenharmony_ci	u32			isdbt_sb_segment_count;
6158c2ecf20Sopenharmony_ci	u8			isdbt_layer_enabled;
6168c2ecf20Sopenharmony_ci	struct {
6178c2ecf20Sopenharmony_ci	    u8			segment_count;
6188c2ecf20Sopenharmony_ci	    enum fe_code_rate	fec;
6198c2ecf20Sopenharmony_ci	    enum fe_modulation	modulation;
6208c2ecf20Sopenharmony_ci	    u8			interleaving;
6218c2ecf20Sopenharmony_ci	} layer[3];
6228c2ecf20Sopenharmony_ci
6238c2ecf20Sopenharmony_ci	/* Multistream specifics */
6248c2ecf20Sopenharmony_ci	u32			stream_id;
6258c2ecf20Sopenharmony_ci
6268c2ecf20Sopenharmony_ci	/* Physical Layer Scrambling specifics */
6278c2ecf20Sopenharmony_ci	u32			scrambling_sequence_index;
6288c2ecf20Sopenharmony_ci
6298c2ecf20Sopenharmony_ci	/* ATSC-MH specifics */
6308c2ecf20Sopenharmony_ci	u8			atscmh_fic_ver;
6318c2ecf20Sopenharmony_ci	u8			atscmh_parade_id;
6328c2ecf20Sopenharmony_ci	u8			atscmh_nog;
6338c2ecf20Sopenharmony_ci	u8			atscmh_tnog;
6348c2ecf20Sopenharmony_ci	u8			atscmh_sgn;
6358c2ecf20Sopenharmony_ci	u8			atscmh_prc;
6368c2ecf20Sopenharmony_ci
6378c2ecf20Sopenharmony_ci	u8			atscmh_rs_frame_mode;
6388c2ecf20Sopenharmony_ci	u8			atscmh_rs_frame_ensemble;
6398c2ecf20Sopenharmony_ci	u8			atscmh_rs_code_mode_pri;
6408c2ecf20Sopenharmony_ci	u8			atscmh_rs_code_mode_sec;
6418c2ecf20Sopenharmony_ci	u8			atscmh_sccc_block_mode;
6428c2ecf20Sopenharmony_ci	u8			atscmh_sccc_code_mode_a;
6438c2ecf20Sopenharmony_ci	u8			atscmh_sccc_code_mode_b;
6448c2ecf20Sopenharmony_ci	u8			atscmh_sccc_code_mode_c;
6458c2ecf20Sopenharmony_ci	u8			atscmh_sccc_code_mode_d;
6468c2ecf20Sopenharmony_ci
6478c2ecf20Sopenharmony_ci	u32			lna;
6488c2ecf20Sopenharmony_ci
6498c2ecf20Sopenharmony_ci	/* statistics data */
6508c2ecf20Sopenharmony_ci	struct dtv_fe_stats	strength;
6518c2ecf20Sopenharmony_ci	struct dtv_fe_stats	cnr;
6528c2ecf20Sopenharmony_ci	struct dtv_fe_stats	pre_bit_error;
6538c2ecf20Sopenharmony_ci	struct dtv_fe_stats	pre_bit_count;
6548c2ecf20Sopenharmony_ci	struct dtv_fe_stats	post_bit_error;
6558c2ecf20Sopenharmony_ci	struct dtv_fe_stats	post_bit_count;
6568c2ecf20Sopenharmony_ci	struct dtv_fe_stats	block_error;
6578c2ecf20Sopenharmony_ci	struct dtv_fe_stats	block_count;
6588c2ecf20Sopenharmony_ci};
6598c2ecf20Sopenharmony_ci
6608c2ecf20Sopenharmony_ci#define DVB_FE_NO_EXIT  0
6618c2ecf20Sopenharmony_ci#define DVB_FE_NORMAL_EXIT      1
6628c2ecf20Sopenharmony_ci#define DVB_FE_DEVICE_REMOVED   2
6638c2ecf20Sopenharmony_ci#define DVB_FE_DEVICE_RESUME    3
6648c2ecf20Sopenharmony_ci
6658c2ecf20Sopenharmony_ci/**
6668c2ecf20Sopenharmony_ci * struct dvb_frontend - Frontend structure to be used on drivers.
6678c2ecf20Sopenharmony_ci *
6688c2ecf20Sopenharmony_ci * @refcount:		refcount to keep track of &struct dvb_frontend
6698c2ecf20Sopenharmony_ci *			references
6708c2ecf20Sopenharmony_ci * @ops:		embedded &struct dvb_frontend_ops
6718c2ecf20Sopenharmony_ci * @dvb:		pointer to &struct dvb_adapter
6728c2ecf20Sopenharmony_ci * @demodulator_priv:	demod private data
6738c2ecf20Sopenharmony_ci * @tuner_priv:		tuner private data
6748c2ecf20Sopenharmony_ci * @frontend_priv:	frontend private data
6758c2ecf20Sopenharmony_ci * @sec_priv:		SEC private data
6768c2ecf20Sopenharmony_ci * @analog_demod_priv:	Analog demod private data
6778c2ecf20Sopenharmony_ci * @dtv_property_cache:	embedded &struct dtv_frontend_properties
6788c2ecf20Sopenharmony_ci * @callback:		callback function used on some drivers to call
6798c2ecf20Sopenharmony_ci *			either the tuner or the demodulator.
6808c2ecf20Sopenharmony_ci * @id:			Frontend ID
6818c2ecf20Sopenharmony_ci * @exit:		Used to inform the DVB core that the frontend
6828c2ecf20Sopenharmony_ci *			thread should exit (usually, means that the hardware
6838c2ecf20Sopenharmony_ci *			got disconnected.)
6848c2ecf20Sopenharmony_ci * @remove_mutex:	mutex that avoids a race condition between a callback
6858c2ecf20Sopenharmony_ci *			called when the hardware is disconnected and the
6868c2ecf20Sopenharmony_ci *			file_operations of dvb_frontend
6878c2ecf20Sopenharmony_ci */
6888c2ecf20Sopenharmony_ci
6898c2ecf20Sopenharmony_cistruct dvb_frontend {
6908c2ecf20Sopenharmony_ci	struct kref refcount;
6918c2ecf20Sopenharmony_ci	struct dvb_frontend_ops ops;
6928c2ecf20Sopenharmony_ci	struct dvb_adapter *dvb;
6938c2ecf20Sopenharmony_ci	void *demodulator_priv;
6948c2ecf20Sopenharmony_ci	void *tuner_priv;
6958c2ecf20Sopenharmony_ci	void *frontend_priv;
6968c2ecf20Sopenharmony_ci	void *sec_priv;
6978c2ecf20Sopenharmony_ci	void *analog_demod_priv;
6988c2ecf20Sopenharmony_ci	struct dtv_frontend_properties dtv_property_cache;
6998c2ecf20Sopenharmony_ci#define DVB_FRONTEND_COMPONENT_TUNER 0
7008c2ecf20Sopenharmony_ci#define DVB_FRONTEND_COMPONENT_DEMOD 1
7018c2ecf20Sopenharmony_ci	int (*callback)(void *adapter_priv, int component, int cmd, int arg);
7028c2ecf20Sopenharmony_ci	int id;
7038c2ecf20Sopenharmony_ci	unsigned int exit;
7048c2ecf20Sopenharmony_ci	struct mutex remove_mutex;
7058c2ecf20Sopenharmony_ci};
7068c2ecf20Sopenharmony_ci
7078c2ecf20Sopenharmony_ci/**
7088c2ecf20Sopenharmony_ci * dvb_register_frontend() - Registers a DVB frontend at the adapter
7098c2ecf20Sopenharmony_ci *
7108c2ecf20Sopenharmony_ci * @dvb: pointer to &struct dvb_adapter
7118c2ecf20Sopenharmony_ci * @fe: pointer to &struct dvb_frontend
7128c2ecf20Sopenharmony_ci *
7138c2ecf20Sopenharmony_ci * Allocate and initialize the private data needed by the frontend core to
7148c2ecf20Sopenharmony_ci * manage the frontend and calls dvb_register_device() to register a new
7158c2ecf20Sopenharmony_ci * frontend. It also cleans the property cache that stores the frontend
7168c2ecf20Sopenharmony_ci * parameters and selects the first available delivery system.
7178c2ecf20Sopenharmony_ci */
7188c2ecf20Sopenharmony_ciint dvb_register_frontend(struct dvb_adapter *dvb,
7198c2ecf20Sopenharmony_ci				 struct dvb_frontend *fe);
7208c2ecf20Sopenharmony_ci
7218c2ecf20Sopenharmony_ci/**
7228c2ecf20Sopenharmony_ci * dvb_unregister_frontend() - Unregisters a DVB frontend
7238c2ecf20Sopenharmony_ci *
7248c2ecf20Sopenharmony_ci * @fe: pointer to &struct dvb_frontend
7258c2ecf20Sopenharmony_ci *
7268c2ecf20Sopenharmony_ci * Stops the frontend kthread, calls dvb_unregister_device() and frees the
7278c2ecf20Sopenharmony_ci * private frontend data allocated by dvb_register_frontend().
7288c2ecf20Sopenharmony_ci *
7298c2ecf20Sopenharmony_ci * NOTE: This function doesn't frees the memory allocated by the demod,
7308c2ecf20Sopenharmony_ci * by the SEC driver and by the tuner. In order to free it, an explicit call to
7318c2ecf20Sopenharmony_ci * dvb_frontend_detach() is needed, after calling this function.
7328c2ecf20Sopenharmony_ci */
7338c2ecf20Sopenharmony_ciint dvb_unregister_frontend(struct dvb_frontend *fe);
7348c2ecf20Sopenharmony_ci
7358c2ecf20Sopenharmony_ci/**
7368c2ecf20Sopenharmony_ci * dvb_frontend_detach() - Detaches and frees frontend specific data
7378c2ecf20Sopenharmony_ci *
7388c2ecf20Sopenharmony_ci * @fe: pointer to &struct dvb_frontend
7398c2ecf20Sopenharmony_ci *
7408c2ecf20Sopenharmony_ci * This function should be called after dvb_unregister_frontend(). It
7418c2ecf20Sopenharmony_ci * calls the SEC, tuner and demod release functions:
7428c2ecf20Sopenharmony_ci * &dvb_frontend_ops.release_sec, &dvb_frontend_ops.tuner_ops.release,
7438c2ecf20Sopenharmony_ci * &dvb_frontend_ops.analog_ops.release and &dvb_frontend_ops.release.
7448c2ecf20Sopenharmony_ci *
7458c2ecf20Sopenharmony_ci * If the driver is compiled with %CONFIG_MEDIA_ATTACH, it also decreases
7468c2ecf20Sopenharmony_ci * the module reference count, needed to allow userspace to remove the
7478c2ecf20Sopenharmony_ci * previously used DVB frontend modules.
7488c2ecf20Sopenharmony_ci */
7498c2ecf20Sopenharmony_civoid dvb_frontend_detach(struct dvb_frontend *fe);
7508c2ecf20Sopenharmony_ci
7518c2ecf20Sopenharmony_ci/**
7528c2ecf20Sopenharmony_ci * dvb_frontend_suspend() - Suspends a Digital TV frontend
7538c2ecf20Sopenharmony_ci *
7548c2ecf20Sopenharmony_ci * @fe: pointer to &struct dvb_frontend
7558c2ecf20Sopenharmony_ci *
7568c2ecf20Sopenharmony_ci * This function prepares a Digital TV frontend to suspend.
7578c2ecf20Sopenharmony_ci *
7588c2ecf20Sopenharmony_ci * In order to prepare the tuner to suspend, if
7598c2ecf20Sopenharmony_ci * &dvb_frontend_ops.tuner_ops.suspend\(\) is available, it calls it. Otherwise,
7608c2ecf20Sopenharmony_ci * it will call &dvb_frontend_ops.tuner_ops.sleep\(\), if available.
7618c2ecf20Sopenharmony_ci *
7628c2ecf20Sopenharmony_ci * It will also call &dvb_frontend_ops.sleep\(\) to put the demod to suspend.
7638c2ecf20Sopenharmony_ci *
7648c2ecf20Sopenharmony_ci * The drivers should also call dvb_frontend_suspend\(\) as part of their
7658c2ecf20Sopenharmony_ci * handler for the &device_driver.suspend\(\).
7668c2ecf20Sopenharmony_ci */
7678c2ecf20Sopenharmony_ciint dvb_frontend_suspend(struct dvb_frontend *fe);
7688c2ecf20Sopenharmony_ci
7698c2ecf20Sopenharmony_ci/**
7708c2ecf20Sopenharmony_ci * dvb_frontend_resume() - Resumes a Digital TV frontend
7718c2ecf20Sopenharmony_ci *
7728c2ecf20Sopenharmony_ci * @fe: pointer to &struct dvb_frontend
7738c2ecf20Sopenharmony_ci *
7748c2ecf20Sopenharmony_ci * This function resumes the usual operation of the tuner after resume.
7758c2ecf20Sopenharmony_ci *
7768c2ecf20Sopenharmony_ci * In order to resume the frontend, it calls the demod &dvb_frontend_ops.init\(\).
7778c2ecf20Sopenharmony_ci *
7788c2ecf20Sopenharmony_ci * If &dvb_frontend_ops.tuner_ops.resume\(\) is available, It, it calls it.
7798c2ecf20Sopenharmony_ci * Otherwise,t will call &dvb_frontend_ops.tuner_ops.init\(\), if available.
7808c2ecf20Sopenharmony_ci *
7818c2ecf20Sopenharmony_ci * Once tuner and demods are resumed, it will enforce that the SEC voltage and
7828c2ecf20Sopenharmony_ci * tone are restored to their previous values and wake up the frontend's
7838c2ecf20Sopenharmony_ci * kthread in order to retune the frontend.
7848c2ecf20Sopenharmony_ci *
7858c2ecf20Sopenharmony_ci * The drivers should also call dvb_frontend_resume() as part of their
7868c2ecf20Sopenharmony_ci * handler for the &device_driver.resume\(\).
7878c2ecf20Sopenharmony_ci */
7888c2ecf20Sopenharmony_ciint dvb_frontend_resume(struct dvb_frontend *fe);
7898c2ecf20Sopenharmony_ci
7908c2ecf20Sopenharmony_ci/**
7918c2ecf20Sopenharmony_ci * dvb_frontend_reinitialise() - forces a reinitialisation at the frontend
7928c2ecf20Sopenharmony_ci *
7938c2ecf20Sopenharmony_ci * @fe: pointer to &struct dvb_frontend
7948c2ecf20Sopenharmony_ci *
7958c2ecf20Sopenharmony_ci * Calls &dvb_frontend_ops.init\(\) and &dvb_frontend_ops.tuner_ops.init\(\),
7968c2ecf20Sopenharmony_ci * and resets SEC tone and voltage (for Satellite systems).
7978c2ecf20Sopenharmony_ci *
7988c2ecf20Sopenharmony_ci * NOTE: Currently, this function is used only by one driver (budget-av).
7998c2ecf20Sopenharmony_ci * It seems to be due to address some special issue with that specific
8008c2ecf20Sopenharmony_ci * frontend.
8018c2ecf20Sopenharmony_ci */
8028c2ecf20Sopenharmony_civoid dvb_frontend_reinitialise(struct dvb_frontend *fe);
8038c2ecf20Sopenharmony_ci
8048c2ecf20Sopenharmony_ci/**
8058c2ecf20Sopenharmony_ci * dvb_frontend_sleep_until() - Sleep for the amount of time given by
8068c2ecf20Sopenharmony_ci *                      add_usec parameter
8078c2ecf20Sopenharmony_ci *
8088c2ecf20Sopenharmony_ci * @waketime: pointer to &struct ktime_t
8098c2ecf20Sopenharmony_ci * @add_usec: time to sleep, in microseconds
8108c2ecf20Sopenharmony_ci *
8118c2ecf20Sopenharmony_ci * This function is used to measure the time required for the
8128c2ecf20Sopenharmony_ci * FE_DISHNETWORK_SEND_LEGACY_CMD() ioctl to work. It needs to be as precise
8138c2ecf20Sopenharmony_ci * as possible, as it affects the detection of the dish tone command at the
8148c2ecf20Sopenharmony_ci * satellite subsystem.
8158c2ecf20Sopenharmony_ci *
8168c2ecf20Sopenharmony_ci * Its used internally by the DVB frontend core, in order to emulate
8178c2ecf20Sopenharmony_ci * FE_DISHNETWORK_SEND_LEGACY_CMD() using the &dvb_frontend_ops.set_voltage\(\)
8188c2ecf20Sopenharmony_ci * callback.
8198c2ecf20Sopenharmony_ci *
8208c2ecf20Sopenharmony_ci * NOTE: it should not be used at the drivers, as the emulation for the
8218c2ecf20Sopenharmony_ci * legacy callback is provided by the Kernel. The only situation where this
8228c2ecf20Sopenharmony_ci * should be at the drivers is when there are some bugs at the hardware that
8238c2ecf20Sopenharmony_ci * would prevent the core emulation to work. On such cases, the driver would
8248c2ecf20Sopenharmony_ci * be writing a &dvb_frontend_ops.dishnetwork_send_legacy_command\(\) and
8258c2ecf20Sopenharmony_ci * calling this function directly.
8268c2ecf20Sopenharmony_ci */
8278c2ecf20Sopenharmony_civoid dvb_frontend_sleep_until(ktime_t *waketime, u32 add_usec);
8288c2ecf20Sopenharmony_ci
8298c2ecf20Sopenharmony_ci#endif
830