PATCH 41/44 multiproto + backward compatibility [VES1820]

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

 




--- v4l-dvb/linux/drivers/media/dvb/frontends/ves1820.c	2006-06-30 19:59:10.000000000 +0400
+++ mp-bc1/linux/drivers/media/dvb/frontends/ves1820.c	2006-07-23 11:41:15.000000000 +0400
@@ -219,9 +219,10 @@ static int ves1820_set_parameters(struct
 	if (real_qam < 0 || real_qam > 4)
 		return -EINVAL;
 
-	if (fe->ops.tuner_ops.set_params) {
-		fe->ops.tuner_ops.set_params(fe, p);
-		if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
+	if (fe->ops.tuner_ops.set_params_compat) {
+		fe->ops.tuner_ops.set_params_compat(fe, p);
+		if (fe->ops.i2c_gate_ctrl)
+			fe->ops.i2c_gate_ctrl(fe, 0);
 	}
 
 	ves1820_set_symbolrate(state, p->u.qam.symbol_rate);
@@ -237,6 +238,62 @@ static int ves1820_set_parameters(struct
 	return 0;
 }
 
+static int ves1820_set_params(struct dvb_frontend* fe,
+			      struct dvbfe_params *p)
+{
+	struct ves1820_state* state = fe->demodulator_priv;
+
+	if (fe->ops.tuner_ops.set_params) {
+		fe->ops.tuner_ops.set_params(fe, p);
+		if (fe->ops.i2c_gate_ctrl)
+			fe->ops.i2c_gate_ctrl(fe, 0);
+	}
+
+	ves1820_set_symbolrate(state, p->delsys.dvbc.symbol_rate);
+	ves1820_writereg(state, 0x34, state->pwm);
+
+	switch (p->delsys.dvbc.modulation) {
+	case DVBFE_MOD_QAM16:
+		ves1820_writereg(state, 0x01, 140);
+		ves1820_writereg(state, 0x05, 135);
+		ves1820_writereg(state, 0x08, 162);
+		ves1820_writereg(state, 0x09, 145);
+		ves1820_setup_reg0(state, 0x00, p->inversion);
+		break;
+	case DVBFE_MOD_QAM32:
+		ves1820_writereg(state, 0x01, 140);
+		ves1820_writereg(state, 0x05, 100);
+		ves1820_writereg(state, 0x08, 116);
+		ves1820_writereg(state, 0x09, 150);
+		ves1820_setup_reg0(state, 0x04, p->inversion);
+		break;
+	case DVBFE_MOD_QAM64:
+		ves1820_writereg(state, 0x01, 106);
+		ves1820_writereg(state, 0x05, 70);
+		ves1820_writereg(state, 0x08, 67);
+		ves1820_writereg(state, 0x09, 106);
+		ves1820_setup_reg0(state, 0x08, p->inversion);
+		break;
+	case DVBFE_MOD_QAM128:
+		ves1820_writereg(state, 0x01, 100);
+		ves1820_writereg(state, 0x05, 54);
+		ves1820_writereg(state, 0x08, 52);
+		ves1820_writereg(state, 0x09, 126);
+		ves1820_setup_reg0(state, 0x0c, p->inversion);
+	case DVBFE_MOD_QAM256:
+		ves1820_writereg(state, 0x01, 92);
+		ves1820_writereg(state, 0x05, 38);
+		ves1820_writereg(state, 0x08, 35);
+		ves1820_writereg(state, 0x09, 107);
+		ves1820_setup_reg0(state, 0x10, p->inversion);
+		break;
+	default:
+		return -EINVAL;
+	}
+	ves1820_writereg(state, 2, ves1820_inittab[2] | (state->config->selagc ? 0x08 : 0));
+	return 0;
+}
+
 static int ves1820_read_status(struct dvb_frontend* fe, fe_status_t* status)
 {
 	struct ves1820_state* state = fe->demodulator_priv;
@@ -341,6 +398,54 @@ static int ves1820_get_frontend(struct d
 	return 0;
 }
 
+static int ves1820_get_params(struct dvb_frontend* fe,
+			      struct dvbfe_params *p)
+{
+	struct ves1820_state* state = fe->demodulator_priv;
+	int sync;
+	s8 afc = 0;
+	u32 modulation;
+
+	sync = ves1820_readreg(state, 0x11);
+	afc = ves1820_readreg(state, 0x19);
+	if (verbose) {
+		/* AFC only valid when carrier has been recovered */
+		printk(sync & 2 ? "ves1820: AFC (%d) %dHz\n" :
+			"ves1820: [AFC (%d) %dHz]\n", afc, -((s32) p->delsys.dvbc.symbol_rate * afc) >> 10);
+	}
+
+	if (!state->config->invert) {
+		p->inversion = (state->reg0 & 0x20) ? INVERSION_ON : INVERSION_OFF;
+	} else {
+		p->inversion = (!(state->reg0 & 0x20)) ? INVERSION_ON : INVERSION_OFF;
+	}
+
+	modulation = (state->reg0 >> 2) & 7;
+	switch (modulation) {
+	case 0:
+		p->delsys.dvbc.modulation = DVBFE_MOD_QAM16;
+		break;
+	case 1:
+		p->delsys.dvbc.modulation = DVBFE_MOD_QAM32;
+		break;
+	case 2:
+		p->delsys.dvbc.modulation = DVBFE_MOD_QAM64;
+		break;
+	case 3:
+		p->delsys.dvbc.modulation = DVBFE_MOD_QAM128;
+		break;
+	case 4:
+		p->delsys.dvbc.modulation = DVBFE_MOD_QAM256;
+		break;
+	}
+
+	p->frequency = ((p->frequency + 31250) / 62500) * 62500;
+	if (sync & 2)
+		p->frequency -= ((s32) p->delsys.dvbc.symbol_rate * afc) >> 10;
+
+	return 0;
+}
+
 static int ves1820_sleep(struct dvb_frontend* fe)
 {
 	struct ves1820_state* state = fe->demodulator_priv;
@@ -405,6 +510,32 @@ error:
 	return NULL;
 }
 
+static struct dvbfe_info dvbc_info	= {
+	.name				= "VLSI VES1820 DVB-C",
+	.delivery			= DVBFE_DELSYS_DVBC,
+	.delsys				= {
+		.dvbc.modulation	= DVBFE_MOD_QAM16  | DVBFE_MOD_QAM32  |
+					  DVBFE_MOD_QAM64  | DVBFE_MOD_QAM128 |
+					  DVBFE_MOD_QAM256
+	},
+
+	.frequency_step			= 62500,
+};
+
+static int ves1820_get_info(struct dvb_frontend *fe, struct dvbfe_info *fe_info)
+{
+	memcpy(fe_info, &dvbc_info, sizeof (dvbc_info));
+
+	return 0;
+}
+
+static int ves1820_get_delsys(struct dvb_frontend *fe, enum dvbfe_delsys *fe_delsys)
+{
+	*fe_delsys = DVBFE_DELSYS_DVBC;
+
+	return 0;
+}
+
 static struct dvb_frontend_ops ves1820_ops = {
 
 	.info = {
@@ -435,6 +566,11 @@ static struct dvb_frontend_ops ves1820_o
 	.read_signal_strength = ves1820_read_signal_strength,
 	.read_snr = ves1820_read_snr,
 	.read_ucblocks = ves1820_read_ucblocks,
+
+	.set_params	= ves1820_set_params,
+	.get_params	= ves1820_get_params,
+	.get_info	= ves1820_get_info,
+	.get_delsys	= ves1820_get_delsys,
 };
 
 module_param(verbose, int, 0644);

_______________________________________________

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