linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/10] r820t: add DVBC profile in sysfreq_sel
@ 2015-03-15 22:57 Benjamin Larsson
  2015-03-15 22:57 ` [PATCH 02/10] r820t: change read_gain() code to match register layout Benjamin Larsson
                   ` (9 more replies)
  0 siblings, 10 replies; 27+ messages in thread
From: Benjamin Larsson @ 2015-03-15 22:57 UTC (permalink / raw)
  To: crope, mchehab; +Cc: Linux Media Mailing List

This will make the Astrometa DVB-T/T2/C usb stick be able to pick up
muxes around 290-314 MHz.

Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
---
 drivers/media/tuners/r820t.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
index 8e040cf..639c220 100644
--- a/drivers/media/tuners/r820t.c
+++ b/drivers/media/tuners/r820t.c
@@ -775,6 +775,19 @@ static int r820t_sysfreq_sel(struct r820t_priv *priv, u32 freq,
 		div_buf_cur = 0x30;	/* 11, 150u */
 		filter_cur = 0x40;	/* 10, low */
 		break;
+	case SYS_DVBC_ANNEX_A:
+		mixer_top = 0x24;       /* mixer top:13 , top-1, low-discharge */
+		lna_top = 0xe5;
+		lna_vth_l = 0x62;
+		mixer_vth_l = 0x75;
+		air_cable1_in = 0x60;
+		cable2_in = 0x00;
+		pre_dect = 0x40;
+		lna_discharge = 14;
+		cp_cur = 0x38;          /* 111, auto */
+		div_buf_cur = 0x30;     /* 11, 150u */
+		filter_cur = 0x40;      /* 10, low */
+		break;
 	default: /* DVB-T 8M */
 		mixer_top = 0x24;	/* mixer top:13 , top-1, low-discharge */
 		lna_top = 0xe5;		/* detect bw 3, lna top:4, predet top:2 */
-- 
2.1.0


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

* [PATCH 02/10] r820t: change read_gain() code to match register layout
  2015-03-15 22:57 [PATCH 01/10] r820t: add DVBC profile in sysfreq_sel Benjamin Larsson
@ 2015-03-15 22:57 ` Benjamin Larsson
  2015-03-16 21:23   ` Antti Palosaari
  2015-03-15 22:57 ` [PATCH 03/10] rtl28xxu: lower the rc poll time to mitigate i2c transfer errors Benjamin Larsson
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: Benjamin Larsson @ 2015-03-15 22:57 UTC (permalink / raw)
  To: crope, mchehab; +Cc: Linux Media Mailing List

Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
---
 drivers/media/tuners/r820t.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
index 639c220..eaaf1dc 100644
--- a/drivers/media/tuners/r820t.c
+++ b/drivers/media/tuners/r820t.c
@@ -1199,7 +1199,7 @@ static int r820t_read_gain(struct r820t_priv *priv)
 	if (rc < 0)
 		return rc;
 
-	return ((data[3] & 0x0f) << 1) + ((data[3] & 0xf0) >> 4);
+	return ((data[3] & 0x08) << 1) + ((data[3] & 0xf0) >> 4);
 }
 
 #if 0
-- 
2.1.0


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

* [PATCH 03/10] rtl28xxu: lower the rc poll time to mitigate i2c transfer errors
  2015-03-15 22:57 [PATCH 01/10] r820t: add DVBC profile in sysfreq_sel Benjamin Larsson
  2015-03-15 22:57 ` [PATCH 02/10] r820t: change read_gain() code to match register layout Benjamin Larsson
@ 2015-03-15 22:57 ` Benjamin Larsson
  2015-03-16 21:26   ` Antti Palosaari
  2015-03-15 22:57 ` [PATCH 04/10] rtl28xxu: swap frontend order for slave demods Benjamin Larsson
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: Benjamin Larsson @ 2015-03-15 22:57 UTC (permalink / raw)
  To: crope, mchehab; +Cc: Linux Media Mailing List

The Astrometa device has issues with i2c transfers. Lowering the
poll time somehow makes these errors disappear.

Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
---
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index 77dcfdf..ea75b3a 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -1611,7 +1611,7 @@ static int rtl2832u_get_rc_config(struct dvb_usb_device *d,
 	rc->allowed_protos = RC_BIT_ALL;
 	rc->driver_type = RC_DRIVER_IR_RAW;
 	rc->query = rtl2832u_rc_query;
-	rc->interval = 400;
+	rc->interval = 200;
 
 	return 0;
 }
-- 
2.1.0


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

* [PATCH 04/10] rtl28xxu: swap frontend order for slave demods
  2015-03-15 22:57 [PATCH 01/10] r820t: add DVBC profile in sysfreq_sel Benjamin Larsson
  2015-03-15 22:57 ` [PATCH 02/10] r820t: change read_gain() code to match register layout Benjamin Larsson
  2015-03-15 22:57 ` [PATCH 03/10] rtl28xxu: lower the rc poll time to mitigate i2c transfer errors Benjamin Larsson
@ 2015-03-15 22:57 ` Benjamin Larsson
  2015-03-16 20:44   ` Benjamin Larsson
  2015-03-15 22:57 ` [PATCH 05/10] mn88472: implement lock for all delivery systems Benjamin Larsson
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: Benjamin Larsson @ 2015-03-15 22:57 UTC (permalink / raw)
  To: crope, mchehab; +Cc: Linux Media Mailing List

Some devices have 2 demodulators, when this is the case
make the slave demod be listed first. Enumerating the slave
first will help legacy applications to use the hardware.

Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
---
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index ea75b3a..bb5003d 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -853,6 +853,7 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
 
 	if (dev->slave_demod) {
 		struct i2c_board_info info = {};
+		struct dvb_frontend *tmp_fe;
 
 		/*
 		 * We continue on reduced mode, without DVB-T2/C, using master
@@ -907,6 +908,11 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
 
 			dev->i2c_client_slave_demod = client;
 		}
+
+		/* Swap frontend order */
+		tmp_fe = adap->fe[0];
+		adap->fe[0] = adap->fe[1];
+		adap->fe[1] = tmp_fe;
 	}
 
 	return 0;
@@ -1134,12 +1140,6 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
 				adap->fe[0]->ops.tuner_ops.get_rf_strength;
 		break;
 	case TUNER_RTL2832_R828D:
-		fe = dvb_attach(r820t_attach, adap->fe[0],
-				dev->demod_i2c_adapter,
-				&rtl2832u_r828d_config);
-		adap->fe[0]->ops.read_signal_strength =
-				adap->fe[0]->ops.tuner_ops.get_rf_strength;
-
 		if (adap->fe[1]) {
 			fe = dvb_attach(r820t_attach, adap->fe[1],
 					dev->demod_i2c_adapter,
@@ -1147,6 +1147,12 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
 			adap->fe[1]->ops.read_signal_strength =
 					adap->fe[1]->ops.tuner_ops.get_rf_strength;
 		}
+
+		fe = dvb_attach(r820t_attach, adap->fe[0],
+			dev->demod_i2c_adapter,
+			&rtl2832u_r828d_config);
+		adap->fe[0]->ops.read_signal_strength =
+			adap->fe[0]->ops.tuner_ops.get_rf_strength;
 		break;
 	default:
 		dev_err(&d->intf->dev, "unknown tuner %d\n", dev->tuner);
-- 
2.1.0


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

* [PATCH 05/10] mn88472: implement lock for all delivery systems
  2015-03-15 22:57 [PATCH 01/10] r820t: add DVBC profile in sysfreq_sel Benjamin Larsson
                   ` (2 preceding siblings ...)
  2015-03-15 22:57 ` [PATCH 04/10] rtl28xxu: swap frontend order for slave demods Benjamin Larsson
@ 2015-03-15 22:57 ` Benjamin Larsson
  2015-03-16 21:30   ` Antti Palosaari
  2015-03-15 22:57 ` [PATCH 06/10] mn88472: implement firmware parity check Benjamin Larsson
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: Benjamin Larsson @ 2015-03-15 22:57 UTC (permalink / raw)
  To: crope, mchehab; +Cc: Linux Media Mailing List

The increase of the lock timeout is needed for dvb-t2.

Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
---
 drivers/staging/media/mn88472/mn88472.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c
index 6eebe56..5070c37 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -19,7 +19,7 @@
 static int mn88472_get_tune_settings(struct dvb_frontend *fe,
 	struct dvb_frontend_tune_settings *s)
 {
-	s->min_delay_ms = 400;
+	s->min_delay_ms = 800;
 	return 0;
 }
 
@@ -201,6 +201,7 @@ static int mn88472_read_status(struct dvb_frontend *fe, fe_status_t *status)
 	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
 	int ret;
 	unsigned int utmp;
+	int lock = 0;
 
 	*status = 0;
 
@@ -211,21 +212,36 @@ static int mn88472_read_status(struct dvb_frontend *fe, fe_status_t *status)
 
 	switch (c->delivery_system) {
 	case SYS_DVBT:
+		ret = regmap_read(dev->regmap[0], 0x7F, &utmp);
+		if (ret)
+			goto err;
+		if ((utmp & 0xF) >= 0x09)
+			lock = 1;
+		break;
 	case SYS_DVBT2:
-		/* FIXME: implement me */
-		utmp = 0x08; /* DVB-C lock value */
+		ret = regmap_read(dev->regmap[2], 0x92, &utmp);
+		if (ret)
+			goto err;
+		if ((utmp & 0xF) >= 0x07)
+			*status |= FE_HAS_SIGNAL;
+		if ((utmp & 0xF) >= 0x0a)
+			*status |= FE_HAS_CARRIER;
+		if ((utmp & 0xF) >= 0x0d)
+			*status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
 		break;
 	case SYS_DVBC_ANNEX_A:
 		ret = regmap_read(dev->regmap[1], 0x84, &utmp);
 		if (ret)
 			goto err;
+		if ((utmp & 0xF) >= 0x08)
+			lock = 1;
 		break;
 	default:
 		ret = -EINVAL;
 		goto err;
 	}
 
-	if (utmp == 0x08)
+	if (lock)
 		*status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
 				FE_HAS_SYNC | FE_HAS_LOCK;
 
-- 
2.1.0


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

* [PATCH 06/10] mn88472: implement firmware parity check
  2015-03-15 22:57 [PATCH 01/10] r820t: add DVBC profile in sysfreq_sel Benjamin Larsson
                   ` (3 preceding siblings ...)
  2015-03-15 22:57 ` [PATCH 05/10] mn88472: implement lock for all delivery systems Benjamin Larsson
@ 2015-03-15 22:57 ` Benjamin Larsson
  2015-03-16 21:37   ` Antti Palosaari
  2015-03-15 22:57 ` [PATCH 07/10] mn88473: " Benjamin Larsson
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: Benjamin Larsson @ 2015-03-15 22:57 UTC (permalink / raw)
  To: crope, mchehab; +Cc: Linux Media Mailing List

Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
Reviewed-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Antti Palosaari <crope@iki.fi>
---
 drivers/staging/media/mn88472/mn88472.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c
index 5070c37..4a00a4d 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -258,6 +258,7 @@ static int mn88472_init(struct dvb_frontend *fe)
 	int ret, len, remaining;
 	const struct firmware *fw = NULL;
 	u8 *fw_file = MN88472_FIRMWARE;
+	unsigned int csum;
 
 	dev_dbg(&client->dev, "\n");
 
@@ -303,6 +304,20 @@ static int mn88472_init(struct dvb_frontend *fe)
 		}
 	}
 
