cxusb.c 50 KB

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