PATCH 36/44 multiproto + backward compatibility [TDA8083]

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

 




--- v4l-dvb/linux/drivers/media/dvb/frontends/tda8083.c	2006-06-30 19:59:10.000000000 +0400
+++ mp-bc1/linux/drivers/media/dvb/frontends/tda8083.c	2006-07-23 11:41:03.000000000 +0400
@@ -107,7 +107,7 @@ static int tda8083_set_inversion (struct
 	return -EINVAL;
 }
 
-static int tda8083_set_fec (struct tda8083_state* state, fe_code_rate_t fec)
+static int tda8083_set_fec_compat(struct tda8083_state* state, fe_code_rate_t fec)
 {
 	if (fec == FEC_AUTO)
 		return tda8083_writereg (state, 0x07, 0xff);
@@ -118,7 +118,29 @@ static int tda8083_set_fec (struct tda80
 	return -EINVAL;
 }
 
-static fe_code_rate_t tda8083_get_fec (struct tda8083_state* state)
+static int tda8083_set_fec(struct tda8083_state* state, enum dvbfe_fec fec)
+{
+	switch (fec) {
+	case DVBFE_FEC_AUTO:
+		return tda8083_writereg(state, 0x07, 0xff);
+	case DVBFE_FEC_1_2:
+		return tda8083_writereg(state, 0x07, (1 << 7));
+	case DVBFE_FEC_2_3:
+		return tda8083_writereg(state, 0x07, (1 << 6));
+	case DVBFE_FEC_3_4:
+		return tda8083_writereg(state, 0x07, (1 << 5));
+	case DVBFE_FEC_5_6:
+		return tda8083_writereg(state, 0x07, (1 << 4));
+	case DVBFE_FEC_7_8:
+		return tda8083_writereg(state, 0x07, (1 << 1));
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static fe_code_rate_t tda8083_get_fec_compat(struct tda8083_state* state)
 {
 	u8 index;
 	static fe_code_rate_t fec_tab [] = { FEC_8_9, FEC_1_2, FEC_2_3, FEC_3_4,
@@ -129,6 +151,26 @@ static fe_code_rate_t tda8083_get_fec (s
 	return fec_tab [index];
 }
 
+static fe_code_rate_t tda8083_get_fec(struct tda8083_state* state)
+{
+	u8 index;
+
+	enum dvbfe_fec fec_tab [] = {
+		DVBFE_FEC_8_9,
+		DVBFE_FEC_1_2,
+		DVBFE_FEC_2_3,
+		DVBFE_FEC_3_4,
+		DVBFE_FEC_4_5,
+		DVBFE_FEC_5_6,
+		DVBFE_FEC_6_7,
+		DVBFE_FEC_7_8
+	};
+
+	index = tda8083_readreg(state, 0x0e) & 0x07;
+
+	return fec_tab[index];
+}
+
 static int tda8083_set_symbolrate (struct tda8083_state* state, u32 srate)
 {
 	u32 ratio;
@@ -292,13 +334,14 @@ static int tda8083_set_frontend(struct d
 {
 	struct tda8083_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);
+	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);
 	}
 
-	tda8083_set_inversion (state, p->inversion);
-	tda8083_set_fec (state, p->u.qpsk.fec_inner);
+	tda8083_set_inversion(state, p->inversion);
+	tda8083_set_fec_compat(state, p->u.qpsk.fec_inner);
 	tda8083_set_symbolrate (state, p->u.qpsk.symbol_rate);
 
 	tda8083_writereg (state, 0x00, 0x3c);
@@ -307,7 +350,29 @@ static int tda8083_set_frontend(struct d
 	return 0;
 }
 
-static int tda8083_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+static int tda8083_set_params(struct dvb_frontend* fe,
+			      struct dvbfe_params *p)
+{
+	struct tda8083_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);
+	}
+
+	tda8083_set_inversion(state, p->inversion);
+	tda8083_set_fec(state, p->delsys.dvbs.fec);
+	tda8083_set_symbolrate(state, p->delsys.dvbs.symbol_rate);
+
+	tda8083_writereg(state, 0x00, 0x3c);
+	tda8083_writereg(state, 0x00, 0x04);
+
+	return 0;
+}
+
+static int tda8083_get_frontend(struct dvb_frontend* fe,
+				struct dvb_frontend_parameters *p)
 {
 	struct tda8083_state* state = fe->demodulator_priv;
 
@@ -315,7 +380,22 @@ static int tda8083_get_frontend(struct d
 	/*p->frequency = ???;*/
 	p->inversion = (tda8083_readreg (state, 0x0e) & 0x80) ?
 			INVERSION_ON : INVERSION_OFF;
-	p->u.qpsk.fec_inner = tda8083_get_fec (state);
+	p->u.qpsk.fec_inner = tda8083_get_fec_compat(state);
+	/*p->u.qpsk.symbol_rate = tda8083_get_symbolrate (state);*/
+
+	return 0;
+}
+
+static int tda8083_get_params(struct dvb_frontend* fe,
+			      struct dvbfe_params *p)
+{
+	struct tda8083_state* state = fe->demodulator_priv;
+
+	/*  FIXME: get symbolrate & frequency offset...*/
+	/*p->frequency = ???;*/
+	p->inversion = (tda8083_readreg (state, 0x0e) & 0x80) ?
+			INVERSION_ON : INVERSION_OFF;
+	p->delsys.dvbs.fec = tda8083_get_fec(state);
 	/*p->u.qpsk.symbol_rate = tda8083_get_symbolrate (state);*/
 
 	return 0;
@@ -410,6 +490,37 @@ error:
 	return NULL;
 }
 
+static struct dvbfe_info dvbs_info	= {
+	.name				= "Philips TDA8083 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			= 1400000,
+	.frequency_step			= 125,
+	.symbol_rate_min		= 1000000,
+	.symbol_rate_max		= 45000000,
+};
+
+static int tda8083_get_info(struct dvb_frontend *fe, struct dvbfe_info *fe_info)
+{
+	memcpy(fe_info, &dvbs_info, sizeof (dvbs_info));
+
+	return 0;
+}
+
+static int tda8083_get_delsys(struct dvb_frontend *fe, enum dvbfe_delsys *fe_delsys)
+{
+	*fe_delsys = DVBFE_DELSYS_DVBS;
+
+	return 0;
+}
+
 static struct dvb_frontend_ops tda8083_ops = {
 
 	.info = {
@@ -445,6 +556,11 @@ static struct dvb_frontend_ops tda8083_o
 	.diseqc_send_burst = tda8083_diseqc_send_burst,
 	.set_tone = tda8083_diseqc_set_tone,
 	.set_voltage = tda8083_diseqc_set_voltage,
+
+	.set_params	= tda8083_set_params,
+	.get_params	= tda8083_get_params,
+	.get_info	= tda8083_get_info,
+	.get_delsys	= tda8083_get_delsys,
 };
 
 module_param(debug, 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