4 * The Digital TV Frontend kABI defines a driver-internal interface for
5 * registering low-level, hardware specific driver to a hardware independent
8 * Copyright (C) 2001 convergence integrated media GmbH
9 * Copyright (C) 2004 convergence GmbH
11 * Written by Ralph Metzler
12 * Overhauled by Holger Waechtler
13 * Kernel I2C stuff by Michael Hunold <hunold@convergence.de>
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.
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.
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.
32 #ifndef _DVB_FRONTEND_H_
33 #define _DVB_FRONTEND_H_
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>
42 #include <linux/mutex.h>
43 #include <linux/slab.h>
45 #include <linux/dvb/frontend.h>
50 * Maximum number of Delivery systems per frontend. It
51 * should be smaller or equal to 32
56 * struct dvb_frontend_tune_settings - parameters to adjust frontend tuning
58 * @min_delay_ms: minimum delay for tuning, in ms
59 * @step_size: step size between two consecutive frequencies
60 * @max_drift: maximum drift
62 * NOTE: step_size is in Hz, for terrestrial/cable or kHz for satellite
64 struct dvb_frontend_tune_settings {
73 * struct dvb_tuner_info - Frontend name and min/max ranges/bandwidths
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
83 * NOTE: frequency parameters are in Hz, for terrestrial/cable or kHz for
86 struct dvb_tuner_info {
99 * struct analog_parameters - Parameters to tune into an analog/radio channel
101 * @frequency: Frequency used by analog TV tuner (either in 62.5 kHz step,
102 * for TV, or 62.5 Hz for radio)
103 * @mode: Tuner mode, as defined on enum v4l2_tuner_type
104 * @audmode: Audio mode as defined for the rxsubchans field at videodev2.h,
105 * e. g. V4L2_TUNER_MODE_*
106 * @std: TV standard bitmap as defined at videodev2.h, e. g. V4L2_STD_*
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.
112 struct analog_parameters {
113 unsigned int frequency;
115 unsigned int audmode;
120 * enum dvbfe_algo - defines the algorithm used to tune into a channel
122 * @DVBFE_ALGO_HW: Hardware Algorithm -
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.
128 * @DVBFE_ALGO_SW: Software Algorithm -
129 * These are dumb devices, that require software to do everything
131 * @DVBFE_ALGO_CUSTOM: Customizable Agorithm -
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.
139 * @DVBFE_ALGO_RECOVERY: Recovery Algorithm -
140 * These devices have AUTO recovery capabilities from LOCK failure
143 DVBFE_ALGO_HW = (1 << 0),
144 DVBFE_ALGO_SW = (1 << 1),
145 DVBFE_ALGO_CUSTOM = (1 << 2),
146 DVBFE_ALGO_RECOVERY = (1 << 31)
150 * enum dvbfe_search - search callback possible return status
152 * @DVBFE_ALGO_SEARCH_SUCCESS:
153 * The frontend search algorithm completed and returned successfully
155 * @DVBFE_ALGO_SEARCH_ASLEEP:
156 * The frontend search algorithm is sleeping
158 * @DVBFE_ALGO_SEARCH_FAILED:
159 * The frontend search for a signal failed
161 * @DVBFE_ALGO_SEARCH_INVALID:
162 * The frontend search algorith was probably supplied with invalid
163 * parameters and the search is an invalid one
165 * @DVBFE_ALGO_SEARCH_ERROR:
166 * The frontend search algorithm failed due to some error
168 * @DVBFE_ALGO_SEARCH_AGAIN:
169 * The frontend search algorithm was requested to search again
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),
181 * struct dvb_tuner_ops - Tuner information and callbacks
183 * @info: embedded struct dvb_tuner_info with tuner properties
184 * @release: callback function called when frontend is dettached.
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
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
194 * are stored at @dvb_frontend.dtv_property_cache;. The
195 * tuner demod can change the parameters to reflect the
196 * changes needed for the channel to be tuned, and
197 * update statistics. This is the recommended way to set
198 * the tuner parameters and should be used on newer
200 * @set_analog_params: callback function used to tune into an analog TV
201 * channel on hybrid tuners. It passes @analog_parameters;
203 * @set_config: callback function used to send some tuner-specific
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,
209 * @get_status: returns the frontend lock status
210 * @get_rf_strength: returns the RF signal strengh. Used mostly to support
211 * analog TV and radio. Digital TV should report, instead,
212 * via DVBv5 API (@dvb_frontend.dtv_property_cache;).
213 * @get_afc: Used only by analog TV core. Reports the frequency
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.
220 * NOTE: frequencies used on get_frequency and set_frequency are in Hz for
221 * terrestrial/cable or kHz for satellite.
224 struct dvb_tuner_ops {
226 struct dvb_tuner_info info;
228 int (*release)(struct dvb_frontend *fe);
229 int (*init)(struct dvb_frontend *fe);
230 int (*sleep)(struct dvb_frontend *fe);
231 int (*suspend)(struct dvb_frontend *fe);
232 int (*resume)(struct dvb_frontend *fe);
234 /* This is the recomended way to set the tuner */
235 int (*set_params)(struct dvb_frontend *fe);
236 int (*set_analog_params)(struct dvb_frontend *fe, struct analog_parameters *p);
238 int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
240 int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency);
241 int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
242 int (*get_if_frequency)(struct dvb_frontend *fe, u32 *frequency);
244 #define TUNER_STATUS_LOCKED 1
245 #define TUNER_STATUS_STEREO 2
246 int (*get_status)(struct dvb_frontend *fe, u32 *status);
247 int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength);
248 int (*get_afc)(struct dvb_frontend *fe, s32 *afc);
251 * This is support for demods like the mt352 - fills out the supplied
252 * buffer with what to write.
254 * Don't use on newer drivers.
256 int (*calc_regs)(struct dvb_frontend *fe, u8 *buf, int buf_len);
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.
263 * Don't use on newer drivers.
265 int (*set_frequency)(struct dvb_frontend *fe, u32 frequency);
266 int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
270 * struct analog_demod_info - Information struct for analog TV part of the demod
272 * @name: Name of the analog TV demodulator
274 struct analog_demod_info {
279 * struct analog_demod_ops - Demodulation information and callbacks for
280 * analog TV and radio
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
286 * struct @analog_params;.
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
290 * @tuner_status: callback function that returns tuner status bits, e. g.
291 * TUNER_STATUS_LOCKED and TUNER_STATUS_STEREO.
292 * @standby: set the tuner to standby mode.
293 * @release: callback function called when frontend is dettached.
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
300 struct analog_demod_ops {
302 struct analog_demod_info info;
304 void (*set_params)(struct dvb_frontend *fe,
305 struct analog_parameters *params);
306 int (*has_signal)(struct dvb_frontend *fe, u16 *signal);
307 int (*get_afc)(struct dvb_frontend *fe, s32 *afc);
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);
313 /** This is to allow setting tuner-specific configuration */
314 int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
317 struct dtv_frontend_properties;
321 * struct dvb_frontend_ops - Demodulation information and callbacks for
324 * @info: embedded struct dvb_tuner_info with tuner properties
325 * @delsys: Delivery systems supported by the frontend
326 * @release: callback function called when frontend is dettached.
327 * drivers should free any allocated memory.
328 * @release_sec: callback function requesting that the Satelite Equipment
329 * Control (SEC) driver to release and free any memory
330 * allocated by the driver.
331 * @init: callback function used to initialize the tuner device.
332 * @sleep: callback function used to put the tuner to sleep.
333 * @write: callback function used by some demod legacy drivers to
334 * allow other drivers to write data into their registers.
335 * Should not be used on new drivers.
336 * @tune: callback function used by demod drivers that use
337 * @DVBFE_ALGO_HW; to tune into a frequency.
338 * @get_frontend_algo: returns the desired hardware algorithm.
339 * @set_frontend: callback function used to inform the demod to set the
340 * parameters for demodulating a digital TV channel.
341 * The properties to be used are stored at
342 * @dvb_frontend.dtv_property_cache;. The demod can change
343 * the parameters to reflect the changes needed for the
344 * channel to be decoded, and update statistics.
345 * @get_tune_settings: callback function
346 * @get_frontend: callback function used to inform the parameters
347 * actuall in use. The properties to be used are stored at
348 * @dvb_frontend.dtv_property_cache; and update
349 * statistics. Please notice that it should not return
350 * an error code if the statistics are not available
351 * because the demog is not locked.
352 * @read_status: returns the locking status of the frontend.
353 * @read_ber: legacy callback function to return the bit error rate.
354 * Newer drivers should provide such info via DVBv5 API,
355 * e. g. @set_frontend;/@get_frontend;, implementing this
356 * callback only if DVBv3 API compatibility is wanted.
357 * @read_signal_strength: legacy callback function to return the signal
358 * strength. Newer drivers should provide such info via
359 * DVBv5 API, e. g. @set_frontend;/@get_frontend;,
360 * implementing this callback only if DVBv3 API
361 * compatibility is wanted.
362 * @read_snr: legacy callback function to return the Signal/Noise
363 * rate. Newer drivers should provide such info via
364 * DVBv5 API, e. g. @set_frontend;/@get_frontend;,
365 * implementing this callback only if DVBv3 API
366 * compatibility is wanted.
367 * @read_ucblocks: legacy callback function to return the Uncorrected Error
368 * Blocks. Newer drivers should provide such info via
369 * DVBv5 API, e. g. @set_frontend;/@get_frontend;,
370 * implementing this callback only if DVBv3 API
371 * compatibility is wanted.
372 * @diseqc_reset_overload: callback function to implement the
373 * FE_DISEQC_RESET_OVERLOAD ioctl (only Satellite)
374 * @diseqc_send_master_cmd: callback function to implement the
375 * FE_DISEQC_SEND_MASTER_CMD ioctl (only Satellite).
376 * @diseqc_recv_slave_reply: callback function to implement the
377 * FE_DISEQC_RECV_SLAVE_REPLY ioctl (only Satellite)
378 * @diseqc_send_burst: callback function to implement the
379 * FE_DISEQC_SEND_BURST ioctl (only Satellite).
380 * @set_tone: callback function to implement the
381 * FE_SET_TONE ioctl (only Satellite).
382 * @set_voltage: callback function to implement the
383 * FE_SET_VOLTAGE ioctl (only Satellite).
384 * @enable_high_lnb_voltage: callback function to implement the
385 * FE_ENABLE_HIGH_LNB_VOLTAGE ioctl (only Satellite).
386 * @dishnetwork_send_legacy_command: callback function to implement the
387 * FE_DISHNETWORK_SEND_LEGACY_CMD ioctl (only Satellite).
388 * Drivers should not use this, except when the DVB
389 * core emulation fails to provide proper support (e.g.
390 * if @set_voltage takes more than 8ms to work), and
391 * when backward compatibility with this legacy API is
393 * @i2c_gate_ctrl: controls the I2C gate. Newer drivers should use I2C
394 * mux support instead.
395 * @ts_bus_ctrl: callback function used to take control of the TS bus.
396 * @set_lna: callback function to power on/off/auto the LNA.
397 * @search: callback function used on some custom algo search algos.
398 * @tuner_ops: pointer to struct dvb_tuner_ops
399 * @analog_ops: pointer to struct analog_demod_ops
401 struct dvb_frontend_ops {
402 struct dvb_frontend_info info;
404 u8 delsys[MAX_DELSYS];
406 void (*release)(struct dvb_frontend* fe);
407 void (*release_sec)(struct dvb_frontend* fe);
409 int (*init)(struct dvb_frontend* fe);
410 int (*sleep)(struct dvb_frontend* fe);
412 int (*write)(struct dvb_frontend* fe, const u8 buf[], int len);
414 /* if this is set, it overrides the default swzigzag */
415 int (*tune)(struct dvb_frontend* fe,
417 unsigned int mode_flags,
419 enum fe_status *status);
421 /* get frontend tuning algorithm from the module */
422 enum dvbfe_algo (*get_frontend_algo)(struct dvb_frontend *fe);
424 /* these two are only used for the swzigzag code */
425 int (*set_frontend)(struct dvb_frontend *fe);
426 int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);
428 int (*get_frontend)(struct dvb_frontend *fe,
429 struct dtv_frontend_properties *props);
431 int (*read_status)(struct dvb_frontend *fe, enum fe_status *status);
432 int (*read_ber)(struct dvb_frontend* fe, u32* ber);
433 int (*read_signal_strength)(struct dvb_frontend* fe, u16* strength);
434 int (*read_snr)(struct dvb_frontend* fe, u16* snr);
435 int (*read_ucblocks)(struct dvb_frontend* fe, u32* ucblocks);
437 int (*diseqc_reset_overload)(struct dvb_frontend* fe);
438 int (*diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);
439 int (*diseqc_recv_slave_reply)(struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply);
440 int (*diseqc_send_burst)(struct dvb_frontend *fe,
441 enum fe_sec_mini_cmd minicmd);
442 int (*set_tone)(struct dvb_frontend *fe, enum fe_sec_tone_mode tone);
443 int (*set_voltage)(struct dvb_frontend *fe,
444 enum fe_sec_voltage voltage);
445 int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg);
446 int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
447 int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);
448 int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire);
449 int (*set_lna)(struct dvb_frontend *);
452 * These callbacks are for devices that implement their own
453 * tuning algorithms, rather than a simple swzigzag
455 enum dvbfe_search (*search)(struct dvb_frontend *fe);
457 struct dvb_tuner_ops tuner_ops;
458 struct analog_demod_ops analog_ops;
464 /* Used only internally at dvb_frontend.c */
465 struct dvb_fe_events {
466 struct dvb_frontend_event events[MAX_EVENT];
470 wait_queue_head_t wait_queue;
476 * struct dtv_frontend_properties - contains a list of properties that are
477 * specific to a digital TV standard.
479 * @frequency: frequency in Hz for terrestrial/cable or in kHz for
481 * @modulation: Frontend modulation type
482 * @voltage: SEC voltage (only Satellite)
483 * @sectone: SEC tone mode (only Satellite)
484 * @inversion: Spectral inversion
485 * @fec_inner: Forward error correction inner Code Rate
486 * @transmission_mode: Transmission Mode
487 * @bandwidth_hz: Bandwidth, in Hz. A zero value means that userspace
488 * wants to autodetect.
489 * @guard_interval: Guard Interval
490 * @hierarchy: Hierarchy
491 * @symbol_rate: Symbol Rate
492 * @code_rate_HP: high priority stream code rate
493 * @code_rate_LP: low priority stream code rate
494 * @pilot: Enable/disable/autodetect pilot tones
495 * @rolloff: Rolloff factor (alpha)
496 * @delivery_system: FE delivery system (e. g. digital TV standard)
497 * @interleaving: interleaving
498 * @isdbt_partial_reception: ISDB-T partial reception (only ISDB standard)
499 * @isdbt_sb_mode: ISDB-T Sound Broadcast (SB) mode (only ISDB standard)
500 * @isdbt_sb_subchannel: ISDB-T SB subchannel (only ISDB standard)
501 * @isdbt_sb_segment_idx: ISDB-T SB segment index (only ISDB standard)
502 * @isdbt_sb_segment_count: ISDB-T SB segment count (only ISDB standard)
503 * @isdbt_layer_enabled: ISDB Layer enabled (only ISDB standard)
504 * @layer: ISDB per-layer data (only ISDB standard)
505 * @layer.segment_count: Segment Count;
506 * @layer.fec: per layer code rate;
507 * @layer.modulation: per layer modulation;
508 * @layer.interleaving: per layer interleaving.
509 * @stream_id: If different than zero, enable substream filtering, if
510 * hardware supports (DVB-S2 and DVB-T2).
511 * @atscmh_fic_ver: Version number of the FIC (Fast Information Channel)
512 * signaling data (only ATSC-M/H)
513 * @atscmh_parade_id: Parade identification number (only ATSC-M/H)
514 * @atscmh_nog: Number of MH groups per MH subframe for a designated
515 * parade (only ATSC-M/H)
516 * @atscmh_tnog: Total number of MH groups including all MH groups
517 * belonging to all MH parades in one MH subframe
519 * @atscmh_sgn: Start group number (only ATSC-M/H)
520 * @atscmh_prc: Parade repetition cycle (only ATSC-M/H)
521 * @atscmh_rs_frame_mode: Reed Solomon (RS) frame mode (only ATSC-M/H)
522 * @atscmh_rs_frame_ensemble: RS frame ensemble (only ATSC-M/H)
523 * @atscmh_rs_code_mode_pri: RS code mode pri (only ATSC-M/H)
524 * @atscmh_rs_code_mode_sec: RS code mode sec (only ATSC-M/H)
525 * @atscmh_sccc_block_mode: Series Concatenated Convolutional Code (SCCC)
526 * Block Mode (only ATSC-M/H)
527 * @atscmh_sccc_code_mode_a: SCCC code mode A (only ATSC-M/H)
528 * @atscmh_sccc_code_mode_b: SCCC code mode B (only ATSC-M/H)
529 * @atscmh_sccc_code_mode_c: SCCC code mode C (only ATSC-M/H)
530 * @atscmh_sccc_code_mode_d: SCCC code mode D (only ATSC-M/H)
531 * @lna: Power ON/OFF/AUTO the Linear Now-noise Amplifier (LNA)
532 * @strength: DVBv5 API statistics: Signal Strength
533 * @cnr: DVBv5 API statistics: Signal to Noise ratio of the
535 * @pre_bit_error: DVBv5 API statistics: pre-Viterbi bit error count
536 * @pre_bit_count: DVBv5 API statistics: pre-Viterbi bit count
537 * @post_bit_error: DVBv5 API statistics: post-Viterbi bit error count
538 * @post_bit_count: DVBv5 API statistics: post-Viterbi bit count
539 * @block_error: DVBv5 API statistics: block error count
540 * @block_count: DVBv5 API statistics: block count
542 * NOTE: derivated statistics like Uncorrected Error blocks (UCE) are
543 * calculated on userspace.
545 * Only a subset of the properties are needed for a given delivery system.
546 * For more info, consult the media_api.html with the documentation of the
549 struct dtv_frontend_properties {
551 enum fe_modulation modulation;
553 enum fe_sec_voltage voltage;
554 enum fe_sec_tone_mode sectone;
555 enum fe_spectral_inversion inversion;
556 enum fe_code_rate fec_inner;
557 enum fe_transmit_mode transmission_mode;
558 u32 bandwidth_hz; /* 0 = AUTO */
559 enum fe_guard_interval guard_interval;
560 enum fe_hierarchy hierarchy;
562 enum fe_code_rate code_rate_HP;
563 enum fe_code_rate code_rate_LP;
566 enum fe_rolloff rolloff;
568 enum fe_delivery_system delivery_system;
570 enum fe_interleaving interleaving;
572 /* ISDB-T specifics */
573 u8 isdbt_partial_reception;
575 u8 isdbt_sb_subchannel;
576 u32 isdbt_sb_segment_idx;
577 u32 isdbt_sb_segment_count;
578 u8 isdbt_layer_enabled;
581 enum fe_code_rate fec;
582 enum fe_modulation modulation;
586 /* Multistream specifics */
589 /* ATSC-MH specifics */
597 u8 atscmh_rs_frame_mode;
598 u8 atscmh_rs_frame_ensemble;
599 u8 atscmh_rs_code_mode_pri;
600 u8 atscmh_rs_code_mode_sec;
601 u8 atscmh_sccc_block_mode;
602 u8 atscmh_sccc_code_mode_a;
603 u8 atscmh_sccc_code_mode_b;
604 u8 atscmh_sccc_code_mode_c;
605 u8 atscmh_sccc_code_mode_d;
609 /* statistics data */
610 struct dtv_fe_stats strength;
611 struct dtv_fe_stats cnr;
612 struct dtv_fe_stats pre_bit_error;
613 struct dtv_fe_stats pre_bit_count;
614 struct dtv_fe_stats post_bit_error;
615 struct dtv_fe_stats post_bit_count;
616 struct dtv_fe_stats block_error;
617 struct dtv_fe_stats block_count;
620 #define DVB_FE_NO_EXIT 0
621 #define DVB_FE_NORMAL_EXIT 1
622 #define DVB_FE_DEVICE_REMOVED 2
623 #define DVB_FE_DEVICE_RESUME 3
626 * struct dvb_frontend - Frontend structure to be used on drivers.
628 * @ops: embedded struct dvb_frontend_ops
629 * @dvb: pointer to struct dvb_adapter
630 * @demodulator_priv: demod private data
631 * @tuner_priv: tuner private data
632 * @frontend_priv: frontend private data
633 * @sec_priv: SEC private data
634 * @analog_demod_priv: Analog demod private data
635 * @dtv_property_cache: embedded struct dtv_frontend_properties
636 * @callback: callback function used on some drivers to call
637 * either the tuner or the demodulator.
639 * @exit: Used to inform the DVB core that the frontend
640 * thread should exit (usually, means that the hardware
644 struct dvb_frontend {
645 struct dvb_frontend_ops ops;
646 struct dvb_adapter *dvb;
647 void *demodulator_priv;
651 void *analog_demod_priv;
652 struct dtv_frontend_properties dtv_property_cache;
653 #define DVB_FRONTEND_COMPONENT_TUNER 0
654 #define DVB_FRONTEND_COMPONENT_DEMOD 1
655 int (*callback)(void *adapter_priv, int component, int cmd, int arg);
661 * dvb_register_frontend() - Registers a DVB frontend at the adapter
663 * @dvb: pointer to the dvb adapter
664 * @fe: pointer to the frontend struct
666 * Allocate and initialize the private data needed by the frontend core to
667 * manage the frontend and calls dvb_register_device() to register a new
668 * frontend. It also cleans the property cache that stores the frontend
669 * parameters and selects the first available delivery system.
671 int dvb_register_frontend(struct dvb_adapter *dvb,
672 struct dvb_frontend *fe);
675 * dvb_unregister_frontend() - Unregisters a DVB frontend
677 * @fe: pointer to the frontend struct
679 * Stops the frontend kthread, calls dvb_unregister_device() and frees the
680 * private frontend data allocated by dvb_register_frontend().
682 * NOTE: This function doesn't frees the memory allocated by the demod,
683 * by the SEC driver and by the tuner. In order to free it, an explicit call to
684 * dvb_frontend_detach() is needed, after calling this function.
686 int dvb_unregister_frontend(struct dvb_frontend *fe);
689 * dvb_frontend_detach() - Detaches and frees frontend specific data
691 * @fe: pointer to the frontend struct
693 * This function should be called after dvb_unregister_frontend(). It
694 * calls the SEC, tuner and demod release functions:
695 * &dvb_frontend_ops.release_sec, &dvb_frontend_ops.tuner_ops.release,
696 * &dvb_frontend_ops.analog_ops.release and &dvb_frontend_ops.release.
698 * If the driver is compiled with CONFIG_MEDIA_ATTACH, it also decreases
699 * the module reference count, needed to allow userspace to remove the
700 * previously used DVB frontend modules.
702 void dvb_frontend_detach(struct dvb_frontend *fe);
705 * dvb_frontend_suspend() - Suspends a Digital TV frontend
707 * @fe: pointer to the frontend struct
709 * This function prepares a Digital TV frontend to suspend.
711 * In order to prepare the tuner to suspend, if
712 * &dvb_frontend_ops.tuner_ops.suspend\(\) is available, it calls it. Otherwise,
713 * it will call &dvb_frontend_ops.tuner_ops.sleep\(\), if available.
715 * It will also call &dvb_frontend_ops.sleep\(\) to put the demod to suspend.
717 * The drivers should also call dvb_frontend_suspend\(\) as part of their
718 * handler for the &device_driver.suspend\(\).
720 int dvb_frontend_suspend(struct dvb_frontend *fe);
723 * dvb_frontend_resume() - Resumes a Digital TV frontend
725 * @fe: pointer to the frontend struct
727 * This function resumes the usual operation of the tuner after resume.
729 * In order to resume the frontend, it calls the demod &dvb_frontend_ops.init\(\).
731 * If &dvb_frontend_ops.tuner_ops.resume\(\) is available, It, it calls it.
732 * Otherwise,t will call &dvb_frontend_ops.tuner_ops.init\(\), if available.
734 * Once tuner and demods are resumed, it will enforce that the SEC voltage and
735 * tone are restored to their previous values and wake up the frontend's
736 * kthread in order to retune the frontend.
738 * The drivers should also call dvb_frontend_resume() as part of their
739 * handler for the &device_driver.resume\(\).
741 int dvb_frontend_resume(struct dvb_frontend *fe);
744 * dvb_frontend_reinitialise() - forces a reinitialisation at the frontend
746 * @fe: pointer to the frontend struct
748 * Calls &dvb_frontend_ops.init\(\) and &dvb_frontend_ops.tuner_ops.init\(\),
749 * and resets SEC tone and voltage (for Satellite systems).
751 * NOTE: Currently, this function is used only by one driver (budget-av).
752 * It seems to be due to address some special issue with that specific
755 void dvb_frontend_reinitialise(struct dvb_frontend *fe);
758 * dvb_frontend_sleep_until() - Sleep for the amount of time given by
761 * @waketime: pointer to a struct ktime_t
762 * @add_usec: time to sleep, in microseconds
764 * This function is used to measure the time required for the
765 * %FE_DISHNETWORK_SEND_LEGACY_CMD ioctl to work. It needs to be as precise
766 * as possible, as it affects the detection of the dish tone command at the
767 * satellite subsystem.
769 * Its used internally by the DVB frontend core, in order to emulate
770 * %FE_DISHNETWORK_SEND_LEGACY_CMD using the &dvb_frontend_ops.set_voltage\(\)
773 * NOTE: it should not be used at the drivers, as the emulation for the
774 * legacy callback is provided by the Kernel. The only situation where this
775 * should be at the drivers is when there are some bugs at the hardware that
776 * would prevent the core emulation to work. On such cases, the driver would
777 * be writing a &dvb_frontend_ops.dishnetwork_send_legacy_command\(\) and
778 * calling this function directly.
780 void dvb_frontend_sleep_until(ktime_t *waketime, u32 add_usec);