+	/* parity check of firmware */
+	ret = regmap_read(dev->regmap[0], 0xf8, &csum);
+	if (ret) {
+		dev_err(&client->dev,
+				"parity reg read failed=%d\n", ret);
+		goto err;
+	}
+	if (csum & 0x10) {
+		dev_err(&client->dev,
+				"firmware parity check failed=0x%x\n", csum);
+		goto err;
+	}
+	dev_err(&client->dev, "firmware parity check succeeded=0x%x\n", csum);
+
 	ret = regmap_write(dev->regmap[0], 0xf5, 0x00);
 	if (ret)
 		goto err;
-- 
2.1.0


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

* [PATCH 07/10] mn88473: implement firmware parity check
  2015-03-15 22:57 [PATCH 01/10] r820t: add DVBC profile in sysfreq_sel Benjamin Larsson
                   ` (4 preceding siblings ...)
  2015-03-15 22:57 ` [PATCH 06/10] mn88472: implement firmware parity check Benjamin Larsson
@ 2015-03-15 22:57 ` Benjamin Larsson
  2015-03-16 21:39   ` Antti Palosaari
  2015-03-15 22:57 ` [PATCH 08/10] mn88473: check if firmware is already running before loading it Benjamin Larsson
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: Benjamin Larsson @ 2015-03-15 22:57 UTC (permalink / raw)
  To: crope, mchehab; +Cc: Linux Media Mailing List

Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
---
 drivers/staging/media/mn88473/mn88473.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/staging/media/mn88473/mn88473.c b/drivers/staging/media/mn88473/mn88473.c
index 84bd4fa..607ce4d 100644
--- a/drivers/staging/media/mn88473/mn88473.c
+++ b/drivers/staging/media/mn88473/mn88473.c
@@ -192,6 +192,7 @@ static int mn88473_init(struct dvb_frontend *fe)
 	int ret, len, remaining;
 	const struct firmware *fw = NULL;
 	u8 *fw_file = MN88473_FIRMWARE;
+	unsigned int tmp;
 
 	dev_dbg(&client->dev, "\n");
 
@@ -227,6 +228,20 @@ static int mn88473_init(struct dvb_frontend *fe)
 		}
 	}
 
+	/* parity check of firmware */
+	ret = regmap_read(dev->regmap[0], 0xf8, &tmp);
+	if (ret) {
+		dev_err(&client->dev,
+				"parity reg read failed=%d\n", ret);
+		goto err;
+	}
+	if (tmp & 0x10) {
+		dev_err(&client->dev,
+				"firmware parity check failed=0x%x\n", tmp);
+		goto err;
+	}
+	dev_err(&client->dev, "firmware parity check succeeded=0x%x\n", tmp);
+
 	ret = regmap_write(dev->regmap[0], 0xf5, 0x00);
 	if (ret)
 		goto err;
-- 
2.1.0


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

* [PATCH 08/10] mn88473: check if firmware is already running before loading it
  2015-03-15 22:57 [PATCH 01/10] r820t: add DVBC profile in sysfreq_sel Benjamin Larsson
                   ` (5 preceding siblings ...)
  2015-03-15 22:57 ` [PATCH 07/10] mn88473: " Benjamin Larsson
@ 2015-03-15 22:57 ` Benjamin Larsson
  2015-03-16 21:41   ` Antti Palosaari
  2015-03-16 21:43   ` Antti Palosaari
  2015-03-15 22:57 ` [PATCH 09/10] mn88472: " Benjamin Larsson
                   ` (2 subsequent siblings)
  9 siblings, 2 replies; 27+ messages in thread
From: Benjamin Larsson @ 2015-03-15 22:57 UTC (permalink / raw)
  To: crope, mchehab; +Cc: Linux Media Mailing List

Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
---
 drivers/staging/media/mn88473/mn88473.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/mn88473/mn88473.c b/drivers/staging/media/mn88473/mn88473.c
