Mailing List archive

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

[linux-dvb] Re: Improved tda10045h patch



On Monday 16 June 2003 22:49, Holger Waechtler wrote:
> Andrew de Quincey wrote:
> > Hi, more improvements:
> >
> > 1) Now tunes properly! Previously it could only tune to certain
> > frequencies 'cos of a rounding bug in the calculations.
> >
> > 2) Made it less noisy so it doesn't print disturbing messages when
> > probing for a tda10045h fails.
> >
> > 3) Added FIXME comments in appropriate unfinished places.
>
> (can you please create an incremental patch to the CVS source? I'm a bit
> too lazy right now to do this manually;)
>
> need some sleep. many many thanks,

:)
Here you go
Index: linux/drivers/media/dvb/frontends/tda10045h.c
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/tda10045h.c,v
retrieving revision 1.1
diff -p -u -r1.1 tda10045h.c
--- linux/drivers/media/dvb/frontends/tda10045h.c	16 Jun 2003 21:35:38 -0000	1.1
+++ linux/drivers/media/dvb/frontends/tda10045h.c	17 Jun 2003 09:28:57 -0000
@@ -153,7 +153,7 @@ int tda10045h_write_byte(struct dvb_i2c_
 	ret = i2c->xfer(i2c, &msg, 1);
 
 	if (ret != 1)
-		printk("%s: error reg=0x%x, data=0x%x, ret=%i\n",
+		dprintk("%s: error reg=0x%x, data=0x%x, ret=%i\n",
 		       __FUNCTION__, reg, data, ret);
 
 	dprintk("%s: success reg=0x%x, data=0x%x, ret=%i\n", __FUNCTION__,
@@ -177,7 +177,7 @@ int tda10045h_read_byte(struct dvb_i2c_b
 	ret = i2c->xfer(i2c, msg, 2);
 
 	if (ret != 2) {
-		printk("%s: error reg=0x%x, ret=%i\n", __FUNCTION__, reg,
+		dprintk("%s: error reg=0x%x, ret=%i\n", __FUNCTION__, reg,
 		       ret);
 		return -1;
 	}
@@ -191,12 +191,12 @@ static
 int tda10045h_write_mask(struct dvb_i2c_bus *i2c, int reg, int mask,
 			 int data)
 {
-
+        int val;
 	dprintk("%s: reg=0x%x, mask=0x%x, data=0x%x\n", __FUNCTION__, reg,
 		mask, data);
 
 	// read a byte and check
-	int val = tda10045h_read_byte(i2c, reg);
+	val = tda10045h_read_byte(i2c, reg);
 	if (val < 0)
 		return val;
 
@@ -230,10 +230,10 @@ int tda10045h_write_buf(struct dvb_i2c_b
 static
 int tda10045h_enable_tuner_i2c(struct dvb_i2c_bus *i2c)
 {
-
+        int result;
 	dprintk("%s\n", __FUNCTION__);
 
-	int result = tda10045h_write_mask(i2c, TDA10045H_CONFC4, 2, 2);
+	result = tda10045h_write_mask(i2c, TDA10045H_CONFC4, 2, 2);
 	dvb_delay(1);
 	return result;
 }
@@ -530,7 +530,7 @@ int tda10045h_set_frequency(struct dvb_i
 
 		// setup tuner buffer
 		tuner_frequency =
-		    ((fe_params->frequency * 6) + 217502000) / 1000000;
+		    (((fe_params->frequency / 1000) * 6) + 217502) / 1000;
 		tuner_buf[0] = tuner_frequency >> 8;
 		tuner_buf[1] = tuner_frequency & 0xff;
 		tuner_buf[2] = 0x88;
@@ -570,7 +570,6 @@ int tda10045h_set_frequency(struct dvb_i
 	case TDA10045H_TDM1316L_ADDRESS:
 		// determine settings
 		tuner_frequency = fe_params->frequency + 36167000;
-		dprintk("tuner_freq: %i\n", tuner_frequency);
 		if (tuner_frequency < 87000000) {
 			return -EINVAL;
 		} else if (tuner_frequency < 130000000) {
@@ -628,7 +627,7 @@ int tda10045h_set_frequency(struct dvb_i
 
 		// calculate tuner parameters
 		tuner_frequency =
-		    ((fe_params->frequency * 6) + 217502000) / 1000000;
+		    (((fe_params->frequency / 1000) * 6) + 217502) / 1000;
 		tuner_buf[0] = tuner_frequency >> 8;
 		tuner_buf[1] = tuner_frequency & 0xff;
 		tuner_buf[2] = 0xca;
@@ -990,6 +989,7 @@ int tda10045h_read_snr(struct dvb_i2c_bu
 	tmp = tda10045h_read_byte(i2c, TDA10045H_SNR);
 	if (tmp < 0)
 		return -EIO;
+        // FIXME: calculate this properly
 
 	// done
 	*snr = tmp;
@@ -1023,7 +1023,8 @@ int tda10045h_read_ucblocks(struct dvb_i
 		if ((tmp2 < tmp) || (tmp2 == 0))
 			break;
 	}
-
+        // FIXME: calculate this properly
+	
 	// done
 	if (tmp != 0x7f) {
 		*ucblocks = tmp;
@@ -1049,7 +1050,8 @@ int tda10045h_read_vber(struct dvb_i2c_b
 
 	// reset counter
 	tda10045h_read_byte(i2c, TDA10045H_CVBER_LUT);
-
+        // FIXME: calculate this properly
+	
 	// done
 	dprintk("%s: vber=0x%x\n", __FUNCTION__, *vber);
 	return 0;

Home | Main Index | Thread Index