xref: /OK3568_Linux_fs/kernel/include/media/dvb_frontend.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * dvb_frontend.h
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * The Digital TV Frontend kABI defines a driver-internal interface for
5*4882a593Smuzhiyun  * registering low-level, hardware specific driver to a hardware independent
6*4882a593Smuzhiyun  * frontend layer.
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  * Copyright (C) 2001 convergence integrated media GmbH
9*4882a593Smuzhiyun  * Copyright (C) 2004 convergence GmbH
10*4882a593Smuzhiyun  *
11*4882a593Smuzhiyun  * Written by Ralph Metzler
12*4882a593Smuzhiyun  * Overhauled by Holger Waechtler
13*4882a593Smuzhiyun  * Kernel I2C stuff by Michael Hunold <hunold@convergence.de>
14*4882a593Smuzhiyun  *
15*4882a593Smuzhiyun  * This program is free software; you can redistribute it and/or
16*4882a593Smuzhiyun  * modify it under the terms of the GNU Lesser General Public License
17*4882a593Smuzhiyun  * as published by the Free Software Foundation; either version 2.1
18*4882a593Smuzhiyun  * of the License, or (at your option) any later version.
19*4882a593Smuzhiyun  *
20*4882a593Smuzhiyun  * This program is distributed in the hope that it will be useful,
21*4882a593Smuzhiyun  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22*4882a593Smuzhiyun  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23*4882a593Smuzhiyun  * GNU General Public License for more details.
24*4882a593Smuzhiyun  *
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun  * You should have received a copy of the GNU Lesser General Public License
27*4882a593Smuzhiyun  * along with this program; if not, write to the Free Software
28*4882a593Smuzhiyun  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
29*4882a593Smuzhiyun  *
30*4882a593Smuzhiyun  */
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun #ifndef _DVB_FRONTEND_H_
33*4882a593Smuzhiyun #define _DVB_FRONTEND_H_
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun #include <linux/types.h>
36*4882a593Smuzhiyun #include <linux/sched.h>
37*4882a593Smuzhiyun #include <linux/ioctl.h>
38*4882a593Smuzhiyun #include <linux/i2c.h>
39*4882a593Smuzhiyun #include <linux/module.h>
40*4882a593Smuzhiyun #include <linux/errno.h>
41*4882a593Smuzhiyun #include <linux/delay.h>
42*4882a593Smuzhiyun #include <linux/mutex.h>
43*4882a593Smuzhiyun #include <linux/slab.h>
44*4882a593Smuzhiyun #include <linux/bitops.h>
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun #include <linux/dvb/frontend.h>
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun #include <media/dvbdev.h>
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun /*
51*4882a593Smuzhiyun  * Maximum number of Delivery systems per frontend. It
52*4882a593Smuzhiyun  * should be smaller or equal to 32
53*4882a593Smuzhiyun  */
54*4882a593Smuzhiyun #define MAX_DELSYS	8
55*4882a593Smuzhiyun 
56*4882a593Smuzhiyun /* Helper definitions to be used at frontend drivers */
57*4882a593Smuzhiyun #define kHz 1000UL
58*4882a593Smuzhiyun #define MHz 1000000UL
59*4882a593Smuzhiyun 
60*4882a593Smuzhiyun /**
61*4882a593Smuzhiyun  * struct dvb_frontend_tune_settings - parameters to adjust frontend tuning
62*4882a593Smuzhiyun  *
63*4882a593Smuzhiyun  * @min_delay_ms:	minimum delay for tuning, in ms
64*4882a593Smuzhiyun  * @step_size:		step size between two consecutive frequencies
65*4882a593Smuzhiyun  * @max_drift:		maximum drift
66*4882a593Smuzhiyun  *
67*4882a593Smuzhiyun  * NOTE: step_size is in Hz, for terrestrial/cable or kHz for satellite
68*4882a593Smuzhiyun  */
69*4882a593Smuzhiyun struct dvb_frontend_tune_settings {
70*4882a593Smuzhiyun 	int min_delay_ms;
71*4882a593Smuzhiyun 	int step_size;
72*4882a593Smuzhiyun 	int max_drift;
73*4882a593Smuzhiyun };
74*4882a593Smuzhiyun 
75*4882a593Smuzhiyun struct dvb_frontend;
76*4882a593Smuzhiyun 
77*4882a593Smuzhiyun /**
78*4882a593Smuzhiyun  * struct dvb_tuner_info - Frontend name and min/max ranges/bandwidths
79*4882a593Smuzhiyun  *
80*4882a593Smuzhiyun  * @name:		name of the Frontend
81*4882a593Smuzhiyun  * @frequency_min_hz:	minimal frequency supported in Hz
82*4882a593Smuzhiyun  * @frequency_max_hz:	maximum frequency supported in Hz
83*4882a593Smuzhiyun  * @frequency_step_hz:	frequency step in Hz
84*4882a593Smuzhiyun  * @bandwidth_min:	minimal frontend bandwidth supported
85*4882a593Smuzhiyun  * @bandwidth_max:	maximum frontend bandwidth supported
86*4882a593Smuzhiyun  * @bandwidth_step:	frontend bandwidth step
87*4882a593Smuzhiyun  */
88*4882a593Smuzhiyun struct dvb_tuner_info {
89*4882a593Smuzhiyun 	char name[128];
90*4882a593Smuzhiyun 
91*4882a593Smuzhiyun 	u32 frequency_min_hz;
92*4882a593Smuzhiyun 	u32 frequency_max_hz;
93*4882a593Smuzhiyun 	u32 frequency_step_hz;
94*4882a593Smuzhiyun 
95*4882a593Smuzhiyun 	u32 bandwidth_min;
96*4882a593Smuzhiyun 	u32 bandwidth_max;
97*4882a593Smuzhiyun 	u32 bandwidth_step;
98*4882a593Smuzhiyun };
99*4882a593Smuzhiyun 
100*4882a593Smuzhiyun /**
101*4882a593Smuzhiyun  * struct analog_parameters - Parameters to tune into an analog/radio channel
102*4882a593Smuzhiyun  *
103*4882a593Smuzhiyun  * @frequency:	Frequency used by analog TV tuner (either in 62.5 kHz step,
104*4882a593Smuzhiyun  *		for TV, or 62.5 Hz for radio)
105*4882a593Smuzhiyun  * @mode:	Tuner mode, as defined on enum v4l2_tuner_type
106*4882a593Smuzhiyun  * @audmode:	Audio mode as defined for the rxsubchans field at videodev2.h,
107*4882a593Smuzhiyun  *		e. g. V4L2_TUNER_MODE_*
108*4882a593Smuzhiyun  * @std:	TV standard bitmap as defined at videodev2.h, e. g. V4L2_STD_*
109*4882a593Smuzhiyun  *
110*4882a593Smuzhiyun  * Hybrid tuners should be supported by both V4L2 and DVB APIs. This
111*4882a593Smuzhiyun  * struct contains the data that are used by the V4L2 side. To avoid
112*4882a593Smuzhiyun  * dependencies from V4L2 headers, all enums here are declared as integers.
113*4882a593Smuzhiyun  */
114*4882a593Smuzhiyun struct analog_parameters {
115*4882a593Smuzhiyun 	unsigned int frequency;
116*4882a593Smuzhiyun 	unsigned int mode;
117*4882a593Smuzhiyun 	unsigned int audmode;
118*4882a593Smuzhiyun 	u64 std;
119*4882a593Smuzhiyun };
120*4882a593Smuzhiyun 
121*4882a593Smuzhiyun /**
122*4882a593Smuzhiyun  * enum dvbfe_algo - defines the algorithm used to tune into a channel
123*4882a593Smuzhiyun  *
124*4882a593Smuzhiyun  * @DVBFE_ALGO_HW: Hardware Algorithm -
125*4882a593Smuzhiyun  *	Devices that support this algorithm do everything in hardware
126*4882a593Smuzhiyun  *	and no software support is needed to handle them.
127*4882a593Smuzhiyun  *	Requesting these devices to LOCK is the only thing required,
128*4882a593Smuzhiyun  *	device is supposed to do everything in the hardware.
129*4882a593Smuzhiyun  *
130*4882a593Smuzhiyun  * @DVBFE_ALGO_SW: Software Algorithm -
131*4882a593Smuzhiyun  * These are dumb devices, that require software to do everything
132*4882a593Smuzhiyun  *
133*4882a593Smuzhiyun  * @DVBFE_ALGO_CUSTOM: Customizable Agorithm -
134*4882a593Smuzhiyun  *	Devices having this algorithm can be customized to have specific
135*4882a593Smuzhiyun  *	algorithms in the frontend driver, rather than simply doing a
136*4882a593Smuzhiyun  *	software zig-zag. In this case the zigzag maybe hardware assisted
137*4882a593Smuzhiyun  *	or it maybe completely done in hardware. In all cases, usage of
138*4882a593Smuzhiyun  *	this algorithm, in conjunction with the search and track
139*4882a593Smuzhiyun  *	callbacks, utilizes the driver specific algorithm.
140*4882a593Smuzhiyun  *
141*4882a593Smuzhiyun  * @DVBFE_ALGO_RECOVERY: Recovery Algorithm -
142*4882a593Smuzhiyun  *	These devices have AUTO recovery capabilities from LOCK failure
143*4882a593Smuzhiyun  */
144*4882a593Smuzhiyun enum dvbfe_algo {
145*4882a593Smuzhiyun 	DVBFE_ALGO_HW			= BIT(0),
146*4882a593Smuzhiyun 	DVBFE_ALGO_SW			= BIT(1),
147*4882a593Smuzhiyun 	DVBFE_ALGO_CUSTOM		= BIT(2),
148*4882a593Smuzhiyun 	DVBFE_ALGO_RECOVERY		= BIT(31),
149*4882a593Smuzhiyun };
150*4882a593Smuzhiyun 
151*4882a593Smuzhiyun /**
152*4882a593Smuzhiyun  * enum dvbfe_search - search callback possible return status
153*4882a593Smuzhiyun  *
154*4882a593Smuzhiyun  * @DVBFE_ALGO_SEARCH_SUCCESS:
155*4882a593Smuzhiyun  *	The frontend search algorithm completed and returned successfully
156*4882a593Smuzhiyun  *
157*4882a593Smuzhiyun  * @DVBFE_ALGO_SEARCH_ASLEEP:
158*4882a593Smuzhiyun  *	The frontend search algorithm is sleeping
159*4882a593Smuzhiyun  *
160*4882a593Smuzhiyun  * @DVBFE_ALGO_SEARCH_FAILED:
161*4882a593Smuzhiyun  *	The frontend search for a signal failed
162*4882a593Smuzhiyun  *
163*4882a593Smuzhiyun  * @DVBFE_ALGO_SEARCH_INVALID:
164*4882a593Smuzhiyun  *	The frontend search algorithm was probably supplied with invalid
165*4882a593Smuzhiyun  *	parameters and the search is an invalid one
166*4882a593Smuzhiyun  *
167*4882a593Smuzhiyun  * @DVBFE_ALGO_SEARCH_ERROR:
168*4882a593Smuzhiyun  *	The frontend search algorithm failed due to some error
169*4882a593Smuzhiyun  *
170*4882a593Smuzhiyun  * @DVBFE_ALGO_SEARCH_AGAIN:
171*4882a593Smuzhiyun  *	The frontend search algorithm was requested to search again
172*4882a593Smuzhiyun  */
173*4882a593Smuzhiyun enum dvbfe_search {
174*4882a593Smuzhiyun 	DVBFE_ALGO_SEARCH_SUCCESS	= BIT(0),
175*4882a593Smuzhiyun 	DVBFE_ALGO_SEARCH_ASLEEP	= BIT(1),
176*4882a593Smuzhiyun 	DVBFE_ALGO_SEARCH_FAILED	= BIT(2),
177*4882a593Smuzhiyun 	DVBFE_ALGO_SEARCH_INVALID	= BIT(3),
178*4882a593Smuzhiyun 	DVBFE_ALGO_SEARCH_AGAIN		= BIT(4),
179*4882a593Smuzhiyun 	DVBFE_ALGO_SEARCH_ERROR		= BIT(31),
180*4882a593Smuzhiyun };
181*4882a593Smuzhiyun 
182*4882a593Smuzhiyun /**
183*4882a593Smuzhiyun  * struct dvb_tuner_ops - Tuner information and callbacks
184*4882a593Smuzhiyun  *
185*4882a593Smuzhiyun  * @info:		embedded &struct dvb_tuner_info with tuner properties
186*4882a593Smuzhiyun  * @release:		callback function called when frontend is detached.
187*4882a593Smuzhiyun  *			drivers should free any allocated memory.
188*4882a593Smuzhiyun  * @init:		callback function used to initialize the tuner device.
189*4882a593Smuzhiyun  * @sleep:		callback function used to put the tuner to sleep.
190*4882a593Smuzhiyun  * @suspend:		callback function used to inform that the Kernel will
191*4882a593Smuzhiyun  *			suspend.
192*4882a593Smuzhiyun  * @resume:		callback function used to inform that the Kernel is
193*4882a593Smuzhiyun  *			resuming from suspend.
194*4882a593Smuzhiyun  * @set_params:		callback function used to inform the tuner to tune
195*4882a593Smuzhiyun  *			into a digital TV channel. The properties to be used
196*4882a593Smuzhiyun  *			are stored at &struct dvb_frontend.dtv_property_cache.
197*4882a593Smuzhiyun  *			The tuner demod can change the parameters to reflect
198*4882a593Smuzhiyun  *			the changes needed for the channel to be tuned, and
199*4882a593Smuzhiyun  *			update statistics. This is the recommended way to set
200*4882a593Smuzhiyun  *			the tuner parameters and should be used on newer
201*4882a593Smuzhiyun  *			drivers.
202*4882a593Smuzhiyun  * @set_analog_params:	callback function used to tune into an analog TV
203*4882a593Smuzhiyun  *			channel on hybrid tuners. It passes @analog_parameters
204*4882a593Smuzhiyun  *			to the driver.
205*4882a593Smuzhiyun  * @set_config:		callback function used to send some tuner-specific
206*4882a593Smuzhiyun  *			parameters.
207*4882a593Smuzhiyun  * @get_frequency:	get the actual tuned frequency
208*4882a593Smuzhiyun  * @get_bandwidth:	get the bandwidth used by the low pass filters
209*4882a593Smuzhiyun  * @get_if_frequency:	get the Intermediate Frequency, in Hz. For baseband,
210*4882a593Smuzhiyun  *			should return 0.
211*4882a593Smuzhiyun  * @get_status:		returns the frontend lock status
212*4882a593Smuzhiyun  * @get_rf_strength:	returns the RF signal strength. Used mostly to support
213*4882a593Smuzhiyun  *			analog TV and radio. Digital TV should report, instead,
214*4882a593Smuzhiyun  *			via DVBv5 API (&struct dvb_frontend.dtv_property_cache).
215*4882a593Smuzhiyun  * @get_afc:		Used only by analog TV core. Reports the frequency
216*4882a593Smuzhiyun  *			drift due to AFC.
217*4882a593Smuzhiyun  * @calc_regs:		callback function used to pass register data settings
218*4882a593Smuzhiyun  *			for simple tuners.  Shouldn't be used on newer drivers.
219*4882a593Smuzhiyun  * @set_frequency:	Set a new frequency. Shouldn't be used on newer drivers.
220*4882a593Smuzhiyun  * @set_bandwidth:	Set a new frequency. Shouldn't be used on newer drivers.
221*4882a593Smuzhiyun  *
222*4882a593Smuzhiyun  * NOTE: frequencies used on @get_frequency and @set_frequency are in Hz for
223*4882a593Smuzhiyun  * terrestrial/cable or kHz for satellite.
224*4882a593Smuzhiyun  *
225*4882a593Smuzhiyun  */
226*4882a593Smuzhiyun struct dvb_tuner_ops {
227*4882a593Smuzhiyun 
228*4882a593Smuzhiyun 	struct dvb_tuner_info info;
229*4882a593Smuzhiyun 
230*4882a593Smuzhiyun 	void (*release)(struct dvb_frontend *fe);
231*4882a593Smuzhiyun 	int (*init)(struct dvb_frontend *fe);
232*4882a593Smuzhiyun 	int (*sleep)(struct dvb_frontend *fe);
233*4882a593Smuzhiyun 	int (*suspend)(struct dvb_frontend *fe);
234*4882a593Smuzhiyun 	int (*resume)(struct dvb_frontend *fe);
235*4882a593Smuzhiyun 
236*4882a593Smuzhiyun 	/* This is the recommended way to set the tuner */
237*4882a593Smuzhiyun 	int (*set_params)(struct dvb_frontend *fe);
238*4882a593Smuzhiyun 	int (*set_analog_params)(struct dvb_frontend *fe, struct analog_parameters *p);
239*4882a593Smuzhiyun 
240*4882a593Smuzhiyun 	int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
241*4882a593Smuzhiyun 
242*4882a593Smuzhiyun 	int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency);
243*4882a593Smuzhiyun 	int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
244*4882a593Smuzhiyun 	int (*get_if_frequency)(struct dvb_frontend *fe, u32 *frequency);
245*4882a593Smuzhiyun 
246*4882a593Smuzhiyun #define TUNER_STATUS_LOCKED 1
247*4882a593Smuzhiyun #define TUNER_STATUS_STEREO 2
248*4882a593Smuzhiyun 	int (*get_status)(struct dvb_frontend *fe, u32 *status);
249*4882a593Smuzhiyun 	int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength);
250*4882a593Smuzhiyun 	int (*get_afc)(struct dvb_frontend *fe, s32 *afc);
251*4882a593Smuzhiyun 
252*4882a593Smuzhiyun 	/*
253*4882a593Smuzhiyun 	 * This is support for demods like the mt352 - fills out the supplied
254*4882a593Smuzhiyun 	 * buffer with what to write.
255*4882a593Smuzhiyun 	 *
256*4882a593Smuzhiyun 	 * Don't use on newer drivers.
257*4882a593Smuzhiyun 	 */
258*4882a593Smuzhiyun 	int (*calc_regs)(struct dvb_frontend *fe, u8 *buf, int buf_len);
259*4882a593Smuzhiyun 
260*4882a593Smuzhiyun 	/*
261*4882a593Smuzhiyun 	 * These are provided separately from set_params in order to
262*4882a593Smuzhiyun 	 * facilitate silicon tuners which require sophisticated tuning loops,
263*4882a593Smuzhiyun 	 * controlling each parameter separately.
264*4882a593Smuzhiyun 	 *
265*4882a593Smuzhiyun 	 * Don't use on newer drivers.
266*4882a593Smuzhiyun 	 */
267*4882a593Smuzhiyun 	int (*set_frequency)(struct dvb_frontend *fe, u32 frequency);
268*4882a593Smuzhiyun 	int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
269*4882a593Smuzhiyun };
270*4882a593Smuzhiyun 
271*4882a593Smuzhiyun /**
272*4882a593Smuzhiyun  * struct analog_demod_info - Information struct for analog TV part of the demod
273*4882a593Smuzhiyun  *
274*4882a593Smuzhiyun  * @name:	Name of the analog TV demodulator
275*4882a593Smuzhiyun  */
276*4882a593Smuzhiyun struct analog_demod_info {
277*4882a593Smuzhiyun 	char *name;
278*4882a593Smuzhiyun };
279*4882a593Smuzhiyun 
280*4882a593Smuzhiyun /**
281*4882a593Smuzhiyun  * struct analog_demod_ops  - Demodulation information and callbacks for
282*4882a593Smuzhiyun  *			      analog TV and radio
283*4882a593Smuzhiyun  *
284*4882a593Smuzhiyun  * @info:		pointer to struct analog_demod_info
285*4882a593Smuzhiyun  * @set_params:		callback function used to inform the demod to set the
286*4882a593Smuzhiyun  *			demodulator parameters needed to decode an analog or
287*4882a593Smuzhiyun  *			radio channel. The properties are passed via
288*4882a593Smuzhiyun  *			&struct analog_params.
289*4882a593Smuzhiyun  * @has_signal:		returns 0xffff if has signal, or 0 if it doesn't.
290*4882a593Smuzhiyun  * @get_afc:		Used only by analog TV core. Reports the frequency
291*4882a593Smuzhiyun  *			drift due to AFC.
292*4882a593Smuzhiyun  * @tuner_status:	callback function that returns tuner status bits, e. g.
293*4882a593Smuzhiyun  *			%TUNER_STATUS_LOCKED and %TUNER_STATUS_STEREO.
294*4882a593Smuzhiyun  * @standby:		set the tuner to standby mode.
295*4882a593Smuzhiyun  * @release:		callback function called when frontend is detached.
296*4882a593Smuzhiyun  *			drivers should free any allocated memory.
297*4882a593Smuzhiyun  * @i2c_gate_ctrl:	controls the I2C gate. Newer drivers should use I2C
298*4882a593Smuzhiyun  *			mux support instead.
299*4882a593Smuzhiyun  * @set_config:		callback function used to send some tuner-specific
300*4882a593Smuzhiyun  *			parameters.
301*4882a593Smuzhiyun  */
302*4882a593Smuzhiyun struct analog_demod_ops {
303*4882a593Smuzhiyun 
304*4882a593Smuzhiyun 	struct analog_demod_info info;
305*4882a593Smuzhiyun 
306*4882a593Smuzhiyun 	void (*set_params)(struct dvb_frontend *fe,
307*4882a593Smuzhiyun 			   struct analog_parameters *params);
308*4882a593Smuzhiyun 	int  (*has_signal)(struct dvb_frontend *fe, u16 *signal);
309*4882a593Smuzhiyun 	int  (*get_afc)(struct dvb_frontend *fe, s32 *afc);
310*4882a593Smuzhiyun 	void (*tuner_status)(struct dvb_frontend *fe);
311*4882a593Smuzhiyun 	void (*standby)(struct dvb_frontend *fe);
312*4882a593Smuzhiyun 	void (*release)(struct dvb_frontend *fe);
313*4882a593Smuzhiyun 	int  (*i2c_gate_ctrl)(struct dvb_frontend *fe, int enable);
314*4882a593Smuzhiyun 
315*4882a593Smuzhiyun 	/** This is to allow setting tuner-specific configuration */
316*4882a593Smuzhiyun 	int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
317*4882a593Smuzhiyun };
318*4882a593Smuzhiyun 
319*4882a593Smuzhiyun struct dtv_frontend_properties;
320*4882a593Smuzhiyun 
321*4882a593Smuzhiyun /**
322*4882a593Smuzhiyun  * struct dvb_frontend_internal_info - Frontend properties and capabilities
323*4882a593Smuzhiyun  *
324*4882a593Smuzhiyun  * @name:			Name of the frontend
325*4882a593Smuzhiyun  * @frequency_min_hz:		Minimal frequency supported by the frontend.
326*4882a593Smuzhiyun  * @frequency_max_hz:		Minimal frequency supported by the frontend.
327*4882a593Smuzhiyun  * @frequency_stepsize_hz:	All frequencies are multiple of this value.
328*4882a593Smuzhiyun  * @frequency_tolerance_hz:	Frequency tolerance.
329*4882a593Smuzhiyun  * @symbol_rate_min:		Minimal symbol rate, in bauds
330*4882a593Smuzhiyun  *				(for Cable/Satellite systems).
331*4882a593Smuzhiyun  * @symbol_rate_max:		Maximal symbol rate, in bauds
332*4882a593Smuzhiyun  *				(for Cable/Satellite systems).
333*4882a593Smuzhiyun  * @symbol_rate_tolerance:	Maximal symbol rate tolerance, in ppm
334*4882a593Smuzhiyun  *				(for Cable/Satellite systems).
335*4882a593Smuzhiyun  * @caps:			Capabilities supported by the frontend,
336*4882a593Smuzhiyun  *				as specified in &enum fe_caps.
337*4882a593Smuzhiyun  */
338*4882a593Smuzhiyun struct dvb_frontend_internal_info {
339*4882a593Smuzhiyun 	char	name[128];
340*4882a593Smuzhiyun 	u32	frequency_min_hz;
341*4882a593Smuzhiyun 	u32	frequency_max_hz;
342*4882a593Smuzhiyun 	u32	frequency_stepsize_hz;
343*4882a593Smuzhiyun 	u32	frequency_tolerance_hz;
344*4882a593Smuzhiyun 	u32	symbol_rate_min;
345*4882a593Smuzhiyun 	u32	symbol_rate_max;
346*4882a593Smuzhiyun 	u32	symbol_rate_tolerance;
347*4882a593Smuzhiyun 	enum fe_caps caps;
348*4882a593Smuzhiyun };
349*4882a593Smuzhiyun 
350*4882a593Smuzhiyun /**
351*4882a593Smuzhiyun  * struct dvb_frontend_ops - Demodulation information and callbacks for
352*4882a593Smuzhiyun  *			      ditialt TV
353*4882a593Smuzhiyun  *
354*4882a593Smuzhiyun  * @info:		embedded &struct dvb_tuner_info with tuner properties
355*4882a593Smuzhiyun  * @delsys:		Delivery systems supported by the frontend
356*4882a593Smuzhiyun  * @detach:		callback function called when frontend is detached.
357*4882a593Smuzhiyun  *			drivers should clean up, but not yet free the &struct
358*4882a593Smuzhiyun  *			dvb_frontend allocation.
359*4882a593Smuzhiyun  * @release:		callback function called when frontend is ready to be
360*4882a593Smuzhiyun  *			freed.
361*4882a593Smuzhiyun  *			drivers should free any allocated memory.
362*4882a593Smuzhiyun  * @release_sec:	callback function requesting that the Satellite Equipment
363*4882a593Smuzhiyun  *			Control (SEC) driver to release and free any memory
364*4882a593Smuzhiyun  *			allocated by the driver.
365*4882a593Smuzhiyun  * @init:		callback function used to initialize the tuner device.
366*4882a593Smuzhiyun  * @sleep:		callback function used to put the tuner to sleep.
367*4882a593Smuzhiyun  * @write:		callback function used by some demod legacy drivers to
368*4882a593Smuzhiyun  *			allow other drivers to write data into their registers.
369*4882a593Smuzhiyun  *			Should not be used on new drivers.
370*4882a593Smuzhiyun  * @tune:		callback function used by demod drivers that use
371*4882a593Smuzhiyun  *			@DVBFE_ALGO_HW to tune into a frequency.
372*4882a593Smuzhiyun  * @get_frontend_algo:	returns the desired hardware algorithm.
373*4882a593Smuzhiyun  * @set_frontend:	callback function used to inform the demod to set the
374*4882a593Smuzhiyun  *			parameters for demodulating a digital TV channel.
375*4882a593Smuzhiyun  *			The properties to be used are stored at &struct
376*4882a593Smuzhiyun  *			dvb_frontend.dtv_property_cache. The demod can change
377*4882a593Smuzhiyun  *			the parameters to reflect the changes needed for the
378*4882a593Smuzhiyun  *			channel to be decoded, and update statistics.
379*4882a593Smuzhiyun  * @get_tune_settings:	callback function
380*4882a593Smuzhiyun  * @get_frontend:	callback function used to inform the parameters
381*4882a593Smuzhiyun  *			actuall in use. The properties to be used are stored at
382*4882a593Smuzhiyun  *			&struct dvb_frontend.dtv_property_cache and update
383*4882a593Smuzhiyun  *			statistics. Please notice that it should not return
384*4882a593Smuzhiyun  *			an error code if the statistics are not available
385*4882a593Smuzhiyun  *			because the demog is not locked.
386*4882a593Smuzhiyun  * @read_status:	returns the locking status of the frontend.
387*4882a593Smuzhiyun  * @read_ber:		legacy callback function to return the bit error rate.
388*4882a593Smuzhiyun  *			Newer drivers should provide such info via DVBv5 API,
389*4882a593Smuzhiyun  *			e. g. @set_frontend;/@get_frontend, implementing this
390*4882a593Smuzhiyun  *			callback only if DVBv3 API compatibility is wanted.
391*4882a593Smuzhiyun  * @read_signal_strength: legacy callback function to return the signal
392*4882a593Smuzhiyun  *			strength. Newer drivers should provide such info via
393*4882a593Smuzhiyun  *			DVBv5 API, e. g. @set_frontend/@get_frontend,
394*4882a593Smuzhiyun  *			implementing this callback only if DVBv3 API
395*4882a593Smuzhiyun  *			compatibility is wanted.
396*4882a593Smuzhiyun  * @read_snr:		legacy callback function to return the Signal/Noise
397*4882a593Smuzhiyun  *			rate. Newer drivers should provide such info via
398*4882a593Smuzhiyun  *			DVBv5 API, e. g. @set_frontend/@get_frontend,
399*4882a593Smuzhiyun  *			implementing this callback only if DVBv3 API
400*4882a593Smuzhiyun  *			compatibility is wanted.
401*4882a593Smuzhiyun  * @read_ucblocks:	legacy callback function to return the Uncorrected Error
402*4882a593Smuzhiyun  *			Blocks. Newer drivers should provide such info via
403*4882a593Smuzhiyun  *			DVBv5 API, e. g. @set_frontend/@get_frontend,
404*4882a593Smuzhiyun  *			implementing this callback only if DVBv3 API
405*4882a593Smuzhiyun  *			compatibility is wanted.
406*4882a593Smuzhiyun  * @diseqc_reset_overload: callback function to implement the
407*4882a593Smuzhiyun  *			FE_DISEQC_RESET_OVERLOAD() ioctl (only Satellite)
408*4882a593Smuzhiyun  * @diseqc_send_master_cmd: callback function to implement the
409*4882a593Smuzhiyun  *			FE_DISEQC_SEND_MASTER_CMD() ioctl (only Satellite).
410*4882a593Smuzhiyun  * @diseqc_recv_slave_reply: callback function to implement the
411*4882a593Smuzhiyun  *			FE_DISEQC_RECV_SLAVE_REPLY() ioctl (only Satellite)
412*4882a593Smuzhiyun  * @diseqc_send_burst:	callback function to implement the
413*4882a593Smuzhiyun  *			FE_DISEQC_SEND_BURST() ioctl (only Satellite).
414*4882a593Smuzhiyun  * @set_tone:		callback function to implement the
415*4882a593Smuzhiyun  *			FE_SET_TONE() ioctl (only Satellite).
416*4882a593Smuzhiyun  * @set_voltage:	callback function to implement the
417*4882a593Smuzhiyun  *			FE_SET_VOLTAGE() ioctl (only Satellite).
418*4882a593Smuzhiyun  * @enable_high_lnb_voltage: callback function to implement the
419*4882a593Smuzhiyun  *			FE_ENABLE_HIGH_LNB_VOLTAGE() ioctl (only Satellite).
420*4882a593Smuzhiyun  * @dishnetwork_send_legacy_command: callback function to implement the
421*4882a593Smuzhiyun  *			FE_DISHNETWORK_SEND_LEGACY_CMD() ioctl (only Satellite).
422*4882a593Smuzhiyun  *			Drivers should not use this, except when the DVB
423*4882a593Smuzhiyun  *			core emulation fails to provide proper support (e.g.
424*4882a593Smuzhiyun  *			if @set_voltage takes more than 8ms to work), and
425*4882a593Smuzhiyun  *			when backward compatibility with this legacy API is
426*4882a593Smuzhiyun  *			required.
427*4882a593Smuzhiyun  * @i2c_gate_ctrl:	controls the I2C gate. Newer drivers should use I2C
428*4882a593Smuzhiyun  *			mux support instead.
429*4882a593Smuzhiyun  * @ts_bus_ctrl:	callback function used to take control of the TS bus.
430*4882a593Smuzhiyun  * @set_lna:		callback function to power on/off/auto the LNA.
431*4882a593Smuzhiyun  * @search:		callback function used on some custom algo search algos.
432*4882a593Smuzhiyun  * @tuner_ops:		pointer to &struct dvb_tuner_ops
433*4882a593Smuzhiyun  * @analog_ops:		pointer to &struct analog_demod_ops
434*4882a593Smuzhiyun  */
435*4882a593Smuzhiyun struct dvb_frontend_ops {
436*4882a593Smuzhiyun 	struct dvb_frontend_internal_info info;
437*4882a593Smuzhiyun 
438*4882a593Smuzhiyun 	u8 delsys[MAX_DELSYS];
439*4882a593Smuzhiyun 
440*4882a593Smuzhiyun 	void (*detach)(struct dvb_frontend *fe);
441*4882a593Smuzhiyun 	void (*release)(struct dvb_frontend* fe);
442*4882a593Smuzhiyun 	void (*release_sec)(struct dvb_frontend* fe);
443*4882a593Smuzhiyun 
444*4882a593Smuzhiyun 	int (*init)(struct dvb_frontend* fe);
445*4882a593Smuzhiyun 	int (*sleep)(struct dvb_frontend* fe);
446*4882a593Smuzhiyun 
447*4882a593Smuzhiyun 	int (*write)(struct dvb_frontend* fe, const u8 buf[], int len);
448*4882a593Smuzhiyun 
449*4882a593Smuzhiyun 	/* if this is set, it overrides the default swzigzag */
450*4882a593Smuzhiyun 	int (*tune)(struct dvb_frontend* fe,
451*4882a593Smuzhiyun 		    bool re_tune,
452*4882a593Smuzhiyun 		    unsigned int mode_flags,
453*4882a593Smuzhiyun 		    unsigned int *delay,
454*4882a593Smuzhiyun 		    enum fe_status *status);
455*4882a593Smuzhiyun 
456*4882a593Smuzhiyun 	/* get frontend tuning algorithm from the module */
457*4882a593Smuzhiyun 	enum dvbfe_algo (*get_frontend_algo)(struct dvb_frontend *fe);
458*4882a593Smuzhiyun 
459*4882a593Smuzhiyun 	/* these two are only used for the swzigzag code */
460*4882a593Smuzhiyun 	int (*set_frontend)(struct dvb_frontend *fe);
461*4882a593Smuzhiyun 	int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);
462*4882a593Smuzhiyun 
463*4882a593Smuzhiyun 	int (*get_frontend)(struct dvb_frontend *fe,
464*4882a593Smuzhiyun 			    struct dtv_frontend_properties *props);
465*4882a593Smuzhiyun 
466*4882a593Smuzhiyun 	int (*read_status)(struct dvb_frontend *fe, enum fe_status *status);
467*4882a593Smuzhiyun 	int (*read_ber)(struct dvb_frontend* fe, u32* ber);
468*4882a593Smuzhiyun 	int (*read_signal_strength)(struct dvb_frontend* fe, u16* strength);
469*4882a593Smuzhiyun 	int (*read_snr)(struct dvb_frontend* fe, u16* snr);
470*4882a593Smuzhiyun 	int (*read_ucblocks)(struct dvb_frontend* fe, u32* ucblocks);
471*4882a593Smuzhiyun 
472*4882a593Smuzhiyun 	int (*diseqc_reset_overload)(struct dvb_frontend* fe);
473*4882a593Smuzhiyun 	int (*diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);
474*4882a593Smuzhiyun 	int (*diseqc_recv_slave_reply)(struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply);
475*4882a593Smuzhiyun 	int (*diseqc_send_burst)(struct dvb_frontend *fe,
476*4882a593Smuzhiyun 				 enum fe_sec_mini_cmd minicmd);
477*4882a593Smuzhiyun 	int (*set_tone)(struct dvb_frontend *fe, enum fe_sec_tone_mode tone);
478*4882a593Smuzhiyun 	int (*set_voltage)(struct dvb_frontend *fe,
479*4882a593Smuzhiyun 			   enum fe_sec_voltage voltage);
480*4882a593Smuzhiyun 	int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg);
481*4882a593Smuzhiyun 	int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
482*4882a593Smuzhiyun 	int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);
483*4882a593Smuzhiyun 	int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire);
484*4882a593Smuzhiyun 	int (*set_lna)(struct dvb_frontend *);
485*4882a593Smuzhiyun 
486*4882a593Smuzhiyun 	/*
487*4882a593Smuzhiyun 	 * These callbacks are for devices that implement their own
488*4882a593Smuzhiyun 	 * tuning algorithms, rather than a simple swzigzag
489*4882a593Smuzhiyun 	 */
490*4882a593Smuzhiyun 	enum dvbfe_search (*search)(struct dvb_frontend *fe);
491*4882a593Smuzhiyun 
492*4882a593Smuzhiyun 	struct dvb_tuner_ops tuner_ops;
493*4882a593Smuzhiyun 	struct analog_demod_ops analog_ops;
494*4882a593Smuzhiyun };
495*4882a593Smuzhiyun 
496*4882a593Smuzhiyun #ifdef __DVB_CORE__
497*4882a593Smuzhiyun #define MAX_EVENT 8
498*4882a593Smuzhiyun 
499*4882a593Smuzhiyun /* Used only internally at dvb_frontend.c */
500*4882a593Smuzhiyun struct dvb_fe_events {
501*4882a593Smuzhiyun 	struct dvb_frontend_event events[MAX_EVENT];
502*4882a593Smuzhiyun 	int			  eventw;
503*4882a593Smuzhiyun 	int			  eventr;
504*4882a593Smuzhiyun 	int			  overflow;
505*4882a593Smuzhiyun 	wait_queue_head_t	  wait_queue;
506*4882a593Smuzhiyun 	struct mutex		  mtx;
507*4882a593Smuzhiyun };
508*4882a593Smuzhiyun #endif
509*4882a593Smuzhiyun 
510*4882a593Smuzhiyun /**
511*4882a593Smuzhiyun  * struct dtv_frontend_properties - contains a list of properties that are
512*4882a593Smuzhiyun  *				    specific to a digital TV standard.
513*4882a593Smuzhiyun  *
514*4882a593Smuzhiyun  * @frequency:		frequency in Hz for terrestrial/cable or in kHz for
515*4882a593Smuzhiyun  *			Satellite
516*4882a593Smuzhiyun  * @modulation:		Frontend modulation type
517*4882a593Smuzhiyun  * @voltage:		SEC voltage (only Satellite)
518*4882a593Smuzhiyun  * @sectone:		SEC tone mode (only Satellite)
519*4882a593Smuzhiyun  * @inversion:		Spectral inversion
520*4882a593Smuzhiyun  * @fec_inner:		Forward error correction inner Code Rate
521*4882a593Smuzhiyun  * @transmission_mode:	Transmission Mode
522*4882a593Smuzhiyun  * @bandwidth_hz:	Bandwidth, in Hz. A zero value means that userspace
523*4882a593Smuzhiyun  *			wants to autodetect.
524*4882a593Smuzhiyun  * @guard_interval:	Guard Interval
525*4882a593Smuzhiyun  * @hierarchy:		Hierarchy
526*4882a593Smuzhiyun  * @symbol_rate:	Symbol Rate
527*4882a593Smuzhiyun  * @code_rate_HP:	high priority stream code rate
528*4882a593Smuzhiyun  * @code_rate_LP:	low priority stream code rate
529*4882a593Smuzhiyun  * @pilot:		Enable/disable/autodetect pilot tones
530*4882a593Smuzhiyun  * @rolloff:		Rolloff factor (alpha)
531*4882a593Smuzhiyun  * @delivery_system:	FE delivery system (e. g. digital TV standard)
532*4882a593Smuzhiyun  * @interleaving:	interleaving
533*4882a593Smuzhiyun  * @isdbt_partial_reception: ISDB-T partial reception (only ISDB standard)
534*4882a593Smuzhiyun  * @isdbt_sb_mode:	ISDB-T Sound Broadcast (SB) mode (only ISDB standard)
535*4882a593Smuzhiyun  * @isdbt_sb_subchannel:	ISDB-T SB subchannel (only ISDB standard)
536*4882a593Smuzhiyun  * @isdbt_sb_segment_idx:	ISDB-T SB segment index (only ISDB standard)
537*4882a593Smuzhiyun  * @isdbt_sb_segment_count:	ISDB-T SB segment count (only ISDB standard)
538*4882a593Smuzhiyun  * @isdbt_layer_enabled:	ISDB Layer enabled (only ISDB standard)
539*4882a593Smuzhiyun  * @layer:		ISDB per-layer data (only ISDB standard)
540*4882a593Smuzhiyun  * @layer.segment_count: Segment Count;
541*4882a593Smuzhiyun  * @layer.fec:		per layer code rate;
542*4882a593Smuzhiyun  * @layer.modulation:	per layer modulation;
543*4882a593Smuzhiyun  * @layer.interleaving:	 per layer interleaving.
544*4882a593Smuzhiyun  * @stream_id:		If different than zero, enable substream filtering, if
545*4882a593Smuzhiyun  *			hardware supports (DVB-S2 and DVB-T2).
546*4882a593Smuzhiyun  * @scrambling_sequence_index:	Carries the index of the DVB-S2 physical layer
547*4882a593Smuzhiyun  *				scrambling sequence.
548*4882a593Smuzhiyun  * @atscmh_fic_ver:	Version number of the FIC (Fast Information Channel)
549*4882a593Smuzhiyun  *			signaling data (only ATSC-M/H)
550*4882a593Smuzhiyun  * @atscmh_parade_id:	Parade identification number (only ATSC-M/H)
551*4882a593Smuzhiyun  * @atscmh_nog:		Number of MH groups per MH subframe for a designated
552*4882a593Smuzhiyun  *			parade (only ATSC-M/H)
553*4882a593Smuzhiyun  * @atscmh_tnog:	Total number of MH groups including all MH groups
554*4882a593Smuzhiyun  *			belonging to all MH parades in one MH subframe
555*4882a593Smuzhiyun  *			(only ATSC-M/H)
556*4882a593Smuzhiyun  * @atscmh_sgn:		Start group number (only ATSC-M/H)
557*4882a593Smuzhiyun  * @atscmh_prc:		Parade repetition cycle (only ATSC-M/H)
558*4882a593Smuzhiyun  * @atscmh_rs_frame_mode:	Reed Solomon (RS) frame mode (only ATSC-M/H)
559*4882a593Smuzhiyun  * @atscmh_rs_frame_ensemble:	RS frame ensemble (only ATSC-M/H)
560*4882a593Smuzhiyun  * @atscmh_rs_code_mode_pri:	RS code mode pri (only ATSC-M/H)
561*4882a593Smuzhiyun  * @atscmh_rs_code_mode_sec:	RS code mode sec (only ATSC-M/H)
562*4882a593Smuzhiyun  * @atscmh_sccc_block_mode:	Series Concatenated Convolutional Code (SCCC)
563*4882a593Smuzhiyun  *				Block Mode (only ATSC-M/H)
564*4882a593Smuzhiyun  * @atscmh_sccc_code_mode_a:	SCCC code mode A (only ATSC-M/H)
565*4882a593Smuzhiyun  * @atscmh_sccc_code_mode_b:	SCCC code mode B (only ATSC-M/H)
566*4882a593Smuzhiyun  * @atscmh_sccc_code_mode_c:	SCCC code mode C (only ATSC-M/H)
567*4882a593Smuzhiyun  * @atscmh_sccc_code_mode_d:	SCCC code mode D (only ATSC-M/H)
568*4882a593Smuzhiyun  * @lna:		Power ON/OFF/AUTO the Linear Now-noise Amplifier (LNA)
569*4882a593Smuzhiyun  * @strength:		DVBv5 API statistics: Signal Strength
570*4882a593Smuzhiyun  * @cnr:		DVBv5 API statistics: Signal to Noise ratio of the
571*4882a593Smuzhiyun  *			(main) carrier
572*4882a593Smuzhiyun  * @pre_bit_error:	DVBv5 API statistics: pre-Viterbi bit error count
573*4882a593Smuzhiyun  * @pre_bit_count:	DVBv5 API statistics: pre-Viterbi bit count
574*4882a593Smuzhiyun  * @post_bit_error:	DVBv5 API statistics: post-Viterbi bit error count
575*4882a593Smuzhiyun  * @post_bit_count:	DVBv5 API statistics: post-Viterbi bit count
576*4882a593Smuzhiyun  * @block_error:	DVBv5 API statistics: block error count
577*4882a593Smuzhiyun  * @block_count:	DVBv5 API statistics: block count
578*4882a593Smuzhiyun  *
579*4882a593Smuzhiyun  * NOTE: derivated statistics like Uncorrected Error blocks (UCE) are
580*4882a593Smuzhiyun  * calculated on userspace.
581*4882a593Smuzhiyun  *
582*4882a593Smuzhiyun  * Only a subset of the properties are needed for a given delivery system.
583*4882a593Smuzhiyun  * For more info, consult the media_api.html with the documentation of the
584*4882a593Smuzhiyun  * Userspace API.
585*4882a593Smuzhiyun  */
586*4882a593Smuzhiyun struct dtv_frontend_properties {
587*4882a593Smuzhiyun 	u32			frequency;
588*4882a593Smuzhiyun 	enum fe_modulation	modulation;
589*4882a593Smuzhiyun 
590*4882a593Smuzhiyun 	enum fe_sec_voltage	voltage;
591*4882a593Smuzhiyun 	enum fe_sec_tone_mode	sectone;
592*4882a593Smuzhiyun 	enum fe_spectral_inversion inversion;
593*4882a593Smuzhiyun 	enum fe_code_rate	fec_inner;
594*4882a593Smuzhiyun 	enum fe_transmit_mode	transmission_mode;
595*4882a593Smuzhiyun 	u32			bandwidth_hz;	/* 0 = AUTO */
596*4882a593Smuzhiyun 	enum fe_guard_interval	guard_interval;
597*4882a593Smuzhiyun 	enum fe_hierarchy	hierarchy;
598*4882a593Smuzhiyun 	u32			symbol_rate;
599*4882a593Smuzhiyun 	enum fe_code_rate	code_rate_HP;
600*4882a593Smuzhiyun 	enum fe_code_rate	code_rate_LP;
601*4882a593Smuzhiyun 
602*4882a593Smuzhiyun 	enum fe_pilot		pilot;
603*4882a593Smuzhiyun 	enum fe_rolloff		rolloff;
604*4882a593Smuzhiyun 
605*4882a593Smuzhiyun 	enum fe_delivery_system	delivery_system;
606*4882a593Smuzhiyun 
607*4882a593Smuzhiyun 	enum fe_interleaving	interleaving;
608*4882a593Smuzhiyun 
609*4882a593Smuzhiyun 	/* ISDB-T specifics */
610*4882a593Smuzhiyun 	u8			isdbt_partial_reception;
611*4882a593Smuzhiyun 	u8			isdbt_sb_mode;
612*4882a593Smuzhiyun 	u8			isdbt_sb_subchannel;
613*4882a593Smuzhiyun 	u32			isdbt_sb_segment_idx;
614*4882a593Smuzhiyun 	u32			isdbt_sb_segment_count;
615*4882a593Smuzhiyun 	u8			isdbt_layer_enabled;
616*4882a593Smuzhiyun 	struct {
617*4882a593Smuzhiyun 	    u8			segment_count;
618*4882a593Smuzhiyun 	    enum fe_code_rate	fec;
619*4882a593Smuzhiyun 	    enum fe_modulation	modulation;
620*4882a593Smuzhiyun 	    u8			interleaving;
621*4882a593Smuzhiyun 	} layer[3];
622*4882a593Smuzhiyun 
623*4882a593Smuzhiyun 	/* Multistream specifics */
624*4882a593Smuzhiyun 	u32			stream_id;
625*4882a593Smuzhiyun 
626*4882a593Smuzhiyun 	/* Physical Layer Scrambling specifics */
627*4882a593Smuzhiyun 	u32			scrambling_sequence_index;
628*4882a593Smuzhiyun 
629*4882a593Smuzhiyun 	/* ATSC-MH specifics */
630*4882a593Smuzhiyun 	u8			atscmh_fic_ver;
631*4882a593Smuzhiyun 	u8			atscmh_parade_id;
632*4882a593Smuzhiyun 	u8			atscmh_nog;
633*4882a593Smuzhiyun 	u8			atscmh_tnog;
634*4882a593Smuzhiyun 	u8			atscmh_sgn;
635*4882a593Smuzhiyun 	u8			atscmh_prc;
636*4882a593Smuzhiyun 
637*4882a593Smuzhiyun 	u8			atscmh_rs_frame_mode;
638*4882a593Smuzhiyun 	u8			atscmh_rs_frame_ensemble;
639*4882a593Smuzhiyun 	u8			atscmh_rs_code_mode_pri;
640*4882a593Smuzhiyun 	u8			atscmh_rs_code_mode_sec;
641*4882a593Smuzhiyun 	u8			atscmh_sccc_block_mode;
642*4882a593Smuzhiyun 	u8			atscmh_sccc_code_mode_a;
643*4882a593Smuzhiyun 	u8			atscmh_sccc_code_mode_b;
644*4882a593Smuzhiyun 	u8			atscmh_sccc_code_mode_c;
645*4882a593Smuzhiyun 	u8			atscmh_sccc_code_mode_d;
646*4882a593Smuzhiyun 
647*4882a593Smuzhiyun 	u32			lna;
648*4882a593Smuzhiyun 
649*4882a593Smuzhiyun 	/* statistics data */
650*4882a593Smuzhiyun 	struct dtv_fe_stats	strength;
651*4882a593Smuzhiyun 	struct dtv_fe_stats	cnr;
652*4882a593Smuzhiyun 	struct dtv_fe_stats	pre_bit_error;
653*4882a593Smuzhiyun 	struct dtv_fe_stats	pre_bit_count;
654*4882a593Smuzhiyun 	struct dtv_fe_stats	post_bit_error;
655*4882a593Smuzhiyun 	struct dtv_fe_stats	post_bit_count;
656*4882a593Smuzhiyun 	struct dtv_fe_stats	block_error;
657*4882a593Smuzhiyun 	struct dtv_fe_stats	block_count;
658*4882a593Smuzhiyun };
659*4882a593Smuzhiyun 
660*4882a593Smuzhiyun #define DVB_FE_NO_EXIT  0
661*4882a593Smuzhiyun #define DVB_FE_NORMAL_EXIT      1
662*4882a593Smuzhiyun #define DVB_FE_DEVICE_REMOVED   2
663*4882a593Smuzhiyun #define DVB_FE_DEVICE_RESUME    3
664*4882a593Smuzhiyun 
665*4882a593Smuzhiyun /**
666*4882a593Smuzhiyun  * struct dvb_frontend - Frontend structure to be used on drivers.
667*4882a593Smuzhiyun  *
668*4882a593Smuzhiyun  * @refcount:		refcount to keep track of &struct dvb_frontend
669*4882a593Smuzhiyun  *			references
670*4882a593Smuzhiyun  * @ops:		embedded &struct dvb_frontend_ops
671*4882a593Smuzhiyun  * @dvb:		pointer to &struct dvb_adapter
672*4882a593Smuzhiyun  * @demodulator_priv:	demod private data
673*4882a593Smuzhiyun  * @tuner_priv:		tuner private data
674*4882a593Smuzhiyun  * @frontend_priv:	frontend private data
675*4882a593Smuzhiyun  * @sec_priv:		SEC private data
676*4882a593Smuzhiyun  * @analog_demod_priv:	Analog demod private data
677*4882a593Smuzhiyun  * @dtv_property_cache:	embedded &struct dtv_frontend_properties
678*4882a593Smuzhiyun  * @callback:		callback function used on some drivers to call
679*4882a593Smuzhiyun  *			either the tuner or the demodulator.
680*4882a593Smuzhiyun  * @id:			Frontend ID
681*4882a593Smuzhiyun  * @exit:		Used to inform the DVB core that the frontend
682*4882a593Smuzhiyun  *			thread should exit (usually, means that the hardware
683*4882a593Smuzhiyun  *			got disconnected.
684*4882a593Smuzhiyun  */
685*4882a593Smuzhiyun 
686*4882a593Smuzhiyun struct dvb_frontend {
687*4882a593Smuzhiyun 	struct kref refcount;
688*4882a593Smuzhiyun 	struct dvb_frontend_ops ops;
689*4882a593Smuzhiyun 	struct dvb_adapter *dvb;
690*4882a593Smuzhiyun 	void *demodulator_priv;
691*4882a593Smuzhiyun 	void *tuner_priv;
692*4882a593Smuzhiyun 	void *frontend_priv;
693*4882a593Smuzhiyun 	void *sec_priv;
694*4882a593Smuzhiyun 	void *analog_demod_priv;
695*4882a593Smuzhiyun 	struct dtv_frontend_properties dtv_property_cache;
696*4882a593Smuzhiyun #define DVB_FRONTEND_COMPONENT_TUNER 0
697*4882a593Smuzhiyun #define DVB_FRONTEND_COMPONENT_DEMOD 1
698*4882a593Smuzhiyun 	int (*callback)(void *adapter_priv, int component, int cmd, int arg);
699*4882a593Smuzhiyun 	int id;
700*4882a593Smuzhiyun 	unsigned int exit;
701*4882a593Smuzhiyun };
702*4882a593Smuzhiyun 
703*4882a593Smuzhiyun /**
704*4882a593Smuzhiyun  * dvb_register_frontend() - Registers a DVB frontend at the adapter
705*4882a593Smuzhiyun  *
706*4882a593Smuzhiyun  * @dvb: pointer to &struct dvb_adapter
707*4882a593Smuzhiyun  * @fe: pointer to &struct dvb_frontend
708*4882a593Smuzhiyun  *
709*4882a593Smuzhiyun  * Allocate and initialize the private data needed by the frontend core to
710*4882a593Smuzhiyun  * manage the frontend and calls dvb_register_device() to register a new
711*4882a593Smuzhiyun  * frontend. It also cleans the property cache that stores the frontend
712*4882a593Smuzhiyun  * parameters and selects the first available delivery system.
713*4882a593Smuzhiyun  */
714*4882a593Smuzhiyun int dvb_register_frontend(struct dvb_adapter *dvb,
715*4882a593Smuzhiyun 				 struct dvb_frontend *fe);
716*4882a593Smuzhiyun 
717*4882a593Smuzhiyun /**
718*4882a593Smuzhiyun  * dvb_unregister_frontend() - Unregisters a DVB frontend
719*4882a593Smuzhiyun  *
720*4882a593Smuzhiyun  * @fe: pointer to &struct dvb_frontend
721*4882a593Smuzhiyun  *
722*4882a593Smuzhiyun  * Stops the frontend kthread, calls dvb_unregister_device() and frees the
723*4882a593Smuzhiyun  * private frontend data allocated by dvb_register_frontend().
724*4882a593Smuzhiyun  *
725*4882a593Smuzhiyun  * NOTE: This function doesn't frees the memory allocated by the demod,
726*4882a593Smuzhiyun  * by the SEC driver and by the tuner. In order to free it, an explicit call to
727*4882a593Smuzhiyun  * dvb_frontend_detach() is needed, after calling this function.
728*4882a593Smuzhiyun  */
729*4882a593Smuzhiyun int dvb_unregister_frontend(struct dvb_frontend *fe);
730*4882a593Smuzhiyun 
731*4882a593Smuzhiyun /**
732*4882a593Smuzhiyun  * dvb_frontend_detach() - Detaches and frees frontend specific data
733*4882a593Smuzhiyun  *
734*4882a593Smuzhiyun  * @fe: pointer to &struct dvb_frontend
735*4882a593Smuzhiyun  *
736*4882a593Smuzhiyun  * This function should be called after dvb_unregister_frontend(). It
737*4882a593Smuzhiyun  * calls the SEC, tuner and demod release functions:
738*4882a593Smuzhiyun  * &dvb_frontend_ops.release_sec, &dvb_frontend_ops.tuner_ops.release,
739*4882a593Smuzhiyun  * &dvb_frontend_ops.analog_ops.release and &dvb_frontend_ops.release.
740*4882a593Smuzhiyun  *
741*4882a593Smuzhiyun  * If the driver is compiled with %CONFIG_MEDIA_ATTACH, it also decreases
742*4882a593Smuzhiyun  * the module reference count, needed to allow userspace to remove the
743*4882a593Smuzhiyun  * previously used DVB frontend modules.
744*4882a593Smuzhiyun  */
745*4882a593Smuzhiyun void dvb_frontend_detach(struct dvb_frontend *fe);
746*4882a593Smuzhiyun 
747*4882a593Smuzhiyun /**
748*4882a593Smuzhiyun  * dvb_frontend_suspend() - Suspends a Digital TV frontend
749*4882a593Smuzhiyun  *
750*4882a593Smuzhiyun  * @fe: pointer to &struct dvb_frontend
751*4882a593Smuzhiyun  *
752*4882a593Smuzhiyun  * This function prepares a Digital TV frontend to suspend.
753*4882a593Smuzhiyun  *
754*4882a593Smuzhiyun  * In order to prepare the tuner to suspend, if
755*4882a593Smuzhiyun  * &dvb_frontend_ops.tuner_ops.suspend\(\) is available, it calls it. Otherwise,
756*4882a593Smuzhiyun  * it will call &dvb_frontend_ops.tuner_ops.sleep\(\), if available.
757*4882a593Smuzhiyun  *
758*4882a593Smuzhiyun  * It will also call &dvb_frontend_ops.sleep\(\) to put the demod to suspend.
759*4882a593Smuzhiyun  *
760*4882a593Smuzhiyun  * The drivers should also call dvb_frontend_suspend\(\) as part of their
761*4882a593Smuzhiyun  * handler for the &device_driver.suspend\(\).
762*4882a593Smuzhiyun  */
763*4882a593Smuzhiyun int dvb_frontend_suspend(struct dvb_frontend *fe);
764*4882a593Smuzhiyun 
765*4882a593Smuzhiyun /**
766*4882a593Smuzhiyun  * dvb_frontend_resume() - Resumes a Digital TV frontend
767*4882a593Smuzhiyun  *
768*4882a593Smuzhiyun  * @fe: pointer to &struct dvb_frontend
769*4882a593Smuzhiyun  *
770*4882a593Smuzhiyun  * This function resumes the usual operation of the tuner after resume.
771*4882a593Smuzhiyun  *
772*4882a593Smuzhiyun  * In order to resume the frontend, it calls the demod &dvb_frontend_ops.init\(\).
773*4882a593Smuzhiyun  *
774*4882a593Smuzhiyun  * If &dvb_frontend_ops.tuner_ops.resume\(\) is available, It, it calls it.
775*4882a593Smuzhiyun  * Otherwise,t will call &dvb_frontend_ops.tuner_ops.init\(\), if available.
776*4882a593Smuzhiyun  *
777*4882a593Smuzhiyun  * Once tuner and demods are resumed, it will enforce that the SEC voltage and
778*4882a593Smuzhiyun  * tone are restored to their previous values and wake up the frontend's
779*4882a593Smuzhiyun  * kthread in order to retune the frontend.
780*4882a593Smuzhiyun  *
781*4882a593Smuzhiyun  * The drivers should also call dvb_frontend_resume() as part of their
782*4882a593Smuzhiyun  * handler for the &device_driver.resume\(\).
783*4882a593Smuzhiyun  */
784*4882a593Smuzhiyun int dvb_frontend_resume(struct dvb_frontend *fe);
785*4882a593Smuzhiyun 
786*4882a593Smuzhiyun /**
787*4882a593Smuzhiyun  * dvb_frontend_reinitialise() - forces a reinitialisation at the frontend
788*4882a593Smuzhiyun  *
789*4882a593Smuzhiyun  * @fe: pointer to &struct dvb_frontend
790*4882a593Smuzhiyun  *
791*4882a593Smuzhiyun  * Calls &dvb_frontend_ops.init\(\) and &dvb_frontend_ops.tuner_ops.init\(\),
792*4882a593Smuzhiyun  * and resets SEC tone and voltage (for Satellite systems).
793*4882a593Smuzhiyun  *
794*4882a593Smuzhiyun  * NOTE: Currently, this function is used only by one driver (budget-av).
795*4882a593Smuzhiyun  * It seems to be due to address some special issue with that specific
796*4882a593Smuzhiyun  * frontend.
797*4882a593Smuzhiyun  */
798*4882a593Smuzhiyun void dvb_frontend_reinitialise(struct dvb_frontend *fe);
799*4882a593Smuzhiyun 
800*4882a593Smuzhiyun /**
801*4882a593Smuzhiyun  * dvb_frontend_sleep_until() - Sleep for the amount of time given by
802*4882a593Smuzhiyun  *                      add_usec parameter
803*4882a593Smuzhiyun  *
804*4882a593Smuzhiyun  * @waketime: pointer to &struct ktime_t
805*4882a593Smuzhiyun  * @add_usec: time to sleep, in microseconds
806*4882a593Smuzhiyun  *
807*4882a593Smuzhiyun  * This function is used to measure the time required for the
808*4882a593Smuzhiyun  * FE_DISHNETWORK_SEND_LEGACY_CMD() ioctl to work. It needs to be as precise
809*4882a593Smuzhiyun  * as possible, as it affects the detection of the dish tone command at the
810*4882a593Smuzhiyun  * satellite subsystem.
811*4882a593Smuzhiyun  *
812*4882a593Smuzhiyun  * Its used internally by the DVB frontend core, in order to emulate
813*4882a593Smuzhiyun  * FE_DISHNETWORK_SEND_LEGACY_CMD() using the &dvb_frontend_ops.set_voltage\(\)
814*4882a593Smuzhiyun  * callback.
815*4882a593Smuzhiyun  *
816*4882a593Smuzhiyun  * NOTE: it should not be used at the drivers, as the emulation for the
817*4882a593Smuzhiyun  * legacy callback is provided by the Kernel. The only situation where this
818*4882a593Smuzhiyun  * should be at the drivers is when there are some bugs at the hardware that
819*4882a593Smuzhiyun  * would prevent the core emulation to work. On such cases, the driver would
820*4882a593Smuzhiyun  * be writing a &dvb_frontend_ops.dishnetwork_send_legacy_command\(\) and
821*4882a593Smuzhiyun  * calling this function directly.
822*4882a593Smuzhiyun  */
823*4882a593Smuzhiyun void dvb_frontend_sleep_until(ktime_t *waketime, u32 add_usec);
824*4882a593Smuzhiyun 
825*4882a593Smuzhiyun #endif
826