cxusb.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  1. /* DVB USB compliant linux driver for Conexant USB reference design.
  2. *
  3. * The Conexant reference design I saw on their website was only for analogue
  4. * capturing (using the cx25842). The box I took to write this driver (reverse
  5. * engineered) is the one labeled Medion MD95700. In addition to the cx25842
  6. * for analogue capturing it also has a cx22702 DVB-T demodulator on the main
  7. * board. Besides it has a atiremote (X10) and a USB2.0 hub onboard.
  8. *
  9. * Maybe it is a little bit premature to call this driver cxusb, but I assume
  10. * the USB protocol is identical or at least inherited from the reference
  11. * design, so it can be reused for the "analogue-only" device (if it will
  12. * appear at all).
  13. *
  14. * TODO: Use the cx25840-driver for the analogue part
  15. *
  16. * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@desy.de)
  17. * Copyright (C) 2006 Michael Krufky (mkrufky@linuxtv.org)
  18. * Copyright (C) 2006 Chris Pascoe (c.pascoe@itee.uq.edu.au)
  19. *
  20. * This program is free software; you can redistribute it and/or modify it
  21. * under the terms of the GNU General Public License as published by the Free
  22. * Software Foundation, version 2.
  23. *
  24. * see Documentation/dvb/README.dvb-usb for more information
  25. */
  26. #include "cxusb.h"
  27. #include "cx22702.h"
  28. #include "lgdt330x.h"
  29. #include "mt352.h"
  30. #include "mt352_priv.h"
  31. #include "zl10353.h"
  32. /* debug */
  33. static int dvb_usb_cxusb_debug;
  34. module_param_named(debug, dvb_usb_cxusb_debug, int, 0644);
  35. MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
  36. #define deb_info(args...) dprintk(dvb_usb_cxusb_debug,0x01,args)
  37. #define deb_i2c(args...) if (d->udev->descriptor.idVendor == USB_VID_MEDION) \
  38. dprintk(dvb_usb_cxusb_debug,0x01,args)
  39. static int cxusb_ctrl_msg(struct dvb_usb_device *d,
  40. u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen)
  41. {
  42. int wo = (rbuf == NULL || rlen == 0); /* write-only */
  43. u8 sndbuf[1+wlen];
  44. memset(sndbuf, 0, 1+wlen);
  45. sndbuf[0] = cmd;
  46. memcpy(&sndbuf[1], wbuf, wlen);
  47. if (wo)
  48. return dvb_usb_generic_write(d, sndbuf, 1+wlen);
  49. else
  50. return dvb_usb_generic_rw(d, sndbuf, 1+wlen, rbuf, rlen, 0);
  51. }
  52. /* GPIO */
  53. static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)
  54. {
  55. struct cxusb_state *st = d->priv;
  56. u8 o[2], i;
  57. if (st->gpio_write_state[GPIO_TUNER] == onoff)
  58. return;
  59. o[0] = GPIO_TUNER;
  60. o[1] = onoff;
  61. cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
  62. if (i != 0x01)
  63. deb_info("gpio_write failed.\n");
  64. st->gpio_write_state[GPIO_TUNER] = onoff;
  65. }
  66. /* I2C */
  67. static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
  68. int num)
  69. {
  70. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  71. int i;
  72. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  73. return -EAGAIN;
  74. if (num > 2)
  75. warn("more than two i2c messages at a time is not handled yet. TODO.");
  76. for (i = 0; i < num; i++) {
  77. if (d->udev->descriptor.idVendor == USB_VID_MEDION)
  78. switch (msg[i].addr) {
  79. case 0x63:
  80. cxusb_gpio_tuner(d, 0);
  81. break;
  82. default:
  83. cxusb_gpio_tuner(d, 1);
  84. break;
  85. }
  86. /* read request */
  87. if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
  88. u8 obuf[3+msg[i].len], ibuf[1+msg[i+1].len];
  89. obuf[0] = msg[i].len;
  90. obuf[1] = msg[i+1].len;
  91. obuf[2] = msg[i].addr;
  92. memcpy(&obuf[3], msg[i].buf, msg[i].len);
  93. if (cxusb_ctrl_msg(d, CMD_I2C_READ,
  94. obuf, 3+msg[i].len,
  95. ibuf, 1+msg[i+1].len) < 0)
  96. break;
  97. if (ibuf[0] != 0x08)
  98. deb_i2c("i2c read may have failed\n");
  99. memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len);
  100. i++;
  101. } else { /* write */
  102. u8 obuf[2+msg[i].len], ibuf;
  103. obuf[0] = msg[i].addr;
  104. obuf[1] = msg[i].len;
  105. memcpy(&obuf[2], msg[i].buf, msg[i].len);
  106. if (cxusb_ctrl_msg(d, CMD_I2C_WRITE, obuf,
  107. 2+msg[i].len, &ibuf,1) < 0)
  108. break;
  109. if (ibuf != 0x08)
  110. deb_i2c("i2c write may have failed\n");
  111. }
  112. }
  113. mutex_unlock(&d->i2c_mutex);
  114. return i;
  115. }
  116. static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
  117. {
  118. return I2C_FUNC_I2C;
  119. }
  120. static struct i2c_algorithm cxusb_i2c_algo = {
  121. .master_xfer = cxusb_i2c_xfer,
  122. .functionality = cxusb_i2c_func,
  123. };
  124. static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff)
  125. {
  126. u8 b = 0;
  127. if (onoff)
  128. return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
  129. else
  130. return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0);
  131. }
  132. static int cxusb_bluebird_power_ctrl(struct dvb_usb_device *d, int onoff)
  133. {
  134. u8 b = 0;
  135. if (onoff)
  136. return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
  137. else
  138. return 0;
  139. }
  140. static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
  141. {
  142. u8 buf[2] = { 0x03, 0x00 };
  143. if (onoff)
  144. cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON, buf, 2, NULL, 0);
  145. else
  146. cxusb_ctrl_msg(adap->dev, CMD_STREAMING_OFF, NULL, 0, NULL, 0);
  147. return 0;
  148. }
  149. static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
  150. {
  151. struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
  152. u8 ircode[4];
  153. int i;
  154. cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
  155. *event = 0;
  156. *state = REMOTE_NO_KEY_PRESSED;
  157. for (i = 0; i < d->props.rc_key_map_size; i++) {
  158. if (keymap[i].custom == ircode[2] &&
  159. keymap[i].data == ircode[3]) {
  160. *event = keymap[i].event;
  161. *state = REMOTE_KEY_PRESSED;
  162. return 0;
  163. }
  164. }
  165. return 0;
  166. }
  167. static struct dvb_usb_rc_key dvico_mce_rc_keys[] = {
  168. { 0xfe, 0x02, KEY_TV },
  169. { 0xfe, 0x0e, KEY_MP3 },
  170. { 0xfe, 0x1a, KEY_DVD },
  171. { 0xfe, 0x1e, KEY_FAVORITES },
  172. { 0xfe, 0x16, KEY_SETUP },
  173. { 0xfe, 0x46, KEY_POWER2 },
  174. { 0xfe, 0x0a, KEY_EPG },
  175. { 0xfe, 0x49, KEY_BACK },
  176. { 0xfe, 0x4d, KEY_MENU },
  177. { 0xfe, 0x51, KEY_UP },
  178. { 0xfe, 0x5b, KEY_LEFT },
  179. { 0xfe, 0x5f, KEY_RIGHT },
  180. { 0xfe, 0x53, KEY_DOWN },
  181. { 0xfe, 0x5e, KEY_OK },
  182. { 0xfe, 0x59, KEY_INFO },
  183. { 0xfe, 0x55, KEY_TAB },
  184. { 0xfe, 0x0f, KEY_PREVIOUSSONG },/* Replay */
  185. { 0xfe, 0x12, KEY_NEXTSONG }, /* Skip */
  186. { 0xfe, 0x42, KEY_ENTER }, /* Windows/Start */
  187. { 0xfe, 0x15, KEY_VOLUMEUP },
  188. { 0xfe, 0x05, KEY_VOLUMEDOWN },
  189. { 0xfe, 0x11, KEY_CHANNELUP },
  190. { 0xfe, 0x09, KEY_CHANNELDOWN },
  191. { 0xfe, 0x52, KEY_CAMERA },
  192. { 0xfe, 0x5a, KEY_TUNER }, /* Live */
  193. { 0xfe, 0x19, KEY_OPEN },
  194. { 0xfe, 0x0b, KEY_1 },
  195. { 0xfe, 0x17, KEY_2 },
  196. { 0xfe, 0x1b, KEY_3 },
  197. { 0xfe, 0x07, KEY_4 },
  198. { 0xfe, 0x50, KEY_5 },
  199. { 0xfe, 0x54, KEY_6 },
  200. { 0xfe, 0x48, KEY_7 },
  201. { 0xfe, 0x4c, KEY_8 },
  202. { 0xfe, 0x58, KEY_9 },
  203. { 0xfe, 0x13, KEY_ANGLE }, /* Aspect */
  204. { 0xfe, 0x03, KEY_0 },
  205. { 0xfe, 0x1f, KEY_ZOOM },
  206. { 0xfe, 0x43, KEY_REWIND },
  207. { 0xfe, 0x47, KEY_PLAYPAUSE },
  208. { 0xfe, 0x4f, KEY_FASTFORWARD },
  209. { 0xfe, 0x57, KEY_MUTE },
  210. { 0xfe, 0x0d, KEY_STOP },
  211. { 0xfe, 0x01, KEY_RECORD },
  212. { 0xfe, 0x4e, KEY_POWER },
  213. };
  214. static struct dvb_usb_rc_key dvico_portable_rc_keys[] = {
  215. { 0xfc, 0x02, KEY_SETUP }, /* Profile */
  216. { 0xfc, 0x43, KEY_POWER2 },
  217. { 0xfc, 0x06, KEY_EPG },
  218. { 0xfc, 0x5a, KEY_BACK },
  219. { 0xfc, 0x05, KEY_MENU },
  220. { 0xfc, 0x47, KEY_INFO },
  221. { 0xfc, 0x01, KEY_TAB },
  222. { 0xfc, 0x42, KEY_PREVIOUSSONG },/* Replay */
  223. { 0xfc, 0x49, KEY_VOLUMEUP },
  224. { 0xfc, 0x09, KEY_VOLUMEDOWN },
  225. { 0xfc, 0x54, KEY_CHANNELUP },
  226. { 0xfc, 0x0b, KEY_CHANNELDOWN },
  227. { 0xfc, 0x16, KEY_CAMERA },
  228. { 0xfc, 0x40, KEY_TUNER }, /* ATV/DTV */
  229. { 0xfc, 0x45, KEY_OPEN },
  230. { 0xfc, 0x19, KEY_1 },
  231. { 0xfc, 0x18, KEY_2 },
  232. { 0xfc, 0x1b, KEY_3 },
  233. { 0xfc, 0x1a, KEY_4 },
  234. { 0xfc, 0x58, KEY_5 },
  235. { 0xfc, 0x59, KEY_6 },
  236. { 0xfc, 0x15, KEY_7 },
  237. { 0xfc, 0x14, KEY_8 },
  238. { 0xfc, 0x17, KEY_9 },
  239. { 0xfc, 0x44, KEY_ANGLE }, /* Aspect */
  240. { 0xfc, 0x55, KEY_0 },
  241. { 0xfc, 0x07, KEY_ZOOM },
  242. { 0xfc, 0x0a, KEY_REWIND },
  243. { 0xfc, 0x08, KEY_PLAYPAUSE },
  244. { 0xfc, 0x4b, KEY_FASTFORWARD },
  245. { 0xfc, 0x5b, KEY_MUTE },
  246. { 0xfc, 0x04, KEY_STOP },
  247. { 0xfc, 0x56, KEY_RECORD },
  248. { 0xfc, 0x57, KEY_POWER },
  249. { 0xfc, 0x41, KEY_UNKNOWN }, /* INPUT */
  250. { 0xfc, 0x00, KEY_UNKNOWN }, /* HD */
  251. };
  252. static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
  253. {
  254. static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 };
  255. static u8 reset [] = { RESET, 0x80 };
  256. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  257. static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
  258. static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
  259. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
  260. mt352_write(fe, clock_config, sizeof(clock_config));
  261. udelay(200);
  262. mt352_write(fe, reset, sizeof(reset));
  263. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  264. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  265. mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
  266. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  267. return 0;
  268. }
  269. static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
  270. { /* used in both lgz201 and th7579 */
  271. static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x29 };
  272. static u8 reset [] = { RESET, 0x80 };
  273. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  274. static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
  275. static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
  276. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
  277. mt352_write(fe, clock_config, sizeof(clock_config));
  278. udelay(200);
  279. mt352_write(fe, reset, sizeof(reset));
  280. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  281. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  282. mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
  283. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  284. return 0;
  285. }
  286. static struct cx22702_config cxusb_cx22702_config = {
  287. .demod_address = 0x63,
  288. .output_mode = CX22702_PARALLEL_OUTPUT,
  289. };
  290. static struct lgdt330x_config cxusb_lgdt3303_config = {
  291. .demod_address = 0x0e,
  292. .demod_chip = LGDT3303,
  293. };
  294. static struct mt352_config cxusb_dee1601_config = {
  295. .demod_address = 0x0f,
  296. .demod_init = cxusb_dee1601_demod_init,
  297. };
  298. static struct zl10353_config cxusb_zl10353_dee1601_config = {
  299. .demod_address = 0x0f,
  300. .parallel_ts = 1,
  301. };
  302. static struct mt352_config cxusb_mt352_config = {
  303. /* used in both lgz201 and th7579 */
  304. .demod_address = 0x0f,
  305. .demod_init = cxusb_mt352_demod_init,
  306. };
  307. /* Callbacks for DVB USB */
  308. static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
  309. {
  310. dvb_attach(dvb_pll_attach, adap->fe, 0x61, &adap->dev->i2c_adap,
  311. DVB_PLL_FMD1216ME);
  312. return 0;
  313. }
  314. static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap)
  315. {
  316. dvb_attach(dvb_pll_attach, adap->fe, 0x61,
  317. NULL, DVB_PLL_THOMSON_DTT7579);
  318. return 0;
  319. }
  320. static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap)
  321. {
  322. dvb_attach(dvb_pll_attach, adap->fe, 0x61, NULL, DVB_PLL_LG_Z201);
  323. return 0;
  324. }
  325. static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap)
  326. {
  327. dvb_attach(dvb_pll_attach, adap->fe, 0x60,
  328. NULL, DVB_PLL_THOMSON_DTT7579);
  329. return 0;
  330. }
  331. static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap)
  332. {
  333. dvb_attach(dvb_pll_attach, adap->fe, 0x61, &adap->dev->i2c_adap,
  334. DVB_PLL_LG_TDVS_H06XF);
  335. return 0;
  336. }
  337. static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
  338. {
  339. u8 b;
  340. if (usb_set_interface(adap->dev->udev, 0, 6) < 0)
  341. err("set interface failed");
  342. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1);
  343. if ((adap->fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config,
  344. &adap->dev->i2c_adap)) != NULL)
  345. return 0;
  346. return -EIO;
  347. }
  348. static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
  349. {
  350. if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
  351. err("set interface failed");
  352. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  353. if ((adap->fe = dvb_attach(lgdt330x_attach, &cxusb_lgdt3303_config,
  354. &adap->dev->i2c_adap)) != NULL)
  355. return 0;
  356. return -EIO;
  357. }
  358. static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap)
  359. {
  360. /* used in both lgz201 and th7579 */
  361. if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
  362. err("set interface failed");
  363. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  364. if ((adap->fe = dvb_attach(mt352_attach, &cxusb_mt352_config,
  365. &adap->dev->i2c_adap)) != NULL)
  366. return 0;
  367. return -EIO;
  368. }
  369. static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
  370. {
  371. if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
  372. err("set interface failed");
  373. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  374. if (((adap->fe = dvb_attach(mt352_attach, &cxusb_dee1601_config,
  375. &adap->dev->i2c_adap)) != NULL) ||
  376. ((adap->fe = dvb_attach(zl10353_attach,
  377. &cxusb_zl10353_dee1601_config,
  378. &adap->dev->i2c_adap)) != NULL))
  379. return 0;
  380. return -EIO;
  381. }
  382. /*
  383. * DViCO bluebird firmware needs the "warm" product ID to be patched into the
  384. * firmware file before download.
  385. */
  386. #define BLUEBIRD_01_ID_OFFSET 6638
  387. static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
  388. const struct firmware *fw)
  389. {
  390. if (fw->size < BLUEBIRD_01_ID_OFFSET + 4)
  391. return -EINVAL;
  392. if (fw->data[BLUEBIRD_01_ID_OFFSET] == (USB_VID_DVICO & 0xff) &&
  393. fw->data[BLUEBIRD_01_ID_OFFSET + 1] == USB_VID_DVICO >> 8) {
  394. fw->data[BLUEBIRD_01_ID_OFFSET + 2] =
  395. le16_to_cpu(udev->descriptor.idProduct) + 1;
  396. fw->data[BLUEBIRD_01_ID_OFFSET + 3] =
  397. le16_to_cpu(udev->descriptor.idProduct) >> 8;
  398. return usb_cypress_load_firmware(udev, fw, CYPRESS_FX2);
  399. }
  400. return -EINVAL;
  401. }
  402. /* DVB USB Driver stuff */
  403. static struct dvb_usb_device_properties cxusb_medion_properties;
  404. static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
  405. static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;
  406. static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;
  407. static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;
  408. static int cxusb_probe(struct usb_interface *intf,
  409. const struct usb_device_id *id)
  410. {
  411. if (dvb_usb_device_init(intf,&cxusb_medion_properties,THIS_MODULE,NULL) == 0 ||
  412. dvb_usb_device_init(intf,&cxusb_bluebird_lgh064f_properties,THIS_MODULE,NULL) == 0 ||
  413. dvb_usb_device_init(intf,&cxusb_bluebird_dee1601_properties,THIS_MODULE,NULL) == 0 ||
  414. dvb_usb_device_init(intf,&cxusb_bluebird_lgz201_properties,THIS_MODULE,NULL) == 0 ||
  415. dvb_usb_device_init(intf,&cxusb_bluebird_dtt7579_properties,THIS_MODULE,NULL) == 0) {
  416. return 0;
  417. }
  418. return -EINVAL;
  419. }
  420. static struct usb_device_id cxusb_table [] = {
  421. { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
  422. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
  423. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
  424. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) },
  425. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) },
  426. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
  427. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
  428. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
  429. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
  430. { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) },
  431. { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) },
  432. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) },
  433. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) },
  434. {} /* Terminating entry */
  435. };
  436. MODULE_DEVICE_TABLE (usb, cxusb_table);
  437. static struct dvb_usb_device_properties cxusb_medion_properties = {
  438. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  439. .usb_ctrl = CYPRESS_FX2,
  440. .size_of_priv = sizeof(struct cxusb_state),
  441. .num_adapters = 1,
  442. .adapter = {
  443. {
  444. .streaming_ctrl = cxusb_streaming_ctrl,
  445. .frontend_attach = cxusb_cx22702_frontend_attach,
  446. .tuner_attach = cxusb_fmd1216me_tuner_attach,
  447. /* parameter for the MPEG2-data transfer */
  448. .stream = {
  449. .type = USB_BULK,
  450. .count = 5,
  451. .endpoint = 0x02,
  452. .u = {
  453. .bulk = {
  454. .buffersize = 8192,
  455. }
  456. }
  457. },
  458. },
  459. },
  460. .power_ctrl = cxusb_power_ctrl,
  461. .i2c_algo = &cxusb_i2c_algo,
  462. .generic_bulk_ctrl_endpoint = 0x01,
  463. .num_device_descs = 1,
  464. .devices = {
  465. { "Medion MD95700 (MDUSBTV-HYBRID)",
  466. { NULL },
  467. { &cxusb_table[0], NULL },
  468. },
  469. }
  470. };
  471. static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
  472. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  473. .usb_ctrl = DEVICE_SPECIFIC,
  474. .firmware = "dvb-usb-bluebird-01.fw",
  475. .download_firmware = bluebird_patch_dvico_firmware_download,
  476. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  477. use usb alt setting 7 for EP2 transfer (atsc) */
  478. .size_of_priv = sizeof(struct cxusb_state),
  479. .num_adapters = 1,
  480. .adapter = {
  481. {
  482. .streaming_ctrl = cxusb_streaming_ctrl,
  483. .frontend_attach = cxusb_lgdt3303_frontend_attach,
  484. .tuner_attach = cxusb_lgh064f_tuner_attach,
  485. /* parameter for the MPEG2-data transfer */
  486. .stream = {
  487. .type = USB_BULK,
  488. .count = 5,
  489. .endpoint = 0x02,
  490. .u = {
  491. .bulk = {
  492. .buffersize = 8192,
  493. }
  494. }
  495. },
  496. },
  497. },
  498. .power_ctrl = cxusb_bluebird_power_ctrl,
  499. .i2c_algo = &cxusb_i2c_algo,
  500. .rc_interval = 100,
  501. .rc_key_map = dvico_portable_rc_keys,
  502. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  503. .rc_query = cxusb_rc_query,
  504. .generic_bulk_ctrl_endpoint = 0x01,
  505. .num_device_descs = 1,
  506. .devices = {
  507. { "DViCO FusionHDTV5 USB Gold",
  508. { &cxusb_table[1], NULL },
  509. { &cxusb_table[2], NULL },
  510. },
  511. }
  512. };
  513. static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
  514. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  515. .usb_ctrl = DEVICE_SPECIFIC,
  516. .firmware = "dvb-usb-bluebird-01.fw",
  517. .download_firmware = bluebird_patch_dvico_firmware_download,
  518. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  519. use usb alt setting 7 for EP2 transfer (atsc) */
  520. .size_of_priv = sizeof(struct cxusb_state),
  521. .num_adapters = 1,
  522. .adapter = {
  523. {
  524. .streaming_ctrl = cxusb_streaming_ctrl,
  525. .frontend_attach = cxusb_dee1601_frontend_attach,
  526. .tuner_attach = cxusb_dee1601_tuner_attach,
  527. /* parameter for the MPEG2-data transfer */
  528. .stream = {
  529. .type = USB_BULK,
  530. .count = 5,
  531. .endpoint = 0x04,
  532. .u = {
  533. .bulk = {
  534. .buffersize = 8192,
  535. }
  536. }
  537. },
  538. },
  539. },
  540. .power_ctrl = cxusb_bluebird_power_ctrl,
  541. .i2c_algo = &cxusb_i2c_algo,
  542. .rc_interval = 150,
  543. .rc_key_map = dvico_mce_rc_keys,
  544. .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
  545. .rc_query = cxusb_rc_query,
  546. .generic_bulk_ctrl_endpoint = 0x01,
  547. .num_device_descs = 3,
  548. .devices = {
  549. { "DViCO FusionHDTV DVB-T Dual USB",
  550. { &cxusb_table[3], NULL },
  551. { &cxusb_table[4], NULL },
  552. },
  553. { "DigitalNow DVB-T Dual USB",
  554. { &cxusb_table[9], NULL },
  555. { &cxusb_table[10], NULL },
  556. },
  557. { "DViCO FusionHDTV DVB-T Dual Digital 2",
  558. { &cxusb_table[11], NULL },
  559. { &cxusb_table[12], NULL },
  560. },
  561. }
  562. };
  563. static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
  564. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  565. .usb_ctrl = DEVICE_SPECIFIC,
  566. .firmware = "dvb-usb-bluebird-01.fw",
  567. .download_firmware = bluebird_patch_dvico_firmware_download,
  568. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  569. use usb alt setting 7 for EP2 transfer (atsc) */
  570. .size_of_priv = sizeof(struct cxusb_state),
  571. .num_adapters = 2,
  572. .adapter = {
  573. {
  574. .streaming_ctrl = cxusb_streaming_ctrl,
  575. .frontend_attach = cxusb_mt352_frontend_attach,
  576. .tuner_attach = cxusb_lgz201_tuner_attach,
  577. /* parameter for the MPEG2-data transfer */
  578. .stream = {
  579. .type = USB_BULK,
  580. .count = 5,
  581. .endpoint = 0x04,
  582. .u = {
  583. .bulk = {
  584. .buffersize = 8192,
  585. }
  586. }
  587. },
  588. },
  589. },
  590. .power_ctrl = cxusb_bluebird_power_ctrl,
  591. .i2c_algo = &cxusb_i2c_algo,
  592. .rc_interval = 100,
  593. .rc_key_map = dvico_portable_rc_keys,
  594. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  595. .rc_query = cxusb_rc_query,
  596. .generic_bulk_ctrl_endpoint = 0x01,
  597. .num_device_descs = 1,
  598. .devices = {
  599. { "DViCO FusionHDTV DVB-T USB (LGZ201)",
  600. { &cxusb_table[5], NULL },
  601. { &cxusb_table[6], NULL },
  602. },
  603. }
  604. };
  605. static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
  606. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  607. .usb_ctrl = DEVICE_SPECIFIC,
  608. .firmware = "dvb-usb-bluebird-01.fw",
  609. .download_firmware = bluebird_patch_dvico_firmware_download,
  610. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  611. use usb alt setting 7 for EP2 transfer (atsc) */
  612. .size_of_priv = sizeof(struct cxusb_state),
  613. .num_adapters = 1,
  614. .adapter = {
  615. {
  616. .streaming_ctrl = cxusb_streaming_ctrl,
  617. .frontend_attach = cxusb_mt352_frontend_attach,
  618. .tuner_attach = cxusb_dtt7579_tuner_attach,
  619. /* parameter for the MPEG2-data transfer */
  620. .stream = {
  621. .type = USB_BULK,
  622. .count = 5,
  623. .endpoint = 0x04,
  624. .u = {
  625. .bulk = {
  626. .buffersize = 8192,
  627. }
  628. }
  629. },
  630. },
  631. },
  632. .power_ctrl = cxusb_bluebird_power_ctrl,
  633. .i2c_algo = &cxusb_i2c_algo,
  634. .rc_interval = 100,
  635. .rc_key_map = dvico_portable_rc_keys,
  636. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  637. .rc_query = cxusb_rc_query,
  638. .generic_bulk_ctrl_endpoint = 0x01,
  639. .num_device_descs = 1,
  640. .devices = {
  641. { "DViCO FusionHDTV DVB-T USB (TH7579)",
  642. { &cxusb_table[7], NULL },
  643. { &cxusb_table[8], NULL },
  644. },
  645. }
  646. };
  647. static struct usb_driver cxusb_driver = {
  648. .name = "dvb_usb_cxusb",
  649. .probe = cxusb_probe,
  650. .disconnect = dvb_usb_device_exit,
  651. .id_table = cxusb_table,
  652. };
  653. /* module stuff */
  654. static int __init cxusb_module_init(void)
  655. {
  656. int result;
  657. if ((result = usb_register(&cxusb_driver))) {
  658. err("usb_register failed. Error number %d",result);
  659. return result;
  660. }
  661. return 0;
  662. }
  663. static void __exit cxusb_module_exit(void)
  664. {
  665. /* deregister this driver from the USB subsystem */
  666. usb_deregister(&cxusb_driver);
  667. }
  668. module_init (cxusb_module_init);
  669. module_exit (cxusb_module_exit);
  670. MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
  671. MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
  672. MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
  673. MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
  674. MODULE_VERSION("1.0-alpha");
  675. MODULE_LICENSE("GPL");