em28xx-dvb.c 57 KB

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