PATCH 19/44 multiproto + backward compatibility [LGDT330x]

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

 



--- v4l-dvb/linux/drivers/media/dvb/frontends/lgdt330x.c	2006-06-30 19:59:10.000000000 +0400
+++ mp-bc1/linux/drivers/media/dvb/frontends/lgdt330x.c	2006-07-23 11:38:50.000000000 +0400
@@ -399,9 +399,134 @@ static int lgdt330x_set_parameters(struc
 	}
 
 	/* Tune to the specified frequency */
+	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);
+	}
+
+	/* Keep track of the new frequency */
+	/* FIXME this is the wrong way to do this...           */
+	/* The tuner is shared with the video4linux analog API */
+	state->current_frequency = param->frequency;
+
+	lgdt330x_SwReset(state);
+	return 0;
+}
+
+static int lgdt330x_set_params(struct dvb_frontend* fe,
+			       struct dvbfe_params *param)
+{
+	/*
+	 * Array of byte pairs <address, value>
+	 * to initialize 8VSB for lgdt3303 chip 50 MHz IF
+	 */
+	static u8 lgdt3303_8vsb_44_data[] = {
+		0x04, 0x00,
+		0x0d, 0x40,
+		0x0e, 0x87,
+		0x0f, 0x8e,
+		0x10, 0x01,
+		0x47, 0x8b
+	};
+
+	/*
+	 * Array of byte pairs <address, value>
+	 * to initialize QAM for lgdt3303 chip
+	 */
+	static u8 lgdt3303_qam_data[] = {
+		0x04, 0x00,
+		0x0d, 0x00,
+		0x0e, 0x00,
+		0x0f, 0x00,
+		0x10, 0x00,
+		0x51, 0x63,
+		0x47, 0x66,
+		0x48, 0x66,
+		0x4d, 0x1a,
+		0x49, 0x08,
+		0x4a, 0x9b
+	};
+
+	struct lgdt330x_state* state = fe->demodulator_priv;
+
+	static u8 top_ctrl_cfg[]   = { TOP_CONTROL, 0x03 };
+
+	int err;
+	/* Change only if we are actually changing the modulation */
+	if (state->current_modulation != param->delsys.atsc.modulation) {
+		switch(param->delsys.atsc.modulation) {
+		case DVBFE_MOD_VSB8:
+			dprintk("%s: 8VSB MODE\n", __FUNCTION__);
+
+			/* Select VSB mode */
+			top_ctrl_cfg[1] = 0x03;
+
+			/* Select ANT connector if supported by card */
+			if (state->config->pll_rf_set)
+				state->config->pll_rf_set(fe, 1);
+
+			if (state->config->demod_chip == LGDT3303) {
+				err = i2c_write_demod_bytes(state, lgdt3303_8vsb_44_data,
+							    sizeof (lgdt3303_8vsb_44_data));
+			}
+			break;
+
+		case DVBFE_MOD_QAM64:
+			dprintk("%s: QAM64 MODE\n", __FUNCTION__);
+
+			/* Select QAM_64 mode */
+			top_ctrl_cfg[1] = 0x00;
+
+			/* Select CABLE connector if supported by card */
+			if (state->config->pll_rf_set)
+				state->config->pll_rf_set(fe, 0);
+
+			if (state->config->demod_chip == LGDT3303) {
+				err = i2c_write_demod_bytes(state, lgdt3303_qam_data,
+											sizeof(lgdt3303_qam_data));
+			}
+			break;
+
+		case DVBFE_MOD_QAM256:
+			dprintk("%s: QAM_256 MODE\n", __FUNCTION__);
+
+			/* Select QAM_256 mode */
+			top_ctrl_cfg[1] = 0x01;
+
+			/* Select CABLE connector if supported by card */
+			if (state->config->pll_rf_set)
+				state->config->pll_rf_set(fe, 0);
+
+			if (state->config->demod_chip == LGDT3303) {
+				err = i2c_write_demod_bytes(state, lgdt3303_qam_data,
+											sizeof(lgdt3303_qam_data));
+			}
+			break;
+		default:
+			printk(KERN_WARNING "lgdt330x: %s: Modulation type(%d) UNSUPPORTED\n", __FUNCTION__, param->delsys.atsc.modulation);
+			return -1;
+		}
+		/*
+		 * select serial or parallel MPEG harware interface
+		 * Serial:   0x04 for LGDT3302 or 0x40 for LGDT3303
+		 * Parallel: 0x00
+		 */
+		top_ctrl_cfg[1] |= state->config->serial_mpeg;
+
+		/* Select the requested mode */
+		i2c_write_demod_bytes(state, top_ctrl_cfg,
+				      sizeof(top_ctrl_cfg));
+		if (state->config->set_ts_params)
+			state->config->set_ts_params(fe, 0);
+		state->current_modulation = param->delsys.atsc.modulation;
+	}
+
+	/* Tune to the specified frequency */
 	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.i2c_gate_ctrl)
