cxusb.c 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855
  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. #include "dib7000p.h"
  38. #include "dib0070.h"
  39. #include "lgs8gl5.h"
  40. /* debug */
  41. static int dvb_usb_cxusb_debug;
  42. module_param_named(debug, dvb_usb_cxusb_debug, int, 0644);
  43. MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
  44. DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
  45. #define deb_info(args...) dprintk(dvb_usb_cxusb_debug, 0x03, args)
  46. #define deb_i2c(args...) dprintk(dvb_usb_cxusb_debug, 0x02, args)
  47. static int cxusb_ctrl_msg(struct dvb_usb_device *d,
  48. u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen)
  49. {
  50. int wo = (rbuf == NULL || rlen == 0); /* write-only */
  51. u8 sndbuf[1+wlen];
  52. memset(sndbuf, 0, 1+wlen);
  53. sndbuf[0] = cmd;
  54. memcpy(&sndbuf[1], wbuf, wlen);
  55. if (wo)
  56. return dvb_usb_generic_write(d, sndbuf, 1+wlen);
  57. else
  58. return dvb_usb_generic_rw(d, sndbuf, 1+wlen, rbuf, rlen, 0);
  59. }
  60. /* GPIO */
  61. static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)
  62. {
  63. struct cxusb_state *st = d->priv;
  64. u8 o[2], i;
  65. if (st->gpio_write_state[GPIO_TUNER] == onoff)
  66. return;
  67. o[0] = GPIO_TUNER;
  68. o[1] = onoff;
  69. cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
  70. if (i != 0x01)
  71. deb_info("gpio_write failed.\n");
  72. st->gpio_write_state[GPIO_TUNER] = onoff;
  73. }
  74. static int cxusb_bluebird_gpio_rw(struct dvb_usb_device *d, u8 changemask,
  75. u8 newval)
  76. {
  77. u8 o[2], gpio_state;
  78. int rc;
  79. o[0] = 0xff & ~changemask; /* mask of bits to keep */
  80. o[1] = newval & changemask; /* new values for bits */
  81. rc = cxusb_ctrl_msg(d, CMD_BLUEBIRD_GPIO_RW, o, 2, &gpio_state, 1);
  82. if (rc < 0 || (gpio_state & changemask) != (newval & changemask))
  83. deb_info("bluebird_gpio_write failed.\n");
  84. return rc < 0 ? rc : gpio_state;
  85. }
  86. static void cxusb_bluebird_gpio_pulse(struct dvb_usb_device *d, u8 pin, int low)
  87. {
  88. cxusb_bluebird_gpio_rw(d, pin, low ? 0 : pin);
  89. msleep(5);
  90. cxusb_bluebird_gpio_rw(d, pin, low ? pin : 0);
  91. }
  92. static void cxusb_nano2_led(struct dvb_usb_device *d, int onoff)
  93. {
  94. cxusb_bluebird_gpio_rw(d, 0x40, onoff ? 0 : 0x40);
  95. }
  96. static int cxusb_d680_dmb_gpio_tuner(struct dvb_usb_device *d,
  97. u8 addr, int onoff)
  98. {
  99. u8 o[2] = {addr, onoff};
  100. u8 i;
  101. int rc;
  102. rc = cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
  103. if (rc < 0)
  104. return rc;
  105. if (i == 0x01)
  106. return 0;
  107. else {
  108. deb_info("gpio_write failed.\n");
  109. return -EIO;
  110. }
  111. }
  112. /* I2C */
  113. static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
  114. int num)
  115. {
  116. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  117. int i;
  118. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  119. return -EAGAIN;
  120. for (i = 0; i < num; i++) {
  121. if (d->udev->descriptor.idVendor == USB_VID_MEDION)
  122. switch (msg[i].addr) {
  123. case 0x63:
  124. cxusb_gpio_tuner(d, 0);
  125. break;
  126. default:
  127. cxusb_gpio_tuner(d, 1);
  128. break;
  129. }
  130. if (msg[i].flags & I2C_M_RD) {
  131. /* read only */
  132. u8 obuf[3], ibuf[1+msg[i].len];
  133. obuf[0] = 0;
  134. obuf[1] = msg[i].len;
  135. obuf[2] = msg[i].addr;
  136. if (cxusb_ctrl_msg(d, CMD_I2C_READ,
  137. obuf, 3,
  138. ibuf, 1+msg[i].len) < 0) {
  139. warn("i2c read failed");
  140. break;
  141. }
  142. memcpy(msg[i].buf, &ibuf[1], msg[i].len);
  143. } else if (i+1 < num && (msg[i+1].flags & I2C_M_RD) &&
  144. msg[i].addr == msg[i+1].addr) {
  145. /* write to then read from same address */
  146. u8 obuf[3+msg[i].len], ibuf[1+msg[i+1].len];
  147. obuf[0] = msg[i].len;
  148. obuf[1] = msg[i+1].len;
  149. obuf[2] = msg[i].addr;
  150. memcpy(&obuf[3], msg[i].buf, msg[i].len);
  151. if (cxusb_ctrl_msg(d, CMD_I2C_READ,
  152. obuf, 3+msg[i].len,
  153. ibuf, 1+msg[i+1].len) < 0)
  154. break;
  155. if (ibuf[0] != 0x08)
  156. deb_i2c("i2c read may have failed\n");
  157. memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len);
  158. i++;
  159. } else {
  160. /* write only */
  161. u8 obuf[2+msg[i].len], ibuf;
  162. obuf[0] = msg[i].addr;
  163. obuf[1] = msg[i].len;
  164. memcpy(&obuf[2], msg[i].buf, msg[i].len);
  165. if (cxusb_ctrl_msg(d, CMD_I2C_WRITE, obuf,
  166. 2+msg[i].len, &ibuf,1) < 0)
  167. break;
  168. if (ibuf != 0x08)
  169. deb_i2c("i2c write may have failed\n");
  170. }
  171. }
  172. mutex_unlock(&d->i2c_mutex);
  173. return i == num ? num : -EREMOTEIO;
  174. }
  175. static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
  176. {
  177. return I2C_FUNC_I2C;
  178. }
  179. static struct i2c_algorithm cxusb_i2c_algo = {
  180. .master_xfer = cxusb_i2c_xfer,
  181. .functionality = cxusb_i2c_func,
  182. };
  183. static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff)
  184. {
  185. u8 b = 0;
  186. if (onoff)
  187. return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
  188. else
  189. return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0);
  190. }
  191. static int cxusb_aver_power_ctrl(struct dvb_usb_device *d, int onoff)
  192. {
  193. int ret;
  194. if (!onoff)
  195. return cxusb_ctrl_msg(d, CMD_POWER_OFF, NULL, 0, NULL, 0);
  196. if (d->state == DVB_USB_STATE_INIT &&
  197. usb_set_interface(d->udev, 0, 0) < 0)
  198. err("set interface failed");
  199. do {} while (!(ret = cxusb_ctrl_msg(d, CMD_POWER_ON, NULL, 0, NULL, 0)) &&
  200. !(ret = cxusb_ctrl_msg(d, 0x15, NULL, 0, NULL, 0)) &&
  201. !(ret = cxusb_ctrl_msg(d, 0x17, NULL, 0, NULL, 0)) && 0);
  202. if (!ret) {
  203. /* FIXME: We don't know why, but we need to configure the
  204. * lgdt3303 with the register settings below on resume */
  205. int i;
  206. u8 buf, bufs[] = {
  207. 0x0e, 0x2, 0x00, 0x7f,
  208. 0x0e, 0x2, 0x02, 0xfe,
  209. 0x0e, 0x2, 0x02, 0x01,
  210. 0x0e, 0x2, 0x00, 0x03,
  211. 0x0e, 0x2, 0x0d, 0x40,
  212. 0x0e, 0x2, 0x0e, 0x87,
  213. 0x0e, 0x2, 0x0f, 0x8e,
  214. 0x0e, 0x2, 0x10, 0x01,
  215. 0x0e, 0x2, 0x14, 0xd7,
  216. 0x0e, 0x2, 0x47, 0x88,
  217. };
  218. msleep(20);
  219. for (i = 0; i < sizeof(bufs)/sizeof(u8); i += 4/sizeof(u8)) {
  220. ret = cxusb_ctrl_msg(d, CMD_I2C_WRITE,
  221. bufs+i, 4, &buf, 1);
  222. if (ret)
  223. break;
  224. if (buf != 0x8)
  225. return -EREMOTEIO;
  226. }
  227. }
  228. return ret;
  229. }
  230. static int cxusb_bluebird_power_ctrl(struct dvb_usb_device *d, int onoff)
  231. {
  232. u8 b = 0;
  233. if (onoff)
  234. return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
  235. else
  236. return 0;
  237. }
  238. static int cxusb_nano2_power_ctrl(struct dvb_usb_device *d, int onoff)
  239. {
  240. int rc = 0;
  241. rc = cxusb_power_ctrl(d, onoff);
  242. if (!onoff)
  243. cxusb_nano2_led(d, 0);
  244. return rc;
  245. }
  246. static int cxusb_d680_dmb_power_ctrl(struct dvb_usb_device *d, int onoff)
  247. {
  248. int ret;
  249. u8 b;
  250. ret = cxusb_power_ctrl(d, onoff);
  251. if (!onoff)
  252. return ret;
  253. msleep(128);
  254. cxusb_ctrl_msg(d, CMD_DIGITAL, NULL, 0, &b, 1);
  255. msleep(100);
  256. return ret;
  257. }
  258. static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
  259. {
  260. u8 buf[2] = { 0x03, 0x00 };
  261. if (onoff)
  262. cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON, buf, 2, NULL, 0);
  263. else
  264. cxusb_ctrl_msg(adap->dev, CMD_STREAMING_OFF, NULL, 0, NULL, 0);
  265. return 0;
  266. }
  267. static int cxusb_aver_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
  268. {
  269. if (onoff)
  270. cxusb_ctrl_msg(adap->dev, CMD_AVER_STREAM_ON, NULL, 0, NULL, 0);
  271. else
  272. cxusb_ctrl_msg(adap->dev, CMD_AVER_STREAM_OFF,
  273. NULL, 0, NULL, 0);
  274. return 0;
  275. }
  276. static void cxusb_d680_dmb_drain_message(struct dvb_usb_device *d)
  277. {
  278. int ep = d->props.generic_bulk_ctrl_endpoint;
  279. const int timeout = 100;
  280. const int junk_len = 32;
  281. u8 *junk;
  282. int rd_count;
  283. /* Discard remaining data in video pipe */
  284. junk = kmalloc(junk_len, GFP_KERNEL);
  285. if (!junk)
  286. return;
  287. while (1) {
  288. if (usb_bulk_msg(d->udev,
  289. usb_rcvbulkpipe(d->udev, ep),
  290. junk, junk_len, &rd_count, timeout) < 0)
  291. break;
  292. if (!rd_count)
  293. break;
  294. }
  295. kfree(junk);
  296. }
  297. static void cxusb_d680_dmb_drain_video(struct dvb_usb_device *d)
  298. {
  299. struct usb_data_stream_properties *p = &d->props.adapter[0].stream;
  300. const int timeout = 100;
  301. const int junk_len = p->u.bulk.buffersize;
  302. u8 *junk;
  303. int rd_count;
  304. /* Discard remaining data in video pipe */
  305. junk = kmalloc(junk_len, GFP_KERNEL);
  306. if (!junk)
  307. return;
  308. while (1) {
  309. if (usb_bulk_msg(d->udev,
  310. usb_rcvbulkpipe(d->udev, p->endpoint),
  311. junk, junk_len, &rd_count, timeout) < 0)
  312. break;
  313. if (!rd_count)
  314. break;
  315. }
  316. kfree(junk);
  317. }
  318. static int cxusb_d680_dmb_streaming_ctrl(
  319. struct dvb_usb_adapter *adap, int onoff)
  320. {
  321. if (onoff) {
  322. u8 buf[2] = { 0x03, 0x00 };
  323. cxusb_d680_dmb_drain_video(adap->dev);
  324. return cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON,
  325. buf, sizeof(buf), NULL, 0);
  326. } else {
  327. int ret = cxusb_ctrl_msg(adap->dev,
  328. CMD_STREAMING_OFF, NULL, 0, NULL, 0);
  329. return ret;
  330. }
  331. }
  332. static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
  333. {
  334. struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
  335. u8 ircode[4];
  336. int i;
  337. cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
  338. *event = 0;
  339. *state = REMOTE_NO_KEY_PRESSED;
  340. for (i = 0; i < d->props.rc_key_map_size; i++) {
  341. if (keymap[i].custom == ircode[2] &&
  342. keymap[i].data == ircode[3]) {
  343. *event = keymap[i].event;
  344. *state = REMOTE_KEY_PRESSED;
  345. return 0;
  346. }
  347. }
  348. return 0;
  349. }
  350. static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d, u32 *event,
  351. int *state)
  352. {
  353. struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
  354. u8 ircode[4];
  355. int i;
  356. struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
  357. .buf = ircode, .len = 4 };
  358. *event = 0;
  359. *state = REMOTE_NO_KEY_PRESSED;
  360. if (cxusb_i2c_xfer(&d->i2c_adap, &msg, 1) != 1)
  361. return 0;
  362. for (i = 0; i < d->props.rc_key_map_size; i++) {
  363. if (keymap[i].custom == ircode[1] &&
  364. keymap[i].data == ircode[2]) {
  365. *event = keymap[i].event;
  366. *state = REMOTE_KEY_PRESSED;
  367. return 0;
  368. }
  369. }
  370. return 0;
  371. }
  372. static int cxusb_d680_dmb_rc_query(struct dvb_usb_device *d, u32 *event,
  373. int *state)
  374. {
  375. struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
  376. u8 ircode[2];
  377. int i;
  378. *event = 0;
  379. *state = REMOTE_NO_KEY_PRESSED;
  380. if (cxusb_ctrl_msg(d, 0x10, NULL, 0, ircode, 2) < 0)
  381. return 0;
  382. for (i = 0; i < d->props.rc_key_map_size; i++) {
  383. if (keymap[i].custom == ircode[0] &&
  384. keymap[i].data == ircode[1]) {
  385. *event = keymap[i].event;
  386. *state = REMOTE_KEY_PRESSED;
  387. return 0;
  388. }
  389. }
  390. return 0;
  391. }
  392. static struct dvb_usb_rc_key dvico_mce_rc_keys[] = {
  393. { 0xfe, 0x02, KEY_TV },
  394. { 0xfe, 0x0e, KEY_MP3 },
  395. { 0xfe, 0x1a, KEY_DVD },
  396. { 0xfe, 0x1e, KEY_FAVORITES },
  397. { 0xfe, 0x16, KEY_SETUP },
  398. { 0xfe, 0x46, KEY_POWER2 },
  399. { 0xfe, 0x0a, KEY_EPG },
  400. { 0xfe, 0x49, KEY_BACK },
  401. { 0xfe, 0x4d, KEY_MENU },
  402. { 0xfe, 0x51, KEY_UP },
  403. { 0xfe, 0x5b, KEY_LEFT },
  404. { 0xfe, 0x5f, KEY_RIGHT },
  405. { 0xfe, 0x53, KEY_DOWN },
  406. { 0xfe, 0x5e, KEY_OK },
  407. { 0xfe, 0x59, KEY_INFO },
  408. { 0xfe, 0x55, KEY_TAB },
  409. { 0xfe, 0x0f, KEY_PREVIOUSSONG },/* Replay */
  410. { 0xfe, 0x12, KEY_NEXTSONG }, /* Skip */
  411. { 0xfe, 0x42, KEY_ENTER }, /* Windows/Start */
  412. { 0xfe, 0x15, KEY_VOLUMEUP },
  413. { 0xfe, 0x05, KEY_VOLUMEDOWN },
  414. { 0xfe, 0x11, KEY_CHANNELUP },
  415. { 0xfe, 0x09, KEY_CHANNELDOWN },
  416. { 0xfe, 0x52, KEY_CAMERA },
  417. { 0xfe, 0x5a, KEY_TUNER }, /* Live */
  418. { 0xfe, 0x19, KEY_OPEN },
  419. { 0xfe, 0x0b, KEY_1 },
  420. { 0xfe, 0x17, KEY_2 },
  421. { 0xfe, 0x1b, KEY_3 },
  422. { 0xfe, 0x07, KEY_4 },
  423. { 0xfe, 0x50, KEY_5 },
  424. { 0xfe, 0x54, KEY_6 },
  425. { 0xfe, 0x48, KEY_7 },
  426. { 0xfe, 0x4c, KEY_8 },
  427. { 0xfe, 0x58, KEY_9 },
  428. { 0xfe, 0x13, KEY_ANGLE }, /* Aspect */
  429. { 0xfe, 0x03, KEY_0 },
  430. { 0xfe, 0x1f, KEY_ZOOM },
  431. { 0xfe, 0x43, KEY_REWIND },
  432. { 0xfe, 0x47, KEY_PLAYPAUSE },
  433. { 0xfe, 0x4f, KEY_FASTFORWARD },
  434. { 0xfe, 0x57, KEY_MUTE },
  435. { 0xfe, 0x0d, KEY_STOP },
  436. { 0xfe, 0x01, KEY_RECORD },
  437. { 0xfe, 0x4e, KEY_POWER },
  438. };
  439. static struct dvb_usb_rc_key dvico_portable_rc_keys[] = {
  440. { 0xfc, 0x02, KEY_SETUP }, /* Profile */
  441. { 0xfc, 0x43, KEY_POWER2 },
  442. { 0xfc, 0x06, KEY_EPG },
  443. { 0xfc, 0x5a, KEY_BACK },
  444. { 0xfc, 0x05, KEY_MENU },
  445. { 0xfc, 0x47, KEY_INFO },
  446. { 0xfc, 0x01, KEY_TAB },
  447. { 0xfc, 0x42, KEY_PREVIOUSSONG },/* Replay */
  448. { 0xfc, 0x49, KEY_VOLUMEUP },
  449. { 0xfc, 0x09, KEY_VOLUMEDOWN },
  450. { 0xfc, 0x54, KEY_CHANNELUP },
  451. { 0xfc, 0x0b, KEY_CHANNELDOWN },
  452. { 0xfc, 0x16, KEY_CAMERA },
  453. { 0xfc, 0x40, KEY_TUNER }, /* ATV/DTV */
  454. { 0xfc, 0x45, KEY_OPEN },
  455. { 0xfc, 0x19, KEY_1 },
  456. { 0xfc, 0x18, KEY_2 },
  457. { 0xfc, 0x1b, KEY_3 },
  458. { 0xfc, 0x1a, KEY_4 },
  459. { 0xfc, 0x58, KEY_5 },
  460. { 0xfc, 0x59, KEY_6 },
  461. { 0xfc, 0x15, KEY_7 },
  462. { 0xfc, 0x14, KEY_8 },
  463. { 0xfc, 0x17, KEY_9 },
  464. { 0xfc, 0x44, KEY_ANGLE }, /* Aspect */
  465. { 0xfc, 0x55, KEY_0 },
  466. { 0xfc, 0x07, KEY_ZOOM },
  467. { 0xfc, 0x0a, KEY_REWIND },
  468. { 0xfc, 0x08, KEY_PLAYPAUSE },
  469. { 0xfc, 0x4b, KEY_FASTFORWARD },
  470. { 0xfc, 0x5b, KEY_MUTE },
  471. { 0xfc, 0x04, KEY_STOP },
  472. { 0xfc, 0x56, KEY_RECORD },
  473. { 0xfc, 0x57, KEY_POWER },
  474. { 0xfc, 0x41, KEY_UNKNOWN }, /* INPUT */
  475. { 0xfc, 0x00, KEY_UNKNOWN }, /* HD */
  476. };
  477. static struct dvb_usb_rc_key d680_dmb_rc_keys[] = {
  478. { 0x00, 0x38, KEY_UNKNOWN }, /* TV/AV */
  479. { 0x08, 0x0c, KEY_ZOOM },
  480. { 0x08, 0x00, KEY_0 },
  481. { 0x00, 0x01, KEY_1 },
  482. { 0x08, 0x02, KEY_2 },
  483. { 0x00, 0x03, KEY_3 },
  484. { 0x08, 0x04, KEY_4 },
  485. { 0x00, 0x05, KEY_5 },
  486. { 0x08, 0x06, KEY_6 },
  487. { 0x00, 0x07, KEY_7 },
  488. { 0x08, 0x08, KEY_8 },
  489. { 0x00, 0x09, KEY_9 },
  490. { 0x00, 0x0a, KEY_MUTE },
  491. { 0x08, 0x29, KEY_BACK },
  492. { 0x00, 0x12, KEY_CHANNELUP },
  493. { 0x08, 0x13, KEY_CHANNELDOWN },
  494. { 0x00, 0x2b, KEY_VOLUMEUP },
  495. { 0x08, 0x2c, KEY_VOLUMEDOWN },
  496. { 0x00, 0x20, KEY_UP },
  497. { 0x08, 0x21, KEY_DOWN },
  498. { 0x00, 0x11, KEY_LEFT },
  499. { 0x08, 0x10, KEY_RIGHT },
  500. { 0x00, 0x0d, KEY_OK },
  501. { 0x08, 0x1f, KEY_RECORD },
  502. { 0x00, 0x17, KEY_PLAYPAUSE },
  503. { 0x08, 0x16, KEY_PLAYPAUSE },
  504. { 0x00, 0x0b, KEY_STOP },
  505. { 0x08, 0x27, KEY_FASTFORWARD },
  506. { 0x00, 0x26, KEY_REWIND },
  507. { 0x08, 0x1e, KEY_UNKNOWN }, /* Time Shift */
  508. { 0x00, 0x0e, KEY_UNKNOWN }, /* Snapshot */
  509. { 0x08, 0x2d, KEY_UNKNOWN }, /* Mouse Cursor */
  510. { 0x00, 0x0f, KEY_UNKNOWN }, /* Minimize/Maximize */
  511. { 0x08, 0x14, KEY_UNKNOWN }, /* Shuffle */
  512. { 0x00, 0x25, KEY_POWER },
  513. };
  514. static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
  515. {
  516. static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 };
  517. static u8 reset [] = { RESET, 0x80 };
  518. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  519. static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
  520. static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
  521. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
  522. mt352_write(fe, clock_config, sizeof(clock_config));
  523. udelay(200);
  524. mt352_write(fe, reset, sizeof(reset));
  525. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  526. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  527. mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
  528. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  529. return 0;
  530. }
  531. static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
  532. { /* used in both lgz201 and th7579 */
  533. static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x29 };
  534. static u8 reset [] = { RESET, 0x80 };
  535. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  536. static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
  537. static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
  538. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
  539. mt352_write(fe, clock_config, sizeof(clock_config));
  540. udelay(200);
  541. mt352_write(fe, reset, sizeof(reset));
  542. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  543. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  544. mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
  545. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  546. return 0;
  547. }
  548. static struct cx22702_config cxusb_cx22702_config = {
  549. .demod_address = 0x63,
  550. .output_mode = CX22702_PARALLEL_OUTPUT,
  551. };
  552. static struct lgdt330x_config cxusb_lgdt3303_config = {
  553. .demod_address = 0x0e,
  554. .demod_chip = LGDT3303,
  555. };
  556. static struct lgdt330x_config cxusb_aver_lgdt3303_config = {
  557. .demod_address = 0x0e,
  558. .demod_chip = LGDT3303,
  559. .clock_polarity_flip = 2,
  560. };
  561. static struct mt352_config cxusb_dee1601_config = {
  562. .demod_address = 0x0f,
  563. .demod_init = cxusb_dee1601_demod_init,
  564. };
  565. static struct zl10353_config cxusb_zl10353_dee1601_config = {
  566. .demod_address = 0x0f,
  567. .parallel_ts = 1,
  568. };
  569. static struct mt352_config cxusb_mt352_config = {
  570. /* used in both lgz201 and th7579 */
  571. .demod_address = 0x0f,
  572. .demod_init = cxusb_mt352_demod_init,
  573. };
  574. static struct zl10353_config cxusb_zl10353_xc3028_config = {
  575. .demod_address = 0x0f,
  576. .if2 = 45600,
  577. .no_tuner = 1,
  578. .parallel_ts = 1,
  579. };
  580. static struct mt352_config cxusb_mt352_xc3028_config = {
  581. .demod_address = 0x0f,
  582. .if2 = 4560,
  583. .no_tuner = 1,
  584. .demod_init = cxusb_mt352_demod_init,
  585. };
  586. /* FIXME: needs tweaking */
  587. static struct mxl5005s_config aver_a868r_tuner = {
  588. .i2c_address = 0x63,
  589. .if_freq = 6000000UL,
  590. .xtal_freq = CRYSTAL_FREQ_16000000HZ,
  591. .agc_mode = MXL_SINGLE_AGC,
  592. .tracking_filter = MXL_TF_C,
  593. .rssi_enable = MXL_RSSI_ENABLE,
  594. .cap_select = MXL_CAP_SEL_ENABLE,
  595. .div_out = MXL_DIV_OUT_4,
  596. .clock_out = MXL_CLOCK_OUT_DISABLE,
  597. .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
  598. .top = MXL5005S_TOP_25P2,
  599. .mod_mode = MXL_DIGITAL_MODE,
  600. .if_mode = MXL_ZERO_IF,
  601. .AgcMasterByte = 0x00,
  602. };
  603. /* FIXME: needs tweaking */
  604. static struct mxl5005s_config d680_dmb_tuner = {
  605. .i2c_address = 0x63,
  606. .if_freq = 36125000UL,
  607. .xtal_freq = CRYSTAL_FREQ_16000000HZ,
  608. .agc_mode = MXL_SINGLE_AGC,
  609. .tracking_filter = MXL_TF_C,
  610. .rssi_enable = MXL_RSSI_ENABLE,
  611. .cap_select = MXL_CAP_SEL_ENABLE,
  612. .div_out = MXL_DIV_OUT_4,
  613. .clock_out = MXL_CLOCK_OUT_DISABLE,
  614. .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
  615. .top = MXL5005S_TOP_25P2,
  616. .mod_mode = MXL_DIGITAL_MODE,
  617. .if_mode = MXL_ZERO_IF,
  618. .AgcMasterByte = 0x00,
  619. };
  620. /* Callbacks for DVB USB */
  621. static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
  622. {
  623. dvb_attach(simple_tuner_attach, adap->fe,
  624. &adap->dev->i2c_adap, 0x61,
  625. TUNER_PHILIPS_FMD1216ME_MK3);
  626. return 0;
  627. }
  628. static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap)
  629. {
  630. dvb_attach(dvb_pll_attach, adap->fe, 0x61,
  631. NULL, DVB_PLL_THOMSON_DTT7579);
  632. return 0;
  633. }
  634. static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap)
  635. {
  636. dvb_attach(dvb_pll_attach, adap->fe, 0x61, NULL, DVB_PLL_LG_Z201);
  637. return 0;
  638. }
  639. static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap)
  640. {
  641. dvb_attach(dvb_pll_attach, adap->fe, 0x60,
  642. NULL, DVB_PLL_THOMSON_DTT7579);
  643. return 0;
  644. }
  645. static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap)
  646. {
  647. dvb_attach(simple_tuner_attach, adap->fe,
  648. &adap->dev->i2c_adap, 0x61, TUNER_LG_TDVS_H06XF);
  649. return 0;
  650. }
  651. static int dvico_bluebird_xc2028_callback(void *ptr, int component,
  652. int command, int arg)
  653. {
  654. struct dvb_usb_adapter *adap = ptr;
  655. struct dvb_usb_device *d = adap->dev;
  656. switch (command) {
  657. case XC2028_TUNER_RESET:
  658. deb_info("%s: XC2028_TUNER_RESET %d\n", __func__, arg);
  659. cxusb_bluebird_gpio_pulse(d, 0x01, 1);
  660. break;
  661. case XC2028_RESET_CLK:
  662. deb_info("%s: XC2028_RESET_CLK %d\n", __func__, arg);
  663. break;
  664. default:
  665. deb_info("%s: unknown command %d, arg %d\n", __func__,
  666. command, arg);
  667. return -EINVAL;
  668. }
  669. return 0;
  670. }
  671. static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter *adap)
  672. {
  673. struct dvb_frontend *fe;
  674. struct xc2028_config cfg = {
  675. .i2c_adap = &adap->dev->i2c_adap,
  676. .i2c_addr = 0x61,
  677. };
  678. static struct xc2028_ctrl ctl = {
  679. .fname = XC2028_DEFAULT_FIRMWARE,
  680. .max_len = 64,
  681. .demod = XC3028_FE_ZARLINK456,
  682. };
  683. /* FIXME: generalize & move to common area */
  684. adap->fe->callback = dvico_bluebird_xc2028_callback;
  685. fe = dvb_attach(xc2028_attach, adap->fe, &cfg);
  686. if (fe == NULL || fe->ops.tuner_ops.set_config == NULL)
  687. return -EIO;
  688. fe->ops.tuner_ops.set_config(fe, &ctl);
  689. return 0;
  690. }
  691. static int cxusb_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap)
  692. {
  693. dvb_attach(mxl5005s_attach, adap->fe,
  694. &adap->dev->i2c_adap, &aver_a868r_tuner);
  695. return 0;
  696. }
  697. static int cxusb_d680_dmb_tuner_attach(struct dvb_usb_adapter *adap)
  698. {
  699. struct dvb_frontend *fe;
  700. fe = dvb_attach(mxl5005s_attach, adap->fe,
  701. &adap->dev->i2c_adap, &d680_dmb_tuner);
  702. return (fe == NULL) ? -EIO : 0;
  703. }
  704. static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
  705. {
  706. u8 b;
  707. if (usb_set_interface(adap->dev->udev, 0, 6) < 0)
  708. err("set interface failed");
  709. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1);
  710. if ((adap->fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config,
  711. &adap->dev->i2c_adap)) != NULL)
  712. return 0;
  713. return -EIO;
  714. }
  715. static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
  716. {
  717. if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
  718. err("set interface failed");
  719. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  720. if ((adap->fe = dvb_attach(lgdt330x_attach, &cxusb_lgdt3303_config,
  721. &adap->dev->i2c_adap)) != NULL)
  722. return 0;
  723. return -EIO;
  724. }
  725. static int cxusb_aver_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
  726. {
  727. adap->fe = dvb_attach(lgdt330x_attach, &cxusb_aver_lgdt3303_config,
  728. &adap->dev->i2c_adap);
  729. if (adap->fe != NULL)
  730. return 0;
  731. return -EIO;
  732. }
  733. static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap)
  734. {
  735. /* used in both lgz201 and th7579 */
  736. if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
  737. err("set interface failed");
  738. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  739. if ((adap->fe = dvb_attach(mt352_attach, &cxusb_mt352_config,
  740. &adap->dev->i2c_adap)) != NULL)
  741. return 0;
  742. return -EIO;
  743. }
  744. static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
  745. {
  746. if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
  747. err("set interface failed");
  748. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  749. if (((adap->fe = dvb_attach(mt352_attach, &cxusb_dee1601_config,
  750. &adap->dev->i2c_adap)) != NULL) ||
  751. ((adap->fe = dvb_attach(zl10353_attach,
  752. &cxusb_zl10353_dee1601_config,
  753. &adap->dev->i2c_adap)) != NULL))
  754. return 0;
  755. return -EIO;
  756. }
  757. static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
  758. {
  759. u8 ircode[4];
  760. int i;
  761. struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
  762. .buf = ircode, .len = 4 };
  763. if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
  764. err("set interface failed");
  765. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  766. /* reset the tuner and demodulator */
  767. cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
  768. cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
  769. cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
  770. if ((adap->fe = dvb_attach(zl10353_attach,
  771. &cxusb_zl10353_xc3028_config,
  772. &adap->dev->i2c_adap)) == NULL)
  773. return -EIO;
  774. /* try to determine if there is no IR decoder on the I2C bus */
  775. for (i = 0; adap->dev->props.rc_key_map != NULL && i < 5; i++) {
  776. msleep(20);
  777. if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1)
  778. goto no_IR;
  779. if (ircode[0] == 0 && ircode[1] == 0)
  780. continue;
  781. if (ircode[2] + ircode[3] != 0xff) {
  782. no_IR:
  783. adap->dev->props.rc_key_map = NULL;
  784. info("No IR receiver detected on this device.");
  785. break;
  786. }
  787. }
  788. return 0;
  789. }
  790. static struct dibx000_agc_config dib7070_agc_config = {
  791. .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
  792. /*
  793. * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
  794. * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
  795. * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
  796. */
  797. .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
  798. (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
  799. .inv_gain = 600,
  800. .time_stabiliz = 10,
  801. .alpha_level = 0,
  802. .thlock = 118,
  803. .wbd_inv = 0,
  804. .wbd_ref = 3530,
  805. .wbd_sel = 1,
  806. .wbd_alpha = 5,
  807. .agc1_max = 65535,
  808. .agc1_min = 0,
  809. .agc2_max = 65535,
  810. .agc2_min = 0,
  811. .agc1_pt1 = 0,
  812. .agc1_pt2 = 40,
  813. .agc1_pt3 = 183,
  814. .agc1_slope1 = 206,
  815. .agc1_slope2 = 255,
  816. .agc2_pt1 = 72,
  817. .agc2_pt2 = 152,
  818. .agc2_slope1 = 88,
  819. .agc2_slope2 = 90,
  820. .alpha_mant = 17,
  821. .alpha_exp = 27,
  822. .beta_mant = 23,
  823. .beta_exp = 51,
  824. .perform_agc_softsplit = 0,
  825. };
  826. static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
  827. .internal = 60000,
  828. .sampling = 15000,
  829. .pll_prediv = 1,
  830. .pll_ratio = 20,
  831. .pll_range = 3,
  832. .pll_reset = 1,
  833. .pll_bypass = 0,
  834. .enable_refdiv = 0,
  835. .bypclk_div = 0,
  836. .IO_CLK_en_core = 1,
  837. .ADClkSrc = 1,
  838. .modulo = 2,
  839. /* refsel, sel, freq_15k */
  840. .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
  841. .ifreq = (0 << 25) | 0,
  842. .timf = 20452225,
  843. .xtal_hz = 12000000,
  844. };
  845. static struct dib7000p_config cxusb_dualdig4_rev2_config = {
  846. .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
  847. .output_mpeg2_in_188_bytes = 1,
  848. .agc_config_count = 1,
  849. .agc = &dib7070_agc_config,
  850. .bw = &dib7070_bw_config_12_mhz,
  851. .tuner_is_baseband = 1,
  852. .spur_protect = 1,
  853. .gpio_dir = 0xfcef,
  854. .gpio_val = 0x0110,
  855. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  856. .hostbus_diversity = 1,
  857. };
  858. static int cxusb_dualdig4_rev2_frontend_attach(struct dvb_usb_adapter *adap)
  859. {
  860. if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
  861. err("set interface failed");
  862. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  863. cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
  864. dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
  865. &cxusb_dualdig4_rev2_config);
  866. adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
  867. &cxusb_dualdig4_rev2_config);
  868. if (adap->fe == NULL)
  869. return -EIO;
  870. return 0;
  871. }
  872. static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
  873. {
  874. return dib7000p_set_gpio(fe, 8, 0, !onoff);
  875. }
  876. static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
  877. {
  878. return 0;
  879. }
  880. static struct dib0070_config dib7070p_dib0070_config = {
  881. .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
  882. .reset = dib7070_tuner_reset,
  883. .sleep = dib7070_tuner_sleep,
  884. .clock_khz = 12000,
  885. };
  886. struct dib0700_adapter_state {
  887. int (*set_param_save) (struct dvb_frontend *,
  888. struct dvb_frontend_parameters *);
  889. };
  890. static int dib7070_set_param_override(struct dvb_frontend *fe,
  891. struct dvb_frontend_parameters *fep)
  892. {
  893. struct dvb_usb_adapter *adap = fe->dvb->priv;
  894. struct dib0700_adapter_state *state = adap->priv;
  895. u16 offset;
  896. u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
  897. switch (band) {
  898. case BAND_VHF: offset = 950; break;
  899. default:
  900. case BAND_UHF: offset = 550; break;
  901. }
  902. dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
  903. return state->set_param_save(fe, fep);
  904. }
  905. static int cxusb_dualdig4_rev2_tuner_attach(struct dvb_usb_adapter *adap)
  906. {
  907. struct dib0700_adapter_state *st = adap->priv;
  908. struct i2c_adapter *tun_i2c =
  909. dib7000p_get_i2c_master(adap->fe,
  910. DIBX000_I2C_INTERFACE_TUNER, 1);
  911. if (dvb_attach(dib0070_attach, adap->fe, tun_i2c,
  912. &dib7070p_dib0070_config) == NULL)
  913. return -ENODEV;
  914. st->set_param_save = adap->fe->ops.tuner_ops.set_params;
  915. adap->fe->ops.tuner_ops.set_params = dib7070_set_param_override;
  916. return 0;
  917. }
  918. static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap)
  919. {
  920. if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
  921. err("set interface failed");
  922. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  923. /* reset the tuner and demodulator */
  924. cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
  925. cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
  926. cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
  927. if ((adap->fe = dvb_attach(zl10353_attach,
  928. &cxusb_zl10353_xc3028_config,
  929. &adap->dev->i2c_adap)) != NULL)
  930. return 0;
  931. if ((adap->fe = dvb_attach(mt352_attach,
  932. &cxusb_mt352_xc3028_config,
  933. &adap->dev->i2c_adap)) != NULL)
  934. return 0;
  935. return -EIO;
  936. }
  937. static struct lgs8gl5_config lgs8gl5_cfg = {
  938. .demod_address = 0x19,
  939. };
  940. static int cxusb_d680_dmb_frontend_attach(struct dvb_usb_adapter *adap)
  941. {
  942. struct dvb_usb_device *d = adap->dev;
  943. int n;
  944. /* Select required USB configuration */
  945. if (usb_set_interface(d->udev, 0, 0) < 0)
  946. err("set interface failed");
  947. /* Unblock all USB pipes */
  948. usb_clear_halt(d->udev,
  949. usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
  950. usb_clear_halt(d->udev,
  951. usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
  952. usb_clear_halt(d->udev,
  953. usb_rcvbulkpipe(d->udev, d->props.adapter[0].stream.endpoint));
  954. /* Drain USB pipes to avoid hang after reboot */
  955. for (n = 0; n < 5; n++) {
  956. cxusb_d680_dmb_drain_message(d);
  957. cxusb_d680_dmb_drain_video(d);
  958. msleep(200);
  959. }
  960. /* Reset the tuner */
  961. if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {
  962. err("clear tuner gpio failed");
  963. return -EIO;
  964. }
  965. msleep(100);
  966. if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {
  967. err("set tuner gpio failed");
  968. return -EIO;
  969. }
  970. msleep(100);
  971. /* Attach frontend */
  972. adap->fe = dvb_attach(lgs8gl5_attach, &lgs8gl5_cfg, &d->i2c_adap);
  973. if (adap->fe == NULL)
  974. return -EIO;
  975. return 0;
  976. }
  977. /*
  978. * DViCO has shipped two devices with the same USB ID, but only one of them
  979. * needs a firmware download. Check the device class details to see if they
  980. * have non-default values to decide whether the device is actually cold or
  981. * not, and forget a match if it turns out we selected the wrong device.
  982. */
  983. static int bluebird_fx2_identify_state(struct usb_device *udev,
  984. struct dvb_usb_device_properties *props,
  985. struct dvb_usb_device_description **desc,
  986. int *cold)
  987. {
  988. int wascold = *cold;
  989. *cold = udev->descriptor.bDeviceClass == 0xff &&
  990. udev->descriptor.bDeviceSubClass == 0xff &&
  991. udev->descriptor.bDeviceProtocol == 0xff;
  992. if (*cold && !wascold)
  993. *desc = NULL;
  994. return 0;
  995. }
  996. /*
  997. * DViCO bluebird firmware needs the "warm" product ID to be patched into the
  998. * firmware file before download.
  999. */
  1000. static const int dvico_firmware_id_offsets[] = { 6638, 3204 };
  1001. static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
  1002. const struct firmware *fw)
  1003. {
  1004. int pos;
  1005. for (pos = 0; pos < ARRAY_SIZE(dvico_firmware_id_offsets); pos++) {
  1006. int idoff = dvico_firmware_id_offsets[pos];
  1007. if (fw->size < idoff + 4)
  1008. continue;
  1009. if (fw->data[idoff] == (USB_VID_DVICO & 0xff) &&
  1010. fw->data[idoff + 1] == USB_VID_DVICO >> 8) {
  1011. struct firmware new_fw;
  1012. u8 *new_fw_data = vmalloc(fw->size);
  1013. int ret;
  1014. if (!new_fw_data)
  1015. return -ENOMEM;
  1016. memcpy(new_fw_data, fw->data, fw->size);
  1017. new_fw.size = fw->size;
  1018. new_fw.data = new_fw_data;
  1019. new_fw_data[idoff + 2] =
  1020. le16_to_cpu(udev->descriptor.idProduct) + 1;
  1021. new_fw_data[idoff + 3] =
  1022. le16_to_cpu(udev->descriptor.idProduct) >> 8;
  1023. ret = usb_cypress_load_firmware(udev, &new_fw,
  1024. CYPRESS_FX2);
  1025. vfree(new_fw_data);
  1026. return ret;
  1027. }
  1028. }
  1029. return -EINVAL;
  1030. }
  1031. /* DVB USB Driver stuff */
  1032. static struct dvb_usb_device_properties cxusb_medion_properties;
  1033. static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
  1034. static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;
  1035. static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;
  1036. static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;
  1037. static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties;
  1038. static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties;
  1039. static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties;
  1040. static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties;
  1041. static struct dvb_usb_device_properties cxusb_aver_a868r_properties;
  1042. static struct dvb_usb_device_properties cxusb_d680_dmb_properties;
  1043. static int cxusb_probe(struct usb_interface *intf,
  1044. const struct usb_device_id *id)
  1045. {
  1046. if (0 == dvb_usb_device_init(intf, &cxusb_medion_properties,
  1047. THIS_MODULE, NULL, adapter_nr) ||
  1048. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties,
  1049. THIS_MODULE, NULL, adapter_nr) ||
  1050. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties,
  1051. THIS_MODULE, NULL, adapter_nr) ||
  1052. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgz201_properties,
  1053. THIS_MODULE, NULL, adapter_nr) ||
  1054. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dtt7579_properties,
  1055. THIS_MODULE, NULL, adapter_nr) ||
  1056. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dualdig4_properties,
  1057. THIS_MODULE, NULL, adapter_nr) ||
  1058. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_nano2_properties,
  1059. THIS_MODULE, NULL, adapter_nr) ||
  1060. 0 == dvb_usb_device_init(intf,
  1061. &cxusb_bluebird_nano2_needsfirmware_properties,
  1062. THIS_MODULE, NULL, adapter_nr) ||
  1063. 0 == dvb_usb_device_init(intf, &cxusb_aver_a868r_properties,
  1064. THIS_MODULE, NULL, adapter_nr) ||
  1065. 0 == dvb_usb_device_init(intf,
  1066. &cxusb_bluebird_dualdig4_rev2_properties,
  1067. THIS_MODULE, NULL, adapter_nr) ||
  1068. 0 == dvb_usb_device_init(intf, &cxusb_d680_dmb_properties,
  1069. THIS_MODULE, NULL, adapter_nr) ||
  1070. 0)
  1071. return 0;
  1072. return -EINVAL;
  1073. }
  1074. static struct usb_device_id cxusb_table [] = {
  1075. { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
  1076. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
  1077. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
  1078. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) },
  1079. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) },
  1080. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
  1081. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
  1082. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
  1083. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
  1084. { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) },
  1085. { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) },
  1086. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) },
  1087. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) },
  1088. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4) },
  1089. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2) },
  1090. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) },
  1091. { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_A868R) },
  1092. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2) },
  1093. { USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB) },
  1094. {} /* Terminating entry */
  1095. };
  1096. MODULE_DEVICE_TABLE (usb, cxusb_table);
  1097. static struct dvb_usb_device_properties cxusb_medion_properties = {
  1098. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1099. .usb_ctrl = CYPRESS_FX2,
  1100. .size_of_priv = sizeof(struct cxusb_state),
  1101. .num_adapters = 1,
  1102. .adapter = {
  1103. {
  1104. .streaming_ctrl = cxusb_streaming_ctrl,
  1105. .frontend_attach = cxusb_cx22702_frontend_attach,
  1106. .tuner_attach = cxusb_fmd1216me_tuner_attach,
  1107. /* parameter for the MPEG2-data transfer */
  1108. .stream = {
  1109. .type = USB_BULK,
  1110. .count = 5,
  1111. .endpoint = 0x02,
  1112. .u = {
  1113. .bulk = {
  1114. .buffersize = 8192,
  1115. }
  1116. }
  1117. },
  1118. },
  1119. },
  1120. .power_ctrl = cxusb_power_ctrl,
  1121. .i2c_algo = &cxusb_i2c_algo,
  1122. .generic_bulk_ctrl_endpoint = 0x01,
  1123. .num_device_descs = 1,
  1124. .devices = {
  1125. { "Medion MD95700 (MDUSBTV-HYBRID)",
  1126. { NULL },
  1127. { &cxusb_table[0], NULL },
  1128. },
  1129. }
  1130. };
  1131. static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
  1132. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1133. .usb_ctrl = DEVICE_SPECIFIC,
  1134. .firmware = "dvb-usb-bluebird-01.fw",
  1135. .download_firmware = bluebird_patch_dvico_firmware_download,
  1136. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  1137. use usb alt setting 7 for EP2 transfer (atsc) */
  1138. .size_of_priv = sizeof(struct cxusb_state),
  1139. .num_adapters = 1,
  1140. .adapter = {
  1141. {
  1142. .streaming_ctrl = cxusb_streaming_ctrl,
  1143. .frontend_attach = cxusb_lgdt3303_frontend_attach,
  1144. .tuner_attach = cxusb_lgh064f_tuner_attach,
  1145. /* parameter for the MPEG2-data transfer */
  1146. .stream = {
  1147. .type = USB_BULK,
  1148. .count = 5,
  1149. .endpoint = 0x02,
  1150. .u = {
  1151. .bulk = {
  1152. .buffersize = 8192,
  1153. }
  1154. }
  1155. },
  1156. },
  1157. },
  1158. .power_ctrl = cxusb_bluebird_power_ctrl,
  1159. .i2c_algo = &cxusb_i2c_algo,
  1160. .rc_interval = 100,
  1161. .rc_key_map = dvico_portable_rc_keys,
  1162. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  1163. .rc_query = cxusb_rc_query,
  1164. .generic_bulk_ctrl_endpoint = 0x01,
  1165. .num_device_descs = 1,
  1166. .devices = {
  1167. { "DViCO FusionHDTV5 USB Gold",
  1168. { &cxusb_table[1], NULL },
  1169. { &cxusb_table[2], NULL },
  1170. },
  1171. }
  1172. };
  1173. static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
  1174. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1175. .usb_ctrl = DEVICE_SPECIFIC,
  1176. .firmware = "dvb-usb-bluebird-01.fw",
  1177. .download_firmware = bluebird_patch_dvico_firmware_download,
  1178. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  1179. use usb alt setting 7 for EP2 transfer (atsc) */
  1180. .size_of_priv = sizeof(struct cxusb_state),
  1181. .num_adapters = 1,
  1182. .adapter = {
  1183. {
  1184. .streaming_ctrl = cxusb_streaming_ctrl,
  1185. .frontend_attach = cxusb_dee1601_frontend_attach,
  1186. .tuner_attach = cxusb_dee1601_tuner_attach,
  1187. /* parameter for the MPEG2-data transfer */
  1188. .stream = {
  1189. .type = USB_BULK,
  1190. .count = 5,
  1191. .endpoint = 0x04,
  1192. .u = {
  1193. .bulk = {
  1194. .buffersize = 8192,
  1195. }
  1196. }
  1197. },
  1198. },
  1199. },
  1200. .power_ctrl = cxusb_bluebird_power_ctrl,
  1201. .i2c_algo = &cxusb_i2c_algo,
  1202. .rc_interval = 150,
  1203. .rc_key_map = dvico_mce_rc_keys,
  1204. .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
  1205. .rc_query = cxusb_rc_query,
  1206. .generic_bulk_ctrl_endpoint = 0x01,
  1207. .num_device_descs = 3,
  1208. .devices = {
  1209. { "DViCO FusionHDTV DVB-T Dual USB",
  1210. { &cxusb_table[3], NULL },
  1211. { &cxusb_table[4], NULL },
  1212. },
  1213. { "DigitalNow DVB-T Dual USB",
  1214. { &cxusb_table[9], NULL },
  1215. { &cxusb_table[10], NULL },
  1216. },
  1217. { "DViCO FusionHDTV DVB-T Dual Digital 2",
  1218. { &cxusb_table[11], NULL },
  1219. { &cxusb_table[12], NULL },
  1220. },
  1221. }
  1222. };
  1223. static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
  1224. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1225. .usb_ctrl = DEVICE_SPECIFIC,
  1226. .firmware = "dvb-usb-bluebird-01.fw",
  1227. .download_firmware = bluebird_patch_dvico_firmware_download,
  1228. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  1229. use usb alt setting 7 for EP2 transfer (atsc) */
  1230. .size_of_priv = sizeof(struct cxusb_state),
  1231. .num_adapters = 2,
  1232. .adapter = {
  1233. {
  1234. .streaming_ctrl = cxusb_streaming_ctrl,
  1235. .frontend_attach = cxusb_mt352_frontend_attach,
  1236. .tuner_attach = cxusb_lgz201_tuner_attach,
  1237. /* parameter for the MPEG2-data transfer */
  1238. .stream = {
  1239. .type = USB_BULK,
  1240. .count = 5,
  1241. .endpoint = 0x04,
  1242. .u = {
  1243. .bulk = {
  1244. .buffersize = 8192,
  1245. }
  1246. }
  1247. },
  1248. },
  1249. },
  1250. .power_ctrl = cxusb_bluebird_power_ctrl,
  1251. .i2c_algo = &cxusb_i2c_algo,
  1252. .rc_interval = 100,
  1253. .rc_key_map = dvico_portable_rc_keys,
  1254. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  1255. .rc_query = cxusb_rc_query,
  1256. .generic_bulk_ctrl_endpoint = 0x01,
  1257. .num_device_descs = 1,
  1258. .devices = {
  1259. { "DViCO FusionHDTV DVB-T USB (LGZ201)",
  1260. { &cxusb_table[5], NULL },
  1261. { &cxusb_table[6], NULL },
  1262. },
  1263. }
  1264. };
  1265. static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
  1266. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1267. .usb_ctrl = DEVICE_SPECIFIC,
  1268. .firmware = "dvb-usb-bluebird-01.fw",
  1269. .download_firmware = bluebird_patch_dvico_firmware_download,
  1270. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  1271. use usb alt setting 7 for EP2 transfer (atsc) */
  1272. .size_of_priv = sizeof(struct cxusb_state),
  1273. .num_adapters = 1,
  1274. .adapter = {
  1275. {
  1276. .streaming_ctrl = cxusb_streaming_ctrl,
  1277. .frontend_attach = cxusb_mt352_frontend_attach,
  1278. .tuner_attach = cxusb_dtt7579_tuner_attach,
  1279. /* parameter for the MPEG2-data transfer */
  1280. .stream = {
  1281. .type = USB_BULK,
  1282. .count = 5,
  1283. .endpoint = 0x04,
  1284. .u = {
  1285. .bulk = {
  1286. .buffersize = 8192,
  1287. }
  1288. }
  1289. },
  1290. },
  1291. },
  1292. .power_ctrl = cxusb_bluebird_power_ctrl,
  1293. .i2c_algo = &cxusb_i2c_algo,
  1294. .rc_interval = 100,
  1295. .rc_key_map = dvico_portable_rc_keys,
  1296. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  1297. .rc_query = cxusb_rc_query,
  1298. .generic_bulk_ctrl_endpoint = 0x01,
  1299. .num_device_descs = 1,
  1300. .devices = {
  1301. { "DViCO FusionHDTV DVB-T USB (TH7579)",
  1302. { &cxusb_table[7], NULL },
  1303. { &cxusb_table[8], NULL },
  1304. },
  1305. }
  1306. };
  1307. static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
  1308. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1309. .usb_ctrl = CYPRESS_FX2,
  1310. .size_of_priv = sizeof(struct cxusb_state),
  1311. .num_adapters = 1,
  1312. .adapter = {
  1313. {
  1314. .streaming_ctrl = cxusb_streaming_ctrl,
  1315. .frontend_attach = cxusb_dualdig4_frontend_attach,
  1316. .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
  1317. /* parameter for the MPEG2-data transfer */
  1318. .stream = {
  1319. .type = USB_BULK,
  1320. .count = 5,
  1321. .endpoint = 0x02,
  1322. .u = {
  1323. .bulk = {
  1324. .buffersize = 8192,
  1325. }
  1326. }
  1327. },
  1328. },
  1329. },
  1330. .power_ctrl = cxusb_power_ctrl,
  1331. .i2c_algo = &cxusb_i2c_algo,
  1332. .generic_bulk_ctrl_endpoint = 0x01,
  1333. .rc_interval = 100,
  1334. .rc_key_map = dvico_mce_rc_keys,
  1335. .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
  1336. .rc_query = cxusb_bluebird2_rc_query,
  1337. .num_device_descs = 1,
  1338. .devices = {
  1339. { "DViCO FusionHDTV DVB-T Dual Digital 4",
  1340. { NULL },
  1341. { &cxusb_table[13], NULL },
  1342. },
  1343. }
  1344. };
  1345. static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
  1346. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1347. .usb_ctrl = CYPRESS_FX2,
  1348. .identify_state = bluebird_fx2_identify_state,
  1349. .size_of_priv = sizeof(struct cxusb_state),
  1350. .num_adapters = 1,
  1351. .adapter = {
  1352. {
  1353. .streaming_ctrl = cxusb_streaming_ctrl,
  1354. .frontend_attach = cxusb_nano2_frontend_attach,
  1355. .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
  1356. /* parameter for the MPEG2-data transfer */
  1357. .stream = {
  1358. .type = USB_BULK,
  1359. .count = 5,
  1360. .endpoint = 0x02,
  1361. .u = {
  1362. .bulk = {
  1363. .buffersize = 8192,
  1364. }
  1365. }
  1366. },
  1367. },
  1368. },
  1369. .power_ctrl = cxusb_nano2_power_ctrl,
  1370. .i2c_algo = &cxusb_i2c_algo,
  1371. .generic_bulk_ctrl_endpoint = 0x01,
  1372. .rc_interval = 100,
  1373. .rc_key_map = dvico_portable_rc_keys,
  1374. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  1375. .rc_query = cxusb_bluebird2_rc_query,
  1376. .num_device_descs = 1,
  1377. .devices = {
  1378. { "DViCO FusionHDTV DVB-T NANO2",
  1379. { NULL },
  1380. { &cxusb_table[14], NULL },
  1381. },
  1382. }
  1383. };
  1384. static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties = {
  1385. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1386. .usb_ctrl = DEVICE_SPECIFIC,
  1387. .firmware = "dvb-usb-bluebird-02.fw",
  1388. .download_firmware = bluebird_patch_dvico_firmware_download,
  1389. .identify_state = bluebird_fx2_identify_state,
  1390. .size_of_priv = sizeof(struct cxusb_state),
  1391. .num_adapters = 1,
  1392. .adapter = {
  1393. {
  1394. .streaming_ctrl = cxusb_streaming_ctrl,
  1395. .frontend_attach = cxusb_nano2_frontend_attach,
  1396. .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
  1397. /* parameter for the MPEG2-data transfer */
  1398. .stream = {
  1399. .type = USB_BULK,
  1400. .count = 5,
  1401. .endpoint = 0x02,
  1402. .u = {
  1403. .bulk = {
  1404. .buffersize = 8192,
  1405. }
  1406. }
  1407. },
  1408. },
  1409. },
  1410. .power_ctrl = cxusb_nano2_power_ctrl,
  1411. .i2c_algo = &cxusb_i2c_algo,
  1412. .generic_bulk_ctrl_endpoint = 0x01,
  1413. .rc_interval = 100,
  1414. .rc_key_map = dvico_portable_rc_keys,
  1415. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  1416. .rc_query = cxusb_rc_query,
  1417. .num_device_descs = 1,
  1418. .devices = {
  1419. { "DViCO FusionHDTV DVB-T NANO2 w/o firmware",
  1420. { &cxusb_table[14], NULL },
  1421. { &cxusb_table[15], NULL },
  1422. },
  1423. }
  1424. };
  1425. static struct dvb_usb_device_properties cxusb_aver_a868r_properties = {
  1426. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1427. .usb_ctrl = CYPRESS_FX2,
  1428. .size_of_priv = sizeof(struct cxusb_state),
  1429. .num_adapters = 1,
  1430. .adapter = {
  1431. {
  1432. .streaming_ctrl = cxusb_aver_streaming_ctrl,
  1433. .frontend_attach = cxusb_aver_lgdt3303_frontend_attach,
  1434. .tuner_attach = cxusb_mxl5003s_tuner_attach,
  1435. /* parameter for the MPEG2-data transfer */
  1436. .stream = {
  1437. .type = USB_BULK,
  1438. .count = 5,
  1439. .endpoint = 0x04,
  1440. .u = {
  1441. .bulk = {
  1442. .buffersize = 8192,
  1443. }
  1444. }
  1445. },
  1446. },
  1447. },
  1448. .power_ctrl = cxusb_aver_power_ctrl,
  1449. .i2c_algo = &cxusb_i2c_algo,
  1450. .generic_bulk_ctrl_endpoint = 0x01,
  1451. .num_device_descs = 1,
  1452. .devices = {
  1453. { "AVerMedia AVerTVHD Volar (A868R)",
  1454. { NULL },
  1455. { &cxusb_table[16], NULL },
  1456. },
  1457. }
  1458. };
  1459. static
  1460. struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties = {
  1461. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1462. .usb_ctrl = CYPRESS_FX2,
  1463. .size_of_priv = sizeof(struct cxusb_state),
  1464. .num_adapters = 1,
  1465. .adapter = {
  1466. {
  1467. .streaming_ctrl = cxusb_streaming_ctrl,
  1468. .frontend_attach = cxusb_dualdig4_rev2_frontend_attach,
  1469. .tuner_attach = cxusb_dualdig4_rev2_tuner_attach,
  1470. .size_of_priv = sizeof(struct dib0700_adapter_state),
  1471. /* parameter for the MPEG2-data transfer */
  1472. .stream = {
  1473. .type = USB_BULK,
  1474. .count = 7,
  1475. .endpoint = 0x02,
  1476. .u = {
  1477. .bulk = {
  1478. .buffersize = 4096,
  1479. }
  1480. }
  1481. },
  1482. },
  1483. },
  1484. .power_ctrl = cxusb_bluebird_power_ctrl,
  1485. .i2c_algo = &cxusb_i2c_algo,
  1486. .generic_bulk_ctrl_endpoint = 0x01,
  1487. .rc_interval = 100,
  1488. .rc_key_map = dvico_mce_rc_keys,
  1489. .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
  1490. .rc_query = cxusb_rc_query,
  1491. .num_device_descs = 1,
  1492. .devices = {
  1493. { "DViCO FusionHDTV DVB-T Dual Digital 4 (rev 2)",
  1494. { NULL },
  1495. { &cxusb_table[17], NULL },
  1496. },
  1497. }
  1498. };
  1499. static struct dvb_usb_device_properties cxusb_d680_dmb_properties = {
  1500. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1501. .usb_ctrl = CYPRESS_FX2,
  1502. .size_of_priv = sizeof(struct cxusb_state),
  1503. .num_adapters = 1,
  1504. .adapter = {
  1505. {
  1506. .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl,
  1507. .frontend_attach = cxusb_d680_dmb_frontend_attach,
  1508. .tuner_attach = cxusb_d680_dmb_tuner_attach,
  1509. /* parameter for the MPEG2-data transfer */
  1510. .stream = {
  1511. .type = USB_BULK,
  1512. .count = 5,
  1513. .endpoint = 0x02,
  1514. .u = {
  1515. .bulk = {
  1516. .buffersize = 8192,
  1517. }
  1518. }
  1519. },
  1520. },
  1521. },
  1522. .power_ctrl = cxusb_d680_dmb_power_ctrl,
  1523. .i2c_algo = &cxusb_i2c_algo,
  1524. .generic_bulk_ctrl_endpoint = 0x01,
  1525. .rc_interval = 100,
  1526. .rc_key_map = d680_dmb_rc_keys,
  1527. .rc_key_map_size = ARRAY_SIZE(d680_dmb_rc_keys),
  1528. .rc_query = cxusb_d680_dmb_rc_query,
  1529. .num_device_descs = 1,
  1530. .devices = {
  1531. {
  1532. "Conexant DMB-TH Stick",
  1533. { NULL },
  1534. { &cxusb_table[18], NULL },
  1535. },
  1536. }
  1537. };
  1538. static struct usb_driver cxusb_driver = {
  1539. .name = "dvb_usb_cxusb",
  1540. .probe = cxusb_probe,
  1541. .disconnect = dvb_usb_device_exit,
  1542. .id_table = cxusb_table,
  1543. };
  1544. /* module stuff */
  1545. static int __init cxusb_module_init(void)
  1546. {
  1547. int result;
  1548. if ((result = usb_register(&cxusb_driver))) {
  1549. err("usb_register failed. Error number %d",result);
  1550. return result;
  1551. }
  1552. return 0;
  1553. }
  1554. static void __exit cxusb_module_exit(void)
  1555. {
  1556. /* deregister this driver from the USB subsystem */
  1557. usb_deregister(&cxusb_driver);
  1558. }
  1559. module_init (cxusb_module_init);
  1560. module_exit (cxusb_module_exit);
  1561. MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
  1562. MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
  1563. MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
  1564. MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
  1565. MODULE_VERSION("1.0-alpha");
  1566. MODULE_LICENSE("GPL");