Enscript Output

extractedLnx/linux-2.6.38/drivers/media/video/saa7134/saa7134-dvb.c_dvb_init.c

static int dvb_init(struct saa7134_dev *dev)
{
	int ret;
	int attach_xc3028 = 0;
	struct videobuf_dvb_frontend *fe0;

	/* FIXME: add support for multi-frontend */
	mutex_init(&dev->frontends.lock);
	INIT_LIST_HEAD(&dev->frontends.felist);

	printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
	fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
	if (!fe0) {
		printk(KERN_ERR "%s() failed to alloc\n", __func__);
		return -ENOMEM;
	}

	/* init struct videobuf_dvb */
	dev->ts.nr_bufs    = 32;
	dev->ts.nr_packets = 32*4;
	fe0->dvb.name = dev->name;
	videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
			    &dev->pci->dev, &dev->slock,
			    V4L2_BUF_TYPE_VIDEO_CAPTURE,
			    V4L2_FIELD_ALTERNATE,
			    sizeof(struct saa7134_buf),
			    dev, NULL);

	switch (dev->board) {
	case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
		dprintk("pinnacle 300i dvb setup\n");
		fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
					       &dev->i2c_adap);
		if (fe0->dvb.frontend) {
			fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
		}
		break;
	case SAA7134_BOARD_AVERMEDIA_777:
	case SAA7134_BOARD_AVERMEDIA_A16AR:
		dprintk("avertv 777 dvb setup\n");
		fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
					       &dev->i2c_adap);
		if (fe0->dvb.frontend) {
			dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
				   &dev->i2c_adap, 0x61,
				   TUNER_PHILIPS_TD1316);
		}
		break;
	case SAA7134_BOARD_AVERMEDIA_A16D:
		dprintk("AverMedia A16D dvb setup\n");
		fe0->dvb.frontend = dvb_attach(mt352_attach,
						&avermedia_xc3028_mt352_dev,
						&dev->i2c_adap);
		attach_xc3028 = 1;
		break;
	case SAA7134_BOARD_MD7134:
		fe0->dvb.frontend = dvb_attach(tda10046_attach,
					       &medion_cardbus,
					       &dev->i2c_adap);
		if (fe0->dvb.frontend) {
			dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
				   &dev->i2c_adap, medion_cardbus.tuner_address,
				   TUNER_PHILIPS_FMD1216ME_MK3);
		}
		break;
	case SAA7134_BOARD_PHILIPS_TOUGH:
		fe0->dvb.frontend = dvb_attach(tda10046_attach,
					       &philips_tu1216_60_config,
					       &dev->i2c_adap);
		if (fe0->dvb.frontend) {
			fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
			fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
		}
		break;
	case SAA7134_BOARD_FLYDVBTDUO:
	case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
		if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
					 &tda827x_cfg_0) < 0)
			goto dettach_frontend;
		break;
	case SAA7134_BOARD_PHILIPS_EUROPA:
	case SAA7134_BOARD_VIDEOMATE_DVBT_300:
	case SAA7134_BOARD_ASUS_EUROPA_HYBRID:
		fe0->dvb.frontend = dvb_attach(tda10046_attach,
					       &philips_europa_config,
					       &dev->i2c_adap);
		if (fe0->dvb.frontend) {
			dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
			fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
			fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
			fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
			fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
		}
		break;
	case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000:
		fe0->dvb.frontend = dvb_attach(tda10046_attach,
					       &technotrend_budget_t3000_config,
					       &dev->i2c_adap);
		if (fe0->dvb.frontend) {
			dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
			fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
			fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
			fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
			fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
		}
		break;
	case SAA7134_BOARD_VIDEOMATE_DVBT_200:
		fe0->dvb.frontend = dvb_attach(tda10046_attach,
					       &philips_tu1216_61_config,
					       &dev->i2c_adap);
		if (fe0->dvb.frontend) {
			fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
			fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
		}
		break;
	case SAA7134_BOARD_KWORLD_DVBT_210:
		if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
					 &tda827x_cfg_2) < 0)
			goto dettach_frontend;
		break;
	case SAA7134_BOARD_HAUPPAUGE_HVR1120:
		fe0->dvb.frontend = dvb_attach(tda10048_attach,
					       &hcw_tda10048_config,
					       &dev->i2c_adap);
		if (fe0->dvb.frontend != NULL) {
			dvb_attach(tda829x_attach, fe0->dvb.frontend,
				   &dev->i2c_adap, 0x4b,
				   &tda829x_no_probe);
			dvb_attach(tda18271_attach, fe0->dvb.frontend,
				   0x60, &dev->i2c_adap,
				   &hcw_tda18271_config);
		}
		break;
	case SAA7134_BOARD_PHILIPS_TIGER:
		if (configure_tda827x_fe(dev, &philips_tiger_config,
					 &tda827x_cfg_0) < 0)
			goto dettach_frontend;
		break;
	case SAA7134_BOARD_PINNACLE_PCTV_310i:
		if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
					 &tda827x_cfg_1) < 0)
			goto dettach_frontend;
		break;
	case SAA7134_BOARD_HAUPPAUGE_HVR1110:
		if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
					 &tda827x_cfg_1) < 0)
			goto dettach_frontend;
		break;
	case SAA7134_BOARD_HAUPPAUGE_HVR1150:
		fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
					       &hcw_lgdt3305_config,
					       &dev->i2c_adap);
		if (fe0->dvb.frontend) {
			dvb_attach(tda829x_attach, fe0->dvb.frontend,
				   &dev->i2c_adap, 0x4b,
				   &tda829x_no_probe);
			dvb_attach(tda18271_attach, fe0->dvb.frontend,
				   0x60, &dev->i2c_adap,
				   &hcw_tda18271_config);
		}
		break;
	case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
		if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
					 &tda827x_cfg_0) < 0)
			goto dettach_frontend;
		break;
	case SAA7134_BOARD_FLYDVBT_LR301:
		if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
					 &tda827x_cfg_0) < 0)
			goto dettach_frontend;
		break;
	case SAA7134_BOARD_FLYDVB_TRIO:
		if (!use_frontend) {	/* terrestrial */
			if (configure_tda827x_fe(dev, &lifeview_trio_config,
						 &tda827x_cfg_0) < 0)
				goto dettach_frontend;
		} else {  		/* satellite */
			fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
			if (fe0->dvb.frontend) {
				if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
									&dev->i2c_adap, 0) == NULL) {
					wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
					goto dettach_frontend;
				}
				if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
										0x08, 0, 0) == NULL) {
					wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
					goto dettach_frontend;
				}
			}
		}
		break;
	case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
	case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
		fe0->dvb.frontend = dvb_attach(tda10046_attach,
					       &ads_tech_duo_config,
					       &dev->i2c_adap);
		if (fe0->dvb.frontend) {
			if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
				   ads_tech_duo_config.tuner_address, &dev->i2c_adap,
								&ads_duo_cfg) == NULL) {
				wprintk("no tda827x tuner found at addr: %02x\n",
					ads_tech_duo_config.tuner_address);
				goto dettach_frontend;
			}
		} else
			wprintk("failed to attach tda10046\n");
		break;
	case SAA7134_BOARD_TEVION_DVBT_220RF:
		if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
					 &tda827x_cfg_0) < 0)
			goto dettach_frontend;
		break;
	case SAA7134_BOARD_MEDION_MD8800_QUADRO:
		if (!use_frontend) {     /* terrestrial */
			if (configure_tda827x_fe(dev, &md8800_dvbt_config,
						 &tda827x_cfg_0) < 0)
				goto dettach_frontend;
		} else {        /* satellite */
			fe0->dvb.frontend = dvb_attach(tda10086_attach,
							&flydvbs, &dev->i2c_adap);
			if (fe0->dvb.frontend) {
				struct dvb_frontend *fe = fe0->dvb.frontend;
				u8 dev_id = dev->eedata[2];
				u8 data = 0xc4;
				struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};

				if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
						0x60, &dev->i2c_adap, 0) == NULL) {
					wprintk("%s: Medion Quadro, no tda826x "
						"found !\n", __func__);
					goto dettach_frontend;
				}
				if (dev_id != 0x08) {
					/* we need to open the i2c gate (we know it exists) */
					fe->ops.i2c_gate_ctrl(fe, 1);
					if (dvb_attach(isl6405_attach, fe,
							&dev->i2c_adap, 0x08, 0, 0) == NULL) {
						wprintk("%s: Medion Quadro, no ISL6405 "
							"found !\n", __func__);
						goto dettach_frontend;
					}
					if (dev_id == 0x07) {
						/* fire up the 2nd section of the LNB supply since
						   we can't do this from the other section */
						msg.buf = &data;
						i2c_transfer(&dev->i2c_adap, &msg, 1);
					}
					fe->ops.i2c_gate_ctrl(fe, 0);
					dev->original_set_voltage = fe->ops.set_voltage;
					fe->ops.set_voltage = md8800_set_voltage;
					dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
					fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
				} else {
					fe->ops.set_voltage = md8800_set_voltage2;
					fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
				}
			}
		}
		break;
	case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
		fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
					       &dev->i2c_adap);
		if (fe0->dvb.frontend)
			dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
				   NULL, DVB_PLL_TDHU2);
		break;
	case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
	case SAA7134_BOARD_KWORLD_ATSC110:
		fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
					       &dev->i2c_adap);
		if (fe0->dvb.frontend)
			dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
				   &dev->i2c_adap, 0x61,
				   TUNER_PHILIPS_TUV1236D);
		break;
	case SAA7134_BOARD_FLYDVBS_LR300:
		fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
					       &dev->i2c_adap);
		if (fe0->dvb.frontend) {
			if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
				       &dev->i2c_adap, 0) == NULL) {
				wprintk("%s: No tda826x found!\n", __func__);
				goto dettach_frontend;
			}
			if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
				       &dev->i2c_adap, 0x08, 0, 0) == NULL) {
				wprintk("%s: No ISL6421 found!\n", __func__);
				goto dettach_frontend;
			}
		}
		break;
	case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
		fe0->dvb.frontend = dvb_attach(tda10046_attach,
					       &medion_cardbus,
					       &dev->i2c_adap);
		if (fe0->dvb.frontend) {
			dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
			fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;

			dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
				   &dev->i2c_adap, medion_cardbus.tuner_address,
				   TUNER_PHILIPS_FMD1216ME_MK3);
		}
		break;
	case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
		fe0->dvb.frontend = dvb_attach(tda10046_attach,
				&philips_europa_config,
				&dev->i2c_adap);
		if (fe0->dvb.frontend) {
			fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
			fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
		}
		break;
	case SAA7134_BOARD_CINERGY_HT_PCMCIA:
		if (configure_tda827x_fe(dev, &cinergy_ht_config,
					 &tda827x_cfg_0) < 0)
			goto dettach_frontend;
		break;
	case SAA7134_BOARD_CINERGY_HT_PCI:
		if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
					 &tda827x_cfg_0) < 0)
			goto dettach_frontend;
		break;
	case SAA7134_BOARD_PHILIPS_TIGER_S:
		if (configure_tda827x_fe(dev, &philips_tiger_s_config,
					 &tda827x_cfg_2) < 0)
			goto dettach_frontend;
		break;
	case SAA7134_BOARD_ASUS_P7131_4871:
		if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
					 &tda827x_cfg_2) < 0)
			goto dettach_frontend;
		break;
	case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
		if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
					 &tda827x_cfg_2) < 0)
			goto dettach_frontend;
		break;
	case SAA7134_BOARD_AVERMEDIA_SUPER_007:
		if (configure_tda827x_fe(dev, &avermedia_super_007_config,
					 &tda827x_cfg_0) < 0)
			goto dettach_frontend;
		break;
	case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
		if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
					 &tda827x_cfg_2_sw42) < 0)
			goto dettach_frontend;
		break;
	case SAA7134_BOARD_PHILIPS_SNAKE:
		fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
						&dev->i2c_adap);
		if (fe0->dvb.frontend) {
			if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
					&dev->i2c_adap, 0) == NULL) {
				wprintk("%s: No tda826x found!\n", __func__);
				goto dettach_frontend;
			}
			if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
					&dev->i2c_adap, 0, 0) == NULL) {
				wprintk("%s: No lnbp21 found!\n", __func__);
				goto dettach_frontend;
			}
		}
		break;
	case SAA7134_BOARD_CREATIX_CTX953:
		if (configure_tda827x_fe(dev, &md8800_dvbt_config,
					 &tda827x_cfg_0) < 0)
			goto dettach_frontend;
		break;
	case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
		if (configure_tda827x_fe(dev, &philips_tiger_s_config,
					 &tda827x_cfg_2) < 0)
			goto dettach_frontend;
		break;
	case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
		dprintk("AverMedia E506R dvb setup\n");
		saa7134_set_gpio(dev, 25, 0);
		msleep(10);
		saa7134_set_gpio(dev, 25, 1);
		fe0->dvb.frontend = dvb_attach(mt352_attach,
						&avermedia_xc3028_mt352_dev,
						&dev->i2c_adap);
		attach_xc3028 = 1;
		break;
	case SAA7134_BOARD_MD7134_BRIDGE_2:
		fe0->dvb.frontend = dvb_attach(tda10086_attach,
						&sd1878_4m, &dev->i2c_adap);
		if (fe0->dvb.frontend) {
			struct dvb_frontend *fe;
			if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
				  &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
				wprintk("%s: MD7134 DVB-S, no SD1878 "
					"found !\n", __func__);
				goto dettach_frontend;
			}
			/* we need to open the i2c gate (we know it exists) */
			fe = fe0->dvb.frontend;
			fe->ops.i2c_gate_ctrl(fe, 1);
			if (dvb_attach(isl6405_attach, fe,
					&dev->i2c_adap, 0x08, 0, 0) == NULL) {
				wprintk("%s: MD7134 DVB-S, no ISL6405 "
					"found !\n", __func__);
				goto dettach_frontend;
			}
			fe->ops.i2c_gate_ctrl(fe, 0);
			dev->original_set_voltage = fe->ops.set_voltage;
			fe->ops.set_voltage = md8800_set_voltage;
			dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
			fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
		}
		break;
	case SAA7134_BOARD_AVERMEDIA_M103:
		saa7134_set_gpio(dev, 25, 0);
		msleep(10);
		saa7134_set_gpio(dev, 25, 1);
		fe0->dvb.frontend = dvb_attach(mt352_attach,
						&avermedia_xc3028_mt352_dev,
						&dev->i2c_adap);
		attach_xc3028 = 1;
		break;
	case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
		if (!use_frontend) {     /* terrestrial */
			if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
							&tda827x_cfg_2) < 0)
				goto dettach_frontend;
		} else {  		/* satellite */
			fe0->dvb.frontend = dvb_attach(tda10086_attach,
						&flydvbs, &dev->i2c_adap);
			if (fe0->dvb.frontend) {
				if (dvb_attach(tda826x_attach,
						fe0->dvb.frontend, 0x60,
						&dev->i2c_adap, 0) == NULL) {
					wprintk("%s: Asus Tiger 3in1, no "
						"tda826x found!\n", __func__);
					goto dettach_frontend;
				}
				if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
						&dev->i2c_adap, 0, 0) == NULL) {
					wprintk("%s: Asus Tiger 3in1, no lnbp21"
						" found!\n", __func__);
					goto dettach_frontend;
				}
			}
		}
		break;
	case SAA7134_BOARD_ASUSTeK_TIGER:
		if (configure_tda827x_fe(dev, &philips_tiger_config,
					 &tda827x_cfg_0) < 0)
			goto dettach_frontend;
		break;
	case SAA7134_BOARD_BEHOLD_H6:
		fe0->dvb.frontend = dvb_attach(zl10353_attach,
						&behold_h6_config,
						&dev->i2c_adap);
		if (fe0->dvb.frontend) {
			dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
				   &dev->i2c_adap, 0x61,
				   TUNER_PHILIPS_FMD1216MEX_MK3);
		}
		break;
	case SAA7134_BOARD_BEHOLD_X7:
		fe0->dvb.frontend = dvb_attach(zl10353_attach,
						&behold_x7_config,
						&dev->i2c_adap);
		if (fe0->dvb.frontend) {
			dvb_attach(xc5000_attach, fe0->dvb.frontend,
				   &dev->i2c_adap, &behold_x7_tunerconfig);
		}
		break;
	case SAA7134_BOARD_BEHOLD_H7:
		fe0->dvb.frontend = dvb_attach(zl10353_attach,
						&behold_x7_config,
						&dev->i2c_adap);
		if (fe0->dvb.frontend) {
			dvb_attach(xc5000_attach, fe0->dvb.frontend,
				   &dev->i2c_adap, &behold_x7_tunerconfig);
		}
		break;
	case SAA7134_BOARD_AVERMEDIA_A700_PRO:
	case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
		/* Zarlink ZL10313 */
		fe0->dvb.frontend = dvb_attach(mt312_attach,
			&avertv_a700_mt312, &dev->i2c_adap);
		if (fe0->dvb.frontend) {
			if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
					&avertv_a700_tuner, &dev->i2c_adap) == NULL) {
				wprintk("%s: No zl10036 found!\n",
					__func__);
			}
		}
		break;
	case SAA7134_BOARD_VIDEOMATE_S350:
		fe0->dvb.frontend = dvb_attach(mt312_attach,
				&zl10313_compro_s350_config, &dev->i2c_adap);
		if (fe0->dvb.frontend)
			if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
					0x60, &dev->i2c_adap) == NULL)
				wprintk("%s: No zl10039 found!\n",
					__func__);

		break;
	case SAA7134_BOARD_ZOLID_HYBRID_PCI:
		fe0->dvb.frontend = dvb_attach(tda10048_attach,
					       &zolid_tda10048_config,
					       &dev->i2c_adap);
		if (fe0->dvb.frontend != NULL) {
			dvb_attach(tda829x_attach, fe0->dvb.frontend,
				   &dev->i2c_adap, 0x4b,
				   &tda829x_no_probe);
			dvb_attach(tda18271_attach, fe0->dvb.frontend,
				   0x60, &dev->i2c_adap,
				   &zolid_tda18271_config);
		}
		break;
	case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
		fe0->dvb.frontend = dvb_attach(tda10048_attach,
					       &dtv1000s_tda10048_config,
					       &dev->i2c_adap);
		if (fe0->dvb.frontend != NULL) {
			dvb_attach(tda829x_attach, fe0->dvb.frontend,
				   &dev->i2c_adap, 0x4b,
				   &tda829x_no_probe);
			dvb_attach(tda18271_attach, fe0->dvb.frontend,
				   0x60, &dev->i2c_adap,
				   &dtv1000s_tda18271_config);
		}
		break;
	case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG:
		/* Switch to digital mode */
		saa7134_tuner_callback(dev, 0,
				       TDA18271_CALLBACK_CMD_AGC_ENABLE, 1);
		fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
					       &kworld_mb86a20s_config,
					       &dev->i2c_adap);
		if (fe0->dvb.frontend != NULL) {
			dvb_attach(tda829x_attach, fe0->dvb.frontend,
				   &dev->i2c_adap, 0x4b,
				   &tda829x_no_probe);
			dvb_attach(tda18271_attach, fe0->dvb.frontend,
				   0x60, &dev->i2c_adap,
				   &kworld_tda18271_config);
			fe0->dvb.frontend->ops.i2c_gate_ctrl = kworld_sbtvd_gate_ctrl;
		}

		/* mb86a20s need to use the I2C gateway */
		break;
	default:
		wprintk("Huh? unknown DVB card?\n");
		break;
	}

	if (attach_xc3028) {
		struct dvb_frontend *fe;
		struct xc2028_config cfg = {
			.i2c_adap  = &dev->i2c_adap,
			.i2c_addr  = 0x61,
		};

		if (!fe0->dvb.frontend)
			goto dettach_frontend;

		fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
		if (!fe) {
			printk(KERN_ERR "%s/2: xc3028 attach failed\n",
			       dev->name);
			goto dettach_frontend;
		}
	}

	if (NULL == fe0->dvb.frontend) {
		printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
		goto dettach_frontend;
	}
	/* define general-purpose callback pointer */
	fe0->dvb.frontend->callback = saa7134_tuner_callback;

	/* register everything else */
	ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
					&dev->pci->dev, adapter_nr, 0, NULL);

	/* this sequence is necessary to make the tda1004x load its firmware
	 * and to enter analog mode of hybrid boards
	 */
	if (!ret) {
		if (fe0->dvb.frontend->ops.init)
			fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
		if (fe0->dvb.frontend->ops.sleep)
			fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
		if (fe0->dvb.frontend->ops.tuner_ops.sleep)
			fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
	}
	return ret;

dettach_frontend:
	videobuf_dvb_dealloc_frontends(&dev->frontends);
	return -EINVAL;
}

Generated by GNU enscript 1.6.4.