hd29l2_priv.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. /*
  2. * HDIC HD29L2 DMB-TH demodulator driver
  3. *
  4. * Copyright (C) 2011 Metropolia University of Applied Sciences, Electria R&D
  5. *
  6. * Author: Antti Palosaari <crope@iki.fi>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. */
  22. #ifndef HD29L2_PRIV
  23. #define HD29L2_PRIV
  24. #include <linux/dvb/version.h>
  25. #include "dvb_frontend.h"
  26. #include "dvb_math.h"
  27. #include "hd29l2.h"
  28. #define HD29L2_XTAL 30400000 /* Hz */
  29. #define HD29L2_QAM4NR 0x00
  30. #define HD29L2_QAM4 0x01
  31. #define HD29L2_QAM16 0x02
  32. #define HD29L2_QAM32 0x03
  33. #define HD29L2_QAM64 0x04
  34. #define HD29L2_CODE_RATE_04 0x00
  35. #define HD29L2_CODE_RATE_06 0x08
  36. #define HD29L2_CODE_RATE_08 0x10
  37. #define HD29L2_PN945 0x00
  38. #define HD29L2_PN595 0x01
  39. #define HD29L2_PN420 0x02
  40. #define HD29L2_CARRIER_SINGLE 0x00
  41. #define HD29L2_CARRIER_MULTI 0x01
  42. #define HD29L2_INTERLEAVER_720 0x00
  43. #define HD29L2_INTERLEAVER_420 0x01
  44. struct reg_val {
  45. u8 reg;
  46. u8 val;
  47. };
  48. struct reg_mod_vals {
  49. u8 reg;
  50. u8 val[5];
  51. };
  52. struct hd29l2_priv {
  53. struct i2c_adapter *i2c;
  54. struct dvb_frontend fe;
  55. struct hd29l2_config cfg;
  56. u8 tuner_i2c_addr_programmed:1;
  57. enum fe_status fe_status;
  58. };
  59. static const struct reg_mod_vals reg_mod_vals_tab[] = {
  60. /* REG, QAM4NR, QAM4,QAM16,QAM32,QAM64 */
  61. { 0x01, { 0x10, 0x10, 0x10, 0x10, 0x10 } },
  62. { 0x02, { 0x07, 0x07, 0x07, 0x07, 0x07 } },
  63. { 0x03, { 0x10, 0x10, 0x10, 0x10, 0x10 } },
  64. { 0x04, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  65. { 0x05, { 0x61, 0x60, 0x60, 0x61, 0x60 } },
  66. { 0x06, { 0xff, 0xff, 0xff, 0xff, 0xff } },
  67. { 0x07, { 0xff, 0xff, 0xff, 0xff, 0xff } },
  68. { 0x08, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  69. { 0x09, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  70. { 0x0a, { 0x15, 0x15, 0x03, 0x03, 0x03 } },
  71. { 0x0d, { 0x78, 0x78, 0x88, 0x78, 0x78 } },
  72. { 0x0e, { 0xa0, 0x90, 0xa0, 0xa0, 0xa0 } },
  73. { 0x0f, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  74. { 0x10, { 0xa0, 0xa0, 0x58, 0x38, 0x38 } },
  75. { 0x11, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  76. { 0x12, { 0x5a, 0x5a, 0x5a, 0x5a, 0x5a } },
  77. { 0x13, { 0xa2, 0xa2, 0xa2, 0xa2, 0xa2 } },
  78. { 0x17, { 0x40, 0x40, 0x40, 0x40, 0x40 } },
  79. { 0x18, { 0x21, 0x21, 0x42, 0x52, 0x42 } },
  80. { 0x19, { 0x21, 0x21, 0x62, 0x72, 0x62 } },
  81. { 0x1a, { 0x32, 0x43, 0xa9, 0xb9, 0xa9 } },
  82. { 0x1b, { 0x32, 0x43, 0xb9, 0xd8, 0xb9 } },
  83. { 0x1c, { 0x02, 0x02, 0x03, 0x02, 0x03 } },
  84. { 0x1d, { 0x0c, 0x0c, 0x01, 0x02, 0x02 } },
  85. { 0x1e, { 0x02, 0x02, 0x02, 0x01, 0x02 } },
  86. { 0x1f, { 0x02, 0x02, 0x01, 0x02, 0x04 } },
  87. { 0x20, { 0x01, 0x02, 0x01, 0x01, 0x01 } },
  88. { 0x21, { 0x08, 0x08, 0x0a, 0x0a, 0x0a } },
  89. { 0x22, { 0x06, 0x06, 0x04, 0x05, 0x05 } },
  90. { 0x23, { 0x06, 0x06, 0x05, 0x03, 0x05 } },
  91. { 0x24, { 0x08, 0x08, 0x05, 0x07, 0x07 } },
  92. { 0x25, { 0x16, 0x10, 0x10, 0x0a, 0x10 } },
  93. { 0x26, { 0x14, 0x14, 0x04, 0x04, 0x04 } },
  94. { 0x27, { 0x58, 0x58, 0x58, 0x5c, 0x58 } },
  95. { 0x28, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
  96. { 0x29, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
  97. { 0x2a, { 0x08, 0x0a, 0x08, 0x08, 0x08 } },
  98. { 0x2b, { 0x08, 0x08, 0x08, 0x08, 0x08 } },
  99. { 0x2c, { 0x06, 0x06, 0x06, 0x06, 0x06 } },
  100. { 0x2d, { 0x05, 0x06, 0x06, 0x06, 0x06 } },
  101. { 0x2e, { 0x21, 0x21, 0x21, 0x21, 0x21 } },
  102. { 0x2f, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  103. { 0x30, { 0x14, 0x14, 0x14, 0x14, 0x14 } },
  104. { 0x33, { 0xb7, 0xb7, 0xb7, 0xb7, 0xb7 } },
  105. { 0x34, { 0x81, 0x81, 0x81, 0x81, 0x81 } },
  106. { 0x35, { 0x80, 0x80, 0x80, 0x80, 0x80 } },
  107. { 0x37, { 0x70, 0x70, 0x70, 0x70, 0x70 } },
  108. { 0x38, { 0x04, 0x04, 0x02, 0x02, 0x02 } },
  109. { 0x39, { 0x07, 0x07, 0x05, 0x05, 0x05 } },
  110. { 0x3a, { 0x06, 0x06, 0x06, 0x06, 0x06 } },
  111. { 0x3b, { 0x03, 0x03, 0x03, 0x03, 0x03 } },
  112. { 0x3c, { 0x07, 0x06, 0x04, 0x04, 0x04 } },
  113. { 0x3d, { 0xf0, 0xf0, 0xf0, 0xf0, 0x80 } },
  114. { 0x3e, { 0x60, 0x60, 0x60, 0x60, 0xff } },
  115. { 0x3f, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  116. { 0x40, { 0x5b, 0x5b, 0x5b, 0x57, 0x50 } },
  117. { 0x41, { 0x30, 0x30, 0x30, 0x30, 0x18 } },
  118. { 0x42, { 0x20, 0x20, 0x20, 0x00, 0x30 } },
  119. { 0x43, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  120. { 0x44, { 0x3f, 0x3f, 0x3f, 0x3f, 0x3f } },
  121. { 0x45, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  122. { 0x46, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
  123. { 0x47, { 0x00, 0x00, 0x95, 0x00, 0x95 } },
  124. { 0x48, { 0xc0, 0xc0, 0xc0, 0xc0, 0xc0 } },
  125. { 0x49, { 0xc0, 0xc0, 0xc0, 0xc0, 0xc0 } },
  126. { 0x4a, { 0x40, 0x40, 0x33, 0x11, 0x11 } },
  127. { 0x4b, { 0x40, 0x40, 0x00, 0x00, 0x00 } },
  128. { 0x4c, { 0x40, 0x40, 0x99, 0x11, 0x11 } },
  129. { 0x4d, { 0x40, 0x40, 0x00, 0x00, 0x00 } },
  130. { 0x4e, { 0x40, 0x40, 0x66, 0x77, 0x77 } },
  131. { 0x4f, { 0x40, 0x40, 0x00, 0x00, 0x00 } },
  132. { 0x50, { 0x40, 0x40, 0x88, 0x33, 0x11 } },
  133. { 0x51, { 0x40, 0x40, 0x00, 0x00, 0x00 } },
  134. { 0x52, { 0x40, 0x40, 0x88, 0x02, 0x02 } },
  135. { 0x53, { 0x40, 0x40, 0x00, 0x02, 0x02 } },
  136. { 0x54, { 0x00, 0x00, 0x88, 0x33, 0x33 } },
  137. { 0x55, { 0x40, 0x40, 0x00, 0x00, 0x00 } },
  138. { 0x56, { 0x00, 0x00, 0x00, 0x0b, 0x00 } },
  139. { 0x57, { 0x40, 0x40, 0x0a, 0x0b, 0x0a } },
  140. { 0x58, { 0xaa, 0x00, 0x00, 0x00, 0x00 } },
  141. { 0x59, { 0x7a, 0x40, 0x02, 0x02, 0x02 } },
  142. { 0x5a, { 0x18, 0x18, 0x01, 0x01, 0x01 } },
  143. { 0x5b, { 0x18, 0x18, 0x01, 0x01, 0x01 } },
  144. { 0x5c, { 0x18, 0x18, 0x01, 0x01, 0x01 } },
  145. { 0x5d, { 0x18, 0x18, 0x01, 0x01, 0x01 } },
  146. { 0x5e, { 0xc0, 0xc0, 0xc0, 0xff, 0xc0 } },
  147. { 0x5f, { 0xc0, 0xc0, 0xc0, 0xff, 0xc0 } },
  148. { 0x60, { 0x40, 0x40, 0x00, 0x30, 0x30 } },
  149. { 0x61, { 0x40, 0x40, 0x10, 0x30, 0x30 } },
  150. { 0x62, { 0x40, 0x40, 0x00, 0x30, 0x30 } },
  151. { 0x63, { 0x40, 0x40, 0x05, 0x30, 0x30 } },
  152. { 0x64, { 0x40, 0x40, 0x06, 0x00, 0x30 } },
  153. { 0x65, { 0x40, 0x40, 0x06, 0x08, 0x30 } },
  154. { 0x66, { 0x40, 0x40, 0x00, 0x00, 0x20 } },
  155. { 0x67, { 0x40, 0x40, 0x01, 0x04, 0x20 } },
  156. { 0x68, { 0x00, 0x00, 0x30, 0x00, 0x20 } },
  157. { 0x69, { 0xa0, 0xa0, 0x00, 0x08, 0x20 } },
  158. { 0x6a, { 0x00, 0x00, 0x30, 0x00, 0x25 } },
  159. { 0x6b, { 0xa0, 0xa0, 0x00, 0x06, 0x25 } },
  160. { 0x6c, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  161. { 0x6d, { 0xa0, 0x60, 0x0c, 0x03, 0x0c } },
  162. { 0x6e, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  163. { 0x6f, { 0xa0, 0x60, 0x04, 0x01, 0x04 } },
  164. { 0x70, { 0x58, 0x58, 0xaa, 0xaa, 0xaa } },
  165. { 0x71, { 0x58, 0x58, 0xaa, 0xaa, 0xaa } },
  166. { 0x72, { 0x58, 0x58, 0xff, 0xff, 0xff } },
  167. { 0x73, { 0x58, 0x58, 0xff, 0xff, 0xff } },
  168. { 0x74, { 0x06, 0x06, 0x09, 0x05, 0x05 } },
  169. { 0x75, { 0x06, 0x06, 0x0a, 0x10, 0x10 } },
  170. { 0x76, { 0x10, 0x10, 0x06, 0x0a, 0x0a } },
  171. { 0x77, { 0x12, 0x18, 0x28, 0x10, 0x28 } },
  172. { 0x78, { 0xf8, 0xf8, 0xf8, 0xf8, 0xf8 } },
  173. { 0x79, { 0x15, 0x15, 0x03, 0x03, 0x03 } },
  174. { 0x7a, { 0x02, 0x02, 0x01, 0x04, 0x03 } },
  175. { 0x7b, { 0x01, 0x02, 0x03, 0x03, 0x03 } },
  176. { 0x7c, { 0x28, 0x28, 0x28, 0x28, 0x28 } },
  177. { 0x7f, { 0x25, 0x92, 0x5f, 0x17, 0x2d } },
  178. { 0x80, { 0x64, 0x64, 0x64, 0x74, 0x64 } },
  179. { 0x83, { 0x06, 0x03, 0x04, 0x04, 0x04 } },
  180. { 0x84, { 0xff, 0xff, 0xff, 0xff, 0xff } },
  181. { 0x85, { 0x05, 0x05, 0x05, 0x05, 0x05 } },
  182. { 0x86, { 0x00, 0x00, 0x11, 0x11, 0x11 } },
  183. { 0x87, { 0x03, 0x03, 0x03, 0x03, 0x03 } },
  184. { 0x88, { 0x09, 0x09, 0x09, 0x09, 0x09 } },
  185. { 0x89, { 0x20, 0x20, 0x30, 0x20, 0x20 } },
  186. { 0x8a, { 0x03, 0x03, 0x02, 0x03, 0x02 } },
  187. { 0x8b, { 0x00, 0x07, 0x09, 0x00, 0x09 } },
  188. { 0x8c, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  189. { 0x8d, { 0x4f, 0x4f, 0x4f, 0x3f, 0x4f } },
  190. { 0x8e, { 0xf0, 0xf0, 0x60, 0xf0, 0xa0 } },
  191. { 0x8f, { 0xe8, 0xe8, 0xe8, 0xe8, 0xe8 } },
  192. { 0x90, { 0x10, 0x10, 0x10, 0x10, 0x10 } },
  193. { 0x91, { 0x40, 0x40, 0x70, 0x70, 0x10 } },
  194. { 0x92, { 0x00, 0x00, 0x00, 0x00, 0x04 } },
  195. { 0x93, { 0x60, 0x60, 0x60, 0x60, 0x60 } },
  196. { 0x94, { 0x00, 0x00, 0x00, 0x00, 0x03 } },
  197. { 0x95, { 0x09, 0x09, 0x47, 0x47, 0x47 } },
  198. { 0x96, { 0x80, 0xa0, 0xa0, 0x40, 0xa0 } },
  199. { 0x97, { 0x60, 0x60, 0x60, 0x60, 0x60 } },
  200. { 0x98, { 0x50, 0x50, 0x50, 0x30, 0x50 } },
  201. { 0x99, { 0x10, 0x10, 0x10, 0x10, 0x10 } },
  202. { 0x9a, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  203. { 0x9b, { 0x40, 0x40, 0x40, 0x30, 0x40 } },
  204. { 0x9c, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  205. { 0xa0, { 0xf0, 0xf0, 0xf0, 0xf0, 0xf0 } },
  206. { 0xa1, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  207. { 0xa2, { 0x30, 0x30, 0x00, 0x30, 0x00 } },
  208. { 0xa3, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  209. { 0xa4, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  210. { 0xa5, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  211. { 0xa6, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  212. { 0xa7, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  213. { 0xa8, { 0x77, 0x77, 0x77, 0x77, 0x77 } },
  214. { 0xa9, { 0x02, 0x02, 0x02, 0x02, 0x02 } },
  215. { 0xaa, { 0x40, 0x40, 0x40, 0x40, 0x40 } },
  216. { 0xac, { 0x1f, 0x1f, 0x1f, 0x1f, 0x1f } },
  217. { 0xad, { 0x14, 0x14, 0x14, 0x14, 0x14 } },
  218. { 0xae, { 0x78, 0x78, 0x78, 0x78, 0x78 } },
  219. { 0xaf, { 0x06, 0x06, 0x06, 0x06, 0x07 } },
  220. { 0xb0, { 0x1b, 0x1b, 0x1b, 0x19, 0x1b } },
  221. { 0xb1, { 0x18, 0x17, 0x17, 0x18, 0x17 } },
  222. { 0xb2, { 0x35, 0x82, 0x82, 0x38, 0x82 } },
  223. { 0xb3, { 0xb6, 0xce, 0xc7, 0x5c, 0xb0 } },
  224. { 0xb4, { 0x3f, 0x3e, 0x3e, 0x3f, 0x3e } },
  225. { 0xb5, { 0x70, 0x58, 0x50, 0x68, 0x50 } },
  226. { 0xb6, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  227. { 0xb7, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  228. { 0xb8, { 0x03, 0x03, 0x01, 0x01, 0x01 } },
  229. { 0xb9, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  230. { 0xba, { 0x06, 0x06, 0x0a, 0x05, 0x0a } },
  231. { 0xbb, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  232. { 0xbc, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  233. { 0xbd, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  234. { 0xbe, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  235. { 0xbf, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  236. { 0xc0, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  237. { 0xc1, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  238. { 0xc2, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  239. { 0xc3, { 0x00, 0x00, 0x88, 0x66, 0x88 } },
  240. { 0xc4, { 0x10, 0x10, 0x00, 0x00, 0x00 } },
  241. { 0xc5, { 0x00, 0x00, 0x44, 0x60, 0x44 } },
  242. { 0xc6, { 0x10, 0x0a, 0x00, 0x00, 0x00 } },
  243. { 0xc7, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  244. { 0xc8, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  245. { 0xc9, { 0x90, 0x04, 0x00, 0x00, 0x00 } },
  246. { 0xca, { 0x90, 0x08, 0x01, 0x01, 0x01 } },
  247. { 0xcb, { 0xa0, 0x04, 0x00, 0x44, 0x00 } },
  248. { 0xcc, { 0xa0, 0x10, 0x03, 0x00, 0x03 } },
  249. { 0xcd, { 0x06, 0x06, 0x06, 0x05, 0x06 } },
  250. { 0xce, { 0x05, 0x05, 0x01, 0x01, 0x01 } },
  251. { 0xcf, { 0x40, 0x20, 0x18, 0x18, 0x18 } },
  252. { 0xd0, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  253. { 0xd1, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  254. { 0xd2, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  255. { 0xd3, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  256. { 0xd4, { 0x05, 0x05, 0x05, 0x05, 0x05 } },
  257. { 0xd5, { 0x05, 0x05, 0x05, 0x03, 0x05 } },
  258. { 0xd6, { 0xac, 0x22, 0xca, 0x8f, 0xca } },
  259. { 0xd7, { 0x20, 0x20, 0x20, 0x20, 0x20 } },
  260. { 0xd8, { 0x01, 0x01, 0x01, 0x01, 0x01 } },
  261. { 0xd9, { 0x00, 0x00, 0x0f, 0x00, 0x0f } },
  262. { 0xda, { 0x00, 0xff, 0xff, 0x0e, 0xff } },
  263. { 0xdb, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
  264. { 0xdc, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
  265. { 0xdd, { 0x05, 0x05, 0x05, 0x05, 0x05 } },
  266. { 0xde, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
  267. { 0xdf, { 0x42, 0x42, 0x44, 0x44, 0x04 } },
  268. { 0xe0, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  269. { 0xe1, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  270. { 0xe2, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  271. { 0xe3, { 0x00, 0x00, 0x26, 0x06, 0x26 } },
  272. { 0xe4, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  273. { 0xe5, { 0x01, 0x0a, 0x01, 0x01, 0x01 } },
  274. { 0xe6, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  275. { 0xe7, { 0x08, 0x08, 0x08, 0x08, 0x08 } },
  276. { 0xe8, { 0x63, 0x63, 0x63, 0x63, 0x63 } },
  277. { 0xe9, { 0x59, 0x59, 0x59, 0x59, 0x59 } },
  278. { 0xea, { 0x80, 0x80, 0x20, 0x80, 0x80 } },
  279. { 0xeb, { 0x37, 0x37, 0x78, 0x37, 0x77 } },
  280. { 0xec, { 0x1f, 0x1f, 0x25, 0x25, 0x25 } },
  281. { 0xed, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
  282. { 0xee, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  283. { 0xef, { 0x70, 0x70, 0x58, 0x38, 0x58 } },
  284. { 0xf0, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
  285. };
  286. #endif /* HD29L2_PRIV */