tuner-xc2028.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356
  1. /* tuner-xc2028
  2. *
  3. * Copyright (c) 2007-2008 Mauro Carvalho Chehab (mchehab@infradead.org)
  4. *
  5. * Copyright (c) 2007 Michel Ludwig (michel.ludwig@gmail.com)
  6. * - frontend interface
  7. *
  8. * This code is placed under the terms of the GNU General Public License v2
  9. */
  10. #include <linux/i2c.h>
  11. #include <asm/div64.h>
  12. #include <linux/firmware.h>
  13. #include <linux/videodev2.h>
  14. #include <linux/delay.h>
  15. #include <media/tuner.h>
  16. #include <linux/mutex.h>
  17. #include <linux/slab.h>
  18. #include <asm/unaligned.h>
  19. #include "tuner-i2c.h"
  20. #include "tuner-xc2028.h"
  21. #include "tuner-xc2028-types.h"
  22. #include <linux/dvb/frontend.h>
  23. #include "dvb_frontend.h"
  24. static int debug;
  25. module_param(debug, int, 0644);
  26. MODULE_PARM_DESC(debug, "enable verbose debug messages");
  27. static int no_poweroff;
  28. module_param(no_poweroff, int, 0644);
  29. MODULE_PARM_DESC(no_poweroff, "0 (default) powers device off when not used.\n"
  30. "1 keep device energized and with tuner ready all the times.\n"
  31. " Faster, but consumes more power and keeps the device hotter\n");
  32. static char audio_std[8];
  33. module_param_string(audio_std, audio_std, sizeof(audio_std), 0);
  34. MODULE_PARM_DESC(audio_std,
  35. "Audio standard. XC3028 audio decoder explicitly "
  36. "needs to know what audio\n"
  37. "standard is needed for some video standards with audio A2 or NICAM.\n"
  38. "The valid values are:\n"
  39. "A2\n"
  40. "A2/A\n"
  41. "A2/B\n"
  42. "NICAM\n"
  43. "NICAM/A\n"
  44. "NICAM/B\n");
  45. static char firmware_name[30];
  46. module_param_string(firmware_name, firmware_name, sizeof(firmware_name), 0);
  47. MODULE_PARM_DESC(firmware_name, "Firmware file name. Allows overriding the "
  48. "default firmware name\n");
  49. static LIST_HEAD(hybrid_tuner_instance_list);
  50. static DEFINE_MUTEX(xc2028_list_mutex);
  51. /* struct for storing firmware table */
  52. struct firmware_description {
  53. unsigned int type;
  54. v4l2_std_id id;
  55. __u16 int_freq;
  56. unsigned char *ptr;
  57. unsigned int size;
  58. };
  59. struct firmware_properties {
  60. unsigned int type;
  61. v4l2_std_id id;
  62. v4l2_std_id std_req;
  63. __u16 int_freq;
  64. unsigned int scode_table;
  65. int scode_nr;
  66. };
  67. struct xc2028_data {
  68. struct list_head hybrid_tuner_instance_list;
  69. struct tuner_i2c_props i2c_props;
  70. __u32 frequency;
  71. struct firmware_description *firm;
  72. int firm_size;
  73. __u16 firm_version;
  74. __u16 hwmodel;
  75. __u16 hwvers;
  76. struct xc2028_ctrl ctrl;
  77. struct firmware_properties cur_fw;
  78. struct mutex lock;
  79. };
  80. #define i2c_send(priv, buf, size) ({ \
  81. int _rc; \
  82. _rc = tuner_i2c_xfer_send(&priv->i2c_props, buf, size); \
  83. if (size != _rc) \
  84. tuner_info("i2c output error: rc = %d (should be %d)\n",\
  85. _rc, (int)size); \
  86. if (priv->ctrl.msleep) \
  87. msleep(priv->ctrl.msleep); \
  88. _rc; \
  89. })
  90. #define i2c_rcv(priv, buf, size) ({ \
  91. int _rc; \
  92. _rc = tuner_i2c_xfer_recv(&priv->i2c_props, buf, size); \
  93. if (size != _rc) \
  94. tuner_err("i2c input error: rc = %d (should be %d)\n", \
  95. _rc, (int)size); \
  96. _rc; \
  97. })
  98. #define i2c_send_recv(priv, obuf, osize, ibuf, isize) ({ \
  99. int _rc; \
  100. _rc = tuner_i2c_xfer_send_recv(&priv->i2c_props, obuf, osize, \
  101. ibuf, isize); \
  102. if (isize != _rc) \
  103. tuner_err("i2c input error: rc = %d (should be %d)\n", \
  104. _rc, (int)isize); \
  105. if (priv->ctrl.msleep) \
  106. msleep(priv->ctrl.msleep); \
  107. _rc; \
  108. })
  109. #define send_seq(priv, data...) ({ \
  110. static u8 _val[] = data; \
  111. int _rc; \
  112. if (sizeof(_val) != \
  113. (_rc = tuner_i2c_xfer_send(&priv->i2c_props, \
  114. _val, sizeof(_val)))) { \
  115. tuner_err("Error on line %d: %d\n", __LINE__, _rc); \
  116. } else if (priv->ctrl.msleep) \
  117. msleep(priv->ctrl.msleep); \
  118. _rc; \
  119. })
  120. static int xc2028_get_reg(struct xc2028_data *priv, u16 reg, u16 *val)
  121. {
  122. unsigned char buf[2];
  123. unsigned char ibuf[2];
  124. tuner_dbg("%s %04x called\n", __func__, reg);
  125. buf[0] = reg >> 8;
  126. buf[1] = (unsigned char) reg;
  127. if (i2c_send_recv(priv, buf, 2, ibuf, 2) != 2)
  128. return -EIO;
  129. *val = (ibuf[1]) | (ibuf[0] << 8);
  130. return 0;
  131. }
  132. #define dump_firm_type(t) dump_firm_type_and_int_freq(t, 0)
  133. static void dump_firm_type_and_int_freq(unsigned int type, u16 int_freq)
  134. {
  135. if (type & BASE)
  136. printk("BASE ");
  137. if (type & INIT1)
  138. printk("INIT1 ");
  139. if (type & F8MHZ)
  140. printk("F8MHZ ");
  141. if (type & MTS)
  142. printk("MTS ");
  143. if (type & D2620)
  144. printk("D2620 ");
  145. if (type & D2633)
  146. printk("D2633 ");
  147. if (type & DTV6)
  148. printk("DTV6 ");
  149. if (type & QAM)
  150. printk("QAM ");
  151. if (type & DTV7)
  152. printk("DTV7 ");
  153. if (type & DTV78)
  154. printk("DTV78 ");
  155. if (type & DTV8)
  156. printk("DTV8 ");
  157. if (type & FM)
  158. printk("FM ");
  159. if (type & INPUT1)
  160. printk("INPUT1 ");
  161. if (type & LCD)
  162. printk("LCD ");
  163. if (type & NOGD)
  164. printk("NOGD ");
  165. if (type & MONO)
  166. printk("MONO ");
  167. if (type & ATSC)
  168. printk("ATSC ");
  169. if (type & IF)
  170. printk("IF ");
  171. if (type & LG60)
  172. printk("LG60 ");
  173. if (type & ATI638)
  174. printk("ATI638 ");
  175. if (type & OREN538)
  176. printk("OREN538 ");
  177. if (type & OREN36)
  178. printk("OREN36 ");
  179. if (type & TOYOTA388)
  180. printk("TOYOTA388 ");
  181. if (type & TOYOTA794)
  182. printk("TOYOTA794 ");
  183. if (type & DIBCOM52)
  184. printk("DIBCOM52 ");
  185. if (type & ZARLINK456)
  186. printk("ZARLINK456 ");
  187. if (type & CHINA)
  188. printk("CHINA ");
  189. if (type & F6MHZ)
  190. printk("F6MHZ ");
  191. if (type & INPUT2)
  192. printk("INPUT2 ");
  193. if (type & SCODE)
  194. printk("SCODE ");
  195. if (type & HAS_IF)
  196. printk("HAS_IF_%d ", int_freq);
  197. }
  198. static v4l2_std_id parse_audio_std_option(void)
  199. {
  200. if (strcasecmp(audio_std, "A2") == 0)
  201. return V4L2_STD_A2;
  202. if (strcasecmp(audio_std, "A2/A") == 0)
  203. return V4L2_STD_A2_A;
  204. if (strcasecmp(audio_std, "A2/B") == 0)
  205. return V4L2_STD_A2_B;
  206. if (strcasecmp(audio_std, "NICAM") == 0)
  207. return V4L2_STD_NICAM;
  208. if (strcasecmp(audio_std, "NICAM/A") == 0)
  209. return V4L2_STD_NICAM_A;
  210. if (strcasecmp(audio_std, "NICAM/B") == 0)
  211. return V4L2_STD_NICAM_B;
  212. return 0;
  213. }
  214. static void free_firmware(struct xc2028_data *priv)
  215. {
  216. int i;
  217. tuner_dbg("%s called\n", __func__);
  218. if (!priv->firm)
  219. return;
  220. for (i = 0; i < priv->firm_size; i++)
  221. kfree(priv->firm[i].ptr);
  222. kfree(priv->firm);
  223. priv->firm = NULL;
  224. priv->firm_size = 0;
  225. memset(&priv->cur_fw, 0, sizeof(priv->cur_fw));
  226. }
  227. static int load_all_firmwares(struct dvb_frontend *fe)
  228. {
  229. struct xc2028_data *priv = fe->tuner_priv;
  230. const struct firmware *fw = NULL;
  231. const unsigned char *p, *endp;
  232. int rc = 0;
  233. int n, n_array;
  234. char name[33];
  235. char *fname;
  236. tuner_dbg("%s called\n", __func__);
  237. if (!firmware_name[0])
  238. fname = priv->ctrl.fname;
  239. else
  240. fname = firmware_name;
  241. tuner_dbg("Reading firmware %s\n", fname);
  242. rc = request_firmware(&fw, fname, priv->i2c_props.adap->dev.parent);
  243. if (rc < 0) {
  244. if (rc == -ENOENT)
  245. tuner_err("Error: firmware %s not found.\n",
  246. fname);
  247. else
  248. tuner_err("Error %d while requesting firmware %s \n",
  249. rc, fname);
  250. return rc;
  251. }
  252. p = fw->data;
  253. endp = p + fw->size;
  254. if (fw->size < sizeof(name) - 1 + 2 + 2) {
  255. tuner_err("Error: firmware file %s has invalid size!\n",
  256. fname);
  257. goto corrupt;
  258. }
  259. memcpy(name, p, sizeof(name) - 1);
  260. name[sizeof(name) - 1] = 0;
  261. p += sizeof(name) - 1;
  262. priv->firm_version = get_unaligned_le16(p);
  263. p += 2;
  264. n_array = get_unaligned_le16(p);
  265. p += 2;
  266. tuner_info("Loading %d firmware images from %s, type: %s, ver %d.%d\n",
  267. n_array, fname, name,
  268. priv->firm_version >> 8, priv->firm_version & 0xff);
  269. priv->firm = kzalloc(sizeof(*priv->firm) * n_array, GFP_KERNEL);
  270. if (priv->firm == NULL) {
  271. tuner_err("Not enough memory to load firmware file.\n");
  272. rc = -ENOMEM;
  273. goto err;
  274. }
  275. priv->firm_size = n_array;
  276. n = -1;
  277. while (p < endp) {
  278. __u32 type, size;
  279. v4l2_std_id id;
  280. __u16 int_freq = 0;
  281. n++;
  282. if (n >= n_array) {
  283. tuner_err("More firmware images in file than "
  284. "were expected!\n");
  285. goto corrupt;
  286. }
  287. /* Checks if there's enough bytes to read */
  288. if (endp - p < sizeof(type) + sizeof(id) + sizeof(size))
  289. goto header;
  290. type = get_unaligned_le32(p);
  291. p += sizeof(type);
  292. id = get_unaligned_le64(p);
  293. p += sizeof(id);
  294. if (type & HAS_IF) {
  295. int_freq = get_unaligned_le16(p);
  296. p += sizeof(int_freq);
  297. if (endp - p < sizeof(size))
  298. goto header;
  299. }
  300. size = get_unaligned_le32(p);
  301. p += sizeof(size);
  302. if (!size || size > endp - p) {
  303. tuner_err("Firmware type ");
  304. dump_firm_type(type);
  305. printk("(%x), id %llx is corrupted "
  306. "(size=%d, expected %d)\n",
  307. type, (unsigned long long)id,
  308. (unsigned)(endp - p), size);
  309. goto corrupt;
  310. }
  311. priv->firm[n].ptr = kzalloc(size, GFP_KERNEL);
  312. if (priv->firm[n].ptr == NULL) {
  313. tuner_err("Not enough memory to load firmware file.\n");
  314. rc = -ENOMEM;
  315. goto err;
  316. }
  317. tuner_dbg("Reading firmware type ");
  318. if (debug) {
  319. dump_firm_type_and_int_freq(type, int_freq);
  320. printk("(%x), id %llx, size=%d.\n",
  321. type, (unsigned long long)id, size);
  322. }
  323. memcpy(priv->firm[n].ptr, p, size);
  324. priv->firm[n].type = type;
  325. priv->firm[n].id = id;
  326. priv->firm[n].size = size;
  327. priv->firm[n].int_freq = int_freq;
  328. p += size;
  329. }
  330. if (n + 1 != priv->firm_size) {
  331. tuner_err("Firmware file is incomplete!\n");
  332. goto corrupt;
  333. }
  334. goto done;
  335. header:
  336. tuner_err("Firmware header is incomplete!\n");
  337. corrupt:
  338. rc = -EINVAL;
  339. tuner_err("Error: firmware file is corrupted!\n");
  340. err:
  341. tuner_info("Releasing partially loaded firmware file.\n");
  342. free_firmware(priv);
  343. done:
  344. release_firmware(fw);
  345. if (rc == 0)
  346. tuner_dbg("Firmware files loaded.\n");
  347. return rc;
  348. }
  349. static int seek_firmware(struct dvb_frontend *fe, unsigned int type,
  350. v4l2_std_id *id)
  351. {
  352. struct xc2028_data *priv = fe->tuner_priv;
  353. int i, best_i = -1, best_nr_matches = 0;
  354. unsigned int type_mask = 0;
  355. tuner_dbg("%s called, want type=", __func__);
  356. if (debug) {
  357. dump_firm_type(type);
  358. printk("(%x), id %016llx.\n", type, (unsigned long long)*id);
  359. }
  360. if (!priv->firm) {
  361. tuner_err("Error! firmware not loaded\n");
  362. return -EINVAL;
  363. }
  364. if (((type & ~SCODE) == 0) && (*id == 0))
  365. *id = V4L2_STD_PAL;
  366. if (type & BASE)
  367. type_mask = BASE_TYPES;
  368. else if (type & SCODE) {
  369. type &= SCODE_TYPES;
  370. type_mask = SCODE_TYPES & ~HAS_IF;
  371. } else if (type & DTV_TYPES)
  372. type_mask = DTV_TYPES;
  373. else if (type & STD_SPECIFIC_TYPES)
  374. type_mask = STD_SPECIFIC_TYPES;
  375. type &= type_mask;
  376. if (!(type & SCODE))
  377. type_mask = ~0;
  378. /* Seek for exact match */
  379. for (i = 0; i < priv->firm_size; i++) {
  380. if ((type == (priv->firm[i].type & type_mask)) &&
  381. (*id == priv->firm[i].id))
  382. goto found;
  383. }
  384. /* Seek for generic video standard match */
  385. for (i = 0; i < priv->firm_size; i++) {
  386. v4l2_std_id match_mask;
  387. int nr_matches;
  388. if (type != (priv->firm[i].type & type_mask))
  389. continue;
  390. match_mask = *id & priv->firm[i].id;
  391. if (!match_mask)
  392. continue;
  393. if ((*id & match_mask) == *id)
  394. goto found; /* Supports all the requested standards */
  395. nr_matches = hweight64(match_mask);
  396. if (nr_matches > best_nr_matches) {
  397. best_nr_matches = nr_matches;
  398. best_i = i;
  399. }
  400. }
  401. if (best_nr_matches > 0) {
  402. tuner_dbg("Selecting best matching firmware (%d bits) for "
  403. "type=", best_nr_matches);
  404. dump_firm_type(type);
  405. printk("(%x), id %016llx:\n", type, (unsigned long long)*id);
  406. i = best_i;
  407. goto found;
  408. }
  409. /*FIXME: Would make sense to seek for type "hint" match ? */
  410. i = -ENOENT;
  411. goto ret;
  412. found:
  413. *id = priv->firm[i].id;
  414. ret:
  415. tuner_dbg("%s firmware for type=", (i < 0) ? "Can't find" : "Found");
  416. if (debug) {
  417. dump_firm_type(type);
  418. printk("(%x), id %016llx.\n", type, (unsigned long long)*id);
  419. }
  420. return i;
  421. }
  422. static inline int do_tuner_callback(struct dvb_frontend *fe, int cmd, int arg)
  423. {
  424. struct xc2028_data *priv = fe->tuner_priv;
  425. /* analog side (tuner-core) uses i2c_adap->algo_data.
  426. * digital side is not guaranteed to have algo_data defined.
  427. *
  428. * digital side will always have fe->dvb defined.
  429. * analog side (tuner-core) doesn't (yet) define fe->dvb.
  430. */
  431. return (!fe->callback) ? -EINVAL :
  432. fe->callback(((fe->dvb) && (fe->dvb->priv)) ?
  433. fe->dvb->priv : priv->i2c_props.adap->algo_data,
  434. DVB_FRONTEND_COMPONENT_TUNER, cmd, arg);
  435. }
  436. static int load_firmware(struct dvb_frontend *fe, unsigned int type,
  437. v4l2_std_id *id)
  438. {
  439. struct xc2028_data *priv = fe->tuner_priv;
  440. int pos, rc;
  441. unsigned char *p, *endp, buf[priv->ctrl.max_len];
  442. tuner_dbg("%s called\n", __func__);
  443. pos = seek_firmware(fe, type, id);
  444. if (pos < 0)
  445. return pos;
  446. tuner_info("Loading firmware for type=");
  447. dump_firm_type(priv->firm[pos].type);
  448. printk("(%x), id %016llx.\n", priv->firm[pos].type,
  449. (unsigned long long)*id);
  450. p = priv->firm[pos].ptr;
  451. endp = p + priv->firm[pos].size;
  452. while (p < endp) {
  453. __u16 size;
  454. /* Checks if there's enough bytes to read */
  455. if (p + sizeof(size) > endp) {
  456. tuner_err("Firmware chunk size is wrong\n");
  457. return -EINVAL;
  458. }
  459. size = le16_to_cpu(*(__u16 *) p);
  460. p += sizeof(size);
  461. if (size == 0xffff)
  462. return 0;
  463. if (!size) {
  464. /* Special callback command received */
  465. rc = do_tuner_callback(fe, XC2028_TUNER_RESET, 0);
  466. if (rc < 0) {
  467. tuner_err("Error at RESET code %d\n",
  468. (*p) & 0x7f);
  469. return -EINVAL;
  470. }
  471. continue;
  472. }
  473. if (size >= 0xff00) {
  474. switch (size) {
  475. case 0xff00:
  476. rc = do_tuner_callback(fe, XC2028_RESET_CLK, 0);
  477. if (rc < 0) {
  478. tuner_err("Error at RESET code %d\n",
  479. (*p) & 0x7f);
  480. return -EINVAL;
  481. }
  482. break;
  483. default:
  484. tuner_info("Invalid RESET code %d\n",
  485. size & 0x7f);
  486. return -EINVAL;
  487. }
  488. continue;
  489. }
  490. /* Checks for a sleep command */
  491. if (size & 0x8000) {
  492. msleep(size & 0x7fff);
  493. continue;
  494. }
  495. if ((size + p > endp)) {
  496. tuner_err("missing bytes: need %d, have %d\n",
  497. size, (int)(endp - p));
  498. return -EINVAL;
  499. }
  500. buf[0] = *p;
  501. p++;
  502. size--;
  503. /* Sends message chunks */
  504. while (size > 0) {
  505. int len = (size < priv->ctrl.max_len - 1) ?
  506. size : priv->ctrl.max_len - 1;
  507. memcpy(buf + 1, p, len);
  508. rc = i2c_send(priv, buf, len + 1);
  509. if (rc < 0) {
  510. tuner_err("%d returned from send\n", rc);
  511. return -EINVAL;
  512. }
  513. p += len;
  514. size -= len;
  515. }
  516. }
  517. return 0;
  518. }
  519. static int load_scode(struct dvb_frontend *fe, unsigned int type,
  520. v4l2_std_id *id, __u16 int_freq, int scode)
  521. {
  522. struct xc2028_data *priv = fe->tuner_priv;
  523. int pos, rc;
  524. unsigned char *p;
  525. tuner_dbg("%s called\n", __func__);
  526. if (!int_freq) {
  527. pos = seek_firmware(fe, type, id);
  528. if (pos < 0)
  529. return pos;
  530. } else {
  531. for (pos = 0; pos < priv->firm_size; pos++) {
  532. if ((priv->firm[pos].int_freq == int_freq) &&
  533. (priv->firm[pos].type & HAS_IF))
  534. break;
  535. }
  536. if (pos == priv->firm_size)
  537. return -ENOENT;
  538. }
  539. p = priv->firm[pos].ptr;
  540. if (priv->firm[pos].type & HAS_IF) {
  541. if (priv->firm[pos].size != 12 * 16 || scode >= 16)
  542. return -EINVAL;
  543. p += 12 * scode;
  544. } else {
  545. /* 16 SCODE entries per file; each SCODE entry is 12 bytes and
  546. * has a 2-byte size header in the firmware format. */
  547. if (priv->firm[pos].size != 14 * 16 || scode >= 16 ||
  548. le16_to_cpu(*(__u16 *)(p + 14 * scode)) != 12)
  549. return -EINVAL;
  550. p += 14 * scode + 2;
  551. }
  552. tuner_info("Loading SCODE for type=");
  553. dump_firm_type_and_int_freq(priv->firm[pos].type,
  554. priv->firm[pos].int_freq);
  555. printk("(%x), id %016llx.\n", priv->firm[pos].type,
  556. (unsigned long long)*id);
  557. if (priv->firm_version < 0x0202)
  558. rc = send_seq(priv, {0x20, 0x00, 0x00, 0x00});
  559. else
  560. rc = send_seq(priv, {0xa0, 0x00, 0x00, 0x00});
  561. if (rc < 0)
  562. return -EIO;
  563. rc = i2c_send(priv, p, 12);
  564. if (rc < 0)
  565. return -EIO;
  566. rc = send_seq(priv, {0x00, 0x8c});
  567. if (rc < 0)
  568. return -EIO;
  569. return 0;
  570. }
  571. static int check_firmware(struct dvb_frontend *fe, unsigned int type,
  572. v4l2_std_id std, __u16 int_freq)
  573. {
  574. struct xc2028_data *priv = fe->tuner_priv;
  575. struct firmware_properties new_fw;
  576. int rc = 0, retry_count = 0;
  577. u16 version, hwmodel;
  578. v4l2_std_id std0;
  579. tuner_dbg("%s called\n", __func__);
  580. if (!priv->firm) {
  581. if (!priv->ctrl.fname) {
  582. tuner_info("xc2028/3028 firmware name not set!\n");
  583. return -EINVAL;
  584. }
  585. rc = load_all_firmwares(fe);
  586. if (rc < 0)
  587. return rc;
  588. }
  589. if (priv->ctrl.mts && !(type & FM))
  590. type |= MTS;
  591. retry:
  592. new_fw.type = type;
  593. new_fw.id = std;
  594. new_fw.std_req = std;
  595. new_fw.scode_table = SCODE | priv->ctrl.scode_table;
  596. new_fw.scode_nr = 0;
  597. new_fw.int_freq = int_freq;
  598. tuner_dbg("checking firmware, user requested type=");
  599. if (debug) {
  600. dump_firm_type(new_fw.type);
  601. printk("(%x), id %016llx, ", new_fw.type,
  602. (unsigned long long)new_fw.std_req);
  603. if (!int_freq) {
  604. printk("scode_tbl ");
  605. dump_firm_type(priv->ctrl.scode_table);
  606. printk("(%x), ", priv->ctrl.scode_table);
  607. } else
  608. printk("int_freq %d, ", new_fw.int_freq);
  609. printk("scode_nr %d\n", new_fw.scode_nr);
  610. }
  611. /* No need to reload base firmware if it matches */
  612. if (((BASE | new_fw.type) & BASE_TYPES) ==
  613. (priv->cur_fw.type & BASE_TYPES)) {
  614. tuner_dbg("BASE firmware not changed.\n");
  615. goto skip_base;
  616. }
  617. /* Updating BASE - forget about all currently loaded firmware */
  618. memset(&priv->cur_fw, 0, sizeof(priv->cur_fw));
  619. /* Reset is needed before loading firmware */
  620. rc = do_tuner_callback(fe, XC2028_TUNER_RESET, 0);
  621. if (rc < 0)
  622. goto fail;
  623. /* BASE firmwares are all std0 */
  624. std0 = 0;
  625. rc = load_firmware(fe, BASE | new_fw.type, &std0);
  626. if (rc < 0) {
  627. tuner_err("Error %d while loading base firmware\n",
  628. rc);
  629. goto fail;
  630. }
  631. /* Load INIT1, if needed */
  632. tuner_dbg("Load init1 firmware, if exists\n");
  633. rc = load_firmware(fe, BASE | INIT1 | new_fw.type, &std0);
  634. if (rc == -ENOENT)
  635. rc = load_firmware(fe, (BASE | INIT1 | new_fw.type) & ~F8MHZ,
  636. &std0);
  637. if (rc < 0 && rc != -ENOENT) {
  638. tuner_err("Error %d while loading init1 firmware\n",
  639. rc);
  640. goto fail;
  641. }
  642. skip_base:
  643. /*
  644. * No need to reload standard specific firmware if base firmware
  645. * was not reloaded and requested video standards have not changed.
  646. */
  647. if (priv->cur_fw.type == (BASE | new_fw.type) &&
  648. priv->cur_fw.std_req == std) {
  649. tuner_dbg("Std-specific firmware already loaded.\n");
  650. goto skip_std_specific;
  651. }
  652. /* Reloading std-specific firmware forces a SCODE update */
  653. priv->cur_fw.scode_table = 0;
  654. rc = load_firmware(fe, new_fw.type, &new_fw.id);
  655. if (rc == -ENOENT)
  656. rc = load_firmware(fe, new_fw.type & ~F8MHZ, &new_fw.id);
  657. if (rc < 0)
  658. goto fail;
  659. skip_std_specific:
  660. if (priv->cur_fw.scode_table == new_fw.scode_table &&
  661. priv->cur_fw.scode_nr == new_fw.scode_nr) {
  662. tuner_dbg("SCODE firmware already loaded.\n");
  663. goto check_device;
  664. }
  665. if (new_fw.type & FM)
  666. goto check_device;
  667. /* Load SCODE firmware, if exists */
  668. tuner_dbg("Trying to load scode %d\n", new_fw.scode_nr);
  669. rc = load_scode(fe, new_fw.type | new_fw.scode_table, &new_fw.id,
  670. new_fw.int_freq, new_fw.scode_nr);
  671. check_device:
  672. if (xc2028_get_reg(priv, 0x0004, &version) < 0 ||
  673. xc2028_get_reg(priv, 0x0008, &hwmodel) < 0) {
  674. tuner_err("Unable to read tuner registers.\n");
  675. goto fail;
  676. }
  677. tuner_dbg("Device is Xceive %d version %d.%d, "
  678. "firmware version %d.%d\n",
  679. hwmodel, (version & 0xf000) >> 12, (version & 0xf00) >> 8,
  680. (version & 0xf0) >> 4, version & 0xf);
  681. if (priv->ctrl.read_not_reliable)
  682. goto read_not_reliable;
  683. /* Check firmware version against what we downloaded. */
  684. if (priv->firm_version != ((version & 0xf0) << 4 | (version & 0x0f))) {
  685. if (!priv->ctrl.read_not_reliable) {
  686. tuner_err("Incorrect readback of firmware version.\n");
  687. goto fail;
  688. } else {
  689. tuner_err("Returned an incorrect version. However, "
  690. "read is not reliable enough. Ignoring it.\n");
  691. hwmodel = 3028;
  692. }
  693. }
  694. /* Check that the tuner hardware model remains consistent over time. */
  695. if (priv->hwmodel == 0 && (hwmodel == 2028 || hwmodel == 3028)) {
  696. priv->hwmodel = hwmodel;
  697. priv->hwvers = version & 0xff00;
  698. } else if (priv->hwmodel == 0 || priv->hwmodel != hwmodel ||
  699. priv->hwvers != (version & 0xff00)) {
  700. tuner_err("Read invalid device hardware information - tuner "
  701. "hung?\n");
  702. goto fail;
  703. }
  704. read_not_reliable:
  705. memcpy(&priv->cur_fw, &new_fw, sizeof(priv->cur_fw));
  706. /*
  707. * By setting BASE in cur_fw.type only after successfully loading all
  708. * firmwares, we can:
  709. * 1. Identify that BASE firmware with type=0 has been loaded;
  710. * 2. Tell whether BASE firmware was just changed the next time through.
  711. */
  712. priv->cur_fw.type |= BASE;
  713. return 0;
  714. fail:
  715. memset(&priv->cur_fw, 0, sizeof(priv->cur_fw));
  716. if (retry_count < 8) {
  717. msleep(50);
  718. retry_count++;
  719. tuner_dbg("Retrying firmware load\n");
  720. goto retry;
  721. }
  722. if (rc == -ENOENT)
  723. rc = -EINVAL;
  724. return rc;
  725. }
  726. static int xc2028_signal(struct dvb_frontend *fe, u16 *strength)
  727. {
  728. struct xc2028_data *priv = fe->tuner_priv;
  729. u16 frq_lock, signal = 0;
  730. int rc;
  731. tuner_dbg("%s called\n", __func__);
  732. mutex_lock(&priv->lock);
  733. /* Sync Lock Indicator */
  734. rc = xc2028_get_reg(priv, 0x0002, &frq_lock);
  735. if (rc < 0)
  736. goto ret;
  737. /* Frequency is locked */
  738. if (frq_lock == 1)
  739. signal = 32768;
  740. /* Get SNR of the video signal */
  741. rc = xc2028_get_reg(priv, 0x0040, &signal);
  742. if (rc < 0)
  743. goto ret;
  744. /* Use both frq_lock and signal to generate the result */
  745. signal = signal || ((signal & 0x07) << 12);
  746. ret:
  747. mutex_unlock(&priv->lock);
  748. *strength = signal;
  749. tuner_dbg("signal strength is %d\n", signal);
  750. return rc;
  751. }
  752. #define DIV 15625
  753. static int generic_set_freq(struct dvb_frontend *fe, u32 freq /* in HZ */,
  754. enum v4l2_tuner_type new_type,
  755. unsigned int type,
  756. v4l2_std_id std,
  757. u16 int_freq)
  758. {
  759. struct xc2028_data *priv = fe->tuner_priv;
  760. int rc = -EINVAL;
  761. unsigned char buf[4];
  762. u32 div, offset = 0;
  763. tuner_dbg("%s called\n", __func__);
  764. mutex_lock(&priv->lock);
  765. tuner_dbg("should set frequency %d kHz\n", freq / 1000);
  766. if (check_firmware(fe, type, std, int_freq) < 0)
  767. goto ret;
  768. /* On some cases xc2028 can disable video output, if
  769. * very weak signals are received. By sending a soft
  770. * reset, this is re-enabled. So, it is better to always
  771. * send a soft reset before changing channels, to be sure
  772. * that xc2028 will be in a safe state.
  773. * Maybe this might also be needed for DTV.
  774. */
  775. if (new_type == V4L2_TUNER_ANALOG_TV) {
  776. rc = send_seq(priv, {0x00, 0x00});
  777. /* Analog modes require offset = 0 */
  778. } else {
  779. /*
  780. * Digital modes require an offset to adjust to the
  781. * proper frequency. The offset depends on what
  782. * firmware version is used.
  783. */
  784. /*
  785. * Adjust to the center frequency. This is calculated by the
  786. * formula: offset = 1.25MHz - BW/2
  787. * For DTV 7/8, the firmware uses BW = 8000, so it needs a
  788. * further adjustment to get the frequency center on VHF
  789. */
  790. if (priv->cur_fw.type & DTV6)
  791. offset = 1750000;
  792. else if (priv->cur_fw.type & DTV7)
  793. offset = 2250000;
  794. else /* DTV8 or DTV78 */
  795. offset = 2750000;
  796. if ((priv->cur_fw.type & DTV78) && freq < 470000000)
  797. offset -= 500000;
  798. /*
  799. * xc3028 additional "magic"
  800. * Depending on the firmware version, it needs some adjustments
  801. * to properly centralize the frequency. This seems to be
  802. * needed to compensate the SCODE table adjustments made by
  803. * newer firmwares
  804. */
  805. #if 1
  806. /*
  807. * The proper adjustment would be to do it at s-code table.
  808. * However, this didn't work, as reported by
  809. * Robert Lowery <rglowery@exemail.com.au>
  810. */
  811. if (priv->cur_fw.type & DTV7)
  812. offset += 500000;
  813. #else
  814. /*
  815. * Still need tests for XC3028L (firmware 3.2 or upper)
  816. * So, for now, let's just comment the per-firmware
  817. * version of this change. Reports with xc3028l working
  818. * with and without the lines bellow are welcome
  819. */
  820. if (priv->firm_version < 0x0302) {
  821. if (priv->cur_fw.type & DTV7)
  822. offset += 500000;
  823. } else {
  824. if (priv->cur_fw.type & DTV7)
  825. offset -= 300000;
  826. else if (type != ATSC) /* DVB @6MHz, DTV 8 and DTV 7/8 */
  827. offset += 200000;
  828. }
  829. #endif
  830. }
  831. div = (freq - offset + DIV / 2) / DIV;
  832. /* CMD= Set frequency */
  833. if (priv->firm_version < 0x0202)
  834. rc = send_seq(priv, {0x00, 0x02, 0x00, 0x00});
  835. else
  836. rc = send_seq(priv, {0x80, 0x02, 0x00, 0x00});
  837. if (rc < 0)
  838. goto ret;
  839. /* Return code shouldn't be checked.
  840. The reset CLK is needed only with tm6000.
  841. Driver should work fine even if this fails.
  842. */
  843. if (priv->ctrl.msleep)
  844. msleep(priv->ctrl.msleep);
  845. do_tuner_callback(fe, XC2028_RESET_CLK, 1);
  846. msleep(10);
  847. buf[0] = 0xff & (div >> 24);
  848. buf[1] = 0xff & (div >> 16);
  849. buf[2] = 0xff & (div >> 8);
  850. buf[3] = 0xff & (div);
  851. rc = i2c_send(priv, buf, sizeof(buf));
  852. if (rc < 0)
  853. goto ret;
  854. msleep(100);
  855. priv->frequency = freq;
  856. tuner_dbg("divisor= %02x %02x %02x %02x (freq=%d.%03d)\n",
  857. buf[0], buf[1], buf[2], buf[3],
  858. freq / 1000000, (freq % 1000000) / 1000);
  859. rc = 0;
  860. ret:
  861. mutex_unlock(&priv->lock);
  862. return rc;
  863. }
  864. static int xc2028_set_analog_freq(struct dvb_frontend *fe,
  865. struct analog_parameters *p)
  866. {
  867. struct xc2028_data *priv = fe->tuner_priv;
  868. unsigned int type=0;
  869. tuner_dbg("%s called\n", __func__);
  870. if (p->mode == V4L2_TUNER_RADIO) {
  871. type |= FM;
  872. if (priv->ctrl.input1)
  873. type |= INPUT1;
  874. return generic_set_freq(fe, (625l * p->frequency) / 10,
  875. V4L2_TUNER_RADIO, type, 0, 0);
  876. }
  877. /* if std is not defined, choose one */
  878. if (!p->std)
  879. p->std = V4L2_STD_MN;
  880. /* PAL/M, PAL/N, PAL/Nc and NTSC variants should use 6MHz firmware */
  881. if (!(p->std & V4L2_STD_MN))
  882. type |= F8MHZ;
  883. /* Add audio hack to std mask */
  884. p->std |= parse_audio_std_option();
  885. return generic_set_freq(fe, 62500l * p->frequency,
  886. V4L2_TUNER_ANALOG_TV, type, p->std, 0);
  887. }
  888. static int xc2028_set_params(struct dvb_frontend *fe,
  889. struct dvb_frontend_parameters *p)
  890. {
  891. struct xc2028_data *priv = fe->tuner_priv;
  892. unsigned int type=0;
  893. fe_bandwidth_t bw = BANDWIDTH_8_MHZ;
  894. u16 demod = 0;
  895. tuner_dbg("%s called\n", __func__);
  896. switch(fe->ops.info.type) {
  897. case FE_OFDM:
  898. bw = p->u.ofdm.bandwidth;
  899. /*
  900. * The only countries with 6MHz seem to be Taiwan/Uruguay.
  901. * Both seem to require QAM firmware for OFDM decoding
  902. * Tested in Taiwan by Terry Wu <terrywu2009@gmail.com>
  903. */
  904. if (bw == BANDWIDTH_6_MHZ)
  905. type |= QAM;
  906. break;
  907. case FE_ATSC:
  908. bw = BANDWIDTH_6_MHZ;
  909. /* The only ATSC firmware (at least on v2.7) is D2633 */
  910. type |= ATSC | D2633;
  911. break;
  912. /* DVB-S and pure QAM (FE_QAM) are not supported */
  913. default:
  914. return -EINVAL;
  915. }
  916. switch (bw) {
  917. case BANDWIDTH_8_MHZ:
  918. if (p->frequency < 470000000)
  919. priv->ctrl.vhfbw7 = 0;
  920. else
  921. priv->ctrl.uhfbw8 = 1;
  922. type |= (priv->ctrl.vhfbw7 && priv->ctrl.uhfbw8) ? DTV78 : DTV8;
  923. type |= F8MHZ;
  924. break;
  925. case BANDWIDTH_7_MHZ:
  926. if (p->frequency < 470000000)
  927. priv->ctrl.vhfbw7 = 1;
  928. else
  929. priv->ctrl.uhfbw8 = 0;
  930. type |= (priv->ctrl.vhfbw7 && priv->ctrl.uhfbw8) ? DTV78 : DTV7;
  931. type |= F8MHZ;
  932. break;
  933. case BANDWIDTH_6_MHZ:
  934. type |= DTV6;
  935. priv->ctrl.vhfbw7 = 0;
  936. priv->ctrl.uhfbw8 = 0;
  937. break;
  938. default:
  939. tuner_err("error: bandwidth not supported.\n");
  940. };
  941. /*
  942. Selects between D2633 or D2620 firmware.
  943. It doesn't make sense for ATSC, since it should be D2633 on all cases
  944. */
  945. if (fe->ops.info.type != FE_ATSC) {
  946. switch (priv->ctrl.type) {
  947. case XC2028_D2633:
  948. type |= D2633;
  949. break;
  950. case XC2028_D2620:
  951. type |= D2620;
  952. break;
  953. case XC2028_AUTO:
  954. default:
  955. /* Zarlink seems to need D2633 */
  956. if (priv->ctrl.demod == XC3028_FE_ZARLINK456)
  957. type |= D2633;
  958. else
  959. type |= D2620;
  960. }
  961. }
  962. /* All S-code tables need a 200kHz shift */
  963. if (priv->ctrl.demod) {
  964. demod = priv->ctrl.demod;
  965. /*
  966. * Newer firmwares require a 200 kHz offset only for ATSC
  967. */
  968. if (type == ATSC || priv->firm_version < 0x0302)
  969. demod += 200;
  970. /*
  971. * The DTV7 S-code table needs a 700 kHz shift.
  972. *
  973. * DTV7 is only used in Australia. Germany or Italy may also
  974. * use this firmware after initialization, but a tune to a UHF
  975. * channel should then cause DTV78 to be used.
  976. *
  977. * Unfortunately, on real-field tests, the s-code offset
  978. * didn't work as expected, as reported by
  979. * Robert Lowery <rglowery@exemail.com.au>
  980. */
  981. }
  982. return generic_set_freq(fe, p->frequency,
  983. V4L2_TUNER_DIGITAL_TV, type, 0, demod);
  984. }
  985. static int xc2028_sleep(struct dvb_frontend *fe)
  986. {
  987. struct xc2028_data *priv = fe->tuner_priv;
  988. int rc = 0;
  989. /* Avoid firmware reload on slow devices or if PM disabled */
  990. if (no_poweroff || priv->ctrl.disable_power_mgmt)
  991. return 0;
  992. tuner_dbg("Putting xc2028/3028 into poweroff mode.\n");
  993. if (debug > 1) {
  994. tuner_dbg("Printing sleep stack trace:\n");
  995. dump_stack();
  996. }
  997. mutex_lock(&priv->lock);
  998. if (priv->firm_version < 0x0202)
  999. rc = send_seq(priv, {0x00, 0x08, 0x00, 0x00});
  1000. else
  1001. rc = send_seq(priv, {0x80, 0x08, 0x00, 0x00});
  1002. priv->cur_fw.type = 0; /* need firmware reload */
  1003. mutex_unlock(&priv->lock);
  1004. return rc;
  1005. }
  1006. static int xc2028_dvb_release(struct dvb_frontend *fe)
  1007. {
  1008. struct xc2028_data *priv = fe->tuner_priv;
  1009. tuner_dbg("%s called\n", __func__);
  1010. mutex_lock(&xc2028_list_mutex);
  1011. /* only perform final cleanup if this is the last instance */
  1012. if (hybrid_tuner_report_instance_count(priv) == 1) {
  1013. kfree(priv->ctrl.fname);
  1014. free_firmware(priv);
  1015. }
  1016. if (priv)
  1017. hybrid_tuner_release_state(priv);
  1018. mutex_unlock(&xc2028_list_mutex);
  1019. fe->tuner_priv = NULL;
  1020. return 0;
  1021. }
  1022. static int xc2028_get_frequency(struct dvb_frontend *fe, u32 *frequency)
  1023. {
  1024. struct xc2028_data *priv = fe->tuner_priv;
  1025. tuner_dbg("%s called\n", __func__);
  1026. *frequency = priv->frequency;
  1027. return 0;
  1028. }
  1029. static int xc2028_set_config(struct dvb_frontend *fe, void *priv_cfg)
  1030. {
  1031. struct xc2028_data *priv = fe->tuner_priv;
  1032. struct xc2028_ctrl *p = priv_cfg;
  1033. int rc = 0;
  1034. tuner_dbg("%s called\n", __func__);
  1035. mutex_lock(&priv->lock);
  1036. memcpy(&priv->ctrl, p, sizeof(priv->ctrl));
  1037. if (priv->ctrl.max_len < 9)
  1038. priv->ctrl.max_len = 13;
  1039. if (p->fname) {
  1040. if (priv->ctrl.fname && strcmp(p->fname, priv->ctrl.fname)) {
  1041. kfree(priv->ctrl.fname);
  1042. free_firmware(priv);
  1043. }
  1044. priv->ctrl.fname = kstrdup(p->fname, GFP_KERNEL);
  1045. if (priv->ctrl.fname == NULL)
  1046. rc = -ENOMEM;
  1047. }
  1048. mutex_unlock(&priv->lock);
  1049. return rc;
  1050. }
  1051. static const struct dvb_tuner_ops xc2028_dvb_tuner_ops = {
  1052. .info = {
  1053. .name = "Xceive XC3028",
  1054. .frequency_min = 42000000,
  1055. .frequency_max = 864000000,
  1056. .frequency_step = 50000,
  1057. },
  1058. .set_config = xc2028_set_config,
  1059. .set_analog_params = xc2028_set_analog_freq,
  1060. .release = xc2028_dvb_release,
  1061. .get_frequency = xc2028_get_frequency,
  1062. .get_rf_strength = xc2028_signal,
  1063. .set_params = xc2028_set_params,
  1064. .sleep = xc2028_sleep,
  1065. };
  1066. struct dvb_frontend *xc2028_attach(struct dvb_frontend *fe,
  1067. struct xc2028_config *cfg)
  1068. {
  1069. struct xc2028_data *priv;
  1070. int instance;
  1071. if (debug)
  1072. printk(KERN_DEBUG "xc2028: Xcv2028/3028 init called!\n");
  1073. if (NULL == cfg)
  1074. return NULL;
  1075. if (!fe) {
  1076. printk(KERN_ERR "xc2028: No frontend!\n");
  1077. return NULL;
  1078. }
  1079. mutex_lock(&xc2028_list_mutex);
  1080. instance = hybrid_tuner_request_state(struct xc2028_data, priv,
  1081. hybrid_tuner_instance_list,
  1082. cfg->i2c_adap, cfg->i2c_addr,
  1083. "xc2028");
  1084. switch (instance) {
  1085. case 0:
  1086. /* memory allocation failure */
  1087. goto fail;
  1088. break;
  1089. case 1:
  1090. /* new tuner instance */
  1091. priv->ctrl.max_len = 13;
  1092. mutex_init(&priv->lock);
  1093. fe->tuner_priv = priv;
  1094. break;
  1095. case 2:
  1096. /* existing tuner instance */
  1097. fe->tuner_priv = priv;
  1098. break;
  1099. }
  1100. memcpy(&fe->ops.tuner_ops, &xc2028_dvb_tuner_ops,
  1101. sizeof(xc2028_dvb_tuner_ops));
  1102. tuner_info("type set to %s\n", "XCeive xc2028/xc3028 tuner");
  1103. if (cfg->ctrl)
  1104. xc2028_set_config(fe, cfg->ctrl);
  1105. mutex_unlock(&xc2028_list_mutex);
  1106. return fe;
  1107. fail:
  1108. mutex_unlock(&xc2028_list_mutex);
  1109. xc2028_dvb_release(fe);
  1110. return NULL;
  1111. }
  1112. EXPORT_SYMBOL(xc2028_attach);
  1113. MODULE_DESCRIPTION("Xceive xc2028/xc3028 tuner driver");
  1114. MODULE_AUTHOR("Michel Ludwig <michel.ludwig@gmail.com>");
  1115. MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>");
  1116. MODULE_LICENSE("GPL");