index 607ce4d..a23e59e 100644
--- a/drivers/staging/media/mn88473/mn88473.c
+++ b/drivers/staging/media/mn88473/mn88473.c
@@ -196,8 +196,19 @@ static int mn88473_init(struct dvb_frontend *fe)
 
 	dev_dbg(&client->dev, "\n");
 
-	if (dev->warm)
+	/* set cold state by default */
+	dev->warm = false;
+
+	/* check if firmware is already running */
+	ret = regmap_read(dev->regmap[0], 0xf5, &tmp);
+	if (ret)
+		goto err;
+
+	if (!(tmp & 0x1)) {
+		dev_info(&client->dev, "firmware already running\n");
+		dev->warm = true;
 		return 0;
+	}
 
 	/* request the firmware, this will block and timeout */
 	ret = request_firmware(&fw, fw_file, &client->dev);
-- 
2.1.0


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

* [PATCH 09/10] mn88472: check if firmware is already running before loading it
  2015-03-15 22:57 [PATCH 01/10] r820t: add DVBC profile in sysfreq_sel Benjamin Larsson
                   ` (6 preceding siblings ...)
  2015-03-15 22:57 ` [PATCH 08/10] mn88473: check if firmware is already running before loading it Benjamin Larsson
@ 2015-03-15 22:57 ` Benjamin Larsson
  2015-03-16 21:45   ` Antti Palosaari
  2015-03-15 22:57 ` [PATCH 10/10] mn88473: implement lock for all delivery systems Benjamin Larsson
  2015-03-16 21:14 ` [PATCH 01/10] r820t: add DVBC profile in sysfreq_sel Antti Palosaari
  9 siblings, 1 reply; 27+ messages in thread
From: Benjamin Larsson @ 2015-03-15 22:57 UTC (permalink / raw)
  To: crope, mchehab; +Cc: Linux Media Mailing List

Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
---
 drivers/staging/media/mn88472/mn88472.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c
index 4a00a4d..c041fbf 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -258,7 +258,7 @@ static int mn88472_init(struct dvb_frontend *fe)
 	int ret, len, remaining;
 	const struct firmware *fw = NULL;
 	u8 *fw_file = MN88472_FIRMWARE;
-	unsigned int csum;
+	unsigned int tmp;
 
 	dev_dbg(&client->dev, "\n");
 
@@ -274,6 +274,17 @@ static int mn88472_init(struct dvb_frontend *fe)
 	if (ret)
 		goto err;
 
+	/* check if firmware is already running */
+	ret = regmap_read(dev->regmap[0], 0xf5, &tmp);
+	if (ret)
+		goto err;
+
+	if (!(tmp & 0x1)) {
+		dev_info(&client->dev, "firmware already running\n");
+		dev->warm = true;
+		return 0;
+	}
+
 	/* request the firmware, this will block and timeout */
 	ret = request_firmware(&fw, fw_file, &client->dev);
 	if (ret) {
@@ -305,18 +316,18 @@ static int mn88472_init(struct dvb_frontend *fe)
 	}
 
 	/* parity check of firmware */
-	ret = regmap_read(dev->regmap[0], 0xf8, &csum);
+	ret = regmap_read(dev->regmap[0], 0xf8, &tmp);
 	if (ret) {
 		dev_err(&client->dev,
 				"parity reg read failed=%d\n", ret);
 		goto err;
 	}
-	if (csum & 0x10) {
+	if (tmp & 0x10) {
 		dev_err(&client->dev,
-				"firmware parity check failed=0x%x\n", csum);
+				"firmware parity check failed=0x%x\n", tmp);
 		goto err;
 	}
-	dev_err(&client->dev, "firmware parity check succeeded=0x%x\n", csum);
+	dev_err(&client->dev, "firmware parity check succeeded=0x%x\n", tmp);
 
 	ret = regmap_write(dev->regmap[0], 0xf5, 0x00);
 	if (ret)
-- 
2.1.0


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

* [PATCH 10/10] mn88473: implement lock for all delivery systems
  2015-03-15 22:57 [PATCH 01/10] r820t: add DVBC profile in sysfreq_sel Benjamin Larsson
                   ` (7 preceding siblings ...)
  2015-03-15 22:57 ` [PATCH 09/10] mn88472: " Benjamin Larsson
@ 2015-03-15 22:57 ` Benjamin Larsson
  2015-03-16 21:47   ` Antti Palosaari
  2015-03-16 21:14 ` [PATCH 01/10] r820t: add DVBC profile in sysfreq_sel Antti Palosaari
  9 siblings, 1 reply; 27+ messages in thread
From: Benjamin Larsson @ 2015-03-15 22:57 UTC (permalink / raw)
  To: crope, mchehab; +Cc: Linux Media Mailing List

Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
---
 drivers/staging/media/mn88473/mn88473.c | 50 +++++++++++++++++++++++++++++++--
 1 file changed, 48 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/mn88473/mn88473.c b/drivers/staging/media/mn88473/mn88473.c
index a23e59e..ba39614 100644
--- a/drivers/staging/media/mn88473/mn88473.c
+++ b/drivers/staging/media/mn88473/mn88473.c
@@ -167,7 +167,10 @@ static int mn88473_read_status(struct dvb_frontend *fe, fe_status_t *status)
 {
 	struct i2c_client *client = fe->demodulator_priv;
 	struct mn88473_dev *dev = i2c_get_clientdata(client);
+	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
 	int ret;
+	unsigned int utmp;
+	int lock = 0;
 
 	*status = 0;
 
@@ -176,8 +179,51 @@ static int mn88473_read_status(struct dvb_frontend *fe, fe_status_t *status)
 		goto err;
 	}
 
-	*status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
-			FE_HAS_SYNC | FE_HAS_LOCK;
+	switch (c->delivery_system) {
+	case SYS_DVBT:
+		ret = regmap_read(dev->regmap[0], 0x62, &utmp);
+		if (ret)
+			goto err;
+		if (utmp & 0xA0) {
+			if ((utmp & 0xF) >= 0x03)
+				*status |= FE_HAS_SIGNAL;
+			if ((utmp & 0xF) >= 0x09)
+				lock = 1;
+		}
+		break;
+	case SYS_DVBT2:
+		ret = regmap_read(dev->regmap[2], 0x8B, &utmp);
+		if (ret)
+			goto err;
+		if (utmp & 0x40) {
+			if ((utmp & 0xF) >= 0x07)
+				*status |= FE_HAS_SIGNAL;
+			if ((utmp & 0xF) >= 0x0a)
+				*status |= FE_HAS_CARRIER;
+			if ((utmp & 0xF) >= 0x0d)
+				*status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
+		}
+		break;
+	case SYS_DVBC_ANNEX_A:
+		ret = regmap_read(dev->regmap[1], 0x85, &utmp);
+		if (ret)
+			goto err;
+		if (utmp & 0x40) {
+			ret = regmap_read(dev->regmap[1], 0x89, &utmp);
+			if (ret)
+				goto err;
+			if (utmp & 0x01)
+				lock = 1;
+		}
+		break;
+	default:
+		ret = -EINVAL;
+		goto err;
+	}
+
+	if (lock)
+		*status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
+				FE_HAS_SYNC | FE_HAS_LOCK;
 
 	return 0;
 err:
-- 
2.1.0


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

* Re: [PATCH 04/10] rtl28xxu: swap frontend order for slave demods
  2015-03-15 22:57 ` [PATCH 04/10] rtl28xxu: swap frontend order for slave demods Benjamin Larsson
@ 2015-03-16 20:44   ` Benjamin Larsson
  2015-03-16 21:04     ` Antti Palosaari
  0 siblings, 1 reply; 27+ messages in thread
