dvb_frontend.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  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. * Maximum number of Delivery systems per frontend. It
  41. * should be smaller or equal to 32
  42. */
  43. #define MAX_DELSYS 8
  44. /**
  45. * struct dvb_frontend_tune_settings - parameters to adjust frontend tuning
  46. *
  47. * @min_delay_ms: minimum delay for tuning, in ms
  48. * @step_size: step size between two consecutive frequencies
  49. * @max_drift: maximum drift
  50. *
  51. * NOTE: step_size is in Hz, for terrestrial/cable or kHz for satellite
  52. */
  53. struct dvb_frontend_tune_settings {
  54. int min_delay_ms;
  55. int step_size;
  56. int max_drift;
  57. };
  58. struct dvb_frontend;
  59. /**
  60. * struct dvb_tuner_info - Frontend name and min/max ranges/bandwidths
  61. *
  62. * @name: name of the Frontend
  63. * @frequency_min: minimal frequency supported
  64. * @frequency_max: maximum frequency supported
  65. * @frequency_step: frequency step
  66. * @bandwidth_min: minimal frontend bandwidth supported
  67. * @bandwidth_max: maximum frontend bandwidth supported
  68. * @bandwidth_step: frontend bandwidth step
  69. *
  70. * NOTE: frequency parameters are in Hz, for terrestrial/cable or kHz for
  71. * satellite.
  72. */
  73. struct dvb_tuner_info {
  74. char name[128];
  75. u32 frequency_min;
  76. u32 frequency_max;
  77. u32 frequency_step;
  78. u32 bandwidth_min;
  79. u32 bandwidth_max;
  80. u32 bandwidth_step;
  81. };
  82. /**
  83. * struct analog_parameters - Parameters to tune into an analog/radio channel
  84. *
  85. * @frequency: Frequency used by analog TV tuner (either in 62.5 kHz step,
  86. * for TV, or 62.5 Hz for radio)
  87. * @mode: Tuner mode, as defined on enum v4l2_tuner_type
  88. * @audmode: Audio mode as defined for the rxsubchans field at videodev2.h,
  89. * e. g. V4L2_TUNER_MODE_*
  90. * @std: TV standard bitmap as defined at videodev2.h, e. g. V4L2_STD_*
  91. *
  92. * Hybrid tuners should be supported by both V4L2 and DVB APIs. This
  93. * struct contains the data that are used by the V4L2 side. To avoid
  94. * dependencies from V4L2 headers, all enums here are declared as integers.
  95. */
  96. struct analog_parameters {
  97. unsigned int frequency;
  98. unsigned int mode;
  99. unsigned int audmode;
  100. u64 std;
  101. };
  102. enum tuner_param {
  103. DVBFE_TUNER_FREQUENCY = (1 << 0),
  104. DVBFE_TUNER_TUNERSTEP = (1 << 1),
  105. DVBFE_TUNER_IFFREQ = (1 << 2),
  106. DVBFE_TUNER_BANDWIDTH = (1 << 3),
  107. DVBFE_TUNER_REFCLOCK = (1 << 4),
  108. DVBFE_TUNER_IQSENSE = (1 << 5),
  109. DVBFE_TUNER_DUMMY = (1 << 31)
  110. };
  111. /**
  112. * enum dvbfe_algo - defines the algorithm used to tune into a channel
  113. *
  114. * @DVBFE_ALGO_HW: Hardware Algorithm -
  115. * Devices that support this algorithm do everything in hardware
  116. * and no software support is needed to handle them.
  117. * Requesting these devices to LOCK is the only thing required,
  118. * device is supposed to do everything in the hardware.
  119. *
  120. * @DVBFE_ALGO_SW: Software Algorithm -
  121. * These are dumb devices, that require software to do everything
  122. *
  123. * @DVBFE_ALGO_CUSTOM: Customizable Agorithm -
  124. * Devices having this algorithm can be customized to have specific
  125. * algorithms in the frontend driver, rather than simply doing a
  126. * software zig-zag. In this case the zigzag maybe hardware assisted
  127. * or it maybe completely done in hardware. In all cases, usage of
  128. * this algorithm, in conjunction with the search and track
  129. * callbacks, utilizes the driver specific algorithm.
  130. *
  131. * @DVBFE_ALGO_RECOVERY: Recovery Algorithm -
  132. * These devices have AUTO recovery capabilities from LOCK failure
  133. */
  134. enum dvbfe_algo {
  135. DVBFE_ALGO_HW = (1 << 0),
  136. DVBFE_ALGO_SW = (1 << 1),
  137. DVBFE_ALGO_CUSTOM = (1 << 2),
  138. DVBFE_ALGO_RECOVERY = (1 << 31)
  139. };
  140. struct tuner_state {
  141. u32 frequency;
  142. u32 tunerstep;
  143. u32 ifreq;
  144. u32 bandwidth;
  145. u32 iqsense;
  146. u32 refclock;
  147. };
  148. /**
  149. * enum dvbfe_search - search callback possible return status
  150. *
  151. * @DVBFE_ALGO_SEARCH_SUCCESS:
  152. * The frontend search algorithm completed and returned successfully
  153. *
  154. * @DVBFE_ALGO_SEARCH_ASLEEP:
  155. * The frontend search algorithm is sleeping
  156. *
  157. * @DVBFE_ALGO_SEARCH_FAILED:
  158. * The frontend search for a signal failed
  159. *
  160. * @DVBFE_ALGO_SEARCH_INVALID:
  161. * The frontend search algorith was probably supplied with invalid
  162. * parameters and the search is an invalid one
  163. *
  164. * @DVBFE_ALGO_SEARCH_ERROR:
  165. * The frontend search algorithm failed due to some error
  166. *
  167. * @DVBFE_ALGO_SEARCH_AGAIN:
  168. * The frontend search algorithm was requested to search again
  169. */
  170. enum dvbfe_search {
  171. DVBFE_ALGO_SEARCH_SUCCESS = (1 << 0),
  172. DVBFE_ALGO_SEARCH_ASLEEP = (1 << 1),
  173. DVBFE_ALGO_SEARCH_FAILED = (1 << 2),
  174. DVBFE_ALGO_SEARCH_INVALID = (1 << 3),
  175. DVBFE_ALGO_SEARCH_AGAIN = (1 << 4),
  176. DVBFE_ALGO_SEARCH_ERROR = (1 << 31),
  177. };
  178. /**
  179. * struct dvb_tuner_ops - Tuner information and callbacks
  180. *
  181. * @info: embedded struct dvb_tuner_info with tuner properties
  182. * @release: callback function called when frontend is dettached.
  183. * drivers should free any allocated memory.
  184. * @init: callback function used to initialize the tuner device.
  185. * @sleep: callback function used to put the tuner to sleep.
  186. * @suspend: callback function used to inform that the Kernel will
  187. * suspend.
  188. * @resume: callback function used to inform that the Kernel is
  189. * resuming from suspend.
  190. * @set_params: callback function used to inform the tuner to tune
  191. * into a digital TV channel. The properties to be used
  192. * are stored at @dvb_frontend.dtv_property_cache;. The
  193. * tuner demod can change the parameters to reflect the
  194. * changes needed for the channel to be tuned, and
  195. * update statistics.
  196. * @set_analog_params: callback function used to tune into an analog TV
  197. * channel on hybrid tuners. It passes @analog_parameters;
  198. * to the driver.
  199. * @calc_regs: callback function used to pass register data settings
  200. * for simple tuners.
  201. * @set_config: callback function used to send some tuner-specific
  202. * parameters.
  203. * @get_frequency: get the actual tuned frequency
  204. * @get_bandwidth: get the bandwitdh used by the low pass filters
  205. * @get_if_frequency: get the Intermediate Frequency, in Hz. For baseband,
  206. * should return 0.
  207. * @get_status: returns the frontend lock status
  208. * @get_rf_strength: returns the RF signal strengh. Used mostly to support
  209. * analog TV and radio. Digital TV should report, instead,
  210. * via DVBv5 API (@dvb_frontend.dtv_property_cache;).
  211. * @get_afc: Used only by analog TV core. Reports the frequency
  212. * drift due to AFC.
  213. * @set_frequency: Set a new frequency. Please notice that using
  214. * set_params is preferred.
  215. * @set_bandwidth: Set a new frequency. Please notice that using
  216. * set_params is preferred.
  217. * @set_state: callback function used on some legacy drivers that
  218. * don't implement set_params in order to set properties.
  219. * Shouldn't be used on new drivers.
  220. * @get_state: callback function used to get properties by some
  221. * legacy drivers that don't implement set_params.
  222. * Shouldn't be used on new drivers.
  223. *
  224. * NOTE: frequencies used on get_frequency and set_frequency are in Hz for
  225. * terrestrial/cable or kHz for satellite.
  226. *
  227. */
  228. struct dvb_tuner_ops {
  229. struct dvb_tuner_info info;
  230. int (*release)(struct dvb_frontend *fe);
  231. int (*init)(struct dvb_frontend *fe);
  232. int (*sleep)(struct dvb_frontend *fe);
  233. int (*suspend)(struct dvb_frontend *fe);
  234. int (*resume)(struct dvb_frontend *fe);
  235. /** This is for simple PLLs - set all parameters in one go. */
  236. int (*set_params)(struct dvb_frontend *fe);
  237. int (*set_analog_params)(struct dvb_frontend *fe, struct analog_parameters *p);
  238. /** This is support for demods like the mt352 - fills out the supplied buffer with what to write. */
  239. int (*calc_regs)(struct dvb_frontend *fe, u8 *buf, int buf_len);
  240. /** This is to allow setting tuner-specific configs */
  241. int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
  242. int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency);
  243. int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
  244. int (*get_if_frequency)(struct dvb_frontend *fe, u32 *frequency);
  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. /** These are provided separately from set_params in order to facilitate silicon
  251. * tuners which require sophisticated tuning loops, controlling each parameter separately. */
  252. int (*set_frequency)(struct dvb_frontend *fe, u32 frequency);
  253. int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
  254. /*
  255. * These are provided separately from set_params in order to facilitate silicon
  256. * tuners which require sophisticated tuning loops, controlling each parameter separately.
  257. */
  258. int (*set_state)(struct dvb_frontend *fe, enum tuner_param param, struct tuner_state *state);
  259. int (*get_state)(struct dvb_frontend *fe, enum tuner_param param, struct tuner_state *state);
  260. };
  261. /**
  262. * struct analog_demod_info - Information struct for analog TV part of the demod
  263. *
  264. * @name: Name of the analog TV demodulator
  265. */
  266. struct analog_demod_info {
  267. char *name;
  268. };
  269. /**
  270. * struct analog_demod_ops - Demodulation information and callbacks for
  271. * analog TV and radio
  272. *
  273. * @info: pointer to struct analog_demod_info
  274. * @set_params: callback function used to inform the demod to set the
  275. * demodulator parameters needed to decode an analog or
  276. * radio channel. The properties are passed via
  277. * struct @analog_params;.
  278. * @has_signal: returns 0xffff if has signal, or 0 if it doesn't.
  279. * @get_afc: Used only by analog TV core. Reports the frequency
  280. * drift due to AFC.
  281. * @tuner_status: callback function that returns tuner status bits, e. g.
  282. * TUNER_STATUS_LOCKED and TUNER_STATUS_STEREO.
  283. * @standby: set the tuner to standby mode.
  284. * @release: callback function called when frontend is dettached.
  285. * drivers should free any allocated memory.
  286. * @i2c_gate_ctrl: controls the I2C gate. Newer drivers should use I2C
  287. * mux support instead.
  288. * @set_config: callback function used to send some tuner-specific
  289. * parameters.
  290. */
  291. struct analog_demod_ops {
  292. struct analog_demod_info info;
  293. void (*set_params)(struct dvb_frontend *fe,
  294. struct analog_parameters *params);
  295. int (*has_signal)(struct dvb_frontend *fe, u16 *signal);
  296. int (*get_afc)(struct dvb_frontend *fe, s32 *afc);
  297. void (*tuner_status)(struct dvb_frontend *fe);
  298. void (*standby)(struct dvb_frontend *fe);
  299. void (*release)(struct dvb_frontend *fe);
  300. int (*i2c_gate_ctrl)(struct dvb_frontend *fe, int enable);
  301. /** This is to allow setting tuner-specific configuration */
  302. int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
  303. };
  304. struct dtv_frontend_properties;
  305. /**
  306. * struct dvb_frontend_ops - Demodulation information and callbacks for
  307. * ditialt TV
  308. *
  309. * @info: embedded struct dvb_tuner_info with tuner properties
  310. * @delsys: Delivery systems supported by the frontend
  311. * @release: callback function called when frontend is dettached.
  312. * drivers should free any allocated memory.
  313. * @release_sec: callback function requesting that the Satelite Equipment
  314. * Control (SEC) driver to release and free any memory
  315. * allocated by the driver.
  316. * @init: callback function used to initialize the tuner device.
  317. * @sleep: callback function used to put the tuner to sleep.
  318. * @write: callback function used by some demod legacy drivers to
  319. * allow other drivers to write data into their registers.
  320. * Should not be used on new drivers.
  321. * @tune: callback function used by demod drivers that use
  322. * @DVBFE_ALGO_HW; to tune into a frequency.
  323. * @get_frontend_algo: returns the desired hardware algorithm.
  324. * @set_frontend: callback function used to inform the demod to set the
  325. * parameters for demodulating a digital TV channel.
  326. * The properties to be used are stored at
  327. * @dvb_frontend.dtv_property_cache;. The demod can change
  328. * the parameters to reflect the changes needed for the
  329. * channel to be decoded, and update statistics.
  330. * @get_tune_settings: callback function
  331. * @get_frontend: callback function used to inform the parameters
  332. * actuall in use. The properties to be used are stored at
  333. * @dvb_frontend.dtv_property_cache; and update
  334. * statistics. Please notice that it should not return
  335. * an error code if the statistics are not available
  336. * because the demog is not locked.
  337. * @read_status: returns the locking status of the frontend.
  338. * @read_ber: legacy callback function to return the bit error rate.
  339. * Newer drivers should provide such info via DVBv5 API,
  340. * e. g. @set_frontend;/@get_frontend;, implementing this
  341. * callback only if DVBv3 API compatibility is wanted.
  342. * @read_signal_strength: legacy callback function to return the signal
  343. * strength. Newer drivers should provide such info via
  344. * DVBv5 API, e. g. @set_frontend;/@get_frontend;,
  345. * implementing this callback only if DVBv3 API
  346. * compatibility is wanted.
  347. * @read_snr: legacy callback function to return the Signal/Noise
  348. * rate. Newer drivers should provide such info via
  349. * DVBv5 API, e. g. @set_frontend;/@get_frontend;,
  350. * implementing this callback only if DVBv3 API
  351. * compatibility is wanted.
  352. * @read_ucblocks: legacy callback function to return the Uncorrected Error
  353. * Blocks. Newer drivers should provide such info via
  354. * DVBv5 API, e. g. @set_frontend;/@get_frontend;,
  355. * implementing this callback only if DVBv3 API
  356. * compatibility is wanted.
  357. * @diseqc_reset_overload: callback function to implement the
  358. * FE_DISEQC_RESET_OVERLOAD ioctl (only Satellite)
  359. * @diseqc_send_master_cmd: callback function to implement the
  360. * FE_DISEQC_SEND_MASTER_CMD ioctl (only Satellite).
  361. * @diseqc_recv_slave_reply: callback function to implement the
  362. * FE_DISEQC_RECV_SLAVE_REPLY ioctl (only Satellite)
  363. * @diseqc_send_burst: callback function to implement the
  364. * FE_DISEQC_SEND_BURST ioctl (only Satellite).
  365. * @set_tone: callback function to implement the
  366. * FE_SET_TONE ioctl (only Satellite).
  367. * @set_voltage: callback function to implement the
  368. * FE_SET_VOLTAGE ioctl (only Satellite).
  369. * @enable_high_lnb_voltage: callback function to implement the
  370. * FE_ENABLE_HIGH_LNB_VOLTAGE ioctl (only Satellite).
  371. * @dishnetwork_send_legacy_command: callback function to implement the
  372. * FE_DISHNETWORK_SEND_LEGACY_CMD ioctl (only Satellite).
  373. * @i2c_gate_ctrl: controls the I2C gate. Newer drivers should use I2C
  374. * mux support instead.
  375. * @ts_bus_ctrl: callback function used to take control of the TS bus.
  376. * @set_lna: callback function to power on/off/auto the LNA.
  377. * @search: callback function used on some custom algo search algos.
  378. * @tuner_ops: pointer to struct dvb_tuner_ops
  379. * @analog_ops: pointer to struct analog_demod_ops
  380. * @set_property: callback function to allow the frontend to validade
  381. * incoming properties. Should not be used on new drivers.
  382. * @get_property: callback function to allow the frontend to override
  383. * outcoming properties. Should not be used on new drivers.
  384. */
  385. struct dvb_frontend_ops {
  386. struct dvb_frontend_info info;
  387. u8 delsys[MAX_DELSYS];
  388. void (*release)(struct dvb_frontend* fe);
  389. void (*release_sec)(struct dvb_frontend* fe);
  390. int (*init)(struct dvb_frontend* fe);
  391. int (*sleep)(struct dvb_frontend* fe);
  392. int (*write)(struct dvb_frontend* fe, const u8 buf[], int len);
  393. /* if this is set, it overrides the default swzigzag */
  394. int (*tune)(struct dvb_frontend* fe,
  395. bool re_tune,
  396. unsigned int mode_flags,
  397. unsigned int *delay,
  398. enum fe_status *status);
  399. /* get frontend tuning algorithm from the module */
  400. enum dvbfe_algo (*get_frontend_algo)(struct dvb_frontend *fe);
  401. /* these two are only used for the swzigzag code */
  402. int (*set_frontend)(struct dvb_frontend *fe);
  403. int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);
  404. int (*get_frontend)(struct dvb_frontend *fe);
  405. int (*read_status)(struct dvb_frontend *fe, enum fe_status *status);
  406. int (*read_ber)(struct dvb_frontend* fe, u32* ber);
  407. int (*read_signal_strength)(struct dvb_frontend* fe, u16* strength);
  408. int (*read_snr)(struct dvb_frontend* fe, u16* snr);
  409. int (*read_ucblocks)(struct dvb_frontend* fe, u32* ucblocks);
  410. int (*diseqc_reset_overload)(struct dvb_frontend* fe);
  411. int (*diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);
  412. int (*diseqc_recv_slave_reply)(struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply);
  413. int (*diseqc_send_burst)(struct dvb_frontend *fe,
  414. enum fe_sec_mini_cmd minicmd);
  415. int (*set_tone)(struct dvb_frontend *fe, enum fe_sec_tone_mode tone);
  416. int (*set_voltage)(struct dvb_frontend *fe,
  417. enum fe_sec_voltage voltage);
  418. int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg);
  419. int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
  420. int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);
  421. int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire);
  422. int (*set_lna)(struct dvb_frontend *);
  423. /* These callbacks are for devices that implement their own
  424. * tuning algorithms, rather than a simple swzigzag
  425. */
  426. enum dvbfe_search (*search)(struct dvb_frontend *fe);
  427. struct dvb_tuner_ops tuner_ops;
  428. struct analog_demod_ops analog_ops;
  429. int (*set_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
  430. int (*get_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
  431. };
  432. #ifdef __DVB_CORE__
  433. #define MAX_EVENT 8
  434. /* Used only internally at dvb_frontend.c */
  435. struct dvb_fe_events {
  436. struct dvb_frontend_event events[MAX_EVENT];
  437. int eventw;
  438. int eventr;
  439. int overflow;
  440. wait_queue_head_t wait_queue;
  441. struct mutex mtx;
  442. };
  443. #endif
  444. /**
  445. * struct dtv_frontend_properties - contains a list of properties that are
  446. * specific to a digital TV standard.
  447. *
  448. * @frequency: frequency in Hz for terrestrial/cable or in kHz for
  449. * Satellite
  450. * @modulation: Frontend modulation type
  451. * @voltage: SEC voltage (only Satellite)
  452. * @sectone: SEC tone mode (only Satellite)
  453. * @inversion: Spectral inversion
  454. * @fec_inner: Forward error correction inner Code Rate
  455. * @transmission_mode: Transmission Mode
  456. * @bandwidth_hz: Bandwidth, in Hz. A zero value means that userspace
  457. * wants to autodetect.
  458. * @guard_interval: Guard Interval
  459. * @hierarchy: Hierarchy
  460. * @symbol_rate: Symbol Rate
  461. * @code_rate_HP: high priority stream code rate
  462. * @code_rate_LP: low priority stream code rate
  463. * @pilot: Enable/disable/autodetect pilot tones
  464. * @rolloff: Rolloff factor (alpha)
  465. * @delivery_system: FE delivery system (e. g. digital TV standard)
  466. * @interleaving: interleaving
  467. * @isdbt_partial_reception: ISDB-T partial reception (only ISDB standard)
  468. * @isdbt_sb_mode: ISDB-T Sound Broadcast (SB) mode (only ISDB standard)
  469. * @isdbt_sb_subchannel: ISDB-T SB subchannel (only ISDB standard)
  470. * @isdbt_sb_segment_idx: ISDB-T SB segment index (only ISDB standard)
  471. * @isdbt_sb_segment_count: ISDB-T SB segment count (only ISDB standard)
  472. * @isdbt_layer_enabled: ISDB Layer enabled (only ISDB standard)
  473. * @layer: ISDB per-layer data (only ISDB standard)
  474. * @layer.segment_count: Segment Count;
  475. * @layer.fec: per layer code rate;
  476. * @layer.modulation: per layer modulation;
  477. * @layer.interleaving: per layer interleaving.
  478. * @stream_id: If different than zero, enable substream filtering, if
  479. * hardware supports (DVB-S2 and DVB-T2).
  480. * @atscmh_fic_ver: Version number of the FIC (Fast Information Channel)
  481. * signaling data (only ATSC-M/H)
  482. * @atscmh_parade_id: Parade identification number (only ATSC-M/H)
  483. * @atscmh_nog: Number of MH groups per MH subframe for a designated
  484. * parade (only ATSC-M/H)
  485. * @atscmh_tnog: Total number of MH groups including all MH groups
  486. * belonging to all MH parades in one MH subframe
  487. * (only ATSC-M/H)
  488. * @atscmh_sgn: Start group number (only ATSC-M/H)
  489. * @atscmh_prc: Parade repetition cycle (only ATSC-M/H)
  490. * @atscmh_rs_frame_mode: Reed Solomon (RS) frame mode (only ATSC-M/H)
  491. * @atscmh_rs_frame_ensemble: RS frame ensemble (only ATSC-M/H)
  492. * @atscmh_rs_code_mode_pri: RS code mode pri (only ATSC-M/H)
  493. * @atscmh_rs_code_mode_sec: RS code mode sec (only ATSC-M/H)
  494. * @atscmh_sccc_block_mode: Series Concatenated Convolutional Code (SCCC)
  495. * Block Mode (only ATSC-M/H)
  496. * @atscmh_sccc_code_mode_a: SCCC code mode A (only ATSC-M/H)
  497. * @atscmh_sccc_code_mode_b: SCCC code mode B (only ATSC-M/H)
  498. * @atscmh_sccc_code_mode_c: SCCC code mode C (only ATSC-M/H)
  499. * @atscmh_sccc_code_mode_d: SCCC code mode D (only ATSC-M/H)
  500. * @lna: Power ON/OFF/AUTO the Linear Now-noise Amplifier (LNA)
  501. * @strength: DVBv5 API statistics: Signal Strength
  502. * @cnr: DVBv5 API statistics: Signal to Noise ratio of the
  503. * (main) carrier
  504. * @pre_bit_error: DVBv5 API statistics: pre-Viterbi bit error count
  505. * @pre_bit_count: DVBv5 API statistics: pre-Viterbi bit count
  506. * @post_bit_error: DVBv5 API statistics: post-Viterbi bit error count
  507. * @post_bit_count: DVBv5 API statistics: post-Viterbi bit count
  508. * @block_error: DVBv5 API statistics: block error count
  509. * @block_count: DVBv5 API statistics: block count
  510. *
  511. * NOTE: derivated statistics like Uncorrected Error blocks (UCE) are
  512. * calculated on userspace.
  513. *
  514. * Only a subset of the properties are needed for a given delivery system.
  515. * For more info, consult the media_api.html with the documentation of the
  516. * Userspace API.
  517. */
  518. struct dtv_frontend_properties {
  519. u32 frequency;
  520. enum fe_modulation modulation;
  521. enum fe_sec_voltage voltage;
  522. enum fe_sec_tone_mode sectone;
  523. enum fe_spectral_inversion inversion;
  524. enum fe_code_rate fec_inner;
  525. enum fe_transmit_mode transmission_mode;
  526. u32 bandwidth_hz; /* 0 = AUTO */
  527. enum fe_guard_interval guard_interval;
  528. enum fe_hierarchy hierarchy;
  529. u32 symbol_rate;
  530. enum fe_code_rate code_rate_HP;
  531. enum fe_code_rate code_rate_LP;
  532. enum fe_pilot pilot;
  533. enum fe_rolloff rolloff;
  534. enum fe_delivery_system delivery_system;
  535. enum fe_interleaving interleaving;
  536. /* ISDB-T specifics */
  537. u8 isdbt_partial_reception;
  538. u8 isdbt_sb_mode;
  539. u8 isdbt_sb_subchannel;
  540. u32 isdbt_sb_segment_idx;
  541. u32 isdbt_sb_segment_count;
  542. u8 isdbt_layer_enabled;
  543. struct {
  544. u8 segment_count;
  545. enum fe_code_rate fec;
  546. enum fe_modulation modulation;
  547. u8 interleaving;
  548. } layer[3];
  549. /* Multistream specifics */
  550. u32 stream_id;
  551. /* ATSC-MH specifics */
  552. u8 atscmh_fic_ver;
  553. u8 atscmh_parade_id;
  554. u8 atscmh_nog;
  555. u8 atscmh_tnog;
  556. u8 atscmh_sgn;
  557. u8 atscmh_prc;
  558. u8 atscmh_rs_frame_mode;
  559. u8 atscmh_rs_frame_ensemble;
  560. u8 atscmh_rs_code_mode_pri;
  561. u8 atscmh_rs_code_mode_sec;
  562. u8 atscmh_sccc_block_mode;
  563. u8 atscmh_sccc_code_mode_a;
  564. u8 atscmh_sccc_code_mode_b;
  565. u8 atscmh_sccc_code_mode_c;
  566. u8 atscmh_sccc_code_mode_d;
  567. u32 lna;
  568. /* statistics data */
  569. struct dtv_fe_stats strength;
  570. struct dtv_fe_stats cnr;
  571. struct dtv_fe_stats pre_bit_error;
  572. struct dtv_fe_stats pre_bit_count;
  573. struct dtv_fe_stats post_bit_error;
  574. struct dtv_fe_stats post_bit_count;
  575. struct dtv_fe_stats block_error;
  576. struct dtv_fe_stats block_count;
  577. /* private: */
  578. /* Cache State */
  579. u32 state;
  580. };
  581. #define DVB_FE_NO_EXIT 0
  582. #define DVB_FE_NORMAL_EXIT 1
  583. #define DVB_FE_DEVICE_REMOVED 2
  584. #define DVB_FE_DEVICE_RESUME 3
  585. /**
  586. * struct dvb_frontend - Frontend structure to be used on drivers.
  587. *
  588. * @ops: embedded struct dvb_frontend_ops
  589. * @dvb: pointer to struct dvb_adapter
  590. * @demodulator_priv: demod private data
  591. * @tuner_priv: tuner private data
  592. * @frontend_priv: frontend private data
  593. * @sec_priv: SEC private data
  594. * @analog_demod_priv: Analog demod private data
  595. * @dtv_property_cache: embedded struct dtv_frontend_properties
  596. * @callback: callback function used on some drivers to call
  597. * either the tuner or the demodulator.
  598. * @id: Frontend ID
  599. * @exit: Used to inform the DVB core that the frontend
  600. * thread should exit (usually, means that the hardware
  601. * got disconnected.
  602. */
  603. struct dvb_frontend {
  604. struct dvb_frontend_ops ops;
  605. struct dvb_adapter *dvb;
  606. void *demodulator_priv;
  607. void *tuner_priv;
  608. void *frontend_priv;
  609. void *sec_priv;
  610. void *analog_demod_priv;
  611. struct dtv_frontend_properties dtv_property_cache;
  612. #define DVB_FRONTEND_COMPONENT_TUNER 0
  613. #define DVB_FRONTEND_COMPONENT_DEMOD 1
  614. int (*callback)(void *adapter_priv, int component, int cmd, int arg);
  615. int id;
  616. unsigned int exit;
  617. };
  618. extern int dvb_register_frontend(struct dvb_adapter *dvb,
  619. struct dvb_frontend *fe);
  620. extern int dvb_unregister_frontend(struct dvb_frontend *fe);
  621. extern void dvb_frontend_detach(struct dvb_frontend *fe);
  622. extern void dvb_frontend_reinitialise(struct dvb_frontend *fe);
  623. extern int dvb_frontend_suspend(struct dvb_frontend *fe);
  624. extern int dvb_frontend_resume(struct dvb_frontend *fe);
  625. extern void dvb_frontend_sleep_until(ktime_t *waketime, u32 add_usec);
  626. #endif