cxusb.c 60 KB

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