From: Benjamin Larsson @ 2015-03-16 20:44 UTC (permalink / raw)
  To: crope, mchehab; +Cc: Linux Media Mailing List

On 03/15/2015 11:57 PM, Benjamin Larsson wrote:
> Some devices have 2 demodulators, when this is the case
> make the slave demod be listed first. Enumerating the slave
> first will help legacy applications to use the hardware.
>

Ignore this patch for now. Stuff gets broken if applied.

/Benjamin


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

* Re: [PATCH 04/10] rtl28xxu: swap frontend order for slave demods
  2015-03-16 20:44   ` Benjamin Larsson
@ 2015-03-16 21:04     ` Antti Palosaari
  2015-03-16 21:22       ` Benjamin Larsson
  0 siblings, 1 reply; 27+ messages in thread
From: Antti Palosaari @ 2015-03-16 21:04 UTC (permalink / raw)
  To: Benjamin Larsson, mchehab; +Cc: Linux Media Mailing List

On 03/16/2015 10:44 PM, Benjamin Larsson wrote:
> On 03/15/2015 11:57 PM, Benjamin Larsson wrote:
>> Some devices have 2 demodulators, when this is the case
>> make the slave demod be listed first. Enumerating the slave
>> first will help legacy applications to use the hardware.
>>
>
> Ignore this patch for now. Stuff gets broken if applied.

I will not apply it even you fix it. I don't like idea adding such hack 
to kernel in order to workaround buggy applications. There is many older 
devices having similar situation, having 2 demods - one for DVB-T and 
one for DVB-C. So there has been surely enough time for app developers 
to add support for multiple frontends... laziness.

Quite same happened for DVB-T2 support. I added initially hack for 
CXD2820R driver in order to support DVB-T2 even applications are not 
supporting it. That was implemented using trick driver did DVB-T2 tune 
when DVB-T tune fails. After many years I did another DVB-T2 driver 
Si2168 and didn't add such hack anymore. And what was result; almost all 
applications were still lacking proper DVB-T2 support, after many many 
years...

So I will never ever add any hacks to driver to workaround application 
support as application developers are so lazy to add support or new 
things if there is some workaround available.

regards
Antti

-- 
http://palosaari.fi/

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

* Re: [PATCH 01/10] r820t: add DVBC profile in sysfreq_sel
  2015-03-15 22:57 [PATCH 01/10] r820t: add DVBC profile in sysfreq_sel Benjamin Larsson
                   ` (8 preceding siblings ...)
  2015-03-15 22:57 ` [PATCH 10/10] mn88473: implement lock for all delivery systems Benjamin Larsson
@ 2015-03-16 21:14 ` Antti Palosaari
  9 siblings, 0 replies; 27+ messages in thread
From: Antti Palosaari @ 2015-03-16 21:14 UTC (permalink / raw)
  To: Benjamin Larsson, mchehab; +Cc: Linux Media Mailing List

On 03/16/2015 12:57 AM, Benjamin Larsson wrote:
> This will make the Astrometa DVB-T/T2/C usb stick be able to pick up
> muxes around 290-314 MHz.
>
> Signed-off-by: Benjamin Larsson <benjamin@southpole.se>

Looks correct. I added initially DVB-C support for that driver, but I 
forget to add this. After looking the driver I realized there was 2 
places to add standard specific configurations - and I added only one place.
I will apply that to my tree.

regards
Antti


> ---
>   drivers/media/tuners/r820t.c | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
>
> diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
> index 8e040cf..639c220 100644
> --- a/drivers/media/tuners/r820t.c
> +++ b/drivers/media/tuners/r820t.c
> @@ -775,6 +775,19 @@ static int r820t_sysfreq_sel(struct r820t_priv *priv, u32 freq,
>   		div_buf_cur = 0x30;	/* 11, 150u */
>   		filter_cur = 0x40;	/* 10, low */
>   		break;
> +	case SYS_DVBC_ANNEX_A:
> +		mixer_top = 0x24;       /* mixer top:13 , top-1, low-discharge */
> +		lna_top = 0xe5;
> +		lna_vth_l = 0x62;
> +		mixer_vth_l = 0x75;
> +		air_cable1_in = 0x60;
> +		cable2_in = 0x00;
> +		pre_dect = 0x40;
> +		lna_discharge = 14;
> +		cp_cur = 0x38;          /* 111, auto */
> +		div_buf_cur = 0x30;     /* 11, 150u */
> +		filter_cur = 0x40;      /* 10, low */
> +		break;
>   	default: /* DVB-T 8M */
>   		mixer_top = 0x24;	/* mixer top:13 , top-1, low-discharge */
>   		lna_top = 0xe5;		/* detect bw 3, lna top:4, predet top:2 */
>

-- 
http://palosaari.fi/

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

* Re: [PATCH 04/10] rtl28xxu: swap frontend order for slave demods
  2015-03-16 21:04     ` Antti Palosaari
@ 2015-03-16 21:22       ` Benjamin Larsson
  0 siblings, 0 replies; 27+ messages in thread
From: Benjamin Larsson @ 2015-03-16 21:22 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: Linux Media Mailing List

On 03/16/2015 10:04 PM, Antti Palosaari wrote:
> On 03/16/2015 10:44 PM, Benjamin Larsson wrote:
>> On 03/15/2015 11:57 PM, Benjamin Larsson wrote:
>>> Some devices have 2 demodulators, when this is the case
>>> make the slave demod be listed first. Enumerating the slave
>>> first will help legacy applications to use the hardware.
>>>
>>
>> Ignore this patch for now. Stuff gets broken if applied.
>
> I will not apply it even you fix it. I don't like idea adding such hack
> to kernel in order to workaround buggy applications. There is many older
> devices having similar situation, having 2 demods - one for DVB-T and
> one for DVB-C. So there has been surely enough time for app developers
> to add support for multiple frontends... laziness.
>
> Quite same happened for DVB-T2 support. I added initially hack for
> CXD2820R driver in order to support DVB-T2 even applications are not
> supporting it. That was implemented using trick driver did DVB-T2 tune
> when DVB-T tune fails. After many years I did another DVB-T2 driver
> Si2168 and didn't add such hack anymore. And what was result; almost all
> applications were still lacking proper DVB-T2 support, after many many
> years...
>
> So I will never ever add any hacks to driver to workaround application
> support as application developers are so lazy to add support or new
> things if there is some workaround available.
>
> regards
> Antti
>

While I agree with your reasoning, the point with this patch is just to 
register one demod before another. If that is a hack or not I don't 
know. I have used it locally for test purposes and it is not needed for 
actual use so consider the patch withdrawn.

MvH
Benjamin Larsson

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

* Re: [PATCH 02/10] r820t: change read_gain() code to match register layout
  2015-03-15 22:57 ` [PATCH 02/10] r820t: change read_gain() code to match register layout Benjamin Larsson
@ 2015-03-16 21:23   ` Antti Palosaari
  0 siblings, 0 replies; 27+ messages in thread
From: Antti Palosaari @ 2015-03-16 21:23 UTC (permalink / raw)
  To: Benjamin Larsson, mchehab; +Cc: Linux Media Mailing List

On 03/16/2015 12:57 AM, Benjamin Larsson wrote:
> Signed-off-by: Benjamin Larsson <benjamin@southpole.se>

Looks correct, I will apply it.
That routine is used to estimate signal strength only.

regards
Antti

> ---
>   drivers/media/tuners/r820t.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
> index 639c220..eaaf1dc 100644
> --- a/drivers/media/tuners/r820t.c
> +++ b/drivers/media/tuners/r820t.c
> @@ -1199,7 +1199,7 @@ static int r820t_read_gain(struct r820t_priv *priv)
>   	if (rc < 0)
>   		return rc;
>
> -	return ((data[3] & 0x0f) << 1) + ((data[3] & 0xf0) >> 4);
> +	return ((data[3] & 0x08) << 1) + ((data[3] & 0xf0) >> 4);
>   }
>
>   #if 0
>

