public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 4/4] Modifications to the driver mb86a20s‏‏
@ 2011-05-13  2:13 Manoel PN
  2011-05-13  7:27 ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 2+ messages in thread
From: Manoel PN @ 2011-05-13  2:13 UTC (permalink / raw)
  To: linux-media, Mauro Chehab, lgspn

[-- Attachment #1: Type: text/plain, Size: 266 bytes --]



This patch implement changes to the function mb86a20s_read_signal_strength.

The original function, binary search, does not work with device dtb08.

I would like to know if this function works.


Signed-off-by: Manoel Pinheiro <pinusdtv@hotmail.com>


 		 	   		  

[-- Attachment #2: signal_strength.patch --]
[-- Type: application/octet-stream, Size: 1210 bytes --]

diff --git a/drivers/media/dvb/frontends/mb86a20s.c b/drivers/media/dvb/frontends/mb86a20s.c
index 0f867a5..8f39da5 100644
--- a/drivers/media/dvb/frontends/mb86a20s.c
+++ b/drivers/media/dvb/frontends/mb86a20s.c
@@ -414,6 +414,12 @@ err:
 static int mb86a20s_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
 {
 	struct mb86a20s_state *state = fe->demodulator_priv;
+	int i, val, val2;
+
+#if 0
+	/*
+	 * Binary search don't work with DTB08
+	 */
 	unsigned rf_max, rf_min, rf;
 	u8	 val;
 
@@ -447,6 +453,30 @@ static int mb86a20s_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
 
 	if (fe->ops.i2c_gate_ctrl)
 		fe->ops.i2c_gate_ctrl(fe, 1);
+#endif
+
+	dprintk("\n");
+
+	*strength = 0;
+
+	for (i = 0; i < 10; i++)
+	{
+		val = mb86a20s_readreg(state, 0x0a);
+		if (val >= 2) {
+			mb86a20s_writereg(state, 0x04, 0x25);
+			val2 = mb86a20s_readreg(state, 0x05);
+			mb86a20s_writereg(state, 0x04, 0x26);
+			val = mb86a20s_readreg(state, 0x05);
+			if (val >= 0 && val2 >= 0) {
+				val = (val2 << 8) | val;
+				val2 = (val * 0x100100) >> 16;
+				dprintk("signal strength = %i\n", val2);
+				*strength = (u16)val2;
+				return 0;
+			}
+		}
+		msleep(10);
+	}
 
 	return 0;
 }

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-05-13  7:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-13  2:13 [PATCH 4/4] Modifications to the driver mb86a20s‏‏ Manoel PN
2011-05-13  7:27 ` Mauro Carvalho Chehab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox