dvb_frontend.h 31 KB

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