PATCH 34/44 multiproto + backward compatibility [TDA10021]

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

 



--- v4l-dvb/linux/drivers/media/dvb/frontends/tda10021.c	2006-06-30 19:59:10.000000000 +0400
+++ mp-bc1/linux/drivers/media/dvb/frontends/tda10021.c	2006-07-23 11:40:53.000000000 +0400
@@ -259,9 +259,10 @@ static int tda10021_set_parameters (stru
 
 	//printk("tda10021: set frequency to %d qam=%d symrate=%d\n", p->frequency,qam,p->u.qam.symbol_rate);
 
-	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);
 	}
 
 	tda10021_set_symbolrate (state, p->u.qam.symbol_rate);
@@ -436,6 +437,130 @@ error:
 	return NULL;
 }
 
+static struct dvbfe_info dvbc_info	= {
+	.name				= "Philips TDA10021 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_min			= 51000000,
+	.frequency_max			= 858000000,
+	.symbol_rate_min		= (XIN / 2) / 64,
+	.symbol_rate_max		= (XIN / 2) / 4,
+};
+
+static int tda10021_set_params(struct dvb_frontend *fe,
+			       struct dvbfe_params *p)
+{
+	struct tda10021_state* state = fe->demodulator_priv;
+
+	//table for QAM4-QAM256 ready  QAM4  QAM16 QAM32 QAM64 QAM128 QAM256
+	//CONF
+	static const u8 reg0x00 [] = { 0x14, 0x00, 0x04, 0x08, 0x0c,  0x10 };
+	//AGCREF value
+	static const u8 reg0x01 [] = { 0x78, 0x8c, 0x8c, 0x6a, 0x78,  0x5c };
+	//LTHR value
+	static const u8 reg0x05 [] = { 0x78, 0x87, 0x64, 0x46, 0x36,  0x26 };
+	//MSETH
+	static const u8 reg0x08 [] = { 0x8c, 0xa2, 0x74, 0x43, 0x34,  0x23 };
+	//AREF
+	static const u8 reg0x09 [] = { 0x96, 0x91, 0x96, 0x6a, 0x7e,  0x6b };
+
+	int qam = p->delsys.dvbc.modulation;
+
+//	if (qam < 0 || qam > 5)
+//		return -EINVAL;
+
+	//printk("tda10021: set frequency to %d qam=%d symrate=%d\n", p->frequency,qam,p->u.qam.symbol_rate);
+
+	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);
+	}
+
+	tda10021_set_symbolrate(state, p->delsys.dvbc.symbol_rate);
+	tda10021_writereg(state, 0x34, state->pwm);
+
+	tda10021_writereg(state, 0x01, reg0x01[fls(qam) - fls(DVBFE_MOD_QAM4)]);
+	tda10021_writereg(state, 0x05, reg0x05[fls(qam) - fls(DVBFE_MOD_QAM4)]);
+	tda10021_writereg(state, 0x08, reg0x08[fls(qam) - fls(DVBFE_MOD_QAM4)]);
+	tda10021_writereg(state, 0x09, reg0x09[fls(qam) - fls(DVBFE_MOD_QAM4)]);
+
+	tda10021_setup_reg0(state, reg0x00[qam], p->inversion);
+
+	return 0;
+}
+
+static int tda10021_get_params(struct dvb_frontend* fe, struct dvbfe_params *p)
+{
+	struct tda10021_state* state = fe->demodulator_priv;
+	int sync;
+	s8 afc = 0;
+	u32 mod;
+
+	sync = tda10021_readreg(state, 0x11);
+	afc = tda10021_readreg(state, 0x19);
+	if (verbose) {
+		/* AFC only valid when carrier has been recovered */
+		printk(sync & 2 ? "DVB: TDA10021(%d): AFC (%d) %dHz\n" :
+				  "DVB: TDA10021(%d): [AFC (%d) %dHz]\n",
+			state->frontend.dvb->num, afc,
+		       -((s32)p->delsys.dvbc.symbol_rate * afc) >> 10);
+	}
+
+	p->inversion = HAS_INVERSION(state->reg0) ? INVERSION_ON : INVERSION_OFF;
+	mod = ((state->reg0 >> 2) & 7);
+	switch (mod) {
+	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:
+	case 7:
+		p->delsys.dvbc.modulation = DVBFE_MOD_QAM128;
+		break;
+	case 4:
+		p->delsys.dvbc.modulation = DVBFE_MOD_QAM256;
+		break;
+	case 5:
+		p->delsys.dvbc.modulation = DVBFE_MOD_QAM4;
+		break;
+	default:
+		break;
+	}
+
+	p->delsys.dvbc.fec = DVBFE_FEC_NONE;
+	p->frequency = ((p->frequency + 31250) / 62500) * 62500;
+
+	if (sync & 2)
+		p->frequency -= ((s32)p->delsys.dvbc.symbol_rate * afc) >> 10;
+
+	return 0;
+}
+
+static int tda10021_get_info(struct dvb_frontend *fe, struct dvbfe_info *fe_info)
+{
+	memcpy(fe_info, &dvbc_info, sizeof (dvbc_info));
+
+	return 0;
+}
+
+static int tda10021_get_delsys(struct dvb_frontend *fe, enum dvbfe_delsys *fe_delsys)
+{
+	*fe_delsys = DVBFE_DELSYS_DVBC;
+
+	return 0;
+}
+
 static struct dvb_frontend_ops tda10021_ops = {
 
 	.info = {
@@ -470,6 +595,11 @@ static struct dvb_frontend_ops tda10021_
 	.read_signal_strength = tda10021_read_signal_strength,
 	.read_snr = tda10021_read_snr,
 	.read_ucblocks = tda10021_read_ucblocks,
+
+	.set_params	= tda10021_set_params,
+	.get_params	= tda10021_get_params,
+	.get_info	= tda10021_get_info,
+	.get_delsys	= tda10021_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