cxusb.c 57 KB

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