-- 
http://palosaari.fi/

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

* Re: [PATCH 03/10] rtl28xxu: lower the rc poll time to mitigate i2c transfer errors
  2015-03-15 22:57 ` [PATCH 03/10] rtl28xxu: lower the rc poll time to mitigate i2c transfer errors Benjamin Larsson
@ 2015-03-16 21:26   ` Antti Palosaari
  0 siblings, 0 replies; 27+ messages in thread
From: Antti Palosaari @ 2015-03-16 21:26 UTC (permalink / raw)
  To: Benjamin Larsson, mchehab; +Cc: Linux Media Mailing List

On 03/16/2015 12:57 AM, Benjamin Larsson wrote:
> The Astrometa device has issues with i2c transfers. Lowering the
> poll time somehow makes these errors disappear.
>
> Signed-off-by: Benjamin Larsson <benjamin@southpole.se>

Applied!

Antti


> ---
>   drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
> index 77dcfdf..ea75b3a 100644
> --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
> +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
> @@ -1611,7 +1611,7 @@ static int rtl2832u_get_rc_config(struct dvb_usb_device *d,
>   	rc->allowed_protos = RC_BIT_ALL;
>   	rc->driver_type = RC_DRIVER_IR_RAW;
>   	rc->query = rtl2832u_rc_query;
> -	rc->interval = 400;
> +	rc->interval = 200;
>
>   	return 0;
>   }
>

-- 
http://palosaari.fi/

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

* Re: [PATCH 05/10] mn88472: implement lock for all delivery systems
  2015-03-15 22:57 ` [PATCH 05/10] mn88472: implement lock for all delivery systems Benjamin Larsson
@ 2015-03-16 21:30   ` Antti Palosaari
  0 siblings, 0 replies; 27+ messages in thread
From: Antti Palosaari @ 2015-03-16 21:30 UTC (permalink / raw)
  To: Benjamin Larsson, mchehab; +Cc: Linux Media Mailing List

On 03/16/2015 12:57 AM, Benjamin Larsson wrote:
> The increase of the lock timeout is needed for dvb-t2.
>
> Signed-off-by: Benjamin Larsson <benjamin@southpole.se>

Applied!

regards
Antti

> ---
>   drivers/staging/media/mn88472/mn88472.c | 24 ++++++++++++++++++++----
>   1 file changed, 20 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c
> index 6eebe56..5070c37 100644
> --- a/drivers/staging/media/mn88472/mn88472.c
> +++ b/drivers/staging/media/mn88472/mn88472.c
> @@ -19,7 +19,7 @@
>   static int mn88472_get_tune_settings(struct dvb_frontend *fe,
>   	struct dvb_frontend_tune_settings *s)
>   {
> -	s->min_delay_ms = 400;
> +	s->min_delay_ms = 800;
>   	return 0;
>   }
>
> @@ -201,6 +201,7 @@ static int mn88472_read_status(struct dvb_frontend *fe, fe_status_t *status)
>   	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
>   	int ret;
>   	unsigned int utmp;
> +	int lock = 0;
>
>   	*status = 0;
>
> @@ -211,21 +212,36 @@ static int mn88472_read_status(struct dvb_frontend *fe, fe_status_t *status)
>
>   	switch (c->delivery_system) {
>   	case SYS_DVBT:
> +		ret = regmap_read(dev->regmap[0], 0x7F, &utmp);
> +		if (ret)
> +			goto err;
> +		if ((utmp & 0xF) >= 0x09)
> +			lock = 1;
> +		break;
>   	case SYS_DVBT2:
> -		/* FIXME: implement me */
> -		utmp = 0x08; /* DVB-C lock value */
> +		ret = regmap_read(dev->regmap[2], 0x92, &utmp);
> +		if (ret)
> +			goto err;
> +		if ((utmp & 0xF) >= 0x07)
> +			*status |= FE_HAS_SIGNAL;
> +		if ((utmp & 0xF) >= 0x0a)
> +			*status |= FE_HAS_CARRIER;
> +		if ((utmp & 0xF) >= 0x0d)
> +			*status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
>   		break;
>   	case SYS_DVBC_ANNEX_A:
>   		ret = regmap_read(dev->regmap[1], 0x84, &utmp);
>   		if (ret)
>   			goto err;
> +		if ((utmp & 0xF) >= 0x08)
> +			lock = 1;
>   		break;
>   	default:
>   		ret = -EINVAL;
>   		goto err;
>   	}
>
> -	if (utmp == 0x08)
> +	if (lock)
>   		*status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
>   				FE_HAS_SYNC | FE_HAS_LOCK;
>
>

-- 
http://palosaari.fi/

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

* Re: [PATCH 06/10] mn88472: implement firmware parity check
  2015-03-15 22:57 ` [PATCH 06/10] mn88472: implement firmware parity check Benjamin Larsson
@ 2015-03-16 21:37   ` Antti Palosaari
  0 siblings, 0 replies; 27+ messages in thread
From: Antti Palosaari @ 2015-03-16 21:37 UTC (permalink / raw)
  To: Benjamin Larsson, mchehab; +Cc: Linux Media Mailing List

On 03/16/2015 12:57 AM, Benjamin Larsson wrote:
> Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
> Reviewed-by: Antti Palosaari <crope@iki.fi>
> Signed-off-by: Antti Palosaari <crope@iki.fi>

Applied!

Please don't use dev_err() logging for nothing but errors. That last 
logging should be dev_dbg(), but as this is staging driver and features 
really rule over minor issues I will simply apply that and fix minor 
issues later.

regards
Antti



> ---
>   drivers/staging/media/mn88472/mn88472.c | 15 +++++++++++++++
>   1 file changed, 15 insertions(+)
>
> diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c
> index 5070c37..4a00a4d 100644
> --- a/drivers/staging/media/mn88472/mn88472.c
> +++ b/drivers/staging/media/mn88472/mn88472.c
> @@ -258,6 +258,7 @@ static int mn88472_init(struct dvb_frontend *fe)
>   	int ret, len, remaining;
>   	const struct firmware *fw = NULL;
>   	u8 *fw_file = MN88472_FIRMWARE;
> +	unsigned int csum;
>
>   	dev_dbg(&client->dev, "\n");
>
> @@ -303,6 +304,20 @@ static int mn88472_init(struct dvb_frontend *fe)
>   		}
>   	}
>
> +	/* parity check of firmware */
> +	ret = regmap_read(dev->regmap[0], 0xf8, &csum);
> +	if (ret) {
> +		dev_err(&client->dev,
> +				"parity reg read failed=%d\n", ret);
> +		goto err;
> +	}
> +	if (csum & 0x10) {
> +		dev_err(&client->dev,
> +				"firmware parity check failed=0x%x\n", csum);
> +		goto err;
> +	}
> +	dev_err(&client->dev, "firmware parity check succeeded=0x%x\n", csum);
> +
>   	ret = regmap_write(dev->regmap[0], 0xf5, 0x00);
>   	if (ret)
>   		goto err;
>

-- 
http://palosaari.fi/

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

* Re: [PATCH 07/10] mn88473: implement firmware parity check
  2015-03-15 22:57 ` [PATCH 07/10] mn88473: " Benjamin Larsson
@ 2015-03-16 21:39   ` Antti Palosaari
  0 siblings, 0 replies; 27+ messages in thread
