m920x.c 21 KB

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