dvb_frontend.h 30 KB

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