drx_driver.h 78 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343
  1. /*
  2. Copyright (c), 2004-2005,2007-2010 Trident Microsystems, Inc.
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright notice,
  7. this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright notice,
  9. this list of conditions and the following disclaimer in the documentation
  10. and/or other materials provided with the distribution.
  11. * Neither the name of Trident Microsystems nor Hauppauge Computer Works
  12. nor the names of its contributors may be used to endorse or promote
  13. products derived from this software without specific prior written
  14. permission.
  15. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  16. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  18. ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  19. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  20. CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  21. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  22. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  23. CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  25. POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #ifndef __DRXDRIVER_H__
  28. #define __DRXDRIVER_H__
  29. #include <linux/kernel.h>
  30. #include <linux/errno.h>
  31. #include <linux/firmware.h>
  32. #include <linux/i2c.h>
  33. /*
  34. * This structure contains the I2C address, the device ID and a user_data pointer.
  35. * The user_data pointer can be used for application specific purposes.
  36. */
  37. struct i2c_device_addr {
  38. u16 i2c_addr; /* The I2C address of the device. */
  39. u16 i2c_dev_id; /* The device identifier. */
  40. void *user_data; /* User data pointer */
  41. };
  42. /**
  43. * \def IS_I2C_10BIT( addr )
  44. * \brief Determine if I2C address 'addr' is a 10 bits address or not.
  45. * \param addr The I2C address.
  46. * \return int.
  47. * \retval 0 if address is not a 10 bits I2C address.
  48. * \retval 1 if address is a 10 bits I2C address.
  49. */
  50. #define IS_I2C_10BIT(addr) \
  51. (((addr) & 0xF8) == 0xF0)
  52. /*------------------------------------------------------------------------------
  53. Exported FUNCTIONS
  54. ------------------------------------------------------------------------------*/
  55. /**
  56. * \fn drxbsp_i2c_init()
  57. * \brief Initialize I2C communication module.
  58. * \return int Return status.
  59. * \retval 0 Initialization successful.
  60. * \retval -EIO Initialization failed.
  61. */
  62. int drxbsp_i2c_init(void);
  63. /**
  64. * \fn drxbsp_i2c_term()
  65. * \brief Terminate I2C communication module.
  66. * \return int Return status.
  67. * \retval 0 Termination successful.
  68. * \retval -EIO Termination failed.
  69. */
  70. int drxbsp_i2c_term(void);
  71. /**
  72. * \fn int drxbsp_i2c_write_read( struct i2c_device_addr *w_dev_addr,
  73. * u16 w_count,
  74. * u8 * wData,
  75. * struct i2c_device_addr *r_dev_addr,
  76. * u16 r_count,
  77. * u8 * r_data)
  78. * \brief Read and/or write count bytes from I2C bus, store them in data[].
  79. * \param w_dev_addr The device i2c address and the device ID to write to
  80. * \param w_count The number of bytes to write
  81. * \param wData The array to write the data to
  82. * \param r_dev_addr The device i2c address and the device ID to read from
  83. * \param r_count The number of bytes to read
  84. * \param r_data The array to read the data from
  85. * \return int Return status.
  86. * \retval 0 Succes.
  87. * \retval -EIO Failure.
  88. * \retval -EINVAL Parameter 'wcount' is not zero but parameter
  89. * 'wdata' contains NULL.
  90. * Idem for 'rcount' and 'rdata'.
  91. * Both w_dev_addr and r_dev_addr are NULL.
  92. *
  93. * This function must implement an atomic write and/or read action on the I2C bus
  94. * No other process may use the I2C bus when this function is executing.
  95. * The critical section of this function runs from and including the I2C
  96. * write, up to and including the I2C read action.
  97. *
  98. * The device ID can be useful if several devices share an I2C address.
  99. * It can be used to control a "switch" on the I2C bus to the correct device.
  100. */
  101. int drxbsp_i2c_write_read(struct i2c_device_addr *w_dev_addr,
  102. u16 w_count,
  103. u8 *wData,
  104. struct i2c_device_addr *r_dev_addr,
  105. u16 r_count, u8 *r_data);
  106. /**
  107. * \fn drxbsp_i2c_error_text()
  108. * \brief Returns a human readable error.
  109. * Counter part of numerical drx_i2c_error_g.
  110. *
  111. * \return char* Pointer to human readable error text.
  112. */
  113. char *drxbsp_i2c_error_text(void);
  114. /**
  115. * \var drx_i2c_error_g;
  116. * \brief I2C specific error codes, platform dependent.
  117. */
  118. extern int drx_i2c_error_g;
  119. #define TUNER_MODE_SUB0 0x0001 /* for sub-mode (e.g. RF-AGC setting) */
  120. #define TUNER_MODE_SUB1 0x0002 /* for sub-mode (e.g. RF-AGC setting) */
  121. #define TUNER_MODE_SUB2 0x0004 /* for sub-mode (e.g. RF-AGC setting) */
  122. #define TUNER_MODE_SUB3 0x0008 /* for sub-mode (e.g. RF-AGC setting) */
  123. #define TUNER_MODE_SUB4 0x0010 /* for sub-mode (e.g. RF-AGC setting) */
  124. #define TUNER_MODE_SUB5 0x0020 /* for sub-mode (e.g. RF-AGC setting) */
  125. #define TUNER_MODE_SUB6 0x0040 /* for sub-mode (e.g. RF-AGC setting) */
  126. #define TUNER_MODE_SUB7 0x0080 /* for sub-mode (e.g. RF-AGC setting) */
  127. #define TUNER_MODE_DIGITAL 0x0100 /* for digital channel (e.g. DVB-T) */
  128. #define TUNER_MODE_ANALOG 0x0200 /* for analog channel (e.g. PAL) */
  129. #define TUNER_MODE_SWITCH 0x0400 /* during channel switch & scanning */
  130. #define TUNER_MODE_LOCK 0x0800 /* after tuner has locked */
  131. #define TUNER_MODE_6MHZ 0x1000 /* for 6MHz bandwidth channels */
  132. #define TUNER_MODE_7MHZ 0x2000 /* for 7MHz bandwidth channels */
  133. #define TUNER_MODE_8MHZ 0x4000 /* for 8MHz bandwidth channels */
  134. #define TUNER_MODE_SUB_MAX 8
  135. #define TUNER_MODE_SUBALL (TUNER_MODE_SUB0 | TUNER_MODE_SUB1 | \
  136. TUNER_MODE_SUB2 | TUNER_MODE_SUB3 | \
  137. TUNER_MODE_SUB4 | TUNER_MODE_SUB5 | \
  138. TUNER_MODE_SUB6 | TUNER_MODE_SUB7)
  139. enum tuner_lock_status {
  140. TUNER_LOCKED,
  141. TUNER_NOT_LOCKED
  142. };
  143. struct tuner_common {
  144. char *name; /* Tuner brand & type name */
  145. s32 min_freq_rf; /* Lowest RF input frequency, in kHz */
  146. s32 max_freq_rf; /* Highest RF input frequency, in kHz */
  147. u8 sub_mode; /* Index to sub-mode in use */
  148. char ***sub_mode_descriptions; /* Pointer to description of sub-modes */
  149. u8 sub_modes; /* Number of available sub-modes */
  150. /* The following fields will be either 0, NULL or false and do not need
  151. initialisation */
  152. void *self_check; /* gives proof of initialization */
  153. bool programmed; /* only valid if self_check is OK */
  154. s32 r_ffrequency; /* only valid if programmed */
  155. s32 i_ffrequency; /* only valid if programmed */
  156. void *my_user_data; /* pointer to associated demod instance */
  157. u16 my_capabilities; /* value for storing application flags */
  158. };
  159. struct tuner_instance;
  160. typedef int(*tuner_open_func_t) (struct tuner_instance *tuner);
  161. typedef int(*tuner_close_func_t) (struct tuner_instance *tuner);
  162. typedef int(*tuner_set_frequency_func_t) (struct tuner_instance *tuner,
  163. u32 mode,
  164. s32
  165. frequency);
  166. typedef int(*tuner_get_frequency_func_t) (struct tuner_instance *tuner,
  167. u32 mode,
  168. s32 *
  169. r_ffrequency,
  170. s32 *
  171. i_ffrequency);
  172. typedef int(*tuner_lock_status_func_t) (struct tuner_instance *tuner,
  173. enum tuner_lock_status *
  174. lock_stat);
  175. typedef int(*tune_ri2c_write_read_func_t) (struct tuner_instance *tuner,
  176. struct i2c_device_addr *
  177. w_dev_addr, u16 w_count,
  178. u8 *wData,
  179. struct i2c_device_addr *
  180. r_dev_addr, u16 r_count,
  181. u8 *r_data);
  182. struct tuner_ops {
  183. tuner_open_func_t open_func;
  184. tuner_close_func_t close_func;
  185. tuner_set_frequency_func_t set_frequency_func;
  186. tuner_get_frequency_func_t get_frequency_func;
  187. tuner_lock_status_func_t lock_status_func;
  188. tune_ri2c_write_read_func_t i2c_write_read_func;
  189. };
  190. struct tuner_instance {
  191. struct i2c_device_addr my_i2c_dev_addr;
  192. struct tuner_common *my_common_attr;
  193. void *my_ext_attr;
  194. struct tuner_ops *my_funct;
  195. };
  196. int drxbsp_tuner_set_frequency(struct tuner_instance *tuner,
  197. u32 mode,
  198. s32 frequency);
  199. int drxbsp_tuner_get_frequency(struct tuner_instance *tuner,
  200. u32 mode,
  201. s32 *r_ffrequency,
  202. s32 *i_ffrequency);
  203. int drxbsp_tuner_default_i2c_write_read(struct tuner_instance *tuner,
  204. struct i2c_device_addr *w_dev_addr,
  205. u16 w_count,
  206. u8 *wData,
  207. struct i2c_device_addr *r_dev_addr,
  208. u16 r_count, u8 *r_data);
  209. /**************
  210. *
  211. * This section configures the DRX Data Access Protocols (DAPs).
  212. *
  213. **************/
  214. /**
  215. * \def DRXDAP_SINGLE_MASTER
  216. * \brief Enable I2C single or I2C multimaster mode on host.
  217. *
  218. * Set to 1 to enable single master mode
  219. * Set to 0 to enable multi master mode
  220. *
  221. * The actual DAP implementation may be restricted to only one of the modes.
  222. * A compiler warning or error will be generated if the DAP implementation
  223. * overides or cannot handle the mode defined below.
  224. *
  225. */
  226. #ifndef DRXDAP_SINGLE_MASTER
  227. #define DRXDAP_SINGLE_MASTER 1
  228. #endif
  229. /**
  230. * \def DRXDAP_MAX_WCHUNKSIZE
  231. * \brief Defines maximum chunksize of an i2c write action by host.
  232. *
  233. * This indicates the maximum size of data the I2C device driver is able to
  234. * write at a time. This includes I2C device address and register addressing.
  235. *
  236. * This maximum size may be restricted by the actual DAP implementation.
  237. * A compiler warning or error will be generated if the DAP implementation
  238. * overides or cannot handle the chunksize defined below.
  239. *
  240. * Beware that the DAP uses DRXDAP_MAX_WCHUNKSIZE to create a temporary data
  241. * buffer. Do not undefine or choose too large, unless your system is able to
  242. * handle a stack buffer of that size.
  243. *
  244. */
  245. #ifndef DRXDAP_MAX_WCHUNKSIZE
  246. #define DRXDAP_MAX_WCHUNKSIZE 60
  247. #endif
  248. /**
  249. * \def DRXDAP_MAX_RCHUNKSIZE
  250. * \brief Defines maximum chunksize of an i2c read action by host.
  251. *
  252. * This indicates the maximum size of data the I2C device driver is able to read
  253. * at a time. Minimum value is 2. Also, the read chunk size must be even.
  254. *
  255. * This maximum size may be restricted by the actual DAP implementation.
  256. * A compiler warning or error will be generated if the DAP implementation
  257. * overides or cannot handle the chunksize defined below.
  258. *
  259. */
  260. #ifndef DRXDAP_MAX_RCHUNKSIZE
  261. #define DRXDAP_MAX_RCHUNKSIZE 60
  262. #endif
  263. /**************
  264. *
  265. * This section describes drxdriver defines.
  266. *
  267. **************/
  268. /**
  269. * \def DRX_UNKNOWN
  270. * \brief Generic UNKNOWN value for DRX enumerated types.
  271. *
  272. * Used to indicate that the parameter value is unknown or not yet initalized.
  273. */
  274. #ifndef DRX_UNKNOWN
  275. #define DRX_UNKNOWN (254)
  276. #endif
  277. /**
  278. * \def DRX_AUTO
  279. * \brief Generic AUTO value for DRX enumerated types.
  280. *
  281. * Used to instruct the driver to automatically determine the value of the
  282. * parameter.
  283. */
  284. #ifndef DRX_AUTO
  285. #define DRX_AUTO (255)
  286. #endif
  287. /**************
  288. *
  289. * This section describes flag definitions for the device capbilities.
  290. *
  291. **************/
  292. /**
  293. * \brief LNA capability flag
  294. *
  295. * Device has a Low Noise Amplifier
  296. *
  297. */
  298. #define DRX_CAPABILITY_HAS_LNA (1UL << 0)
  299. /**
  300. * \brief OOB-RX capability flag
  301. *
  302. * Device has OOB-RX
  303. *
  304. */
  305. #define DRX_CAPABILITY_HAS_OOBRX (1UL << 1)
  306. /**
  307. * \brief ATV capability flag
  308. *
  309. * Device has ATV
  310. *
  311. */
  312. #define DRX_CAPABILITY_HAS_ATV (1UL << 2)
  313. /**
  314. * \brief DVB-T capability flag
  315. *
  316. * Device has DVB-T
  317. *
  318. */
  319. #define DRX_CAPABILITY_HAS_DVBT (1UL << 3)
  320. /**
  321. * \brief ITU-B capability flag
  322. *
  323. * Device has ITU-B
  324. *
  325. */
  326. #define DRX_CAPABILITY_HAS_ITUB (1UL << 4)
  327. /**
  328. * \brief Audio capability flag
  329. *
  330. * Device has Audio
  331. *
  332. */
  333. #define DRX_CAPABILITY_HAS_AUD (1UL << 5)
  334. /**
  335. * \brief SAW switch capability flag
  336. *
  337. * Device has SAW switch
  338. *
  339. */
  340. #define DRX_CAPABILITY_HAS_SAWSW (1UL << 6)
  341. /**
  342. * \brief GPIO1 capability flag
  343. *
  344. * Device has GPIO1
  345. *
  346. */
  347. #define DRX_CAPABILITY_HAS_GPIO1 (1UL << 7)
  348. /**
  349. * \brief GPIO2 capability flag
  350. *
  351. * Device has GPIO2
  352. *
  353. */
  354. #define DRX_CAPABILITY_HAS_GPIO2 (1UL << 8)
  355. /**
  356. * \brief IRQN capability flag
  357. *
  358. * Device has IRQN
  359. *
  360. */
  361. #define DRX_CAPABILITY_HAS_IRQN (1UL << 9)
  362. /**
  363. * \brief 8VSB capability flag
  364. *
  365. * Device has 8VSB
  366. *
  367. */
  368. #define DRX_CAPABILITY_HAS_8VSB (1UL << 10)
  369. /**
  370. * \brief SMA-TX capability flag
  371. *
  372. * Device has SMATX
  373. *
  374. */
  375. #define DRX_CAPABILITY_HAS_SMATX (1UL << 11)
  376. /**
  377. * \brief SMA-RX capability flag
  378. *
  379. * Device has SMARX
  380. *
  381. */
  382. #define DRX_CAPABILITY_HAS_SMARX (1UL << 12)
  383. /**
  384. * \brief ITU-A/C capability flag
  385. *
  386. * Device has ITU-A/C
  387. *
  388. */
  389. #define DRX_CAPABILITY_HAS_ITUAC (1UL << 13)
  390. /*-------------------------------------------------------------------------
  391. MACROS
  392. -------------------------------------------------------------------------*/
  393. /* Macros to stringify the version number */
  394. #define DRX_VERSIONSTRING(MAJOR, MINOR, PATCH) \
  395. DRX_VERSIONSTRING_HELP(MAJOR)"." \
  396. DRX_VERSIONSTRING_HELP(MINOR)"." \
  397. DRX_VERSIONSTRING_HELP(PATCH)
  398. #define DRX_VERSIONSTRING_HELP(NUM) #NUM
  399. /**
  400. * \brief Macro to create byte array elements from 16 bit integers.
  401. * This macro is used to create byte arrays for block writes.
  402. * Block writes speed up I2C traffic between host and demod.
  403. * The macro takes care of the required byte order in a 16 bits word.
  404. * x->lowbyte(x), highbyte(x)
  405. */
  406. #define DRX_16TO8(x) ((u8) (((u16)x) & 0xFF)), \
  407. ((u8)((((u16)x)>>8)&0xFF))
  408. /**
  409. * \brief Macro to sign extend signed 9 bit value to signed 16 bit value
  410. */
  411. #define DRX_S9TOS16(x) ((((u16)x)&0x100) ? ((s16)((u16)(x)|0xFF00)) : (x))
  412. /**
  413. * \brief Macro to sign extend signed 9 bit value to signed 16 bit value
  414. */
  415. #define DRX_S24TODRXFREQ(x) ((((u32) x) & 0x00800000UL) ? \
  416. ((s32) \
  417. (((u32) x) | 0xFF000000)) : \
  418. ((s32) x))
  419. /**
  420. * \brief Macro to convert 16 bit register value to a s32
  421. */
  422. #define DRX_U16TODRXFREQ(x) ((x & 0x8000) ? \
  423. ((s32) \
  424. (((u32) x) | 0xFFFF0000)) : \
  425. ((s32) x))
  426. /*-------------------------------------------------------------------------
  427. ENUM
  428. -------------------------------------------------------------------------*/
  429. /**
  430. * \enum enum drx_standard
  431. * \brief Modulation standards.
  432. */
  433. enum drx_standard {
  434. DRX_STANDARD_DVBT = 0, /**< Terrestrial DVB-T. */
  435. DRX_STANDARD_8VSB, /**< Terrestrial 8VSB. */
  436. DRX_STANDARD_NTSC, /**< Terrestrial\Cable analog NTSC. */
  437. DRX_STANDARD_PAL_SECAM_BG,
  438. /**< Terrestrial analog PAL/SECAM B/G */
  439. DRX_STANDARD_PAL_SECAM_DK,
  440. /**< Terrestrial analog PAL/SECAM D/K */
  441. DRX_STANDARD_PAL_SECAM_I,
  442. /**< Terrestrial analog PAL/SECAM I */
  443. DRX_STANDARD_PAL_SECAM_L,
  444. /**< Terrestrial analog PAL/SECAM L
  445. with negative modulation */
  446. DRX_STANDARD_PAL_SECAM_LP,
  447. /**< Terrestrial analog PAL/SECAM L
  448. with positive modulation */
  449. DRX_STANDARD_ITU_A, /**< Cable ITU ANNEX A. */
  450. DRX_STANDARD_ITU_B, /**< Cable ITU ANNEX B. */
  451. DRX_STANDARD_ITU_C, /**< Cable ITU ANNEX C. */
  452. DRX_STANDARD_ITU_D, /**< Cable ITU ANNEX D. */
  453. DRX_STANDARD_FM, /**< Terrestrial\Cable FM radio */
  454. DRX_STANDARD_DTMB, /**< Terrestrial DTMB standard (China)*/
  455. DRX_STANDARD_UNKNOWN = DRX_UNKNOWN,
  456. /**< Standard unknown. */
  457. DRX_STANDARD_AUTO = DRX_AUTO
  458. /**< Autodetect standard. */
  459. };
  460. /**
  461. * \enum enum drx_standard
  462. * \brief Modulation sub-standards.
  463. */
  464. enum drx_substandard {
  465. DRX_SUBSTANDARD_MAIN = 0, /**< Main subvariant of standard */
  466. DRX_SUBSTANDARD_ATV_BG_SCANDINAVIA,
  467. DRX_SUBSTANDARD_ATV_DK_POLAND,
  468. DRX_SUBSTANDARD_ATV_DK_CHINA,
  469. DRX_SUBSTANDARD_UNKNOWN = DRX_UNKNOWN,
  470. /**< Sub-standard unknown. */
  471. DRX_SUBSTANDARD_AUTO = DRX_AUTO
  472. /**< Auto (default) sub-standard */
  473. };
  474. /**
  475. * \enum enum drx_bandwidth
  476. * \brief Channel bandwidth or channel spacing.
  477. */
  478. enum drx_bandwidth {
  479. DRX_BANDWIDTH_8MHZ = 0, /**< Bandwidth 8 MHz. */
  480. DRX_BANDWIDTH_7MHZ, /**< Bandwidth 7 MHz. */
  481. DRX_BANDWIDTH_6MHZ, /**< Bandwidth 6 MHz. */
  482. DRX_BANDWIDTH_UNKNOWN = DRX_UNKNOWN,
  483. /**< Bandwidth unknown. */
  484. DRX_BANDWIDTH_AUTO = DRX_AUTO
  485. /**< Auto Set Bandwidth */
  486. };
  487. /**
  488. * \enum enum drx_mirror
  489. * \brief Indicate if channel spectrum is mirrored or not.
  490. */
  491. enum drx_mirror {
  492. DRX_MIRROR_NO = 0, /**< Spectrum is not mirrored. */
  493. DRX_MIRROR_YES, /**< Spectrum is mirrored. */
  494. DRX_MIRROR_UNKNOWN = DRX_UNKNOWN,
  495. /**< Unknown if spectrum is mirrored. */
  496. DRX_MIRROR_AUTO = DRX_AUTO
  497. /**< Autodetect if spectrum is mirrored. */
  498. };
  499. /**
  500. * \enum enum drx_modulation
  501. * \brief Constellation type of the channel.
  502. */
  503. enum drx_modulation {
  504. DRX_CONSTELLATION_BPSK = 0, /**< Modulation is BPSK. */
  505. DRX_CONSTELLATION_QPSK, /**< Constellation is QPSK. */
  506. DRX_CONSTELLATION_PSK8, /**< Constellation is PSK8. */
  507. DRX_CONSTELLATION_QAM16, /**< Constellation is QAM16. */
  508. DRX_CONSTELLATION_QAM32, /**< Constellation is QAM32. */
  509. DRX_CONSTELLATION_QAM64, /**< Constellation is QAM64. */
  510. DRX_CONSTELLATION_QAM128, /**< Constellation is QAM128. */
  511. DRX_CONSTELLATION_QAM256, /**< Constellation is QAM256. */
  512. DRX_CONSTELLATION_QAM512, /**< Constellation is QAM512. */
  513. DRX_CONSTELLATION_QAM1024, /**< Constellation is QAM1024. */
  514. DRX_CONSTELLATION_QPSK_NR, /**< Constellation is QPSK_NR */
  515. DRX_CONSTELLATION_UNKNOWN = DRX_UNKNOWN,
  516. /**< Constellation unknown. */
  517. DRX_CONSTELLATION_AUTO = DRX_AUTO
  518. /**< Autodetect constellation. */
  519. };
  520. /**
  521. * \enum enum drx_hierarchy
  522. * \brief Hierarchy of the channel.
  523. */
  524. enum drx_hierarchy {
  525. DRX_HIERARCHY_NONE = 0, /**< None hierarchical channel. */
  526. DRX_HIERARCHY_ALPHA1, /**< Hierarchical channel, alpha=1. */
  527. DRX_HIERARCHY_ALPHA2, /**< Hierarchical channel, alpha=2. */
  528. DRX_HIERARCHY_ALPHA4, /**< Hierarchical channel, alpha=4. */
  529. DRX_HIERARCHY_UNKNOWN = DRX_UNKNOWN,
  530. /**< Hierarchy unknown. */
  531. DRX_HIERARCHY_AUTO = DRX_AUTO
  532. /**< Autodetect hierarchy. */
  533. };
  534. /**
  535. * \enum enum drx_priority
  536. * \brief Channel priority in case of hierarchical transmission.
  537. */
  538. enum drx_priority {
  539. DRX_PRIORITY_LOW = 0, /**< Low priority channel. */
  540. DRX_PRIORITY_HIGH, /**< High priority channel. */
  541. DRX_PRIORITY_UNKNOWN = DRX_UNKNOWN
  542. /**< Priority unknown. */
  543. };
  544. /**
  545. * \enum enum drx_coderate
  546. * \brief Channel priority in case of hierarchical transmission.
  547. */
  548. enum drx_coderate {
  549. DRX_CODERATE_1DIV2 = 0, /**< Code rate 1/2nd. */
  550. DRX_CODERATE_2DIV3, /**< Code rate 2/3nd. */
  551. DRX_CODERATE_3DIV4, /**< Code rate 3/4nd. */
  552. DRX_CODERATE_5DIV6, /**< Code rate 5/6nd. */
  553. DRX_CODERATE_7DIV8, /**< Code rate 7/8nd. */
  554. DRX_CODERATE_UNKNOWN = DRX_UNKNOWN,
  555. /**< Code rate unknown. */
  556. DRX_CODERATE_AUTO = DRX_AUTO
  557. /**< Autodetect code rate. */
  558. };
  559. /**
  560. * \enum enum drx_guard
  561. * \brief Guard interval of a channel.
  562. */
  563. enum drx_guard {
  564. DRX_GUARD_1DIV32 = 0, /**< Guard interval 1/32nd. */
  565. DRX_GUARD_1DIV16, /**< Guard interval 1/16th. */
  566. DRX_GUARD_1DIV8, /**< Guard interval 1/8th. */
  567. DRX_GUARD_1DIV4, /**< Guard interval 1/4th. */
  568. DRX_GUARD_UNKNOWN = DRX_UNKNOWN,
  569. /**< Guard interval unknown. */
  570. DRX_GUARD_AUTO = DRX_AUTO
  571. /**< Autodetect guard interval. */
  572. };
  573. /**
  574. * \enum enum drx_fft_mode
  575. * \brief FFT mode.
  576. */
  577. enum drx_fft_mode {
  578. DRX_FFTMODE_2K = 0, /**< 2K FFT mode. */
  579. DRX_FFTMODE_4K, /**< 4K FFT mode. */
  580. DRX_FFTMODE_8K, /**< 8K FFT mode. */
  581. DRX_FFTMODE_UNKNOWN = DRX_UNKNOWN,
  582. /**< FFT mode unknown. */
  583. DRX_FFTMODE_AUTO = DRX_AUTO
  584. /**< Autodetect FFT mode. */
  585. };
  586. /**
  587. * \enum enum drx_classification
  588. * \brief Channel classification.
  589. */
  590. enum drx_classification {
  591. DRX_CLASSIFICATION_GAUSS = 0, /**< Gaussion noise. */
  592. DRX_CLASSIFICATION_HVY_GAUSS, /**< Heavy Gaussion noise. */
  593. DRX_CLASSIFICATION_COCHANNEL, /**< Co-channel. */
  594. DRX_CLASSIFICATION_STATIC, /**< Static echo. */
  595. DRX_CLASSIFICATION_MOVING, /**< Moving echo. */
  596. DRX_CLASSIFICATION_ZERODB, /**< Zero dB echo. */
  597. DRX_CLASSIFICATION_UNKNOWN = DRX_UNKNOWN,
  598. /**< Unknown classification */
  599. DRX_CLASSIFICATION_AUTO = DRX_AUTO
  600. /**< Autodetect classification. */
  601. };
  602. /**
  603. * /enum enum drx_interleave_mode
  604. * /brief Interleave modes
  605. */
  606. enum drx_interleave_mode {
  607. DRX_INTERLEAVEMODE_I128_J1 = 0,
  608. DRX_INTERLEAVEMODE_I128_J1_V2,
  609. DRX_INTERLEAVEMODE_I128_J2,
  610. DRX_INTERLEAVEMODE_I64_J2,
  611. DRX_INTERLEAVEMODE_I128_J3,
  612. DRX_INTERLEAVEMODE_I32_J4,
  613. DRX_INTERLEAVEMODE_I128_J4,
  614. DRX_INTERLEAVEMODE_I16_J8,
  615. DRX_INTERLEAVEMODE_I128_J5,
  616. DRX_INTERLEAVEMODE_I8_J16,
  617. DRX_INTERLEAVEMODE_I128_J6,
  618. DRX_INTERLEAVEMODE_RESERVED_11,
  619. DRX_INTERLEAVEMODE_I128_J7,
  620. DRX_INTERLEAVEMODE_RESERVED_13,
  621. DRX_INTERLEAVEMODE_I128_J8,
  622. DRX_INTERLEAVEMODE_RESERVED_15,
  623. DRX_INTERLEAVEMODE_I12_J17,
  624. DRX_INTERLEAVEMODE_I5_J4,
  625. DRX_INTERLEAVEMODE_B52_M240,
  626. DRX_INTERLEAVEMODE_B52_M720,
  627. DRX_INTERLEAVEMODE_B52_M48,
  628. DRX_INTERLEAVEMODE_B52_M0,
  629. DRX_INTERLEAVEMODE_UNKNOWN = DRX_UNKNOWN,
  630. /**< Unknown interleave mode */
  631. DRX_INTERLEAVEMODE_AUTO = DRX_AUTO
  632. /**< Autodetect interleave mode */
  633. };
  634. /**
  635. * \enum enum drx_carrier_mode
  636. * \brief Channel Carrier Mode.
  637. */
  638. enum drx_carrier_mode {
  639. DRX_CARRIER_MULTI = 0, /**< Multi carrier mode */
  640. DRX_CARRIER_SINGLE, /**< Single carrier mode */
  641. DRX_CARRIER_UNKNOWN = DRX_UNKNOWN,
  642. /**< Carrier mode unknown. */
  643. DRX_CARRIER_AUTO = DRX_AUTO /**< Autodetect carrier mode */
  644. };
  645. /**
  646. * \enum enum drx_frame_mode
  647. * \brief Channel Frame Mode.
  648. */
  649. enum drx_frame_mode {
  650. DRX_FRAMEMODE_420 = 0, /**< 420 with variable PN */
  651. DRX_FRAMEMODE_595, /**< 595 */
  652. DRX_FRAMEMODE_945, /**< 945 with variable PN */
  653. DRX_FRAMEMODE_420_FIXED_PN,
  654. /**< 420 with fixed PN */
  655. DRX_FRAMEMODE_945_FIXED_PN,
  656. /**< 945 with fixed PN */
  657. DRX_FRAMEMODE_UNKNOWN = DRX_UNKNOWN,
  658. /**< Frame mode unknown. */
  659. DRX_FRAMEMODE_AUTO = DRX_AUTO
  660. /**< Autodetect frame mode */
  661. };
  662. /**
  663. * \enum enum drx_tps_frame
  664. * \brief Frame number in current super-frame.
  665. */
  666. enum drx_tps_frame {
  667. DRX_TPS_FRAME1 = 0, /**< TPS frame 1. */
  668. DRX_TPS_FRAME2, /**< TPS frame 2. */
  669. DRX_TPS_FRAME3, /**< TPS frame 3. */
  670. DRX_TPS_FRAME4, /**< TPS frame 4. */
  671. DRX_TPS_FRAME_UNKNOWN = DRX_UNKNOWN
  672. /**< TPS frame unknown. */
  673. };
  674. /**
  675. * \enum enum drx_ldpc
  676. * \brief TPS LDPC .
  677. */
  678. enum drx_ldpc {
  679. DRX_LDPC_0_4 = 0, /**< LDPC 0.4 */
  680. DRX_LDPC_0_6, /**< LDPC 0.6 */
  681. DRX_LDPC_0_8, /**< LDPC 0.8 */
  682. DRX_LDPC_UNKNOWN = DRX_UNKNOWN,
  683. /**< LDPC unknown. */
  684. DRX_LDPC_AUTO = DRX_AUTO /**< Autodetect LDPC */
  685. };
  686. /**
  687. * \enum enum drx_pilot_mode
  688. * \brief Pilot modes in DTMB.
  689. */
  690. enum drx_pilot_mode {
  691. DRX_PILOT_ON = 0, /**< Pilot On */
  692. DRX_PILOT_OFF, /**< Pilot Off */
  693. DRX_PILOT_UNKNOWN = DRX_UNKNOWN,
  694. /**< Pilot unknown. */
  695. DRX_PILOT_AUTO = DRX_AUTO /**< Autodetect Pilot */
  696. };
  697. /**
  698. * enum drxu_code_action - indicate if firmware has to be uploaded or verified.
  699. * @UCODE_UPLOAD: Upload the microcode image to device
  700. * @UCODE_VERIFY: Compare microcode image with code on device
  701. */
  702. enum drxu_code_action {
  703. UCODE_UPLOAD,
  704. UCODE_VERIFY
  705. };
  706. /**
  707. * \enum enum drx_lock_status * \brief Used to reflect current lock status of demodulator.
  708. *
  709. * The generic lock states have device dependent semantics.
  710. DRX_NEVER_LOCK = 0,
  711. **< Device will never lock on this signal *
  712. DRX_NOT_LOCKED,
  713. **< Device has no lock at all *
  714. DRX_LOCK_STATE_1,
  715. **< Generic lock state *
  716. DRX_LOCK_STATE_2,
  717. **< Generic lock state *
  718. DRX_LOCK_STATE_3,
  719. **< Generic lock state *
  720. DRX_LOCK_STATE_4,
  721. **< Generic lock state *
  722. DRX_LOCK_STATE_5,
  723. **< Generic lock state *
  724. DRX_LOCK_STATE_6,
  725. **< Generic lock state *
  726. DRX_LOCK_STATE_7,
  727. **< Generic lock state *
  728. DRX_LOCK_STATE_8,
  729. **< Generic lock state *
  730. DRX_LOCK_STATE_9,
  731. **< Generic lock state *
  732. DRX_LOCKED **< Device is in lock *
  733. */
  734. enum drx_lock_status {
  735. DRX_NEVER_LOCK = 0,
  736. DRX_NOT_LOCKED,
  737. DRX_LOCK_STATE_1,
  738. DRX_LOCK_STATE_2,
  739. DRX_LOCK_STATE_3,
  740. DRX_LOCK_STATE_4,
  741. DRX_LOCK_STATE_5,
  742. DRX_LOCK_STATE_6,
  743. DRX_LOCK_STATE_7,
  744. DRX_LOCK_STATE_8,
  745. DRX_LOCK_STATE_9,
  746. DRX_LOCKED
  747. };
  748. /**
  749. * \enum enum drx_uio* \brief Used to address a User IO (UIO).
  750. */
  751. enum drx_uio {
  752. DRX_UIO1,
  753. DRX_UIO2,
  754. DRX_UIO3,
  755. DRX_UIO4,
  756. DRX_UIO5,
  757. DRX_UIO6,
  758. DRX_UIO7,
  759. DRX_UIO8,
  760. DRX_UIO9,
  761. DRX_UIO10,
  762. DRX_UIO11,
  763. DRX_UIO12,
  764. DRX_UIO13,
  765. DRX_UIO14,
  766. DRX_UIO15,
  767. DRX_UIO16,
  768. DRX_UIO17,
  769. DRX_UIO18,
  770. DRX_UIO19,
  771. DRX_UIO20,
  772. DRX_UIO21,
  773. DRX_UIO22,
  774. DRX_UIO23,
  775. DRX_UIO24,
  776. DRX_UIO25,
  777. DRX_UIO26,
  778. DRX_UIO27,
  779. DRX_UIO28,
  780. DRX_UIO29,
  781. DRX_UIO30,
  782. DRX_UIO31,
  783. DRX_UIO32,
  784. DRX_UIO_MAX = DRX_UIO32
  785. };
  786. /**
  787. * \enum enum drxuio_mode * \brief Used to configure the modus oprandi of a UIO.
  788. *
  789. * DRX_UIO_MODE_FIRMWARE is an old uio mode.
  790. * It is replaced by the modes DRX_UIO_MODE_FIRMWARE0 .. DRX_UIO_MODE_FIRMWARE9.
  791. * To be backward compatible DRX_UIO_MODE_FIRMWARE is equivalent to
  792. * DRX_UIO_MODE_FIRMWARE0.
  793. */
  794. enum drxuio_mode {
  795. DRX_UIO_MODE_DISABLE = 0x01,
  796. /**< not used, pin is configured as input */
  797. DRX_UIO_MODE_READWRITE = 0x02,
  798. /**< used for read/write by application */
  799. DRX_UIO_MODE_FIRMWARE = 0x04,
  800. /**< controlled by firmware, function 0 */
  801. DRX_UIO_MODE_FIRMWARE0 = DRX_UIO_MODE_FIRMWARE,
  802. /**< same as above */
  803. DRX_UIO_MODE_FIRMWARE1 = 0x08,
  804. /**< controlled by firmware, function 1 */
  805. DRX_UIO_MODE_FIRMWARE2 = 0x10,
  806. /**< controlled by firmware, function 2 */
  807. DRX_UIO_MODE_FIRMWARE3 = 0x20,
  808. /**< controlled by firmware, function 3 */
  809. DRX_UIO_MODE_FIRMWARE4 = 0x40,
  810. /**< controlled by firmware, function 4 */
  811. DRX_UIO_MODE_FIRMWARE5 = 0x80
  812. /**< controlled by firmware, function 5 */
  813. };
  814. /**
  815. * \enum enum drxoob_downstream_standard * \brief Used to select OOB standard.
  816. *
  817. * Based on ANSI 55-1 and 55-2
  818. */
  819. enum drxoob_downstream_standard {
  820. DRX_OOB_MODE_A = 0,
  821. /**< ANSI 55-1 */
  822. DRX_OOB_MODE_B_GRADE_A,
  823. /**< ANSI 55-2 A */
  824. DRX_OOB_MODE_B_GRADE_B
  825. /**< ANSI 55-2 B */
  826. };
  827. /*-------------------------------------------------------------------------
  828. STRUCTS
  829. -------------------------------------------------------------------------*/
  830. /*============================================================================*/
  831. /*============================================================================*/
  832. /*== CTRL CFG related data structures ========================================*/
  833. /*============================================================================*/
  834. /*============================================================================*/
  835. #ifndef DRX_CFG_BASE
  836. #define DRX_CFG_BASE 0
  837. #endif
  838. #define DRX_CFG_MPEG_OUTPUT (DRX_CFG_BASE + 0) /* MPEG TS output */
  839. #define DRX_CFG_PKTERR (DRX_CFG_BASE + 1) /* Packet Error */
  840. #define DRX_CFG_SYMCLK_OFFS (DRX_CFG_BASE + 2) /* Symbol Clk Offset */
  841. #define DRX_CFG_SMA (DRX_CFG_BASE + 3) /* Smart Antenna */
  842. #define DRX_CFG_PINSAFE (DRX_CFG_BASE + 4) /* Pin safe mode */
  843. #define DRX_CFG_SUBSTANDARD (DRX_CFG_BASE + 5) /* substandard */
  844. #define DRX_CFG_AUD_VOLUME (DRX_CFG_BASE + 6) /* volume */
  845. #define DRX_CFG_AUD_RDS (DRX_CFG_BASE + 7) /* rds */
  846. #define DRX_CFG_AUD_AUTOSOUND (DRX_CFG_BASE + 8) /* ASS & ASC */
  847. #define DRX_CFG_AUD_ASS_THRES (DRX_CFG_BASE + 9) /* ASS Thresholds */
  848. #define DRX_CFG_AUD_DEVIATION (DRX_CFG_BASE + 10) /* Deviation */
  849. #define DRX_CFG_AUD_PRESCALE (DRX_CFG_BASE + 11) /* Prescale */
  850. #define DRX_CFG_AUD_MIXER (DRX_CFG_BASE + 12) /* Mixer */
  851. #define DRX_CFG_AUD_AVSYNC (DRX_CFG_BASE + 13) /* AVSync */
  852. #define DRX_CFG_AUD_CARRIER (DRX_CFG_BASE + 14) /* Audio carriers */
  853. #define DRX_CFG_I2S_OUTPUT (DRX_CFG_BASE + 15) /* I2S output */
  854. #define DRX_CFG_ATV_STANDARD (DRX_CFG_BASE + 16) /* ATV standard */
  855. #define DRX_CFG_SQI_SPEED (DRX_CFG_BASE + 17) /* SQI speed */
  856. #define DRX_CTRL_CFG_MAX (DRX_CFG_BASE + 18) /* never to be used */
  857. #define DRX_CFG_PINS_SAFE_MODE DRX_CFG_PINSAFE
  858. /*============================================================================*/
  859. /*============================================================================*/
  860. /*== CTRL related data structures ============================================*/
  861. /*============================================================================*/
  862. /*============================================================================*/
  863. /**
  864. * struct drxu_code_info Parameters for microcode upload and verfiy.
  865. *
  866. * @mc_file: microcode file name
  867. *
  868. * Used by DRX_CTRL_LOAD_UCODE and DRX_CTRL_VERIFY_UCODE
  869. */
  870. struct drxu_code_info {
  871. char *mc_file;
  872. };
  873. /**
  874. * \struct drx_mc_version_rec_t
  875. * \brief Microcode version record
  876. * Version numbers are stored in BCD format, as usual:
  877. * o major number = bits 31-20 (first three nibbles of MSW)
  878. * o minor number = bits 19-16 (fourth nibble of MSW)
  879. * o patch number = bits 15-0 (remaining nibbles in LSW)
  880. *
  881. * The device type indicates for which the device is meant. It is based on the
  882. * JTAG ID, using everything except the bond ID and the metal fix.
  883. *
  884. * Special values:
  885. * - mc_dev_type == 0 => any device allowed
  886. * - mc_base_version == 0.0.0 => full microcode (mc_version is the version)
  887. * - mc_base_version != 0.0.0 => patch microcode, the base microcode version
  888. * (mc_version is the version)
  889. */
  890. #define AUX_VER_RECORD 0x8000
  891. struct drx_mc_version_rec {
  892. u16 aux_type; /* type of aux data - 0x8000 for version record */
  893. u32 mc_dev_type; /* device type, based on JTAG ID */
  894. u32 mc_version; /* version of microcode */
  895. u32 mc_base_version; /* in case of patch: the original microcode version */
  896. };
  897. /*========================================*/
  898. /**
  899. * \struct drx_filter_info_t
  900. * \brief Parameters for loading filter coefficients
  901. *
  902. * Used by DRX_CTRL_LOAD_FILTER
  903. */
  904. struct drx_filter_info {
  905. u8 *data_re;
  906. /**< pointer to coefficients for RE */
  907. u8 *data_im;
  908. /**< pointer to coefficients for IM */
  909. u16 size_re;
  910. /**< size of coefficients for RE */
  911. u16 size_im;
  912. /**< size of coefficients for IM */
  913. };
  914. /*========================================*/
  915. /**
  916. * \struct struct drx_channel * \brief The set of parameters describing a single channel.
  917. *
  918. * Used by DRX_CTRL_SET_CHANNEL and DRX_CTRL_GET_CHANNEL.
  919. * Only certain fields need to be used for a specfic standard.
  920. *
  921. */
  922. struct drx_channel {
  923. s32 frequency;
  924. /**< frequency in kHz */
  925. enum drx_bandwidth bandwidth;
  926. /**< bandwidth */
  927. enum drx_mirror mirror; /**< mirrored or not on RF */
  928. enum drx_modulation constellation;
  929. /**< constellation */
  930. enum drx_hierarchy hierarchy;
  931. /**< hierarchy */
  932. enum drx_priority priority; /**< priority */
  933. enum drx_coderate coderate; /**< coderate */
  934. enum drx_guard guard; /**< guard interval */
  935. enum drx_fft_mode fftmode; /**< fftmode */
  936. enum drx_classification classification;
  937. /**< classification */
  938. u32 symbolrate;
  939. /**< symbolrate in symbols/sec */
  940. enum drx_interleave_mode interleavemode;
  941. /**< interleaveMode QAM */
  942. enum drx_ldpc ldpc; /**< ldpc */
  943. enum drx_carrier_mode carrier; /**< carrier */
  944. enum drx_frame_mode framemode;
  945. /**< frame mode */
  946. enum drx_pilot_mode pilot; /**< pilot mode */
  947. };
  948. /*========================================*/
  949. enum drx_cfg_sqi_speed {
  950. DRX_SQI_SPEED_FAST = 0,
  951. DRX_SQI_SPEED_MEDIUM,
  952. DRX_SQI_SPEED_SLOW,
  953. DRX_SQI_SPEED_UNKNOWN = DRX_UNKNOWN
  954. };
  955. /*========================================*/
  956. /**
  957. * \struct struct drx_complex * A complex number.
  958. *
  959. * Used by DRX_CTRL_CONSTEL.
  960. */
  961. struct drx_complex {
  962. s16 im;
  963. /**< Imaginary part. */
  964. s16 re;
  965. /**< Real part. */
  966. };
  967. /*========================================*/
  968. /**
  969. * \struct struct drx_frequency_plan * Array element of a frequency plan.
  970. *
  971. * Used by DRX_CTRL_SCAN_INIT.
  972. */
  973. struct drx_frequency_plan {
  974. s32 first;
  975. /**< First centre frequency in this band */
  976. s32 last;
  977. /**< Last centre frequency in this band */
  978. s32 step;
  979. /**< Stepping frequency in this band */
  980. enum drx_bandwidth bandwidth;
  981. /**< Bandwidth within this frequency band */
  982. u16 ch_number;
  983. /**< First channel number in this band, or first
  984. index in ch_names */
  985. char **ch_names;
  986. /**< Optional list of channel names in this
  987. band */
  988. };
  989. /*========================================*/
  990. /**
  991. * \struct struct drx_scan_param * Parameters for channel scan.
  992. *
  993. * Used by DRX_CTRL_SCAN_INIT.
  994. */
  995. struct drx_scan_param {
  996. struct drx_frequency_plan *frequency_plan;
  997. /**< Frequency plan (array)*/
  998. u16 frequency_plan_size; /**< Number of bands */
  999. u32 num_tries; /**< Max channels tried */
  1000. s32 skip; /**< Minimum frequency step to take
  1001. after a channel is found */
  1002. void *ext_params; /**< Standard specific params */
  1003. };
  1004. /*========================================*/
  1005. /**
  1006. * \brief Scan commands.
  1007. * Used by scanning algorithms.
  1008. */
  1009. enum drx_scan_command {
  1010. DRX_SCAN_COMMAND_INIT = 0,/**< Initialize scanning */
  1011. DRX_SCAN_COMMAND_NEXT, /**< Next scan */
  1012. DRX_SCAN_COMMAND_STOP /**< Stop scanning */
  1013. };
  1014. /*========================================*/
  1015. /**
  1016. * \brief Inner scan function prototype.
  1017. */
  1018. typedef int(*drx_scan_func_t) (void *scan_context,
  1019. enum drx_scan_command scan_command,
  1020. struct drx_channel *scan_channel,
  1021. bool *get_next_channel);
  1022. /*========================================*/
  1023. /**
  1024. * \struct struct drxtps_info * TPS information, DVB-T specific.
  1025. *
  1026. * Used by DRX_CTRL_TPS_INFO.
  1027. */
  1028. struct drxtps_info {
  1029. enum drx_fft_mode fftmode; /**< Fft mode */
  1030. enum drx_guard guard; /**< Guard interval */
  1031. enum drx_modulation constellation;
  1032. /**< Constellation */
  1033. enum drx_hierarchy hierarchy;
  1034. /**< Hierarchy */
  1035. enum drx_coderate high_coderate;
  1036. /**< High code rate */
  1037. enum drx_coderate low_coderate;
  1038. /**< Low cod rate */
  1039. enum drx_tps_frame frame; /**< Tps frame */
  1040. u8 length; /**< Length */
  1041. u16 cell_id; /**< Cell id */
  1042. };
  1043. /*========================================*/
  1044. /**
  1045. * \brief Power mode of device.
  1046. *
  1047. * Used by DRX_CTRL_SET_POWER_MODE.
  1048. */
  1049. enum drx_power_mode {
  1050. DRX_POWER_UP = 0,
  1051. /**< Generic , Power Up Mode */
  1052. DRX_POWER_MODE_1,
  1053. /**< Device specific , Power Up Mode */
  1054. DRX_POWER_MODE_2,
  1055. /**< Device specific , Power Up Mode */
  1056. DRX_POWER_MODE_3,
  1057. /**< Device specific , Power Up Mode */
  1058. DRX_POWER_MODE_4,
  1059. /**< Device specific , Power Up Mode */
  1060. DRX_POWER_MODE_5,
  1061. /**< Device specific , Power Up Mode */
  1062. DRX_POWER_MODE_6,
  1063. /**< Device specific , Power Up Mode */
  1064. DRX_POWER_MODE_7,
  1065. /**< Device specific , Power Up Mode */
  1066. DRX_POWER_MODE_8,
  1067. /**< Device specific , Power Up Mode */
  1068. DRX_POWER_MODE_9,
  1069. /**< Device specific , Power Down Mode */
  1070. DRX_POWER_MODE_10,
  1071. /**< Device specific , Power Down Mode */
  1072. DRX_POWER_MODE_11,
  1073. /**< Device specific , Power Down Mode */
  1074. DRX_POWER_MODE_12,
  1075. /**< Device specific , Power Down Mode */
  1076. DRX_POWER_MODE_13,
  1077. /**< Device specific , Power Down Mode */
  1078. DRX_POWER_MODE_14,
  1079. /**< Device specific , Power Down Mode */
  1080. DRX_POWER_MODE_15,
  1081. /**< Device specific , Power Down Mode */
  1082. DRX_POWER_MODE_16,
  1083. /**< Device specific , Power Down Mode */
  1084. DRX_POWER_DOWN = 255
  1085. /**< Generic , Power Down Mode */
  1086. };
  1087. /*========================================*/
  1088. /**
  1089. * \enum enum drx_module * \brief Software module identification.
  1090. *
  1091. * Used by DRX_CTRL_VERSION.
  1092. */
  1093. enum drx_module {
  1094. DRX_MODULE_DEVICE,
  1095. DRX_MODULE_MICROCODE,
  1096. DRX_MODULE_DRIVERCORE,
  1097. DRX_MODULE_DEVICEDRIVER,
  1098. DRX_MODULE_DAP,
  1099. DRX_MODULE_BSP_I2C,
  1100. DRX_MODULE_BSP_TUNER,
  1101. DRX_MODULE_BSP_HOST,
  1102. DRX_MODULE_UNKNOWN
  1103. };
  1104. /**
  1105. * \enum struct drx_version * \brief Version information of one software module.
  1106. *
  1107. * Used by DRX_CTRL_VERSION.
  1108. */
  1109. struct drx_version {
  1110. enum drx_module module_type;
  1111. /**< Type identifier of the module */
  1112. char *module_name;
  1113. /**< Name or description of module */
  1114. u16 v_major; /**< Major version number */
  1115. u16 v_minor; /**< Minor version number */
  1116. u16 v_patch; /**< Patch version number */
  1117. char *v_string; /**< Version as text string */
  1118. };
  1119. /**
  1120. * \enum struct drx_version_list * \brief List element of NULL terminated, linked list for version information.
  1121. *
  1122. * Used by DRX_CTRL_VERSION.
  1123. */
  1124. struct drx_version_list {
  1125. struct drx_version *version;/**< Version information */
  1126. struct drx_version_list *next;
  1127. /**< Next list element */
  1128. };
  1129. /*========================================*/
  1130. /**
  1131. * \brief Parameters needed to confiugure a UIO.
  1132. *
  1133. * Used by DRX_CTRL_UIO_CFG.
  1134. */
  1135. struct drxuio_cfg {
  1136. enum drx_uio uio;
  1137. /**< UIO identifier */
  1138. enum drxuio_mode mode;
  1139. /**< UIO operational mode */
  1140. };
  1141. /*========================================*/
  1142. /**
  1143. * \brief Parameters needed to read from or write to a UIO.
  1144. *
  1145. * Used by DRX_CTRL_UIO_READ and DRX_CTRL_UIO_WRITE.
  1146. */
  1147. struct drxuio_data {
  1148. enum drx_uio uio;
  1149. /**< UIO identifier */
  1150. bool value;
  1151. /**< UIO value (true=1, false=0) */
  1152. };
  1153. /*========================================*/
  1154. /**
  1155. * \brief Parameters needed to configure OOB.
  1156. *
  1157. * Used by DRX_CTRL_SET_OOB.
  1158. */
  1159. struct drxoob {
  1160. s32 frequency; /**< Frequency in kHz */
  1161. enum drxoob_downstream_standard standard;
  1162. /**< OOB standard */
  1163. bool spectrum_inverted; /**< If true, then spectrum
  1164. is inverted */
  1165. };
  1166. /*========================================*/
  1167. /**
  1168. * \brief Metrics from OOB.
  1169. *
  1170. * Used by DRX_CTRL_GET_OOB.
  1171. */
  1172. struct drxoob_status {
  1173. s32 frequency; /**< Frequency in Khz */
  1174. enum drx_lock_status lock; /**< Lock status */
  1175. u32 mer; /**< MER */
  1176. s32 symbol_rate_offset; /**< Symbolrate offset in ppm */
  1177. };
  1178. /*========================================*/
  1179. /**
  1180. * \brief Device dependent configuration data.
  1181. *
  1182. * Used by DRX_CTRL_SET_CFG and DRX_CTRL_GET_CFG.
  1183. * A sort of nested drx_ctrl() functionality for device specific controls.
  1184. */
  1185. struct drx_cfg {
  1186. u32 cfg_type;
  1187. /**< Function identifier */
  1188. void *cfg_data;
  1189. /**< Function data */
  1190. };
  1191. /*========================================*/
  1192. /**
  1193. * /struct DRXMpegStartWidth_t
  1194. * MStart width [nr MCLK cycles] for serial MPEG output.
  1195. */
  1196. enum drxmpeg_str_width {
  1197. DRX_MPEG_STR_WIDTH_1,
  1198. DRX_MPEG_STR_WIDTH_8
  1199. };
  1200. /* CTRL CFG MPEG ouput */
  1201. /**
  1202. * \struct struct drx_cfg_mpeg_output * \brief Configuartion parameters for MPEG output control.
  1203. *
  1204. * Used by DRX_CFG_MPEG_OUTPUT, in combination with DRX_CTRL_SET_CFG and
  1205. * DRX_CTRL_GET_CFG.
  1206. */
  1207. struct drx_cfg_mpeg_output {
  1208. bool enable_mpeg_output;/**< If true, enable MPEG output */
  1209. bool insert_rs_byte; /**< If true, insert RS byte */
  1210. bool enable_parallel; /**< If true, parallel out otherwise
  1211. serial */
  1212. bool invert_data; /**< If true, invert DATA signals */
  1213. bool invert_err; /**< If true, invert ERR signal */
  1214. bool invert_str; /**< If true, invert STR signals */
  1215. bool invert_val; /**< If true, invert VAL signals */
  1216. bool invert_clk; /**< If true, invert CLK signals */
  1217. bool static_clk; /**< If true, static MPEG clockrate
  1218. will be used, otherwise clockrate
  1219. will adapt to the bitrate of the
  1220. TS */
  1221. u32 bitrate; /**< Maximum bitrate in b/s in case
  1222. static clockrate is selected */
  1223. enum drxmpeg_str_width width_str;
  1224. /**< MPEG start width */
  1225. };
  1226. /*========================================*/
  1227. /**
  1228. * \struct struct drxi2c_data * \brief Data for I2C via 2nd or 3rd or etc I2C port.
  1229. *
  1230. * Used by DRX_CTRL_I2C_READWRITE.
  1231. * If port_nr is equal to primairy port_nr BSPI2C will be used.
  1232. *
  1233. */
  1234. struct drxi2c_data {
  1235. u16 port_nr; /**< I2C port number */
  1236. struct i2c_device_addr *w_dev_addr;
  1237. /**< Write device address */
  1238. u16 w_count; /**< Size of write data in bytes */
  1239. u8 *wData; /**< Pointer to write data */
  1240. struct i2c_device_addr *r_dev_addr;
  1241. /**< Read device address */
  1242. u16 r_count; /**< Size of data to read in bytes */
  1243. u8 *r_data; /**< Pointer to read buffer */
  1244. };
  1245. /*========================================*/
  1246. /**
  1247. * \enum enum drx_aud_standard * \brief Audio standard identifier.
  1248. *
  1249. * Used by DRX_CTRL_SET_AUD.
  1250. */
  1251. enum drx_aud_standard {
  1252. DRX_AUD_STANDARD_BTSC, /**< set BTSC standard (USA) */
  1253. DRX_AUD_STANDARD_A2, /**< set A2-Korea FM Stereo */
  1254. DRX_AUD_STANDARD_EIAJ, /**< set to Japanese FM Stereo */
  1255. DRX_AUD_STANDARD_FM_STEREO,/**< set to FM-Stereo Radio */
  1256. DRX_AUD_STANDARD_M_MONO, /**< for 4.5 MHz mono detected */
  1257. DRX_AUD_STANDARD_D_K_MONO, /**< for 6.5 MHz mono detected */
  1258. DRX_AUD_STANDARD_BG_FM, /**< set BG_FM standard */
  1259. DRX_AUD_STANDARD_D_K1, /**< set D_K1 standard */
  1260. DRX_AUD_STANDARD_D_K2, /**< set D_K2 standard */
  1261. DRX_AUD_STANDARD_D_K3, /**< set D_K3 standard */
  1262. DRX_AUD_STANDARD_BG_NICAM_FM,
  1263. /**< set BG_NICAM_FM standard */
  1264. DRX_AUD_STANDARD_L_NICAM_AM,
  1265. /**< set L_NICAM_AM standard */
  1266. DRX_AUD_STANDARD_I_NICAM_FM,
  1267. /**< set I_NICAM_FM standard */
  1268. DRX_AUD_STANDARD_D_K_NICAM_FM,
  1269. /**< set D_K_NICAM_FM standard */
  1270. DRX_AUD_STANDARD_NOT_READY,/**< used to detect audio standard */
  1271. DRX_AUD_STANDARD_AUTO = DRX_AUTO,
  1272. /**< Automatic Standard Detection */
  1273. DRX_AUD_STANDARD_UNKNOWN = DRX_UNKNOWN
  1274. /**< used as auto and for readback */
  1275. };
  1276. /* CTRL_AUD_GET_STATUS - struct drx_aud_status */
  1277. /**
  1278. * \enum enum drx_aud_nicam_status * \brief Status of NICAM carrier.
  1279. */
  1280. enum drx_aud_nicam_status {
  1281. DRX_AUD_NICAM_DETECTED = 0,
  1282. /**< NICAM carrier detected */
  1283. DRX_AUD_NICAM_NOT_DETECTED,
  1284. /**< NICAM carrier not detected */
  1285. DRX_AUD_NICAM_BAD /**< NICAM carrier bad quality */
  1286. };
  1287. /**
  1288. * \struct struct drx_aud_status * \brief Audio status characteristics.
  1289. */
  1290. struct drx_aud_status {
  1291. bool stereo; /**< stereo detection */
  1292. bool carrier_a; /**< carrier A detected */
  1293. bool carrier_b; /**< carrier B detected */
  1294. bool sap; /**< sap / bilingual detection */
  1295. bool rds; /**< RDS data array present */
  1296. enum drx_aud_nicam_status nicam_status;
  1297. /**< status of NICAM carrier */
  1298. s8 fm_ident; /**< FM Identification value */
  1299. };
  1300. /* CTRL_AUD_READ_RDS - DRXRDSdata_t */
  1301. /**
  1302. * \struct DRXRDSdata_t
  1303. * \brief Raw RDS data array.
  1304. */
  1305. struct drx_cfg_aud_rds {
  1306. bool valid; /**< RDS data validation */
  1307. u16 data[18]; /**< data from one RDS data array */
  1308. };
  1309. /* DRX_CFG_AUD_VOLUME - struct drx_cfg_aud_volume - set/get */
  1310. /**
  1311. * \enum DRXAudAVCDecayTime_t
  1312. * \brief Automatic volume control configuration.
  1313. */
  1314. enum drx_aud_avc_mode {
  1315. DRX_AUD_AVC_OFF, /**< Automatic volume control off */
  1316. DRX_AUD_AVC_DECAYTIME_8S, /**< level volume in 8 seconds */
  1317. DRX_AUD_AVC_DECAYTIME_4S, /**< level volume in 4 seconds */
  1318. DRX_AUD_AVC_DECAYTIME_2S, /**< level volume in 2 seconds */
  1319. DRX_AUD_AVC_DECAYTIME_20MS/**< level volume in 20 millisec */
  1320. };
  1321. /**
  1322. * /enum DRXAudMaxAVCGain_t
  1323. * /brief Automatic volume control max gain in audio baseband.
  1324. */
  1325. enum drx_aud_avc_max_gain {
  1326. DRX_AUD_AVC_MAX_GAIN_0DB, /**< maximum AVC gain 0 dB */
  1327. DRX_AUD_AVC_MAX_GAIN_6DB, /**< maximum AVC gain 6 dB */
  1328. DRX_AUD_AVC_MAX_GAIN_12DB /**< maximum AVC gain 12 dB */
  1329. };
  1330. /**
  1331. * /enum DRXAudMaxAVCAtten_t
  1332. * /brief Automatic volume control max attenuation in audio baseband.
  1333. */
  1334. enum drx_aud_avc_max_atten {
  1335. DRX_AUD_AVC_MAX_ATTEN_12DB,
  1336. /**< maximum AVC attenuation 12 dB */
  1337. DRX_AUD_AVC_MAX_ATTEN_18DB,
  1338. /**< maximum AVC attenuation 18 dB */
  1339. DRX_AUD_AVC_MAX_ATTEN_24DB/**< maximum AVC attenuation 24 dB */
  1340. };
  1341. /**
  1342. * \struct struct drx_cfg_aud_volume * \brief Audio volume configuration.
  1343. */
  1344. struct drx_cfg_aud_volume {
  1345. bool mute; /**< mute overrides volume setting */
  1346. s16 volume; /**< volume, range -114 to 12 dB */
  1347. enum drx_aud_avc_mode avc_mode; /**< AVC auto volume control mode */
  1348. u16 avc_ref_level; /**< AVC reference level */
  1349. enum drx_aud_avc_max_gain avc_max_gain;
  1350. /**< AVC max gain selection */
  1351. enum drx_aud_avc_max_atten avc_max_atten;
  1352. /**< AVC max attenuation selection */
  1353. s16 strength_left; /**< quasi-peak, left speaker */
  1354. s16 strength_right; /**< quasi-peak, right speaker */
  1355. };
  1356. /* DRX_CFG_I2S_OUTPUT - struct drx_cfg_i2s_output - set/get */
  1357. /**
  1358. * \enum enum drxi2s_mode * \brief I2S output mode.
  1359. */
  1360. enum drxi2s_mode {
  1361. DRX_I2S_MODE_MASTER, /**< I2S is in master mode */
  1362. DRX_I2S_MODE_SLAVE /**< I2S is in slave mode */
  1363. };
  1364. /**
  1365. * \enum enum drxi2s_word_length * \brief Width of I2S data.
  1366. */
  1367. enum drxi2s_word_length {
  1368. DRX_I2S_WORDLENGTH_32 = 0,/**< I2S data is 32 bit wide */
  1369. DRX_I2S_WORDLENGTH_16 = 1 /**< I2S data is 16 bit wide */
  1370. };
  1371. /**
  1372. * \enum enum drxi2s_format * \brief Data wordstrobe alignment for I2S.
  1373. */
  1374. enum drxi2s_format {
  1375. DRX_I2S_FORMAT_WS_WITH_DATA,
  1376. /**< I2S data and wordstrobe are aligned */
  1377. DRX_I2S_FORMAT_WS_ADVANCED
  1378. /**< I2S data one cycle after wordstrobe */
  1379. };
  1380. /**
  1381. * \enum enum drxi2s_polarity * \brief Polarity of I2S data.
  1382. */
  1383. enum drxi2s_polarity {
  1384. DRX_I2S_POLARITY_RIGHT,/**< wordstrobe - right high, left low */
  1385. DRX_I2S_POLARITY_LEFT /**< wordstrobe - right low, left high */
  1386. };
  1387. /**
  1388. * \struct struct drx_cfg_i2s_output * \brief I2S output configuration.
  1389. */
  1390. struct drx_cfg_i2s_output {
  1391. bool output_enable; /**< I2S output enable */
  1392. u32 frequency; /**< range from 8000-48000 Hz */
  1393. enum drxi2s_mode mode; /**< I2S mode, master or slave */
  1394. enum drxi2s_word_length word_length;
  1395. /**< I2S wordlength, 16 or 32 bits */
  1396. enum drxi2s_polarity polarity;/**< I2S wordstrobe polarity */
  1397. enum drxi2s_format format; /**< I2S wordstrobe delay to data */
  1398. };
  1399. /* ------------------------------expert interface-----------------------------*/
  1400. /**
  1401. * /enum enum drx_aud_fm_deemphasis * setting for FM-Deemphasis in audio demodulator.
  1402. *
  1403. */
  1404. enum drx_aud_fm_deemphasis {
  1405. DRX_AUD_FM_DEEMPH_50US,
  1406. DRX_AUD_FM_DEEMPH_75US,
  1407. DRX_AUD_FM_DEEMPH_OFF
  1408. };
  1409. /**
  1410. * /enum DRXAudDeviation_t
  1411. * setting for deviation mode in audio demodulator.
  1412. *
  1413. */
  1414. enum drx_cfg_aud_deviation {
  1415. DRX_AUD_DEVIATION_NORMAL,
  1416. DRX_AUD_DEVIATION_HIGH
  1417. };
  1418. /**
  1419. * /enum enum drx_no_carrier_option * setting for carrier, mute/noise.
  1420. *
  1421. */
  1422. enum drx_no_carrier_option {
  1423. DRX_NO_CARRIER_MUTE,
  1424. DRX_NO_CARRIER_NOISE
  1425. };
  1426. /**
  1427. * \enum DRXAudAutoSound_t
  1428. * \brief Automatic Sound
  1429. */
  1430. enum drx_cfg_aud_auto_sound {
  1431. DRX_AUD_AUTO_SOUND_OFF = 0,
  1432. DRX_AUD_AUTO_SOUND_SELECT_ON_CHANGE_ON,
  1433. DRX_AUD_AUTO_SOUND_SELECT_ON_CHANGE_OFF
  1434. };
  1435. /**
  1436. * \enum DRXAudASSThres_t
  1437. * \brief Automatic Sound Select Thresholds
  1438. */
  1439. struct drx_cfg_aud_ass_thres {
  1440. u16 a2; /* A2 Threshold for ASS configuration */
  1441. u16 btsc; /* BTSC Threshold for ASS configuration */
  1442. u16 nicam; /* Nicam Threshold for ASS configuration */
  1443. };
  1444. /**
  1445. * \struct struct drx_aud_carrier * \brief Carrier detection related parameters
  1446. */
  1447. struct drx_aud_carrier {
  1448. u16 thres; /* carrier detetcion threshold for primary carrier (A) */
  1449. enum drx_no_carrier_option opt; /* Mute or noise at no carrier detection (A) */
  1450. s32 shift; /* DC level of incoming signal (A) */
  1451. s32 dco; /* frequency adjustment (A) */
  1452. };
  1453. /**
  1454. * \struct struct drx_cfg_aud_carriers * \brief combining carrier A & B to one struct
  1455. */
  1456. struct drx_cfg_aud_carriers {
  1457. struct drx_aud_carrier a;
  1458. struct drx_aud_carrier b;
  1459. };
  1460. /**
  1461. * /enum enum drx_aud_i2s_src * Selection of audio source
  1462. */
  1463. enum drx_aud_i2s_src {
  1464. DRX_AUD_SRC_MONO,
  1465. DRX_AUD_SRC_STEREO_OR_AB,
  1466. DRX_AUD_SRC_STEREO_OR_A,
  1467. DRX_AUD_SRC_STEREO_OR_B};
  1468. /**
  1469. * \enum enum drx_aud_i2s_matrix * \brief Used for selecting I2S output.
  1470. */
  1471. enum drx_aud_i2s_matrix {
  1472. DRX_AUD_I2S_MATRIX_A_MONO,
  1473. /**< A sound only, stereo or mono */
  1474. DRX_AUD_I2S_MATRIX_B_MONO,
  1475. /**< B sound only, stereo or mono */
  1476. DRX_AUD_I2S_MATRIX_STEREO,
  1477. /**< A+B sound, transparant */
  1478. DRX_AUD_I2S_MATRIX_MONO /**< A+B mixed to mono sum, (L+R)/2 */};
  1479. /**
  1480. * /enum enum drx_aud_fm_matrix * setting for FM-Matrix in audio demodulator.
  1481. *
  1482. */
  1483. enum drx_aud_fm_matrix {
  1484. DRX_AUD_FM_MATRIX_NO_MATRIX,
  1485. DRX_AUD_FM_MATRIX_GERMAN,
  1486. DRX_AUD_FM_MATRIX_KOREAN,
  1487. DRX_AUD_FM_MATRIX_SOUND_A,
  1488. DRX_AUD_FM_MATRIX_SOUND_B};
  1489. /**
  1490. * \struct DRXAudMatrices_t
  1491. * \brief Mixer settings
  1492. */
  1493. struct drx_cfg_aud_mixer {
  1494. enum drx_aud_i2s_src source_i2s;
  1495. enum drx_aud_i2s_matrix matrix_i2s;
  1496. enum drx_aud_fm_matrix matrix_fm;
  1497. };
  1498. /**
  1499. * \enum DRXI2SVidSync_t
  1500. * \brief Audio/video synchronization, interacts with I2S mode.
  1501. * AUTO_1 and AUTO_2 are for automatic video standard detection with preference
  1502. * for NTSC or Monochrome, because the frequencies are too close (59.94 & 60 Hz)
  1503. */
  1504. enum drx_cfg_aud_av_sync {
  1505. DRX_AUD_AVSYNC_OFF,/**< audio/video synchronization is off */
  1506. DRX_AUD_AVSYNC_NTSC,
  1507. /**< it is an NTSC system */
  1508. DRX_AUD_AVSYNC_MONOCHROME,
  1509. /**< it is a MONOCHROME system */
  1510. DRX_AUD_AVSYNC_PAL_SECAM
  1511. /**< it is a PAL/SECAM system */};
  1512. /**
  1513. * \struct struct drx_cfg_aud_prescale * \brief Prescalers
  1514. */
  1515. struct drx_cfg_aud_prescale {
  1516. u16 fm_deviation;
  1517. s16 nicam_gain;
  1518. };
  1519. /**
  1520. * \struct struct drx_aud_beep * \brief Beep
  1521. */
  1522. struct drx_aud_beep {
  1523. s16 volume; /* dB */
  1524. u16 frequency; /* Hz */
  1525. bool mute;
  1526. };
  1527. /**
  1528. * \enum enum drx_aud_btsc_detect * \brief BTSC detetcion mode
  1529. */
  1530. enum drx_aud_btsc_detect {
  1531. DRX_BTSC_STEREO,
  1532. DRX_BTSC_MONO_AND_SAP};
  1533. /**
  1534. * \struct struct drx_aud_data * \brief Audio data structure
  1535. */
  1536. struct drx_aud_data {
  1537. /* audio storage */
  1538. bool audio_is_active;
  1539. enum drx_aud_standard audio_standard;
  1540. struct drx_cfg_i2s_output i2sdata;
  1541. struct drx_cfg_aud_volume volume;
  1542. enum drx_cfg_aud_auto_sound auto_sound;
  1543. struct drx_cfg_aud_ass_thres ass_thresholds;
  1544. struct drx_cfg_aud_carriers carriers;
  1545. struct drx_cfg_aud_mixer mixer;
  1546. enum drx_cfg_aud_deviation deviation;
  1547. enum drx_cfg_aud_av_sync av_sync;
  1548. struct drx_cfg_aud_prescale prescale;
  1549. enum drx_aud_fm_deemphasis deemph;
  1550. enum drx_aud_btsc_detect btsc_detect;
  1551. /* rds */
  1552. u16 rds_data_counter;
  1553. bool rds_data_present;
  1554. };
  1555. /**
  1556. * \enum enum drx_qam_lock_range * \brief QAM lock range mode
  1557. */
  1558. enum drx_qam_lock_range {
  1559. DRX_QAM_LOCKRANGE_NORMAL,
  1560. DRX_QAM_LOCKRANGE_EXTENDED};
  1561. /*============================================================================*/
  1562. /*============================================================================*/
  1563. /*== Data access structures ==================================================*/
  1564. /*============================================================================*/
  1565. /*============================================================================*/
  1566. /* Address on device */
  1567. typedef u32 dr_xaddr_t, *pdr_xaddr_t;
  1568. /* Protocol specific flags */
  1569. typedef u32 dr_xflags_t, *pdr_xflags_t;
  1570. /* Write block of data to device */
  1571. typedef int(*drx_write_block_func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
  1572. u32 addr, /* address of register/memory */
  1573. u16 datasize, /* size of data in bytes */
  1574. u8 *data, /* data to send */
  1575. u32 flags);
  1576. /* Read block of data from device */
  1577. typedef int(*drx_read_block_func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
  1578. u32 addr, /* address of register/memory */
  1579. u16 datasize, /* size of data in bytes */
  1580. u8 *data, /* receive buffer */
  1581. u32 flags);
  1582. /* Write 8-bits value to device */
  1583. typedef int(*drx_write_reg8func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
  1584. u32 addr, /* address of register/memory */
  1585. u8 data, /* data to send */
  1586. u32 flags);
  1587. /* Read 8-bits value to device */
  1588. typedef int(*drx_read_reg8func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
  1589. u32 addr, /* address of register/memory */
  1590. u8 *data, /* receive buffer */
  1591. u32 flags);
  1592. /* Read modify write 8-bits value to device */
  1593. typedef int(*drx_read_modify_write_reg8func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
  1594. u32 waddr, /* write address of register */
  1595. u32 raddr, /* read address of register */
  1596. u8 wdata, /* data to write */
  1597. u8 *rdata); /* data to read */
  1598. /* Write 16-bits value to device */
  1599. typedef int(*drx_write_reg16func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
  1600. u32 addr, /* address of register/memory */
  1601. u16 data, /* data to send */
  1602. u32 flags);
  1603. /* Read 16-bits value to device */
  1604. typedef int(*drx_read_reg16func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
  1605. u32 addr, /* address of register/memory */
  1606. u16 *data, /* receive buffer */
  1607. u32 flags);
  1608. /* Read modify write 16-bits value to device */
  1609. typedef int(*drx_read_modify_write_reg16func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
  1610. u32 waddr, /* write address of register */
  1611. u32 raddr, /* read address of register */
  1612. u16 wdata, /* data to write */
  1613. u16 *rdata); /* data to read */
  1614. /* Write 32-bits value to device */
  1615. typedef int(*drx_write_reg32func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
  1616. u32 addr, /* address of register/memory */
  1617. u32 data, /* data to send */
  1618. u32 flags);
  1619. /* Read 32-bits value to device */
  1620. typedef int(*drx_read_reg32func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
  1621. u32 addr, /* address of register/memory */
  1622. u32 *data, /* receive buffer */
  1623. u32 flags);
  1624. /* Read modify write 32-bits value to device */
  1625. typedef int(*drx_read_modify_write_reg32func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
  1626. u32 waddr, /* write address of register */
  1627. u32 raddr, /* read address of register */
  1628. u32 wdata, /* data to write */
  1629. u32 *rdata); /* data to read */
  1630. /**
  1631. * \struct struct drx_access_func * \brief Interface to an access protocol.
  1632. */
  1633. struct drx_access_func {
  1634. drx_write_block_func_t write_block_func;
  1635. drx_read_block_func_t read_block_func;
  1636. drx_write_reg8func_t write_reg8func;
  1637. drx_read_reg8func_t read_reg8func;
  1638. drx_read_modify_write_reg8func_t read_modify_write_reg8func;
  1639. drx_write_reg16func_t write_reg16func;
  1640. drx_read_reg16func_t read_reg16func;
  1641. drx_read_modify_write_reg16func_t read_modify_write_reg16func;
  1642. drx_write_reg32func_t write_reg32func;
  1643. drx_read_reg32func_t read_reg32func;
  1644. drx_read_modify_write_reg32func_t read_modify_write_reg32func;
  1645. };
  1646. /* Register address and data for register dump function */
  1647. struct drx_reg_dump {
  1648. u32 address;
  1649. u32 data;
  1650. };
  1651. /*============================================================================*/
  1652. /*============================================================================*/
  1653. /*== Demod instance data structures ==========================================*/
  1654. /*============================================================================*/
  1655. /*============================================================================*/
  1656. /**
  1657. * \struct struct drx_common_attr * \brief Set of common attributes, shared by all DRX devices.
  1658. */
  1659. struct drx_common_attr {
  1660. /* Microcode (firmware) attributes */
  1661. char *microcode_file; /**< microcode filename */
  1662. bool verify_microcode;
  1663. /**< Use microcode verify or not. */
  1664. struct drx_mc_version_rec mcversion;
  1665. /**< Version record of microcode from file */
  1666. /* Clocks and tuner attributes */
  1667. s32 intermediate_freq;
  1668. /**< IF,if tuner instance not used. (kHz)*/
  1669. s32 sys_clock_freq;
  1670. /**< Systemclock frequency. (kHz) */
  1671. s32 osc_clock_freq;
  1672. /**< Oscillator clock frequency. (kHz) */
  1673. s16 osc_clock_deviation;
  1674. /**< Oscillator clock deviation. (ppm) */
  1675. bool mirror_freq_spect;
  1676. /**< Mirror IF frequency spectrum or not.*/
  1677. /* Initial MPEG output attributes */
  1678. struct drx_cfg_mpeg_output mpeg_cfg;
  1679. /**< MPEG configuration */
  1680. bool is_opened; /**< if true instance is already opened. */
  1681. /* Channel scan */
  1682. struct drx_scan_param *scan_param;
  1683. /**< scan parameters */
  1684. u16 scan_freq_plan_index;
  1685. /**< next index in freq plan */
  1686. s32 scan_next_frequency;
  1687. /**< next freq to scan */
  1688. bool scan_ready; /**< scan ready flag */
  1689. u32 scan_max_channels;/**< number of channels in freqplan */
  1690. u32 scan_channels_scanned;
  1691. /**< number of channels scanned */
  1692. /* Channel scan - inner loop: demod related */
  1693. drx_scan_func_t scan_function;
  1694. /**< function to check channel */
  1695. /* Channel scan - inner loop: SYSObj related */
  1696. void *scan_context; /**< Context Pointer of SYSObj */
  1697. /* Channel scan - parameters for default DTV scan function in core driver */
  1698. u16 scan_demod_lock_timeout;
  1699. /**< millisecs to wait for lock */
  1700. enum drx_lock_status scan_desired_lock;
  1701. /**< lock requirement for channel found */
  1702. /* scan_active can be used by SetChannel to decide how to program the tuner,
  1703. fast or slow (but stable). Usually fast during scan. */
  1704. bool scan_active; /**< true when scan routines are active */
  1705. /* Power management */
  1706. enum drx_power_mode current_power_mode;
  1707. /**< current power management mode */
  1708. /* Tuner */
  1709. u8 tuner_port_nr; /**< nr of I2C port to wich tuner is */
  1710. s32 tuner_min_freq_rf;
  1711. /**< minimum RF input frequency, in kHz */
  1712. s32 tuner_max_freq_rf;
  1713. /**< maximum RF input frequency, in kHz */
  1714. bool tuner_rf_agc_pol; /**< if true invert RF AGC polarity */
  1715. bool tuner_if_agc_pol; /**< if true invert IF AGC polarity */
  1716. bool tuner_slow_mode; /**< if true invert IF AGC polarity */
  1717. struct drx_channel current_channel;
  1718. /**< current channel parameters */
  1719. enum drx_standard current_standard;
  1720. /**< current standard selection */
  1721. enum drx_standard prev_standard;
  1722. /**< previous standard selection */
  1723. enum drx_standard di_cache_standard;
  1724. /**< standard in DI cache if available */
  1725. bool use_bootloader; /**< use bootloader in open */
  1726. u32 capabilities; /**< capabilities flags */
  1727. u32 product_id; /**< product ID inc. metal fix number */};
  1728. /*
  1729. * Generic functions for DRX devices.
  1730. */
  1731. struct drx_demod_instance;
  1732. /**
  1733. * \struct struct drx_demod_instance * \brief Top structure of demodulator instance.
  1734. */
  1735. struct drx_demod_instance {
  1736. /**< data access protocol functions */
  1737. struct i2c_device_addr *my_i2c_dev_addr;
  1738. /**< i2c address and device identifier */
  1739. struct drx_common_attr *my_common_attr;
  1740. /**< common DRX attributes */
  1741. void *my_ext_attr; /**< device specific attributes */
  1742. /* generic demodulator data */
  1743. struct i2c_adapter *i2c;
  1744. const struct firmware *firmware;
  1745. };
  1746. /*-------------------------------------------------------------------------
  1747. MACROS
  1748. Conversion from enum values to human readable form.
  1749. -------------------------------------------------------------------------*/
  1750. /* standard */
  1751. #define DRX_STR_STANDARD(x) ( \
  1752. (x == DRX_STANDARD_DVBT) ? "DVB-T" : \
  1753. (x == DRX_STANDARD_8VSB) ? "8VSB" : \
  1754. (x == DRX_STANDARD_NTSC) ? "NTSC" : \
  1755. (x == DRX_STANDARD_PAL_SECAM_BG) ? "PAL/SECAM B/G" : \
  1756. (x == DRX_STANDARD_PAL_SECAM_DK) ? "PAL/SECAM D/K" : \
  1757. (x == DRX_STANDARD_PAL_SECAM_I) ? "PAL/SECAM I" : \
  1758. (x == DRX_STANDARD_PAL_SECAM_L) ? "PAL/SECAM L" : \
  1759. (x == DRX_STANDARD_PAL_SECAM_LP) ? "PAL/SECAM LP" : \
  1760. (x == DRX_STANDARD_ITU_A) ? "ITU-A" : \
  1761. (x == DRX_STANDARD_ITU_B) ? "ITU-B" : \
  1762. (x == DRX_STANDARD_ITU_C) ? "ITU-C" : \
  1763. (x == DRX_STANDARD_ITU_D) ? "ITU-D" : \
  1764. (x == DRX_STANDARD_FM) ? "FM" : \
  1765. (x == DRX_STANDARD_DTMB) ? "DTMB" : \
  1766. (x == DRX_STANDARD_AUTO) ? "Auto" : \
  1767. (x == DRX_STANDARD_UNKNOWN) ? "Unknown" : \
  1768. "(Invalid)")
  1769. /* channel */
  1770. #define DRX_STR_BANDWIDTH(x) ( \
  1771. (x == DRX_BANDWIDTH_8MHZ) ? "8 MHz" : \
  1772. (x == DRX_BANDWIDTH_7MHZ) ? "7 MHz" : \
  1773. (x == DRX_BANDWIDTH_6MHZ) ? "6 MHz" : \
  1774. (x == DRX_BANDWIDTH_AUTO) ? "Auto" : \
  1775. (x == DRX_BANDWIDTH_UNKNOWN) ? "Unknown" : \
  1776. "(Invalid)")
  1777. #define DRX_STR_FFTMODE(x) ( \
  1778. (x == DRX_FFTMODE_2K) ? "2k" : \
  1779. (x == DRX_FFTMODE_4K) ? "4k" : \
  1780. (x == DRX_FFTMODE_8K) ? "8k" : \
  1781. (x == DRX_FFTMODE_AUTO) ? "Auto" : \
  1782. (x == DRX_FFTMODE_UNKNOWN) ? "Unknown" : \
  1783. "(Invalid)")
  1784. #define DRX_STR_GUARD(x) ( \
  1785. (x == DRX_GUARD_1DIV32) ? "1/32nd" : \
  1786. (x == DRX_GUARD_1DIV16) ? "1/16th" : \
  1787. (x == DRX_GUARD_1DIV8) ? "1/8th" : \
  1788. (x == DRX_GUARD_1DIV4) ? "1/4th" : \
  1789. (x == DRX_GUARD_AUTO) ? "Auto" : \
  1790. (x == DRX_GUARD_UNKNOWN) ? "Unknown" : \
  1791. "(Invalid)")
  1792. #define DRX_STR_CONSTELLATION(x) ( \
  1793. (x == DRX_CONSTELLATION_BPSK) ? "BPSK" : \
  1794. (x == DRX_CONSTELLATION_QPSK) ? "QPSK" : \
  1795. (x == DRX_CONSTELLATION_PSK8) ? "PSK8" : \
  1796. (x == DRX_CONSTELLATION_QAM16) ? "QAM16" : \
  1797. (x == DRX_CONSTELLATION_QAM32) ? "QAM32" : \
  1798. (x == DRX_CONSTELLATION_QAM64) ? "QAM64" : \
  1799. (x == DRX_CONSTELLATION_QAM128) ? "QAM128" : \
  1800. (x == DRX_CONSTELLATION_QAM256) ? "QAM256" : \
  1801. (x == DRX_CONSTELLATION_QAM512) ? "QAM512" : \
  1802. (x == DRX_CONSTELLATION_QAM1024) ? "QAM1024" : \
  1803. (x == DRX_CONSTELLATION_QPSK_NR) ? "QPSK_NR" : \
  1804. (x == DRX_CONSTELLATION_AUTO) ? "Auto" : \
  1805. (x == DRX_CONSTELLATION_UNKNOWN) ? "Unknown" : \
  1806. "(Invalid)")
  1807. #define DRX_STR_CODERATE(x) ( \
  1808. (x == DRX_CODERATE_1DIV2) ? "1/2nd" : \
  1809. (x == DRX_CODERATE_2DIV3) ? "2/3rd" : \
  1810. (x == DRX_CODERATE_3DIV4) ? "3/4th" : \
  1811. (x == DRX_CODERATE_5DIV6) ? "5/6th" : \
  1812. (x == DRX_CODERATE_7DIV8) ? "7/8th" : \
  1813. (x == DRX_CODERATE_AUTO) ? "Auto" : \
  1814. (x == DRX_CODERATE_UNKNOWN) ? "Unknown" : \
  1815. "(Invalid)")
  1816. #define DRX_STR_HIERARCHY(x) ( \
  1817. (x == DRX_HIERARCHY_NONE) ? "None" : \
  1818. (x == DRX_HIERARCHY_ALPHA1) ? "Alpha=1" : \
  1819. (x == DRX_HIERARCHY_ALPHA2) ? "Alpha=2" : \
  1820. (x == DRX_HIERARCHY_ALPHA4) ? "Alpha=4" : \
  1821. (x == DRX_HIERARCHY_AUTO) ? "Auto" : \
  1822. (x == DRX_HIERARCHY_UNKNOWN) ? "Unknown" : \
  1823. "(Invalid)")
  1824. #define DRX_STR_PRIORITY(x) ( \
  1825. (x == DRX_PRIORITY_LOW) ? "Low" : \
  1826. (x == DRX_PRIORITY_HIGH) ? "High" : \
  1827. (x == DRX_PRIORITY_UNKNOWN) ? "Unknown" : \
  1828. "(Invalid)")
  1829. #define DRX_STR_MIRROR(x) ( \
  1830. (x == DRX_MIRROR_NO) ? "Normal" : \
  1831. (x == DRX_MIRROR_YES) ? "Mirrored" : \
  1832. (x == DRX_MIRROR_AUTO) ? "Auto" : \
  1833. (x == DRX_MIRROR_UNKNOWN) ? "Unknown" : \
  1834. "(Invalid)")
  1835. #define DRX_STR_CLASSIFICATION(x) ( \
  1836. (x == DRX_CLASSIFICATION_GAUSS) ? "Gaussion" : \
  1837. (x == DRX_CLASSIFICATION_HVY_GAUSS) ? "Heavy Gaussion" : \
  1838. (x == DRX_CLASSIFICATION_COCHANNEL) ? "Co-channel" : \
  1839. (x == DRX_CLASSIFICATION_STATIC) ? "Static echo" : \
  1840. (x == DRX_CLASSIFICATION_MOVING) ? "Moving echo" : \
  1841. (x == DRX_CLASSIFICATION_ZERODB) ? "Zero dB echo" : \
  1842. (x == DRX_CLASSIFICATION_UNKNOWN) ? "Unknown" : \
  1843. (x == DRX_CLASSIFICATION_AUTO) ? "Auto" : \
  1844. "(Invalid)")
  1845. #define DRX_STR_INTERLEAVEMODE(x) ( \
  1846. (x == DRX_INTERLEAVEMODE_I128_J1) ? "I128_J1" : \
  1847. (x == DRX_INTERLEAVEMODE_I128_J1_V2) ? "I128_J1_V2" : \
  1848. (x == DRX_INTERLEAVEMODE_I128_J2) ? "I128_J2" : \
  1849. (x == DRX_INTERLEAVEMODE_I64_J2) ? "I64_J2" : \
  1850. (x == DRX_INTERLEAVEMODE_I128_J3) ? "I128_J3" : \
  1851. (x == DRX_INTERLEAVEMODE_I32_J4) ? "I32_J4" : \
  1852. (x == DRX_INTERLEAVEMODE_I128_J4) ? "I128_J4" : \
  1853. (x == DRX_INTERLEAVEMODE_I16_J8) ? "I16_J8" : \
  1854. (x == DRX_INTERLEAVEMODE_I128_J5) ? "I128_J5" : \
  1855. (x == DRX_INTERLEAVEMODE_I8_J16) ? "I8_J16" : \
  1856. (x == DRX_INTERLEAVEMODE_I128_J6) ? "I128_J6" : \
  1857. (x == DRX_INTERLEAVEMODE_RESERVED_11) ? "Reserved 11" : \
  1858. (x == DRX_INTERLEAVEMODE_I128_J7) ? "I128_J7" : \
  1859. (x == DRX_INTERLEAVEMODE_RESERVED_13) ? "Reserved 13" : \
  1860. (x == DRX_INTERLEAVEMODE_I128_J8) ? "I128_J8" : \
  1861. (x == DRX_INTERLEAVEMODE_RESERVED_15) ? "Reserved 15" : \
  1862. (x == DRX_INTERLEAVEMODE_I12_J17) ? "I12_J17" : \
  1863. (x == DRX_INTERLEAVEMODE_I5_J4) ? "I5_J4" : \
  1864. (x == DRX_INTERLEAVEMODE_B52_M240) ? "B52_M240" : \
  1865. (x == DRX_INTERLEAVEMODE_B52_M720) ? "B52_M720" : \
  1866. (x == DRX_INTERLEAVEMODE_B52_M48) ? "B52_M48" : \
  1867. (x == DRX_INTERLEAVEMODE_B52_M0) ? "B52_M0" : \
  1868. (x == DRX_INTERLEAVEMODE_UNKNOWN) ? "Unknown" : \
  1869. (x == DRX_INTERLEAVEMODE_AUTO) ? "Auto" : \
  1870. "(Invalid)")
  1871. #define DRX_STR_LDPC(x) ( \
  1872. (x == DRX_LDPC_0_4) ? "0.4" : \
  1873. (x == DRX_LDPC_0_6) ? "0.6" : \
  1874. (x == DRX_LDPC_0_8) ? "0.8" : \
  1875. (x == DRX_LDPC_AUTO) ? "Auto" : \
  1876. (x == DRX_LDPC_UNKNOWN) ? "Unknown" : \
  1877. "(Invalid)")
  1878. #define DRX_STR_CARRIER(x) ( \
  1879. (x == DRX_CARRIER_MULTI) ? "Multi" : \
  1880. (x == DRX_CARRIER_SINGLE) ? "Single" : \
  1881. (x == DRX_CARRIER_AUTO) ? "Auto" : \
  1882. (x == DRX_CARRIER_UNKNOWN) ? "Unknown" : \
  1883. "(Invalid)")
  1884. #define DRX_STR_FRAMEMODE(x) ( \
  1885. (x == DRX_FRAMEMODE_420) ? "420" : \
  1886. (x == DRX_FRAMEMODE_595) ? "595" : \
  1887. (x == DRX_FRAMEMODE_945) ? "945" : \
  1888. (x == DRX_FRAMEMODE_420_FIXED_PN) ? "420 with fixed PN" : \
  1889. (x == DRX_FRAMEMODE_945_FIXED_PN) ? "945 with fixed PN" : \
  1890. (x == DRX_FRAMEMODE_AUTO) ? "Auto" : \
  1891. (x == DRX_FRAMEMODE_UNKNOWN) ? "Unknown" : \
  1892. "(Invalid)")
  1893. #define DRX_STR_PILOT(x) ( \
  1894. (x == DRX_PILOT_ON) ? "On" : \
  1895. (x == DRX_PILOT_OFF) ? "Off" : \
  1896. (x == DRX_PILOT_AUTO) ? "Auto" : \
  1897. (x == DRX_PILOT_UNKNOWN) ? "Unknown" : \
  1898. "(Invalid)")
  1899. /* TPS */
  1900. #define DRX_STR_TPS_FRAME(x) ( \
  1901. (x == DRX_TPS_FRAME1) ? "Frame1" : \
  1902. (x == DRX_TPS_FRAME2) ? "Frame2" : \
  1903. (x == DRX_TPS_FRAME3) ? "Frame3" : \
  1904. (x == DRX_TPS_FRAME4) ? "Frame4" : \
  1905. (x == DRX_TPS_FRAME_UNKNOWN) ? "Unknown" : \
  1906. "(Invalid)")
  1907. /* lock status */
  1908. #define DRX_STR_LOCKSTATUS(x) ( \
  1909. (x == DRX_NEVER_LOCK) ? "Never" : \
  1910. (x == DRX_NOT_LOCKED) ? "No" : \
  1911. (x == DRX_LOCKED) ? "Locked" : \
  1912. (x == DRX_LOCK_STATE_1) ? "Lock state 1" : \
  1913. (x == DRX_LOCK_STATE_2) ? "Lock state 2" : \
  1914. (x == DRX_LOCK_STATE_3) ? "Lock state 3" : \
  1915. (x == DRX_LOCK_STATE_4) ? "Lock state 4" : \
  1916. (x == DRX_LOCK_STATE_5) ? "Lock state 5" : \
  1917. (x == DRX_LOCK_STATE_6) ? "Lock state 6" : \
  1918. (x == DRX_LOCK_STATE_7) ? "Lock state 7" : \
  1919. (x == DRX_LOCK_STATE_8) ? "Lock state 8" : \
  1920. (x == DRX_LOCK_STATE_9) ? "Lock state 9" : \
  1921. "(Invalid)")
  1922. /* version information , modules */
  1923. #define DRX_STR_MODULE(x) ( \
  1924. (x == DRX_MODULE_DEVICE) ? "Device" : \
  1925. (x == DRX_MODULE_MICROCODE) ? "Microcode" : \
  1926. (x == DRX_MODULE_DRIVERCORE) ? "CoreDriver" : \
  1927. (x == DRX_MODULE_DEVICEDRIVER) ? "DeviceDriver" : \
  1928. (x == DRX_MODULE_BSP_I2C) ? "BSP I2C" : \
  1929. (x == DRX_MODULE_BSP_TUNER) ? "BSP Tuner" : \
  1930. (x == DRX_MODULE_BSP_HOST) ? "BSP Host" : \
  1931. (x == DRX_MODULE_DAP) ? "Data Access Protocol" : \
  1932. (x == DRX_MODULE_UNKNOWN) ? "Unknown" : \
  1933. "(Invalid)")
  1934. #define DRX_STR_POWER_MODE(x) ( \
  1935. (x == DRX_POWER_UP) ? "DRX_POWER_UP " : \
  1936. (x == DRX_POWER_MODE_1) ? "DRX_POWER_MODE_1" : \
  1937. (x == DRX_POWER_MODE_2) ? "DRX_POWER_MODE_2" : \
  1938. (x == DRX_POWER_MODE_3) ? "DRX_POWER_MODE_3" : \
  1939. (x == DRX_POWER_MODE_4) ? "DRX_POWER_MODE_4" : \
  1940. (x == DRX_POWER_MODE_5) ? "DRX_POWER_MODE_5" : \
  1941. (x == DRX_POWER_MODE_6) ? "DRX_POWER_MODE_6" : \
  1942. (x == DRX_POWER_MODE_7) ? "DRX_POWER_MODE_7" : \
  1943. (x == DRX_POWER_MODE_8) ? "DRX_POWER_MODE_8" : \
  1944. (x == DRX_POWER_MODE_9) ? "DRX_POWER_MODE_9" : \
  1945. (x == DRX_POWER_MODE_10) ? "DRX_POWER_MODE_10" : \
  1946. (x == DRX_POWER_MODE_11) ? "DRX_POWER_MODE_11" : \
  1947. (x == DRX_POWER_MODE_12) ? "DRX_POWER_MODE_12" : \
  1948. (x == DRX_POWER_MODE_13) ? "DRX_POWER_MODE_13" : \
  1949. (x == DRX_POWER_MODE_14) ? "DRX_POWER_MODE_14" : \
  1950. (x == DRX_POWER_MODE_15) ? "DRX_POWER_MODE_15" : \
  1951. (x == DRX_POWER_MODE_16) ? "DRX_POWER_MODE_16" : \
  1952. (x == DRX_POWER_DOWN) ? "DRX_POWER_DOWN " : \
  1953. "(Invalid)")
  1954. #define DRX_STR_OOB_STANDARD(x) ( \
  1955. (x == DRX_OOB_MODE_A) ? "ANSI 55-1 " : \
  1956. (x == DRX_OOB_MODE_B_GRADE_A) ? "ANSI 55-2 A" : \
  1957. (x == DRX_OOB_MODE_B_GRADE_B) ? "ANSI 55-2 B" : \
  1958. "(Invalid)")
  1959. #define DRX_STR_AUD_STANDARD(x) ( \
  1960. (x == DRX_AUD_STANDARD_BTSC) ? "BTSC" : \
  1961. (x == DRX_AUD_STANDARD_A2) ? "A2" : \
  1962. (x == DRX_AUD_STANDARD_EIAJ) ? "EIAJ" : \
  1963. (x == DRX_AUD_STANDARD_FM_STEREO) ? "FM Stereo" : \
  1964. (x == DRX_AUD_STANDARD_AUTO) ? "Auto" : \
  1965. (x == DRX_AUD_STANDARD_M_MONO) ? "M-Standard Mono" : \
  1966. (x == DRX_AUD_STANDARD_D_K_MONO) ? "D/K Mono FM" : \
  1967. (x == DRX_AUD_STANDARD_BG_FM) ? "B/G-Dual Carrier FM (A2)" : \
  1968. (x == DRX_AUD_STANDARD_D_K1) ? "D/K1-Dual Carrier FM" : \
  1969. (x == DRX_AUD_STANDARD_D_K2) ? "D/K2-Dual Carrier FM" : \
  1970. (x == DRX_AUD_STANDARD_D_K3) ? "D/K3-Dual Carrier FM" : \
  1971. (x == DRX_AUD_STANDARD_BG_NICAM_FM) ? "B/G-NICAM-FM" : \
  1972. (x == DRX_AUD_STANDARD_L_NICAM_AM) ? "L-NICAM-AM" : \
  1973. (x == DRX_AUD_STANDARD_I_NICAM_FM) ? "I-NICAM-FM" : \
  1974. (x == DRX_AUD_STANDARD_D_K_NICAM_FM) ? "D/K-NICAM-FM" : \
  1975. (x == DRX_AUD_STANDARD_UNKNOWN) ? "Unknown" : \
  1976. "(Invalid)")
  1977. #define DRX_STR_AUD_STEREO(x) ( \
  1978. (x == true) ? "Stereo" : \
  1979. (x == false) ? "Mono" : \
  1980. "(Invalid)")
  1981. #define DRX_STR_AUD_SAP(x) ( \
  1982. (x == true) ? "Present" : \
  1983. (x == false) ? "Not present" : \
  1984. "(Invalid)")
  1985. #define DRX_STR_AUD_CARRIER(x) ( \
  1986. (x == true) ? "Present" : \
  1987. (x == false) ? "Not present" : \
  1988. "(Invalid)")
  1989. #define DRX_STR_AUD_RDS(x) ( \
  1990. (x == true) ? "Available" : \
  1991. (x == false) ? "Not Available" : \
  1992. "(Invalid)")
  1993. #define DRX_STR_AUD_NICAM_STATUS(x) ( \
  1994. (x == DRX_AUD_NICAM_DETECTED) ? "Detected" : \
  1995. (x == DRX_AUD_NICAM_NOT_DETECTED) ? "Not detected" : \
  1996. (x == DRX_AUD_NICAM_BAD) ? "Bad" : \
  1997. "(Invalid)")
  1998. #define DRX_STR_RDS_VALID(x) ( \
  1999. (x == true) ? "Valid" : \
  2000. (x == false) ? "Not Valid" : \
  2001. "(Invalid)")
  2002. /*-------------------------------------------------------------------------
  2003. Access macros
  2004. -------------------------------------------------------------------------*/
  2005. /**
  2006. * \brief Create a compilable reference to the microcode attribute
  2007. * \param d pointer to demod instance
  2008. *
  2009. * Used as main reference to an attribute field.
  2010. * Used by both macro implementation and function implementation.
  2011. * These macros are defined to avoid duplication of code in macro and function
  2012. * definitions that handle access of demod common or extended attributes.
  2013. *
  2014. */
  2015. #define DRX_ATTR_MCRECORD(d) ((d)->my_common_attr->mcversion)
  2016. #define DRX_ATTR_MIRRORFREQSPECT(d) ((d)->my_common_attr->mirror_freq_spect)
  2017. #define DRX_ATTR_CURRENTPOWERMODE(d)((d)->my_common_attr->current_power_mode)
  2018. #define DRX_ATTR_ISOPENED(d) ((d)->my_common_attr->is_opened)
  2019. #define DRX_ATTR_USEBOOTLOADER(d) ((d)->my_common_attr->use_bootloader)
  2020. #define DRX_ATTR_CURRENTSTANDARD(d) ((d)->my_common_attr->current_standard)
  2021. #define DRX_ATTR_PREVSTANDARD(d) ((d)->my_common_attr->prev_standard)
  2022. #define DRX_ATTR_CACHESTANDARD(d) ((d)->my_common_attr->di_cache_standard)
  2023. #define DRX_ATTR_CURRENTCHANNEL(d) ((d)->my_common_attr->current_channel)
  2024. #define DRX_ATTR_MICROCODE(d) ((d)->my_common_attr->microcode)
  2025. #define DRX_ATTR_VERIFYMICROCODE(d) ((d)->my_common_attr->verify_microcode)
  2026. #define DRX_ATTR_CAPABILITIES(d) ((d)->my_common_attr->capabilities)
  2027. #define DRX_ATTR_PRODUCTID(d) ((d)->my_common_attr->product_id)
  2028. #define DRX_ATTR_INTERMEDIATEFREQ(d) ((d)->my_common_attr->intermediate_freq)
  2029. #define DRX_ATTR_SYSCLOCKFREQ(d) ((d)->my_common_attr->sys_clock_freq)
  2030. #define DRX_ATTR_TUNERRFAGCPOL(d) ((d)->my_common_attr->tuner_rf_agc_pol)
  2031. #define DRX_ATTR_TUNERIFAGCPOL(d) ((d)->my_common_attr->tuner_if_agc_pol)
  2032. #define DRX_ATTR_TUNERSLOWMODE(d) ((d)->my_common_attr->tuner_slow_mode)
  2033. #define DRX_ATTR_TUNERSPORTNR(d) ((d)->my_common_attr->tuner_port_nr)
  2034. #define DRX_ATTR_I2CADDR(d) ((d)->my_i2c_dev_addr->i2c_addr)
  2035. #define DRX_ATTR_I2CDEVID(d) ((d)->my_i2c_dev_addr->i2c_dev_id)
  2036. #define DRX_ISMCVERTYPE(x) ((x) == AUX_VER_RECORD)
  2037. /**************************/
  2038. /* Macros with device-specific handling are converted to CFG functions */
  2039. #define DRX_ACCESSMACRO_SET(demod, value, cfg_name, data_type) \
  2040. do { \
  2041. struct drx_cfg config; \
  2042. data_type cfg_data; \
  2043. config.cfg_type = cfg_name; \
  2044. config.cfg_data = &cfg_data; \
  2045. cfg_data = value; \
  2046. drx_ctrl(demod, DRX_CTRL_SET_CFG, &config); \
  2047. } while (0)
  2048. #define DRX_ACCESSMACRO_GET(demod, value, cfg_name, data_type, error_value) \
  2049. do { \
  2050. int cfg_status; \
  2051. struct drx_cfg config; \
  2052. data_type cfg_data; \
  2053. config.cfg_type = cfg_name; \
  2054. config.cfg_data = &cfg_data; \
  2055. cfg_status = drx_ctrl(demod, DRX_CTRL_GET_CFG, &config); \
  2056. if (cfg_status == 0) { \
  2057. value = cfg_data; \
  2058. } else { \
  2059. value = (data_type)error_value; \
  2060. } \
  2061. } while (0)
  2062. /* Configuration functions for usage by Access (XS) Macros */
  2063. #ifndef DRX_XS_CFG_BASE
  2064. #define DRX_XS_CFG_BASE (500)
  2065. #endif
  2066. #define DRX_XS_CFG_PRESET (DRX_XS_CFG_BASE + 0)
  2067. #define DRX_XS_CFG_AUD_BTSC_DETECT (DRX_XS_CFG_BASE + 1)
  2068. #define DRX_XS_CFG_QAM_LOCKRANGE (DRX_XS_CFG_BASE + 2)
  2069. /* Access Macros with device-specific handling */
  2070. #define DRX_SET_PRESET(d, x) \
  2071. DRX_ACCESSMACRO_SET((d), (x), DRX_XS_CFG_PRESET, char*)
  2072. #define DRX_GET_PRESET(d, x) \
  2073. DRX_ACCESSMACRO_GET((d), (x), DRX_XS_CFG_PRESET, char*, "ERROR")
  2074. #define DRX_SET_AUD_BTSC_DETECT(d, x) DRX_ACCESSMACRO_SET((d), (x), \
  2075. DRX_XS_CFG_AUD_BTSC_DETECT, enum drx_aud_btsc_detect)
  2076. #define DRX_GET_AUD_BTSC_DETECT(d, x) DRX_ACCESSMACRO_GET((d), (x), \
  2077. DRX_XS_CFG_AUD_BTSC_DETECT, enum drx_aud_btsc_detect, DRX_UNKNOWN)
  2078. #define DRX_SET_QAM_LOCKRANGE(d, x) DRX_ACCESSMACRO_SET((d), (x), \
  2079. DRX_XS_CFG_QAM_LOCKRANGE, enum drx_qam_lock_range)
  2080. #define DRX_GET_QAM_LOCKRANGE(d, x) DRX_ACCESSMACRO_GET((d), (x), \
  2081. DRX_XS_CFG_QAM_LOCKRANGE, enum drx_qam_lock_range, DRX_UNKNOWN)
  2082. /**
  2083. * \brief Macro to check if std is an ATV standard
  2084. * \retval true std is an ATV standard
  2085. * \retval false std is an ATV standard
  2086. */
  2087. #define DRX_ISATVSTD(std) (((std) == DRX_STANDARD_PAL_SECAM_BG) || \
  2088. ((std) == DRX_STANDARD_PAL_SECAM_DK) || \
  2089. ((std) == DRX_STANDARD_PAL_SECAM_I) || \
  2090. ((std) == DRX_STANDARD_PAL_SECAM_L) || \
  2091. ((std) == DRX_STANDARD_PAL_SECAM_LP) || \
  2092. ((std) == DRX_STANDARD_NTSC) || \
  2093. ((std) == DRX_STANDARD_FM))
  2094. /**
  2095. * \brief Macro to check if std is an QAM standard
  2096. * \retval true std is an QAM standards
  2097. * \retval false std is an QAM standards
  2098. */
  2099. #define DRX_ISQAMSTD(std) (((std) == DRX_STANDARD_ITU_A) || \
  2100. ((std) == DRX_STANDARD_ITU_B) || \
  2101. ((std) == DRX_STANDARD_ITU_C) || \
  2102. ((std) == DRX_STANDARD_ITU_D))
  2103. /**
  2104. * \brief Macro to check if std is VSB standard
  2105. * \retval true std is VSB standard
  2106. * \retval false std is not VSB standard
  2107. */
  2108. #define DRX_ISVSBSTD(std) ((std) == DRX_STANDARD_8VSB)
  2109. /**
  2110. * \brief Macro to check if std is DVBT standard
  2111. * \retval true std is DVBT standard
  2112. * \retval false std is not DVBT standard
  2113. */
  2114. #define DRX_ISDVBTSTD(std) ((std) == DRX_STANDARD_DVBT)
  2115. /*-------------------------------------------------------------------------
  2116. THE END
  2117. -------------------------------------------------------------------------*/
  2118. #endif /* __DRXDRIVER_H__ */