dvb_frontend.h 30 KB

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