3 * device driver for Conexant 2388x based TV cards
4 * MPEG Transport Stream (DVB) routines
6 * (c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>
7 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <linux/module.h>
25 #include <linux/init.h>
26 #include <linux/device.h>
28 #include <linux/kthread.h>
29 #include <linux/file.h>
30 #include <linux/suspend.h>
34 #include <media/v4l2-common.h>
37 #include "mt352_priv.h"
38 #include "cx88-vp3054-i2c.h"
48 #include "tuner-simple.h"
58 #include "stb6100_proc.h"
60 MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
61 MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
62 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
63 MODULE_LICENSE("GPL");
65 static unsigned int debug
;
66 module_param(debug
, int, 0644);
67 MODULE_PARM_DESC(debug
,"enable debug messages [dvb]");
69 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
71 #define dprintk(level,fmt, arg...) if (debug >= level) \
72 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
74 /* ------------------------------------------------------------------ */
76 static int dvb_buf_setup(struct videobuf_queue
*q
,
77 unsigned int *count
, unsigned int *size
)
79 struct cx8802_dev
*dev
= q
->priv_data
;
81 dev
->ts_packet_size
= 188 * 4;
82 dev
->ts_packet_count
= 32;
84 *size
= dev
->ts_packet_size
* dev
->ts_packet_count
;
89 static int dvb_buf_prepare(struct videobuf_queue
*q
,
90 struct videobuf_buffer
*vb
, enum v4l2_field field
)
92 struct cx8802_dev
*dev
= q
->priv_data
;
93 return cx8802_buf_prepare(q
, dev
, (struct cx88_buffer
*)vb
,field
);
96 static void dvb_buf_queue(struct videobuf_queue
*q
, struct videobuf_buffer
*vb
)
98 struct cx8802_dev
*dev
= q
->priv_data
;
99 cx8802_buf_queue(dev
, (struct cx88_buffer
*)vb
);
102 static void dvb_buf_release(struct videobuf_queue
*q
,
103 struct videobuf_buffer
*vb
)
105 cx88_free_buffer(q
, (struct cx88_buffer
*)vb
);
108 static struct videobuf_queue_ops dvb_qops
= {
109 .buf_setup
= dvb_buf_setup
,
110 .buf_prepare
= dvb_buf_prepare
,
111 .buf_queue
= dvb_buf_queue
,
112 .buf_release
= dvb_buf_release
,
115 /* ------------------------------------------------------------------ */
117 static int cx88_dvb_bus_ctrl(struct dvb_frontend
* fe
, int acquire
)
119 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
120 struct cx8802_driver
*drv
= NULL
;
124 fe_id
= videobuf_dvb_find_frontend(&dev
->frontends
, fe
);
126 printk(KERN_ERR
"%s() No frontend found\n", __func__
);
130 drv
= cx8802_get_driver(dev
, CX88_MPEG_DVB
);
133 dev
->frontends
.active_fe_id
= fe_id
;
134 ret
= drv
->request_acquire(drv
);
136 ret
= drv
->request_release(drv
);
137 dev
->frontends
.active_fe_id
= 0;
144 static void cx88_dvb_gate_ctrl(struct cx88_core
*core
, int open
)
146 struct videobuf_dvb_frontends
*f
;
147 struct videobuf_dvb_frontend
*fe
;
152 f
= &core
->dvbdev
->frontends
;
157 if (f
->gate
<= 1) /* undefined or fe0 */
158 fe
= videobuf_dvb_get_frontend(f
, 1);
160 fe
= videobuf_dvb_get_frontend(f
, f
->gate
);
162 if (fe
&& fe
->dvb
.frontend
&& fe
->dvb
.frontend
->ops
.i2c_gate_ctrl
)
163 fe
->dvb
.frontend
->ops
.i2c_gate_ctrl(fe
->dvb
.frontend
, open
);
166 /* ------------------------------------------------------------------ */
168 static int dvico_fusionhdtv_demod_init(struct dvb_frontend
* fe
)
170 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x39 };
171 static u8 reset
[] = { RESET
, 0x80 };
172 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
173 static u8 agc_cfg
[] = { AGC_TARGET
, 0x24, 0x20 };
174 static u8 gpp_ctl_cfg
[] = { GPP_CTL
, 0x33 };
175 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x32 };
177 mt352_write(fe
, clock_config
, sizeof(clock_config
));
179 mt352_write(fe
, reset
, sizeof(reset
));
180 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
182 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
183 mt352_write(fe
, gpp_ctl_cfg
, sizeof(gpp_ctl_cfg
));
184 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
188 static int dvico_dual_demod_init(struct dvb_frontend
*fe
)
190 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x38 };
191 static u8 reset
[] = { RESET
, 0x80 };
192 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
193 static u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0x20 };
194 static u8 gpp_ctl_cfg
[] = { GPP_CTL
, 0x33 };
195 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x32 };
197 mt352_write(fe
, clock_config
, sizeof(clock_config
));
199 mt352_write(fe
, reset
, sizeof(reset
));
200 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
202 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
203 mt352_write(fe
, gpp_ctl_cfg
, sizeof(gpp_ctl_cfg
));
204 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
209 static int dntv_live_dvbt_demod_init(struct dvb_frontend
* fe
)
211 static u8 clock_config
[] = { 0x89, 0x38, 0x39 };
212 static u8 reset
[] = { 0x50, 0x80 };
213 static u8 adc_ctl_1_cfg
[] = { 0x8E, 0x40 };
214 static u8 agc_cfg
[] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
215 0x00, 0xFF, 0x00, 0x40, 0x40 };
216 static u8 dntv_extra
[] = { 0xB5, 0x7A };
217 static u8 capt_range_cfg
[] = { 0x75, 0x32 };
219 mt352_write(fe
, clock_config
, sizeof(clock_config
));
221 mt352_write(fe
, reset
, sizeof(reset
));
222 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
224 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
226 mt352_write(fe
, dntv_extra
, sizeof(dntv_extra
));
227 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
232 static struct mt352_config dvico_fusionhdtv
= {
233 .demod_address
= 0x0f,
234 .demod_init
= dvico_fusionhdtv_demod_init
,
237 static struct mt352_config dntv_live_dvbt_config
= {
238 .demod_address
= 0x0f,
239 .demod_init
= dntv_live_dvbt_demod_init
,
242 static struct mt352_config dvico_fusionhdtv_dual
= {
243 .demod_address
= 0x0f,
244 .demod_init
= dvico_dual_demod_init
,
247 static struct zl10353_config cx88_terratec_cinergy_ht_pci_mkii_config
= {
248 .demod_address
= (0x1e >> 1),
253 #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && \
255 static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend
* fe
)
257 static u8 clock_config
[] = { 0x89, 0x38, 0x38 };
258 static u8 reset
[] = { 0x50, 0x80 };
259 static u8 adc_ctl_1_cfg
[] = { 0x8E, 0x40 };
260 static u8 agc_cfg
[] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
261 0x00, 0xFF, 0x00, 0x40, 0x40 };
262 static u8 dntv_extra
[] = { 0xB5, 0x7A };
263 static u8 capt_range_cfg
[] = { 0x75, 0x32 };
265 mt352_write(fe
, clock_config
, sizeof(clock_config
));
267 mt352_write(fe
, reset
, sizeof(reset
));
268 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
270 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
272 mt352_write(fe
, dntv_extra
, sizeof(dntv_extra
));
273 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
278 static struct mt352_config dntv_live_dvbt_pro_config
= {
279 .demod_address
= 0x0f,
281 .demod_init
= dntv_live_dvbt_pro_demod_init
,
285 static struct zl10353_config dvico_fusionhdtv_hybrid
= {
286 .demod_address
= 0x0f,
290 static struct zl10353_config dvico_fusionhdtv_xc3028
= {
291 .demod_address
= 0x0f,
296 static struct mt352_config dvico_fusionhdtv_mt352_xc3028
= {
297 .demod_address
= 0x0f,
300 .demod_init
= dvico_fusionhdtv_demod_init
,
303 static struct zl10353_config dvico_fusionhdtv_plus_v1_1
= {
304 .demod_address
= 0x0f,
307 static struct cx22702_config connexant_refboard_config
= {
308 .demod_address
= 0x43,
309 .output_mode
= CX22702_SERIAL_OUTPUT
,
312 static struct cx22702_config hauppauge_hvr_config
= {
313 .demod_address
= 0x63,
314 .output_mode
= CX22702_SERIAL_OUTPUT
,
317 static int or51132_set_ts_param(struct dvb_frontend
* fe
, int is_punctured
)
319 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
320 dev
->ts_gen_cntrl
= is_punctured
? 0x04 : 0x00;
324 static struct or51132_config pchdtv_hd3000
= {
325 .demod_address
= 0x15,
326 .set_ts_params
= or51132_set_ts_param
,
329 static int lgdt330x_pll_rf_set(struct dvb_frontend
* fe
, int index
)
331 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
332 struct cx88_core
*core
= dev
->core
;
334 dprintk(1, "%s: index = %d\n", __func__
, index
);
336 cx_clear(MO_GP0_IO
, 8);
338 cx_set(MO_GP0_IO
, 8);
342 static int lgdt330x_set_ts_param(struct dvb_frontend
* fe
, int is_punctured
)
344 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
346 dev
->ts_gen_cntrl
|= 0x04;
348 dev
->ts_gen_cntrl
&= ~0x04;
352 static struct lgdt330x_config fusionhdtv_3_gold
= {
353 .demod_address
= 0x0e,
354 .demod_chip
= LGDT3302
,
355 .serial_mpeg
= 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
356 .set_ts_params
= lgdt330x_set_ts_param
,
359 static struct lgdt330x_config fusionhdtv_5_gold
= {
360 .demod_address
= 0x0e,
361 .demod_chip
= LGDT3303
,
362 .serial_mpeg
= 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
363 .set_ts_params
= lgdt330x_set_ts_param
,
366 static struct lgdt330x_config pchdtv_hd5500
= {
367 .demod_address
= 0x59,
368 .demod_chip
= LGDT3303
,
369 .serial_mpeg
= 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
370 .set_ts_params
= lgdt330x_set_ts_param
,
373 static int nxt200x_set_ts_param(struct dvb_frontend
* fe
, int is_punctured
)
375 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
376 dev
->ts_gen_cntrl
= is_punctured
? 0x04 : 0x00;
380 static struct nxt200x_config ati_hdtvwonder
= {
381 .demod_address
= 0x0a,
382 .set_ts_params
= nxt200x_set_ts_param
,
385 static int cx24123_set_ts_param(struct dvb_frontend
* fe
,
388 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
389 dev
->ts_gen_cntrl
= 0x02;
393 static int kworld_dvbs_100_set_voltage(struct dvb_frontend
* fe
,
394 fe_sec_voltage_t voltage
)
396 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
397 struct cx88_core
*core
= dev
->core
;
399 if (voltage
== SEC_VOLTAGE_OFF
)
400 cx_write(MO_GP0_IO
, 0x000006fb);
402 cx_write(MO_GP0_IO
, 0x000006f9);
404 if (core
->prev_set_voltage
)
405 return core
->prev_set_voltage(fe
, voltage
);
409 static int geniatech_dvbs_set_voltage(struct dvb_frontend
*fe
,
410 fe_sec_voltage_t voltage
)
412 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
413 struct cx88_core
*core
= dev
->core
;
415 if (voltage
== SEC_VOLTAGE_OFF
) {
416 dprintk(1,"LNB Voltage OFF\n");
417 cx_write(MO_GP0_IO
, 0x0000efff);
420 if (core
->prev_set_voltage
)
421 return core
->prev_set_voltage(fe
, voltage
);
425 static int tevii_dvbs_set_voltage(struct dvb_frontend
*fe
,
426 fe_sec_voltage_t voltage
)
428 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
429 struct cx88_core
*core
= dev
->core
;
431 cx_set(MO_GP0_IO
, 0x6040);
434 cx_clear(MO_GP0_IO
, 0x20);
437 cx_set(MO_GP0_IO
, 0x20);
439 case SEC_VOLTAGE_OFF
:
440 cx_clear(MO_GP0_IO
, 0x20);
444 if (core
->prev_set_voltage
)
445 return core
->prev_set_voltage(fe
, voltage
);
449 static struct cx24123_config geniatech_dvbs_config
= {
450 .demod_address
= 0x55,
451 .set_ts_params
= cx24123_set_ts_param
,
454 static struct cx24123_config hauppauge_novas_config
= {
455 .demod_address
= 0x55,
456 .set_ts_params
= cx24123_set_ts_param
,
459 static struct cx24123_config kworld_dvbs_100_config
= {
460 .demod_address
= 0x15,
461 .set_ts_params
= cx24123_set_ts_param
,
465 static struct s5h1409_config pinnacle_pctv_hd_800i_config
= {
466 .demod_address
= 0x32 >> 1,
467 .output_mode
= S5H1409_PARALLEL_OUTPUT
,
468 .gpio
= S5H1409_GPIO_ON
,
470 .inversion
= S5H1409_INVERSION_OFF
,
471 .status_mode
= S5H1409_DEMODLOCKING
,
472 .mpeg_timing
= S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK
,
475 static struct s5h1409_config dvico_hdtv5_pci_nano_config
= {
476 .demod_address
= 0x32 >> 1,
477 .output_mode
= S5H1409_SERIAL_OUTPUT
,
478 .gpio
= S5H1409_GPIO_OFF
,
479 .inversion
= S5H1409_INVERSION_OFF
,
480 .status_mode
= S5H1409_DEMODLOCKING
,
481 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
484 static struct s5h1409_config kworld_atsc_120_config
= {
485 .demod_address
= 0x32 >> 1,
486 .output_mode
= S5H1409_SERIAL_OUTPUT
,
487 .gpio
= S5H1409_GPIO_OFF
,
488 .inversion
= S5H1409_INVERSION_OFF
,
489 .status_mode
= S5H1409_DEMODLOCKING
,
490 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
493 static struct xc5000_config pinnacle_pctv_hd_800i_tuner_config
= {
498 static struct zl10353_config cx88_pinnacle_hybrid_pctv
= {
499 .demod_address
= (0x1e >> 1),
504 static struct zl10353_config cx88_geniatech_x8000_mt
= {
505 .demod_address
= (0x1e >> 1),
507 .disable_i2c_gate_ctrl
= 1,
510 static struct s5h1411_config dvico_fusionhdtv7_config
= {
511 .output_mode
= S5H1411_SERIAL_OUTPUT
,
512 .gpio
= S5H1411_GPIO_ON
,
513 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
514 .qam_if
= S5H1411_IF_44000
,
515 .vsb_if
= S5H1411_IF_44000
,
516 .inversion
= S5H1411_INVERSION_OFF
,
517 .status_mode
= S5H1411_DEMODLOCKING
520 static struct xc5000_config dvico_fusionhdtv7_tuner_config
= {
521 .i2c_address
= 0xc2 >> 1,
525 static int attach_xc3028(u8 addr
, struct cx8802_dev
*dev
)
527 struct dvb_frontend
*fe
;
528 struct videobuf_dvb_frontend
*fe0
= NULL
;
529 struct xc2028_ctrl ctl
;
530 struct xc2028_config cfg
= {
531 .i2c_adap
= &dev
->core
->i2c_adap
,
536 /* Get the first frontend */
537 fe0
= videobuf_dvb_get_frontend(&dev
->frontends
, 1);
541 if (!fe0
->dvb
.frontend
) {
542 printk(KERN_ERR
"%s/2: dvb frontend not attached. "
543 "Can't attach xc3028\n",
549 * Some xc3028 devices may be hidden by an I2C gate. This is known
550 * to happen with some s5h1409-based devices.
551 * Now that I2C gate is open, sets up xc3028 configuration
553 cx88_setup_xc3028(dev
->core
, &ctl
);
555 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
, &cfg
);
557 printk(KERN_ERR
"%s/2: xc3028 attach failed\n",
559 dvb_frontend_detach(fe0
->dvb
.frontend
);
560 dvb_unregister_frontend(fe0
->dvb
.frontend
);
561 fe0
->dvb
.frontend
= NULL
;
565 printk(KERN_INFO
"%s/2: xc3028 attached\n",
571 static int cx24116_set_ts_param(struct dvb_frontend
*fe
,
574 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
575 dev
->ts_gen_cntrl
= 0x2;
580 static int stv0900_set_ts_param(struct dvb_frontend
*fe
,
583 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
584 dev
->ts_gen_cntrl
= 0;
589 static int cx24116_reset_device(struct dvb_frontend
*fe
)
591 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
592 struct cx88_core
*core
= dev
->core
;
595 /* Put the cx24116 into reset */
596 cx_write(MO_SRST_IO
, 0);
598 /* Take the cx24116 out of reset */
599 cx_write(MO_SRST_IO
, 1);
605 static struct cx24116_config hauppauge_hvr4000_config
= {
606 .demod_address
= 0x05,
607 .set_ts_params
= cx24116_set_ts_param
,
608 .reset_device
= cx24116_reset_device
,
611 static struct cx24116_config tevii_s460_config
= {
612 .demod_address
= 0x55,
613 .set_ts_params
= cx24116_set_ts_param
,
614 .reset_device
= cx24116_reset_device
,
617 static struct stv0900_config prof_7301_stv0900_config
= {
618 .demod_address
= 0x6a,
621 .clkmode
= 3,/* 0-CLKI, 2-XTALI, else AUTO */
622 .diseqc_mode
= 2,/* 2/3 PWM */
623 .tun1_maddress
= 0,/* 0x60 */
624 .tun1_adc
= 0,/* 2 Vpp */
626 .set_ts_params
= stv0900_set_ts_param
,
629 static struct stb6100_config prof_7301_stb6100_config
= {
630 .tuner_address
= 0x60,
631 .refclock
= 27000000,
634 static struct stv0299_config tevii_tuner_sharp_config
= {
635 .demod_address
= 0x68,
636 .inittab
= sharp_z0194a_inittab
,
641 .volt13_op0_op1
= STV0299_VOLT13_OP1
,
643 .set_symbol_rate
= sharp_z0194a_set_symbol_rate
,
644 .set_ts_params
= cx24116_set_ts_param
,
647 static struct stv0288_config tevii_tuner_earda_config
= {
648 .demod_address
= 0x68,
650 .set_ts_params
= cx24116_set_ts_param
,
653 static int cx8802_alloc_frontends(struct cx8802_dev
*dev
)
655 struct cx88_core
*core
= dev
->core
;
656 struct videobuf_dvb_frontend
*fe
= NULL
;
659 mutex_init(&dev
->frontends
.lock
);
660 INIT_LIST_HEAD(&dev
->frontends
.felist
);
662 if (!core
->board
.num_frontends
)
665 printk(KERN_INFO
"%s() allocating %d frontend(s)\n", __func__
,
666 core
->board
.num_frontends
);
667 for (i
= 1; i
<= core
->board
.num_frontends
; i
++) {
668 fe
= videobuf_dvb_alloc_frontend(&dev
->frontends
, i
);
670 printk(KERN_ERR
"%s() failed to alloc\n", __func__
);
671 videobuf_dvb_dealloc_frontends(&dev
->frontends
);
680 static u8 samsung_smt_7020_inittab
[] = {
732 static int samsung_smt_7020_tuner_set_params(struct dvb_frontend
*fe
,
733 struct dvb_frontend_parameters
*params
)
735 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
738 struct i2c_msg msg
= {
742 .len
= sizeof(buf
) };
744 div
= params
->frequency
/ 125;
746 buf
[0] = (div
>> 8) & 0x7f;
748 buf
[2] = 0x84; /* 0xC4 */
751 if (params
->frequency
< 1500000)
754 if (fe
->ops
.i2c_gate_ctrl
)
755 fe
->ops
.i2c_gate_ctrl(fe
, 1);
757 if (i2c_transfer(&dev
->core
->i2c_adap
, &msg
, 1) != 1)
763 static int samsung_smt_7020_set_tone(struct dvb_frontend
*fe
,
764 fe_sec_tone_mode_t tone
)
766 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
767 struct cx88_core
*core
= dev
->core
;
769 cx_set(MO_GP0_IO
, 0x0800);
773 cx_set(MO_GP0_IO
, 0x08);
776 cx_clear(MO_GP0_IO
, 0x08);
785 static int samsung_smt_7020_set_voltage(struct dvb_frontend
*fe
,
786 fe_sec_voltage_t voltage
)
788 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
789 struct cx88_core
*core
= dev
->core
;
792 struct i2c_msg msg
= {
796 .len
= sizeof(data
) };
798 cx_set(MO_GP0_IO
, 0x8000);
801 case SEC_VOLTAGE_OFF
:
804 data
= ISL6421_EN1
| ISL6421_LLC1
;
805 cx_clear(MO_GP0_IO
, 0x80);
808 data
= ISL6421_EN1
| ISL6421_LLC1
| ISL6421_VSEL1
;
809 cx_clear(MO_GP0_IO
, 0x80);
815 return (i2c_transfer(&dev
->core
->i2c_adap
, &msg
, 1) == 1) ? 0 : -EIO
;
818 static int samsung_smt_7020_stv0299_set_symbol_rate(struct dvb_frontend
*fe
,
819 u32 srate
, u32 ratio
)
824 if (srate
< 1500000) {
827 } else if (srate
< 3000000) {
830 } else if (srate
< 7000000) {
833 } else if (srate
< 14000000) {
836 } else if (srate
< 30000000) {
839 } else if (srate
< 45000000) {
844 stv0299_writereg(fe
, 0x13, aclk
);
845 stv0299_writereg(fe
, 0x14, bclk
);
846 stv0299_writereg(fe
, 0x1f, (ratio
>> 16) & 0xff);
847 stv0299_writereg(fe
, 0x20, (ratio
>> 8) & 0xff);
848 stv0299_writereg(fe
, 0x21, ratio
& 0xf0);
854 static struct stv0299_config samsung_stv0299_config
= {
855 .demod_address
= 0x68,
856 .inittab
= samsung_smt_7020_inittab
,
860 .lock_output
= STV0299_LOCKOUTPUT_LK
,
861 .volt13_op0_op1
= STV0299_VOLT13_OP1
,
863 .set_symbol_rate
= samsung_smt_7020_stv0299_set_symbol_rate
,
866 static int dvb_register(struct cx8802_dev
*dev
)
868 struct cx88_core
*core
= dev
->core
;
869 struct videobuf_dvb_frontend
*fe0
, *fe1
= NULL
;
870 int mfe_shared
= 0; /* bus not shared by default */
872 if (0 != core
->i2c_rc
) {
873 printk(KERN_ERR
"%s/2: no i2c-bus available, cannot attach dvb drivers\n", core
->name
);
874 goto frontend_detach
;
877 /* Get the first frontend */
878 fe0
= videobuf_dvb_get_frontend(&dev
->frontends
, 1);
880 goto frontend_detach
;
882 /* multi-frontend gate control is undefined or defaults to fe0 */
883 dev
->frontends
.gate
= 0;
885 /* Sets the gate control callback to be used by i2c command calls */
886 core
->gate_ctrl
= cx88_dvb_gate_ctrl
;
888 /* init frontend(s) */
889 switch (core
->boardnr
) {
890 case CX88_BOARD_HAUPPAUGE_DVB_T1
:
891 fe0
->dvb
.frontend
= dvb_attach(cx22702_attach
,
892 &connexant_refboard_config
,
894 if (fe0
->dvb
.frontend
!= NULL
) {
895 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
896 0x61, &core
->i2c_adap
,
897 DVB_PLL_THOMSON_DTT759X
))
898 goto frontend_detach
;
901 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1
:
902 case CX88_BOARD_CONEXANT_DVB_T1
:
903 case CX88_BOARD_KWORLD_DVB_T_CX22702
:
904 case CX88_BOARD_WINFAST_DTV1000
:
905 fe0
->dvb
.frontend
= dvb_attach(cx22702_attach
,
906 &connexant_refboard_config
,
908 if (fe0
->dvb
.frontend
!= NULL
) {
909 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
910 0x60, &core
->i2c_adap
,
911 DVB_PLL_THOMSON_DTT7579
))
912 goto frontend_detach
;
915 case CX88_BOARD_WINFAST_DTV2000H
:
916 case CX88_BOARD_WINFAST_DTV2000H_J
:
917 case CX88_BOARD_HAUPPAUGE_HVR1100
:
918 case CX88_BOARD_HAUPPAUGE_HVR1100LP
:
919 case CX88_BOARD_HAUPPAUGE_HVR1300
:
920 fe0
->dvb
.frontend
= dvb_attach(cx22702_attach
,
921 &hauppauge_hvr_config
,
923 if (fe0
->dvb
.frontend
!= NULL
) {
924 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
925 &core
->i2c_adap
, 0x61,
926 TUNER_PHILIPS_FMD1216ME_MK3
))
927 goto frontend_detach
;
930 case CX88_BOARD_HAUPPAUGE_HVR3000
:
933 dev
->frontends
.gate
= 2;
935 fe0
->dvb
.frontend
= dvb_attach(cx24123_attach
,
936 &hauppauge_novas_config
,
937 &dev
->core
->i2c_adap
);
938 if (fe0
->dvb
.frontend
) {
939 if (!dvb_attach(isl6421_attach
,
941 &dev
->core
->i2c_adap
,
942 0x08, ISL6421_DCL
, 0x00))
943 goto frontend_detach
;
946 fe1
= videobuf_dvb_get_frontend(&dev
->frontends
, 2);
948 goto frontend_detach
;
950 fe1
->dvb
.frontend
= dvb_attach(cx22702_attach
,
951 &hauppauge_hvr_config
,
952 &dev
->core
->i2c_adap
);
953 if (fe1
->dvb
.frontend
) {
954 fe1
->dvb
.frontend
->id
= 1;
955 if (!dvb_attach(simple_tuner_attach
,
957 &dev
->core
->i2c_adap
,
958 0x61, TUNER_PHILIPS_FMD1216ME_MK3
))
959 goto frontend_detach
;
962 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS
:
963 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
966 if (fe0
->dvb
.frontend
!= NULL
) {
967 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
968 0x60, NULL
, DVB_PLL_THOMSON_DTT7579
))
969 goto frontend_detach
;
972 /* ZL10353 replaces MT352 on later cards */
973 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
974 &dvico_fusionhdtv_plus_v1_1
,
976 if (fe0
->dvb
.frontend
!= NULL
) {
977 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
978 0x60, NULL
, DVB_PLL_THOMSON_DTT7579
))
979 goto frontend_detach
;
982 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL
:
983 /* The tin box says DEE1601, but it seems to be DTT7579
984 * compatible, with a slightly different MT352 AGC gain. */
985 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
986 &dvico_fusionhdtv_dual
,
988 if (fe0
->dvb
.frontend
!= NULL
) {
989 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
990 0x61, NULL
, DVB_PLL_THOMSON_DTT7579
))
991 goto frontend_detach
;
994 /* ZL10353 replaces MT352 on later cards */
995 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
996 &dvico_fusionhdtv_plus_v1_1
,
998 if (fe0
->dvb
.frontend
!= NULL
) {
999 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
1000 0x61, NULL
, DVB_PLL_THOMSON_DTT7579
))
1001 goto frontend_detach
;
1004 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1
:
1005 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1008 if (fe0
->dvb
.frontend
!= NULL
) {
1009 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
1010 0x61, NULL
, DVB_PLL_LG_Z201
))
1011 goto frontend_detach
;
1014 case CX88_BOARD_KWORLD_DVB_T
:
1015 case CX88_BOARD_DNTV_LIVE_DVB_T
:
1016 case CX88_BOARD_ADSTECH_DVB_T_PCI
:
1017 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1018 &dntv_live_dvbt_config
,
1020 if (fe0
->dvb
.frontend
!= NULL
) {
1021 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
1022 0x61, NULL
, DVB_PLL_UNKNOWN_1
))
1023 goto frontend_detach
;
1026 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO
:
1027 #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && \
1029 /* MT352 is on a secondary I2C bus made from some GPIO lines */
1030 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
, &dntv_live_dvbt_pro_config
,
1031 &dev
->vp3054
->adap
);
1032 if (fe0
->dvb
.frontend
!= NULL
) {
1033 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1034 &core
->i2c_adap
, 0x61,
1035 TUNER_PHILIPS_FMD1216ME_MK3
))
1036 goto frontend_detach
;
1039 printk(KERN_ERR
"%s/2: built without vp3054 support\n",
1043 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID
:
1044 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1045 &dvico_fusionhdtv_hybrid
,
1047 if (fe0
->dvb
.frontend
!= NULL
) {
1048 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1049 &core
->i2c_adap
, 0x61,
1050 TUNER_THOMSON_FE6600
))
1051 goto frontend_detach
;
1054 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO
:
1055 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1056 &dvico_fusionhdtv_xc3028
,
1058 if (fe0
->dvb
.frontend
== NULL
)
1059 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1060 &dvico_fusionhdtv_mt352_xc3028
,
1063 * On this board, the demod provides the I2C bus pullup.
1064 * We must not permit gate_ctrl to be performed, or
1065 * the xc3028 cannot communicate on the bus.
1067 if (fe0
->dvb
.frontend
)
1068 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= NULL
;
1069 if (attach_xc3028(0x61, dev
) < 0)
1070 goto frontend_detach
;
1072 case CX88_BOARD_PCHDTV_HD3000
:
1073 fe0
->dvb
.frontend
= dvb_attach(or51132_attach
, &pchdtv_hd3000
,
1075 if (fe0
->dvb
.frontend
!= NULL
) {
1076 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1077 &core
->i2c_adap
, 0x61,
1078 TUNER_THOMSON_DTT761X
))
1079 goto frontend_detach
;
1082 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q
:
1083 dev
->ts_gen_cntrl
= 0x08;
1085 /* Do a hardware reset of chip before using it. */
1086 cx_clear(MO_GP0_IO
, 1);
1088 cx_set(MO_GP0_IO
, 1);
1091 /* Select RF connector callback */
1092 fusionhdtv_3_gold
.pll_rf_set
= lgdt330x_pll_rf_set
;
1093 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
1096 if (fe0
->dvb
.frontend
!= NULL
) {
1097 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1098 &core
->i2c_adap
, 0x61,
1099 TUNER_MICROTUNE_4042FI5
))
1100 goto frontend_detach
;
1103 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T
:
1104 dev
->ts_gen_cntrl
= 0x08;
1106 /* Do a hardware reset of chip before using it. */
1107 cx_clear(MO_GP0_IO
, 1);
1109 cx_set(MO_GP0_IO
, 9);
1111 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
1114 if (fe0
->dvb
.frontend
!= NULL
) {
1115 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1116 &core
->i2c_adap
, 0x61,
1117 TUNER_THOMSON_DTT761X
))
1118 goto frontend_detach
;
1121 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD
:
1122 dev
->ts_gen_cntrl
= 0x08;
1124 /* Do a hardware reset of chip before using it. */
1125 cx_clear(MO_GP0_IO
, 1);
1127 cx_set(MO_GP0_IO
, 1);
1129 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
1132 if (fe0
->dvb
.frontend
!= NULL
) {
1133 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1134 &core
->i2c_adap
, 0x61,
1135 TUNER_LG_TDVS_H06XF
))
1136 goto frontend_detach
;
1137 if (!dvb_attach(tda9887_attach
, fe0
->dvb
.frontend
,
1138 &core
->i2c_adap
, 0x43))
1139 goto frontend_detach
;
1142 case CX88_BOARD_PCHDTV_HD5500
:
1143 dev
->ts_gen_cntrl
= 0x08;
1145 /* Do a hardware reset of chip before using it. */
1146 cx_clear(MO_GP0_IO
, 1);
1148 cx_set(MO_GP0_IO
, 1);
1150 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
1153 if (fe0
->dvb
.frontend
!= NULL
) {
1154 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1155 &core
->i2c_adap
, 0x61,
1156 TUNER_LG_TDVS_H06XF
))
1157 goto frontend_detach
;
1158 if (!dvb_attach(tda9887_attach
, fe0
->dvb
.frontend
,
1159 &core
->i2c_adap
, 0x43))
1160 goto frontend_detach
;
1163 case CX88_BOARD_ATI_HDTVWONDER
:
1164 fe0
->dvb
.frontend
= dvb_attach(nxt200x_attach
,
1167 if (fe0
->dvb
.frontend
!= NULL
) {
1168 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1169 &core
->i2c_adap
, 0x61,
1170 TUNER_PHILIPS_TUV1236D
))
1171 goto frontend_detach
;
1174 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1
:
1175 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1
:
1176 fe0
->dvb
.frontend
= dvb_attach(cx24123_attach
,
1177 &hauppauge_novas_config
,
1179 if (fe0
->dvb
.frontend
) {
1180 if (!dvb_attach(isl6421_attach
, fe0
->dvb
.frontend
,
1181 &core
->i2c_adap
, 0x08, ISL6421_DCL
, 0x00))
1182 goto frontend_detach
;
1185 case CX88_BOARD_KWORLD_DVBS_100
:
1186 fe0
->dvb
.frontend
= dvb_attach(cx24123_attach
,
1187 &kworld_dvbs_100_config
,
1189 if (fe0
->dvb
.frontend
) {
1190 core
->prev_set_voltage
= fe0
->dvb
.frontend
->ops
.set_voltage
;
1191 fe0
->dvb
.frontend
->ops
.set_voltage
= kworld_dvbs_100_set_voltage
;
1194 case CX88_BOARD_GENIATECH_DVBS
:
1195 fe0
->dvb
.frontend
= dvb_attach(cx24123_attach
,
1196 &geniatech_dvbs_config
,
1198 if (fe0
->dvb
.frontend
) {
1199 core
->prev_set_voltage
= fe0
->dvb
.frontend
->ops
.set_voltage
;
1200 fe0
->dvb
.frontend
->ops
.set_voltage
= geniatech_dvbs_set_voltage
;
1203 case CX88_BOARD_PINNACLE_PCTV_HD_800i
:
1204 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1205 &pinnacle_pctv_hd_800i_config
,
1207 if (fe0
->dvb
.frontend
!= NULL
) {
1208 if (!dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1210 &pinnacle_pctv_hd_800i_tuner_config
))
1211 goto frontend_detach
;
1214 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO
:
1215 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1216 &dvico_hdtv5_pci_nano_config
,
1218 if (fe0
->dvb
.frontend
!= NULL
) {
1219 struct dvb_frontend
*fe
;
1220 struct xc2028_config cfg
= {
1221 .i2c_adap
= &core
->i2c_adap
,
1224 static struct xc2028_ctrl ctl
= {
1225 .fname
= XC2028_DEFAULT_FIRMWARE
,
1227 .scode_table
= XC3028_FE_OREN538
,
1230 fe
= dvb_attach(xc2028_attach
,
1231 fe0
->dvb
.frontend
, &cfg
);
1232 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1233 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1236 case CX88_BOARD_PINNACLE_HYBRID_PCTV
:
1237 case CX88_BOARD_WINFAST_DTV1800H
:
1238 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1239 &cx88_pinnacle_hybrid_pctv
,
1241 if (fe0
->dvb
.frontend
) {
1242 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= NULL
;
1243 if (attach_xc3028(0x61, dev
) < 0)
1244 goto frontend_detach
;
1247 case CX88_BOARD_GENIATECH_X8000_MT
:
1248 dev
->ts_gen_cntrl
= 0x00;
1250 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1251 &cx88_geniatech_x8000_mt
,
1253 if (attach_xc3028(0x61, dev
) < 0)
1254 goto frontend_detach
;
1256 case CX88_BOARD_KWORLD_ATSC_120
:
1257 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1258 &kworld_atsc_120_config
,
1260 if (attach_xc3028(0x61, dev
) < 0)
1261 goto frontend_detach
;
1263 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD
:
1264 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1265 &dvico_fusionhdtv7_config
,
1267 if (fe0
->dvb
.frontend
!= NULL
) {
1268 if (!dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1270 &dvico_fusionhdtv7_tuner_config
))
1271 goto frontend_detach
;
1274 case CX88_BOARD_HAUPPAUGE_HVR4000
:
1275 /* MFE frontend 1 */
1277 dev
->frontends
.gate
= 2;
1279 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1280 &hauppauge_hvr4000_config
,
1281 &dev
->core
->i2c_adap
);
1282 if (fe0
->dvb
.frontend
) {
1283 if (!dvb_attach(isl6421_attach
,
1285 &dev
->core
->i2c_adap
,
1286 0x08, ISL6421_DCL
, 0x00))
1287 goto frontend_detach
;
1289 /* MFE frontend 2 */
1290 fe1
= videobuf_dvb_get_frontend(&dev
->frontends
, 2);
1292 goto frontend_detach
;
1294 fe1
->dvb
.frontend
= dvb_attach(cx22702_attach
,
1295 &hauppauge_hvr_config
,
1296 &dev
->core
->i2c_adap
);
1297 if (fe1
->dvb
.frontend
) {
1298 fe1
->dvb
.frontend
->id
= 1;
1299 if (!dvb_attach(simple_tuner_attach
,
1301 &dev
->core
->i2c_adap
,
1302 0x61, TUNER_PHILIPS_FMD1216ME_MK3
))
1303 goto frontend_detach
;
1306 case CX88_BOARD_HAUPPAUGE_HVR4000LITE
:
1307 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1308 &hauppauge_hvr4000_config
,
1309 &dev
->core
->i2c_adap
);
1310 if (fe0
->dvb
.frontend
) {
1311 if (!dvb_attach(isl6421_attach
,
1313 &dev
->core
->i2c_adap
,
1314 0x08, ISL6421_DCL
, 0x00))
1315 goto frontend_detach
;
1318 case CX88_BOARD_PROF_6200
:
1319 case CX88_BOARD_TBS_8910
:
1320 case CX88_BOARD_TEVII_S420
:
1321 fe0
->dvb
.frontend
= dvb_attach(stv0299_attach
,
1322 &tevii_tuner_sharp_config
,
1324 if (fe0
->dvb
.frontend
!= NULL
) {
1325 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
, 0x60,
1326 &core
->i2c_adap
, DVB_PLL_OPERA1
))
1327 goto frontend_detach
;
1328 core
->prev_set_voltage
= fe0
->dvb
.frontend
->ops
.set_voltage
;
1329 fe0
->dvb
.frontend
->ops
.set_voltage
= tevii_dvbs_set_voltage
;
1332 fe0
->dvb
.frontend
= dvb_attach(stv0288_attach
,
1333 &tevii_tuner_earda_config
,
1335 if (fe0
->dvb
.frontend
!= NULL
) {
1336 if (!dvb_attach(stb6000_attach
, fe0
->dvb
.frontend
, 0x61,
1338 goto frontend_detach
;
1339 core
->prev_set_voltage
= fe0
->dvb
.frontend
->ops
.set_voltage
;
1340 fe0
->dvb
.frontend
->ops
.set_voltage
= tevii_dvbs_set_voltage
;
1344 case CX88_BOARD_TEVII_S460
:
1345 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1348 if (fe0
->dvb
.frontend
!= NULL
)
1349 fe0
->dvb
.frontend
->ops
.set_voltage
= tevii_dvbs_set_voltage
;
1351 case CX88_BOARD_OMICOM_SS4_PCI
:
1352 case CX88_BOARD_TBS_8920
:
1353 case CX88_BOARD_PROF_7300
:
1354 case CX88_BOARD_SATTRADE_ST4200
:
1355 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1356 &hauppauge_hvr4000_config
,
1358 if (fe0
->dvb
.frontend
!= NULL
)
1359 fe0
->dvb
.frontend
->ops
.set_voltage
= tevii_dvbs_set_voltage
;
1361 case CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII
:
1362 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1363 &cx88_terratec_cinergy_ht_pci_mkii_config
,
1365 if (fe0
->dvb
.frontend
) {
1366 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= NULL
;
1367 if (attach_xc3028(0x61, dev
) < 0)
1368 goto frontend_detach
;
1371 case CX88_BOARD_PROF_7301
:{
1372 struct dvb_tuner_ops
*tuner_ops
= NULL
;
1374 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
1375 &prof_7301_stv0900_config
,
1376 &core
->i2c_adap
, 0);
1377 if (fe0
->dvb
.frontend
!= NULL
) {
1378 if (!dvb_attach(stb6100_attach
, fe0
->dvb
.frontend
,
1379 &prof_7301_stb6100_config
,
1381 goto frontend_detach
;
1383 tuner_ops
= &fe0
->dvb
.frontend
->ops
.tuner_ops
;
1384 tuner_ops
->set_frequency
= stb6100_set_freq
;
1385 tuner_ops
->get_frequency
= stb6100_get_freq
;
1386 tuner_ops
->set_bandwidth
= stb6100_set_bandw
;
1387 tuner_ops
->get_bandwidth
= stb6100_get_bandw
;
1389 core
->prev_set_voltage
=
1390 fe0
->dvb
.frontend
->ops
.set_voltage
;
1391 fe0
->dvb
.frontend
->ops
.set_voltage
=
1392 tevii_dvbs_set_voltage
;
1396 case CX88_BOARD_SAMSUNG_SMT_7020
:
1397 dev
->ts_gen_cntrl
= 0x08;
1399 cx_set(MO_GP0_IO
, 0x0101);
1401 cx_clear(MO_GP0_IO
, 0x01);
1403 cx_set(MO_GP0_IO
, 0x01);
1406 fe0
->dvb
.frontend
= dvb_attach(stv0299_attach
,
1407 &samsung_stv0299_config
,
1408 &dev
->core
->i2c_adap
);
1409 if (fe0
->dvb
.frontend
) {
1410 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
=
1411 samsung_smt_7020_tuner_set_params
;
1412 fe0
->dvb
.frontend
->tuner_priv
=
1413 &dev
->core
->i2c_adap
;
1414 fe0
->dvb
.frontend
->ops
.set_voltage
=
1415 samsung_smt_7020_set_voltage
;
1416 fe0
->dvb
.frontend
->ops
.set_tone
=
1417 samsung_smt_7020_set_tone
;
1423 printk(KERN_ERR
"%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
1428 if ( (NULL
== fe0
->dvb
.frontend
) || (fe1
&& NULL
== fe1
->dvb
.frontend
) ) {
1430 "%s/2: frontend initialization failed\n",
1432 goto frontend_detach
;
1434 /* define general-purpose callback pointer */
1435 fe0
->dvb
.frontend
->callback
= cx88_tuner_callback
;
1437 /* Ensure all frontends negotiate bus access */
1438 fe0
->dvb
.frontend
->ops
.ts_bus_ctrl
= cx88_dvb_bus_ctrl
;
1440 fe1
->dvb
.frontend
->ops
.ts_bus_ctrl
= cx88_dvb_bus_ctrl
;
1442 /* Put the analog decoder in standby to keep it quiet */
1443 call_all(core
, core
, s_power
, 0);
1445 /* register everything */
1446 return videobuf_dvb_register_bus(&dev
->frontends
, THIS_MODULE
, dev
,
1447 &dev
->pci
->dev
, adapter_nr
, mfe_shared
, NULL
);
1450 core
->gate_ctrl
= NULL
;
1451 videobuf_dvb_dealloc_frontends(&dev
->frontends
);
1455 /* ----------------------------------------------------------- */
1457 /* CX8802 MPEG -> mini driver - We have been given the hardware */
1458 static int cx8802_dvb_advise_acquire(struct cx8802_driver
*drv
)
1460 struct cx88_core
*core
= drv
->core
;
1462 dprintk( 1, "%s\n", __func__
);
1464 switch (core
->boardnr
) {
1465 case CX88_BOARD_HAUPPAUGE_HVR1300
:
1466 /* We arrive here with either the cx23416 or the cx22702
1467 * on the bus. Take the bus from the cx23416 and enable the
1470 /* Toggle reset on cx22702 leaving i2c active */
1471 cx_set(MO_GP0_IO
, 0x00000080);
1473 cx_clear(MO_GP0_IO
, 0x00000080);
1475 cx_set(MO_GP0_IO
, 0x00000080);
1477 /* enable the cx22702 pins */
1478 cx_clear(MO_GP0_IO
, 0x00000004);
1482 case CX88_BOARD_HAUPPAUGE_HVR3000
:
1483 case CX88_BOARD_HAUPPAUGE_HVR4000
:
1484 /* Toggle reset on cx22702 leaving i2c active */
1485 cx_set(MO_GP0_IO
, 0x00000080);
1487 cx_clear(MO_GP0_IO
, 0x00000080);
1489 cx_set(MO_GP0_IO
, 0x00000080);
1491 switch (core
->dvbdev
->frontends
.active_fe_id
) {
1492 case 1: /* DVB-S/S2 Enabled */
1493 /* tri-state the cx22702 pins */
1494 cx_set(MO_GP0_IO
, 0x00000004);
1495 /* Take the cx24116/cx24123 out of reset */
1496 cx_write(MO_SRST_IO
, 1);
1497 core
->dvbdev
->ts_gen_cntrl
= 0x02; /* Parallel IO */
1499 case 2: /* DVB-T Enabled */
1500 /* Put the cx24116/cx24123 into reset */
1501 cx_write(MO_SRST_IO
, 0);
1502 /* enable the cx22702 pins */
1503 cx_clear(MO_GP0_IO
, 0x00000004);
1504 core
->dvbdev
->ts_gen_cntrl
= 0x0c; /* Serial IO */
1516 /* CX8802 MPEG -> mini driver - We no longer have the hardware */
1517 static int cx8802_dvb_advise_release(struct cx8802_driver
*drv
)
1519 struct cx88_core
*core
= drv
->core
;
1521 dprintk( 1, "%s\n", __func__
);
1523 switch (core
->boardnr
) {
1524 case CX88_BOARD_HAUPPAUGE_HVR1300
:
1525 /* Do Nothing, leave the cx22702 on the bus. */
1527 case CX88_BOARD_HAUPPAUGE_HVR3000
:
1528 case CX88_BOARD_HAUPPAUGE_HVR4000
:
1536 static int cx8802_dvb_probe(struct cx8802_driver
*drv
)
1538 struct cx88_core
*core
= drv
->core
;
1539 struct cx8802_dev
*dev
= drv
->core
->dvbdev
;
1541 struct videobuf_dvb_frontend
*fe
;
1544 dprintk( 1, "%s\n", __func__
);
1545 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
1552 if (!(core
->board
.mpeg
& CX88_MPEG_DVB
))
1555 /* If vp3054 isn't enabled, a stub will just return 0 */
1556 err
= vp3054_i2c_probe(dev
);
1561 printk(KERN_INFO
"%s/2: cx2388x based DVB/ATSC card\n", core
->name
);
1562 dev
->ts_gen_cntrl
= 0x0c;
1564 err
= cx8802_alloc_frontends(dev
);
1569 for (i
= 1; i
<= core
->board
.num_frontends
; i
++) {
1570 fe
= videobuf_dvb_get_frontend(&core
->dvbdev
->frontends
, i
);
1572 printk(KERN_ERR
"%s() failed to get frontend(%d)\n",
1576 videobuf_queue_sg_init(&fe
->dvb
.dvbq
, &dvb_qops
,
1577 &dev
->pci
->dev
, &dev
->slock
,
1578 V4L2_BUF_TYPE_VIDEO_CAPTURE
,
1580 sizeof(struct cx88_buffer
),
1582 /* init struct videobuf_dvb */
1583 fe
->dvb
.name
= dev
->core
->name
;
1586 err
= dvb_register(dev
);
1588 /* frontends/adapter de-allocated in dvb_register */
1589 printk(KERN_ERR
"%s/2: dvb_register failed (err = %d)\n",
1593 videobuf_dvb_dealloc_frontends(&core
->dvbdev
->frontends
);
1598 static int cx8802_dvb_remove(struct cx8802_driver
*drv
)
1600 struct cx88_core
*core
= drv
->core
;
1601 struct cx8802_dev
*dev
= drv
->core
->dvbdev
;
1603 dprintk( 1, "%s\n", __func__
);
1605 videobuf_dvb_unregister_bus(&dev
->frontends
);
1607 vp3054_i2c_remove(dev
);
1609 core
->gate_ctrl
= NULL
;
1614 static struct cx8802_driver cx8802_dvb_driver
= {
1615 .type_id
= CX88_MPEG_DVB
,
1616 .hw_access
= CX8802_DRVCTL_SHARED
,
1617 .probe
= cx8802_dvb_probe
,
1618 .remove
= cx8802_dvb_remove
,
1619 .advise_acquire
= cx8802_dvb_advise_acquire
,
1620 .advise_release
= cx8802_dvb_advise_release
,
1623 static int __init
dvb_init(void)
1625 printk(KERN_INFO
"cx88/2: cx2388x dvb driver version %d.%d.%d loaded\n",
1626 (CX88_VERSION_CODE
>> 16) & 0xff,
1627 (CX88_VERSION_CODE
>> 8) & 0xff,
1628 CX88_VERSION_CODE
& 0xff);
1630 printk(KERN_INFO
"cx2388x: snapshot date %04d-%02d-%02d\n",
1631 SNAPSHOT
/10000, (SNAPSHOT
/100)%100, SNAPSHOT
%100);
1633 return cx8802_register_driver(&cx8802_dvb_driver
);
1636 static void __exit
dvb_fini(void)
1638 cx8802_unregister_driver(&cx8802_dvb_driver
);
1641 module_init(dvb_init
);
1642 module_exit(dvb_fini
);
1647 * compile-command: "make DVB=1"