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_tuner
;
71 static struct s5h1432_config dvico_s5h1432_config
= {
72 .output_mode
= S5H1432_SERIAL_OUTPUT
,
73 .gpio
= S5H1432_GPIO_ON
,
74 .qam_if
= S5H1432_IF_4000
,
75 .vsb_if
= S5H1432_IF_4000
,
76 .inversion
= S5H1432_INVERSION_OFF
,
77 .status_mode
= S5H1432_DEMODLOCKING
,
78 .mpeg_timing
= S5H1432_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
81 static struct tda18271_std_map cnxt_rde253s_tda18271_std_map
= {
82 .dvbt_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 4,
83 .if_lvl
= 1, .rfagc_top
= 0x37, },
84 .dvbt_7
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
85 .if_lvl
= 1, .rfagc_top
= 0x37, },
86 .dvbt_8
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 6,
87 .if_lvl
= 1, .rfagc_top
= 0x37, },
90 static struct tda18271_std_map mb86a20s_tda18271_config
= {
91 .dvbt_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 4,
92 .if_lvl
= 0, .rfagc_top
= 0x37, },
95 static struct tda18271_config cnxt_rde253s_tunerconfig
= {
96 .std_map
= &cnxt_rde253s_tda18271_std_map
,
97 .gate
= TDA18271_GATE_ANALOG
,
100 static struct s5h1411_config tda18271_s5h1411_config
= {
101 .output_mode
= S5H1411_SERIAL_OUTPUT
,
102 .gpio
= S5H1411_GPIO_OFF
,
103 .vsb_if
= S5H1411_IF_3250
,
104 .qam_if
= S5H1411_IF_4000
,
105 .inversion
= S5H1411_INVERSION_ON
,
106 .status_mode
= S5H1411_DEMODLOCKING
,
107 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
109 static struct s5h1411_config xc5000_s5h1411_config
= {
110 .output_mode
= S5H1411_SERIAL_OUTPUT
,
111 .gpio
= S5H1411_GPIO_OFF
,
112 .vsb_if
= S5H1411_IF_3250
,
113 .qam_if
= S5H1411_IF_3250
,
114 .inversion
= S5H1411_INVERSION_OFF
,
115 .status_mode
= S5H1411_DEMODLOCKING
,
116 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
119 static struct lgdt3305_config hcw_lgdt3305_config
= {
121 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
122 .tpclk_edge
= LGDT3305_TPCLK_FALLING_EDGE
,
123 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
125 .spectral_inversion
= 1,
130 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
131 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
132 .if_lvl
= 1, .rfagc_top
= 0x58, },
133 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
134 .if_lvl
= 1, .rfagc_top
= 0x58, },
137 static struct tda18271_config hcw_tda18271_config
= {
138 .std_map
= &hauppauge_tda18271_std_map
,
139 .gate
= TDA18271_GATE_DIGITAL
,
142 static const struct mb86a20s_config pv_mb86a20s_config
= {
143 .demod_address
= 0x10,
147 static struct tda18271_config pv_tda18271_config
= {
148 .std_map
= &mb86a20s_tda18271_config
,
149 .gate
= TDA18271_GATE_DIGITAL
,
150 .small_i2c
= TDA18271_03_BYTE_CHUNK_INIT
,
153 static const struct si2165_config hauppauge_930C_HD_1113xx_si2165_config
= {
155 .chip_mode
= SI2165_MODE_PLL_XTAL
,
156 .ref_freq_Hz
= 16000000,
159 static const struct si2165_config pctv_quatro_stick_1114xx_si2165_config
= {
161 .chip_mode
= SI2165_MODE_PLL_EXT
,
162 .ref_freq_Hz
= 24000000,
165 static struct lgdt3306a_config hauppauge_955q_lgdt3306a_config
= {
170 .spectral_inversion
= 1,
171 .mpeg_mode
= LGDT3306A_MPEG_SERIAL
,
172 .tpclk_edge
= LGDT3306A_TPCLK_RISING_EDGE
,
173 .tpvalid_polarity
= LGDT3306A_TP_VALID_HIGH
,
177 static inline void print_err_status(struct cx231xx
*dev
, int packet
, int status
)
179 char *errmsg
= "Unknown";
183 errmsg
= "unlinked synchronuously";
186 errmsg
= "unlinked asynchronuously";
189 errmsg
= "Buffer error (overrun)";
192 errmsg
= "Stalled (device not responding)";
195 errmsg
= "Babble (bad cable?)";
198 errmsg
= "Bit-stuff error (bad cable?)";
201 errmsg
= "CRC/Timeout (could be anything)";
204 errmsg
= "Device does not respond";
209 "URB status %d [%s].\n", status
, errmsg
);
212 "URB packet %d, status %d [%s].\n",
213 packet
, status
, errmsg
);
217 static inline int dvb_isoc_copy(struct cx231xx
*dev
, struct urb
*urb
)
224 if (dev
->state
& DEV_DISCONNECTED
)
227 if (urb
->status
< 0) {
228 print_err_status(dev
, -1, urb
->status
);
229 if (urb
->status
== -ENOENT
)
233 for (i
= 0; i
< urb
->number_of_packets
; i
++) {
234 int status
= urb
->iso_frame_desc
[i
].status
;
237 print_err_status(dev
, i
, status
);
238 if (urb
->iso_frame_desc
[i
].status
!= -EPROTO
)
242 dvb_dmx_swfilter(&dev
->dvb
->demux
,
243 urb
->transfer_buffer
+
244 urb
->iso_frame_desc
[i
].offset
,
245 urb
->iso_frame_desc
[i
].actual_length
);
251 static inline int dvb_bulk_copy(struct cx231xx
*dev
, struct urb
*urb
)
256 if (dev
->state
& DEV_DISCONNECTED
)
259 if (urb
->status
< 0) {
260 print_err_status(dev
, -1, urb
->status
);
261 if (urb
->status
== -ENOENT
)
265 /* Feed the transport payload into the kernel demux */
266 dvb_dmx_swfilter(&dev
->dvb
->demux
,
267 urb
->transfer_buffer
, urb
->actual_length
);
272 static int start_streaming(struct cx231xx_dvb
*dvb
)
275 struct cx231xx
*dev
= dvb
->adapter
.priv
;
278 dev_dbg(dev
->dev
, "DVB transfer mode is ISO.\n");
279 cx231xx_set_alt_setting(dev
, INDEX_TS1
, 4);
280 rc
= cx231xx_set_mode(dev
, CX231XX_DIGITAL_MODE
);
284 return cx231xx_init_isoc(dev
, CX231XX_DVB_MAX_PACKETS
,
285 CX231XX_DVB_NUM_BUFS
,
286 dev
->ts1_mode
.max_pkt_size
,
289 dev_dbg(dev
->dev
, "DVB transfer mode is BULK.\n");
290 cx231xx_set_alt_setting(dev
, INDEX_TS1
, 0);
291 rc
= cx231xx_set_mode(dev
, CX231XX_DIGITAL_MODE
);
295 return cx231xx_init_bulk(dev
, CX231XX_DVB_MAX_PACKETS
,
296 CX231XX_DVB_NUM_BUFS
,
297 dev
->ts1_mode
.max_pkt_size
,
303 static int stop_streaming(struct cx231xx_dvb
*dvb
)
305 struct cx231xx
*dev
= dvb
->adapter
.priv
;
308 cx231xx_uninit_isoc(dev
);
310 cx231xx_uninit_bulk(dev
);
312 cx231xx_set_mode(dev
, CX231XX_SUSPEND
);
317 static int start_feed(struct dvb_demux_feed
*feed
)
319 struct dvb_demux
*demux
= feed
->demux
;
320 struct cx231xx_dvb
*dvb
= demux
->priv
;
323 if (!demux
->dmx
.frontend
)
326 mutex_lock(&dvb
->lock
);
330 if (dvb
->nfeeds
== 1) {
331 ret
= start_streaming(dvb
);
336 mutex_unlock(&dvb
->lock
);
340 static int stop_feed(struct dvb_demux_feed
*feed
)
342 struct dvb_demux
*demux
= feed
->demux
;
343 struct cx231xx_dvb
*dvb
= demux
->priv
;
346 mutex_lock(&dvb
->lock
);
349 if (0 == dvb
->nfeeds
)
350 err
= stop_streaming(dvb
);
352 mutex_unlock(&dvb
->lock
);
356 /* ------------------------------------------------------------------ */
357 static int cx231xx_dvb_bus_ctrl(struct dvb_frontend
*fe
, int acquire
)
359 struct cx231xx
*dev
= fe
->dvb
->priv
;
362 return cx231xx_set_mode(dev
, CX231XX_DIGITAL_MODE
);
364 return cx231xx_set_mode(dev
, CX231XX_SUSPEND
);
367 /* ------------------------------------------------------------------ */
369 static struct xc5000_config cnxt_rde250_tunerconfig
= {
373 static struct xc5000_config cnxt_rdu250_tunerconfig
= {
378 /* ------------------------------------------------------------------ */
380 static int attach_xc5000(u8 addr
, struct cx231xx
*dev
)
383 struct dvb_frontend
*fe
;
384 struct xc5000_config cfg
;
386 memset(&cfg
, 0, sizeof(cfg
));
387 cfg
.i2c_adap
= cx231xx_get_i2c_adap(dev
, dev
->board
.tuner_i2c_master
);
390 if (!dev
->dvb
->frontend
) {
391 dev_err(dev
->dev
, "%s/2: dvb frontend not attached. "
392 "Can't attach xc5000\n", dev
->name
);
396 fe
= dvb_attach(xc5000_attach
, dev
->dvb
->frontend
, &cfg
);
398 dev_err(dev
->dev
, "%s/2: xc5000 attach failed\n", dev
->name
);
399 dvb_frontend_detach(dev
->dvb
->frontend
);
400 dev
->dvb
->frontend
= NULL
;
404 dev_info(dev
->dev
, "%s/2: xc5000 attached\n", dev
->name
);
410 int cx231xx_set_analog_freq(struct cx231xx
*dev
, u32 freq
)
412 if ((dev
->dvb
!= NULL
) && (dev
->dvb
->frontend
!= NULL
)) {
414 struct dvb_tuner_ops
*dops
= &dev
->dvb
->frontend
->ops
.tuner_ops
;
416 if (dops
->set_analog_params
!= NULL
) {
417 struct analog_parameters params
;
419 params
.frequency
= freq
;
420 params
.std
= dev
->norm
;
421 params
.mode
= 0; /* 0- Air; 1 - cable */
422 /*params.audmode = ; */
424 /* Set the analog parameters to set the frequency */
425 dops
->set_analog_params(dev
->dvb
->frontend
, ¶ms
);
433 int cx231xx_reset_analog_tuner(struct cx231xx
*dev
)
437 if ((dev
->dvb
!= NULL
) && (dev
->dvb
->frontend
!= NULL
)) {
439 struct dvb_tuner_ops
*dops
= &dev
->dvb
->frontend
->ops
.tuner_ops
;
441 if (dops
->init
!= NULL
&& !dev
->xc_fw_load_done
) {
444 "Reloading firmware for XC5000\n");
445 status
= dops
->init(dev
->dvb
->frontend
);
447 dev
->xc_fw_load_done
= 1;
449 "XC5000 firmware download completed\n");
451 dev
->xc_fw_load_done
= 0;
453 "XC5000 firmware download failed !!!\n");
462 /* ------------------------------------------------------------------ */
464 static int register_dvb(struct cx231xx_dvb
*dvb
,
465 struct module
*module
,
466 struct cx231xx
*dev
, struct device
*device
)
470 mutex_init(&dvb
->lock
);
473 /* register adapter */
474 result
= dvb_register_adapter(&dvb
->adapter
, dev
->name
, module
, device
,
478 "%s: dvb_register_adapter failed (errno = %d)\n",
482 dvb_register_media_controller(&dvb
->adapter
, dev
->media_dev
);
484 /* Ensure all frontends negotiate bus access */
485 dvb
->frontend
->ops
.ts_bus_ctrl
= cx231xx_dvb_bus_ctrl
;
487 dvb
->adapter
.priv
= dev
;
489 /* register frontend */
490 result
= dvb_register_frontend(&dvb
->adapter
, dvb
->frontend
);
493 "%s: dvb_register_frontend failed (errno = %d)\n",
498 /* register demux stuff */
499 dvb
->demux
.dmx
.capabilities
=
500 DMX_TS_FILTERING
| DMX_SECTION_FILTERING
|
501 DMX_MEMORY_BASED_FILTERING
;
502 dvb
->demux
.priv
= dvb
;
503 dvb
->demux
.filternum
= 256;
504 dvb
->demux
.feednum
= 256;
505 dvb
->demux
.start_feed
= start_feed
;
506 dvb
->demux
.stop_feed
= stop_feed
;
508 result
= dvb_dmx_init(&dvb
->demux
);
511 "%s: dvb_dmx_init failed (errno = %d)\n",
516 dvb
->dmxdev
.filternum
= 256;
517 dvb
->dmxdev
.demux
= &dvb
->demux
.dmx
;
518 dvb
->dmxdev
.capabilities
= 0;
519 result
= dvb_dmxdev_init(&dvb
->dmxdev
, &dvb
->adapter
);
522 "%s: dvb_dmxdev_init failed (errno = %d)\n",
527 dvb
->fe_hw
.source
= DMX_FRONTEND_0
;
528 result
= dvb
->demux
.dmx
.add_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
531 "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n",
536 dvb
->fe_mem
.source
= DMX_MEMORY_FE
;
537 result
= dvb
->demux
.dmx
.add_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
540 "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n",
545 result
= dvb
->demux
.dmx
.connect_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
548 "%s: connect_frontend failed (errno = %d)\n",
553 /* register network adapter */
554 dvb_net_init(&dvb
->adapter
, &dvb
->net
, &dvb
->demux
.dmx
);
555 result
= dvb_create_media_graph(&dvb
->adapter
,
556 dev
->tuner_type
== TUNER_ABSENT
);
558 goto fail_create_graph
;
563 dvb_net_release(&dvb
->net
);
565 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
567 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
569 dvb_dmxdev_release(&dvb
->dmxdev
);
571 dvb_dmx_release(&dvb
->demux
);
573 dvb_unregister_frontend(dvb
->frontend
);
575 dvb_frontend_detach(dvb
->frontend
);
576 dvb_unregister_adapter(&dvb
->adapter
);
581 static void unregister_dvb(struct cx231xx_dvb
*dvb
)
583 struct i2c_client
*client
;
584 dvb_net_release(&dvb
->net
);
585 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
586 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
587 dvb_dmxdev_release(&dvb
->dmxdev
);
588 dvb_dmx_release(&dvb
->demux
);
589 client
= dvb
->i2c_client_tuner
;
590 /* remove I2C tuner */
592 module_put(client
->dev
.driver
->owner
);
593 i2c_unregister_device(client
);
595 dvb_unregister_frontend(dvb
->frontend
);
596 dvb_frontend_detach(dvb
->frontend
);
597 dvb_unregister_adapter(&dvb
->adapter
);
600 static int dvb_init(struct cx231xx
*dev
)
603 struct cx231xx_dvb
*dvb
;
604 struct i2c_adapter
*tuner_i2c
;
605 struct i2c_adapter
*demod_i2c
;
607 if (!dev
->board
.has_dvb
) {
608 /* This device does not support the extension */
612 dvb
= kzalloc(sizeof(struct cx231xx_dvb
), GFP_KERNEL
);
616 "cx231xx_dvb: memory allocation failed\n");
620 dev
->cx231xx_set_analog_freq
= cx231xx_set_analog_freq
;
621 dev
->cx231xx_reset_analog_tuner
= cx231xx_reset_analog_tuner
;
623 tuner_i2c
= cx231xx_get_i2c_adap(dev
, dev
->board
.tuner_i2c_master
);
624 demod_i2c
= cx231xx_get_i2c_adap(dev
, dev
->board
.demod_i2c_master
);
625 mutex_lock(&dev
->lock
);
626 cx231xx_set_mode(dev
, CX231XX_DIGITAL_MODE
);
627 cx231xx_demod_reset(dev
);
629 switch (dev
->model
) {
630 case CX231XX_BOARD_CNXT_CARRAERA
:
631 case CX231XX_BOARD_CNXT_RDE_250
:
633 dev
->dvb
->frontend
= dvb_attach(s5h1432_attach
,
634 &dvico_s5h1432_config
,
637 if (dev
->dvb
->frontend
== NULL
) {
639 "Failed to attach s5h1432 front end\n");
644 /* define general-purpose callback pointer */
645 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
647 if (!dvb_attach(xc5000_attach
, dev
->dvb
->frontend
,
649 &cnxt_rde250_tunerconfig
)) {
655 case CX231XX_BOARD_CNXT_SHELBY
:
656 case CX231XX_BOARD_CNXT_RDU_250
:
658 dev
->dvb
->frontend
= dvb_attach(s5h1411_attach
,
659 &xc5000_s5h1411_config
,
662 if (dev
->dvb
->frontend
== NULL
) {
664 "Failed to attach s5h1411 front end\n");
669 /* define general-purpose callback pointer */
670 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
672 if (!dvb_attach(xc5000_attach
, dev
->dvb
->frontend
,
674 &cnxt_rdu250_tunerconfig
)) {
679 case CX231XX_BOARD_CNXT_RDE_253S
:
681 dev
->dvb
->frontend
= dvb_attach(s5h1432_attach
,
682 &dvico_s5h1432_config
,
685 if (dev
->dvb
->frontend
== NULL
) {
687 "Failed to attach s5h1432 front end\n");
692 /* define general-purpose callback pointer */
693 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
695 if (!dvb_attach(tda18271_attach
, dev
->dvb
->frontend
,
697 &cnxt_rde253s_tunerconfig
)) {
702 case CX231XX_BOARD_CNXT_RDU_253S
:
703 case CX231XX_BOARD_KWORLD_UB445_USB_HYBRID
:
705 dev
->dvb
->frontend
= dvb_attach(s5h1411_attach
,
706 &tda18271_s5h1411_config
,
709 if (dev
->dvb
->frontend
== NULL
) {
711 "Failed to attach s5h1411 front end\n");
716 /* define general-purpose callback pointer */
717 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
719 if (!dvb_attach(tda18271_attach
, dev
->dvb
->frontend
,
721 &cnxt_rde253s_tunerconfig
)) {
726 case CX231XX_BOARD_HAUPPAUGE_EXETER
:
729 "%s: looking for tuner / demod on i2c bus: %d\n",
730 __func__
, i2c_adapter_id(tuner_i2c
));
732 dev
->dvb
->frontend
= dvb_attach(lgdt3305_attach
,
733 &hcw_lgdt3305_config
,
736 if (dev
->dvb
->frontend
== NULL
) {
738 "Failed to attach LG3305 front end\n");
743 /* define general-purpose callback pointer */
744 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
746 dvb_attach(tda18271_attach
, dev
->dvb
->frontend
,
748 &hcw_tda18271_config
);
751 case CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx
:
753 dev
->dvb
->frontend
= dvb_attach(si2165_attach
,
754 &hauppauge_930C_HD_1113xx_si2165_config
,
758 if (dev
->dvb
->frontend
== NULL
) {
760 "Failed to attach SI2165 front end\n");
765 dev
->dvb
->frontend
->ops
.i2c_gate_ctrl
= NULL
;
767 /* define general-purpose callback pointer */
768 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
770 dvb_attach(tda18271_attach
, dev
->dvb
->frontend
,
773 &hcw_tda18271_config
);
775 dev
->cx231xx_reset_analog_tuner
= NULL
;
778 case CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx
:
780 struct i2c_client
*client
;
781 struct i2c_board_info info
;
782 struct si2157_config si2157_config
;
784 memset(&info
, 0, sizeof(struct i2c_board_info
));
786 dev
->dvb
->frontend
= dvb_attach(si2165_attach
,
787 &pctv_quatro_stick_1114xx_si2165_config
,
791 if (dev
->dvb
->frontend
== NULL
) {
793 "Failed to attach SI2165 front end\n");
798 dev
->dvb
->frontend
->ops
.i2c_gate_ctrl
= NULL
;
800 /* define general-purpose callback pointer */
801 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
804 memset(&si2157_config
, 0, sizeof(si2157_config
));
805 si2157_config
.fe
= dev
->dvb
->frontend
;
806 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
807 si2157_config
.mdev
= dev
->media_dev
;
809 si2157_config
.if_port
= 1;
810 si2157_config
.inversion
= true;
811 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
813 info
.platform_data
= &si2157_config
;
814 request_module("si2157");
816 client
= i2c_new_device(
819 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
820 dvb_frontend_detach(dev
->dvb
->frontend
);
825 if (!try_module_get(client
->dev
.driver
->owner
)) {
826 i2c_unregister_device(client
);
827 dvb_frontend_detach(dev
->dvb
->frontend
);
832 dev
->cx231xx_reset_analog_tuner
= NULL
;
834 dev
->dvb
->i2c_client_tuner
= client
;
837 case CX231XX_BOARD_HAUPPAUGE_955Q
:
839 struct i2c_client
*client
;
840 struct i2c_board_info info
;
841 struct si2157_config si2157_config
;
843 memset(&info
, 0, sizeof(struct i2c_board_info
));
845 dev
->dvb
->frontend
= dvb_attach(lgdt3306a_attach
,
846 &hauppauge_955q_lgdt3306a_config
,
850 if (dev
->dvb
->frontend
== NULL
) {
852 "Failed to attach LGDT3306A frontend.\n");
857 dev
->dvb
->frontend
->ops
.i2c_gate_ctrl
= NULL
;
859 /* define general-purpose callback pointer */
860 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
863 memset(&si2157_config
, 0, sizeof(si2157_config
));
864 si2157_config
.fe
= dev
->dvb
->frontend
;
865 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
866 si2157_config
.mdev
= dev
->media_dev
;
868 si2157_config
.if_port
= 1;
869 si2157_config
.inversion
= true;
870 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
872 info
.platform_data
= &si2157_config
;
873 request_module("si2157");
875 client
= i2c_new_device(
878 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
879 dvb_frontend_detach(dev
->dvb
->frontend
);
884 if (!try_module_get(client
->dev
.driver
->owner
)) {
885 i2c_unregister_device(client
);
886 dvb_frontend_detach(dev
->dvb
->frontend
);
891 dev
->cx231xx_reset_analog_tuner
= NULL
;
893 dev
->dvb
->i2c_client_tuner
= client
;
896 case CX231XX_BOARD_PV_PLAYTV_USB_HYBRID
:
897 case CX231XX_BOARD_KWORLD_UB430_USB_HYBRID
:
900 "%s: looking for demod on i2c bus: %d\n",
901 __func__
, i2c_adapter_id(tuner_i2c
));
903 dev
->dvb
->frontend
= dvb_attach(mb86a20s_attach
,
907 if (dev
->dvb
->frontend
== NULL
) {
909 "Failed to attach mb86a20s demod\n");
914 /* define general-purpose callback pointer */
915 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
917 dvb_attach(tda18271_attach
, dev
->dvb
->frontend
,
919 &pv_tda18271_config
);
924 "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
928 if (NULL
== dvb
->frontend
) {
930 "%s/2: frontend initialization failed\n", dev
->name
);
935 /* register everything */
936 result
= register_dvb(dvb
, THIS_MODULE
, dev
, dev
->dev
);
942 dev_info(dev
->dev
, "Successfully loaded cx231xx-dvb\n");
945 cx231xx_set_mode(dev
, CX231XX_SUSPEND
);
946 mutex_unlock(&dev
->lock
);
955 static int dvb_fini(struct cx231xx
*dev
)
957 if (!dev
->board
.has_dvb
) {
958 /* This device does not support the extension */
963 unregister_dvb(dev
->dvb
);
970 static struct cx231xx_ops dvb_ops
= {
972 .name
= "Cx231xx dvb Extension",
977 static int __init
cx231xx_dvb_register(void)
979 return cx231xx_register_extension(&dvb_ops
);
982 static void __exit
cx231xx_dvb_unregister(void)
984 cx231xx_unregister_extension(&dvb_ops
);
987 module_init(cx231xx_dvb_register
);
988 module_exit(cx231xx_dvb_unregister
);