From: Antti Palosaari @ 2015-03-16 21:39 UTC (permalink / raw)
  To: Benjamin Larsson, mchehab; +Cc: Linux Media Mailing List

On 03/16/2015 12:57 AM, Benjamin Larsson wrote:
> Signed-off-by: Benjamin Larsson <benjamin@southpole.se>

Applied with same comments that mn88472 patch.

regards
Antti

> ---
>   drivers/staging/media/mn88473/mn88473.c | 15 +++++++++++++++
>   1 file changed, 15 insertions(+)
>
> diff --git a/drivers/staging/media/mn88473/mn88473.c b/drivers/staging/media/mn88473/mn88473.c
> index 84bd4fa..607ce4d 100644
> --- a/drivers/staging/media/mn88473/mn88473.c
> +++ b/drivers/staging/media/mn88473/mn88473.c
> @@ -192,6 +192,7 @@ static int mn88473_init(struct dvb_frontend *fe)
>   	int ret, len, remaining;
>   	const struct firmware *fw = NULL;
>   	u8 *fw_file = MN88473_FIRMWARE;
> +	unsigned int tmp;
>
>   	dev_dbg(&client->dev, "\n");
>
> @@ -227,6 +228,20 @@ static int mn88473_init(struct dvb_frontend *fe)
>   		}
>   	}
>
> +	/* parity check of firmware */
> +	ret = regmap_read(dev->regmap[0], 0xf8, &tmp);
> +	if (ret) {
> +		dev_err(&client->dev,
> +				"parity reg read failed=%d\n", ret);
> +		goto err;
> +	}
> +	if (tmp & 0x10) {
> +		dev_err(&client->dev,
> +				"firmware parity check failed=0x%x\n", tmp);
> +		goto err;
> +	}
> +	dev_err(&client->dev, "firmware parity check succeeded=0x%x\n", tmp);
> +
>   	ret = regmap_write(dev->regmap[0], 0xf5, 0x00);
>   	if (ret)
>   		goto err;
>

-- 
http://palosaari.fi/

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

* Re: [PATCH 08/10] mn88473: check if firmware is already running before loading it
  2015-03-15 22:57 ` [PATCH 08/10] mn88473: check if firmware is already running before loading it Benjamin Larsson
@ 2015-03-16 21:41   ` Antti Palosaari
  2015-03-16 21:43   ` Antti Palosaari
  1 sibling, 0 replies; 27+ messages in thread
From: Antti Palosaari @ 2015-03-16 21:41 UTC (permalink / raw)
  To: Benjamin Larsson, mchehab; +Cc: Linux Media Mailing List

On 03/16/2015 12:57 AM, Benjamin Larsson wrote:
> Signed-off-by: Benjamin Larsson <benjamin@southpole.se>

Applied!

Antti

> ---
>   drivers/staging/media/mn88473/mn88473.c | 13 ++++++++++++-
>   1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/media/mn88473/mn88473.c b/drivers/staging/media/mn88473/mn88473.c
> index 607ce4d..a23e59e 100644
> --- a/drivers/staging/media/mn88473/mn88473.c
> +++ b/drivers/staging/media/mn88473/mn88473.c
> @@ -196,8 +196,19 @@ static int mn88473_init(struct dvb_frontend *fe)
>
>   	dev_dbg(&client->dev, "\n");
>
> -	if (dev->warm)
> +	/* set cold state by default */
> +	dev->warm = false;
> +
> +	/* check if firmware is already running */
> +	ret = regmap_read(dev->regmap[0], 0xf5, &tmp);
> +	if (ret)
> +		goto err;
> +
> +	if (!(tmp & 0x1)) {
> +		dev_info(&client->dev, "firmware already running\n");
> +		dev->warm = true;
>   		return 0;
> +	}
>
>   	/* request the firmware, this will block and timeout */
>   	ret = request_firmware(&fw, fw_file, &client->dev);
>

-- 
http://palosaari.fi/

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

* Re: [PATCH 08/10] mn88473: check if firmware is already running before loading it
  2015-03-15 22:57 ` [PATCH 08/10] mn88473: check if firmware is already running before loading it Benjamin Larsson
  2015-03-16 21:41   ` Antti Palosaari
@ 2015-03-16 21:43   ` Antti Palosaari
  1 sibling, 0 replies; 27+ messages in thread
From: Antti Palosaari @ 2015-03-16 21:43 UTC (permalink / raw)
  To: Benjamin Larsson, mchehab; +Cc: Linux Media Mailing List

On 03/16/2015 12:57 AM, Benjamin Larsson wrote:
> Signed-off-by: Benjamin Larsson <benjamin@southpole.se>

Applied!

Antti

> ---
>   drivers/staging/media/mn88473/mn88473.c | 13 ++++++++++++-
>   1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/media/mn88473/mn88473.c b/drivers/staging/media/mn88473/mn88473.c
> index 607ce4d..a23e59e 100644
> --- a/drivers/staging/media/mn88473/mn88473.c
> +++ b/drivers/staging/media/mn88473/mn88473.c
> @@ -196,8 +196,19 @@ static int mn88473_init(struct dvb_frontend *fe)
>
>   	dev_dbg(&client->dev, "\n");
>
> -	if (dev->warm)
> +	/* set cold state by default */
> +	dev->warm = false;
> +
> +	/* check if firmware is already running */
> +	ret = regmap_read(dev->regmap[0], 0xf5, &tmp);
> +	if (ret)
> +		goto err;
> +
> +	if (!(tmp & 0x1)) {
> +		dev_info(&client->dev, "firmware already running\n");
> +		dev->warm = true;
>   		return 0;
> +	}
>
>   	/* request the firmware, this will block and timeout */
>   	ret = request_firmware(&fw, fw_file, &client->dev);
>

-- 
http://palosaari.fi/

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

* Re: [PATCH 09/10] mn88472: check if firmware is already running before loading it
  2015-03-15 22:57 ` [PATCH 09/10] mn88472: " Benjamin Larsson
@ 2015-03-16 21:45   ` Antti Palosaari
  0 siblings, 0 replies; 27+ messages in thread
From: Antti Palosaari @ 2015-03-16 21:45 UTC (permalink / raw)
  To: Benjamin Larsson, mchehab; +Cc: Linux Media Mailing List

On 03/16/2015 12:57 AM, Benjamin Larsson wrote:
> Signed-off-by: Benjamin Larsson <benjamin@southpole.se>

Applied! Please try to add some commit message, even patch topic says it 
all...

regards
Antti

> ---
>   drivers/staging/media/mn88472/mn88472.c | 21 ++++++++++++++++-----
>   1 file changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c
> index 4a00a4d..c041fbf 100644
> --- a/drivers/staging/media/mn88472/mn88472.c
> +++ b/drivers/staging/media/mn88472/mn88472.c
> @@ -258,7 +258,7 @@ static int mn88472_init(struct dvb_frontend *fe)
>   	int ret, len, remaining;
>   	const struct firmware *fw = NULL;
>   	u8 *fw_file = MN88472_FIRMWARE;
> -	unsigned int csum;
> +	unsigned int tmp;
>
>   	dev_dbg(&client->dev, "\n");
>
> @@ -274,6 +274,17 @@ static int mn88472_init(struct dvb_frontend *fe)
>   	if (ret)
>   		goto err;
>
> +	/* check if firmware is already running */
> +	ret = regmap_read(dev->regmap[0], 0xf5, &tmp);
> +	if (ret)
> +		goto err;
> +
> +	if (!(tmp & 0x1)) {
> +		dev_info(&client->dev, "firmware already running\n");
> +		dev->warm = true;
> +		return 0;
> +	}
> +
>   	/* request the firmware, this will block and timeout */
>   	ret = request_firmware(&fw, fw_file, &client->dev);
>   	if (ret) {
> @@ -305,18 +316,18 @@ static int mn88472_init(struct dvb_frontend *fe)
>   	}
>
>   	/* parity check of firmware */
> -	ret = regmap_read(dev->regmap[0], 0xf8, &csum);
> +	ret = regmap_read(dev->regmap[0], 0xf8, &tmp);
>   	if (ret) {
>   		dev_err(&client->dev,
>   				"parity reg read failed=%d\n", ret);
>   		goto err;
>   	}
> -	if (csum & 0x10) {
> +	if (tmp & 0x10) {
>   		dev_err(&client->dev,
> -				"firmware parity check failed=0x%x\n", csum);
> +				"firmware parity check failed=0x%x\n", tmp);
>   		goto err;
>   	}
> -	dev_err(&client->dev, "firmware parity check succeeded=0x%x\n", csum);
> +	dev_err(&client->dev, "firmware parity check succeeded=0x%x\n", tmp);
>
>   	ret = regmap_write(dev->regmap[0], 0xf5, 0x00);
>   	if (ret)
>

