af9033_priv.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. /*
  2. * Afatech AF9033 demodulator driver
  3. *
  4. * Copyright (C) 2009 Antti Palosaari <crope@iki.fi>
  5. * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along
  18. * with this program; if not, write to the Free Software Foundation, Inc.,
  19. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  20. */
  21. #ifndef AF9033_PRIV_H
  22. #define AF9033_PRIV_H
  23. #include "dvb_frontend.h"
  24. #include "af9033.h"
  25. struct reg_val {
  26. u32 reg;
  27. u8 val;
  28. };
  29. struct reg_val_mask {
  30. u32 reg;
  31. u8 val;
  32. u8 mask;
  33. };
  34. struct coeff {
  35. u32 clock;
  36. u32 bandwidth_hz;
  37. u8 val[36];
  38. };
  39. struct clock_adc {
  40. u32 clock;
  41. u32 adc;
  42. };
  43. struct val_snr {
  44. u32 val;
  45. u8 snr;
  46. };
  47. /* Xtal clock vs. ADC clock lookup table */
  48. static const struct clock_adc clock_adc_lut[] = {
  49. { 16384000, 20480000 },
  50. { 20480000, 20480000 },
  51. { 36000000, 20250000 },
  52. { 30000000, 20156250 },
  53. { 26000000, 20583333 },
  54. { 28000000, 20416667 },
  55. { 32000000, 20500000 },
  56. { 34000000, 20187500 },
  57. { 24000000, 20500000 },
  58. { 22000000, 20625000 },
  59. { 12000000, 20250000 },
  60. };
  61. /* pre-calculated coeff lookup table */
  62. static const struct coeff coeff_lut[] = {
  63. /* 12.000 MHz */
  64. { 12000000, 8000000, {
  65. 0x01, 0xce, 0x55, 0xc9, 0x00, 0xe7, 0x2a, 0xe4, 0x00, 0x73,
  66. 0x99, 0x0f, 0x00, 0x73, 0x95, 0x72, 0x00, 0x73, 0x91, 0xd5,
  67. 0x00, 0x39, 0xca, 0xb9, 0x00, 0xe7, 0x2a, 0xe4, 0x00, 0x73,
  68. 0x95, 0x72, 0x37, 0x02, 0xce, 0x01 }
  69. },
  70. { 12000000, 7000000, {
  71. 0x01, 0x94, 0x8b, 0x10, 0x00, 0xca, 0x45, 0x88, 0x00, 0x65,
  72. 0x25, 0xed, 0x00, 0x65, 0x22, 0xc4, 0x00, 0x65, 0x1f, 0x9b,
  73. 0x00, 0x32, 0x91, 0x62, 0x00, 0xca, 0x45, 0x88, 0x00, 0x65,
  74. 0x22, 0xc4, 0x88, 0x02, 0x95, 0x01 }
  75. },
  76. { 12000000, 6000000, {
  77. 0x01, 0x5a, 0xc0, 0x56, 0x00, 0xad, 0x60, 0x2b, 0x00, 0x56,
  78. 0xb2, 0xcb, 0x00, 0x56, 0xb0, 0x15, 0x00, 0x56, 0xad, 0x60,
  79. 0x00, 0x2b, 0x58, 0x0b, 0x00, 0xad, 0x60, 0x2b, 0x00, 0x56,
  80. 0xb0, 0x15, 0xf4, 0x02, 0x5b, 0x01 }
  81. },
  82. };
  83. /* QPSK SNR lookup table */
  84. static const struct val_snr qpsk_snr_lut[] = {
  85. { 0x0b4771, 0 },
  86. { 0x0c1aed, 1 },
  87. { 0x0d0d27, 2 },
  88. { 0x0e4d19, 3 },
  89. { 0x0e5da8, 4 },
  90. { 0x107097, 5 },
  91. { 0x116975, 6 },
  92. { 0x1252d9, 7 },
  93. { 0x131fa4, 8 },
  94. { 0x13d5e1, 9 },
  95. { 0x148e53, 10 },
  96. { 0x15358b, 11 },
  97. { 0x15dd29, 12 },
  98. { 0x168112, 13 },
  99. { 0x170b61, 14 },
  100. { 0x17a532, 15 },
  101. { 0x180f94, 16 },
  102. { 0x186ed2, 17 },
  103. { 0x18b271, 18 },
  104. { 0x18e118, 19 },
  105. { 0x18ff4b, 20 },
  106. { 0x190af1, 21 },
  107. { 0x191451, 22 },
  108. { 0xffffff, 23 },
  109. };
  110. /* QAM16 SNR lookup table */
  111. static const struct val_snr qam16_snr_lut[] = {
  112. { 0x04f0d5, 0 },
  113. { 0x05387a, 1 },
  114. { 0x0573a4, 2 },
  115. { 0x05a99e, 3 },
  116. { 0x05cc80, 4 },
  117. { 0x05eb62, 5 },
  118. { 0x05fecf, 6 },
  119. { 0x060b80, 7 },
  120. { 0x062501, 8 },
  121. { 0x064865, 9 },
  122. { 0x069604, 10 },
  123. { 0x06f356, 11 },
  124. { 0x07706a, 12 },
  125. { 0x0804d3, 13 },
  126. { 0x089d1a, 14 },
  127. { 0x093e3d, 15 },
  128. { 0x09e35d, 16 },
  129. { 0x0a7c3c, 17 },
  130. { 0x0afaf8, 18 },
  131. { 0x0b719d, 19 },
  132. { 0x0bda6a, 20 },
  133. { 0x0c0c75, 21 },
  134. { 0x0c3f7d, 22 },
  135. { 0x0c5e62, 23 },
  136. { 0x0c6c31, 24 },
  137. { 0x0c7925, 25 },
  138. { 0xffffff, 26 },
  139. };
  140. /* QAM64 SNR lookup table */
  141. static const struct val_snr qam64_snr_lut[] = {
  142. { 0x0256d0, 0 },
  143. { 0x027a65, 1 },
  144. { 0x029873, 2 },
  145. { 0x02b7fe, 3 },
  146. { 0x02cf1e, 4 },
  147. { 0x02e234, 5 },
  148. { 0x02f409, 6 },
  149. { 0x030046, 7 },
  150. { 0x030844, 8 },
  151. { 0x030a02, 9 },
  152. { 0x030cde, 10 },
  153. { 0x031031, 11 },
  154. { 0x03144c, 12 },
  155. { 0x0315dd, 13 },
  156. { 0x031920, 14 },
  157. { 0x0322d0, 15 },
  158. { 0x0339fc, 16 },
  159. { 0x0364a1, 17 },
  160. { 0x038bcc, 18 },
  161. { 0x03c7d3, 19 },
  162. { 0x0408cc, 20 },
  163. { 0x043bed, 21 },
  164. { 0x048061, 22 },
  165. { 0x04be95, 23 },
  166. { 0x04fa7d, 24 },
  167. { 0x052405, 25 },
  168. { 0x05570d, 26 },
  169. { 0x059feb, 27 },
  170. { 0x05bf38, 28 },
  171. { 0xffffff, 29 },
  172. };
  173. static const struct reg_val ofsm_init[] = {
  174. { 0x800051, 0x01 },
  175. { 0x800070, 0x0a },
  176. { 0x80007e, 0x04 },
  177. { 0x800081, 0x0a },
  178. { 0x80008a, 0x01 },
  179. { 0x80008e, 0x01 },
  180. { 0x800092, 0x06 },
  181. { 0x800099, 0x01 },
  182. { 0x80009f, 0xe1 },
  183. { 0x8000a0, 0xcf },
  184. { 0x8000a3, 0x01 },
  185. { 0x8000a5, 0x01 },
  186. { 0x8000a6, 0x01 },
  187. { 0x8000a9, 0x00 },
  188. { 0x8000aa, 0x01 },
  189. { 0x8000b0, 0x01 },
  190. { 0x8000c4, 0x05 },
  191. { 0x8000c8, 0x19 },
  192. { 0x80f000, 0x0f },
  193. { 0x80f016, 0x10 },
  194. { 0x80f017, 0x04 },
  195. { 0x80f018, 0x05 },
  196. { 0x80f019, 0x04 },
  197. { 0x80f01a, 0x05 },
  198. { 0x80f021, 0x03 },
  199. { 0x80f022, 0x0a },
  200. { 0x80f023, 0x0a },
  201. { 0x80f02b, 0x00 },
  202. { 0x80f02c, 0x01 },
  203. { 0x80f064, 0x03 },
  204. { 0x80f065, 0xf9 },
  205. { 0x80f066, 0x03 },
  206. { 0x80f067, 0x01 },
  207. { 0x80f06f, 0xe0 },
  208. { 0x80f070, 0x03 },
  209. { 0x80f072, 0x0f },
  210. { 0x80f073, 0x03 },
  211. { 0x80f078, 0x00 },
  212. { 0x80f087, 0x00 },
  213. { 0x80f09b, 0x3f },
  214. { 0x80f09c, 0x00 },
  215. { 0x80f09d, 0x20 },
  216. { 0x80f09e, 0x00 },
  217. { 0x80f09f, 0x0c },
  218. { 0x80f0a0, 0x00 },
  219. { 0x80f130, 0x04 },
  220. { 0x80f132, 0x04 },
  221. { 0x80f144, 0x1a },
  222. { 0x80f146, 0x00 },
  223. { 0x80f14a, 0x01 },
  224. { 0x80f14c, 0x00 },
  225. { 0x80f14d, 0x00 },
  226. { 0x80f14f, 0x04 },
  227. { 0x80f158, 0x7f },
  228. { 0x80f15a, 0x00 },
  229. { 0x80f15b, 0x08 },
  230. { 0x80f15d, 0x03 },
  231. { 0x80f15e, 0x05 },
  232. { 0x80f163, 0x05 },
  233. { 0x80f166, 0x01 },
  234. { 0x80f167, 0x40 },
  235. { 0x80f168, 0x0f },
  236. { 0x80f17a, 0x00 },
  237. { 0x80f17b, 0x00 },
  238. { 0x80f183, 0x01 },
  239. { 0x80f19d, 0x40 },
  240. { 0x80f1bc, 0x36 },
  241. { 0x80f1bd, 0x00 },
  242. { 0x80f1cb, 0xa0 },
  243. { 0x80f1cc, 0x01 },
  244. { 0x80f204, 0x10 },
  245. { 0x80f214, 0x00 },
  246. { 0x80f40e, 0x0a },
  247. { 0x80f40f, 0x40 },
  248. { 0x80f410, 0x08 },
  249. { 0x80f55f, 0x0a },
  250. { 0x80f561, 0x15 },
  251. { 0x80f562, 0x20 },
  252. { 0x80f5df, 0xfb },
  253. { 0x80f5e0, 0x00 },
  254. { 0x80f5e3, 0x09 },
  255. { 0x80f5e4, 0x01 },
  256. { 0x80f5e5, 0x01 },
  257. { 0x80f5f8, 0x01 },
  258. { 0x80f5fd, 0x01 },
  259. { 0x80f600, 0x05 },
  260. { 0x80f601, 0x08 },
  261. { 0x80f602, 0x0b },
  262. { 0x80f603, 0x0e },
  263. { 0x80f604, 0x11 },
  264. { 0x80f605, 0x14 },
  265. { 0x80f606, 0x17 },
  266. { 0x80f607, 0x1f },
  267. { 0x80f60e, 0x00 },
  268. { 0x80f60f, 0x04 },
  269. { 0x80f610, 0x32 },
  270. { 0x80f611, 0x10 },
  271. { 0x80f707, 0xfc },
  272. { 0x80f708, 0x00 },
  273. { 0x80f709, 0x37 },
  274. { 0x80f70a, 0x00 },
  275. { 0x80f78b, 0x01 },
  276. { 0x80f80f, 0x40 },
  277. { 0x80f810, 0x54 },
  278. { 0x80f811, 0x5a },
  279. { 0x80f905, 0x01 },
  280. { 0x80fb06, 0x03 },
  281. { 0x80fd8b, 0x00 },
  282. };
  283. /* Infineon TUA 9001 tuner init
  284. AF9033_TUNER_TUA9001 = 0x27 */
  285. static const struct reg_val tuner_init_tua9001[] = {
  286. { 0x800046, 0x27 },
  287. { 0x800057, 0x00 },
  288. { 0x800058, 0x01 },
  289. { 0x80005f, 0x00 },
  290. { 0x800060, 0x00 },
  291. { 0x80006d, 0x00 },
  292. { 0x800071, 0x05 },
  293. { 0x800072, 0x02 },
  294. { 0x800074, 0x01 },
  295. { 0x800075, 0x03 },
  296. { 0x800076, 0x02 },
  297. { 0x800077, 0x00 },
  298. { 0x800078, 0x01 },
  299. { 0x800079, 0x00 },
  300. { 0x80007a, 0x7e },
  301. { 0x80007b, 0x3e },
  302. { 0x800093, 0x00 },
  303. { 0x800094, 0x01 },
  304. { 0x800095, 0x02 },
  305. { 0x800096, 0x01 },
  306. { 0x800098, 0x0a },
  307. { 0x80009b, 0x05 },
  308. { 0x80009c, 0x80 },
  309. { 0x8000b3, 0x00 },
  310. { 0x8000c5, 0x01 },
  311. { 0x8000c6, 0x00 },
  312. { 0x8000c9, 0x5d },
  313. { 0x80f007, 0x00 },
  314. { 0x80f01f, 0x82 },
  315. { 0x80f020, 0x00 },
  316. { 0x80f029, 0x82 },
  317. { 0x80f02a, 0x00 },
  318. { 0x80f047, 0x00 },
  319. { 0x80f054, 0x00 },
  320. { 0x80f055, 0x00 },
  321. { 0x80f077, 0x01 },
  322. { 0x80f1e6, 0x00 },
  323. };
  324. /* Fitipower fc0011 tuner init
  325. AF9033_TUNER_FC0011 = 0x28 */
  326. static const struct reg_val tuner_init_fc0011[] = {
  327. { 0x800046, 0x28 },
  328. { 0x800057, 0x00 },
  329. { 0x800058, 0x01 },
  330. { 0x80005f, 0x00 },
  331. { 0x800060, 0x00 },
  332. { 0x800068, 0xa5 },
  333. { 0x80006e, 0x01 },
  334. { 0x800071, 0x0a },
  335. { 0x800072, 0x02 },
  336. { 0x800074, 0x01 },
  337. { 0x800079, 0x01 },
  338. { 0x800093, 0x00 },
  339. { 0x800094, 0x00 },
  340. { 0x800095, 0x00 },
  341. { 0x800096, 0x00 },
  342. { 0x80009b, 0x2d },
  343. { 0x80009c, 0x60 },
  344. { 0x80009d, 0x23 },
  345. { 0x8000a4, 0x50 },
  346. { 0x8000ad, 0x50 },
  347. { 0x8000b3, 0x01 },
  348. { 0x8000b7, 0x88 },
  349. { 0x8000b8, 0xa6 },
  350. { 0x8000c5, 0x01 },
  351. { 0x8000c6, 0x01 },
  352. { 0x8000c9, 0x69 },
  353. { 0x80f007, 0x00 },
  354. { 0x80f00a, 0x1b },
  355. { 0x80f00b, 0x1b },
  356. { 0x80f00c, 0x1b },
  357. { 0x80f00d, 0x1b },
  358. { 0x80f00e, 0xff },
  359. { 0x80f00f, 0x01 },
  360. { 0x80f010, 0x00 },
  361. { 0x80f011, 0x02 },
  362. { 0x80f012, 0xff },
  363. { 0x80f013, 0x01 },
  364. { 0x80f014, 0x00 },
  365. { 0x80f015, 0x02 },
  366. { 0x80f01b, 0xef },
  367. { 0x80f01c, 0x01 },
  368. { 0x80f01d, 0x0f },
  369. { 0x80f01e, 0x02 },
  370. { 0x80f01f, 0x6e },
  371. { 0x80f020, 0x00 },
  372. { 0x80f025, 0xde },
  373. { 0x80f026, 0x00 },
  374. { 0x80f027, 0x0a },
  375. { 0x80f028, 0x03 },
  376. { 0x80f029, 0x6e },
  377. { 0x80f02a, 0x00 },
  378. { 0x80f047, 0x00 },
  379. { 0x80f054, 0x00 },
  380. { 0x80f055, 0x00 },
  381. { 0x80f077, 0x01 },
  382. { 0x80f1e6, 0x00 },
  383. };
  384. /* Fitipower FC0012 tuner init
  385. AF9033_TUNER_FC0012 = 0x2e */
  386. static const struct reg_val tuner_init_fc0012[] = {
  387. { 0x800046, 0x2e },
  388. { 0x800057, 0x00 },
  389. { 0x800058, 0x01 },
  390. { 0x800059, 0x01 },
  391. { 0x80005f, 0x00 },
  392. { 0x800060, 0x00 },
  393. { 0x80006d, 0x00 },
  394. { 0x800071, 0x05 },
  395. { 0x800072, 0x02 },
  396. { 0x800074, 0x01 },
  397. { 0x800075, 0x03 },
  398. { 0x800076, 0x02 },
  399. { 0x800077, 0x01 },
  400. { 0x800078, 0x00 },
  401. { 0x800079, 0x00 },
  402. { 0x80007a, 0x90 },
  403. { 0x80007b, 0x90 },
  404. { 0x800093, 0x00 },
  405. { 0x800094, 0x01 },
  406. { 0x800095, 0x02 },
  407. { 0x800096, 0x01 },
  408. { 0x800098, 0x0a },
  409. { 0x80009b, 0x05 },
  410. { 0x80009c, 0x80 },
  411. { 0x8000b3, 0x00 },
  412. { 0x8000c5, 0x01 },
  413. { 0x8000c6, 0x00 },
  414. { 0x8000c9, 0x5d },
  415. { 0x80f007, 0x00 },
  416. { 0x80f01f, 0xa0 },
  417. { 0x80f020, 0x00 },
  418. { 0x80f029, 0x82 },
  419. { 0x80f02a, 0x00 },
  420. { 0x80f047, 0x00 },
  421. { 0x80f054, 0x00 },
  422. { 0x80f055, 0x00 },
  423. { 0x80f077, 0x01 },
  424. { 0x80f1e6, 0x00 },
  425. };
  426. /* MaxLinear MxL5007T tuner init
  427. AF9033_TUNER_MXL5007T = 0xa0 */
  428. static const struct reg_val tuner_init_mxl5007t[] = {
  429. { 0x800046, 0x1b },
  430. { 0x800057, 0x01 },
  431. { 0x800058, 0x01 },
  432. { 0x80005f, 0x00 },
  433. { 0x800060, 0x00 },
  434. { 0x800068, 0x96 },
  435. { 0x800071, 0x05 },
  436. { 0x800072, 0x02 },
  437. { 0x800074, 0x01 },
  438. { 0x800079, 0x01 },
  439. { 0x800093, 0x00 },
  440. { 0x800094, 0x00 },
  441. { 0x800095, 0x00 },
  442. { 0x800096, 0x00 },
  443. { 0x8000b3, 0x01 },
  444. { 0x8000c1, 0x01 },
  445. { 0x8000c2, 0x00 },
  446. { 0x80f007, 0x00 },
  447. { 0x80f00c, 0x19 },
  448. { 0x80f00d, 0x1a },
  449. { 0x80f012, 0xda },
  450. { 0x80f013, 0x00 },
  451. { 0x80f014, 0x00 },
  452. { 0x80f015, 0x02 },
  453. { 0x80f01f, 0x82 },
  454. { 0x80f020, 0x00 },
  455. { 0x80f029, 0x82 },
  456. { 0x80f02a, 0x00 },
  457. { 0x80f077, 0x02 },
  458. { 0x80f1e6, 0x00 },
  459. };
  460. /* NXP TDA 18218HN tuner init
  461. AF9033_TUNER_TDA18218 = 0xa1 */
  462. static const struct reg_val tuner_init_tda18218[] = {
  463. {0x800046, 0xa1},
  464. {0x800057, 0x01},
  465. {0x800058, 0x01},
  466. {0x80005f, 0x00},
  467. {0x800060, 0x00},
  468. {0x800071, 0x05},
  469. {0x800072, 0x02},
  470. {0x800074, 0x01},
  471. {0x800079, 0x01},
  472. {0x800093, 0x00},
  473. {0x800094, 0x00},
  474. {0x800095, 0x00},
  475. {0x800096, 0x00},
  476. {0x8000b3, 0x01},
  477. {0x8000c3, 0x01},
  478. {0x8000c4, 0x00},
  479. {0x80f007, 0x00},
  480. {0x80f00c, 0x19},
  481. {0x80f00d, 0x1a},
  482. {0x80f012, 0xda},
  483. {0x80f013, 0x00},
  484. {0x80f014, 0x00},
  485. {0x80f015, 0x02},
  486. {0x80f01f, 0x82},
  487. {0x80f020, 0x00},
  488. {0x80f029, 0x82},
  489. {0x80f02a, 0x00},
  490. {0x80f077, 0x02},
  491. {0x80f1e6, 0x00},
  492. };
  493. /* FCI FC2580 tuner init */
  494. static const struct reg_val tuner_init_fc2580[] = {
  495. { 0x800046, 0x32 },
  496. { 0x800057, 0x01 },
  497. { 0x800058, 0x00 },
  498. { 0x80005f, 0x00 },
  499. { 0x800060, 0x00 },
  500. { 0x800071, 0x05 },
  501. { 0x800072, 0x02 },
  502. { 0x800074, 0x01 },
  503. { 0x800079, 0x01 },
  504. { 0x800093, 0x00 },
  505. { 0x800094, 0x00 },
  506. { 0x800095, 0x00 },
  507. { 0x800096, 0x05 },
  508. { 0x8000b3, 0x01 },
  509. { 0x8000c5, 0x01 },
  510. { 0x8000c6, 0x00 },
  511. { 0x8000d1, 0x01 },
  512. { 0x80f007, 0x00 },
  513. { 0x80f00c, 0x19 },
  514. { 0x80f00d, 0x1a },
  515. { 0x80f00e, 0x00 },
  516. { 0x80f00f, 0x02 },
  517. { 0x80f010, 0x00 },
  518. { 0x80f011, 0x02 },
  519. { 0x80f012, 0x00 },
  520. { 0x80f013, 0x02 },
  521. { 0x80f014, 0x00 },
  522. { 0x80f015, 0x02 },
  523. { 0x80f01f, 0x96 },
  524. { 0x80f020, 0x00 },
  525. { 0x80f029, 0x96 },
  526. { 0x80f02a, 0x00 },
  527. { 0x80f077, 0x01 },
  528. { 0x80f1e6, 0x01 },
  529. };
  530. #endif /* AF9033_PRIV_H */