1 // SPDX-License-Identifier: GPL-2.0-or-later
3 DVB device driver for cx231xx
5 Copyright (C) 2008 <srinivasa.deevi at conexant dot com>
11 #include <linux/kernel.h>
12 #include <linux/slab.h>
14 #include <media/dvbdev.h>
15 #include <media/dmxdev.h>
16 #include <media/dvb_demux.h>
17 #include <media/dvb_net.h>
18 #include <media/dvb_frontend.h>
19 #include <media/v4l2-common.h>
20 #include <media/tuner.h>
31 #include "lgdt3306a.h"
35 MODULE_DESCRIPTION("driver for cx231xx based DVB cards");
36 MODULE_AUTHOR("Srinivasa Deevi <srinivasa.deevi@conexant.com>");
37 MODULE_LICENSE("GPL");
39 static unsigned int debug
;
40 module_param(debug
, int, 0644);
41 MODULE_PARM_DESC(debug
, "enable debug messages [dvb]");
43 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
45 #define CX231XX_DVB_NUM_BUFS 5
46 #define CX231XX_DVB_MAX_PACKETSIZE 564
47 #define CX231XX_DVB_MAX_PACKETS 64
48 #define CX231XX_DVB_MAX_FRONTENDS 2
51 struct dvb_frontend
*frontend
[CX231XX_DVB_MAX_FRONTENDS
];
53 /* feed count management */
57 /* general boilerplate stuff */
58 struct dvb_adapter adapter
;
59 struct dvb_demux demux
;
61 struct dmx_frontend fe_hw
;
62 struct dmx_frontend fe_mem
;
64 struct i2c_client
*i2c_client_demod
[2];
65 struct i2c_client
*i2c_client_tuner
;
68 static struct s5h1432_config dvico_s5h1432_config
= {
69 .output_mode
= S5H1432_SERIAL_OUTPUT
,
70 .gpio
= S5H1432_GPIO_ON
,
71 .qam_if
= S5H1432_IF_4000
,
72 .vsb_if
= S5H1432_IF_4000
,
73 .inversion
= S5H1432_INVERSION_OFF
,
74 .status_mode
= S5H1432_DEMODLOCKING
,
75 .mpeg_timing
= S5H1432_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
78 static struct tda18271_std_map cnxt_rde253s_tda18271_std_map
= {
79 .dvbt_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 4,
80 .if_lvl
= 1, .rfagc_top
= 0x37, },
81 .dvbt_7
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
82 .if_lvl
= 1, .rfagc_top
= 0x37, },
83 .dvbt_8
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 6,
84 .if_lvl
= 1, .rfagc_top
= 0x37, },
87 static struct tda18271_std_map mb86a20s_tda18271_config
= {
88 .dvbt_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 4,
89 .if_lvl
= 0, .rfagc_top
= 0x37, },
92 static struct tda18271_config cnxt_rde253s_tunerconfig
= {
93 .std_map
= &cnxt_rde253s_tda18271_std_map
,
94 .gate
= TDA18271_GATE_ANALOG
,
97 static struct s5h1411_config tda18271_s5h1411_config
= {
98 .output_mode
= S5H1411_SERIAL_OUTPUT
,
99 .gpio
= S5H1411_GPIO_OFF
,
100 .vsb_if
= S5H1411_IF_3250
,
101 .qam_if
= S5H1411_IF_4000
,
102 .inversion
= S5H1411_INVERSION_ON
,
103 .status_mode
= S5H1411_DEMODLOCKING
,
104 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
106 static struct s5h1411_config xc5000_s5h1411_config
= {
107 .output_mode
= S5H1411_SERIAL_OUTPUT
,
108 .gpio
= S5H1411_GPIO_OFF
,
109 .vsb_if
= S5H1411_IF_3250
,
110 .qam_if
= S5H1411_IF_3250
,
111 .inversion
= S5H1411_INVERSION_OFF
,
112 .status_mode
= S5H1411_DEMODLOCKING
,
113 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
116 static struct lgdt3305_config hcw_lgdt3305_config
= {
118 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
119 .tpclk_edge
= LGDT3305_TPCLK_FALLING_EDGE
,
120 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
122 .spectral_inversion
= 1,
127 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
128 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
129 .if_lvl
= 1, .rfagc_top
= 0x58, },
130 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
131 .if_lvl
= 1, .rfagc_top
= 0x58, },
134 static struct tda18271_config hcw_tda18271_config
= {
135 .std_map
= &hauppauge_tda18271_std_map
,
136 .gate
= TDA18271_GATE_DIGITAL
,
139 static const struct mb86a20s_config pv_mb86a20s_config
= {
140 .demod_address
= 0x10,
144 static struct tda18271_config pv_tda18271_config
= {
145 .std_map
= &mb86a20s_tda18271_config
,
146 .gate
= TDA18271_GATE_DIGITAL
,
147 .small_i2c
= TDA18271_03_BYTE_CHUNK_INIT
,
150 static const struct lgdt3306a_config hauppauge_955q_lgdt3306a_config
= {
153 .spectral_inversion
= 1,
154 .mpeg_mode
= LGDT3306A_MPEG_SERIAL
,
155 .tpclk_edge
= LGDT3306A_TPCLK_RISING_EDGE
,
156 .tpvalid_polarity
= LGDT3306A_TP_VALID_HIGH
,
160 static struct r820t_config astrometa_t2hybrid_r820t_config
= {
161 .i2c_addr
= 0x3a, /* 0x74 >> 1 */
163 .rafael_chip
= CHIP_R828D
,
164 .max_i2c_msg_len
= 2,
167 static inline void print_err_status(struct cx231xx
*dev
, int packet
, int status
)
169 char *errmsg
= "Unknown";
173 errmsg
= "unlinked synchronously";
176 errmsg
= "unlinked asynchronously";
179 errmsg
= "Buffer error (overrun)";
182 errmsg
= "Stalled (device not responding)";
185 errmsg
= "Babble (bad cable?)";
188 errmsg
= "Bit-stuff error (bad cable?)";
191 errmsg
= "CRC/Timeout (could be anything)";
194 errmsg
= "Device does not respond";
199 "URB status %d [%s].\n", status
, errmsg
);
202 "URB packet %d, status %d [%s].\n",
203 packet
, status
, errmsg
);
207 static inline int dvb_isoc_copy(struct cx231xx
*dev
, struct urb
*urb
)
214 if (dev
->state
& DEV_DISCONNECTED
)
217 if (urb
->status
< 0) {
218 print_err_status(dev
, -1, urb
->status
);
219 if (urb
->status
== -ENOENT
)
223 for (i
= 0; i
< urb
->number_of_packets
; i
++) {
224 int status
= urb
->iso_frame_desc
[i
].status
;
227 print_err_status(dev
, i
, status
);
228 if (urb
->iso_frame_desc
[i
].status
!= -EPROTO
)
232 dvb_dmx_swfilter(&dev
->dvb
->demux
,
233 urb
->transfer_buffer
+
234 urb
->iso_frame_desc
[i
].offset
,
235 urb
->iso_frame_desc
[i
].actual_length
);
241 static inline int dvb_bulk_copy(struct cx231xx
*dev
, struct urb
*urb
)
246 if (dev
->state
& DEV_DISCONNECTED
)
249 if (urb
->status
< 0) {
250 print_err_status(dev
, -1, urb
->status
);
251 if (urb
->status
== -ENOENT
)
255 /* Feed the transport payload into the kernel demux */
256 dvb_dmx_swfilter(&dev
->dvb
->demux
,
257 urb
->transfer_buffer
, urb
->actual_length
);
262 static int start_streaming(struct cx231xx_dvb
*dvb
)
265 struct cx231xx
*dev
= dvb
->adapter
.priv
;
268 dev_dbg(dev
->dev
, "DVB transfer mode is ISO.\n");
269 cx231xx_set_alt_setting(dev
, INDEX_TS1
, 5);
270 rc
= cx231xx_set_mode(dev
, CX231XX_DIGITAL_MODE
);
274 return cx231xx_init_isoc(dev
, CX231XX_DVB_MAX_PACKETS
,
275 CX231XX_DVB_NUM_BUFS
,
276 dev
->ts1_mode
.max_pkt_size
,
279 dev_dbg(dev
->dev
, "DVB transfer mode is BULK.\n");
280 cx231xx_set_alt_setting(dev
, INDEX_TS1
, 0);
281 rc
= cx231xx_set_mode(dev
, CX231XX_DIGITAL_MODE
);
285 return cx231xx_init_bulk(dev
, CX231XX_DVB_MAX_PACKETS
,
286 CX231XX_DVB_NUM_BUFS
,
287 dev
->ts1_mode
.max_pkt_size
,
293 static int stop_streaming(struct cx231xx_dvb
*dvb
)
295 struct cx231xx
*dev
= dvb
->adapter
.priv
;
298 cx231xx_uninit_isoc(dev
);
300 cx231xx_uninit_bulk(dev
);
302 cx231xx_set_mode(dev
, CX231XX_SUSPEND
);
307 static int start_feed(struct dvb_demux_feed
*feed
)
309 struct dvb_demux
*demux
= feed
->demux
;
310 struct cx231xx_dvb
*dvb
= demux
->priv
;
313 if (!demux
->dmx
.frontend
)
316 mutex_lock(&dvb
->lock
);
320 if (dvb
->nfeeds
== 1) {
321 ret
= start_streaming(dvb
);
326 mutex_unlock(&dvb
->lock
);
330 static int stop_feed(struct dvb_demux_feed
*feed
)
332 struct dvb_demux
*demux
= feed
->demux
;
333 struct cx231xx_dvb
*dvb
= demux
->priv
;
336 mutex_lock(&dvb
->lock
);
339 if (0 == dvb
->nfeeds
)
340 err
= stop_streaming(dvb
);
342 mutex_unlock(&dvb
->lock
);
346 /* ------------------------------------------------------------------ */
347 static int cx231xx_dvb_bus_ctrl(struct dvb_frontend
*fe
, int acquire
)
349 struct cx231xx
*dev
= fe
->dvb
->priv
;
352 return cx231xx_set_mode(dev
, CX231XX_DIGITAL_MODE
);
354 return cx231xx_set_mode(dev
, CX231XX_SUSPEND
);
357 /* ------------------------------------------------------------------ */
359 static struct xc5000_config cnxt_rde250_tunerconfig
= {
363 static struct xc5000_config cnxt_rdu250_tunerconfig
= {
368 /* ------------------------------------------------------------------ */
370 static int attach_xc5000(u8 addr
, struct cx231xx
*dev
)
373 struct dvb_frontend
*fe
;
374 struct xc5000_config cfg
;
376 memset(&cfg
, 0, sizeof(cfg
));
377 cfg
.i2c_adap
= cx231xx_get_i2c_adap(dev
, dev
->board
.tuner_i2c_master
);
380 if (!dev
->dvb
->frontend
[0]) {
381 dev_err(dev
->dev
, "%s/2: dvb frontend not attached. Can't attach xc5000\n",
386 fe
= dvb_attach(xc5000_attach
, dev
->dvb
->frontend
[0], &cfg
);
388 dev_err(dev
->dev
, "%s/2: xc5000 attach failed\n", dev
->name
);
389 dvb_frontend_detach(dev
->dvb
->frontend
[0]);
390 dev
->dvb
->frontend
[0] = NULL
;
394 dev_info(dev
->dev
, "%s/2: xc5000 attached\n", dev
->name
);
400 int cx231xx_set_analog_freq(struct cx231xx
*dev
, u32 freq
)
402 if (dev
->dvb
&& dev
->dvb
->frontend
[0]) {
404 struct dvb_tuner_ops
*dops
= &dev
->dvb
->frontend
[0]->ops
.tuner_ops
;
406 if (dops
->set_analog_params
!= NULL
) {
407 struct analog_parameters params
;
409 params
.frequency
= freq
;
410 params
.std
= dev
->norm
;
411 params
.mode
= 0; /* 0- Air; 1 - cable */
412 /*params.audmode = ; */
414 /* Set the analog parameters to set the frequency */
415 dops
->set_analog_params(dev
->dvb
->frontend
[0], ¶ms
);
423 int cx231xx_reset_analog_tuner(struct cx231xx
*dev
)
427 if (dev
->dvb
&& dev
->dvb
->frontend
[0]) {
429 struct dvb_tuner_ops
*dops
= &dev
->dvb
->frontend
[0]->ops
.tuner_ops
;
431 if (dops
->init
!= NULL
&& !dev
->xc_fw_load_done
) {
434 "Reloading firmware for XC5000\n");
435 status
= dops
->init(dev
->dvb
->frontend
[0]);
437 dev
->xc_fw_load_done
= 1;
439 "XC5000 firmware download completed\n");
441 dev
->xc_fw_load_done
= 0;
443 "XC5000 firmware download failed !!!\n");
452 /* ------------------------------------------------------------------ */
454 static int register_dvb(struct cx231xx_dvb
*dvb
,
455 struct module
*module
,
456 struct cx231xx
*dev
, struct device
*device
)
460 mutex_init(&dvb
->lock
);
463 /* register adapter */
464 result
= dvb_register_adapter(&dvb
->adapter
, dev
->name
, module
, device
,
468 "%s: dvb_register_adapter failed (errno = %d)\n",
472 dvb_register_media_controller(&dvb
->adapter
, dev
->media_dev
);
474 /* Ensure all frontends negotiate bus access */
475 dvb
->frontend
[0]->ops
.ts_bus_ctrl
= cx231xx_dvb_bus_ctrl
;
476 if (dvb
->frontend
[1])
477 dvb
->frontend
[1]->ops
.ts_bus_ctrl
= cx231xx_dvb_bus_ctrl
;
479 dvb
->adapter
.priv
= dev
;
481 /* register frontend */
482 result
= dvb_register_frontend(&dvb
->adapter
, dvb
->frontend
[0]);
485 "%s: dvb_register_frontend failed (errno = %d)\n",
490 if (dvb
->frontend
[1]) {
491 result
= dvb_register_frontend(&dvb
->adapter
, dvb
->frontend
[1]);
494 "%s: 2nd dvb_register_frontend failed (errno = %d)\n",
500 dvb
->adapter
.mfe_shared
= 1;
503 /* register demux stuff */
504 dvb
->demux
.dmx
.capabilities
=
505 DMX_TS_FILTERING
| DMX_SECTION_FILTERING
|
506 DMX_MEMORY_BASED_FILTERING
;
507 dvb
->demux
.priv
= dvb
;
508 dvb
->demux
.filternum
= 256;
509 dvb
->demux
.feednum
= 256;
510 dvb
->demux
.start_feed
= start_feed
;
511 dvb
->demux
.stop_feed
= stop_feed
;
513 result
= dvb_dmx_init(&dvb
->demux
);
516 "%s: dvb_dmx_init failed (errno = %d)\n",
521 dvb
->dmxdev
.filternum
= 256;
522 dvb
->dmxdev
.demux
= &dvb
->demux
.dmx
;
523 dvb
->dmxdev
.capabilities
= 0;
524 result
= dvb_dmxdev_init(&dvb
->dmxdev
, &dvb
->adapter
);
527 "%s: dvb_dmxdev_init failed (errno = %d)\n",
532 dvb
->fe_hw
.source
= DMX_FRONTEND_0
;
533 result
= dvb
->demux
.dmx
.add_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
536 "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n",
541 dvb
->fe_mem
.source
= DMX_MEMORY_FE
;
542 result
= dvb
->demux
.dmx
.add_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
545 "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n",
550 result
= dvb
->demux
.dmx
.connect_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
553 "%s: connect_frontend failed (errno = %d)\n",
558 /* register network adapter */
559 dvb_net_init(&dvb
->adapter
, &dvb
->net
, &dvb
->demux
.dmx
);
560 result
= dvb_create_media_graph(&dvb
->adapter
,
561 dev
->tuner_type
== TUNER_ABSENT
);
563 goto fail_create_graph
;
568 dvb_net_release(&dvb
->net
);
570 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
572 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
574 dvb_dmxdev_release(&dvb
->dmxdev
);
576 dvb_dmx_release(&dvb
->demux
);
578 if (dvb
->frontend
[1])
579 dvb_unregister_frontend(dvb
->frontend
[1]);
580 dvb_unregister_frontend(dvb
->frontend
[0]);
582 if (dvb
->frontend
[1])
583 dvb_frontend_detach(dvb
->frontend
[1]);
585 dvb_frontend_detach(dvb
->frontend
[0]);
586 dvb_unregister_adapter(&dvb
->adapter
);
591 static void unregister_dvb(struct cx231xx_dvb
*dvb
)
593 dvb_net_release(&dvb
->net
);
594 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
595 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
596 dvb_dmxdev_release(&dvb
->dmxdev
);
597 dvb_dmx_release(&dvb
->demux
);
598 if (dvb
->frontend
[1])
599 dvb_unregister_frontend(dvb
->frontend
[1]);
600 dvb_unregister_frontend(dvb
->frontend
[0]);
601 if (dvb
->frontend
[1])
602 dvb_frontend_detach(dvb
->frontend
[1]);
603 dvb_frontend_detach(dvb
->frontend
[0]);
604 dvb_unregister_adapter(&dvb
->adapter
);
606 /* remove I2C tuner */
607 dvb_module_release(dvb
->i2c_client_tuner
);
608 dvb
->i2c_client_tuner
= NULL
;
609 /* remove I2C demod(s) */
610 dvb_module_release(dvb
->i2c_client_demod
[1]);
611 dvb
->i2c_client_demod
[1] = NULL
;
612 dvb_module_release(dvb
->i2c_client_demod
[0]);
613 dvb
->i2c_client_demod
[0] = NULL
;
616 static int dvb_init(struct cx231xx
*dev
)
619 struct cx231xx_dvb
*dvb
;
620 struct i2c_adapter
*tuner_i2c
;
621 struct i2c_adapter
*demod_i2c
;
622 struct i2c_client
*client
;
623 struct i2c_adapter
*adapter
;
625 if (!dev
->board
.has_dvb
) {
626 /* This device does not support the extension */
630 dvb
= kzalloc(sizeof(struct cx231xx_dvb
), GFP_KERNEL
);
634 "cx231xx_dvb: memory allocation failed\n");
638 dev
->cx231xx_set_analog_freq
= cx231xx_set_analog_freq
;
639 dev
->cx231xx_reset_analog_tuner
= cx231xx_reset_analog_tuner
;
641 tuner_i2c
= cx231xx_get_i2c_adap(dev
, dev
->board
.tuner_i2c_master
);
642 demod_i2c
= cx231xx_get_i2c_adap(dev
, dev
->board
.demod_i2c_master
);
643 mutex_lock(&dev
->lock
);
644 cx231xx_set_mode(dev
, CX231XX_DIGITAL_MODE
);
645 cx231xx_demod_reset(dev
);
647 switch (dev
->model
) {
648 case CX231XX_BOARD_CNXT_CARRAERA
:
649 case CX231XX_BOARD_CNXT_RDE_250
:
651 dev
->dvb
->frontend
[0] = dvb_attach(s5h1432_attach
,
652 &dvico_s5h1432_config
,
655 if (!dev
->dvb
->frontend
[0]) {
657 "Failed to attach s5h1432 front end\n");
662 /* define general-purpose callback pointer */
663 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
665 if (!dvb_attach(xc5000_attach
, dev
->dvb
->frontend
[0],
667 &cnxt_rde250_tunerconfig
)) {
673 case CX231XX_BOARD_CNXT_SHELBY
:
674 case CX231XX_BOARD_CNXT_RDU_250
:
676 dev
->dvb
->frontend
[0] = dvb_attach(s5h1411_attach
,
677 &xc5000_s5h1411_config
,
680 if (!dev
->dvb
->frontend
[0]) {
682 "Failed to attach s5h1411 front end\n");
687 /* define general-purpose callback pointer */
688 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
690 if (!dvb_attach(xc5000_attach
, dev
->dvb
->frontend
[0],
692 &cnxt_rdu250_tunerconfig
)) {
697 case CX231XX_BOARD_CNXT_RDE_253S
:
699 dev
->dvb
->frontend
[0] = dvb_attach(s5h1432_attach
,
700 &dvico_s5h1432_config
,
703 if (!dev
->dvb
->frontend
[0]) {
705 "Failed to attach s5h1432 front end\n");
710 /* define general-purpose callback pointer */
711 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
713 if (!dvb_attach(tda18271_attach
, dev
->dvb
->frontend
[0],
714 dev
->board
.tuner_addr
, tuner_i2c
,
715 &cnxt_rde253s_tunerconfig
)) {
720 case CX231XX_BOARD_CNXT_RDU_253S
:
721 case CX231XX_BOARD_KWORLD_UB445_USB_HYBRID
:
723 dev
->dvb
->frontend
[0] = dvb_attach(s5h1411_attach
,
724 &tda18271_s5h1411_config
,
727 if (!dev
->dvb
->frontend
[0]) {
729 "Failed to attach s5h1411 front end\n");
734 /* define general-purpose callback pointer */
735 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
737 if (!dvb_attach(tda18271_attach
, dev
->dvb
->frontend
[0],
738 dev
->board
.tuner_addr
, tuner_i2c
,
739 &cnxt_rde253s_tunerconfig
)) {
744 case CX231XX_BOARD_HAUPPAUGE_EXETER
:
747 "%s: looking for tuner / demod on i2c bus: %d\n",
748 __func__
, i2c_adapter_id(tuner_i2c
));
750 dev
->dvb
->frontend
[0] = dvb_attach(lgdt3305_attach
,
751 &hcw_lgdt3305_config
,
754 if (!dev
->dvb
->frontend
[0]) {
756 "Failed to attach LG3305 front end\n");
761 /* define general-purpose callback pointer */
762 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
764 dvb_attach(tda18271_attach
, dev
->dvb
->frontend
[0],
765 dev
->board
.tuner_addr
, tuner_i2c
,
766 &hcw_tda18271_config
);
769 case CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx
:
771 struct si2165_platform_data si2165_pdata
= {};
774 si2165_pdata
.fe
= &dev
->dvb
->frontend
[0];
775 si2165_pdata
.chip_mode
= SI2165_MODE_PLL_XTAL
;
776 si2165_pdata
.ref_freq_hz
= 16000000;
778 /* perform probe/init/attach */
779 client
= dvb_module_probe("si2165", NULL
, demod_i2c
,
780 dev
->board
.demod_addr
,
786 dvb
->i2c_client_demod
[0] = client
;
788 dev
->dvb
->frontend
[0]->ops
.i2c_gate_ctrl
= NULL
;
790 /* define general-purpose callback pointer */
791 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
793 dvb_attach(tda18271_attach
, dev
->dvb
->frontend
[0],
794 dev
->board
.tuner_addr
, tuner_i2c
,
795 &hcw_tda18271_config
);
797 dev
->cx231xx_reset_analog_tuner
= NULL
;
800 case CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx
:
802 struct si2165_platform_data si2165_pdata
= {};
803 struct si2157_config si2157_config
= {};
806 si2165_pdata
.fe
= &dev
->dvb
->frontend
[0];
807 si2165_pdata
.chip_mode
= SI2165_MODE_PLL_EXT
;
808 si2165_pdata
.ref_freq_hz
= 24000000;
810 /* perform probe/init/attach */
811 client
= dvb_module_probe("si2165", NULL
, demod_i2c
,
812 dev
->board
.demod_addr
,
818 dvb
->i2c_client_demod
[0] = client
;
820 dev
->dvb
->frontend
[0]->ops
.i2c_gate_ctrl
= NULL
;
822 /* define general-purpose callback pointer */
823 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
826 si2157_config
.fe
= dev
->dvb
->frontend
[0];
827 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
828 si2157_config
.mdev
= dev
->media_dev
;
830 si2157_config
.if_port
= 1;
831 si2157_config
.inversion
= true;
833 /* perform probe/init/attach */
834 client
= dvb_module_probe("si2157", NULL
, tuner_i2c
,
835 dev
->board
.tuner_addr
,
841 dev
->cx231xx_reset_analog_tuner
= NULL
;
843 dev
->dvb
->i2c_client_tuner
= client
;
846 case CX231XX_BOARD_HAUPPAUGE_955Q
:
848 struct si2157_config si2157_config
= {};
849 struct lgdt3306a_config lgdt3306a_config
= {};
851 lgdt3306a_config
= hauppauge_955q_lgdt3306a_config
;
852 lgdt3306a_config
.fe
= &dev
->dvb
->frontend
[0];
853 lgdt3306a_config
.i2c_adapter
= &adapter
;
855 /* perform probe/init/attach */
856 client
= dvb_module_probe("lgdt3306a", NULL
, demod_i2c
,
857 dev
->board
.demod_addr
,
863 dvb
->i2c_client_demod
[0] = client
;
865 dev
->dvb
->frontend
[0]->ops
.i2c_gate_ctrl
= NULL
;
867 /* define general-purpose callback pointer */
868 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
871 si2157_config
.fe
= dev
->dvb
->frontend
[0];
872 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
873 si2157_config
.mdev
= dev
->media_dev
;
875 si2157_config
.if_port
= 1;
876 si2157_config
.inversion
= true;
878 /* perform probe/init/attach */
879 client
= dvb_module_probe("si2157", NULL
, tuner_i2c
,
880 dev
->board
.tuner_addr
,
886 dev
->cx231xx_reset_analog_tuner
= NULL
;
888 dev
->dvb
->i2c_client_tuner
= client
;
891 case CX231XX_BOARD_PV_PLAYTV_USB_HYBRID
:
892 case CX231XX_BOARD_KWORLD_UB430_USB_HYBRID
:
895 "%s: looking for demod on i2c bus: %d\n",
896 __func__
, i2c_adapter_id(tuner_i2c
));
898 dev
->dvb
->frontend
[0] = dvb_attach(mb86a20s_attach
,
902 if (!dev
->dvb
->frontend
[0]) {
904 "Failed to attach mb86a20s demod\n");
909 /* define general-purpose callback pointer */
910 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
912 dvb_attach(tda18271_attach
, dev
->dvb
->frontend
[0],
913 dev
->board
.tuner_addr
, tuner_i2c
,
914 &pv_tda18271_config
);
917 case CX231XX_BOARD_EVROMEDIA_FULL_HYBRID_FULLHD
:
919 struct si2157_config si2157_config
= {};
920 struct si2168_config si2168_config
= {};
922 /* attach demodulator chip */
923 si2168_config
.ts_mode
= SI2168_TS_SERIAL
; /* from *.inf file */
924 si2168_config
.fe
= &dev
->dvb
->frontend
[0];
925 si2168_config
.i2c_adapter
= &adapter
;
926 si2168_config
.ts_clock_inv
= true;
928 /* perform probe/init/attach */
929 client
= dvb_module_probe("si2168", NULL
, demod_i2c
,
930 dev
->board
.demod_addr
,
936 dvb
->i2c_client_demod
[0] = client
;
938 /* attach tuner chip */
939 si2157_config
.fe
= dev
->dvb
->frontend
[0];
940 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
941 si2157_config
.mdev
= dev
->media_dev
;
943 si2157_config
.if_port
= 1;
944 si2157_config
.inversion
= false;
946 /* perform probe/init/attach */
947 client
= dvb_module_probe("si2157", NULL
, tuner_i2c
,
948 dev
->board
.tuner_addr
,
954 dev
->cx231xx_reset_analog_tuner
= NULL
;
955 dev
->dvb
->i2c_client_tuner
= client
;
958 case CX231XX_BOARD_ASTROMETA_T2HYBRID
:
960 struct mn88473_config mn88473_config
= {};
962 /* attach demodulator chip */
963 mn88473_config
.i2c_wr_max
= 16;
964 mn88473_config
.xtal
= 25000000;
965 mn88473_config
.fe
= &dev
->dvb
->frontend
[0];
967 /* perform probe/init/attach */
968 client
= dvb_module_probe("mn88473", NULL
, demod_i2c
,
969 dev
->board
.demod_addr
,
975 dvb
->i2c_client_demod
[0] = client
;
977 /* define general-purpose callback pointer */
978 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
980 /* attach tuner chip */
981 dvb_attach(r820t_attach
, dev
->dvb
->frontend
[0],
983 &astrometa_t2hybrid_r820t_config
);
986 case CX231XX_BOARD_HAUPPAUGE_935C
:
988 struct si2157_config si2157_config
= {};
989 struct si2168_config si2168_config
= {};
991 /* attach demodulator chip */
992 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
993 si2168_config
.fe
= &dev
->dvb
->frontend
[0];
994 si2168_config
.i2c_adapter
= &adapter
;
995 si2168_config
.ts_clock_inv
= true;
997 /* perform probe/init/attach */
998 client
= dvb_module_probe("si2168", NULL
, demod_i2c
,
999 dev
->board
.demod_addr
,
1005 dvb
->i2c_client_demod
[0] = client
;
1006 dev
->dvb
->frontend
[0]->ops
.i2c_gate_ctrl
= NULL
;
1008 /* define general-purpose callback pointer */
1009 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
1012 si2157_config
.fe
= dev
->dvb
->frontend
[0];
1013 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
1014 si2157_config
.mdev
= dev
->media_dev
;
1016 si2157_config
.if_port
= 1;
1017 si2157_config
.inversion
= true;
1019 /* perform probe/init/attach */
1020 client
= dvb_module_probe("si2157", NULL
, tuner_i2c
,
1021 dev
->board
.tuner_addr
,
1027 dev
->cx231xx_reset_analog_tuner
= NULL
;
1028 dev
->dvb
->i2c_client_tuner
= client
;
1031 case CX231XX_BOARD_HAUPPAUGE_975
:
1033 struct i2c_adapter
*adapter2
;
1034 struct si2157_config si2157_config
= {};
1035 struct lgdt3306a_config lgdt3306a_config
= {};
1036 struct si2168_config si2168_config
= {};
1038 /* attach first demodulator chip */
1039 lgdt3306a_config
= hauppauge_955q_lgdt3306a_config
;
1040 lgdt3306a_config
.fe
= &dev
->dvb
->frontend
[0];
1041 lgdt3306a_config
.i2c_adapter
= &adapter
;
1043 /* perform probe/init/attach */
1044 client
= dvb_module_probe("lgdt3306a", NULL
, demod_i2c
,
1045 dev
->board
.demod_addr
,
1051 dvb
->i2c_client_demod
[0] = client
;
1053 /* attach second demodulator chip */
1054 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
1055 si2168_config
.fe
= &dev
->dvb
->frontend
[1];
1056 si2168_config
.i2c_adapter
= &adapter2
;
1057 si2168_config
.ts_clock_inv
= true;
1059 /* perform probe/init/attach */
1060 client
= dvb_module_probe("si2168", NULL
, adapter
,
1061 dev
->board
.demod_addr2
,
1067 dvb
->i2c_client_demod
[1] = client
;
1068 dvb
->frontend
[1]->id
= 1;
1070 /* define general-purpose callback pointer */
1071 dvb
->frontend
[0]->callback
= cx231xx_tuner_callback
;
1072 dvb
->frontend
[1]->callback
= cx231xx_tuner_callback
;
1075 si2157_config
.fe
= dev
->dvb
->frontend
[0];
1076 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
1077 si2157_config
.mdev
= dev
->media_dev
;
1079 si2157_config
.if_port
= 1;
1080 si2157_config
.inversion
= true;
1082 /* perform probe/init/attach */
1083 client
= dvb_module_probe("si2157", NULL
, adapter
,
1084 dev
->board
.tuner_addr
,
1090 dev
->cx231xx_reset_analog_tuner
= NULL
;
1091 dvb
->i2c_client_tuner
= client
;
1093 dvb
->frontend
[1]->tuner_priv
= dvb
->frontend
[0]->tuner_priv
;
1095 memcpy(&dvb
->frontend
[1]->ops
.tuner_ops
,
1096 &dvb
->frontend
[0]->ops
.tuner_ops
,
1097 sizeof(struct dvb_tuner_ops
));
1102 "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
1106 if (!dvb
->frontend
[0]) {
1108 "%s/2: frontend initialization failed\n", dev
->name
);
1113 /* register everything */
1114 result
= register_dvb(dvb
, THIS_MODULE
, dev
, dev
->dev
);
1120 dev_info(dev
->dev
, "Successfully loaded cx231xx-dvb\n");
1123 cx231xx_set_mode(dev
, CX231XX_SUSPEND
);
1124 mutex_unlock(&dev
->lock
);
1128 /* remove I2C tuner */
1129 dvb_module_release(dvb
->i2c_client_tuner
);
1130 dvb
->i2c_client_tuner
= NULL
;
1131 /* remove I2C demod(s) */
1132 dvb_module_release(dvb
->i2c_client_demod
[1]);
1133 dvb
->i2c_client_demod
[1] = NULL
;
1134 dvb_module_release(dvb
->i2c_client_demod
[0]);
1135 dvb
->i2c_client_demod
[0] = NULL
;
1141 static int dvb_fini(struct cx231xx
*dev
)
1143 if (!dev
->board
.has_dvb
) {
1144 /* This device does not support the extension */
1149 unregister_dvb(dev
->dvb
);
1157 static struct cx231xx_ops dvb_ops
= {
1159 .name
= "Cx231xx dvb Extension",
1164 static int __init
cx231xx_dvb_register(void)
1166 return cx231xx_register_extension(&dvb_ops
);
1169 static void __exit
cx231xx_dvb_unregister(void)
1171 cx231xx_unregister_extension(&dvb_ops
);
1174 module_init(cx231xx_dvb_register
);
1175 module_exit(cx231xx_dvb_unregister
);