-- 
http://palosaari.fi/

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

* Re: [PATCH 10/10] mn88473: implement lock for all delivery systems
  2015-03-15 22:57 ` [PATCH 10/10] mn88473: implement lock for all delivery systems Benjamin Larsson
@ 2015-03-16 21:47   ` Antti Palosaari
  2015-03-16 22:44     ` Antti Palosaari
  0 siblings, 1 reply; 27+ messages in thread
From: Antti Palosaari @ 2015-03-16 21:47 UTC (permalink / raw)
  To: Benjamin Larsson, mchehab; +Cc: Linux Media Mailing List

On 03/16/2015 12:57 AM, Benjamin Larsson wrote:
> Signed-off-by: Benjamin Larsson <benjamin@southpole.se>

Applied.

Antti

> ---
>   drivers/staging/media/mn88473/mn88473.c | 50 +++++++++++++++++++++++++++++++--
>   1 file changed, 48 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/media/mn88473/mn88473.c b/drivers/staging/media/mn88473/mn88473.c
> index a23e59e..ba39614 100644
> --- a/drivers/staging/media/mn88473/mn88473.c
> +++ b/drivers/staging/media/mn88473/mn88473.c
> @@ -167,7 +167,10 @@ static int mn88473_read_status(struct dvb_frontend *fe, fe_status_t *status)
>   {
>   	struct i2c_client *client = fe->demodulator_priv;
>   	struct mn88473_dev *dev = i2c_get_clientdata(client);
> +	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
>   	int ret;
> +	unsigned int utmp;
> +	int lock = 0;
>
>   	*status = 0;
>
> @@ -176,8 +179,51 @@ static int mn88473_read_status(struct dvb_frontend *fe, fe_status_t *status)
>   		goto err;
>   	}
>
> -	*status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
> -			FE_HAS_SYNC | FE_HAS_LOCK;
> +	switch (c->delivery_system) {
> +	case SYS_DVBT:
> +		ret = regmap_read(dev->regmap[0], 0x62, &utmp);
> +		if (ret)
> +			goto err;
> +		if (utmp & 0xA0) {
> +			if ((utmp & 0xF) >= 0x03)
> +				*status |= FE_HAS_SIGNAL;
> +			if ((utmp & 0xF) >= 0x09)
> +				lock = 1;
> +		}
> +		break;
> +	case SYS_DVBT2:
> +		ret = regmap_read(dev->regmap[2], 0x8B, &utmp);
> +		if (ret)
> +			goto err;
> +		if (utmp & 0x40) {
> +			if ((utmp & 0xF) >= 0x07)
> +				*status |= FE_HAS_SIGNAL;
> +			if ((utmp & 0xF) >= 0x0a)
> +				*status |= FE_HAS_CARRIER;
> +			if ((utmp & 0xF) >= 0x0d)
> +				*status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
> +		}
> +		break;
> +	case SYS_DVBC_ANNEX_A:
> +		ret = regmap_read(dev->regmap[1], 0x85, &utmp);
> +		if (ret)
> +			goto err;
> +		if (utmp & 0x40) {
> +			ret = regmap_read(dev->regmap[1], 0x89, &utmp);
> +			if (ret)
> +				goto err;
> +			if (utmp & 0x01)
> +				lock = 1;
> +		}
> +		break;
> +	default:
> +		ret = -EINVAL;
> +		goto err;
> +	}
> +
> +	if (lock)
> +		*status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
> +				FE_HAS_SYNC | FE_HAS_LOCK;
>
>   	return 0;
>   err:
>

-- 
http://palosaari.fi/

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

* Re: [PATCH 10/10] mn88473: implement lock for all delivery systems
  2015-03-16 21:47   ` Antti Palosaari
@ 2015-03-16 22:44     ` Antti Palosaari
  2015-03-16 23:10       ` Benjamin Larsson
  0 siblings, 1 reply; 27+ messages in thread
From: Antti Palosaari @ 2015-03-16 22:44 UTC (permalink / raw)
  To: Benjamin Larsson, mchehab; +Cc: Linux Media Mailing List

On 03/16/2015 11:47 PM, Antti Palosaari wrote:
> On 03/16/2015 12:57 AM, Benjamin Larsson wrote:
>> Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
>
> Applied.

I found this does not work at least for DVB-C. After playing with 
modulator I find reg 0x85 on bank 1 is likely AGC. Its value is changed 
according to RF level even modulation itself is turned off.

I will likely remove that patch... It is a bit hard to find out lock 
bits and it comes even harder without a modulator. Using typical tricks 
to plug and unplug antenna, while dumping register values out is error 
prone as you could not adjust signal strength nor change modulation 
parameters causing wrong decision easily.

regards
Antti


>
> Antti
>
>> ---
>>   drivers/staging/media/mn88473/mn88473.c | 50
>> +++++++++++++++++++++++++++++++--
>>   1 file changed, 48 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/media/mn88473/mn88473.c
>> b/drivers/staging/media/mn88473/mn88473.c
>> index a23e59e..ba39614 100644
>> --- a/drivers/staging/media/mn88473/mn88473.c
>> +++ b/drivers/staging/media/mn88473/mn88473.c
>> @@ -167,7 +167,10 @@ static int mn88473_read_status(struct
>> dvb_frontend *fe, fe_status_t *status)
>>   {
>>       struct i2c_client *client = fe->demodulator_priv;
>>       struct mn88473_dev *dev = i2c_get_clientdata(client);
>> +    struct dtv_frontend_properties *c = &fe->dtv_property_cache;
>>       int ret;
>> +    unsigned int utmp;
>> +    int lock = 0;
>>
>>       *status = 0;
>>
>> @@ -176,8 +179,51 @@ static int mn88473_read_status(struct
>> dvb_frontend *fe, fe_status_t *status)
>>           goto err;
>>       }
>>
>> -    *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
>> -            FE_HAS_SYNC | FE_HAS_LOCK;
>> +    switch (c->delivery_system) {
>> +    case SYS_DVBT:
>> +        ret = regmap_read(dev->regmap[0], 0x62, &utmp);
>> +        if (ret)
>> +            goto err;
>> +        if (utmp & 0xA0) {
>> +            if ((utmp & 0xF) >= 0x03)
>> +                *status |= FE_HAS_SIGNAL;
>> +            if ((utmp & 0xF) >= 0x09)
>> +                lock = 1;
>> +        }
>> +        break;
>> +    case SYS_DVBT2:
>> +        ret = regmap_read(dev->regmap[2], 0x8B, &utmp);
>> +        if (ret)
>> +            goto err;
>> +        if (utmp & 0x40) {
>> +            if ((utmp & 0xF) >= 0x07)
>> +                *status |= FE_HAS_SIGNAL;
>> +            if ((utmp & 0xF) >= 0x0a)
>> +                *status |= FE_HAS_CARRIER;
>> +            if ((utmp & 0xF) >= 0x0d)
>> +                *status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
>> +        }
>> +        break;
>> +    case SYS_DVBC_ANNEX_A:
>> +        ret = regmap_read(dev->regmap[1], 0x85, &utmp);
>> +        if (ret)
>> +            goto err;
>> +        if (utmp & 0x40) {
>> +            ret = regmap_read(dev->regmap[1], 0x89, &utmp);
>> +            if (ret)
>> +                goto err;
>> +            if (utmp & 0x01)
>> +                lock = 1;
>> +        }
>> +        break;
>> +    default:
>> +        ret = -EINVAL;
>> +        goto err;
>> +    }
>> +
>> +    if (lock)
>> +        *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
>> +                FE_HAS_SYNC | FE_HAS_LOCK;
>>
>>       return 0;
>>   err:
>>
>

