PATCH 24/44 multiproto + backward compatibility [NXT6000]

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

 




--- v4l-dvb/linux/drivers/media/dvb/frontends/nxt6000.c	2006-06-30 19:59:10.000000000 +0400
+++ mp-bc1/linux/drivers/media/dvb/frontends/nxt6000.c	2006-07-23 11:39:35.000000000 +0400
@@ -81,7 +81,7 @@ static void nxt6000_reset(struct nxt6000
 	nxt6000_writereg(state, OFDM_COR_CTL, val | COREACT);
 }
 
-static int nxt6000_set_bandwidth(struct nxt6000_state* state, fe_bandwidth_t bandwidth)
+static int nxt6000_set_bandwidth_compat(struct nxt6000_state* state, fe_bandwidth_t bandwidth)
 {
 	u16 nominal_rate;
 	int result;
@@ -110,7 +110,33 @@ static int nxt6000_set_bandwidth(struct 
 	return nxt6000_writereg(state, OFDM_TRL_NOMINALRATE_2, (nominal_rate >> 8) & 0xFF);
 }
 
-static int nxt6000_set_guard_interval(struct nxt6000_state* state, fe_guard_interval_t guard_interval)
+static int nxt6000_set_bandwidth(struct nxt6000_state* state,
+				 enum dvbfe_bandwidth bandwidth)
+{
+	u16 nominal_rate;
+	int result;
+
+	switch (bandwidth) {
+	case DVBFE_BANDWIDTH_6_MHZ:
+		nominal_rate = 0x55B7;
+		break;
+	case DVBFE_BANDWIDTH_7_MHZ:
+		nominal_rate = 0x6400;
+		break;
+	case DVBFE_BANDWIDTH_8_MHZ:
+		nominal_rate = 0x7249;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	if ((result = nxt6000_writereg(state, OFDM_TRL_NOMINALRATE_1, nominal_rate & 0xFF)) < 0)
+		return result;
+
+	return nxt6000_writereg(state, OFDM_TRL_NOMINALRATE_2, (nominal_rate >> 8) & 0xFF);
+}
+
+static int nxt6000_set_guard_interval_compat(struct nxt6000_state* state, fe_guard_interval_t guard_interval)
 {
 	switch (guard_interval) {
 
@@ -132,6 +158,23 @@ static int nxt6000_set_guard_interval(st
 	}
 }
 
+static int nxt6000_set_guard_interval(struct nxt6000_state* state, enum dvbfe_guard_interval guard_interval)
+{
+	switch (guard_interval) {
+	case DVBFE_GUARD_INTERVAL_1_32:
+		return nxt6000_writereg(state, OFDM_COR_MODEGUARD, 0x00 | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x03));
+	case DVBFE_GUARD_INTERVAL_1_16:
+		return nxt6000_writereg(state, OFDM_COR_MODEGUARD, 0x01 | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x03));
+	case DVBFE_GUARD_INTERVAL_AUTO:
+	case DVBFE_GUARD_INTERVAL_1_8:
+		return nxt6000_writereg(state, OFDM_COR_MODEGUARD, 0x02 | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x03));
+	case DVBFE_GUARD_INTERVAL_1_4:
+		return nxt6000_writereg(state, OFDM_COR_MODEGUARD, 0x03 | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x03));
+	default:
+		return -EINVAL;
+	}
+}
+
 static int nxt6000_set_inversion(struct nxt6000_state* state, fe_spectral_inversion_t inversion)
 {
 	switch (inversion) {
@@ -148,7 +191,7 @@ static int nxt6000_set_inversion(struct 
 	}
 }
 
-static int nxt6000_set_transmission_mode(struct nxt6000_state* state, fe_transmit_mode_t transmission_mode)
+static int nxt6000_set_transmission_mode_compat(struct nxt6000_state* state, fe_transmit_mode_t transmission_mode)
 {
 	int result;
 
@@ -173,6 +216,27 @@ static int nxt6000_set_transmission_mode
 	}
 }
 
