cxusb.c 52 KB

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