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) && defined(MODULE))
254 static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend
* fe
)
256 static u8 clock_config
[] = { 0x89, 0x38, 0x38 };
257 static u8 reset
[] = { 0x50, 0x80 };
258 static u8 adc_ctl_1_cfg
[] = { 0x8E, 0x40 };
259 static u8 agc_cfg
[] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
260 0x00, 0xFF, 0x00, 0x40, 0x40 };
261 static u8 dntv_extra
[] = { 0xB5, 0x7A };
262 static u8 capt_range_cfg
[] = { 0x75, 0x32 };
264 mt352_write(fe
, clock_config
, sizeof(clock_config
));
266 mt352_write(fe
, reset
, sizeof(reset
));
267 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
269 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
271 mt352_write(fe
, dntv_extra
, sizeof(dntv_extra
));
272 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
277 static struct mt352_config dntv_live_dvbt_pro_config
= {
278 .demod_address
= 0x0f,
280 .demod_init
= dntv_live_dvbt_pro_demod_init
,
284 static struct zl10353_config dvico_fusionhdtv_hybrid
= {
285 .demod_address
= 0x0f,
289 static struct zl10353_config dvico_fusionhdtv_xc3028
= {
290 .demod_address
= 0x0f,
295 static struct mt352_config dvico_fusionhdtv_mt352_xc3028
= {
296 .demod_address
= 0x0f,
299 .demod_init
= dvico_fusionhdtv_demod_init
,
302 static struct zl10353_config dvico_fusionhdtv_plus_v1_1
= {
303 .demod_address
= 0x0f,
306 static struct cx22702_config connexant_refboard_config
= {
307 .demod_address
= 0x43,
308 .output_mode
= CX22702_SERIAL_OUTPUT
,
311 static struct cx22702_config hauppauge_hvr_config
= {
312 .demod_address
= 0x63,
313 .output_mode
= CX22702_SERIAL_OUTPUT
,
316 static int or51132_set_ts_param(struct dvb_frontend
* fe
, int is_punctured
)
318 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
319 dev
->ts_gen_cntrl
= is_punctured
? 0x04 : 0x00;
323 static struct or51132_config pchdtv_hd3000
= {
324 .demod_address
= 0x15,
325 .set_ts_params
= or51132_set_ts_param
,
328 static int lgdt330x_pll_rf_set(struct dvb_frontend
* fe
, int index
)
330 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
331 struct cx88_core
*core
= dev
->core
;
333 dprintk(1, "%s: index = %d\n", __func__
, index
);
335 cx_clear(MO_GP0_IO
, 8);
337 cx_set(MO_GP0_IO
, 8);
341 static int lgdt330x_set_ts_param(struct dvb_frontend
* fe
, int is_punctured
)
343 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
345 dev
->ts_gen_cntrl
|= 0x04;
347 dev
->ts_gen_cntrl
&= ~0x04;
351 static struct lgdt330x_config fusionhdtv_3_gold
= {
352 .demod_address
= 0x0e,
353 .demod_chip
= LGDT3302
,
354 .serial_mpeg
= 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
355 .set_ts_params
= lgdt330x_set_ts_param
,
358 static struct lgdt330x_config fusionhdtv_5_gold
= {
359 .demod_address
= 0x0e,
360 .demod_chip
= LGDT3303
,
361 .serial_mpeg
= 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
362 .set_ts_params
= lgdt330x_set_ts_param
,
365 static struct lgdt330x_config pchdtv_hd5500
= {
366 .demod_address
= 0x59,
367 .demod_chip
= LGDT3303
,
368 .serial_mpeg
= 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
369 .set_ts_params
= lgdt330x_set_ts_param
,
372 static int nxt200x_set_ts_param(struct dvb_frontend
* fe
, int is_punctured
)
374 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
375 dev
->ts_gen_cntrl
= is_punctured
? 0x04 : 0x00;
379 static struct nxt200x_config ati_hdtvwonder
= {
380 .demod_address
= 0x0a,
381 .set_ts_params
= nxt200x_set_ts_param
,
384 static int cx24123_set_ts_param(struct dvb_frontend
* fe
,
387 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
388 dev
->ts_gen_cntrl
= 0x02;
392 static int kworld_dvbs_100_set_voltage(struct dvb_frontend
* fe
,
393 fe_sec_voltage_t voltage
)
395 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
396 struct cx88_core
*core
= dev
->core
;
398 if (voltage
== SEC_VOLTAGE_OFF
)
399 cx_write(MO_GP0_IO
, 0x000006fb);
401 cx_write(MO_GP0_IO
, 0x000006f9);
403 if (core
->prev_set_voltage
)
404 return core
->prev_set_voltage(fe
, voltage
);
408 static int geniatech_dvbs_set_voltage(struct dvb_frontend
*fe
,
409 fe_sec_voltage_t voltage
)
411 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
412 struct cx88_core
*core
= dev
->core
;
414 if (voltage
== SEC_VOLTAGE_OFF
) {
415 dprintk(1,"LNB Voltage OFF\n");
416 cx_write(MO_GP0_IO
, 0x0000efff);
419 if (core
->prev_set_voltage
)
420 return core
->prev_set_voltage(fe
, voltage
);
424 static int tevii_dvbs_set_voltage(struct dvb_frontend
*fe
,
425 fe_sec_voltage_t voltage
)
427 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
428 struct cx88_core
*core
= dev
->core
;
430 cx_set(MO_GP0_IO
, 0x6040);
433 cx_clear(MO_GP0_IO
, 0x20);
436 cx_set(MO_GP0_IO
, 0x20);
438 case SEC_VOLTAGE_OFF
:
439 cx_clear(MO_GP0_IO
, 0x20);
443 if (core
->prev_set_voltage
)
444 return core
->prev_set_voltage(fe
, voltage
);
448 static struct cx24123_config geniatech_dvbs_config
= {
449 .demod_address
= 0x55,
450 .set_ts_params
= cx24123_set_ts_param
,
453 static struct cx24123_config hauppauge_novas_config
= {
454 .demod_address
= 0x55,
455 .set_ts_params
= cx24123_set_ts_param
,
458 static struct cx24123_config kworld_dvbs_100_config
= {
459 .demod_address
= 0x15,
460 .set_ts_params
= cx24123_set_ts_param
,
464 static struct s5h1409_config pinnacle_pctv_hd_800i_config
= {
465 .demod_address
= 0x32 >> 1,
466 .output_mode
= S5H1409_PARALLEL_OUTPUT
,
467 .gpio
= S5H1409_GPIO_ON
,
469 .inversion
= S5H1409_INVERSION_OFF
,
470 .status_mode
= S5H1409_DEMODLOCKING
,
471 .mpeg_timing
= S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK
,
474 static struct s5h1409_config dvico_hdtv5_pci_nano_config
= {
475 .demod_address
= 0x32 >> 1,
476 .output_mode
= S5H1409_SERIAL_OUTPUT
,
477 .gpio
= S5H1409_GPIO_OFF
,
478 .inversion
= S5H1409_INVERSION_OFF
,
479 .status_mode
= S5H1409_DEMODLOCKING
,
480 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
483 static struct s5h1409_config kworld_atsc_120_config
= {
484 .demod_address
= 0x32 >> 1,
485 .output_mode
= S5H1409_SERIAL_OUTPUT
,
486 .gpio
= S5H1409_GPIO_OFF
,
487 .inversion
= S5H1409_INVERSION_OFF
,
488 .status_mode
= S5H1409_DEMODLOCKING
,
489 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
492 static struct xc5000_config pinnacle_pctv_hd_800i_tuner_config
= {
497 static struct zl10353_config cx88_pinnacle_hybrid_pctv
= {
498 .demod_address
= (0x1e >> 1),
503 static struct zl10353_config cx88_geniatech_x8000_mt
= {
504 .demod_address
= (0x1e >> 1),
506 .disable_i2c_gate_ctrl
= 1,
509 static struct s5h1411_config dvico_fusionhdtv7_config
= {
510 .output_mode
= S5H1411_SERIAL_OUTPUT
,
511 .gpio
= S5H1411_GPIO_ON
,
512 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
513 .qam_if
= S5H1411_IF_44000
,
514 .vsb_if
= S5H1411_IF_44000
,
515 .inversion
= S5H1411_INVERSION_OFF
,
516 .status_mode
= S5H1411_DEMODLOCKING
519 static struct xc5000_config dvico_fusionhdtv7_tuner_config
= {
520 .i2c_address
= 0xc2 >> 1,
524 static int attach_xc3028(u8 addr
, struct cx8802_dev
*dev
)
526 struct dvb_frontend
*fe
;
527 struct videobuf_dvb_frontend
*fe0
= NULL
;
528 struct xc2028_ctrl ctl
;
529 struct xc2028_config cfg
= {
530 .i2c_adap
= &dev
->core
->i2c_adap
,
535 /* Get the first frontend */
536 fe0
= videobuf_dvb_get_frontend(&dev
->frontends
, 1);
540 if (!fe0
->dvb
.frontend
) {
541 printk(KERN_ERR
"%s/2: dvb frontend not attached. "
542 "Can't attach xc3028\n",
548 * Some xc3028 devices may be hidden by an I2C gate. This is known
549 * to happen with some s5h1409-based devices.
550 * Now that I2C gate is open, sets up xc3028 configuration
552 cx88_setup_xc3028(dev
->core
, &ctl
);
554 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
, &cfg
);
556 printk(KERN_ERR
"%s/2: xc3028 attach failed\n",
558 dvb_frontend_detach(fe0
->dvb
.frontend
);
559 dvb_unregister_frontend(fe0
->dvb
.frontend
);
560 fe0
->dvb
.frontend
= NULL
;
564 printk(KERN_INFO
"%s/2: xc3028 attached\n",
570 static int cx24116_set_ts_param(struct dvb_frontend
*fe
,
573 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
574 dev
->ts_gen_cntrl
= 0x2;
579 static int stv0900_set_ts_param(struct dvb_frontend
*fe
,
582 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
583 dev
->ts_gen_cntrl
= 0;
588 static int cx24116_reset_device(struct dvb_frontend
*fe
)
590 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
591 struct cx88_core
*core
= dev
->core
;
594 /* Put the cx24116 into reset */
595 cx_write(MO_SRST_IO
, 0);
597 /* Take the cx24116 out of reset */
598 cx_write(MO_SRST_IO
, 1);
604 static struct cx24116_config hauppauge_hvr4000_config
= {
605 .demod_address
= 0x05,
606 .set_ts_params
= cx24116_set_ts_param
,
607 .reset_device
= cx24116_reset_device
,
610 static struct cx24116_config tevii_s460_config
= {
611 .demod_address
= 0x55,
612 .set_ts_params
= cx24116_set_ts_param
,
613 .reset_device
= cx24116_reset_device
,
616 static struct stv0900_config prof_7301_stv0900_config
= {
617 .demod_address
= 0x6a,
620 .clkmode
= 3,/* 0-CLKI, 2-XTALI, else AUTO */
621 .diseqc_mode
= 2,/* 2/3 PWM */
622 .tun1_maddress
= 0,/* 0x60 */
623 .tun1_adc
= 0,/* 2 Vpp */
625 .set_ts_params
= stv0900_set_ts_param
,
628 static struct stb6100_config prof_7301_stb6100_config
= {
629 .tuner_address
= 0x60,
630 .refclock
= 27000000,
633 static struct stv0299_config tevii_tuner_sharp_config
= {
634 .demod_address
= 0x68,
635 .inittab
= sharp_z0194a_inittab
,
640 .volt13_op0_op1
= STV0299_VOLT13_OP1
,
642 .set_symbol_rate
= sharp_z0194a_set_symbol_rate
,
643 .set_ts_params
= cx24116_set_ts_param
,
646 static struct stv0288_config tevii_tuner_earda_config
= {
647 .demod_address
= 0x68,
649 .set_ts_params
= cx24116_set_ts_param
,
652 static int cx8802_alloc_frontends(struct cx8802_dev
*dev
)
654 struct cx88_core
*core
= dev
->core
;
655 struct videobuf_dvb_frontend
*fe
= NULL
;
658 mutex_init(&dev
->frontends
.lock
);
659 INIT_LIST_HEAD(&dev
->frontends
.felist
);
661 if (!core
->board
.num_frontends
)
664 printk(KERN_INFO
"%s() allocating %d frontend(s)\n", __func__
,
665 core
->board
.num_frontends
);
666 for (i
= 1; i
<= core
->board
.num_frontends
; i
++) {
667 fe
= videobuf_dvb_alloc_frontend(&dev
->frontends
, i
);
669 printk(KERN_ERR
"%s() failed to alloc\n", __func__
);
670 videobuf_dvb_dealloc_frontends(&dev
->frontends
);
679 static u8 samsung_smt_7020_inittab
[] = {
731 static int samsung_smt_7020_tuner_set_params(struct dvb_frontend
*fe
,
732 struct dvb_frontend_parameters
*params
)
734 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
737 struct i2c_msg msg
= {
741 .len
= sizeof(buf
) };
743 div
= params
->frequency
/ 125;
745 buf
[0] = (div
>> 8) & 0x7f;
747 buf
[2] = 0x84; /* 0xC4 */
750 if (params
->frequency
< 1500000)
753 if (fe
->ops
.i2c_gate_ctrl
)
754 fe
->ops
.i2c_gate_ctrl(fe
, 1);
756 if (i2c_transfer(&dev
->core
->i2c_adap
, &msg
, 1) != 1)
762 static int samsung_smt_7020_set_tone(struct dvb_frontend
*fe
,
763 fe_sec_tone_mode_t tone
)
765 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
766 struct cx88_core
*core
= dev
->core
;
768 cx_set(MO_GP0_IO
, 0x0800);
772 cx_set(MO_GP0_IO
, 0x08);
775 cx_clear(MO_GP0_IO
, 0x08);
784 static int samsung_smt_7020_set_voltage(struct dvb_frontend
*fe
,
785 fe_sec_voltage_t voltage
)
787 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
788 struct cx88_core
*core
= dev
->core
;
791 struct i2c_msg msg
= {
795 .len
= sizeof(data
) };
797 cx_set(MO_GP0_IO
, 0x8000);
800 case SEC_VOLTAGE_OFF
:
803 data
= ISL6421_EN1
| ISL6421_LLC1
;
804 cx_clear(MO_GP0_IO
, 0x80);
807 data
= ISL6421_EN1
| ISL6421_LLC1
| ISL6421_VSEL1
;
808 cx_clear(MO_GP0_IO
, 0x80);
814 return (i2c_transfer(&dev
->core
->i2c_adap
, &msg
, 1) == 1) ? 0 : -EIO
;
817 static int samsung_smt_7020_stv0299_set_symbol_rate(struct dvb_frontend
*fe
,
818 u32 srate
, u32 ratio
)
823 if (srate
< 1500000) {
826 } else if (srate
< 3000000) {
829 } else if (srate
< 7000000) {
832 } else if (srate
< 14000000) {
835 } else if (srate
< 30000000) {
838 } else if (srate
< 45000000) {
843 stv0299_writereg(fe
, 0x13, aclk
);
844 stv0299_writereg(fe
, 0x14, bclk
);
845 stv0299_writereg(fe
, 0x1f, (ratio
>> 16) & 0xff);
846 stv0299_writereg(fe
, 0x20, (ratio
>> 8) & 0xff);
847 stv0299_writereg(fe
, 0x21, ratio
& 0xf0);
853 static struct stv0299_config samsung_stv0299_config
= {
854 .demod_address
= 0x68,
855 .inittab
= samsung_smt_7020_inittab
,
859 .lock_output
= STV0299_LOCKOUTPUT_LK
,
860 .volt13_op0_op1
= STV0299_VOLT13_OP1
,
862 .set_symbol_rate
= samsung_smt_7020_stv0299_set_symbol_rate
,
865 static int dvb_register(struct cx8802_dev
*dev
)
867 struct cx88_core
*core
= dev
->core
;
868 struct videobuf_dvb_frontend
*fe0
, *fe1
= NULL
;
869 int mfe_shared
= 0; /* bus not shared by default */
871 if (0 != core
->i2c_rc
) {
872 printk(KERN_ERR
"%s/2: no i2c-bus available, cannot attach dvb drivers\n", core
->name
);
873 goto frontend_detach
;
876 /* Get the first frontend */
877 fe0
= videobuf_dvb_get_frontend(&dev
->frontends
, 1);
879 goto frontend_detach
;
881 /* multi-frontend gate control is undefined or defaults to fe0 */
882 dev
->frontends
.gate
= 0;
884 /* Sets the gate control callback to be used by i2c command calls */
885 core
->gate_ctrl
= cx88_dvb_gate_ctrl
;
887 /* init frontend(s) */
888 switch (core
->boardnr
) {
889 case CX88_BOARD_HAUPPAUGE_DVB_T1
:
890 fe0
->dvb
.frontend
= dvb_attach(cx22702_attach
,
891 &connexant_refboard_config
,
893 if (fe0
->dvb
.frontend
!= NULL
) {
894 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
895 0x61, &core
->i2c_adap
,
896 DVB_PLL_THOMSON_DTT759X
))
897 goto frontend_detach
;
900 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1
:
901 case CX88_BOARD_CONEXANT_DVB_T1
:
902 case CX88_BOARD_KWORLD_DVB_T_CX22702
:
903 case CX88_BOARD_WINFAST_DTV1000
:
904 fe0
->dvb
.frontend
= dvb_attach(cx22702_attach
,
905 &connexant_refboard_config
,
907 if (fe0
->dvb
.frontend
!= NULL
) {
908 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
909 0x60, &core
->i2c_adap
,
910 DVB_PLL_THOMSON_DTT7579
))
911 goto frontend_detach
;
914 case CX88_BOARD_WINFAST_DTV2000H
:
915 case CX88_BOARD_WINFAST_DTV2000H_J
:
916 case CX88_BOARD_HAUPPAUGE_HVR1100
:
917 case CX88_BOARD_HAUPPAUGE_HVR1100LP
:
918 case CX88_BOARD_HAUPPAUGE_HVR1300
:
919 fe0
->dvb
.frontend
= dvb_attach(cx22702_attach
,
920 &hauppauge_hvr_config
,
922 if (fe0
->dvb
.frontend
!= NULL
) {
923 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
924 &core
->i2c_adap
, 0x61,
925 TUNER_PHILIPS_FMD1216ME_MK3
))
926 goto frontend_detach
;
929 case CX88_BOARD_HAUPPAUGE_HVR3000
:
932 dev
->frontends
.gate
= 2;
934 fe0
->dvb
.frontend
= dvb_attach(cx24123_attach
,
935 &hauppauge_novas_config
,
936 &dev
->core
->i2c_adap
);
937 if (fe0
->dvb
.frontend
) {
938 if (!dvb_attach(isl6421_attach
,
940 &dev
->core
->i2c_adap
,
941 0x08, ISL6421_DCL
, 0x00))
942 goto frontend_detach
;
945 fe1
= videobuf_dvb_get_frontend(&dev
->frontends
, 2);
947 goto frontend_detach
;
949 fe1
->dvb
.frontend
= dvb_attach(cx22702_attach
,
950 &hauppauge_hvr_config
,
951 &dev
->core
->i2c_adap
);
952 if (fe1
->dvb
.frontend
) {
953 fe1
->dvb
.frontend
->id
= 1;
954 if (!dvb_attach(simple_tuner_attach
,
956 &dev
->core
->i2c_adap
,
957 0x61, TUNER_PHILIPS_FMD1216ME_MK3
))
958 goto frontend_detach
;
961 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS
:
962 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
965 if (fe0
->dvb
.frontend
!= NULL
) {
966 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
967 0x60, NULL
, DVB_PLL_THOMSON_DTT7579
))
968 goto frontend_detach
;
971 /* ZL10353 replaces MT352 on later cards */
972 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
973 &dvico_fusionhdtv_plus_v1_1
,
975 if (fe0
->dvb
.frontend
!= NULL
) {
976 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
977 0x60, NULL
, DVB_PLL_THOMSON_DTT7579
))
978 goto frontend_detach
;
981 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL
:
982 /* The tin box says DEE1601, but it seems to be DTT7579
983 * compatible, with a slightly different MT352 AGC gain. */
984 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
985 &dvico_fusionhdtv_dual
,
987 if (fe0
->dvb
.frontend
!= NULL
) {
988 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
989 0x61, NULL
, DVB_PLL_THOMSON_DTT7579
))
990 goto frontend_detach
;
993 /* ZL10353 replaces MT352 on later cards */
994 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
995 &dvico_fusionhdtv_plus_v1_1
,
997 if (fe0
->dvb
.frontend
!= NULL
) {
998 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
999 0x61, NULL
, DVB_PLL_THOMSON_DTT7579
))
1000 goto frontend_detach
;
1003 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1
:
1004 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1007 if (fe0
->dvb
.frontend
!= NULL
) {
1008 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
1009 0x61, NULL
, DVB_PLL_LG_Z201
))
1010 goto frontend_detach
;
1013 case CX88_BOARD_KWORLD_DVB_T
:
1014 case CX88_BOARD_DNTV_LIVE_DVB_T
:
1015 case CX88_BOARD_ADSTECH_DVB_T_PCI
:
1016 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1017 &dntv_live_dvbt_config
,
1019 if (fe0
->dvb
.frontend
!= NULL
) {
1020 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
1021 0x61, NULL
, DVB_PLL_UNKNOWN_1
))
1022 goto frontend_detach
;
1025 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO
:
1026 #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
1027 /* MT352 is on a secondary I2C bus made from some GPIO lines */
1028 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
, &dntv_live_dvbt_pro_config
,
1029 &dev
->vp3054
->adap
);
1030 if (fe0
->dvb
.frontend
!= NULL
) {
1031 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1032 &core
->i2c_adap
, 0x61,
1033 TUNER_PHILIPS_FMD1216ME_MK3
))
1034 goto frontend_detach
;
1037 printk(KERN_ERR
"%s/2: built without vp3054 support\n",
1041 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID
:
1042 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1043 &dvico_fusionhdtv_hybrid
,
1045 if (fe0
->dvb
.frontend
!= NULL
) {
1046 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1047 &core
->i2c_adap
, 0x61,
1048 TUNER_THOMSON_FE6600
))
1049 goto frontend_detach
;
1052 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO
:
1053 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1054 &dvico_fusionhdtv_xc3028
,
1056 if (fe0
->dvb
.frontend
== NULL
)
1057 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1058 &dvico_fusionhdtv_mt352_xc3028
,
1061 * On this board, the demod provides the I2C bus pullup.
1062 * We must not permit gate_ctrl to be performed, or
1063 * the xc3028 cannot communicate on the bus.
1065 if (fe0
->dvb
.frontend
)
1066 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= NULL
;
1067 if (attach_xc3028(0x61, dev
) < 0)
1068 goto frontend_detach
;
1070 case CX88_BOARD_PCHDTV_HD3000
:
1071 fe0
->dvb
.frontend
= dvb_attach(or51132_attach
, &pchdtv_hd3000
,
1073 if (fe0
->dvb
.frontend
!= NULL
) {
1074 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1075 &core
->i2c_adap
, 0x61,
1076 TUNER_THOMSON_DTT761X
))
1077 goto frontend_detach
;
1080 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q
:
1081 dev
->ts_gen_cntrl
= 0x08;
1083 /* Do a hardware reset of chip before using it. */
1084 cx_clear(MO_GP0_IO
, 1);
1086 cx_set(MO_GP0_IO
, 1);
1089 /* Select RF connector callback */
1090 fusionhdtv_3_gold
.pll_rf_set
= lgdt330x_pll_rf_set
;
1091 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
1094 if (fe0
->dvb
.frontend
!= NULL
) {
1095 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1096 &core
->i2c_adap
, 0x61,
1097 TUNER_MICROTUNE_4042FI5
))
1098 goto frontend_detach
;
1101 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T
:
1102 dev
->ts_gen_cntrl
= 0x08;
1104 /* Do a hardware reset of chip before using it. */
1105 cx_clear(MO_GP0_IO
, 1);
1107 cx_set(MO_GP0_IO
, 9);
1109 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
1112 if (fe0
->dvb
.frontend
!= NULL
) {
1113 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1114 &core
->i2c_adap
, 0x61,
1115 TUNER_THOMSON_DTT761X
))
1116 goto frontend_detach
;
1119 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD
:
1120 dev
->ts_gen_cntrl
= 0x08;
1122 /* Do a hardware reset of chip before using it. */
1123 cx_clear(MO_GP0_IO
, 1);
1125 cx_set(MO_GP0_IO
, 1);
1127 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
1130 if (fe0
->dvb
.frontend
!= NULL
) {
1131 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1132 &core
->i2c_adap
, 0x61,
1133 TUNER_LG_TDVS_H06XF
))
1134 goto frontend_detach
;
1135 if (!dvb_attach(tda9887_attach
, fe0
->dvb
.frontend
,
1136 &core
->i2c_adap
, 0x43))
1137 goto frontend_detach
;
1140 case CX88_BOARD_PCHDTV_HD5500
:
1141 dev
->ts_gen_cntrl
= 0x08;
1143 /* Do a hardware reset of chip before using it. */
1144 cx_clear(MO_GP0_IO
, 1);
1146 cx_set(MO_GP0_IO
, 1);
1148 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
1151 if (fe0
->dvb
.frontend
!= NULL
) {
1152 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1153 &core
->i2c_adap
, 0x61,
1154 TUNER_LG_TDVS_H06XF
))
1155 goto frontend_detach
;
1156 if (!dvb_attach(tda9887_attach
, fe0
->dvb
.frontend
,
1157 &core
->i2c_adap
, 0x43))
1158 goto frontend_detach
;
1161 case CX88_BOARD_ATI_HDTVWONDER
:
1162 fe0
->dvb
.frontend
= dvb_attach(nxt200x_attach
,
1165 if (fe0
->dvb
.frontend
!= NULL
) {
1166 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1167 &core
->i2c_adap
, 0x61,
1168 TUNER_PHILIPS_TUV1236D
))
1169 goto frontend_detach
;
1172 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1
:
1173 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1
:
1174 fe0
->dvb
.frontend
= dvb_attach(cx24123_attach
,
1175 &hauppauge_novas_config
,
1177 if (fe0
->dvb
.frontend
) {
1178 if (!dvb_attach(isl6421_attach
, fe0
->dvb
.frontend
,
1179 &core
->i2c_adap
, 0x08, ISL6421_DCL
, 0x00))
1180 goto frontend_detach
;
1183 case CX88_BOARD_KWORLD_DVBS_100
:
1184 fe0
->dvb
.frontend
= dvb_attach(cx24123_attach
,
1185 &kworld_dvbs_100_config
,
1187 if (fe0
->dvb
.frontend
) {
1188 core
->prev_set_voltage
= fe0
->dvb
.frontend
->ops
.set_voltage
;
1189 fe0
->dvb
.frontend
->ops
.set_voltage
= kworld_dvbs_100_set_voltage
;
1192 case CX88_BOARD_GENIATECH_DVBS
:
1193 fe0
->dvb
.frontend
= dvb_attach(cx24123_attach
,
1194 &geniatech_dvbs_config
,
1196 if (fe0
->dvb
.frontend
) {
1197 core
->prev_set_voltage
= fe0
->dvb
.frontend
->ops
.set_voltage
;
1198 fe0
->dvb
.frontend
->ops
.set_voltage
= geniatech_dvbs_set_voltage
;
1201 case CX88_BOARD_PINNACLE_PCTV_HD_800i
:
1202 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1203 &pinnacle_pctv_hd_800i_config
,
1205 if (fe0
->dvb
.frontend
!= NULL
) {
1206 if (!dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1208 &pinnacle_pctv_hd_800i_tuner_config
))
1209 goto frontend_detach
;
1212 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO
:
1213 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1214 &dvico_hdtv5_pci_nano_config
,
1216 if (fe0
->dvb
.frontend
!= NULL
) {
1217 struct dvb_frontend
*fe
;
1218 struct xc2028_config cfg
= {
1219 .i2c_adap
= &core
->i2c_adap
,
1222 static struct xc2028_ctrl ctl
= {
1223 .fname
= XC2028_DEFAULT_FIRMWARE
,
1225 .scode_table
= XC3028_FE_OREN538
,
1228 fe
= dvb_attach(xc2028_attach
,
1229 fe0
->dvb
.frontend
, &cfg
);
1230 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1231 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1234 case CX88_BOARD_PINNACLE_HYBRID_PCTV
:
1235 case CX88_BOARD_WINFAST_DTV1800H
:
1236 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1237 &cx88_pinnacle_hybrid_pctv
,
1239 if (fe0
->dvb
.frontend
) {
1240 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= NULL
;
1241 if (attach_xc3028(0x61, dev
) < 0)
1242 goto frontend_detach
;
1245 case CX88_BOARD_GENIATECH_X8000_MT
:
1246 dev
->ts_gen_cntrl
= 0x00;
1248 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1249 &cx88_geniatech_x8000_mt
,
1251 if (attach_xc3028(0x61, dev
) < 0)
1252 goto frontend_detach
;
1254 case CX88_BOARD_KWORLD_ATSC_120
:
1255 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1256 &kworld_atsc_120_config
,
1258 if (attach_xc3028(0x61, dev
) < 0)
1259 goto frontend_detach
;
1261 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD
:
1262 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1263 &dvico_fusionhdtv7_config
,
1265 if (fe0
->dvb
.frontend
!= NULL
) {
1266 if (!dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1268 &dvico_fusionhdtv7_tuner_config
))
1269 goto frontend_detach
;
1272 case CX88_BOARD_HAUPPAUGE_HVR4000
:
1273 /* MFE frontend 1 */
1275 dev
->frontends
.gate
= 2;
1277 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1278 &hauppauge_hvr4000_config
,
1279 &dev
->core
->i2c_adap
);
1280 if (fe0
->dvb
.frontend
) {
1281 if (!dvb_attach(isl6421_attach
,
1283 &dev
->core
->i2c_adap
,
1284 0x08, ISL6421_DCL
, 0x00))
1285 goto frontend_detach
;
1287 /* MFE frontend 2 */
1288 fe1
= videobuf_dvb_get_frontend(&dev
->frontends
, 2);
1290 goto frontend_detach
;
1292 fe1
->dvb
.frontend
= dvb_attach(cx22702_attach
,
1293 &hauppauge_hvr_config
,
1294 &dev
->core
->i2c_adap
);
1295 if (fe1
->dvb
.frontend
) {
1296 fe1
->dvb
.frontend
->id
= 1;
1297 if (!dvb_attach(simple_tuner_attach
,
1299 &dev
->core
->i2c_adap
,
1300 0x61, TUNER_PHILIPS_FMD1216ME_MK3
))
1301 goto frontend_detach
;
1304 case CX88_BOARD_HAUPPAUGE_HVR4000LITE
:
1305 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1306 &hauppauge_hvr4000_config
,
1307 &dev
->core
->i2c_adap
);
1308 if (fe0
->dvb
.frontend
) {
1309 if (!dvb_attach(isl6421_attach
,
1311 &dev
->core
->i2c_adap
,
1312 0x08, ISL6421_DCL
, 0x00))
1313 goto frontend_detach
;
1316 case CX88_BOARD_PROF_6200
:
1317 case CX88_BOARD_TBS_8910
:
1318 case CX88_BOARD_TEVII_S420
:
1319 fe0
->dvb
.frontend
= dvb_attach(stv0299_attach
,
1320 &tevii_tuner_sharp_config
,
1322 if (fe0
->dvb
.frontend
!= NULL
) {
1323 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
, 0x60,
1324 &core
->i2c_adap
, DVB_PLL_OPERA1
))
1325 goto frontend_detach
;
1326 core
->prev_set_voltage
= fe0
->dvb
.frontend
->ops
.set_voltage
;
1327 fe0
->dvb
.frontend
->ops
.set_voltage
= tevii_dvbs_set_voltage
;
1330 fe0
->dvb
.frontend
= dvb_attach(stv0288_attach
,
1331 &tevii_tuner_earda_config
,
1333 if (fe0
->dvb
.frontend
!= NULL
) {
1334 if (!dvb_attach(stb6000_attach
, fe0
->dvb
.frontend
, 0x61,
1336 goto frontend_detach
;
1337 core
->prev_set_voltage
= fe0
->dvb
.frontend
->ops
.set_voltage
;
1338 fe0
->dvb
.frontend
->ops
.set_voltage
= tevii_dvbs_set_voltage
;
1342 case CX88_BOARD_TEVII_S460
:
1343 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1346 if (fe0
->dvb
.frontend
!= NULL
)
1347 fe0
->dvb
.frontend
->ops
.set_voltage
= tevii_dvbs_set_voltage
;
1349 case CX88_BOARD_OMICOM_SS4_PCI
:
1350 case CX88_BOARD_TBS_8920
:
1351 case CX88_BOARD_PROF_7300
:
1352 case CX88_BOARD_SATTRADE_ST4200
:
1353 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1354 &hauppauge_hvr4000_config
,
1356 if (fe0
->dvb
.frontend
!= NULL
)
1357 fe0
->dvb
.frontend
->ops
.set_voltage
= tevii_dvbs_set_voltage
;
1359 case CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII
:
1360 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1361 &cx88_terratec_cinergy_ht_pci_mkii_config
,
1363 if (fe0
->dvb
.frontend
) {
1364 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= NULL
;
1365 if (attach_xc3028(0x61, dev
) < 0)
1366 goto frontend_detach
;
1369 case CX88_BOARD_PROF_7301
:{
1370 struct dvb_tuner_ops
*tuner_ops
= NULL
;
1372 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
1373 &prof_7301_stv0900_config
,
1374 &core
->i2c_adap
, 0);
1375 if (fe0
->dvb
.frontend
!= NULL
) {
1376 if (!dvb_attach(stb6100_attach
, fe0
->dvb
.frontend
,
1377 &prof_7301_stb6100_config
,
1379 goto frontend_detach
;
1381 tuner_ops
= &fe0
->dvb
.frontend
->ops
.tuner_ops
;
1382 tuner_ops
->set_frequency
= stb6100_set_freq
;
1383 tuner_ops
->get_frequency
= stb6100_get_freq
;
1384 tuner_ops
->set_bandwidth
= stb6100_set_bandw
;
1385 tuner_ops
->get_bandwidth
= stb6100_get_bandw
;
1387 core
->prev_set_voltage
=
1388 fe0
->dvb
.frontend
->ops
.set_voltage
;
1389 fe0
->dvb
.frontend
->ops
.set_voltage
=
1390 tevii_dvbs_set_voltage
;
1394 case CX88_BOARD_SAMSUNG_SMT_7020
:
1395 dev
->ts_gen_cntrl
= 0x08;
1397 cx_set(MO_GP0_IO
, 0x0101);
1399 cx_clear(MO_GP0_IO
, 0x01);
1401 cx_set(MO_GP0_IO
, 0x01);
1404 fe0
->dvb
.frontend
= dvb_attach(stv0299_attach
,
1405 &samsung_stv0299_config
,
1406 &dev
->core
->i2c_adap
);
1407 if (fe0
->dvb
.frontend
) {
1408 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
=
1409 samsung_smt_7020_tuner_set_params
;
1410 fe0
->dvb
.frontend
->tuner_priv
=
1411 &dev
->core
->i2c_adap
;
1412 fe0
->dvb
.frontend
->ops
.set_voltage
=
1413 samsung_smt_7020_set_voltage
;
1414 fe0
->dvb
.frontend
->ops
.set_tone
=
1415 samsung_smt_7020_set_tone
;
1421 printk(KERN_ERR
"%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
1426 if ( (NULL
== fe0
->dvb
.frontend
) || (fe1
&& NULL
== fe1
->dvb
.frontend
) ) {
1428 "%s/2: frontend initialization failed\n",
1430 goto frontend_detach
;
1432 /* define general-purpose callback pointer */
1433 fe0
->dvb
.frontend
->callback
= cx88_tuner_callback
;
1435 /* Ensure all frontends negotiate bus access */
1436 fe0
->dvb
.frontend
->ops
.ts_bus_ctrl
= cx88_dvb_bus_ctrl
;
1438 fe1
->dvb
.frontend
->ops
.ts_bus_ctrl
= cx88_dvb_bus_ctrl
;
1440 /* Put the analog decoder in standby to keep it quiet */
1441 call_all(core
, core
, s_power
, 0);
1443 /* register everything */
1444 return videobuf_dvb_register_bus(&dev
->frontends
, THIS_MODULE
, dev
,
1445 &dev
->pci
->dev
, adapter_nr
, mfe_shared
, NULL
);
1448 core
->gate_ctrl
= NULL
;
1449 videobuf_dvb_dealloc_frontends(&dev
->frontends
);
1453 /* ----------------------------------------------------------- */
1455 /* CX8802 MPEG -> mini driver - We have been given the hardware */
1456 static int cx8802_dvb_advise_acquire(struct cx8802_driver
*drv
)
1458 struct cx88_core
*core
= drv
->core
;
1460 dprintk( 1, "%s\n", __func__
);
1462 switch (core
->boardnr
) {
1463 case CX88_BOARD_HAUPPAUGE_HVR1300
:
1464 /* We arrive here with either the cx23416 or the cx22702
1465 * on the bus. Take the bus from the cx23416 and enable the
1468 /* Toggle reset on cx22702 leaving i2c active */
1469 cx_set(MO_GP0_IO
, 0x00000080);
1471 cx_clear(MO_GP0_IO
, 0x00000080);
1473 cx_set(MO_GP0_IO
, 0x00000080);
1475 /* enable the cx22702 pins */
1476 cx_clear(MO_GP0_IO
, 0x00000004);
1480 case CX88_BOARD_HAUPPAUGE_HVR3000
:
1481 case CX88_BOARD_HAUPPAUGE_HVR4000
:
1482 /* Toggle reset on cx22702 leaving i2c active */
1483 cx_set(MO_GP0_IO
, 0x00000080);
1485 cx_clear(MO_GP0_IO
, 0x00000080);
1487 cx_set(MO_GP0_IO
, 0x00000080);
1489 switch (core
->dvbdev
->frontends
.active_fe_id
) {
1490 case 1: /* DVB-S/S2 Enabled */
1491 /* tri-state the cx22702 pins */
1492 cx_set(MO_GP0_IO
, 0x00000004);
1493 /* Take the cx24116/cx24123 out of reset */
1494 cx_write(MO_SRST_IO
, 1);
1495 core
->dvbdev
->ts_gen_cntrl
= 0x02; /* Parallel IO */
1497 case 2: /* DVB-T Enabled */
1498 /* Put the cx24116/cx24123 into reset */
1499 cx_write(MO_SRST_IO
, 0);
1500 /* enable the cx22702 pins */
1501 cx_clear(MO_GP0_IO
, 0x00000004);
1502 core
->dvbdev
->ts_gen_cntrl
= 0x0c; /* Serial IO */
1514 /* CX8802 MPEG -> mini driver - We no longer have the hardware */
1515 static int cx8802_dvb_advise_release(struct cx8802_driver
*drv
)
1517 struct cx88_core
*core
= drv
->core
;
1519 dprintk( 1, "%s\n", __func__
);
1521 switch (core
->boardnr
) {
1522 case CX88_BOARD_HAUPPAUGE_HVR1300
:
1523 /* Do Nothing, leave the cx22702 on the bus. */
1525 case CX88_BOARD_HAUPPAUGE_HVR3000
:
1526 case CX88_BOARD_HAUPPAUGE_HVR4000
:
1534 static int cx8802_dvb_probe(struct cx8802_driver
*drv
)
1536 struct cx88_core
*core
= drv
->core
;
1537 struct cx8802_dev
*dev
= drv
->core
->dvbdev
;
1539 struct videobuf_dvb_frontend
*fe
;
1542 dprintk( 1, "%s\n", __func__
);
1543 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
1550 if (!(core
->board
.mpeg
& CX88_MPEG_DVB
))
1553 /* If vp3054 isn't enabled, a stub will just return 0 */
1554 err
= vp3054_i2c_probe(dev
);
1559 printk(KERN_INFO
"%s/2: cx2388x based DVB/ATSC card\n", core
->name
);
1560 dev
->ts_gen_cntrl
= 0x0c;
1562 err
= cx8802_alloc_frontends(dev
);
1567 for (i
= 1; i
<= core
->board
.num_frontends
; i
++) {
1568 fe
= videobuf_dvb_get_frontend(&core
->dvbdev
->frontends
, i
);
1570 printk(KERN_ERR
"%s() failed to get frontend(%d)\n",
1574 videobuf_queue_sg_init(&fe
->dvb
.dvbq
, &dvb_qops
,
1575 &dev
->pci
->dev
, &dev
->slock
,
1576 V4L2_BUF_TYPE_VIDEO_CAPTURE
,
1578 sizeof(struct cx88_buffer
),
1580 /* init struct videobuf_dvb */
1581 fe
->dvb
.name
= dev
->core
->name
;
1584 err
= dvb_register(dev
);
1586 /* frontends/adapter de-allocated in dvb_register */
1587 printk(KERN_ERR
"%s/2: dvb_register failed (err = %d)\n",
1591 videobuf_dvb_dealloc_frontends(&core
->dvbdev
->frontends
);
1596 static int cx8802_dvb_remove(struct cx8802_driver
*drv
)
1598 struct cx88_core
*core
= drv
->core
;
1599 struct cx8802_dev
*dev
= drv
->core
->dvbdev
;
1601 dprintk( 1, "%s\n", __func__
);
1603 videobuf_dvb_unregister_bus(&dev
->frontends
);
1605 vp3054_i2c_remove(dev
);
1607 core
->gate_ctrl
= NULL
;
1612 static struct cx8802_driver cx8802_dvb_driver
= {
1613 .type_id
= CX88_MPEG_DVB
,
1614 .hw_access
= CX8802_DRVCTL_SHARED
,
1615 .probe
= cx8802_dvb_probe
,
1616 .remove
= cx8802_dvb_remove
,
1617 .advise_acquire
= cx8802_dvb_advise_acquire
,
1618 .advise_release
= cx8802_dvb_advise_release
,
1621 static int __init
dvb_init(void)
1623 printk(KERN_INFO
"cx88/2: cx2388x dvb driver version %d.%d.%d loaded\n",
1624 (CX88_VERSION_CODE
>> 16) & 0xff,
1625 (CX88_VERSION_CODE
>> 8) & 0xff,
1626 CX88_VERSION_CODE
& 0xff);
1628 printk(KERN_INFO
"cx2388x: snapshot date %04d-%02d-%02d\n",
1629 SNAPSHOT
/10000, (SNAPSHOT
/100)%100, SNAPSHOT
%100);
1631 return cx8802_register_driver(&cx8802_dvb_driver
);
1634 static void __exit
dvb_fini(void)
1636 cx8802_unregister_driver(&cx8802_dvb_driver
);
1639 module_init(dvb_init
);
1640 module_exit(dvb_fini
);
1645 * compile-command: "make DVB=1"