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