cxusb.c 52 KB

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