PATCH 23/44 multiproto + backward compatibility [NXT200x]

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

 



--- v4l-dvb/linux/drivers/media/dvb/frontends/nxt200x.c	2006-06-30 19:59:10.000000000 +0400
+++ mp-bc1/linux/drivers/media/dvb/frontends/nxt200x.c	2006-07-23 11:39:25.000000000 +0400
@@ -547,8 +547,8 @@ static int nxt200x_setup_frontend_parame
 	}
 
 	/* get tuning information */
-	if (fe->ops.tuner_ops.calc_regs) {
-		fe->ops.tuner_ops.calc_regs(fe, p, buf, 5);
+	if (fe->ops.tuner_ops.calc_regs_compat) {
+		fe->ops.tuner_ops.calc_regs_compat(fe, p, buf, 5);
 	}
 
 	/* set additional params */
@@ -1209,6 +1209,309 @@ error:
 	return NULL;
 }
 
+static struct dvbfe_info nxt2002_info	= {
+	.name				= "Nextwave NXT2002 ATSC",
+	.delivery			= DVBFE_DELSYS_ATSC,
+	.delsys				= {
+		.atsc.modulation	= DVBFE_MOD_VSB8  | DVBFE_MOD_QAM64 |
+					  DVBFE_MOD_QAM256
+	},
+
+	.frequency_min			= 54000000,
+	.frequency_max			= 860000000,
+	.frequency_step			= 166666,
+};
+
+static struct dvbfe_info nxt2004_info	= {
+	.name				= "Nextwave NXT2004 ATSC",
+	.delivery			= DVBFE_DELSYS_ATSC,
+	.delsys				= {
+		.atsc.modulation	= DVBFE_MOD_VSB8  | DVBFE_MOD_QAM64 |
+					  DVBFE_MOD_QAM256
+	},
+
+	.frequency_min			= 54000000,
+	.frequency_max			= 860000000,
+	.frequency_step			= 166666,
+};
+
+static int nxt200x_set_params(struct dvb_frontend* fe,
+			      struct dvbfe_params *p)
+{
+	struct nxt200x_state* state = fe->demodulator_priv;
+	u8 buf[5];
+
+	/* stop the micro first */
+	nxt200x_microcontroller_stop(state);
+
+	if (state->demod_chip == NXT2004) {
+		/* make sure demod is set to digital */
+		buf[0] = 0x04;
+		nxt200x_writebytes(state, 0x14, buf, 1);
+		buf[0] = 0x00;
+		nxt200x_writebytes(state, 0x17, buf, 1);
+	}
+
+	/* get tuning information */
+	if (fe->ops.tuner_ops.calc_regs) {
+		fe->ops.tuner_ops.calc_regs(fe, p, buf, 5);
+	}
+
+	/* set additional params */
+	switch (p->delsys.atsc.modulation) {
+	case DVBFE_MOD_QAM64:
+	case DVBFE_MOD_QAM256:
+		/* Set punctured clock for QAM */
+		/* This is just a guess since I am unable to test it */
+		if (state->config->set_ts_params)
+			state->config->set_ts_params(fe, 1);
+
+		/* set input */
+		if (state->config->set_pll_input)
+			state->config->set_pll_input(buf, 1);
+		break;
+	case DVBFE_MOD_VSB8:
+		/* Set non-punctured clock for VSB */
+		if (state->config->set_ts_params)
+			state->config->set_ts_params(fe, 0);
+
+		/* set input */
+		if (state->config->set_pll_input)
+			state->config->set_pll_input(buf, 0);
+		break;
+	default:
+		return -EINVAL;
+		break;
+	}
+
+	/* write frequency information */
+	nxt200x_writetuner(state, buf);
+
+	/* reset the agc now that tuning has been completed */
+	nxt200x_agc_reset(state);
+
+	/* set target power level */
+	switch (p->delsys.atsc.modulation) {
+	case DVBFE_MOD_QAM64:
+	case DVBFE_MOD_QAM256:
+		buf[0] = 0x74;
+		break;
+	case DVBFE_MOD_VSB8:
+		buf[0] = 0x70;
+		break;
+	default:
+		return -EINVAL;
+		break;
+	}
+	nxt200x_writebytes(state, 0x42, buf, 1);
+
+	/* configure sdm */
+	switch (state->demod_chip) {
+	case NXT2002:
+		buf[0] = 0x87;
+		break;
+	case NXT2004:
+		buf[0] = 0x07;
+		break;
+	default:
+		return -EINVAL;
+		break;
+	}
+	nxt200x_writebytes(state, 0x57, buf, 1);
+
+	/* write sdm1 input */
+	buf[0] = 0x10;
+	buf[1] = 0x00;
+	switch (state->demod_chip) {
+	case NXT2002:
+		nxt200x_writereg_multibyte(state, 0x58, buf, 2);
+		break;
+	case NXT2004:
+		nxt200x_writebytes(state, 0x58, buf, 2);
+		break;
+	default:
+		return -EINVAL;
+			break;
+	}
+
+	/* write sdmx input */
+	switch (p->delsys.atsc.modulation) {
+	case DVBFE_MOD_QAM64:
+		buf[0] = 0x68;
+		break;
+	case DVBFE_MOD_QAM256:
+		buf[0] = 0x64;
+		break;
+	case DVBFE_MOD_VSB8:
+		buf[0] = 0x60;
+		break;
+	default:
+		return -EINVAL;
+		break;
+	}
+	buf[1] = 0x00;
+	switch (state->demod_chip) {
+	case NXT2002:
+		nxt200x_writereg_multibyte(state, 0x5C, buf, 2);
+		break;
+	case NXT2004:
+		nxt200x_writebytes(state, 0x5C, buf, 2);
+		break;
+	default:
+		return -EINVAL;
+		break;
+	}
+
+	/* write adc power lpf fc */
+	buf[0] = 0x05;
+	nxt200x_writebytes(state, 0x43, buf, 1);
+
+	if (state->demod_chip == NXT2004) {
+		/* write ??? */
+		buf[0] = 0x00;
+		buf[1] = 0x00;
+		nxt200x_writebytes(state, 0x46, buf, 2);
+	}
+
+	/* write accumulator2 input */
+	buf[0] = 0x80;
+	buf[1] = 0x00;
+	switch (state->demod_chip) {
+	case NXT2002:
+		nxt200x_writereg_multibyte(state, 0x4B, buf, 2);
+		break;
+	case NXT2004:
+		nxt200x_writebytes(state, 0x4B, buf, 2);
+		break;
+	default:
+		return -EINVAL;
+		break;
+	}
+
+	/* write kg1 */
+	buf[0] = 0x00;
+	nxt200x_writebytes(state, 0x4D, buf, 1);
+
+	/* write sdm12 lpf fc */
+	buf[0] = 0x44;
+	nxt200x_writebytes(state, 0x55, buf, 1);
+
+	/* write agc control reg */
+	buf[0] = 0x04;
+	nxt200x_writebytes(state, 0x41, buf, 1);
+
+	if (state->demod_chip == NXT2004) {
+		nxt200x_readreg_multibyte(state, 0x80, buf, 1);
+		buf[0] = 0x24;
+		nxt200x_writereg_multibyte(state, 0x80, buf, 1);
+
+		/* soft reset? */
+		nxt200x_readreg_multibyte(state, 0x08, buf, 1);
+		buf[0] = 0x10;
+		nxt200x_writereg_multibyte(state, 0x08, buf, 1);
+		nxt200x_readreg_multibyte(state, 0x08, buf, 1);
+		buf[0] = 0x00;
+		nxt200x_writereg_multibyte(state, 0x08, buf, 1);
+
+		nxt200x_readreg_multibyte(state, 0x80, buf, 1);
+		buf[0] = 0x04;
+		nxt200x_writereg_multibyte(state, 0x80, buf, 1);
+		buf[0] = 0x00;
+		nxt200x_writereg_multibyte(state, 0x81, buf, 1);
+		buf[0] = 0x80; buf[1] = 0x00; buf[2] = 0x00;
+		nxt200x_writereg_multibyte(state, 0x82, buf, 3);
+		nxt200x_readreg_multibyte(state, 0x88, buf, 1);
+		buf[0] = 0x11;
+		nxt200x_writereg_multibyte(state, 0x88, buf, 1);
+		nxt200x_readreg_multibyte(state, 0x80, buf, 1);
+		buf[0] = 0x44;
+		nxt200x_writereg_multibyte(state, 0x80, buf, 1);
+	}
+
+	/* write agc ucgp0 */
+	switch (p->delsys.atsc.modulation) {
+	case DVBFE_MOD_QAM64:
+		buf[0] = 0x02;
+		break;
+	case DVBFE_MOD_QAM256:
+		buf[0] = 0x03;
+		break;
+	case DVBFE_MOD_VSB8:
+		buf[0] = 0x00;
+		break;
+	default:
+		return -EINVAL;
+		break;
+	}
+	nxt200x_writebytes(state, 0x30, buf, 1);
+
+	/* write agc control reg */
+	buf[0] = 0x00;
+	nxt200x_writebytes(state, 0x41, buf, 1);
+
+	/* write accumulator2 input */
+	buf[0] = 0x80;
+	buf[1] = 0x00;
+	switch (state->demod_chip) {
+	case NXT2002:
+		nxt200x_writereg_multibyte(state, 0x49, buf, 2);
+		nxt200x_writereg_multibyte(state, 0x4B, buf, 2);
+		break;
+	case NXT2004:
+		nxt200x_writebytes(state, 0x49, buf, 2);
+		nxt200x_writebytes(state, 0x4B, buf, 2);
+		break;
+	default:
+		return -EINVAL;
+		break;
+	}
+
+	/* write agc control reg */
+	buf[0] = 0x04;
+	nxt200x_writebytes(state, 0x41, buf, 1);
+
+	nxt200x_microcontroller_start(state);
+
+	if (state->demod_chip == NXT2004) {
+		nxt2004_microcontroller_init(state);
+
+		/* ???? */
+		buf[0] = 0xF0;
+		buf[1] = 0x00;
+		nxt200x_writebytes(state, 0x5C, buf, 2);
+	}
+
+	/* adjacent channel detection should be done here, but I don't
+	have any stations with this need so I cannot test it */
+
+	return 0;
+}
+
+static int nxt200x_get_info(struct dvb_frontend *fe, struct dvbfe_info *fe_info)
+{
+	struct nxt200x_state *state = fe->demodulator_priv;
+
+	switch (state->demod_chip) {
+	case NXT2002:
+		memcpy(fe_info, &nxt2002_info, sizeof (nxt2002_info));
+		break;
+	case NXT2004:
+		memcpy(fe_info, &nxt2004_info, sizeof (nxt2004_info));
+		break;
+	default:
+		break;
+	}
+
+	return 0;
+}
+
+static int nxt200x_get_delsys(struct dvb_frontend *fe, enum dvbfe_delsys *fe_delsys)
+{
+	*fe_delsys = DVBFE_DELSYS_DVBS;
+
+	return 0;
+}
+
 static struct dvb_frontend_ops nxt200x_ops = {
 
 	.info = {
@@ -1235,6 +1538,10 @@ static struct dvb_frontend_ops nxt200x_o
 	.read_signal_strength = nxt200x_read_signal_strength,
 	.read_snr = nxt200x_read_snr,
 	.read_ucblocks = nxt200x_read_ucblocks,
+
+	.set_params	= nxt200x_set_params,
+	.get_info	= nxt200x_get_info,
+	.get_delsys	= nxt200x_get_delsys,
 };
 
 module_param(debug, int, 0644);
@@ -1245,4 +1552,3 @@ MODULE_AUTHOR("Kirk Lapray, Michael Kruf
 MODULE_LICENSE("GPL");
 
 EXPORT_SYMBOL(nxt200x_attach);
-
_______________________________________________

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