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