dib3000mb_priv.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. /*
  2. * dib3000mb_priv.h
  3. *
  4. * Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@desy.de)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation, version 2.
  9. *
  10. * for more information see dib3000mb.c .
  11. */
  12. #ifndef __DIB3000MB_PRIV_H_INCLUDED__
  13. #define __DIB3000MB_PRIV_H_INCLUDED__
  14. /* register addresses and some of their default values */
  15. /* restart subsystems */
  16. #define DIB3000MB_REG_RESTART ( 0)
  17. #define DIB3000MB_RESTART_OFF ( 0)
  18. #define DIB3000MB_RESTART_AUTO_SEARCH (1 << 1)
  19. #define DIB3000MB_RESTART_CTRL (1 << 2)
  20. #define DIB3000MB_RESTART_AGC (1 << 3)
  21. /* FFT size */
  22. #define DIB3000MB_REG_FFT ( 1)
  23. /* Guard time */
  24. #define DIB3000MB_REG_GUARD_TIME ( 2)
  25. /* QAM */
  26. #define DIB3000MB_REG_QAM ( 3)
  27. /* Alpha coefficient high priority Viterbi algorithm */
  28. #define DIB3000MB_REG_VIT_ALPHA ( 4)
  29. /* spectrum inversion */
  30. #define DIB3000MB_REG_DDS_INV ( 5)
  31. /* DDS frequency value (IF position) ad ? values don't match reg_3000mb.txt */
  32. #define DIB3000MB_REG_DDS_FREQ_MSB ( 6)
  33. #define DIB3000MB_REG_DDS_FREQ_LSB ( 7)
  34. #define DIB3000MB_DDS_FREQ_MSB ( 178)
  35. #define DIB3000MB_DDS_FREQ_LSB ( 8990)
  36. /* timing frequency (carrier spacing) */
  37. static u16 dib3000mb_reg_timing_freq[] = { 8,9 };
  38. static u16 dib3000mb_timing_freq[][2] = {
  39. { 126 , 48873 }, /* 6 MHz */
  40. { 147 , 57019 }, /* 7 MHz */
  41. { 168 , 65164 }, /* 8 MHz */
  42. };
  43. /* impulse noise parameter */
  44. /* 36 ??? */
  45. static u16 dib3000mb_reg_impulse_noise[] = { 10,11,12,15,36 };
  46. enum dib3000mb_impulse_noise_type {
  47. DIB3000MB_IMPNOISE_OFF,
  48. DIB3000MB_IMPNOISE_MOBILE,
  49. DIB3000MB_IMPNOISE_FIXED,
  50. DIB3000MB_IMPNOISE_DEFAULT
  51. };
  52. static u16 dib3000mb_impulse_noise_values[][5] = {
  53. { 0x0000, 0x0004, 0x0014, 0x01ff, 0x0399 }, /* off */
  54. { 0x0001, 0x0004, 0x0014, 0x01ff, 0x037b }, /* mobile */
  55. { 0x0001, 0x0004, 0x0020, 0x01bd, 0x0399 }, /* fixed */
  56. { 0x0000, 0x0002, 0x000a, 0x01ff, 0x0399 }, /* default */
  57. };
  58. /*
  59. * Dual Automatic-Gain-Control
  60. * - gains RF in tuner (AGC1)
  61. * - gains IF after filtering (AGC2)
  62. */
  63. /* also from 16 to 18 */
  64. static u16 dib3000mb_reg_agc_gain[] = {
  65. 19,20,21,22,23,24,25,26,27,28,29,30,31,32
  66. };
  67. static u16 dib3000mb_default_agc_gain[] =
  68. { 0x0001, 52429, 623, 128, 166, 195, 61, /* RF ??? */
  69. 0x0001, 53766, 38011, 0, 90, 33, 23 }; /* IF ??? */
  70. /* phase noise */
  71. /* 36 is set when setting the impulse noise */
  72. static u16 dib3000mb_reg_phase_noise[] = { 33,34,35,37,38 };
  73. static u16 dib3000mb_default_noise_phase[] = { 2, 544, 0, 5, 4 };
  74. /* lock duration */
  75. static u16 dib3000mb_reg_lock_duration[] = { 39,40 };
  76. static u16 dib3000mb_default_lock_duration[] = { 135, 135 };
  77. /* AGC loop bandwidth */
  78. static u16 dib3000mb_reg_agc_bandwidth[] = { 43,44,45,46,47,48,49,50 };
  79. static u16 dib3000mb_agc_bandwidth_low[] =
  80. { 2088, 10, 2088, 10, 3448, 5, 3448, 5 };
  81. static u16 dib3000mb_agc_bandwidth_high[] =
  82. { 2349, 5, 2349, 5, 2586, 2, 2586, 2 };
  83. /*
  84. * lock0 definition (coff_lock)
  85. */
  86. #define DIB3000MB_REG_LOCK0_MASK ( 51)
  87. #define DIB3000MB_LOCK0_DEFAULT ( 4)
  88. /*
  89. * lock1 definition (cpil_lock)
  90. * for auto search
  91. * which values hide behind the lock masks
  92. */
  93. #define DIB3000MB_REG_LOCK1_MASK ( 52)
  94. #define DIB3000MB_LOCK1_SEARCH_4 (0x0004)
  95. #define DIB3000MB_LOCK1_SEARCH_2048 (0x0800)
  96. #define DIB3000MB_LOCK1_DEFAULT (0x0001)
  97. /*
  98. * lock2 definition (fec_lock) */
  99. #define DIB3000MB_REG_LOCK2_MASK ( 53)
  100. #define DIB3000MB_LOCK2_DEFAULT (0x0080)
  101. /*
  102. * SEQ ? what was that again ... :)
  103. * changes when, inversion, guard time and fft is
  104. * either automatically detected or not
  105. */
  106. #define DIB3000MB_REG_SEQ ( 54)
  107. /* bandwidth */
  108. static u16 dib3000mb_reg_bandwidth[] = { 55,56,57,58,59,60,61,62,63,64,65,66,67 };
  109. static u16 dib3000mb_bandwidth_6mhz[] =
  110. { 0, 33, 53312, 112, 46635, 563, 36565, 0, 1000, 0, 1010, 1, 45264 };
  111. static u16 dib3000mb_bandwidth_7mhz[] =
  112. { 0, 28, 64421, 96, 39973, 483, 3255, 0, 1000, 0, 1010, 1, 45264 };
  113. static u16 dib3000mb_bandwidth_8mhz[] =
  114. { 0, 25, 23600, 84, 34976, 422, 43808, 0, 1000, 0, 1010, 1, 45264 };
  115. #define DIB3000MB_REG_UNK_68 ( 68)
  116. #define DIB3000MB_UNK_68 ( 0)
  117. #define DIB3000MB_REG_UNK_69 ( 69)
  118. #define DIB3000MB_UNK_69 ( 0)
  119. #define DIB3000MB_REG_UNK_71 ( 71)
  120. #define DIB3000MB_UNK_71 ( 0)
  121. #define DIB3000MB_REG_UNK_77 ( 77)
  122. #define DIB3000MB_UNK_77 ( 6)
  123. #define DIB3000MB_REG_UNK_78 ( 78)
  124. #define DIB3000MB_UNK_78 (0x0080)
  125. /* isi */
  126. #define DIB3000MB_REG_ISI ( 79)
  127. #define DIB3000MB_ISI_ACTIVATE ( 0)
  128. #define DIB3000MB_ISI_INHIBIT ( 1)
  129. /* sync impovement */
  130. #define DIB3000MB_REG_SYNC_IMPROVEMENT ( 84)
  131. #define DIB3000MB_SYNC_IMPROVE_2K_1_8 ( 3)
  132. #define DIB3000MB_SYNC_IMPROVE_DEFAULT ( 0)
  133. /* phase noise compensation inhibition */
  134. #define DIB3000MB_REG_PHASE_NOISE ( 87)
  135. #define DIB3000MB_PHASE_NOISE_DEFAULT ( 0)
  136. #define DIB3000MB_REG_UNK_92 ( 92)
  137. #define DIB3000MB_UNK_92 (0x0080)
  138. #define DIB3000MB_REG_UNK_96 ( 96)
  139. #define DIB3000MB_UNK_96 (0x0010)
  140. #define DIB3000MB_REG_UNK_97 ( 97)
  141. #define DIB3000MB_UNK_97 (0x0009)
  142. /* mobile mode ??? */
  143. #define DIB3000MB_REG_MOBILE_MODE ( 101)
  144. #define DIB3000MB_MOBILE_MODE_ON ( 1)
  145. #define DIB3000MB_MOBILE_MODE_OFF ( 0)
  146. #define DIB3000MB_REG_UNK_106 ( 106)
  147. #define DIB3000MB_UNK_106 (0x0080)
  148. #define DIB3000MB_REG_UNK_107 ( 107)
  149. #define DIB3000MB_UNK_107 (0x0080)
  150. #define DIB3000MB_REG_UNK_108 ( 108)
  151. #define DIB3000MB_UNK_108 (0x0080)
  152. /* fft */
  153. #define DIB3000MB_REG_UNK_121 ( 121)
  154. #define DIB3000MB_UNK_121_2K ( 7)
  155. #define DIB3000MB_UNK_121_DEFAULT ( 5)
  156. #define DIB3000MB_REG_UNK_122 ( 122)
  157. #define DIB3000MB_UNK_122 ( 2867)
  158. /* QAM for mobile mode */
  159. #define DIB3000MB_REG_MOBILE_MODE_QAM ( 126)
  160. #define DIB3000MB_MOBILE_MODE_QAM_64 ( 3)
  161. #define DIB3000MB_MOBILE_MODE_QAM_QPSK_16 ( 1)
  162. #define DIB3000MB_MOBILE_MODE_QAM_OFF ( 0)
  163. /*
  164. * data diversity when having more than one chip on-board
  165. * see also DIB3000MB_OUTPUT_MODE_DATA_DIVERSITY
  166. */
  167. #define DIB3000MB_REG_DATA_IN_DIVERSITY ( 127)
  168. #define DIB3000MB_DATA_DIVERSITY_IN_OFF ( 0)
  169. #define DIB3000MB_DATA_DIVERSITY_IN_ON ( 2)
  170. /* vit hrch */
  171. #define DIB3000MB_REG_VIT_HRCH ( 128)
  172. /* vit code rate */
  173. #define DIB3000MB_REG_VIT_CODE_RATE ( 129)
  174. /* vit select hp */
  175. #define DIB3000MB_REG_VIT_HP ( 130)
  176. /* time frame for Bit-Error-Rate calculation */
  177. #define DIB3000MB_REG_BERLEN ( 135)
  178. #define DIB3000MB_BERLEN_LONG ( 0)
  179. #define DIB3000MB_BERLEN_DEFAULT ( 1)
  180. #define DIB3000MB_BERLEN_MEDIUM ( 2)
  181. #define DIB3000MB_BERLEN_SHORT ( 3)
  182. /* 142 - 152 FIFO parameters
  183. * which is what ?
  184. */
  185. #define DIB3000MB_REG_FIFO_142 ( 142)
  186. #define DIB3000MB_FIFO_142 ( 0)
  187. /* MPEG2 TS output mode */
  188. #define DIB3000MB_REG_MPEG2_OUT_MODE ( 143)
  189. #define DIB3000MB_MPEG2_OUT_MODE_204 ( 0)
  190. #define DIB3000MB_MPEG2_OUT_MODE_188 ( 1)
  191. #define DIB3000MB_REG_PID_PARSE ( 144)
  192. #define DIB3000MB_PID_PARSE_INHIBIT ( 0)
  193. #define DIB3000MB_PID_PARSE_ACTIVATE ( 1)
  194. #define DIB3000MB_REG_FIFO ( 145)
  195. #define DIB3000MB_FIFO_INHIBIT ( 1)
  196. #define DIB3000MB_FIFO_ACTIVATE ( 0)
  197. #define DIB3000MB_REG_FIFO_146 ( 146)
  198. #define DIB3000MB_FIFO_146 ( 3)
  199. #define DIB3000MB_REG_FIFO_147 ( 147)
  200. #define DIB3000MB_FIFO_147 (0x0100)
  201. /*
  202. * pidfilter
  203. * it is not a hardware pidfilter but a filter which drops all pids
  204. * except the ones set. Necessary because of the limited USB1.1 bandwidth.
  205. * regs 153-168
  206. */
  207. #define DIB3000MB_REG_FIRST_PID ( 153)
  208. #define DIB3000MB_NUM_PIDS ( 16)
  209. /*
  210. * output mode
  211. * USB devices have to use 'slave'-mode
  212. * see also DIB3000MB_REG_ELECT_OUT_MODE
  213. */
  214. #define DIB3000MB_REG_OUTPUT_MODE ( 169)
  215. #define DIB3000MB_OUTPUT_MODE_GATED_CLK ( 0)
  216. #define DIB3000MB_OUTPUT_MODE_CONT_CLK ( 1)
  217. #define DIB3000MB_OUTPUT_MODE_SERIAL ( 2)
  218. #define DIB3000MB_OUTPUT_MODE_DATA_DIVERSITY ( 5)
  219. #define DIB3000MB_OUTPUT_MODE_SLAVE ( 6)
  220. /* irq event mask */
  221. #define DIB3000MB_REG_IRQ_EVENT_MASK ( 170)
  222. #define DIB3000MB_IRQ_EVENT_MASK ( 0)
  223. /* filter coefficients */
  224. static u16 dib3000mb_reg_filter_coeffs[] = {
  225. 171, 172, 173, 174, 175, 176, 177, 178,
  226. 179, 180, 181, 182, 183, 184, 185, 186,
  227. 188, 189, 190, 191, 192, 194
  228. };
  229. static u16 dib3000mb_filter_coeffs[] = {
  230. 226, 160, 29,
  231. 979, 998, 19,
  232. 22, 1019, 1006,
  233. 1022, 12, 6,
  234. 1017, 1017, 3,
  235. 6, 1019,
  236. 1021, 2, 3,
  237. 1, 0,
  238. };
  239. /*
  240. * mobile algorithm (when you are moving with your device)
  241. * but not faster than 90 km/h
  242. */
  243. #define DIB3000MB_REG_MOBILE_ALGO ( 195)
  244. #define DIB3000MB_MOBILE_ALGO_ON ( 0)
  245. #define DIB3000MB_MOBILE_ALGO_OFF ( 1)
  246. /* multiple demodulators algorithm */
  247. #define DIB3000MB_REG_MULTI_DEMOD_MSB ( 206)
  248. #define DIB3000MB_REG_MULTI_DEMOD_LSB ( 207)
  249. /* terminator, no more demods */
  250. #define DIB3000MB_MULTI_DEMOD_MSB ( 32767)
  251. #define DIB3000MB_MULTI_DEMOD_LSB ( 4095)
  252. /* bring the device into a known */
  253. #define DIB3000MB_REG_RESET_DEVICE ( 1024)
  254. #define DIB3000MB_RESET_DEVICE (0x812c)
  255. #define DIB3000MB_RESET_DEVICE_RST ( 0)
  256. /* hardware clock configuration */
  257. #define DIB3000MB_REG_CLOCK ( 1027)
  258. #define DIB3000MB_CLOCK_DEFAULT (0x9000)
  259. #define DIB3000MB_CLOCK_DIVERSITY (0x92b0)
  260. /* power down config */
  261. #define DIB3000MB_REG_POWER_CONTROL ( 1028)
  262. #define DIB3000MB_POWER_DOWN ( 1)
  263. #define DIB3000MB_POWER_UP ( 0)
  264. /* electrical output mode */
  265. #define DIB3000MB_REG_ELECT_OUT_MODE ( 1029)
  266. #define DIB3000MB_ELECT_OUT_MODE_OFF ( 0)
  267. #define DIB3000MB_ELECT_OUT_MODE_ON ( 1)
  268. /* set the tuner i2c address */
  269. #define DIB3000MB_REG_TUNER ( 1089)
  270. /* monitoring registers (read only) */
  271. /* agc loop locked (size: 1) */
  272. #define DIB3000MB_REG_AGC_LOCK ( 324)
  273. /* agc power (size: 16) */
  274. #define DIB3000MB_REG_AGC_POWER ( 325)
  275. /* agc1 value (16) */
  276. #define DIB3000MB_REG_AGC1_VALUE ( 326)
  277. /* agc2 value (16) */
  278. #define DIB3000MB_REG_AGC2_VALUE ( 327)
  279. /* total RF power (16), can be used for signal strength */
  280. #define DIB3000MB_REG_RF_POWER ( 328)
  281. /* dds_frequency with offset (24) */
  282. #define DIB3000MB_REG_DDS_VALUE_MSB ( 339)
  283. #define DIB3000MB_REG_DDS_VALUE_LSB ( 340)
  284. /* timing offset signed (24) */
  285. #define DIB3000MB_REG_TIMING_OFFSET_MSB ( 341)
  286. #define DIB3000MB_REG_TIMING_OFFSET_LSB ( 342)
  287. /* fft start position (13) */
  288. #define DIB3000MB_REG_FFT_WINDOW_POS ( 353)
  289. /* carriers locked (1) */
  290. #define DIB3000MB_REG_CARRIER_LOCK ( 355)
  291. /* noise power (24) */
  292. #define DIB3000MB_REG_NOISE_POWER_MSB ( 372)
  293. #define DIB3000MB_REG_NOISE_POWER_LSB ( 373)
  294. #define DIB3000MB_REG_MOBILE_NOISE_MSB ( 374)
  295. #define DIB3000MB_REG_MOBILE_NOISE_LSB ( 375)
  296. /*
  297. * signal power (16), this and the above can be
  298. * used to calculate the signal/noise - ratio
  299. */
  300. #define DIB3000MB_REG_SIGNAL_POWER ( 380)
  301. /* mer (24) */
  302. #define DIB3000MB_REG_MER_MSB ( 381)
  303. #define DIB3000MB_REG_MER_LSB ( 382)
  304. /*
  305. * Transmission Parameter Signalling (TPS)
  306. * the following registers can be used to get TPS-information.
  307. * The values are according to the DVB-T standard.
  308. */
  309. /* TPS locked (1) */
  310. #define DIB3000MB_REG_TPS_LOCK ( 394)
  311. /* QAM from TPS (2) (values according to DIB3000MB_REG_QAM) */
  312. #define DIB3000MB_REG_TPS_QAM ( 398)
  313. /* hierarchy from TPS (1) */
  314. #define DIB3000MB_REG_TPS_HRCH ( 399)
  315. /* alpha from TPS (3) (values according to DIB3000MB_REG_VIT_ALPHA) */
  316. #define DIB3000MB_REG_TPS_VIT_ALPHA ( 400)
  317. /* code rate high priority from TPS (3) (values according to DIB3000MB_FEC_*) */
  318. #define DIB3000MB_REG_TPS_CODE_RATE_HP ( 401)
  319. /* code rate low priority from TPS (3) if DIB3000MB_REG_TPS_VIT_ALPHA */
  320. #define DIB3000MB_REG_TPS_CODE_RATE_LP ( 402)
  321. /* guard time from TPS (2) (values according to DIB3000MB_REG_GUARD_TIME */
  322. #define DIB3000MB_REG_TPS_GUARD_TIME ( 403)
  323. /* fft size from TPS (2) (values according to DIB3000MB_REG_FFT) */
  324. #define DIB3000MB_REG_TPS_FFT ( 404)
  325. /* cell id from TPS (16) */
  326. #define DIB3000MB_REG_TPS_CELL_ID ( 406)
  327. /* TPS (68) */
  328. #define DIB3000MB_REG_TPS_1 ( 408)
  329. #define DIB3000MB_REG_TPS_2 ( 409)
  330. #define DIB3000MB_REG_TPS_3 ( 410)
  331. #define DIB3000MB_REG_TPS_4 ( 411)
  332. #define DIB3000MB_REG_TPS_5 ( 412)
  333. /* bit error rate (before RS correction) (21) */
  334. #define DIB3000MB_REG_BER_MSB ( 414)
  335. #define DIB3000MB_REG_BER_LSB ( 415)
  336. /* packet error rate (uncorrected TS packets) (16) */
  337. #define DIB3000MB_REG_PACKET_ERROR_RATE ( 417)
  338. /* uncorrected packet count (16) */
  339. #define DIB3000MB_REG_UNC ( 420)
  340. /* viterbi locked (1) */
  341. #define DIB3000MB_REG_VIT_LCK ( 421)
  342. /* viterbi inidcator (16) */
  343. #define DIB3000MB_REG_VIT_INDICATOR ( 422)
  344. /* transport stream sync lock (1) */
  345. #define DIB3000MB_REG_TS_SYNC_LOCK ( 423)
  346. /* transport stream RS lock (1) */
  347. #define DIB3000MB_REG_TS_RS_LOCK ( 424)
  348. /* lock mask 0 value (1) */
  349. #define DIB3000MB_REG_LOCK0_VALUE ( 425)
  350. /* lock mask 1 value (1) */
  351. #define DIB3000MB_REG_LOCK1_VALUE ( 426)
  352. /* lock mask 2 value (1) */
  353. #define DIB3000MB_REG_LOCK2_VALUE ( 427)
  354. /* interrupt pending for auto search */
  355. #define DIB3000MB_REG_AS_IRQ_PENDING ( 434)
  356. #endif