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

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


This patch implements mb86a20s_read_snr and adds mb86a20s_read_ber and mb86a20s_read_ucblocks both without practical utility but that programs as dvbsnoop need.


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



 		 	   		  

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

diff --git a/drivers/media/dvb/frontends/mb86a20s.c b/drivers/media/dvb/frontends/mb86a20s.c
index 0f867a5..0de4abf 100644
--- a/drivers/media/dvb/frontends/mb86a20s.c
+++ b/drivers/media/dvb/frontends/mb86a20s.c
@@ -411,6 +411,56 @@ err:
 	return rc;
 }
 
+static int mb86a20s_read_snr(struct dvb_frontend *fe, u16 *snr)
+{
+	struct mb86a20s_state *state = fe->demodulator_priv;
+	int i, cnr, val, val2;
+
+	for (i = 0; i < 30; i++) {
+		if (mb86a20s_readreg(state, 0x0a) >= 2)
+			val = mb86a20s_readreg(state, 0x45); /* read cnr_flag */
+		else
+			val = -1;
+		if (val > 0 && ((val >> 6) & 1) != 0) {
+			val2 = mb86a20s_readreg(state, 0x46);
+			val = mb86a20s_readreg(state, 0x47);
+			if (val2 >=0 && val >= 0) {
+				cnr = (val2 << 0x08) | val;
+				if (cnr > 0x4cc0) cnr = 0x4cc0;
+				val = ((0x4cc0 - cnr) * 10000) / 0x4cc0;
+				val2 = (65535 * val) / 10000;
+				*snr = (u16)val2;
+				dprintk("snr=%i, cnr=%i, val=%i\n", val2, cnr, val);
+				/* reset cnr_counter */
+				val = mb86a20s_readreg(state, 0x45);
+				if (val >= 0)
+				{
+					mb86a20s_writereg(state, 0x45, val | 0x10);
+					msleep(5);
+					mb86a20s_writereg(state, 0x45, val & 0x6f); /* FIXME: or 0xef ? */
+				}
+				return 0;
+			}
+		}
+		msleep(30);
+	}
+	*snr = 0;
+	dprintk("no signal!\n");
+	return 0;
+}
+
+static int mb86a20s_read_ber(struct dvb_frontend *fe, u32 *ber)
+{
+	*ber = 0;
+	return 0;
+}
+
+static int mb86a20s_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
+{
+	*ucblocks = 0;
+	return 0;
+}
+
 static int mb86a20s_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
 {
 	struct mb86a20s_state *state = fe->demodulator_priv;
@@ -627,6 +677,9 @@ static struct dvb_frontend_ops mb86a20s_ops = {
 	.release = mb86a20s_release,
 
 	.init = mb86a20s_initfe,
+	.read_snr = mb86a20s_read_snr,
+	.read_ber = mb86a20s_read_ber,
+	.read_ucblocks = mb86a20s_read_ucblocks,
 	.set_frontend = mb86a20s_set_frontend,
 	.get_frontend = mb86a20s_get_frontend,
 	.read_status = mb86a20s_read_status,

^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [PATCH 2/4] Modifications to the driver mb86a20s
@ 2011-05-13  2:05 Manoel PN
  2011-05-13  6:57 ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 4+ messages in thread
From: Manoel PN @ 2011-05-13  2:05 UTC (permalink / raw)
  To: linux-media, Mauro Chehab, lgspn


This patch implements mb86a20s_read_snr and adds mb86a20s_read_ber and mb86a20s_read_ucblocks both without practical utility but that programs as dvbsnoop need.


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


 		 	   		  

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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-13  2:08 [PATCH 2/4] Modifications to the driver mb86a20s Manoel PN
2011-05-13  7:08 ` Mauro Carvalho Chehab
  -- strict thread matches above, loose matches on Subject: below --
2011-05-13  2:05 Manoel PN
2011-05-13  6:57 ` 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