PATCH 17/44 multiproto + backward compatibility [DVB-USB]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



diff -Naurp v4l-dvb/linux/drivers/media/dvb/dvb-usb/cxusb.c mp-bc1/linux/drivers/media/dvb/dvb-usb/cxusb.c
--- v4l-dvb/linux/drivers/media/dvb/dvb-usb/cxusb.c	2006-06-30 19:59:10.000000000 +0400
+++ mp-bc1/linux/drivers/media/dvb/dvb-usb/cxusb.c	2006-07-23 11:43:56.000000000 +0400
@@ -324,8 +324,15 @@ static int cxusb_mt352_demod_init(struct
 	return 0;
 }
 
+static int cxusb_lgh064f_tuner_set_params_compat(struct dvb_frontend *fe,
+						 struct dvb_frontend_parameters *fep)
+{
+	struct dvb_usb_device *d = fe->dvb->priv;
+	return lg_h06xf_pll_set_compat(fe, &d->i2c_adap, fep);
+}
+
 static int cxusb_lgh064f_tuner_set_params(struct dvb_frontend *fe,
-					  struct dvb_frontend_parameters *fep)
+					  struct dvbfe_params *fep)
 {
 	struct dvb_usb_device *d = fe->dvb->priv;
 	return lg_h06xf_pll_set(fe, &d->i2c_adap, fep);
@@ -366,7 +373,7 @@ static int cxusb_fmd1216me_tuner_attach(
 	d->pll_desc = &dvb_pll_fmd1216me;
 
 	d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c;
-	d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c;
+	d->fe->ops.tuner_ops.set_params_compat = dvb_usb_tuner_set_params_i2c_compat;
 
 	return 0;
 }
@@ -375,6 +382,7 @@ static int cxusb_dee1601_tuner_attach(st
 {
 	d->pll_addr = 0x61;
 	d->pll_desc = &dvb_pll_thomson_dtt7579;
+	d->fe->ops.tuner_ops.calc_regs_compat = dvb_usb_tuner_calc_regs_compat;
 	d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
 	return 0;
 }
@@ -383,6 +391,7 @@ static int cxusb_lgz201_tuner_attach(str
 {
 	d->pll_addr = 0x61;
 	d->pll_desc = &dvb_pll_lg_z201;
+	d->fe->ops.tuner_ops.calc_regs_compat = dvb_usb_tuner_calc_regs_compat;
 	d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
 	return 0;
 }
@@ -391,12 +400,13 @@ static int cxusb_dtt7579_tuner_attach(st
 {
 	d->pll_addr = 0x60;
 	d->pll_desc = &dvb_pll_thomson_dtt7579;
-	d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
+	d->fe->ops.tuner_ops.calc_regs_compat = dvb_usb_tuner_calc_regs_compat;
 	return 0;
 }
 
 static int cxusb_lgdt3303_tuner_attach(struct dvb_usb_device *d)
 {
+	d->fe->ops.tuner_ops.set_params_compat = cxusb_lgh064f_tuner_set_params_compat;
 	d->fe->ops.tuner_ops.set_params = cxusb_lgh064f_tuner_set_params;
 	return 0;
 }
diff -Naurp v4l-dvb/linux/drivers/media/dvb/dvb-usb/dibusb-common.c mp-bc1/linux/drivers/media/dvb/dvb-usb/dibusb-common.c
--- v4l-dvb/linux/drivers/media/dvb/dvb-usb/dibusb-common.c	2006-06-30 19:59:10.000000000 +0400
+++ mp-bc1/linux/drivers/media/dvb/dvb-usb/dibusb-common.c	2006-07-05 03:44:45.000000000 +0400
@@ -176,7 +176,7 @@ int dibusb_dib3000mc_frontend_attach(str
 	for (demod_cfg.demod_address = 0x8; demod_cfg.demod_address < 0xd; demod_cfg.demod_address++)
 		if ((d->fe = dib3000mc_attach(&demod_cfg,&d->i2c_adap,&st->ops)) != NULL) {
 			d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c;
-			d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c;
+			d->fe->ops.tuner_ops.set_params_compat = dvb_usb_tuner_set_params_i2c_compat;
 			d->tuner_pass_ctrl = st->ops.tuner_pass_ctrl;
 			return 0;
 		}
@@ -191,7 +191,7 @@ int dibusb_dib3000mc_tuner_attach (struc
 	d->pll_desc = &dvb_pll_env57h1xd5;
 
 	d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c;
-	d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c;
+	d->fe->ops.tuner_ops.set_params_compat = dvb_usb_tuner_set_params_i2c_compat;
 
 	return 0;
 }
diff -Naurp v4l-dvb/linux/drivers/media/dvb/dvb-usb/dibusb-mb.c mp-bc1/linux/drivers/media/dvb/dvb-usb/dibusb-mb.c
--- v4l-dvb/linux/drivers/media/dvb/dvb-usb/dibusb-mb.c	2006-06-30 19:59:10.000000000 +0400
+++ mp-bc1/linux/drivers/media/dvb/dvb-usb/dibusb-mb.c	2006-07-05 03:45:02.000000000 +0400
@@ -23,7 +23,7 @@ static int dibusb_dib3000mb_frontend_att
 
 	if ((d->fe = dib3000mb_attach(&demod_cfg,&d->i2c_adap,&st->ops)) == NULL) {
 		d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c;
-		d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c;
+		d->fe->ops.tuner_ops.set_params_compat = dvb_usb_tuner_set_params_i2c_compat;
 		return -ENODEV;
 	}
 
diff -Naurp v4l-dvb/linux/drivers/media/dvb/dvb-usb/digitv.c mp-bc1/linux/drivers/media/dvb/dvb-usb/digitv.c
--- v4l-dvb/linux/drivers/media/dvb/dvb-usb/digitv.c	2006-06-30 19:59:10.000000000 +0400
+++ mp-bc1/linux/drivers/media/dvb/dvb-usb/digitv.c	2006-07-23 11:43:03.000000000 +0400
@@ -114,7 +114,17 @@ static struct mt352_config digitv_mt352_
 	.demod_init = digitv_mt352_demod_init,
 };
 
-static int digitv_nxt6000_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep)
+static int digitv_nxt6000_tuner_set_params_compat(struct dvb_frontend *fe,
+						  struct dvb_frontend_parameters *fep)
+{
+	struct dvb_usb_device *d = fe->dvb->priv;
+	u8 b[5];
+	dvb_usb_tuner_calc_regs_compat(fe,fep,b, 5);
+	return digitv_ctrl_msg(d,USB_WRITE_TUNER,0,&b[1],4,NULL,0);
+}
+
+static int digitv_nxt6000_tuner_set_params(struct dvb_frontend *fe,
+					   struct dvbfe_params *fep)
 {
 	struct dvb_usb_device *d = fe->dvb->priv;
 	u8 b[5];
@@ -129,10 +139,12 @@ static struct nxt6000_config digitv_nxt6
 static int digitv_frontend_attach(struct dvb_usb_device *d)
 {
 	if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) != NULL) {
+		d->fe->ops.tuner_ops.calc_regs_compat = dvb_usb_tuner_calc_regs_compat;
 		d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
 		return 0;
 	}
 	if ((d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) != NULL) {
+		d->fe->ops.tuner_ops.set_params_compat = digitv_nxt6000_tuner_set_params_compat;
 		d->fe->ops.tuner_ops.set_params = digitv_nxt6000_tuner_set_params;
 		return 0;
 	}
diff -Naurp v4l-dvb/linux/drivers/media/dvb/dvb-usb/dtt200u-fe.c mp-bc1/linux/drivers/media/dvb/dvb-usb/dtt200u-fe.c
--- v4l-dvb/linux/drivers/media/dvb/dvb-usb/dtt200u-fe.c	2006-06-30 19:59:10.000000000 +0400
+++ mp-bc1/linux/drivers/media/dvb/dvb-usb/dtt200u-fe.c	2006-07-23 11:43:11.000000000 +0400
@@ -17,6 +17,7 @@ struct dtt200u_fe_state {
 	fe_status_t stat;
 
 	struct dvb_frontend_parameters fep;
+	struct dvbfe_params fe_params;
 	struct dvb_frontend frontend;
 };
 
@@ -134,6 +135,47 @@ static int dtt200u_fe_set_frontend(struc
 	return 0;
 }
 
+static int dtt200u_set_params(struct dvb_frontend* fe,
+			      struct dvbfe_params *fep)
+{
+	struct dtt200u_fe_state *state = fe->demodulator_priv;
+	int i;
+	fe_status_t st;
+	u16 freq = fep->frequency / 250000;
+	u8 bwbuf[2] = { SET_BANDWIDTH, 0 },freqbuf[3] = { SET_RF_FREQ, 0, 0 };
+
+	switch (fep->delsys.dvbt.bandwidth) {
+	case DVBFE_BANDWIDTH_8_MHZ:
+		bwbuf[1] = 8;
+		break;
+	case DVBFE_BANDWIDTH_7_MHZ:
+		bwbuf[1] = 7;
+		break;
+	case DVBFE_BANDWIDTH_6_MHZ:
+		bwbuf[1] = 6;
+		break;
+	case DVBFE_BANDWIDTH_AUTO:
+		return -EOPNOTSUPP;
+	default:
+		return -EINVAL;
+	}
+
+	dvb_usb_generic_write(state->d, bwbuf, 2);
+
+	freqbuf[1] = freq & 0xff;
+	freqbuf[2] = (freq >> 8) & 0xff;
+	dvb_usb_generic_write(state->d, freqbuf, 3);
+
+	for (i = 0; i < 30; i++) {
+		msleep(20);
+		dtt200u_fe_read_status(fe, &st);
+		if (st & FE_TIMEDOUT)
+			continue;
+	}
+
+	return 0;
+}
+
 static int dtt200u_fe_get_frontend(struct dvb_frontend* fe,
 				  struct dvb_frontend_parameters *fep)
 {
@@ -142,6 +184,14 @@ static int dtt200u_fe_get_frontend(struc
 	return 0;
 }
 
+static int dtt200u_get_params(struct dvb_frontend* fe,
+			      struct dvbfe_params *fep)
+{
+	struct dtt200u_fe_state *state = fe->demodulator_priv;
+	memcpy(fep, &state->fe_params, sizeof (struct dvbfe_params));
+	return 0;
+}
+
 static void dtt200u_fe_release(struct dvb_frontend* fe)
 {
 	struct dtt200u_fe_state *state = (struct dtt200u_fe_state*) fe->demodulator_priv;
@@ -171,6 +221,39 @@ error:
 	return NULL;
 }
 
+static struct dvbfe_info dvbt_info	= {
+	.name				= "Wideview USB DVB-T",
+	.delivery			= DVBFE_DELSYS_DVBT,
+	.delsys				= {
+		.dvbt.modulation	= DVBFE_MOD_OFDM,
+		.dvbt.stream_priority	= DVBFE_STREAM_PRIORITY_HP |
+					  DVBFE_STREAM_PRIORITY_LP,
+	},
+
+	.frequency_min			= 44250000,
+	.frequency_max			= 867250000,
+	.frequency_step			= 250000,
+};
+
+static int dtt200u_get_info(struct dvb_frontend *fe, struct dvbfe_info *fe_info)
+{
+	memcpy(fe_info, &dvbt_info, sizeof (dvbt_info));
+
+	return 0;
+}
+
+static int dtt200u_get_delsys(struct dvb_frontend *fe, enum dvbfe_delsys *fe_delsys)
+{
+	*fe_delsys = DVBFE_DELSYS_DVBT;
+
+	return 0;
+}
+
+static enum dvbfe_algo dtt200u_get_algo(struct dvb_frontend *fe)
+{
+	return DVBFE_ALGO_RECOVERY;
+}
+
 static struct dvb_frontend_ops dtt200u_fe_ops = {
 	.info = {
 		.name			= "WideView USB DVB-T",
@@ -202,4 +285,10 @@ static struct dvb_frontend_ops dtt200u_f
 	.read_signal_strength = dtt200u_fe_read_signal_strength,
 	.read_snr = dtt200u_fe_read_snr,
 	.read_ucblocks = dtt200u_fe_read_unc_blocks,
+
+	.set_params		= dtt200u_set_params,
+	.get_params		= dtt200u_get_params,
+	.get_info		= dtt200u_get_info,
+	.get_delsys		= dtt200u_get_delsys,
+	.get_frontend_algo	= dtt200u_get_algo,
 };
diff -Naurp v4l-dvb/linux/drivers/media/dvb/dvb-usb/dvb-usb.h mp-bc1/linux/drivers/media/dvb/dvb-usb/dvb-usb.h
--- v4l-dvb/linux/drivers/media/dvb/dvb-usb/dvb-usb.h	2006-06-30 19:59:10.000000000 +0400
+++ mp-bc1/linux/drivers/media/dvb/dvb-usb/dvb-usb.h	2006-07-08 02:08:55.000000000 +0400
@@ -342,8 +342,9 @@ extern int dvb_usb_nec_rc_key_to_event(s
 
 /* commonly used pll init and set functions */
 extern int dvb_usb_tuner_init_i2c(struct dvb_frontend *);
-extern int dvb_usb_tuner_calc_regs(struct dvb_frontend *, struct dvb_frontend_parameters *, u8 *buf, int buf_len);
-extern int dvb_usb_tuner_set_params_i2c(struct dvb_frontend *, struct dvb_frontend_parameters *);
+extern int dvb_usb_tuner_calc_regs_compat(struct dvb_frontend *, struct dvb_frontend_parameters *, u8 *buf, int buf_len);
+extern int dvb_usb_tuner_calc_regs(struct dvb_frontend *, struct dvbfe_params *, u8 *buf, int buf_len);
+extern int dvb_usb_tuner_set_params_i2c_compat(struct dvb_frontend *, struct dvb_frontend_parameters *);
 
 /* commonly used firmware download types and function */
 struct hexline {
diff -Naurp v4l-dvb/linux/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c mp-bc1/linux/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
--- v4l-dvb/linux/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c	2006-06-30 19:59:10.000000000 +0400
+++ mp-bc1/linux/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c	2006-07-08 02:08:00.000000000 +0400
@@ -77,7 +77,9 @@ int dvb_usb_tuner_init_i2c(struct dvb_fr
 }
 EXPORT_SYMBOL(dvb_usb_tuner_init_i2c);
 
-int dvb_usb_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep, u8 *b, int buf_len)
+int dvb_usb_tuner_calc_regs_compat(struct dvb_frontend *fe, 
+				   struct dvb_frontend_parameters *fep, 
+				   u8 *b, int buf_len)
 {
 	struct dvb_usb_device *d = fe->dvb->priv;
 
@@ -95,16 +97,38 @@ int dvb_usb_tuner_calc_regs(struct dvb_f
 
 	return 5;
 }
+EXPORT_SYMBOL(dvb_usb_tuner_calc_regs_compat);
+
+int dvb_usb_tuner_calc_regs(struct dvb_frontend *fe, 
+			    struct dvbfe_params *fep, 
+			    u8 *b, int buf_len)
+{
+	struct dvb_usb_device *d = fe->dvb->priv;
+
+	if (buf_len != 5)
+		return -EINVAL;
+	if (d->pll_desc == NULL)
+		return 0;
+
+	deb_pll("pll addr: %x, freq: %d %p\n",d->pll_addr,fep->frequency,d->pll_desc);
+
+	b[0] = d->pll_addr;
+	dvb_pll_configure(d->pll_desc,&b[1],fep->frequency,fep->delsys.dvbt.bandwidth);
+
+	deb_pll("pll-buf: %x %x %x %x %x\n",b[0],b[1],b[2],b[3],b[4]);
+
+	return 5;
+}
 EXPORT_SYMBOL(dvb_usb_tuner_calc_regs);
 
-int dvb_usb_tuner_set_params_i2c(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep)
+int dvb_usb_tuner_set_params_i2c_compat(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep)
 {
 	struct dvb_usb_device *d = fe->dvb->priv;
 	int ret = 0;
 	u8 b[5];
 	struct i2c_msg msg = { .addr = d->pll_addr, .flags = 0, .buf = &b[1], .len = 4 };
 
-	dvb_usb_tuner_calc_regs(fe,fep,b,5);
+	dvb_usb_tuner_calc_regs_compat(fe,fep,b,5);
 
 	if (d->tuner_pass_ctrl)
 		d->tuner_pass_ctrl(fe,1,d->pll_addr);
@@ -122,4 +146,4 @@ int dvb_usb_tuner_set_params_i2c(struct 
 
 	return ret;
 }
-EXPORT_SYMBOL(dvb_usb_tuner_set_params_i2c);
+EXPORT_SYMBOL(dvb_usb_tuner_set_params_i2c_compat);
diff -Naurp v4l-dvb/linux/drivers/media/dvb/dvb-usb/gp8psk-fe.c mp-bc1/linux/drivers/media/dvb/dvb-usb/gp8psk-fe.c
--- v4l-dvb/linux/drivers/media/dvb/dvb-usb/gp8psk-fe.c	2006-06-30 19:59:10.000000000 +0400
+++ mp-bc1/linux/drivers/media/dvb/dvb-usb/gp8psk-fe.c	2006-07-23 11:43:24.000000000 +0400
@@ -129,12 +129,57 @@ static int gp8psk_fe_set_frontend(struct
 	return 0;
 }
 
+static int gp8psk_set_params(struct dvb_frontend* fe,
+			     struct dvbfe_params *fep)
+{
+	struct gp8psk_fe_state *state = fe->demodulator_priv;
+	u8 cmd[10];
+	u32 freq = fep->frequency * 1000;
+
+	cmd[4] = freq         & 0xff;
+	cmd[5] = (freq >> 8)  & 0xff;
+	cmd[6] = (freq >> 16) & 0xff;
+	cmd[7] = (freq >> 24) & 0xff;
+
+	switch(fe->ops.info.type) {
+	case FE_QPSK:
+		cmd[0] =  fep->delsys.dvbs.symbol_rate        & 0xff;
+		cmd[1] = (fep->delsys.dvbs.symbol_rate >>  8) & 0xff;
+		cmd[2] = (fep->delsys.dvbs.symbol_rate >> 16) & 0xff;
+		cmd[3] = (fep->delsys.dvbs.symbol_rate >> 24) & 0xff;
+		cmd[8] = ADV_MOD_DVB_QPSK;
+		cmd[9] = 0x03; /*ADV_MOD_FEC_XXX*/
+		break;
+	default:
+		// other modes are unsuported right now
+		cmd[0] = 0;
+		cmd[1] = 0;
+		cmd[2] = 0;
+		cmd[3] = 0;
+		cmd[8] = 0;
+		cmd[9] = 0;
+		break;
+	}
+
+	gp8psk_usb_out_op(state->d,TUNE_8PSK,0,0,cmd,10);
+
+	state->next_snr_check = jiffies;
+
+	return 0;
+}
+
 static int gp8psk_fe_get_frontend(struct dvb_frontend* fe,
 				  struct dvb_frontend_parameters *fep)
 {
 	return 0;
 }
 
+static int gp8psk_get_params(struct dvb_frontend* fe,
+			     struct dvbfe_params *fep)
+{
+	return 0;
+}
+
 
 static int gp8psk_fe_send_diseqc_msg (struct dvb_frontend* fe,
 				    struct dvb_diseqc_master_cmd *m)
@@ -232,6 +277,37 @@ success:
 	return &s->fe;
 }
 
+static struct dvbfe_info dvbs_info	= {
+	.name				= "Genpix 8PSK USB DVB-S",
+	.delivery			= DVBFE_DELSYS_DVBS,
+	.delsys				= {
+		.dvbs.modulation	= DVBFE_MOD_QPSK,
+		.dvbs.fec		= DVBFE_FEC_1_2  | DVBFE_FEC_2_3 |
+					  DVBFE_FEC_3_4  | DVBFE_FEC_5_6 |
+					  DVBFE_FEC_7_8  | DVBFE_FEC_AUTO
+	},
+
+	.frequency_min			= 950000,
+	.frequency_max			= 2150000,
+	.frequency_step			= 100,
+	.symbol_rate_min		= 1000000,
+	.symbol_rate_max		= 45000000,
+	.symbol_rate_tolerance		= 500,
+};
+
+static int gp8psk_get_info(struct dvb_frontend *fe, struct dvbfe_info *fe_info)
+{
+	memcpy(fe_info, &dvbs_info, sizeof (dvbs_info));
+
+	return 0;
+}
+
+static int gp8psk_get_delsys(struct dvb_frontend *fe, enum dvbfe_delsys *fe_delsys)
+{
+	*fe_delsys = DVBFE_DELSYS_DVBS;
+
+	return 0;
+}
 
 static struct dvb_frontend_ops gp8psk_fe_ops = {
 	.info = {
@@ -269,4 +345,9 @@ static struct dvb_frontend_ops gp8psk_fe
 	.set_tone = gp8psk_fe_set_tone,
 	.set_voltage = gp8psk_fe_set_voltage,
 	.dishnetwork_send_legacy_command = gp8psk_fe_send_legacy_dish_cmd,
+
+	.set_params	= gp8psk_set_params,
+	.get_params	= gp8psk_get_params,
+	.get_info	= gp8psk_get_info,
+	.get_delsys	= gp8psk_get_delsys,
 };
diff -Naurp v4l-dvb/linux/drivers/media/dvb/dvb-usb/umt-010.c mp-bc1/linux/drivers/media/dvb/dvb-usb/umt-010.c
--- v4l-dvb/linux/drivers/media/dvb/dvb-usb/umt-010.c	2006-06-30 19:59:10.000000000 +0400
+++ mp-bc1/linux/drivers/media/dvb/dvb-usb/umt-010.c	2006-07-08 02:09:17.000000000 +0400
@@ -67,6 +67,7 @@ static int umt_tuner_attach (struct dvb_
 {
 	d->pll_addr = 0x61;
 	d->pll_desc = &dvb_pll_tua6034;
+	d->fe->ops.tuner_ops.calc_regs_compat = dvb_usb_tuner_calc_regs_compat;
 	d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
 	return 0;
 }
diff -Naurp v4l-dvb/linux/drivers/media/dvb/dvb-usb/vp702x-fe.c mp-bc1/linux/drivers/media/dvb/dvb-usb/vp702x-fe.c
--- v4l-dvb/linux/drivers/media/dvb/dvb-usb/vp702x-fe.c	2006-06-30 19:59:10.000000000 +0400
+++ mp-bc1/linux/drivers/media/dvb/dvb-usb/vp702x-fe.c	2006-07-23 11:43:38.000000000 +0400
@@ -183,6 +183,62 @@ static int vp702x_fe_set_frontend(struct
 	return 0;
 }
 
+static int vp702x_set_params(struct dvb_frontend* fe,
+			     struct dvbfe_params *fep)
+{
+	struct vp702x_fe_state *st = fe->demodulator_priv;
+	u32 freq = fep->frequency / 1000;
+	/*CalFrequency*/
+/*	u16 frequencyRef[16] = { 2, 4, 8, 16, 32, 64, 128, 256, 24, 5, 10, 20, 40, 80, 160, 320 }; */
+	u64 sr;
+	u8 cmd[8] = { 0 },ibuf[10];
+
+	cmd[0] = (freq >> 8) & 0x7f;
+	cmd[1] =  freq       & 0xff;
+	cmd[2] = 1; /* divrate == 4 -> frequencyRef[1] -> 1 here */
+
+	sr = (u64) (fep->delsys.dvbs.symbol_rate / 1000) << 20;
+	do_div(sr,88000);
+	cmd[3] = (sr >> 12) & 0xff;
+	cmd[4] = (sr >> 4)  & 0xff;
+	cmd[5] = (sr << 4)  & 0xf0;
+
+	deb_fe("setting frontend to: %u -> %u (%x) LNB-based GHz, symbolrate: %d -> %lu (%lx)\n",
+			fep->frequency,freq,freq, fep->delsys.dvbs.symbol_rate,
+			(unsigned long) sr, (unsigned long) sr);
+
+/*	if (fep->inversion == INVERSION_ON)
+		cmd[6] |= 0x80; */
+
+	if (st->voltage == SEC_VOLTAGE_18)
+		cmd[6] |= 0x40;
+
+/*	if (fep->u.qpsk.symbol_rate > 8000000)
+		cmd[6] |= 0x20;
+
+	if (fep->frequency < 1531000)
+		cmd[6] |= 0x04;
+
+	if (st->tone_mode == SEC_TONE_ON)
+		cmd[6] |= 0x01;*/
+
+	cmd[7] = vp702x_chksum(cmd,0,7);
+
+	st->status_check_interval = 250;
+	st->next_status_check = jiffies;
+
+	vp702x_usb_in_op(st->d, RESET_TUNER, 0, 0, NULL, 0);
+	msleep(30);
+	vp702x_usb_inout_op(st->d, cmd, 8, ibuf, 10, 100);
+
+	if (ibuf[2] == 0 && ibuf[3] == 0)
+		deb_fe("tuning failed.\n");
+	else
+		deb_fe("tuning succeeded.\n");
+
+	return 0;
+}
+
 static int vp702x_fe_get_frontend(struct dvb_frontend* fe,
 				  struct dvb_frontend_parameters *fep)
 {
@@ -190,6 +246,13 @@ static int vp702x_fe_get_frontend(struct
 	return 0;
 }
 
+static int vp702x_get_params(struct dvb_frontend* fe,
+			     struct dvbfe_params *fep)
+{
+	deb_fe("%s\n",__FUNCTION__);
+	return 0;
+}
+
 static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe,
 				    struct dvb_diseqc_master_cmd *m)
 {
@@ -299,6 +362,38 @@ error:
 	return NULL;
 }
 
+static struct dvbfe_info dvbs_info	= {
+	.name				= "Twinhan(VP7020/1) DVB-S",
+	.delivery			= DVBFE_DELSYS_DVBS,
+	.delsys				= {
+		.dvbs.modulation	= DVBFE_MOD_QPSK,
+		.dvbs.fec		= DVBFE_FEC_1_2 | DVBFE_FEC_2_3 |
+					  DVBFE_FEC_3_4 | DVBFE_FEC_5_6 |
+					  DVBFE_FEC_7_8 | DVBFE_FEC_AUTO
+	},
+
+	.frequency_min			= 950000,
+	.frequency_max			= 2150000,
+	.frequency_step			= 1000,
+	.frequency_tolerance		= 0,
+	.symbol_rate_min		= 1000000,
+	.symbol_rate_max		= 45000000,
+	.symbol_rate_tolerance		= 500,
+};
+
+static int vp702x_get_info(struct dvb_frontend *fe, struct dvbfe_info *fe_info)
+{
+	memcpy(fe_info, &dvbs_info, sizeof (dvbs_info));
+
+	return 0;
+}
+
+static int vp702x_get_delsys(struct dvb_frontend *fe, enum dvbfe_delsys *fe_delsys)
+{
+	*fe_delsys = DVBFE_DELSYS_DVBS;
+
+	return 0;
+}
 
 static struct dvb_frontend_ops vp702x_fe_ops = {
 	.info = {
@@ -335,4 +430,9 @@ static struct dvb_frontend_ops vp702x_fe
 	.diseqc_send_burst = vp702x_fe_send_diseqc_burst,
 	.set_tone = vp702x_fe_set_tone,
 	.set_voltage = vp702x_fe_set_voltage,
+
+	.set_params	= vp702x_set_params,
+	.get_params	= vp702x_get_params,
+	.get_info	= vp702x_get_info,
+	.get_delsys	= vp702x_get_delsys,
 };
diff -Naurp v4l-dvb/linux/drivers/media/dvb/dvb-usb/vp7045-fe.c mp-bc1/linux/drivers/media/dvb/dvb-usb/vp7045-fe.c
--- v4l-dvb/linux/drivers/media/dvb/dvb-usb/vp7045-fe.c	2006-06-30 19:59:10.000000000 +0400
+++ mp-bc1/linux/drivers/media/dvb/dvb-usb/vp7045-fe.c	2006-07-23 11:43:45.000000000 +0400
@@ -128,12 +128,50 @@ static int vp7045_fe_set_frontend(struct
 	return 0;
 }
 
+static int vp7045_set_params(struct dvb_frontend* fe,
+			     struct dvbfe_params *fep)
+{
+	struct vp7045_fe_state *state = fe->demodulator_priv;
+	u8 buf[5];
+	u32 freq = fep->frequency / 1000;
+
+	buf[0] = (freq >> 16) & 0xff;
+	buf[1] = (freq >>  8) & 0xff;
+	buf[2] =  freq        & 0xff;
+	buf[3] = 0;
+
+	switch (fep->delsys.dvbt.bandwidth) {
+	case DVBFE_BANDWIDTH_8_MHZ:
+		buf[4] = 8;
+		break;
+	case DVBFE_BANDWIDTH_7_MHZ:
+		buf[4] = 7;
+		break;
+	case DVBFE_BANDWIDTH_6_MHZ:
+		buf[4] = 6;
+		break;
+	case DVBFE_BANDWIDTH_AUTO:
+		return -EOPNOTSUPP;
+	default:
+		return -EINVAL;
+	}
+
+	vp7045_usb_op(state->d, LOCK_TUNER_COMMAND, buf, 5, NULL, 0, 200);
+	return 0;
+}
+
 static int vp7045_fe_get_frontend(struct dvb_frontend* fe,
 				  struct dvb_frontend_parameters *fep)
 {
 	return 0;
 }
 
+static int vp7045_get_params(struct dvb_frontend* fe,
+			     struct dvbfe_params *fep)
+{
+	return 0;
+}
+
 static void vp7045_fe_release(struct dvb_frontend* fe)
 {
 	struct vp7045_fe_state *state = fe->demodulator_priv;
@@ -157,6 +195,37 @@ error:
 	return NULL;
 }
 
+static struct dvbfe_info dvbt_info	= {
+	.name				= "Twinhan VP7045/6 USB DVB-T",
+	.delivery			= DVBFE_DELSYS_DVBT,
+	.delsys				= {
+		.dvbt.modulation	= DVBFE_MOD_OFDM,
+		.dvbt.stream_priority	= DVBFE_STREAM_PRIORITY_HP,
+	},
+
+	.frequency_min			= 44250000,
+	.frequency_max			= 867250000,
+	.frequency_step			= 1000,
+};
+
+static int vp7045_get_info(struct dvb_frontend *fe, struct dvbfe_info *fe_info)
+{
+	memcpy(fe_info, &dvbt_info, sizeof (dvbt_info));
+
+	return 0;
+}
+
+static int vp7045_get_delsys(struct dvb_frontend *fe, enum dvbfe_delsys *fe_delsys)
+{
+	*fe_delsys = DVBFE_DELSYS_DVBT;
+
+	return 0;
+}
+
+static enum dvbfe_algo vp7045_get_algo(struct dvb_frontend *fe)
+{
+	return DVBFE_ALGO_RECOVERY;
+}
 
 static struct dvb_frontend_ops vp7045_fe_ops = {
 	.info = {
@@ -189,4 +258,10 @@ static struct dvb_frontend_ops vp7045_fe
 	.read_signal_strength = vp7045_fe_read_signal_strength,
 	.read_snr = vp7045_fe_read_snr,
 	.read_ucblocks = vp7045_fe_read_unc_blocks,
+
+	.set_params		= vp7045_set_params,
+	.get_params		= vp7045_get_params,
+	.get_info		= vp7045_get_info,
+	.get_delsys		= vp7045_get_delsys,
+	.get_frontend_algo	= vp7045_get_algo,
 };
_______________________________________________

linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux