tuner-xc2028.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. /* tuner-xc2028
  2. *
  3. * Copyright (c) 2007 Mauro Carvalho Chehab (mchehab@infradead.org)
  4. * Copyright (c) 2007 Michel Ludwig (michel.ludwig@gmail.com)
  5. * - frontend interface
  6. * This code is placed under the terms of the GNU General Public License v2
  7. */
  8. #include <linux/i2c.h>
  9. #include <asm/div64.h>
  10. #include <linux/firmware.h>
  11. #include <linux/videodev.h>
  12. #include <linux/delay.h>
  13. #include <media/tuner.h>
  14. #include <linux/mutex.h>
  15. #include "tuner-i2c.h"
  16. #include "tuner-xc2028.h"
  17. #include "tuner-xc2028-types.h"
  18. #include <linux/dvb/frontend.h>
  19. #include "dvb_frontend.h"
  20. #define PREFIX "xc2028 "
  21. static LIST_HEAD(xc2028_list);
  22. /* struct for storing firmware table */
  23. struct firmware_description {
  24. unsigned int type;
  25. v4l2_std_id id;
  26. unsigned char *ptr;
  27. unsigned int size;
  28. };
  29. struct xc2028_data {
  30. struct list_head xc2028_list;
  31. struct tuner_i2c_props i2c_props;
  32. int (*tuner_callback) (void *dev,
  33. int command, int arg);
  34. struct device *dev;
  35. void *video_dev;
  36. int count;
  37. __u32 frequency;
  38. struct firmware_description *firm;
  39. int firm_size;
  40. __u16 version;
  41. struct xc2028_ctrl ctrl;
  42. v4l2_std_id firm_type; /* video stds supported
  43. by current firmware */
  44. fe_bandwidth_t bandwidth; /* Firmware bandwidth:
  45. 6M, 7M or 8M */
  46. int need_load_generic; /* The generic firmware
  47. were loaded? */
  48. int max_len; /* Max firmware chunk */
  49. enum tuner_mode mode;
  50. struct i2c_client *i2c_client;
  51. struct mutex lock;
  52. };
  53. #define i2c_send(rc, priv, buf, size) \
  54. if (size != (rc = tuner_i2c_xfer_send(&priv->i2c_props, buf, size))) \
  55. tuner_info("i2c output error: rc = %d (should be %d)\n", \
  56. rc, (int)size);
  57. #define i2c_rcv(rc, priv, buf, size) \
  58. if (size != (rc = tuner_i2c_xfer_recv(&priv->i2c_props, buf, size))) \
  59. tuner_info("i2c input error: rc = %d (should be %d)\n", \
  60. rc, (int)size);
  61. #define send_seq(priv, data...) \
  62. { int rc; \
  63. static u8 _val[] = data; \
  64. if (sizeof(_val) != \
  65. (rc = tuner_i2c_xfer_send (&priv->i2c_props, \
  66. _val, sizeof(_val)))) { \
  67. tuner_info("Error on line %d: %d\n",__LINE__,rc); \
  68. return -EINVAL; \
  69. } \
  70. msleep (10); \
  71. }
  72. static int xc2028_get_reg(struct xc2028_data *priv, u16 reg)
  73. {
  74. int rc;
  75. unsigned char buf[1];
  76. tuner_info("%s called\n", __FUNCTION__);
  77. buf[0]= reg;
  78. i2c_send(rc, priv, buf, sizeof(buf));
  79. if (rc<0)
  80. return rc;
  81. i2c_rcv(rc, priv, buf, 2);
  82. if (rc<0)
  83. return rc;
  84. return (buf[1])|(buf[0]<<8);
  85. }
  86. static void free_firmware (struct xc2028_data *priv)
  87. {
  88. int i;
  89. if (!priv->firm)
  90. return;
  91. for (i=0;i<priv->firm_size;i++) {
  92. if (priv->firm[i].ptr)
  93. kfree(priv->firm[i].ptr);
  94. }
  95. kfree(priv->firm);
  96. priv->firm=NULL;
  97. priv->need_load_generic = 1;
  98. }
  99. static int load_all_firmwares (struct dvb_frontend *fe)
  100. {
  101. struct xc2028_data *priv = fe->tuner_priv;
  102. const struct firmware *fw=NULL;
  103. unsigned char *p, *endp;
  104. int rc=0, n, n_array;
  105. char name[33];
  106. tuner_info("%s called\n", __FUNCTION__);
  107. tuner_info("Loading firmware %s\n", priv->ctrl.fname);
  108. rc = request_firmware(&fw, priv->ctrl.fname, priv->dev);
  109. if (rc < 0) {
  110. if (rc==-ENOENT)
  111. tuner_info("Error: firmware %s not found.\n",
  112. priv->ctrl.fname);
  113. else
  114. tuner_info("Error %d while requesting firmware %s \n",
  115. rc, priv->ctrl.fname);
  116. return rc;
  117. }
  118. p=fw->data;
  119. endp=p+fw->size;
  120. if(fw->size<sizeof(name)-1+2) {
  121. tuner_info("Error: firmware size is zero!\n");
  122. rc=-EINVAL;
  123. goto done;
  124. }
  125. memcpy(name,p,sizeof(name)-1);
  126. name[sizeof(name)-1]=0;
  127. p+=sizeof(name)-1;
  128. priv->version = le16_to_cpu(*(__u16 *)p);
  129. p += 2;
  130. tuner_info("firmware: %s, ver %d.%d\n", name,
  131. priv->version>>8, priv->version&0xff);
  132. if (p+2>endp)
  133. goto corrupt;
  134. n_array = le16_to_cpu(*(__u16 *)p);
  135. p += 2;
  136. tuner_info("there are %d firmwares at %s\n", n_array, priv->ctrl.fname);
  137. priv->firm=kzalloc(sizeof(*priv->firm)*n_array,GFP_KERNEL);
  138. if (!fw) {
  139. tuner_info("Not enough memory for loading firmware.\n");
  140. rc=-ENOMEM;
  141. goto done;
  142. }
  143. priv->firm_size = n_array;
  144. n=-1;
  145. while (p<endp) {
  146. __u32 type, size;
  147. v4l2_std_id id;
  148. n++;
  149. if (n >= n_array) {
  150. tuner_info("Too much firmwares at the file\n");
  151. goto corrupt;
  152. }
  153. /* Checks if there's enough bytes to read */
  154. if (p+sizeof(type)+sizeof(id)+sizeof(size)>endp) {
  155. tuner_info("Lost firmware!\n");
  156. goto corrupt;
  157. }
  158. type = le32_to_cpu(*(__u32 *)p);
  159. p += sizeof(type);
  160. id = le64_to_cpu(*(v4l2_std_id *)p);
  161. p += sizeof(id);
  162. size = le32_to_cpu(*(v4l2_std_id *)p);
  163. p += sizeof(size);
  164. if ((!size)||(size+p>endp)) {
  165. tuner_info("Firmware type %x, id %lx corrupt\n",
  166. type, (unsigned long) id);
  167. goto corrupt;
  168. }
  169. priv->firm[n].ptr=kzalloc(size,GFP_KERNEL);
  170. if (!priv->firm[n].ptr) {
  171. tuner_info("Not enough memory.\n");
  172. rc=-ENOMEM;
  173. goto err;
  174. }
  175. tuner_info("Loading firmware type %x, id %lx, size=%d.\n",
  176. type, (unsigned long) id, size);
  177. memcpy(priv->firm[n].ptr, p, size);
  178. priv->firm[n].type = type;
  179. priv->firm[n].id = id;
  180. priv->firm[n].size = size;
  181. p += size;
  182. }
  183. if (n+1 != priv->firm_size) {
  184. tuner_info("Firmware file is incomplete!\n");
  185. goto corrupt;
  186. }
  187. goto done;
  188. corrupt:
  189. rc=-EINVAL;
  190. tuner_info("Error: firmware file is corrupted!\n");
  191. err:
  192. tuner_info("Releasing loaded firmware file.\n");
  193. free_firmware(priv);
  194. done:
  195. release_firmware(fw);
  196. tuner_info("Firmware files loaded.\n");
  197. return rc;
  198. }
  199. static int load_firmware (struct dvb_frontend *fe, unsigned int type,
  200. v4l2_std_id *id)
  201. {
  202. struct xc2028_data *priv = fe->tuner_priv;
  203. int i, rc;
  204. unsigned char *p, *endp, buf[priv->max_len];
  205. tuner_info("%s called\n", __FUNCTION__);
  206. if (!priv->firm) {
  207. printk (KERN_ERR PREFIX "Error! firmware not loaded\n");
  208. return -EINVAL;
  209. }
  210. if ((type == 0) && (*id == 0))
  211. *id=V4L2_STD_PAL;
  212. /* Seek for exact match */
  213. for (i=0;i<priv->firm_size;i++) {
  214. if ( (type == priv->firm[i].type) &&
  215. (*id == priv->firm[i].id))
  216. goto found;
  217. }
  218. /* Seek for generic video standard match */
  219. for (i=0;i<priv->firm_size;i++) {
  220. if ( (type == priv->firm[i].type) && (*id & priv->firm[i].id))
  221. goto found;
  222. }
  223. /*FIXME: Would make sense to seek for type "hint" match ? */
  224. tuner_info ("Can't find firmware for type=%x, id=%lx\n", type,
  225. (long int)*id);
  226. return -EINVAL;
  227. found:
  228. *id = priv->firm[i].id;
  229. tuner_info ("Found firmware for type=%x, id=%lx\n", type,
  230. (long int)*id);
  231. p = priv->firm[i].ptr;
  232. if (!p) {
  233. printk(KERN_ERR PREFIX "Firmware pointer were freed!");
  234. return -EINVAL;
  235. }
  236. endp = p+priv->firm[i].size;
  237. while (p<endp) {
  238. __u16 size;
  239. /* Checks if there's enough bytes to read */
  240. if (p+sizeof(size)>endp) {
  241. tuner_info("missing bytes\n");
  242. return -EINVAL;
  243. }
  244. size = le16_to_cpu(*(__u16 *)p);
  245. p += sizeof(size);
  246. if (size == 0xffff)
  247. return 0;
  248. if (!size) {
  249. /* Special callback command received */
  250. rc = priv->tuner_callback(priv->video_dev,
  251. XC2028_TUNER_RESET, 0);
  252. if (rc<0) {
  253. tuner_info("Error at RESET code %d\n",
  254. (*p)&0x7f);
  255. return -EINVAL;
  256. }
  257. continue;
  258. }
  259. /* Checks for a sleep command */
  260. if (size & 0x8000) {
  261. msleep (size & 0x7fff);
  262. continue;
  263. }
  264. if ((size + p > endp)) {
  265. tuner_info("missing bytes: need %d, have %d\n",
  266. size, (int)(endp-p));
  267. return -EINVAL;
  268. }
  269. buf[0] = *p;
  270. p++;
  271. size--;
  272. /* Sends message chunks */
  273. while (size>0) {
  274. int len = (size<priv->max_len-1)?size:priv->max_len-1;
  275. memcpy(buf+1, p, len);
  276. i2c_send(rc, priv, buf, len+1);
  277. if (rc<0) {
  278. tuner_info("%d returned from send\n",rc);
  279. return -EINVAL;
  280. }
  281. p += len;
  282. size -= len;
  283. }
  284. }
  285. return -EINVAL;
  286. }
  287. static int check_firmware(struct dvb_frontend *fe, enum tuner_mode new_mode,
  288. v4l2_std_id std,
  289. fe_bandwidth_t bandwidth)
  290. {
  291. struct xc2028_data *priv = fe->tuner_priv;
  292. int rc, version;
  293. v4l2_std_id std0=0;
  294. unsigned int type0=0,type=0;
  295. int change_digital_bandwidth;
  296. tuner_info("%s called\n", __FUNCTION__);
  297. if (!priv->firm) {
  298. if (!priv->ctrl.fname)
  299. return -EINVAL;
  300. rc=load_all_firmwares(fe);
  301. if (rc<0)
  302. return rc;
  303. }
  304. tuner_info( "I am in mode %u and I should switch to mode %i\n",
  305. priv->mode, new_mode);
  306. /* first of all, determine whether we have switched the mode */
  307. if(new_mode != priv->mode) {
  308. priv->mode = new_mode;
  309. priv->need_load_generic = 1;
  310. }
  311. change_digital_bandwidth = (priv->mode == T_DIGITAL_TV
  312. && bandwidth != priv->bandwidth) ? 1 : 0;
  313. tuner_info("old bandwidth %u, new bandwidth %u\n", priv->bandwidth,
  314. bandwidth);
  315. if (priv->need_load_generic) {
  316. /* Reset is needed before loading firmware */
  317. rc = priv->tuner_callback(priv->video_dev,
  318. XC2028_TUNER_RESET, 0);
  319. if (rc<0)
  320. return rc;
  321. type0=BASE;
  322. if (priv->ctrl.type == XC2028_FIRM_MTS)
  323. type0 |= MTS;
  324. if (priv->bandwidth==8)
  325. type0 |= F8MHZ;
  326. /* FIXME: How to load FM and FM|INPUT1 firmwares? */
  327. rc = load_firmware(fe, type0, &std0);
  328. if (rc<0) {
  329. tuner_info("Error %d while loading generic firmware\n",
  330. rc);
  331. return rc;
  332. }
  333. priv->need_load_generic=0;
  334. priv->firm_type=0;
  335. if(priv->mode == T_DIGITAL_TV) {
  336. change_digital_bandwidth=1;
  337. }
  338. }
  339. tuner_info("I should change bandwidth %u\n",
  340. change_digital_bandwidth);
  341. if (change_digital_bandwidth) {
  342. /*FIXME: Should allow selecting between D2620 and D2633 */
  343. type |= D2620;
  344. /* FIXME: When should select a DTV78 firmware?
  345. */
  346. switch(bandwidth) {
  347. case BANDWIDTH_8_MHZ:
  348. type |= DTV8;
  349. break;
  350. case BANDWIDTH_7_MHZ:
  351. type |= DTV7;
  352. break;
  353. case BANDWIDTH_6_MHZ:
  354. /* FIXME: Should allow select also ATSC */
  355. type |= DTV6_QAM;
  356. break;
  357. default:
  358. tuner_info("error: bandwidth not supported.\n");
  359. };
  360. priv->bandwidth = bandwidth;
  361. }
  362. /* Load INIT1, if needed */
  363. tuner_info("Trying to load init1 firmware\n");
  364. type0 = BASE | INIT1 | priv->ctrl.type;
  365. if (priv->ctrl.type == XC2028_FIRM_MTS)
  366. type0 |= MTS;
  367. /* FIXME: Should handle errors - if INIT1 found */
  368. rc = load_firmware(fe, type0, &std0);
  369. /* FIXME: Should add support for FM radio
  370. */
  371. if (priv->ctrl.type == XC2028_FIRM_MTS)
  372. type |= MTS;
  373. tuner_info("firmware standard to load: %08lx\n",(unsigned long) std);
  374. if (priv->firm_type & std) {
  375. tuner_info("no need to load a std-specific firmware.\n");
  376. return 0;
  377. }
  378. rc = load_firmware(fe, type, &std);
  379. if (rc<0)
  380. return rc;
  381. version = xc2028_get_reg(priv, 0x4);
  382. tuner_info("Firmware version is %d.%d\n",
  383. (version>>4)&0x0f,(version)&0x0f);
  384. priv->firm_type=std;
  385. return 0;
  386. }
  387. static int xc2028_signal(struct dvb_frontend *fe, u16 *strength)
  388. {
  389. struct xc2028_data *priv = fe->tuner_priv;
  390. int frq_lock, signal=0;
  391. tuner_info("%s called\n", __FUNCTION__);
  392. mutex_lock(&priv->lock);
  393. *strength = 0;
  394. frq_lock = xc2028_get_reg(priv, 0x2);
  395. if (frq_lock<=0)
  396. goto ret;
  397. /* Frequency is locked. Return signal quality */
  398. signal = xc2028_get_reg(priv, 0x40);
  399. if(signal<=0) {
  400. signal=frq_lock;
  401. }
  402. ret:
  403. mutex_unlock(&priv->lock);
  404. *strength = signal;
  405. return 0;
  406. }
  407. #define DIV 15625
  408. static int generic_set_tv_freq(struct dvb_frontend *fe, u32 freq /* in Hz */,
  409. enum tuner_mode new_mode,
  410. v4l2_std_id std,
  411. fe_bandwidth_t bandwidth)
  412. {
  413. struct xc2028_data *priv = fe->tuner_priv;
  414. int rc=-EINVAL;
  415. unsigned char buf[5];
  416. u32 div, offset = 0;
  417. tuner_info("%s called\n", __FUNCTION__);
  418. mutex_lock(&priv->lock);
  419. /* HACK: It seems that specific firmware need to be reloaded
  420. when freq is changed */
  421. priv->firm_type=0;
  422. /* Reset GPIO 1 */
  423. rc = priv->tuner_callback(priv->video_dev, XC2028_TUNER_RESET, 0);
  424. if (rc<0)
  425. goto ret;
  426. msleep(10);
  427. tuner_info("should set frequency %d kHz)\n", freq / 1000);
  428. if (check_firmware(fe, new_mode, std, bandwidth)<0)
  429. goto ret;
  430. if(new_mode == T_DIGITAL_TV)
  431. offset = 2750000;
  432. div = (freq - offset + DIV/2)/DIV;
  433. /* CMD= Set frequency */
  434. if (priv->version<0x0202) {
  435. send_seq(priv, {0x00, 0x02, 0x00, 0x00});
  436. } else {
  437. send_seq(priv, {0x80, 0x02, 0x00, 0x00});
  438. }
  439. rc = priv->tuner_callback(priv->video_dev, XC2028_RESET_CLK, 1);
  440. if (rc<0)
  441. goto ret;
  442. msleep(10);
  443. buf[0]= 0xff & (div>>24);
  444. buf[1]= 0xff & (div>>16);
  445. buf[2]= 0xff & (div>>8);
  446. buf[3]= 0xff & (div);
  447. buf[4]= 0;
  448. i2c_send(rc, priv, buf, sizeof(buf));
  449. if (rc<0)
  450. goto ret;
  451. msleep(100);
  452. priv->frequency=freq;
  453. printk("divider= %02x %02x %02x %02x (freq=%d.%02d)\n",
  454. buf[1],buf[2],buf[3],buf[4],
  455. freq / 1000000, (freq%1000000)/10000);
  456. rc=0;
  457. ret:
  458. mutex_unlock(&priv->lock);
  459. return rc;
  460. }
  461. static int xc2028_set_tv_freq(struct dvb_frontend *fe,
  462. struct analog_parameters *p)
  463. {
  464. struct xc2028_data *priv = fe->tuner_priv;
  465. tuner_info("%s called\n", __FUNCTION__);
  466. return generic_set_tv_freq(fe, 62500l*p->frequency, T_ANALOG_TV,
  467. p->std,
  468. BANDWIDTH_8_MHZ /* NOT USED */);
  469. }
  470. static int xc2028_set_params(struct dvb_frontend *fe,
  471. struct dvb_frontend_parameters *p)
  472. {
  473. struct xc2028_data *priv = fe->tuner_priv;
  474. tuner_info("%s called\n", __FUNCTION__);
  475. /* FIXME: Only OFDM implemented */
  476. if (fe->ops.info.type != FE_OFDM) {
  477. tuner_info ("DTV type not implemented.\n");
  478. return -EINVAL;
  479. }
  480. return generic_set_tv_freq(fe, p->frequency, T_DIGITAL_TV,
  481. 0, /* NOT USED */
  482. p->u.ofdm.bandwidth);
  483. }
  484. static int xc2028_dvb_release(struct dvb_frontend *fe)
  485. {
  486. struct xc2028_data *priv = fe->tuner_priv;
  487. tuner_info("%s called\n", __FUNCTION__);
  488. priv->count--;
  489. if (!priv->count) {
  490. if (priv->ctrl.fname)
  491. kfree(priv->ctrl.fname);
  492. free_firmware(priv);
  493. kfree (priv);
  494. }
  495. return 0;
  496. }
  497. static int xc2028_get_frequency(struct dvb_frontend *fe, u32 *frequency)
  498. {
  499. struct xc2028_data *priv = fe->tuner_priv;
  500. tuner_info("%s called\n", __FUNCTION__);
  501. *frequency = priv->frequency;
  502. return 0;
  503. }
  504. static int xc2028_set_config (struct dvb_frontend *fe, void *priv_cfg)
  505. {
  506. struct xc2028_data *priv = fe->tuner_priv;
  507. struct xc2028_ctrl *p = priv_cfg;
  508. tuner_info("%s called\n", __FUNCTION__);
  509. priv->ctrl.type = p->type;
  510. if (p->fname) {
  511. if (priv->ctrl.fname)
  512. kfree(priv->ctrl.fname);
  513. priv->ctrl.fname = kmalloc(strlen(p->fname)+1, GFP_KERNEL);
  514. if (!priv->ctrl.fname)
  515. return -ENOMEM;
  516. free_firmware(priv);
  517. strcpy(priv->ctrl.fname, p->fname);
  518. }
  519. tuner_info("%s OK\n", __FUNCTION__);
  520. return 0;
  521. }
  522. static const struct dvb_tuner_ops xc2028_dvb_tuner_ops = {
  523. .info = {
  524. .name = "Xceive XC3028",
  525. .frequency_min = 42000000,
  526. .frequency_max = 864000000,
  527. .frequency_step = 50000,
  528. },
  529. .set_config = xc2028_set_config,
  530. .set_analog_params = xc2028_set_tv_freq,
  531. .release = xc2028_dvb_release,
  532. .get_frequency = xc2028_get_frequency,
  533. .get_rf_strength = xc2028_signal,
  534. .set_params = xc2028_set_params,
  535. // int (*sleep)(struct dvb_frontend *fe);
  536. // int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
  537. // int (*get_status)(struct dvb_frontend *fe, u32 *status);
  538. };
  539. int xc2028_attach(struct dvb_frontend *fe, struct i2c_adapter* i2c_adap,
  540. u8 i2c_addr, struct device *dev, void *video_dev,
  541. int (*tuner_callback) (void *dev, int command,int arg))
  542. {
  543. struct xc2028_data *priv;
  544. printk( KERN_INFO PREFIX "Xcv2028/3028 init called!\n");
  545. if (NULL == dev)
  546. return -ENODEV;
  547. if (NULL == video_dev)
  548. return -ENODEV;
  549. if (!tuner_callback) {
  550. printk( KERN_ERR PREFIX "No tuner callback!\n");
  551. return -EINVAL;
  552. }
  553. list_for_each_entry(priv, &xc2028_list, xc2028_list) {
  554. if (priv->dev == dev) {
  555. dev = NULL;
  556. priv->count++;
  557. }
  558. }
  559. if (dev) {
  560. priv = kzalloc(sizeof(*priv), GFP_KERNEL);
  561. if (priv == NULL)
  562. return -ENOMEM;
  563. fe->tuner_priv = priv;
  564. priv->bandwidth=BANDWIDTH_6_MHZ;
  565. priv->need_load_generic=1;
  566. priv->mode = T_UNINITIALIZED;
  567. priv->i2c_props.addr = i2c_addr;
  568. priv->i2c_props.adap = i2c_adap;
  569. priv->dev = dev;
  570. priv->video_dev = video_dev;
  571. priv->tuner_callback = tuner_callback;
  572. priv->max_len = 13;
  573. mutex_init(&priv->lock);
  574. list_add_tail(&priv->xc2028_list,&xc2028_list);
  575. }
  576. memcpy(&fe->ops.tuner_ops, &xc2028_dvb_tuner_ops,
  577. sizeof(xc2028_dvb_tuner_ops));
  578. tuner_info("type set to %s\n", "XCeive xc2028/xc3028 tuner");
  579. return 0;
  580. }
  581. EXPORT_SYMBOL(xc2028_attach);
  582. MODULE_DESCRIPTION("Xceive xc2028/xc3028 tuner driver");
  583. MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>");
  584. MODULE_LICENSE("GPL");