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 (c) 2012 Frank Schäfer <fschaefer.oss@googlemail.com>
15 Based on cx88-dvb, saa7134-dvb and videobuf-dvb originally written by:
16 (c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>
17 (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
19 This program is free software; you can redistribute it and/or modify
20 it under the terms of the GNU General Public License as published by
21 the Free Software Foundation; either version 2 of the License.
24 #include <linux/kernel.h>
25 #include <linux/slab.h>
26 #include <linux/usb.h>
29 #include <media/v4l2-common.h>
30 #include <dvb_demux.h>
33 #include <media/tuner.h>
34 #include "tuner-simple.h"
35 #include <linux/gpio.h>
43 #include "mt352_priv.h" /* FIXME */
45 #include "drx39xyj/drx39xxj.h"
50 #include "tda18271c2dd.h"
57 #include "m88ds3103.h"
62 #include "qm1d1c0042.h"
64 MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>");
65 MODULE_LICENSE("GPL");
66 MODULE_DESCRIPTION(DRIVER_DESC
" - digital TV interface");
67 MODULE_VERSION(EM28XX_VERSION
);
69 static unsigned int debug
;
70 module_param(debug
, int, 0644);
71 MODULE_PARM_DESC(debug
, "enable debug messages [dvb]");
73 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
75 #define dprintk(level, fmt, arg...) do { \
77 printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->name, ## arg); \
81 struct dvb_frontend
*fe
[2];
83 /* feed count management */
87 /* general boilerplate stuff */
88 struct dvb_adapter adapter
;
89 struct dvb_demux demux
;
91 struct dmx_frontend fe_hw
;
92 struct dmx_frontend fe_mem
;
95 /* Due to DRX-K - probably need changes */
96 int (*gate_ctrl
)(struct dvb_frontend
*, int);
97 struct semaphore pll_mutex
;
100 struct i2c_client
*i2c_client_demod
;
101 struct i2c_client
*i2c_client_tuner
;
102 struct i2c_client
*i2c_client_sec
;
105 static inline void print_err_status(struct em28xx
*dev
,
106 int packet
, int status
)
108 char *errmsg
= "Unknown";
112 errmsg
= "unlinked synchronuously";
115 errmsg
= "unlinked asynchronuously";
118 errmsg
= "Buffer error (overrun)";
121 errmsg
= "Stalled (device not responding)";
124 errmsg
= "Babble (bad cable?)";
127 errmsg
= "Bit-stuff error (bad cable?)";
130 errmsg
= "CRC/Timeout (could be anything)";
133 errmsg
= "Device does not respond";
137 dprintk(1, "URB status %d [%s].\n", status
, errmsg
);
139 dprintk(1, "URB packet %d, status %d [%s].\n",
140 packet
, status
, errmsg
);
144 static inline int em28xx_dvb_urb_data_copy(struct em28xx
*dev
, struct urb
*urb
)
146 int xfer_bulk
, num_packets
, i
;
151 if (dev
->disconnected
)
155 print_err_status(dev
, -1, urb
->status
);
157 xfer_bulk
= usb_pipebulk(urb
->pipe
);
159 if (xfer_bulk
) /* bulk */
162 num_packets
= urb
->number_of_packets
;
164 for (i
= 0; i
< num_packets
; i
++) {
166 if (urb
->status
< 0) {
167 print_err_status(dev
, i
, urb
->status
);
168 if (urb
->status
!= -EPROTO
)
171 if (!urb
->actual_length
)
173 dvb_dmx_swfilter(&dev
->dvb
->demux
, urb
->transfer_buffer
,
176 if (urb
->iso_frame_desc
[i
].status
< 0) {
177 print_err_status(dev
, i
,
178 urb
->iso_frame_desc
[i
].status
);
179 if (urb
->iso_frame_desc
[i
].status
!= -EPROTO
)
182 if (!urb
->iso_frame_desc
[i
].actual_length
)
184 dvb_dmx_swfilter(&dev
->dvb
->demux
,
185 urb
->transfer_buffer
+
186 urb
->iso_frame_desc
[i
].offset
,
187 urb
->iso_frame_desc
[i
].actual_length
);
194 static int em28xx_start_streaming(struct em28xx_dvb
*dvb
)
197 struct em28xx_i2c_bus
*i2c_bus
= dvb
->adapter
.priv
;
198 struct em28xx
*dev
= i2c_bus
->dev
;
199 int dvb_max_packet_size
, packet_multiplier
, dvb_alt
;
201 if (dev
->dvb_xfer_bulk
) {
202 if (!dev
->dvb_ep_bulk
)
204 dvb_max_packet_size
= 512; /* USB 2.0 spec */
205 packet_multiplier
= EM28XX_DVB_BULK_PACKET_MULTIPLIER
;
208 if (!dev
->dvb_ep_isoc
)
210 dvb_max_packet_size
= dev
->dvb_max_pkt_size_isoc
;
211 if (dvb_max_packet_size
< 0)
212 return dvb_max_packet_size
;
213 packet_multiplier
= EM28XX_DVB_NUM_ISOC_PACKETS
;
214 dvb_alt
= dev
->dvb_alt_isoc
;
217 usb_set_interface(dev
->udev
, dev
->ifnum
, dvb_alt
);
218 rc
= em28xx_set_mode(dev
, EM28XX_DIGITAL_MODE
);
222 dprintk(1, "Using %d buffers each with %d x %d bytes, alternate %d\n",
225 dvb_max_packet_size
, dvb_alt
);
227 return em28xx_init_usb_xfer(dev
, EM28XX_DIGITAL_MODE
,
232 em28xx_dvb_urb_data_copy
);
235 static int em28xx_stop_streaming(struct em28xx_dvb
*dvb
)
237 struct em28xx_i2c_bus
*i2c_bus
= dvb
->adapter
.priv
;
238 struct em28xx
*dev
= i2c_bus
->dev
;
240 em28xx_stop_urbs(dev
);
245 static int em28xx_start_feed(struct dvb_demux_feed
*feed
)
247 struct dvb_demux
*demux
= feed
->demux
;
248 struct em28xx_dvb
*dvb
= demux
->priv
;
251 if (!demux
->dmx
.frontend
)
254 mutex_lock(&dvb
->lock
);
258 if (dvb
->nfeeds
== 1) {
259 ret
= em28xx_start_streaming(dvb
);
264 mutex_unlock(&dvb
->lock
);
268 static int em28xx_stop_feed(struct dvb_demux_feed
*feed
)
270 struct dvb_demux
*demux
= feed
->demux
;
271 struct em28xx_dvb
*dvb
= demux
->priv
;
274 mutex_lock(&dvb
->lock
);
277 if (0 == dvb
->nfeeds
)
278 err
= em28xx_stop_streaming(dvb
);
280 mutex_unlock(&dvb
->lock
);
285 /* ------------------------------------------------------------------ */
286 static int em28xx_dvb_bus_ctrl(struct dvb_frontend
*fe
, int acquire
)
288 struct em28xx_i2c_bus
*i2c_bus
= fe
->dvb
->priv
;
289 struct em28xx
*dev
= i2c_bus
->dev
;
292 return em28xx_set_mode(dev
, EM28XX_DIGITAL_MODE
);
294 return em28xx_set_mode(dev
, EM28XX_SUSPEND
);
297 /* ------------------------------------------------------------------ */
299 static struct lgdt330x_config em2880_lgdt3303_dev
= {
300 .demod_address
= 0x0e,
301 .demod_chip
= LGDT3303
,
304 static struct lgdt3305_config em2870_lgdt3304_dev
= {
306 .demod_chip
= LGDT3304
,
307 .spectral_inversion
= 1,
309 .mpeg_mode
= LGDT3305_MPEG_PARALLEL
,
310 .tpclk_edge
= LGDT3305_TPCLK_FALLING_EDGE
,
311 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
316 static struct lgdt3305_config em2874_lgdt3305_dev
= {
318 .demod_chip
= LGDT3305
,
319 .spectral_inversion
= 1,
321 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
322 .tpclk_edge
= LGDT3305_TPCLK_FALLING_EDGE
,
323 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
328 static struct lgdt3305_config em2874_lgdt3305_nogate_dev
= {
330 .demod_chip
= LGDT3305
,
331 .spectral_inversion
= 1,
333 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
334 .tpclk_edge
= LGDT3305_TPCLK_FALLING_EDGE
,
335 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
340 static struct s921_config sharp_isdbt
= {
341 .demod_address
= 0x30 >> 1
344 static struct zl10353_config em28xx_zl10353_with_xc3028
= {
345 .demod_address
= (0x1e >> 1),
351 static struct s5h1409_config em28xx_s5h1409_with_xc3028
= {
352 .demod_address
= 0x32 >> 1,
353 .output_mode
= S5H1409_PARALLEL_OUTPUT
,
354 .gpio
= S5H1409_GPIO_OFF
,
355 .inversion
= S5H1409_INVERSION_OFF
,
356 .status_mode
= S5H1409_DEMODLOCKING
,
357 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
360 static struct tda18271_std_map kworld_a340_std_map
= {
361 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 0,
362 .if_lvl
= 1, .rfagc_top
= 0x37, },
363 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 1,
364 .if_lvl
= 1, .rfagc_top
= 0x37, },
367 static struct tda18271_config kworld_a340_config
= {
368 .std_map
= &kworld_a340_std_map
,
371 static struct tda18271_config kworld_ub435q_v2_config
= {
372 .std_map
= &kworld_a340_std_map
,
373 .gate
= TDA18271_GATE_DIGITAL
,
376 static struct tda18212_config kworld_ub435q_v3_config
= {
381 static struct zl10353_config em28xx_zl10353_xc3028_no_i2c_gate
= {
382 .demod_address
= (0x1e >> 1),
384 .disable_i2c_gate_ctrl
= 1,
389 static struct drxd_config em28xx_drxd
= {
390 .demod_address
= 0x70,
391 .demod_revision
= 0xa2,
392 .pll_type
= DRXD_PLL_NONE
,
396 .disable_i2c_gate_ctrl
= 1,
399 static struct drxk_config terratec_h5_drxk
= {
403 .microcode_name
= "dvb-usb-terratec-h5-drxk.fw",
404 .qam_demod_parameter_count
= 2,
407 static struct drxk_config hauppauge_930c_drxk
= {
411 .microcode_name
= "dvb-usb-hauppauge-hvr930c-drxk.fw",
413 .qam_demod_parameter_count
= 2,
416 static struct drxk_config terratec_htc_stick_drxk
= {
420 .microcode_name
= "dvb-usb-terratec-htc-stick-drxk.fw",
422 .qam_demod_parameter_count
= 2,
423 /* Required for the antenna_gpio to disable LNA. */
424 .antenna_dvbt
= true,
425 /* The windows driver uses the same. This will disable LNA. */
429 static struct drxk_config maxmedia_ub425_tc_drxk
= {
433 .microcode_name
= "dvb-demod-drxk-01.fw",
435 .qam_demod_parameter_count
= 2,
438 static struct drxk_config pctv_520e_drxk
= {
441 .microcode_name
= "dvb-demod-drxk-pctv.fw",
442 .qam_demod_parameter_count
= 2,
444 .antenna_dvbt
= true, /* disable LNA */
445 .antenna_gpio
= (1 << 2), /* disable LNA */
448 static int drxk_gate_ctrl(struct dvb_frontend
*fe
, int enable
)
450 struct em28xx_dvb
*dvb
= fe
->sec_priv
;
457 down(&dvb
->pll_mutex
);
458 status
= dvb
->gate_ctrl(fe
, 1);
460 status
= dvb
->gate_ctrl(fe
, 0);
466 static void hauppauge_hvr930c_init(struct em28xx
*dev
)
470 struct em28xx_reg_seq hauppauge_hvr930c_init
[] = {
471 {EM2874_R80_GPIO_P0_CTRL
, 0xff, 0xff, 0x65},
472 {EM2874_R80_GPIO_P0_CTRL
, 0xfb, 0xff, 0x32},
473 {EM2874_R80_GPIO_P0_CTRL
, 0xff, 0xff, 0xb8},
476 struct em28xx_reg_seq hauppauge_hvr930c_end
[] = {
477 {EM2874_R80_GPIO_P0_CTRL
, 0xef, 0xff, 0x01},
478 {EM2874_R80_GPIO_P0_CTRL
, 0xaf, 0xff, 0x65},
479 {EM2874_R80_GPIO_P0_CTRL
, 0xef, 0xff, 0x76},
480 {EM2874_R80_GPIO_P0_CTRL
, 0xef, 0xff, 0x01},
481 {EM2874_R80_GPIO_P0_CTRL
, 0xcf, 0xff, 0x0b},
482 {EM2874_R80_GPIO_P0_CTRL
, 0xef, 0xff, 0x40},
484 {EM2874_R80_GPIO_P0_CTRL
, 0xcf, 0xff, 0x65},
485 {EM2874_R80_GPIO_P0_CTRL
, 0xef, 0xff, 0x65},
486 {EM2874_R80_GPIO_P0_CTRL
, 0xcf, 0xff, 0x0b},
487 {EM2874_R80_GPIO_P0_CTRL
, 0xef, 0xff, 0x65},
496 {{ 0x06, 0x02, 0x00, 0x31 }, 4},
498 {{ 0x01, 0x02, 0x00, 0xc6 }, 4},
500 {{ 0x01, 0x00, 0xff, 0xaf }, 4},
501 {{ 0x01, 0x00, 0x03, 0xa0 }, 4},
503 {{ 0x01, 0x00, 0x73, 0xaf }, 4},
506 {{ 0x00, 0x04, 0x00, 0x0a }, 4},
508 {{ 0x04, 0x14, 0x00, 0x00 }, 4},
511 em28xx_gpio_set(dev
, hauppauge_hvr930c_init
);
512 em28xx_write_reg(dev
, EM28XX_R06_I2C_CLK
, 0x40);
514 em28xx_write_reg(dev
, EM28XX_R06_I2C_CLK
, 0x44);
517 dev
->i2c_client
[dev
->def_i2c_bus
].addr
= 0x82 >> 1;
519 for (i
= 0; i
< ARRAY_SIZE(regs
); i
++)
520 i2c_master_send(&dev
->i2c_client
[dev
->def_i2c_bus
], regs
[i
].r
, regs
[i
].len
);
521 em28xx_gpio_set(dev
, hauppauge_hvr930c_end
);
525 em28xx_write_reg(dev
, EM28XX_R06_I2C_CLK
, 0x44);
528 em28xx_write_reg(dev
, EM28XX_R06_I2C_CLK
, 0x45);
533 static void terratec_h5_init(struct em28xx
*dev
)
536 struct em28xx_reg_seq terratec_h5_init
[] = {
537 {EM2820_R08_GPIO_CTRL
, 0xff, 0xff, 10},
538 {EM2874_R80_GPIO_P0_CTRL
, 0xf6, 0xff, 100},
539 {EM2874_R80_GPIO_P0_CTRL
, 0xf2, 0xff, 50},
540 {EM2874_R80_GPIO_P0_CTRL
, 0xf6, 0xff, 100},
543 struct em28xx_reg_seq terratec_h5_end
[] = {
544 {EM2874_R80_GPIO_P0_CTRL
, 0xe6, 0xff, 100},
545 {EM2874_R80_GPIO_P0_CTRL
, 0xa6, 0xff, 50},
546 {EM2874_R80_GPIO_P0_CTRL
, 0xe6, 0xff, 100},
553 {{ 0x06, 0x02, 0x00, 0x31 }, 4},
555 {{ 0x01, 0x02, 0x00, 0xc6 }, 4},
557 {{ 0x01, 0x00, 0xff, 0xaf }, 4},
558 {{ 0x01, 0x00, 0x03, 0xa0 }, 4},
560 {{ 0x01, 0x00, 0x73, 0xaf }, 4},
563 {{ 0x00, 0x04, 0x00, 0x0a }, 4},
565 {{ 0x04, 0x14, 0x00, 0x00 }, 4},
568 em28xx_gpio_set(dev
, terratec_h5_init
);
569 em28xx_write_reg(dev
, EM28XX_R06_I2C_CLK
, 0x40);
571 em28xx_write_reg(dev
, EM28XX_R06_I2C_CLK
, 0x45);
574 dev
->i2c_client
[dev
->def_i2c_bus
].addr
= 0x82 >> 1;
576 for (i
= 0; i
< ARRAY_SIZE(regs
); i
++)
577 i2c_master_send(&dev
->i2c_client
[dev
->def_i2c_bus
], regs
[i
].r
, regs
[i
].len
);
578 em28xx_gpio_set(dev
, terratec_h5_end
);
581 static void terratec_htc_stick_init(struct em28xx
*dev
)
586 * GPIO configuration:
587 * 0xff: unknown (does not affect DVB-T).
588 * 0xf6: DRX-K (demodulator).
589 * 0xe6: unknown (does not affect DVB-T).
590 * 0xb6: unknown (does not affect DVB-T).
592 struct em28xx_reg_seq terratec_htc_stick_init
[] = {
593 {EM2820_R08_GPIO_CTRL
, 0xff, 0xff, 10},
594 {EM2874_R80_GPIO_P0_CTRL
, 0xf6, 0xff, 100},
595 {EM2874_R80_GPIO_P0_CTRL
, 0xe6, 0xff, 50},
596 {EM2874_R80_GPIO_P0_CTRL
, 0xf6, 0xff, 100},
599 struct em28xx_reg_seq terratec_htc_stick_end
[] = {
600 {EM2874_R80_GPIO_P0_CTRL
, 0xb6, 0xff, 100},
601 {EM2874_R80_GPIO_P0_CTRL
, 0xf6, 0xff, 50},
606 * Init the analog decoder (not yet supported), but
607 * it's probably still a good idea.
613 {{ 0x06, 0x02, 0x00, 0x31 }, 4},
615 {{ 0x01, 0x02, 0x00, 0xc6 }, 4},
617 {{ 0x01, 0x00, 0xff, 0xaf }, 4},
620 em28xx_gpio_set(dev
, terratec_htc_stick_init
);
622 em28xx_write_reg(dev
, EM28XX_R06_I2C_CLK
, 0x40);
624 em28xx_write_reg(dev
, EM28XX_R06_I2C_CLK
, 0x44);
627 dev
->i2c_client
[dev
->def_i2c_bus
].addr
= 0x82 >> 1;
629 for (i
= 0; i
< ARRAY_SIZE(regs
); i
++)
630 i2c_master_send(&dev
->i2c_client
[dev
->def_i2c_bus
], regs
[i
].r
, regs
[i
].len
);
632 em28xx_gpio_set(dev
, terratec_htc_stick_end
);
635 static void terratec_htc_usb_xs_init(struct em28xx
*dev
)
639 struct em28xx_reg_seq terratec_htc_usb_xs_init
[] = {
640 {EM2820_R08_GPIO_CTRL
, 0xff, 0xff, 10},
641 {EM2874_R80_GPIO_P0_CTRL
, 0xb2, 0xff, 100},
642 {EM2874_R80_GPIO_P0_CTRL
, 0xb2, 0xff, 50},
643 {EM2874_R80_GPIO_P0_CTRL
, 0xb6, 0xff, 100},
646 struct em28xx_reg_seq terratec_htc_usb_xs_end
[] = {
647 {EM2874_R80_GPIO_P0_CTRL
, 0xa6, 0xff, 100},
648 {EM2874_R80_GPIO_P0_CTRL
, 0xa6, 0xff, 50},
649 {EM2874_R80_GPIO_P0_CTRL
, 0xe6, 0xff, 100},
654 * Init the analog decoder (not yet supported), but
655 * it's probably still a good idea.
661 {{ 0x06, 0x02, 0x00, 0x31 }, 4},
663 {{ 0x01, 0x02, 0x00, 0xc6 }, 4},
665 {{ 0x01, 0x00, 0xff, 0xaf }, 4},
666 {{ 0x01, 0x00, 0x03, 0xa0 }, 4},
668 {{ 0x01, 0x00, 0x73, 0xaf }, 4},
671 {{ 0x00, 0x04, 0x00, 0x0a }, 4},
673 {{ 0x04, 0x14, 0x00, 0x00 }, 4},
676 em28xx_write_reg(dev
, EM28XX_R06_I2C_CLK
, 0x40);
678 em28xx_gpio_set(dev
, terratec_htc_usb_xs_init
);
680 em28xx_write_reg(dev
, EM28XX_R06_I2C_CLK
, 0x40);
682 em28xx_write_reg(dev
, EM28XX_R06_I2C_CLK
, 0x44);
685 dev
->i2c_client
[dev
->def_i2c_bus
].addr
= 0x82 >> 1;
687 for (i
= 0; i
< ARRAY_SIZE(regs
); i
++)
688 i2c_master_send(&dev
->i2c_client
[dev
->def_i2c_bus
], regs
[i
].r
, regs
[i
].len
);
690 em28xx_gpio_set(dev
, terratec_htc_usb_xs_end
);
693 static void pctv_520e_init(struct em28xx
*dev
)
696 * Init AVF4910B analog decoder. Looks like I2C traffic to
697 * digital demodulator and tuner are routed via AVF4910B.
704 {{ 0x06, 0x02, 0x00, 0x31 }, 4},
706 {{ 0x01, 0x02, 0x00, 0xc6 }, 4},
708 {{ 0x01, 0x00, 0xff, 0xaf }, 4},
709 {{ 0x01, 0x00, 0x03, 0xa0 }, 4},
711 {{ 0x01, 0x00, 0x73, 0xaf }, 4},
714 dev
->i2c_client
[dev
->def_i2c_bus
].addr
= 0x82 >> 1; /* 0x41 */
716 for (i
= 0; i
< ARRAY_SIZE(regs
); i
++)
717 i2c_master_send(&dev
->i2c_client
[dev
->def_i2c_bus
], regs
[i
].r
, regs
[i
].len
);
720 static int em28xx_pctv_290e_set_lna(struct dvb_frontend
*fe
)
722 struct dtv_frontend_properties
*c
= &fe
->dtv_property_cache
;
723 struct em28xx_i2c_bus
*i2c_bus
= fe
->dvb
->priv
;
724 struct em28xx
*dev
= i2c_bus
->dev
;
725 #ifdef CONFIG_GPIOLIB
726 struct em28xx_dvb
*dvb
= dev
->dvb
;
731 flags
= GPIOF_OUT_INIT_HIGH
; /* enable LNA */
733 flags
= GPIOF_OUT_INIT_LOW
; /* disable LNA */
735 ret
= gpio_request_one(dvb
->lna_gpio
, flags
, NULL
);
737 em28xx_errdev("gpio request failed %d\n", ret
);
739 gpio_free(dvb
->lna_gpio
);
743 dev_warn(&dev
->udev
->dev
, "%s: LNA control is disabled (lna=%u)\n",
744 KBUILD_MODNAME
, c
->lna
);
749 static int em28xx_pctv_292e_set_lna(struct dvb_frontend
*fe
)
751 struct dtv_frontend_properties
*c
= &fe
->dtv_property_cache
;
752 struct em28xx_i2c_bus
*i2c_bus
= fe
->dvb
->priv
;
753 struct em28xx
*dev
= i2c_bus
->dev
;
761 return em28xx_write_reg_bits(dev
, EM2874_R80_GPIO_P0_CTRL
, lna
, 0x01);
764 static int em28xx_mt352_terratec_xs_init(struct dvb_frontend
*fe
)
766 /* Values extracted from a USB trace of the Terratec Windows driver */
767 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x2c };
768 static u8 reset
[] = { RESET
, 0x80 };
769 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
770 static u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0xa0 };
771 static u8 input_freq_cfg
[] = { INPUT_FREQ_1
, 0x31, 0xb8 };
772 static u8 rs_err_cfg
[] = { RS_ERR_PER_1
, 0x00, 0x4d };
773 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x32 };
774 static u8 trl_nom_cfg
[] = { TRL_NOMINAL_RATE_1
, 0x64, 0x00 };
775 static u8 tps_given_cfg
[] = { TPS_GIVEN_1
, 0x40, 0x80, 0x50 };
776 static u8 tuner_go
[] = { TUNER_GO
, 0x01};
778 mt352_write(fe
, clock_config
, sizeof(clock_config
));
780 mt352_write(fe
, reset
, sizeof(reset
));
781 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
782 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
783 mt352_write(fe
, input_freq_cfg
, sizeof(input_freq_cfg
));
784 mt352_write(fe
, rs_err_cfg
, sizeof(rs_err_cfg
));
785 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
786 mt352_write(fe
, trl_nom_cfg
, sizeof(trl_nom_cfg
));
787 mt352_write(fe
, tps_given_cfg
, sizeof(tps_given_cfg
));
788 mt352_write(fe
, tuner_go
, sizeof(tuner_go
));
792 static void px_bcud_init(struct em28xx
*dev
)
813 static struct em28xx_reg_seq gpio
[] = {
814 {EM28XX_R06_I2C_CLK
, 0x40, 0xff, 300},
815 {EM2874_R80_GPIO_P0_CTRL
, 0xfd, 0xff, 60},
816 {EM28XX_R15_RGAIN
, 0x20, 0xff, 0},
817 {EM28XX_R16_GGAIN
, 0x20, 0xff, 0},
818 {EM28XX_R17_BGAIN
, 0x20, 0xff, 0},
819 {EM28XX_R18_ROFFSET
, 0x00, 0xff, 0},
820 {EM28XX_R19_GOFFSET
, 0x00, 0xff, 0},
821 {EM28XX_R1A_BOFFSET
, 0x00, 0xff, 0},
822 {EM28XX_R23_UOFFSET
, 0x00, 0xff, 0},
823 {EM28XX_R24_VOFFSET
, 0x00, 0xff, 0},
824 {EM28XX_R26_COMPR
, 0x00, 0xff, 0},
825 {0x13, 0x08, 0xff, 0},
826 {EM28XX_R12_VINENABLE
, 0x27, 0xff, 0},
827 {EM28XX_R0C_USBSUSP
, 0x10, 0xff, 0},
828 {EM28XX_R27_OUTFMT
, 0x00, 0xff, 0},
829 {EM28XX_R10_VINMODE
, 0x00, 0xff, 0},
830 {EM28XX_R11_VINCTRL
, 0x11, 0xff, 0},
831 {EM2874_R50_IR_CONFIG
, 0x01, 0xff, 0},
832 {EM2874_R5F_TS_ENABLE
, 0x80, 0xff, 0},
833 {EM28XX_R06_I2C_CLK
, 0x46, 0xff, 0},
835 em28xx_write_reg(dev
, EM28XX_R06_I2C_CLK
, 0x46);
836 /* sleeping ISDB-T */
837 dev
->dvb
->i2c_client_demod
->addr
= 0x14;
838 for (i
= 0; i
< ARRAY_SIZE(regs1
); i
++)
839 i2c_master_send(dev
->dvb
->i2c_client_demod
, regs1
[i
].r
,
841 /* sleeping ISDB-S */
842 dev
->dvb
->i2c_client_demod
->addr
= 0x15;
843 for (i
= 0; i
< ARRAY_SIZE(regs2
); i
++)
844 i2c_master_send(dev
->dvb
->i2c_client_demod
, regs2
[i
].r
,
846 for (i
= 0; i
< ARRAY_SIZE(gpio
); i
++) {
847 em28xx_write_reg_bits(dev
, gpio
[i
].reg
, gpio
[i
].val
,
849 if (gpio
[i
].sleep
> 0)
850 msleep(gpio
[i
].sleep
);
854 static struct mt352_config terratec_xs_mt352_cfg
= {
855 .demod_address
= (0x1e >> 1),
858 .demod_init
= em28xx_mt352_terratec_xs_init
,
861 static struct tda10023_config em28xx_tda10023_config
= {
862 .demod_address
= 0x0c,
866 static struct cxd2820r_config em28xx_cxd2820r_config
= {
867 .i2c_address
= (0xd8 >> 1),
868 .ts_mode
= CXD2820R_TS_SERIAL
,
871 static struct tda18271_config em28xx_cxd2820r_tda18271_config
= {
872 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
873 .gate
= TDA18271_GATE_DIGITAL
,
876 static struct zl10353_config em28xx_zl10353_no_i2c_gate_dev
= {
877 .demod_address
= (0x1e >> 1),
878 .disable_i2c_gate_ctrl
= 1,
883 static struct mt2060_config em28xx_mt2060_config
= {
887 static struct qt1010_config em28xx_qt1010_config
= {
891 static const struct mb86a20s_config c3tech_duo_mb86a20s_config
= {
892 .demod_address
= 0x10,
896 static struct tda18271_std_map mb86a20s_tda18271_config
= {
897 .dvbt_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 4,
898 .if_lvl
= 1, .rfagc_top
= 0x37, },
901 static struct tda18271_config c3tech_duo_tda18271_config
= {
902 .std_map
= &mb86a20s_tda18271_config
,
903 .gate
= TDA18271_GATE_DIGITAL
,
904 .small_i2c
= TDA18271_03_BYTE_CHUNK_INIT
,
907 static struct tda18271_std_map drx_j_std_map
= {
908 .atsc_6
= { .if_freq
= 5000, .agc_mode
= 3, .std
= 0, .if_lvl
= 1,
909 .rfagc_top
= 0x37, },
910 .qam_6
= { .if_freq
= 5380, .agc_mode
= 3, .std
= 3, .if_lvl
= 1,
911 .rfagc_top
= 0x37, },
914 static struct tda18271_config pinnacle_80e_dvb_config
= {
915 .std_map
= &drx_j_std_map
,
916 .gate
= TDA18271_GATE_DIGITAL
,
917 .role
= TDA18271_MASTER
,
920 /* ------------------------------------------------------------------ */
922 static int em28xx_attach_xc3028(u8 addr
, struct em28xx
*dev
)
924 struct dvb_frontend
*fe
;
925 struct xc2028_config cfg
;
926 struct xc2028_ctrl ctl
;
928 memset(&cfg
, 0, sizeof(cfg
));
929 cfg
.i2c_adap
= &dev
->i2c_adap
[dev
->def_i2c_bus
];
932 memset(&ctl
, 0, sizeof(ctl
));
933 em28xx_setup_xc3028(dev
, &ctl
);
936 if (!dev
->dvb
->fe
[0]) {
937 em28xx_errdev("/2: dvb frontend not attached. "
938 "Can't attach xc3028\n");
942 fe
= dvb_attach(xc2028_attach
, dev
->dvb
->fe
[0], &cfg
);
944 em28xx_errdev("/2: xc3028 attach failed\n");
945 dvb_frontend_detach(dev
->dvb
->fe
[0]);
946 dev
->dvb
->fe
[0] = NULL
;
950 em28xx_info("%s/2: xc3028 attached\n", dev
->name
);
955 /* ------------------------------------------------------------------ */
957 static int em28xx_register_dvb(struct em28xx_dvb
*dvb
, struct module
*module
,
958 struct em28xx
*dev
, struct device
*device
)
961 bool create_rf_connector
= false;
963 mutex_init(&dvb
->lock
);
965 /* register adapter */
966 result
= dvb_register_adapter(&dvb
->adapter
, dev
->name
, module
, device
,
969 printk(KERN_WARNING
"%s: dvb_register_adapter failed (errno = %d)\n",
973 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
974 dvb
->adapter
.mdev
= dev
->media_dev
;
977 /* Ensure all frontends negotiate bus access */
978 dvb
->fe
[0]->ops
.ts_bus_ctrl
= em28xx_dvb_bus_ctrl
;
980 dvb
->fe
[1]->ops
.ts_bus_ctrl
= em28xx_dvb_bus_ctrl
;
982 dvb
->adapter
.priv
= &dev
->i2c_bus
[dev
->def_i2c_bus
];
984 /* register frontend */
985 result
= dvb_register_frontend(&dvb
->adapter
, dvb
->fe
[0]);
987 printk(KERN_WARNING
"%s: dvb_register_frontend failed (errno = %d)\n",
992 /* register 2nd frontend */
994 result
= dvb_register_frontend(&dvb
->adapter
, dvb
->fe
[1]);
996 printk(KERN_WARNING
"%s: 2nd dvb_register_frontend failed (errno = %d)\n",
1002 /* register demux stuff */
1003 dvb
->demux
.dmx
.capabilities
=
1004 DMX_TS_FILTERING
| DMX_SECTION_FILTERING
|
1005 DMX_MEMORY_BASED_FILTERING
;
1006 dvb
->demux
.priv
= dvb
;
1007 dvb
->demux
.filternum
= 256;
1008 dvb
->demux
.feednum
= 256;
1009 dvb
->demux
.start_feed
= em28xx_start_feed
;
1010 dvb
->demux
.stop_feed
= em28xx_stop_feed
;
1012 result
= dvb_dmx_init(&dvb
->demux
);
1014 printk(KERN_WARNING
"%s: dvb_dmx_init failed (errno = %d)\n",
1019 dvb
->dmxdev
.filternum
= 256;
1020 dvb
->dmxdev
.demux
= &dvb
->demux
.dmx
;
1021 dvb
->dmxdev
.capabilities
= 0;
1022 result
= dvb_dmxdev_init(&dvb
->dmxdev
, &dvb
->adapter
);
1024 printk(KERN_WARNING
"%s: dvb_dmxdev_init failed (errno = %d)\n",
1029 dvb
->fe_hw
.source
= DMX_FRONTEND_0
;
1030 result
= dvb
->demux
.dmx
.add_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
1032 printk(KERN_WARNING
"%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n",
1037 dvb
->fe_mem
.source
= DMX_MEMORY_FE
;
1038 result
= dvb
->demux
.dmx
.add_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
1040 printk(KERN_WARNING
"%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n",
1045 result
= dvb
->demux
.dmx
.connect_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
1047 printk(KERN_WARNING
"%s: connect_frontend failed (errno = %d)\n",
1052 /* register network adapter */
1053 dvb_net_init(&dvb
->adapter
, &dvb
->net
, &dvb
->demux
.dmx
);
1055 /* If the analog part won't create RF connectors, DVB will do it */
1056 if (!dev
->has_video
|| (dev
->tuner_type
== TUNER_ABSENT
))
1057 create_rf_connector
= true;
1059 result
= dvb_create_media_graph(&dvb
->adapter
, create_rf_connector
);
1061 goto fail_create_graph
;
1066 dvb_net_release(&dvb
->net
);
1068 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
1070 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
1072 dvb_dmxdev_release(&dvb
->dmxdev
);
1074 dvb_dmx_release(&dvb
->demux
);
1077 dvb_unregister_frontend(dvb
->fe
[1]);
1078 dvb_unregister_frontend(dvb
->fe
[0]);
1081 dvb_frontend_detach(dvb
->fe
[1]);
1083 dvb_frontend_detach(dvb
->fe
[0]);
1084 dvb_unregister_adapter(&dvb
->adapter
);
1089 static void em28xx_unregister_dvb(struct em28xx_dvb
*dvb
)
1091 dvb_net_release(&dvb
->net
);
1092 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
1093 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
1094 dvb_dmxdev_release(&dvb
->dmxdev
);
1095 dvb_dmx_release(&dvb
->demux
);
1097 dvb_unregister_frontend(dvb
->fe
[1]);
1098 dvb_unregister_frontend(dvb
->fe
[0]);
1099 if (dvb
->fe
[1] && !dvb
->dont_attach_fe1
)
1100 dvb_frontend_detach(dvb
->fe
[1]);
1101 dvb_frontend_detach(dvb
->fe
[0]);
1102 dvb_unregister_adapter(&dvb
->adapter
);
1105 static int em28xx_dvb_init(struct em28xx
*dev
)
1108 struct em28xx_dvb
*dvb
;
1110 if (dev
->is_audio_only
) {
1111 /* Shouldn't initialize IR for this interface */
1115 if (!dev
->board
.has_dvb
) {
1116 /* This device does not support the extension */
1120 em28xx_info("Binding DVB extension\n");
1122 dvb
= kzalloc(sizeof(struct em28xx_dvb
), GFP_KERNEL
);
1124 em28xx_info("em28xx_dvb: memory allocation failed\n");
1128 dvb
->fe
[0] = dvb
->fe
[1] = NULL
;
1130 /* pre-allocate DVB usb transfer buffers */
1131 if (dev
->dvb_xfer_bulk
) {
1132 result
= em28xx_alloc_urbs(dev
, EM28XX_DIGITAL_MODE
,
1134 EM28XX_DVB_NUM_BUFS
,
1136 EM28XX_DVB_BULK_PACKET_MULTIPLIER
);
1138 result
= em28xx_alloc_urbs(dev
, EM28XX_DIGITAL_MODE
,
1140 EM28XX_DVB_NUM_BUFS
,
1141 dev
->dvb_max_pkt_size_isoc
,
1142 EM28XX_DVB_NUM_ISOC_PACKETS
);
1145 em28xx_errdev("em28xx_dvb: failed to pre-allocate USB transfer buffers for DVB.\n");
1151 mutex_lock(&dev
->lock
);
1152 em28xx_set_mode(dev
, EM28XX_DIGITAL_MODE
);
1154 switch (dev
->model
) {
1155 case EM2874_BOARD_LEADERSHIP_ISDBT
:
1156 dvb
->fe
[0] = dvb_attach(s921_attach
,
1157 &sharp_isdbt
, &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1165 case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850
:
1166 case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950
:
1167 case EM2880_BOARD_PINNACLE_PCTV_HD_PRO
:
1168 case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600
:
1169 dvb
->fe
[0] = dvb_attach(lgdt330x_attach
,
1170 &em2880_lgdt3303_dev
,
1171 &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1172 if (em28xx_attach_xc3028(0x61, dev
) < 0) {
1177 case EM2880_BOARD_KWORLD_DVB_310U
:
1178 dvb
->fe
[0] = dvb_attach(zl10353_attach
,
1179 &em28xx_zl10353_with_xc3028
,
1180 &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1181 if (em28xx_attach_xc3028(0x61, dev
) < 0) {
1186 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900
:
1187 case EM2882_BOARD_TERRATEC_HYBRID_XS
:
1188 case EM2880_BOARD_EMPIRE_DUAL_TV
:
1189 dvb
->fe
[0] = dvb_attach(zl10353_attach
,
1190 &em28xx_zl10353_xc3028_no_i2c_gate
,
1191 &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1192 if (em28xx_attach_xc3028(0x61, dev
) < 0) {
1197 case EM2880_BOARD_TERRATEC_HYBRID_XS
:
1198 case EM2880_BOARD_TERRATEC_HYBRID_XS_FR
:
1199 case EM2881_BOARD_PINNACLE_HYBRID_PRO
:
1200 case EM2882_BOARD_DIKOM_DK300
:
1201 case EM2882_BOARD_KWORLD_VS_DVBT
:
1202 dvb
->fe
[0] = dvb_attach(zl10353_attach
,
1203 &em28xx_zl10353_xc3028_no_i2c_gate
,
1204 &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1205 if (dvb
->fe
[0] == NULL
) {
1206 /* This board could have either a zl10353 or a mt352.
1207 If the chip id isn't for zl10353, try mt352 */
1208 dvb
->fe
[0] = dvb_attach(mt352_attach
,
1209 &terratec_xs_mt352_cfg
,
1210 &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1213 if (em28xx_attach_xc3028(0x61, dev
) < 0) {
1218 case EM2870_BOARD_TERRATEC_XS_MT2060
:
1219 dvb
->fe
[0] = dvb_attach(zl10353_attach
,
1220 &em28xx_zl10353_no_i2c_gate_dev
,
1221 &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1222 if (dvb
->fe
[0] != NULL
) {
1223 dvb_attach(mt2060_attach
, dvb
->fe
[0],
1224 &dev
->i2c_adap
[dev
->def_i2c_bus
],
1225 &em28xx_mt2060_config
, 1220);
1228 case EM2870_BOARD_KWORLD_355U
:
1229 dvb
->fe
[0] = dvb_attach(zl10353_attach
,
1230 &em28xx_zl10353_no_i2c_gate_dev
,
1231 &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1232 if (dvb
->fe
[0] != NULL
)
1233 dvb_attach(qt1010_attach
, dvb
->fe
[0],
1234 &dev
->i2c_adap
[dev
->def_i2c_bus
], &em28xx_qt1010_config
);
1236 case EM2883_BOARD_KWORLD_HYBRID_330U
:
1237 case EM2882_BOARD_EVGA_INDTUBE
:
1238 dvb
->fe
[0] = dvb_attach(s5h1409_attach
,
1239 &em28xx_s5h1409_with_xc3028
,
1240 &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1241 if (em28xx_attach_xc3028(0x61, dev
) < 0) {
1246 case EM2882_BOARD_KWORLD_ATSC_315U
:
1247 dvb
->fe
[0] = dvb_attach(lgdt330x_attach
,
1248 &em2880_lgdt3303_dev
,
1249 &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1250 if (dvb
->fe
[0] != NULL
) {
1251 if (!dvb_attach(simple_tuner_attach
, dvb
->fe
[0],
1252 &dev
->i2c_adap
[dev
->def_i2c_bus
],
1253 0x61, TUNER_THOMSON_DTT761X
)) {
1259 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2
:
1260 case EM2882_BOARD_PINNACLE_HYBRID_PRO_330E
:
1261 dvb
->fe
[0] = dvb_attach(drxd_attach
, &em28xx_drxd
, NULL
,
1262 &dev
->i2c_adap
[dev
->def_i2c_bus
], &dev
->udev
->dev
);
1263 if (em28xx_attach_xc3028(0x61, dev
) < 0) {
1268 case EM2870_BOARD_REDDO_DVB_C_USB_BOX
:
1269 /* Philips CU1216L NIM (Philips TDA10023 + Infineon TUA6034) */
1270 dvb
->fe
[0] = dvb_attach(tda10023_attach
,
1271 &em28xx_tda10023_config
,
1272 &dev
->i2c_adap
[dev
->def_i2c_bus
], 0x48);
1274 if (!dvb_attach(simple_tuner_attach
, dvb
->fe
[0],
1275 &dev
->i2c_adap
[dev
->def_i2c_bus
],
1276 0x60, TUNER_PHILIPS_CU1216L
)) {
1282 case EM2870_BOARD_KWORLD_A340
:
1283 dvb
->fe
[0] = dvb_attach(lgdt3305_attach
,
1284 &em2870_lgdt3304_dev
,
1285 &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1290 if (!dvb_attach(tda18271_attach
, dvb
->fe
[0], 0x60,
1291 &dev
->i2c_adap
[dev
->def_i2c_bus
],
1292 &kworld_a340_config
)) {
1293 dvb_frontend_detach(dvb
->fe
[0]);
1298 case EM28174_BOARD_PCTV_290E
:
1299 /* set default GPIO0 for LNA, used if GPIOLIB is undefined */
1300 dvb
->lna_gpio
= CXD2820R_GPIO_E
| CXD2820R_GPIO_O
|
1302 dvb
->fe
[0] = dvb_attach(cxd2820r_attach
,
1303 &em28xx_cxd2820r_config
,
1304 &dev
->i2c_adap
[dev
->def_i2c_bus
],
1307 /* FE 0 attach tuner */
1308 if (!dvb_attach(tda18271_attach
,
1311 &dev
->i2c_adap
[dev
->def_i2c_bus
],
1312 &em28xx_cxd2820r_tda18271_config
)) {
1314 dvb_frontend_detach(dvb
->fe
[0]);
1319 #ifdef CONFIG_GPIOLIB
1320 /* enable LNA for DVB-T, DVB-T2 and DVB-C */
1321 result
= gpio_request_one(dvb
->lna_gpio
,
1322 GPIOF_OUT_INIT_LOW
, NULL
);
1324 em28xx_errdev("gpio request failed %d\n",
1327 gpio_free(dvb
->lna_gpio
);
1329 result
= 0; /* continue even set LNA fails */
1331 dvb
->fe
[0]->ops
.set_lna
= em28xx_pctv_290e_set_lna
;
1335 case EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C
:
1337 struct xc5000_config cfg
;
1339 hauppauge_hvr930c_init(dev
);
1341 dvb
->fe
[0] = dvb_attach(drxk_attach
,
1342 &hauppauge_930c_drxk
, &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1347 /* FIXME: do we need a pll semaphore? */
1348 dvb
->fe
[0]->sec_priv
= dvb
;
1349 sema_init(&dvb
->pll_mutex
, 1);
1350 dvb
->gate_ctrl
= dvb
->fe
[0]->ops
.i2c_gate_ctrl
;
1351 dvb
->fe
[0]->ops
.i2c_gate_ctrl
= drxk_gate_ctrl
;
1354 memset(&cfg
, 0, sizeof(cfg
));
1355 cfg
.i2c_address
= 0x61;
1358 if (dvb
->fe
[0]->ops
.i2c_gate_ctrl
)
1359 dvb
->fe
[0]->ops
.i2c_gate_ctrl(dvb
->fe
[0], 1);
1360 if (!dvb_attach(xc5000_attach
, dvb
->fe
[0], &dev
->i2c_adap
[dev
->def_i2c_bus
],
1365 if (dvb
->fe
[0]->ops
.i2c_gate_ctrl
)
1366 dvb
->fe
[0]->ops
.i2c_gate_ctrl(dvb
->fe
[0], 0);
1370 case EM2884_BOARD_TERRATEC_H5
:
1371 terratec_h5_init(dev
);
1373 dvb
->fe
[0] = dvb_attach(drxk_attach
, &terratec_h5_drxk
, &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1378 /* FIXME: do we need a pll semaphore? */
1379 dvb
->fe
[0]->sec_priv
= dvb
;
1380 sema_init(&dvb
->pll_mutex
, 1);
1381 dvb
->gate_ctrl
= dvb
->fe
[0]->ops
.i2c_gate_ctrl
;
1382 dvb
->fe
[0]->ops
.i2c_gate_ctrl
= drxk_gate_ctrl
;
1384 /* Attach tda18271 to DVB-C frontend */
1385 if (dvb
->fe
[0]->ops
.i2c_gate_ctrl
)
1386 dvb
->fe
[0]->ops
.i2c_gate_ctrl(dvb
->fe
[0], 1);
1387 if (!dvb_attach(tda18271c2dd_attach
, dvb
->fe
[0], &dev
->i2c_adap
[dev
->def_i2c_bus
], 0x60)) {
1391 if (dvb
->fe
[0]->ops
.i2c_gate_ctrl
)
1392 dvb
->fe
[0]->ops
.i2c_gate_ctrl(dvb
->fe
[0], 0);
1395 case EM2884_BOARD_C3TECH_DIGITAL_DUO
:
1396 dvb
->fe
[0] = dvb_attach(mb86a20s_attach
,
1397 &c3tech_duo_mb86a20s_config
,
1398 &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1399 if (dvb
->fe
[0] != NULL
)
1400 dvb_attach(tda18271_attach
, dvb
->fe
[0], 0x60,
1401 &dev
->i2c_adap
[dev
->def_i2c_bus
],
1402 &c3tech_duo_tda18271_config
);
1404 case EM28174_BOARD_PCTV_460E
: {
1405 struct i2c_client
*client
;
1406 struct i2c_board_info board_info
;
1407 struct tda10071_platform_data tda10071_pdata
= {};
1408 struct a8293_platform_data a8293_pdata
= {};
1410 /* attach demod + tuner combo */
1411 tda10071_pdata
.clk
= 40444000, /* 40.444 MHz */
1412 tda10071_pdata
.i2c_wr_max
= 64,
1413 tda10071_pdata
.ts_mode
= TDA10071_TS_SERIAL
,
1414 tda10071_pdata
.pll_multiplier
= 20,
1415 tda10071_pdata
.tuner_i2c_addr
= 0x14,
1416 memset(&board_info
, 0, sizeof(board_info
));
1417 strlcpy(board_info
.type
, "tda10071_cx24118", I2C_NAME_SIZE
);
1418 board_info
.addr
= 0x55;
1419 board_info
.platform_data
= &tda10071_pdata
;
1420 request_module("tda10071");
1421 client
= i2c_new_device(&dev
->i2c_adap
[dev
->def_i2c_bus
], &board_info
);
1422 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
1426 if (!try_module_get(client
->dev
.driver
->owner
)) {
1427 i2c_unregister_device(client
);
1431 dvb
->fe
[0] = tda10071_pdata
.get_dvb_frontend(client
);
1432 dvb
->i2c_client_demod
= client
;
1435 a8293_pdata
.dvb_frontend
= dvb
->fe
[0];
1436 memset(&board_info
, 0, sizeof(board_info
));
1437 strlcpy(board_info
.type
, "a8293", I2C_NAME_SIZE
);
1438 board_info
.addr
= 0x08;
1439 board_info
.platform_data
= &a8293_pdata
;
1440 request_module("a8293");
1441 client
= i2c_new_device(&dev
->i2c_adap
[dev
->def_i2c_bus
], &board_info
);
1442 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
1443 module_put(dvb
->i2c_client_demod
->dev
.driver
->owner
);
1444 i2c_unregister_device(dvb
->i2c_client_demod
);
1448 if (!try_module_get(client
->dev
.driver
->owner
)) {
1449 i2c_unregister_device(client
);
1450 module_put(dvb
->i2c_client_demod
->dev
.driver
->owner
);
1451 i2c_unregister_device(dvb
->i2c_client_demod
);
1455 dvb
->i2c_client_sec
= client
;
1458 case EM2874_BOARD_DELOCK_61959
:
1459 case EM2874_BOARD_MAXMEDIA_UB425_TC
:
1460 /* attach demodulator */
1461 dvb
->fe
[0] = dvb_attach(drxk_attach
, &maxmedia_ub425_tc_drxk
,
1462 &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1465 /* disable I2C-gate */
1466 dvb
->fe
[0]->ops
.i2c_gate_ctrl
= NULL
;
1469 if (!dvb_attach(tda18271_attach
, dvb
->fe
[0], 0x60,
1470 &dev
->i2c_adap
[dev
->def_i2c_bus
],
1471 &em28xx_cxd2820r_tda18271_config
)) {
1472 dvb_frontend_detach(dvb
->fe
[0]);
1478 case EM2884_BOARD_PCTV_510E
:
1479 case EM2884_BOARD_PCTV_520E
:
1480 pctv_520e_init(dev
);
1482 /* attach demodulator */
1483 dvb
->fe
[0] = dvb_attach(drxk_attach
, &pctv_520e_drxk
,
1484 &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1488 if (!dvb_attach(tda18271_attach
, dvb
->fe
[0], 0x60,
1489 &dev
->i2c_adap
[dev
->def_i2c_bus
],
1490 &em28xx_cxd2820r_tda18271_config
)) {
1491 dvb_frontend_detach(dvb
->fe
[0]);
1497 case EM2884_BOARD_ELGATO_EYETV_HYBRID_2008
:
1498 case EM2884_BOARD_CINERGY_HTC_STICK
:
1499 terratec_htc_stick_init(dev
);
1501 /* attach demodulator */
1502 dvb
->fe
[0] = dvb_attach(drxk_attach
, &terratec_htc_stick_drxk
,
1503 &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1509 /* Attach the demodulator. */
1510 if (!dvb_attach(tda18271_attach
, dvb
->fe
[0], 0x60,
1511 &dev
->i2c_adap
[dev
->def_i2c_bus
],
1512 &em28xx_cxd2820r_tda18271_config
)) {
1517 case EM2884_BOARD_TERRATEC_HTC_USB_XS
:
1518 terratec_htc_usb_xs_init(dev
);
1520 /* attach demodulator */
1521 dvb
->fe
[0] = dvb_attach(drxk_attach
, &terratec_htc_stick_drxk
,
1522 &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1528 /* Attach the demodulator. */
1529 if (!dvb_attach(tda18271_attach
, dvb
->fe
[0], 0x60,
1530 &dev
->i2c_adap
[dev
->def_i2c_bus
],
1531 &em28xx_cxd2820r_tda18271_config
)) {
1536 case EM2874_BOARD_KWORLD_UB435Q_V2
:
1537 dvb
->fe
[0] = dvb_attach(lgdt3305_attach
,
1538 &em2874_lgdt3305_dev
,
1539 &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1545 /* Attach the demodulator. */
1546 if (!dvb_attach(tda18271_attach
, dvb
->fe
[0], 0x60,
1547 &dev
->i2c_adap
[dev
->def_i2c_bus
],
1548 &kworld_ub435q_v2_config
)) {
1553 case EM2874_BOARD_KWORLD_UB435Q_V3
:
1555 struct i2c_client
*client
;
1556 struct i2c_adapter
*adapter
= &dev
->i2c_adap
[dev
->def_i2c_bus
];
1557 struct i2c_board_info board_info
= {
1560 .platform_data
= &kworld_ub435q_v3_config
,
1563 dvb
->fe
[0] = dvb_attach(lgdt3305_attach
,
1564 &em2874_lgdt3305_nogate_dev
,
1565 &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1572 kworld_ub435q_v3_config
.fe
= dvb
->fe
[0];
1573 request_module("tda18212");
1574 client
= i2c_new_device(adapter
, &board_info
);
1575 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
1576 dvb_frontend_detach(dvb
->fe
[0]);
1581 if (!try_module_get(client
->dev
.driver
->owner
)) {
1582 i2c_unregister_device(client
);
1583 dvb_frontend_detach(dvb
->fe
[0]);
1588 dvb
->i2c_client_tuner
= client
;
1591 case EM2874_BOARD_PCTV_HD_MINI_80E
:
1592 dvb
->fe
[0] = dvb_attach(drx39xxj_attach
, &dev
->i2c_adap
[dev
->def_i2c_bus
]);
1593 if (dvb
->fe
[0] != NULL
) {
1594 dvb
->fe
[0] = dvb_attach(tda18271_attach
, dvb
->fe
[0], 0x60,
1595 &dev
->i2c_adap
[dev
->def_i2c_bus
],
1596 &pinnacle_80e_dvb_config
);
1603 case EM28178_BOARD_PCTV_461E
: {
1604 struct i2c_client
*client
;
1605 struct i2c_adapter
*i2c_adapter
;
1606 struct i2c_board_info board_info
;
1607 struct m88ds3103_platform_data m88ds3103_pdata
= {};
1608 struct ts2020_config ts2020_config
= {};
1609 struct a8293_platform_data a8293_pdata
= {};
1612 m88ds3103_pdata
.clk
= 27000000;
1613 m88ds3103_pdata
.i2c_wr_max
= 33;
1614 m88ds3103_pdata
.ts_mode
= M88DS3103_TS_PARALLEL
;
1615 m88ds3103_pdata
.ts_clk
= 16000;
1616 m88ds3103_pdata
.ts_clk_pol
= 1;
1617 m88ds3103_pdata
.agc
= 0x99;
1618 memset(&board_info
, 0, sizeof(board_info
));
1619 strlcpy(board_info
.type
, "m88ds3103", I2C_NAME_SIZE
);
1620 board_info
.addr
= 0x68;
1621 board_info
.platform_data
= &m88ds3103_pdata
;
1622 request_module("m88ds3103");
1623 client
= i2c_new_device(&dev
->i2c_adap
[dev
->def_i2c_bus
], &board_info
);
1624 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
1628 if (!try_module_get(client
->dev
.driver
->owner
)) {
1629 i2c_unregister_device(client
);
1633 dvb
->fe
[0] = m88ds3103_pdata
.get_dvb_frontend(client
);
1634 i2c_adapter
= m88ds3103_pdata
.get_i2c_adapter(client
);
1635 dvb
->i2c_client_demod
= client
;
1638 ts2020_config
.fe
= dvb
->fe
[0];
1639 memset(&board_info
, 0, sizeof(board_info
));
1640 strlcpy(board_info
.type
, "ts2022", I2C_NAME_SIZE
);
1641 board_info
.addr
= 0x60;
1642 board_info
.platform_data
= &ts2020_config
;
1643 request_module("ts2020");
1644 client
= i2c_new_device(i2c_adapter
, &board_info
);
1645 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
1646 module_put(dvb
->i2c_client_demod
->dev
.driver
->owner
);
1647 i2c_unregister_device(dvb
->i2c_client_demod
);
1651 if (!try_module_get(client
->dev
.driver
->owner
)) {
1652 i2c_unregister_device(client
);
1653 module_put(dvb
->i2c_client_demod
->dev
.driver
->owner
);
1654 i2c_unregister_device(dvb
->i2c_client_demod
);
1658 dvb
->i2c_client_tuner
= client
;
1659 /* delegate signal strength measurement to tuner */
1660 dvb
->fe
[0]->ops
.read_signal_strength
=
1661 dvb
->fe
[0]->ops
.tuner_ops
.get_rf_strength
;
1664 a8293_pdata
.dvb_frontend
= dvb
->fe
[0];
1665 memset(&board_info
, 0, sizeof(board_info
));
1666 strlcpy(board_info
.type
, "a8293", I2C_NAME_SIZE
);
1667 board_info
.addr
= 0x08;
1668 board_info
.platform_data
= &a8293_pdata
;
1669 request_module("a8293");
1670 client
= i2c_new_device(&dev
->i2c_adap
[dev
->def_i2c_bus
], &board_info
);
1671 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
1672 module_put(dvb
->i2c_client_tuner
->dev
.driver
->owner
);
1673 i2c_unregister_device(dvb
->i2c_client_tuner
);
1674 module_put(dvb
->i2c_client_demod
->dev
.driver
->owner
);
1675 i2c_unregister_device(dvb
->i2c_client_demod
);
1679 if (!try_module_get(client
->dev
.driver
->owner
)) {
1680 i2c_unregister_device(client
);
1681 module_put(dvb
->i2c_client_tuner
->dev
.driver
->owner
);
1682 i2c_unregister_device(dvb
->i2c_client_tuner
);
1683 module_put(dvb
->i2c_client_demod
->dev
.driver
->owner
);
1684 i2c_unregister_device(dvb
->i2c_client_demod
);
1688 dvb
->i2c_client_sec
= client
;
1691 case EM28178_BOARD_PCTV_292E
:
1693 struct i2c_adapter
*adapter
;
1694 struct i2c_client
*client
;
1695 struct i2c_board_info info
;
1696 struct si2168_config si2168_config
;
1697 struct si2157_config si2157_config
;
1700 memset(&si2168_config
, 0, sizeof(si2168_config
));
1701 si2168_config
.i2c_adapter
= &adapter
;
1702 si2168_config
.fe
= &dvb
->fe
[0];
1703 si2168_config
.ts_mode
= SI2168_TS_PARALLEL
;
1704 memset(&info
, 0, sizeof(struct i2c_board_info
));
1705 strlcpy(info
.type
, "si2168", I2C_NAME_SIZE
);
1707 info
.platform_data
= &si2168_config
;
1708 request_module(info
.type
);
1709 client
= i2c_new_device(&dev
->i2c_adap
[dev
->def_i2c_bus
], &info
);
1710 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
1715 if (!try_module_get(client
->dev
.driver
->owner
)) {
1716 i2c_unregister_device(client
);
1721 dvb
->i2c_client_demod
= client
;
1724 memset(&si2157_config
, 0, sizeof(si2157_config
));
1725 si2157_config
.fe
= dvb
->fe
[0];
1726 si2157_config
.if_port
= 1;
1727 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
1728 si2157_config
.mdev
= dev
->media_dev
;
1730 memset(&info
, 0, sizeof(struct i2c_board_info
));
1731 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
1733 info
.platform_data
= &si2157_config
;
1734 request_module(info
.type
);
1735 client
= i2c_new_device(adapter
, &info
);
1736 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
1737 module_put(dvb
->i2c_client_demod
->dev
.driver
->owner
);
1738 i2c_unregister_device(dvb
->i2c_client_demod
);
1743 if (!try_module_get(client
->dev
.driver
->owner
)) {
1744 i2c_unregister_device(client
);
1745 module_put(dvb
->i2c_client_demod
->dev
.driver
->owner
);
1746 i2c_unregister_device(dvb
->i2c_client_demod
);
1751 dvb
->i2c_client_tuner
= client
;
1752 dvb
->fe
[0]->ops
.set_lna
= em28xx_pctv_292e_set_lna
;
1755 case EM28178_BOARD_TERRATEC_T2_STICK_HD
:
1757 struct i2c_adapter
*adapter
;
1758 struct i2c_client
*client
;
1759 struct i2c_board_info info
;
1760 struct si2168_config si2168_config
;
1761 struct si2157_config si2157_config
;
1764 memset(&si2168_config
, 0, sizeof(si2168_config
));
1765 si2168_config
.i2c_adapter
= &adapter
;
1766 si2168_config
.fe
= &dvb
->fe
[0];
1767 si2168_config
.ts_mode
= SI2168_TS_PARALLEL
;
1768 memset(&info
, 0, sizeof(struct i2c_board_info
));
1769 strlcpy(info
.type
, "si2168", I2C_NAME_SIZE
);
1771 info
.platform_data
= &si2168_config
;
1772 request_module(info
.type
);
1773 client
= i2c_new_device(&dev
->i2c_adap
[dev
->def_i2c_bus
], &info
);
1774 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
1779 if (!try_module_get(client
->dev
.driver
->owner
)) {
1780 i2c_unregister_device(client
);
1785 dvb
->i2c_client_demod
= client
;
1788 memset(&si2157_config
, 0, sizeof(si2157_config
));
1789 si2157_config
.fe
= dvb
->fe
[0];
1790 si2157_config
.if_port
= 0;
1791 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
1792 si2157_config
.mdev
= dev
->media_dev
;
1794 memset(&info
, 0, sizeof(struct i2c_board_info
));
1795 strlcpy(info
.type
, "si2146", I2C_NAME_SIZE
);
1797 info
.platform_data
= &si2157_config
;
1798 request_module("si2157");
1799 client
= i2c_new_device(adapter
, &info
);
1800 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
1801 module_put(dvb
->i2c_client_demod
->dev
.driver
->owner
);
1802 i2c_unregister_device(dvb
->i2c_client_demod
);
1807 if (!try_module_get(client
->dev
.driver
->owner
)) {
1808 i2c_unregister_device(client
);
1809 module_put(dvb
->i2c_client_demod
->dev
.driver
->owner
);
1810 i2c_unregister_device(dvb
->i2c_client_demod
);
1815 dvb
->i2c_client_tuner
= client
;
1819 case EM28178_BOARD_PLEX_PX_BCUD
:
1821 struct i2c_client
*client
;
1822 struct i2c_board_info info
;
1823 struct tc90522_config tc90522_config
;
1824 struct qm1d1c0042_config qm1d1c0042_config
;
1827 memset(&tc90522_config
, 0, sizeof(tc90522_config
));
1828 memset(&info
, 0, sizeof(struct i2c_board_info
));
1829 strlcpy(info
.type
, "tc90522sat", I2C_NAME_SIZE
);
1831 info
.platform_data
= &tc90522_config
;
1832 request_module("tc90522");
1833 client
= i2c_new_device(&dev
->i2c_adap
[dev
->def_i2c_bus
], &info
);
1834 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
1838 dvb
->i2c_client_demod
= client
;
1839 if (!try_module_get(client
->dev
.driver
->owner
)) {
1840 i2c_unregister_device(client
);
1846 memset(&qm1d1c0042_config
, 0,
1847 sizeof(qm1d1c0042_config
));
1848 qm1d1c0042_config
.fe
= tc90522_config
.fe
;
1849 qm1d1c0042_config
.lpf
= 1;
1850 memset(&info
, 0, sizeof(struct i2c_board_info
));
1851 strlcpy(info
.type
, "qm1d1c0042", I2C_NAME_SIZE
);
1853 info
.platform_data
= &qm1d1c0042_config
;
1854 request_module(info
.type
);
1855 client
= i2c_new_device(tc90522_config
.tuner_i2c
,
1857 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
1858 module_put(dvb
->i2c_client_demod
->dev
.driver
->owner
);
1859 i2c_unregister_device(dvb
->i2c_client_demod
);
1863 dvb
->i2c_client_tuner
= client
;
1864 if (!try_module_get(client
->dev
.driver
->owner
)) {
1865 i2c_unregister_device(client
);
1866 module_put(dvb
->i2c_client_demod
->dev
.driver
->owner
);
1867 i2c_unregister_device(dvb
->i2c_client_demod
);
1871 dvb
->fe
[0] = tc90522_config
.fe
;
1875 case EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB
:
1877 struct i2c_adapter
*adapter
;
1878 struct i2c_client
*client
;
1879 struct i2c_board_info info
;
1880 struct si2168_config si2168_config
;
1881 struct si2157_config si2157_config
;
1884 memset(&si2168_config
, 0, sizeof(si2168_config
));
1885 si2168_config
.i2c_adapter
= &adapter
;
1886 si2168_config
.fe
= &dvb
->fe
[0];
1887 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
1888 memset(&info
, 0, sizeof(struct i2c_board_info
));
1889 strlcpy(info
.type
, "si2168", I2C_NAME_SIZE
);
1891 info
.platform_data
= &si2168_config
;
1892 request_module(info
.type
);
1893 client
= i2c_new_device(&dev
->i2c_adap
[dev
->def_i2c_bus
], &info
);
1894 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
1899 if (!try_module_get(client
->dev
.driver
->owner
)) {
1900 i2c_unregister_device(client
);
1905 dvb
->i2c_client_demod
= client
;
1908 memset(&si2157_config
, 0, sizeof(si2157_config
));
1909 si2157_config
.fe
= dvb
->fe
[0];
1910 si2157_config
.if_port
= 1;
1911 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
1912 si2157_config
.mdev
= dev
->media_dev
;
1914 memset(&info
, 0, sizeof(struct i2c_board_info
));
1915 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
1917 info
.platform_data
= &si2157_config
;
1918 request_module(info
.type
);
1919 client
= i2c_new_device(adapter
, &info
);
1920 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
1921 module_put(dvb
->i2c_client_demod
->dev
.driver
->owner
);
1922 i2c_unregister_device(dvb
->i2c_client_demod
);
1927 if (!try_module_get(client
->dev
.driver
->owner
)) {
1928 i2c_unregister_device(client
);
1929 module_put(dvb
->i2c_client_demod
->dev
.driver
->owner
);
1930 i2c_unregister_device(dvb
->i2c_client_demod
);
1935 dvb
->i2c_client_tuner
= client
;
1940 em28xx_errdev("/2: The frontend of your DVB/ATSC card"
1941 " isn't supported yet\n");
1944 if (NULL
== dvb
->fe
[0]) {
1945 em28xx_errdev("/2: frontend initialization failed\n");
1949 /* define general-purpose callback pointer */
1950 dvb
->fe
[0]->callback
= em28xx_tuner_callback
;
1952 dvb
->fe
[1]->callback
= em28xx_tuner_callback
;
1954 /* register everything */
1955 result
= em28xx_register_dvb(dvb
, THIS_MODULE
, dev
, &dev
->udev
->dev
);
1960 em28xx_info("DVB extension successfully initialized\n");
1962 kref_get(&dev
->ref
);
1965 em28xx_set_mode(dev
, EM28XX_SUSPEND
);
1966 mutex_unlock(&dev
->lock
);
1975 static inline void prevent_sleep(struct dvb_frontend_ops
*ops
)
1977 ops
->set_voltage
= NULL
;
1979 ops
->tuner_ops
.sleep
= NULL
;
1982 static int em28xx_dvb_fini(struct em28xx
*dev
)
1984 struct em28xx_dvb
*dvb
;
1985 struct i2c_client
*client
;
1987 if (dev
->is_audio_only
) {
1988 /* Shouldn't initialize IR for this interface */
1992 if (!dev
->board
.has_dvb
) {
1993 /* This device does not support the extension */
2000 em28xx_info("Closing DVB extension\n");
2004 em28xx_uninit_usb_xfer(dev
, EM28XX_DIGITAL_MODE
);
2006 if (dev
->disconnected
) {
2007 /* We cannot tell the device to sleep
2008 * once it has been unplugged. */
2010 prevent_sleep(&dvb
->fe
[0]->ops
);
2011 dvb
->fe
[0]->exit
= DVB_FE_DEVICE_REMOVED
;
2014 prevent_sleep(&dvb
->fe
[1]->ops
);
2015 dvb
->fe
[1]->exit
= DVB_FE_DEVICE_REMOVED
;
2019 /* remove I2C SEC */
2020 client
= dvb
->i2c_client_sec
;
2022 module_put(client
->dev
.driver
->owner
);
2023 i2c_unregister_device(client
);
2026 /* remove I2C tuner */
2027 client
= dvb
->i2c_client_tuner
;
2029 module_put(client
->dev
.driver
->owner
);
2030 i2c_unregister_device(client
);
2033 /* remove I2C demod */
2034 client
= dvb
->i2c_client_demod
;
2036 module_put(client
->dev
.driver
->owner
);
2037 i2c_unregister_device(client
);
2040 em28xx_unregister_dvb(dvb
);
2043 kref_put(&dev
->ref
, em28xx_free_device
);
2048 static int em28xx_dvb_suspend(struct em28xx
*dev
)
2052 if (dev
->is_audio_only
)
2055 if (!dev
->board
.has_dvb
)
2058 em28xx_info("Suspending DVB extension\n");
2060 struct em28xx_dvb
*dvb
= dev
->dvb
;
2063 ret
= dvb_frontend_suspend(dvb
->fe
[0]);
2064 em28xx_info("fe0 suspend %d\n", ret
);
2067 dvb_frontend_suspend(dvb
->fe
[1]);
2068 em28xx_info("fe1 suspend %d\n", ret
);
2075 static int em28xx_dvb_resume(struct em28xx
*dev
)
2079 if (dev
->is_audio_only
)
2082 if (!dev
->board
.has_dvb
)
2085 em28xx_info("Resuming DVB extension\n");
2087 struct em28xx_dvb
*dvb
= dev
->dvb
;
2090 ret
= dvb_frontend_resume(dvb
->fe
[0]);
2091 em28xx_info("fe0 resume %d\n", ret
);
2095 ret
= dvb_frontend_resume(dvb
->fe
[1]);
2096 em28xx_info("fe1 resume %d\n", ret
);
2103 static struct em28xx_ops dvb_ops
= {
2105 .name
= "Em28xx dvb Extension",
2106 .init
= em28xx_dvb_init
,
2107 .fini
= em28xx_dvb_fini
,
2108 .suspend
= em28xx_dvb_suspend
,
2109 .resume
= em28xx_dvb_resume
,
2112 static int __init
em28xx_dvb_register(void)
2114 return em28xx_register_extension(&dvb_ops
);
2117 static void __exit
em28xx_dvb_unregister(void)
2119 em28xx_unregister_extension(&dvb_ops
);
2122 module_init(em28xx_dvb_register
);
2123 module_exit(em28xx_dvb_unregister
);