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"
47 MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
48 MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
49 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
50 MODULE_LICENSE("GPL");
52 static unsigned int debug = 0;
53 module_param(debug, int, 0644);
54 MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
56 #define dprintk(level,fmt, arg...) if (debug >= level) \
57 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
59 /* ------------------------------------------------------------------ */
61 static int dvb_buf_setup(struct videobuf_queue *q,
62 unsigned int *count, unsigned int *size)
64 struct cx8802_dev *dev = q->priv_data;
66 dev->ts_packet_size = 188 * 4;
67 dev->ts_packet_count = 32;
69 *size = dev->ts_packet_size * dev->ts_packet_count;
74 static int dvb_buf_prepare(struct videobuf_queue *q,
75 struct videobuf_buffer *vb, enum v4l2_field field)
77 struct cx8802_dev *dev = q->priv_data;
78 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
81 static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
83 struct cx8802_dev *dev = q->priv_data;
84 cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
87 static void dvb_buf_release(struct videobuf_queue *q,
88 struct videobuf_buffer *vb)
90 cx88_free_buffer(q, (struct cx88_buffer*)vb);
93 static struct videobuf_queue_ops dvb_qops = {
94 .buf_setup = dvb_buf_setup,
95 .buf_prepare = dvb_buf_prepare,
96 .buf_queue = dvb_buf_queue,
97 .buf_release = dvb_buf_release,
100 /* ------------------------------------------------------------------ */
102 static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
104 struct cx8802_dev *dev= fe->dvb->priv;
105 struct cx8802_driver *drv = NULL;
108 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
111 ret = drv->request_acquire(drv);
113 ret = drv->request_release(drv);
119 /* ------------------------------------------------------------------ */
121 static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
123 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
124 static u8 reset [] = { RESET, 0x80 };
125 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
126 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
127 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
128 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
130 mt352_write(fe, clock_config, sizeof(clock_config));
132 mt352_write(fe, reset, sizeof(reset));
133 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
135 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
136 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
137 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
141 static int dvico_dual_demod_init(struct dvb_frontend *fe)
143 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
144 static u8 reset [] = { RESET, 0x80 };
145 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
146 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
147 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
148 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
150 mt352_write(fe, clock_config, sizeof(clock_config));
152 mt352_write(fe, reset, sizeof(reset));
153 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
155 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
156 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
157 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
162 static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
164 static u8 clock_config [] = { 0x89, 0x38, 0x39 };
165 static u8 reset [] = { 0x50, 0x80 };
166 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
167 static u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
168 0x00, 0xFF, 0x00, 0x40, 0x40 };
169 static u8 dntv_extra[] = { 0xB5, 0x7A };
170 static u8 capt_range_cfg[] = { 0x75, 0x32 };
172 mt352_write(fe, clock_config, sizeof(clock_config));
174 mt352_write(fe, reset, sizeof(reset));
175 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
177 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
179 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
180 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
185 static struct mt352_config dvico_fusionhdtv = {
186 .demod_address = 0x0f,
187 .demod_init = dvico_fusionhdtv_demod_init,
190 static struct mt352_config dntv_live_dvbt_config = {
191 .demod_address = 0x0f,
192 .demod_init = dntv_live_dvbt_demod_init,
195 static struct mt352_config dvico_fusionhdtv_dual = {
196 .demod_address = 0x0f,
197 .demod_init = dvico_dual_demod_init,
200 #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
201 static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
203 static u8 clock_config [] = { 0x89, 0x38, 0x38 };
204 static u8 reset [] = { 0x50, 0x80 };
205 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
206 static u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
207 0x00, 0xFF, 0x00, 0x40, 0x40 };
208 static u8 dntv_extra[] = { 0xB5, 0x7A };
209 static u8 capt_range_cfg[] = { 0x75, 0x32 };
211 mt352_write(fe, clock_config, sizeof(clock_config));
213 mt352_write(fe, reset, sizeof(reset));
214 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
216 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
218 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
219 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
224 static struct mt352_config dntv_live_dvbt_pro_config = {
225 .demod_address = 0x0f,
227 .demod_init = dntv_live_dvbt_pro_demod_init,
231 static struct zl10353_config dvico_fusionhdtv_hybrid = {
232 .demod_address = 0x0f,
236 static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
237 .demod_address = 0x0f,
240 static struct cx22702_config connexant_refboard_config = {
241 .demod_address = 0x43,
242 .output_mode = CX22702_SERIAL_OUTPUT,
245 static struct cx22702_config hauppauge_hvr_config = {
246 .demod_address = 0x63,
247 .output_mode = CX22702_SERIAL_OUTPUT,
250 static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
252 struct cx8802_dev *dev= fe->dvb->priv;
253 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
257 static struct or51132_config pchdtv_hd3000 = {
258 .demod_address = 0x15,
259 .set_ts_params = or51132_set_ts_param,
262 static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
264 struct cx8802_dev *dev= fe->dvb->priv;
265 struct cx88_core *core = dev->core;
267 dprintk(1, "%s: index = %d\n", __FUNCTION__, index);
269 cx_clear(MO_GP0_IO, 8);
271 cx_set(MO_GP0_IO, 8);
275 static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
277 struct cx8802_dev *dev= fe->dvb->priv;
279 dev->ts_gen_cntrl |= 0x04;
281 dev->ts_gen_cntrl &= ~0x04;
285 static struct lgdt330x_config fusionhdtv_3_gold = {
286 .demod_address = 0x0e,
287 .demod_chip = LGDT3302,
288 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
289 .set_ts_params = lgdt330x_set_ts_param,
292 static struct lgdt330x_config fusionhdtv_5_gold = {
293 .demod_address = 0x0e,
294 .demod_chip = LGDT3303,
295 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
296 .set_ts_params = lgdt330x_set_ts_param,
299 static struct lgdt330x_config pchdtv_hd5500 = {
300 .demod_address = 0x59,
301 .demod_chip = LGDT3303,
302 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
303 .set_ts_params = lgdt330x_set_ts_param,
306 static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
308 struct cx8802_dev *dev= fe->dvb->priv;
309 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
313 static struct nxt200x_config ati_hdtvwonder = {
314 .demod_address = 0x0a,
315 .set_ts_params = nxt200x_set_ts_param,
318 static int cx24123_set_ts_param(struct dvb_frontend* fe,
321 struct cx8802_dev *dev= fe->dvb->priv;
322 dev->ts_gen_cntrl = 0x02;
326 static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
327 fe_sec_voltage_t voltage)
329 struct cx8802_dev *dev= fe->dvb->priv;
330 struct cx88_core *core = dev->core;
332 if (voltage == SEC_VOLTAGE_OFF)
333 cx_write(MO_GP0_IO, 0x000006fb);
335 cx_write(MO_GP0_IO, 0x000006f9);
337 if (core->prev_set_voltage)
338 return core->prev_set_voltage(fe, voltage);
342 static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
343 fe_sec_voltage_t voltage)
345 struct cx8802_dev *dev= fe->dvb->priv;
346 struct cx88_core *core = dev->core;
348 if (voltage == SEC_VOLTAGE_OFF) {
349 dprintk(1,"LNB Voltage OFF\n");
350 cx_write(MO_GP0_IO, 0x0000efff);
353 if (core->prev_set_voltage)
354 return core->prev_set_voltage(fe, voltage);
358 static struct cx24123_config geniatech_dvbs_config = {
359 .demod_address = 0x55,
360 .set_ts_params = cx24123_set_ts_param,
363 static struct cx24123_config hauppauge_novas_config = {
364 .demod_address = 0x55,
365 .set_ts_params = cx24123_set_ts_param,
368 static struct cx24123_config kworld_dvbs_100_config = {
369 .demod_address = 0x15,
370 .set_ts_params = cx24123_set_ts_param,
374 static int dvb_register(struct cx8802_dev *dev)
376 /* init struct videobuf_dvb */
377 dev->dvb.name = dev->core->name;
378 dev->ts_gen_cntrl = 0x0c;
381 switch (dev->core->board) {
382 case CX88_BOARD_HAUPPAUGE_DVB_T1:
383 dev->dvb.frontend = dvb_attach(cx22702_attach,
384 &connexant_refboard_config,
385 &dev->core->i2c_adap);
386 if (dev->dvb.frontend != NULL) {
387 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
388 &dev->core->i2c_adap,
389 DVB_PLL_THOMSON_DTT759X);
392 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
393 case CX88_BOARD_CONEXANT_DVB_T1:
394 case CX88_BOARD_KWORLD_DVB_T_CX22702:
395 case CX88_BOARD_WINFAST_DTV1000:
396 dev->dvb.frontend = dvb_attach(cx22702_attach,
397 &connexant_refboard_config,
398 &dev->core->i2c_adap);
399 if (dev->dvb.frontend != NULL) {
400 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
401 &dev->core->i2c_adap,
402 DVB_PLL_THOMSON_DTT7579);
405 case CX88_BOARD_WINFAST_DTV2000H:
406 case CX88_BOARD_HAUPPAUGE_HVR1100:
407 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
408 case CX88_BOARD_HAUPPAUGE_HVR1300:
409 case CX88_BOARD_HAUPPAUGE_HVR3000:
410 dev->dvb.frontend = dvb_attach(cx22702_attach,
411 &hauppauge_hvr_config,
412 &dev->core->i2c_adap);
413 if (dev->dvb.frontend != NULL) {
414 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
415 &dev->core->i2c_adap, DVB_PLL_FMD1216ME);
418 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
419 dev->dvb.frontend = dvb_attach(mt352_attach,
421 &dev->core->i2c_adap);
422 if (dev->dvb.frontend != NULL) {
423 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
424 NULL, DVB_PLL_THOMSON_DTT7579);
427 /* ZL10353 replaces MT352 on later cards */
428 dev->dvb.frontend = dvb_attach(zl10353_attach,
429 &dvico_fusionhdtv_plus_v1_1,
430 &dev->core->i2c_adap);
431 if (dev->dvb.frontend != NULL) {
432 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
433 NULL, DVB_PLL_THOMSON_DTT7579);
436 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
437 /* The tin box says DEE1601, but it seems to be DTT7579
438 * compatible, with a slightly different MT352 AGC gain. */
439 dev->dvb.frontend = dvb_attach(mt352_attach,
440 &dvico_fusionhdtv_dual,
441 &dev->core->i2c_adap);
442 if (dev->dvb.frontend != NULL) {
443 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
444 NULL, DVB_PLL_THOMSON_DTT7579);
447 /* ZL10353 replaces MT352 on later cards */
448 dev->dvb.frontend = dvb_attach(zl10353_attach,
449 &dvico_fusionhdtv_plus_v1_1,
450 &dev->core->i2c_adap);
451 if (dev->dvb.frontend != NULL) {
452 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
453 NULL, DVB_PLL_THOMSON_DTT7579);
456 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
457 dev->dvb.frontend = dvb_attach(mt352_attach,
459 &dev->core->i2c_adap);
460 if (dev->dvb.frontend != NULL) {
461 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
462 NULL, DVB_PLL_LG_Z201);
465 case CX88_BOARD_KWORLD_DVB_T:
466 case CX88_BOARD_DNTV_LIVE_DVB_T:
467 case CX88_BOARD_ADSTECH_DVB_T_PCI:
468 dev->dvb.frontend = dvb_attach(mt352_attach,
469 &dntv_live_dvbt_config,
470 &dev->core->i2c_adap);
471 if (dev->dvb.frontend != NULL) {
472 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
473 NULL, DVB_PLL_UNKNOWN_1);
476 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
477 #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
478 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
479 &((struct vp3054_i2c_state *)dev->card_priv)->adap);
480 if (dev->dvb.frontend != NULL) {
481 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
482 &dev->core->i2c_adap, DVB_PLL_FMD1216ME);
485 printk("%s: built without vp3054 support\n", dev->core->name);
488 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
489 dev->dvb.frontend = dvb_attach(zl10353_attach,
490 &dvico_fusionhdtv_hybrid,
491 &dev->core->i2c_adap);
492 if (dev->dvb.frontend != NULL) {
493 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
494 &dev->core->i2c_adap,
495 DVB_PLL_THOMSON_FE6600);
498 case CX88_BOARD_PCHDTV_HD3000:
499 dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
500 &dev->core->i2c_adap);
501 if (dev->dvb.frontend != NULL) {
502 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
503 &dev->core->i2c_adap,
504 DVB_PLL_THOMSON_DTT761X);
507 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
508 dev->ts_gen_cntrl = 0x08;
510 /* Do a hardware reset of chip before using it. */
511 struct cx88_core *core = dev->core;
513 cx_clear(MO_GP0_IO, 1);
515 cx_set(MO_GP0_IO, 1);
518 /* Select RF connector callback */
519 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
520 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
522 &dev->core->i2c_adap);
523 if (dev->dvb.frontend != NULL) {
524 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
525 &dev->core->i2c_adap,
526 DVB_PLL_MICROTUNE_4042);
530 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
531 dev->ts_gen_cntrl = 0x08;
533 /* Do a hardware reset of chip before using it. */
534 struct cx88_core *core = dev->core;
536 cx_clear(MO_GP0_IO, 1);
538 cx_set(MO_GP0_IO, 9);
540 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
542 &dev->core->i2c_adap);
543 if (dev->dvb.frontend != NULL) {
544 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
545 &dev->core->i2c_adap,
546 DVB_PLL_THOMSON_DTT761X);
550 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
551 dev->ts_gen_cntrl = 0x08;
553 /* Do a hardware reset of chip before using it. */
554 struct cx88_core *core = dev->core;
556 cx_clear(MO_GP0_IO, 1);
558 cx_set(MO_GP0_IO, 1);
560 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
562 &dev->core->i2c_adap);
563 if (dev->dvb.frontend != NULL) {
564 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
565 &dev->core->i2c_adap,
566 DVB_PLL_LG_TDVS_H06XF);
570 case CX88_BOARD_PCHDTV_HD5500:
571 dev->ts_gen_cntrl = 0x08;
573 /* Do a hardware reset of chip before using it. */
574 struct cx88_core *core = dev->core;
576 cx_clear(MO_GP0_IO, 1);
578 cx_set(MO_GP0_IO, 1);
580 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
582 &dev->core->i2c_adap);
583 if (dev->dvb.frontend != NULL) {
584 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
585 &dev->core->i2c_adap,
586 DVB_PLL_LG_TDVS_H06XF);
590 case CX88_BOARD_ATI_HDTVWONDER:
591 dev->dvb.frontend = dvb_attach(nxt200x_attach,
593 &dev->core->i2c_adap);
594 if (dev->dvb.frontend != NULL) {
595 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
596 NULL, DVB_PLL_TUV1236D);
599 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
600 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
601 dev->dvb.frontend = dvb_attach(cx24123_attach,
602 &hauppauge_novas_config,
603 &dev->core->i2c_adap);
604 if (dev->dvb.frontend) {
605 dvb_attach(isl6421_attach, dev->dvb.frontend,
606 &dev->core->i2c_adap, 0x08, 0x00, 0x00);
609 case CX88_BOARD_KWORLD_DVBS_100:
610 dev->dvb.frontend = dvb_attach(cx24123_attach,
611 &kworld_dvbs_100_config,
612 &dev->core->i2c_adap);
613 if (dev->dvb.frontend) {
614 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
615 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
618 case CX88_BOARD_GENIATECH_DVBS:
619 dev->dvb.frontend = dvb_attach(cx24123_attach,
620 &geniatech_dvbs_config,
621 &dev->core->i2c_adap);
622 if (dev->dvb.frontend) {
623 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
624 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
628 printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
632 if (NULL == dev->dvb.frontend) {
633 printk("%s: frontend initialization failed\n",dev->core->name);
637 /* Ensure all frontends negotiate bus access */
638 dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
640 /* Put the analog decoder in standby to keep it quiet */
641 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
643 /* register everything */
644 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
647 /* ----------------------------------------------------------- */
649 /* CX8802 MPEG -> mini driver - We have been given the hardware */
650 static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
652 struct cx88_core *core = drv->core;
654 dprintk( 1, "%s\n", __FUNCTION__);
656 switch (core->board) {
657 case CX88_BOARD_HAUPPAUGE_HVR1300:
658 /* We arrive here with either the cx23416 or the cx22702
659 * on the bus. Take the bus from the cx23416 and enable the
662 cx_set(MO_GP0_IO, 0x00000080); /* cx22702 out of reset and enable */
663 cx_clear(MO_GP0_IO, 0x00000004);
672 /* CX8802 MPEG -> mini driver - We no longer have the hardware */
673 static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
675 struct cx88_core *core = drv->core;
677 dprintk( 1, "%s\n", __FUNCTION__);
679 switch (core->board) {
680 case CX88_BOARD_HAUPPAUGE_HVR1300:
681 /* Do Nothing, leave the cx22702 on the bus. */
689 static int cx8802_dvb_probe(struct cx8802_driver *drv)
691 struct cx88_core *core = drv->core;
692 struct cx8802_dev *dev = drv->core->dvbdev;
695 dprintk( 1, "%s\n", __FUNCTION__);
696 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
703 if (!(cx88_boards[core->board].mpeg & CX88_MPEG_DVB))
706 /* If vp3054 isn't enabled, a stub will just return 0 */
707 err = vp3054_i2c_probe(dev);
712 printk("%s/2: cx2388x based dvb card\n", core->name);
713 videobuf_queue_init(&dev->dvb.dvbq, &dvb_qops,
714 dev->pci, &dev->slock,
715 V4L2_BUF_TYPE_VIDEO_CAPTURE,
717 sizeof(struct cx88_buffer),
719 err = dvb_register(dev);
721 printk("%s dvb_register failed err = %d\n", __FUNCTION__, err);
727 static int cx8802_dvb_remove(struct cx8802_driver *drv)
729 struct cx8802_dev *dev = drv->core->dvbdev;
732 videobuf_dvb_unregister(&dev->dvb);
734 vp3054_i2c_remove(dev);
739 static struct cx8802_driver cx8802_dvb_driver = {
740 .type_id = CX88_MPEG_DVB,
741 .hw_access = CX8802_DRVCTL_SHARED,
742 .probe = cx8802_dvb_probe,
743 .remove = cx8802_dvb_remove,
744 .advise_acquire = cx8802_dvb_advise_acquire,
745 .advise_release = cx8802_dvb_advise_release,
748 static int dvb_init(void)
750 printk(KERN_INFO "cx2388x dvb driver version %d.%d.%d loaded\n",
751 (CX88_VERSION_CODE >> 16) & 0xff,
752 (CX88_VERSION_CODE >> 8) & 0xff,
753 CX88_VERSION_CODE & 0xff);
755 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
756 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
758 return cx8802_register_driver(&cx8802_dvb_driver);
761 static void dvb_fini(void)
763 cx8802_unregister_driver(&cx8802_dvb_driver);
766 module_init(dvb_init);
767 module_exit(dvb_fini);
772 * compile-command: "make DVB=1"