cxusb.c 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563
  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 "cxusb.h"
  29. #include "cx22702.h"
  30. #include "lgdt330x.h"
  31. #include "mt352.h"
  32. #include "mt352_priv.h"
  33. #include "zl10353.h"
  34. #include "tuner-xc2028.h"
  35. #include "tuner-simple.h"
  36. #include "mxl5005s.h"
  37. #include "dib7000p.h"
  38. #include "dib0070.h"
  39. /* debug */
  40. static int dvb_usb_cxusb_debug;
  41. module_param_named(debug, dvb_usb_cxusb_debug, int, 0644);
  42. MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
  43. DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
  44. #define deb_info(args...) dprintk(dvb_usb_cxusb_debug, 0x03, args)
  45. #define deb_i2c(args...) dprintk(dvb_usb_cxusb_debug, 0x02, args)
  46. static int cxusb_ctrl_msg(struct dvb_usb_device *d,
  47. u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen)
  48. {
  49. int wo = (rbuf == NULL || rlen == 0); /* write-only */
  50. u8 sndbuf[1+wlen];
  51. memset(sndbuf, 0, 1+wlen);
  52. sndbuf[0] = cmd;
  53. memcpy(&sndbuf[1], wbuf, wlen);
  54. if (wo)
  55. return dvb_usb_generic_write(d, sndbuf, 1+wlen);
  56. else
  57. return dvb_usb_generic_rw(d, sndbuf, 1+wlen, rbuf, rlen, 0);
  58. }
  59. /* GPIO */
  60. static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)
  61. {
  62. struct cxusb_state *st = d->priv;
  63. u8 o[2], i;
  64. if (st->gpio_write_state[GPIO_TUNER] == onoff)
  65. return;
  66. o[0] = GPIO_TUNER;
  67. o[1] = onoff;
  68. cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
  69. if (i != 0x01)
  70. deb_info("gpio_write failed.\n");
  71. st->gpio_write_state[GPIO_TUNER] = onoff;
  72. }
  73. static int cxusb_bluebird_gpio_rw(struct dvb_usb_device *d, u8 changemask,
  74. u8 newval)
  75. {
  76. u8 o[2], gpio_state;
  77. int rc;
  78. o[0] = 0xff & ~changemask; /* mask of bits to keep */
  79. o[1] = newval & changemask; /* new values for bits */
  80. rc = cxusb_ctrl_msg(d, CMD_BLUEBIRD_GPIO_RW, o, 2, &gpio_state, 1);
  81. if (rc < 0 || (gpio_state & changemask) != (newval & changemask))
  82. deb_info("bluebird_gpio_write failed.\n");
  83. return rc < 0 ? rc : gpio_state;
  84. }
  85. static void cxusb_bluebird_gpio_pulse(struct dvb_usb_device *d, u8 pin, int low)
  86. {
  87. cxusb_bluebird_gpio_rw(d, pin, low ? 0 : pin);
  88. msleep(5);
  89. cxusb_bluebird_gpio_rw(d, pin, low ? pin : 0);
  90. }
  91. static void cxusb_nano2_led(struct dvb_usb_device *d, int onoff)
  92. {
  93. cxusb_bluebird_gpio_rw(d, 0x40, onoff ? 0 : 0x40);
  94. }
  95. /* I2C */
  96. static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
  97. int num)
  98. {
  99. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  100. int i;
  101. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  102. return -EAGAIN;
  103. for (i = 0; i < num; i++) {
  104. if (d->udev->descriptor.idVendor == USB_VID_MEDION)
  105. switch (msg[i].addr) {
  106. case 0x63:
  107. cxusb_gpio_tuner(d, 0);
  108. break;
  109. default:
  110. cxusb_gpio_tuner(d, 1);
  111. break;
  112. }
  113. if (msg[i].flags & I2C_M_RD) {
  114. /* read only */
  115. u8 obuf[3], ibuf[1+msg[i].len];
  116. obuf[0] = 0;
  117. obuf[1] = msg[i].len;
  118. obuf[2] = msg[i].addr;
  119. if (cxusb_ctrl_msg(d, CMD_I2C_READ,
  120. obuf, 3,
  121. ibuf, 1+msg[i].len) < 0) {
  122. warn("i2c read failed");
  123. break;
  124. }
  125. memcpy(msg[i].buf, &ibuf[1], msg[i].len);
  126. } else if (i+1 < num && (msg[i+1].flags & I2C_M_RD) &&
  127. msg[i].addr == msg[i+1].addr) {
  128. /* write to then read from same address */
  129. u8 obuf[3+msg[i].len], ibuf[1+msg[i+1].len];
  130. obuf[0] = msg[i].len;
  131. obuf[1] = msg[i+1].len;
  132. obuf[2] = msg[i].addr;
  133. memcpy(&obuf[3], msg[i].buf, msg[i].len);
  134. if (cxusb_ctrl_msg(d, CMD_I2C_READ,
  135. obuf, 3+msg[i].len,
  136. ibuf, 1+msg[i+1].len) < 0)
  137. break;
  138. if (ibuf[0] != 0x08)
  139. deb_i2c("i2c read may have failed\n");
  140. memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len);
  141. i++;
  142. } else {
  143. /* write only */
  144. u8 obuf[2+msg[i].len], ibuf;
  145. obuf[0] = msg[i].addr;
  146. obuf[1] = msg[i].len;
  147. memcpy(&obuf[2], msg[i].buf, msg[i].len);
  148. if (cxusb_ctrl_msg(d, CMD_I2C_WRITE, obuf,
  149. 2+msg[i].len, &ibuf,1) < 0)
  150. break;
  151. if (ibuf != 0x08)
  152. deb_i2c("i2c write may have failed\n");
  153. }
  154. }
  155. mutex_unlock(&d->i2c_mutex);
  156. return i == num ? num : -EREMOTEIO;
  157. }
  158. static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
  159. {
  160. return I2C_FUNC_I2C;
  161. }
  162. static struct i2c_algorithm cxusb_i2c_algo = {
  163. .master_xfer = cxusb_i2c_xfer,
  164. .functionality = cxusb_i2c_func,
  165. };
  166. static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff)
  167. {
  168. u8 b = 0;
  169. if (onoff)
  170. return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
  171. else
  172. return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0);
  173. }
  174. static int cxusb_aver_power_ctrl(struct dvb_usb_device *d, int onoff)
  175. {
  176. int ret;
  177. if (!onoff)
  178. return cxusb_ctrl_msg(d, CMD_POWER_OFF, NULL, 0, NULL, 0);
  179. if (d->state == DVB_USB_STATE_INIT &&
  180. usb_set_interface(d->udev, 0, 0) < 0)
  181. err("set interface failed");
  182. do {} while (!(ret = cxusb_ctrl_msg(d, CMD_POWER_ON, NULL, 0, NULL, 0)) &&
  183. !(ret = cxusb_ctrl_msg(d, 0x15, NULL, 0, NULL, 0)) &&
  184. !(ret = cxusb_ctrl_msg(d, 0x17, NULL, 0, NULL, 0)) && 0);
  185. if (!ret) {
  186. /* FIXME: We don't know why, but we need to configure the
  187. * lgdt3303 with the register settings below on resume */
  188. int i;
  189. u8 buf, bufs[] = {
  190. 0x0e, 0x2, 0x00, 0x7f,
  191. 0x0e, 0x2, 0x02, 0xfe,
  192. 0x0e, 0x2, 0x02, 0x01,
  193. 0x0e, 0x2, 0x00, 0x03,
  194. 0x0e, 0x2, 0x0d, 0x40,
  195. 0x0e, 0x2, 0x0e, 0x87,
  196. 0x0e, 0x2, 0x0f, 0x8e,
  197. 0x0e, 0x2, 0x10, 0x01,
  198. 0x0e, 0x2, 0x14, 0xd7,
  199. 0x0e, 0x2, 0x47, 0x88,
  200. };
  201. msleep(20);
  202. for (i = 0; i < sizeof(bufs)/sizeof(u8); i += 4/sizeof(u8)) {
  203. ret = cxusb_ctrl_msg(d, CMD_I2C_WRITE,
  204. bufs+i, 4, &buf, 1);
  205. if (ret)
  206. break;
  207. if (buf != 0x8)
  208. return -EREMOTEIO;
  209. }
  210. }
  211. return ret;
  212. }
  213. static int cxusb_bluebird_power_ctrl(struct dvb_usb_device *d, int onoff)
  214. {
  215. u8 b = 0;
  216. if (onoff)
  217. return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
  218. else
  219. return 0;
  220. }
  221. static int cxusb_nano2_power_ctrl(struct dvb_usb_device *d, int onoff)
  222. {
  223. int rc = 0;
  224. rc = cxusb_power_ctrl(d, onoff);
  225. if (!onoff)
  226. cxusb_nano2_led(d, 0);
  227. return rc;
  228. }
  229. static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
  230. {
  231. u8 buf[2] = { 0x03, 0x00 };
  232. if (onoff)
  233. cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON, buf, 2, NULL, 0);
  234. else
  235. cxusb_ctrl_msg(adap->dev, CMD_STREAMING_OFF, NULL, 0, NULL, 0);
  236. return 0;
  237. }
  238. static int cxusb_aver_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
  239. {
  240. if (onoff)
  241. cxusb_ctrl_msg(adap->dev, CMD_AVER_STREAM_ON, NULL, 0, NULL, 0);
  242. else
  243. cxusb_ctrl_msg(adap->dev, CMD_AVER_STREAM_OFF,
  244. NULL, 0, NULL, 0);
  245. return 0;
  246. }
  247. static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
  248. {
  249. struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
  250. u8 ircode[4];
  251. int i;
  252. cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
  253. *event = 0;
  254. *state = REMOTE_NO_KEY_PRESSED;
  255. for (i = 0; i < d->props.rc_key_map_size; i++) {
  256. if (keymap[i].custom == ircode[2] &&
  257. keymap[i].data == ircode[3]) {
  258. *event = keymap[i].event;
  259. *state = REMOTE_KEY_PRESSED;
  260. return 0;
  261. }
  262. }
  263. return 0;
  264. }
  265. static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d, u32 *event,
  266. int *state)
  267. {
  268. struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
  269. u8 ircode[4];
  270. int i;
  271. struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
  272. .buf = ircode, .len = 4 };
  273. *event = 0;
  274. *state = REMOTE_NO_KEY_PRESSED;
  275. if (cxusb_i2c_xfer(&d->i2c_adap, &msg, 1) != 1)
  276. return 0;
  277. for (i = 0; i < d->props.rc_key_map_size; i++) {
  278. if (keymap[i].custom == ircode[1] &&
  279. keymap[i].data == ircode[2]) {
  280. *event = keymap[i].event;
  281. *state = REMOTE_KEY_PRESSED;
  282. return 0;
  283. }
  284. }
  285. return 0;
  286. }
  287. static struct dvb_usb_rc_key dvico_mce_rc_keys[] = {
  288. { 0xfe, 0x02, KEY_TV },
  289. { 0xfe, 0x0e, KEY_MP3 },
  290. { 0xfe, 0x1a, KEY_DVD },
  291. { 0xfe, 0x1e, KEY_FAVORITES },
  292. { 0xfe, 0x16, KEY_SETUP },
  293. { 0xfe, 0x46, KEY_POWER2 },
  294. { 0xfe, 0x0a, KEY_EPG },
  295. { 0xfe, 0x49, KEY_BACK },
  296. { 0xfe, 0x4d, KEY_MENU },
  297. { 0xfe, 0x51, KEY_UP },
  298. { 0xfe, 0x5b, KEY_LEFT },
  299. { 0xfe, 0x5f, KEY_RIGHT },
  300. { 0xfe, 0x53, KEY_DOWN },
  301. { 0xfe, 0x5e, KEY_OK },
  302. { 0xfe, 0x59, KEY_INFO },
  303. { 0xfe, 0x55, KEY_TAB },
  304. { 0xfe, 0x0f, KEY_PREVIOUSSONG },/* Replay */
  305. { 0xfe, 0x12, KEY_NEXTSONG }, /* Skip */
  306. { 0xfe, 0x42, KEY_ENTER }, /* Windows/Start */
  307. { 0xfe, 0x15, KEY_VOLUMEUP },
  308. { 0xfe, 0x05, KEY_VOLUMEDOWN },
  309. { 0xfe, 0x11, KEY_CHANNELUP },
  310. { 0xfe, 0x09, KEY_CHANNELDOWN },
  311. { 0xfe, 0x52, KEY_CAMERA },
  312. { 0xfe, 0x5a, KEY_TUNER }, /* Live */
  313. { 0xfe, 0x19, KEY_OPEN },
  314. { 0xfe, 0x0b, KEY_1 },
  315. { 0xfe, 0x17, KEY_2 },
  316. { 0xfe, 0x1b, KEY_3 },
  317. { 0xfe, 0x07, KEY_4 },
  318. { 0xfe, 0x50, KEY_5 },
  319. { 0xfe, 0x54, KEY_6 },
  320. { 0xfe, 0x48, KEY_7 },
  321. { 0xfe, 0x4c, KEY_8 },
  322. { 0xfe, 0x58, KEY_9 },
  323. { 0xfe, 0x13, KEY_ANGLE }, /* Aspect */
  324. { 0xfe, 0x03, KEY_0 },
  325. { 0xfe, 0x1f, KEY_ZOOM },
  326. { 0xfe, 0x43, KEY_REWIND },
  327. { 0xfe, 0x47, KEY_PLAYPAUSE },
  328. { 0xfe, 0x4f, KEY_FASTFORWARD },
  329. { 0xfe, 0x57, KEY_MUTE },
  330. { 0xfe, 0x0d, KEY_STOP },
  331. { 0xfe, 0x01, KEY_RECORD },
  332. { 0xfe, 0x4e, KEY_POWER },
  333. };
  334. static struct dvb_usb_rc_key dvico_portable_rc_keys[] = {
  335. { 0xfc, 0x02, KEY_SETUP }, /* Profile */
  336. { 0xfc, 0x43, KEY_POWER2 },
  337. { 0xfc, 0x06, KEY_EPG },
  338. { 0xfc, 0x5a, KEY_BACK },
  339. { 0xfc, 0x05, KEY_MENU },
  340. { 0xfc, 0x47, KEY_INFO },
  341. { 0xfc, 0x01, KEY_TAB },
  342. { 0xfc, 0x42, KEY_PREVIOUSSONG },/* Replay */
  343. { 0xfc, 0x49, KEY_VOLUMEUP },
  344. { 0xfc, 0x09, KEY_VOLUMEDOWN },
  345. { 0xfc, 0x54, KEY_CHANNELUP },
  346. { 0xfc, 0x0b, KEY_CHANNELDOWN },
  347. { 0xfc, 0x16, KEY_CAMERA },
  348. { 0xfc, 0x40, KEY_TUNER }, /* ATV/DTV */
  349. { 0xfc, 0x45, KEY_OPEN },
  350. { 0xfc, 0x19, KEY_1 },
  351. { 0xfc, 0x18, KEY_2 },
  352. { 0xfc, 0x1b, KEY_3 },
  353. { 0xfc, 0x1a, KEY_4 },
  354. { 0xfc, 0x58, KEY_5 },
  355. { 0xfc, 0x59, KEY_6 },
  356. { 0xfc, 0x15, KEY_7 },
  357. { 0xfc, 0x14, KEY_8 },
  358. { 0xfc, 0x17, KEY_9 },
  359. { 0xfc, 0x44, KEY_ANGLE }, /* Aspect */
  360. { 0xfc, 0x55, KEY_0 },
  361. { 0xfc, 0x07, KEY_ZOOM },
  362. { 0xfc, 0x0a, KEY_REWIND },
  363. { 0xfc, 0x08, KEY_PLAYPAUSE },
  364. { 0xfc, 0x4b, KEY_FASTFORWARD },
  365. { 0xfc, 0x5b, KEY_MUTE },
  366. { 0xfc, 0x04, KEY_STOP },
  367. { 0xfc, 0x56, KEY_RECORD },
  368. { 0xfc, 0x57, KEY_POWER },
  369. { 0xfc, 0x41, KEY_UNKNOWN }, /* INPUT */
  370. { 0xfc, 0x00, KEY_UNKNOWN }, /* HD */
  371. };
  372. static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
  373. {
  374. static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 };
  375. static u8 reset [] = { RESET, 0x80 };
  376. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  377. static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
  378. static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
  379. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
  380. mt352_write(fe, clock_config, sizeof(clock_config));
  381. udelay(200);
  382. mt352_write(fe, reset, sizeof(reset));
  383. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  384. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  385. mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
  386. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  387. return 0;
  388. }
  389. static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
  390. { /* used in both lgz201 and th7579 */
  391. static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x29 };
  392. static u8 reset [] = { RESET, 0x80 };
  393. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  394. static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
  395. static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
  396. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
  397. mt352_write(fe, clock_config, sizeof(clock_config));
  398. udelay(200);
  399. mt352_write(fe, reset, sizeof(reset));
  400. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  401. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  402. mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
  403. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  404. return 0;
  405. }
  406. static struct cx22702_config cxusb_cx22702_config = {
  407. .demod_address = 0x63,
  408. .output_mode = CX22702_PARALLEL_OUTPUT,
  409. };
  410. static struct lgdt330x_config cxusb_lgdt3303_config = {
  411. .demod_address = 0x0e,
  412. .demod_chip = LGDT3303,
  413. };
  414. static struct lgdt330x_config cxusb_aver_lgdt3303_config = {
  415. .demod_address = 0x0e,
  416. .demod_chip = LGDT3303,
  417. .clock_polarity_flip = 2,
  418. };
  419. static struct mt352_config cxusb_dee1601_config = {
  420. .demod_address = 0x0f,
  421. .demod_init = cxusb_dee1601_demod_init,
  422. };
  423. static struct zl10353_config cxusb_zl10353_dee1601_config = {
  424. .demod_address = 0x0f,
  425. .parallel_ts = 1,
  426. };
  427. static struct mt352_config cxusb_mt352_config = {
  428. /* used in both lgz201 and th7579 */
  429. .demod_address = 0x0f,
  430. .demod_init = cxusb_mt352_demod_init,
  431. };
  432. static struct zl10353_config cxusb_zl10353_xc3028_config = {
  433. .demod_address = 0x0f,
  434. .if2 = 45600,
  435. .no_tuner = 1,
  436. .parallel_ts = 1,
  437. };
  438. static struct mt352_config cxusb_mt352_xc3028_config = {
  439. .demod_address = 0x0f,
  440. .if2 = 4560,
  441. .no_tuner = 1,
  442. .demod_init = cxusb_mt352_demod_init,
  443. };
  444. /* FIXME: needs tweaking */
  445. static struct mxl5005s_config aver_a868r_tuner = {
  446. .i2c_address = 0x63,
  447. .if_freq = 6000000UL,
  448. .xtal_freq = CRYSTAL_FREQ_16000000HZ,
  449. .agc_mode = MXL_SINGLE_AGC,
  450. .tracking_filter = MXL_TF_C,
  451. .rssi_enable = MXL_RSSI_ENABLE,
  452. .cap_select = MXL_CAP_SEL_ENABLE,
  453. .div_out = MXL_DIV_OUT_4,
  454. .clock_out = MXL_CLOCK_OUT_DISABLE,
  455. .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
  456. .top = MXL5005S_TOP_25P2,
  457. .mod_mode = MXL_DIGITAL_MODE,
  458. .if_mode = MXL_ZERO_IF,
  459. .AgcMasterByte = 0x00,
  460. };
  461. /* Callbacks for DVB USB */
  462. static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
  463. {
  464. dvb_attach(simple_tuner_attach, adap->fe,
  465. &adap->dev->i2c_adap, 0x61,
  466. TUNER_PHILIPS_FMD1216ME_MK3);
  467. return 0;
  468. }
  469. static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap)
  470. {
  471. dvb_attach(dvb_pll_attach, adap->fe, 0x61,
  472. NULL, DVB_PLL_THOMSON_DTT7579);
  473. return 0;
  474. }
  475. static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap)
  476. {
  477. dvb_attach(dvb_pll_attach, adap->fe, 0x61, NULL, DVB_PLL_LG_Z201);
  478. return 0;
  479. }
  480. static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap)
  481. {
  482. dvb_attach(dvb_pll_attach, adap->fe, 0x60,
  483. NULL, DVB_PLL_THOMSON_DTT7579);
  484. return 0;
  485. }
  486. static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap)
  487. {
  488. dvb_attach(simple_tuner_attach, adap->fe,
  489. &adap->dev->i2c_adap, 0x61, TUNER_LG_TDVS_H06XF);
  490. return 0;
  491. }
  492. static int dvico_bluebird_xc2028_callback(void *ptr, int command, int arg)
  493. {
  494. struct dvb_usb_adapter *adap = ptr;
  495. struct dvb_usb_device *d = adap->dev;
  496. switch (command) {
  497. case XC2028_TUNER_RESET:
  498. deb_info("%s: XC2028_TUNER_RESET %d\n", __func__, arg);
  499. cxusb_bluebird_gpio_pulse(d, 0x01, 1);
  500. break;
  501. case XC2028_RESET_CLK:
  502. deb_info("%s: XC2028_RESET_CLK %d\n", __func__, arg);
  503. break;
  504. default:
  505. deb_info("%s: unknown command %d, arg %d\n", __func__,
  506. command, arg);
  507. return -EINVAL;
  508. }
  509. return 0;
  510. }
  511. static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter *adap)
  512. {
  513. struct dvb_frontend *fe;
  514. struct xc2028_config cfg = {
  515. .i2c_adap = &adap->dev->i2c_adap,
  516. .i2c_addr = 0x61,
  517. .callback = dvico_bluebird_xc2028_callback,
  518. };
  519. static struct xc2028_ctrl ctl = {
  520. .fname = "xc3028-v27.fw",
  521. .max_len = 64,
  522. .demod = XC3028_FE_ZARLINK456,
  523. };
  524. fe = dvb_attach(xc2028_attach, adap->fe, &cfg);
  525. if (fe == NULL || fe->ops.tuner_ops.set_config == NULL)
  526. return -EIO;
  527. fe->ops.tuner_ops.set_config(fe, &ctl);
  528. return 0;
  529. }
  530. static int cxusb_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap)
  531. {
  532. dvb_attach(mxl5005s_attach, adap->fe,
  533. &adap->dev->i2c_adap, &aver_a868r_tuner);
  534. return 0;
  535. }
  536. static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
  537. {
  538. u8 b;
  539. if (usb_set_interface(adap->dev->udev, 0, 6) < 0)
  540. err("set interface failed");
  541. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1);
  542. if ((adap->fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config,
  543. &adap->dev->i2c_adap)) != NULL)
  544. return 0;
  545. return -EIO;
  546. }
  547. static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
  548. {
  549. if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
  550. err("set interface failed");
  551. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  552. if ((adap->fe = dvb_attach(lgdt330x_attach, &cxusb_lgdt3303_config,
  553. &adap->dev->i2c_adap)) != NULL)
  554. return 0;
  555. return -EIO;
  556. }
  557. static int cxusb_aver_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
  558. {
  559. adap->fe = dvb_attach(lgdt330x_attach, &cxusb_aver_lgdt3303_config,
  560. &adap->dev->i2c_adap);
  561. if (adap->fe != NULL)
  562. return 0;
  563. return -EIO;
  564. }
  565. static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap)
  566. {
  567. /* used in both lgz201 and th7579 */
  568. if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
  569. err("set interface failed");
  570. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  571. if ((adap->fe = dvb_attach(mt352_attach, &cxusb_mt352_config,
  572. &adap->dev->i2c_adap)) != NULL)
  573. return 0;
  574. return -EIO;
  575. }
  576. static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
  577. {
  578. if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
  579. err("set interface failed");
  580. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  581. if (((adap->fe = dvb_attach(mt352_attach, &cxusb_dee1601_config,
  582. &adap->dev->i2c_adap)) != NULL) ||
  583. ((adap->fe = dvb_attach(zl10353_attach,
  584. &cxusb_zl10353_dee1601_config,
  585. &adap->dev->i2c_adap)) != NULL))
  586. return 0;
  587. return -EIO;
  588. }
  589. static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
  590. {
  591. u8 ircode[4];
  592. int i;
  593. struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
  594. .buf = ircode, .len = 4 };
  595. if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
  596. err("set interface failed");
  597. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  598. /* reset the tuner and demodulator */
  599. cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
  600. cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
  601. cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
  602. if ((adap->fe = dvb_attach(zl10353_attach,
  603. &cxusb_zl10353_xc3028_config,
  604. &adap->dev->i2c_adap)) == NULL)
  605. return -EIO;
  606. /* try to determine if there is no IR decoder on the I2C bus */
  607. for (i = 0; adap->dev->props.rc_key_map != NULL && i < 5; i++) {
  608. msleep(20);
  609. if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1)
  610. goto no_IR;
  611. if (ircode[0] == 0 && ircode[1] == 0)
  612. continue;
  613. if (ircode[2] + ircode[3] != 0xff) {
  614. no_IR:
  615. adap->dev->props.rc_key_map = NULL;
  616. info("No IR receiver detected on this device.");
  617. break;
  618. }
  619. }
  620. return 0;
  621. }
  622. static struct dibx000_agc_config dib7070_agc_config = {
  623. .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
  624. /*
  625. * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
  626. * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
  627. * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
  628. */
  629. .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
  630. (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
  631. .inv_gain = 600,
  632. .time_stabiliz = 10,
  633. .alpha_level = 0,
  634. .thlock = 118,
  635. .wbd_inv = 0,
  636. .wbd_ref = 3530,
  637. .wbd_sel = 1,
  638. .wbd_alpha = 5,
  639. .agc1_max = 65535,
  640. .agc1_min = 0,
  641. .agc2_max = 65535,
  642. .agc2_min = 0,
  643. .agc1_pt1 = 0,
  644. .agc1_pt2 = 40,
  645. .agc1_pt3 = 183,
  646. .agc1_slope1 = 206,
  647. .agc1_slope2 = 255,
  648. .agc2_pt1 = 72,
  649. .agc2_pt2 = 152,
  650. .agc2_slope1 = 88,
  651. .agc2_slope2 = 90,
  652. .alpha_mant = 17,
  653. .alpha_exp = 27,
  654. .beta_mant = 23,
  655. .beta_exp = 51,
  656. .perform_agc_softsplit = 0,
  657. };
  658. static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
  659. .internal = 60000,
  660. .sampling = 15000,
  661. .pll_prediv = 1,
  662. .pll_ratio = 20,
  663. .pll_range = 3,
  664. .pll_reset = 1,
  665. .pll_bypass = 0,
  666. .enable_refdiv = 0,
  667. .bypclk_div = 0,
  668. .IO_CLK_en_core = 1,
  669. .ADClkSrc = 1,
  670. .modulo = 2,
  671. /* refsel, sel, freq_15k */
  672. .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
  673. .ifreq = (0 << 25) | 0,
  674. .timf = 20452225,
  675. .xtal_hz = 12000000,
  676. };
  677. static struct dib7000p_config cxusb_dualdig4_rev2_config = {
  678. .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
  679. .output_mpeg2_in_188_bytes = 1,
  680. .agc_config_count = 1,
  681. .agc = &dib7070_agc_config,
  682. .bw = &dib7070_bw_config_12_mhz,
  683. .tuner_is_baseband = 1,
  684. .spur_protect = 1,
  685. .gpio_dir = 0xfcef,
  686. .gpio_val = 0x0110,
  687. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  688. .hostbus_diversity = 1,
  689. };
  690. static int cxusb_dualdig4_rev2_frontend_attach(struct dvb_usb_adapter *adap)
  691. {
  692. if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
  693. err("set interface failed");
  694. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  695. cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
  696. dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
  697. &cxusb_dualdig4_rev2_config);
  698. if ((adap->fe = dvb_attach(dib7000p_attach,
  699. &adap->dev->i2c_adap, 0x80,
  700. &cxusb_dualdig4_rev2_config)) == NULL)
  701. return -EIO;
  702. return 0;
  703. }
  704. static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
  705. {
  706. return dib7000p_set_gpio(fe, 8, 0, !onoff);
  707. }
  708. static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
  709. {
  710. return 0;
  711. }
  712. static struct dib0070_config dib7070p_dib0070_config = {
  713. .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
  714. .reset = dib7070_tuner_reset,
  715. .sleep = dib7070_tuner_sleep,
  716. .clock_khz = 12000,
  717. };
  718. struct dib0700_adapter_state {
  719. int (*set_param_save) (struct dvb_frontend *,
  720. struct dvb_frontend_parameters *);
  721. };
  722. static int dib7070_set_param_override(struct dvb_frontend *fe,
  723. struct dvb_frontend_parameters *fep)
  724. {
  725. struct dvb_usb_adapter *adap = fe->dvb->priv;
  726. struct dib0700_adapter_state *state = adap->priv;
  727. u16 offset;
  728. u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
  729. switch (band) {
  730. case BAND_VHF: offset = 950; break;
  731. case BAND_UHF:
  732. default: offset = 550; break;
  733. }
  734. dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
  735. return state->set_param_save(fe, fep);
  736. }
  737. static int cxusb_dualdig4_rev2_tuner_attach(struct dvb_usb_adapter *adap)
  738. {
  739. struct dib0700_adapter_state *st = adap->priv;
  740. struct i2c_adapter *tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
  741. if (dvb_attach(dib0070_attach, adap->fe, tun_i2c,
  742. &dib7070p_dib0070_config) == NULL)
  743. return -ENODEV;
  744. st->set_param_save = adap->fe->ops.tuner_ops.set_params;
  745. adap->fe->ops.tuner_ops.set_params = dib7070_set_param_override;
  746. return 0;
  747. }
  748. static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap)
  749. {
  750. if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
  751. err("set interface failed");
  752. cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
  753. /* reset the tuner and demodulator */
  754. cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
  755. cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
  756. cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
  757. if ((adap->fe = dvb_attach(zl10353_attach,
  758. &cxusb_zl10353_xc3028_config,
  759. &adap->dev->i2c_adap)) != NULL)
  760. return 0;
  761. if ((adap->fe = dvb_attach(mt352_attach,
  762. &cxusb_mt352_xc3028_config,
  763. &adap->dev->i2c_adap)) != NULL)
  764. return 0;
  765. return -EIO;
  766. }
  767. /*
  768. * DViCO has shipped two devices with the same USB ID, but only one of them
  769. * needs a firmware download. Check the device class details to see if they
  770. * have non-default values to decide whether the device is actually cold or
  771. * not, and forget a match if it turns out we selected the wrong device.
  772. */
  773. static int bluebird_fx2_identify_state(struct usb_device *udev,
  774. struct dvb_usb_device_properties *props,
  775. struct dvb_usb_device_description **desc,
  776. int *cold)
  777. {
  778. int wascold = *cold;
  779. *cold = udev->descriptor.bDeviceClass == 0xff &&
  780. udev->descriptor.bDeviceSubClass == 0xff &&
  781. udev->descriptor.bDeviceProtocol == 0xff;
  782. if (*cold && !wascold)
  783. *desc = NULL;
  784. return 0;
  785. }
  786. /*
  787. * DViCO bluebird firmware needs the "warm" product ID to be patched into the
  788. * firmware file before download.
  789. */
  790. static const int dvico_firmware_id_offsets[] = { 6638, 3204 };
  791. static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
  792. const struct firmware *fw)
  793. {
  794. int pos;
  795. for (pos = 0; pos < ARRAY_SIZE(dvico_firmware_id_offsets); pos++) {
  796. int idoff = dvico_firmware_id_offsets[pos];
  797. if (fw->size < idoff + 4)
  798. continue;
  799. if (fw->data[idoff] == (USB_VID_DVICO & 0xff) &&
  800. fw->data[idoff + 1] == USB_VID_DVICO >> 8) {
  801. struct firmware new_fw;
  802. u8 *new_fw_data = vmalloc(fw->size);
  803. int ret;
  804. if (!new_fw_data)
  805. return -ENOMEM;
  806. memcpy(new_fw_data, fw->data, fw->size);
  807. new_fw.size = fw->size;
  808. new_fw.data = new_fw_data;
  809. new_fw_data[idoff + 2] =
  810. le16_to_cpu(udev->descriptor.idProduct) + 1;
  811. new_fw_data[idoff + 3] =
  812. le16_to_cpu(udev->descriptor.idProduct) >> 8;
  813. ret = usb_cypress_load_firmware(udev, &new_fw,
  814. CYPRESS_FX2);
  815. vfree(new_fw_data);
  816. return ret;
  817. }
  818. }
  819. return -EINVAL;
  820. }
  821. /* DVB USB Driver stuff */
  822. static struct dvb_usb_device_properties cxusb_medion_properties;
  823. static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
  824. static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;
  825. static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;
  826. static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;
  827. static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties;
  828. static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties;
  829. static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties;
  830. static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties;
  831. static struct dvb_usb_device_properties cxusb_aver_a868r_properties;
  832. static int cxusb_probe(struct usb_interface *intf,
  833. const struct usb_device_id *id)
  834. {
  835. if (0 == dvb_usb_device_init(intf, &cxusb_medion_properties,
  836. THIS_MODULE, NULL, adapter_nr) ||
  837. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties,
  838. THIS_MODULE, NULL, adapter_nr) ||
  839. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties,
  840. THIS_MODULE, NULL, adapter_nr) ||
  841. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgz201_properties,
  842. THIS_MODULE, NULL, adapter_nr) ||
  843. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dtt7579_properties,
  844. THIS_MODULE, NULL, adapter_nr) ||
  845. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dualdig4_properties,
  846. THIS_MODULE, NULL, adapter_nr) ||
  847. 0 == dvb_usb_device_init(intf, &cxusb_bluebird_nano2_properties,
  848. THIS_MODULE, NULL, adapter_nr) ||
  849. 0 == dvb_usb_device_init(intf,
  850. &cxusb_bluebird_nano2_needsfirmware_properties,
  851. THIS_MODULE, NULL, adapter_nr) ||
  852. 0 == dvb_usb_device_init(intf, &cxusb_aver_a868r_properties,
  853. THIS_MODULE, NULL, adapter_nr) ||
  854. 0 == dvb_usb_device_init(intf,
  855. &cxusb_bluebird_dualdig4_rev2_properties,
  856. THIS_MODULE, NULL, adapter_nr) ||
  857. 0)
  858. return 0;
  859. return -EINVAL;
  860. }
  861. static struct usb_device_id cxusb_table [] = {
  862. { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
  863. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
  864. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
  865. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) },
  866. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) },
  867. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
  868. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
  869. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
  870. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
  871. { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) },
  872. { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) },
  873. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) },
  874. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) },
  875. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4) },
  876. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2) },
  877. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) },
  878. { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_A868R) },
  879. { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2) },
  880. {} /* Terminating entry */
  881. };
  882. MODULE_DEVICE_TABLE (usb, cxusb_table);
  883. static struct dvb_usb_device_properties cxusb_medion_properties = {
  884. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  885. .usb_ctrl = CYPRESS_FX2,
  886. .size_of_priv = sizeof(struct cxusb_state),
  887. .num_adapters = 1,
  888. .adapter = {
  889. {
  890. .streaming_ctrl = cxusb_streaming_ctrl,
  891. .frontend_attach = cxusb_cx22702_frontend_attach,
  892. .tuner_attach = cxusb_fmd1216me_tuner_attach,
  893. /* parameter for the MPEG2-data transfer */
  894. .stream = {
  895. .type = USB_BULK,
  896. .count = 5,
  897. .endpoint = 0x02,
  898. .u = {
  899. .bulk = {
  900. .buffersize = 8192,
  901. }
  902. }
  903. },
  904. },
  905. },
  906. .power_ctrl = cxusb_power_ctrl,
  907. .i2c_algo = &cxusb_i2c_algo,
  908. .generic_bulk_ctrl_endpoint = 0x01,
  909. .num_device_descs = 1,
  910. .devices = {
  911. { "Medion MD95700 (MDUSBTV-HYBRID)",
  912. { NULL },
  913. { &cxusb_table[0], NULL },
  914. },
  915. }
  916. };
  917. static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
  918. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  919. .usb_ctrl = DEVICE_SPECIFIC,
  920. .firmware = "dvb-usb-bluebird-01.fw",
  921. .download_firmware = bluebird_patch_dvico_firmware_download,
  922. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  923. use usb alt setting 7 for EP2 transfer (atsc) */
  924. .size_of_priv = sizeof(struct cxusb_state),
  925. .num_adapters = 1,
  926. .adapter = {
  927. {
  928. .streaming_ctrl = cxusb_streaming_ctrl,
  929. .frontend_attach = cxusb_lgdt3303_frontend_attach,
  930. .tuner_attach = cxusb_lgh064f_tuner_attach,
  931. /* parameter for the MPEG2-data transfer */
  932. .stream = {
  933. .type = USB_BULK,
  934. .count = 5,
  935. .endpoint = 0x02,
  936. .u = {
  937. .bulk = {
  938. .buffersize = 8192,
  939. }
  940. }
  941. },
  942. },
  943. },
  944. .power_ctrl = cxusb_bluebird_power_ctrl,
  945. .i2c_algo = &cxusb_i2c_algo,
  946. .rc_interval = 100,
  947. .rc_key_map = dvico_portable_rc_keys,
  948. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  949. .rc_query = cxusb_rc_query,
  950. .generic_bulk_ctrl_endpoint = 0x01,
  951. .num_device_descs = 1,
  952. .devices = {
  953. { "DViCO FusionHDTV5 USB Gold",
  954. { &cxusb_table[1], NULL },
  955. { &cxusb_table[2], NULL },
  956. },
  957. }
  958. };
  959. static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
  960. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  961. .usb_ctrl = DEVICE_SPECIFIC,
  962. .firmware = "dvb-usb-bluebird-01.fw",
  963. .download_firmware = bluebird_patch_dvico_firmware_download,
  964. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  965. use usb alt setting 7 for EP2 transfer (atsc) */
  966. .size_of_priv = sizeof(struct cxusb_state),
  967. .num_adapters = 1,
  968. .adapter = {
  969. {
  970. .streaming_ctrl = cxusb_streaming_ctrl,
  971. .frontend_attach = cxusb_dee1601_frontend_attach,
  972. .tuner_attach = cxusb_dee1601_tuner_attach,
  973. /* parameter for the MPEG2-data transfer */
  974. .stream = {
  975. .type = USB_BULK,
  976. .count = 5,
  977. .endpoint = 0x04,
  978. .u = {
  979. .bulk = {
  980. .buffersize = 8192,
  981. }
  982. }
  983. },
  984. },
  985. },
  986. .power_ctrl = cxusb_bluebird_power_ctrl,
  987. .i2c_algo = &cxusb_i2c_algo,
  988. .rc_interval = 150,
  989. .rc_key_map = dvico_mce_rc_keys,
  990. .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
  991. .rc_query = cxusb_rc_query,
  992. .generic_bulk_ctrl_endpoint = 0x01,
  993. .num_device_descs = 3,
  994. .devices = {
  995. { "DViCO FusionHDTV DVB-T Dual USB",
  996. { &cxusb_table[3], NULL },
  997. { &cxusb_table[4], NULL },
  998. },
  999. { "DigitalNow DVB-T Dual USB",
  1000. { &cxusb_table[9], NULL },
  1001. { &cxusb_table[10], NULL },
  1002. },
  1003. { "DViCO FusionHDTV DVB-T Dual Digital 2",
  1004. { &cxusb_table[11], NULL },
  1005. { &cxusb_table[12], NULL },
  1006. },
  1007. }
  1008. };
  1009. static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
  1010. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1011. .usb_ctrl = DEVICE_SPECIFIC,
  1012. .firmware = "dvb-usb-bluebird-01.fw",
  1013. .download_firmware = bluebird_patch_dvico_firmware_download,
  1014. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  1015. use usb alt setting 7 for EP2 transfer (atsc) */
  1016. .size_of_priv = sizeof(struct cxusb_state),
  1017. .num_adapters = 2,
  1018. .adapter = {
  1019. {
  1020. .streaming_ctrl = cxusb_streaming_ctrl,
  1021. .frontend_attach = cxusb_mt352_frontend_attach,
  1022. .tuner_attach = cxusb_lgz201_tuner_attach,
  1023. /* parameter for the MPEG2-data transfer */
  1024. .stream = {
  1025. .type = USB_BULK,
  1026. .count = 5,
  1027. .endpoint = 0x04,
  1028. .u = {
  1029. .bulk = {
  1030. .buffersize = 8192,
  1031. }
  1032. }
  1033. },
  1034. },
  1035. },
  1036. .power_ctrl = cxusb_bluebird_power_ctrl,
  1037. .i2c_algo = &cxusb_i2c_algo,
  1038. .rc_interval = 100,
  1039. .rc_key_map = dvico_portable_rc_keys,
  1040. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  1041. .rc_query = cxusb_rc_query,
  1042. .generic_bulk_ctrl_endpoint = 0x01,
  1043. .num_device_descs = 1,
  1044. .devices = {
  1045. { "DViCO FusionHDTV DVB-T USB (LGZ201)",
  1046. { &cxusb_table[5], NULL },
  1047. { &cxusb_table[6], NULL },
  1048. },
  1049. }
  1050. };
  1051. static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
  1052. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1053. .usb_ctrl = DEVICE_SPECIFIC,
  1054. .firmware = "dvb-usb-bluebird-01.fw",
  1055. .download_firmware = bluebird_patch_dvico_firmware_download,
  1056. /* use usb alt setting 0 for EP4 transfer (dvb-t),
  1057. use usb alt setting 7 for EP2 transfer (atsc) */
  1058. .size_of_priv = sizeof(struct cxusb_state),
  1059. .num_adapters = 1,
  1060. .adapter = {
  1061. {
  1062. .streaming_ctrl = cxusb_streaming_ctrl,
  1063. .frontend_attach = cxusb_mt352_frontend_attach,
  1064. .tuner_attach = cxusb_dtt7579_tuner_attach,
  1065. /* parameter for the MPEG2-data transfer */
  1066. .stream = {
  1067. .type = USB_BULK,
  1068. .count = 5,
  1069. .endpoint = 0x04,
  1070. .u = {
  1071. .bulk = {
  1072. .buffersize = 8192,
  1073. }
  1074. }
  1075. },
  1076. },
  1077. },
  1078. .power_ctrl = cxusb_bluebird_power_ctrl,
  1079. .i2c_algo = &cxusb_i2c_algo,
  1080. .rc_interval = 100,
  1081. .rc_key_map = dvico_portable_rc_keys,
  1082. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  1083. .rc_query = cxusb_rc_query,
  1084. .generic_bulk_ctrl_endpoint = 0x01,
  1085. .num_device_descs = 1,
  1086. .devices = {
  1087. { "DViCO FusionHDTV DVB-T USB (TH7579)",
  1088. { &cxusb_table[7], NULL },
  1089. { &cxusb_table[8], NULL },
  1090. },
  1091. }
  1092. };
  1093. static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
  1094. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1095. .usb_ctrl = CYPRESS_FX2,
  1096. .size_of_priv = sizeof(struct cxusb_state),
  1097. .num_adapters = 1,
  1098. .adapter = {
  1099. {
  1100. .streaming_ctrl = cxusb_streaming_ctrl,
  1101. .frontend_attach = cxusb_dualdig4_frontend_attach,
  1102. .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
  1103. /* parameter for the MPEG2-data transfer */
  1104. .stream = {
  1105. .type = USB_BULK,
  1106. .count = 5,
  1107. .endpoint = 0x02,
  1108. .u = {
  1109. .bulk = {
  1110. .buffersize = 8192,
  1111. }
  1112. }
  1113. },
  1114. },
  1115. },
  1116. .power_ctrl = cxusb_power_ctrl,
  1117. .i2c_algo = &cxusb_i2c_algo,
  1118. .generic_bulk_ctrl_endpoint = 0x01,
  1119. .rc_interval = 100,
  1120. .rc_key_map = dvico_mce_rc_keys,
  1121. .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
  1122. .rc_query = cxusb_bluebird2_rc_query,
  1123. .num_device_descs = 1,
  1124. .devices = {
  1125. { "DViCO FusionHDTV DVB-T Dual Digital 4",
  1126. { NULL },
  1127. { &cxusb_table[13], NULL },
  1128. },
  1129. }
  1130. };
  1131. static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
  1132. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1133. .usb_ctrl = CYPRESS_FX2,
  1134. .identify_state = bluebird_fx2_identify_state,
  1135. .size_of_priv = sizeof(struct cxusb_state),
  1136. .num_adapters = 1,
  1137. .adapter = {
  1138. {
  1139. .streaming_ctrl = cxusb_streaming_ctrl,
  1140. .frontend_attach = cxusb_nano2_frontend_attach,
  1141. .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
  1142. /* parameter for the MPEG2-data transfer */
  1143. .stream = {
  1144. .type = USB_BULK,
  1145. .count = 5,
  1146. .endpoint = 0x02,
  1147. .u = {
  1148. .bulk = {
  1149. .buffersize = 8192,
  1150. }
  1151. }
  1152. },
  1153. },
  1154. },
  1155. .power_ctrl = cxusb_nano2_power_ctrl,
  1156. .i2c_algo = &cxusb_i2c_algo,
  1157. .generic_bulk_ctrl_endpoint = 0x01,
  1158. .rc_interval = 100,
  1159. .rc_key_map = dvico_portable_rc_keys,
  1160. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  1161. .rc_query = cxusb_bluebird2_rc_query,
  1162. .num_device_descs = 1,
  1163. .devices = {
  1164. { "DViCO FusionHDTV DVB-T NANO2",
  1165. { NULL },
  1166. { &cxusb_table[14], NULL },
  1167. },
  1168. }
  1169. };
  1170. static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties = {
  1171. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1172. .usb_ctrl = DEVICE_SPECIFIC,
  1173. .firmware = "dvb-usb-bluebird-02.fw",
  1174. .download_firmware = bluebird_patch_dvico_firmware_download,
  1175. .identify_state = bluebird_fx2_identify_state,
  1176. .size_of_priv = sizeof(struct cxusb_state),
  1177. .num_adapters = 1,
  1178. .adapter = {
  1179. {
  1180. .streaming_ctrl = cxusb_streaming_ctrl,
  1181. .frontend_attach = cxusb_nano2_frontend_attach,
  1182. .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
  1183. /* parameter for the MPEG2-data transfer */
  1184. .stream = {
  1185. .type = USB_BULK,
  1186. .count = 5,
  1187. .endpoint = 0x02,
  1188. .u = {
  1189. .bulk = {
  1190. .buffersize = 8192,
  1191. }
  1192. }
  1193. },
  1194. },
  1195. },
  1196. .power_ctrl = cxusb_nano2_power_ctrl,
  1197. .i2c_algo = &cxusb_i2c_algo,
  1198. .generic_bulk_ctrl_endpoint = 0x01,
  1199. .rc_interval = 100,
  1200. .rc_key_map = dvico_portable_rc_keys,
  1201. .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
  1202. .rc_query = cxusb_rc_query,
  1203. .num_device_descs = 1,
  1204. .devices = {
  1205. { "DViCO FusionHDTV DVB-T NANO2 w/o firmware",
  1206. { &cxusb_table[14], NULL },
  1207. { &cxusb_table[15], NULL },
  1208. },
  1209. }
  1210. };
  1211. static struct dvb_usb_device_properties cxusb_aver_a868r_properties = {
  1212. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1213. .usb_ctrl = CYPRESS_FX2,
  1214. .size_of_priv = sizeof(struct cxusb_state),
  1215. .num_adapters = 1,
  1216. .adapter = {
  1217. {
  1218. .streaming_ctrl = cxusb_aver_streaming_ctrl,
  1219. .frontend_attach = cxusb_aver_lgdt3303_frontend_attach,
  1220. .tuner_attach = cxusb_mxl5003s_tuner_attach,
  1221. /* parameter for the MPEG2-data transfer */
  1222. .stream = {
  1223. .type = USB_BULK,
  1224. .count = 5,
  1225. .endpoint = 0x04,
  1226. .u = {
  1227. .bulk = {
  1228. .buffersize = 8192,
  1229. }
  1230. }
  1231. },
  1232. },
  1233. },
  1234. .power_ctrl = cxusb_aver_power_ctrl,
  1235. .i2c_algo = &cxusb_i2c_algo,
  1236. .generic_bulk_ctrl_endpoint = 0x01,
  1237. .num_device_descs = 1,
  1238. .devices = {
  1239. { "AVerMedia AVerTVHD Volar (A868R)",
  1240. { NULL },
  1241. { &cxusb_table[16], NULL },
  1242. },
  1243. }
  1244. };
  1245. static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties = {
  1246. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1247. .usb_ctrl = CYPRESS_FX2,
  1248. .size_of_priv = sizeof(struct cxusb_state),
  1249. .num_adapters = 1,
  1250. .adapter = {
  1251. {
  1252. .streaming_ctrl = cxusb_streaming_ctrl,
  1253. .frontend_attach = cxusb_dualdig4_rev2_frontend_attach,
  1254. .tuner_attach = cxusb_dualdig4_rev2_tuner_attach,
  1255. .size_of_priv = sizeof(struct dib0700_adapter_state),
  1256. /* parameter for the MPEG2-data transfer */
  1257. .stream = {
  1258. .type = USB_BULK,
  1259. .count = 7,
  1260. .endpoint = 0x02,
  1261. .u = {
  1262. .bulk = {
  1263. .buffersize = 4096,
  1264. }
  1265. }
  1266. },
  1267. },
  1268. },
  1269. .power_ctrl = cxusb_bluebird_power_ctrl,
  1270. .i2c_algo = &cxusb_i2c_algo,
  1271. .generic_bulk_ctrl_endpoint = 0x01,
  1272. .rc_interval = 100,
  1273. .rc_key_map = dvico_mce_rc_keys,
  1274. .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
  1275. .rc_query = cxusb_rc_query,
  1276. .num_device_descs = 1,
  1277. .devices = {
  1278. { "DViCO FusionHDTV DVB-T Dual Digital 4 (rev 2)",
  1279. { NULL },
  1280. { &cxusb_table[17], NULL },
  1281. },
  1282. }
  1283. };
  1284. static struct usb_driver cxusb_driver = {
  1285. .name = "dvb_usb_cxusb",
  1286. .probe = cxusb_probe,
  1287. .disconnect = dvb_usb_device_exit,
  1288. .id_table = cxusb_table,
  1289. };
  1290. /* module stuff */
  1291. static int __init cxusb_module_init(void)
  1292. {
  1293. int result;
  1294. if ((result = usb_register(&cxusb_driver))) {
  1295. err("usb_register failed. Error number %d",result);
  1296. return result;
  1297. }
  1298. return 0;
  1299. }
  1300. static void __exit cxusb_module_exit(void)
  1301. {
  1302. /* deregister this driver from the USB subsystem */
  1303. usb_deregister(&cxusb_driver);
  1304. }
  1305. module_init (cxusb_module_init);
  1306. module_exit (cxusb_module_exit);
  1307. MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
  1308. MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
  1309. MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
  1310. MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
  1311. MODULE_VERSION("1.0-alpha");
  1312. MODULE_LICENSE("GPL");