+static int nxt6000_set_transmission_mode(struct nxt6000_state* state, enum dvbfe_transmission_mode transmission_mode)
+{
+	int result;
+
+	switch (transmission_mode) {
+	case DVBFE_TRANSMISSION_MODE_2K:
+		if ((result = nxt6000_writereg(state, EN_DMD_RACQ, 0x00 | (nxt6000_readreg(state, EN_DMD_RACQ) & ~0x03))) < 0)
+			return result;
+		return nxt6000_writereg(state, OFDM_COR_MODEGUARD, (0x00 << 2) | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x04));
+	case DVBFE_TRANSMISSION_MODE_8K:
+	case DVBFE_TRANSMISSION_MODE_AUTO:
+		if ((result = nxt6000_writereg(state, EN_DMD_RACQ, 0x02 | (nxt6000_readreg(state, EN_DMD_RACQ) & ~0x03))) < 0)
+			return result;
+
+		return nxt6000_writereg(state, OFDM_COR_MODEGUARD, (0x01 << 2) | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x04));
+	default:
+		return -EINVAL;
+
+	}
+}
+
 static void nxt6000_setup(struct dvb_frontend* fe)
 {
 	struct nxt6000_state* state = fe->demodulator_priv;
@@ -462,16 +526,17 @@ static int nxt6000_set_frontend(struct d
 	struct nxt6000_state* state = fe->demodulator_priv;
 	int result;
 
-	if (fe->ops.tuner_ops.set_params) {
-		fe->ops.tuner_ops.set_params(fe, param);
-		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, param);
+		if (fe->ops.i2c_gate_ctrl)
+			fe->ops.i2c_gate_ctrl(fe, 0);
 	}
 
-	if ((result = nxt6000_set_bandwidth(state, param->u.ofdm.bandwidth)) < 0)
+	if ((result = nxt6000_set_bandwidth_compat(state, param->u.ofdm.bandwidth)) < 0)
 		return result;
-	if ((result = nxt6000_set_guard_interval(state, param->u.ofdm.guard_interval)) < 0)
+	if ((result = nxt6000_set_guard_interval_compat(state, param->u.ofdm.guard_interval)) < 0)
 		return result;
-	if ((result = nxt6000_set_transmission_mode(state, param->u.ofdm.transmission_mode)) < 0)
+	if ((result = nxt6000_set_transmission_mode_compat(state, param->u.ofdm.transmission_mode)) < 0)
 		return result;
 	if ((result = nxt6000_set_inversion(state, param->inversion)) < 0)
 		return result;
@@ -565,6 +630,62 @@ error:
 	return NULL;
 }
 
+static struct dvbfe_info dvbt_info	= {
+	.name				= "Nextwave NXT6000 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			= 0,
+	.frequency_max			= 863250000,
+	.frequency_step			= 62500,
+	.symbol_rate_min		= 0,
+	.symbol_rate_max		= 9360000,
+	.symbol_rate_tolerance		= 4000,
+};
+
+static int nxt6000_set_params(struct dvb_frontend* fe,
+			      struct dvbfe_params *param)
+{
+	struct nxt6000_state* state = fe->demodulator_priv;
+	int result;
+
+	if (fe->ops.tuner_ops.set_params) {
+		fe->ops.tuner_ops.set_params(fe, param);
+		if (fe->ops.i2c_gate_ctrl)
+			fe->ops.i2c_gate_ctrl(fe, 0);
+	}
+
+	if ((result = nxt6000_set_bandwidth(state, param->delsys.dvbt.bandwidth)) < 0)
+		return result;
+	if ((result = nxt6000_set_guard_interval(state, param->delsys.dvbt.guard_interval)) < 0)
+		return result;
+	if ((result = nxt6000_set_transmission_mode(state, param->delsys.dvbt.transmission_mode)) < 0)
+		return result;
+	if ((result = nxt6000_set_inversion(state, param->inversion)) < 0)
+		return result;
+
+	msleep(500);
+	return 0;
+}
+
+static int nxt6000_get_info(struct dvb_frontend *fe, struct dvbfe_info *fe_info)
+{
+	memcpy(fe_info, &dvbt_info, sizeof (dvbt_info));
+
+	return 0;
+}
+
+static int nxt6000_get_delsys(struct dvb_frontend *fe, enum dvbfe_delsys *fe_delsys)
+{
+	*fe_delsys = DVBFE_DELSYS_DVBT;
+
+	return 0;
+}
+
 static struct dvb_frontend_ops nxt6000_ops = {
 
 	.info = {
@@ -598,6 +719,10 @@ static struct dvb_frontend_ops nxt6000_o
 	.read_ber = nxt6000_read_ber,
 	.read_signal_strength = nxt6000_read_signal_strength,
 	.read_snr = nxt6000_read_snr,
+
+	.set_params	= nxt6000_set_params,
+	.get_info	= nxt6000_get_info,
+	.get_delsys	= nxt6000_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