dvb_frontend.h 30 KB

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