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