PATCH 25/44 multiproto + backward compatibility [OR51132]

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

 



--- v4l-dvb/linux/drivers/media/dvb/frontends/or51132.c	2006-06-30 19:59:10.000000000 +0400
+++ mp-bc1/linux/drivers/media/dvb/frontends/or51132.c	2006-07-23 11:39:50.000000000 +0400
@@ -382,9 +382,81 @@ static int or51132_set_parameters(struct
 		or51132_setmode(fe);
 	}
 
+	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);
+	}
+
+	/* Set to current mode */
+	or51132_setmode(fe);
+
+	/* Update current frequency */
+	state->current_frequency = param->frequency;
+	return 0;
+}
+
+static int or51132_set_params(struct dvb_frontend* fe,
+			      struct dvbfe_params *param)
+{
+	int ret;
+	struct or51132_state* state = fe->demodulator_priv;
+	const struct firmware *fw;
+	const char *fwname;
+	int clock_mode;
+
+	/* Upload new firmware only if we need a different one */
+	if (modulation_fw_class(state->current_modulation) !=
+	    modulation_fw_class(param->delsys.atsc.modulation)) {
+		switch(modulation_fw_class(param->delsys.atsc.modulation)) {
+		case DVBFE_MOD_VSB8:
+			dprintk("set_parameters VSB MODE\n");
+			fwname = OR51132_VSB_FIRMWARE;
+
+			/* Set non-punctured clock for VSB */
+			clock_mode = 0;
+			break;
+		case DVBFE_MOD_QAM64:
+		case DVBFE_MOD_QAM256:
+			dprintk("set_parameters QAM MODE\n");
+			fwname = OR51132_QAM_FIRMWARE;
+
+			/* Set punctured clock for QAM */
+			clock_mode = 1;
+			break;
+		default:
+			printk("or51132: Modulation type(%d) UNSUPPORTED\n",
+			       param->delsys.atsc.modulation);
+			return -1;
+		}
+		printk("or51132: Waiting for firmware upload(%s)...\n",
+		       fwname);
+		ret = request_firmware(&fw, fwname, &state->i2c->dev);
+		if (ret) {
+			printk(KERN_WARNING "or51132: No firmware up"
+			       "loaded(timeout or file not found?)\n");
+			return ret;
+		}
+		ret = or51132_load_firmware(fe, fw);
+		release_firmware(fw);
+		if (ret) {
+			printk(KERN_WARNING "or51132: Writing firmware to "
+			       "device failed!\n");
+			return ret;
+		}
+		printk("or51132: Firmware upload complete.\n");
+		state->config->set_ts_params(fe, clock_mode);
+	}
+	/* Change only if we are actually changing the modulation */
+	if (state->current_modulation != param->delsys.atsc.modulation) {
+		state->current_modulation = param->delsys.atsc.modulation;
+		or51132_setmode(fe);
+	}
+
 	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);
 	}
 
 	/* Set to current mode */
@@ -433,6 +505,50 @@ static int or51132_get_parameters(struct
 	return 0;
 }
 
+static int or51132_get_params(struct dvb_frontend* fe,
+			      struct dvbfe_params *param)
+{
+	struct or51132_state* state = fe->demodulator_priv;
+	u8 buf[2];
+
+	/* Receiver Status */
+	buf[0]=0x04;
+	buf[1]=0x00;
+	msleep(30); /* 30ms */
+	if (i2c_writebytes(state,state->config->demod_address,buf,2)) {
+		printk(KERN_WARNING "or51132: get_parameters write error\n");
+		return -EREMOTEIO;
+	}
+	msleep(30); /* 30ms */
+	if (i2c_readbytes(state,state->config->demod_address,buf,2)) {
+		printk(KERN_WARNING "or51132: get_parameters read error\n");
+		return -EREMOTEIO;
+	}
+	switch(buf[0]) {
+	case 0x06:
+		param->delsys.atsc.modulation = DVBFE_MOD_VSB8;
+		break;
+	case 0x43:
+		param->delsys.atsc.modulation = DVBFE_MOD_QAM64;
+		break;
+	case 0x45:
+		param->delsys.atsc.modulation = DVBFE_MOD_QAM256;
+		break;
+	default:
+		printk(KERN_WARNING "or51132: unknown status 0x%02x\n",
+		       buf[0]);
+		return -EREMOTEIO;
+	}
+
+	/* FIXME: Read frequency from frontend, take AFC into account */
+	param->frequency = state->current_frequency;
+
+	/* FIXME: How to read inversion setting? Receiver 6 register? */
+	param->inversion = INVERSION_AUTO;
+
+	return 0;
+}
+
 static int or51132_read_status(struct dvb_frontend* fe, fe_status_t* status)
 {
 	struct or51132_state* state = fe->demodulator_priv;
@@ -630,6 +746,33 @@ error:
 	return NULL;
 }
 
+static struct dvbfe_info atsc_info	= {
+	.name				= "Oren OR51132 ATSC",
+	.delivery			= DVBFE_DELSYS_ATSC,
+	.delsys				= {
+		.atsc.modulation	= DVBFE_MOD_VSB8  |DVBFE_MOD_QAM64 |
+					  DVBFE_MOD_QAM256
+	},
+
+	.frequency_min			= 44000000,
+	.frequency_max			= 958000000,
+	.frequency_step			= 166666,
+};
+
+static int or51132_get_info(struct dvb_frontend *fe, struct dvbfe_info *fe_info)
+{
+	memcpy(fe_info, &atsc_info, sizeof (atsc_info));
+
+	return 0;
+}
+
+static int or51132_get_delsys(struct dvb_frontend *fe, enum dvbfe_delsys *fe_delsys)
+{
+	*fe_delsys = DVBFE_DELSYS_ATSC;
+
+	return 0;
+}
+
 static struct dvb_frontend_ops or51132_ops = {
 
 	.info = {
@@ -658,6 +801,11 @@ static struct dvb_frontend_ops or51132_o
 	.read_signal_strength = or51132_read_signal_strength,
 	.read_snr = or51132_read_snr,
 	.read_ucblocks = or51132_read_ucblocks,
+
+	.set_params	= or51132_set_params,
+	.get_params	= or51132_get_params,
+	.get_info	= or51132_get_info,
+	.get_delsys	= or51132_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