2 DVB device driver for em28xx
4 (c) 2008-2011 Mauro Carvalho Chehab <mchehab@infradead.org>
6 (c) 2008 Devin Heitmueller <devin.heitmueller@gmail.com>
7 - Fixes for the driver to properly work with HVR-950
8 - Fixes for the driver to properly work with Pinnacle PCTV HD Pro Stick
9 - Fixes for the driver to properly work with AMD ATI TV Wonder HD 600
11 (c) 2008 Aidan Thornton <makosoft@googlemail.com>
13 Based on cx88-dvb, saa7134-dvb and videobuf-dvb originally written by:
14 (c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>
15 (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
17 This program is free software; you can redistribute it and/or modify
18 it under the terms of the GNU General Public License as published by
19 the Free Software Foundation; either version 2 of the License.
22 #include <linux/kernel.h>
23 #include <linux/slab.h>
24 #include <linux/usb.h>
27 #include <media/v4l2-common.h>
28 #include <media/videobuf-vmalloc.h>
29 #include <media/tuner.h>
30 #include "tuner-simple.h"
37 #include "mt352_priv.h" /* FIXME */
43 #include "tda18271c2dd.h"
46 MODULE_DESCRIPTION("driver for em28xx based DVB cards");
47 MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>");
48 MODULE_LICENSE("GPL");
50 static unsigned int debug
;
51 module_param(debug
, int, 0644);
52 MODULE_PARM_DESC(debug
, "enable debug messages [dvb]");
54 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
56 #define dprintk(level, fmt, arg...) do { \
58 printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->name, ## arg); \
61 #define EM28XX_DVB_NUM_BUFS 5
62 #define EM28XX_DVB_MAX_PACKETS 64
65 struct dvb_frontend
*fe
[2];
67 /* feed count management */
71 /* general boilerplate stuff */
72 struct dvb_adapter adapter
;
73 struct dvb_demux demux
;
75 struct dmx_frontend fe_hw
;
76 struct dmx_frontend fe_mem
;
79 /* Due to DRX-K - probably need changes */
80 int (*gate_ctrl
)(struct dvb_frontend
*, int);
81 struct semaphore pll_mutex
;
86 static inline void print_err_status(struct em28xx
*dev
,
87 int packet
, int status
)
89 char *errmsg
= "Unknown";
93 errmsg
= "unlinked synchronuously";
96 errmsg
= "unlinked asynchronuously";
99 errmsg
= "Buffer error (overrun)";
102 errmsg
= "Stalled (device not responding)";
105 errmsg
= "Babble (bad cable?)";
108 errmsg
= "Bit-stuff error (bad cable?)";
111 errmsg
= "CRC/Timeout (could be anything)";
114 errmsg
= "Device does not respond";
118 dprintk(1, "URB status %d [%s].\n", status
, errmsg
);
120 dprintk(1, "URB packet %d, status %d [%s].\n",
121 packet
, status
, errmsg
);
125 static inline int dvb_isoc_copy(struct em28xx
*dev
, struct urb
*urb
)
132 if ((dev
->state
& DEV_DISCONNECTED
) || (dev
->state
& DEV_MISCONFIGURED
))
135 if (urb
->status
< 0) {
136 print_err_status(dev
, -1, urb
->status
);
137 if (urb
->status
== -ENOENT
)
141 for (i
= 0; i
< urb
->number_of_packets
; i
++) {
142 int status
= urb
->iso_frame_desc
[i
].status
;
145 print_err_status(dev
, i
, status
);
146 if (urb
->iso_frame_desc
[i
].status
!= -EPROTO
)
150 dvb_dmx_swfilter(&dev
->dvb
->demux
, urb
->transfer_buffer
+
151 urb
->iso_frame_desc
[i
].offset
,
152 urb
->iso_frame_desc
[i
].actual_length
);
158 static int start_streaming(struct em28xx_dvb
*dvb
)
161 struct em28xx
*dev
= dvb
->adapter
.priv
;
162 int max_dvb_packet_size
;
164 usb_set_interface(dev
->udev
, 0, 1);
165 rc
= em28xx_set_mode(dev
, EM28XX_DIGITAL_MODE
);
169 max_dvb_packet_size
= em28xx_isoc_dvb_max_packetsize(dev
);
170 if (max_dvb_packet_size
< 0)
171 return max_dvb_packet_size
;
172 dprintk(1, "Using %d buffers each with %d bytes\n",
174 max_dvb_packet_size
);
176 return em28xx_init_isoc(dev
, EM28XX_DVB_MAX_PACKETS
,
177 EM28XX_DVB_NUM_BUFS
, max_dvb_packet_size
,
181 static int stop_streaming(struct em28xx_dvb
*dvb
)
183 struct em28xx
*dev
= dvb
->adapter
.priv
;
185 em28xx_uninit_isoc(dev
);
187 em28xx_set_mode(dev
, EM28XX_SUSPEND
);
192 static int start_feed(struct dvb_demux_feed
*feed
)
194 struct dvb_demux
*demux
= feed
->demux
;
195 struct em28xx_dvb
*dvb
= demux
->priv
;
198 if (!demux
->dmx
.frontend
)
201 mutex_lock(&dvb
->lock
);
205 if (dvb
->nfeeds
== 1) {
206 ret
= start_streaming(dvb
);
211 mutex_unlock(&dvb
->lock
);
215 static int stop_feed(struct dvb_demux_feed
*feed
)
217 struct dvb_demux
*demux
= feed
->demux
;
218 struct em28xx_dvb
*dvb
= demux
->priv
;
221 mutex_lock(&dvb
->lock
);
224 if (0 == dvb
->nfeeds
)
225 err
= stop_streaming(dvb
);
227 mutex_unlock(&dvb
->lock
);
233 /* ------------------------------------------------------------------ */
234 static int em28xx_dvb_bus_ctrl(struct dvb_frontend
*fe
, int acquire
)
236 struct em28xx
*dev
= fe
->dvb
->priv
;
239 return em28xx_set_mode(dev
, EM28XX_DIGITAL_MODE
);
241 return em28xx_set_mode(dev
, EM28XX_SUSPEND
);
244 /* ------------------------------------------------------------------ */
246 static struct lgdt330x_config em2880_lgdt3303_dev
= {
247 .demod_address
= 0x0e,
248 .demod_chip
= LGDT3303
,
251 static struct lgdt3305_config em2870_lgdt3304_dev
= {
253 .demod_chip
= LGDT3304
,
254 .spectral_inversion
= 1,
256 .mpeg_mode
= LGDT3305_MPEG_PARALLEL
,
257 .tpclk_edge
= LGDT3305_TPCLK_FALLING_EDGE
,
258 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
263 static struct s921_config sharp_isdbt
= {
264 .demod_address
= 0x30 >> 1
267 static struct zl10353_config em28xx_zl10353_with_xc3028
= {
268 .demod_address
= (0x1e >> 1),
274 static struct s5h1409_config em28xx_s5h1409_with_xc3028
= {
275 .demod_address
= 0x32 >> 1,
276 .output_mode
= S5H1409_PARALLEL_OUTPUT
,
277 .gpio
= S5H1409_GPIO_OFF
,
278 .inversion
= S5H1409_INVERSION_OFF
,
279 .status_mode
= S5H1409_DEMODLOCKING
,
280 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
283 static struct tda18271_std_map kworld_a340_std_map
= {
284 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 0,
285 .if_lvl
= 1, .rfagc_top
= 0x37, },
286 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 1,
287 .if_lvl
= 1, .rfagc_top
= 0x37, },
290 static struct tda18271_config kworld_a340_config
= {
291 .std_map
= &kworld_a340_std_map
,
294 static struct zl10353_config em28xx_zl10353_xc3028_no_i2c_gate
= {
295 .demod_address
= (0x1e >> 1),
297 .disable_i2c_gate_ctrl
= 1,
302 static struct drxd_config em28xx_drxd
= {
303 .index
= 0, .demod_address
= 0x70, .demod_revision
= 0xa2,
304 .demoda_address
= 0x00, .pll_address
= 0x00,
305 .pll_type
= DRXD_PLL_NONE
, .clock
= 12000, .insert_rs_byte
= 1,
306 .pll_set
= NULL
, .osc_deviation
= NULL
, .IF
= 42800000,
307 .disable_i2c_gate_ctrl
= 1,
310 struct drxk_config terratec_h5_drxk
= {
314 .microcode_name
= "dvb-usb-terratec-h5-drxk.fw",
317 static int drxk_gate_ctrl(struct dvb_frontend
*fe
, int enable
)
319 struct em28xx_dvb
*dvb
= fe
->sec_priv
;
326 down(&dvb
->pll_mutex
);
327 status
= dvb
->gate_ctrl(fe
, 1);
329 status
= dvb
->gate_ctrl(fe
, 0);
335 static void terratec_h5_init(struct em28xx
*dev
)
338 struct em28xx_reg_seq terratec_h5_init
[] = {
339 {EM28XX_R08_GPIO
, 0xff, 0xff, 10},
340 {EM2874_R80_GPIO
, 0xf6, 0xff, 100},
341 {EM2874_R80_GPIO
, 0xf2, 0xff, 50},
342 {EM2874_R80_GPIO
, 0xf6, 0xff, 100},
345 struct em28xx_reg_seq terratec_h5_end
[] = {
346 {EM2874_R80_GPIO
, 0xe6, 0xff, 100},
347 {EM2874_R80_GPIO
, 0xa6, 0xff, 50},
348 {EM2874_R80_GPIO
, 0xe6, 0xff, 100},
355 {{ 0x06, 0x02, 0x00, 0x31 }, 4},
357 {{ 0x01, 0x02, 0x00, 0xc6 }, 4},
359 {{ 0x01, 0x00, 0xff, 0xaf }, 4},
360 {{ 0x01, 0x00, 0x03, 0xa0 }, 4},
362 {{ 0x01, 0x00, 0x73, 0xaf }, 4},
365 {{ 0x00, 0x04, 0x00, 0x0a }, 4},
367 {{ 0x04, 0x14, 0x00, 0x00 }, 4},
370 em28xx_gpio_set(dev
, terratec_h5_init
);
371 em28xx_write_reg(dev
, EM28XX_R06_I2C_CLK
, 0x40);
373 em28xx_write_reg(dev
, EM28XX_R06_I2C_CLK
, 0x45);
376 dev
->i2c_client
.addr
= 0x82 >> 1;
378 for (i
= 0; i
< ARRAY_SIZE(regs
); i
++)
379 i2c_master_send(&dev
->i2c_client
, regs
[i
].r
, regs
[i
].len
);
380 em28xx_gpio_set(dev
, terratec_h5_end
);
383 static int mt352_terratec_xs_init(struct dvb_frontend
*fe
)
385 /* Values extracted from a USB trace of the Terratec Windows driver */
386 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x2c };
387 static u8 reset
[] = { RESET
, 0x80 };
388 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
389 static u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0xa0 };
390 static u8 input_freq_cfg
[] = { INPUT_FREQ_1
, 0x31, 0xb8 };
391 static u8 rs_err_cfg
[] = { RS_ERR_PER_1
, 0x00, 0x4d };
392 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x32 };
393 static u8 trl_nom_cfg
[] = { TRL_NOMINAL_RATE_1
, 0x64, 0x00 };
394 static u8 tps_given_cfg
[] = { TPS_GIVEN_1
, 0x40, 0x80, 0x50 };
395 static u8 tuner_go
[] = { TUNER_GO
, 0x01};
397 mt352_write(fe
, clock_config
, sizeof(clock_config
));
399 mt352_write(fe
, reset
, sizeof(reset
));
400 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
401 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
402 mt352_write(fe
, input_freq_cfg
, sizeof(input_freq_cfg
));
403 mt352_write(fe
, rs_err_cfg
, sizeof(rs_err_cfg
));
404 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
405 mt352_write(fe
, trl_nom_cfg
, sizeof(trl_nom_cfg
));
406 mt352_write(fe
, tps_given_cfg
, sizeof(tps_given_cfg
));
407 mt352_write(fe
, tuner_go
, sizeof(tuner_go
));
411 static struct mt352_config terratec_xs_mt352_cfg
= {
412 .demod_address
= (0x1e >> 1),
415 .demod_init
= mt352_terratec_xs_init
,
418 static struct tda10023_config em28xx_tda10023_config
= {
419 .demod_address
= 0x0c,
423 static struct cxd2820r_config em28xx_cxd2820r_config
= {
424 .i2c_address
= (0xd8 >> 1),
425 .ts_mode
= CXD2820R_TS_SERIAL
,
434 /* enable LNA for DVB-T2 and DVB-C */
435 .gpio_dvbt2
[0] = CXD2820R_GPIO_E
| CXD2820R_GPIO_O
| CXD2820R_GPIO_L
,
436 .gpio_dvbc
[0] = CXD2820R_GPIO_E
| CXD2820R_GPIO_O
| CXD2820R_GPIO_L
,
439 static struct tda18271_config em28xx_cxd2820r_tda18271_config
= {
440 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
443 /* ------------------------------------------------------------------ */
445 static int attach_xc3028(u8 addr
, struct em28xx
*dev
)
447 struct dvb_frontend
*fe
;
448 struct xc2028_config cfg
;
450 memset(&cfg
, 0, sizeof(cfg
));
451 cfg
.i2c_adap
= &dev
->i2c_adap
;
454 if (!dev
->dvb
->fe
[0]) {
455 em28xx_errdev("/2: dvb frontend not attached. "
456 "Can't attach xc3028\n");
460 fe
= dvb_attach(xc2028_attach
, dev
->dvb
->fe
[0], &cfg
);
462 em28xx_errdev("/2: xc3028 attach failed\n");
463 dvb_frontend_detach(dev
->dvb
->fe
[0]);
464 dev
->dvb
->fe
[0] = NULL
;
468 em28xx_info("%s/2: xc3028 attached\n", dev
->name
);
473 /* ------------------------------------------------------------------ */
475 static int register_dvb(struct em28xx_dvb
*dvb
,
476 struct module
*module
,
478 struct device
*device
)
482 mutex_init(&dvb
->lock
);
484 /* register adapter */
485 result
= dvb_register_adapter(&dvb
->adapter
, dev
->name
, module
, device
,
488 printk(KERN_WARNING
"%s: dvb_register_adapter failed (errno = %d)\n",
493 /* Ensure all frontends negotiate bus access */
494 dvb
->fe
[0]->ops
.ts_bus_ctrl
= em28xx_dvb_bus_ctrl
;
496 dvb
->fe
[1]->ops
.ts_bus_ctrl
= em28xx_dvb_bus_ctrl
;
498 dvb
->adapter
.priv
= dev
;
500 /* register frontend */
501 result
= dvb_register_frontend(&dvb
->adapter
, dvb
->fe
[0]);
503 printk(KERN_WARNING
"%s: dvb_register_frontend failed (errno = %d)\n",
508 /* register 2nd frontend */
510 result
= dvb_register_frontend(&dvb
->adapter
, dvb
->fe
[1]);
512 printk(KERN_WARNING
"%s: 2nd dvb_register_frontend failed (errno = %d)\n",
518 /* register demux stuff */
519 dvb
->demux
.dmx
.capabilities
=
520 DMX_TS_FILTERING
| DMX_SECTION_FILTERING
|
521 DMX_MEMORY_BASED_FILTERING
;
522 dvb
->demux
.priv
= dvb
;
523 dvb
->demux
.filternum
= 256;
524 dvb
->demux
.feednum
= 256;
525 dvb
->demux
.start_feed
= start_feed
;
526 dvb
->demux
.stop_feed
= stop_feed
;
528 result
= dvb_dmx_init(&dvb
->demux
);
530 printk(KERN_WARNING
"%s: dvb_dmx_init failed (errno = %d)\n",
535 dvb
->dmxdev
.filternum
= 256;
536 dvb
->dmxdev
.demux
= &dvb
->demux
.dmx
;
537 dvb
->dmxdev
.capabilities
= 0;
538 result
= dvb_dmxdev_init(&dvb
->dmxdev
, &dvb
->adapter
);
540 printk(KERN_WARNING
"%s: dvb_dmxdev_init failed (errno = %d)\n",
545 dvb
->fe_hw
.source
= DMX_FRONTEND_0
;
546 result
= dvb
->demux
.dmx
.add_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
548 printk(KERN_WARNING
"%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n",
553 dvb
->fe_mem
.source
= DMX_MEMORY_FE
;
554 result
= dvb
->demux
.dmx
.add_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
556 printk(KERN_WARNING
"%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n",
561 result
= dvb
->demux
.dmx
.connect_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
563 printk(KERN_WARNING
"%s: connect_frontend failed (errno = %d)\n",
568 /* register network adapter */
569 dvb_net_init(&dvb
->adapter
, &dvb
->net
, &dvb
->demux
.dmx
);
573 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
575 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
577 dvb_dmxdev_release(&dvb
->dmxdev
);
579 dvb_dmx_release(&dvb
->demux
);
582 dvb_unregister_frontend(dvb
->fe
[1]);
583 dvb_unregister_frontend(dvb
->fe
[0]);
586 dvb_frontend_detach(dvb
->fe
[1]);
588 dvb_frontend_detach(dvb
->fe
[0]);
589 dvb_unregister_adapter(&dvb
->adapter
);
594 static void unregister_dvb(struct em28xx_dvb
*dvb
)
596 dvb_net_release(&dvb
->net
);
597 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
598 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
599 dvb_dmxdev_release(&dvb
->dmxdev
);
600 dvb_dmx_release(&dvb
->demux
);
602 dvb_unregister_frontend(dvb
->fe
[1]);
603 dvb_unregister_frontend(dvb
->fe
[0]);
604 if (dvb
->fe
[1] && !dvb
->dont_attach_fe1
)
605 dvb_frontend_detach(dvb
->fe
[1]);
606 dvb_frontend_detach(dvb
->fe
[0]);
607 dvb_unregister_adapter(&dvb
->adapter
);
610 static int dvb_init(struct em28xx
*dev
)
613 struct em28xx_dvb
*dvb
;
615 if (!dev
->board
.has_dvb
) {
616 /* This device does not support the extension */
617 printk(KERN_INFO
"em28xx_dvb: This device does not support the extension\n");
621 dvb
= kzalloc(sizeof(struct em28xx_dvb
), GFP_KERNEL
);
624 em28xx_info("em28xx_dvb: memory allocation failed\n");
628 dvb
->fe
[0] = dvb
->fe
[1] = NULL
;
630 mutex_lock(&dev
->lock
);
631 em28xx_set_mode(dev
, EM28XX_DIGITAL_MODE
);
633 switch (dev
->model
) {
634 case EM2874_BOARD_LEADERSHIP_ISDBT
:
635 dvb
->fe
[0] = dvb_attach(s921_attach
,
636 &sharp_isdbt
, &dev
->i2c_adap
);
644 case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850
:
645 case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950
:
646 case EM2880_BOARD_PINNACLE_PCTV_HD_PRO
:
647 case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600
:
648 dvb
->fe
[0] = dvb_attach(lgdt330x_attach
,
649 &em2880_lgdt3303_dev
,
651 if (attach_xc3028(0x61, dev
) < 0) {
656 case EM2880_BOARD_KWORLD_DVB_310U
:
657 dvb
->fe
[0] = dvb_attach(zl10353_attach
,
658 &em28xx_zl10353_with_xc3028
,
660 if (attach_xc3028(0x61, dev
) < 0) {
665 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900
:
666 case EM2882_BOARD_TERRATEC_HYBRID_XS
:
667 case EM2880_BOARD_EMPIRE_DUAL_TV
:
668 dvb
->fe
[0] = dvb_attach(zl10353_attach
,
669 &em28xx_zl10353_xc3028_no_i2c_gate
,
671 if (attach_xc3028(0x61, dev
) < 0) {
676 case EM2880_BOARD_TERRATEC_HYBRID_XS
:
677 case EM2880_BOARD_TERRATEC_HYBRID_XS_FR
:
678 case EM2881_BOARD_PINNACLE_HYBRID_PRO
:
679 case EM2882_BOARD_DIKOM_DK300
:
680 case EM2882_BOARD_KWORLD_VS_DVBT
:
681 dvb
->fe
[0] = dvb_attach(zl10353_attach
,
682 &em28xx_zl10353_xc3028_no_i2c_gate
,
684 if (dvb
->fe
[0] == NULL
) {
685 /* This board could have either a zl10353 or a mt352.
686 If the chip id isn't for zl10353, try mt352 */
687 dvb
->fe
[0] = dvb_attach(mt352_attach
,
688 &terratec_xs_mt352_cfg
,
692 if (attach_xc3028(0x61, dev
) < 0) {
697 case EM2883_BOARD_KWORLD_HYBRID_330U
:
698 case EM2882_BOARD_EVGA_INDTUBE
:
699 dvb
->fe
[0] = dvb_attach(s5h1409_attach
,
700 &em28xx_s5h1409_with_xc3028
,
702 if (attach_xc3028(0x61, dev
) < 0) {
707 case EM2882_BOARD_KWORLD_ATSC_315U
:
708 dvb
->fe
[0] = dvb_attach(lgdt330x_attach
,
709 &em2880_lgdt3303_dev
,
711 if (dvb
->fe
[0] != NULL
) {
712 if (!dvb_attach(simple_tuner_attach
, dvb
->fe
[0],
713 &dev
->i2c_adap
, 0x61, TUNER_THOMSON_DTT761X
)) {
719 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2
:
720 case EM2882_BOARD_PINNACLE_HYBRID_PRO_330E
:
721 dvb
->fe
[0] = dvb_attach(drxd_attach
, &em28xx_drxd
, NULL
,
722 &dev
->i2c_adap
, &dev
->udev
->dev
);
723 if (attach_xc3028(0x61, dev
) < 0) {
728 case EM2870_BOARD_REDDO_DVB_C_USB_BOX
:
729 /* Philips CU1216L NIM (Philips TDA10023 + Infineon TUA6034) */
730 dvb
->fe
[0] = dvb_attach(tda10023_attach
,
731 &em28xx_tda10023_config
,
732 &dev
->i2c_adap
, 0x48);
734 if (!dvb_attach(simple_tuner_attach
, dvb
->fe
[0],
735 &dev
->i2c_adap
, 0x60, TUNER_PHILIPS_CU1216L
)) {
741 case EM2870_BOARD_KWORLD_A340
:
742 dvb
->fe
[0] = dvb_attach(lgdt3305_attach
,
743 &em2870_lgdt3304_dev
,
745 if (dvb
->fe
[0] != NULL
)
746 dvb_attach(tda18271_attach
, dvb
->fe
[0], 0x60,
747 &dev
->i2c_adap
, &kworld_a340_config
);
749 case EM28174_BOARD_PCTV_290E
:
751 * FE 0 = DVB-T/T2 + FE 1 = DVB-C, both sharing same tuner. */
753 dvb
->fe
[0] = dvb_attach(cxd2820r_attach
,
754 &em28xx_cxd2820r_config
, &dev
->i2c_adap
, NULL
);
756 struct i2c_adapter
*i2c_tuner
;
757 i2c_tuner
= cxd2820r_get_tuner_i2c_adapter(dvb
->fe
[0]);
758 /* FE 0 attach tuner */
759 if (!dvb_attach(tda18271_attach
, dvb
->fe
[0], 0x60,
760 i2c_tuner
, &em28xx_cxd2820r_tda18271_config
)) {
761 dvb_frontend_detach(dvb
->fe
[0]);
765 /* FE 1. This dvb_attach() cannot fail. */
766 dvb
->fe
[1] = dvb_attach(cxd2820r_attach
, NULL
, NULL
,
769 /* FE 1 attach tuner */
770 if (!dvb_attach(tda18271_attach
, dvb
->fe
[1], 0x60,
771 i2c_tuner
, &em28xx_cxd2820r_tda18271_config
)) {
772 dvb_frontend_detach(dvb
->fe
[1]);
773 /* leave FE 0 still active */
777 case EM2884_BOARD_TERRATEC_H5
:
778 terratec_h5_init(dev
);
780 dvb
->dont_attach_fe1
= 1;
782 dvb
->fe
[0] = dvb_attach(drxk_attach
, &terratec_h5_drxk
, &dev
->i2c_adap
, &dvb
->fe
[1]);
788 /* FIXME: do we need a pll semaphore? */
789 dvb
->fe
[0]->sec_priv
= dvb
;
790 sema_init(&dvb
->pll_mutex
, 1);
791 dvb
->gate_ctrl
= dvb
->fe
[0]->ops
.i2c_gate_ctrl
;
792 dvb
->fe
[0]->ops
.i2c_gate_ctrl
= drxk_gate_ctrl
;
795 /* Attach tda18271 to DVB-C frontend */
796 if (dvb
->fe
[0]->ops
.i2c_gate_ctrl
)
797 dvb
->fe
[0]->ops
.i2c_gate_ctrl(dvb
->fe
[0], 1);
798 if (!dvb_attach(tda18271c2dd_attach
, dvb
->fe
[0], &dev
->i2c_adap
, 0x60)) {
802 if (dvb
->fe
[0]->ops
.i2c_gate_ctrl
)
803 dvb
->fe
[0]->ops
.i2c_gate_ctrl(dvb
->fe
[0], 0);
805 /* Hack - needed by drxk/tda18271c2dd */
806 dvb
->fe
[1]->tuner_priv
= dvb
->fe
[0]->tuner_priv
;
807 memcpy(&dvb
->fe
[1]->ops
.tuner_ops
,
808 &dvb
->fe
[0]->ops
.tuner_ops
,
809 sizeof(dvb
->fe
[0]->ops
.tuner_ops
));
813 em28xx_errdev("/2: The frontend of your DVB/ATSC card"
814 " isn't supported yet\n");
817 if (NULL
== dvb
->fe
[0]) {
818 em28xx_errdev("/2: frontend initialization failed\n");
822 /* define general-purpose callback pointer */
823 dvb
->fe
[0]->callback
= em28xx_tuner_callback
;
825 /* register everything */
826 result
= register_dvb(dvb
, THIS_MODULE
, dev
, &dev
->udev
->dev
);
831 em28xx_info("Successfully loaded em28xx-dvb\n");
833 em28xx_set_mode(dev
, EM28XX_SUSPEND
);
834 mutex_unlock(&dev
->lock
);
843 static int dvb_fini(struct em28xx
*dev
)
845 if (!dev
->board
.has_dvb
) {
846 /* This device does not support the extension */
851 unregister_dvb(dev
->dvb
);
859 static struct em28xx_ops dvb_ops
= {
861 .name
= "Em28xx dvb Extension",
866 static int __init
em28xx_dvb_register(void)
868 return em28xx_register_extension(&dvb_ops
);
871 static void __exit
em28xx_dvb_unregister(void)
873 em28xx_unregister_extension(&dvb_ops
);
876 module_init(em28xx_dvb_register
);
877 module_exit(em28xx_dvb_unregister
);