cxusb.c 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357
  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_adapter *adap = ptr;
  493. struct dvb_usb_device *d = adap->dev;
  494. switch (command) {
  495. case XC2028_TUNER_RESET:
  496. deb_info("%s: XC2028_TUNER_RESET %d\n", __func__, arg);
  497. cxusb_bluebird_gpio_pulse(d, 0x01, 1);
  498. break;
  499. case XC2028_RESET_CLK:
  500. deb_info("%s: XC2028_RESET_CLK %d\n", __func__, arg);
  501. break;
  502. default:
  503. deb_info("%s: unknown command %d, arg %d\n", __func__,
  504. command, arg);
  505. return -EINVAL;
  506. }
  507. return 0;
  508. }
  509. static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter *adap)
  510. {
  511. struct dvb_frontend *fe;
  512. struct xc2028_config cfg = {
  513. .i2c_adap = &adap->dev->i2c_adap,
  514. .i2c_addr = 0x61,
  515. .callback = dvico_bluebird_xc2028_callback,
  516. };
  517. static struct xc2028_ctrl ctl = {
  518. .fname = "xc3028-v27.fw",
  519. .max_len = 64,
  520. .demod = XC3028_FE_ZARLINK456,
  521. };
  522. fe = dvb_attach(xc2028_attach, adap->fe, &cfg);
  523. if (fe == NULL || fe->ops.tuner_ops.set_config == NULL)
  524. return -EIO;
  525. fe->ops.tuner_ops.set_config(fe, &ctl);
  526. return 0;
  527. }
  528. static int cxusb_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap)
  529. {
  530. dvb_attach(mxl5005s_attach, adap->fe,
  531. &adap->dev->i2c_adap, &aver_a868r_tuner);
  532. return 0;
  533. }
  534. static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
  535. {
  536. u8 b;
  537. if (usb_set_interface(adap->dev->udev, 0, 6) < 0)
  538. err("set interface failed");
  539. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1);
  540. if ((adap->fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config,
  541. &adap->dev->i2c_adap)) != NULL)
  542. return 0;
  543. return -EIO;
  544. }
  545. static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
  546. {
  547. if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
  548. err("set interface failed");
  549. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  550. if ((adap->fe = dvb_attach(lgdt330x_attach, &cxusb_lgdt3303_config,
  551. &adap->dev->i2c_adap)) != NULL)
  552. return 0;
  553. return -EIO;
  554. }
  555. static int cxusb_aver_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
  556. {
  557. adap->fe = dvb_attach(lgdt330x_attach, &cxusb_aver_lgdt3303_config,
  558. &adap->dev->i2c_adap);
  559. if (adap->fe != NULL)
  560. return 0;
  561. return -EIO;
  562. }
  563. static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap)
  564. {
  565. /* used in both lgz201 and th7579 */
  566. if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
  567. err("set interface failed");
  568. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  569. if ((adap->fe = dvb_attach(mt352_attach, &cxusb_mt352_config,
  570. &adap->dev->i2c_adap)) != NULL)
  571. return 0;
  572. return -EIO;
  573. }
  574. static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
  575. {
  576. if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
  577. err("set interface failed");
  578. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  579. if (((adap->fe = dvb_attach(mt352_attach, &cxusb_dee1601_config,
  580. &adap->dev->i2c_adap)) != NULL) ||
  581. ((adap->fe = dvb_attach(zl10353_attach,
  582. &cxusb_zl10353_dee1601_config,
  583. &adap->dev->i2c_adap)) != NULL))
  584. return 0;
  585. return -EIO;
  586. }
  587. static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
  588. {
  589. u8 ircode[4];
  590. int i;
  591. struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
  592. .buf = ircode, .len = 4 };
  593. if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
  594. err("set interface failed");
  595. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  596. /* reset the tuner and demodulator */
  597. cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
  598. cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
  599. cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
  600. if ((adap->fe = dvb_attach(zl10353_attach,
  601. &cxusb_zl10353_xc3028_config,
  602. &adap->dev->i2c_adap)) == NULL)
  603. return -EIO;
  604. /* try to determine if there is no IR decoder on the I2C bus */
  605. for (i = 0; adap->dev->props.rc_key_map != NULL && i < 5; i++) {
  606. msleep(20);
  607. if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1)
  608. goto no_IR;
  609. if (ircode[0] == 0 && ircode[1] == 0)
  610. continue;
  611. if (ircode[2] + ircode[3] != 0xff) {
  612. no_IR:
  613. adap->dev->props.rc_key_map = NULL;
  614. info("No IR receiver detected on this device.");
  615. break;
  616. }
  617. }
  618. return 0;
  619. }
  620. static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap)
  621. {
  622. if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
  623. err("set interface failed");
  624. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  625. /* reset the tuner and demodulator */
  626. cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
  627. cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
  628. cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
  629. if ((adap->fe = dvb_attach(zl10353_attach,
  630. &cxusb_zl10353_xc3028_config,
  631. &adap->dev->i2c_adap)) != NULL)
  632. return 0;
  633. if ((adap->fe = dvb_attach(mt352_attach,
  634. &cxusb_mt352_xc3028_config,
  635. &adap->dev->i2c_adap)) != NULL)
  636. return 0;
  637. return -EIO;
  638. }
  639. /*
  640. * DViCO has shipped two devices with the same USB ID, but only one of them
  641. * needs a firmware download. Check the device class details to see if they
  642. * have non-default values to decide whether the device is actually cold or
  643. * not, and forget a match if it turns out we selected the wrong device.
  644. */
  645. static int bluebird_fx2_identify_state(struct usb_device *udev,
  646. struct dvb_usb_device_properties *props,
  647. struct dvb_usb_device_description **desc,
  648. int *cold)
  649. {
  650. int wascold = *cold;
  651. *cold = udev->descriptor.bDeviceClass == 0xff &&
  652. udev->descriptor.bDeviceSubClass == 0xff &&
  653. udev->descriptor.bDeviceProtocol == 0xff;
  654. if (*cold && !wascold)
  655. *desc = NULL;
  656. return 0;
  657. }
  658. /*
  659. * DViCO bluebird firmware needs the "warm" product ID to be patched into the
  660. * firmware file before download.
  661. */
  662. static const int dvico_firmware_id_offsets[] = { 6638, 3204 };
  663. static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
  664. const struct firmware *fw)
  665. {
  666. int pos;
  667. for (pos = 0; pos < ARRAY_SIZE(dvico_firmware_id_offsets); pos++) {
  668. int idoff = dvico_firmware_id_offsets[pos];
  669. if (fw->size < idoff + 4)
  670. continue;
  671. if (fw->data[idoff] == (USB_VID_DVICO & 0xff) &&
  672. fw->data[idoff + 1] == USB_VID_DVICO >> 8) {
  673. struct firmware new_fw;
  674. u8 *new_fw_data = vmalloc(fw->size);
  675. int ret;
  676. if (!new_fw_data)
  677. return -ENOMEM;
  678. memcpy(new_fw_data, fw->data, fw->size);
  679. new_fw.size = fw->size;
  680. new_fw.data = new_fw_data;
  681. new_fw_data[idoff + 2] =
  682. le16_to_cpu(udev->descriptor.idProduct) + 1;
  683. new_fw_data[idoff + 3] =
  684. le16_to_cpu(udev->descriptor.idProduct) >> 8;
  685. ret = usb_cypress_load_firmware(udev, &new_fw,
  686. CYPRESS_FX2);
  687. vfree(new_fw_data);
  688. return ret;
  689. }
  690. }
  691. return -EINVAL;
  692. }
  693. /* DVB USB Driver stuff */
  694. static struct dvb_usb_device_properties cxusb_medion_properties;
  695. static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
  696. static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;
  697. static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;
  698. static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;
  699. static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties;
  700. static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties;
  701. static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties;
  702. static struct dvb_usb_device_properties cxusb_aver_a868r_properties;
  703. static int cxusb_probe(struct usb_interface *intf,
  704. const struct usb_device_id *id)
  705. {
  706. if (0 == dvb_usb_device_init(intf, &cxusb_medion_properties,
  707. THIS_MODULE, NULL, adapter_nr) ||
  708. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties,
  709. THIS_MODULE, NULL, adapter_nr) ||
  710. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties,
  711. THIS_MODULE, NULL, adapter_nr) ||
  712. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgz201_properties,
  713. THIS_MODULE, NULL, adapter_nr) ||
  714. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dtt7579_properties,
  715. THIS_MODULE, NULL, adapter_nr) ||
  716. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dualdig4_properties,
  717. THIS_MODULE, NULL, adapter_nr) ||
  718. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_nano2_properties,
  719. THIS_MODULE, NULL, adapter_nr) ||
  720. 0 == dvb_usb_device_init(intf,
  721. &cxusb_bluebird_nano2_needsfirmware_properties,
  722. THIS_MODULE, NULL, adapter_nr) ||
  723. 0 == dvb_usb_device_init(intf, &cxusb_aver_a868r_properties,
  724. THIS_MODULE, NULL, adapter_nr) ||
  725. 0)
  726. return 0;
  727. return -EINVAL;
  728. }
  729. static struct usb_device_id cxusb_table [] = {
  730. { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
  731. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
  732. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
  733. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) },
  734. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) },
  735. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
  736. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
  737. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
  738. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
  739. { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) },
  740. { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) },
  741. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) },
  742. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) },
  743. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4) },
  744. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2) },
  745. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) },
  746. { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_A868R) },
  747. {} /* Terminating entry */
  748. };
  749. MODULE_DEVICE_TABLE (usb, cxusb_table);
  750. static struct dvb_usb_device_properties cxusb_medion_properties = {
  751. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  752. .usb_ctrl = CYPRESS_FX2,
  753. .size_of_priv = sizeof(struct cxusb_state),
  754. .num_adapters = 1,
  755. .adapter = {
  756. {
  757. .streaming_ctrl = cxusb_streaming_ctrl,
  758. .frontend_attach = cxusb_cx22702_frontend_attach,
  759. .tuner_attach = cxusb_fmd1216me_tuner_attach,
  760. /* parameter for the MPEG2-data transfer */
  761. .stream = {
  762. .type = USB_BULK,
  763. .count = 5,
  764. .endpoint = 0x02,
  765. .u = {
  766. .bulk = {
  767. .buffersize = 8192,
  768. }
  769. }
  770. },
  771. },
  772. },
  773. .power_ctrl = cxusb_power_ctrl,
  774. .i2c_algo = &cxusb_i2c_algo,
  775. .generic_bulk_ctrl_endpoint = 0x01,
  776. .num_device_descs = 1,
  777. .devices = {
  778. { "Medion MD95700 (MDUSBTV-HYBRID)",
  779. { NULL },
  780. { &cxusb_table[0], NULL },
  781. },
  782. }
  783. };
  784. static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
  785. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  786. .usb_ctrl = DEVICE_SPECIFIC,
  787. .firmware = "dvb-usb-bluebird-01.fw",
  788. .download_firmware = bluebird_patch_dvico_firmware_download,
  789. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  790. use usb alt setting 7 for EP2 transfer (atsc) */
  791. .size_of_priv = sizeof(struct cxusb_state),
  792. .num_adapters = 1,
  793. .adapter = {
  794. {
  795. .streaming_ctrl = cxusb_streaming_ctrl,
  796. .frontend_attach = cxusb_lgdt3303_frontend_attach,
  797. .tuner_attach = cxusb_lgh064f_tuner_attach,
  798. /* parameter for the MPEG2-data transfer */
  799. .stream = {
  800. .type = USB_BULK,
  801. .count = 5,
  802. .endpoint = 0x02,
  803. .u = {
  804. .bulk = {
  805. .buffersize = 8192,
  806. }
  807. }
  808. },
  809. },
  810. },
  811. .power_ctrl = cxusb_bluebird_power_ctrl,
  812. .i2c_algo = &cxusb_i2c_algo,
  813. .rc_interval = 100,
  814. .rc_key_map = dvico_portable_rc_keys,
  815. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  816. .rc_query = cxusb_rc_query,
  817. .generic_bulk_ctrl_endpoint = 0x01,
  818. .num_device_descs = 1,
  819. .devices = {
  820. { "DViCO FusionHDTV5 USB Gold",
  821. { &cxusb_table[1], NULL },
  822. { &cxusb_table[2], NULL },
  823. },
  824. }
  825. };
  826. static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
  827. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  828. .usb_ctrl = DEVICE_SPECIFIC,
  829. .firmware = "dvb-usb-bluebird-01.fw",
  830. .download_firmware = bluebird_patch_dvico_firmware_download,
  831. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  832. use usb alt setting 7 for EP2 transfer (atsc) */
  833. .size_of_priv = sizeof(struct cxusb_state),
  834. .num_adapters = 1,
  835. .adapter = {
  836. {
  837. .streaming_ctrl = cxusb_streaming_ctrl,
  838. .frontend_attach = cxusb_dee1601_frontend_attach,
  839. .tuner_attach = cxusb_dee1601_tuner_attach,
  840. /* parameter for the MPEG2-data transfer */
  841. .stream = {
  842. .type = USB_BULK,
  843. .count = 5,
  844. .endpoint = 0x04,
  845. .u = {
  846. .bulk = {
  847. .buffersize = 8192,
  848. }
  849. }
  850. },
  851. },
  852. },
  853. .power_ctrl = cxusb_bluebird_power_ctrl,
  854. .i2c_algo = &cxusb_i2c_algo,
  855. .rc_interval = 150,
  856. .rc_key_map = dvico_mce_rc_keys,
  857. .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
  858. .rc_query = cxusb_rc_query,
  859. .generic_bulk_ctrl_endpoint = 0x01,
  860. .num_device_descs = 3,
  861. .devices = {
  862. { "DViCO FusionHDTV DVB-T Dual USB",
  863. { &cxusb_table[3], NULL },
  864. { &cxusb_table[4], NULL },
  865. },
  866. { "DigitalNow DVB-T Dual USB",
  867. { &cxusb_table[9], NULL },
  868. { &cxusb_table[10], NULL },
  869. },
  870. { "DViCO FusionHDTV DVB-T Dual Digital 2",
  871. { &cxusb_table[11], NULL },
  872. { &cxusb_table[12], NULL },
  873. },
  874. }
  875. };
  876. static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
  877. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  878. .usb_ctrl = DEVICE_SPECIFIC,
  879. .firmware = "dvb-usb-bluebird-01.fw",
  880. .download_firmware = bluebird_patch_dvico_firmware_download,
  881. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  882. use usb alt setting 7 for EP2 transfer (atsc) */
  883. .size_of_priv = sizeof(struct cxusb_state),
  884. .num_adapters = 2,
  885. .adapter = {
  886. {
  887. .streaming_ctrl = cxusb_streaming_ctrl,
  888. .frontend_attach = cxusb_mt352_frontend_attach,
  889. .tuner_attach = cxusb_lgz201_tuner_attach,
  890. /* parameter for the MPEG2-data transfer */
  891. .stream = {
  892. .type = USB_BULK,
  893. .count = 5,
  894. .endpoint = 0x04,
  895. .u = {
  896. .bulk = {
  897. .buffersize = 8192,
  898. }
  899. }
  900. },
  901. },
  902. },
  903. .power_ctrl = cxusb_bluebird_power_ctrl,
  904. .i2c_algo = &cxusb_i2c_algo,
  905. .rc_interval = 100,
  906. .rc_key_map = dvico_portable_rc_keys,
  907. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  908. .rc_query = cxusb_rc_query,
  909. .generic_bulk_ctrl_endpoint = 0x01,
  910. .num_device_descs = 1,
  911. .devices = {
  912. { "DViCO FusionHDTV DVB-T USB (LGZ201)",
  913. { &cxusb_table[5], NULL },
  914. { &cxusb_table[6], NULL },
  915. },
  916. }
  917. };
  918. static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
  919. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  920. .usb_ctrl = DEVICE_SPECIFIC,
  921. .firmware = "dvb-usb-bluebird-01.fw",
  922. .download_firmware = bluebird_patch_dvico_firmware_download,
  923. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  924. use usb alt setting 7 for EP2 transfer (atsc) */
  925. .size_of_priv = sizeof(struct cxusb_state),
  926. .num_adapters = 1,
  927. .adapter = {
  928. {
  929. .streaming_ctrl = cxusb_streaming_ctrl,
  930. .frontend_attach = cxusb_mt352_frontend_attach,
  931. .tuner_attach = cxusb_dtt7579_tuner_attach,
  932. /* parameter for the MPEG2-data transfer */
  933. .stream = {
  934. .type = USB_BULK,
  935. .count = 5,
  936. .endpoint = 0x04,
  937. .u = {
  938. .bulk = {
  939. .buffersize = 8192,
  940. }
  941. }
  942. },
  943. },
  944. },
  945. .power_ctrl = cxusb_bluebird_power_ctrl,
  946. .i2c_algo = &cxusb_i2c_algo,
  947. .rc_interval = 100,
  948. .rc_key_map = dvico_portable_rc_keys,
  949. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  950. .rc_query = cxusb_rc_query,
  951. .generic_bulk_ctrl_endpoint = 0x01,
  952. .num_device_descs = 1,
  953. .devices = {
  954. { "DViCO FusionHDTV DVB-T USB (TH7579)",
  955. { &cxusb_table[7], NULL },
  956. { &cxusb_table[8], NULL },
  957. },
  958. }
  959. };
  960. static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
  961. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  962. .usb_ctrl = CYPRESS_FX2,
  963. .size_of_priv = sizeof(struct cxusb_state),
  964. .num_adapters = 1,
  965. .adapter = {
  966. {
  967. .streaming_ctrl = cxusb_streaming_ctrl,
  968. .frontend_attach = cxusb_dualdig4_frontend_attach,
  969. .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
  970. /* parameter for the MPEG2-data transfer */
  971. .stream = {
  972. .type = USB_BULK,
  973. .count = 5,
  974. .endpoint = 0x02,
  975. .u = {
  976. .bulk = {
  977. .buffersize = 8192,
  978. }
  979. }
  980. },
  981. },
  982. },
  983. .power_ctrl = cxusb_power_ctrl,
  984. .i2c_algo = &cxusb_i2c_algo,
  985. .generic_bulk_ctrl_endpoint = 0x01,
  986. .rc_interval = 100,
  987. .rc_key_map = dvico_mce_rc_keys,
  988. .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
  989. .rc_query = cxusb_bluebird2_rc_query,
  990. .num_device_descs = 1,
  991. .devices = {
  992. { "DViCO FusionHDTV DVB-T Dual Digital 4",
  993. { NULL },
  994. { &cxusb_table[13], NULL },
  995. },
  996. }
  997. };
  998. static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
  999. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1000. .usb_ctrl = CYPRESS_FX2,
  1001. .identify_state = bluebird_fx2_identify_state,
  1002. .size_of_priv = sizeof(struct cxusb_state),
  1003. .num_adapters = 1,
  1004. .adapter = {
  1005. {
  1006. .streaming_ctrl = cxusb_streaming_ctrl,
  1007. .frontend_attach = cxusb_nano2_frontend_attach,
  1008. .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
  1009. /* parameter for the MPEG2-data transfer */
  1010. .stream = {
  1011. .type = USB_BULK,
  1012. .count = 5,
  1013. .endpoint = 0x02,
  1014. .u = {
  1015. .bulk = {
  1016. .buffersize = 8192,
  1017. }
  1018. }
  1019. },
  1020. },
  1021. },
  1022. .power_ctrl = cxusb_nano2_power_ctrl,
  1023. .i2c_algo = &cxusb_i2c_algo,
  1024. .generic_bulk_ctrl_endpoint = 0x01,
  1025. .rc_interval = 100,
  1026. .rc_key_map = dvico_portable_rc_keys,
  1027. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  1028. .rc_query = cxusb_bluebird2_rc_query,
  1029. .num_device_descs = 1,
  1030. .devices = {
  1031. { "DViCO FusionHDTV DVB-T NANO2",
  1032. { NULL },
  1033. { &cxusb_table[14], NULL },
  1034. },
  1035. }
  1036. };
  1037. static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties = {
  1038. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1039. .usb_ctrl = DEVICE_SPECIFIC,
  1040. .firmware = "dvb-usb-bluebird-02.fw",
  1041. .download_firmware = bluebird_patch_dvico_firmware_download,
  1042. .identify_state = bluebird_fx2_identify_state,
  1043. .size_of_priv = sizeof(struct cxusb_state),
  1044. .num_adapters = 1,
  1045. .adapter = {
  1046. {
  1047. .streaming_ctrl = cxusb_streaming_ctrl,
  1048. .frontend_attach = cxusb_nano2_frontend_attach,
  1049. .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
  1050. /* parameter for the MPEG2-data transfer */
  1051. .stream = {
  1052. .type = USB_BULK,
  1053. .count = 5,
  1054. .endpoint = 0x02,
  1055. .u = {
  1056. .bulk = {
  1057. .buffersize = 8192,
  1058. }
  1059. }
  1060. },
  1061. },
  1062. },
  1063. .power_ctrl = cxusb_nano2_power_ctrl,
  1064. .i2c_algo = &cxusb_i2c_algo,
  1065. .generic_bulk_ctrl_endpoint = 0x01,
  1066. .rc_interval = 100,
  1067. .rc_key_map = dvico_portable_rc_keys,
  1068. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  1069. .rc_query = cxusb_rc_query,
  1070. .num_device_descs = 1,
  1071. .devices = {
  1072. { "DViCO FusionHDTV DVB-T NANO2 w/o firmware",
  1073. { &cxusb_table[14], NULL },
  1074. { &cxusb_table[15], NULL },
  1075. },
  1076. }
  1077. };
  1078. static struct dvb_usb_device_properties cxusb_aver_a868r_properties = {
  1079. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1080. .usb_ctrl = CYPRESS_FX2,
  1081. .size_of_priv = sizeof(struct cxusb_state),
  1082. .num_adapters = 1,
  1083. .adapter = {
  1084. {
  1085. .streaming_ctrl = cxusb_aver_streaming_ctrl,
  1086. .frontend_attach = cxusb_aver_lgdt3303_frontend_attach,
  1087. .tuner_attach = cxusb_mxl5003s_tuner_attach,
  1088. /* parameter for the MPEG2-data transfer */
  1089. .stream = {
  1090. .type = USB_BULK,
  1091. .count = 5,
  1092. .endpoint = 0x04,
  1093. .u = {
  1094. .bulk = {
  1095. .buffersize = 8192,
  1096. }
  1097. }
  1098. },
  1099. },
  1100. },
  1101. .power_ctrl = cxusb_aver_power_ctrl,
  1102. .i2c_algo = &cxusb_i2c_algo,
  1103. .generic_bulk_ctrl_endpoint = 0x01,
  1104. .num_device_descs = 1,
  1105. .devices = {
  1106. { "AVerMedia AVerTVHD Volar (A868R)",
  1107. { NULL },
  1108. { &cxusb_table[16], NULL },
  1109. },
  1110. }
  1111. };
  1112. static struct usb_driver cxusb_driver = {
  1113. .name = "dvb_usb_cxusb",
  1114. .probe = cxusb_probe,
  1115. .disconnect = dvb_usb_device_exit,
  1116. .id_table = cxusb_table,
  1117. };
  1118. /* module stuff */
  1119. static int __init cxusb_module_init(void)
  1120. {
  1121. int result;
  1122. if ((result = usb_register(&cxusb_driver))) {
  1123. err("usb_register failed. Error number %d",result);
  1124. return result;
  1125. }
  1126. return 0;
  1127. }
  1128. static void __exit cxusb_module_exit(void)
  1129. {
  1130. /* deregister this driver from the USB subsystem */
  1131. usb_deregister(&cxusb_driver);
  1132. }
  1133. module_init (cxusb_module_init);
  1134. module_exit (cxusb_module_exit);
  1135. MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
  1136. MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
  1137. MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
  1138. MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
  1139. MODULE_VERSION("1.0-alpha");
  1140. MODULE_LICENSE("GPL");