cxusb.c 51 KB

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