m920x.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907
  1. /* DVB USB compliant linux driver for MSI Mega Sky 580 DVB-T USB2.0 receiver
  2. *
  3. * Copyright (C) 2006 Aapo Tahkola (aet@rasterburn.org)
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the
  7. * Free Software Foundation, version 2.
  8. *
  9. * see Documentation/dvb/README.dvb-usb for more information
  10. */
  11. #include "m920x.h"
  12. #include "mt352.h"
  13. #include "mt352_priv.h"
  14. #include "qt1010.h"
  15. #include "tda1004x.h"
  16. #include "tda827x.h"
  17. /* debug */
  18. static int dvb_usb_m920x_debug;
  19. module_param_named(debug,dvb_usb_m920x_debug, int, 0644);
  20. MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
  21. static inline int m9206_read(struct usb_device *udev, u8 request, u16 value,
  22. u16 index, void *data, int size)
  23. {
  24. int ret;
  25. ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
  26. request, USB_TYPE_VENDOR | USB_DIR_IN,
  27. value, index, data, size, 2000);
  28. if (ret < 0) {
  29. printk(KERN_INFO "m920x_read = error: %d\n", ret);
  30. return ret;
  31. }
  32. if (ret != size) {
  33. deb_rc("m920x_read = no data\n");
  34. return -EIO;
  35. }
  36. return 0;
  37. }
  38. static inline int m9206_write(struct usb_device *udev, u8 request,
  39. u16 value, u16 index)
  40. {
  41. int ret;
  42. ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
  43. request, USB_TYPE_VENDOR | USB_DIR_OUT,
  44. value, index, NULL, 0, 2000);
  45. return ret;
  46. }
  47. static int m9206_init(struct dvb_usb_device *d, struct m9206_inits *rc_seq)
  48. {
  49. int ret = 0;
  50. /* Remote controller init. */
  51. if (d->props.rc_query) {
  52. deb_rc("Initialising remote control\n");
  53. while (rc_seq->address) {
  54. if ((ret = m9206_write(d->udev, M9206_CORE,
  55. rc_seq->data,
  56. rc_seq->address)) != 0) {
  57. deb_rc("Initialising remote control failed\n");
  58. return ret;
  59. }
  60. rc_seq++;
  61. }
  62. deb_rc("Initialising remote control success\n");
  63. }
  64. return ret;
  65. }
  66. static int m9206_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
  67. {
  68. struct m9206_state *m = d->priv;
  69. int i, ret = 0;
  70. u8 rc_state[2];
  71. if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE,
  72. rc_state, 1)) != 0)
  73. goto unlock;
  74. if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY,
  75. rc_state + 1, 1)) != 0)
  76. goto unlock;
  77. for (i = 0; i < d->props.rc_key_map_size; i++)
  78. if (d->props.rc_key_map[i].data == rc_state[1]) {
  79. *event = d->props.rc_key_map[i].event;
  80. switch(rc_state[0]) {
  81. case 0x80:
  82. *state = REMOTE_NO_KEY_PRESSED;
  83. goto unlock;
  84. case 0x88: /* framing error or "invalid code" */
  85. case 0x99:
  86. case 0xc0:
  87. case 0xd8:
  88. *state = REMOTE_NO_KEY_PRESSED;
  89. m->rep_count = 0;
  90. goto unlock;
  91. case 0x93:
  92. case 0x92:
  93. m->rep_count = 0;
  94. *state = REMOTE_KEY_PRESSED;
  95. goto unlock;
  96. case 0x91:
  97. /* prevent immediate auto-repeat */
  98. if (++m->rep_count > 2)
  99. *state = REMOTE_KEY_REPEAT;
  100. else
  101. *state = REMOTE_NO_KEY_PRESSED;
  102. goto unlock;
  103. default:
  104. deb_rc("Unexpected rc state %02x\n",
  105. rc_state[0]);
  106. *state = REMOTE_NO_KEY_PRESSED;
  107. goto unlock;
  108. }
  109. }
  110. if (rc_state[1] != 0)
  111. deb_rc("Unknown rc key %02x\n", rc_state[1]);
  112. *state = REMOTE_NO_KEY_PRESSED;
  113. unlock:
  114. return ret;
  115. }
  116. /* I2C */
  117. static int m9206_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
  118. int num)
  119. {
  120. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  121. int i, j;
  122. int ret = 0;
  123. if (!num)
  124. return -EINVAL;
  125. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  126. return -EAGAIN;
  127. for (i = 0; i < num; i++) {
  128. if (msg[i].flags & (I2C_M_NO_RD_ACK | I2C_M_IGNORE_NAK |
  129. I2C_M_TEN) || msg[i].len == 0) {
  130. /* For a 0 byte message, I think sending the address
  131. * to index 0x80|0x40 would be the correct thing to
  132. * do. However, zero byte messages are only used for
  133. * probing, and since we don't know how to get the
  134. * slave's ack, we can't probe. */
  135. ret = -ENOTSUPP;
  136. goto unlock;
  137. }
  138. /* Send START & address/RW bit */
  139. if (!(msg[i].flags & I2C_M_NOSTART)) {
  140. if ((ret = m9206_write(d->udev, M9206_I2C,
  141. (msg[i].addr << 1) |
  142. (msg[i].flags & I2C_M_RD ? 0x01 : 0),
  143. 0x80)) != 0)
  144. goto unlock;
  145. /* Should check for ack here, if we knew how. */
  146. }
  147. if (msg[i].flags & I2C_M_RD) {
  148. for (j = 0; j < msg[i].len; j++) {
  149. /* Last byte of transaction?
  150. * Send STOP, otherwise send ACK. */
  151. int stop = (i+1 == num && j+1 == msg[i].len)
  152. ? 0x40 : 0x01;
  153. if ((ret = m9206_read(d->udev, M9206_I2C, 0x0,
  154. 0x20|stop,
  155. &msg[i].buf[j], 1)) != 0)
  156. goto unlock;
  157. }
  158. } else {
  159. for (j = 0; j < msg[i].len; j++) {
  160. /* Last byte of transaction? Then send STOP. */
  161. int stop = (i+1 == num && j+1 == msg[i].len)
  162. ? 0x40 : 0x00;
  163. if ((ret = m9206_write(d->udev, M9206_I2C,
  164. msg[i].buf[j],
  165. stop)) != 0)
  166. goto unlock;
  167. /* Should check for ack here too. */
  168. }
  169. }
  170. }
  171. ret = num;
  172. unlock:
  173. mutex_unlock(&d->i2c_mutex);
  174. return ret;
  175. }
  176. static u32 m9206_i2c_func(struct i2c_adapter *adapter)
  177. {
  178. return I2C_FUNC_I2C;
  179. }
  180. static struct i2c_algorithm m9206_i2c_algo = {
  181. .master_xfer = m9206_i2c_xfer,
  182. .functionality = m9206_i2c_func,
  183. };
  184. /* pid filter */
  185. static int m9206_set_filter(struct dvb_usb_adapter *adap,
  186. int type, int idx, int pid)
  187. {
  188. int ret = 0;
  189. if (pid >= 0x8000)
  190. return -EINVAL;
  191. pid |= 0x8000;
  192. if ((ret = m9206_write(adap->dev->udev, M9206_FILTER, pid,
  193. (type << 8) | (idx * 4) )) != 0)
  194. return ret;
  195. if ((ret = m9206_write(adap->dev->udev, M9206_FILTER, 0,
  196. (type << 8) | (idx * 4) )) != 0)
  197. return ret;
  198. return ret;
  199. }
  200. static int m9206_update_filters(struct dvb_usb_adapter *adap)
  201. {
  202. struct m9206_state *m = adap->dev->priv;
  203. int enabled = m->filtering_enabled;
  204. int i, ret = 0, filter = 0;
  205. for (i = 0; i < M9206_MAX_FILTERS; i++)
  206. if (m->filters[i] == 8192)
  207. enabled = 0;
  208. /* Disable all filters */
  209. if ((ret = m9206_set_filter(adap, 0x81, 1, enabled)) != 0)
  210. return ret;
  211. for (i = 0; i < M9206_MAX_FILTERS; i++)
  212. if ((ret = m9206_set_filter(adap, 0x81, i + 2, 0)) != 0)
  213. return ret;
  214. if ((ret = m9206_set_filter(adap, 0x82, 0, 0x0)) != 0)
  215. return ret;
  216. /* Set */
  217. if (enabled) {
  218. for (i = 0; i < M9206_MAX_FILTERS; i++) {
  219. if (m->filters[i] == 0)
  220. continue;
  221. if ((ret = m9206_set_filter(adap, 0x81, filter + 2,
  222. m->filters[i])) != 0)
  223. return ret;
  224. filter++;
  225. }
  226. }
  227. if ((ret = m9206_set_filter(adap, 0x82, 0, 0x02f5)) != 0)
  228. return ret;
  229. return ret;
  230. }
  231. static int m9206_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
  232. {
  233. struct m9206_state *m = adap->dev->priv;
  234. m->filtering_enabled = onoff ? 1 : 0;
  235. return m9206_update_filters(adap);
  236. }
  237. static int m9206_pid_filter(struct dvb_usb_adapter *adap,
  238. int index, u16 pid, int onoff)
  239. {
  240. struct m9206_state *m = adap->dev->priv;
  241. m->filters[index] = onoff ? pid : 0;
  242. return m9206_update_filters(adap);
  243. }
  244. static int m9206_firmware_download(struct usb_device *udev,
  245. const struct firmware *fw)
  246. {
  247. u16 value, index, size;
  248. u8 read[4], *buff;
  249. int i, pass, ret = 0;
  250. buff = kmalloc(65536, GFP_KERNEL);
  251. if ((ret = m9206_read(udev, M9206_FILTER, 0x0, 0x8000, read, 4)) != 0)
  252. goto done;
  253. deb_rc("%x %x %x %x\n", read[0], read[1], read[2], read[3]);
  254. if ((ret = m9206_read(udev, M9206_FW, 0x0, 0x0, read, 1)) != 0)
  255. goto done;
  256. deb_rc("%x\n", read[0]);
  257. for (pass = 0; pass < 2; pass++) {
  258. for (i = 0; i + (sizeof(u16) * 3) < fw->size;) {
  259. value = le16_to_cpu(*(u16 *)(fw->data + i));
  260. i += sizeof(u16);
  261. index = le16_to_cpu(*(u16 *)(fw->data + i));
  262. i += sizeof(u16);
  263. size = le16_to_cpu(*(u16 *)(fw->data + i));
  264. i += sizeof(u16);
  265. if (pass == 1) {
  266. /* Will stall if using fw->data ... */
  267. memcpy(buff, fw->data + i, size);
  268. ret = usb_control_msg(udev, usb_sndctrlpipe(udev,0),
  269. M9206_FW,
  270. USB_TYPE_VENDOR | USB_DIR_OUT,
  271. value, index, buff, size, 20);
  272. if (ret != size) {
  273. deb_rc("error while uploading fw!\n");
  274. ret = -EIO;
  275. goto done;
  276. }
  277. msleep(3);
  278. }
  279. i += size;
  280. }
  281. if (i != fw->size) {
  282. deb_rc("bad firmware file!\n");
  283. ret = -EINVAL;
  284. goto done;
  285. }
  286. }
  287. msleep(36);
  288. /* m9206 will disconnect itself from the bus after this. */
  289. (void) m9206_write(udev, M9206_CORE, 0x01, M9206_FW_GO);
  290. deb_rc("firmware uploaded!\n");
  291. done:
  292. kfree(buff);
  293. return ret;
  294. }
  295. /* Callbacks for DVB USB */
  296. static int m920x_identify_state(struct usb_device *udev,
  297. struct dvb_usb_device_properties *props,
  298. struct dvb_usb_device_description **desc,
  299. int *cold)
  300. {
  301. struct usb_host_interface *alt;
  302. alt = usb_altnum_to_altsetting(usb_ifnum_to_if(udev, 0), 1);
  303. *cold = (alt == NULL) ? 1 : 0;
  304. return 0;
  305. }
  306. /* demod configurations */
  307. static int m920x_mt352_demod_init(struct dvb_frontend *fe)
  308. {
  309. u8 config[] = { CONFIG, 0x3d };
  310. u8 clock[] = { CLOCK_CTL, 0x30 };
  311. u8 reset[] = { RESET, 0x80 };
  312. u8 adc_ctl[] = { ADC_CTL_1, 0x40 };
  313. u8 agc[] = { AGC_TARGET, 0x1c, 0x20 };
  314. u8 sec_agc[] = { 0x69, 0x00, 0xff, 0xff, 0x40, 0xff, 0x00, 0x40, 0x40 };
  315. u8 unk1[] = { 0x93, 0x1a };
  316. u8 unk2[] = { 0xb5, 0x7a };
  317. mt352_write(fe, config, ARRAY_SIZE(config));
  318. mt352_write(fe, clock, ARRAY_SIZE(clock));
  319. mt352_write(fe, reset, ARRAY_SIZE(reset));
  320. mt352_write(fe, adc_ctl, ARRAY_SIZE(adc_ctl));
  321. mt352_write(fe, agc, ARRAY_SIZE(agc));
  322. mt352_write(fe, sec_agc, ARRAY_SIZE(sec_agc));
  323. mt352_write(fe, unk1, ARRAY_SIZE(unk1));
  324. mt352_write(fe, unk2, ARRAY_SIZE(unk2));
  325. deb_rc("Demod init!\n");
  326. return 0;
  327. }
  328. static struct mt352_config m920x_mt352_config = {
  329. .demod_address = 0x0f,
  330. .no_tuner = 1,
  331. .demod_init = m920x_mt352_demod_init,
  332. };
  333. static struct tda1004x_config m920x_tda10046_08_config = {
  334. .demod_address = 0x08,
  335. .invert = 0,
  336. .invert_oclk = 0,
  337. .ts_mode = TDA10046_TS_SERIAL,
  338. .xtal_freq = TDA10046_XTAL_16M,
  339. .if_freq = TDA10046_FREQ_045,
  340. .agc_config = TDA10046_AGC_TDA827X,
  341. .gpio_config = TDA10046_GPTRI,
  342. .request_firmware = NULL,
  343. };
  344. static struct tda1004x_config m920x_tda10046_0b_config = {
  345. .demod_address = 0x0b,
  346. .invert = 0,
  347. .invert_oclk = 0,
  348. .ts_mode = TDA10046_TS_SERIAL,
  349. .xtal_freq = TDA10046_XTAL_16M,
  350. .if_freq = TDA10046_FREQ_045,
  351. .agc_config = TDA10046_AGC_TDA827X,
  352. .gpio_config = TDA10046_GPTRI,
  353. .request_firmware = NULL, /* uses firmware EEPROM */
  354. };
  355. /* tuner configurations */
  356. static struct qt1010_config m920x_qt1010_config = {
  357. .i2c_address = 0x62
  358. };
  359. /* Callbacks for DVB USB */
  360. static int m920x_mt352_frontend_attach(struct dvb_usb_adapter *adap)
  361. {
  362. deb_rc("%s\n",__FUNCTION__);
  363. if ((adap->fe = dvb_attach(mt352_attach, &m920x_mt352_config,
  364. &adap->dev->i2c_adap)) == NULL)
  365. return -EIO;
  366. return 0;
  367. }
  368. static int m920x_tda10046_08_frontend_attach(struct dvb_usb_adapter *adap)
  369. {
  370. deb_rc("%s\n",__FUNCTION__);
  371. if ((adap->fe = dvb_attach(tda10046_attach,
  372. &m920x_tda10046_08_config,
  373. &adap->dev->i2c_adap)) == NULL)
  374. return -EIO;
  375. return 0;
  376. }
  377. static int m920x_tda10046_0b_frontend_attach(struct dvb_usb_adapter *adap)
  378. {
  379. deb_rc("%s\n",__FUNCTION__);
  380. if ((adap->fe = dvb_attach(tda10046_attach,
  381. &m920x_tda10046_0b_config,
  382. &adap->dev->i2c_adap)) == NULL)
  383. return -EIO;
  384. return 0;
  385. }
  386. static int m920x_qt1010_tuner_attach(struct dvb_usb_adapter *adap)
  387. {
  388. deb_rc("%s\n",__FUNCTION__);
  389. if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap,
  390. &m920x_qt1010_config) == NULL)
  391. return -ENODEV;
  392. return 0;
  393. }
  394. static int m920x_tda8275_60_tuner_attach(struct dvb_usb_adapter *adap)
  395. {
  396. deb_rc("%s\n",__FUNCTION__);
  397. if (dvb_attach(tda827x_attach, adap->fe, 0x60, &adap->dev->i2c_adap,
  398. NULL) == NULL)
  399. return -ENODEV;
  400. return 0;
  401. }
  402. static int m920x_tda8275_61_tuner_attach(struct dvb_usb_adapter *adap)
  403. {
  404. deb_rc("%s\n",__FUNCTION__);
  405. if (dvb_attach(tda827x_attach, adap->fe, 0x61, &adap->dev->i2c_adap,
  406. NULL) == NULL)
  407. return -ENODEV;
  408. return 0;
  409. }
  410. /* device-specific initialization */
  411. static struct m9206_inits megasky_rc_init [] = {
  412. { M9206_RC_INIT2, 0xa8 },
  413. { M9206_RC_INIT1, 0x51 },
  414. { } /* terminating entry */
  415. };
  416. static struct m9206_inits tvwalkertwin_rc_init [] = {
  417. { M9206_RC_INIT2, 0x00 },
  418. { M9206_RC_INIT1, 0xef },
  419. { 0xff28, 0x00 },
  420. { 0xff23, 0x00 },
  421. { 0xff21, 0x30 },
  422. { } /* terminating entry */
  423. };
  424. /* ir keymaps */
  425. static struct dvb_usb_rc_key megasky_rc_keys [] = {
  426. { 0x0, 0x12, KEY_POWER },
  427. { 0x0, 0x1e, KEY_CYCLEWINDOWS }, /* min/max */
  428. { 0x0, 0x02, KEY_CHANNELUP },
  429. { 0x0, 0x05, KEY_CHANNELDOWN },
  430. { 0x0, 0x03, KEY_VOLUMEUP },
  431. { 0x0, 0x06, KEY_VOLUMEDOWN },
  432. { 0x0, 0x04, KEY_MUTE },
  433. { 0x0, 0x07, KEY_OK }, /* TS */
  434. { 0x0, 0x08, KEY_STOP },
  435. { 0x0, 0x09, KEY_MENU }, /* swap */
  436. { 0x0, 0x0a, KEY_REWIND },
  437. { 0x0, 0x1b, KEY_PAUSE },
  438. { 0x0, 0x1f, KEY_FASTFORWARD },
  439. { 0x0, 0x0c, KEY_RECORD },
  440. { 0x0, 0x0d, KEY_CAMERA }, /* screenshot */
  441. { 0x0, 0x0e, KEY_COFFEE }, /* "MTS" */
  442. };
  443. static struct dvb_usb_rc_key tvwalkertwin_rc_keys [] = {
  444. { 0x0, 0x01, KEY_ZOOM }, /* Full Screen */
  445. { 0x0, 0x02, KEY_CAMERA }, /* snapshot */
  446. { 0x0, 0x03, KEY_MUTE },
  447. { 0x0, 0x04, KEY_REWIND },
  448. { 0x0, 0x05, KEY_PLAYPAUSE }, /* Play/Pause */
  449. { 0x0, 0x06, KEY_FASTFORWARD },
  450. { 0x0, 0x07, KEY_RECORD },
  451. { 0x0, 0x08, KEY_STOP },
  452. { 0x0, 0x09, KEY_TIME }, /* Timeshift */
  453. { 0x0, 0x0c, KEY_COFFEE }, /* Recall */
  454. { 0x0, 0x0e, KEY_CHANNELUP },
  455. { 0x0, 0x12, KEY_POWER },
  456. { 0x0, 0x15, KEY_MENU }, /* source */
  457. { 0x0, 0x18, KEY_CYCLEWINDOWS }, /* TWIN PIP */
  458. { 0x0, 0x1a, KEY_CHANNELDOWN },
  459. { 0x0, 0x1b, KEY_VOLUMEDOWN },
  460. { 0x0, 0x1e, KEY_VOLUMEUP },
  461. };
  462. /* DVB USB Driver stuff */
  463. static struct dvb_usb_device_properties megasky_properties;
  464. static struct dvb_usb_device_properties digivox_mini_ii_properties;
  465. static struct dvb_usb_device_properties tvwalkertwin_properties;
  466. static struct dvb_usb_device_properties dposh_properties;
  467. static int m920x_probe(struct usb_interface *intf,
  468. const struct usb_device_id *id)
  469. {
  470. struct dvb_usb_device *d;
  471. struct usb_host_interface *alt;
  472. int ret;
  473. struct m9206_inits *rc_init_seq = NULL;
  474. int bInterfaceNumber = intf->cur_altsetting->desc.bInterfaceNumber;
  475. deb_rc("Probing for m920x device at interface %d\n", bInterfaceNumber);
  476. if (bInterfaceNumber == 0) {
  477. /* Single-tuner device, or first interface on
  478. * multi-tuner device
  479. */
  480. if ((ret = dvb_usb_device_init(intf, &megasky_properties,
  481. THIS_MODULE, &d)) == 0) {
  482. rc_init_seq = megasky_rc_init;
  483. goto found;
  484. }
  485. if ((ret = dvb_usb_device_init(intf,
  486. &digivox_mini_ii_properties,
  487. THIS_MODULE, &d)) == 0) {
  488. /* No remote control, so no rc_init_seq */
  489. goto found;
  490. }
  491. /* This configures both tuners on the TV Walker Twin */
  492. if ((ret = dvb_usb_device_init(intf, &tvwalkertwin_properties,
  493. THIS_MODULE, &d)) == 0) {
  494. rc_init_seq = tvwalkertwin_rc_init;
  495. goto found;
  496. }
  497. if ((ret = dvb_usb_device_init(intf, &dposh_properties,
  498. THIS_MODULE, &d)) == 0) {
  499. /* Remote controller not supported yet. */
  500. goto found;
  501. }
  502. return ret;
  503. } else {
  504. /* Another interface on a multi-tuner device */
  505. /* The LifeView TV Walker Twin gets here, but struct
  506. * tvwalkertwin_properties already configured both
  507. * tuners, so there is nothing for us to do here
  508. */
  509. return -ENODEV;
  510. }
  511. found:
  512. alt = usb_altnum_to_altsetting(intf, 1);
  513. if (alt == NULL) {
  514. deb_rc("No alt found!\n");
  515. return -ENODEV;
  516. }
  517. ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber,
  518. alt->desc.bAlternateSetting);
  519. if (ret < 0)
  520. return ret;
  521. if ((ret = m9206_init(d, rc_init_seq)) != 0)
  522. return ret;
  523. return ret;
  524. }
  525. static struct usb_device_id m920x_table [] = {
  526. { USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) },
  527. { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
  528. USB_PID_MSI_DIGI_VOX_MINI_II) },
  529. { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
  530. USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD) },
  531. { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
  532. USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM) },
  533. { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_COLD) },
  534. { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_WARM) },
  535. { } /* Terminating entry */
  536. };
  537. MODULE_DEVICE_TABLE (usb, m920x_table);
  538. static struct dvb_usb_device_properties megasky_properties = {
  539. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  540. .usb_ctrl = DEVICE_SPECIFIC,
  541. .firmware = "dvb-usb-megasky-02.fw",
  542. .download_firmware = m9206_firmware_download,
  543. .rc_interval = 100,
  544. .rc_key_map = megasky_rc_keys,
  545. .rc_key_map_size = ARRAY_SIZE(megasky_rc_keys),
  546. .rc_query = m9206_rc_query,
  547. .size_of_priv = sizeof(struct m9206_state),
  548. .identify_state = m920x_identify_state,
  549. .num_adapters = 1,
  550. .adapter = {{
  551. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  552. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  553. .pid_filter_count = 8,
  554. .pid_filter = m9206_pid_filter,
  555. .pid_filter_ctrl = m9206_pid_filter_ctrl,
  556. .frontend_attach = m920x_mt352_frontend_attach,
  557. .tuner_attach = m920x_qt1010_tuner_attach,
  558. .stream = {
  559. .type = USB_BULK,
  560. .count = 8,
  561. .endpoint = 0x81,
  562. .u = {
  563. .bulk = {
  564. .buffersize = 512,
  565. }
  566. }
  567. },
  568. }},
  569. .i2c_algo = &m9206_i2c_algo,
  570. .num_device_descs = 1,
  571. .devices = {
  572. { "MSI Mega Sky 580 DVB-T USB2.0",
  573. { &m920x_table[0], NULL },
  574. { NULL },
  575. }
  576. }
  577. };
  578. static struct dvb_usb_device_properties digivox_mini_ii_properties = {
  579. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  580. .usb_ctrl = DEVICE_SPECIFIC,
  581. .firmware = "dvb-usb-digivox-02.fw",
  582. .download_firmware = m9206_firmware_download,
  583. .size_of_priv = sizeof(struct m9206_state),
  584. .identify_state = m920x_identify_state,
  585. .num_adapters = 1,
  586. .adapter = {{
  587. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  588. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  589. .pid_filter_count = 8,
  590. .pid_filter = m9206_pid_filter,
  591. .pid_filter_ctrl = m9206_pid_filter_ctrl,
  592. .frontend_attach = m920x_tda10046_08_frontend_attach,
  593. .tuner_attach = m920x_tda8275_60_tuner_attach,
  594. .stream = {
  595. .type = USB_BULK,
  596. .count = 8,
  597. .endpoint = 0x81,
  598. .u = {
  599. .bulk = {
  600. .buffersize = 0x4000,
  601. }
  602. }
  603. },
  604. }},
  605. .i2c_algo = &m9206_i2c_algo,
  606. .num_device_descs = 1,
  607. .devices = {
  608. { "MSI DIGI VOX mini II DVB-T USB2.0",
  609. { &m920x_table[1], NULL },
  610. { NULL },
  611. },
  612. }
  613. };
  614. /* LifeView TV Walker Twin support by Nick Andrew <nick@nick-andrew.net>
  615. *
  616. * LifeView TV Walker Twin has 1 x M9206, 2 x TDA10046, 2 x TDA8275A
  617. * TDA10046 #0 is located at i2c address 0x08
  618. * TDA10046 #1 is located at i2c address 0x0b
  619. * TDA8275A #0 is located at i2c address 0x60
  620. * TDA8275A #1 is located at i2c address 0x61
  621. */
  622. static struct dvb_usb_device_properties tvwalkertwin_properties = {
  623. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  624. .usb_ctrl = DEVICE_SPECIFIC,
  625. .firmware = "dvb-usb-tvwalkert.fw",
  626. .download_firmware = m9206_firmware_download,
  627. .rc_interval = 100,
  628. .rc_key_map = tvwalkertwin_rc_keys,
  629. .rc_key_map_size = ARRAY_SIZE(tvwalkertwin_rc_keys),
  630. .rc_query = m9206_rc_query,
  631. .size_of_priv = sizeof(struct m9206_state),
  632. .identify_state = m920x_identify_state,
  633. .num_adapters = 2,
  634. .adapter = {{
  635. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  636. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  637. .pid_filter_count = 8,
  638. .pid_filter = m9206_pid_filter,
  639. .pid_filter_ctrl = m9206_pid_filter_ctrl,
  640. .frontend_attach = m920x_tda10046_08_frontend_attach,
  641. .tuner_attach = m920x_tda8275_60_tuner_attach,
  642. .stream = {
  643. .type = USB_BULK,
  644. .count = 8,
  645. .endpoint = 0x81,
  646. .u = {
  647. .bulk = {
  648. .buffersize = 512,
  649. }
  650. }
  651. }},{
  652. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  653. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  654. .pid_filter_count = 8,
  655. .pid_filter = m9206_pid_filter,
  656. .pid_filter_ctrl = m9206_pid_filter_ctrl,
  657. .frontend_attach = m920x_tda10046_0b_frontend_attach,
  658. .tuner_attach = m920x_tda8275_61_tuner_attach,
  659. .stream = {
  660. .type = USB_BULK,
  661. .count = 8,
  662. .endpoint = 0x82,
  663. .u = {
  664. .bulk = {
  665. .buffersize = 512,
  666. }
  667. }
  668. },
  669. }},
  670. .i2c_algo = &m9206_i2c_algo,
  671. .num_device_descs = 1,
  672. .devices = {
  673. { .name = "LifeView TV Walker Twin DVB-T USB2.0",
  674. .cold_ids = { &m920x_table[2], NULL },
  675. .warm_ids = { &m920x_table[3], NULL },
  676. },
  677. }
  678. };
  679. static struct dvb_usb_device_properties dposh_properties = {
  680. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  681. .usb_ctrl = DEVICE_SPECIFIC,
  682. .firmware = "dvb-usb-dposh-01.fw",
  683. .download_firmware = m9206_firmware_download,
  684. .size_of_priv = sizeof(struct m9206_state),
  685. .identify_state = m920x_identify_state,
  686. .num_adapters = 1,
  687. .adapter = {{
  688. /* Hardware pid filters don't work with this device/firmware */
  689. .frontend_attach = m920x_mt352_frontend_attach,
  690. .tuner_attach = m920x_qt1010_tuner_attach,
  691. .stream = {
  692. .type = USB_BULK,
  693. .count = 8,
  694. .endpoint = 0x81,
  695. .u = {
  696. .bulk = {
  697. .buffersize = 512,
  698. }
  699. }
  700. },
  701. }},
  702. .i2c_algo = &m9206_i2c_algo,
  703. .num_device_descs = 1,
  704. .devices = {
  705. { .name = "Dposh DVB-T USB2.0",
  706. .cold_ids = { &m920x_table[4], NULL },
  707. .warm_ids = { &m920x_table[5], NULL },
  708. },
  709. }
  710. };
  711. static struct usb_driver m920x_driver = {
  712. .name = "dvb_usb_m920x",
  713. .probe = m920x_probe,
  714. .disconnect = dvb_usb_device_exit,
  715. .id_table = m920x_table,
  716. };
  717. /* module stuff */
  718. static int __init m920x_module_init(void)
  719. {
  720. int ret;
  721. if ((ret = usb_register(&m920x_driver))) {
  722. err("usb_register failed. Error number %d", ret);
  723. return ret;
  724. }
  725. return 0;
  726. }
  727. static void __exit m920x_module_exit(void)
  728. {
  729. /* deregister this driver from the USB subsystem */
  730. usb_deregister(&m920x_driver);
  731. }
  732. module_init (m920x_module_init);
  733. module_exit (m920x_module_exit);
  734. MODULE_AUTHOR("Aapo Tahkola <aet@rasterburn.org>");
  735. MODULE_DESCRIPTION("DVB Driver for ULI M920x");
  736. MODULE_VERSION("0.1");
  737. MODULE_LICENSE("GPL");
  738. /*
  739. * Local variables:
  740. * c-basic-offset: 8
  741. */