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>
37 #include "lgdt3306a.h"
39 MODULE_DESCRIPTION("driver for cx231xx based DVB cards");
40 MODULE_AUTHOR("Srinivasa Deevi <srinivasa.deevi@conexant.com>");
41 MODULE_LICENSE("GPL");
43 static unsigned int debug
;
44 module_param(debug
, int, 0644);
45 MODULE_PARM_DESC(debug
, "enable debug messages [dvb]");
47 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
49 #define CX231XX_DVB_NUM_BUFS 5
50 #define CX231XX_DVB_MAX_PACKETSIZE 564
51 #define CX231XX_DVB_MAX_PACKETS 64
54 struct dvb_frontend
*frontend
;
56 /* feed count management */
60 /* general boilerplate stuff */
61 struct dvb_adapter adapter
;
62 struct dvb_demux demux
;
64 struct dmx_frontend fe_hw
;
65 struct dmx_frontend fe_mem
;
67 struct i2c_client
*i2c_client_tuner
;
70 static struct s5h1432_config dvico_s5h1432_config
= {
71 .output_mode
= S5H1432_SERIAL_OUTPUT
,
72 .gpio
= S5H1432_GPIO_ON
,
73 .qam_if
= S5H1432_IF_4000
,
74 .vsb_if
= S5H1432_IF_4000
,
75 .inversion
= S5H1432_INVERSION_OFF
,
76 .status_mode
= S5H1432_DEMODLOCKING
,
77 .mpeg_timing
= S5H1432_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
80 static struct tda18271_std_map cnxt_rde253s_tda18271_std_map
= {
81 .dvbt_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 4,
82 .if_lvl
= 1, .rfagc_top
= 0x37, },
83 .dvbt_7
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
84 .if_lvl
= 1, .rfagc_top
= 0x37, },
85 .dvbt_8
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 6,
86 .if_lvl
= 1, .rfagc_top
= 0x37, },
89 static struct tda18271_std_map mb86a20s_tda18271_config
= {
90 .dvbt_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 4,
91 .if_lvl
= 0, .rfagc_top
= 0x37, },
94 static struct tda18271_config cnxt_rde253s_tunerconfig
= {
95 .std_map
= &cnxt_rde253s_tda18271_std_map
,
96 .gate
= TDA18271_GATE_ANALOG
,
99 static struct s5h1411_config tda18271_s5h1411_config
= {
100 .output_mode
= S5H1411_SERIAL_OUTPUT
,
101 .gpio
= S5H1411_GPIO_OFF
,
102 .vsb_if
= S5H1411_IF_3250
,
103 .qam_if
= S5H1411_IF_4000
,
104 .inversion
= S5H1411_INVERSION_ON
,
105 .status_mode
= S5H1411_DEMODLOCKING
,
106 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
108 static struct s5h1411_config xc5000_s5h1411_config
= {
109 .output_mode
= S5H1411_SERIAL_OUTPUT
,
110 .gpio
= S5H1411_GPIO_OFF
,
111 .vsb_if
= S5H1411_IF_3250
,
112 .qam_if
= S5H1411_IF_3250
,
113 .inversion
= S5H1411_INVERSION_OFF
,
114 .status_mode
= S5H1411_DEMODLOCKING
,
115 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
118 static struct lgdt3305_config hcw_lgdt3305_config
= {
120 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
121 .tpclk_edge
= LGDT3305_TPCLK_FALLING_EDGE
,
122 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
124 .spectral_inversion
= 1,
129 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
130 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
131 .if_lvl
= 1, .rfagc_top
= 0x58, },
132 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
133 .if_lvl
= 1, .rfagc_top
= 0x58, },
136 static struct tda18271_config hcw_tda18271_config
= {
137 .std_map
= &hauppauge_tda18271_std_map
,
138 .gate
= TDA18271_GATE_DIGITAL
,
141 static const struct mb86a20s_config pv_mb86a20s_config
= {
142 .demod_address
= 0x10,
146 static struct tda18271_config pv_tda18271_config
= {
147 .std_map
= &mb86a20s_tda18271_config
,
148 .gate
= TDA18271_GATE_DIGITAL
,
149 .small_i2c
= TDA18271_03_BYTE_CHUNK_INIT
,
152 static const struct si2165_config hauppauge_930C_HD_1113xx_si2165_config
= {
154 .chip_mode
= SI2165_MODE_PLL_XTAL
,
155 .ref_freq_Hz
= 16000000,
158 static const struct si2165_config pctv_quatro_stick_1114xx_si2165_config
= {
160 .chip_mode
= SI2165_MODE_PLL_EXT
,
161 .ref_freq_Hz
= 24000000,
164 static struct lgdt3306a_config hauppauge_955q_lgdt3306a_config
= {
169 .spectral_inversion
= 1,
170 .mpeg_mode
= LGDT3306A_MPEG_SERIAL
,
171 .tpclk_edge
= LGDT3306A_TPCLK_RISING_EDGE
,
172 .tpvalid_polarity
= LGDT3306A_TP_VALID_HIGH
,
176 static inline void print_err_status(struct cx231xx
*dev
, int packet
, int status
)
178 char *errmsg
= "Unknown";
182 errmsg
= "unlinked synchronuously";
185 errmsg
= "unlinked asynchronuously";
188 errmsg
= "Buffer error (overrun)";
191 errmsg
= "Stalled (device not responding)";
194 errmsg
= "Babble (bad cable?)";
197 errmsg
= "Bit-stuff error (bad cable?)";
200 errmsg
= "CRC/Timeout (could be anything)";
203 errmsg
= "Device does not respond";
208 "URB status %d [%s].\n", status
, errmsg
);
211 "URB packet %d, status %d [%s].\n",
212 packet
, status
, errmsg
);
216 static inline int dvb_isoc_copy(struct cx231xx
*dev
, struct urb
*urb
)
223 if (dev
->state
& DEV_DISCONNECTED
)
226 if (urb
->status
< 0) {
227 print_err_status(dev
, -1, urb
->status
);
228 if (urb
->status
== -ENOENT
)
232 for (i
= 0; i
< urb
->number_of_packets
; i
++) {
233 int status
= urb
->iso_frame_desc
[i
].status
;
236 print_err_status(dev
, i
, status
);
237 if (urb
->iso_frame_desc
[i
].status
!= -EPROTO
)
241 dvb_dmx_swfilter(&dev
->dvb
->demux
,
242 urb
->transfer_buffer
+
243 urb
->iso_frame_desc
[i
].offset
,
244 urb
->iso_frame_desc
[i
].actual_length
);
250 static inline int dvb_bulk_copy(struct cx231xx
*dev
, struct urb
*urb
)
255 if (dev
->state
& DEV_DISCONNECTED
)
258 if (urb
->status
< 0) {
259 print_err_status(dev
, -1, urb
->status
);
260 if (urb
->status
== -ENOENT
)
264 /* Feed the transport payload into the kernel demux */
265 dvb_dmx_swfilter(&dev
->dvb
->demux
,
266 urb
->transfer_buffer
, urb
->actual_length
);
271 static int start_streaming(struct cx231xx_dvb
*dvb
)
274 struct cx231xx
*dev
= dvb
->adapter
.priv
;
277 dev_dbg(dev
->dev
, "DVB transfer mode is ISO.\n");
278 cx231xx_set_alt_setting(dev
, INDEX_TS1
, 4);
279 rc
= cx231xx_set_mode(dev
, CX231XX_DIGITAL_MODE
);
283 return cx231xx_init_isoc(dev
, CX231XX_DVB_MAX_PACKETS
,
284 CX231XX_DVB_NUM_BUFS
,
285 dev
->ts1_mode
.max_pkt_size
,
288 dev_dbg(dev
->dev
, "DVB transfer mode is BULK.\n");
289 cx231xx_set_alt_setting(dev
, INDEX_TS1
, 0);
290 rc
= cx231xx_set_mode(dev
, CX231XX_DIGITAL_MODE
);
294 return cx231xx_init_bulk(dev
, CX231XX_DVB_MAX_PACKETS
,
295 CX231XX_DVB_NUM_BUFS
,
296 dev
->ts1_mode
.max_pkt_size
,
302 static int stop_streaming(struct cx231xx_dvb
*dvb
)
304 struct cx231xx
*dev
= dvb
->adapter
.priv
;
307 cx231xx_uninit_isoc(dev
);
309 cx231xx_uninit_bulk(dev
);
311 cx231xx_set_mode(dev
, CX231XX_SUSPEND
);
316 static int start_feed(struct dvb_demux_feed
*feed
)
318 struct dvb_demux
*demux
= feed
->demux
;
319 struct cx231xx_dvb
*dvb
= demux
->priv
;
322 if (!demux
->dmx
.frontend
)
325 mutex_lock(&dvb
->lock
);
329 if (dvb
->nfeeds
== 1) {
330 ret
= start_streaming(dvb
);
335 mutex_unlock(&dvb
->lock
);
339 static int stop_feed(struct dvb_demux_feed
*feed
)
341 struct dvb_demux
*demux
= feed
->demux
;
342 struct cx231xx_dvb
*dvb
= demux
->priv
;
345 mutex_lock(&dvb
->lock
);
348 if (0 == dvb
->nfeeds
)
349 err
= stop_streaming(dvb
);
351 mutex_unlock(&dvb
->lock
);
355 /* ------------------------------------------------------------------ */
356 static int cx231xx_dvb_bus_ctrl(struct dvb_frontend
*fe
, int acquire
)
358 struct cx231xx
*dev
= fe
->dvb
->priv
;
361 return cx231xx_set_mode(dev
, CX231XX_DIGITAL_MODE
);
363 return cx231xx_set_mode(dev
, CX231XX_SUSPEND
);
366 /* ------------------------------------------------------------------ */
368 static struct xc5000_config cnxt_rde250_tunerconfig
= {
372 static struct xc5000_config cnxt_rdu250_tunerconfig
= {
377 /* ------------------------------------------------------------------ */
379 static int attach_xc5000(u8 addr
, struct cx231xx
*dev
)
382 struct dvb_frontend
*fe
;
383 struct xc5000_config cfg
;
385 memset(&cfg
, 0, sizeof(cfg
));
386 cfg
.i2c_adap
= cx231xx_get_i2c_adap(dev
, dev
->board
.tuner_i2c_master
);
389 if (!dev
->dvb
->frontend
) {
390 dev_err(dev
->dev
, "%s/2: dvb frontend not attached. "
391 "Can't attach xc5000\n", dev
->name
);
395 fe
= dvb_attach(xc5000_attach
, dev
->dvb
->frontend
, &cfg
);
397 dev_err(dev
->dev
, "%s/2: xc5000 attach failed\n", dev
->name
);
398 dvb_frontend_detach(dev
->dvb
->frontend
);
399 dev
->dvb
->frontend
= NULL
;
403 dev_info(dev
->dev
, "%s/2: xc5000 attached\n", dev
->name
);
409 int cx231xx_set_analog_freq(struct cx231xx
*dev
, u32 freq
)
411 if ((dev
->dvb
!= NULL
) && (dev
->dvb
->frontend
!= NULL
)) {
413 struct dvb_tuner_ops
*dops
= &dev
->dvb
->frontend
->ops
.tuner_ops
;
415 if (dops
->set_analog_params
!= NULL
) {
416 struct analog_parameters params
;
418 params
.frequency
= freq
;
419 params
.std
= dev
->norm
;
420 params
.mode
= 0; /* 0- Air; 1 - cable */
421 /*params.audmode = ; */
423 /* Set the analog parameters to set the frequency */
424 dops
->set_analog_params(dev
->dvb
->frontend
, ¶ms
);
432 int cx231xx_reset_analog_tuner(struct cx231xx
*dev
)
436 if ((dev
->dvb
!= NULL
) && (dev
->dvb
->frontend
!= NULL
)) {
438 struct dvb_tuner_ops
*dops
= &dev
->dvb
->frontend
->ops
.tuner_ops
;
440 if (dops
->init
!= NULL
&& !dev
->xc_fw_load_done
) {
443 "Reloading firmware for XC5000\n");
444 status
= dops
->init(dev
->dvb
->frontend
);
446 dev
->xc_fw_load_done
= 1;
448 "XC5000 firmware download completed\n");
450 dev
->xc_fw_load_done
= 0;
452 "XC5000 firmware download failed !!!\n");
461 /* ------------------------------------------------------------------ */
463 static int register_dvb(struct cx231xx_dvb
*dvb
,
464 struct module
*module
,
465 struct cx231xx
*dev
, struct device
*device
)
469 mutex_init(&dvb
->lock
);
472 /* register adapter */
473 result
= dvb_register_adapter(&dvb
->adapter
, dev
->name
, module
, device
,
477 "%s: dvb_register_adapter failed (errno = %d)\n",
481 dvb_register_media_controller(&dvb
->adapter
, dev
->media_dev
);
483 /* Ensure all frontends negotiate bus access */
484 dvb
->frontend
->ops
.ts_bus_ctrl
= cx231xx_dvb_bus_ctrl
;
486 dvb
->adapter
.priv
= dev
;
488 /* register frontend */
489 result
= dvb_register_frontend(&dvb
->adapter
, dvb
->frontend
);
492 "%s: dvb_register_frontend failed (errno = %d)\n",
497 /* register demux stuff */
498 dvb
->demux
.dmx
.capabilities
=
499 DMX_TS_FILTERING
| DMX_SECTION_FILTERING
|
500 DMX_MEMORY_BASED_FILTERING
;
501 dvb
->demux
.priv
= dvb
;
502 dvb
->demux
.filternum
= 256;
503 dvb
->demux
.feednum
= 256;
504 dvb
->demux
.start_feed
= start_feed
;
505 dvb
->demux
.stop_feed
= stop_feed
;
507 result
= dvb_dmx_init(&dvb
->demux
);
510 "%s: dvb_dmx_init failed (errno = %d)\n",
515 dvb
->dmxdev
.filternum
= 256;
516 dvb
->dmxdev
.demux
= &dvb
->demux
.dmx
;
517 dvb
->dmxdev
.capabilities
= 0;
518 result
= dvb_dmxdev_init(&dvb
->dmxdev
, &dvb
->adapter
);
521 "%s: dvb_dmxdev_init failed (errno = %d)\n",
526 dvb
->fe_hw
.source
= DMX_FRONTEND_0
;
527 result
= dvb
->demux
.dmx
.add_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
530 "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n",
535 dvb
->fe_mem
.source
= DMX_MEMORY_FE
;
536 result
= dvb
->demux
.dmx
.add_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
539 "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n",
544 result
= dvb
->demux
.dmx
.connect_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
547 "%s: connect_frontend failed (errno = %d)\n",
552 /* register network adapter */
553 dvb_net_init(&dvb
->adapter
, &dvb
->net
, &dvb
->demux
.dmx
);
554 result
= dvb_create_media_graph(&dvb
->adapter
, false);
556 goto fail_create_graph
;
561 dvb_net_release(&dvb
->net
);
563 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
565 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
567 dvb_dmxdev_release(&dvb
->dmxdev
);
569 dvb_dmx_release(&dvb
->demux
);
571 dvb_unregister_frontend(dvb
->frontend
);
573 dvb_frontend_detach(dvb
->frontend
);
574 dvb_unregister_adapter(&dvb
->adapter
);
579 static void unregister_dvb(struct cx231xx_dvb
*dvb
)
581 struct i2c_client
*client
;
582 dvb_net_release(&dvb
->net
);
583 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
584 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
585 dvb_dmxdev_release(&dvb
->dmxdev
);
586 dvb_dmx_release(&dvb
->demux
);
587 client
= dvb
->i2c_client_tuner
;
588 /* remove I2C tuner */
590 module_put(client
->dev
.driver
->owner
);
591 i2c_unregister_device(client
);
593 dvb_unregister_frontend(dvb
->frontend
);
594 dvb_frontend_detach(dvb
->frontend
);
595 dvb_unregister_adapter(&dvb
->adapter
);
598 static int dvb_init(struct cx231xx
*dev
)
601 struct cx231xx_dvb
*dvb
;
602 struct i2c_adapter
*tuner_i2c
;
603 struct i2c_adapter
*demod_i2c
;
605 if (!dev
->board
.has_dvb
) {
606 /* This device does not support the extension */
610 dvb
= kzalloc(sizeof(struct cx231xx_dvb
), GFP_KERNEL
);
614 "cx231xx_dvb: memory allocation failed\n");
618 dev
->cx231xx_set_analog_freq
= cx231xx_set_analog_freq
;
619 dev
->cx231xx_reset_analog_tuner
= cx231xx_reset_analog_tuner
;
621 tuner_i2c
= cx231xx_get_i2c_adap(dev
, dev
->board
.tuner_i2c_master
);
622 demod_i2c
= cx231xx_get_i2c_adap(dev
, dev
->board
.demod_i2c_master
);
623 mutex_lock(&dev
->lock
);
624 cx231xx_set_mode(dev
, CX231XX_DIGITAL_MODE
);
625 cx231xx_demod_reset(dev
);
627 switch (dev
->model
) {
628 case CX231XX_BOARD_CNXT_CARRAERA
:
629 case CX231XX_BOARD_CNXT_RDE_250
:
631 dev
->dvb
->frontend
= dvb_attach(s5h1432_attach
,
632 &dvico_s5h1432_config
,
635 if (dev
->dvb
->frontend
== NULL
) {
637 "Failed to attach s5h1432 front end\n");
642 /* define general-purpose callback pointer */
643 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
645 if (!dvb_attach(xc5000_attach
, dev
->dvb
->frontend
,
647 &cnxt_rde250_tunerconfig
)) {
653 case CX231XX_BOARD_CNXT_SHELBY
:
654 case CX231XX_BOARD_CNXT_RDU_250
:
656 dev
->dvb
->frontend
= dvb_attach(s5h1411_attach
,
657 &xc5000_s5h1411_config
,
660 if (dev
->dvb
->frontend
== NULL
) {
662 "Failed to attach s5h1411 front end\n");
667 /* define general-purpose callback pointer */
668 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
670 if (!dvb_attach(xc5000_attach
, dev
->dvb
->frontend
,
672 &cnxt_rdu250_tunerconfig
)) {
677 case CX231XX_BOARD_CNXT_RDE_253S
:
679 dev
->dvb
->frontend
= dvb_attach(s5h1432_attach
,
680 &dvico_s5h1432_config
,
683 if (dev
->dvb
->frontend
== NULL
) {
685 "Failed to attach s5h1432 front end\n");
690 /* define general-purpose callback pointer */
691 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
693 if (!dvb_attach(tda18271_attach
, dev
->dvb
->frontend
,
695 &cnxt_rde253s_tunerconfig
)) {
700 case CX231XX_BOARD_CNXT_RDU_253S
:
701 case CX231XX_BOARD_KWORLD_UB445_USB_HYBRID
:
703 dev
->dvb
->frontend
= dvb_attach(s5h1411_attach
,
704 &tda18271_s5h1411_config
,
707 if (dev
->dvb
->frontend
== NULL
) {
709 "Failed to attach s5h1411 front end\n");
714 /* define general-purpose callback pointer */
715 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
717 if (!dvb_attach(tda18271_attach
, dev
->dvb
->frontend
,
719 &cnxt_rde253s_tunerconfig
)) {
724 case CX231XX_BOARD_HAUPPAUGE_EXETER
:
727 "%s: looking for tuner / demod on i2c bus: %d\n",
728 __func__
, i2c_adapter_id(tuner_i2c
));
730 dev
->dvb
->frontend
= dvb_attach(lgdt3305_attach
,
731 &hcw_lgdt3305_config
,
734 if (dev
->dvb
->frontend
== NULL
) {
736 "Failed to attach LG3305 front end\n");
741 /* define general-purpose callback pointer */
742 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
744 dvb_attach(tda18271_attach
, dev
->dvb
->frontend
,
746 &hcw_tda18271_config
);
749 case CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx
:
751 dev
->dvb
->frontend
= dvb_attach(si2165_attach
,
752 &hauppauge_930C_HD_1113xx_si2165_config
,
756 if (dev
->dvb
->frontend
== NULL
) {
758 "Failed to attach SI2165 front end\n");
763 dev
->dvb
->frontend
->ops
.i2c_gate_ctrl
= NULL
;
765 /* define general-purpose callback pointer */
766 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
768 dvb_attach(tda18271_attach
, dev
->dvb
->frontend
,
771 &hcw_tda18271_config
);
773 dev
->cx231xx_reset_analog_tuner
= NULL
;
776 case CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx
:
778 struct i2c_client
*client
;
779 struct i2c_board_info info
;
780 struct si2157_config si2157_config
;
782 memset(&info
, 0, sizeof(struct i2c_board_info
));
784 dev
->dvb
->frontend
= dvb_attach(si2165_attach
,
785 &pctv_quatro_stick_1114xx_si2165_config
,
789 if (dev
->dvb
->frontend
== NULL
) {
791 "Failed to attach SI2165 front end\n");
796 dev
->dvb
->frontend
->ops
.i2c_gate_ctrl
= NULL
;
798 /* define general-purpose callback pointer */
799 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
802 memset(&si2157_config
, 0, sizeof(si2157_config
));
803 si2157_config
.fe
= dev
->dvb
->frontend
;
804 si2157_config
.if_port
= 1;
805 si2157_config
.inversion
= true;
806 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
808 info
.platform_data
= &si2157_config
;
809 request_module("si2157");
811 client
= i2c_new_device(
814 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
815 dvb_frontend_detach(dev
->dvb
->frontend
);
820 if (!try_module_get(client
->dev
.driver
->owner
)) {
821 i2c_unregister_device(client
);
822 dvb_frontend_detach(dev
->dvb
->frontend
);
827 dev
->cx231xx_reset_analog_tuner
= NULL
;
829 dev
->dvb
->i2c_client_tuner
= client
;
832 case CX231XX_BOARD_HAUPPAUGE_955Q
:
834 struct i2c_client
*client
;
835 struct i2c_board_info info
;
836 struct si2157_config si2157_config
;
838 memset(&info
, 0, sizeof(struct i2c_board_info
));
840 dev
->dvb
->frontend
= dvb_attach(lgdt3306a_attach
,
841 &hauppauge_955q_lgdt3306a_config
,
845 if (dev
->dvb
->frontend
== NULL
) {
847 "Failed to attach LGDT3306A frontend.\n");
852 dev
->dvb
->frontend
->ops
.i2c_gate_ctrl
= NULL
;
854 /* define general-purpose callback pointer */
855 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
858 memset(&si2157_config
, 0, sizeof(si2157_config
));
859 si2157_config
.fe
= dev
->dvb
->frontend
;
860 si2157_config
.if_port
= 1;
861 si2157_config
.inversion
= true;
862 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
864 info
.platform_data
= &si2157_config
;
865 request_module("si2157");
867 client
= i2c_new_device(
870 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
871 dvb_frontend_detach(dev
->dvb
->frontend
);
876 if (!try_module_get(client
->dev
.driver
->owner
)) {
877 i2c_unregister_device(client
);
878 dvb_frontend_detach(dev
->dvb
->frontend
);
883 dev
->cx231xx_reset_analog_tuner
= NULL
;
885 dev
->dvb
->i2c_client_tuner
= client
;
888 case CX231XX_BOARD_PV_PLAYTV_USB_HYBRID
:
889 case CX231XX_BOARD_KWORLD_UB430_USB_HYBRID
:
892 "%s: looking for demod on i2c bus: %d\n",
893 __func__
, i2c_adapter_id(tuner_i2c
));
895 dev
->dvb
->frontend
= dvb_attach(mb86a20s_attach
,
899 if (dev
->dvb
->frontend
== NULL
) {
901 "Failed to attach mb86a20s demod\n");
906 /* define general-purpose callback pointer */
907 dvb
->frontend
->callback
= cx231xx_tuner_callback
;
909 dvb_attach(tda18271_attach
, dev
->dvb
->frontend
,
911 &pv_tda18271_config
);
916 "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
920 if (NULL
== dvb
->frontend
) {
922 "%s/2: frontend initialization failed\n", dev
->name
);
927 /* register everything */
928 result
= register_dvb(dvb
, THIS_MODULE
, dev
, dev
->dev
);
934 dev_info(dev
->dev
, "Successfully loaded cx231xx-dvb\n");
937 cx231xx_set_mode(dev
, CX231XX_SUSPEND
);
938 mutex_unlock(&dev
->lock
);
947 static int dvb_fini(struct cx231xx
*dev
)
949 if (!dev
->board
.has_dvb
) {
950 /* This device does not support the extension */
955 unregister_dvb(dev
->dvb
);
962 static struct cx231xx_ops dvb_ops
= {
964 .name
= "Cx231xx dvb Extension",
969 static int __init
cx231xx_dvb_register(void)
971 return cx231xx_register_extension(&dvb_ops
);
974 static void __exit
cx231xx_dvb_unregister(void)
976 cx231xx_unregister_extension(&dvb_ops
);
979 module_init(cx231xx_dvb_register
);
980 module_exit(cx231xx_dvb_unregister
);