* [PATCH 1/4] cx231xx_dvb: use demod_i2c for demod attach
@ 2015-11-13 22:54 Matthias Schwarzott
2015-11-13 22:54 ` [PATCH 2/4] si2165: fix checkpatch issues Matthias Schwarzott
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Matthias Schwarzott @ 2015-11-13 22:54 UTC (permalink / raw)
To: linux-media; +Cc: mchehab, crope, xpert-reactos, Matthias Schwarzott
Tested:
* CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx
* CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx
Not Tested:
* CX231XX_BOARD_HAUPPAUGE_EXETER
* CX231XX_BOARD_HAUPPAUGE_955Q
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
drivers/media/usb/cx231xx/cx231xx-cards.c | 8 ++++----
drivers/media/usb/cx231xx/cx231xx-dvb.c | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 4a117a5..5d4b285 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -352,7 +352,7 @@ struct cx231xx_board cx231xx_boards[] = {
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
.tuner_i2c_master = I2C_1_MUX_1,
- .demod_i2c_master = I2C_2,
+ .demod_i2c_master = I2C_1_MUX_1,
.has_dvb = 1,
.demod_addr = 0x0e,
.norm = V4L2_STD_NTSC,
@@ -713,7 +713,7 @@ struct cx231xx_board cx231xx_boards[] = {
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
.tuner_i2c_master = I2C_1_MUX_3,
- .demod_i2c_master = I2C_2,
+ .demod_i2c_master = I2C_1_MUX_3,
.has_dvb = 1,
.demod_addr = 0x0e,
.norm = V4L2_STD_PAL,
@@ -752,7 +752,7 @@ struct cx231xx_board cx231xx_boards[] = {
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
.tuner_i2c_master = I2C_1_MUX_3,
- .demod_i2c_master = I2C_2,
+ .demod_i2c_master = I2C_1_MUX_3,
.has_dvb = 1,
.demod_addr = 0x0e,
.norm = V4L2_STD_PAL,
@@ -791,7 +791,7 @@ struct cx231xx_board cx231xx_boards[] = {
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
.tuner_i2c_master = I2C_1_MUX_3,
- .demod_i2c_master = I2C_2,
+ .demod_i2c_master = I2C_1_MUX_3,
.has_dvb = 1,
.demod_addr = 0x0e,
.norm = V4L2_STD_NTSC,
diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
index 66ee161..e3594b9 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
@@ -725,7 +725,7 @@ static int dvb_init(struct cx231xx *dev)
dev->dvb->frontend = dvb_attach(lgdt3305_attach,
&hcw_lgdt3305_config,
- tuner_i2c);
+ demod_i2c);
if (dev->dvb->frontend == NULL) {
dev_err(dev->dev,
@@ -746,7 +746,7 @@ static int dvb_init(struct cx231xx *dev)
dev->dvb->frontend = dvb_attach(si2165_attach,
&hauppauge_930C_HD_1113xx_si2165_config,
- tuner_i2c
+ demod_i2c
);
if (dev->dvb->frontend == NULL) {
@@ -779,7 +779,7 @@ static int dvb_init(struct cx231xx *dev)
dev->dvb->frontend = dvb_attach(si2165_attach,
&pctv_quatro_stick_1114xx_si2165_config,
- tuner_i2c
+ demod_i2c
);
if (dev->dvb->frontend == NULL) {
@@ -835,7 +835,7 @@ static int dvb_init(struct cx231xx *dev)
dev->dvb->frontend = dvb_attach(lgdt3306a_attach,
&hauppauge_955q_lgdt3306a_config,
- tuner_i2c
+ demod_i2c
);
if (dev->dvb->frontend == NULL) {
--
2.6.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/4] si2165: fix checkpatch issues
2015-11-13 22:54 [PATCH 1/4] cx231xx_dvb: use demod_i2c for demod attach Matthias Schwarzott
@ 2015-11-13 22:54 ` Matthias Schwarzott
2015-11-13 22:54 ` [PATCH 3/4] si2165: cleanup logic Matthias Schwarzott
2015-11-13 22:54 ` [PATCH 4/4] si2165: Add DVB-C support for HVR-4400/HVR-5500 Matthias Schwarzott
2 siblings, 0 replies; 7+ messages in thread
From: Matthias Schwarzott @ 2015-11-13 22:54 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 | 69 ++++++++++++++++++++----------------
1 file changed, 39 insertions(+), 30 deletions(-)
diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index 7c2eeee..c5d7c0d 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -1,21 +1,21 @@
/*
- Driver for Silicon Labs Si2161 DVB-T and Si2165 DVB-C/-T Demodulator
-
- Copyright (C) 2013-2014 Matthias Schwarzott <zzam@gentoo.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- References:
- http://www.silabs.com/Support%20Documents/TechnicalDocs/Si2165-short.pdf
-*/
+ * Driver for Silicon Labs Si2161 DVB-T and Si2165 DVB-C/-T Demodulator
+ *
+ * Copyright (C) 2013-2014 Matthias Schwarzott <zzam@gentoo.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * References:
+ * http://www.silabs.com/Support%20Documents/TechnicalDocs/Si2165-short.pdf
+ */
#include <linux/delay.h>
#include <linux/errno.h>
@@ -31,11 +31,13 @@
#include "si2165_priv.h"
#include "si2165.h"
-/* Hauppauge WinTV-HVR-930C-HD B130 / PCTV QuatroStick 521e 1113xx
- * uses 16 MHz xtal */
-
-/* Hauppauge WinTV-HVR-930C-HD B131 / PCTV QuatroStick 522e 1114xx
- * uses 24 MHz clock provided by tuner */
+/*
+ * Hauppauge WinTV-HVR-930C-HD B130 / PCTV QuatroStick 521e 1113xx
+ * uses 16 MHz xtal
+ *
+ * Hauppauge WinTV-HVR-930C-HD B131 / PCTV QuatroStick 522e 1114xx
+ * uses 24 MHz clock provided by tuner
+ */
struct si2165_state {
struct i2c_adapter *i2c;
@@ -258,8 +260,10 @@ static int si2165_init_pll(struct si2165_state *state)
u8 divl = 12;
u8 buf[4];
- /* hardcoded values can be deleted if calculation is verified
- * or it yields the same values as the windows driver */
+ /*
+ * hardcoded values can be deleted if calculation is verified
+ * or it yields the same values as the windows driver
+ */
switch (ref_freq_Hz) {
case 16000000u:
divn = 56;
@@ -274,8 +278,10 @@ static int si2165_init_pll(struct si2165_state *state)
if (ref_freq_Hz > 16000000u)
divr = 2;
- /* now select divn and divp such that
- * fvco is in 1624..1824 MHz */
+ /*
+ * now select divn and divp such that
+ * fvco is in 1624..1824 MHz
+ */
if (1624000000u * divr > ref_freq_Hz * 2u * 63u)
divp = 4;
@@ -341,10 +347,12 @@ static int si2165_upload_firmware_block(struct si2165_state *state,
if (len % 4 != 0)
return -EINVAL;
- deb_fw_load("si2165_upload_firmware_block called with len=0x%x offset=0x%x blockcount=0x%x\n",
+ deb_fw_load(
+ "si2165_upload_firmware_block called with len=0x%x offset=0x%x blockcount=0x%x\n",
len, offset, block_count);
while (offset+12 <= len && cur_block < block_count) {
- deb_fw_load("si2165_upload_firmware_block in while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n",
+ deb_fw_load(
+ "si2165_upload_firmware_block in while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n",
len, offset, cur_block, block_count);
wordcount = data[offset];
if (wordcount < 1 || data[offset+1] ||
@@ -383,7 +391,8 @@ static int si2165_upload_firmware_block(struct si2165_state *state,
cur_block++;
}
- deb_fw_load("si2165_upload_firmware_block after while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n",
+ deb_fw_load(
+ "si2165_upload_firmware_block after while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n",
len, offset, cur_block, block_count);
if (poffset)
@@ -633,7 +642,7 @@ static int si2165_init(struct dvb_frontend *fe)
goto error;
/* ber_pkt */
- ret = si2165_writereg16(state, 0x0470 , 0x7530);
+ ret = si2165_writereg16(state, 0x0470, 0x7530);
if (ret < 0)
goto error;
--
2.6.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/4] si2165: cleanup logic
2015-11-13 22:54 [PATCH 1/4] cx231xx_dvb: use demod_i2c for demod attach Matthias Schwarzott
2015-11-13 22:54 ` [PATCH 2/4] si2165: fix checkpatch issues Matthias Schwarzott
@ 2015-11-13 22:54 ` Matthias Schwarzott
2015-11-14 1:05 ` kbuild test robot
2015-11-13 22:54 ` [PATCH 4/4] si2165: Add DVB-C support for HVR-4400/HVR-5500 Matthias Schwarzott
2 siblings, 1 reply; 7+ messages in thread
From: Matthias Schwarzott @ 2015-11-13 22:54 UTC (permalink / raw)
To: linux-media; +Cc: mchehab, crope, xpert-reactos, Matthias Schwarzott
Make si2165_set_if_freq_shift query IF frequency itself.
create function to write a set of registers
Always write adc registers after reset.
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
drivers/media/dvb-frontends/si2165.c | 173 ++++++++++++++++++-----------------
1 file changed, 87 insertions(+), 86 deletions(-)
diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index c5d7c0d..c87d927 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)
{
@@ -669,22 +690,19 @@ 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);
+ /* ts output config */
+ ret = si2165_writereg8(state, 0x04e4, 0x20);
if (ret < 0)
- goto error;
- ret = si2165_writereg8(state, 0x012e, 0x0a);
+ return ret;
+ ret = si2165_writereg16(state, 0x04ef, 0x00fe);
if (ret < 0)
- goto error;
- ret = si2165_writereg8(state, 0x012f, 0xff);
+ return ret;
+ ret = si2165_writereg24(state, 0x04f4, 0x555555);
if (ret < 0)
- goto error;
- ret = si2165_writereg8(state, 0x0123, 0x70);
+ return ret;
+ ret = si2165_writereg8(state, 0x04e5, 0x01);
if (ret < 0)
- goto error;
+ return ret;
return 0;
error:
@@ -746,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->frontend);
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;
@@ -767,35 +795,53 @@ 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 const struct si2165_reg_value_pair dvbt_regs[] = {
+ /* 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_parameters(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 IF;
u32 dvb_rate = 0;
u16 bw10k;
+ u32 bw_hz = p->bandwidth_hz;
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;
- 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);
@@ -805,26 +851,12 @@ static int si2165_set_parameters(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);
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)
@@ -832,48 +864,11 @@ static int si2165_set_parameters(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)
@@ -883,8 +878,7 @@ static int si2165_set_parameters(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;
@@ -903,6 +897,13 @@ static int si2165_set_parameters(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)
+ goto error;
+
/* start_synchro */
ret = si2165_writereg8(state, 0x02e0, 0x01);
if (ret < 0)
--
2.6.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/4] si2165: Add DVB-C support for HVR-4400/HVR-5500
2015-11-13 22:54 [PATCH 1/4] cx231xx_dvb: use demod_i2c for demod attach Matthias Schwarzott
2015-11-13 22:54 ` [PATCH 2/4] si2165: fix checkpatch issues Matthias Schwarzott
2015-11-13 22:54 ` [PATCH 3/4] si2165: cleanup logic Matthias Schwarzott
@ 2015-11-13 22:54 ` Matthias Schwarzott
2015-11-19 13:28 ` Mauro Carvalho Chehab
2 siblings, 1 reply; 7+ messages in thread
From: Matthias Schwarzott @ 2015-11-13 22:54 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 | 132 +++++++++++++++++++++++++++++++----
1 file changed, 120 insertions(+), 12 deletions(-)
diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index c87d927..97a6eac 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);
}
@@ -823,7 +823,7 @@ static const struct si2165_reg_value_pair dvbt_regs[] = {
{ 0x0387, 0x00 }
};
-static int si2165_set_parameters(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;
@@ -851,9 +851,6 @@ static int si2165_set_parameters(struct dvb_frontend *fe)
if (ret < 0)
return ret;
- ret = si2165_set_if_freq_shift(state);
- if (ret < 0)
- return ret;
ret = si2165_writereg8(state, 0x08f8, 0x00);
if (ret < 0)
return ret;
@@ -874,6 +871,110 @@ static int si2165_set_parameters(struct dvb_frontend *fe)
if (ret < 0)
return ret;
+ return 0;
+}
+
+static const struct si2165_reg_value_pair dvbc_regs[] = {
+ /* 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 }
+};
+
+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;
+
+ /* standard = DVB-C */
+ ret = si2165_writereg8(state, 0x00ec, 0x05);
+ if (ret < 0)
+ return ret;
+ ret = si2165_adjust_pll_divl(state, 14);
+ if (ret < 0)
+ return ret;
+
+ ret = si2165_writereg8(state, 0x08f8, 0x00);
+ if (ret < 0)
+ return ret;
+
+ /* Oversampling */
+ ret = si2165_set_oversamp(state, dvb_rate);
+ if (ret < 0)
+ return ret;
+
+ ret = si2165_write_reg_list(state, dvbc_regs, ARRAY_SIZE(dvbc_regs));
+ if (ret < 0)
+ return ret;
+
+ /* dsp_addr_jump */
+ ret = si2165_writereg32(state, 0x0348, 0xf4000000);
+ if (ret < 0)
+ return ret;
+
+ si2165_writereg32(state, 0x00c4, bw_hz);
+ si2165_writereg8(state, 0x00cb, 0x01);
+ si2165_writereg8(state, 0x00c0, 0x00);
+ si2165_writereg16(state, 0x024c, 0x0000);
+ si2165_writereg16(state, 0x027c, 0x0000);
+ si2165_writereg8(state, 0x0232, 0x03);
+ si2165_writereg8(state, 0x02f4, 0x0b);
+ si2165_writereg8(state, 0x00c0, 0x00);
+ si2165_writereg8(state, 0x018b, 0x00);
+
+ return 0;
+}
+
+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;
+ case SYS_DVBC_ANNEX_A:
+ ret = si2165_set_frontend_dvbc(fe);
+ if (ret < 0)
+ return ret;
+ break;
+ default:
+ return -EINVAL;
+ }
+
if (fe->ops.tuner_ops.set_params)
fe->ops.tuner_ops.set_params(fe);
@@ -889,6 +990,7 @@ static int si2165_set_parameters(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)
@@ -902,7 +1004,7 @@ static int si2165_set_parameters(struct dvb_frontend *fe)
ret = si2165_write_reg_list(state, agc_rewrite,
ARRAY_SIZE(agc_rewrite));
if (ret < 0)
- goto error;
+ return ret;
/* start_synchro */
ret = si2165_writereg8(state, 0x02e0, 0x01);
@@ -927,7 +1029,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 |
@@ -940,7 +1047,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 |
@@ -953,7 +1059,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,
@@ -1052,9 +1158,11 @@ struct dvb_frontend *si2165_attach(const struct si2165_config *config,
strlcat(state->frontend.ops.info.name, " DVB-T",
sizeof(state->frontend.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->frontend.ops.delsys[n++] = SYS_DVBC_ANNEX_A;
+ strlcat(state->frontend.ops.info.name, " DVB-C",
+ sizeof(state->frontend.ops.info.name));
+ }
return &state->frontend;
--
2.6.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 3/4] si2165: cleanup logic
2015-11-13 22:54 ` [PATCH 3/4] si2165: cleanup logic Matthias Schwarzott
@ 2015-11-14 1:05 ` kbuild test robot
0 siblings, 0 replies; 7+ messages in thread
From: kbuild test robot @ 2015-11-14 1:05 UTC (permalink / raw)
To: Matthias Schwarzott
Cc: kbuild-all, linux-media, mchehab, crope, xpert-reactos,
Matthias Schwarzott
[-- Attachment #1: Type: text/plain, Size: 3788 bytes --]
Hi Matthias,
[auto build test ERROR on v4.3-rc7]
[also build test ERROR on next-20151113]
url: https://github.com/0day-ci/linux/commits/Matthias-Schwarzott/cx231xx_dvb-use-demod_i2c-for-demod-attach/20151114-065917
config: xtensa-allyesconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa
Note: the linux-review/Matthias-Schwarzott/cx231xx_dvb-use-demod_i2c-for-demod-attach/20151114-065917 HEAD 92eaa21d1f22e14d623c057e06ab9d5035f6df7b builds fine.
It only hurts bisectibility.
All errors (new ones prefixed by >>):
drivers/media/dvb-frontends/si2165.c: In function 'si2165_set_parameters':
>> drivers/media/dvb-frontends/si2165.c:886:39: error: 'val' undeclared (first use in this function)
ret = si2165_readreg8(state, 0x0341, val);
^
drivers/media/dvb-frontends/si2165.c:886:39: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/media/dvb-frontends/si2165.c:905:3: error: label 'error' used but not defined
goto error;
^
vim +/val +886 drivers/media/dvb-frontends/si2165.c
3e54a169 Matthias Schwarzott 2014-07-22 880 /* recalc if_freq_shift if IF might has changed */
b480ae7b Matthias Schwarzott 2015-11-13 881 ret = si2165_set_if_freq_shift(state);
3e54a169 Matthias Schwarzott 2014-07-22 882 if (ret < 0)
3e54a169 Matthias Schwarzott 2014-07-22 883 return ret;
3e54a169 Matthias Schwarzott 2014-07-22 884
3e54a169 Matthias Schwarzott 2014-07-22 885 /* boot/wdog status */
3e54a169 Matthias Schwarzott 2014-07-22 @886 ret = si2165_readreg8(state, 0x0341, val);
3e54a169 Matthias Schwarzott 2014-07-22 887 if (ret < 0)
3e54a169 Matthias Schwarzott 2014-07-22 888 return ret;
3e54a169 Matthias Schwarzott 2014-07-22 889 ret = si2165_writereg8(state, 0x0341, 0x00);
3e54a169 Matthias Schwarzott 2014-07-22 890 if (ret < 0)
3e54a169 Matthias Schwarzott 2014-07-22 891 return ret;
3e54a169 Matthias Schwarzott 2014-07-22 892 /* reset all */
3e54a169 Matthias Schwarzott 2014-07-22 893 ret = si2165_writereg8(state, 0x00c0, 0x00);
3e54a169 Matthias Schwarzott 2014-07-22 894 if (ret < 0)
3e54a169 Matthias Schwarzott 2014-07-22 895 return ret;
3e54a169 Matthias Schwarzott 2014-07-22 896 /* gp_reg0 */
3e54a169 Matthias Schwarzott 2014-07-22 897 ret = si2165_writereg32(state, 0x0384, 0x00000000);
3e54a169 Matthias Schwarzott 2014-07-22 898 if (ret < 0)
3e54a169 Matthias Schwarzott 2014-07-22 899 return ret;
b480ae7b Matthias Schwarzott 2015-11-13 900
b480ae7b Matthias Schwarzott 2015-11-13 901 /* write adc values after each reset*/
b480ae7b Matthias Schwarzott 2015-11-13 902 ret = si2165_write_reg_list(state, agc_rewrite,
b480ae7b Matthias Schwarzott 2015-11-13 903 ARRAY_SIZE(agc_rewrite));
b480ae7b Matthias Schwarzott 2015-11-13 904 if (ret < 0)
b480ae7b Matthias Schwarzott 2015-11-13 @905 goto error;
b480ae7b Matthias Schwarzott 2015-11-13 906
3e54a169 Matthias Schwarzott 2014-07-22 907 /* start_synchro */
3e54a169 Matthias Schwarzott 2014-07-22 908 ret = si2165_writereg8(state, 0x02e0, 0x01);
:::::: The code at line 886 was first introduced by commit
:::::: 3e54a1697ace99d1ad602ec268abf117ace1412f [media] si2165: Add demod driver for DVB-T only
:::::: TO: Matthias Schwarzott <zzam@gentoo.org>
:::::: CC: Mauro Carvalho Chehab <m.chehab@samsung.com>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 42426 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 4/4] si2165: Add DVB-C support for HVR-4400/HVR-5500
2015-11-13 22:54 ` [PATCH 4/4] si2165: Add DVB-C support for HVR-4400/HVR-5500 Matthias Schwarzott
@ 2015-11-19 13:28 ` Mauro Carvalho Chehab
2015-11-22 17:46 ` Matthias Schwarzott
0 siblings, 1 reply; 7+ messages in thread
From: Mauro Carvalho Chehab @ 2015-11-19 13:28 UTC (permalink / raw)
To: Matthias Schwarzott; +Cc: linux-media, crope, xpert-reactos
Em Fri, 13 Nov 2015 23:54:58 +0100
Matthias Schwarzott <zzam@gentoo.org> escreveu:
> It works only for HVR-4400/HVR-5500.
> For WinTV-HVR-930C-HD it fails with bad/no reception
> for unknown reasons.
Patch 3/4 of this series is broken. As this one depends on it, please
resend both patches 3 and 4 on your next patch series.
Regards,
Mauro
PS.: patches 1 and 2 are ok and got applied upstream already.
>
> Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
> ---
> drivers/media/dvb-frontends/si2165.c | 132 +++++++++++++++++++++++++++++++----
> 1 file changed, 120 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
> index c87d927..97a6eac 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);
> }
>
> @@ -823,7 +823,7 @@ static const struct si2165_reg_value_pair dvbt_regs[] = {
> { 0x0387, 0x00 }
> };
>
> -static int si2165_set_parameters(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;
> @@ -851,9 +851,6 @@ static int si2165_set_parameters(struct dvb_frontend *fe)
> if (ret < 0)
> return ret;
>
> - ret = si2165_set_if_freq_shift(state);
> - if (ret < 0)
> - return ret;
> ret = si2165_writereg8(state, 0x08f8, 0x00);
> if (ret < 0)
> return ret;
> @@ -874,6 +871,110 @@ static int si2165_set_parameters(struct dvb_frontend *fe)
> if (ret < 0)
> return ret;
>
> + return 0;
> +}
> +
> +static const struct si2165_reg_value_pair dvbc_regs[] = {
> + /* 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 }
> +};
> +
> +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;
> +
> + /* standard = DVB-C */
> + ret = si2165_writereg8(state, 0x00ec, 0x05);
> + if (ret < 0)
> + return ret;
> + ret = si2165_adjust_pll_divl(state, 14);
> + if (ret < 0)
> + return ret;
> +
> + ret = si2165_writereg8(state, 0x08f8, 0x00);
> + if (ret < 0)
> + return ret;
> +
> + /* Oversampling */
> + ret = si2165_set_oversamp(state, dvb_rate);
> + if (ret < 0)
> + return ret;
> +
> + ret = si2165_write_reg_list(state, dvbc_regs, ARRAY_SIZE(dvbc_regs));
> + if (ret < 0)
> + return ret;
> +
> + /* dsp_addr_jump */
> + ret = si2165_writereg32(state, 0x0348, 0xf4000000);
> + if (ret < 0)
> + return ret;
> +
> + si2165_writereg32(state, 0x00c4, bw_hz);
> + si2165_writereg8(state, 0x00cb, 0x01);
> + si2165_writereg8(state, 0x00c0, 0x00);
> + si2165_writereg16(state, 0x024c, 0x0000);
> + si2165_writereg16(state, 0x027c, 0x0000);
> + si2165_writereg8(state, 0x0232, 0x03);
> + si2165_writereg8(state, 0x02f4, 0x0b);
> + si2165_writereg8(state, 0x00c0, 0x00);
> + si2165_writereg8(state, 0x018b, 0x00);
> +
> + return 0;
> +}
> +
> +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;
> + case SYS_DVBC_ANNEX_A:
> + ret = si2165_set_frontend_dvbc(fe);
> + if (ret < 0)
> + return ret;
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> if (fe->ops.tuner_ops.set_params)
> fe->ops.tuner_ops.set_params(fe);
>
> @@ -889,6 +990,7 @@ static int si2165_set_parameters(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)
> @@ -902,7 +1004,7 @@ static int si2165_set_parameters(struct dvb_frontend *fe)
> ret = si2165_write_reg_list(state, agc_rewrite,
> ARRAY_SIZE(agc_rewrite));
> if (ret < 0)
> - goto error;
> + return ret;
>
> /* start_synchro */
> ret = si2165_writereg8(state, 0x02e0, 0x01);
> @@ -927,7 +1029,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 |
> @@ -940,7 +1047,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 |
> @@ -953,7 +1059,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,
> @@ -1052,9 +1158,11 @@ struct dvb_frontend *si2165_attach(const struct si2165_config *config,
> strlcat(state->frontend.ops.info.name, " DVB-T",
> sizeof(state->frontend.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->frontend.ops.delsys[n++] = SYS_DVBC_ANNEX_A;
> + strlcat(state->frontend.ops.info.name, " DVB-C",
> + sizeof(state->frontend.ops.info.name));
> + }
>
> return &state->frontend;
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 4/4] si2165: Add DVB-C support for HVR-4400/HVR-5500
2015-11-19 13:28 ` Mauro Carvalho Chehab
@ 2015-11-22 17:46 ` Matthias Schwarzott
0 siblings, 0 replies; 7+ messages in thread
From: Matthias Schwarzott @ 2015-11-22 17:46 UTC (permalink / raw)
To: Mauro Carvalho Chehab; +Cc: linux-media, crope, xpert-reactos
Am 19.11.2015 um 14:28 schrieb Mauro Carvalho Chehab:
> Em Fri, 13 Nov 2015 23:54:58 +0100
> Matthias Schwarzott <zzam@gentoo.org> escreveu:
>
>> It works only for HVR-4400/HVR-5500.
>> For WinTV-HVR-930C-HD it fails with bad/no reception
>> for unknown reasons.
>
> Patch 3/4 of this series is broken. As this one depends on it, please
> resend both patches 3 and 4 on your next patch series.
>
> Regards,
> Mauro
>
> PS.: patches 1 and 2 are ok and got applied upstream already.
>
>
Hi Mauro,
if you did not notice, I split the patches down into more parts,
improved them a bit and sent them with subject "si2165: Add simple DVB-C
support".
Regards
Matthias
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-11-22 17:47 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-13 22:54 [PATCH 1/4] cx231xx_dvb: use demod_i2c for demod attach Matthias Schwarzott
2015-11-13 22:54 ` [PATCH 2/4] si2165: fix checkpatch issues Matthias Schwarzott
2015-11-13 22:54 ` [PATCH 3/4] si2165: cleanup logic Matthias Schwarzott
2015-11-14 1:05 ` kbuild test robot
2015-11-13 22:54 ` [PATCH 4/4] si2165: Add DVB-C support for HVR-4400/HVR-5500 Matthias Schwarzott
2015-11-19 13:28 ` Mauro Carvalho Chehab
2015-11-22 17:46 ` Matthias Schwarzott
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.