* [PATCH 0/7] Add support for Si2161 demod and improve firmware handling
@ 2014-08-31 11:35 Matthias Schwarzott
2014-08-31 11:35 ` [PATCH 1/7] si2165: Load driver for all hardware revisions Matthias Schwarzott
` (6 more replies)
0 siblings, 7 replies; 10+ messages in thread
From: Matthias Schwarzott @ 2014-08-31 11:35 UTC (permalink / raw)
To: linux-media, m.chehab, crope, zzam
This series adds support for Si2161 based devices.
cx231xx based WinTV-HVR-900-H works with it.
cx231xx based WinTV-HVR-901-H should also work.
Additionally it simplifies firmware structure by no longer adding a seperate header
as suggested by Antti.
Regards
Matthias
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/7] si2165: Load driver for all hardware revisions
2014-08-31 11:35 [PATCH 0/7] Add support for Si2161 demod and improve firmware handling Matthias Schwarzott
@ 2014-08-31 11:35 ` Matthias Schwarzott
2014-08-31 11:35 ` [PATCH 2/7] si2165: enable Si2161 support Matthias Schwarzott
` (5 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Matthias Schwarzott @ 2014-08-31 11:35 UTC (permalink / raw)
To: linux-media, m.chehab, crope, zzam
Current firmware is only for revision D.
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
drivers/media/dvb-frontends/si2165.c | 26 +++++++++++++++++---------
drivers/media/dvb-frontends/si2165_priv.h | 2 +-
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index 3a2d6c5..65e0dc9 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -44,9 +44,7 @@ struct si2165_state {
struct si2165_config config;
- /* chip revision */
- u8 revcode;
- /* chip type */
+ u8 chip_revcode;
u8 chip_type;
/* calculated by xtal and div settings */
@@ -407,7 +405,7 @@ static int si2165_upload_firmware(struct si2165_state *state)
int ret;
const struct firmware *fw = NULL;
- u8 *fw_file = SI2165_FIRMWARE;
+ u8 *fw_file;
const u8 *data;
u32 len;
u32 offset;
@@ -415,10 +413,20 @@ static int si2165_upload_firmware(struct si2165_state *state)
u8 block_count;
u16 crc_expected;
+ switch (state->chip_revcode) {
+ case 0x03: /* revision D */
+ fw_file = SI2165_FIRMWARE_REV_D;
+ break;
+ default:
+ dev_info(&state->i2c->dev, "%s: no firmware file for revision=%d\n",
+ KBUILD_MODNAME, state->chip_revcode);
+ return 0;
+ }
+
/* request the firmware, this will block and timeout */
ret = request_firmware(&fw, fw_file, state->i2c->dev.parent);
if (ret) {
- dev_warn(&state->i2c->dev, "%s: firmare file '%s' not found\n",
+ dev_warn(&state->i2c->dev, "%s: firmware file '%s' not found\n",
KBUILD_MODNAME, fw_file);
goto error;
}
@@ -984,7 +992,7 @@ struct dvb_frontend *si2165_attach(const struct si2165_config *config,
if (val != state->config.chip_mode)
goto error;
- io_ret = si2165_readreg8(state, 0x0023 , &state->revcode);
+ io_ret = si2165_readreg8(state, 0x0023, &state->chip_revcode);
if (io_ret < 0)
goto error;
@@ -998,13 +1006,13 @@ struct dvb_frontend *si2165_attach(const struct si2165_config *config,
goto error;
dev_info(&state->i2c->dev, "%s: hardware revision 0x%02x, chip type 0x%02x\n",
- KBUILD_MODNAME, state->revcode, state->chip_type);
+ KBUILD_MODNAME, state->chip_revcode, state->chip_type);
/* It is a guess that register 0x0118 (chip type?) can be used to
* differ between si2161, si2163 and si2165
* Only si2165 has been tested.
*/
- if (state->revcode == 0x03 && state->chip_type == 0x07) {
+ if (state->chip_type == 0x07) {
state->has_dvbt = true;
state->has_dvbc = true;
} else {
@@ -1037,4 +1045,4 @@ MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
MODULE_DESCRIPTION("Silicon Labs Si2165 DVB-C/-T Demodulator driver");
MODULE_AUTHOR("Matthias Schwarzott <zzam@gentoo.org>");
MODULE_LICENSE("GPL");
-MODULE_FIRMWARE(SI2165_FIRMWARE);
+MODULE_FIRMWARE(SI2165_FIRMWARE_REV_D);
diff --git a/drivers/media/dvb-frontends/si2165_priv.h b/drivers/media/dvb-frontends/si2165_priv.h
index d4cc93f..2b70cf1 100644
--- a/drivers/media/dvb-frontends/si2165_priv.h
+++ b/drivers/media/dvb-frontends/si2165_priv.h
@@ -18,6 +18,6 @@
#ifndef _DVB_SI2165_PRIV
#define _DVB_SI2165_PRIV
-#define SI2165_FIRMWARE "dvb-demod-si2165.fw"
+#define SI2165_FIRMWARE_REV_D "dvb-demod-si2165.fw"
#endif /* _DVB_SI2165_PRIV */
--
2.1.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/7] si2165: enable Si2161 support
2014-08-31 11:35 [PATCH 0/7] Add support for Si2161 demod and improve firmware handling Matthias Schwarzott
2014-08-31 11:35 ` [PATCH 1/7] si2165: Load driver for all hardware revisions Matthias Schwarzott
@ 2014-08-31 11:35 ` Matthias Schwarzott
2014-08-31 11:35 ` [PATCH 3/7] [media] cx231xx: Add support for Hauppauge WinTV-HVR-900H (111xxx) Matthias Schwarzott
` (4 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Matthias Schwarzott @ 2014-08-31 11:35 UTC (permalink / raw)
To: linux-media, m.chehab, crope, zzam
Additionally print chip name with revision symbolically.
This is a preparation for supporting new Hauppauge WinTV-HVR-900-H based
on cx231xx.
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
drivers/media/dvb-frontends/si2165.c | 39 +++++++++++++++++++++++++-----------
1 file changed, 27 insertions(+), 12 deletions(-)
diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index 65e0dc9..fe4e8f2 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -1,5 +1,5 @@
/*
- Driver for Silicon Labs SI2165 DVB-C/-T Demodulator
+ Driver for Silicon Labs Si2161 DVB-T and Si2165 DVB-C/-T Demodulator
Copyright (C) 2013-2014 Matthias Schwarzott <zzam@gentoo.org>
@@ -916,7 +916,7 @@ static void si2165_release(struct dvb_frontend *fe)
static struct dvb_frontend_ops si2165_ops = {
.info = {
- .name = "Silicon Labs Si2165",
+ .name = "Silicon Labs ",
.caps = FE_CAN_FEC_1_2 |
FE_CAN_FEC_2_3 |
FE_CAN_FEC_3_4 |
@@ -956,6 +956,8 @@ struct dvb_frontend *si2165_attach(const struct si2165_config *config,
int n;
int io_ret;
u8 val;
+ char rev_char;
+ const char *chip_name;
if (config == NULL || i2c == NULL)
goto error;
@@ -1005,22 +1007,35 @@ struct dvb_frontend *si2165_attach(const struct si2165_config *config,
if (io_ret < 0)
goto error;
- dev_info(&state->i2c->dev, "%s: hardware revision 0x%02x, chip type 0x%02x\n",
- KBUILD_MODNAME, state->chip_revcode, state->chip_type);
+ if (state->chip_revcode < 26)
+ rev_char = 'A' + state->chip_revcode;
+ else
+ rev_char = '?';
- /* It is a guess that register 0x0118 (chip type?) can be used to
- * differ between si2161, si2163 and si2165
- * Only si2165 has been tested.
- */
- if (state->chip_type == 0x07) {
+ switch (state->chip_type) {
+ case 0x06:
+ chip_name = "Si2161";
+ state->has_dvbt = true;
+ break;
+ case 0x07:
+ chip_name = "Si2165";
state->has_dvbt = true;
state->has_dvbc = true;
- } else {
- dev_err(&state->i2c->dev, "%s: Unsupported chip.\n",
- KBUILD_MODNAME);
+ break;
+ default:
+ dev_err(&state->i2c->dev, "%s: Unsupported Silicon Labs chip (type %d, rev %d)\n",
+ KBUILD_MODNAME, state->chip_type, state->chip_revcode);
goto error;
}
+ dev_info(&state->i2c->dev,
+ "%s: Detected Silicon Labs %s-%c (type %d, rev %d)\n",
+ 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));
+
n = 0;
if (state->has_dvbt) {
state->frontend.ops.delsys[n++] = SYS_DVBT;
--
2.1.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/7] [media] cx231xx: Add support for Hauppauge WinTV-HVR-900H (111xxx)
2014-08-31 11:35 [PATCH 0/7] Add support for Si2161 demod and improve firmware handling Matthias Schwarzott
2014-08-31 11:35 ` [PATCH 1/7] si2165: Load driver for all hardware revisions Matthias Schwarzott
2014-08-31 11:35 ` [PATCH 2/7] si2165: enable Si2161 support Matthias Schwarzott
@ 2014-08-31 11:35 ` Matthias Schwarzott
2014-08-31 11:35 ` [PATCH 4/7] [media] cx231xx: Add support for Hauppauge WinTV-HVR-901H (1114xx) Matthias Schwarzott
` (3 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Matthias Schwarzott @ 2014-08-31 11:35 UTC (permalink / raw)
To: linux-media, m.chehab, crope, zzam
Add support for:
[2040:b138] Hauppauge WinTV HVR-900H (111xxx)
The hardware is similar to [2040:b130] Hauppauge WinTV 930C-HD (model 1113xx)
The only difference is the demod Si2161 instead of Si2165 (but both are
supported by the si2165 driver).
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
drivers/media/usb/cx231xx/cx231xx-cards.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 8039b76..a03a31a 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -705,7 +705,7 @@ struct cx231xx_board cx231xx_boards[] = {
},
},
[CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx] = {
- .name = "Hauppauge WinTV 930C-HD (1113xx) / PCTV QuatroStick 521e",
+ .name = "Hauppauge WinTV 930C-HD (1113xx) / HVR-900H (111xxx) / PCTV QuatroStick 521e",
.tuner_type = TUNER_NXP_TDA18271,
.tuner_addr = 0x60,
.tuner_gpio = RDE250_XCV_TUNER,
@@ -815,6 +815,9 @@ struct usb_device_id cx231xx_id_table[] = {
.driver_info = CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx},
{USB_DEVICE(0x2040, 0xb131),
.driver_info = CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx},
+ /* Hauppauge WinTV-HVR-900-H */
+ {USB_DEVICE(0x2040, 0xb138),
+ .driver_info = CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx},
{USB_DEVICE(0x2040, 0xb140),
.driver_info = CX231XX_BOARD_HAUPPAUGE_EXETER},
{USB_DEVICE(0x2040, 0xc200),
--
2.1.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/7] [media] cx231xx: Add support for Hauppauge WinTV-HVR-901H (1114xx)
2014-08-31 11:35 [PATCH 0/7] Add support for Si2161 demod and improve firmware handling Matthias Schwarzott
` (2 preceding siblings ...)
2014-08-31 11:35 ` [PATCH 3/7] [media] cx231xx: Add support for Hauppauge WinTV-HVR-900H (111xxx) Matthias Schwarzott
@ 2014-08-31 11:35 ` Matthias Schwarzott
2014-08-31 11:35 ` [PATCH 5/7] [media] mceusb: add support for more cx231xx devices Matthias Schwarzott
` (2 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Matthias Schwarzott @ 2014-08-31 11:35 UTC (permalink / raw)
To: linux-media, m.chehab, crope, zzam
Add support for:
[2040:b139] Hauppauge WinTV HVR-901H (1114xx)
According to the inf file, the hardware is similar to [2040:b131] Hauppauge WinTV 930C-HD (model 1114xx)
The only difference is the demod Si2161 instead of Si2165 (but both are
supported by the si2165 driver).
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
drivers/media/usb/cx231xx/cx231xx-cards.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index a03a31a..791f00c 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -744,7 +744,7 @@ struct cx231xx_board cx231xx_boards[] = {
} },
},
[CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx] = {
- .name = "Hauppauge WinTV 930C-HD (1114xx) / PCTV QuatroStick 522e",
+ .name = "Hauppauge WinTV 930C-HD (1114xx) / HVR-901H (1114xx) / PCTV QuatroStick 522e",
.tuner_type = TUNER_ABSENT,
.tuner_addr = 0x60,
.tuner_gpio = RDE250_XCV_TUNER,
@@ -818,6 +818,9 @@ struct usb_device_id cx231xx_id_table[] = {
/* Hauppauge WinTV-HVR-900-H */
{USB_DEVICE(0x2040, 0xb138),
.driver_info = CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx},
+ /* Hauppauge WinTV-HVR-901-H */
+ {USB_DEVICE(0x2040, 0xb139),
+ .driver_info = CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx},
{USB_DEVICE(0x2040, 0xb140),
.driver_info = CX231XX_BOARD_HAUPPAUGE_EXETER},
{USB_DEVICE(0x2040, 0xc200),
--
2.1.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/7] [media] mceusb: add support for more cx231xx devices
2014-08-31 11:35 [PATCH 0/7] Add support for Si2161 demod and improve firmware handling Matthias Schwarzott
` (3 preceding siblings ...)
2014-08-31 11:35 ` [PATCH 4/7] [media] cx231xx: Add support for Hauppauge WinTV-HVR-901H (1114xx) Matthias Schwarzott
@ 2014-08-31 11:35 ` Matthias Schwarzott
2014-08-31 11:35 ` [PATCH 6/7] get_dvb_firmware: si2165: drop the extra header from the firmware Matthias Schwarzott
2014-08-31 11:35 ` [PATCH 7/7] si2165: do load firmware without extra header Matthias Schwarzott
6 siblings, 0 replies; 10+ messages in thread
From: Matthias Schwarzott @ 2014-08-31 11:35 UTC (permalink / raw)
To: linux-media, m.chehab, crope, zzam
From: Mauro Carvalho Chehab <m.chehab@samsung.com>
Add support for the si2161-based cx231xx devices:
[2040:b138] Hauppauge WinTV HVR-900-H (model 111xxx)
[2040:b139] Hauppauge WinTV HVR-901-H (model 1114xx)
They're similar to the already supported:
[2040:b130] Hauppauge WinTV 930C-HD (model 1113xx)
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
drivers/media/rc/mceusb.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index 45b0894..383e24a 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -397,6 +397,10 @@ static struct usb_device_id mceusb_dev_table[] = {
.driver_info = HAUPPAUGE_CX_HYBRID_TV },
{ USB_DEVICE(VENDOR_HAUPPAUGE, 0xb131),
.driver_info = HAUPPAUGE_CX_HYBRID_TV },
+ { USB_DEVICE(VENDOR_HAUPPAUGE, 0xb138),
+ .driver_info = HAUPPAUGE_CX_HYBRID_TV },
+ { USB_DEVICE(VENDOR_HAUPPAUGE, 0xb139),
+ .driver_info = HAUPPAUGE_CX_HYBRID_TV },
{ USB_DEVICE(VENDOR_PCTV, 0x0259),
.driver_info = HAUPPAUGE_CX_HYBRID_TV },
{ USB_DEVICE(VENDOR_PCTV, 0x025e),
--
2.1.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 6/7] get_dvb_firmware: si2165: drop the extra header from the firmware
2014-08-31 11:35 [PATCH 0/7] Add support for Si2161 demod and improve firmware handling Matthias Schwarzott
` (4 preceding siblings ...)
2014-08-31 11:35 ` [PATCH 5/7] [media] mceusb: add support for more cx231xx devices Matthias Schwarzott
@ 2014-08-31 11:35 ` Matthias Schwarzott
2014-08-31 11:35 ` [PATCH 7/7] si2165: do load firmware without extra header Matthias Schwarzott
6 siblings, 0 replies; 10+ messages in thread
From: Matthias Schwarzott @ 2014-08-31 11:35 UTC (permalink / raw)
To: linux-media, m.chehab, crope, zzam
Store it with a different name based on hardware revision.
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
Documentation/dvb/get_dvb_firmware | 20 ++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)
diff --git a/Documentation/dvb/get_dvb_firmware b/Documentation/dvb/get_dvb_firmware
index 26c623d..a0971fa 100755
--- a/Documentation/dvb/get_dvb_firmware
+++ b/Documentation/dvb/get_dvb_firmware
@@ -787,7 +787,8 @@ sub si2165 {
my $sourcefile = "model_111xxx_122xxx_driver_6_0_119_31191_WHQL.zip";
my $url = "http://www.hauppauge.de/files/drivers/";
my $hash = "76633e7c76b0edee47c3ba18ded99336";
- my $fwfile = "dvb-demod-si2165.fw";
+ my $fwfile = "dvb-demod-si2165-D.fw";
+ my $fwhash = "1255c70a53fe562a89d5ff08d7461e2c";
my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
checkstandard();
@@ -795,21 +796,8 @@ sub si2165 {
wgetfile($sourcefile, $url . $sourcefile);
verify($sourcefile, $hash);
unzip($sourcefile, $tmpdir);
- extract("$tmpdir/Driver10/Hcw10bda.sys", 0x80788, 0x81E08-0x80788, "$tmpdir/fw1");
-
- delzero("$tmpdir/fw1","$tmpdir/fw1-1");
- #verify("$tmpdir/fw1","5e0909858fdf0b5b09ad48b9fe622e70");
-
- my $CRC="\x0A\xCC";
- my $BLOCKS_MAIN="\x27";
- open FW,">$fwfile";
- print FW "\x01\x00"; # just a version id for the driver itself
- print FW "\x9A"; # fw version
- print FW "\x00"; # padding
- print FW "$BLOCKS_MAIN"; # number of blocks of main part
- print FW "\x00"; # padding
- print FW "$CRC"; # 16bit crc value of main part
- appendfile(FW,"$tmpdir/fw1");
+ extract("$tmpdir/Driver10/Hcw10bda.sys", 0x80788, 0x81E08-0x80788, "$fwfile");
+ verify($fwfile, $fwhash);
"$fwfile";
}
--
2.1.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 7/7] si2165: do load firmware without extra header
2014-08-31 11:35 [PATCH 0/7] Add support for Si2161 demod and improve firmware handling Matthias Schwarzott
` (5 preceding siblings ...)
2014-08-31 11:35 ` [PATCH 6/7] get_dvb_firmware: si2165: drop the extra header from the firmware Matthias Schwarzott
@ 2014-08-31 11:35 ` Matthias Schwarzott
2014-09-22 22:58 ` Mauro Carvalho Chehab
6 siblings, 1 reply; 10+ messages in thread
From: Matthias Schwarzott @ 2014-08-31 11:35 UTC (permalink / raw)
To: linux-media, m.chehab, crope, zzam
The new file has a different name: dvb-demod-si2165-D.fw
Count blocks instead of reading count from extra header.
Calculate CRC during upload and compare result to what chip calcuated.
Use 0x01 instead of real patch version, because this is only used to
check if something was uploaded but not to check the version of it.
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
drivers/media/dvb-frontends/Kconfig | 1 +
drivers/media/dvb-frontends/si2165.c | 105 ++++++++++++++++++------------
drivers/media/dvb-frontends/si2165_priv.h | 2 +-
3 files changed, 66 insertions(+), 42 deletions(-)
diff --git a/drivers/media/dvb-frontends/Kconfig b/drivers/media/dvb-frontends/Kconfig
index aa5ae22..c57ec49 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -66,6 +66,7 @@ config DVB_TDA18271C2DD
config DVB_SI2165
tristate "Silicon Labs si2165 based"
depends on DVB_CORE && I2C
+ select CRC_ITU_T
default m if !MEDIA_SUBDRV_AUTOSELECT
help
A DVB-C/T demodulator.
diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index fe4e8f2..c807180 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -25,6 +25,7 @@
#include <linux/string.h>
#include <linux/slab.h>
#include <linux/firmware.h>
+#include <linux/crc-itu-t.h>
#include "dvb_frontend.h"
#include "dvb_math.h"
@@ -327,8 +328,50 @@ static bool si2165_wait_init_done(struct si2165_state *state)
return ret;
}
+static int si2165_count_fw_blocks(struct si2165_state *state, const u8 *data,
+ u32 len)
+{
+ int block_count = 0;
+ u32 offset = 0;
+
+ if (len % 4 != 0) {
+ dev_warn(&state->i2c->dev, "%s: firmware size is not multiple of 4\n",
+ KBUILD_MODNAME);
+ return -EINVAL;
+ }
+
+ while (offset + 4 <= len) {
+ u8 wordcount = data[offset];
+
+ if (wordcount < 1 || data[offset+1] ||
+ data[offset+2] || data[offset+3]) {
+ dev_warn(&state->i2c->dev,
+ "%s: bad fw data[0..3] = %*ph at offset=%d\n",
+ KBUILD_MODNAME, 4, data, offset);
+ return -EINVAL;
+ }
+ offset += 8 + 4 * wordcount;
+ ++block_count;
+ }
+ if (offset != len) {
+ dev_warn(&state->i2c->dev,
+ "%s: firmware length does not match content, len=%d, offset=%d\n",
+ KBUILD_MODNAME, len, offset);
+ return -EINVAL;
+ }
+ if (block_count < 6) {
+ dev_err(&state->i2c->dev, "%s: firmware is too short: Only %d blocks\n",
+ KBUILD_MODNAME, block_count);
+ return -EINVAL;
+ }
+ block_count -= 6;
+ dev_info(&state->i2c->dev, "%s: si2165_upload_firmware counted %d main blocks\n",
+ KBUILD_MODNAME, block_count);
+ return block_count;
+}
+
static int si2165_upload_firmware_block(struct si2165_state *state,
- const u8 *data, u32 len, u32 *poffset, u32 block_count)
+ const u8 *data, u32 len, u32 *poffset, u32 block_count, u16 *crc)
{
int ret;
u8 buf_ctrl[4] = { 0x00, 0x00, 0x00, 0xc0 };
@@ -374,6 +417,10 @@ static int si2165_upload_firmware_block(struct si2165_state *state,
offset += 8;
while (wordcount > 0) {
+ *crc = crc_itu_t_byte(*crc, *(data+offset+3));
+ *crc = crc_itu_t_byte(*crc, *(data+offset+2));
+ *crc = crc_itu_t_byte(*crc, *(data+offset+1));
+ *crc = crc_itu_t_byte(*crc, *(data+offset+0));
ret = si2165_write(state, 0x36c, data+offset, 4);
if (ret < 0)
goto error;
@@ -408,10 +455,9 @@ static int si2165_upload_firmware(struct si2165_state *state)
u8 *fw_file;
const u8 *data;
u32 len;
- u32 offset;
- u8 patch_version;
- u8 block_count;
- u16 crc_expected;
+ u32 offset = 0;
+ int main_block_count;
+ u16 crc = 0;
switch (state->chip_revcode) {
case 0x03: /* revision D */
@@ -437,32 +483,13 @@ static int si2165_upload_firmware(struct si2165_state *state)
dev_info(&state->i2c->dev, "%s: downloading firmware from file '%s' size=%d\n",
KBUILD_MODNAME, fw_file, len);
- if (len % 4 != 0) {
- dev_warn(&state->i2c->dev, "%s: firmware size is not multiple of 4\n",
- KBUILD_MODNAME);
- ret = -EINVAL;
- goto error;
- }
-
- /* check header (8 bytes) */
- if (len < 8) {
- dev_warn(&state->i2c->dev, "%s: firmware header is missing\n",
- KBUILD_MODNAME);
- ret = -EINVAL;
- goto error;
- }
-
- if (data[0] != 1 || data[1] != 0) {
- dev_warn(&state->i2c->dev, "%s: firmware file version is wrong\n",
- KBUILD_MODNAME);
- ret = -EINVAL;
- goto error;
+ main_block_count = si2165_count_fw_blocks(state, data, len);
+ if (main_block_count < 0) {
+ dev_err(&state->i2c->dev, "%s: si2165_upload_firmware: cannot use firmware, skip\n",
+ KBUILD_MODNAME);
+ return main_block_count;
}
- patch_version = data[2];
- block_count = data[4];
- crc_expected = data[7] << 8 | data[6];
-
/* start uploading fw */
/* boot/wdog status */
ret = si2165_writereg8(state, 0x0341, 0x00);
@@ -488,17 +515,12 @@ static int si2165_upload_firmware(struct si2165_state *state)
if (ret < 0)
goto error;
- /* start right after the header */
- offset = 8;
-
- dev_info(&state->i2c->dev, "%s: si2165_upload_firmware extracted patch_version=0x%02x, block_count=0x%02x, crc_expected=0x%04x\n",
- KBUILD_MODNAME, patch_version, block_count, crc_expected);
-
- ret = si2165_upload_firmware_block(state, data, len, &offset, 1);
+ ret = si2165_upload_firmware_block(state, data, len, &offset, 1, &crc);
if (ret < 0)
goto error;
- ret = si2165_writereg8(state, 0x0344, patch_version);
+ /* patch version, just write a number different from the default 0x00 */
+ ret = si2165_writereg8(state, 0x0344, 0x01);
if (ret < 0)
goto error;
@@ -506,9 +528,10 @@ static int si2165_upload_firmware(struct si2165_state *state)
ret = si2165_writereg8(state, 0x0379, 0x01);
if (ret)
return ret;
+ crc = 0;
ret = si2165_upload_firmware_block(state, data, len,
- &offset, block_count);
+ &offset, main_block_count, &crc);
if (ret < 0) {
dev_err(&state->i2c->dev,
"%s: firmare could not be uploaded\n",
@@ -521,15 +544,15 @@ static int si2165_upload_firmware(struct si2165_state *state)
if (ret)
goto error;
- if (val16 != crc_expected) {
+ if (val16 != crc) {
dev_err(&state->i2c->dev,
"%s: firmware crc mismatch %04x != %04x\n",
- KBUILD_MODNAME, val16, crc_expected);
+ KBUILD_MODNAME, val16, crc);
ret = -EINVAL;
goto error;
}
- ret = si2165_upload_firmware_block(state, data, len, &offset, 5);
+ ret = si2165_upload_firmware_block(state, data, len, &offset, 5, &crc);
if (ret)
goto error;
diff --git a/drivers/media/dvb-frontends/si2165_priv.h b/drivers/media/dvb-frontends/si2165_priv.h
index 2b70cf1..fd778dc 100644
--- a/drivers/media/dvb-frontends/si2165_priv.h
+++ b/drivers/media/dvb-frontends/si2165_priv.h
@@ -18,6 +18,6 @@
#ifndef _DVB_SI2165_PRIV
#define _DVB_SI2165_PRIV
-#define SI2165_FIRMWARE_REV_D "dvb-demod-si2165.fw"
+#define SI2165_FIRMWARE_REV_D "dvb-demod-si2165-D.fw"
#endif /* _DVB_SI2165_PRIV */
--
2.1.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 7/7] si2165: do load firmware without extra header
2014-08-31 11:35 ` [PATCH 7/7] si2165: do load firmware without extra header Matthias Schwarzott
@ 2014-09-22 22:58 ` Mauro Carvalho Chehab
2014-09-23 4:54 ` Matthias Schwarzott
0 siblings, 1 reply; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-22 22:58 UTC (permalink / raw)
To: Matthias Schwarzott; +Cc: linux-media, crope
Em Sun, 31 Aug 2014 13:35:12 +0200
Matthias Schwarzott <zzam@gentoo.org> escreveu:
> The new file has a different name: dvb-demod-si2165-D.fw
>
> Count blocks instead of reading count from extra header.
> Calculate CRC during upload and compare result to what chip calcuated.
> Use 0x01 instead of real patch version, because this is only used to
> check if something was uploaded but not to check the version of it.
>
> Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
> ---
...
> diff --git a/drivers/media/dvb-frontends/si2165_priv.h b/drivers/media/dvb-frontends/si2165_priv.h
> index 2b70cf1..fd778dc 100644
> --- a/drivers/media/dvb-frontends/si2165_priv.h
> +++ b/drivers/media/dvb-frontends/si2165_priv.h
> @@ -18,6 +18,6 @@
> #ifndef _DVB_SI2165_PRIV
> #define _DVB_SI2165_PRIV
>
> -#define SI2165_FIRMWARE_REV_D "dvb-demod-si2165.fw"
> +#define SI2165_FIRMWARE_REV_D "dvb-demod-si2165-D.fw"
Please, don't do that. Changing the name of the firmware and breaking
the format is a bad idea, specially since you're not supporting anymore
the legacy one.
I would be ok if you were not breaking support for the old firmware
file.
Also, better to use lowercase for the firmware name.
PS.: I'm not applying patch 6/7 as this got rejected.
Regards,
Mauro
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 7/7] si2165: do load firmware without extra header
2014-09-22 22:58 ` Mauro Carvalho Chehab
@ 2014-09-23 4:54 ` Matthias Schwarzott
0 siblings, 0 replies; 10+ messages in thread
From: Matthias Schwarzott @ 2014-09-23 4:54 UTC (permalink / raw)
To: Mauro Carvalho Chehab; +Cc: linux-media, crope
On 23.09.2014 00:58, Mauro Carvalho Chehab wrote:
> Em Sun, 31 Aug 2014 13:35:12 +0200
> Matthias Schwarzott <zzam@gentoo.org> escreveu:
>
>> The new file has a different name: dvb-demod-si2165-D.fw
>>
>> Count blocks instead of reading count from extra header.
>> Calculate CRC during upload and compare result to what chip calcuated.
>> Use 0x01 instead of real patch version, because this is only used to
>> check if something was uploaded but not to check the version of it.
>>
>> Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
>> ---
>
> ...
>
>> diff --git a/drivers/media/dvb-frontends/si2165_priv.h b/drivers/media/dvb-frontends/si2165_priv.h
>> index 2b70cf1..fd778dc 100644
>> --- a/drivers/media/dvb-frontends/si2165_priv.h
>> +++ b/drivers/media/dvb-frontends/si2165_priv.h
>> @@ -18,6 +18,6 @@
>> #ifndef _DVB_SI2165_PRIV
>> #define _DVB_SI2165_PRIV
>>
>> -#define SI2165_FIRMWARE_REV_D "dvb-demod-si2165.fw"
>> +#define SI2165_FIRMWARE_REV_D "dvb-demod-si2165-D.fw"
>
> Please, don't do that. Changing the name of the firmware and breaking
> the format is a bad idea, specially since you're not supporting anymore
> the legacy one.
>
> I would be ok if you were not breaking support for the old firmware
> file.
>
Hmm, there is no kernel yet that contains this driver.
And the firmware is identical, just the header is missing.
Do I really have to support both then?
> Also, better to use lowercase for the firmware name.
Ok, I will change the "D" to lower-case.
>
> PS.: I'm not applying patch 6/7 as this got rejected.
Ok, I will resend patch 6 and eventually 7.
Regards
Matthias
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-09-23 4:54 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-31 11:35 [PATCH 0/7] Add support for Si2161 demod and improve firmware handling Matthias Schwarzott
2014-08-31 11:35 ` [PATCH 1/7] si2165: Load driver for all hardware revisions Matthias Schwarzott
2014-08-31 11:35 ` [PATCH 2/7] si2165: enable Si2161 support Matthias Schwarzott
2014-08-31 11:35 ` [PATCH 3/7] [media] cx231xx: Add support for Hauppauge WinTV-HVR-900H (111xxx) Matthias Schwarzott
2014-08-31 11:35 ` [PATCH 4/7] [media] cx231xx: Add support for Hauppauge WinTV-HVR-901H (1114xx) Matthias Schwarzott
2014-08-31 11:35 ` [PATCH 5/7] [media] mceusb: add support for more cx231xx devices Matthias Schwarzott
2014-08-31 11:35 ` [PATCH 6/7] get_dvb_firmware: si2165: drop the extra header from the firmware Matthias Schwarzott
2014-08-31 11:35 ` [PATCH 7/7] si2165: do load firmware without extra header Matthias Schwarzott
2014-09-22 22:58 ` Mauro Carvalho Chehab
2014-09-23 4:54 ` Matthias Schwarzott
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).