em28xx-dvb.c 55 KB

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