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/dvbdev.h>
27 #include <media/dmxdev.h>
28 #include <media/dvb_demux.h>
29 #include <media/dvb_net.h>
30 #include <media/dvb_frontend.h>
31 #include <media/v4l2-common.h>
32 #include <media/tuner.h>
43 #include "lgdt3306a.h"
47 MODULE_DESCRIPTION("driver for cx231xx based DVB cards");
48 MODULE_AUTHOR("Srinivasa Deevi <srinivasa.deevi@conexant.com>");
49 MODULE_LICENSE("GPL");
51 static unsigned int debug
;
52 module_param(debug
, int, 0644);
53 MODULE_PARM_DESC(debug
, "enable debug messages [dvb]");
55 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
57 #define CX231XX_DVB_NUM_BUFS 5
58 #define CX231XX_DVB_MAX_PACKETSIZE 564
59 #define CX231XX_DVB_MAX_PACKETS 64
60 #define CX231XX_DVB_MAX_FRONTENDS 2
63 struct dvb_frontend
*frontend
[CX231XX_DVB_MAX_FRONTENDS
];
65 /* feed count management */
69 /* general boilerplate stuff */
70 struct dvb_adapter adapter
;
71 struct dvb_demux demux
;
73 struct dmx_frontend fe_hw
;
74 struct dmx_frontend fe_mem
;
76 struct i2c_client
*i2c_client_demod
[2];
77 struct i2c_client
*i2c_client_tuner
;
80 static struct s5h1432_config dvico_s5h1432_config
= {
81 .output_mode
= S5H1432_SERIAL_OUTPUT
,
82 .gpio
= S5H1432_GPIO_ON
,
83 .qam_if
= S5H1432_IF_4000
,
84 .vsb_if
= S5H1432_IF_4000
,
85 .inversion
= S5H1432_INVERSION_OFF
,
86 .status_mode
= S5H1432_DEMODLOCKING
,
87 .mpeg_timing
= S5H1432_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
90 static struct tda18271_std_map cnxt_rde253s_tda18271_std_map
= {
91 .dvbt_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 4,
92 .if_lvl
= 1, .rfagc_top
= 0x37, },
93 .dvbt_7
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
94 .if_lvl
= 1, .rfagc_top
= 0x37, },
95 .dvbt_8
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 6,
96 .if_lvl
= 1, .rfagc_top
= 0x37, },
99 static struct tda18271_std_map mb86a20s_tda18271_config
= {
100 .dvbt_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 4,
101 .if_lvl
= 0, .rfagc_top
= 0x37, },
104 static struct tda18271_config cnxt_rde253s_tunerconfig
= {
105 .std_map
= &cnxt_rde253s_tda18271_std_map
,
106 .gate
= TDA18271_GATE_ANALOG
,
109 static struct s5h1411_config tda18271_s5h1411_config
= {
110 .output_mode
= S5H1411_SERIAL_OUTPUT
,
111 .gpio
= S5H1411_GPIO_OFF
,
112 .vsb_if
= S5H1411_IF_3250
,
113 .qam_if
= S5H1411_IF_4000
,
114 .inversion
= S5H1411_INVERSION_ON
,
115 .status_mode
= S5H1411_DEMODLOCKING
,
116 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
118 static struct s5h1411_config xc5000_s5h1411_config
= {
119 .output_mode
= S5H1411_SERIAL_OUTPUT
,
120 .gpio
= S5H1411_GPIO_OFF
,
121 .vsb_if
= S5H1411_IF_3250
,
122 .qam_if
= S5H1411_IF_3250
,
123 .inversion
= S5H1411_INVERSION_OFF
,
124 .status_mode
= S5H1411_DEMODLOCKING
,
125 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
128 static struct lgdt3305_config hcw_lgdt3305_config
= {
130 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
131 .tpclk_edge
= LGDT3305_TPCLK_FALLING_EDGE
,
132 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
134 .spectral_inversion
= 1,
139 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
140 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
141 .if_lvl
= 1, .rfagc_top
= 0x58, },
142 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
143 .if_lvl
= 1, .rfagc_top
= 0x58, },
146 static struct tda18271_config hcw_tda18271_config
= {
147 .std_map
= &hauppauge_tda18271_std_map
,
148 .gate
= TDA18271_GATE_DIGITAL
,
151 static const struct mb86a20s_config pv_mb86a20s_config
= {
152 .demod_address
= 0x10,
156 static struct tda18271_config pv_tda18271_config
= {
157 .std_map
= &mb86a20s_tda18271_config
,
158 .gate
= TDA18271_GATE_DIGITAL
,
159 .small_i2c
= TDA18271_03_BYTE_CHUNK_INIT
,
162 static struct lgdt3306a_config hauppauge_955q_lgdt3306a_config
= {
165 .spectral_inversion
= 1,
166 .mpeg_mode
= LGDT3306A_MPEG_SERIAL
,
167 .tpclk_edge
= LGDT3306A_TPCLK_RISING_EDGE
,
168 .tpvalid_polarity
= LGDT3306A_TP_VALID_HIGH
,
172 static struct r820t_config astrometa_t2hybrid_r820t_config
= {
173 .i2c_addr
= 0x3a, /* 0x74 >> 1 */
175 .rafael_chip
= CHIP_R828D
,
176 .max_i2c_msg_len
= 2,
179 static inline void print_err_status(struct cx231xx
*dev
, int packet
, int status
)
181 char *errmsg
= "Unknown";
185 errmsg
= "unlinked synchronously";
188 errmsg
= "unlinked asynchronously";
191 errmsg
= "Buffer error (overrun)";
194 errmsg
= "Stalled (device not responding)";
197 errmsg
= "Babble (bad cable?)";
200 errmsg
= "Bit-stuff error (bad cable?)";
203 errmsg
= "CRC/Timeout (could be anything)";
206 errmsg
= "Device does not respond";
211 "URB status %d [%s].\n", status
, errmsg
);
214 "URB packet %d, status %d [%s].\n",
215 packet
, status
, errmsg
);
219 static inline int dvb_isoc_copy(struct cx231xx
*dev
, struct urb
*urb
)
226 if (dev
->state
& DEV_DISCONNECTED
)
229 if (urb
->status
< 0) {
230 print_err_status(dev
, -1, urb
->status
);
231 if (urb
->status
== -ENOENT
)
235 for (i
= 0; i
< urb
->number_of_packets
; i
++) {
236 int status
= urb
->iso_frame_desc
[i
].status
;
239 print_err_status(dev
, i
, status
);
240 if (urb
->iso_frame_desc
[i
].status
!= -EPROTO
)
244 dvb_dmx_swfilter(&dev
->dvb
->demux
,
245 urb
->transfer_buffer
+
246 urb
->iso_frame_desc
[i
].offset
,
247 urb
->iso_frame_desc
[i
].actual_length
);
253 static inline int dvb_bulk_copy(struct cx231xx
*dev
, struct urb
*urb
)
258 if (dev
->state
& DEV_DISCONNECTED
)
261 if (urb
->status
< 0) {
262 print_err_status(dev
, -1, urb
->status
);
263 if (urb
->status
== -ENOENT
)
267 /* Feed the transport payload into the kernel demux */
268 dvb_dmx_swfilter(&dev
->dvb
->demux
,
269 urb
->transfer_buffer
, urb
->actual_length
);
274 static int start_streaming(struct cx231xx_dvb
*dvb
)
277 struct cx231xx
*dev
= dvb
->adapter
.priv
;
280 dev_dbg(dev
->dev
, "DVB transfer mode is ISO.\n");
281 cx231xx_set_alt_setting(dev
, INDEX_TS1
, 5);
282 rc
= cx231xx_set_mode(dev
, CX231XX_DIGITAL_MODE
);
286 return cx231xx_init_isoc(dev
, CX231XX_DVB_MAX_PACKETS
,
287 CX231XX_DVB_NUM_BUFS
,
288 dev
->ts1_mode
.max_pkt_size
,
291 dev_dbg(dev
->dev
, "DVB transfer mode is BULK.\n");
292 cx231xx_set_alt_setting(dev
, INDEX_TS1
, 0);
293 rc
= cx231xx_set_mode(dev
, CX231XX_DIGITAL_MODE
);
297 return cx231xx_init_bulk(dev
, CX231XX_DVB_MAX_PACKETS
,
298 CX231XX_DVB_NUM_BUFS
,
299 dev
->ts1_mode
.max_pkt_size
,
305 static int stop_streaming(struct cx231xx_dvb
*dvb
)
307 struct cx231xx
*dev
= dvb
->adapter
.priv
;
310 cx231xx_uninit_isoc(dev
);
312 cx231xx_uninit_bulk(dev
);
314 cx231xx_set_mode(dev
, CX231XX_SUSPEND
);
319 static int start_feed(struct dvb_demux_feed
*feed
)
321 struct dvb_demux
*demux
= feed
->demux
;
322 struct cx231xx_dvb
*dvb
= demux
->priv
;
325 if (!demux
->dmx
.frontend
)
328 mutex_lock(&dvb
->lock
);
332 if (dvb
->nfeeds
== 1) {
333 ret
= start_streaming(dvb
);
338 mutex_unlock(&dvb
->lock
);
342 static int stop_feed(struct dvb_demux_feed
*feed
)
344 struct dvb_demux
*demux
= feed
->demux
;
345 struct cx231xx_dvb
*dvb
= demux
->priv
;
348 mutex_lock(&dvb
->lock
);
351 if (0 == dvb
->nfeeds
)
352 err
= stop_streaming(dvb
);
354 mutex_unlock(&dvb
->lock
);
358 /* ------------------------------------------------------------------ */
359 static int cx231xx_dvb_bus_ctrl(struct dvb_frontend
*fe
, int acquire
)
361 struct cx231xx
*dev
= fe
->dvb
->priv
;
364 return cx231xx_set_mode(dev
, CX231XX_DIGITAL_MODE
);
366 return cx231xx_set_mode(dev
, CX231XX_SUSPEND
);
369 /* ------------------------------------------------------------------ */
371 static struct xc5000_config cnxt_rde250_tunerconfig
= {
375 static struct xc5000_config cnxt_rdu250_tunerconfig
= {
380 /* ------------------------------------------------------------------ */
382 static int attach_xc5000(u8 addr
, struct cx231xx
*dev
)
385 struct dvb_frontend
*fe
;
386 struct xc5000_config cfg
;
388 memset(&cfg
, 0, sizeof(cfg
));
389 cfg
.i2c_adap
= cx231xx_get_i2c_adap(dev
, dev
->board
.tuner_i2c_master
);
392 if (!dev
->dvb
->frontend
[0]) {
393 dev_err(dev
->dev
, "%s/2: dvb frontend not attached. Can't attach xc5000\n",
398 fe
= dvb_attach(xc5000_attach
, dev
->dvb
->frontend
[0], &cfg
);
400 dev_err(dev
->dev
, "%s/2: xc5000 attach failed\n", dev
->name
);
401 dvb_frontend_detach(dev
->dvb
->frontend
[0]);
402 dev
->dvb
->frontend
[0] = NULL
;
406 dev_info(dev
->dev
, "%s/2: xc5000 attached\n", dev
->name
);
412 int cx231xx_set_analog_freq(struct cx231xx
*dev
, u32 freq
)
414 if (dev
->dvb
&& dev
->dvb
->frontend
[0]) {
416 struct dvb_tuner_ops
*dops
= &dev
->dvb
->frontend
[0]->ops
.tuner_ops
;
418 if (dops
->set_analog_params
!= NULL
) {
419 struct analog_parameters params
;
421 params
.frequency
= freq
;
422 params
.std
= dev
->norm
;
423 params
.mode
= 0; /* 0- Air; 1 - cable */
424 /*params.audmode = ; */
426 /* Set the analog parameters to set the frequency */
427 dops
->set_analog_params(dev
->dvb
->frontend
[0], ¶ms
);
435 int cx231xx_reset_analog_tuner(struct cx231xx
*dev
)
439 if (dev
->dvb
&& dev
->dvb
->frontend
[0]) {
441 struct dvb_tuner_ops
*dops
= &dev
->dvb
->frontend
[0]->ops
.tuner_ops
;
443 if (dops
->init
!= NULL
&& !dev
->xc_fw_load_done
) {
446 "Reloading firmware for XC5000\n");
447 status
= dops
->init(dev
->dvb
->frontend
[0]);
449 dev
->xc_fw_load_done
= 1;
451 "XC5000 firmware download completed\n");
453 dev
->xc_fw_load_done
= 0;
455 "XC5000 firmware download failed !!!\n");
464 /* ------------------------------------------------------------------ */
466 static int register_dvb(struct cx231xx_dvb
*dvb
,
467 struct module
*module
,
468 struct cx231xx
*dev
, struct device
*device
)
472 mutex_init(&dvb
->lock
);
475 /* register adapter */
476 result
= dvb_register_adapter(&dvb
->adapter
, dev
->name
, module
, device
,
480 "%s: dvb_register_adapter failed (errno = %d)\n",
484 dvb_register_media_controller(&dvb
->adapter
, dev
->media_dev
);
486 /* Ensure all frontends negotiate bus access */
487 dvb
->frontend
[0]->ops
.ts_bus_ctrl
= cx231xx_dvb_bus_ctrl
;
488 if (dvb
->frontend
[1])
489 dvb
->frontend
[1]->ops
.ts_bus_ctrl
= cx231xx_dvb_bus_ctrl
;
491 dvb
->adapter
.priv
= dev
;
493 /* register frontend */
494 result
= dvb_register_frontend(&dvb
->adapter
, dvb
->frontend
[0]);
497 "%s: dvb_register_frontend failed (errno = %d)\n",
502 if (dvb
->frontend
[1]) {
503 result
= dvb_register_frontend(&dvb
->adapter
, dvb
->frontend
[1]);
506 "%s: 2nd dvb_register_frontend failed (errno = %d)\n",
512 dvb
->adapter
.mfe_shared
= 1;
515 /* register demux stuff */
516 dvb
->demux
.dmx
.capabilities
=
517 DMX_TS_FILTERING
| DMX_SECTION_FILTERING
|
518 DMX_MEMORY_BASED_FILTERING
;
519 dvb
->demux
.priv
= dvb
;
520 dvb
->demux
.filternum
= 256;
521 dvb
->demux
.feednum
= 256;
522 dvb
->demux
.start_feed
= start_feed
;
523 dvb
->demux
.stop_feed
= stop_feed
;
525 result
= dvb_dmx_init(&dvb
->demux
);
528 "%s: dvb_dmx_init failed (errno = %d)\n",
533 dvb
->dmxdev
.filternum
= 256;
534 dvb
->dmxdev
.demux
= &dvb
->demux
.dmx
;
535 dvb
->dmxdev
.capabilities
= 0;
536 result
= dvb_dmxdev_init(&dvb
->dmxdev
, &dvb
->adapter
);
539 "%s: dvb_dmxdev_init failed (errno = %d)\n",
544 dvb
->fe_hw
.source
= DMX_FRONTEND_0
;
545 result
= dvb
->demux
.dmx
.add_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
548 "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n",
553 dvb
->fe_mem
.source
= DMX_MEMORY_FE
;
554 result
= dvb
->demux
.dmx
.add_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
557 "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n",
562 result
= dvb
->demux
.dmx
.connect_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
565 "%s: connect_frontend failed (errno = %d)\n",
570 /* register network adapter */
571 dvb_net_init(&dvb
->adapter
, &dvb
->net
, &dvb
->demux
.dmx
);
572 result
= dvb_create_media_graph(&dvb
->adapter
,
573 dev
->tuner_type
== TUNER_ABSENT
);
575 goto fail_create_graph
;
580 dvb_net_release(&dvb
->net
);
582 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
584 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
586 dvb_dmxdev_release(&dvb
->dmxdev
);
588 dvb_dmx_release(&dvb
->demux
);
590 if (dvb
->frontend
[1])
591 dvb_unregister_frontend(dvb
->frontend
[1]);
592 dvb_unregister_frontend(dvb
->frontend
[0]);
594 if (dvb
->frontend
[1])
595 dvb_frontend_detach(dvb
->frontend
[1]);
597 dvb_frontend_detach(dvb
->frontend
[0]);
598 dvb_unregister_adapter(&dvb
->adapter
);
603 static void unregister_dvb(struct cx231xx_dvb
*dvb
)
605 dvb_net_release(&dvb
->net
);
606 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
607 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
608 dvb_dmxdev_release(&dvb
->dmxdev
);
609 dvb_dmx_release(&dvb
->demux
);
610 if (dvb
->frontend
[1])
611 dvb_unregister_frontend(dvb
->frontend
[1]);
612 dvb_unregister_frontend(dvb
->frontend
[0]);
613 if (dvb
->frontend
[1])
614 dvb_frontend_detach(dvb
->frontend
[1]);
615 dvb_frontend_detach(dvb
->frontend
[0]);
616 dvb_unregister_adapter(&dvb
->adapter
);
618 /* remove I2C tuner */
619 dvb_module_release(dvb
->i2c_client_tuner
);
620 dvb
->i2c_client_tuner
= NULL
;
621 /* remove I2C demod(s) */
622 dvb_module_release(dvb
->i2c_client_demod
[1]);
623 dvb
->i2c_client_demod
[1] = NULL
;
624 dvb_module_release(dvb
->i2c_client_demod
[0]);
625 dvb
->i2c_client_demod
[0] = NULL
;
628 static int dvb_init(struct cx231xx
*dev
)
631 struct cx231xx_dvb
*dvb
;
632 struct i2c_adapter
*tuner_i2c
;
633 struct i2c_adapter
*demod_i2c
;
634 struct i2c_client
*client
;
635 struct i2c_adapter
*adapter
;
637 if (!dev
->board
.has_dvb
) {
638 /* This device does not support the extension */
642 dvb
= kzalloc(sizeof(struct cx231xx_dvb
), GFP_KERNEL
);
646 "cx231xx_dvb: memory allocation failed\n");
650 dev
->cx231xx_set_analog_freq
= cx231xx_set_analog_freq
;
651 dev
->cx231xx_reset_analog_tuner
= cx231xx_reset_analog_tuner
;
653 tuner_i2c
= cx231xx_get_i2c_adap(dev
, dev
->board
.tuner_i2c_master
);
654 demod_i2c
= cx231xx_get_i2c_adap(dev
, dev
->board
.demod_i2c_master
);
655 mutex_lock(&dev
->lock
);
656 cx231xx_set_mode(dev
, CX231XX_DIGITAL_MODE
);
657 cx231xx_demod_reset(dev
);
659 switch (dev
->model
) {
660 case CX231XX_BOARD_CNXT_CARRAERA
:
661 case CX231XX_BOARD_CNXT_RDE_250
:
663 dev
->dvb
->frontend
[0] = dvb_attach(s5h1432_attach
,
664 &dvico_s5h1432_config
,
667 if (!dev
->dvb
->frontend
[0]) {
669 "Failed to attach s5h1432 front end\n");
674 /* define general-purpose callback pointer */
675 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
677 if (!dvb_attach(xc5000_attach
, dev
->dvb
->frontend
[0],
679 &cnxt_rde250_tunerconfig
)) {
685 case CX231XX_BOARD_CNXT_SHELBY
:
686 case CX231XX_BOARD_CNXT_RDU_250
:
688 dev
->dvb
->frontend
[0] = dvb_attach(s5h1411_attach
,
689 &xc5000_s5h1411_config
,
692 if (!dev
->dvb
->frontend
[0]) {
694 "Failed to attach s5h1411 front end\n");
699 /* define general-purpose callback pointer */
700 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
702 if (!dvb_attach(xc5000_attach
, dev
->dvb
->frontend
[0],
704 &cnxt_rdu250_tunerconfig
)) {
709 case CX231XX_BOARD_CNXT_RDE_253S
:
711 dev
->dvb
->frontend
[0] = dvb_attach(s5h1432_attach
,
712 &dvico_s5h1432_config
,
715 if (!dev
->dvb
->frontend
[0]) {
717 "Failed to attach s5h1432 front end\n");
722 /* define general-purpose callback pointer */
723 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
725 if (!dvb_attach(tda18271_attach
, dev
->dvb
->frontend
[0],
726 dev
->board
.tuner_addr
, tuner_i2c
,
727 &cnxt_rde253s_tunerconfig
)) {
732 case CX231XX_BOARD_CNXT_RDU_253S
:
733 case CX231XX_BOARD_KWORLD_UB445_USB_HYBRID
:
735 dev
->dvb
->frontend
[0] = dvb_attach(s5h1411_attach
,
736 &tda18271_s5h1411_config
,
739 if (!dev
->dvb
->frontend
[0]) {
741 "Failed to attach s5h1411 front end\n");
746 /* define general-purpose callback pointer */
747 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
749 if (!dvb_attach(tda18271_attach
, dev
->dvb
->frontend
[0],
750 dev
->board
.tuner_addr
, tuner_i2c
,
751 &cnxt_rde253s_tunerconfig
)) {
756 case CX231XX_BOARD_HAUPPAUGE_EXETER
:
759 "%s: looking for tuner / demod on i2c bus: %d\n",
760 __func__
, i2c_adapter_id(tuner_i2c
));
762 dev
->dvb
->frontend
[0] = dvb_attach(lgdt3305_attach
,
763 &hcw_lgdt3305_config
,
766 if (!dev
->dvb
->frontend
[0]) {
768 "Failed to attach LG3305 front end\n");
773 /* define general-purpose callback pointer */
774 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
776 dvb_attach(tda18271_attach
, dev
->dvb
->frontend
[0],
777 dev
->board
.tuner_addr
, tuner_i2c
,
778 &hcw_tda18271_config
);
781 case CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx
:
783 struct si2165_platform_data si2165_pdata
= {};
786 si2165_pdata
.fe
= &dev
->dvb
->frontend
[0];
787 si2165_pdata
.chip_mode
= SI2165_MODE_PLL_XTAL
;
788 si2165_pdata
.ref_freq_hz
= 16000000;
790 /* perform probe/init/attach */
791 client
= dvb_module_probe("si2165", NULL
, demod_i2c
,
792 dev
->board
.demod_addr
,
798 dvb
->i2c_client_demod
[0] = client
;
800 dev
->dvb
->frontend
[0]->ops
.i2c_gate_ctrl
= NULL
;
802 /* define general-purpose callback pointer */
803 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
805 dvb_attach(tda18271_attach
, dev
->dvb
->frontend
[0],
806 dev
->board
.tuner_addr
, tuner_i2c
,
807 &hcw_tda18271_config
);
809 dev
->cx231xx_reset_analog_tuner
= NULL
;
812 case CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx
:
814 struct si2165_platform_data si2165_pdata
= {};
815 struct si2157_config si2157_config
= {};
818 si2165_pdata
.fe
= &dev
->dvb
->frontend
[0];
819 si2165_pdata
.chip_mode
= SI2165_MODE_PLL_EXT
;
820 si2165_pdata
.ref_freq_hz
= 24000000;
822 /* perform probe/init/attach */
823 client
= dvb_module_probe("si2165", NULL
, demod_i2c
,
824 dev
->board
.demod_addr
,
830 dvb
->i2c_client_demod
[0] = client
;
832 dev
->dvb
->frontend
[0]->ops
.i2c_gate_ctrl
= NULL
;
834 /* define general-purpose callback pointer */
835 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
838 si2157_config
.fe
= dev
->dvb
->frontend
[0];
839 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
840 si2157_config
.mdev
= dev
->media_dev
;
842 si2157_config
.if_port
= 1;
843 si2157_config
.inversion
= true;
845 /* perform probe/init/attach */
846 client
= dvb_module_probe("si2157", NULL
, tuner_i2c
,
847 dev
->board
.tuner_addr
,
853 dev
->cx231xx_reset_analog_tuner
= NULL
;
855 dev
->dvb
->i2c_client_tuner
= client
;
858 case CX231XX_BOARD_HAUPPAUGE_955Q
:
860 struct si2157_config si2157_config
= {};
861 struct lgdt3306a_config lgdt3306a_config
= {};
863 lgdt3306a_config
= hauppauge_955q_lgdt3306a_config
;
864 lgdt3306a_config
.fe
= &dev
->dvb
->frontend
[0];
865 lgdt3306a_config
.i2c_adapter
= &adapter
;
867 /* perform probe/init/attach */
868 client
= dvb_module_probe("lgdt3306a", NULL
, demod_i2c
,
869 dev
->board
.demod_addr
,
875 dvb
->i2c_client_demod
[0] = client
;
877 dev
->dvb
->frontend
[0]->ops
.i2c_gate_ctrl
= NULL
;
879 /* define general-purpose callback pointer */
880 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
883 si2157_config
.fe
= dev
->dvb
->frontend
[0];
884 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
885 si2157_config
.mdev
= dev
->media_dev
;
887 si2157_config
.if_port
= 1;
888 si2157_config
.inversion
= true;
890 /* perform probe/init/attach */
891 client
= dvb_module_probe("si2157", NULL
, tuner_i2c
,
892 dev
->board
.tuner_addr
,
898 dev
->cx231xx_reset_analog_tuner
= NULL
;
900 dev
->dvb
->i2c_client_tuner
= client
;
903 case CX231XX_BOARD_PV_PLAYTV_USB_HYBRID
:
904 case CX231XX_BOARD_KWORLD_UB430_USB_HYBRID
:
907 "%s: looking for demod on i2c bus: %d\n",
908 __func__
, i2c_adapter_id(tuner_i2c
));
910 dev
->dvb
->frontend
[0] = dvb_attach(mb86a20s_attach
,
914 if (!dev
->dvb
->frontend
[0]) {
916 "Failed to attach mb86a20s demod\n");
921 /* define general-purpose callback pointer */
922 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
924 dvb_attach(tda18271_attach
, dev
->dvb
->frontend
[0],
925 dev
->board
.tuner_addr
, tuner_i2c
,
926 &pv_tda18271_config
);
929 case CX231XX_BOARD_EVROMEDIA_FULL_HYBRID_FULLHD
:
931 struct si2157_config si2157_config
= {};
932 struct si2168_config si2168_config
= {};
934 /* attach demodulator chip */
935 si2168_config
.ts_mode
= SI2168_TS_SERIAL
; /* from *.inf file */
936 si2168_config
.fe
= &dev
->dvb
->frontend
[0];
937 si2168_config
.i2c_adapter
= &adapter
;
938 si2168_config
.ts_clock_inv
= true;
940 /* perform probe/init/attach */
941 client
= dvb_module_probe("si2168", NULL
, demod_i2c
,
942 dev
->board
.demod_addr
,
948 dvb
->i2c_client_demod
[0] = client
;
950 /* attach tuner chip */
951 si2157_config
.fe
= dev
->dvb
->frontend
[0];
952 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
953 si2157_config
.mdev
= dev
->media_dev
;
955 si2157_config
.if_port
= 1;
956 si2157_config
.inversion
= false;
958 /* perform probe/init/attach */
959 client
= dvb_module_probe("si2157", NULL
, tuner_i2c
,
960 dev
->board
.tuner_addr
,
966 dev
->cx231xx_reset_analog_tuner
= NULL
;
967 dev
->dvb
->i2c_client_tuner
= client
;
970 case CX231XX_BOARD_ASTROMETA_T2HYBRID
:
972 struct mn88473_config mn88473_config
= {};
974 /* attach demodulator chip */
975 mn88473_config
.i2c_wr_max
= 16;
976 mn88473_config
.xtal
= 25000000;
977 mn88473_config
.fe
= &dev
->dvb
->frontend
[0];
979 /* perform probe/init/attach */
980 client
= dvb_module_probe("mn88473", NULL
, demod_i2c
,
981 dev
->board
.demod_addr
,
987 dvb
->i2c_client_demod
[0] = client
;
989 /* define general-purpose callback pointer */
990 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
992 /* attach tuner chip */
993 dvb_attach(r820t_attach
, dev
->dvb
->frontend
[0],
995 &astrometa_t2hybrid_r820t_config
);
998 case CX231XX_BOARD_HAUPPAUGE_935C
:
1000 struct si2157_config si2157_config
= {};
1001 struct si2168_config si2168_config
= {};
1003 /* attach demodulator chip */
1004 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
1005 si2168_config
.fe
= &dev
->dvb
->frontend
[0];
1006 si2168_config
.i2c_adapter
= &adapter
;
1007 si2168_config
.ts_clock_inv
= true;
1009 /* perform probe/init/attach */
1010 client
= dvb_module_probe("si2168", NULL
, demod_i2c
,
1011 dev
->board
.demod_addr
,
1017 dvb
->i2c_client_demod
[0] = client
;
1018 dev
->dvb
->frontend
[0]->ops
.i2c_gate_ctrl
= NULL
;
1020 /* define general-purpose callback pointer */
1021 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
1024 si2157_config
.fe
= dev
->dvb
->frontend
[0];
1025 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
1026 si2157_config
.mdev
= dev
->media_dev
;
1028 si2157_config
.if_port
= 1;
1029 si2157_config
.inversion
= true;
1031 /* perform probe/init/attach */
1032 client
= dvb_module_probe("si2157", NULL
, tuner_i2c
,
1033 dev
->board
.tuner_addr
,
1039 dev
->cx231xx_reset_analog_tuner
= NULL
;
1040 dev
->dvb
->i2c_client_tuner
= client
;
1043 case CX231XX_BOARD_HAUPPAUGE_975
:
1045 struct i2c_adapter
*adapter2
;
1046 struct si2157_config si2157_config
= {};
1047 struct lgdt3306a_config lgdt3306a_config
= {};
1048 struct si2168_config si2168_config
= {};
1050 /* attach first demodulator chip */
1051 lgdt3306a_config
= hauppauge_955q_lgdt3306a_config
;
1052 lgdt3306a_config
.fe
= &dev
->dvb
->frontend
[0];
1053 lgdt3306a_config
.i2c_adapter
= &adapter
;
1055 /* perform probe/init/attach */
1056 client
= dvb_module_probe("lgdt3306a", NULL
, demod_i2c
,
1057 dev
->board
.demod_addr
,
1063 dvb
->i2c_client_demod
[0] = client
;
1065 /* attach second demodulator chip */
1066 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
1067 si2168_config
.fe
= &dev
->dvb
->frontend
[1];
1068 si2168_config
.i2c_adapter
= &adapter2
;
1069 si2168_config
.ts_clock_inv
= true;
1071 /* perform probe/init/attach */
1072 client
= dvb_module_probe("si2168", NULL
, adapter
,
1073 dev
->board
.demod_addr2
,
1079 dvb
->i2c_client_demod
[1] = client
;
1080 dvb
->frontend
[1]->id
= 1;
1082 /* define general-purpose callback pointer */
1083 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
1084 dvb
->frontend
[1]->callback
= cx231xx_tuner_callback
;
1087 si2157_config
.fe
= dev
->dvb
->frontend
[0];
1088 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
1089 si2157_config
.mdev
= dev
->media_dev
;
1091 si2157_config
.if_port
= 1;
1092 si2157_config
.inversion
= true;
1094 /* perform probe/init/attach */
1095 client
= dvb_module_probe("si2157", NULL
, adapter
,
1096 dev
->board
.tuner_addr
,
1102 dev
->cx231xx_reset_analog_tuner
= NULL
;
1103 dvb
->i2c_client_tuner
= client
;
1105 dvb
->frontend
[1]->tuner_priv
= dvb
->frontend
[0]->tuner_priv
;
1107 memcpy(&dvb
->frontend
[1]->ops
.tuner_ops
,
1108 &dvb
->frontend
[0]->ops
.tuner_ops
,
1109 sizeof(struct dvb_tuner_ops
));
1114 "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
1118 if (!dvb
->frontend
[0]) {
1120 "%s/2: frontend initialization failed\n", dev
->name
);
1125 /* register everything */
1126 result
= register_dvb(dvb
, THIS_MODULE
, dev
, dev
->dev
);
1132 dev_info(dev
->dev
, "Successfully loaded cx231xx-dvb\n");
1135 cx231xx_set_mode(dev
, CX231XX_SUSPEND
);
1136 mutex_unlock(&dev
->lock
);
1140 /* remove I2C tuner */
1141 dvb_module_release(dvb
->i2c_client_tuner
);
1142 dvb
->i2c_client_tuner
= NULL
;
1143 /* remove I2C demod(s) */
1144 dvb_module_release(dvb
->i2c_client_demod
[1]);
1145 dvb
->i2c_client_demod
[1] = NULL
;
1146 dvb_module_release(dvb
->i2c_client_demod
[0]);
1147 dvb
->i2c_client_demod
[0] = NULL
;
1153 static int dvb_fini(struct cx231xx
*dev
)
1155 if (!dev
->board
.has_dvb
) {
1156 /* This device does not support the extension */
1161 unregister_dvb(dev
->dvb
);
1168 static struct cx231xx_ops dvb_ops
= {
1170 .name
= "Cx231xx dvb Extension",
1175 static int __init
cx231xx_dvb_register(void)
1177 return cx231xx_register_extension(&dvb_ops
);
1180 static void __exit
cx231xx_dvb_unregister(void)
1182 cx231xx_unregister_extension(&dvb_ops
);
1185 module_init(cx231xx_dvb_register
);
1186 module_exit(cx231xx_dvb_unregister
);