em28xx-dvb.c 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123
  1. /*
  2. DVB device driver for em28xx
  3. (c) 2008-2011 Mauro Carvalho Chehab <mchehab@infradead.org>
  4. (c) 2008 Devin Heitmueller <devin.heitmueller@gmail.com>
  5. - Fixes for the driver to properly work with HVR-950
  6. - Fixes for the driver to properly work with Pinnacle PCTV HD Pro Stick
  7. - Fixes for the driver to properly work with AMD ATI TV Wonder HD 600
  8. (c) 2008 Aidan Thornton <makosoft@googlemail.com>
  9. (c) 2012 Frank Schäfer <fschaefer.oss@googlemail.com>
  10. Based on cx88-dvb, saa7134-dvb and videobuf-dvb originally written by:
  11. (c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>
  12. (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
  13. This program is free software; you can redistribute it and/or modify
  14. it under the terms of the GNU General Public License as published by
  15. the Free Software Foundation; either version 2 of the License.
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/slab.h>
  19. #include <linux/usb.h>
  20. #include "em28xx.h"
  21. #include <media/v4l2-common.h>
  22. #include <dvb_demux.h>
  23. #include <dvb_net.h>
  24. #include <dmxdev.h>
  25. #include <media/tuner.h>
  26. #include "tuner-simple.h"
  27. #include <linux/gpio.h>
  28. #include "lgdt330x.h"
  29. #include "lgdt3305.h"
  30. #include "zl10353.h"
  31. #include "s5h1409.h"
  32. #include "mt2060.h"
  33. #include "mt352.h"
  34. #include "mt352_priv.h" /* FIXME */
  35. #include "tda1002x.h"
  36. #include "drx39xyj/drx39xxj.h"
  37. #include "tda18271.h"
  38. #include "s921.h"
  39. #include "drxd.h"
  40. #include "cxd2820r.h"
  41. #include "tda18271c2dd.h"
  42. #include "drxk.h"
  43. #include "tda10071.h"
  44. #include "tda18212.h"
  45. #include "a8293.h"
  46. #include "qt1010.h"
  47. #include "mb86a20s.h"
  48. #include "m88ds3103.h"
  49. #include "ts2020.h"
  50. #include "si2168.h"
  51. #include "si2157.h"
  52. #include "tc90522.h"
  53. #include "qm1d1c0042.h"
  54. MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>");
  55. MODULE_LICENSE("GPL");
  56. MODULE_DESCRIPTION(DRIVER_DESC " - digital TV interface");
  57. MODULE_VERSION(EM28XX_VERSION);
  58. static unsigned int debug;
  59. module_param(debug, int, 0644);
  60. MODULE_PARM_DESC(debug, "enable debug messages [dvb]");
  61. DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
  62. #define dprintk(level, fmt, arg...) do { \
  63. if (debug >= level) \
  64. printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->name, ## arg); \
  65. } while (0)
  66. struct em28xx_dvb {
  67. struct dvb_frontend *fe[2];
  68. /* feed count management */
  69. struct mutex lock;
  70. int nfeeds;
  71. /* general boilerplate stuff */
  72. struct dvb_adapter adapter;
  73. struct dvb_demux demux;
  74. struct dmxdev dmxdev;
  75. struct dmx_frontend fe_hw;
  76. struct dmx_frontend fe_mem;
  77. struct dvb_net net;
  78. /* Due to DRX-K - probably need changes */
  79. int (*gate_ctrl)(struct dvb_frontend *, int);
  80. struct semaphore pll_mutex;
  81. bool dont_attach_fe1;
  82. int lna_gpio;
  83. struct i2c_client *i2c_client_demod;
  84. struct i2c_client *i2c_client_tuner;
  85. struct i2c_client *i2c_client_sec;
  86. };
  87. static inline void print_err_status(struct em28xx *dev,
  88. int packet, int status)
  89. {
  90. char *errmsg = "Unknown";
  91. switch (status) {
  92. case -ENOENT:
  93. errmsg = "unlinked synchronuously";
  94. break;
  95. case -ECONNRESET:
  96. errmsg = "unlinked asynchronuously";
  97. break;
  98. case -ENOSR:
  99. errmsg = "Buffer error (overrun)";
  100. break;
  101. case -EPIPE:
  102. errmsg = "Stalled (device not responding)";
  103. break;
  104. case -EOVERFLOW:
  105. errmsg = "Babble (bad cable?)";
  106. break;
  107. case -EPROTO:
  108. errmsg = "Bit-stuff error (bad cable?)";
  109. break;
  110. case -EILSEQ:
  111. errmsg = "CRC/Timeout (could be anything)";
  112. break;
  113. case -ETIME:
  114. errmsg = "Device does not respond";
  115. break;
  116. }
  117. if (packet < 0) {
  118. dprintk(1, "URB status %d [%s].\n", status, errmsg);
  119. } else {
  120. dprintk(1, "URB packet %d, status %d [%s].\n",
  121. packet, status, errmsg);
  122. }
  123. }
  124. static inline int em28xx_dvb_urb_data_copy(struct em28xx *dev, struct urb *urb)
  125. {
  126. int xfer_bulk, num_packets, i;
  127. if (!dev)
  128. return 0;
  129. if (dev->disconnected)
  130. return 0;
  131. if (urb->status < 0)
  132. print_err_status(dev, -1, urb->status);
  133. xfer_bulk = usb_pipebulk(urb->pipe);
  134. if (xfer_bulk) /* bulk */
  135. num_packets = 1;
  136. else /* isoc */
  137. num_packets = urb->number_of_packets;
  138. for (i = 0; i < num_packets; i++) {
  139. if (xfer_bulk) {
  140. if (urb->status < 0) {
  141. print_err_status(dev, i, urb->status);
  142. if (urb->status != -EPROTO)
  143. continue;
  144. }
  145. if (!urb->actual_length)
  146. continue;
  147. dvb_dmx_swfilter(&dev->dvb->demux, urb->transfer_buffer,
  148. urb->actual_length);
  149. } else {
  150. if (urb->iso_frame_desc[i].status < 0) {
  151. print_err_status(dev, i,
  152. urb->iso_frame_desc[i].status);
  153. if (urb->iso_frame_desc[i].status != -EPROTO)
  154. continue;
  155. }
  156. if (!urb->iso_frame_desc[i].actual_length)
  157. continue;
  158. dvb_dmx_swfilter(&dev->dvb->demux,
  159. urb->transfer_buffer +
  160. urb->iso_frame_desc[i].offset,
  161. urb->iso_frame_desc[i].actual_length);
  162. }
  163. }
  164. return 0;
  165. }
  166. static int em28xx_start_streaming(struct em28xx_dvb *dvb)
  167. {
  168. int rc;
  169. struct em28xx_i2c_bus *i2c_bus = dvb->adapter.priv;
  170. struct em28xx *dev = i2c_bus->dev;
  171. int dvb_max_packet_size, packet_multiplier, dvb_alt;
  172. if (dev->dvb_xfer_bulk) {
  173. if (!dev->dvb_ep_bulk)
  174. return -ENODEV;
  175. dvb_max_packet_size = 512; /* USB 2.0 spec */
  176. packet_multiplier = EM28XX_DVB_BULK_PACKET_MULTIPLIER;
  177. dvb_alt = 0;
  178. } else { /* isoc */
  179. if (!dev->dvb_ep_isoc)
  180. return -ENODEV;
  181. dvb_max_packet_size = dev->dvb_max_pkt_size_isoc;
  182. if (dvb_max_packet_size < 0)
  183. return dvb_max_packet_size;
  184. packet_multiplier = EM28XX_DVB_NUM_ISOC_PACKETS;
  185. dvb_alt = dev->dvb_alt_isoc;
  186. }
  187. usb_set_interface(dev->udev, dev->ifnum, dvb_alt);
  188. rc = em28xx_set_mode(dev, EM28XX_DIGITAL_MODE);
  189. if (rc < 0)
  190. return rc;
  191. dprintk(1, "Using %d buffers each with %d x %d bytes, alternate %d\n",
  192. EM28XX_DVB_NUM_BUFS,
  193. packet_multiplier,
  194. dvb_max_packet_size, dvb_alt);
  195. return em28xx_init_usb_xfer(dev, EM28XX_DIGITAL_MODE,
  196. dev->dvb_xfer_bulk,
  197. EM28XX_DVB_NUM_BUFS,
  198. dvb_max_packet_size,
  199. packet_multiplier,
  200. em28xx_dvb_urb_data_copy);
  201. }
  202. static int em28xx_stop_streaming(struct em28xx_dvb *dvb)
  203. {
  204. struct em28xx_i2c_bus *i2c_bus = dvb->adapter.priv;
  205. struct em28xx *dev = i2c_bus->dev;
  206. em28xx_stop_urbs(dev);
  207. return 0;
  208. }
  209. static int em28xx_start_feed(struct dvb_demux_feed *feed)
  210. {
  211. struct dvb_demux *demux = feed->demux;
  212. struct em28xx_dvb *dvb = demux->priv;
  213. int rc, ret;
  214. if (!demux->dmx.frontend)
  215. return -EINVAL;
  216. mutex_lock(&dvb->lock);
  217. dvb->nfeeds++;
  218. rc = dvb->nfeeds;
  219. if (dvb->nfeeds == 1) {
  220. ret = em28xx_start_streaming(dvb);
  221. if (ret < 0)
  222. rc = ret;
  223. }
  224. mutex_unlock(&dvb->lock);
  225. return rc;
  226. }
  227. static int em28xx_stop_feed(struct dvb_demux_feed *feed)
  228. {
  229. struct dvb_demux *demux = feed->demux;
  230. struct em28xx_dvb *dvb = demux->priv;
  231. int err = 0;
  232. mutex_lock(&dvb->lock);
  233. dvb->nfeeds--;
  234. if (0 == dvb->nfeeds)
  235. err = em28xx_stop_streaming(dvb);
  236. mutex_unlock(&dvb->lock);
  237. return err;
  238. }
  239. /* ------------------------------------------------------------------ */
  240. static int em28xx_dvb_bus_ctrl(struct dvb_frontend *fe, int acquire)
  241. {
  242. struct em28xx_i2c_bus *i2c_bus = fe->dvb->priv;
  243. struct em28xx *dev = i2c_bus->dev;
  244. if (acquire)
  245. return em28xx_set_mode(dev, EM28XX_DIGITAL_MODE);
  246. else
  247. return em28xx_set_mode(dev, EM28XX_SUSPEND);
  248. }
  249. /* ------------------------------------------------------------------ */
  250. static struct lgdt330x_config em2880_lgdt3303_dev = {
  251. .demod_address = 0x0e,
  252. .demod_chip = LGDT3303,
  253. };
  254. static struct lgdt3305_config em2870_lgdt3304_dev = {
  255. .i2c_addr = 0x0e,
  256. .demod_chip = LGDT3304,
  257. .spectral_inversion = 1,
  258. .deny_i2c_rptr = 1,
  259. .mpeg_mode = LGDT3305_MPEG_PARALLEL,
  260. .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
  261. .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
  262. .vsb_if_khz = 3250,
  263. .qam_if_khz = 4000,
  264. };
  265. static struct lgdt3305_config em2874_lgdt3305_dev = {
  266. .i2c_addr = 0x0e,
  267. .demod_chip = LGDT3305,
  268. .spectral_inversion = 1,
  269. .deny_i2c_rptr = 0,
  270. .mpeg_mode = LGDT3305_MPEG_SERIAL,
  271. .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
  272. .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
  273. .vsb_if_khz = 3250,
  274. .qam_if_khz = 4000,
  275. };
  276. static struct lgdt3305_config em2874_lgdt3305_nogate_dev = {
  277. .i2c_addr = 0x0e,
  278. .demod_chip = LGDT3305,
  279. .spectral_inversion = 1,
  280. .deny_i2c_rptr = 1,
  281. .mpeg_mode = LGDT3305_MPEG_SERIAL,
  282. .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
  283. .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
  284. .vsb_if_khz = 3600,
  285. .qam_if_khz = 3600,
  286. };
  287. static struct s921_config sharp_isdbt = {
  288. .demod_address = 0x30 >> 1
  289. };
  290. static struct zl10353_config em28xx_zl10353_with_xc3028 = {
  291. .demod_address = (0x1e >> 1),
  292. .no_tuner = 1,
  293. .parallel_ts = 1,
  294. .if2 = 45600,
  295. };
  296. static struct s5h1409_config em28xx_s5h1409_with_xc3028 = {
  297. .demod_address = 0x32 >> 1,
  298. .output_mode = S5H1409_PARALLEL_OUTPUT,
  299. .gpio = S5H1409_GPIO_OFF,
  300. .inversion = S5H1409_INVERSION_OFF,
  301. .status_mode = S5H1409_DEMODLOCKING,
  302. .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
  303. };
  304. static struct tda18271_std_map kworld_a340_std_map = {
  305. .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 0,
  306. .if_lvl = 1, .rfagc_top = 0x37, },
  307. .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 1,
  308. .if_lvl = 1, .rfagc_top = 0x37, },
  309. };
  310. static struct tda18271_config kworld_a340_config = {
  311. .std_map = &kworld_a340_std_map,
  312. };
  313. static struct tda18271_config kworld_ub435q_v2_config = {
  314. .std_map = &kworld_a340_std_map,
  315. .gate = TDA18271_GATE_DIGITAL,
  316. };
  317. static struct tda18212_config kworld_ub435q_v3_config = {
  318. .if_atsc_vsb = 3600,
  319. .if_atsc_qam = 3600,
  320. };
  321. static struct zl10353_config em28xx_zl10353_xc3028_no_i2c_gate = {
  322. .demod_address = (0x1e >> 1),
  323. .no_tuner = 1,
  324. .disable_i2c_gate_ctrl = 1,
  325. .parallel_ts = 1,
  326. .if2 = 45600,
  327. };
  328. static struct drxd_config em28xx_drxd = {
  329. .demod_address = 0x70,
  330. .demod_revision = 0xa2,
  331. .pll_type = DRXD_PLL_NONE,
  332. .clock = 12000,
  333. .insert_rs_byte = 1,
  334. .IF = 42800000,
  335. .disable_i2c_gate_ctrl = 1,
  336. };
  337. static struct drxk_config terratec_h5_drxk = {
  338. .adr = 0x29,
  339. .single_master = 1,
  340. .no_i2c_bridge = 1,
  341. .microcode_name = "dvb-usb-terratec-h5-drxk.fw",
  342. .qam_demod_parameter_count = 2,
  343. };
  344. static struct drxk_config hauppauge_930c_drxk = {
  345. .adr = 0x29,
  346. .single_master = 1,
  347. .no_i2c_bridge = 1,
  348. .microcode_name = "dvb-usb-hauppauge-hvr930c-drxk.fw",
  349. .chunk_size = 56,
  350. .qam_demod_parameter_count = 2,
  351. };
  352. static struct drxk_config terratec_htc_stick_drxk = {
  353. .adr = 0x29,
  354. .single_master = 1,
  355. .no_i2c_bridge = 1,
  356. .microcode_name = "dvb-usb-terratec-htc-stick-drxk.fw",
  357. .chunk_size = 54,
  358. .qam_demod_parameter_count = 2,
  359. /* Required for the antenna_gpio to disable LNA. */
  360. .antenna_dvbt = true,
  361. /* The windows driver uses the same. This will disable LNA. */
  362. .antenna_gpio = 0x6,
  363. };
  364. static struct drxk_config maxmedia_ub425_tc_drxk = {
  365. .adr = 0x29,
  366. .single_master = 1,
  367. .no_i2c_bridge = 1,
  368. .microcode_name = "dvb-demod-drxk-01.fw",
  369. .chunk_size = 62,
  370. .qam_demod_parameter_count = 2,
  371. };
  372. static struct drxk_config pctv_520e_drxk = {
  373. .adr = 0x29,
  374. .single_master = 1,
  375. .microcode_name = "dvb-demod-drxk-pctv.fw",
  376. .qam_demod_parameter_count = 2,
  377. .chunk_size = 58,
  378. .antenna_dvbt = true, /* disable LNA */
  379. .antenna_gpio = (1 << 2), /* disable LNA */
  380. };
  381. static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
  382. {
  383. struct em28xx_dvb *dvb = fe->sec_priv;
  384. int status;
  385. if (!dvb)
  386. return -EINVAL;
  387. if (enable) {
  388. down(&dvb->pll_mutex);
  389. status = dvb->gate_ctrl(fe, 1);
  390. } else {
  391. status = dvb->gate_ctrl(fe, 0);
  392. up(&dvb->pll_mutex);
  393. }
  394. return status;
  395. }
  396. static void hauppauge_hvr930c_init(struct em28xx *dev)
  397. {
  398. int i;
  399. struct em28xx_reg_seq hauppauge_hvr930c_init[] = {
  400. {EM2874_R80_GPIO_P0_CTRL, 0xff, 0xff, 0x65},
  401. {EM2874_R80_GPIO_P0_CTRL, 0xfb, 0xff, 0x32},
  402. {EM2874_R80_GPIO_P0_CTRL, 0xff, 0xff, 0xb8},
  403. { -1, -1, -1, -1},
  404. };
  405. struct em28xx_reg_seq hauppauge_hvr930c_end[] = {
  406. {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x01},
  407. {EM2874_R80_GPIO_P0_CTRL, 0xaf, 0xff, 0x65},
  408. {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x76},
  409. {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x01},
  410. {EM2874_R80_GPIO_P0_CTRL, 0xcf, 0xff, 0x0b},
  411. {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x40},
  412. {EM2874_R80_GPIO_P0_CTRL, 0xcf, 0xff, 0x65},
  413. {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x65},
  414. {EM2874_R80_GPIO_P0_CTRL, 0xcf, 0xff, 0x0b},
  415. {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x65},
  416. { -1, -1, -1, -1},
  417. };
  418. struct {
  419. unsigned char r[4];
  420. int len;
  421. } regs[] = {
  422. {{ 0x06, 0x02, 0x00, 0x31 }, 4},
  423. {{ 0x01, 0x02 }, 2},
  424. {{ 0x01, 0x02, 0x00, 0xc6 }, 4},
  425. {{ 0x01, 0x00 }, 2},
  426. {{ 0x01, 0x00, 0xff, 0xaf }, 4},
  427. {{ 0x01, 0x00, 0x03, 0xa0 }, 4},
  428. {{ 0x01, 0x00 }, 2},
  429. {{ 0x01, 0x00, 0x73, 0xaf }, 4},
  430. {{ 0x04, 0x00 }, 2},
  431. {{ 0x00, 0x04 }, 2},
  432. {{ 0x00, 0x04, 0x00, 0x0a }, 4},
  433. {{ 0x04, 0x14 }, 2},
  434. {{ 0x04, 0x14, 0x00, 0x00 }, 4},
  435. };
  436. em28xx_gpio_set(dev, hauppauge_hvr930c_init);
  437. em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40);
  438. msleep(10);
  439. em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x44);
  440. msleep(10);
  441. dev->i2c_client[dev->def_i2c_bus].addr = 0x82 >> 1;
  442. for (i = 0; i < ARRAY_SIZE(regs); i++)
  443. i2c_master_send(&dev->i2c_client[dev->def_i2c_bus], regs[i].r, regs[i].len);
  444. em28xx_gpio_set(dev, hauppauge_hvr930c_end);
  445. msleep(100);
  446. em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x44);
  447. msleep(30);
  448. em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x45);
  449. msleep(10);
  450. }
  451. static void terratec_h5_init(struct em28xx *dev)
  452. {
  453. int i;
  454. struct em28xx_reg_seq terratec_h5_init[] = {
  455. {EM2820_R08_GPIO_CTRL, 0xff, 0xff, 10},
  456. {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100},
  457. {EM2874_R80_GPIO_P0_CTRL, 0xf2, 0xff, 50},
  458. {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100},
  459. { -1, -1, -1, -1},
  460. };
  461. struct em28xx_reg_seq terratec_h5_end[] = {
  462. {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100},
  463. {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 50},
  464. {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100},
  465. { -1, -1, -1, -1},
  466. };
  467. struct {
  468. unsigned char r[4];
  469. int len;
  470. } regs[] = {
  471. {{ 0x06, 0x02, 0x00, 0x31 }, 4},
  472. {{ 0x01, 0x02 }, 2},
  473. {{ 0x01, 0x02, 0x00, 0xc6 }, 4},
  474. {{ 0x01, 0x00 }, 2},
  475. {{ 0x01, 0x00, 0xff, 0xaf }, 4},
  476. {{ 0x01, 0x00, 0x03, 0xa0 }, 4},
  477. {{ 0x01, 0x00 }, 2},
  478. {{ 0x01, 0x00, 0x73, 0xaf }, 4},
  479. {{ 0x04, 0x00 }, 2},
  480. {{ 0x00, 0x04 }, 2},
  481. {{ 0x00, 0x04, 0x00, 0x0a }, 4},
  482. {{ 0x04, 0x14 }, 2},
  483. {{ 0x04, 0x14, 0x00, 0x00 }, 4},
  484. };
  485. em28xx_gpio_set(dev, terratec_h5_init);
  486. em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40);
  487. msleep(10);
  488. em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x45);
  489. msleep(10);
  490. dev->i2c_client[dev->def_i2c_bus].addr = 0x82 >> 1;
  491. for (i = 0; i < ARRAY_SIZE(regs); i++)
  492. i2c_master_send(&dev->i2c_client[dev->def_i2c_bus], regs[i].r, regs[i].len);
  493. em28xx_gpio_set(dev, terratec_h5_end);
  494. };
  495. static void terratec_htc_stick_init(struct em28xx *dev)
  496. {
  497. int i;
  498. /*
  499. * GPIO configuration:
  500. * 0xff: unknown (does not affect DVB-T).
  501. * 0xf6: DRX-K (demodulator).
  502. * 0xe6: unknown (does not affect DVB-T).
  503. * 0xb6: unknown (does not affect DVB-T).
  504. */
  505. struct em28xx_reg_seq terratec_htc_stick_init[] = {
  506. {EM2820_R08_GPIO_CTRL, 0xff, 0xff, 10},
  507. {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100},
  508. {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 50},
  509. {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100},
  510. { -1, -1, -1, -1},
  511. };
  512. struct em28xx_reg_seq terratec_htc_stick_end[] = {
  513. {EM2874_R80_GPIO_P0_CTRL, 0xb6, 0xff, 100},
  514. {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 50},
  515. { -1, -1, -1, -1},
  516. };
  517. /*
  518. * Init the analog decoder (not yet supported), but
  519. * it's probably still a good idea.
  520. */
  521. struct {
  522. unsigned char r[4];
  523. int len;
  524. } regs[] = {
  525. {{ 0x06, 0x02, 0x00, 0x31 }, 4},
  526. {{ 0x01, 0x02 }, 2},
  527. {{ 0x01, 0x02, 0x00, 0xc6 }, 4},
  528. {{ 0x01, 0x00 }, 2},
  529. {{ 0x01, 0x00, 0xff, 0xaf }, 4},
  530. };
  531. em28xx_gpio_set(dev, terratec_htc_stick_init);
  532. em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40);
  533. msleep(10);
  534. em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x44);
  535. msleep(10);
  536. dev->i2c_client[dev->def_i2c_bus].addr = 0x82 >> 1;
  537. for (i = 0; i < ARRAY_SIZE(regs); i++)
  538. i2c_master_send(&dev->i2c_client[dev->def_i2c_bus], regs[i].r, regs[i].len);
  539. em28xx_gpio_set(dev, terratec_htc_stick_end);
  540. };
  541. static void terratec_htc_usb_xs_init(struct em28xx *dev)
  542. {
  543. int i;
  544. struct em28xx_reg_seq terratec_htc_usb_xs_init[] = {
  545. {EM2820_R08_GPIO_CTRL, 0xff, 0xff, 10},
  546. {EM2874_R80_GPIO_P0_CTRL, 0xb2, 0xff, 100},
  547. {EM2874_R80_GPIO_P0_CTRL, 0xb2, 0xff, 50},
  548. {EM2874_R80_GPIO_P0_CTRL, 0xb6, 0xff, 100},
  549. { -1, -1, -1, -1},
  550. };
  551. struct em28xx_reg_seq terratec_htc_usb_xs_end[] = {
  552. {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 100},
  553. {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 50},
  554. {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100},
  555. { -1, -1, -1, -1},
  556. };
  557. /*
  558. * Init the analog decoder (not yet supported), but
  559. * it's probably still a good idea.
  560. */
  561. struct {
  562. unsigned char r[4];
  563. int len;
  564. } regs[] = {
  565. {{ 0x06, 0x02, 0x00, 0x31 }, 4},
  566. {{ 0x01, 0x02 }, 2},
  567. {{ 0x01, 0x02, 0x00, 0xc6 }, 4},
  568. {{ 0x01, 0x00 }, 2},
  569. {{ 0x01, 0x00, 0xff, 0xaf }, 4},
  570. {{ 0x01, 0x00, 0x03, 0xa0 }, 4},
  571. {{ 0x01, 0x00 }, 2},
  572. {{ 0x01, 0x00, 0x73, 0xaf }, 4},
  573. {{ 0x04, 0x00 }, 2},
  574. {{ 0x00, 0x04 }, 2},
  575. {{ 0x00, 0x04, 0x00, 0x0a }, 4},
  576. {{ 0x04, 0x14 }, 2},
  577. {{ 0x04, 0x14, 0x00, 0x00 }, 4},
  578. };
  579. em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40);
  580. em28xx_gpio_set(dev, terratec_htc_usb_xs_init);
  581. em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40);
  582. msleep(10);
  583. em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x44);
  584. msleep(10);
  585. dev->i2c_client[dev->def_i2c_bus].addr = 0x82 >> 1;
  586. for (i = 0; i < ARRAY_SIZE(regs); i++)
  587. i2c_master_send(&dev->i2c_client[dev->def_i2c_bus], regs[i].r, regs[i].len);
  588. em28xx_gpio_set(dev, terratec_htc_usb_xs_end);
  589. };
  590. static void pctv_520e_init(struct em28xx *dev)
  591. {
  592. /*
  593. * Init AVF4910B analog decoder. Looks like I2C traffic to
  594. * digital demodulator and tuner are routed via AVF4910B.
  595. */
  596. int i;
  597. struct {
  598. unsigned char r[4];
  599. int len;
  600. } regs[] = {
  601. {{ 0x06, 0x02, 0x00, 0x31 }, 4},
  602. {{ 0x01, 0x02 }, 2},
  603. {{ 0x01, 0x02, 0x00, 0xc6 }, 4},
  604. {{ 0x01, 0x00 }, 2},
  605. {{ 0x01, 0x00, 0xff, 0xaf }, 4},
  606. {{ 0x01, 0x00, 0x03, 0xa0 }, 4},
  607. {{ 0x01, 0x00 }, 2},
  608. {{ 0x01, 0x00, 0x73, 0xaf }, 4},
  609. };
  610. dev->i2c_client[dev->def_i2c_bus].addr = 0x82 >> 1; /* 0x41 */
  611. for (i = 0; i < ARRAY_SIZE(regs); i++)
  612. i2c_master_send(&dev->i2c_client[dev->def_i2c_bus], regs[i].r, regs[i].len);
  613. };
  614. static int em28xx_pctv_290e_set_lna(struct dvb_frontend *fe)
  615. {
  616. struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  617. struct em28xx_i2c_bus *i2c_bus = fe->dvb->priv;
  618. struct em28xx *dev = i2c_bus->dev;
  619. #ifdef CONFIG_GPIOLIB
  620. struct em28xx_dvb *dvb = dev->dvb;
  621. int ret;
  622. unsigned long flags;
  623. if (c->lna == 1)
  624. flags = GPIOF_OUT_INIT_HIGH; /* enable LNA */
  625. else
  626. flags = GPIOF_OUT_INIT_LOW; /* disable LNA */
  627. ret = gpio_request_one(dvb->lna_gpio, flags, NULL);
  628. if (ret)
  629. em28xx_errdev("gpio request failed %d\n", ret);
  630. else
  631. gpio_free(dvb->lna_gpio);
  632. return ret;
  633. #else
  634. dev_warn(&dev->udev->dev, "%s: LNA control is disabled (lna=%u)\n",
  635. KBUILD_MODNAME, c->lna);
  636. return 0;
  637. #endif
  638. }
  639. static int em28xx_pctv_292e_set_lna(struct dvb_frontend *fe)
  640. {
  641. struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  642. struct em28xx_i2c_bus *i2c_bus = fe->dvb->priv;
  643. struct em28xx *dev = i2c_bus->dev;
  644. u8 lna;
  645. if (c->lna == 1)
  646. lna = 0x01;
  647. else
  648. lna = 0x00;
  649. return em28xx_write_reg_bits(dev, EM2874_R80_GPIO_P0_CTRL, lna, 0x01);
  650. }
  651. static int em28xx_mt352_terratec_xs_init(struct dvb_frontend *fe)
  652. {
  653. /* Values extracted from a USB trace of the Terratec Windows driver */
  654. static u8 clock_config[] = { CLOCK_CTL, 0x38, 0x2c };
  655. static u8 reset[] = { RESET, 0x80 };
  656. static u8 adc_ctl_1_cfg[] = { ADC_CTL_1, 0x40 };
  657. static u8 agc_cfg[] = { AGC_TARGET, 0x28, 0xa0 };
  658. static u8 input_freq_cfg[] = { INPUT_FREQ_1, 0x31, 0xb8 };
  659. static u8 rs_err_cfg[] = { RS_ERR_PER_1, 0x00, 0x4d };
  660. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
  661. static u8 trl_nom_cfg[] = { TRL_NOMINAL_RATE_1, 0x64, 0x00 };
  662. static u8 tps_given_cfg[] = { TPS_GIVEN_1, 0x40, 0x80, 0x50 };
  663. static u8 tuner_go[] = { TUNER_GO, 0x01};
  664. mt352_write(fe, clock_config, sizeof(clock_config));
  665. udelay(200);
  666. mt352_write(fe, reset, sizeof(reset));
  667. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  668. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  669. mt352_write(fe, input_freq_cfg, sizeof(input_freq_cfg));
  670. mt352_write(fe, rs_err_cfg, sizeof(rs_err_cfg));
  671. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  672. mt352_write(fe, trl_nom_cfg, sizeof(trl_nom_cfg));
  673. mt352_write(fe, tps_given_cfg, sizeof(tps_given_cfg));
  674. mt352_write(fe, tuner_go, sizeof(tuner_go));
  675. return 0;
  676. }
  677. static void px_bcud_init(struct em28xx *dev)
  678. {
  679. int i;
  680. struct {
  681. unsigned char r[4];
  682. int len;
  683. } regs1[] = {
  684. {{ 0x0e, 0x77 }, 2},
  685. {{ 0x0f, 0x77 }, 2},
  686. {{ 0x03, 0x90 }, 2},
  687. }, regs2[] = {
  688. {{ 0x07, 0x01 }, 2},
  689. {{ 0x08, 0x10 }, 2},
  690. {{ 0x13, 0x00 }, 2},
  691. {{ 0x17, 0x00 }, 2},
  692. {{ 0x03, 0x01 }, 2},
  693. {{ 0x10, 0xb1 }, 2},
  694. {{ 0x11, 0x40 }, 2},
  695. {{ 0x85, 0x7a }, 2},
  696. {{ 0x87, 0x04 }, 2},
  697. };
  698. static struct em28xx_reg_seq gpio[] = {
  699. {EM28XX_R06_I2C_CLK, 0x40, 0xff, 300},
  700. {EM2874_R80_GPIO_P0_CTRL, 0xfd, 0xff, 60},
  701. {EM28XX_R15_RGAIN, 0x20, 0xff, 0},
  702. {EM28XX_R16_GGAIN, 0x20, 0xff, 0},
  703. {EM28XX_R17_BGAIN, 0x20, 0xff, 0},
  704. {EM28XX_R18_ROFFSET, 0x00, 0xff, 0},
  705. {EM28XX_R19_GOFFSET, 0x00, 0xff, 0},
  706. {EM28XX_R1A_BOFFSET, 0x00, 0xff, 0},
  707. {EM28XX_R23_UOFFSET, 0x00, 0xff, 0},
  708. {EM28XX_R24_VOFFSET, 0x00, 0xff, 0},
  709. {EM28XX_R26_COMPR, 0x00, 0xff, 0},
  710. {0x13, 0x08, 0xff, 0},
  711. {EM28XX_R12_VINENABLE, 0x27, 0xff, 0},
  712. {EM28XX_R0C_USBSUSP, 0x10, 0xff, 0},
  713. {EM28XX_R27_OUTFMT, 0x00, 0xff, 0},
  714. {EM28XX_R10_VINMODE, 0x00, 0xff, 0},
  715. {EM28XX_R11_VINCTRL, 0x11, 0xff, 0},
  716. {EM2874_R50_IR_CONFIG, 0x01, 0xff, 0},
  717. {EM2874_R5F_TS_ENABLE, 0x80, 0xff, 0},
  718. {EM28XX_R06_I2C_CLK, 0x46, 0xff, 0},
  719. };
  720. em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x46);
  721. /* sleeping ISDB-T */
  722. dev->dvb->i2c_client_demod->addr = 0x14;
  723. for (i = 0; i < ARRAY_SIZE(regs1); i++)
  724. i2c_master_send(dev->dvb->i2c_client_demod, regs1[i].r,
  725. regs1[i].len);
  726. /* sleeping ISDB-S */
  727. dev->dvb->i2c_client_demod->addr = 0x15;
  728. for (i = 0; i < ARRAY_SIZE(regs2); i++)
  729. i2c_master_send(dev->dvb->i2c_client_demod, regs2[i].r,
  730. regs2[i].len);
  731. for (i = 0; i < ARRAY_SIZE(gpio); i++) {
  732. em28xx_write_reg_bits(dev, gpio[i].reg, gpio[i].val,
  733. gpio[i].mask);
  734. if (gpio[i].sleep > 0)
  735. msleep(gpio[i].sleep);
  736. }
  737. };
  738. static struct mt352_config terratec_xs_mt352_cfg = {
  739. .demod_address = (0x1e >> 1),
  740. .no_tuner = 1,
  741. .if2 = 45600,
  742. .demod_init = em28xx_mt352_terratec_xs_init,
  743. };
  744. static struct tda10023_config em28xx_tda10023_config = {
  745. .demod_address = 0x0c,
  746. .invert = 1,
  747. };
  748. static struct cxd2820r_config em28xx_cxd2820r_config = {
  749. .i2c_address = (0xd8 >> 1),
  750. .ts_mode = CXD2820R_TS_SERIAL,
  751. };
  752. static struct tda18271_config em28xx_cxd2820r_tda18271_config = {
  753. .output_opt = TDA18271_OUTPUT_LT_OFF,
  754. .gate = TDA18271_GATE_DIGITAL,
  755. };
  756. static struct zl10353_config em28xx_zl10353_no_i2c_gate_dev = {
  757. .demod_address = (0x1e >> 1),
  758. .disable_i2c_gate_ctrl = 1,
  759. .no_tuner = 1,
  760. .parallel_ts = 1,
  761. };
  762. static struct mt2060_config em28xx_mt2060_config = {
  763. .i2c_address = 0x60,
  764. };
  765. static struct qt1010_config em28xx_qt1010_config = {
  766. .i2c_address = 0x62
  767. };
  768. static const struct mb86a20s_config c3tech_duo_mb86a20s_config = {
  769. .demod_address = 0x10,
  770. .is_serial = true,
  771. };
  772. static struct tda18271_std_map mb86a20s_tda18271_config = {
  773. .dvbt_6 = { .if_freq = 4000, .agc_mode = 3, .std = 4,
  774. .if_lvl = 1, .rfagc_top = 0x37, },
  775. };
  776. static struct tda18271_config c3tech_duo_tda18271_config = {
  777. .std_map = &mb86a20s_tda18271_config,
  778. .gate = TDA18271_GATE_DIGITAL,
  779. .small_i2c = TDA18271_03_BYTE_CHUNK_INIT,
  780. };
  781. static struct tda18271_std_map drx_j_std_map = {
  782. .atsc_6 = { .if_freq = 5000, .agc_mode = 3, .std = 0, .if_lvl = 1,
  783. .rfagc_top = 0x37, },
  784. .qam_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3, .if_lvl = 1,
  785. .rfagc_top = 0x37, },
  786. };
  787. static struct tda18271_config pinnacle_80e_dvb_config = {
  788. .std_map = &drx_j_std_map,
  789. .gate = TDA18271_GATE_DIGITAL,
  790. .role = TDA18271_MASTER,
  791. };
  792. /* ------------------------------------------------------------------ */
  793. static int em28xx_attach_xc3028(u8 addr, struct em28xx *dev)
  794. {
  795. struct dvb_frontend *fe;
  796. struct xc2028_config cfg;
  797. struct xc2028_ctrl ctl;
  798. memset(&cfg, 0, sizeof(cfg));
  799. cfg.i2c_adap = &dev->i2c_adap[dev->def_i2c_bus];
  800. cfg.i2c_addr = addr;
  801. memset(&ctl, 0, sizeof(ctl));
  802. em28xx_setup_xc3028(dev, &ctl);
  803. cfg.ctrl = &ctl;
  804. if (!dev->dvb->fe[0]) {
  805. em28xx_errdev("/2: dvb frontend not attached. "
  806. "Can't attach xc3028\n");
  807. return -EINVAL;
  808. }
  809. fe = dvb_attach(xc2028_attach, dev->dvb->fe[0], &cfg);
  810. if (!fe) {
  811. em28xx_errdev("/2: xc3028 attach failed\n");
  812. dvb_frontend_detach(dev->dvb->fe[0]);
  813. dev->dvb->fe[0] = NULL;
  814. return -EINVAL;
  815. }
  816. em28xx_info("%s/2: xc3028 attached\n", dev->name);
  817. return 0;
  818. }
  819. /* ------------------------------------------------------------------ */
  820. static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module,
  821. struct em28xx *dev, struct device *device)
  822. {
  823. int result;
  824. bool create_rf_connector = false;
  825. mutex_init(&dvb->lock);
  826. /* register adapter */
  827. result = dvb_register_adapter(&dvb->adapter, dev->name, module, device,
  828. adapter_nr);
  829. if (result < 0) {
  830. printk(KERN_WARNING "%s: dvb_register_adapter failed (errno = %d)\n",
  831. dev->name, result);
  832. goto fail_adapter;
  833. }
  834. #ifdef CONFIG_MEDIA_CONTROLLER_DVB
  835. dvb->adapter.mdev = dev->media_dev;
  836. #endif
  837. /* Ensure all frontends negotiate bus access */
  838. dvb->fe[0]->ops.ts_bus_ctrl = em28xx_dvb_bus_ctrl;
  839. if (dvb->fe[1])
  840. dvb->fe[1]->ops.ts_bus_ctrl = em28xx_dvb_bus_ctrl;
  841. dvb->adapter.priv = &dev->i2c_bus[dev->def_i2c_bus];
  842. /* register frontend */
  843. result = dvb_register_frontend(&dvb->adapter, dvb->fe[0]);
  844. if (result < 0) {
  845. printk(KERN_WARNING "%s: dvb_register_frontend failed (errno = %d)\n",
  846. dev->name, result);
  847. goto fail_frontend0;
  848. }
  849. /* register 2nd frontend */
  850. if (dvb->fe[1]) {
  851. result = dvb_register_frontend(&dvb->adapter, dvb->fe[1]);
  852. if (result < 0) {
  853. printk(KERN_WARNING "%s: 2nd dvb_register_frontend failed (errno = %d)\n",
  854. dev->name, result);
  855. goto fail_frontend1;
  856. }
  857. }
  858. /* register demux stuff */
  859. dvb->demux.dmx.capabilities =
  860. DMX_TS_FILTERING | DMX_SECTION_FILTERING |
  861. DMX_MEMORY_BASED_FILTERING;
  862. dvb->demux.priv = dvb;
  863. dvb->demux.filternum = 256;
  864. dvb->demux.feednum = 256;
  865. dvb->demux.start_feed = em28xx_start_feed;
  866. dvb->demux.stop_feed = em28xx_stop_feed;
  867. result = dvb_dmx_init(&dvb->demux);
  868. if (result < 0) {
  869. printk(KERN_WARNING "%s: dvb_dmx_init failed (errno = %d)\n",
  870. dev->name, result);
  871. goto fail_dmx;
  872. }
  873. dvb->dmxdev.filternum = 256;
  874. dvb->dmxdev.demux = &dvb->demux.dmx;
  875. dvb->dmxdev.capabilities = 0;
  876. result = dvb_dmxdev_init(&dvb->dmxdev, &dvb->adapter);
  877. if (result < 0) {
  878. printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n",
  879. dev->name, result);
  880. goto fail_dmxdev;
  881. }
  882. dvb->fe_hw.source = DMX_FRONTEND_0;
  883. result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw);
  884. if (result < 0) {
  885. printk(KERN_WARNING "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n",
  886. dev->name, result);
  887. goto fail_fe_hw;
  888. }
  889. dvb->fe_mem.source = DMX_MEMORY_FE;
  890. result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem);
  891. if (result < 0) {
  892. printk(KERN_WARNING "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n",
  893. dev->name, result);
  894. goto fail_fe_mem;
  895. }
  896. result = dvb->demux.dmx.connect_frontend(&dvb->demux.dmx, &dvb->fe_hw);
  897. if (result < 0) {
  898. printk(KERN_WARNING "%s: connect_frontend failed (errno = %d)\n",
  899. dev->name, result);
  900. goto fail_fe_conn;
  901. }
  902. /* register network adapter */
  903. dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx);
  904. /* If the analog part won't create RF connectors, DVB will do it */
  905. if (!dev->has_video || (dev->tuner_type == TUNER_ABSENT))
  906. create_rf_connector = true;
  907. result = dvb_create_media_graph(&dvb->adapter, create_rf_connector);
  908. if (result < 0)
  909. goto fail_create_graph;
  910. return 0;
  911. fail_create_graph:
  912. dvb_net_release(&dvb->net);
  913. fail_fe_conn:
  914. dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem);
  915. fail_fe_mem:
  916. dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw);
  917. fail_fe_hw:
  918. dvb_dmxdev_release(&dvb->dmxdev);
  919. fail_dmxdev:
  920. dvb_dmx_release(&dvb->demux);
  921. fail_dmx:
  922. if (dvb->fe[1])
  923. dvb_unregister_frontend(dvb->fe[1]);
  924. dvb_unregister_frontend(dvb->fe[0]);
  925. fail_frontend1:
  926. if (dvb->fe[1])
  927. dvb_frontend_detach(dvb->fe[1]);
  928. fail_frontend0:
  929. dvb_frontend_detach(dvb->fe[0]);
  930. dvb_unregister_adapter(&dvb->adapter);
  931. fail_adapter:
  932. return result;
  933. }
  934. static void em28xx_unregister_dvb(struct em28xx_dvb *dvb)
  935. {
  936. dvb_net_release(&dvb->net);
  937. dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem);
  938. dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw);
  939. dvb_dmxdev_release(&dvb->dmxdev);
  940. dvb_dmx_release(&dvb->demux);
  941. if (dvb->fe[1])
  942. dvb_unregister_frontend(dvb->fe[1]);
  943. dvb_unregister_frontend(dvb->fe[0]);
  944. if (dvb->fe[1] && !dvb->dont_attach_fe1)
  945. dvb_frontend_detach(dvb->fe[1]);
  946. dvb_frontend_detach(dvb->fe[0]);
  947. dvb_unregister_adapter(&dvb->adapter);
  948. }
  949. static int em28xx_dvb_init(struct em28xx *dev)
  950. {
  951. int result = 0;
  952. struct em28xx_dvb *dvb;
  953. if (dev->is_audio_only) {
  954. /* Shouldn't initialize IR for this interface */
  955. return 0;
  956. }
  957. if (!dev->board.has_dvb) {
  958. /* This device does not support the extension */
  959. return 0;
  960. }
  961. em28xx_info("Binding DVB extension\n");
  962. dvb = kzalloc(sizeof(struct em28xx_dvb), GFP_KERNEL);
  963. if (dvb == NULL) {
  964. em28xx_info("em28xx_dvb: memory allocation failed\n");
  965. return -ENOMEM;
  966. }
  967. dev->dvb = dvb;
  968. dvb->fe[0] = dvb->fe[1] = NULL;
  969. /* pre-allocate DVB usb transfer buffers */
  970. if (dev->dvb_xfer_bulk) {
  971. result = em28xx_alloc_urbs(dev, EM28XX_DIGITAL_MODE,
  972. dev->dvb_xfer_bulk,
  973. EM28XX_DVB_NUM_BUFS,
  974. 512,
  975. EM28XX_DVB_BULK_PACKET_MULTIPLIER);
  976. } else {
  977. result = em28xx_alloc_urbs(dev, EM28XX_DIGITAL_MODE,
  978. dev->dvb_xfer_bulk,
  979. EM28XX_DVB_NUM_BUFS,
  980. dev->dvb_max_pkt_size_isoc,
  981. EM28XX_DVB_NUM_ISOC_PACKETS);
  982. }
  983. if (result) {
  984. em28xx_errdev("em28xx_dvb: failed to pre-allocate USB transfer buffers for DVB.\n");
  985. kfree(dvb);
  986. dev->dvb = NULL;
  987. return result;
  988. }
  989. mutex_lock(&dev->lock);
  990. em28xx_set_mode(dev, EM28XX_DIGITAL_MODE);
  991. /* init frontend */
  992. switch (dev->model) {
  993. case EM2874_BOARD_LEADERSHIP_ISDBT:
  994. dvb->fe[0] = dvb_attach(s921_attach,
  995. &sharp_isdbt, &dev->i2c_adap[dev->def_i2c_bus]);
  996. if (!dvb->fe[0]) {
  997. result = -EINVAL;
  998. goto out_free;
  999. }
  1000. break;
  1001. case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850:
  1002. case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
  1003. case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
  1004. case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
  1005. dvb->fe[0] = dvb_attach(lgdt330x_attach,
  1006. &em2880_lgdt3303_dev,
  1007. &dev->i2c_adap[dev->def_i2c_bus]);
  1008. if (em28xx_attach_xc3028(0x61, dev) < 0) {
  1009. result = -EINVAL;
  1010. goto out_free;
  1011. }
  1012. break;
  1013. case EM2880_BOARD_KWORLD_DVB_310U:
  1014. dvb->fe[0] = dvb_attach(zl10353_attach,
  1015. &em28xx_zl10353_with_xc3028,
  1016. &dev->i2c_adap[dev->def_i2c_bus]);
  1017. if (em28xx_attach_xc3028(0x61, dev) < 0) {
  1018. result = -EINVAL;
  1019. goto out_free;
  1020. }
  1021. break;
  1022. case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
  1023. case EM2882_BOARD_TERRATEC_HYBRID_XS:
  1024. case EM2880_BOARD_EMPIRE_DUAL_TV:
  1025. dvb->fe[0] = dvb_attach(zl10353_attach,
  1026. &em28xx_zl10353_xc3028_no_i2c_gate,
  1027. &dev->i2c_adap[dev->def_i2c_bus]);
  1028. if (em28xx_attach_xc3028(0x61, dev) < 0) {
  1029. result = -EINVAL;
  1030. goto out_free;
  1031. }
  1032. break;
  1033. case EM2880_BOARD_TERRATEC_HYBRID_XS:
  1034. case EM2880_BOARD_TERRATEC_HYBRID_XS_FR:
  1035. case EM2881_BOARD_PINNACLE_HYBRID_PRO:
  1036. case EM2882_BOARD_DIKOM_DK300:
  1037. case EM2882_BOARD_KWORLD_VS_DVBT:
  1038. dvb->fe[0] = dvb_attach(zl10353_attach,
  1039. &em28xx_zl10353_xc3028_no_i2c_gate,
  1040. &dev->i2c_adap[dev->def_i2c_bus]);
  1041. if (dvb->fe[0] == NULL) {
  1042. /* This board could have either a zl10353 or a mt352.
  1043. If the chip id isn't for zl10353, try mt352 */
  1044. dvb->fe[0] = dvb_attach(mt352_attach,
  1045. &terratec_xs_mt352_cfg,
  1046. &dev->i2c_adap[dev->def_i2c_bus]);
  1047. }
  1048. if (em28xx_attach_xc3028(0x61, dev) < 0) {
  1049. result = -EINVAL;
  1050. goto out_free;
  1051. }
  1052. break;
  1053. case EM2870_BOARD_TERRATEC_XS_MT2060:
  1054. dvb->fe[0] = dvb_attach(zl10353_attach,
  1055. &em28xx_zl10353_no_i2c_gate_dev,
  1056. &dev->i2c_adap[dev->def_i2c_bus]);
  1057. if (dvb->fe[0] != NULL) {
  1058. dvb_attach(mt2060_attach, dvb->fe[0],
  1059. &dev->i2c_adap[dev->def_i2c_bus],
  1060. &em28xx_mt2060_config, 1220);
  1061. }
  1062. break;
  1063. case EM2870_BOARD_KWORLD_355U:
  1064. dvb->fe[0] = dvb_attach(zl10353_attach,
  1065. &em28xx_zl10353_no_i2c_gate_dev,
  1066. &dev->i2c_adap[dev->def_i2c_bus]);
  1067. if (dvb->fe[0] != NULL)
  1068. dvb_attach(qt1010_attach, dvb->fe[0],
  1069. &dev->i2c_adap[dev->def_i2c_bus], &em28xx_qt1010_config);
  1070. break;
  1071. case EM2883_BOARD_KWORLD_HYBRID_330U:
  1072. case EM2882_BOARD_EVGA_INDTUBE:
  1073. dvb->fe[0] = dvb_attach(s5h1409_attach,
  1074. &em28xx_s5h1409_with_xc3028,
  1075. &dev->i2c_adap[dev->def_i2c_bus]);
  1076. if (em28xx_attach_xc3028(0x61, dev) < 0) {
  1077. result = -EINVAL;
  1078. goto out_free;
  1079. }
  1080. break;
  1081. case EM2882_BOARD_KWORLD_ATSC_315U:
  1082. dvb->fe[0] = dvb_attach(lgdt330x_attach,
  1083. &em2880_lgdt3303_dev,
  1084. &dev->i2c_adap[dev->def_i2c_bus]);
  1085. if (dvb->fe[0] != NULL) {
  1086. if (!dvb_attach(simple_tuner_attach, dvb->fe[0],
  1087. &dev->i2c_adap[dev->def_i2c_bus],
  1088. 0x61, TUNER_THOMSON_DTT761X)) {
  1089. result = -EINVAL;
  1090. goto out_free;
  1091. }
  1092. }
  1093. break;
  1094. case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
  1095. case EM2882_BOARD_PINNACLE_HYBRID_PRO_330E:
  1096. dvb->fe[0] = dvb_attach(drxd_attach, &em28xx_drxd, NULL,
  1097. &dev->i2c_adap[dev->def_i2c_bus], &dev->udev->dev);
  1098. if (em28xx_attach_xc3028(0x61, dev) < 0) {
  1099. result = -EINVAL;
  1100. goto out_free;
  1101. }
  1102. break;
  1103. case EM2870_BOARD_REDDO_DVB_C_USB_BOX:
  1104. /* Philips CU1216L NIM (Philips TDA10023 + Infineon TUA6034) */
  1105. dvb->fe[0] = dvb_attach(tda10023_attach,
  1106. &em28xx_tda10023_config,
  1107. &dev->i2c_adap[dev->def_i2c_bus], 0x48);
  1108. if (dvb->fe[0]) {
  1109. if (!dvb_attach(simple_tuner_attach, dvb->fe[0],
  1110. &dev->i2c_adap[dev->def_i2c_bus],
  1111. 0x60, TUNER_PHILIPS_CU1216L)) {
  1112. result = -EINVAL;
  1113. goto out_free;
  1114. }
  1115. }
  1116. break;
  1117. case EM2870_BOARD_KWORLD_A340:
  1118. dvb->fe[0] = dvb_attach(lgdt3305_attach,
  1119. &em2870_lgdt3304_dev,
  1120. &dev->i2c_adap[dev->def_i2c_bus]);
  1121. if (!dvb->fe[0]) {
  1122. result = -EINVAL;
  1123. goto out_free;
  1124. }
  1125. if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60,
  1126. &dev->i2c_adap[dev->def_i2c_bus],
  1127. &kworld_a340_config)) {
  1128. dvb_frontend_detach(dvb->fe[0]);
  1129. result = -EINVAL;
  1130. goto out_free;
  1131. }
  1132. break;
  1133. case EM28174_BOARD_PCTV_290E:
  1134. /* set default GPIO0 for LNA, used if GPIOLIB is undefined */
  1135. dvb->lna_gpio = CXD2820R_GPIO_E | CXD2820R_GPIO_O |
  1136. CXD2820R_GPIO_L;
  1137. dvb->fe[0] = dvb_attach(cxd2820r_attach,
  1138. &em28xx_cxd2820r_config,
  1139. &dev->i2c_adap[dev->def_i2c_bus],
  1140. &dvb->lna_gpio);
  1141. if (dvb->fe[0]) {
  1142. /* FE 0 attach tuner */
  1143. if (!dvb_attach(tda18271_attach,
  1144. dvb->fe[0],
  1145. 0x60,
  1146. &dev->i2c_adap[dev->def_i2c_bus],
  1147. &em28xx_cxd2820r_tda18271_config)) {
  1148. dvb_frontend_detach(dvb->fe[0]);
  1149. result = -EINVAL;
  1150. goto out_free;
  1151. }
  1152. #ifdef CONFIG_GPIOLIB
  1153. /* enable LNA for DVB-T, DVB-T2 and DVB-C */
  1154. result = gpio_request_one(dvb->lna_gpio,
  1155. GPIOF_OUT_INIT_LOW, NULL);
  1156. if (result)
  1157. em28xx_errdev("gpio request failed %d\n",
  1158. result);
  1159. else
  1160. gpio_free(dvb->lna_gpio);
  1161. result = 0; /* continue even set LNA fails */
  1162. #endif
  1163. dvb->fe[0]->ops.set_lna = em28xx_pctv_290e_set_lna;
  1164. }
  1165. break;
  1166. case EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C:
  1167. {
  1168. struct xc5000_config cfg;
  1169. hauppauge_hvr930c_init(dev);
  1170. dvb->fe[0] = dvb_attach(drxk_attach,
  1171. &hauppauge_930c_drxk, &dev->i2c_adap[dev->def_i2c_bus]);
  1172. if (!dvb->fe[0]) {
  1173. result = -EINVAL;
  1174. goto out_free;
  1175. }
  1176. /* FIXME: do we need a pll semaphore? */
  1177. dvb->fe[0]->sec_priv = dvb;
  1178. sema_init(&dvb->pll_mutex, 1);
  1179. dvb->gate_ctrl = dvb->fe[0]->ops.i2c_gate_ctrl;
  1180. dvb->fe[0]->ops.i2c_gate_ctrl = drxk_gate_ctrl;
  1181. /* Attach xc5000 */
  1182. memset(&cfg, 0, sizeof(cfg));
  1183. cfg.i2c_address = 0x61;
  1184. cfg.if_khz = 4000;
  1185. if (dvb->fe[0]->ops.i2c_gate_ctrl)
  1186. dvb->fe[0]->ops.i2c_gate_ctrl(dvb->fe[0], 1);
  1187. if (!dvb_attach(xc5000_attach, dvb->fe[0], &dev->i2c_adap[dev->def_i2c_bus],
  1188. &cfg)) {
  1189. result = -EINVAL;
  1190. goto out_free;
  1191. }
  1192. if (dvb->fe[0]->ops.i2c_gate_ctrl)
  1193. dvb->fe[0]->ops.i2c_gate_ctrl(dvb->fe[0], 0);
  1194. break;
  1195. }
  1196. case EM2884_BOARD_TERRATEC_H5:
  1197. terratec_h5_init(dev);
  1198. dvb->fe[0] = dvb_attach(drxk_attach, &terratec_h5_drxk, &dev->i2c_adap[dev->def_i2c_bus]);
  1199. if (!dvb->fe[0]) {
  1200. result = -EINVAL;
  1201. goto out_free;
  1202. }
  1203. /* FIXME: do we need a pll semaphore? */
  1204. dvb->fe[0]->sec_priv = dvb;
  1205. sema_init(&dvb->pll_mutex, 1);
  1206. dvb->gate_ctrl = dvb->fe[0]->ops.i2c_gate_ctrl;
  1207. dvb->fe[0]->ops.i2c_gate_ctrl = drxk_gate_ctrl;
  1208. /* Attach tda18271 to DVB-C frontend */
  1209. if (dvb->fe[0]->ops.i2c_gate_ctrl)
  1210. dvb->fe[0]->ops.i2c_gate_ctrl(dvb->fe[0], 1);
  1211. if (!dvb_attach(tda18271c2dd_attach, dvb->fe[0], &dev->i2c_adap[dev->def_i2c_bus], 0x60)) {
  1212. result = -EINVAL;
  1213. goto out_free;
  1214. }
  1215. if (dvb->fe[0]->ops.i2c_gate_ctrl)
  1216. dvb->fe[0]->ops.i2c_gate_ctrl(dvb->fe[0], 0);
  1217. break;
  1218. case EM2884_BOARD_C3TECH_DIGITAL_DUO:
  1219. dvb->fe[0] = dvb_attach(mb86a20s_attach,
  1220. &c3tech_duo_mb86a20s_config,
  1221. &dev->i2c_adap[dev->def_i2c_bus]);
  1222. if (dvb->fe[0] != NULL)
  1223. dvb_attach(tda18271_attach, dvb->fe[0], 0x60,
  1224. &dev->i2c_adap[dev->def_i2c_bus],
  1225. &c3tech_duo_tda18271_config);
  1226. break;
  1227. case EM28174_BOARD_PCTV_460E: {
  1228. struct i2c_client *client;
  1229. struct i2c_board_info board_info;
  1230. struct tda10071_platform_data tda10071_pdata = {};
  1231. struct a8293_platform_data a8293_pdata = {};
  1232. /* attach demod + tuner combo */
  1233. tda10071_pdata.clk = 40444000, /* 40.444 MHz */
  1234. tda10071_pdata.i2c_wr_max = 64,
  1235. tda10071_pdata.ts_mode = TDA10071_TS_SERIAL,
  1236. tda10071_pdata.pll_multiplier = 20,
  1237. tda10071_pdata.tuner_i2c_addr = 0x14,
  1238. memset(&board_info, 0, sizeof(board_info));
  1239. strlcpy(board_info.type, "tda10071_cx24118", I2C_NAME_SIZE);
  1240. board_info.addr = 0x55;
  1241. board_info.platform_data = &tda10071_pdata;
  1242. request_module("tda10071");
  1243. client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &board_info);
  1244. if (client == NULL || client->dev.driver == NULL) {
  1245. result = -ENODEV;
  1246. goto out_free;
  1247. }
  1248. if (!try_module_get(client->dev.driver->owner)) {
  1249. i2c_unregister_device(client);
  1250. result = -ENODEV;
  1251. goto out_free;
  1252. }
  1253. dvb->fe[0] = tda10071_pdata.get_dvb_frontend(client);
  1254. dvb->i2c_client_demod = client;
  1255. /* attach SEC */
  1256. a8293_pdata.dvb_frontend = dvb->fe[0];
  1257. memset(&board_info, 0, sizeof(board_info));
  1258. strlcpy(board_info.type, "a8293", I2C_NAME_SIZE);
  1259. board_info.addr = 0x08;
  1260. board_info.platform_data = &a8293_pdata;
  1261. request_module("a8293");
  1262. client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &board_info);
  1263. if (client == NULL || client->dev.driver == NULL) {
  1264. module_put(dvb->i2c_client_demod->dev.driver->owner);
  1265. i2c_unregister_device(dvb->i2c_client_demod);
  1266. result = -ENODEV;
  1267. goto out_free;
  1268. }
  1269. if (!try_module_get(client->dev.driver->owner)) {
  1270. i2c_unregister_device(client);
  1271. module_put(dvb->i2c_client_demod->dev.driver->owner);
  1272. i2c_unregister_device(dvb->i2c_client_demod);
  1273. result = -ENODEV;
  1274. goto out_free;
  1275. }
  1276. dvb->i2c_client_sec = client;
  1277. break;
  1278. }
  1279. case EM2874_BOARD_DELOCK_61959:
  1280. case EM2874_BOARD_MAXMEDIA_UB425_TC:
  1281. /* attach demodulator */
  1282. dvb->fe[0] = dvb_attach(drxk_attach, &maxmedia_ub425_tc_drxk,
  1283. &dev->i2c_adap[dev->def_i2c_bus]);
  1284. if (dvb->fe[0]) {
  1285. /* disable I2C-gate */
  1286. dvb->fe[0]->ops.i2c_gate_ctrl = NULL;
  1287. /* attach tuner */
  1288. if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60,
  1289. &dev->i2c_adap[dev->def_i2c_bus],
  1290. &em28xx_cxd2820r_tda18271_config)) {
  1291. dvb_frontend_detach(dvb->fe[0]);
  1292. result = -EINVAL;
  1293. goto out_free;
  1294. }
  1295. }
  1296. break;
  1297. case EM2884_BOARD_PCTV_510E:
  1298. case EM2884_BOARD_PCTV_520E:
  1299. pctv_520e_init(dev);
  1300. /* attach demodulator */
  1301. dvb->fe[0] = dvb_attach(drxk_attach, &pctv_520e_drxk,
  1302. &dev->i2c_adap[dev->def_i2c_bus]);
  1303. if (dvb->fe[0]) {
  1304. /* attach tuner */
  1305. if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60,
  1306. &dev->i2c_adap[dev->def_i2c_bus],
  1307. &em28xx_cxd2820r_tda18271_config)) {
  1308. dvb_frontend_detach(dvb->fe[0]);
  1309. result = -EINVAL;
  1310. goto out_free;
  1311. }
  1312. }
  1313. break;
  1314. case EM2884_BOARD_ELGATO_EYETV_HYBRID_2008:
  1315. case EM2884_BOARD_CINERGY_HTC_STICK:
  1316. terratec_htc_stick_init(dev);
  1317. /* attach demodulator */
  1318. dvb->fe[0] = dvb_attach(drxk_attach, &terratec_htc_stick_drxk,
  1319. &dev->i2c_adap[dev->def_i2c_bus]);
  1320. if (!dvb->fe[0]) {
  1321. result = -EINVAL;
  1322. goto out_free;
  1323. }
  1324. /* Attach the demodulator. */
  1325. if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60,
  1326. &dev->i2c_adap[dev->def_i2c_bus],
  1327. &em28xx_cxd2820r_tda18271_config)) {
  1328. result = -EINVAL;
  1329. goto out_free;
  1330. }
  1331. break;
  1332. case EM2884_BOARD_TERRATEC_HTC_USB_XS:
  1333. terratec_htc_usb_xs_init(dev);
  1334. /* attach demodulator */
  1335. dvb->fe[0] = dvb_attach(drxk_attach, &terratec_htc_stick_drxk,
  1336. &dev->i2c_adap[dev->def_i2c_bus]);
  1337. if (!dvb->fe[0]) {
  1338. result = -EINVAL;
  1339. goto out_free;
  1340. }
  1341. /* Attach the demodulator. */
  1342. if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60,
  1343. &dev->i2c_adap[dev->def_i2c_bus],
  1344. &em28xx_cxd2820r_tda18271_config)) {
  1345. result = -EINVAL;
  1346. goto out_free;
  1347. }
  1348. break;
  1349. case EM2874_BOARD_KWORLD_UB435Q_V2:
  1350. dvb->fe[0] = dvb_attach(lgdt3305_attach,
  1351. &em2874_lgdt3305_dev,
  1352. &dev->i2c_adap[dev->def_i2c_bus]);
  1353. if (!dvb->fe[0]) {
  1354. result = -EINVAL;
  1355. goto out_free;
  1356. }
  1357. /* Attach the demodulator. */
  1358. if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60,
  1359. &dev->i2c_adap[dev->def_i2c_bus],
  1360. &kworld_ub435q_v2_config)) {
  1361. result = -EINVAL;
  1362. goto out_free;
  1363. }
  1364. break;
  1365. case EM2874_BOARD_KWORLD_UB435Q_V3:
  1366. {
  1367. struct i2c_client *client;
  1368. struct i2c_adapter *adapter = &dev->i2c_adap[dev->def_i2c_bus];
  1369. struct i2c_board_info board_info = {
  1370. .type = "tda18212",
  1371. .addr = 0x60,
  1372. .platform_data = &kworld_ub435q_v3_config,
  1373. };
  1374. dvb->fe[0] = dvb_attach(lgdt3305_attach,
  1375. &em2874_lgdt3305_nogate_dev,
  1376. &dev->i2c_adap[dev->def_i2c_bus]);
  1377. if (!dvb->fe[0]) {
  1378. result = -EINVAL;
  1379. goto out_free;
  1380. }
  1381. /* attach tuner */
  1382. kworld_ub435q_v3_config.fe = dvb->fe[0];
  1383. request_module("tda18212");
  1384. client = i2c_new_device(adapter, &board_info);
  1385. if (client == NULL || client->dev.driver == NULL) {
  1386. dvb_frontend_detach(dvb->fe[0]);
  1387. result = -ENODEV;
  1388. goto out_free;
  1389. }
  1390. if (!try_module_get(client->dev.driver->owner)) {
  1391. i2c_unregister_device(client);
  1392. dvb_frontend_detach(dvb->fe[0]);
  1393. result = -ENODEV;
  1394. goto out_free;
  1395. }
  1396. dvb->i2c_client_tuner = client;
  1397. break;
  1398. }
  1399. case EM2874_BOARD_PCTV_HD_MINI_80E:
  1400. dvb->fe[0] = dvb_attach(drx39xxj_attach, &dev->i2c_adap[dev->def_i2c_bus]);
  1401. if (dvb->fe[0] != NULL) {
  1402. dvb->fe[0] = dvb_attach(tda18271_attach, dvb->fe[0], 0x60,
  1403. &dev->i2c_adap[dev->def_i2c_bus],
  1404. &pinnacle_80e_dvb_config);
  1405. if (!dvb->fe[0]) {
  1406. result = -EINVAL;
  1407. goto out_free;
  1408. }
  1409. }
  1410. break;
  1411. case EM28178_BOARD_PCTV_461E: {
  1412. struct i2c_client *client;
  1413. struct i2c_adapter *i2c_adapter;
  1414. struct i2c_board_info board_info;
  1415. struct m88ds3103_platform_data m88ds3103_pdata = {};
  1416. struct ts2020_config ts2020_config = {};
  1417. struct a8293_platform_data a8293_pdata = {};
  1418. /* attach demod */
  1419. m88ds3103_pdata.clk = 27000000;
  1420. m88ds3103_pdata.i2c_wr_max = 33;
  1421. m88ds3103_pdata.ts_mode = M88DS3103_TS_PARALLEL;
  1422. m88ds3103_pdata.ts_clk = 16000;
  1423. m88ds3103_pdata.ts_clk_pol = 1;
  1424. m88ds3103_pdata.agc = 0x99;
  1425. memset(&board_info, 0, sizeof(board_info));
  1426. strlcpy(board_info.type, "m88ds3103", I2C_NAME_SIZE);
  1427. board_info.addr = 0x68;
  1428. board_info.platform_data = &m88ds3103_pdata;
  1429. request_module("m88ds3103");
  1430. client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &board_info);
  1431. if (client == NULL || client->dev.driver == NULL) {
  1432. result = -ENODEV;
  1433. goto out_free;
  1434. }
  1435. if (!try_module_get(client->dev.driver->owner)) {
  1436. i2c_unregister_device(client);
  1437. result = -ENODEV;
  1438. goto out_free;
  1439. }
  1440. dvb->fe[0] = m88ds3103_pdata.get_dvb_frontend(client);
  1441. i2c_adapter = m88ds3103_pdata.get_i2c_adapter(client);
  1442. dvb->i2c_client_demod = client;
  1443. /* attach tuner */
  1444. ts2020_config.fe = dvb->fe[0];
  1445. memset(&board_info, 0, sizeof(board_info));
  1446. strlcpy(board_info.type, "ts2022", I2C_NAME_SIZE);
  1447. board_info.addr = 0x60;
  1448. board_info.platform_data = &ts2020_config;
  1449. request_module("ts2020");
  1450. client = i2c_new_device(i2c_adapter, &board_info);
  1451. if (client == NULL || client->dev.driver == NULL) {
  1452. module_put(dvb->i2c_client_demod->dev.driver->owner);
  1453. i2c_unregister_device(dvb->i2c_client_demod);
  1454. result = -ENODEV;
  1455. goto out_free;
  1456. }
  1457. if (!try_module_get(client->dev.driver->owner)) {
  1458. i2c_unregister_device(client);
  1459. module_put(dvb->i2c_client_demod->dev.driver->owner);
  1460. i2c_unregister_device(dvb->i2c_client_demod);
  1461. result = -ENODEV;
  1462. goto out_free;
  1463. }
  1464. dvb->i2c_client_tuner = client;
  1465. /* delegate signal strength measurement to tuner */
  1466. dvb->fe[0]->ops.read_signal_strength =
  1467. dvb->fe[0]->ops.tuner_ops.get_rf_strength;
  1468. /* attach SEC */
  1469. a8293_pdata.dvb_frontend = dvb->fe[0];
  1470. memset(&board_info, 0, sizeof(board_info));
  1471. strlcpy(board_info.type, "a8293", I2C_NAME_SIZE);
  1472. board_info.addr = 0x08;
  1473. board_info.platform_data = &a8293_pdata;
  1474. request_module("a8293");
  1475. client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &board_info);
  1476. if (client == NULL || client->dev.driver == NULL) {
  1477. module_put(dvb->i2c_client_tuner->dev.driver->owner);
  1478. i2c_unregister_device(dvb->i2c_client_tuner);
  1479. module_put(dvb->i2c_client_demod->dev.driver->owner);
  1480. i2c_unregister_device(dvb->i2c_client_demod);
  1481. result = -ENODEV;
  1482. goto out_free;
  1483. }
  1484. if (!try_module_get(client->dev.driver->owner)) {
  1485. i2c_unregister_device(client);
  1486. module_put(dvb->i2c_client_tuner->dev.driver->owner);
  1487. i2c_unregister_device(dvb->i2c_client_tuner);
  1488. module_put(dvb->i2c_client_demod->dev.driver->owner);
  1489. i2c_unregister_device(dvb->i2c_client_demod);
  1490. result = -ENODEV;
  1491. goto out_free;
  1492. }
  1493. dvb->i2c_client_sec = client;
  1494. break;
  1495. }
  1496. case EM28178_BOARD_PCTV_292E:
  1497. {
  1498. struct i2c_adapter *adapter;
  1499. struct i2c_client *client;
  1500. struct i2c_board_info info;
  1501. struct si2168_config si2168_config;
  1502. struct si2157_config si2157_config;
  1503. /* attach demod */
  1504. memset(&si2168_config, 0, sizeof(si2168_config));
  1505. si2168_config.i2c_adapter = &adapter;
  1506. si2168_config.fe = &dvb->fe[0];
  1507. si2168_config.ts_mode = SI2168_TS_PARALLEL;
  1508. memset(&info, 0, sizeof(struct i2c_board_info));
  1509. strlcpy(info.type, "si2168", I2C_NAME_SIZE);
  1510. info.addr = 0x64;
  1511. info.platform_data = &si2168_config;
  1512. request_module(info.type);
  1513. client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &info);
  1514. if (client == NULL || client->dev.driver == NULL) {
  1515. result = -ENODEV;
  1516. goto out_free;
  1517. }
  1518. if (!try_module_get(client->dev.driver->owner)) {
  1519. i2c_unregister_device(client);
  1520. result = -ENODEV;
  1521. goto out_free;
  1522. }
  1523. dvb->i2c_client_demod = client;
  1524. /* attach tuner */
  1525. memset(&si2157_config, 0, sizeof(si2157_config));
  1526. si2157_config.fe = dvb->fe[0];
  1527. si2157_config.if_port = 1;
  1528. #ifdef CONFIG_MEDIA_CONTROLLER_DVB
  1529. si2157_config.mdev = dev->media_dev;
  1530. #endif
  1531. memset(&info, 0, sizeof(struct i2c_board_info));
  1532. strlcpy(info.type, "si2157", I2C_NAME_SIZE);
  1533. info.addr = 0x60;
  1534. info.platform_data = &si2157_config;
  1535. request_module(info.type);
  1536. client = i2c_new_device(adapter, &info);
  1537. if (client == NULL || client->dev.driver == NULL) {
  1538. module_put(dvb->i2c_client_demod->dev.driver->owner);
  1539. i2c_unregister_device(dvb->i2c_client_demod);
  1540. result = -ENODEV;
  1541. goto out_free;
  1542. }
  1543. if (!try_module_get(client->dev.driver->owner)) {
  1544. i2c_unregister_device(client);
  1545. module_put(dvb->i2c_client_demod->dev.driver->owner);
  1546. i2c_unregister_device(dvb->i2c_client_demod);
  1547. result = -ENODEV;
  1548. goto out_free;
  1549. }
  1550. dvb->i2c_client_tuner = client;
  1551. dvb->fe[0]->ops.set_lna = em28xx_pctv_292e_set_lna;
  1552. }
  1553. break;
  1554. case EM28178_BOARD_TERRATEC_T2_STICK_HD:
  1555. {
  1556. struct i2c_adapter *adapter;
  1557. struct i2c_client *client;
  1558. struct i2c_board_info info;
  1559. struct si2168_config si2168_config;
  1560. struct si2157_config si2157_config;
  1561. /* attach demod */
  1562. memset(&si2168_config, 0, sizeof(si2168_config));
  1563. si2168_config.i2c_adapter = &adapter;
  1564. si2168_config.fe = &dvb->fe[0];
  1565. si2168_config.ts_mode = SI2168_TS_PARALLEL;
  1566. memset(&info, 0, sizeof(struct i2c_board_info));
  1567. strlcpy(info.type, "si2168", I2C_NAME_SIZE);
  1568. info.addr = 0x64;
  1569. info.platform_data = &si2168_config;
  1570. request_module(info.type);
  1571. client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &info);
  1572. if (client == NULL || client->dev.driver == NULL) {
  1573. result = -ENODEV;
  1574. goto out_free;
  1575. }
  1576. if (!try_module_get(client->dev.driver->owner)) {
  1577. i2c_unregister_device(client);
  1578. result = -ENODEV;
  1579. goto out_free;
  1580. }
  1581. dvb->i2c_client_demod = client;
  1582. /* attach tuner */
  1583. memset(&si2157_config, 0, sizeof(si2157_config));
  1584. si2157_config.fe = dvb->fe[0];
  1585. si2157_config.if_port = 0;
  1586. #ifdef CONFIG_MEDIA_CONTROLLER_DVB
  1587. si2157_config.mdev = dev->media_dev;
  1588. #endif
  1589. memset(&info, 0, sizeof(struct i2c_board_info));
  1590. strlcpy(info.type, "si2146", I2C_NAME_SIZE);
  1591. info.addr = 0x60;
  1592. info.platform_data = &si2157_config;
  1593. request_module("si2157");
  1594. client = i2c_new_device(adapter, &info);
  1595. if (client == NULL || client->dev.driver == NULL) {
  1596. module_put(dvb->i2c_client_demod->dev.driver->owner);
  1597. i2c_unregister_device(dvb->i2c_client_demod);
  1598. result = -ENODEV;
  1599. goto out_free;
  1600. }
  1601. if (!try_module_get(client->dev.driver->owner)) {
  1602. i2c_unregister_device(client);
  1603. module_put(dvb->i2c_client_demod->dev.driver->owner);
  1604. i2c_unregister_device(dvb->i2c_client_demod);
  1605. result = -ENODEV;
  1606. goto out_free;
  1607. }
  1608. dvb->i2c_client_tuner = client;
  1609. }
  1610. break;
  1611. case EM28178_BOARD_PLEX_PX_BCUD:
  1612. {
  1613. struct i2c_client *client;
  1614. struct i2c_board_info info;
  1615. struct tc90522_config tc90522_config;
  1616. struct qm1d1c0042_config qm1d1c0042_config;
  1617. /* attach demod */
  1618. memset(&tc90522_config, 0, sizeof(tc90522_config));
  1619. memset(&info, 0, sizeof(struct i2c_board_info));
  1620. strlcpy(info.type, "tc90522sat", I2C_NAME_SIZE);
  1621. info.addr = 0x15;
  1622. info.platform_data = &tc90522_config;
  1623. request_module("tc90522");
  1624. client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &info);
  1625. if (client == NULL || client->dev.driver == NULL) {
  1626. result = -ENODEV;
  1627. goto out_free;
  1628. }
  1629. dvb->i2c_client_demod = client;
  1630. if (!try_module_get(client->dev.driver->owner)) {
  1631. i2c_unregister_device(client);
  1632. result = -ENODEV;
  1633. goto out_free;
  1634. }
  1635. /* attach tuner */
  1636. memset(&qm1d1c0042_config, 0,
  1637. sizeof(qm1d1c0042_config));
  1638. qm1d1c0042_config.fe = tc90522_config.fe;
  1639. qm1d1c0042_config.lpf = 1;
  1640. memset(&info, 0, sizeof(struct i2c_board_info));
  1641. strlcpy(info.type, "qm1d1c0042", I2C_NAME_SIZE);
  1642. info.addr = 0x61;
  1643. info.platform_data = &qm1d1c0042_config;
  1644. request_module(info.type);
  1645. client = i2c_new_device(tc90522_config.tuner_i2c,
  1646. &info);
  1647. if (client == NULL || client->dev.driver == NULL) {
  1648. module_put(dvb->i2c_client_demod->dev.driver->owner);
  1649. i2c_unregister_device(dvb->i2c_client_demod);
  1650. result = -ENODEV;
  1651. goto out_free;
  1652. }
  1653. dvb->i2c_client_tuner = client;
  1654. if (!try_module_get(client->dev.driver->owner)) {
  1655. i2c_unregister_device(client);
  1656. module_put(dvb->i2c_client_demod->dev.driver->owner);
  1657. i2c_unregister_device(dvb->i2c_client_demod);
  1658. result = -ENODEV;
  1659. goto out_free;
  1660. }
  1661. dvb->fe[0] = tc90522_config.fe;
  1662. px_bcud_init(dev);
  1663. }
  1664. break;
  1665. case EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB:
  1666. {
  1667. struct i2c_adapter *adapter;
  1668. struct i2c_client *client;
  1669. struct i2c_board_info info;
  1670. struct si2168_config si2168_config;
  1671. struct si2157_config si2157_config;
  1672. /* attach demod */
  1673. memset(&si2168_config, 0, sizeof(si2168_config));
  1674. si2168_config.i2c_adapter = &adapter;
  1675. si2168_config.fe = &dvb->fe[0];
  1676. si2168_config.ts_mode = SI2168_TS_SERIAL;
  1677. memset(&info, 0, sizeof(struct i2c_board_info));
  1678. strlcpy(info.type, "si2168", I2C_NAME_SIZE);
  1679. info.addr = 0x64;
  1680. info.platform_data = &si2168_config;
  1681. request_module(info.type);
  1682. client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &info);
  1683. if (client == NULL || client->dev.driver == NULL) {
  1684. result = -ENODEV;
  1685. goto out_free;
  1686. }
  1687. if (!try_module_get(client->dev.driver->owner)) {
  1688. i2c_unregister_device(client);
  1689. result = -ENODEV;
  1690. goto out_free;
  1691. }
  1692. dvb->i2c_client_demod = client;
  1693. /* attach tuner */
  1694. memset(&si2157_config, 0, sizeof(si2157_config));
  1695. si2157_config.fe = dvb->fe[0];
  1696. si2157_config.if_port = 1;
  1697. #ifdef CONFIG_MEDIA_CONTROLLER_DVB
  1698. si2157_config.mdev = dev->media_dev;
  1699. #endif
  1700. memset(&info, 0, sizeof(struct i2c_board_info));
  1701. strlcpy(info.type, "si2157", I2C_NAME_SIZE);
  1702. info.addr = 0x60;
  1703. info.platform_data = &si2157_config;
  1704. request_module(info.type);
  1705. client = i2c_new_device(adapter, &info);
  1706. if (client == NULL || client->dev.driver == NULL) {
  1707. module_put(dvb->i2c_client_demod->dev.driver->owner);
  1708. i2c_unregister_device(dvb->i2c_client_demod);
  1709. result = -ENODEV;
  1710. goto out_free;
  1711. }
  1712. if (!try_module_get(client->dev.driver->owner)) {
  1713. i2c_unregister_device(client);
  1714. module_put(dvb->i2c_client_demod->dev.driver->owner);
  1715. i2c_unregister_device(dvb->i2c_client_demod);
  1716. result = -ENODEV;
  1717. goto out_free;
  1718. }
  1719. dvb->i2c_client_tuner = client;
  1720. }
  1721. break;
  1722. default:
  1723. em28xx_errdev("/2: The frontend of your DVB/ATSC card"
  1724. " isn't supported yet\n");
  1725. break;
  1726. }
  1727. if (NULL == dvb->fe[0]) {
  1728. em28xx_errdev("/2: frontend initialization failed\n");
  1729. result = -EINVAL;
  1730. goto out_free;
  1731. }
  1732. /* define general-purpose callback pointer */
  1733. dvb->fe[0]->callback = em28xx_tuner_callback;
  1734. if (dvb->fe[1])
  1735. dvb->fe[1]->callback = em28xx_tuner_callback;
  1736. /* register everything */
  1737. result = em28xx_register_dvb(dvb, THIS_MODULE, dev, &dev->udev->dev);
  1738. if (result < 0)
  1739. goto out_free;
  1740. em28xx_info("DVB extension successfully initialized\n");
  1741. kref_get(&dev->ref);
  1742. ret:
  1743. em28xx_set_mode(dev, EM28XX_SUSPEND);
  1744. mutex_unlock(&dev->lock);
  1745. return result;
  1746. out_free:
  1747. kfree(dvb);
  1748. dev->dvb = NULL;
  1749. goto ret;
  1750. }
  1751. static inline void prevent_sleep(struct dvb_frontend_ops *ops)
  1752. {
  1753. ops->set_voltage = NULL;
  1754. ops->sleep = NULL;
  1755. ops->tuner_ops.sleep = NULL;
  1756. }
  1757. static int em28xx_dvb_fini(struct em28xx *dev)
  1758. {
  1759. struct em28xx_dvb *dvb;
  1760. struct i2c_client *client;
  1761. if (dev->is_audio_only) {
  1762. /* Shouldn't initialize IR for this interface */
  1763. return 0;
  1764. }
  1765. if (!dev->board.has_dvb) {
  1766. /* This device does not support the extension */
  1767. return 0;
  1768. }
  1769. if (!dev->dvb)
  1770. return 0;
  1771. em28xx_info("Closing DVB extension\n");
  1772. dvb = dev->dvb;
  1773. em28xx_uninit_usb_xfer(dev, EM28XX_DIGITAL_MODE);
  1774. if (dev->disconnected) {
  1775. /* We cannot tell the device to sleep
  1776. * once it has been unplugged. */
  1777. if (dvb->fe[0]) {
  1778. prevent_sleep(&dvb->fe[0]->ops);
  1779. dvb->fe[0]->exit = DVB_FE_DEVICE_REMOVED;
  1780. }
  1781. if (dvb->fe[1]) {
  1782. prevent_sleep(&dvb->fe[1]->ops);
  1783. dvb->fe[1]->exit = DVB_FE_DEVICE_REMOVED;
  1784. }
  1785. }
  1786. /* remove I2C SEC */
  1787. client = dvb->i2c_client_sec;
  1788. if (client) {
  1789. module_put(client->dev.driver->owner);
  1790. i2c_unregister_device(client);
  1791. }
  1792. /* remove I2C tuner */
  1793. client = dvb->i2c_client_tuner;
  1794. if (client) {
  1795. module_put(client->dev.driver->owner);
  1796. i2c_unregister_device(client);
  1797. }
  1798. /* remove I2C demod */
  1799. client = dvb->i2c_client_demod;
  1800. if (client) {
  1801. module_put(client->dev.driver->owner);
  1802. i2c_unregister_device(client);
  1803. }
  1804. em28xx_unregister_dvb(dvb);
  1805. kfree(dvb);
  1806. dev->dvb = NULL;
  1807. kref_put(&dev->ref, em28xx_free_device);
  1808. return 0;
  1809. }
  1810. static int em28xx_dvb_suspend(struct em28xx *dev)
  1811. {
  1812. int ret = 0;
  1813. if (dev->is_audio_only)
  1814. return 0;
  1815. if (!dev->board.has_dvb)
  1816. return 0;
  1817. em28xx_info("Suspending DVB extension\n");
  1818. if (dev->dvb) {
  1819. struct em28xx_dvb *dvb = dev->dvb;
  1820. if (dvb->fe[0]) {
  1821. ret = dvb_frontend_suspend(dvb->fe[0]);
  1822. em28xx_info("fe0 suspend %d\n", ret);
  1823. }
  1824. if (dvb->fe[1]) {
  1825. dvb_frontend_suspend(dvb->fe[1]);
  1826. em28xx_info("fe1 suspend %d\n", ret);
  1827. }
  1828. }
  1829. return 0;
  1830. }
  1831. static int em28xx_dvb_resume(struct em28xx *dev)
  1832. {
  1833. int ret = 0;
  1834. if (dev->is_audio_only)
  1835. return 0;
  1836. if (!dev->board.has_dvb)
  1837. return 0;
  1838. em28xx_info("Resuming DVB extension\n");
  1839. if (dev->dvb) {
  1840. struct em28xx_dvb *dvb = dev->dvb;
  1841. if (dvb->fe[0]) {
  1842. ret = dvb_frontend_resume(dvb->fe[0]);
  1843. em28xx_info("fe0 resume %d\n", ret);
  1844. }
  1845. if (dvb->fe[1]) {
  1846. ret = dvb_frontend_resume(dvb->fe[1]);
  1847. em28xx_info("fe1 resume %d\n", ret);
  1848. }
  1849. }
  1850. return 0;
  1851. }
  1852. static struct em28xx_ops dvb_ops = {
  1853. .id = EM28XX_DVB,
  1854. .name = "Em28xx dvb Extension",
  1855. .init = em28xx_dvb_init,
  1856. .fini = em28xx_dvb_fini,
  1857. .suspend = em28xx_dvb_suspend,
  1858. .resume = em28xx_dvb_resume,
  1859. };
  1860. static int __init em28xx_dvb_register(void)
  1861. {
  1862. return em28xx_register_extension(&dvb_ops);
  1863. }
  1864. static void __exit em28xx_dvb_unregister(void)
  1865. {
  1866. em28xx_unregister_extension(&dvb_ops);
  1867. }
  1868. module_init(em28xx_dvb_register);
  1869. module_exit(em28xx_dvb_unregister);