cxusb.c 47 KB

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