-- 
http://palosaari.fi/

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

* Re: [PATCH 10/10] mn88473: implement lock for all delivery systems
  2015-03-16 22:44     ` Antti Palosaari
@ 2015-03-16 23:10       ` Benjamin Larsson
  2015-03-18 21:13         ` Antti Palosaari
  0 siblings, 1 reply; 27+ messages in thread
From: Benjamin Larsson @ 2015-03-16 23:10 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: Linux Media Mailing List

On 03/16/2015 11:44 PM, Antti Palosaari wrote:
> On 03/16/2015 11:47 PM, Antti Palosaari wrote:
>> On 03/16/2015 12:57 AM, Benjamin Larsson wrote:
>>> Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
>>
>> Applied.
>
> I found this does not work at least for DVB-C. After playing with
> modulator I find reg 0x85 on bank 1 is likely AGC. Its value is changed
> according to RF level even modulation itself is turned off.
>
> I will likely remove that patch... It is a bit hard to find out lock
> bits and it comes even harder without a modulator. Using typical tricks
> to plug and unplug antenna, while dumping register values out is error
> prone as you could not adjust signal strength nor change modulation
> parameters causing wrong decision easily.
>
> regards
> Antti
>

Indeed the logic was inverted. Will respin the patch.

MvH
Benjamin Larsson


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

* Re: [PATCH 10/10] mn88473: implement lock for all delivery systems
  2015-03-16 23:10       ` Benjamin Larsson
@ 2015-03-18 21:13         ` Antti Palosaari
  2015-03-18 21:40           ` Benjamin Larsson
  0 siblings, 1 reply; 27+ messages in thread
From: Antti Palosaari @ 2015-03-18 21:13 UTC (permalink / raw)
  To: Benjamin Larsson; +Cc: Linux Media Mailing List

On 03/17/2015 01:10 AM, Benjamin Larsson wrote:
> On 03/16/2015 11:44 PM, Antti Palosaari wrote:
>> On 03/16/2015 11:47 PM, Antti Palosaari wrote:
>>> On 03/16/2015 12:57 AM, Benjamin Larsson wrote:
>>>> Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
>>>
>>> Applied.
>>
>> I found this does not work at least for DVB-C. After playing with
>> modulator I find reg 0x85 on bank 1 is likely AGC. Its value is changed
>> according to RF level even modulation itself is turned off.
>>
>> I will likely remove that patch... It is a bit hard to find out lock
>> bits and it comes even harder without a modulator. Using typical tricks
>> to plug and unplug antenna, while dumping register values out is error
>> prone as you could not adjust signal strength nor change modulation
>> parameters causing wrong decision easily.
>>
>> regards
>> Antti
>>
>
> Indeed the logic was inverted. Will respin the patch.

Any ETA for the new patch?

regards
Antti

-- 
http://palosaari.fi/

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

* Re: [PATCH 10/10] mn88473: implement lock for all delivery systems
  2015-03-18 21:13         ` Antti Palosaari
@ 2015-03-18 21:40           ` Benjamin Larsson
  0 siblings, 0 replies; 27+ messages in thread
From: Benjamin Larsson @ 2015-03-18 21:40 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: Linux Media Mailing List

On 03/18/2015 10:13 PM, Antti Palosaari wrote:
> On 03/17/2015 01:10 AM, Benjamin Larsson wrote:
>> On 03/16/2015 11:44 PM, Antti Palosaari wrote:
>>> On 03/16/2015 11:47 PM, Antti Palosaari wrote:
>>>> On 03/16/2015 12:57 AM, Benjamin Larsson wrote:
>>>>> Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
>>>>
>>>> Applied.
>>>
>>> I found this does not work at least for DVB-C. After playing with
>>> modulator I find reg 0x85 on bank 1 is likely AGC. Its value is changed
>>> according to RF level even modulation itself is turned off.
>>>
>>> I will likely remove that patch... It is a bit hard to find out lock
>>> bits and it comes even harder without a modulator. Using typical tricks
>>> to plug and unplug antenna, while dumping register values out is error
>>> prone as you could not adjust signal strength nor change modulation
>>> parameters causing wrong decision easily.
>>>
>>> regards
>>> Antti
>>>
>>
>> Indeed the logic was inverted. Will respin the patch.
>
> Any ETA for the new patch?
>
> regards
> Antti
>

Sent and I tested DVB-C yesterday, it worked fine.

MvH
Benjamin Larsson

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

end of thread, other threads:[~2015-03-18 21:40 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-15 22:57 [PATCH 01/10] r820t: add DVBC profile in sysfreq_sel Benjamin Larsson
2015-03-15 22:57 ` [PATCH 02/10] r820t: change read_gain() code to match register layout Benjamin Larsson
2015-03-16 21:23   ` Antti Palosaari
2015-03-15 22:57 ` [PATCH 03/10] rtl28xxu: lower the rc poll time to mitigate i2c transfer errors Benjamin Larsson
2015-03-16 21:26   ` Antti Palosaari
2015-03-15 22:57 ` [PATCH 04/10] rtl28xxu: swap frontend order for slave demods Benjamin Larsson
2015-03-16 20:44   ` Benjamin Larsson
2015-03-16 21:04     ` Antti Palosaari
2015-03-16 21:22       ` Benjamin Larsson
2015-03-15 22:57 ` [PATCH 05/10] mn88472: implement lock for all delivery systems Benjamin Larsson
2015-03-16 21:30   ` Antti Palosaari
2015-03-15 22:57 ` [PATCH 06/10] mn88472: implement firmware parity check Benjamin Larsson
2015-03-16 21:37   ` Antti Palosaari
2015-03-15 22:57 ` [PATCH 07/10] mn88473: " Benjamin Larsson
2015-03-16 21:39   ` Antti Palosaari
2015-03-15 22:57 ` [PATCH 08/10] mn88473: check if firmware is already running before loading it Benjamin Larsson
2015-03-16 21:41   ` Antti Palosaari
2015-03-16 21:43   ` Antti Palosaari
2015-03-15 22:57 ` [PATCH 09/10] mn88472: " Benjamin Larsson
2015-03-16 21:45   ` Antti Palosaari
2015-03-15 22:57 ` [PATCH 10/10] mn88473: implement lock for all delivery systems Benjamin Larsson
2015-03-16 21:47   ` Antti Palosaari
2015-03-16 22:44     ` Antti Palosaari
2015-03-16 23:10       ` Benjamin Larsson
2015-03-18 21:13         ` Antti Palosaari
2015-03-18 21:40           ` Benjamin Larsson
2015-03-16 21:14 ` [PATCH 01/10] r820t: add DVBC profile in sysfreq_sel Antti Palosaari

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).