PATCH 27/44 multiproto + backward compatibility [PLUTO2]

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

 



diff -Naurp v4l-dvb/linux/drivers/media/dvb/pluto2/pluto2.c mp-bc1/linux/drivers/media/dvb/pluto2/pluto2.c
--- v4l-dvb/linux/drivers/media/dvb/pluto2/pluto2.c	2006-06-30 19:59:10.000000000 +0400
+++ mp-bc1/linux/drivers/media/dvb/pluto2/pluto2.c	2006-07-23 11:44:35.000000000 +0400
@@ -4,7 +4,7 @@
  * Copyright (C) 2005 Andreas Oberritter <obi@xxxxxxxxxxx>
  *
  * based on pluto2.c 1.10 - http://instinct-wp8.no-ip.org/pluto/
- * 	by Dany Salman <salmandany@xxxxxxxx>
+ *	by Dany Salman <salmandany@xxxxxxxx>
  *	Copyright (c) 2004 TDF
  *
  * This program is free software; you can redistribute it and/or modify
@@ -424,8 +424,8 @@ static inline u32 divide(u32 numerator, 
 }
 
 /* LG Innotek TDTE-E001P (Infineon TUA6034) */
-static int lg_tdtpe001p_tuner_set_params(struct dvb_frontend *fe,
-					 struct dvb_frontend_parameters *p)
+static int lg_tdtpe001p_tuner_set_params_compat(struct dvb_frontend *fe,
+						struct dvb_frontend_parameters *p)
 {
 	struct pluto *pluto = frontend_to_pluto(fe);
 	struct i2c_msg msg;
@@ -484,6 +484,66 @@ static int lg_tdtpe001p_tuner_set_params
 	return 0;
 }
 
+static int lg_tdtpe001p_tuner_set_params(struct dvb_frontend *fe,
+					 struct dvbfe_params *p)
+{
+	struct pluto *pluto = frontend_to_pluto(fe);
+	struct i2c_msg msg;
+	int ret;
+	u8 buf[4];
+	u32 div;
+
+	// Fref = 166.667 Hz
+	// Fref * 3 = 500.000 Hz
+	// IF = 36166667
+	// IF / Fref = 217
+	//div = divide(p->frequency + 36166667, 166667);
+	div = divide(p->frequency * 3, 500000) + 217;
+	buf[0] = (div >> 8) & 0x7f;
+	buf[1] = (div >> 0) & 0xff;
+
+	if (p->frequency < 611000000)
+		buf[2] = 0xb4;
+	else if (p->frequency < 811000000)
+		buf[2] = 0xbc;
+	else
+		buf[2] = 0xf4;
+
+	// VHF: 174-230 MHz
+	// center: 350 MHz
+	// UHF: 470-862 MHz
+	if (p->frequency < 350000000)
+		buf[3] = 0x02;
+	else
+		buf[3] = 0x04;
+
+	if (p->delsys.dvbt.bandwidth == DVBFE_BANDWIDTH_8_MHZ)
+		buf[3] |= 0x08;
+
+	if (sizeof (buf) == 6) {
+		buf[4] = buf[2];
+		buf[4] &= ~0x1c;
+		buf[4] |=  0x18;
+
+		buf[5] = (0 << 7) | (2 << 4);
+	}
+
+	msg.addr = I2C_ADDR_TUA6034 >> 1;
+	msg.flags = 0;
+	msg.buf = buf;
+	msg.len = sizeof(buf);
+
+	if (fe->ops.i2c_gate_ctrl)
+		fe->ops.i2c_gate_ctrl(fe, 1);
+	ret = i2c_transfer(&pluto->i2c_adap, &msg, 1);
+	if (ret < 0)
+		return ret;
+	else if (ret == 0)
+		return -EREMOTEIO;
+
+	return 0;
+}
+
 static int pluto2_request_firmware(struct dvb_frontend *fe,
 				   const struct firmware **fw, char *name)
 {
@@ -511,6 +571,7 @@ static int __devinit frontend_init(struc
 		dev_err(&pluto->pdev->dev, "could not attach frontend\n");
 		return -ENODEV;
 	}
+	pluto->fe->ops.tuner_ops.set_params_compat = lg_tdtpe001p_tuner_set_params_compat;
 	pluto->fe->ops.tuner_ops.set_params = lg_tdtpe001p_tuner_set_params;
 
 	ret = dvb_register_frontend(&pluto->dvb_adapter, pluto->fe);
_______________________________________________

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