/*1* dvb_frontend.h2*3* The Digital TV Frontend kABI defines a driver-internal interface for4* registering low-level, hardware specific driver to a hardware independent5* frontend layer.6*7* Copyright (C) 2001 convergence integrated media GmbH8* Copyright (C) 2004 convergence GmbH9*10* Written by Ralph Metzler11* Overhauled by Holger Waechtler12* Kernel I2C stuff by Michael Hunold <[email protected]>13*14* This program is free software; you can redistribute it and/or15* modify it under the terms of the GNU Lesser General Public License16* as published by the Free Software Foundation; either version 2.117* of the License, or (at your option) any later version.18*19* This program is distributed in the hope that it will be useful,20* but WITHOUT ANY WARRANTY; without even the implied warranty of21* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the22* GNU General Public License for more details.23*2425* You should have received a copy of the GNU Lesser General Public License26* along with this program; if not, write to the Free Software27* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.28*29*/3031#ifndef _DVB_FRONTEND_H_32#define _DVB_FRONTEND_H_3334#include <linux/types.h>35#include <linux/sched.h>36#include <linux/ioctl.h>37#include <linux/i2c.h>38#include <linux/module.h>39#include <linux/errno.h>40#include <linux/delay.h>41#include <linux/mutex.h>42#include <linux/slab.h>43#include <linux/bitops.h>4445#include <linux/dvb/frontend.h>4647#include <media/dvbdev.h>4849/*50* Maximum number of Delivery systems per frontend. It51* should be smaller or equal to 3252*/53#define MAX_DELSYS 85455/* Helper definitions to be used at frontend drivers */56#define kHz 1000UL57#define MHz 1000000UL5859/**60* struct dvb_frontend_tune_settings - parameters to adjust frontend tuning61*62* @min_delay_ms: minimum delay for tuning, in ms63* @step_size: step size between two consecutive frequencies64* @max_drift: maximum drift65*66* NOTE: step_size is in Hz, for terrestrial/cable or kHz for satellite67*/68struct dvb_frontend_tune_settings {69int min_delay_ms;70int step_size;71int max_drift;72};7374struct dvb_frontend;7576/**77* struct dvb_tuner_info - Frontend name and min/max ranges/bandwidths78*79* @name: name of the Frontend80* @frequency_min_hz: minimal frequency supported in Hz81* @frequency_max_hz: maximum frequency supported in Hz82* @frequency_step_hz: frequency step in Hz83* @bandwidth_min: minimal frontend bandwidth supported84* @bandwidth_max: maximum frontend bandwidth supported85* @bandwidth_step: frontend bandwidth step86*/87struct dvb_tuner_info {88char name[128];8990u32 frequency_min_hz;91u32 frequency_max_hz;92u32 frequency_step_hz;9394u32 bandwidth_min;95u32 bandwidth_max;96u32 bandwidth_step;97};9899/**100* struct analog_parameters - Parameters to tune into an analog/radio channel101*102* @frequency: Frequency used by analog TV tuner (either in 62.5 kHz step,103* for TV, or 62.5 Hz for radio)104* @mode: Tuner mode, as defined on enum v4l2_tuner_type105* @audmode: Audio mode as defined for the rxsubchans field at videodev2.h,106* e. g. V4L2_TUNER_MODE_*107* @std: TV standard bitmap as defined at videodev2.h, e. g. V4L2_STD_*108*109* Hybrid tuners should be supported by both V4L2 and DVB APIs. This110* struct contains the data that are used by the V4L2 side. To avoid111* dependencies from V4L2 headers, all enums here are declared as integers.112*/113struct analog_parameters {114unsigned int frequency;115unsigned int mode;116unsigned int audmode;117u64 std;118};119120/**121* enum dvbfe_algo - defines the algorithm used to tune into a channel122*123* @DVBFE_ALGO_HW: Hardware Algorithm -124* Devices that support this algorithm do everything in hardware125* and no software support is needed to handle them.126* Requesting these devices to LOCK is the only thing required,127* device is supposed to do everything in the hardware.128*129* @DVBFE_ALGO_SW: Software Algorithm -130* These are dumb devices, that require software to do everything131*132* @DVBFE_ALGO_CUSTOM: Customizable Agorithm -133* Devices having this algorithm can be customized to have specific134* algorithms in the frontend driver, rather than simply doing a135* software zig-zag. In this case the zigzag maybe hardware assisted136* or it maybe completely done in hardware. In all cases, usage of137* this algorithm, in conjunction with the search and track138* callbacks, utilizes the driver specific algorithm.139*140* @DVBFE_ALGO_RECOVERY: Recovery Algorithm -141* These devices have AUTO recovery capabilities from LOCK failure142*/143enum dvbfe_algo {144DVBFE_ALGO_HW = BIT(0),145DVBFE_ALGO_SW = BIT(1),146DVBFE_ALGO_CUSTOM = BIT(2),147DVBFE_ALGO_RECOVERY = BIT(31),148};149150/**151* enum dvbfe_search - search callback possible return status152*153* @DVBFE_ALGO_SEARCH_SUCCESS:154* The frontend search algorithm completed and returned successfully155*156* @DVBFE_ALGO_SEARCH_ASLEEP:157* The frontend search algorithm is sleeping158*159* @DVBFE_ALGO_SEARCH_FAILED:160* The frontend search for a signal failed161*162* @DVBFE_ALGO_SEARCH_INVALID:163* The frontend search algorithm was probably supplied with invalid164* parameters and the search is an invalid one165*166* @DVBFE_ALGO_SEARCH_ERROR:167* The frontend search algorithm failed due to some error168*169* @DVBFE_ALGO_SEARCH_AGAIN:170* The frontend search algorithm was requested to search again171*/172enum dvbfe_search {173DVBFE_ALGO_SEARCH_SUCCESS = BIT(0),174DVBFE_ALGO_SEARCH_ASLEEP = BIT(1),175DVBFE_ALGO_SEARCH_FAILED = BIT(2),176DVBFE_ALGO_SEARCH_INVALID = BIT(3),177DVBFE_ALGO_SEARCH_AGAIN = BIT(4),178DVBFE_ALGO_SEARCH_ERROR = BIT(31),179};180181/**182* struct dvb_tuner_ops - Tuner information and callbacks183*184* @info: embedded &struct dvb_tuner_info with tuner properties185* @release: callback function called when frontend is detached.186* drivers should free any allocated memory.187* @init: callback function used to initialize the tuner device.188* @sleep: callback function used to put the tuner to sleep.189* @suspend: callback function used to inform that the Kernel will190* suspend.191* @resume: callback function used to inform that the Kernel is192* resuming from suspend.193* @set_params: callback function used to inform the tuner to tune194* into a digital TV channel. The properties to be used195* are stored at &struct dvb_frontend.dtv_property_cache.196* The tuner demod can change the parameters to reflect197* the changes needed for the channel to be tuned, and198* update statistics. This is the recommended way to set199* the tuner parameters and should be used on newer200* drivers.201* @set_analog_params: callback function used to tune into an analog TV202* channel on hybrid tuners. It passes @analog_parameters203* to the driver.204* @set_config: callback function used to send some tuner-specific205* parameters.206* @get_frequency: get the actual tuned frequency207* @get_bandwidth: get the bandwidth used by the low pass filters208* @get_if_frequency: get the Intermediate Frequency, in Hz. For baseband,209* should return 0.210* @get_status: returns the frontend lock status211* @get_rf_strength: returns the RF signal strength. Used mostly to support212* analog TV and radio. Digital TV should report, instead,213* via DVBv5 API (&struct dvb_frontend.dtv_property_cache).214* @get_afc: Used only by analog TV core. Reports the frequency215* drift due to AFC.216* @calc_regs: callback function used to pass register data settings217* for simple tuners. Shouldn't be used on newer drivers.218* @set_frequency: Set a new frequency. Shouldn't be used on newer drivers.219* @set_bandwidth: Set a new frequency. Shouldn't be used on newer drivers.220*221* NOTE: frequencies used on @get_frequency and @set_frequency are in Hz for222* terrestrial/cable or kHz for satellite.223*224*/225struct dvb_tuner_ops {226227struct dvb_tuner_info info;228229void (*release)(struct dvb_frontend *fe);230int (*init)(struct dvb_frontend *fe);231int (*sleep)(struct dvb_frontend *fe);232int (*suspend)(struct dvb_frontend *fe);233int (*resume)(struct dvb_frontend *fe);234235/* This is the recommended way to set the tuner */236int (*set_params)(struct dvb_frontend *fe);237int (*set_analog_params)(struct dvb_frontend *fe, struct analog_parameters *p);238239int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);240241int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency);242int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);243int (*get_if_frequency)(struct dvb_frontend *fe, u32 *frequency);244245#define TUNER_STATUS_LOCKED 1246#define TUNER_STATUS_STEREO 2247int (*get_status)(struct dvb_frontend *fe, u32 *status);248int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength);249int (*get_afc)(struct dvb_frontend *fe, s32 *afc);250251/*252* This is support for demods like the mt352 - fills out the supplied253* buffer with what to write.254*255* Don't use on newer drivers.256*/257int (*calc_regs)(struct dvb_frontend *fe, u8 *buf, int buf_len);258259/*260* These are provided separately from set_params in order to261* facilitate silicon tuners which require sophisticated tuning loops,262* controlling each parameter separately.263*264* Don't use on newer drivers.265*/266int (*set_frequency)(struct dvb_frontend *fe, u32 frequency);267int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);268};269270/**271* struct analog_demod_info - Information struct for analog TV part of the demod272*273* @name: Name of the analog TV demodulator274*/275struct analog_demod_info {276char *name;277};278279/**280* struct analog_demod_ops - Demodulation information and callbacks for281* analog TV and radio282*283* @info: pointer to struct analog_demod_info284* @set_params: callback function used to inform the demod to set the285* demodulator parameters needed to decode an analog or286* radio channel. The properties are passed via287* &struct analog_params.288* @has_signal: returns 0xffff if has signal, or 0 if it doesn't.289* @get_afc: Used only by analog TV core. Reports the frequency290* drift due to AFC.291* @tuner_status: callback function that returns tuner status bits, e. g.292* %TUNER_STATUS_LOCKED and %TUNER_STATUS_STEREO.293* @standby: set the tuner to standby mode.294* @release: callback function called when frontend is detached.295* drivers should free any allocated memory.296* @i2c_gate_ctrl: controls the I2C gate. Newer drivers should use I2C297* mux support instead.298* @set_config: callback function used to send some tuner-specific299* parameters.300*/301struct analog_demod_ops {302303struct analog_demod_info info;304305void (*set_params)(struct dvb_frontend *fe,306struct analog_parameters *params);307int (*has_signal)(struct dvb_frontend *fe, u16 *signal);308int (*get_afc)(struct dvb_frontend *fe, s32 *afc);309void (*tuner_status)(struct dvb_frontend *fe);310void (*standby)(struct dvb_frontend *fe);311void (*release)(struct dvb_frontend *fe);312int (*i2c_gate_ctrl)(struct dvb_frontend *fe, int enable);313314/** This is to allow setting tuner-specific configuration */315int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);316};317318struct dtv_frontend_properties;319320/**321* struct dvb_frontend_internal_info - Frontend properties and capabilities322*323* @name: Name of the frontend324* @frequency_min_hz: Minimal frequency supported by the frontend.325* @frequency_max_hz: Minimal frequency supported by the frontend.326* @frequency_stepsize_hz: All frequencies are multiple of this value.327* @frequency_tolerance_hz: Frequency tolerance.328* @symbol_rate_min: Minimal symbol rate, in bauds329* (for Cable/Satellite systems).330* @symbol_rate_max: Maximal symbol rate, in bauds331* (for Cable/Satellite systems).332* @symbol_rate_tolerance: Maximal symbol rate tolerance, in ppm333* (for Cable/Satellite systems).334* @caps: Capabilities supported by the frontend,335* as specified in &enum fe_caps.336*/337struct dvb_frontend_internal_info {338char name[128];339u32 frequency_min_hz;340u32 frequency_max_hz;341u32 frequency_stepsize_hz;342u32 frequency_tolerance_hz;343u32 symbol_rate_min;344u32 symbol_rate_max;345u32 symbol_rate_tolerance;346enum fe_caps caps;347};348349/**350* struct dvb_frontend_ops - Demodulation information and callbacks for351* ditialt TV352*353* @info: embedded &struct dvb_tuner_info with tuner properties354* @delsys: Delivery systems supported by the frontend355* @detach: callback function called when frontend is detached.356* drivers should clean up, but not yet free the &struct357* dvb_frontend allocation.358* @release: callback function called when frontend is ready to be359* freed.360* drivers should free any allocated memory.361* @release_sec: callback function requesting that the Satellite Equipment362* Control (SEC) driver to release and free any memory363* allocated by the driver.364* @init: callback function used to initialize the tuner device.365* @sleep: callback function used to put the tuner to sleep.366* @suspend: callback function used to inform that the Kernel will367* suspend.368* @resume: callback function used to inform that the Kernel is369* resuming from suspend.370* @write: callback function used by some demod legacy drivers to371* allow other drivers to write data into their registers.372* Should not be used on new drivers.373* @tune: callback function used by demod drivers that use374* @DVBFE_ALGO_HW to tune into a frequency.375* @get_frontend_algo: returns the desired hardware algorithm.376* @set_frontend: callback function used to inform the demod to set the377* parameters for demodulating a digital TV channel.378* The properties to be used are stored at &struct379* dvb_frontend.dtv_property_cache. The demod can change380* the parameters to reflect the changes needed for the381* channel to be decoded, and update statistics.382* @get_tune_settings: callback function383* @get_frontend: callback function used to inform the parameters384* actuall in use. The properties to be used are stored at385* &struct dvb_frontend.dtv_property_cache and update386* statistics. Please notice that it should not return387* an error code if the statistics are not available388* because the demog is not locked.389* @read_status: returns the locking status of the frontend.390* @read_ber: legacy callback function to return the bit error rate.391* Newer drivers should provide such info via DVBv5 API,392* e. g. @set_frontend;/@get_frontend, implementing this393* callback only if DVBv3 API compatibility is wanted.394* @read_signal_strength: legacy callback function to return the signal395* strength. Newer drivers should provide such info via396* DVBv5 API, e. g. @set_frontend/@get_frontend,397* implementing this callback only if DVBv3 API398* compatibility is wanted.399* @read_snr: legacy callback function to return the Signal/Noise400* rate. Newer drivers should provide such info via401* DVBv5 API, e. g. @set_frontend/@get_frontend,402* implementing this callback only if DVBv3 API403* compatibility is wanted.404* @read_ucblocks: legacy callback function to return the Uncorrected Error405* Blocks. Newer drivers should provide such info via406* DVBv5 API, e. g. @set_frontend/@get_frontend,407* implementing this callback only if DVBv3 API408* compatibility is wanted.409* @diseqc_reset_overload: callback function to implement the410* FE_DISEQC_RESET_OVERLOAD() ioctl (only Satellite)411* @diseqc_send_master_cmd: callback function to implement the412* FE_DISEQC_SEND_MASTER_CMD() ioctl (only Satellite).413* @diseqc_recv_slave_reply: callback function to implement the414* FE_DISEQC_RECV_SLAVE_REPLY() ioctl (only Satellite)415* @diseqc_send_burst: callback function to implement the416* FE_DISEQC_SEND_BURST() ioctl (only Satellite).417* @set_tone: callback function to implement the418* FE_SET_TONE() ioctl (only Satellite).419* @set_voltage: callback function to implement the420* FE_SET_VOLTAGE() ioctl (only Satellite).421* @enable_high_lnb_voltage: callback function to implement the422* FE_ENABLE_HIGH_LNB_VOLTAGE() ioctl (only Satellite).423* @dishnetwork_send_legacy_command: callback function to implement the424* FE_DISHNETWORK_SEND_LEGACY_CMD() ioctl (only Satellite).425* Drivers should not use this, except when the DVB426* core emulation fails to provide proper support (e.g.427* if @set_voltage takes more than 8ms to work), and428* when backward compatibility with this legacy API is429* required.430* @i2c_gate_ctrl: controls the I2C gate. Newer drivers should use I2C431* mux support instead.432* @ts_bus_ctrl: callback function used to take control of the TS bus.433* @set_lna: callback function to power on/off/auto the LNA.434* @search: callback function used on some custom algo search algos.435* @tuner_ops: pointer to &struct dvb_tuner_ops436* @analog_ops: pointer to &struct analog_demod_ops437*/438struct dvb_frontend_ops {439struct dvb_frontend_internal_info info;440441u8 delsys[MAX_DELSYS];442443void (*detach)(struct dvb_frontend *fe);444void (*release)(struct dvb_frontend* fe);445void (*release_sec)(struct dvb_frontend* fe);446447int (*init)(struct dvb_frontend* fe);448int (*sleep)(struct dvb_frontend* fe);449int (*suspend)(struct dvb_frontend *fe);450int (*resume)(struct dvb_frontend *fe);451452int (*write)(struct dvb_frontend* fe, const u8 buf[], int len);453454/* if this is set, it overrides the default swzigzag */455int (*tune)(struct dvb_frontend* fe,456bool re_tune,457unsigned int mode_flags,458unsigned int *delay,459enum fe_status *status);460461/* get frontend tuning algorithm from the module */462enum dvbfe_algo (*get_frontend_algo)(struct dvb_frontend *fe);463464/* these two are only used for the swzigzag code */465int (*set_frontend)(struct dvb_frontend *fe);466int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);467468int (*get_frontend)(struct dvb_frontend *fe,469struct dtv_frontend_properties *props);470471int (*read_status)(struct dvb_frontend *fe, enum fe_status *status);472int (*read_ber)(struct dvb_frontend* fe, u32* ber);473int (*read_signal_strength)(struct dvb_frontend* fe, u16* strength);474int (*read_snr)(struct dvb_frontend* fe, u16* snr);475int (*read_ucblocks)(struct dvb_frontend* fe, u32* ucblocks);476477int (*diseqc_reset_overload)(struct dvb_frontend* fe);478int (*diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);479int (*diseqc_recv_slave_reply)(struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply);480int (*diseqc_send_burst)(struct dvb_frontend *fe,481enum fe_sec_mini_cmd minicmd);482int (*set_tone)(struct dvb_frontend *fe, enum fe_sec_tone_mode tone);483int (*set_voltage)(struct dvb_frontend *fe,484enum fe_sec_voltage voltage);485int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg);486int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);487int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);488int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire);489int (*set_lna)(struct dvb_frontend *);490491/*492* These callbacks are for devices that implement their own493* tuning algorithms, rather than a simple swzigzag494*/495enum dvbfe_search (*search)(struct dvb_frontend *fe);496497struct dvb_tuner_ops tuner_ops;498struct analog_demod_ops analog_ops;499};500501#ifdef __DVB_CORE__502#define MAX_EVENT 8503504/* Used only internally at dvb_frontend.c */505struct dvb_fe_events {506struct dvb_frontend_event events[MAX_EVENT];507int eventw;508int eventr;509int overflow;510wait_queue_head_t wait_queue;511struct mutex mtx;512};513#endif514515/**516* struct dtv_frontend_properties - contains a list of properties that are517* specific to a digital TV standard.518*519* @frequency: frequency in Hz for terrestrial/cable or in kHz for520* Satellite521* @modulation: Frontend modulation type522* @voltage: SEC voltage (only Satellite)523* @sectone: SEC tone mode (only Satellite)524* @inversion: Spectral inversion525* @fec_inner: Forward error correction inner Code Rate526* @transmission_mode: Transmission Mode527* @bandwidth_hz: Bandwidth, in Hz. A zero value means that userspace528* wants to autodetect.529* @guard_interval: Guard Interval530* @hierarchy: Hierarchy531* @symbol_rate: Symbol Rate532* @code_rate_HP: high priority stream code rate533* @code_rate_LP: low priority stream code rate534* @pilot: Enable/disable/autodetect pilot tones535* @rolloff: Rolloff factor (alpha)536* @delivery_system: FE delivery system (e. g. digital TV standard)537* @interleaving: interleaving538* @isdbt_partial_reception: ISDB-T partial reception (only ISDB standard)539* @isdbt_sb_mode: ISDB-T Sound Broadcast (SB) mode (only ISDB standard)540* @isdbt_sb_subchannel: ISDB-T SB subchannel (only ISDB standard)541* @isdbt_sb_segment_idx: ISDB-T SB segment index (only ISDB standard)542* @isdbt_sb_segment_count: ISDB-T SB segment count (only ISDB standard)543* @isdbt_layer_enabled: ISDB Layer enabled (only ISDB standard)544* @layer: ISDB per-layer data (only ISDB standard)545* @layer.segment_count: Segment Count;546* @layer.fec: per layer code rate;547* @layer.modulation: per layer modulation;548* @layer.interleaving: per layer interleaving.549* @stream_id: If different than zero, enable substream filtering, if550* hardware supports (DVB-S2 and DVB-T2).551* @scrambling_sequence_index: Carries the index of the DVB-S2 physical layer552* scrambling sequence.553* @atscmh_fic_ver: Version number of the FIC (Fast Information Channel)554* signaling data (only ATSC-M/H)555* @atscmh_parade_id: Parade identification number (only ATSC-M/H)556* @atscmh_nog: Number of MH groups per MH subframe for a designated557* parade (only ATSC-M/H)558* @atscmh_tnog: Total number of MH groups including all MH groups559* belonging to all MH parades in one MH subframe560* (only ATSC-M/H)561* @atscmh_sgn: Start group number (only ATSC-M/H)562* @atscmh_prc: Parade repetition cycle (only ATSC-M/H)563* @atscmh_rs_frame_mode: Reed Solomon (RS) frame mode (only ATSC-M/H)564* @atscmh_rs_frame_ensemble: RS frame ensemble (only ATSC-M/H)565* @atscmh_rs_code_mode_pri: RS code mode pri (only ATSC-M/H)566* @atscmh_rs_code_mode_sec: RS code mode sec (only ATSC-M/H)567* @atscmh_sccc_block_mode: Series Concatenated Convolutional Code (SCCC)568* Block Mode (only ATSC-M/H)569* @atscmh_sccc_code_mode_a: SCCC code mode A (only ATSC-M/H)570* @atscmh_sccc_code_mode_b: SCCC code mode B (only ATSC-M/H)571* @atscmh_sccc_code_mode_c: SCCC code mode C (only ATSC-M/H)572* @atscmh_sccc_code_mode_d: SCCC code mode D (only ATSC-M/H)573* @lna: Power ON/OFF/AUTO the Linear Now-noise Amplifier (LNA)574* @strength: DVBv5 API statistics: Signal Strength575* @cnr: DVBv5 API statistics: Signal to Noise ratio of the576* (main) carrier577* @pre_bit_error: DVBv5 API statistics: pre-Viterbi bit error count578* @pre_bit_count: DVBv5 API statistics: pre-Viterbi bit count579* @post_bit_error: DVBv5 API statistics: post-Viterbi bit error count580* @post_bit_count: DVBv5 API statistics: post-Viterbi bit count581* @block_error: DVBv5 API statistics: block error count582* @block_count: DVBv5 API statistics: block count583*584* NOTE: derivated statistics like Uncorrected Error blocks (UCE) are585* calculated on userspace.586*587* Only a subset of the properties are needed for a given delivery system.588* For more info, consult the media_api.html with the documentation of the589* Userspace API.590*/591struct dtv_frontend_properties {592u32 frequency;593enum fe_modulation modulation;594595enum fe_sec_voltage voltage;596enum fe_sec_tone_mode sectone;597enum fe_spectral_inversion inversion;598enum fe_code_rate fec_inner;599enum fe_transmit_mode transmission_mode;600u32 bandwidth_hz; /* 0 = AUTO */601enum fe_guard_interval guard_interval;602enum fe_hierarchy hierarchy;603u32 symbol_rate;604enum fe_code_rate code_rate_HP;605enum fe_code_rate code_rate_LP;606607enum fe_pilot pilot;608enum fe_rolloff rolloff;609610enum fe_delivery_system delivery_system;611612enum fe_interleaving interleaving;613614/* ISDB-T specifics */615u8 isdbt_partial_reception;616u8 isdbt_sb_mode;617u8 isdbt_sb_subchannel;618u32 isdbt_sb_segment_idx;619u32 isdbt_sb_segment_count;620u8 isdbt_layer_enabled;621struct {622u8 segment_count;623enum fe_code_rate fec;624enum fe_modulation modulation;625u8 interleaving;626} layer[3];627628/* Multistream specifics */629u32 stream_id;630631/* Physical Layer Scrambling specifics */632u32 scrambling_sequence_index;633634/* ATSC-MH specifics */635u8 atscmh_fic_ver;636u8 atscmh_parade_id;637u8 atscmh_nog;638u8 atscmh_tnog;639u8 atscmh_sgn;640u8 atscmh_prc;641642u8 atscmh_rs_frame_mode;643u8 atscmh_rs_frame_ensemble;644u8 atscmh_rs_code_mode_pri;645u8 atscmh_rs_code_mode_sec;646u8 atscmh_sccc_block_mode;647u8 atscmh_sccc_code_mode_a;648u8 atscmh_sccc_code_mode_b;649u8 atscmh_sccc_code_mode_c;650u8 atscmh_sccc_code_mode_d;651652u32 lna;653654/* statistics data */655struct dtv_fe_stats strength;656struct dtv_fe_stats cnr;657struct dtv_fe_stats pre_bit_error;658struct dtv_fe_stats pre_bit_count;659struct dtv_fe_stats post_bit_error;660struct dtv_fe_stats post_bit_count;661struct dtv_fe_stats block_error;662struct dtv_fe_stats block_count;663};664665#define DVB_FE_NO_EXIT 0666#define DVB_FE_NORMAL_EXIT 1667#define DVB_FE_DEVICE_REMOVED 2668#define DVB_FE_DEVICE_RESUME 3669670/**671* struct dvb_frontend - Frontend structure to be used on drivers.672*673* @refcount: refcount to keep track of &struct dvb_frontend674* references675* @ops: embedded &struct dvb_frontend_ops676* @dvb: pointer to &struct dvb_adapter677* @demodulator_priv: demod private data678* @tuner_priv: tuner private data679* @frontend_priv: frontend private data680* @sec_priv: SEC private data681* @analog_demod_priv: Analog demod private data682* @dtv_property_cache: embedded &struct dtv_frontend_properties683* @callback: callback function used on some drivers to call684* either the tuner or the demodulator.685* @id: Frontend ID686* @exit: Used to inform the DVB core that the frontend687* thread should exit (usually, means that the hardware688* got disconnected.689*/690691struct dvb_frontend {692struct kref refcount;693struct dvb_frontend_ops ops;694struct dvb_adapter *dvb;695void *demodulator_priv;696void *tuner_priv;697void *frontend_priv;698void *sec_priv;699void *analog_demod_priv;700struct dtv_frontend_properties dtv_property_cache;701#define DVB_FRONTEND_COMPONENT_TUNER 0702#define DVB_FRONTEND_COMPONENT_DEMOD 1703int (*callback)(void *adapter_priv, int component, int cmd, int arg);704int id;705unsigned int exit;706};707708/**709* dvb_register_frontend() - Registers a DVB frontend at the adapter710*711* @dvb: pointer to &struct dvb_adapter712* @fe: pointer to &struct dvb_frontend713*714* Allocate and initialize the private data needed by the frontend core to715* manage the frontend and calls dvb_register_device() to register a new716* frontend. It also cleans the property cache that stores the frontend717* parameters and selects the first available delivery system.718*/719int dvb_register_frontend(struct dvb_adapter *dvb,720struct dvb_frontend *fe);721722/**723* dvb_unregister_frontend() - Unregisters a DVB frontend724*725* @fe: pointer to &struct dvb_frontend726*727* Stops the frontend kthread, calls dvb_unregister_device() and frees the728* private frontend data allocated by dvb_register_frontend().729*730* NOTE: This function doesn't frees the memory allocated by the demod,731* by the SEC driver and by the tuner. In order to free it, an explicit call to732* dvb_frontend_detach() is needed, after calling this function.733*/734int dvb_unregister_frontend(struct dvb_frontend *fe);735736/**737* dvb_frontend_detach() - Detaches and frees frontend specific data738*739* @fe: pointer to &struct dvb_frontend740*741* This function should be called after dvb_unregister_frontend(). It742* calls the SEC, tuner and demod release functions:743* &dvb_frontend_ops.release_sec, &dvb_frontend_ops.tuner_ops.release,744* &dvb_frontend_ops.analog_ops.release and &dvb_frontend_ops.release.745*746* If the driver is compiled with %CONFIG_MEDIA_ATTACH, it also decreases747* the module reference count, needed to allow userspace to remove the748* previously used DVB frontend modules.749*/750void dvb_frontend_detach(struct dvb_frontend *fe);751752/**753* dvb_frontend_suspend() - Suspends a Digital TV frontend754*755* @fe: pointer to &struct dvb_frontend756*757* This function prepares a Digital TV frontend to suspend.758*759* In order to prepare the tuner to suspend, if760* &dvb_frontend_ops.tuner_ops.suspend\(\) is available, it calls it. Otherwise,761* it will call &dvb_frontend_ops.tuner_ops.sleep\(\), if available.762*763* It will also call &dvb_frontend_ops.suspend\(\) to put the demod to suspend,764* if available. Otherwise it will call &dvb_frontend_ops.sleep\(\).765*766* The drivers should also call dvb_frontend_suspend\(\) as part of their767* handler for the &device_driver.suspend\(\).768*/769int dvb_frontend_suspend(struct dvb_frontend *fe);770771/**772* dvb_frontend_resume() - Resumes a Digital TV frontend773*774* @fe: pointer to &struct dvb_frontend775*776* This function resumes the usual operation of the tuner after resume.777*778* In order to resume the frontend, it calls the demod779* &dvb_frontend_ops.resume\(\) if available. Otherwise it calls demod780* &dvb_frontend_ops.init\(\).781*782* If &dvb_frontend_ops.tuner_ops.resume\(\) is available, It, it calls it.783* Otherwise,t will call &dvb_frontend_ops.tuner_ops.init\(\), if available.784*785* Once tuner and demods are resumed, it will enforce that the SEC voltage and786* tone are restored to their previous values and wake up the frontend's787* kthread in order to retune the frontend.788*789* The drivers should also call dvb_frontend_resume() as part of their790* handler for the &device_driver.resume\(\).791*/792int dvb_frontend_resume(struct dvb_frontend *fe);793794/**795* dvb_frontend_reinitialise() - forces a reinitialisation at the frontend796*797* @fe: pointer to &struct dvb_frontend798*799* Calls &dvb_frontend_ops.init\(\) and &dvb_frontend_ops.tuner_ops.init\(\),800* and resets SEC tone and voltage (for Satellite systems).801*802* NOTE: Currently, this function is used only by one driver (budget-av).803* It seems to be due to address some special issue with that specific804* frontend.805*/806void dvb_frontend_reinitialise(struct dvb_frontend *fe);807808/**809* dvb_frontend_sleep_until() - Sleep for the amount of time given by810* add_usec parameter811*812* @waketime: pointer to &struct ktime_t813* @add_usec: time to sleep, in microseconds814*815* This function is used to measure the time required for the816* FE_DISHNETWORK_SEND_LEGACY_CMD() ioctl to work. It needs to be as precise817* as possible, as it affects the detection of the dish tone command at the818* satellite subsystem.819*820* Its used internally by the DVB frontend core, in order to emulate821* FE_DISHNETWORK_SEND_LEGACY_CMD() using the &dvb_frontend_ops.set_voltage\(\)822* callback.823*824* NOTE: it should not be used at the drivers, as the emulation for the825* legacy callback is provided by the Kernel. The only situation where this826* should be at the drivers is when there are some bugs at the hardware that827* would prevent the core emulation to work. On such cases, the driver would828* be writing a &dvb_frontend_ops.dishnetwork_send_legacy_command\(\) and829* calling this function directly.830*/831void dvb_frontend_sleep_until(ktime_t *waketime, u32 add_usec);832833#endif834835836