dvb_frontend.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  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. This is the recommended way to set
  201. * the tuner parameters and should be used on newer
  202. * drivers.
  203. * @set_analog_params: callback function used to tune into an analog TV
  204. * channel on hybrid tuners. It passes @analog_parameters;
  205. * to the driver.
  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. * @calc_regs: callback function used to pass register data settings
  219. * for simple tuners. Shouldn't be used on newer drivers.
  220. * @set_frequency: Set a new frequency. Shouldn't be used on newer drivers.
  221. * @set_bandwidth: Set a new frequency. Shouldn't be used on newer drivers.
  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 the recomended way to set the tuner */
  235. int (*set_params)(struct dvb_frontend *fe);
  236. int (*set_analog_params)(struct dvb_frontend *fe, struct analog_parameters *p);
  237. int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
  238. int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency);
  239. int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
  240. int (*get_if_frequency)(struct dvb_frontend *fe, u32 *frequency);
  241. #define TUNER_STATUS_LOCKED 1
  242. #define TUNER_STATUS_STEREO 2
  243. int (*get_status)(struct dvb_frontend *fe, u32 *status);
  244. int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength);
  245. int (*get_afc)(struct dvb_frontend *fe, s32 *afc);
  246. /*
  247. * This is support for demods like the mt352 - fills out the supplied
  248. * buffer with what to write.
  249. *
  250. * Don't use on newer drivers.
  251. */
  252. int (*calc_regs)(struct dvb_frontend *fe, u8 *buf, int buf_len);
  253. /*
  254. * These are provided separately from set_params in order to
  255. * facilitate silicon tuners which require sophisticated tuning loops,
  256. * controlling each parameter separately.
  257. *
  258. * Don't use on newer drivers.
  259. */
  260. int (*set_frequency)(struct dvb_frontend *fe, u32 frequency);
  261. int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
  262. };
  263. /**
  264. * struct analog_demod_info - Information struct for analog TV part of the demod
  265. *
  266. * @name: Name of the analog TV demodulator
  267. */
  268. struct analog_demod_info {
  269. char *name;
  270. };
  271. /**
  272. * struct analog_demod_ops - Demodulation information and callbacks for
  273. * analog TV and radio
  274. *
  275. * @info: pointer to struct analog_demod_info
  276. * @set_params: callback function used to inform the demod to set the
  277. * demodulator parameters needed to decode an analog or
  278. * radio channel. The properties are passed via
  279. * struct @analog_params;.
  280. * @has_signal: returns 0xffff if has signal, or 0 if it doesn't.
  281. * @get_afc: Used only by analog TV core. Reports the frequency
  282. * drift due to AFC.
  283. * @tuner_status: callback function that returns tuner status bits, e. g.
  284. * TUNER_STATUS_LOCKED and TUNER_STATUS_STEREO.
  285. * @standby: set the tuner to standby mode.
  286. * @release: callback function called when frontend is dettached.
  287. * drivers should free any allocated memory.
  288. * @i2c_gate_ctrl: controls the I2C gate. Newer drivers should use I2C
  289. * mux support instead.
  290. * @set_config: callback function used to send some tuner-specific
  291. * parameters.
  292. */
  293. struct analog_demod_ops {
  294. struct analog_demod_info info;
  295. void (*set_params)(struct dvb_frontend *fe,
  296. struct analog_parameters *params);
  297. int (*has_signal)(struct dvb_frontend *fe, u16 *signal);
  298. int (*get_afc)(struct dvb_frontend *fe, s32 *afc);
  299. void (*tuner_status)(struct dvb_frontend *fe);
  300. void (*standby)(struct dvb_frontend *fe);
  301. void (*release)(struct dvb_frontend *fe);
  302. int (*i2c_gate_ctrl)(struct dvb_frontend *fe, int enable);
  303. /** This is to allow setting tuner-specific configuration */
  304. int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
  305. };
  306. struct dtv_frontend_properties;
  307. /**
  308. * struct dvb_frontend_ops - Demodulation information and callbacks for
  309. * ditialt TV
  310. *
  311. * @info: embedded struct dvb_tuner_info with tuner properties
  312. * @delsys: Delivery systems supported by the frontend
  313. * @release: callback function called when frontend is dettached.
  314. * drivers should free any allocated memory.
  315. * @release_sec: callback function requesting that the Satelite Equipment
  316. * Control (SEC) driver to release and free any memory
  317. * allocated by the driver.
  318. * @init: callback function used to initialize the tuner device.
  319. * @sleep: callback function used to put the tuner to sleep.
  320. * @write: callback function used by some demod legacy drivers to
  321. * allow other drivers to write data into their registers.
  322. * Should not be used on new drivers.
  323. * @tune: callback function used by demod drivers that use
  324. * @DVBFE_ALGO_HW; to tune into a frequency.
  325. * @get_frontend_algo: returns the desired hardware algorithm.
  326. * @set_frontend: callback function used to inform the demod to set the
  327. * parameters for demodulating a digital TV channel.
  328. * The properties to be used are stored at
  329. * @dvb_frontend.dtv_property_cache;. The demod can change
  330. * the parameters to reflect the changes needed for the
  331. * channel to be decoded, and update statistics.
  332. * @get_tune_settings: callback function
  333. * @get_frontend: callback function used to inform the parameters
  334. * actuall in use. The properties to be used are stored at
  335. * @dvb_frontend.dtv_property_cache; and update
  336. * statistics. Please notice that it should not return
  337. * an error code if the statistics are not available
  338. * because the demog is not locked.
  339. * @read_status: returns the locking status of the frontend.
  340. * @read_ber: legacy callback function to return the bit error rate.
  341. * Newer drivers should provide such info via DVBv5 API,
  342. * e. g. @set_frontend;/@get_frontend;, implementing this
  343. * callback only if DVBv3 API compatibility is wanted.
  344. * @read_signal_strength: legacy callback function to return the signal
  345. * strength. Newer drivers should provide such info via
  346. * DVBv5 API, e. g. @set_frontend;/@get_frontend;,
  347. * implementing this callback only if DVBv3 API
  348. * compatibility is wanted.
  349. * @read_snr: legacy callback function to return the Signal/Noise
  350. * rate. Newer drivers should provide such info via
  351. * DVBv5 API, e. g. @set_frontend;/@get_frontend;,
  352. * implementing this callback only if DVBv3 API
  353. * compatibility is wanted.
  354. * @read_ucblocks: legacy callback function to return the Uncorrected Error
  355. * Blocks. Newer drivers should provide such info via
  356. * DVBv5 API, e. g. @set_frontend;/@get_frontend;,
  357. * implementing this callback only if DVBv3 API
  358. * compatibility is wanted.
  359. * @diseqc_reset_overload: callback function to implement the
  360. * FE_DISEQC_RESET_OVERLOAD ioctl (only Satellite)
  361. * @diseqc_send_master_cmd: callback function to implement the
  362. * FE_DISEQC_SEND_MASTER_CMD ioctl (only Satellite).
  363. * @diseqc_recv_slave_reply: callback function to implement the
  364. * FE_DISEQC_RECV_SLAVE_REPLY ioctl (only Satellite)
  365. * @diseqc_send_burst: callback function to implement the
  366. * FE_DISEQC_SEND_BURST ioctl (only Satellite).
  367. * @set_tone: callback function to implement the
  368. * FE_SET_TONE ioctl (only Satellite).
  369. * @set_voltage: callback function to implement the
  370. * FE_SET_VOLTAGE ioctl (only Satellite).
  371. * @enable_high_lnb_voltage: callback function to implement the
  372. * FE_ENABLE_HIGH_LNB_VOLTAGE ioctl (only Satellite).
  373. * @dishnetwork_send_legacy_command: callback function to implement the
  374. * FE_DISHNETWORK_SEND_LEGACY_CMD ioctl (only Satellite).
  375. * Drivers should not use this, except when the DVB
  376. * core emulation fails to provide proper support (e.g.
  377. * if set_voltage() takes more than 8ms to work), and
  378. * when backward compatibility with this legacy API is
  379. * required.
  380. * @i2c_gate_ctrl: controls the I2C gate. Newer drivers should use I2C
  381. * mux support instead.
  382. * @ts_bus_ctrl: callback function used to take control of the TS bus.
  383. * @set_lna: callback function to power on/off/auto the LNA.
  384. * @search: callback function used on some custom algo search algos.
  385. * @tuner_ops: pointer to struct dvb_tuner_ops
  386. * @analog_ops: pointer to struct analog_demod_ops
  387. * @set_property: callback function to allow the frontend to validade
  388. * incoming properties. Should not be used on new drivers.
  389. * @get_property: callback function to allow the frontend to override
  390. * outcoming properties. Should not be used on new drivers.
  391. */
  392. struct dvb_frontend_ops {
  393. struct dvb_frontend_info info;
  394. u8 delsys[MAX_DELSYS];
  395. void (*release)(struct dvb_frontend* fe);
  396. void (*release_sec)(struct dvb_frontend* fe);
  397. int (*init)(struct dvb_frontend* fe);
  398. int (*sleep)(struct dvb_frontend* fe);
  399. int (*write)(struct dvb_frontend* fe, const u8 buf[], int len);
  400. /* if this is set, it overrides the default swzigzag */
  401. int (*tune)(struct dvb_frontend* fe,
  402. bool re_tune,
  403. unsigned int mode_flags,
  404. unsigned int *delay,
  405. enum fe_status *status);
  406. /* get frontend tuning algorithm from the module */
  407. enum dvbfe_algo (*get_frontend_algo)(struct dvb_frontend *fe);
  408. /* these two are only used for the swzigzag code */
  409. int (*set_frontend)(struct dvb_frontend *fe);
  410. int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);
  411. int (*get_frontend)(struct dvb_frontend *fe,
  412. struct dtv_frontend_properties *props);
  413. int (*read_status)(struct dvb_frontend *fe, enum fe_status *status);
  414. int (*read_ber)(struct dvb_frontend* fe, u32* ber);
  415. int (*read_signal_strength)(struct dvb_frontend* fe, u16* strength);
  416. int (*read_snr)(struct dvb_frontend* fe, u16* snr);
  417. int (*read_ucblocks)(struct dvb_frontend* fe, u32* ucblocks);
  418. int (*diseqc_reset_overload)(struct dvb_frontend* fe);
  419. int (*diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);
  420. int (*diseqc_recv_slave_reply)(struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply);
  421. int (*diseqc_send_burst)(struct dvb_frontend *fe,
  422. enum fe_sec_mini_cmd minicmd);
  423. int (*set_tone)(struct dvb_frontend *fe, enum fe_sec_tone_mode tone);
  424. int (*set_voltage)(struct dvb_frontend *fe,
  425. enum fe_sec_voltage voltage);
  426. int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg);
  427. int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
  428. int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);
  429. int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire);
  430. int (*set_lna)(struct dvb_frontend *);
  431. /*
  432. * These callbacks are for devices that implement their own
  433. * tuning algorithms, rather than a simple swzigzag
  434. */
  435. enum dvbfe_search (*search)(struct dvb_frontend *fe);
  436. struct dvb_tuner_ops tuner_ops;
  437. struct analog_demod_ops analog_ops;
  438. int (*set_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
  439. int (*get_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
  440. };
  441. #ifdef __DVB_CORE__
  442. #define MAX_EVENT 8
  443. /* Used only internally at dvb_frontend.c */
  444. struct dvb_fe_events {
  445. struct dvb_frontend_event events[MAX_EVENT];
  446. int eventw;
  447. int eventr;
  448. int overflow;
  449. wait_queue_head_t wait_queue;
  450. struct mutex mtx;
  451. };
  452. #endif
  453. /**
  454. * struct dtv_frontend_properties - contains a list of properties that are
  455. * specific to a digital TV standard.
  456. *
  457. * @frequency: frequency in Hz for terrestrial/cable or in kHz for
  458. * Satellite
  459. * @modulation: Frontend modulation type
  460. * @voltage: SEC voltage (only Satellite)
  461. * @sectone: SEC tone mode (only Satellite)
  462. * @inversion: Spectral inversion
  463. * @fec_inner: Forward error correction inner Code Rate
  464. * @transmission_mode: Transmission Mode
  465. * @bandwidth_hz: Bandwidth, in Hz. A zero value means that userspace
  466. * wants to autodetect.
  467. * @guard_interval: Guard Interval
  468. * @hierarchy: Hierarchy
  469. * @symbol_rate: Symbol Rate
  470. * @code_rate_HP: high priority stream code rate
  471. * @code_rate_LP: low priority stream code rate
  472. * @pilot: Enable/disable/autodetect pilot tones
  473. * @rolloff: Rolloff factor (alpha)
  474. * @delivery_system: FE delivery system (e. g. digital TV standard)
  475. * @interleaving: interleaving
  476. * @isdbt_partial_reception: ISDB-T partial reception (only ISDB standard)
  477. * @isdbt_sb_mode: ISDB-T Sound Broadcast (SB) mode (only ISDB standard)
  478. * @isdbt_sb_subchannel: ISDB-T SB subchannel (only ISDB standard)
  479. * @isdbt_sb_segment_idx: ISDB-T SB segment index (only ISDB standard)
  480. * @isdbt_sb_segment_count: ISDB-T SB segment count (only ISDB standard)
  481. * @isdbt_layer_enabled: ISDB Layer enabled (only ISDB standard)
  482. * @layer: ISDB per-layer data (only ISDB standard)
  483. * @layer.segment_count: Segment Count;
  484. * @layer.fec: per layer code rate;
  485. * @layer.modulation: per layer modulation;
  486. * @layer.interleaving: per layer interleaving.
  487. * @stream_id: If different than zero, enable substream filtering, if
  488. * hardware supports (DVB-S2 and DVB-T2).
  489. * @atscmh_fic_ver: Version number of the FIC (Fast Information Channel)
  490. * signaling data (only ATSC-M/H)
  491. * @atscmh_parade_id: Parade identification number (only ATSC-M/H)
  492. * @atscmh_nog: Number of MH groups per MH subframe for a designated
  493. * parade (only ATSC-M/H)
  494. * @atscmh_tnog: Total number of MH groups including all MH groups
  495. * belonging to all MH parades in one MH subframe
  496. * (only ATSC-M/H)
  497. * @atscmh_sgn: Start group number (only ATSC-M/H)
  498. * @atscmh_prc: Parade repetition cycle (only ATSC-M/H)
  499. * @atscmh_rs_frame_mode: Reed Solomon (RS) frame mode (only ATSC-M/H)
  500. * @atscmh_rs_frame_ensemble: RS frame ensemble (only ATSC-M/H)
  501. * @atscmh_rs_code_mode_pri: RS code mode pri (only ATSC-M/H)
  502. * @atscmh_rs_code_mode_sec: RS code mode sec (only ATSC-M/H)
  503. * @atscmh_sccc_block_mode: Series Concatenated Convolutional Code (SCCC)
  504. * Block Mode (only ATSC-M/H)
  505. * @atscmh_sccc_code_mode_a: SCCC code mode A (only ATSC-M/H)
  506. * @atscmh_sccc_code_mode_b: SCCC code mode B (only ATSC-M/H)
  507. * @atscmh_sccc_code_mode_c: SCCC code mode C (only ATSC-M/H)
  508. * @atscmh_sccc_code_mode_d: SCCC code mode D (only ATSC-M/H)
  509. * @lna: Power ON/OFF/AUTO the Linear Now-noise Amplifier (LNA)
  510. * @strength: DVBv5 API statistics: Signal Strength
  511. * @cnr: DVBv5 API statistics: Signal to Noise ratio of the
  512. * (main) carrier
  513. * @pre_bit_error: DVBv5 API statistics: pre-Viterbi bit error count
  514. * @pre_bit_count: DVBv5 API statistics: pre-Viterbi bit count
  515. * @post_bit_error: DVBv5 API statistics: post-Viterbi bit error count
  516. * @post_bit_count: DVBv5 API statistics: post-Viterbi bit count
  517. * @block_error: DVBv5 API statistics: block error count
  518. * @block_count: DVBv5 API statistics: block count
  519. *
  520. * NOTE: derivated statistics like Uncorrected Error blocks (UCE) are
  521. * calculated on userspace.
  522. *
  523. * Only a subset of the properties are needed for a given delivery system.
  524. * For more info, consult the media_api.html with the documentation of the
  525. * Userspace API.
  526. */
  527. struct dtv_frontend_properties {
  528. u32 frequency;
  529. enum fe_modulation modulation;
  530. enum fe_sec_voltage voltage;
  531. enum fe_sec_tone_mode sectone;
  532. enum fe_spectral_inversion inversion;
  533. enum fe_code_rate fec_inner;
  534. enum fe_transmit_mode transmission_mode;
  535. u32 bandwidth_hz; /* 0 = AUTO */
  536. enum fe_guard_interval guard_interval;
  537. enum fe_hierarchy hierarchy;
  538. u32 symbol_rate;
  539. enum fe_code_rate code_rate_HP;
  540. enum fe_code_rate code_rate_LP;
  541. enum fe_pilot pilot;
  542. enum fe_rolloff rolloff;
  543. enum fe_delivery_system delivery_system;
  544. enum fe_interleaving interleaving;
  545. /* ISDB-T specifics */
  546. u8 isdbt_partial_reception;
  547. u8 isdbt_sb_mode;
  548. u8 isdbt_sb_subchannel;
  549. u32 isdbt_sb_segment_idx;
  550. u32 isdbt_sb_segment_count;
  551. u8 isdbt_layer_enabled;
  552. struct {
  553. u8 segment_count;
  554. enum fe_code_rate fec;
  555. enum fe_modulation modulation;
  556. u8 interleaving;
  557. } layer[3];
  558. /* Multistream specifics */
  559. u32 stream_id;
  560. /* ATSC-MH specifics */
  561. u8 atscmh_fic_ver;
  562. u8 atscmh_parade_id;
  563. u8 atscmh_nog;
  564. u8 atscmh_tnog;
  565. u8 atscmh_sgn;
  566. u8 atscmh_prc;
  567. u8 atscmh_rs_frame_mode;
  568. u8 atscmh_rs_frame_ensemble;
  569. u8 atscmh_rs_code_mode_pri;
  570. u8 atscmh_rs_code_mode_sec;
  571. u8 atscmh_sccc_block_mode;
  572. u8 atscmh_sccc_code_mode_a;
  573. u8 atscmh_sccc_code_mode_b;
  574. u8 atscmh_sccc_code_mode_c;
  575. u8 atscmh_sccc_code_mode_d;
  576. u32 lna;
  577. /* statistics data */
  578. struct dtv_fe_stats strength;
  579. struct dtv_fe_stats cnr;
  580. struct dtv_fe_stats pre_bit_error;
  581. struct dtv_fe_stats pre_bit_count;
  582. struct dtv_fe_stats post_bit_error;
  583. struct dtv_fe_stats post_bit_count;
  584. struct dtv_fe_stats block_error;
  585. struct dtv_fe_stats block_count;
  586. /* private: */
  587. /* Cache State */
  588. u32 state;
  589. };
  590. #define DVB_FE_NO_EXIT 0
  591. #define DVB_FE_NORMAL_EXIT 1
  592. #define DVB_FE_DEVICE_REMOVED 2
  593. #define DVB_FE_DEVICE_RESUME 3
  594. /**
  595. * struct dvb_frontend - Frontend structure to be used on drivers.
  596. *
  597. * @ops: embedded struct dvb_frontend_ops
  598. * @dvb: pointer to struct dvb_adapter
  599. * @demodulator_priv: demod private data
  600. * @tuner_priv: tuner private data
  601. * @frontend_priv: frontend private data
  602. * @sec_priv: SEC private data
  603. * @analog_demod_priv: Analog demod private data
  604. * @dtv_property_cache: embedded struct dtv_frontend_properties
  605. * @callback: callback function used on some drivers to call
  606. * either the tuner or the demodulator.
  607. * @id: Frontend ID
  608. * @exit: Used to inform the DVB core that the frontend
  609. * thread should exit (usually, means that the hardware
  610. * got disconnected.
  611. */
  612. struct dvb_frontend {
  613. struct dvb_frontend_ops ops;
  614. struct dvb_adapter *dvb;
  615. void *demodulator_priv;
  616. void *tuner_priv;
  617. void *frontend_priv;
  618. void *sec_priv;
  619. void *analog_demod_priv;
  620. struct dtv_frontend_properties dtv_property_cache;
  621. #define DVB_FRONTEND_COMPONENT_TUNER 0
  622. #define DVB_FRONTEND_COMPONENT_DEMOD 1
  623. int (*callback)(void *adapter_priv, int component, int cmd, int arg);
  624. int id;
  625. unsigned int exit;
  626. };
  627. /**
  628. * dvb_register_frontend() - Registers a DVB frontend at the adapter
  629. *
  630. * @dvb: pointer to the dvb adapter
  631. * @fe: pointer to the frontend struct
  632. *
  633. * Allocate and initialize the private data needed by the frontend core to
  634. * manage the frontend and calls dvb_register_device() to register a new
  635. * frontend. It also cleans the property cache that stores the frontend
  636. * parameters and selects the first available delivery system.
  637. */
  638. int dvb_register_frontend(struct dvb_adapter *dvb,
  639. struct dvb_frontend *fe);
  640. /**
  641. * dvb_unregister_frontend() - Unregisters a DVB frontend
  642. *
  643. * @fe: pointer to the frontend struct
  644. *
  645. * Stops the frontend kthread, calls dvb_unregister_device() and frees the
  646. * private frontend data allocated by dvb_register_frontend().
  647. *
  648. * NOTE: This function doesn't frees the memory allocated by the demod,
  649. * by the SEC driver and by the tuner. In order to free it, an explicit call to
  650. * dvb_frontend_detach() is needed, after calling this function.
  651. */
  652. int dvb_unregister_frontend(struct dvb_frontend *fe);
  653. /**
  654. * dvb_frontend_detach() - Detaches and frees frontend specific data
  655. *
  656. * @fe: pointer to the frontend struct
  657. *
  658. * This function should be called after dvb_unregister_frontend(). It
  659. * calls the SEC, tuner and demod release functions:
  660. * &dvb_frontend_ops.release_sec, &dvb_frontend_ops.tuner_ops.release,
  661. * &dvb_frontend_ops.analog_ops.release and &dvb_frontend_ops.release.
  662. *
  663. * If the driver is compiled with CONFIG_MEDIA_ATTACH, it also decreases
  664. * the module reference count, needed to allow userspace to remove the
  665. * previously used DVB frontend modules.
  666. */
  667. void dvb_frontend_detach(struct dvb_frontend *fe);
  668. /**
  669. * dvb_frontend_suspend() - Suspends a Digital TV frontend
  670. *
  671. * @fe: pointer to the frontend struct
  672. *
  673. * This function prepares a Digital TV frontend to suspend.
  674. *
  675. * In order to prepare the tuner to suspend, if
  676. * &dvb_frontend_ops.tuner_ops.suspend() is available, it calls it. Otherwise,
  677. * it will call &dvb_frontend_ops.tuner_ops.sleep(), if available.
  678. *
  679. * It will also call &dvb_frontend_ops.sleep() to put the demod to suspend.
  680. *
  681. * The drivers should also call dvb_frontend_suspend() as part of their
  682. * handler for the &device_driver.suspend().
  683. */
  684. int dvb_frontend_suspend(struct dvb_frontend *fe);
  685. /**
  686. * dvb_frontend_resume() - Resumes a Digital TV frontend
  687. *
  688. * @fe: pointer to the frontend struct
  689. *
  690. * This function resumes the usual operation of the tuner after resume.
  691. *
  692. * In order to resume the frontend, it calls the demod &dvb_frontend_ops.init().
  693. *
  694. * If &dvb_frontend_ops.tuner_ops.resume() is available, It, it calls it.
  695. * Otherwise,t will call &dvb_frontend_ops.tuner_ops.init(), if available.
  696. *
  697. * Once tuner and demods are resumed, it will enforce that the SEC voltage and
  698. * tone are restored to their previous values and wake up the frontend's
  699. * kthread in order to retune the frontend.
  700. *
  701. * The drivers should also call dvb_frontend_resume() as part of their
  702. * handler for the &device_driver.resume().
  703. */
  704. int dvb_frontend_resume(struct dvb_frontend *fe);
  705. /**
  706. * dvb_frontend_reinitialise() - forces a reinitialisation at the frontend
  707. *
  708. * @fe: pointer to the frontend struct
  709. *
  710. * Calls &dvb_frontend_ops.init() and &dvb_frontend_ops.tuner_ops.init(),
  711. * and resets SEC tone and voltage (for Satellite systems).
  712. *
  713. * NOTE: Currently, this function is used only by one driver (budget-av).
  714. * It seems to be due to address some special issue with that specific
  715. * frontend.
  716. */
  717. void dvb_frontend_reinitialise(struct dvb_frontend *fe);
  718. /**
  719. * dvb_frontend_sleep_until() - Sleep for the amount of time given by
  720. * add_usec parameter
  721. *
  722. * @waketime: pointer to a struct ktime_t
  723. * @add_usec: time to sleep, in microseconds
  724. *
  725. * This function is used to measure the time required for the
  726. * %FE_DISHNETWORK_SEND_LEGACY_CMD ioctl to work. It needs to be as precise
  727. * as possible, as it affects the detection of the dish tone command at the
  728. * satellite subsystem.
  729. *
  730. * Its used internally by the DVB frontend core, in order to emulate
  731. * %FE_DISHNETWORK_SEND_LEGACY_CMD using the &dvb_frontend_ops.set_voltage()
  732. * callback.
  733. *
  734. * NOTE: it should not be used at the drivers, as the emulation for the
  735. * legacy callback is provided by the Kernel. The only situation where this
  736. * should be at the drivers is when there are some bugs at the hardware that
  737. * would prevent the core emulation to work. On such cases, the driver would
  738. * be writing a &dvb_frontend_ops.dishnetwork_send_legacy_command() and
  739. * calling this function directly.
  740. */
  741. void dvb_frontend_sleep_until(ktime_t *waketime, u32 add_usec);
  742. #endif