cxusb.c 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017
  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].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,
  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, 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, 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, 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,
  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->callback = dvico_bluebird_xc2028_callback;
  699. fe = dvb_attach(xc2028_attach, adap->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,
  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,
  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,
  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. if ((adap->fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config,
  732. &adap->dev->i2c_adap)) != NULL)
  733. return 0;
  734. return -EIO;
  735. }
  736. static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
  737. {
  738. if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
  739. err("set interface failed");
  740. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  741. if ((adap->fe = dvb_attach(lgdt330x_attach, &cxusb_lgdt3303_config,
  742. &adap->dev->i2c_adap)) != NULL)
  743. return 0;
  744. return -EIO;
  745. }
  746. static int cxusb_aver_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
  747. {
  748. adap->fe = dvb_attach(lgdt330x_attach, &cxusb_aver_lgdt3303_config,
  749. &adap->dev->i2c_adap);
  750. if (adap->fe != NULL)
  751. return 0;
  752. return -EIO;
  753. }
  754. static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap)
  755. {
  756. /* used in both lgz201 and th7579 */
  757. if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
  758. err("set interface failed");
  759. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  760. if ((adap->fe = dvb_attach(mt352_attach, &cxusb_mt352_config,
  761. &adap->dev->i2c_adap)) != NULL)
  762. return 0;
  763. return -EIO;
  764. }
  765. static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
  766. {
  767. if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
  768. err("set interface failed");
  769. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  770. if (((adap->fe = dvb_attach(mt352_attach, &cxusb_dee1601_config,
  771. &adap->dev->i2c_adap)) != NULL) ||
  772. ((adap->fe = dvb_attach(zl10353_attach,
  773. &cxusb_zl10353_dee1601_config,
  774. &adap->dev->i2c_adap)) != NULL))
  775. return 0;
  776. return -EIO;
  777. }
  778. static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
  779. {
  780. u8 ircode[4];
  781. int i;
  782. struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
  783. .buf = ircode, .len = 4 };
  784. if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
  785. err("set interface failed");
  786. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  787. /* reset the tuner and demodulator */
  788. cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
  789. cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
  790. cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
  791. if ((adap->fe = dvb_attach(zl10353_attach,
  792. &cxusb_zl10353_xc3028_config_no_i2c_gate,
  793. &adap->dev->i2c_adap)) == NULL)
  794. return -EIO;
  795. /* try to determine if there is no IR decoder on the I2C bus */
  796. for (i = 0; adap->dev->props.rc.legacy.rc_map_table != NULL && i < 5; i++) {
  797. msleep(20);
  798. if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1)
  799. goto no_IR;
  800. if (ircode[0] == 0 && ircode[1] == 0)
  801. continue;
  802. if (ircode[2] + ircode[3] != 0xff) {
  803. no_IR:
  804. adap->dev->props.rc.legacy.rc_map_table = NULL;
  805. info("No IR receiver detected on this device.");
  806. break;
  807. }
  808. }
  809. return 0;
  810. }
  811. static struct dibx000_agc_config dib7070_agc_config = {
  812. .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
  813. /*
  814. * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
  815. * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
  816. * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
  817. */
  818. .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
  819. (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
  820. .inv_gain = 600,
  821. .time_stabiliz = 10,
  822. .alpha_level = 0,
  823. .thlock = 118,
  824. .wbd_inv = 0,
  825. .wbd_ref = 3530,
  826. .wbd_sel = 1,
  827. .wbd_alpha = 5,
  828. .agc1_max = 65535,
  829. .agc1_min = 0,
  830. .agc2_max = 65535,
  831. .agc2_min = 0,
  832. .agc1_pt1 = 0,
  833. .agc1_pt2 = 40,
  834. .agc1_pt3 = 183,
  835. .agc1_slope1 = 206,
  836. .agc1_slope2 = 255,
  837. .agc2_pt1 = 72,
  838. .agc2_pt2 = 152,
  839. .agc2_slope1 = 88,
  840. .agc2_slope2 = 90,
  841. .alpha_mant = 17,
  842. .alpha_exp = 27,
  843. .beta_mant = 23,
  844. .beta_exp = 51,
  845. .perform_agc_softsplit = 0,
  846. };
  847. static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
  848. .internal = 60000,
  849. .sampling = 15000,
  850. .pll_prediv = 1,
  851. .pll_ratio = 20,
  852. .pll_range = 3,
  853. .pll_reset = 1,
  854. .pll_bypass = 0,
  855. .enable_refdiv = 0,
  856. .bypclk_div = 0,
  857. .IO_CLK_en_core = 1,
  858. .ADClkSrc = 1,
  859. .modulo = 2,
  860. /* refsel, sel, freq_15k */
  861. .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
  862. .ifreq = (0 << 25) | 0,
  863. .timf = 20452225,
  864. .xtal_hz = 12000000,
  865. };
  866. static struct dib7000p_config cxusb_dualdig4_rev2_config = {
  867. .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
  868. .output_mpeg2_in_188_bytes = 1,
  869. .agc_config_count = 1,
  870. .agc = &dib7070_agc_config,
  871. .bw = &dib7070_bw_config_12_mhz,
  872. .tuner_is_baseband = 1,
  873. .spur_protect = 1,
  874. .gpio_dir = 0xfcef,
  875. .gpio_val = 0x0110,
  876. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  877. .hostbus_diversity = 1,
  878. };
  879. static int cxusb_dualdig4_rev2_frontend_attach(struct dvb_usb_adapter *adap)
  880. {
  881. if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
  882. err("set interface failed");
  883. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  884. cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
  885. if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
  886. &cxusb_dualdig4_rev2_config) < 0) {
  887. printk(KERN_WARNING "Unable to enumerate dib7000p\n");
  888. return -ENODEV;
  889. }
  890. adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
  891. &cxusb_dualdig4_rev2_config);
  892. if (adap->fe == NULL)
  893. return -EIO;
  894. return 0;
  895. }
  896. static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
  897. {
  898. return dib7000p_set_gpio(fe, 8, 0, !onoff);
  899. }
  900. static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
  901. {
  902. return 0;
  903. }
  904. static struct dib0070_config dib7070p_dib0070_config = {
  905. .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
  906. .reset = dib7070_tuner_reset,
  907. .sleep = dib7070_tuner_sleep,
  908. .clock_khz = 12000,
  909. };
  910. struct dib0700_adapter_state {
  911. int (*set_param_save) (struct dvb_frontend *,
  912. struct dvb_frontend_parameters *);
  913. };
  914. static int dib7070_set_param_override(struct dvb_frontend *fe,
  915. struct dvb_frontend_parameters *fep)
  916. {
  917. struct dvb_usb_adapter *adap = fe->dvb->priv;
  918. struct dib0700_adapter_state *state = adap->priv;
  919. u16 offset;
  920. u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
  921. switch (band) {
  922. case BAND_VHF: offset = 950; break;
  923. default:
  924. case BAND_UHF: offset = 550; break;
  925. }
  926. dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
  927. return state->set_param_save(fe, fep);
  928. }
  929. static int cxusb_dualdig4_rev2_tuner_attach(struct dvb_usb_adapter *adap)
  930. {
  931. struct dib0700_adapter_state *st = adap->priv;
  932. struct i2c_adapter *tun_i2c =
  933. dib7000p_get_i2c_master(adap->fe,
  934. DIBX000_I2C_INTERFACE_TUNER, 1);
  935. if (dvb_attach(dib0070_attach, adap->fe, tun_i2c,
  936. &dib7070p_dib0070_config) == NULL)
  937. return -ENODEV;
  938. st->set_param_save = adap->fe->ops.tuner_ops.set_params;
  939. adap->fe->ops.tuner_ops.set_params = dib7070_set_param_override;
  940. return 0;
  941. }
  942. static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap)
  943. {
  944. if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
  945. err("set interface failed");
  946. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  947. /* reset the tuner and demodulator */
  948. cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
  949. cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
  950. cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
  951. if ((adap->fe = dvb_attach(zl10353_attach,
  952. &cxusb_zl10353_xc3028_config,
  953. &adap->dev->i2c_adap)) != NULL)
  954. return 0;
  955. if ((adap->fe = dvb_attach(mt352_attach,
  956. &cxusb_mt352_xc3028_config,
  957. &adap->dev->i2c_adap)) != NULL)
  958. return 0;
  959. return -EIO;
  960. }
  961. static struct lgs8gxx_config d680_lgs8gl5_cfg = {
  962. .prod = LGS8GXX_PROD_LGS8GL5,
  963. .demod_address = 0x19,
  964. .serial_ts = 0,
  965. .ts_clk_pol = 0,
  966. .ts_clk_gated = 1,
  967. .if_clk_freq = 30400, /* 30.4 MHz */
  968. .if_freq = 5725, /* 5.725 MHz */
  969. .if_neg_center = 0,
  970. .ext_adc = 0,
  971. .adc_signed = 0,
  972. .if_neg_edge = 0,
  973. };
  974. static int cxusb_d680_dmb_frontend_attach(struct dvb_usb_adapter *adap)
  975. {
  976. struct dvb_usb_device *d = adap->dev;
  977. int n;
  978. /* Select required USB configuration */
  979. if (usb_set_interface(d->udev, 0, 0) < 0)
  980. err("set interface failed");
  981. /* Unblock all USB pipes */
  982. usb_clear_halt(d->udev,
  983. usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
  984. usb_clear_halt(d->udev,
  985. usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
  986. usb_clear_halt(d->udev,
  987. usb_rcvbulkpipe(d->udev, d->props.adapter[0].stream.endpoint));
  988. /* Drain USB pipes to avoid hang after reboot */
  989. for (n = 0; n < 5; n++) {
  990. cxusb_d680_dmb_drain_message(d);
  991. cxusb_d680_dmb_drain_video(d);
  992. msleep(200);
  993. }
  994. /* Reset the tuner */
  995. if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {
  996. err("clear tuner gpio failed");
  997. return -EIO;
  998. }
  999. msleep(100);
  1000. if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {
  1001. err("set tuner gpio failed");
  1002. return -EIO;
  1003. }
  1004. msleep(100);
  1005. /* Attach frontend */
  1006. adap->fe = dvb_attach(lgs8gxx_attach, &d680_lgs8gl5_cfg, &d->i2c_adap);
  1007. if (adap->fe == NULL)
  1008. return -EIO;
  1009. return 0;
  1010. }
  1011. static struct atbm8830_config mygica_d689_atbm8830_cfg = {
  1012. .prod = ATBM8830_PROD_8830,
  1013. .demod_address = 0x40,
  1014. .serial_ts = 0,
  1015. .ts_sampling_edge = 1,
  1016. .ts_clk_gated = 0,
  1017. .osc_clk_freq = 30400, /* in kHz */
  1018. .if_freq = 0, /* zero IF */
  1019. .zif_swap_iq = 1,
  1020. .agc_min = 0x2E,
  1021. .agc_max = 0x90,
  1022. .agc_hold_loop = 0,
  1023. };
  1024. static int cxusb_mygica_d689_frontend_attach(struct dvb_usb_adapter *adap)
  1025. {
  1026. struct dvb_usb_device *d = adap->dev;
  1027. /* Select required USB configuration */
  1028. if (usb_set_interface(d->udev, 0, 0) < 0)
  1029. err("set interface failed");
  1030. /* Unblock all USB pipes */
  1031. usb_clear_halt(d->udev,
  1032. usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
  1033. usb_clear_halt(d->udev,
  1034. usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
  1035. usb_clear_halt(d->udev,
  1036. usb_rcvbulkpipe(d->udev, d->props.adapter[0].stream.endpoint));
  1037. /* Reset the tuner */
  1038. if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {
  1039. err("clear tuner gpio failed");
  1040. return -EIO;
  1041. }
  1042. msleep(100);
  1043. if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {
  1044. err("set tuner gpio failed");
  1045. return -EIO;
  1046. }
  1047. msleep(100);
  1048. /* Attach frontend */
  1049. adap->fe = dvb_attach(atbm8830_attach, &mygica_d689_atbm8830_cfg,
  1050. &d->i2c_adap);
  1051. if (adap->fe == NULL)
  1052. return -EIO;
  1053. return 0;
  1054. }
  1055. /*
  1056. * DViCO has shipped two devices with the same USB ID, but only one of them
  1057. * needs a firmware download. Check the device class details to see if they
  1058. * have non-default values to decide whether the device is actually cold or
  1059. * not, and forget a match if it turns out we selected the wrong device.
  1060. */
  1061. static int bluebird_fx2_identify_state(struct usb_device *udev,
  1062. struct dvb_usb_device_properties *props,
  1063. struct dvb_usb_device_description **desc,
  1064. int *cold)
  1065. {
  1066. int wascold = *cold;
  1067. *cold = udev->descriptor.bDeviceClass == 0xff &&
  1068. udev->descriptor.bDeviceSubClass == 0xff &&
  1069. udev->descriptor.bDeviceProtocol == 0xff;
  1070. if (*cold && !wascold)
  1071. *desc = NULL;
  1072. return 0;
  1073. }
  1074. /*
  1075. * DViCO bluebird firmware needs the "warm" product ID to be patched into the
  1076. * firmware file before download.
  1077. */
  1078. static const int dvico_firmware_id_offsets[] = { 6638, 3204 };
  1079. static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
  1080. const struct firmware *fw)
  1081. {
  1082. int pos;
  1083. for (pos = 0; pos < ARRAY_SIZE(dvico_firmware_id_offsets); pos++) {
  1084. int idoff = dvico_firmware_id_offsets[pos];
  1085. if (fw->size < idoff + 4)
  1086. continue;
  1087. if (fw->data[idoff] == (USB_VID_DVICO & 0xff) &&
  1088. fw->data[idoff + 1] == USB_VID_DVICO >> 8) {
  1089. struct firmware new_fw;
  1090. u8 *new_fw_data = vmalloc(fw->size);
  1091. int ret;
  1092. if (!new_fw_data)
  1093. return -ENOMEM;
  1094. memcpy(new_fw_data, fw->data, fw->size);
  1095. new_fw.size = fw->size;
  1096. new_fw.data = new_fw_data;
  1097. new_fw_data[idoff + 2] =
  1098. le16_to_cpu(udev->descriptor.idProduct) + 1;
  1099. new_fw_data[idoff + 3] =
  1100. le16_to_cpu(udev->descriptor.idProduct) >> 8;
  1101. ret = usb_cypress_load_firmware(udev, &new_fw,
  1102. CYPRESS_FX2);
  1103. vfree(new_fw_data);
  1104. return ret;
  1105. }
  1106. }
  1107. return -EINVAL;
  1108. }
  1109. /* DVB USB Driver stuff */
  1110. static struct dvb_usb_device_properties cxusb_medion_properties;
  1111. static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
  1112. static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;
  1113. static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;
  1114. static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;
  1115. static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties;
  1116. static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties;
  1117. static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties;
  1118. static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties;
  1119. static struct dvb_usb_device_properties cxusb_aver_a868r_properties;
  1120. static struct dvb_usb_device_properties cxusb_d680_dmb_properties;
  1121. static struct dvb_usb_device_properties cxusb_mygica_d689_properties;
  1122. static int cxusb_probe(struct usb_interface *intf,
  1123. const struct usb_device_id *id)
  1124. {
  1125. if (0 == dvb_usb_device_init(intf, &cxusb_medion_properties,
  1126. THIS_MODULE, NULL, adapter_nr) ||
  1127. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties,
  1128. THIS_MODULE, NULL, adapter_nr) ||
  1129. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties,
  1130. THIS_MODULE, NULL, adapter_nr) ||
  1131. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgz201_properties,
  1132. THIS_MODULE, NULL, adapter_nr) ||
  1133. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dtt7579_properties,
  1134. THIS_MODULE, NULL, adapter_nr) ||
  1135. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dualdig4_properties,
  1136. THIS_MODULE, NULL, adapter_nr) ||
  1137. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_nano2_properties,
  1138. THIS_MODULE, NULL, adapter_nr) ||
  1139. 0 == dvb_usb_device_init(intf,
  1140. &cxusb_bluebird_nano2_needsfirmware_properties,
  1141. THIS_MODULE, NULL, adapter_nr) ||
  1142. 0 == dvb_usb_device_init(intf, &cxusb_aver_a868r_properties,
  1143. THIS_MODULE, NULL, adapter_nr) ||
  1144. 0 == dvb_usb_device_init(intf,
  1145. &cxusb_bluebird_dualdig4_rev2_properties,
  1146. THIS_MODULE, NULL, adapter_nr) ||
  1147. 0 == dvb_usb_device_init(intf, &cxusb_d680_dmb_properties,
  1148. THIS_MODULE, NULL, adapter_nr) ||
  1149. 0 == dvb_usb_device_init(intf, &cxusb_mygica_d689_properties,
  1150. THIS_MODULE, NULL, adapter_nr) ||
  1151. 0)
  1152. return 0;
  1153. return -EINVAL;
  1154. }
  1155. static struct usb_device_id cxusb_table [] = {
  1156. { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
  1157. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
  1158. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
  1159. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) },
  1160. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) },
  1161. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
  1162. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
  1163. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
  1164. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
  1165. { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) },
  1166. { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) },
  1167. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) },
  1168. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) },
  1169. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4) },
  1170. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2) },
  1171. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) },
  1172. { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_A868R) },
  1173. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2) },
  1174. { USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB) },
  1175. { USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_D689) },
  1176. {} /* Terminating entry */
  1177. };
  1178. MODULE_DEVICE_TABLE (usb, cxusb_table);
  1179. static struct dvb_usb_device_properties cxusb_medion_properties = {
  1180. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1181. .usb_ctrl = CYPRESS_FX2,
  1182. .size_of_priv = sizeof(struct cxusb_state),
  1183. .num_adapters = 1,
  1184. .adapter = {
  1185. {
  1186. .streaming_ctrl = cxusb_streaming_ctrl,
  1187. .frontend_attach = cxusb_cx22702_frontend_attach,
  1188. .tuner_attach = cxusb_fmd1216me_tuner_attach,
  1189. /* parameter for the MPEG2-data transfer */
  1190. .stream = {
  1191. .type = USB_BULK,
  1192. .count = 5,
  1193. .endpoint = 0x02,
  1194. .u = {
  1195. .bulk = {
  1196. .buffersize = 8192,
  1197. }
  1198. }
  1199. },
  1200. },
  1201. },
  1202. .power_ctrl = cxusb_power_ctrl,
  1203. .i2c_algo = &cxusb_i2c_algo,
  1204. .generic_bulk_ctrl_endpoint = 0x01,
  1205. .num_device_descs = 1,
  1206. .devices = {
  1207. { "Medion MD95700 (MDUSBTV-HYBRID)",
  1208. { NULL },
  1209. { &cxusb_table[0], NULL },
  1210. },
  1211. }
  1212. };
  1213. static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
  1214. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1215. .usb_ctrl = DEVICE_SPECIFIC,
  1216. .firmware = "dvb-usb-bluebird-01.fw",
  1217. .download_firmware = bluebird_patch_dvico_firmware_download,
  1218. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  1219. use usb alt setting 7 for EP2 transfer (atsc) */
  1220. .size_of_priv = sizeof(struct cxusb_state),
  1221. .num_adapters = 1,
  1222. .adapter = {
  1223. {
  1224. .streaming_ctrl = cxusb_streaming_ctrl,
  1225. .frontend_attach = cxusb_lgdt3303_frontend_attach,
  1226. .tuner_attach = cxusb_lgh064f_tuner_attach,
  1227. /* parameter for the MPEG2-data transfer */
  1228. .stream = {
  1229. .type = USB_BULK,
  1230. .count = 5,
  1231. .endpoint = 0x02,
  1232. .u = {
  1233. .bulk = {
  1234. .buffersize = 8192,
  1235. }
  1236. }
  1237. },
  1238. },
  1239. },
  1240. .power_ctrl = cxusb_bluebird_power_ctrl,
  1241. .i2c_algo = &cxusb_i2c_algo,
  1242. .rc.legacy = {
  1243. .rc_interval = 100,
  1244. .rc_map_table = rc_map_dvico_portable_table,
  1245. .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table),
  1246. .rc_query = cxusb_rc_query,
  1247. },
  1248. .generic_bulk_ctrl_endpoint = 0x01,
  1249. .num_device_descs = 1,
  1250. .devices = {
  1251. { "DViCO FusionHDTV5 USB Gold",
  1252. { &cxusb_table[1], NULL },
  1253. { &cxusb_table[2], NULL },
  1254. },
  1255. }
  1256. };
  1257. static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
  1258. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1259. .usb_ctrl = DEVICE_SPECIFIC,
  1260. .firmware = "dvb-usb-bluebird-01.fw",
  1261. .download_firmware = bluebird_patch_dvico_firmware_download,
  1262. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  1263. use usb alt setting 7 for EP2 transfer (atsc) */
  1264. .size_of_priv = sizeof(struct cxusb_state),
  1265. .num_adapters = 1,
  1266. .adapter = {
  1267. {
  1268. .streaming_ctrl = cxusb_streaming_ctrl,
  1269. .frontend_attach = cxusb_dee1601_frontend_attach,
  1270. .tuner_attach = cxusb_dee1601_tuner_attach,
  1271. /* parameter for the MPEG2-data transfer */
  1272. .stream = {
  1273. .type = USB_BULK,
  1274. .count = 5,
  1275. .endpoint = 0x04,
  1276. .u = {
  1277. .bulk = {
  1278. .buffersize = 8192,
  1279. }
  1280. }
  1281. },
  1282. },
  1283. },
  1284. .power_ctrl = cxusb_bluebird_power_ctrl,
  1285. .i2c_algo = &cxusb_i2c_algo,
  1286. .rc.legacy = {
  1287. .rc_interval = 150,
  1288. .rc_map_table = rc_map_dvico_mce_table,
  1289. .rc_map_size = ARRAY_SIZE(rc_map_dvico_mce_table),
  1290. .rc_query = cxusb_rc_query,
  1291. },
  1292. .generic_bulk_ctrl_endpoint = 0x01,
  1293. .num_device_descs = 3,
  1294. .devices = {
  1295. { "DViCO FusionHDTV DVB-T Dual USB",
  1296. { &cxusb_table[3], NULL },
  1297. { &cxusb_table[4], NULL },
  1298. },
  1299. { "DigitalNow DVB-T Dual USB",
  1300. { &cxusb_table[9], NULL },
  1301. { &cxusb_table[10], NULL },
  1302. },
  1303. { "DViCO FusionHDTV DVB-T Dual Digital 2",
  1304. { &cxusb_table[11], NULL },
  1305. { &cxusb_table[12], NULL },
  1306. },
  1307. }
  1308. };
  1309. static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
  1310. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1311. .usb_ctrl = DEVICE_SPECIFIC,
  1312. .firmware = "dvb-usb-bluebird-01.fw",
  1313. .download_firmware = bluebird_patch_dvico_firmware_download,
  1314. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  1315. use usb alt setting 7 for EP2 transfer (atsc) */
  1316. .size_of_priv = sizeof(struct cxusb_state),
  1317. .num_adapters = 2,
  1318. .adapter = {
  1319. {
  1320. .streaming_ctrl = cxusb_streaming_ctrl,
  1321. .frontend_attach = cxusb_mt352_frontend_attach,
  1322. .tuner_attach = cxusb_lgz201_tuner_attach,
  1323. /* parameter for the MPEG2-data transfer */
  1324. .stream = {
  1325. .type = USB_BULK,
  1326. .count = 5,
  1327. .endpoint = 0x04,
  1328. .u = {
  1329. .bulk = {
  1330. .buffersize = 8192,
  1331. }
  1332. }
  1333. },
  1334. },
  1335. },
  1336. .power_ctrl = cxusb_bluebird_power_ctrl,
  1337. .i2c_algo = &cxusb_i2c_algo,
  1338. .rc.legacy = {
  1339. .rc_interval = 100,
  1340. .rc_map_table = rc_map_dvico_portable_table,
  1341. .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table),
  1342. .rc_query = cxusb_rc_query,
  1343. },
  1344. .generic_bulk_ctrl_endpoint = 0x01,
  1345. .num_device_descs = 1,
  1346. .devices = {
  1347. { "DViCO FusionHDTV DVB-T USB (LGZ201)",
  1348. { &cxusb_table[5], NULL },
  1349. { &cxusb_table[6], NULL },
  1350. },
  1351. }
  1352. };
  1353. static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
  1354. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1355. .usb_ctrl = DEVICE_SPECIFIC,
  1356. .firmware = "dvb-usb-bluebird-01.fw",
  1357. .download_firmware = bluebird_patch_dvico_firmware_download,
  1358. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  1359. use usb alt setting 7 for EP2 transfer (atsc) */
  1360. .size_of_priv = sizeof(struct cxusb_state),
  1361. .num_adapters = 1,
  1362. .adapter = {
  1363. {
  1364. .streaming_ctrl = cxusb_streaming_ctrl,
  1365. .frontend_attach = cxusb_mt352_frontend_attach,
  1366. .tuner_attach = cxusb_dtt7579_tuner_attach,
  1367. /* parameter for the MPEG2-data transfer */
  1368. .stream = {
  1369. .type = USB_BULK,
  1370. .count = 5,
  1371. .endpoint = 0x04,
  1372. .u = {
  1373. .bulk = {
  1374. .buffersize = 8192,
  1375. }
  1376. }
  1377. },
  1378. },
  1379. },
  1380. .power_ctrl = cxusb_bluebird_power_ctrl,
  1381. .i2c_algo = &cxusb_i2c_algo,
  1382. .rc.legacy = {
  1383. .rc_interval = 100,
  1384. .rc_map_table = rc_map_dvico_portable_table,
  1385. .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table),
  1386. .rc_query = cxusb_rc_query,
  1387. },
  1388. .generic_bulk_ctrl_endpoint = 0x01,
  1389. .num_device_descs = 1,
  1390. .devices = {
  1391. { "DViCO FusionHDTV DVB-T USB (TH7579)",
  1392. { &cxusb_table[7], NULL },
  1393. { &cxusb_table[8], NULL },
  1394. },
  1395. }
  1396. };
  1397. static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
  1398. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1399. .usb_ctrl = CYPRESS_FX2,
  1400. .size_of_priv = sizeof(struct cxusb_state),
  1401. .num_adapters = 1,
  1402. .adapter = {
  1403. {
  1404. .streaming_ctrl = cxusb_streaming_ctrl,
  1405. .frontend_attach = cxusb_dualdig4_frontend_attach,
  1406. .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
  1407. /* parameter for the MPEG2-data transfer */
  1408. .stream = {
  1409. .type = USB_BULK,
  1410. .count = 5,
  1411. .endpoint = 0x02,
  1412. .u = {
  1413. .bulk = {
  1414. .buffersize = 8192,
  1415. }
  1416. }
  1417. },
  1418. },
  1419. },
  1420. .power_ctrl = cxusb_power_ctrl,
  1421. .i2c_algo = &cxusb_i2c_algo,
  1422. .generic_bulk_ctrl_endpoint = 0x01,
  1423. .rc.legacy = {
  1424. .rc_interval = 100,
  1425. .rc_map_table = rc_map_dvico_mce_table,
  1426. .rc_map_size = ARRAY_SIZE(rc_map_dvico_mce_table),
  1427. .rc_query = cxusb_bluebird2_rc_query,
  1428. },
  1429. .num_device_descs = 1,
  1430. .devices = {
  1431. { "DViCO FusionHDTV DVB-T Dual Digital 4",
  1432. { NULL },
  1433. { &cxusb_table[13], NULL },
  1434. },
  1435. }
  1436. };
  1437. static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
  1438. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1439. .usb_ctrl = CYPRESS_FX2,
  1440. .identify_state = bluebird_fx2_identify_state,
  1441. .size_of_priv = sizeof(struct cxusb_state),
  1442. .num_adapters = 1,
  1443. .adapter = {
  1444. {
  1445. .streaming_ctrl = cxusb_streaming_ctrl,
  1446. .frontend_attach = cxusb_nano2_frontend_attach,
  1447. .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
  1448. /* parameter for the MPEG2-data transfer */
  1449. .stream = {
  1450. .type = USB_BULK,
  1451. .count = 5,
  1452. .endpoint = 0x02,
  1453. .u = {
  1454. .bulk = {
  1455. .buffersize = 8192,
  1456. }
  1457. }
  1458. },
  1459. },
  1460. },
  1461. .power_ctrl = cxusb_nano2_power_ctrl,
  1462. .i2c_algo = &cxusb_i2c_algo,
  1463. .generic_bulk_ctrl_endpoint = 0x01,
  1464. .rc.legacy = {
  1465. .rc_interval = 100,
  1466. .rc_map_table = rc_map_dvico_portable_table,
  1467. .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table),
  1468. .rc_query = cxusb_bluebird2_rc_query,
  1469. },
  1470. .num_device_descs = 1,
  1471. .devices = {
  1472. { "DViCO FusionHDTV DVB-T NANO2",
  1473. { NULL },
  1474. { &cxusb_table[14], NULL },
  1475. },
  1476. }
  1477. };
  1478. static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties = {
  1479. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1480. .usb_ctrl = DEVICE_SPECIFIC,
  1481. .firmware = "dvb-usb-bluebird-02.fw",
  1482. .download_firmware = bluebird_patch_dvico_firmware_download,
  1483. .identify_state = bluebird_fx2_identify_state,
  1484. .size_of_priv = sizeof(struct cxusb_state),
  1485. .num_adapters = 1,
  1486. .adapter = {
  1487. {
  1488. .streaming_ctrl = cxusb_streaming_ctrl,
  1489. .frontend_attach = cxusb_nano2_frontend_attach,
  1490. .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
  1491. /* parameter for the MPEG2-data transfer */
  1492. .stream = {
  1493. .type = USB_BULK,
  1494. .count = 5,
  1495. .endpoint = 0x02,
  1496. .u = {
  1497. .bulk = {
  1498. .buffersize = 8192,
  1499. }
  1500. }
  1501. },
  1502. },
  1503. },
  1504. .power_ctrl = cxusb_nano2_power_ctrl,
  1505. .i2c_algo = &cxusb_i2c_algo,
  1506. .generic_bulk_ctrl_endpoint = 0x01,
  1507. .rc.legacy = {
  1508. .rc_interval = 100,
  1509. .rc_map_table = rc_map_dvico_portable_table,
  1510. .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table),
  1511. .rc_query = cxusb_rc_query,
  1512. },
  1513. .num_device_descs = 1,
  1514. .devices = {
  1515. { "DViCO FusionHDTV DVB-T NANO2 w/o firmware",
  1516. { &cxusb_table[14], NULL },
  1517. { &cxusb_table[15], NULL },
  1518. },
  1519. }
  1520. };
  1521. static struct dvb_usb_device_properties cxusb_aver_a868r_properties = {
  1522. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1523. .usb_ctrl = CYPRESS_FX2,
  1524. .size_of_priv = sizeof(struct cxusb_state),
  1525. .num_adapters = 1,
  1526. .adapter = {
  1527. {
  1528. .streaming_ctrl = cxusb_aver_streaming_ctrl,
  1529. .frontend_attach = cxusb_aver_lgdt3303_frontend_attach,
  1530. .tuner_attach = cxusb_mxl5003s_tuner_attach,
  1531. /* parameter for the MPEG2-data transfer */
  1532. .stream = {
  1533. .type = USB_BULK,
  1534. .count = 5,
  1535. .endpoint = 0x04,
  1536. .u = {
  1537. .bulk = {
  1538. .buffersize = 8192,
  1539. }
  1540. }
  1541. },
  1542. },
  1543. },
  1544. .power_ctrl = cxusb_aver_power_ctrl,
  1545. .i2c_algo = &cxusb_i2c_algo,
  1546. .generic_bulk_ctrl_endpoint = 0x01,
  1547. .num_device_descs = 1,
  1548. .devices = {
  1549. { "AVerMedia AVerTVHD Volar (A868R)",
  1550. { NULL },
  1551. { &cxusb_table[16], NULL },
  1552. },
  1553. }
  1554. };
  1555. static
  1556. struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties = {
  1557. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1558. .usb_ctrl = CYPRESS_FX2,
  1559. .size_of_priv = sizeof(struct cxusb_state),
  1560. .num_adapters = 1,
  1561. .adapter = {
  1562. {
  1563. .streaming_ctrl = cxusb_streaming_ctrl,
  1564. .frontend_attach = cxusb_dualdig4_rev2_frontend_attach,
  1565. .tuner_attach = cxusb_dualdig4_rev2_tuner_attach,
  1566. .size_of_priv = sizeof(struct dib0700_adapter_state),
  1567. /* parameter for the MPEG2-data transfer */
  1568. .stream = {
  1569. .type = USB_BULK,
  1570. .count = 7,
  1571. .endpoint = 0x02,
  1572. .u = {
  1573. .bulk = {
  1574. .buffersize = 4096,
  1575. }
  1576. }
  1577. },
  1578. },
  1579. },
  1580. .power_ctrl = cxusb_bluebird_power_ctrl,
  1581. .i2c_algo = &cxusb_i2c_algo,
  1582. .generic_bulk_ctrl_endpoint = 0x01,
  1583. .rc.legacy = {
  1584. .rc_interval = 100,
  1585. .rc_map_table = rc_map_dvico_mce_table,
  1586. .rc_map_size = ARRAY_SIZE(rc_map_dvico_mce_table),
  1587. .rc_query = cxusb_rc_query,
  1588. },
  1589. .num_device_descs = 1,
  1590. .devices = {
  1591. { "DViCO FusionHDTV DVB-T Dual Digital 4 (rev 2)",
  1592. { NULL },
  1593. { &cxusb_table[17], NULL },
  1594. },
  1595. }
  1596. };
  1597. static struct dvb_usb_device_properties cxusb_d680_dmb_properties = {
  1598. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1599. .usb_ctrl = CYPRESS_FX2,
  1600. .size_of_priv = sizeof(struct cxusb_state),
  1601. .num_adapters = 1,
  1602. .adapter = {
  1603. {
  1604. .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl,
  1605. .frontend_attach = cxusb_d680_dmb_frontend_attach,
  1606. .tuner_attach = cxusb_d680_dmb_tuner_attach,
  1607. /* parameter for the MPEG2-data transfer */
  1608. .stream = {
  1609. .type = USB_BULK,
  1610. .count = 5,
  1611. .endpoint = 0x02,
  1612. .u = {
  1613. .bulk = {
  1614. .buffersize = 8192,
  1615. }
  1616. }
  1617. },
  1618. },
  1619. },
  1620. .power_ctrl = cxusb_d680_dmb_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_d680_dmb_table,
  1626. .rc_map_size = ARRAY_SIZE(rc_map_d680_dmb_table),
  1627. .rc_query = cxusb_d680_dmb_rc_query,
  1628. },
  1629. .num_device_descs = 1,
  1630. .devices = {
  1631. {
  1632. "Conexant DMB-TH Stick",
  1633. { NULL },
  1634. { &cxusb_table[18], NULL },
  1635. },
  1636. }
  1637. };
  1638. static struct dvb_usb_device_properties cxusb_mygica_d689_properties = {
  1639. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1640. .usb_ctrl = CYPRESS_FX2,
  1641. .size_of_priv = sizeof(struct cxusb_state),
  1642. .num_adapters = 1,
  1643. .adapter = {
  1644. {
  1645. .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl,
  1646. .frontend_attach = cxusb_mygica_d689_frontend_attach,
  1647. .tuner_attach = cxusb_mygica_d689_tuner_attach,
  1648. /* parameter for the MPEG2-data transfer */
  1649. .stream = {
  1650. .type = USB_BULK,
  1651. .count = 5,
  1652. .endpoint = 0x02,
  1653. .u = {
  1654. .bulk = {
  1655. .buffersize = 8192,
  1656. }
  1657. }
  1658. },
  1659. },
  1660. },
  1661. .power_ctrl = cxusb_d680_dmb_power_ctrl,
  1662. .i2c_algo = &cxusb_i2c_algo,
  1663. .generic_bulk_ctrl_endpoint = 0x01,
  1664. .rc.legacy = {
  1665. .rc_interval = 100,
  1666. .rc_map_table = rc_map_d680_dmb_table,
  1667. .rc_map_size = ARRAY_SIZE(rc_map_d680_dmb_table),
  1668. .rc_query = cxusb_d680_dmb_rc_query,
  1669. },
  1670. .num_device_descs = 1,
  1671. .devices = {
  1672. {
  1673. "Mygica D689 DMB-TH",
  1674. { NULL },
  1675. { &cxusb_table[19], NULL },
  1676. },
  1677. }
  1678. };
  1679. static struct usb_driver cxusb_driver = {
  1680. .name = "dvb_usb_cxusb",
  1681. .probe = cxusb_probe,
  1682. .disconnect = dvb_usb_device_exit,
  1683. .id_table = cxusb_table,
  1684. };
  1685. /* module stuff */
  1686. static int __init cxusb_module_init(void)
  1687. {
  1688. int result;
  1689. if ((result = usb_register(&cxusb_driver))) {
  1690. err("usb_register failed. Error number %d",result);
  1691. return result;
  1692. }
  1693. return 0;
  1694. }
  1695. static void __exit cxusb_module_exit(void)
  1696. {
  1697. /* deregister this driver from the USB subsystem */
  1698. usb_deregister(&cxusb_driver);
  1699. }
  1700. module_init (cxusb_module_init);
  1701. module_exit (cxusb_module_exit);
  1702. MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
  1703. MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
  1704. MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
  1705. MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
  1706. MODULE_VERSION("1.0-alpha");
  1707. MODULE_LICENSE("GPL");