cxusb.c 35 KB

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