+			fe->ops.i2c_gate_ctrl(fe, 0);
 	}
 
 	/* Keep track of the new frequency */
@@ -421,6 +546,14 @@ static int lgdt330x_get_frontend(struct 
 	return 0;
 }
 
+static int lgdt330x_get_params(struct dvb_frontend* fe,
+			       struct dvbfe_params* param)
+{
+	struct lgdt330x_state *state = fe->demodulator_priv;
+	param->frequency = state->current_frequency;
+	return 0;
+}
+
 static int lgdt3302_read_status(struct dvb_frontend* fe, fe_status_t* status)
 {
 	struct lgdt330x_state* state = fe->demodulator_priv;
@@ -769,6 +902,60 @@ error:
 	return NULL;
 }
 
+static struct dvbfe_info lgdt3302_info	= {
+	.name				= "LG LGDT3302 ATSC",
+	.delivery			= DVBFE_DELSYS_ATSC,
+	.delsys				= {
+		.atsc.modulation	= DVBFE_MOD_VSB8  | DVBFE_MOD_QAM64 |
+					  DVBFE_MOD_QAM256
+	},
+
+	.frequency_min			= 54000000,
+	.frequency_max			= 858000000,
+	.frequency_step			= 62500,
+	.symbol_rate_min		= 5056941,
+	.symbol_rate_max		= 10762000
+};
+
+static struct dvbfe_info lgdt3303_info	= {
+	.name				= "LG LGDT3302 ATSC",
+	.delivery			= DVBFE_DELSYS_ATSC,
+	.delsys				= {
+		.atsc.modulation	= DVBFE_MOD_VSB8  | DVBFE_MOD_QAM64 |
+					  DVBFE_MOD_QAM256
+	},
+
+	.frequency_min			= 54000000,
+	.frequency_max			= 858000000,
+	.frequency_step			= 62500,
+	.symbol_rate_min		= 5056941,
+	.symbol_rate_max		= 10762000
+};
+
+static int lgdt330x_get_info(struct dvb_frontend *fe, struct dvbfe_info *fe_info)
+{
+	struct lgdt330x_state *state = fe->demodulator_priv;
+
+	switch(state->config->demod_chip) {
+	case LGDT3302:
+		memcpy(fe_info, &lgdt3302_info, sizeof (lgdt3302_info));
+		break;
+	case LGDT3303:
+		memcpy(fe_info, &lgdt3303_info, sizeof (lgdt3303_info));
+		break;
+	default:
+		break;
+	}
+	return 0;
+}
+
+static int lgdt330x_get_delsys(struct dvb_frontend *fe, enum dvbfe_delsys *fe_delsys)
+{
+	*fe_delsys = DVBFE_DELSYS_DVBS;
+
+	return 0;
+}
+
 static struct dvb_frontend_ops lgdt3302_ops = {
 	.info = {
 		.name= "LG Electronics LGDT3302 VSB/QAM Frontend",
@@ -790,6 +977,11 @@ static struct dvb_frontend_ops lgdt3302_
 	.read_snr             = lgdt3302_read_snr,
 	.read_ucblocks        = lgdt330x_read_ucblocks,
 	.release              = lgdt330x_release,
+
+	.set_params	= lgdt330x_set_params,
+	.get_params	= lgdt330x_get_params,
+	.get_info	= lgdt330x_get_info,
+	.get_delsys	= lgdt330x_get_delsys,
 };
 
 static struct dvb_frontend_ops lgdt3303_ops = {
@@ -813,6 +1005,11 @@ static struct dvb_frontend_ops lgdt3303_
 	.read_snr             = lgdt3303_read_snr,
 	.read_ucblocks        = lgdt330x_read_ucblocks,
 	.release              = lgdt330x_release,
+
+	.set_params	= lgdt330x_set_params,
+	.get_params	= lgdt330x_get_params,
+	.get_info	= lgdt330x_get_info,
+	.get_delsys	= lgdt330x_get_delsys,
 };
 
 MODULE_DESCRIPTION("LGDT330X (ATSC 8VSB & ITU-T J.83 AnnexB 64/256 QAM) Demodulator Driver");
_______________________________________________

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