cxusb.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203
  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, 2007 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 <media/tuner.h>
  27. #include "cxusb.h"
  28. #include "cx22702.h"
  29. #include "lgdt330x.h"
  30. #include "mt352.h"
  31. #include "mt352_priv.h"
  32. #include "zl10353.h"
  33. #include "tuner-xc2028.h"
  34. #include "tuner-simple.h"
  35. /* debug */
  36. static int dvb_usb_cxusb_debug;
  37. module_param_named(debug, dvb_usb_cxusb_debug, int, 0644);
  38. MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
  39. DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
  40. #define deb_info(args...) dprintk(dvb_usb_cxusb_debug,0x01,args)
  41. #define deb_i2c(args...) if (d->udev->descriptor.idVendor == USB_VID_MEDION) \
  42. dprintk(dvb_usb_cxusb_debug,0x01,args)
  43. static int cxusb_ctrl_msg(struct dvb_usb_device *d,
  44. u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen)
  45. {
  46. int wo = (rbuf == NULL || rlen == 0); /* write-only */
  47. u8 sndbuf[1+wlen];
  48. memset(sndbuf, 0, 1+wlen);
  49. sndbuf[0] = cmd;
  50. memcpy(&sndbuf[1], wbuf, wlen);
  51. if (wo)
  52. return dvb_usb_generic_write(d, sndbuf, 1+wlen);
  53. else
  54. return dvb_usb_generic_rw(d, sndbuf, 1+wlen, rbuf, rlen, 0);
  55. }
  56. /* GPIO */
  57. static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)
  58. {
  59. struct cxusb_state *st = d->priv;
  60. u8 o[2], i;
  61. if (st->gpio_write_state[GPIO_TUNER] == onoff)
  62. return;
  63. o[0] = GPIO_TUNER;
  64. o[1] = onoff;
  65. cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
  66. if (i != 0x01)
  67. deb_info("gpio_write failed.\n");
  68. st->gpio_write_state[GPIO_TUNER] = onoff;
  69. }
  70. static int cxusb_bluebird_gpio_rw(struct dvb_usb_device *d, u8 changemask,
  71. u8 newval)
  72. {
  73. u8 o[2], gpio_state;
  74. int rc;
  75. o[0] = 0xff & ~changemask; /* mask of bits to keep */
  76. o[1] = newval & changemask; /* new values for bits */
  77. rc = cxusb_ctrl_msg(d, CMD_BLUEBIRD_GPIO_RW, o, 2, &gpio_state, 1);
  78. if (rc < 0 || (gpio_state & changemask) != (newval & changemask))
  79. deb_info("bluebird_gpio_write failed.\n");
  80. return rc < 0 ? rc : gpio_state;
  81. }
  82. static void cxusb_bluebird_gpio_pulse(struct dvb_usb_device *d, u8 pin, int low)
  83. {
  84. cxusb_bluebird_gpio_rw(d, pin, low ? 0 : pin);
  85. msleep(5);
  86. cxusb_bluebird_gpio_rw(d, pin, low ? pin : 0);
  87. }
  88. static void cxusb_nano2_led(struct dvb_usb_device *d, int onoff)
  89. {
  90. cxusb_bluebird_gpio_rw(d, 0x40, onoff ? 0 : 0x40);
  91. }
  92. /* I2C */
  93. static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
  94. int num)
  95. {
  96. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  97. int i;
  98. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  99. return -EAGAIN;
  100. for (i = 0; i < num; i++) {
  101. if (d->udev->descriptor.idVendor == USB_VID_MEDION)
  102. switch (msg[i].addr) {
  103. case 0x63:
  104. cxusb_gpio_tuner(d, 0);
  105. break;
  106. default:
  107. cxusb_gpio_tuner(d, 1);
  108. break;
  109. }
  110. if (msg[i].flags & I2C_M_RD) {
  111. /* read only */
  112. u8 obuf[3], ibuf[1+msg[i].len];
  113. obuf[0] = 0;
  114. obuf[1] = msg[i].len;
  115. obuf[2] = msg[i].addr;
  116. if (cxusb_ctrl_msg(d, CMD_I2C_READ,
  117. obuf, 3,
  118. ibuf, 1+msg[i].len) < 0) {
  119. warn("i2c read failed");
  120. break;
  121. }
  122. memcpy(msg[i].buf, &ibuf[1], msg[i].len);
  123. } else if (i+1 < num && (msg[i+1].flags & I2C_M_RD) &&
  124. msg[i].addr == msg[i+1].addr) {
  125. /* write to then read from same address */
  126. u8 obuf[3+msg[i].len], ibuf[1+msg[i+1].len];
  127. obuf[0] = msg[i].len;
  128. obuf[1] = msg[i+1].len;
  129. obuf[2] = msg[i].addr;
  130. memcpy(&obuf[3], msg[i].buf, msg[i].len);
  131. if (cxusb_ctrl_msg(d, CMD_I2C_READ,
  132. obuf, 3+msg[i].len,
  133. ibuf, 1+msg[i+1].len) < 0)
  134. break;
  135. if (ibuf[0] != 0x08)
  136. deb_i2c("i2c read may have failed\n");
  137. memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len);
  138. i++;
  139. } else {
  140. /* write only */
  141. u8 obuf[2+msg[i].len], ibuf;
  142. obuf[0] = msg[i].addr;
  143. obuf[1] = msg[i].len;
  144. memcpy(&obuf[2], msg[i].buf, msg[i].len);
  145. if (cxusb_ctrl_msg(d, CMD_I2C_WRITE, obuf,
  146. 2+msg[i].len, &ibuf,1) < 0)
  147. break;
  148. if (ibuf != 0x08)
  149. deb_i2c("i2c write may have failed\n");
  150. }
  151. }
  152. mutex_unlock(&d->i2c_mutex);
  153. return i == num ? num : -EREMOTEIO;
  154. }
  155. static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
  156. {
  157. return I2C_FUNC_I2C;
  158. }
  159. static struct i2c_algorithm cxusb_i2c_algo = {
  160. .master_xfer = cxusb_i2c_xfer,
  161. .functionality = cxusb_i2c_func,
  162. };
  163. static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff)
  164. {
  165. u8 b = 0;
  166. if (onoff)
  167. return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
  168. else
  169. return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0);
  170. }
  171. static int cxusb_bluebird_power_ctrl(struct dvb_usb_device *d, int onoff)
  172. {
  173. u8 b = 0;
  174. if (onoff)
  175. return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
  176. else
  177. return 0;
  178. }
  179. static int cxusb_nano2_power_ctrl(struct dvb_usb_device *d, int onoff)
  180. {
  181. int rc = 0;
  182. rc = cxusb_power_ctrl(d, onoff);
  183. if (!onoff)
  184. cxusb_nano2_led(d, 0);
  185. return rc;
  186. }
  187. static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
  188. {
  189. u8 buf[2] = { 0x03, 0x00 };
  190. if (onoff)
  191. cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON, buf, 2, NULL, 0);
  192. else
  193. cxusb_ctrl_msg(adap->dev, CMD_STREAMING_OFF, NULL, 0, NULL, 0);
  194. return 0;
  195. }
  196. static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
  197. {
  198. struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
  199. u8 ircode[4];
  200. int i;
  201. cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
  202. *event = 0;
  203. *state = REMOTE_NO_KEY_PRESSED;
  204. for (i = 0; i < d->props.rc_key_map_size; i++) {
  205. if (keymap[i].custom == ircode[2] &&
  206. keymap[i].data == ircode[3]) {
  207. *event = keymap[i].event;
  208. *state = REMOTE_KEY_PRESSED;
  209. return 0;
  210. }
  211. }
  212. return 0;
  213. }
  214. static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d, u32 *event,
  215. int *state)
  216. {
  217. struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
  218. u8 ircode[4];
  219. int i;
  220. struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
  221. .buf = ircode, .len = 4 };
  222. *event = 0;
  223. *state = REMOTE_NO_KEY_PRESSED;
  224. if (cxusb_i2c_xfer(&d->i2c_adap, &msg, 1) != 1)
  225. return 0;
  226. for (i = 0; i < d->props.rc_key_map_size; i++) {
  227. if (keymap[i].custom == ircode[1] &&
  228. keymap[i].data == ircode[2]) {
  229. *event = keymap[i].event;
  230. *state = REMOTE_KEY_PRESSED;
  231. return 0;
  232. }
  233. }
  234. return 0;
  235. }
  236. static struct dvb_usb_rc_key dvico_mce_rc_keys[] = {
  237. { 0xfe, 0x02, KEY_TV },
  238. { 0xfe, 0x0e, KEY_MP3 },
  239. { 0xfe, 0x1a, KEY_DVD },
  240. { 0xfe, 0x1e, KEY_FAVORITES },
  241. { 0xfe, 0x16, KEY_SETUP },
  242. { 0xfe, 0x46, KEY_POWER2 },
  243. { 0xfe, 0x0a, KEY_EPG },
  244. { 0xfe, 0x49, KEY_BACK },
  245. { 0xfe, 0x4d, KEY_MENU },
  246. { 0xfe, 0x51, KEY_UP },
  247. { 0xfe, 0x5b, KEY_LEFT },
  248. { 0xfe, 0x5f, KEY_RIGHT },
  249. { 0xfe, 0x53, KEY_DOWN },
  250. { 0xfe, 0x5e, KEY_OK },
  251. { 0xfe, 0x59, KEY_INFO },
  252. { 0xfe, 0x55, KEY_TAB },
  253. { 0xfe, 0x0f, KEY_PREVIOUSSONG },/* Replay */
  254. { 0xfe, 0x12, KEY_NEXTSONG }, /* Skip */
  255. { 0xfe, 0x42, KEY_ENTER }, /* Windows/Start */
  256. { 0xfe, 0x15, KEY_VOLUMEUP },
  257. { 0xfe, 0x05, KEY_VOLUMEDOWN },
  258. { 0xfe, 0x11, KEY_CHANNELUP },
  259. { 0xfe, 0x09, KEY_CHANNELDOWN },
  260. { 0xfe, 0x52, KEY_CAMERA },
  261. { 0xfe, 0x5a, KEY_TUNER }, /* Live */
  262. { 0xfe, 0x19, KEY_OPEN },
  263. { 0xfe, 0x0b, KEY_1 },
  264. { 0xfe, 0x17, KEY_2 },
  265. { 0xfe, 0x1b, KEY_3 },
  266. { 0xfe, 0x07, KEY_4 },
  267. { 0xfe, 0x50, KEY_5 },
  268. { 0xfe, 0x54, KEY_6 },
  269. { 0xfe, 0x48, KEY_7 },
  270. { 0xfe, 0x4c, KEY_8 },
  271. { 0xfe, 0x58, KEY_9 },
  272. { 0xfe, 0x13, KEY_ANGLE }, /* Aspect */
  273. { 0xfe, 0x03, KEY_0 },
  274. { 0xfe, 0x1f, KEY_ZOOM },
  275. { 0xfe, 0x43, KEY_REWIND },
  276. { 0xfe, 0x47, KEY_PLAYPAUSE },
  277. { 0xfe, 0x4f, KEY_FASTFORWARD },
  278. { 0xfe, 0x57, KEY_MUTE },
  279. { 0xfe, 0x0d, KEY_STOP },
  280. { 0xfe, 0x01, KEY_RECORD },
  281. { 0xfe, 0x4e, KEY_POWER },
  282. };
  283. static struct dvb_usb_rc_key dvico_portable_rc_keys[] = {
  284. { 0xfc, 0x02, KEY_SETUP }, /* Profile */
  285. { 0xfc, 0x43, KEY_POWER2 },
  286. { 0xfc, 0x06, KEY_EPG },
  287. { 0xfc, 0x5a, KEY_BACK },
  288. { 0xfc, 0x05, KEY_MENU },
  289. { 0xfc, 0x47, KEY_INFO },
  290. { 0xfc, 0x01, KEY_TAB },
  291. { 0xfc, 0x42, KEY_PREVIOUSSONG },/* Replay */
  292. { 0xfc, 0x49, KEY_VOLUMEUP },
  293. { 0xfc, 0x09, KEY_VOLUMEDOWN },
  294. { 0xfc, 0x54, KEY_CHANNELUP },
  295. { 0xfc, 0x0b, KEY_CHANNELDOWN },
  296. { 0xfc, 0x16, KEY_CAMERA },
  297. { 0xfc, 0x40, KEY_TUNER }, /* ATV/DTV */
  298. { 0xfc, 0x45, KEY_OPEN },
  299. { 0xfc, 0x19, KEY_1 },
  300. { 0xfc, 0x18, KEY_2 },
  301. { 0xfc, 0x1b, KEY_3 },
  302. { 0xfc, 0x1a, KEY_4 },
  303. { 0xfc, 0x58, KEY_5 },
  304. { 0xfc, 0x59, KEY_6 },
  305. { 0xfc, 0x15, KEY_7 },
  306. { 0xfc, 0x14, KEY_8 },
  307. { 0xfc, 0x17, KEY_9 },
  308. { 0xfc, 0x44, KEY_ANGLE }, /* Aspect */
  309. { 0xfc, 0x55, KEY_0 },
  310. { 0xfc, 0x07, KEY_ZOOM },
  311. { 0xfc, 0x0a, KEY_REWIND },
  312. { 0xfc, 0x08, KEY_PLAYPAUSE },
  313. { 0xfc, 0x4b, KEY_FASTFORWARD },
  314. { 0xfc, 0x5b, KEY_MUTE },
  315. { 0xfc, 0x04, KEY_STOP },
  316. { 0xfc, 0x56, KEY_RECORD },
  317. { 0xfc, 0x57, KEY_POWER },
  318. { 0xfc, 0x41, KEY_UNKNOWN }, /* INPUT */
  319. { 0xfc, 0x00, KEY_UNKNOWN }, /* HD */
  320. };
  321. static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
  322. {
  323. static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 };
  324. static u8 reset [] = { RESET, 0x80 };
  325. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  326. static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
  327. static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
  328. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
  329. mt352_write(fe, clock_config, sizeof(clock_config));
  330. udelay(200);
  331. mt352_write(fe, reset, sizeof(reset));
  332. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  333. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  334. mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
  335. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  336. return 0;
  337. }
  338. static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
  339. { /* used in both lgz201 and th7579 */
  340. static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x29 };
  341. static u8 reset [] = { RESET, 0x80 };
  342. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  343. static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
  344. static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
  345. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
  346. mt352_write(fe, clock_config, sizeof(clock_config));
  347. udelay(200);
  348. mt352_write(fe, reset, sizeof(reset));
  349. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  350. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  351. mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
  352. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  353. return 0;
  354. }
  355. static struct cx22702_config cxusb_cx22702_config = {
  356. .demod_address = 0x63,
  357. .output_mode = CX22702_PARALLEL_OUTPUT,
  358. };
  359. static struct lgdt330x_config cxusb_lgdt3303_config = {
  360. .demod_address = 0x0e,
  361. .demod_chip = LGDT3303,
  362. };
  363. static struct mt352_config cxusb_dee1601_config = {
  364. .demod_address = 0x0f,
  365. .demod_init = cxusb_dee1601_demod_init,
  366. };
  367. static struct zl10353_config cxusb_zl10353_dee1601_config = {
  368. .demod_address = 0x0f,
  369. .parallel_ts = 1,
  370. };
  371. static struct mt352_config cxusb_mt352_config = {
  372. /* used in both lgz201 and th7579 */
  373. .demod_address = 0x0f,
  374. .demod_init = cxusb_mt352_demod_init,
  375. };
  376. static struct zl10353_config cxusb_zl10353_xc3028_config = {
  377. .demod_address = 0x0f,
  378. .if2 = 45600,
  379. .no_tuner = 1,
  380. .parallel_ts = 1,
  381. };
  382. static struct mt352_config cxusb_mt352_xc3028_config = {
  383. .demod_address = 0x0f,
  384. .if2 = 4560,
  385. .no_tuner = 1,
  386. .demod_init = cxusb_mt352_demod_init,
  387. };
  388. /* Callbacks for DVB USB */
  389. static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
  390. {
  391. dvb_attach(simple_tuner_attach, adap->fe,
  392. &adap->dev->i2c_adap, 0x61,
  393. TUNER_PHILIPS_FMD1216ME_MK3);
  394. return 0;
  395. }
  396. static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap)
  397. {
  398. dvb_attach(dvb_pll_attach, adap->fe, 0x61,
  399. NULL, DVB_PLL_THOMSON_DTT7579);
  400. return 0;
  401. }
  402. static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap)
  403. {
  404. dvb_attach(dvb_pll_attach, adap->fe, 0x61, NULL, DVB_PLL_LG_Z201);
  405. return 0;
  406. }
  407. static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap)
  408. {
  409. dvb_attach(dvb_pll_attach, adap->fe, 0x60,
  410. NULL, DVB_PLL_THOMSON_DTT7579);
  411. return 0;
  412. }
  413. static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap)
  414. {
  415. dvb_attach(simple_tuner_attach, adap->fe,
  416. &adap->dev->i2c_adap, 0x61, TUNER_LG_TDVS_H06XF);
  417. return 0;
  418. }
  419. static int dvico_bluebird_xc2028_callback(void *ptr, int command, int arg)
  420. {
  421. struct dvb_usb_device *d = ptr;
  422. switch (command) {
  423. case XC2028_TUNER_RESET:
  424. deb_info("%s: XC2028_TUNER_RESET %d\n", __func__, arg);
  425. cxusb_bluebird_gpio_pulse(d, 0x01, 1);
  426. break;
  427. case XC2028_RESET_CLK:
  428. deb_info("%s: XC2028_RESET_CLK %d\n", __func__, arg);
  429. break;
  430. default:
  431. deb_info("%s: unknown command %d, arg %d\n", __func__,
  432. command, arg);
  433. return -EINVAL;
  434. }
  435. return 0;
  436. }
  437. static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter *adap)
  438. {
  439. struct dvb_frontend *fe;
  440. struct xc2028_config cfg = {
  441. .i2c_adap = &adap->dev->i2c_adap,
  442. .i2c_addr = 0x61,
  443. .callback = dvico_bluebird_xc2028_callback,
  444. };
  445. static struct xc2028_ctrl ctl = {
  446. .fname = "xc3028-dvico-au-01.fw",
  447. .max_len = 64,
  448. .scode_table = XC3028_FE_ZARLINK456,
  449. };
  450. fe = dvb_attach(xc2028_attach, adap->fe, &cfg);
  451. if (fe == NULL || fe->ops.tuner_ops.set_config == NULL)
  452. return -EIO;
  453. fe->ops.tuner_ops.set_config(fe, &ctl);
  454. return 0;
  455. }
  456. static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
  457. {
  458. u8 b;
  459. if (usb_set_interface(adap->dev->udev, 0, 6) < 0)
  460. err("set interface failed");
  461. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1);
  462. if ((adap->fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config,
  463. &adap->dev->i2c_adap)) != NULL)
  464. return 0;
  465. return -EIO;
  466. }
  467. static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
  468. {
  469. if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
  470. err("set interface failed");
  471. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  472. if ((adap->fe = dvb_attach(lgdt330x_attach, &cxusb_lgdt3303_config,
  473. &adap->dev->i2c_adap)) != NULL)
  474. return 0;
  475. return -EIO;
  476. }
  477. static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap)
  478. {
  479. /* used in both lgz201 and th7579 */
  480. if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
  481. err("set interface failed");
  482. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  483. if ((adap->fe = dvb_attach(mt352_attach, &cxusb_mt352_config,
  484. &adap->dev->i2c_adap)) != NULL)
  485. return 0;
  486. return -EIO;
  487. }
  488. static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
  489. {
  490. if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
  491. err("set interface failed");
  492. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  493. if (((adap->fe = dvb_attach(mt352_attach, &cxusb_dee1601_config,
  494. &adap->dev->i2c_adap)) != NULL) ||
  495. ((adap->fe = dvb_attach(zl10353_attach,
  496. &cxusb_zl10353_dee1601_config,
  497. &adap->dev->i2c_adap)) != NULL))
  498. return 0;
  499. return -EIO;
  500. }
  501. static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
  502. {
  503. u8 ircode[4];
  504. int i;
  505. struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
  506. .buf = ircode, .len = 4 };
  507. if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
  508. err("set interface failed");
  509. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  510. /* reset the tuner and demodulator */
  511. cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
  512. cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
  513. cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
  514. if ((adap->fe = dvb_attach(zl10353_attach,
  515. &cxusb_zl10353_xc3028_config,
  516. &adap->dev->i2c_adap)) == NULL)
  517. return -EIO;
  518. /* try to determine if there is no IR decoder on the I2C bus */
  519. for (i = 0; adap->dev->props.rc_key_map != NULL && i < 5; i++) {
  520. msleep(20);
  521. if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1)
  522. goto no_IR;
  523. if (ircode[0] == 0 && ircode[1] == 0)
  524. continue;
  525. if (ircode[2] + ircode[3] != 0xff) {
  526. no_IR:
  527. adap->dev->props.rc_key_map = NULL;
  528. info("No IR receiver detected on this device.");
  529. break;
  530. }
  531. }
  532. return 0;
  533. }
  534. static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap)
  535. {
  536. if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
  537. err("set interface failed");
  538. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  539. /* reset the tuner and demodulator */
  540. cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
  541. cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
  542. cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
  543. if ((adap->fe = dvb_attach(zl10353_attach,
  544. &cxusb_zl10353_xc3028_config,
  545. &adap->dev->i2c_adap)) != NULL)
  546. return 0;
  547. if ((adap->fe = dvb_attach(mt352_attach,
  548. &cxusb_mt352_xc3028_config,
  549. &adap->dev->i2c_adap)) != NULL)
  550. return 0;
  551. return -EIO;
  552. }
  553. /*
  554. * DViCO has shipped two devices with the same USB ID, but only one of them
  555. * needs a firmware download. Check the device class details to see if they
  556. * have non-default values to decide whether the device is actually cold or
  557. * not, and forget a match if it turns out we selected the wrong device.
  558. */
  559. static int bluebird_fx2_identify_state(struct usb_device *udev,
  560. struct dvb_usb_device_properties *props,
  561. struct dvb_usb_device_description **desc,
  562. int *cold)
  563. {
  564. int wascold = *cold;
  565. *cold = udev->descriptor.bDeviceClass == 0xff &&
  566. udev->descriptor.bDeviceSubClass == 0xff &&
  567. udev->descriptor.bDeviceProtocol == 0xff;
  568. if (*cold && !wascold)
  569. *desc = NULL;
  570. return 0;
  571. }
  572. /*
  573. * DViCO bluebird firmware needs the "warm" product ID to be patched into the
  574. * firmware file before download.
  575. */
  576. static const int dvico_firmware_id_offsets[] = { 6638, 3204 };
  577. static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
  578. const struct firmware *fw)
  579. {
  580. int pos;
  581. for (pos = 0; pos < ARRAY_SIZE(dvico_firmware_id_offsets); pos++) {
  582. int idoff = dvico_firmware_id_offsets[pos];
  583. if (fw->size < idoff + 4)
  584. continue;
  585. if (fw->data[idoff] == (USB_VID_DVICO & 0xff) &&
  586. fw->data[idoff + 1] == USB_VID_DVICO >> 8) {
  587. fw->data[idoff + 2] =
  588. le16_to_cpu(udev->descriptor.idProduct) + 1;
  589. fw->data[idoff + 3] =
  590. le16_to_cpu(udev->descriptor.idProduct) >> 8;
  591. return usb_cypress_load_firmware(udev, fw, CYPRESS_FX2);
  592. }
  593. }
  594. return -EINVAL;
  595. }
  596. /* DVB USB Driver stuff */
  597. static struct dvb_usb_device_properties cxusb_medion_properties;
  598. static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
  599. static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;
  600. static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;
  601. static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;
  602. static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties;
  603. static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties;
  604. static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties;
  605. static int cxusb_probe(struct usb_interface *intf,
  606. const struct usb_device_id *id)
  607. {
  608. if (0 == dvb_usb_device_init(intf, &cxusb_medion_properties,
  609. THIS_MODULE, NULL, adapter_nr) ||
  610. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties,
  611. THIS_MODULE, NULL, adapter_nr) ||
  612. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties,
  613. THIS_MODULE, NULL, adapter_nr) ||
  614. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgz201_properties,
  615. THIS_MODULE, NULL, adapter_nr) ||
  616. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dtt7579_properties,
  617. THIS_MODULE, NULL, adapter_nr) ||
  618. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dualdig4_properties,
  619. THIS_MODULE, NULL, adapter_nr) ||
  620. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_nano2_properties,
  621. THIS_MODULE, NULL, adapter_nr) ||
  622. 0 == dvb_usb_device_init(intf,
  623. &cxusb_bluebird_nano2_needsfirmware_properties,
  624. THIS_MODULE, NULL, adapter_nr))
  625. return 0;
  626. return -EINVAL;
  627. }
  628. static struct usb_device_id cxusb_table [] = {
  629. { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
  630. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
  631. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
  632. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) },
  633. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) },
  634. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
  635. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
  636. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
  637. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
  638. { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) },
  639. { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) },
  640. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) },
  641. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) },
  642. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4) },
  643. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2) },
  644. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) },
  645. {} /* Terminating entry */
  646. };
  647. MODULE_DEVICE_TABLE (usb, cxusb_table);
  648. static struct dvb_usb_device_properties cxusb_medion_properties = {
  649. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  650. .usb_ctrl = CYPRESS_FX2,
  651. .size_of_priv = sizeof(struct cxusb_state),
  652. .num_adapters = 1,
  653. .adapter = {
  654. {
  655. .streaming_ctrl = cxusb_streaming_ctrl,
  656. .frontend_attach = cxusb_cx22702_frontend_attach,
  657. .tuner_attach = cxusb_fmd1216me_tuner_attach,
  658. /* parameter for the MPEG2-data transfer */
  659. .stream = {
  660. .type = USB_BULK,
  661. .count = 5,
  662. .endpoint = 0x02,
  663. .u = {
  664. .bulk = {
  665. .buffersize = 8192,
  666. }
  667. }
  668. },
  669. },
  670. },
  671. .power_ctrl = cxusb_power_ctrl,
  672. .i2c_algo = &cxusb_i2c_algo,
  673. .generic_bulk_ctrl_endpoint = 0x01,
  674. .num_device_descs = 1,
  675. .devices = {
  676. { "Medion MD95700 (MDUSBTV-HYBRID)",
  677. { NULL },
  678. { &cxusb_table[0], NULL },
  679. },
  680. }
  681. };
  682. static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
  683. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  684. .usb_ctrl = DEVICE_SPECIFIC,
  685. .firmware = "dvb-usb-bluebird-01.fw",
  686. .download_firmware = bluebird_patch_dvico_firmware_download,
  687. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  688. use usb alt setting 7 for EP2 transfer (atsc) */
  689. .size_of_priv = sizeof(struct cxusb_state),
  690. .num_adapters = 1,
  691. .adapter = {
  692. {
  693. .streaming_ctrl = cxusb_streaming_ctrl,
  694. .frontend_attach = cxusb_lgdt3303_frontend_attach,
  695. .tuner_attach = cxusb_lgh064f_tuner_attach,
  696. /* parameter for the MPEG2-data transfer */
  697. .stream = {
  698. .type = USB_BULK,
  699. .count = 5,
  700. .endpoint = 0x02,
  701. .u = {
  702. .bulk = {
  703. .buffersize = 8192,
  704. }
  705. }
  706. },
  707. },
  708. },
  709. .power_ctrl = cxusb_bluebird_power_ctrl,
  710. .i2c_algo = &cxusb_i2c_algo,
  711. .rc_interval = 100,
  712. .rc_key_map = dvico_portable_rc_keys,
  713. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  714. .rc_query = cxusb_rc_query,
  715. .generic_bulk_ctrl_endpoint = 0x01,
  716. .num_device_descs = 1,
  717. .devices = {
  718. { "DViCO FusionHDTV5 USB Gold",
  719. { &cxusb_table[1], NULL },
  720. { &cxusb_table[2], NULL },
  721. },
  722. }
  723. };
  724. static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
  725. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  726. .usb_ctrl = DEVICE_SPECIFIC,
  727. .firmware = "dvb-usb-bluebird-01.fw",
  728. .download_firmware = bluebird_patch_dvico_firmware_download,
  729. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  730. use usb alt setting 7 for EP2 transfer (atsc) */
  731. .size_of_priv = sizeof(struct cxusb_state),
  732. .num_adapters = 1,
  733. .adapter = {
  734. {
  735. .streaming_ctrl = cxusb_streaming_ctrl,
  736. .frontend_attach = cxusb_dee1601_frontend_attach,
  737. .tuner_attach = cxusb_dee1601_tuner_attach,
  738. /* parameter for the MPEG2-data transfer */
  739. .stream = {
  740. .type = USB_BULK,
  741. .count = 5,
  742. .endpoint = 0x04,
  743. .u = {
  744. .bulk = {
  745. .buffersize = 8192,
  746. }
  747. }
  748. },
  749. },
  750. },
  751. .power_ctrl = cxusb_bluebird_power_ctrl,
  752. .i2c_algo = &cxusb_i2c_algo,
  753. .rc_interval = 150,
  754. .rc_key_map = dvico_mce_rc_keys,
  755. .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
  756. .rc_query = cxusb_rc_query,
  757. .generic_bulk_ctrl_endpoint = 0x01,
  758. .num_device_descs = 3,
  759. .devices = {
  760. { "DViCO FusionHDTV DVB-T Dual USB",
  761. { &cxusb_table[3], NULL },
  762. { &cxusb_table[4], NULL },
  763. },
  764. { "DigitalNow DVB-T Dual USB",
  765. { &cxusb_table[9], NULL },
  766. { &cxusb_table[10], NULL },
  767. },
  768. { "DViCO FusionHDTV DVB-T Dual Digital 2",
  769. { &cxusb_table[11], NULL },
  770. { &cxusb_table[12], NULL },
  771. },
  772. }
  773. };
  774. static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
  775. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  776. .usb_ctrl = DEVICE_SPECIFIC,
  777. .firmware = "dvb-usb-bluebird-01.fw",
  778. .download_firmware = bluebird_patch_dvico_firmware_download,
  779. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  780. use usb alt setting 7 for EP2 transfer (atsc) */
  781. .size_of_priv = sizeof(struct cxusb_state),
  782. .num_adapters = 2,
  783. .adapter = {
  784. {
  785. .streaming_ctrl = cxusb_streaming_ctrl,
  786. .frontend_attach = cxusb_mt352_frontend_attach,
  787. .tuner_attach = cxusb_lgz201_tuner_attach,
  788. /* parameter for the MPEG2-data transfer */
  789. .stream = {
  790. .type = USB_BULK,
  791. .count = 5,
  792. .endpoint = 0x04,
  793. .u = {
  794. .bulk = {
  795. .buffersize = 8192,
  796. }
  797. }
  798. },
  799. },
  800. },
  801. .power_ctrl = cxusb_bluebird_power_ctrl,
  802. .i2c_algo = &cxusb_i2c_algo,
  803. .rc_interval = 100,
  804. .rc_key_map = dvico_portable_rc_keys,
  805. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  806. .rc_query = cxusb_rc_query,
  807. .generic_bulk_ctrl_endpoint = 0x01,
  808. .num_device_descs = 1,
  809. .devices = {
  810. { "DViCO FusionHDTV DVB-T USB (LGZ201)",
  811. { &cxusb_table[5], NULL },
  812. { &cxusb_table[6], NULL },
  813. },
  814. }
  815. };
  816. static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
  817. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  818. .usb_ctrl = DEVICE_SPECIFIC,
  819. .firmware = "dvb-usb-bluebird-01.fw",
  820. .download_firmware = bluebird_patch_dvico_firmware_download,
  821. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  822. use usb alt setting 7 for EP2 transfer (atsc) */
  823. .size_of_priv = sizeof(struct cxusb_state),
  824. .num_adapters = 1,
  825. .adapter = {
  826. {
  827. .streaming_ctrl = cxusb_streaming_ctrl,
  828. .frontend_attach = cxusb_mt352_frontend_attach,
  829. .tuner_attach = cxusb_dtt7579_tuner_attach,
  830. /* parameter for the MPEG2-data transfer */
  831. .stream = {
  832. .type = USB_BULK,
  833. .count = 5,
  834. .endpoint = 0x04,
  835. .u = {
  836. .bulk = {
  837. .buffersize = 8192,
  838. }
  839. }
  840. },
  841. },
  842. },
  843. .power_ctrl = cxusb_bluebird_power_ctrl,
  844. .i2c_algo = &cxusb_i2c_algo,
  845. .rc_interval = 100,
  846. .rc_key_map = dvico_portable_rc_keys,
  847. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  848. .rc_query = cxusb_rc_query,
  849. .generic_bulk_ctrl_endpoint = 0x01,
  850. .num_device_descs = 1,
  851. .devices = {
  852. { "DViCO FusionHDTV DVB-T USB (TH7579)",
  853. { &cxusb_table[7], NULL },
  854. { &cxusb_table[8], NULL },
  855. },
  856. }
  857. };
  858. static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
  859. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  860. .usb_ctrl = CYPRESS_FX2,
  861. .size_of_priv = sizeof(struct cxusb_state),
  862. .num_adapters = 1,
  863. .adapter = {
  864. {
  865. .streaming_ctrl = cxusb_streaming_ctrl,
  866. .frontend_attach = cxusb_dualdig4_frontend_attach,
  867. .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
  868. /* parameter for the MPEG2-data transfer */
  869. .stream = {
  870. .type = USB_BULK,
  871. .count = 5,
  872. .endpoint = 0x02,
  873. .u = {
  874. .bulk = {
  875. .buffersize = 8192,
  876. }
  877. }
  878. },
  879. },
  880. },
  881. .power_ctrl = cxusb_power_ctrl,
  882. .i2c_algo = &cxusb_i2c_algo,
  883. .generic_bulk_ctrl_endpoint = 0x01,
  884. .rc_interval = 100,
  885. .rc_key_map = dvico_mce_rc_keys,
  886. .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
  887. .rc_query = cxusb_bluebird2_rc_query,
  888. .num_device_descs = 1,
  889. .devices = {
  890. { "DViCO FusionHDTV DVB-T Dual Digital 4",
  891. { NULL },
  892. { &cxusb_table[13], NULL },
  893. },
  894. }
  895. };
  896. static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
  897. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  898. .usb_ctrl = CYPRESS_FX2,
  899. .identify_state = bluebird_fx2_identify_state,
  900. .size_of_priv = sizeof(struct cxusb_state),
  901. .num_adapters = 1,
  902. .adapter = {
  903. {
  904. .streaming_ctrl = cxusb_streaming_ctrl,
  905. .frontend_attach = cxusb_nano2_frontend_attach,
  906. .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
  907. /* parameter for the MPEG2-data transfer */
  908. .stream = {
  909. .type = USB_BULK,
  910. .count = 5,
  911. .endpoint = 0x02,
  912. .u = {
  913. .bulk = {
  914. .buffersize = 8192,
  915. }
  916. }
  917. },
  918. },
  919. },
  920. .power_ctrl = cxusb_nano2_power_ctrl,
  921. .i2c_algo = &cxusb_i2c_algo,
  922. .generic_bulk_ctrl_endpoint = 0x01,
  923. .rc_interval = 100,
  924. .rc_key_map = dvico_portable_rc_keys,
  925. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  926. .rc_query = cxusb_bluebird2_rc_query,
  927. .num_device_descs = 1,
  928. .devices = {
  929. { "DViCO FusionHDTV DVB-T NANO2",
  930. { NULL },
  931. { &cxusb_table[14], NULL },
  932. },
  933. }
  934. };
  935. static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties = {
  936. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  937. .usb_ctrl = DEVICE_SPECIFIC,
  938. .firmware = "dvb-usb-bluebird-02.fw",
  939. .download_firmware = bluebird_patch_dvico_firmware_download,
  940. .identify_state = bluebird_fx2_identify_state,
  941. .size_of_priv = sizeof(struct cxusb_state),
  942. .num_adapters = 1,
  943. .adapter = {
  944. {
  945. .streaming_ctrl = cxusb_streaming_ctrl,
  946. .frontend_attach = cxusb_nano2_frontend_attach,
  947. .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
  948. /* parameter for the MPEG2-data transfer */
  949. .stream = {
  950. .type = USB_BULK,
  951. .count = 5,
  952. .endpoint = 0x02,
  953. .u = {
  954. .bulk = {
  955. .buffersize = 8192,
  956. }
  957. }
  958. },
  959. },
  960. },
  961. .power_ctrl = cxusb_nano2_power_ctrl,
  962. .i2c_algo = &cxusb_i2c_algo,
  963. .generic_bulk_ctrl_endpoint = 0x01,
  964. .rc_interval = 100,
  965. .rc_key_map = dvico_portable_rc_keys,
  966. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  967. .rc_query = cxusb_rc_query,
  968. .num_device_descs = 1,
  969. .devices = {
  970. { "DViCO FusionHDTV DVB-T NANO2 w/o firmware",
  971. { &cxusb_table[14], NULL },
  972. { &cxusb_table[15], NULL },
  973. },
  974. }
  975. };
  976. static struct usb_driver cxusb_driver = {
  977. .name = "dvb_usb_cxusb",
  978. .probe = cxusb_probe,
  979. .disconnect = dvb_usb_device_exit,
  980. .id_table = cxusb_table,
  981. };
  982. /* module stuff */
  983. static int __init cxusb_module_init(void)
  984. {
  985. int result;
  986. if ((result = usb_register(&cxusb_driver))) {
  987. err("usb_register failed. Error number %d",result);
  988. return result;
  989. }
  990. return 0;
  991. }
  992. static void __exit cxusb_module_exit(void)
  993. {
  994. /* deregister this driver from the USB subsystem */
  995. usb_deregister(&cxusb_driver);
  996. }
  997. module_init (cxusb_module_init);
  998. module_exit (cxusb_module_exit);
  999. MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
  1000. MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
  1001. MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
  1002. MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
  1003. MODULE_VERSION("1.0-alpha");
  1004. MODULE_LICENSE("GPL");