cxusb.c 50 KB

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