m920x.c 22 KB

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