2 DVB device driver for cx231xx
4 Copyright (C) 2008 <srinivasa.deevi at conexant dot com>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <linux/kernel.h>
24 #include <linux/slab.h>
26 #include <media/v4l2-common.h>
27 #include <media/videobuf-vmalloc.h>
28 #include <media/tuner.h>
38 #include "lgdt3306a.h"
40 MODULE_DESCRIPTION("driver for cx231xx based DVB cards");
41 MODULE_AUTHOR("Srinivasa Deevi <srinivasa.deevi@conexant.com>");
42 MODULE_LICENSE("GPL");
44 static unsigned int debug
;
45 module_param(debug
, int, 0644);
46 MODULE_PARM_DESC(debug
, "enable debug messages [dvb]");
48 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
50 #define CX231XX_DVB_NUM_BUFS 5
51 #define CX231XX_DVB_MAX_PACKETSIZE 564
52 #define CX231XX_DVB_MAX_PACKETS 64
55 struct dvb_frontend
*frontend
;
57 /* feed count management */
61 /* general boilerplate stuff */
62 struct dvb_adapter adapter
;
63 struct dvb_demux demux
;
65 struct dmx_frontend fe_hw
;
66 struct dmx_frontend fe_mem
;
68 struct i2c_client
*i2c_client_demod
;
69 struct i2c_client
*i2c_client_tuner
;
72 static struct s5h1432_config dvico_s5h1432_config
= {
73 .output_mode
= S5H1432_SERIAL_OUTPUT
,
74 .gpio
= S5H1432_GPIO_ON
,
75 .qam_if
= S5H1432_IF_4000
,
76 .vsb_if
= S5H1432_IF_4000
,
77 .inversion
= S5H1432_INVERSION_OFF
,
78 .status_mode
= S5H1432_DEMODLOCKING
,
79 .mpeg_timing
= S5H1432_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
82 static struct tda18271_std_map cnxt_rde253s_tda18271_std_map
= {
83 .dvbt_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 4,
84 .if_lvl
= 1, .rfagc_top
= 0x37, },
85 .dvbt_7
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
86 .if_lvl
= 1, .rfagc_top
= 0x37, },
87 .dvbt_8
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 6,
88 .if_lvl
= 1, .rfagc_top
= 0x37, },
91 static struct tda18271_std_map mb86a20s_tda18271_config
= {
92 .dvbt_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 4,
93 .if_lvl
= 0, .rfagc_top
= 0x37, },
96 static struct tda18271_config cnxt_rde253s_tunerconfig
= {
97 .std_map
= &cnxt_rde253s_tda18271_std_map
,
98 .gate
= TDA18271_GATE_ANALOG
,
101 static struct s5h1411_config tda18271_s5h1411_config
= {
102 .output_mode
= S5H1411_SERIAL_OUTPUT
,
103 .gpio
= S5H1411_GPIO_OFF
,
104 .vsb_if
= S5H1411_IF_3250
,
105 .qam_if
= S5H1411_IF_4000
,
106 .inversion
= S5H1411_INVERSION_ON
,
107 .status_mode
= S5H1411_DEMODLOCKING
,
108 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
110 static struct s5h1411_config xc5000_s5h1411_config
= {
111 .output_mode
= S5H1411_SERIAL_OUTPUT
,
112 .gpio
= S5H1411_GPIO_OFF
,
113 .vsb_if
= S5H1411_IF_3250
,
114 .qam_if
= S5H1411_IF_3250
,
115 .inversion
= S5H1411_INVERSION_OFF
,
116 .status_mode
= S5H1411_DEMODLOCKING
,
117 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
120 static struct lgdt3305_config hcw_lgdt3305_config
= {
122 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
123 .tpclk_edge
= LGDT3305_TPCLK_FALLING_EDGE
,
124 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
126 .spectral_inversion
= 1,
131 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
132 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
133 .if_lvl
= 1, .rfagc_top
= 0x58, },
134 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
135 .if_lvl
= 1, .rfagc_top
= 0x58, },
138 static struct tda18271_config hcw_tda18271_config
= {
139 .std_map
= &hauppauge_tda18271_std_map
,
140 .gate
= TDA18271_GATE_DIGITAL
,
143 static const struct mb86a20s_config pv_mb86a20s_config
= {
144 .demod_address
= 0x10,
148 static struct tda18271_config pv_tda18271_config
= {
149 .std_map
= &mb86a20s_tda18271_config
,
150 .gate
= TDA18271_GATE_DIGITAL
,
151 .small_i2c
= TDA18271_03_BYTE_CHUNK_INIT
,
154 static struct lgdt3306a_config hauppauge_955q_lgdt3306a_config
= {
159 .spectral_inversion
= 1,
160 .mpeg_mode
= LGDT3306A_MPEG_SERIAL
,
161 .tpclk_edge
= LGDT3306A_TPCLK_RISING_EDGE
,
162 .tpvalid_polarity
= LGDT3306A_TP_VALID_HIGH
,
166 static inline void print_err_status(struct cx231xx
*dev
, int packet
, int status
)
168 char *errmsg
= "Unknown";
172 errmsg
= "unlinked synchronuously";
175 errmsg
= "unlinked asynchronuously";
178 errmsg
= "Buffer error (overrun)";
181 errmsg
= "Stalled (device not responding)";
184 errmsg
= "Babble (bad cable?)";
187 errmsg
= "Bit-stuff error (bad cable?)";
190 errmsg
= "CRC/Timeout (could be anything)";
193 errmsg
= "Device does not respond";
198 "URB status %d [%s].\n", status
, errmsg
);
201 "URB packet %d, status %d [%s].\n",
202 packet
, status
, errmsg
);
206 static inline int dvb_isoc_copy(struct cx231xx
*dev
, struct urb
*urb
)
213 if (dev
->state
& DEV_DISCONNECTED
)
216 if (urb
->status
< 0) {
217 print_err_status(dev
, -1, urb
->status
);
218 if (urb
->status
== -ENOENT
)
222 for (i
= 0; i
< urb
->number_of_packets
; i
++) {
223 int status
= urb
->iso_frame_desc
[i
].status
;
226 print_err_status(dev
, i
, status
);
227 if (urb
->iso_frame_desc
[i
].status
!= -EPROTO
)
231 dvb_dmx_swfilter(&dev
->dvb
->demux
,
232 urb
->transfer_buffer
+
233 urb
->iso_frame_desc
[i
].offset
,
234 urb
->iso_frame_desc
[i
].actual_length
);
240 static inline int dvb_bulk_copy(struct cx231xx
*dev
, struct urb
*urb
)
245 if (dev
->state
& DEV_DISCONNECTED
)
248 if (urb
->status
< 0) {
249 print_err_status(dev
, -1, urb
->status
);
250 if (urb
->status
== -ENOENT
)
254 /* Feed the transport payload into the kernel demux */
255 dvb_dmx_swfilter(&dev
->dvb
->demux
,
256 urb
->transfer_buffer
, urb
->actual_length
);
261 static int start_streaming(struct cx231xx_dvb
*dvb
)
264 struct cx231xx
*dev
= dvb
->adapter
.priv
;
267 dev_dbg(dev
->dev
, "DVB transfer mode is ISO.\n");
268 cx231xx_set_alt_setting(dev
, INDEX_TS1
, 4);
269 rc
= cx231xx_set_mode(dev
, CX231XX_DIGITAL_MODE
);
273 return cx231xx_init_isoc(dev
, CX231XX_DVB_MAX_PACKETS
,
274 CX231XX_DVB_NUM_BUFS
,
275 dev
->ts1_mode
.max_pkt_size
,
278 dev_dbg(dev
->dev
, "DVB transfer mode is BULK.\n");
279 cx231xx_set_alt_setting(dev
, INDEX_TS1
, 0);
280 rc
= cx231xx_set_mode(dev
, CX231XX_DIGITAL_MODE
);
284 return cx231xx_init_bulk(dev
, CX231XX_DVB_MAX_PACKETS
,
285 CX231XX_DVB_NUM_BUFS
,
286 dev
->ts1_mode
.max_pkt_size
,
292 static int stop_streaming(struct cx231xx_dvb
*dvb
)
294 struct cx231xx
*dev
= dvb
->adapter
.priv
;
297 cx231xx_uninit_isoc(dev
);
299 cx231xx_uninit_bulk(dev
);
301 cx231xx_set_mode(dev
, CX231XX_SUSPEND
);
306 static int start_feed(struct dvb_demux_feed
*feed
)
308 struct dvb_demux
*demux
= feed
->demux
;
309 struct cx231xx_dvb
*dvb
= demux
->priv
;
312 if (!demux
->dmx
.frontend
)
315 mutex_lock(&dvb
->lock
);
319 if (dvb
->nfeeds
== 1) {
320 ret
= start_streaming(dvb
);
325 mutex_unlock(&dvb
->lock
);
329 static int stop_feed(struct dvb_demux_feed
*feed
)
331 struct dvb_demux
*demux
= feed
->demux
;
332 struct cx231xx_dvb
*dvb
= demux
->priv
;
335 mutex_lock(&dvb
->lock
);
338 if (0 == dvb
->nfeeds
)
339 err
= stop_streaming(dvb
);
341 mutex_unlock(&dvb
->lock
);
345 /* ------------------------------------------------------------------ */
346 static int cx231xx_dvb_bus_ctrl(struct dvb_frontend
*fe
, int acquire
)
348 struct cx231xx
*dev
= fe
->dvb
->priv
;
351 return cx231xx_set_mode(dev
, CX231XX_DIGITAL_MODE
);
353 return cx231xx_set_mode(dev
, CX231XX_SUSPEND
);
356 /* ------------------------------------------------------------------ */
358 static struct xc5000_config cnxt_rde250_tunerconfig
= {
362 static struct xc5000_config cnxt_rdu250_tunerconfig
= {
367 /* ------------------------------------------------------------------ */
369 static int attach_xc5000(u8 addr
, struct cx231xx
*dev
)
372 struct dvb_frontend
*fe
;
373 struct xc5000_config cfg
;
375 memset(&cfg
, 0, sizeof(cfg
));
376 cfg
.i2c_adap
= cx231xx_get_i2c_adap(dev
, dev
->board
.tuner_i2c_master
);
379 if (!dev
->dvb
->frontend
) {
380 dev_err(dev
->dev
, "%s/2: dvb frontend not attached. Can't attach xc5000\n",
385 fe
= dvb_attach(xc5000_attach
, dev
->dvb
->frontend
, &cfg
);
387 dev_err(dev
->dev
, "%s/2: xc5000 attach failed\n", dev
->name
);
388 dvb_frontend_detach(dev
->dvb
->frontend
);
389 dev
->dvb
->frontend
= NULL
;
393 dev_info(dev
->dev
, "%s/2: xc5000 attached\n", dev
->name
);
399 int cx231xx_set_analog_freq(struct cx231xx
*dev
, u32 freq
)
401 if ((dev
->dvb
!= NULL
) && (dev
->dvb
->frontend
!= NULL
)) {
403 struct dvb_tuner_ops
*dops
= &dev
->dvb
->frontend
->ops
.tuner_ops
;
405 if (dops
->set_analog_params
!= NULL
) {
406 struct analog_parameters params
;
408 params
.frequency
= freq
;
409 params
.std
= dev
->norm
;
410 params
.mode
= 0; /* 0- Air; 1 - cable */
411 /*params.audmode = ; */
413 /* Set the analog parameters to set the frequency */
414 dops
->set_analog_params(dev
->dvb
->frontend
, ¶ms
);
422 int cx231xx_reset_analog_tuner(struct cx231xx
*dev
)
426 if ((dev
->dvb
!= NULL
) && (dev
->dvb
->frontend
!= NULL
)) {
428 struct dvb_tuner_ops
*dops
= &dev
->dvb
->frontend
->ops
.tuner_ops
;
430 if (dops
->init
!= NULL
&& !dev
->xc_fw_load_done
) {
433 "Reloading firmware for XC5000\n");
434 status
= dops
->init(dev
->dvb
->frontend
);
436 dev
->xc_fw_load_done
= 1;
438 "XC5000 firmware download completed\n");
440 dev
->xc_fw_load_done
= 0;
442 "XC5000 firmware download failed !!!\n");
451 /* ------------------------------------------------------------------ */
453 static int register_dvb(struct cx231xx_dvb
*dvb
,
454 struct module
*module
,
455 struct cx231xx
*dev
, struct device
*device
)
459 mutex_init(&dvb
->lock
);
462 /* register adapter */
463 result
= dvb_register_adapter(&dvb
->adapter
, dev
->name
, module
, device
,
467 "%s: dvb_register_adapter failed (errno = %d)\n",
471 dvb_register_media_controller(&dvb
->adapter
, dev
->media_dev
);
473 /* Ensure all frontends negotiate bus access */
474 dvb
->frontend
->ops
.ts_bus_ctrl
= cx231xx_dvb_bus_ctrl
;
476 dvb
->adapter
.priv
= dev
;
478 /* register frontend */
479 result
= dvb_register_frontend(&dvb
->adapter
, dvb
->frontend
);
482 "%s: dvb_register_frontend failed (errno = %d)\n",
487 /* register demux stuff */
488 dvb
->demux
.dmx
.capabilities
=
489 DMX_TS_FILTERING
| DMX_SECTION_FILTERING
|
490 DMX_MEMORY_BASED_FILTERING
;
491 dvb
->demux
.priv
= dvb
;
492 dvb
->demux
.filternum
= 256;
493 dvb
->demux
.feednum
= 256;
494 dvb
->demux
.start_feed
= start_feed
;
495 dvb
->demux
.stop_feed
= stop_feed
;
497 result
= dvb_dmx_init(&dvb
->demux
);
500 "%s: dvb_dmx_init failed (errno = %d)\n",
505 dvb
->dmxdev
.filternum
= 256;
506 dvb
->dmxdev
.demux
= &dvb
->demux
.dmx
;
507 dvb
->dmxdev
.capabilities
= 0;
508 result
= dvb_dmxdev_init(&dvb
->dmxdev
, &dvb
->adapter
);
511 "%s: dvb_dmxdev_init failed (errno = %d)\n",
516 dvb
->fe_hw
.source
= DMX_FRONTEND_0
;
517 result
= dvb
->demux
.dmx
.add_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
520 "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n",
525 dvb
->fe_mem
.source
= DMX_MEMORY_FE
;
526 result
= dvb
->demux
.dmx
.add_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
529 "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n",
534 result
= dvb
->demux
.dmx
.connect_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
537 "%s: connect_frontend failed (errno = %d)\n",
542 /* register network adapter */
543 dvb_net_init(&dvb
->adapter
, &dvb
->net
, &dvb
->demux
.dmx
);
544 result
= dvb_create_media_graph(&dvb
->adapter
,
545 dev
->tuner_type
== TUNER_ABSENT
);
547 goto fail_create_graph
;
552 dvb_net_release(&dvb
->net
);
554 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
556 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
558 dvb_dmxdev_release(&dvb
->dmxdev
);
560 dvb_dmx_release(&dvb
->demux
);
562 dvb_unregister_frontend(dvb
->frontend
);
564 dvb_frontend_detach(dvb
->frontend
);
565 dvb_unregister_adapter(&dvb
->adapter
);
570 static void unregister_dvb(struct cx231xx_dvb
*dvb
)
572 struct i2c_client
*client
;
573 dvb_net_release(&dvb
->net
);
574 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
575 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
576 dvb_dmxdev_release(&dvb
->dmxdev
);
577 dvb_dmx_release(&dvb
->demux
);
578 /* remove I2C tuner */
579 client
= dvb
->i2c_client_tuner
;
581 module_put(client
->dev
.driver
->owner
);
582 i2c_unregister_device(client
);
584 /* remove I2C demod */
585 client
= dvb
->i2c_client_demod
;
587 module_put(client
->dev
.driver
->owner
);
588 i2c_unregister_device(client
);
590 dvb_unregister_frontend(dvb
->frontend
);
591 dvb_frontend_detach(dvb
->frontend
);
592 dvb_unregister_adapter(&dvb
->adapter
);
595 static int dvb_init(struct cx231xx
*dev
)
598 struct cx231xx_dvb
*dvb
;
599 struct i2c_adapter
*tuner_i2c
;
600 struct i2c_adapter
*demod_i2c
;
602 if (!dev
->board
.has_dvb
) {
603 /* This device does not support the extension */
607 dvb
= kzalloc(sizeof(struct cx231xx_dvb
), GFP_KERNEL
);
611 "cx231xx_dvb: memory allocation failed\n");
615 dev
->cx231xx_set_analog_freq
= cx231xx_set_analog_freq
;
616 dev
->cx231xx_reset_analog_tuner
= cx231xx_reset_analog_tuner
;
618 tuner_i2c
= cx231xx_get_i2c_adap(dev
, dev
->board
.tuner_i2c_master
);
619 demod_i2c
= cx231xx_get_i2c_adap(dev
, dev
->board
.demod_i2c_master
);
620 mutex_lock(&dev
->lock
);
621 cx231xx_set_mode(dev
, CX231XX_DIGITAL_MODE
);
622 cx231xx_demod_reset(dev
);
624 switch (dev
->model
) {
625 case CX231XX_BOARD_CNXT_CARRAERA
:
626 case CX231XX_BOARD_CNXT_RDE_250
:
628 dev
->dvb
->frontend
= dvb_attach(s5h1432_attach
,
629 &dvico_s5h1432_config
,
632 if (dev
->dvb
->frontend
== NULL
) {
634 "Failed to attach s5h1432 front end\n");
639 /* define general-purpose callback pointer */
640 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
642 if (!dvb_attach(xc5000_attach
, dev
->dvb
->frontend
,
644 &cnxt_rde250_tunerconfig
)) {
650 case CX231XX_BOARD_CNXT_SHELBY
:
651 case CX231XX_BOARD_CNXT_RDU_250
:
653 dev
->dvb
->frontend
= dvb_attach(s5h1411_attach
,
654 &xc5000_s5h1411_config
,
657 if (dev
->dvb
->frontend
== NULL
) {
659 "Failed to attach s5h1411 front end\n");
664 /* define general-purpose callback pointer */
665 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
667 if (!dvb_attach(xc5000_attach
, dev
->dvb
->frontend
,
669 &cnxt_rdu250_tunerconfig
)) {
674 case CX231XX_BOARD_CNXT_RDE_253S
:
676 dev
->dvb
->frontend
= dvb_attach(s5h1432_attach
,
677 &dvico_s5h1432_config
,
680 if (dev
->dvb
->frontend
== NULL
) {
682 "Failed to attach s5h1432 front end\n");
687 /* define general-purpose callback pointer */
688 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
690 if (!dvb_attach(tda18271_attach
, dev
->dvb
->frontend
,
692 &cnxt_rde253s_tunerconfig
)) {
697 case CX231XX_BOARD_CNXT_RDU_253S
:
698 case CX231XX_BOARD_KWORLD_UB445_USB_HYBRID
:
700 dev
->dvb
->frontend
= dvb_attach(s5h1411_attach
,
701 &tda18271_s5h1411_config
,
704 if (dev
->dvb
->frontend
== NULL
) {
706 "Failed to attach s5h1411 front end\n");
711 /* define general-purpose callback pointer */
712 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
714 if (!dvb_attach(tda18271_attach
, dev
->dvb
->frontend
,
716 &cnxt_rde253s_tunerconfig
)) {
721 case CX231XX_BOARD_HAUPPAUGE_EXETER
:
724 "%s: looking for tuner / demod on i2c bus: %d\n",
725 __func__
, i2c_adapter_id(tuner_i2c
));
727 dev
->dvb
->frontend
= dvb_attach(lgdt3305_attach
,
728 &hcw_lgdt3305_config
,
731 if (dev
->dvb
->frontend
== NULL
) {
733 "Failed to attach LG3305 front end\n");
738 /* define general-purpose callback pointer */
739 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
741 dvb_attach(tda18271_attach
, dev
->dvb
->frontend
,
743 &hcw_tda18271_config
);
746 case CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx
:
748 struct i2c_client
*client
;
749 struct i2c_board_info info
;
750 struct si2165_platform_data si2165_pdata
;
753 memset(&si2165_pdata
, 0, sizeof(si2165_pdata
));
754 si2165_pdata
.fe
= &dev
->dvb
->frontend
;
755 si2165_pdata
.chip_mode
= SI2165_MODE_PLL_XTAL
,
756 si2165_pdata
.ref_freq_Hz
= 16000000,
758 memset(&info
, 0, sizeof(struct i2c_board_info
));
759 strlcpy(info
.type
, "si2165", I2C_NAME_SIZE
);
761 info
.platform_data
= &si2165_pdata
;
762 request_module(info
.type
);
763 client
= i2c_new_device(demod_i2c
, &info
);
764 if (client
== NULL
|| client
->dev
.driver
== NULL
|| dev
->dvb
->frontend
== NULL
) {
766 "Failed to attach SI2165 front end\n");
771 if (!try_module_get(client
->dev
.driver
->owner
)) {
772 i2c_unregister_device(client
);
777 dvb
->i2c_client_demod
= client
;
779 dev
->dvb
->frontend
->ops
.i2c_gate_ctrl
= NULL
;
781 /* define general-purpose callback pointer */
782 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
784 dvb_attach(tda18271_attach
, dev
->dvb
->frontend
,
787 &hcw_tda18271_config
);
789 dev
->cx231xx_reset_analog_tuner
= NULL
;
792 case CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx
:
794 struct i2c_client
*client
;
795 struct i2c_board_info info
;
796 struct si2165_platform_data si2165_pdata
;
797 struct si2157_config si2157_config
;
800 memset(&si2165_pdata
, 0, sizeof(si2165_pdata
));
801 si2165_pdata
.fe
= &dev
->dvb
->frontend
;
802 si2165_pdata
.chip_mode
= SI2165_MODE_PLL_EXT
,
803 si2165_pdata
.ref_freq_Hz
= 24000000,
805 memset(&info
, 0, sizeof(struct i2c_board_info
));
806 strlcpy(info
.type
, "si2165", I2C_NAME_SIZE
);
808 info
.platform_data
= &si2165_pdata
;
809 request_module(info
.type
);
810 client
= i2c_new_device(demod_i2c
, &info
);
811 if (client
== NULL
|| client
->dev
.driver
== NULL
|| dev
->dvb
->frontend
== NULL
) {
813 "Failed to attach SI2165 front end\n");
818 if (!try_module_get(client
->dev
.driver
->owner
)) {
819 i2c_unregister_device(client
);
824 dvb
->i2c_client_demod
= client
;
826 memset(&info
, 0, sizeof(struct i2c_board_info
));
828 dev
->dvb
->frontend
->ops
.i2c_gate_ctrl
= NULL
;
830 /* define general-purpose callback pointer */
831 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
834 memset(&si2157_config
, 0, sizeof(si2157_config
));
835 si2157_config
.fe
= dev
->dvb
->frontend
;
836 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
837 si2157_config
.mdev
= dev
->media_dev
;
839 si2157_config
.if_port
= 1;
840 si2157_config
.inversion
= true;
841 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
843 info
.platform_data
= &si2157_config
;
844 request_module("si2157");
846 client
= i2c_new_device(
849 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
850 dvb_frontend_detach(dev
->dvb
->frontend
);
855 if (!try_module_get(client
->dev
.driver
->owner
)) {
856 i2c_unregister_device(client
);
857 dvb_frontend_detach(dev
->dvb
->frontend
);
862 dev
->cx231xx_reset_analog_tuner
= NULL
;
864 dev
->dvb
->i2c_client_tuner
= client
;
867 case CX231XX_BOARD_HAUPPAUGE_955Q
:
869 struct i2c_client
*client
;
870 struct i2c_board_info info
;
871 struct si2157_config si2157_config
;
873 memset(&info
, 0, sizeof(struct i2c_board_info
));
875 dev
->dvb
->frontend
= dvb_attach(lgdt3306a_attach
,
876 &hauppauge_955q_lgdt3306a_config
,
880 if (dev
->dvb
->frontend
== NULL
) {
882 "Failed to attach LGDT3306A frontend.\n");
887 dev
->dvb
->frontend
->ops
.i2c_gate_ctrl
= NULL
;
889 /* define general-purpose callback pointer */
890 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
893 memset(&si2157_config
, 0, sizeof(si2157_config
));
894 si2157_config
.fe
= dev
->dvb
->frontend
;
895 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
896 si2157_config
.mdev
= dev
->media_dev
;
898 si2157_config
.if_port
= 1;
899 si2157_config
.inversion
= true;
900 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
902 info
.platform_data
= &si2157_config
;
903 request_module("si2157");
905 client
= i2c_new_device(
908 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
909 dvb_frontend_detach(dev
->dvb
->frontend
);
914 if (!try_module_get(client
->dev
.driver
->owner
)) {
915 i2c_unregister_device(client
);
916 dvb_frontend_detach(dev
->dvb
->frontend
);
921 dev
->cx231xx_reset_analog_tuner
= NULL
;
923 dev
->dvb
->i2c_client_tuner
= client
;
926 case CX231XX_BOARD_PV_PLAYTV_USB_HYBRID
:
927 case CX231XX_BOARD_KWORLD_UB430_USB_HYBRID
:
930 "%s: looking for demod on i2c bus: %d\n",
931 __func__
, i2c_adapter_id(tuner_i2c
));
933 dev
->dvb
->frontend
= dvb_attach(mb86a20s_attach
,
937 if (dev
->dvb
->frontend
== NULL
) {
939 "Failed to attach mb86a20s demod\n");
944 /* define general-purpose callback pointer */
945 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
947 dvb_attach(tda18271_attach
, dev
->dvb
->frontend
,
949 &pv_tda18271_config
);
954 "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
958 if (NULL
== dvb
->frontend
) {
960 "%s/2: frontend initialization failed\n", dev
->name
);
965 /* register everything */
966 result
= register_dvb(dvb
, THIS_MODULE
, dev
, dev
->dev
);
972 dev_info(dev
->dev
, "Successfully loaded cx231xx-dvb\n");
975 cx231xx_set_mode(dev
, CX231XX_SUSPEND
);
976 mutex_unlock(&dev
->lock
);
985 static int dvb_fini(struct cx231xx
*dev
)
987 if (!dev
->board
.has_dvb
) {
988 /* This device does not support the extension */
993 unregister_dvb(dev
->dvb
);
1000 static struct cx231xx_ops dvb_ops
= {
1002 .name
= "Cx231xx dvb Extension",
1007 static int __init
cx231xx_dvb_register(void)
1009 return cx231xx_register_extension(&dvb_ops
);
1012 static void __exit
cx231xx_dvb_unregister(void)
1014 cx231xx_unregister_extension(&dvb_ops
);
1017 module_init(cx231xx_dvb_register
);
1018 module_exit(cx231xx_dvb_unregister
);