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"
49 #include "tuner-simple.h"
59 #include "stb6100_proc.h"
64 MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
65 MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
66 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
67 MODULE_LICENSE("GPL");
68 MODULE_VERSION(CX88_VERSION
);
70 static unsigned int debug
;
71 module_param(debug
, int, 0644);
72 MODULE_PARM_DESC(debug
,"enable debug messages [dvb]");
74 static unsigned int dvb_buf_tscnt
= 32;
75 module_param(dvb_buf_tscnt
, int, 0644);
76 MODULE_PARM_DESC(dvb_buf_tscnt
, "DVB Buffer TS count [dvb]");
78 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
80 #define dprintk(level,fmt, arg...) if (debug >= level) \
81 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
83 /* ------------------------------------------------------------------ */
85 static int dvb_buf_setup(struct videobuf_queue
*q
,
86 unsigned int *count
, unsigned int *size
)
88 struct cx8802_dev
*dev
= q
->priv_data
;
90 dev
->ts_packet_size
= 188 * 4;
91 dev
->ts_packet_count
= dvb_buf_tscnt
;
93 *size
= dev
->ts_packet_size
* dev
->ts_packet_count
;
94 *count
= dvb_buf_tscnt
;
98 static int dvb_buf_prepare(struct videobuf_queue
*q
,
99 struct videobuf_buffer
*vb
, enum v4l2_field field
)
101 struct cx8802_dev
*dev
= q
->priv_data
;
102 return cx8802_buf_prepare(q
, dev
, (struct cx88_buffer
*)vb
,field
);
105 static void dvb_buf_queue(struct videobuf_queue
*q
, struct videobuf_buffer
*vb
)
107 struct cx8802_dev
*dev
= q
->priv_data
;
108 cx8802_buf_queue(dev
, (struct cx88_buffer
*)vb
);
111 static void dvb_buf_release(struct videobuf_queue
*q
,
112 struct videobuf_buffer
*vb
)
114 cx88_free_buffer(q
, (struct cx88_buffer
*)vb
);
117 static const struct videobuf_queue_ops dvb_qops
= {
118 .buf_setup
= dvb_buf_setup
,
119 .buf_prepare
= dvb_buf_prepare
,
120 .buf_queue
= dvb_buf_queue
,
121 .buf_release
= dvb_buf_release
,
124 /* ------------------------------------------------------------------ */
126 static int cx88_dvb_bus_ctrl(struct dvb_frontend
* fe
, int acquire
)
128 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
129 struct cx8802_driver
*drv
= NULL
;
133 fe_id
= videobuf_dvb_find_frontend(&dev
->frontends
, fe
);
135 printk(KERN_ERR
"%s() No frontend found\n", __func__
);
139 mutex_lock(&dev
->core
->lock
);
140 drv
= cx8802_get_driver(dev
, CX88_MPEG_DVB
);
143 dev
->frontends
.active_fe_id
= fe_id
;
144 ret
= drv
->request_acquire(drv
);
146 ret
= drv
->request_release(drv
);
147 dev
->frontends
.active_fe_id
= 0;
150 mutex_unlock(&dev
->core
->lock
);
155 static void cx88_dvb_gate_ctrl(struct cx88_core
*core
, int open
)
157 struct videobuf_dvb_frontends
*f
;
158 struct videobuf_dvb_frontend
*fe
;
163 f
= &core
->dvbdev
->frontends
;
168 if (f
->gate
<= 1) /* undefined or fe0 */
169 fe
= videobuf_dvb_get_frontend(f
, 1);
171 fe
= videobuf_dvb_get_frontend(f
, f
->gate
);
173 if (fe
&& fe
->dvb
.frontend
&& fe
->dvb
.frontend
->ops
.i2c_gate_ctrl
)
174 fe
->dvb
.frontend
->ops
.i2c_gate_ctrl(fe
->dvb
.frontend
, open
);
177 /* ------------------------------------------------------------------ */
179 static int dvico_fusionhdtv_demod_init(struct dvb_frontend
* fe
)
181 static const u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x39 };
182 static const u8 reset
[] = { RESET
, 0x80 };
183 static const u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
184 static const u8 agc_cfg
[] = { AGC_TARGET
, 0x24, 0x20 };
185 static const u8 gpp_ctl_cfg
[] = { GPP_CTL
, 0x33 };
186 static const u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x32 };
188 mt352_write(fe
, clock_config
, sizeof(clock_config
));
190 mt352_write(fe
, reset
, sizeof(reset
));
191 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
193 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
194 mt352_write(fe
, gpp_ctl_cfg
, sizeof(gpp_ctl_cfg
));
195 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
199 static int dvico_dual_demod_init(struct dvb_frontend
*fe
)
201 static const u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x38 };
202 static const u8 reset
[] = { RESET
, 0x80 };
203 static const u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
204 static const u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0x20 };
205 static const u8 gpp_ctl_cfg
[] = { GPP_CTL
, 0x33 };
206 static const u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x32 };
208 mt352_write(fe
, clock_config
, sizeof(clock_config
));
210 mt352_write(fe
, reset
, sizeof(reset
));
211 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
213 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
214 mt352_write(fe
, gpp_ctl_cfg
, sizeof(gpp_ctl_cfg
));
215 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
220 static int dntv_live_dvbt_demod_init(struct dvb_frontend
* fe
)
222 static const u8 clock_config
[] = { 0x89, 0x38, 0x39 };
223 static const u8 reset
[] = { 0x50, 0x80 };
224 static const u8 adc_ctl_1_cfg
[] = { 0x8E, 0x40 };
225 static const u8 agc_cfg
[] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
226 0x00, 0xFF, 0x00, 0x40, 0x40 };
227 static const u8 dntv_extra
[] = { 0xB5, 0x7A };
228 static const u8 capt_range_cfg
[] = { 0x75, 0x32 };
230 mt352_write(fe
, clock_config
, sizeof(clock_config
));
232 mt352_write(fe
, reset
, sizeof(reset
));
233 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
235 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
237 mt352_write(fe
, dntv_extra
, sizeof(dntv_extra
));
238 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
243 static const struct mt352_config dvico_fusionhdtv
= {
244 .demod_address
= 0x0f,
245 .demod_init
= dvico_fusionhdtv_demod_init
,
248 static const struct mt352_config dntv_live_dvbt_config
= {
249 .demod_address
= 0x0f,
250 .demod_init
= dntv_live_dvbt_demod_init
,
253 static const struct mt352_config dvico_fusionhdtv_dual
= {
254 .demod_address
= 0x0f,
255 .demod_init
= dvico_dual_demod_init
,
258 static const struct zl10353_config cx88_terratec_cinergy_ht_pci_mkii_config
= {
259 .demod_address
= (0x1e >> 1),
264 static struct mb86a16_config twinhan_vp1027
= {
265 .demod_address
= 0x08,
268 #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
269 static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend
* fe
)
271 static const u8 clock_config
[] = { 0x89, 0x38, 0x38 };
272 static const u8 reset
[] = { 0x50, 0x80 };
273 static const u8 adc_ctl_1_cfg
[] = { 0x8E, 0x40 };
274 static const u8 agc_cfg
[] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
275 0x00, 0xFF, 0x00, 0x40, 0x40 };
276 static const u8 dntv_extra
[] = { 0xB5, 0x7A };
277 static const u8 capt_range_cfg
[] = { 0x75, 0x32 };
279 mt352_write(fe
, clock_config
, sizeof(clock_config
));
281 mt352_write(fe
, reset
, sizeof(reset
));
282 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
284 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
286 mt352_write(fe
, dntv_extra
, sizeof(dntv_extra
));
287 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
292 static const struct mt352_config dntv_live_dvbt_pro_config
= {
293 .demod_address
= 0x0f,
295 .demod_init
= dntv_live_dvbt_pro_demod_init
,
299 static const struct zl10353_config dvico_fusionhdtv_hybrid
= {
300 .demod_address
= 0x0f,
304 static const struct zl10353_config dvico_fusionhdtv_xc3028
= {
305 .demod_address
= 0x0f,
310 static const struct mt352_config dvico_fusionhdtv_mt352_xc3028
= {
311 .demod_address
= 0x0f,
314 .demod_init
= dvico_fusionhdtv_demod_init
,
317 static const struct zl10353_config dvico_fusionhdtv_plus_v1_1
= {
318 .demod_address
= 0x0f,
321 static const struct cx22702_config connexant_refboard_config
= {
322 .demod_address
= 0x43,
323 .output_mode
= CX22702_SERIAL_OUTPUT
,
326 static const struct cx22702_config hauppauge_hvr_config
= {
327 .demod_address
= 0x63,
328 .output_mode
= CX22702_SERIAL_OUTPUT
,
331 static int or51132_set_ts_param(struct dvb_frontend
* fe
, int is_punctured
)
333 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
334 dev
->ts_gen_cntrl
= is_punctured
? 0x04 : 0x00;
338 static const struct or51132_config pchdtv_hd3000
= {
339 .demod_address
= 0x15,
340 .set_ts_params
= or51132_set_ts_param
,
343 static int lgdt330x_pll_rf_set(struct dvb_frontend
* fe
, int index
)
345 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
346 struct cx88_core
*core
= dev
->core
;
348 dprintk(1, "%s: index = %d\n", __func__
, index
);
350 cx_clear(MO_GP0_IO
, 8);
352 cx_set(MO_GP0_IO
, 8);
356 static int lgdt330x_set_ts_param(struct dvb_frontend
* fe
, int is_punctured
)
358 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
360 dev
->ts_gen_cntrl
|= 0x04;
362 dev
->ts_gen_cntrl
&= ~0x04;
366 static struct lgdt330x_config fusionhdtv_3_gold
= {
367 .demod_address
= 0x0e,
368 .demod_chip
= LGDT3302
,
369 .serial_mpeg
= 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
370 .set_ts_params
= lgdt330x_set_ts_param
,
373 static const struct lgdt330x_config fusionhdtv_5_gold
= {
374 .demod_address
= 0x0e,
375 .demod_chip
= LGDT3303
,
376 .serial_mpeg
= 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
377 .set_ts_params
= lgdt330x_set_ts_param
,
380 static const struct lgdt330x_config pchdtv_hd5500
= {
381 .demod_address
= 0x59,
382 .demod_chip
= LGDT3303
,
383 .serial_mpeg
= 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
384 .set_ts_params
= lgdt330x_set_ts_param
,
387 static int nxt200x_set_ts_param(struct dvb_frontend
* fe
, int is_punctured
)
389 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
390 dev
->ts_gen_cntrl
= is_punctured
? 0x04 : 0x00;
394 static const struct nxt200x_config ati_hdtvwonder
= {
395 .demod_address
= 0x0a,
396 .set_ts_params
= nxt200x_set_ts_param
,
399 static int cx24123_set_ts_param(struct dvb_frontend
* fe
,
402 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
403 dev
->ts_gen_cntrl
= 0x02;
407 static int kworld_dvbs_100_set_voltage(struct dvb_frontend
* fe
,
408 fe_sec_voltage_t voltage
)
410 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
411 struct cx88_core
*core
= dev
->core
;
413 if (voltage
== SEC_VOLTAGE_OFF
)
414 cx_write(MO_GP0_IO
, 0x000006fb);
416 cx_write(MO_GP0_IO
, 0x000006f9);
418 if (core
->prev_set_voltage
)
419 return core
->prev_set_voltage(fe
, voltage
);
423 static int geniatech_dvbs_set_voltage(struct dvb_frontend
*fe
,
424 fe_sec_voltage_t voltage
)
426 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
427 struct cx88_core
*core
= dev
->core
;
429 if (voltage
== SEC_VOLTAGE_OFF
) {
430 dprintk(1,"LNB Voltage OFF\n");
431 cx_write(MO_GP0_IO
, 0x0000efff);
434 if (core
->prev_set_voltage
)
435 return core
->prev_set_voltage(fe
, voltage
);
439 static int tevii_dvbs_set_voltage(struct dvb_frontend
*fe
,
440 fe_sec_voltage_t voltage
)
442 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
443 struct cx88_core
*core
= dev
->core
;
445 cx_set(MO_GP0_IO
, 0x6040);
448 cx_clear(MO_GP0_IO
, 0x20);
451 cx_set(MO_GP0_IO
, 0x20);
453 case SEC_VOLTAGE_OFF
:
454 cx_clear(MO_GP0_IO
, 0x20);
458 if (core
->prev_set_voltage
)
459 return core
->prev_set_voltage(fe
, voltage
);
463 static int vp1027_set_voltage(struct dvb_frontend
*fe
,
464 fe_sec_voltage_t voltage
)
466 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
467 struct cx88_core
*core
= dev
->core
;
471 dprintk(1, "LNB SEC Voltage=13\n");
472 cx_write(MO_GP0_IO
, 0x00001220);
475 dprintk(1, "LNB SEC Voltage=18\n");
476 cx_write(MO_GP0_IO
, 0x00001222);
478 case SEC_VOLTAGE_OFF
:
479 dprintk(1, "LNB Voltage OFF\n");
480 cx_write(MO_GP0_IO
, 0x00001230);
484 if (core
->prev_set_voltage
)
485 return core
->prev_set_voltage(fe
, voltage
);
489 static const struct cx24123_config geniatech_dvbs_config
= {
490 .demod_address
= 0x55,
491 .set_ts_params
= cx24123_set_ts_param
,
494 static const struct cx24123_config hauppauge_novas_config
= {
495 .demod_address
= 0x55,
496 .set_ts_params
= cx24123_set_ts_param
,
499 static const struct cx24123_config kworld_dvbs_100_config
= {
500 .demod_address
= 0x15,
501 .set_ts_params
= cx24123_set_ts_param
,
505 static const struct s5h1409_config pinnacle_pctv_hd_800i_config
= {
506 .demod_address
= 0x32 >> 1,
507 .output_mode
= S5H1409_PARALLEL_OUTPUT
,
508 .gpio
= S5H1409_GPIO_ON
,
510 .inversion
= S5H1409_INVERSION_OFF
,
511 .status_mode
= S5H1409_DEMODLOCKING
,
512 .mpeg_timing
= S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK
,
515 static const struct s5h1409_config dvico_hdtv5_pci_nano_config
= {
516 .demod_address
= 0x32 >> 1,
517 .output_mode
= S5H1409_SERIAL_OUTPUT
,
518 .gpio
= S5H1409_GPIO_OFF
,
519 .inversion
= S5H1409_INVERSION_OFF
,
520 .status_mode
= S5H1409_DEMODLOCKING
,
521 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
524 static const struct s5h1409_config kworld_atsc_120_config
= {
525 .demod_address
= 0x32 >> 1,
526 .output_mode
= S5H1409_SERIAL_OUTPUT
,
527 .gpio
= S5H1409_GPIO_OFF
,
528 .inversion
= S5H1409_INVERSION_OFF
,
529 .status_mode
= S5H1409_DEMODLOCKING
,
530 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
533 static const struct xc5000_config pinnacle_pctv_hd_800i_tuner_config
= {
538 static const struct zl10353_config cx88_pinnacle_hybrid_pctv
= {
539 .demod_address
= (0x1e >> 1),
544 static const struct zl10353_config cx88_geniatech_x8000_mt
= {
545 .demod_address
= (0x1e >> 1),
547 .disable_i2c_gate_ctrl
= 1,
550 static const struct s5h1411_config dvico_fusionhdtv7_config
= {
551 .output_mode
= S5H1411_SERIAL_OUTPUT
,
552 .gpio
= S5H1411_GPIO_ON
,
553 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
554 .qam_if
= S5H1411_IF_44000
,
555 .vsb_if
= S5H1411_IF_44000
,
556 .inversion
= S5H1411_INVERSION_OFF
,
557 .status_mode
= S5H1411_DEMODLOCKING
560 static const struct xc5000_config dvico_fusionhdtv7_tuner_config
= {
561 .i2c_address
= 0xc2 >> 1,
565 static int attach_xc3028(u8 addr
, struct cx8802_dev
*dev
)
567 struct dvb_frontend
*fe
;
568 struct videobuf_dvb_frontend
*fe0
= NULL
;
569 struct xc2028_ctrl ctl
;
570 struct xc2028_config cfg
= {
571 .i2c_adap
= &dev
->core
->i2c_adap
,
576 /* Get the first frontend */
577 fe0
= videobuf_dvb_get_frontend(&dev
->frontends
, 1);
581 if (!fe0
->dvb
.frontend
) {
582 printk(KERN_ERR
"%s/2: dvb frontend not attached. "
583 "Can't attach xc3028\n",
589 * Some xc3028 devices may be hidden by an I2C gate. This is known
590 * to happen with some s5h1409-based devices.
591 * Now that I2C gate is open, sets up xc3028 configuration
593 cx88_setup_xc3028(dev
->core
, &ctl
);
595 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
, &cfg
);
597 printk(KERN_ERR
"%s/2: xc3028 attach failed\n",
599 dvb_frontend_detach(fe0
->dvb
.frontend
);
600 dvb_unregister_frontend(fe0
->dvb
.frontend
);
601 fe0
->dvb
.frontend
= NULL
;
605 printk(KERN_INFO
"%s/2: xc3028 attached\n",
611 static int attach_xc4000(struct cx8802_dev
*dev
, struct xc4000_config
*cfg
)
613 struct dvb_frontend
*fe
;
614 struct videobuf_dvb_frontend
*fe0
= NULL
;
616 /* Get the first frontend */
617 fe0
= videobuf_dvb_get_frontend(&dev
->frontends
, 1);
621 if (!fe0
->dvb
.frontend
) {
622 printk(KERN_ERR
"%s/2: dvb frontend not attached. "
623 "Can't attach xc4000\n",
628 fe
= dvb_attach(xc4000_attach
, fe0
->dvb
.frontend
, &dev
->core
->i2c_adap
,
631 printk(KERN_ERR
"%s/2: xc4000 attach failed\n",
633 dvb_frontend_detach(fe0
->dvb
.frontend
);
634 dvb_unregister_frontend(fe0
->dvb
.frontend
);
635 fe0
->dvb
.frontend
= NULL
;
639 printk(KERN_INFO
"%s/2: xc4000 attached\n", dev
->core
->name
);
644 static int cx24116_set_ts_param(struct dvb_frontend
*fe
,
647 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
648 dev
->ts_gen_cntrl
= 0x2;
653 static int stv0900_set_ts_param(struct dvb_frontend
*fe
,
656 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
657 dev
->ts_gen_cntrl
= 0;
662 static int cx24116_reset_device(struct dvb_frontend
*fe
)
664 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
665 struct cx88_core
*core
= dev
->core
;
668 /* Put the cx24116 into reset */
669 cx_write(MO_SRST_IO
, 0);
671 /* Take the cx24116 out of reset */
672 cx_write(MO_SRST_IO
, 1);
678 static const struct cx24116_config hauppauge_hvr4000_config
= {
679 .demod_address
= 0x05,
680 .set_ts_params
= cx24116_set_ts_param
,
681 .reset_device
= cx24116_reset_device
,
684 static const struct cx24116_config tevii_s460_config
= {
685 .demod_address
= 0x55,
686 .set_ts_params
= cx24116_set_ts_param
,
687 .reset_device
= cx24116_reset_device
,
690 static int ds3000_set_ts_param(struct dvb_frontend
*fe
,
693 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
694 dev
->ts_gen_cntrl
= 4;
699 static struct ds3000_config tevii_ds3000_config
= {
700 .demod_address
= 0x68,
701 .set_ts_params
= ds3000_set_ts_param
,
704 static struct ts2020_config tevii_ts2020_config
= {
705 .tuner_address
= 0x60,
708 static const struct stv0900_config prof_7301_stv0900_config
= {
709 .demod_address
= 0x6a,
712 .clkmode
= 3,/* 0-CLKI, 2-XTALI, else AUTO */
713 .diseqc_mode
= 2,/* 2/3 PWM */
714 .tun1_maddress
= 0,/* 0x60 */
715 .tun1_adc
= 0,/* 2 Vpp */
717 .set_ts_params
= stv0900_set_ts_param
,
720 static const struct stb6100_config prof_7301_stb6100_config
= {
721 .tuner_address
= 0x60,
722 .refclock
= 27000000,
725 static const struct stv0299_config tevii_tuner_sharp_config
= {
726 .demod_address
= 0x68,
727 .inittab
= sharp_z0194a_inittab
,
732 .volt13_op0_op1
= STV0299_VOLT13_OP1
,
734 .set_symbol_rate
= sharp_z0194a_set_symbol_rate
,
735 .set_ts_params
= cx24116_set_ts_param
,
738 static const struct stv0288_config tevii_tuner_earda_config
= {
739 .demod_address
= 0x68,
741 .set_ts_params
= cx24116_set_ts_param
,
744 static int cx8802_alloc_frontends(struct cx8802_dev
*dev
)
746 struct cx88_core
*core
= dev
->core
;
747 struct videobuf_dvb_frontend
*fe
= NULL
;
750 mutex_init(&dev
->frontends
.lock
);
751 INIT_LIST_HEAD(&dev
->frontends
.felist
);
753 if (!core
->board
.num_frontends
)
756 printk(KERN_INFO
"%s() allocating %d frontend(s)\n", __func__
,
757 core
->board
.num_frontends
);
758 for (i
= 1; i
<= core
->board
.num_frontends
; i
++) {
759 fe
= videobuf_dvb_alloc_frontend(&dev
->frontends
, i
);
761 printk(KERN_ERR
"%s() failed to alloc\n", __func__
);
762 videobuf_dvb_dealloc_frontends(&dev
->frontends
);
771 static const u8 samsung_smt_7020_inittab
[] = {
823 static int samsung_smt_7020_tuner_set_params(struct dvb_frontend
*fe
)
825 struct dtv_frontend_properties
*c
= &fe
->dtv_property_cache
;
826 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
829 struct i2c_msg msg
= {
833 .len
= sizeof(buf
) };
835 div
= c
->frequency
/ 125;
837 buf
[0] = (div
>> 8) & 0x7f;
839 buf
[2] = 0x84; /* 0xC4 */
842 if (c
->frequency
< 1500000)
845 if (fe
->ops
.i2c_gate_ctrl
)
846 fe
->ops
.i2c_gate_ctrl(fe
, 1);
848 if (i2c_transfer(&dev
->core
->i2c_adap
, &msg
, 1) != 1)
854 static int samsung_smt_7020_set_tone(struct dvb_frontend
*fe
,
855 fe_sec_tone_mode_t tone
)
857 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
858 struct cx88_core
*core
= dev
->core
;
860 cx_set(MO_GP0_IO
, 0x0800);
864 cx_set(MO_GP0_IO
, 0x08);
867 cx_clear(MO_GP0_IO
, 0x08);
876 static int samsung_smt_7020_set_voltage(struct dvb_frontend
*fe
,
877 fe_sec_voltage_t voltage
)
879 struct cx8802_dev
*dev
= fe
->dvb
->priv
;
880 struct cx88_core
*core
= dev
->core
;
883 struct i2c_msg msg
= {
887 .len
= sizeof(data
) };
889 cx_set(MO_GP0_IO
, 0x8000);
892 case SEC_VOLTAGE_OFF
:
895 data
= ISL6421_EN1
| ISL6421_LLC1
;
896 cx_clear(MO_GP0_IO
, 0x80);
899 data
= ISL6421_EN1
| ISL6421_LLC1
| ISL6421_VSEL1
;
900 cx_clear(MO_GP0_IO
, 0x80);
906 return (i2c_transfer(&dev
->core
->i2c_adap
, &msg
, 1) == 1) ? 0 : -EIO
;
909 static int samsung_smt_7020_stv0299_set_symbol_rate(struct dvb_frontend
*fe
,
910 u32 srate
, u32 ratio
)
915 if (srate
< 1500000) {
918 } else if (srate
< 3000000) {
921 } else if (srate
< 7000000) {
924 } else if (srate
< 14000000) {
927 } else if (srate
< 30000000) {
930 } else if (srate
< 45000000) {
935 stv0299_writereg(fe
, 0x13, aclk
);
936 stv0299_writereg(fe
, 0x14, bclk
);
937 stv0299_writereg(fe
, 0x1f, (ratio
>> 16) & 0xff);
938 stv0299_writereg(fe
, 0x20, (ratio
>> 8) & 0xff);
939 stv0299_writereg(fe
, 0x21, ratio
& 0xf0);
945 static const struct stv0299_config samsung_stv0299_config
= {
946 .demod_address
= 0x68,
947 .inittab
= samsung_smt_7020_inittab
,
951 .lock_output
= STV0299_LOCKOUTPUT_LK
,
952 .volt13_op0_op1
= STV0299_VOLT13_OP1
,
954 .set_symbol_rate
= samsung_smt_7020_stv0299_set_symbol_rate
,
957 static int dvb_register(struct cx8802_dev
*dev
)
959 struct cx88_core
*core
= dev
->core
;
960 struct videobuf_dvb_frontend
*fe0
, *fe1
= NULL
;
961 int mfe_shared
= 0; /* bus not shared by default */
964 if (0 != core
->i2c_rc
) {
965 printk(KERN_ERR
"%s/2: no i2c-bus available, cannot attach dvb drivers\n", core
->name
);
966 goto frontend_detach
;
969 /* Get the first frontend */
970 fe0
= videobuf_dvb_get_frontend(&dev
->frontends
, 1);
972 goto frontend_detach
;
974 /* multi-frontend gate control is undefined or defaults to fe0 */
975 dev
->frontends
.gate
= 0;
977 /* Sets the gate control callback to be used by i2c command calls */
978 core
->gate_ctrl
= cx88_dvb_gate_ctrl
;
980 /* init frontend(s) */
981 switch (core
->boardnr
) {
982 case CX88_BOARD_HAUPPAUGE_DVB_T1
:
983 fe0
->dvb
.frontend
= dvb_attach(cx22702_attach
,
984 &connexant_refboard_config
,
986 if (fe0
->dvb
.frontend
!= NULL
) {
987 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
988 0x61, &core
->i2c_adap
,
989 DVB_PLL_THOMSON_DTT759X
))
990 goto frontend_detach
;
993 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1
:
994 case CX88_BOARD_CONEXANT_DVB_T1
:
995 case CX88_BOARD_KWORLD_DVB_T_CX22702
:
996 case CX88_BOARD_WINFAST_DTV1000
:
997 fe0
->dvb
.frontend
= dvb_attach(cx22702_attach
,
998 &connexant_refboard_config
,
1000 if (fe0
->dvb
.frontend
!= NULL
) {
1001 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
1002 0x60, &core
->i2c_adap
,
1003 DVB_PLL_THOMSON_DTT7579
))
1004 goto frontend_detach
;
1007 case CX88_BOARD_WINFAST_DTV2000H
:
1008 case CX88_BOARD_HAUPPAUGE_HVR1100
:
1009 case CX88_BOARD_HAUPPAUGE_HVR1100LP
:
1010 case CX88_BOARD_HAUPPAUGE_HVR1300
:
1011 fe0
->dvb
.frontend
= dvb_attach(cx22702_attach
,
1012 &hauppauge_hvr_config
,
1014 if (fe0
->dvb
.frontend
!= NULL
) {
1015 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1016 &core
->i2c_adap
, 0x61,
1017 TUNER_PHILIPS_FMD1216ME_MK3
))
1018 goto frontend_detach
;
1021 case CX88_BOARD_WINFAST_DTV2000H_J
:
1022 fe0
->dvb
.frontend
= dvb_attach(cx22702_attach
,
1023 &hauppauge_hvr_config
,
1025 if (fe0
->dvb
.frontend
!= NULL
) {
1026 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1027 &core
->i2c_adap
, 0x61,
1028 TUNER_PHILIPS_FMD1216MEX_MK3
))
1029 goto frontend_detach
;
1032 case CX88_BOARD_HAUPPAUGE_HVR3000
:
1033 /* MFE frontend 1 */
1035 dev
->frontends
.gate
= 2;
1037 fe0
->dvb
.frontend
= dvb_attach(cx24123_attach
,
1038 &hauppauge_novas_config
,
1039 &dev
->core
->i2c_adap
);
1040 if (fe0
->dvb
.frontend
) {
1041 if (!dvb_attach(isl6421_attach
,
1043 &dev
->core
->i2c_adap
,
1044 0x08, ISL6421_DCL
, 0x00))
1045 goto frontend_detach
;
1047 /* MFE frontend 2 */
1048 fe1
= videobuf_dvb_get_frontend(&dev
->frontends
, 2);
1050 goto frontend_detach
;
1052 fe1
->dvb
.frontend
= dvb_attach(cx22702_attach
,
1053 &hauppauge_hvr_config
,
1054 &dev
->core
->i2c_adap
);
1055 if (fe1
->dvb
.frontend
) {
1056 fe1
->dvb
.frontend
->id
= 1;
1057 if (!dvb_attach(simple_tuner_attach
,
1059 &dev
->core
->i2c_adap
,
1060 0x61, TUNER_PHILIPS_FMD1216ME_MK3
))
1061 goto frontend_detach
;
1064 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS
:
1065 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1068 if (fe0
->dvb
.frontend
!= NULL
) {
1069 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
1070 0x60, NULL
, DVB_PLL_THOMSON_DTT7579
))
1071 goto frontend_detach
;
1074 /* ZL10353 replaces MT352 on later cards */
1075 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1076 &dvico_fusionhdtv_plus_v1_1
,
1078 if (fe0
->dvb
.frontend
!= NULL
) {
1079 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
1080 0x60, NULL
, DVB_PLL_THOMSON_DTT7579
))
1081 goto frontend_detach
;
1084 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL
:
1085 /* The tin box says DEE1601, but it seems to be DTT7579
1086 * compatible, with a slightly different MT352 AGC gain. */
1087 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1088 &dvico_fusionhdtv_dual
,
1090 if (fe0
->dvb
.frontend
!= NULL
) {
1091 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
1092 0x61, NULL
, DVB_PLL_THOMSON_DTT7579
))
1093 goto frontend_detach
;
1096 /* ZL10353 replaces MT352 on later cards */
1097 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1098 &dvico_fusionhdtv_plus_v1_1
,
1100 if (fe0
->dvb
.frontend
!= NULL
) {
1101 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
1102 0x61, NULL
, DVB_PLL_THOMSON_DTT7579
))
1103 goto frontend_detach
;
1106 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1
:
1107 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1110 if (fe0
->dvb
.frontend
!= NULL
) {
1111 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
1112 0x61, NULL
, DVB_PLL_LG_Z201
))
1113 goto frontend_detach
;
1116 case CX88_BOARD_KWORLD_DVB_T
:
1117 case CX88_BOARD_DNTV_LIVE_DVB_T
:
1118 case CX88_BOARD_ADSTECH_DVB_T_PCI
:
1119 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1120 &dntv_live_dvbt_config
,
1122 if (fe0
->dvb
.frontend
!= NULL
) {
1123 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
,
1124 0x61, NULL
, DVB_PLL_UNKNOWN_1
))
1125 goto frontend_detach
;
1128 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO
:
1129 #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
1130 /* MT352 is on a secondary I2C bus made from some GPIO lines */
1131 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
, &dntv_live_dvbt_pro_config
,
1132 &dev
->vp3054
->adap
);
1133 if (fe0
->dvb
.frontend
!= NULL
) {
1134 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1135 &core
->i2c_adap
, 0x61,
1136 TUNER_PHILIPS_FMD1216ME_MK3
))
1137 goto frontend_detach
;
1140 printk(KERN_ERR
"%s/2: built without vp3054 support\n",
1144 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID
:
1145 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1146 &dvico_fusionhdtv_hybrid
,
1148 if (fe0
->dvb
.frontend
!= NULL
) {
1149 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1150 &core
->i2c_adap
, 0x61,
1151 TUNER_THOMSON_FE6600
))
1152 goto frontend_detach
;
1155 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO
:
1156 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1157 &dvico_fusionhdtv_xc3028
,
1159 if (fe0
->dvb
.frontend
== NULL
)
1160 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1161 &dvico_fusionhdtv_mt352_xc3028
,
1164 * On this board, the demod provides the I2C bus pullup.
1165 * We must not permit gate_ctrl to be performed, or
1166 * the xc3028 cannot communicate on the bus.
1168 if (fe0
->dvb
.frontend
)
1169 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= NULL
;
1170 if (attach_xc3028(0x61, dev
) < 0)
1171 goto frontend_detach
;
1173 case CX88_BOARD_PCHDTV_HD3000
:
1174 fe0
->dvb
.frontend
= dvb_attach(or51132_attach
, &pchdtv_hd3000
,
1176 if (fe0
->dvb
.frontend
!= NULL
) {
1177 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1178 &core
->i2c_adap
, 0x61,
1179 TUNER_THOMSON_DTT761X
))
1180 goto frontend_detach
;
1183 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q
:
1184 dev
->ts_gen_cntrl
= 0x08;
1186 /* Do a hardware reset of chip before using it. */
1187 cx_clear(MO_GP0_IO
, 1);
1189 cx_set(MO_GP0_IO
, 1);
1192 /* Select RF connector callback */
1193 fusionhdtv_3_gold
.pll_rf_set
= lgdt330x_pll_rf_set
;
1194 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
1197 if (fe0
->dvb
.frontend
!= NULL
) {
1198 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1199 &core
->i2c_adap
, 0x61,
1200 TUNER_MICROTUNE_4042FI5
))
1201 goto frontend_detach
;
1204 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T
:
1205 dev
->ts_gen_cntrl
= 0x08;
1207 /* Do a hardware reset of chip before using it. */
1208 cx_clear(MO_GP0_IO
, 1);
1210 cx_set(MO_GP0_IO
, 9);
1212 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
1215 if (fe0
->dvb
.frontend
!= NULL
) {
1216 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1217 &core
->i2c_adap
, 0x61,
1218 TUNER_THOMSON_DTT761X
))
1219 goto frontend_detach
;
1222 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD
:
1223 dev
->ts_gen_cntrl
= 0x08;
1225 /* Do a hardware reset of chip before using it. */
1226 cx_clear(MO_GP0_IO
, 1);
1228 cx_set(MO_GP0_IO
, 1);
1230 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
1233 if (fe0
->dvb
.frontend
!= NULL
) {
1234 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1235 &core
->i2c_adap
, 0x61,
1236 TUNER_LG_TDVS_H06XF
))
1237 goto frontend_detach
;
1238 if (!dvb_attach(tda9887_attach
, fe0
->dvb
.frontend
,
1239 &core
->i2c_adap
, 0x43))
1240 goto frontend_detach
;
1243 case CX88_BOARD_PCHDTV_HD5500
:
1244 dev
->ts_gen_cntrl
= 0x08;
1246 /* Do a hardware reset of chip before using it. */
1247 cx_clear(MO_GP0_IO
, 1);
1249 cx_set(MO_GP0_IO
, 1);
1251 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
1254 if (fe0
->dvb
.frontend
!= NULL
) {
1255 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1256 &core
->i2c_adap
, 0x61,
1257 TUNER_LG_TDVS_H06XF
))
1258 goto frontend_detach
;
1259 if (!dvb_attach(tda9887_attach
, fe0
->dvb
.frontend
,
1260 &core
->i2c_adap
, 0x43))
1261 goto frontend_detach
;
1264 case CX88_BOARD_ATI_HDTVWONDER
:
1265 fe0
->dvb
.frontend
= dvb_attach(nxt200x_attach
,
1268 if (fe0
->dvb
.frontend
!= NULL
) {
1269 if (!dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1270 &core
->i2c_adap
, 0x61,
1271 TUNER_PHILIPS_TUV1236D
))
1272 goto frontend_detach
;
1275 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1
:
1276 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1
:
1277 fe0
->dvb
.frontend
= dvb_attach(cx24123_attach
,
1278 &hauppauge_novas_config
,
1280 if (fe0
->dvb
.frontend
) {
1281 if (!dvb_attach(isl6421_attach
, fe0
->dvb
.frontend
,
1282 &core
->i2c_adap
, 0x08, ISL6421_DCL
, 0x00))
1283 goto frontend_detach
;
1286 case CX88_BOARD_KWORLD_DVBS_100
:
1287 fe0
->dvb
.frontend
= dvb_attach(cx24123_attach
,
1288 &kworld_dvbs_100_config
,
1290 if (fe0
->dvb
.frontend
) {
1291 core
->prev_set_voltage
= fe0
->dvb
.frontend
->ops
.set_voltage
;
1292 fe0
->dvb
.frontend
->ops
.set_voltage
= kworld_dvbs_100_set_voltage
;
1295 case CX88_BOARD_GENIATECH_DVBS
:
1296 fe0
->dvb
.frontend
= dvb_attach(cx24123_attach
,
1297 &geniatech_dvbs_config
,
1299 if (fe0
->dvb
.frontend
) {
1300 core
->prev_set_voltage
= fe0
->dvb
.frontend
->ops
.set_voltage
;
1301 fe0
->dvb
.frontend
->ops
.set_voltage
= geniatech_dvbs_set_voltage
;
1304 case CX88_BOARD_PINNACLE_PCTV_HD_800i
:
1305 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1306 &pinnacle_pctv_hd_800i_config
,
1308 if (fe0
->dvb
.frontend
!= NULL
) {
1309 if (!dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1311 &pinnacle_pctv_hd_800i_tuner_config
))
1312 goto frontend_detach
;
1315 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO
:
1316 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1317 &dvico_hdtv5_pci_nano_config
,
1319 if (fe0
->dvb
.frontend
!= NULL
) {
1320 struct dvb_frontend
*fe
;
1321 struct xc2028_config cfg
= {
1322 .i2c_adap
= &core
->i2c_adap
,
1325 static struct xc2028_ctrl ctl
= {
1326 .fname
= XC2028_DEFAULT_FIRMWARE
,
1328 .scode_table
= XC3028_FE_OREN538
,
1331 fe
= dvb_attach(xc2028_attach
,
1332 fe0
->dvb
.frontend
, &cfg
);
1333 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1334 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1337 case CX88_BOARD_PINNACLE_HYBRID_PCTV
:
1338 case CX88_BOARD_WINFAST_DTV1800H
:
1339 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1340 &cx88_pinnacle_hybrid_pctv
,
1342 if (fe0
->dvb
.frontend
) {
1343 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= NULL
;
1344 if (attach_xc3028(0x61, dev
) < 0)
1345 goto frontend_detach
;
1348 case CX88_BOARD_WINFAST_DTV1800H_XC4000
:
1349 case CX88_BOARD_WINFAST_DTV2000H_PLUS
:
1350 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1351 &cx88_pinnacle_hybrid_pctv
,
1353 if (fe0
->dvb
.frontend
) {
1354 struct xc4000_config cfg
= {
1355 .i2c_address
= 0x61,
1357 .dvb_amplitude
= 134,
1358 .set_smoothedcvbs
= 1,
1361 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= NULL
;
1362 if (attach_xc4000(dev
, &cfg
) < 0)
1363 goto frontend_detach
;
1366 case CX88_BOARD_GENIATECH_X8000_MT
:
1367 dev
->ts_gen_cntrl
= 0x00;
1369 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1370 &cx88_geniatech_x8000_mt
,
1372 if (attach_xc3028(0x61, dev
) < 0)
1373 goto frontend_detach
;
1375 case CX88_BOARD_KWORLD_ATSC_120
:
1376 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1377 &kworld_atsc_120_config
,
1379 if (attach_xc3028(0x61, dev
) < 0)
1380 goto frontend_detach
;
1382 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD
:
1383 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1384 &dvico_fusionhdtv7_config
,
1386 if (fe0
->dvb
.frontend
!= NULL
) {
1387 if (!dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1389 &dvico_fusionhdtv7_tuner_config
))
1390 goto frontend_detach
;
1393 case CX88_BOARD_HAUPPAUGE_HVR4000
:
1394 /* MFE frontend 1 */
1396 dev
->frontends
.gate
= 2;
1398 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1399 &hauppauge_hvr4000_config
,
1400 &dev
->core
->i2c_adap
);
1401 if (fe0
->dvb
.frontend
) {
1402 if (!dvb_attach(isl6421_attach
,
1404 &dev
->core
->i2c_adap
,
1405 0x08, ISL6421_DCL
, 0x00))
1406 goto frontend_detach
;
1408 /* MFE frontend 2 */
1409 fe1
= videobuf_dvb_get_frontend(&dev
->frontends
, 2);
1411 goto frontend_detach
;
1413 fe1
->dvb
.frontend
= dvb_attach(cx22702_attach
,
1414 &hauppauge_hvr_config
,
1415 &dev
->core
->i2c_adap
);
1416 if (fe1
->dvb
.frontend
) {
1417 fe1
->dvb
.frontend
->id
= 1;
1418 if (!dvb_attach(simple_tuner_attach
,
1420 &dev
->core
->i2c_adap
,
1421 0x61, TUNER_PHILIPS_FMD1216ME_MK3
))
1422 goto frontend_detach
;
1425 case CX88_BOARD_HAUPPAUGE_HVR4000LITE
:
1426 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1427 &hauppauge_hvr4000_config
,
1428 &dev
->core
->i2c_adap
);
1429 if (fe0
->dvb
.frontend
) {
1430 if (!dvb_attach(isl6421_attach
,
1432 &dev
->core
->i2c_adap
,
1433 0x08, ISL6421_DCL
, 0x00))
1434 goto frontend_detach
;
1437 case CX88_BOARD_PROF_6200
:
1438 case CX88_BOARD_TBS_8910
:
1439 case CX88_BOARD_TEVII_S420
:
1440 fe0
->dvb
.frontend
= dvb_attach(stv0299_attach
,
1441 &tevii_tuner_sharp_config
,
1443 if (fe0
->dvb
.frontend
!= NULL
) {
1444 if (!dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
, 0x60,
1445 &core
->i2c_adap
, DVB_PLL_OPERA1
))
1446 goto frontend_detach
;
1447 core
->prev_set_voltage
= fe0
->dvb
.frontend
->ops
.set_voltage
;
1448 fe0
->dvb
.frontend
->ops
.set_voltage
= tevii_dvbs_set_voltage
;
1451 fe0
->dvb
.frontend
= dvb_attach(stv0288_attach
,
1452 &tevii_tuner_earda_config
,
1454 if (fe0
->dvb
.frontend
!= NULL
) {
1455 if (!dvb_attach(stb6000_attach
, fe0
->dvb
.frontend
, 0x61,
1457 goto frontend_detach
;
1458 core
->prev_set_voltage
= fe0
->dvb
.frontend
->ops
.set_voltage
;
1459 fe0
->dvb
.frontend
->ops
.set_voltage
= tevii_dvbs_set_voltage
;
1463 case CX88_BOARD_TEVII_S460
:
1464 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1467 if (fe0
->dvb
.frontend
!= NULL
)
1468 fe0
->dvb
.frontend
->ops
.set_voltage
= tevii_dvbs_set_voltage
;
1470 case CX88_BOARD_TEVII_S464
:
1471 fe0
->dvb
.frontend
= dvb_attach(ds3000_attach
,
1472 &tevii_ds3000_config
,
1474 if (fe0
->dvb
.frontend
!= NULL
) {
1475 dvb_attach(ts2020_attach
, fe0
->dvb
.frontend
,
1476 &tevii_ts2020_config
, &core
->i2c_adap
);
1477 fe0
->dvb
.frontend
->ops
.set_voltage
=
1478 tevii_dvbs_set_voltage
;
1481 case CX88_BOARD_OMICOM_SS4_PCI
:
1482 case CX88_BOARD_TBS_8920
:
1483 case CX88_BOARD_PROF_7300
:
1484 case CX88_BOARD_SATTRADE_ST4200
:
1485 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1486 &hauppauge_hvr4000_config
,
1488 if (fe0
->dvb
.frontend
!= NULL
)
1489 fe0
->dvb
.frontend
->ops
.set_voltage
= tevii_dvbs_set_voltage
;
1491 case CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII
:
1492 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1493 &cx88_terratec_cinergy_ht_pci_mkii_config
,
1495 if (fe0
->dvb
.frontend
) {
1496 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= NULL
;
1497 if (attach_xc3028(0x61, dev
) < 0)
1498 goto frontend_detach
;
1501 case CX88_BOARD_PROF_7301
:{
1502 struct dvb_tuner_ops
*tuner_ops
= NULL
;
1504 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
1505 &prof_7301_stv0900_config
,
1506 &core
->i2c_adap
, 0);
1507 if (fe0
->dvb
.frontend
!= NULL
) {
1508 if (!dvb_attach(stb6100_attach
, fe0
->dvb
.frontend
,
1509 &prof_7301_stb6100_config
,
1511 goto frontend_detach
;
1513 tuner_ops
= &fe0
->dvb
.frontend
->ops
.tuner_ops
;
1514 tuner_ops
->set_frequency
= stb6100_set_freq
;
1515 tuner_ops
->get_frequency
= stb6100_get_freq
;
1516 tuner_ops
->set_bandwidth
= stb6100_set_bandw
;
1517 tuner_ops
->get_bandwidth
= stb6100_get_bandw
;
1519 core
->prev_set_voltage
=
1520 fe0
->dvb
.frontend
->ops
.set_voltage
;
1521 fe0
->dvb
.frontend
->ops
.set_voltage
=
1522 tevii_dvbs_set_voltage
;
1526 case CX88_BOARD_SAMSUNG_SMT_7020
:
1527 dev
->ts_gen_cntrl
= 0x08;
1529 cx_set(MO_GP0_IO
, 0x0101);
1531 cx_clear(MO_GP0_IO
, 0x01);
1533 cx_set(MO_GP0_IO
, 0x01);
1536 fe0
->dvb
.frontend
= dvb_attach(stv0299_attach
,
1537 &samsung_stv0299_config
,
1538 &dev
->core
->i2c_adap
);
1539 if (fe0
->dvb
.frontend
) {
1540 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
=
1541 samsung_smt_7020_tuner_set_params
;
1542 fe0
->dvb
.frontend
->tuner_priv
=
1543 &dev
->core
->i2c_adap
;
1544 fe0
->dvb
.frontend
->ops
.set_voltage
=
1545 samsung_smt_7020_set_voltage
;
1546 fe0
->dvb
.frontend
->ops
.set_tone
=
1547 samsung_smt_7020_set_tone
;
1551 case CX88_BOARD_TWINHAN_VP1027_DVBS
:
1552 dev
->ts_gen_cntrl
= 0x00;
1553 fe0
->dvb
.frontend
= dvb_attach(mb86a16_attach
,
1556 if (fe0
->dvb
.frontend
) {
1557 core
->prev_set_voltage
=
1558 fe0
->dvb
.frontend
->ops
.set_voltage
;
1559 fe0
->dvb
.frontend
->ops
.set_voltage
=
1565 printk(KERN_ERR
"%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
1570 if ( (NULL
== fe0
->dvb
.frontend
) || (fe1
&& NULL
== fe1
->dvb
.frontend
) ) {
1572 "%s/2: frontend initialization failed\n",
1574 goto frontend_detach
;
1576 /* define general-purpose callback pointer */
1577 fe0
->dvb
.frontend
->callback
= cx88_tuner_callback
;
1579 /* Ensure all frontends negotiate bus access */
1580 fe0
->dvb
.frontend
->ops
.ts_bus_ctrl
= cx88_dvb_bus_ctrl
;
1582 fe1
->dvb
.frontend
->ops
.ts_bus_ctrl
= cx88_dvb_bus_ctrl
;
1584 /* Put the analog decoder in standby to keep it quiet */
1585 call_all(core
, core
, s_power
, 0);
1587 /* register everything */
1588 res
= videobuf_dvb_register_bus(&dev
->frontends
, THIS_MODULE
, dev
,
1589 &dev
->pci
->dev
, adapter_nr
, mfe_shared
);
1591 goto frontend_detach
;
1595 core
->gate_ctrl
= NULL
;
1596 videobuf_dvb_dealloc_frontends(&dev
->frontends
);
1600 /* ----------------------------------------------------------- */
1602 /* CX8802 MPEG -> mini driver - We have been given the hardware */
1603 static int cx8802_dvb_advise_acquire(struct cx8802_driver
*drv
)
1605 struct cx88_core
*core
= drv
->core
;
1607 dprintk( 1, "%s\n", __func__
);
1609 switch (core
->boardnr
) {
1610 case CX88_BOARD_HAUPPAUGE_HVR1300
:
1611 /* We arrive here with either the cx23416 or the cx22702
1612 * on the bus. Take the bus from the cx23416 and enable the
1615 /* Toggle reset on cx22702 leaving i2c active */
1616 cx_set(MO_GP0_IO
, 0x00000080);
1618 cx_clear(MO_GP0_IO
, 0x00000080);
1620 cx_set(MO_GP0_IO
, 0x00000080);
1622 /* enable the cx22702 pins */
1623 cx_clear(MO_GP0_IO
, 0x00000004);
1627 case CX88_BOARD_HAUPPAUGE_HVR3000
:
1628 case CX88_BOARD_HAUPPAUGE_HVR4000
:
1629 /* Toggle reset on cx22702 leaving i2c active */
1630 cx_set(MO_GP0_IO
, 0x00000080);
1632 cx_clear(MO_GP0_IO
, 0x00000080);
1634 cx_set(MO_GP0_IO
, 0x00000080);
1636 switch (core
->dvbdev
->frontends
.active_fe_id
) {
1637 case 1: /* DVB-S/S2 Enabled */
1638 /* tri-state the cx22702 pins */
1639 cx_set(MO_GP0_IO
, 0x00000004);
1640 /* Take the cx24116/cx24123 out of reset */
1641 cx_write(MO_SRST_IO
, 1);
1642 core
->dvbdev
->ts_gen_cntrl
= 0x02; /* Parallel IO */
1644 case 2: /* DVB-T Enabled */
1645 /* Put the cx24116/cx24123 into reset */
1646 cx_write(MO_SRST_IO
, 0);
1647 /* enable the cx22702 pins */
1648 cx_clear(MO_GP0_IO
, 0x00000004);
1649 core
->dvbdev
->ts_gen_cntrl
= 0x0c; /* Serial IO */
1655 case CX88_BOARD_WINFAST_DTV2000H_PLUS
:
1656 /* set RF input to AIR for DVB-T (GPIO 16) */
1657 cx_write(MO_GP2_IO
, 0x0101);
1666 /* CX8802 MPEG -> mini driver - We no longer have the hardware */
1667 static int cx8802_dvb_advise_release(struct cx8802_driver
*drv
)
1669 struct cx88_core
*core
= drv
->core
;
1671 dprintk( 1, "%s\n", __func__
);
1673 switch (core
->boardnr
) {
1674 case CX88_BOARD_HAUPPAUGE_HVR1300
:
1675 /* Do Nothing, leave the cx22702 on the bus. */
1677 case CX88_BOARD_HAUPPAUGE_HVR3000
:
1678 case CX88_BOARD_HAUPPAUGE_HVR4000
:
1686 static int cx8802_dvb_probe(struct cx8802_driver
*drv
)
1688 struct cx88_core
*core
= drv
->core
;
1689 struct cx8802_dev
*dev
= drv
->core
->dvbdev
;
1691 struct videobuf_dvb_frontend
*fe
;
1694 dprintk( 1, "%s\n", __func__
);
1695 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
1702 if (!(core
->board
.mpeg
& CX88_MPEG_DVB
))
1705 /* If vp3054 isn't enabled, a stub will just return 0 */
1706 err
= vp3054_i2c_probe(dev
);
1711 printk(KERN_INFO
"%s/2: cx2388x based DVB/ATSC card\n", core
->name
);
1712 dev
->ts_gen_cntrl
= 0x0c;
1714 err
= cx8802_alloc_frontends(dev
);
1719 for (i
= 1; i
<= core
->board
.num_frontends
; i
++) {
1720 fe
= videobuf_dvb_get_frontend(&core
->dvbdev
->frontends
, i
);
1722 printk(KERN_ERR
"%s() failed to get frontend(%d)\n",
1726 videobuf_queue_sg_init(&fe
->dvb
.dvbq
, &dvb_qops
,
1727 &dev
->pci
->dev
, &dev
->slock
,
1728 V4L2_BUF_TYPE_VIDEO_CAPTURE
,
1730 sizeof(struct cx88_buffer
),
1732 /* init struct videobuf_dvb */
1733 fe
->dvb
.name
= dev
->core
->name
;
1736 err
= dvb_register(dev
);
1738 /* frontends/adapter de-allocated in dvb_register */
1739 printk(KERN_ERR
"%s/2: dvb_register failed (err = %d)\n",
1743 videobuf_dvb_dealloc_frontends(&core
->dvbdev
->frontends
);
1748 static int cx8802_dvb_remove(struct cx8802_driver
*drv
)
1750 struct cx88_core
*core
= drv
->core
;
1751 struct cx8802_dev
*dev
= drv
->core
->dvbdev
;
1753 dprintk( 1, "%s\n", __func__
);
1755 videobuf_dvb_unregister_bus(&dev
->frontends
);
1757 vp3054_i2c_remove(dev
);
1759 core
->gate_ctrl
= NULL
;
1764 static struct cx8802_driver cx8802_dvb_driver
= {
1765 .type_id
= CX88_MPEG_DVB
,
1766 .hw_access
= CX8802_DRVCTL_SHARED
,
1767 .probe
= cx8802_dvb_probe
,
1768 .remove
= cx8802_dvb_remove
,
1769 .advise_acquire
= cx8802_dvb_advise_acquire
,
1770 .advise_release
= cx8802_dvb_advise_release
,
1773 static int __init
dvb_init(void)
1775 printk(KERN_INFO
"cx88/2: cx2388x dvb driver version %s loaded\n",
1777 return cx8802_register_driver(&cx8802_dvb_driver
);
1780 static void __exit
dvb_fini(void)
1782 cx8802_unregister_driver(&cx8802_dvb_driver
);
1785 module_init(dvb_init
);
1786 module_exit(dvb_fini
);