public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* si2165: Add simple DVB-C support
@ 2015-11-19 20:03 Matthias Schwarzott
  2015-11-19 20:03 ` [PATCH 01/10] si2165: rename frontend -> fe Matthias Schwarzott
                   ` (9 more replies)
  0 siblings, 10 replies; 14+ messages in thread
From: Matthias Schwarzott @ 2015-11-19 20:03 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, crope, xpert-reactos

This series adds simple DVB-C support to the si2165 demod driver.

It works only for HVR-4400/HVR-5500.
For WinTV-HVR-930C-HD it fails with bad/no reception
for unknown reasons.

Regards
Matthias


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

* [PATCH 01/10] si2165: rename frontend -> fe
  2015-11-19 20:03 si2165: Add simple DVB-C support Matthias Schwarzott
@ 2015-11-19 20:03 ` Matthias Schwarzott
  2015-11-19 20:03 ` [PATCH 02/10] si2165: rename si2165_set_parameters to si2165_set_frontend Matthias Schwarzott
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Matthias Schwarzott @ 2015-11-19 20:03 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, crope, xpert-reactos, Matthias Schwarzott

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
 drivers/media/dvb-frontends/si2165.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index c5d7c0d..d36b36c 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -42,7 +42,7 @@
 struct si2165_state {
 	struct i2c_adapter *i2c;
 
-	struct dvb_frontend frontend;
+	struct dvb_frontend fe;
 
 	struct si2165_config config;
 
@@ -988,9 +988,9 @@ struct dvb_frontend *si2165_attach(const struct si2165_config *config,
 	}
 
 	/* create dvb_frontend */
-	memcpy(&state->frontend.ops, &si2165_ops,
+	memcpy(&state->fe.ops, &si2165_ops,
 		sizeof(struct dvb_frontend_ops));
-	state->frontend.demodulator_priv = state;
+	state->fe.demodulator_priv = state;
 
 	/* powerup */
 	io_ret = si2165_writereg8(state, 0x0000, state->config.chip_mode);
@@ -1042,20 +1042,20 @@ struct dvb_frontend *si2165_attach(const struct si2165_config *config,
 		KBUILD_MODNAME, chip_name, rev_char, state->chip_type,
 		state->chip_revcode);
 
-	strlcat(state->frontend.ops.info.name, chip_name,
-			sizeof(state->frontend.ops.info.name));
+	strlcat(state->fe.ops.info.name, chip_name,
+			sizeof(state->fe.ops.info.name));
 
 	n = 0;
 	if (state->has_dvbt) {
-		state->frontend.ops.delsys[n++] = SYS_DVBT;
-		strlcat(state->frontend.ops.info.name, " DVB-T",
-			sizeof(state->frontend.ops.info.name));
+		state->fe.ops.delsys[n++] = SYS_DVBT;
+		strlcat(state->fe.ops.info.name, " DVB-T",
+			sizeof(state->fe.ops.info.name));
 	}
 	if (state->has_dvbc)
 		dev_warn(&state->i2c->dev, "%s: DVB-C is not yet supported.\n",
 		       KBUILD_MODNAME);
 
-	return &state->frontend;
+	return &state->fe;
 
 error:
 	kfree(state);
-- 
2.6.3


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

* [PATCH 02/10] si2165: rename si2165_set_parameters to si2165_set_frontend
  2015-11-19 20:03 si2165: Add simple DVB-C support Matthias Schwarzott
  2015-11-19 20:03 ` [PATCH 01/10] si2165: rename frontend -> fe Matthias Schwarzott
@ 2015-11-19 20:03 ` Matthias Schwarzott
  2015-11-19 20:03 ` [PATCH 03/10] si2165: create function si2165_write_reg_list for writing register lists Matthias Schwarzott
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Matthias Schwarzott @ 2015-11-19 20:03 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, crope, xpert-reactos, Matthias Schwarzott

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
 drivers/media/dvb-frontends/si2165.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index d36b36c..a0e4600 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -767,7 +767,7 @@ static int si2165_set_if_freq_shift(struct si2165_state *state, u32 IF)
 	return si2165_writereg32(state, 0x00e8, reg_value);
 }
 
-static int si2165_set_parameters(struct dvb_frontend *fe)
+static int si2165_set_frontend(struct dvb_frontend *fe)
 {
 	int ret;
 	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
@@ -952,7 +952,7 @@ static struct dvb_frontend_ops si2165_ops = {
 	.init = si2165_init,
 	.sleep = si2165_sleep,
 
-	.set_frontend      = si2165_set_parameters,
+	.set_frontend      = si2165_set_frontend,
 	.read_status       = si2165_read_status,
 
 	.release = si2165_release,
-- 
2.6.3


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

* [PATCH 03/10] si2165: create function si2165_write_reg_list for writing register lists
  2015-11-19 20:03 si2165: Add simple DVB-C support Matthias Schwarzott
  2015-11-19 20:03 ` [PATCH 01/10] si2165: rename frontend -> fe Matthias Schwarzott
  2015-11-19 20:03 ` [PATCH 02/10] si2165: rename si2165_set_parameters to si2165_set_frontend Matthias Schwarzott
@ 2015-11-19 20:03 ` Matthias Schwarzott
  2015-11-19 20:03 ` [PATCH 04/10] si2165: only write agc registers after reset before start_syncro Matthias Schwarzott
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Matthias Schwarzott @ 2015-11-19 20:03 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, crope, xpert-reactos, Matthias Schwarzott

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
 drivers/media/dvb-frontends/si2165.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index a0e4600..222d775 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -243,6 +243,27 @@ err:
 	return ret;
 }
 
+#define REG16(reg, val) { (reg), (val) & 0xff }, { (reg)+1, (val)>>8 & 0xff }
+struct si2165_reg_value_pair {
+	u16 reg;
+	u8 val;
+};
+
+static int si2165_write_reg_list(struct si2165_state *state,
+				 const struct si2165_reg_value_pair *regs,
+				 int count)
+{
+	int i;
+	int ret;
+
+	for (i = 0; i < count; i++) {
+		ret = si2165_writereg8(state, regs[i].reg, regs[i].val);
+		if (ret < 0)
+			return ret;
+	}
+	return 0;
+}
+
 static int si2165_get_tune_settings(struct dvb_frontend *fe,
 				    struct dvb_frontend_tune_settings *s)
 {
-- 
2.6.3


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

* [PATCH 04/10] si2165: only write agc registers after reset before start_syncro
  2015-11-19 20:03 si2165: Add simple DVB-C support Matthias Schwarzott
                   ` (2 preceding siblings ...)
  2015-11-19 20:03 ` [PATCH 03/10] si2165: create function si2165_write_reg_list for writing register lists Matthias Schwarzott
@ 2015-11-19 20:03 ` Matthias Schwarzott
  2015-11-19 20:03 ` [PATCH 05/10] si2165: move setting ts config to init Matthias Schwarzott
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Matthias Schwarzott @ 2015-11-19 20:03 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, crope, xpert-reactos, Matthias Schwarzott

Datasheet says they must be rewritten after reset.
But it only makes sense to write them when trying to tune afterwards.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
 drivers/media/dvb-frontends/si2165.c | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index 222d775..07247e3 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -690,23 +690,6 @@ static int si2165_init(struct dvb_frontend *fe)
 			goto error;
 	}
 
-	/* write adc values after each reset*/
-	ret = si2165_writereg8(state, 0x012a, 0x46);
-	if (ret < 0)
-		goto error;
-	ret = si2165_writereg8(state, 0x012c, 0x00);
-	if (ret < 0)
-		goto error;
-	ret = si2165_writereg8(state, 0x012e, 0x0a);
-	if (ret < 0)
-		goto error;
-	ret = si2165_writereg8(state, 0x012f, 0xff);
-	if (ret < 0)
-		goto error;
-	ret = si2165_writereg8(state, 0x0123, 0x70);
-	if (ret < 0)
-		goto error;
-
 	return 0;
 error:
 	return ret;
@@ -788,6 +771,14 @@ static int si2165_set_if_freq_shift(struct si2165_state *state, u32 IF)
 	return si2165_writereg32(state, 0x00e8, reg_value);
 }
 
+static const struct si2165_reg_value_pair agc_rewrite[] = {
+	{ 0x012a, 0x46 },
+	{ 0x012c, 0x00 },
+	{ 0x012e, 0x0a },
+	{ 0x012f, 0xff },
+	{ 0x0123, 0x70 }
+};
+
 static int si2165_set_frontend(struct dvb_frontend *fe)
 {
 	int ret;
@@ -924,6 +915,13 @@ static int si2165_set_frontend(struct dvb_frontend *fe)
 	ret = si2165_writereg32(state, 0x0384, 0x00000000);
 	if (ret < 0)
 		return ret;
+
+	/* write adc values after each reset*/
+	ret = si2165_write_reg_list(state, agc_rewrite,
+				    ARRAY_SIZE(agc_rewrite));
+	if (ret < 0)
+		return ret;
+
 	/* start_synchro */
 	ret = si2165_writereg8(state, 0x02e0, 0x01);
 	if (ret < 0)
-- 
2.6.3


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

* [PATCH 05/10] si2165: move setting ts config to init
  2015-11-19 20:03 si2165: Add simple DVB-C support Matthias Schwarzott
                   ` (3 preceding siblings ...)
  2015-11-19 20:03 ` [PATCH 04/10] si2165: only write agc registers after reset before start_syncro Matthias Schwarzott
@ 2015-11-19 20:03 ` Matthias Schwarzott
  2015-11-19 20:03 ` [PATCH 06/10] si2165: Simplify si2165_set_if_freq_shift usage Matthias Schwarzott
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Matthias Schwarzott @ 2015-11-19 20:03 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, crope, xpert-reactos, Matthias Schwarzott

The TS config is fixed, so no need to write it for each tune.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
 drivers/media/dvb-frontends/si2165.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index 07247e3..0c1f4c4 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -690,6 +690,20 @@ static int si2165_init(struct dvb_frontend *fe)
 			goto error;
 	}
 
+	/* ts output config */
+	ret = si2165_writereg8(state, 0x04e4, 0x20);
+	if (ret < 0)
+		return ret;
+	ret = si2165_writereg16(state, 0x04ef, 0x00fe);
+	if (ret < 0)
+		return ret;
+	ret = si2165_writereg24(state, 0x04f4, 0x555555);
+	if (ret < 0)
+		return ret;
+	ret = si2165_writereg8(state, 0x04e5, 0x01);
+	if (ret < 0)
+		return ret;
+
 	return 0;
 error:
 	return ret;
@@ -824,19 +838,6 @@ static int si2165_set_frontend(struct dvb_frontend *fe)
 	ret = si2165_writereg8(state, 0x08f8, 0x00);
 	if (ret < 0)
 		return ret;
-	/* ts output config */
-	ret = si2165_writereg8(state, 0x04e4, 0x20);
-	if (ret < 0)
-		return ret;
-	ret = si2165_writereg16(state, 0x04ef, 0x00fe);
-	if (ret < 0)
-		return ret;
-	ret = si2165_writereg24(state, 0x04f4, 0x555555);
-	if (ret < 0)
-		return ret;
-	ret = si2165_writereg8(state, 0x04e5, 0x01);
-	if (ret < 0)
-		return ret;
 	/* bandwidth in 10KHz steps */
 	ret = si2165_writereg16(state, 0x0308, bw10k);
 	if (ret < 0)
-- 
2.6.3


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

* [PATCH 06/10] si2165: Simplify si2165_set_if_freq_shift usage
  2015-11-19 20:03 si2165: Add simple DVB-C support Matthias Schwarzott
                   ` (4 preceding siblings ...)
  2015-11-19 20:03 ` [PATCH 05/10] si2165: move setting ts config to init Matthias Schwarzott
@ 2015-11-19 20:03 ` Matthias Schwarzott
  2015-11-19 20:03 ` [PATCH 07/10] si2165: Fix DVB-T bandwidth default Matthias Schwarzott
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Matthias Schwarzott @ 2015-11-19 20:03 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, crope, xpert-reactos, Matthias Schwarzott

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
 drivers/media/dvb-frontends/si2165.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index 0c1f4c4..807a3c9 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -764,12 +764,22 @@ static int si2165_set_oversamp(struct si2165_state *state, u32 dvb_rate)
 	return si2165_writereg32(state, 0x00e4, reg_value);
 }
 
-static int si2165_set_if_freq_shift(struct si2165_state *state, u32 IF)
+static int si2165_set_if_freq_shift(struct si2165_state *state)
 {
+	struct dvb_frontend *fe = &state->fe;
 	u64 if_freq_shift;
 	s32 reg_value = 0;
 	u32 fe_clk = si2165_get_fe_clk(state);
+	u32 IF = 0;
 
+	if (!fe->ops.tuner_ops.get_if_frequency) {
+		dev_err(&state->i2c->dev,
+			"%s: Error: get_if_frequency() not defined at tuner. Can't work without it!\n",
+			KBUILD_MODNAME);
+		return -EINVAL;
+	}
+
+	fe->ops.tuner_ops.get_if_frequency(fe, &IF);
 	if_freq_shift = IF;
 	if_freq_shift <<= 29;
 
@@ -799,19 +809,11 @@ static int si2165_set_frontend(struct dvb_frontend *fe)
 	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
 	struct si2165_state *state = fe->demodulator_priv;
 	u8 val[3];
-	u32 IF;
 	u32 dvb_rate = 0;
 	u16 bw10k;
 
 	dprintk("%s: called\n", __func__);
 
-	if (!fe->ops.tuner_ops.get_if_frequency) {
-		dev_err(&state->i2c->dev,
-			"%s: Error: get_if_frequency() not defined at tuner. Can't work without it!\n",
-			KBUILD_MODNAME);
-		return -EINVAL;
-	}
-
 	if (!state->has_dvbt)
 		return -EINVAL;
 
@@ -831,8 +833,7 @@ static int si2165_set_frontend(struct dvb_frontend *fe)
 	if (ret < 0)
 		return ret;
 
-	fe->ops.tuner_ops.get_if_frequency(fe, &IF);
-	ret = si2165_set_if_freq_shift(state, IF);
+	ret = si2165_set_if_freq_shift(state);
 	if (ret < 0)
 		return ret;
 	ret = si2165_writereg8(state, 0x08f8, 0x00);
@@ -896,8 +897,7 @@ static int si2165_set_frontend(struct dvb_frontend *fe)
 		fe->ops.tuner_ops.set_params(fe);
 
 	/* recalc if_freq_shift if IF might has changed */
-	fe->ops.tuner_ops.get_if_frequency(fe, &IF);
-	ret = si2165_set_if_freq_shift(state, IF);
+	ret = si2165_set_if_freq_shift(state);
 	if (ret < 0)
 		return ret;
 
-- 
2.6.3


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

* [PATCH 07/10] si2165: Fix DVB-T bandwidth default
  2015-11-19 20:03 si2165: Add simple DVB-C support Matthias Schwarzott
                   ` (5 preceding siblings ...)
  2015-11-19 20:03 ` [PATCH 06/10] si2165: Simplify si2165_set_if_freq_shift usage Matthias Schwarzott
@ 2015-11-19 20:03 ` Matthias Schwarzott
  2015-12-03 14:15   ` Mauro Carvalho Chehab
  2015-11-19 20:04 ` [PATCH 08/10] si2165: set list of DVB-T registers together Matthias Schwarzott
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 14+ messages in thread
From: Matthias Schwarzott @ 2015-11-19 20:03 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, crope, xpert-reactos, Matthias Schwarzott

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
 drivers/media/dvb-frontends/si2165.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index 807a3c9..e97b0e6 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -811,19 +811,18 @@ static int si2165_set_frontend(struct dvb_frontend *fe)
 	u8 val[3];
 	u32 dvb_rate = 0;
 	u16 bw10k;
+	u32 bw_hz = p->bandwidth_hz;
 
 	dprintk("%s: called\n", __func__);
 
 	if (!state->has_dvbt)
 		return -EINVAL;
 
-	if (p->bandwidth_hz > 0) {
-		dvb_rate = p->bandwidth_hz * 8 / 7;
-		bw10k = p->bandwidth_hz / 10000;
-	} else {
-		dvb_rate = 8 * 8 / 7;
-		bw10k = 800;
-	}
+	if (bw_hz == 0)
+		bw_hz = 8000000;
+
+	dvb_rate = bw_hz * 8 / 7;
+	bw10k = bw_hz / 10000;
 
 	/* standard = DVB-T */
 	ret = si2165_writereg8(state, 0x00ec, 0x01);
-- 
2.6.3


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

* [PATCH 08/10] si2165: set list of DVB-T registers together
  2015-11-19 20:03 si2165: Add simple DVB-C support Matthias Schwarzott
                   ` (6 preceding siblings ...)
  2015-11-19 20:03 ` [PATCH 07/10] si2165: Fix DVB-T bandwidth default Matthias Schwarzott
@ 2015-11-19 20:04 ` Matthias Schwarzott
  2015-11-19 20:04 ` [PATCH 09/10] si2165: Prepare si2165_set_frontend for splitting Matthias Schwarzott
  2015-11-19 20:04 ` [PATCH 10/10] si2165: Add DVB-C support for HVR-4400/HVR-5500 Matthias Schwarzott
  9 siblings, 0 replies; 14+ messages in thread
From: Matthias Schwarzott @ 2015-11-19 20:04 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, crope, xpert-reactos, Matthias Schwarzott

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
 drivers/media/dvb-frontends/si2165.c | 73 +++++++++++++-----------------------
 1 file changed, 26 insertions(+), 47 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index e97b0e6..01c9a19 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -803,6 +803,29 @@ static const struct si2165_reg_value_pair agc_rewrite[] = {
 	{ 0x0123, 0x70 }
 };
 
+static const struct si2165_reg_value_pair dvbt_regs[] = {
+	/* standard = DVB-T */
+	{ 0x00ec, 0x01 },
+	{ 0x08f8, 0x00 },
+	/* impulsive_noise_remover */
+	{ 0x031c, 0x01 },
+	{ 0x00cb, 0x00 },
+	/* agc2 */
+	{ 0x016e, 0x41 },
+	{ 0x016c, 0x0e },
+	{ 0x016d, 0x10 },
+	/* agc */
+	{ 0x015b, 0x03 },
+	{ 0x0150, 0x78 },
+	/* agc */
+	{ 0x01a0, 0x78 },
+	{ 0x01c8, 0x68 },
+	/* freq_sync_range */
+	REG16(0x030c, 0x0064),
+	/* gp_reg0 */
+	{ 0x0387, 0x00 }
+};
+
 static int si2165_set_frontend(struct dvb_frontend *fe)
 {
 	int ret;
@@ -824,10 +847,6 @@ static int si2165_set_frontend(struct dvb_frontend *fe)
 	dvb_rate = bw_hz * 8 / 7;
 	bw10k = bw_hz / 10000;
 
-	/* standard = DVB-T */
-	ret = si2165_writereg8(state, 0x00ec, 0x01);
-	if (ret < 0)
-		return ret;
 	ret = si2165_adjust_pll_divl(state, 12);
 	if (ret < 0)
 		return ret;
@@ -835,9 +854,6 @@ static int si2165_set_frontend(struct dvb_frontend *fe)
 	ret = si2165_set_if_freq_shift(state);
 	if (ret < 0)
 		return ret;
-	ret = si2165_writereg8(state, 0x08f8, 0x00);
-	if (ret < 0)
-		return ret;
 	/* bandwidth in 10KHz steps */
 	ret = si2165_writereg16(state, 0x0308, bw10k);
 	if (ret < 0)
@@ -845,48 +861,11 @@ static int si2165_set_frontend(struct dvb_frontend *fe)
 	ret = si2165_set_oversamp(state, dvb_rate);
 	if (ret < 0)
 		return ret;
-	/* impulsive_noise_remover */
-	ret = si2165_writereg8(state, 0x031c, 0x01);
-	if (ret < 0)
-		return ret;
-	ret = si2165_writereg8(state, 0x00cb, 0x00);
-	if (ret < 0)
-		return ret;
-	/* agc2 */
-	ret = si2165_writereg8(state, 0x016e, 0x41);
-	if (ret < 0)
-		return ret;
-	ret = si2165_writereg8(state, 0x016c, 0x0e);
-	if (ret < 0)
-		return ret;
-	ret = si2165_writereg8(state, 0x016d, 0x10);
-	if (ret < 0)
-		return ret;
-	/* agc */
-	ret = si2165_writereg8(state, 0x015b, 0x03);
-	if (ret < 0)
-		return ret;
-	ret = si2165_writereg8(state, 0x0150, 0x78);
-	if (ret < 0)
-		return ret;
-	/* agc */
-	ret = si2165_writereg8(state, 0x01a0, 0x78);
-	if (ret < 0)
-		return ret;
-	ret = si2165_writereg8(state, 0x01c8, 0x68);
-	if (ret < 0)
-		return ret;
-	/* freq_sync_range */
-	ret = si2165_writereg16(state, 0x030c, 0x0064);
-	if (ret < 0)
-		return ret;
-	/* gp_reg0 */
-	ret = si2165_readreg8(state, 0x0387, val);
-	if (ret < 0)
-		return ret;
-	ret = si2165_writereg8(state, 0x0387, 0x00);
+
+	ret = si2165_write_reg_list(state, dvbt_regs, ARRAY_SIZE(dvbt_regs));
 	if (ret < 0)
 		return ret;
+
 	/* dsp_addr_jump */
 	ret = si2165_writereg32(state, 0x0348, 0xf4000000);
 	if (ret < 0)
-- 
2.6.3


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

* [PATCH 09/10] si2165: Prepare si2165_set_frontend for splitting
  2015-11-19 20:03 si2165: Add simple DVB-C support Matthias Schwarzott
                   ` (7 preceding siblings ...)
  2015-11-19 20:04 ` [PATCH 08/10] si2165: set list of DVB-T registers together Matthias Schwarzott
@ 2015-11-19 20:04 ` Matthias Schwarzott
  2015-11-19 20:04 ` [PATCH 10/10] si2165: Add DVB-C support for HVR-4400/HVR-5500 Matthias Schwarzott
  9 siblings, 0 replies; 14+ messages in thread
From: Matthias Schwarzott @ 2015-11-19 20:04 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, crope, xpert-reactos, Matthias Schwarzott

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
 drivers/media/dvb-frontends/si2165.c | 51 ++++++++++++++++++++++++++----------
 1 file changed, 37 insertions(+), 14 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index 01c9a19..131aef1 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -760,7 +760,7 @@ static int si2165_set_oversamp(struct si2165_state *state, u32 dvb_rate)
 	do_div(oversamp, dvb_rate);
 	reg_value = oversamp & 0x3fffffff;
 
-	/* oversamp, usbdump contained 0x03100000; */
+	dprintk("%s: Write oversamp=%#x\n", __func__, reg_value);
 	return si2165_writereg32(state, 0x00e4, reg_value);
 }
 
@@ -795,14 +795,6 @@ static int si2165_set_if_freq_shift(struct si2165_state *state)
 	return si2165_writereg32(state, 0x00e8, reg_value);
 }
 
-static const struct si2165_reg_value_pair agc_rewrite[] = {
-	{ 0x012a, 0x46 },
-	{ 0x012c, 0x00 },
-	{ 0x012e, 0x0a },
-	{ 0x012f, 0xff },
-	{ 0x0123, 0x70 }
-};
-
 static const struct si2165_reg_value_pair dvbt_regs[] = {
 	/* standard = DVB-T */
 	{ 0x00ec, 0x01 },
@@ -826,12 +818,11 @@ static const struct si2165_reg_value_pair dvbt_regs[] = {
 	{ 0x0387, 0x00 }
 };
 
-static int si2165_set_frontend(struct dvb_frontend *fe)
+static int si2165_set_frontend_dvbt(struct dvb_frontend *fe)
 {
 	int ret;
 	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
 	struct si2165_state *state = fe->demodulator_priv;
-	u8 val[3];
 	u32 dvb_rate = 0;
 	u16 bw10k;
 	u32 bw_hz = p->bandwidth_hz;
@@ -851,9 +842,6 @@ static int si2165_set_frontend(struct dvb_frontend *fe)
 	if (ret < 0)
 		return ret;
 
-	ret = si2165_set_if_freq_shift(state);
-	if (ret < 0)
-		return ret;
 	/* bandwidth in 10KHz steps */
 	ret = si2165_writereg16(state, 0x0308, bw10k);
 	if (ret < 0)
@@ -866,6 +854,40 @@ static int si2165_set_frontend(struct dvb_frontend *fe)
 	if (ret < 0)
 		return ret;
 
+	return 0;
+}
+
+static const struct si2165_reg_value_pair agc_rewrite[] = {
+	{ 0x012a, 0x46 },
+	{ 0x012c, 0x00 },
+	{ 0x012e, 0x0a },
+	{ 0x012f, 0xff },
+	{ 0x0123, 0x70 }
+};
+
+static int si2165_set_frontend(struct dvb_frontend *fe)
+{
+	struct si2165_state *state = fe->demodulator_priv;
+	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
+	u32 delsys = p->delivery_system;
+	int ret;
+	u8 val[3];
+
+	/* initial setting of if freq shift */
+	ret = si2165_set_if_freq_shift(state);
+	if (ret < 0)
+		return ret;
+
+	switch (delsys) {
+	case SYS_DVBT:
+		ret = si2165_set_frontend_dvbt(fe);
+		if (ret < 0)
+			return ret;
+		break;
+	default:
+		return -EINVAL;
+	}
+
 	/* dsp_addr_jump */
 	ret = si2165_writereg32(state, 0x0348, 0xf4000000);
 	if (ret < 0)
@@ -886,6 +908,7 @@ static int si2165_set_frontend(struct dvb_frontend *fe)
 	ret = si2165_writereg8(state, 0x0341, 0x00);
 	if (ret < 0)
 		return ret;
+
 	/* reset all */
 	ret = si2165_writereg8(state, 0x00c0, 0x00);
 	if (ret < 0)
-- 
2.6.3


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

* [PATCH 10/10] si2165: Add DVB-C support for HVR-4400/HVR-5500
  2015-11-19 20:03 si2165: Add simple DVB-C support Matthias Schwarzott
                   ` (8 preceding siblings ...)
  2015-11-19 20:04 ` [PATCH 09/10] si2165: Prepare si2165_set_frontend for splitting Matthias Schwarzott
@ 2015-11-19 20:04 ` Matthias Schwarzott
  9 siblings, 0 replies; 14+ messages in thread
From: Matthias Schwarzott @ 2015-11-19 20:04 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, crope, xpert-reactos, Matthias Schwarzott

It works only for HVR-4400/HVR-5500.
For WinTV-HVR-930C-HD it fails with bad/no reception
for unknown reasons.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
 drivers/media/dvb-frontends/si2165.c | 86 +++++++++++++++++++++++++++++++++---
 1 file changed, 81 insertions(+), 5 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index 131aef1..dd4503a 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -857,6 +857,71 @@ static int si2165_set_frontend_dvbt(struct dvb_frontend *fe)
 	return 0;
 }
 
+static const struct si2165_reg_value_pair dvbc_regs[] = {
+	/* standard = DVB-C */
+	{ 0x00ec, 0x05 },
+	{ 0x08f8, 0x00 },
+
+	/* agc2 */
+	{ 0x016e, 0x50 },
+	{ 0x016c, 0x0e },
+	{ 0x016d, 0x10 },
+	/* agc */
+	{ 0x015b, 0x03 },
+	{ 0x0150, 0x68 },
+	/* agc */
+	{ 0x01a0, 0x68 },
+	{ 0x01c8, 0x50 },
+
+	{ 0x0278, 0x0d },
+
+	{ 0x023a, 0x05 },
+	{ 0x0261, 0x09 },
+	REG16(0x0350, 0x3e80),
+	{ 0x02f4, 0x00 },
+
+	{ 0x00cb, 0x01 },
+	REG16(0x024c, 0x0000),
+	REG16(0x027c, 0x0000),
+	{ 0x0232, 0x03 },
+	{ 0x02f4, 0x0b },
+	{ 0x018b, 0x00 },
+};
+
+static int si2165_set_frontend_dvbc(struct dvb_frontend *fe)
+{
+	struct si2165_state *state = fe->demodulator_priv;
+	int ret;
+	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
+	const u32 dvb_rate = p->symbol_rate;
+	const u32 bw_hz = p->bandwidth_hz;
+
+	if (!state->has_dvbc)
+		return -EINVAL;
+
+	if (dvb_rate == 0)
+		return -EINVAL;
+
+	ret = si2165_adjust_pll_divl(state, 14);
+	if (ret < 0)
+		return ret;
+
+	/* Oversampling */
+	ret = si2165_set_oversamp(state, dvb_rate);
+	if (ret < 0)
+		return ret;
+
+	ret = si2165_writereg32(state, 0x00c4, bw_hz);
+	if (ret < 0)
+		return ret;
+
+	ret = si2165_write_reg_list(state, dvbc_regs, ARRAY_SIZE(dvbc_regs));
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
 static const struct si2165_reg_value_pair agc_rewrite[] = {
 	{ 0x012a, 0x46 },
 	{ 0x012c, 0x00 },
@@ -884,6 +949,11 @@ static int si2165_set_frontend(struct dvb_frontend *fe)
 		if (ret < 0)
 			return ret;
 		break;
+	case SYS_DVBC_ANNEX_A:
+		ret = si2165_set_frontend_dvbc(fe);
+		if (ret < 0)
+			return ret;
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -947,7 +1017,12 @@ static void si2165_release(struct dvb_frontend *fe)
 static struct dvb_frontend_ops si2165_ops = {
 	.info = {
 		.name = "Silicon Labs ",
-		.caps =	FE_CAN_FEC_1_2 |
+		 /* For DVB-C */
+		.symbol_rate_min = 1000000,
+		.symbol_rate_max = 7200000,
+		/* For DVB-T */
+		.frequency_stepsize = 166667,
+		.caps = FE_CAN_FEC_1_2 |
 			FE_CAN_FEC_2_3 |
 			FE_CAN_FEC_3_4 |
 			FE_CAN_FEC_5_6 |
@@ -960,7 +1035,6 @@ static struct dvb_frontend_ops si2165_ops = {
 			FE_CAN_QAM_128 |
 			FE_CAN_QAM_256 |
 			FE_CAN_QAM_AUTO |
-			FE_CAN_TRANSMISSION_MODE_AUTO |
 			FE_CAN_GUARD_INTERVAL_AUTO |
 			FE_CAN_HIERARCHY_AUTO |
 			FE_CAN_MUTE_TS |
@@ -1072,9 +1146,11 @@ struct dvb_frontend *si2165_attach(const struct si2165_config *config,
 		strlcat(state->fe.ops.info.name, " DVB-T",
 			sizeof(state->fe.ops.info.name));
 	}
-	if (state->has_dvbc)
-		dev_warn(&state->i2c->dev, "%s: DVB-C is not yet supported.\n",
-		       KBUILD_MODNAME);
+	if (state->has_dvbc) {
+		state->fe.ops.delsys[n++] = SYS_DVBC_ANNEX_A;
+		strlcat(state->fe.ops.info.name, " DVB-C",
+			sizeof(state->fe.ops.info.name));
+	}
 
 	return &state->fe;
 
-- 
2.6.3


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

* Re: [PATCH 07/10] si2165: Fix DVB-T bandwidth default
  2015-11-19 20:03 ` [PATCH 07/10] si2165: Fix DVB-T bandwidth default Matthias Schwarzott
@ 2015-12-03 14:15   ` Mauro Carvalho Chehab
  2015-12-03 20:11     ` Matthias Schwarzott
  0 siblings, 1 reply; 14+ messages in thread
From: Mauro Carvalho Chehab @ 2015-12-03 14:15 UTC (permalink / raw)
  To: Matthias Schwarzott; +Cc: linux-media, crope, xpert-reactos

Em Thu, 19 Nov 2015 21:03:59 +0100
Matthias Schwarzott <zzam@gentoo.org> escreveu:


Please, add a description to your patches.

That's said, this patch should be called, instead:

si2165: Fix DVB-T bandwidth auto

DVB auto bandwidth mode (bandwidth_hz == 0) logic was setting
the initial value for dvb_rate to a wrong value. Fix it.

as a zero value here means to let the frontend to auto-detect
the bandwidth. Of course, assuming that si2165 is capable of
doing that.

If si2165 chip or driver doesn't support bandwidth auto-detection, it
should, instead, return -EINVAL.

Are you sure that it will auto-detect the bandwidth if we keep it
as 8MHz?

Regards,
Mauro





> Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
> ---
>  drivers/media/dvb-frontends/si2165.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
> index 807a3c9..e97b0e6 100644
> --- a/drivers/media/dvb-frontends/si2165.c
> +++ b/drivers/media/dvb-frontends/si2165.c
> @@ -811,19 +811,18 @@ static int si2165_set_frontend(struct dvb_frontend *fe)
>  	u8 val[3];
>  	u32 dvb_rate = 0;
>  	u16 bw10k;
> +	u32 bw_hz = p->bandwidth_hz;
>  
>  	dprintk("%s: called\n", __func__);
>  
>  	if (!state->has_dvbt)
>  		return -EINVAL;
>  
> -	if (p->bandwidth_hz > 0) {
> -		dvb_rate = p->bandwidth_hz * 8 / 7;
> -		bw10k = p->bandwidth_hz / 10000;
> -	} else {
> -		dvb_rate = 8 * 8 / 7;
> -		bw10k = 800;
> -	}
> +	if (bw_hz == 0)
> +		bw_hz = 8000000;
> +
> +	dvb_rate = bw_hz * 8 / 7;
> +	bw10k = bw_hz / 10000;
>  
>  	/* standard = DVB-T */
>  	ret = si2165_writereg8(state, 0x00ec, 0x01);

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

* Re: [PATCH 07/10] si2165: Fix DVB-T bandwidth default
  2015-12-03 14:15   ` Mauro Carvalho Chehab
@ 2015-12-03 20:11     ` Matthias Schwarzott
  2015-12-03 20:12       ` [PATCH] si2165: Reject DVB-T bandwidth auto mode Matthias Schwarzott
  0 siblings, 1 reply; 14+ messages in thread
From: Matthias Schwarzott @ 2015-12-03 20:11 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-media, crope, xpert-reactos

Am 03.12.2015 um 15:15 schrieb Mauro Carvalho Chehab:
> Em Thu, 19 Nov 2015 21:03:59 +0100
> Matthias Schwarzott <zzam@gentoo.org> escreveu:
> 
> 
> Please, add a description to your patches.
> 
> That's said, this patch should be called, instead:
> 
> si2165: Fix DVB-T bandwidth auto
> 
> DVB auto bandwidth mode (bandwidth_hz == 0) logic was setting
> the initial value for dvb_rate to a wrong value. Fix it.
> 
> as a zero value here means to let the frontend to auto-detect
> the bandwidth. Of course, assuming that si2165 is capable of
> doing that.
> 
> If si2165 chip or driver doesn't support bandwidth auto-detection, it
> should, instead, return -EINVAL.
> 
> Are you sure that it will auto-detect the bandwidth if we keep it
> as 8MHz?
> 

Thanks for the feedback.
As far as I know si2165 does not support auto-detection of bandwidth.

I only have 8MHz channels available I tried what happens when
configuring other bandwidth values - it will not lock.

So I will resend the modified the patch.

Regards
Matthias


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

* [PATCH] si2165: Reject DVB-T bandwidth auto mode
  2015-12-03 20:11     ` Matthias Schwarzott
@ 2015-12-03 20:12       ` Matthias Schwarzott
  0 siblings, 0 replies; 14+ messages in thread
From: Matthias Schwarzott @ 2015-12-03 20:12 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, crope, xpert-reactos, Matthias Schwarzott

The si2165 does not support bandwidth auto-detection.
Reject the request.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
 drivers/media/dvb-frontends/si2165.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index 1cf6e52..6fcd3ba 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -825,19 +825,19 @@ static int si2165_set_frontend_dvbt(struct dvb_frontend *fe)
 	struct si2165_state *state = fe->demodulator_priv;
 	u32 dvb_rate = 0;
 	u16 bw10k;
+	u32 bw_hz = p->bandwidth_hz;
 
 	dprintk("%s: called\n", __func__);
 
 	if (!state->has_dvbt)
 		return -EINVAL;
 
-	if (p->bandwidth_hz > 0) {
-		dvb_rate = p->bandwidth_hz * 8 / 7;
-		bw10k = p->bandwidth_hz / 10000;
-	} else {
-		dvb_rate = 8 * 8 / 7;
-		bw10k = 800;
-	}
+	/* no bandwidth auto-detection */
+	if (bw_hz == 0)
+		return -EINVAL;
+
+	dvb_rate = bw_hz * 8 / 7;
+	bw10k = bw_hz / 10000;
 
 	ret = si2165_adjust_pll_divl(state, 12);
 	if (ret < 0)
-- 
2.6.3


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

end of thread, other threads:[~2015-12-03 20:13 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-19 20:03 si2165: Add simple DVB-C support Matthias Schwarzott
2015-11-19 20:03 ` [PATCH 01/10] si2165: rename frontend -> fe Matthias Schwarzott
2015-11-19 20:03 ` [PATCH 02/10] si2165: rename si2165_set_parameters to si2165_set_frontend Matthias Schwarzott
2015-11-19 20:03 ` [PATCH 03/10] si2165: create function si2165_write_reg_list for writing register lists Matthias Schwarzott
2015-11-19 20:03 ` [PATCH 04/10] si2165: only write agc registers after reset before start_syncro Matthias Schwarzott
2015-11-19 20:03 ` [PATCH 05/10] si2165: move setting ts config to init Matthias Schwarzott
2015-11-19 20:03 ` [PATCH 06/10] si2165: Simplify si2165_set_if_freq_shift usage Matthias Schwarzott
2015-11-19 20:03 ` [PATCH 07/10] si2165: Fix DVB-T bandwidth default Matthias Schwarzott
2015-12-03 14:15   ` Mauro Carvalho Chehab
2015-12-03 20:11     ` Matthias Schwarzott
2015-12-03 20:12       ` [PATCH] si2165: Reject DVB-T bandwidth auto mode Matthias Schwarzott
2015-11-19 20:04 ` [PATCH 08/10] si2165: set list of DVB-T registers together Matthias Schwarzott
2015-11-19 20:04 ` [PATCH 09/10] si2165: Prepare si2165_set_frontend for splitting Matthias Schwarzott
2015-11-19 20:04 ` [PATCH 10/10] si2165: Add DVB-C support for HVR-4400/HVR-5500 Matthias Schwarzott

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