diff mbox

[3/4] V4L/DVB: Update tuner initialization sequence

Message ID 1407217613.2988.7.camel@ite-desktop (mailing list archive)
State New, archived
Headers show

Commit Message

Bimow Chen Aug. 5, 2014, 5:46 a.m. UTC

Comments

Antti Palosaari Aug. 9, 2014, 8:47 p.m. UTC | #1
I applied that patch too, but reverted register writes you removed / 
moved to af9033 demod driver. Also, register write added for attach() 
happens too late leaving tuner ops populated even it fails. That causes 
surely kernel crash when tuner attach fails and DVB-core sees tuner 
callbacks are populated. So I moved it happen few lines earlier. Also 
removed sleep as I didn't see any need for it.

There should be commit description on each patch saying what it does and 
why. I did a lot of reverse-engineering to understand these patches.


regards
Antti
diff mbox

Patch

From 68df717c82f5da425a807a417872de0a9566211c Mon Sep 17 00:00:00 2001
From: Bimow Chen <Bimow.Chen@ite.com.tw>
Date: Tue, 5 Aug 2014 11:14:47 +0800
Subject: [PATCH 3/4] Update tuner initialization sequence.


Signed-off-by: Bimow Chen <Bimow.Chen@ite.com.tw>
---
 drivers/media/tuners/tuner_it913x.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/media/tuners/tuner_it913x.c b/drivers/media/tuners/tuner_it913x.c
index 6f30d7e..728de57 100644
--- a/drivers/media/tuners/tuner_it913x.c
+++ b/drivers/media/tuners/tuner_it913x.c
@@ -200,10 +200,7 @@  static int it913x_init(struct dvb_frontend *fe)
 		}
 	}
 
-	/* Power Up Tuner - common all versions */
-	ret = it913x_wr_reg(state, PRO_DMOD, 0xec40, 0x1);
-	ret |= it913x_wr_reg(state, PRO_DMOD, 0xfba8, 0x0);
-	ret |= it913x_wr_reg(state, PRO_DMOD, 0xec57, 0x0);
+	ret = it913x_wr_reg(state, PRO_DMOD, 0xec57, 0x0);
 	ret |= it913x_wr_reg(state, PRO_DMOD, 0xec58, 0x0);
 
 	return it913x_wr_reg(state, PRO_DMOD, 0xed81, val);
@@ -396,6 +393,7 @@  struct dvb_frontend *it913x_attach(struct dvb_frontend *fe,
 		struct i2c_adapter *i2c_adap, u8 i2c_addr, u8 config)
 {
 	struct it913x_state *state = NULL;
+	int ret;
 
 	/* allocate memory for the internal state */
 	state = kzalloc(sizeof(struct it913x_state), GFP_KERNEL);
@@ -429,6 +427,13 @@  struct dvb_frontend *it913x_attach(struct dvb_frontend *fe,
 	memcpy(&fe->ops.tuner_ops, &it913x_tuner_ops,
 			sizeof(struct dvb_tuner_ops));
 
+	/* tuner RF initial */
+	ret = it913x_wr_reg(state, PRO_DMOD, 0xec4c, 0x68);
+	if (ret < 0)
+		goto error;
+
+	msleep(30);
+
 	dev_info(&i2c_adap->dev,
 			"%s: ITE Tech IT913X successfully attached\n",
 			KBUILD_MODNAME);
-- 
1.7.0.4