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