cxusb.c 55 KB

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