dvb_frontend.h 29 KB

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