iwlwifi: Microcode SW error

2021-04-19 Thread Gon Solo
Hi all!

My internet was very slow and I saw the following in dmesg:

[Apr19 10:50] iwlwifi :02:00.0: Queue 10 is active on fifo 1 and stuck for 
1 ms. SW [40, 93] HW [40, 93] FH TRB=0x0c010a037
[  +0,001244] iwlwifi :02:00.0: Microcode SW error detected.  Restarting 
0x200.

The rest of the message is at the end of this message.
The kernel version is "Linux Limone 5.12.0-051200rc7-lowlatency" from 
https://kernel.ubuntu.com/~kernel-ppa/mainline.
The relevant output of lspci is:
02:00.0 Network controller: Intel Corporation Wireless 7260 (rev 73)

I would be glad to provide additional details if somebody is interested
to fix this bug.

Regards,
Andreas

[[Apr19 10:50] iwlwifi :02:00.0: Queue 10 is active on fifo 1 and stuck for 
1 ms. SW [40, 93] HW [40, 93] FH TRB=0x0c010a037
[  +0,001244] iwlwifi :02:00.0: Microcode SW error detected.  Restarting 
0x200.
[  +0,000160] iwlwifi :02:00.0: Start IWL Error Log Dump:
[  +0,04] iwlwifi :02:00.0: Status: 0x0040, count: 6
[  +0,05] iwlwifi :02:00.0: Loaded firmware version: 17.3216344376.0 
7260-17.ucode
[  +0,05] iwlwifi :02:00.0: 0x0084 | NMI_INTERRUPT_UNKNOWN   
[  +0,05] iwlwifi :02:00.0: 0x02B0 | trm_hw_status0
[  +0,03] iwlwifi :02:00.0: 0x | trm_hw_status1
[  +0,04] iwlwifi :02:00.0: 0x0B30 | branchlink2
[  +0,04] iwlwifi :02:00.0: 0x000164C0 | interruptlink1
[  +0,03] iwlwifi :02:00.0: 0x000164C0 | interruptlink2
[  +0,04] iwlwifi :02:00.0: 0x | data1
[  +0,03] iwlwifi :02:00.0: 0x0080 | data2
[  +0,03] iwlwifi :02:00.0: 0x0703 | data3
[  +0,04] iwlwifi :02:00.0: 0x5440EBF3 | beacon time
[  +0,04] iwlwifi :02:00.0: 0xF0BCB49D | tsf low
[  +0,03] iwlwifi :02:00.0: 0x0097 | tsf hi
[  +0,03] iwlwifi :02:00.0: 0x | time gp1
[  +0,04] iwlwifi :02:00.0: 0x0845CB55 | time gp2
[  +0,03] iwlwifi :02:00.0: 0x | uCode revision type
[  +0,04] iwlwifi :02:00.0: 0x0011 | uCode version major
[  +0,03] iwlwifi :02:00.0: 0xBFB58538 | uCode version minor
[  +0,04] iwlwifi :02:00.0: 0x0144 | hw version
[  +0,03] iwlwifi :02:00.0: 0x40489204 | board version
[  +0,03] iwlwifi :02:00.0: 0x001C | hcmd
[  +0,04] iwlwifi :02:00.0: 0x00022002 | isr0
[  +0,03] iwlwifi :02:00.0: 0x | isr1
[  +0,03] iwlwifi :02:00.0: 0x000A | isr2
[  +0,03] iwlwifi :02:00.0: 0x0041D4C0 | isr3
[  +0,04] iwlwifi :02:00.0: 0x | isr4
[  +0,03] iwlwifi :02:00.0: 0x0110 | last cmd Id
[  +0,03] iwlwifi :02:00.0: 0x | wait_event
[  +0,04] iwlwifi :02:00.0: 0x0080 | l2p_control
[  +0,03] iwlwifi :02:00.0: 0x00010020 | l2p_duration
[  +0,04] iwlwifi :02:00.0: 0x003F | l2p_mhvalid
[  +0,03] iwlwifi :02:00.0: 0x0080 | l2p_addr_match
[  +0,03] iwlwifi :02:00.0: 0x0005 | lmpm_pmg_sel
[  +0,03] iwlwifi :02:00.0: 0x15041745 | timestamp
[  +0,04] iwlwifi :02:00.0: 0x00348098 | flow_handler
[  +0,66] iwlwifi :02:00.0: Fseq Registers:
[  +0,57] iwlwifi :02:00.0: 0x | FSEQ_ERROR_CODE
[  +0,57] iwlwifi :02:00.0: 0x | FSEQ_TOP_INIT_VERSION
[  +0,56] iwlwifi :02:00.0: 0x | FSEQ_CNVIO_INIT_VERSION
[  +0,56] iwlwifi :02:00.0: 0x | FSEQ_OTP_VERSION
[  +0,71] iwlwifi :02:00.0: 0x | FSEQ_TOP_CONTENT_VERSION
[  +0,69] iwlwifi :02:00.0: 0x | FSEQ_ALIVE_TOKEN
[  +0,74] iwlwifi :02:00.0: 0x | FSEQ_CNVI_ID
[  +0,74] iwlwifi :02:00.0: 0x | FSEQ_CNVR_ID
[  +0,61] iwlwifi :02:00.0: 0x | CNVI_AUX_MISC_CHIP
[  +0,61] iwlwifi :02:00.0: 0x | CNVR_AUX_MISC_CHIP
[  +0,59] iwlwifi :02:00.0: 0x | 
CNVR_SCU_SD_REGS_SD_REG_DIG_DCDC_VTRIM
[  +0,62] iwlwifi :02:00.0: 0x | 
CNVR_SCU_SD_REGS_SD_REG_ACTIVE_VDIG_MIRROR
[  +0,73] iwlwifi :02:00.0: Collecting data: trigger 2 fired.
[  +0,08] ieee80211 phy0: Hardware restart was requested


[PATCH 2/2] Perf: Clean beauty directory.

2021-03-07 Thread Gon Solo
Clean up generated beauty directory.

Suggested-by: Arnaldo Carvalho de Melo 
Signed-off-by: Andreas Wendleder 
---
 tools/perf/Makefile.perf | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 5345ac70cd83..293e297f719d 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -1087,6 +1087,7 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean 
$(LIBBPF)-clean $(LIBSUBCMD)-clea
$(OUTPUT)$(sync_file_range_arrays)
$(call QUIET_CLEAN, Documentation) \
$(MAKE) -C $(DOC_DIR) O=$(OUTPUT) clean >/dev/null
+   $(call QUIET_CLEAN, beauty) $(RM) -r $(beauty_outdir)
 
 #
 # To provide FEATURE-DUMP into $(FEATURE_DUMP_COPY)
-- 
2.27.0



[PATCH 1/2] Perf: Clean generated directory, other archs.

2021-03-07 Thread Gon Solo
After a make clean there are generated directories left in the arch
directories of perf. Clean them up.

Suggested-by: Arnaldo Carvalho de Melo 
Signed-off-by: Andreas Wendleder 
---
 tools/perf/arch/arm64/Makefile   | 5 +++--
 tools/perf/arch/powerpc/Makefile | 5 +++--
 tools/perf/arch/s390/Makefile| 5 +++--
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/tools/perf/arch/arm64/Makefile b/tools/perf/arch/arm64/Makefile
index fab3095fb5d0..426aecdd0b71 100644
--- a/tools/perf/arch/arm64/Makefile
+++ b/tools/perf/arch/arm64/Makefile
@@ -10,7 +10,8 @@ HAVE_KVM_STAT_SUPPORT := 1
 # Syscall table generation for perf
 #
 
-out:= $(OUTPUT)arch/arm64/include/generated/asm
+generated := $(OUTPUT)arch/arm64/include/generated
+out:= $(generated)/asm
 header := $(out)/syscalls.c
 incpath := $(srctree)/tools
 sysdef := $(srctree)/tools/arch/arm64/include/uapi/asm/unistd.h
@@ -24,6 +25,6 @@ $(header): $(sysdef) $(systbl)
$(Q)$(SHELL) '$(systbl)' '$(CC)' '$(HOSTCC)' $(incpath) $(sysdef) > $@
 
 clean::
-   $(call QUIET_CLEAN, arm64) $(RM) $(header)
+   $(call QUIET_CLEAN, arm64) $(RM) -r $(header) $(generated)
 
 archheaders: $(header)
diff --git a/tools/perf/arch/powerpc/Makefile b/tools/perf/arch/powerpc/Makefile
index 840ea0e59287..979c2bebc167 100644
--- a/tools/perf/arch/powerpc/Makefile
+++ b/tools/perf/arch/powerpc/Makefile
@@ -11,7 +11,8 @@ PERF_HAVE_JITDUMP := 1
 # Syscall table generation for perf
 #
 
-out:= $(OUTPUT)arch/powerpc/include/generated/asm
+generated := $(OUTPUT)arch/powerpc/include/generated
+out:= $(generated)/asm
 header32 := $(out)/syscalls_32.c
 header64 := $(out)/syscalls_64.c
 sysprf := $(srctree)/tools/perf/arch/powerpc/entry/syscalls
@@ -28,6 +29,6 @@ $(header32): $(sysdef) $(systbl)
$(Q)$(SHELL) '$(systbl)' '32' $(sysdef) > $@
 
 clean::
-   $(call QUIET_CLEAN, powerpc) $(RM) $(header32) $(header64)
+   $(call QUIET_CLEAN, powerpc) $(RM) -r $(header32) $(header64) 
$(generated)
 
 archheaders: $(header32) $(header64)
diff --git a/tools/perf/arch/s390/Makefile b/tools/perf/arch/s390/Makefile
index 74bffbea03e2..27cf67f1cc78 100644
--- a/tools/perf/arch/s390/Makefile
+++ b/tools/perf/arch/s390/Makefile
@@ -10,7 +10,8 @@ PERF_HAVE_JITDUMP := 1
 # Syscall table generation for perf
 #
 
-out:= $(OUTPUT)arch/s390/include/generated/asm
+generated := $(OUTPUT)arch/s390/include/generated
+out:= $(generated)/asm
 header := $(out)/syscalls_64.c
 sysprf := $(srctree)/tools/perf/arch/s390/entry/syscalls
 sysdef := $(sysprf)/syscall.tbl
@@ -23,6 +24,6 @@ $(header): $(sysdef) $(systbl)
$(Q)$(SHELL) '$(systbl)' $(sysdef) > $@
 
 clean::
-   $(call QUIET_CLEAN, s390) $(RM) $(header)
+   $(call QUIET_CLEAN, s390) $(RM) -r $(header) $(generted)
 
 archheaders: $(header)
-- 
2.27.0



[PATCH 2/2] Perf: Clean beauty directory.

2021-03-03 Thread Gon Solo
---
 tools/perf/Makefile.perf | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 5345ac70cd83..293e297f719d 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -1087,6 +1087,7 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean 
$(LIBBPF)-clean $(LIBSUBCMD)-clea
$(OUTPUT)$(sync_file_range_arrays)
$(call QUIET_CLEAN, Documentation) \
$(MAKE) -C $(DOC_DIR) O=$(OUTPUT) clean >/dev/null
+   $(call QUIET_CLEAN, beauty) $(RM) -r $(beauty_outdir)
 
 #
 # To provide FEATURE-DUMP into $(FEATURE_DUMP_COPY)
-- 
2.27.0



[PATCH 1/2] Perf: Clean generated directory, other archs.

2021-03-03 Thread Gon Solo
---
 tools/perf/arch/arm64/Makefile   | 5 +++--
 tools/perf/arch/powerpc/Makefile | 5 +++--
 tools/perf/arch/s390/Makefile| 5 +++--
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/tools/perf/arch/arm64/Makefile b/tools/perf/arch/arm64/Makefile
index fab3095fb5d0..426aecdd0b71 100644
--- a/tools/perf/arch/arm64/Makefile
+++ b/tools/perf/arch/arm64/Makefile
@@ -10,7 +10,8 @@ HAVE_KVM_STAT_SUPPORT := 1
 # Syscall table generation for perf
 #
 
-out:= $(OUTPUT)arch/arm64/include/generated/asm
+generated := $(OUTPUT)arch/arm64/include/generated
+out:= $(generated)/asm
 header := $(out)/syscalls.c
 incpath := $(srctree)/tools
 sysdef := $(srctree)/tools/arch/arm64/include/uapi/asm/unistd.h
@@ -24,6 +25,6 @@ $(header): $(sysdef) $(systbl)
$(Q)$(SHELL) '$(systbl)' '$(CC)' '$(HOSTCC)' $(incpath) $(sysdef) > $@
 
 clean::
-   $(call QUIET_CLEAN, arm64) $(RM) $(header)
+   $(call QUIET_CLEAN, arm64) $(RM) -r $(header) $(generated)
 
 archheaders: $(header)
diff --git a/tools/perf/arch/powerpc/Makefile b/tools/perf/arch/powerpc/Makefile
index 840ea0e59287..979c2bebc167 100644
--- a/tools/perf/arch/powerpc/Makefile
+++ b/tools/perf/arch/powerpc/Makefile
@@ -11,7 +11,8 @@ PERF_HAVE_JITDUMP := 1
 # Syscall table generation for perf
 #
 
-out:= $(OUTPUT)arch/powerpc/include/generated/asm
+generated := $(OUTPUT)arch/powerpc/include/generated
+out:= $(generated)/asm
 header32 := $(out)/syscalls_32.c
 header64 := $(out)/syscalls_64.c
 sysprf := $(srctree)/tools/perf/arch/powerpc/entry/syscalls
@@ -28,6 +29,6 @@ $(header32): $(sysdef) $(systbl)
$(Q)$(SHELL) '$(systbl)' '32' $(sysdef) > $@
 
 clean::
-   $(call QUIET_CLEAN, powerpc) $(RM) $(header32) $(header64)
+   $(call QUIET_CLEAN, powerpc) $(RM) -r $(header32) $(header64) 
$(generated)
 
 archheaders: $(header32) $(header64)
diff --git a/tools/perf/arch/s390/Makefile b/tools/perf/arch/s390/Makefile
index 74bffbea03e2..27cf67f1cc78 100644
--- a/tools/perf/arch/s390/Makefile
+++ b/tools/perf/arch/s390/Makefile
@@ -10,7 +10,8 @@ PERF_HAVE_JITDUMP := 1
 # Syscall table generation for perf
 #
 
-out:= $(OUTPUT)arch/s390/include/generated/asm
+generated := $(OUTPUT)arch/s390/include/generated
+out:= $(generated)/asm
 header := $(out)/syscalls_64.c
 sysprf := $(srctree)/tools/perf/arch/s390/entry/syscalls
 sysdef := $(sysprf)/syscall.tbl
@@ -23,6 +24,6 @@ $(header): $(sysdef) $(systbl)
$(Q)$(SHELL) '$(systbl)' $(sysdef) > $@
 
 clean::
-   $(call QUIET_CLEAN, s390) $(RM) $(header)
+   $(call QUIET_CLEAN, s390) $(RM) -r $(header) $(generted)
 
 archheaders: $(header)
-- 
2.27.0



[PATCH] Perf: Clean generated directory.

2021-03-01 Thread Gon Solo
From: Andreas Wendleder 

Remove generated directory tools/perf/arch/x86/include/generated.

Signed-off-by: Andreas Wendleder 
---
 tools/perf/arch/x86/Makefile | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/perf/arch/x86/Makefile b/tools/perf/arch/x86/Makefile
index 8cc6642fce7a..5a9f9a7bf07d 100644
--- a/tools/perf/arch/x86/Makefile
+++ b/tools/perf/arch/x86/Makefile
@@ -10,10 +10,11 @@ PERF_HAVE_JITDUMP := 1
 # Syscall table generation
 #
 
-out:= $(OUTPUT)arch/x86/include/generated/asm
-header := $(out)/syscalls_64.c
-sys:= $(srctree)/tools/perf/arch/x86/entry/syscalls
-systbl := $(sys)/syscalltbl.sh
+generated := $(OUTPUT)arch/x86/include/generated
+out   := $(generated)/asm
+header:= $(out)/syscalls_64.c
+sys   := $(srctree)/tools/perf/arch/x86/entry/syscalls
+systbl:= $(sys)/syscalltbl.sh
 
 # Create output directory if not already present
 _dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
@@ -22,6 +23,6 @@ $(header): $(sys)/syscall_64.tbl $(systbl)
$(Q)$(SHELL) '$(systbl)' $(sys)/syscall_64.tbl 'x86_64' > $@
 
 clean::
-   $(call QUIET_CLEAN, x86) $(RM) $(header)
+   $(call QUIET_CLEAN, x86) $(RM) -r $(header) $(generated)
 
 archheaders: $(header)
-- 
2.27.0



Unused lines

2020-06-29 Thread Gon Solo
Hi!

Are the 147MB or 1.6 million(!) lines in
drivers/gpu/drm/amd/include/asic_reg really necessary? I grepped a few
of them and they don't seem to be used, neither in the kernel nor drm or
mesa. As an example I removed one of the unused lines (see the attached
patch) and the amdgpu driver seems to build just fine.

Cheers,
g

>From 6dbc3e4d129ce46f952c8365f6ca22b2e1aaa33b Mon Sep 17 00:00:00 2001
From: Gon Solo 
Date: Tue, 30 Jun 2020 07:47:12 +0200
Subject: [PATCH] Remove unused line.

---
 drivers/gpu/drm/amd/include/asic_reg/nbio/nbio_6_1_sh_mask.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/include/asic_reg/nbio/nbio_6_1_sh_mask.h b/drivers/gpu/drm/amd/include/asic_reg/nbio/nbio_6_1_sh_mask.h
index 29af5167cd00..d45bd18a05dd 100644
--- a/drivers/gpu/drm/amd/include/asic_reg/nbio/nbio_6_1_sh_mask.h
+++ b/drivers/gpu/drm/amd/include/asic_reg/nbio/nbio_6_1_sh_mask.h
@@ -24,7 +24,6 @@
 
 // addressBlock: nbio_pcie_pswuscfg0_cfgdecp
 //PSWUSCFG0_VENDOR_ID
-#define PSWUSCFG0_VENDOR_ID__VENDOR_ID__SHIFT 0x0
 #define PSWUSCFG0_VENDOR_ID__VENDOR_ID_MASK   0xL
 //PSWUSCFG0_DEVICE_ID
 #define PSWUSCFG0_DEVICE_ID__DEVICE_ID__SHIFT 0x0
-- 
2.25.1



Re: [PATCH 4/4] Add support for Logilink VG0022A.

2019-10-10 Thread Gon Solo
Hi!

> "When the [...] firmware that came with the device is replaced
> by a new one, any I2C data received from the tuner will be
> replaced by 0xff.
> 
> Probably, the vendor firmware has some patch specifically
> designed for this device. So, we can't replace by the generic
> firmware.
> 
> The right solution would be to extract the [...] firmware from
> the original driver and ask the driver to load the specifically
> designed firmware, but, while we don't have that, the next best
> solution is to just keep the original firmware at the device."
 
The information in the patch is not totally correct. It is the
si2168(!) firmware download that confuses things, not the one for the
si2157. The si2157 seems to have no firmware and the problem is
that we used to bail out because we didn't recognize the bogus
chip id. The following patch corrects this.

Signed-off-by: 

diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c 
b/drivers/media/usb/dvb-usb-v2/af9035.c
index 792667ee5ebc..5a2943e2932b 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -1621,17 +1621,20 @@ static int it930x_tuner_attach(struct dvb_usb_adapter 
*adap)
si2157_config.fe = adap->fe[0];
 
/*
-* HACK: The Logilink VG0022A has a bug: when the si2157
+* HACK: The Logilink VG0022A has a bug: When the si2168
 * firmware that came with the device is replaced by a new
 * one, the I2C transfers to the tuner will return just 0xff.
 *
 * Probably, the vendor firmware has some patch specifically
 * designed for this device. So, we can't replace by the
 * generic firmware. The right solution would be to extract
-* the si2157 firmware from the original driver and ask the
+* the si2157/68 firmware from the original driver and ask the
 * driver to load the specifically designed firmware, but,
 * while we don't have that, the next best solution is to just
 * keep the original firmware at the device.
+*
+* Or, the Windows driver includes the same hack and doesn't
+* bail out on bogus chip ids.
 */
if (le16_to_cpu(d->udev->descriptor.idVendor) == USB_VID_DEXATEK &&
le16_to_cpu(d->udev->descriptor.idProduct) == 0x0100)


Re: [PATCH 1/4] media: si2168: use bits instead of bool for flags

2019-10-10 Thread Gon Solo
On Fri, Oct 04, 2019 at 10:15:22AM -0300, Mauro Carvalho Chehab wrote:
> Using bool on struct is not recommended, as it wastes lots of
> space. So, instead, let's use bits.

Wouldn't "bool b:1;" even be better? I performed a little test:

#include 
#include 

struct uints {
unsigned int a0;
unsigned int a1;
unsigned int a2;
unsigned int a3;
unsigned int a4;
unsigned int a5;
unsigned int a6;
unsigned int a7;
};

struct bools {
bool a0;
bool a1;
bool a2;
bool a3;
bool a4;
bool a5;
bool a6;
bool a7;
};

struct bit_uints {
unsigned int a0:1;
unsigned int a1:1;
unsigned int a2:1;
unsigned int a3:1;
unsigned int a4:1;
unsigned int a5:1;
unsigned int a6:1;
unsigned int a7:1;
};

struct bit_bools {
bool a0:1;
bool a1:1;
bool a2:1;
bool a3:1;
bool a4:1;
bool a5:1;
bool a6:1;
bool a7:1;
};

int main() {
printf("bit_uints: %ld\n", sizeof(struct bit_uints));
printf("bit_bools: %ld\n", sizeof(struct bit_bools));
printf("uints: %ld\n", sizeof(struct uints));
printf("bools: %ld\n", sizeof(struct bools));
}

Result:

bit_uints: 4
bit_bools: 1
uints: 32
bools: 8

I know with different types within the struct it looks different, but
still.

g



[PATCH 4/4] Add support for Logilink VG0022A.

2019-10-10 Thread Gon Solo
This includes a hack for the device as it returns only 0xff after a new
firmware is loaded. To quote Mauro:

"When the [...] firmware that came with the device is replaced
by a new one, any I2C data received from the tuner will be
replaced by 0xff.

Probably, the vendor firmware has some patch specifically
designed for this device. So, we can't replace by the generic
firmware.

The right solution would be to extract the [...] firmware from
the original driver and ask the driver to load the specifically
designed firmware, but, while we don't have that, the next best
solution is to just keep the original firmware at the device."

Signed-off-by: Gon Solo 
---
 drivers/media/usb/dvb-usb-v2/af9035.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c 
b/drivers/media/usb/dvb-usb-v2/af9035.c
index 51e607ea3add..792667ee5ebc 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -1619,6 +1619,24 @@ static int it930x_tuner_attach(struct dvb_usb_adapter 
*adap)
 
memset(&si2157_config, 0, sizeof(si2157_config));
si2157_config.fe = adap->fe[0];
+
+   /*
+* HACK: The Logilink VG0022A has a bug: when the si2157
+* firmware that came with the device is replaced by a new
+* one, the I2C transfers to the tuner will return just 0xff.
+*
+* Probably, the vendor firmware has some patch specifically
+* designed for this device. So, we can't replace by the
+* generic firmware. The right solution would be to extract
+* the si2157 firmware from the original driver and ask the
+* driver to load the specifically designed firmware, but,
+* while we don't have that, the next best solution is to just
+* keep the original firmware at the device.
+*/
+   if (le16_to_cpu(d->udev->descriptor.idVendor) == USB_VID_DEXATEK &&
+   le16_to_cpu(d->udev->descriptor.idProduct) == 0x0100)
+   si2157_config.dont_load_firmware = true;
+
si2157_config.if_port = 
it930x_addresses_table[state->it930x_addresses].tuner_if_port;
ret = af9035_add_i2c_dev(d, "si2157",
 
it930x_addresses_table[state->it930x_addresses].tuner_i2c_addr,
@@ -2130,6 +2148,8 @@ static const struct usb_device_id af9035_id_table[] = {
&it930x_props, "ITE 9303 Generic", NULL) },
{ DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_TD310,
&it930x_props, "AVerMedia TD310 DVB-T2", NULL) },
+   { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x0100,
+   &it930x_props, "Logilink VG0022A", NULL) },
{ }
 };
 MODULE_DEVICE_TABLE(usb, af9035_id_table);
-- 
2.20.1



[PATCH 2/4] si2157: Add option for not downloading firmware.

2019-10-10 Thread Gon Solo
While at it, convert to kernel-doc format and use bits instead of bools.

Signed-off-by: Gon Solo 
---
 drivers/media/tuners/si2157.c  |  6 ++
 drivers/media/tuners/si2157.h  | 33 +-
 drivers/media/tuners/si2157_priv.h |  5 +++--
 3 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index e87040d6eca7..898e0f9f8b70 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -118,6 +118,11 @@ static int si2157_init(struct dvb_frontend *fe)
goto err;
}
 
+   if (dev->dont_load_firmware) {
+   dev_info(&client->dev, "device is buggy, skipping firmware 
download\n");
+   goto skip_fw_download;
+   }
+
/* query chip revision */
memcpy(cmd.args, "\x02", 1);
cmd.wlen = 1;
@@ -440,6 +445,7 @@ static int si2157_probe(struct i2c_client *client,
i2c_set_clientdata(client, dev);
dev->fe = cfg->fe;
dev->inversion = cfg->inversion;
+   dev->dont_load_firmware = cfg->dont_load_firmware;
dev->if_port = cfg->if_port;
dev->chiptype = (u8)id->driver_data;
dev->if_frequency = 500; /* default value of property 0x0706 */
diff --git a/drivers/media/tuners/si2157.h b/drivers/media/tuners/si2157.h
index c22ca784f43f..ffdece3c2eaa 100644
--- a/drivers/media/tuners/si2157.h
+++ b/drivers/media/tuners/si2157.h
@@ -11,29 +11,34 @@
 #include 
 #include 
 
-/*
- * I2C address
- * 0x60
+/**
+ * struct si2157_config - configuration parameters for si2157
+ *
+ * @fe:
+ * frontend returned by driver
+ * @mdev:
+ * media device returned by driver
+ * @inversion:
+ * spectral inversion
+ * @dont_load_firmware:
+ * Instead of uploading a new firmware, use the existing one
+ * @if_port:
+ * Port selection
+ * Select the RF interface to use (pins 9+11 or 12+13)
+ *
+ * Note:
+ * The I2C address of this demod is 0x60.
  */
 struct si2157_config {
-   /*
-* frontend
-*/
struct dvb_frontend *fe;
 
 #if defined(CONFIG_MEDIA_CONTROLLER)
struct media_device *mdev;
 #endif
 
-   /*
-* Spectral Inversion
-*/
-   bool inversion;
+   unsigned int inversion:1;
+   unsigned int dont_load_firmware:1;
 
-   /*
-* Port selection
-* Select the RF interface to use (pins 9+11 or 12+13)
-*/
u8 if_port;
 };
 
diff --git a/drivers/media/tuners/si2157_priv.h 
b/drivers/media/tuners/si2157_priv.h
index 2bda903358da..778f81b39996 100644
--- a/drivers/media/tuners/si2157_priv.h
+++ b/drivers/media/tuners/si2157_priv.h
@@ -23,8 +23,9 @@ enum si2157_pads {
 struct si2157_dev {
struct mutex i2c_mutex;
struct dvb_frontend *fe;
-   bool active;
-   bool inversion;
+   unsigned int active:1;
+   unsigned int inversion:1;
+   unsigned int dont_load_firmware:1;
u8 chiptype;
u8 if_port;
u32 if_frequency;
-- 
2.20.1



[PATCH 1/4] si2168: Use bits and convert to kernel-doc format.

2019-10-10 Thread Gon Solo
Signed-off-by: Gon Solo 
---
 drivers/media/dvb-frontends/si2168.h  | 47 +--
 drivers/media/dvb-frontends/si2168_priv.h | 10 ++---
 2 files changed, 31 insertions(+), 26 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.h 
b/drivers/media/dvb-frontends/si2168.h
index 50dccb394efa..ecd21adf8950 100644
--- a/drivers/media/dvb-frontends/si2168.h
+++ b/drivers/media/dvb-frontends/si2168.h
@@ -9,38 +9,43 @@
 #define SI2168_H
 
 #include 
-/*
- * I2C address
- * 0x64
+/**
+ * struct si2168_config - configuration parameters for si2168
+ *
+ * @fe:
+ * frontend returned by driver
+ * @i2c_adapter:
+ * tuner I2C adapter returned by driver
+ * @ts_mode:
+ * Transport Stream mode. Can be:
+ * - %SI2168_TS_PARALLEL
+ * - %SI2168_TS_SERIAL
+ * - %SI2168_TS_TRISTATE
+ * - %SI2168_TS_CLK_MANUAL
+ * @ts_clock_inv:
+ * TS clock inverted
+ * @ts_clock_gapped:
+ * TS clock gapped
+ * @spectral_inversion:
+ * Inverted spectrum
+ *
+ * Note:
+ * The I2C address of this demod is 0x64.
  */
 struct si2168_config {
-   /*
-* frontend
-* returned by driver
-*/
struct dvb_frontend **fe;
-
-   /*
-* tuner I2C adapter
-* returned by driver
-*/
struct i2c_adapter **i2c_adapter;
 
-   /* TS mode */
 #define SI2168_TS_PARALLEL 0x06
 #define SI2168_TS_SERIAL   0x03
 #define SI2168_TS_TRISTATE 0x00
 #define SI2168_TS_CLK_MANUAL   0x20
u8 ts_mode;
 
-   /* TS clock inverted */
-   bool ts_clock_inv;
-
-   /* TS clock gapped */
-   bool ts_clock_gapped;
-
-   /* Inverted spectrum */
-   bool spectral_inversion;
+   /* Flags */
+   unsigned int ts_clock_inv:1;
+   unsigned int ts_clock_gapped:1;
+   unsigned int spectral_inversion:1;
 };
 
 #endif
diff --git a/drivers/media/dvb-frontends/si2168_priv.h 
b/drivers/media/dvb-frontends/si2168_priv.h
index 804d5b30c697..18bea5222082 100644
--- a/drivers/media/dvb-frontends/si2168_priv.h
+++ b/drivers/media/dvb-frontends/si2168_priv.h
@@ -34,12 +34,12 @@ struct si2168_dev {
unsigned int chip_id;
unsigned int version;
const char *firmware_name;
-   bool active;
-   bool warm;
u8 ts_mode;
-   bool ts_clock_inv;
-   bool ts_clock_gapped;
-   bool spectral_inversion;
+   unsigned int active:1;
+   unsigned int warm:1;
+   unsigned int ts_clock_inv:1;
+   unsigned int ts_clock_gapped:1;
+   unsigned int spectral_inversion:1;
 };
 
 /* firmware command struct */
-- 
2.20.1



[PATCH 3/4] af9035: Make speed computation clear.

2019-10-10 Thread Gon Solo
Signed-off-by: Gon Solo 
---
 drivers/media/usb/dvb-usb-v2/af9035.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c 
b/drivers/media/usb/dvb-usb-v2/af9035.c
index 3afd18733614..51e607ea3add 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -1197,6 +1197,15 @@ static int af9035_frontend_attach(struct dvb_usb_adapter 
*adap)
return ret;
 }
 
+/*
+ * The I2C speed register is calculated with:
+ * I2C speed register = (10 / (24.4 * 16 * I2C_speed))
+ *
+ * The default speed register for it930x is 7, with means a
+ * speed of ~366 kbps
+ */
+#define I2C_SPEED_366K 7
+
 static int it930x_frontend_attach(struct dvb_usb_adapter *adap)
 {
struct state *state = adap_to_priv(adap);
@@ -1208,13 +1217,13 @@ static int it930x_frontend_attach(struct 
dvb_usb_adapter *adap)
 
dev_dbg(&intf->dev, "adap->id=%d\n", adap->id);
 
-   /* I2C master bus 2 clock speed 300k */
-   ret = af9035_wr_reg(d, 0x00f6a7, 0x07);
+   /* I2C master bus 2 clock speed 366k */
+   ret = af9035_wr_reg(d, 0x00f6a7, I2C_SPEED_366K);
if (ret < 0)
goto err;
 
-   /* I2C master bus 1,3 clock speed 300k */
-   ret = af9035_wr_reg(d, 0x00f103, 0x07);
+   /* I2C master bus 1,3 clock speed 366k */
+   ret = af9035_wr_reg(d, 0x00f103, I2C_SPEED_366K);
if (ret < 0)
goto err;
 
-- 
2.20.1



[PATCH 0/4] Add support for Logilink VG0022A.

2019-10-10 Thread Gon Solo
These patches add support for the Logilink VG0022A.

Signed-off-by: Andreas Wendleder 

Gon Solo (4):
  si2168: Use bits and convert to kernel-doc format.
  si2157: Add option for not downloading firmware.
  af9035: Make speed computation clear.
  Add support for Logilink VG0022A.

 drivers/media/dvb-frontends/si2168.h  | 47 +--
 drivers/media/dvb-frontends/si2168_priv.h | 10 ++---
 drivers/media/tuners/si2157.c |  6 +++
 drivers/media/tuners/si2157.h | 33 +---
 drivers/media/tuners/si2157_priv.h|  5 ++-
 drivers/media/usb/dvb-usb-v2/af9035.c | 37 --
 6 files changed, 92 insertions(+), 46 deletions(-)

-- 
2.20.1



Re: [PATCH 3/4] media: af9035: add support for Logilink VG0022A

2019-10-10 Thread Gon Solo
Hi!

This patch works for me. It disables firmware downloading for the si2157
instead of the si2168.

Convert si2157 and si2168 to kernel-doc format as suggested by Mauro.
Use bits instead of bool.  Add a flag to si2157 for not loading the
firmware.  Make computation of speed register clear. Add hack for
Logilink VG0022A.

Signed-off-by: Andreas Wendleder 

diff --git a/drivers/media/dvb-frontends/si2168.h 
b/drivers/media/dvb-frontends/si2168.h
index 50dccb394efa..ecd21adf8950 100644
--- a/drivers/media/dvb-frontends/si2168.h
+++ b/drivers/media/dvb-frontends/si2168.h
@@ -9,38 +9,43 @@
 #define SI2168_H
 
 #include 
-/*
- * I2C address
- * 0x64
+/**
+ * struct si2168_config - configuration parameters for si2168
+ *
+ * @fe:
+ * frontend returned by driver
+ * @i2c_adapter:
+ * tuner I2C adapter returned by driver
+ * @ts_mode:
+ * Transport Stream mode. Can be:
+ * - %SI2168_TS_PARALLEL
+ * - %SI2168_TS_SERIAL
+ * - %SI2168_TS_TRISTATE
+ * - %SI2168_TS_CLK_MANUAL
+ * @ts_clock_inv:
+ * TS clock inverted
+ * @ts_clock_gapped:
+ * TS clock gapped
+ * @spectral_inversion:
+ * Inverted spectrum
+ *
+ * Note:
+ * The I2C address of this demod is 0x64.
  */
 struct si2168_config {
-   /*
-* frontend
-* returned by driver
-*/
struct dvb_frontend **fe;
-
-   /*
-* tuner I2C adapter
-* returned by driver
-*/
struct i2c_adapter **i2c_adapter;
 
-   /* TS mode */
 #define SI2168_TS_PARALLEL 0x06
 #define SI2168_TS_SERIAL   0x03
 #define SI2168_TS_TRISTATE 0x00
 #define SI2168_TS_CLK_MANUAL   0x20
u8 ts_mode;
 
-   /* TS clock inverted */
-   bool ts_clock_inv;
-
-   /* TS clock gapped */
-   bool ts_clock_gapped;
-
-   /* Inverted spectrum */
-   bool spectral_inversion;
+   /* Flags */
+   unsigned int ts_clock_inv:1;
+   unsigned int ts_clock_gapped:1;
+   unsigned int spectral_inversion:1;
 };
 
 #endif
diff --git a/drivers/media/dvb-frontends/si2168_priv.h 
b/drivers/media/dvb-frontends/si2168_priv.h
index 804d5b30c697..18bea5222082 100644
--- a/drivers/media/dvb-frontends/si2168_priv.h
+++ b/drivers/media/dvb-frontends/si2168_priv.h
@@ -34,12 +34,12 @@ struct si2168_dev {
unsigned int chip_id;
unsigned int version;
const char *firmware_name;
-   bool active;
-   bool warm;
u8 ts_mode;
-   bool ts_clock_inv;
-   bool ts_clock_gapped;
-   bool spectral_inversion;
+   unsigned int active:1;
+   unsigned int warm:1;
+   unsigned int ts_clock_inv:1;
+   unsigned int ts_clock_gapped:1;
+   unsigned int spectral_inversion:1;
 };
 
 /* firmware command struct */
diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index e87040d6eca7..898e0f9f8b70 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -118,6 +118,11 @@ static int si2157_init(struct dvb_frontend *fe)
goto err;
}
 
+   if (dev->dont_load_firmware) {
+   dev_info(&client->dev, "device is buggy, skipping firmware 
download\n");
+   goto skip_fw_download;
+   }
+
/* query chip revision */
memcpy(cmd.args, "\x02", 1);
cmd.wlen = 1;
@@ -440,6 +445,7 @@ static int si2157_probe(struct i2c_client *client,
i2c_set_clientdata(client, dev);
dev->fe = cfg->fe;
dev->inversion = cfg->inversion;
+   dev->dont_load_firmware = cfg->dont_load_firmware;
dev->if_port = cfg->if_port;
dev->chiptype = (u8)id->driver_data;
dev->if_frequency = 500; /* default value of property 0x0706 */
diff --git a/drivers/media/tuners/si2157.h b/drivers/media/tuners/si2157.h
index c22ca784f43f..ffdece3c2eaa 100644
--- a/drivers/media/tuners/si2157.h
+++ b/drivers/media/tuners/si2157.h
@@ -11,29 +11,34 @@
 #include 
 #include 
 
-/*
- * I2C address
- * 0x60
+/**
+ * struct si2157_config - configuration parameters for si2157
+ *
+ * @fe:
+ * frontend returned by driver
+ * @mdev:
+ * media device returned by driver
+ * @inversion:
+ * spectral inversion
+ * @dont_load_firmware:
+ * Instead of uploading a new firmware, use the existing one
+ * @if_port:
+ * Port selection
+ * Select the RF interface to use (pins 9+11 or 12+13)
+ *
+ * Note:
+ * The I2C address of this demod is 0x60.
  */
 struct si2157_config {
-   /*
-* frontend
-*/
struct dvb_frontend *fe;
 
 #if defined(CONFIG_MEDIA_CONTROLLER)
struct media_device *mdev;
 #endif
 
-   /*
-* Spectral Inversion
-*/
-   bool inversion;
+   unsigned int inversion:1;
+   unsigned int dont_load_firmware:1;
 
-   /*
-* Port selection
-* Select the RF interface to use (pins 9+11 or 12+13)
-*/
u8 if_port;
 };
 
diff --git a/drivers/media/tuners/si2157_priv.h 
b/drivers/media/tuners/si215

Re: [PATCH 3/4] media: af9035: add support for Logilink VG0022A

2019-10-10 Thread Gon Solo
Hi!

I rebased Mauros patch on top of mine and this patch [3/4] is the first bad
commit. I believe these lines are the culprit:

+   if (le16_to_cpu(d->udev->descriptor.idVendor) == USB_VID_DEXATEK &&
+   le16_to_cpu(d->udev->descriptor.idProduct) == 0x0100)
+   si2168_config.dont_load_firmware = true;

> From: JP 
> Mauro just took the wrong firmware to skip. demod instead of tuner.
> It would not be hard to fix that.

It seems so.

g



Re: [PATCH 3/4] media: af9035: add support for Logilink VG0022A

2019-10-09 Thread Gon Solo
> Unfortunately, after applying these four patches it doesn't work for me.

Your patch disables firmware loading at dvb-frontends/si2168.c:449 while
my original one disabled it at tuners/si2157.c:554:

case SI_BOGUS:
dev_info(&client->dev, "bogus chip version, trying with no 
firmware\n");
fw_name = NULL;

According to my dmesg the following chip is found:

[  141.726488] si2157 10-0063: found a 'Silicon Labs Si2147-A30'
[  141.777647] si2157 10-0063: firmware version: 3.0.5

So according to:

case SI2147_A30:
case SI2146_A10:
fw_name = NULL;

it should work. Hmmm.

g



Re: [PATCH 3/4] media: af9035: add support for Logilink VG0022A

2019-10-09 Thread Gon Solo
> This it930x-based device has an issue with si2068.
> 
> When the si2168 firmware that came with the device is replaced
> by a new one, any I2C data received from the tuner will be
> replaced by 0xff.
> 
> Probably, the vendor firmware has some patch specifically
> designed for this device. So, we can't replace by the generic
> firmware.
> 
> The right solution would be to extract the si2168 firmware from
> the original driver and ask the driver to load the specifically
> designed firmware, but, while we don't have that, the next best
> solution is to just keep the original firmware at the device.

Unfortunately, after applying these four patches it doesn't work for me.
The messages when inserting the stick:

[  244.133448] i2c i2c-1: Added multiplexed i2c bus 2
[  244.133455] si2168 1-0067: Silicon Labs Si2168-B40 successfully identified
[  244.133458] si2168 1-0067: firmware version: B 4.0.2
[  244.133500] usb 2-1: DVB: registering adapter 0 frontend 0 (Silicon Labs 
Si2168)...
[  244.133514] dvbdev: dvb_create_media_entity: media entity 'Silicon Labs 
Si2168' registered.
[  244.138367] si2157 2-0063: Silicon Labs Si2147/2148/2157/2158 successfully 
attached
[  244.156956] usb 2-1: dvb_usb_v2: 'Logilink VG0022A' successfully initialized 
and connected

The messages when starting VLC:

[  260.490253] si2157 2-0063: found a 'Silicon Labs Si2147-A30'
[  260.541347] si2157 2-0063: firmware version: 3.0.5

But it doesn't work. :(

g

> 
> For more details, see the discussions at:
>   
> https://lore.kernel.org/linux-media/20191002141359.30166-2-gons...@gmail.com/
> 
> Signed-off-by: Mauro Carvalho Chehab 
> ---
>  drivers/media/usb/dvb-usb-v2/af9035.c | 19 +++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c 
> b/drivers/media/usb/dvb-usb-v2/af9035.c
> index 3afd18733614..e555483c3077 100644
> --- a/drivers/media/usb/dvb-usb-v2/af9035.c
> +++ b/drivers/media/usb/dvb-usb-v2/af9035.c
> @@ -1255,6 +1255,23 @@ static int it930x_frontend_attach(struct 
> dvb_usb_adapter *adap)
>   si2168_config.fe = &adap->fe[0];
>   si2168_config.ts_mode = SI2168_TS_SERIAL;
>  
> + /*
> +  * HACK: The Logilink VG0022A has a bug: when the si2168
> +  * firmware that came with the device is replaced by a new
> +  * one, the I2C transfers to the tuner will return just 0xff.
> +  *
> +  * Probably, the vendor firmware has some patch specifically
> +  * designed for this device. So, we can't replace by the
> +  * generic firmware. The right solution would be to extract
> +  * the si2168 firmware from the original driver and ask the
> +  * driver to load the specifically designed firmware, but,
> +  * while we don't have that, the next best solution is to just
> +  * keep the original firmware at the device.
> +  */
> + if (le16_to_cpu(d->udev->descriptor.idVendor) == USB_VID_DEXATEK &&
> + le16_to_cpu(d->udev->descriptor.idProduct) == 0x0100)
> + si2168_config.dont_load_firmware = true;
> +
>   state->af9033_config[adap->id].fe = &adap->fe[0];
>   state->af9033_config[adap->id].ops = &state->ops;
>   ret = af9035_add_i2c_dev(d, "si2168",
> @@ -2121,6 +2138,8 @@ static const struct usb_device_id af9035_id_table[] = {
>   &it930x_props, "ITE 9303 Generic", NULL) },
>   { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_TD310,
>   &it930x_props, "AVerMedia TD310 DVB-T2", NULL) },
> + { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x0100,
> + &it930x_props, "Logilink VG0022A", NULL) },
>   { }
>  };
>  MODULE_DEVICE_TABLE(usb, af9035_id_table);
> -- 
> 2.21.0
> 


Re: [PATCH] si2157: Add support for Logilink VG0022A.

2019-10-03 Thread Gon Solo
> You could also try to disable the firmware upload at si2168 and see
> if the si2157 reads will succeed.

I disabled the upload and while vlc wasn't working anymore I got the
following messages:

[  168.196656] si2157 2-0063: found a 'Silicon Labs Si2147-A30'
[  168.223009] si2157 2-0063: firmware version: 3.0.5


It really seems that the firmware upload is the culprit.

g



Re: [PATCH] si2157: Add support for Logilink VG0022A.

2019-10-03 Thread Gon Solo
> No, I mean with the first patch you sent to the ML, with the powerup
> hack.

Boot time:

[4.653257] si2168 1-0067: Silicon Labs Si2168-B40 successfully identified
[4.653259] si2168 1-0067: firmware version: B 4.0.2
[4.653279] usb 2-1: DVB: registering adapter 0 frontend 0 (Silicon Labs 
Si2168)...
[4.653284] dvbdev: dvb_create_media_entity: media entity 'Silicon Labs 
Si2168' registered.
...
[4.694785] si2157 2-0063: found a 'Silicon Labs Si2147-A30'
[4.694787] si2157 2-0063: Silicon Labs Si2147/2148/2157/2158 successfully 
attached
[4.717814] usb 2-1: dvb_usb_v2: 'Logilink VG0022A' successfully initialized 
and connected
[4.717880] usbcore: registered new interface driver dvb_usb_af9035

VLC time:

[  175.490609] si2168 1-0067: downloading firmware from file 
'dvb-demod-si2168-b40-01.fw'
[  176.746585] si2168 1-0067: firmware version: B 4.0.25
[  176.781570] si2157 2-0063: firmware version: \xff.\xff.255

g



Re: [PATCH] si2157: Add support for Logilink VG0022A.

2019-10-03 Thread Gon Solo
> With the original patch you proposed, what are the logs?

With the following patch applied to media_tree master:

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index e87040d6eca7..4c1ab0b6876a 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -129,13 +129,14 @@ static int si2157_init(struct dvb_frontend *fe)
chip_id = cmd.args[1] << 24 | cmd.args[2] << 16 | cmd.args[3] << 8 |
cmd.args[4] << 0;
 
-   #define SI2177_A30 ('A' << 24 | 77 << 16 | '3' << 8 | '0' << 0)
-   #define SI2158_A20 ('A' << 24 | 58 << 16 | '2' << 8 | '0' << 0)
-   #define SI2148_A20 ('A' << 24 | 48 << 16 | '2' << 8 | '0' << 0)
-   #define SI2157_A30 ('A' << 24 | 57 << 16 | '3' << 8 | '0' << 0)
-   #define SI2147_A30 ('A' << 24 | 47 << 16 | '3' << 8 | '0' << 0)
-   #define SI2146_A10 ('A' << 24 | 46 << 16 | '1' << 8 | '0' << 0)
-   #define SI2141_A10 ('A' << 24 | 41 << 16 | '1' << 8 | '0' << 0)
+   #define SI2177_A30 ('A' << 24 |  77 << 16 | '3' << 8 | '0' << 0)
+   #define SI2158_A20 ('A' << 24 |  58 << 16 | '2' << 8 | '0' << 0)
+   #define SI2148_A20 ('A' << 24 |  48 << 16 | '2' << 8 | '0' << 0)
+   #define SI2157_A30 ('A' << 24 |  57 << 16 | '3' << 8 | '0' << 0)
+   #define SI2147_A30 ('A' << 24 |  47 << 16 | '3' << 8 | '0' << 0)
+   #define SI2146_A10 ('A' << 24 |  46 << 16 | '1' << 8 | '0' << 0)
+   #define SI2141_A10 ('A' << 24 |  41 << 16 | '1' << 8 | '0' << 0)
+   #define SI_BOGUS   (255 << 24 | 255 << 16 | 255 << 8 | 255 << 0)
 
switch (chip_id) {
case SI2158_A20:
@@ -148,6 +149,10 @@ static int si2157_init(struct dvb_frontend *fe)
case SI2177_A30:
fw_name = SI2157_A30_FIRMWARE;
break;
+   case SI_BOGUS:
+   dev_info(&client->dev, "Bogus chip version, trying with no 
firmware\n");
+   fw_name = NULL;
+   break;
case SI2157_A30:
case SI2147_A30:
case SI2146_A10:
@@ -225,6 +230,7 @@ static int si2157_init(struct dvb_frontend *fe)
 
dev_info(&client->dev, "firmware version: %c.%c.%d\n",
cmd.args[6], cmd.args[7], cmd.args[8]);
 warm:
/* init statistics in order signal app which are supported */
c->strength.len = 1;
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c 
b/drivers/media/usb/dvb-usb-v2/af9035.c
index 3afd18733614..a8d59cf06b1e 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -1197,6 +1197,11 @@ static int af9035_frontend_attach(struct dvb_usb_adapter 
*adap)
return ret;
 }
 
+/* I2C speed register = (10 / (24.4 * 16 * I2C_speed))
+ * 7 equals ~400k, 26 ~100k and 260 ~10k.
+ * */
+#define I2C_SPEED_REGISTER 7
+
 static int it930x_frontend_attach(struct dvb_usb_adapter *adap)
 {
struct state *state = adap_to_priv(adap);
@@ -1208,13 +1213,13 @@ static int it930x_frontend_attach(struct 
dvb_usb_adapter *adap)
 
dev_dbg(&intf->dev, "adap->id=%d\n", adap->id);
 
-   /* I2C master bus 2 clock speed 300k */
-   ret = af9035_wr_reg(d, 0x00f6a7, 0x07);
+   /* I2C master bus 2 clock speed */
+   ret = af9035_wr_reg(d, 0x00f6a7, I2C_SPEED_REGISTER);
if (ret < 0)
goto err;
 
-   /* I2C master bus 1,3 clock speed 300k */
-   ret = af9035_wr_reg(d, 0x00f103, 0x07);
+   /* I2C master bus 1,3 clock speed */
+   ret = af9035_wr_reg(d, 0x00f103, I2C_SPEED_REGISTER);
if (ret < 0)
goto err;
 
@@ -2119,6 +2124,8 @@ static const struct usb_device_id af9035_id_table[] = {
/* IT930x devices */
{ DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9303,
&it930x_props, "ITE 9303 Generic", NULL) },
+   { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x0100,
+   &it930x_props, "Logilink VG0022A", NULL) },
{ DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_TD310,
&it930x_props, "AVerMedia TD310 DVB-T2", NULL) },
{ }

the Messages at boot time are

[4.262882] si2168 1-0067: Silicon Labs Si2168-B40 successfully identified
[4.262884] si2168 1-0067: firmware version: B 4.0.2
[4.262902] usb 2-1: DVB: registering adapter 0 frontend 0 (Silicon Labs 
Si2168)...
[4.262908] dvbdev: dvb_create_media_entity: media entity 'Silicon Labs 
Si2168' registered.
[4.289776] si2157 2-0063: Silicon Labs Si2147/2148/2157/2158 successfully 
attached

and the messages when running vlc (successfully) are

[  486.537128] si2168 1-0067: downloading firmware from file 
'dvb-demod-si2168-b40-01.fw'
[  487.795436] si2168 1-0067: firmware version: B 4.0.25
[  487.807614] si2157 2-0063: Bogus chip version, trying with no firmware
[  487.807618] si2157 2-0063: found a 'Silicon Labs Si21255-\xff\xff\xff'
[  487.833876] si2157 2-0063: firmware version: \xff.\xff.255

g



Re: [PATCH] si2157: Add support for Logilink VG0022A.

2019-10-03 Thread Gon Solo
 
> Maybe something like this would make it work?

Nope. :(

[   47.371022] si2168 1-0067: downloading firmware from file 
'dvb-demod-si2168-b40-01.fw'
[   48.632824] si2168 1-0067: firmware version: B 4.0.25
[   48.671268] si2157 2-0063: unknown chip version Si21255-\xff\xff\xff


g



[PATCH 3/3] [PATCH] af9035: Add Logilink VG0022A id.

2019-10-03 Thread Gon Solo
Original patch from Andreas Kemnade.

Signed-off-by: Gon Solo 
---
 drivers/media/usb/dvb-usb-v2/af9035.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c 
b/drivers/media/usb/dvb-usb-v2/af9035.c
index 7828f8567da0..a02cafadfb49 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -2122,6 +2122,8 @@ static const struct usb_device_id af9035_id_table[] = {
/* IT930x devices */
{ DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9303,
&it930x_props, "ITE 9303 Generic", NULL) },
+   { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x0100,
+   &it930x_props, "Logilink VG0022A", NULL) },
{ DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_TD310,
&it930x_props, "AVerMedia TD310 DVB-T2", NULL) },
{ }
-- 
2.20.1



[PATCH 1/3] [PATCH] af9035: Better explain how i2c bus speed is computed.

2019-10-03 Thread Gon Solo
Original patch from Mauro Carvalho Chehab.

Signed-off-by: Gon Solo 
---
 drivers/media/usb/dvb-usb-v2/af9035.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c 
b/drivers/media/usb/dvb-usb-v2/af9035.c
index 3afd18733614..7828f8567da0 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -1197,6 +1197,9 @@ static int af9035_frontend_attach(struct dvb_usb_adapter 
*adap)
return ret;
 }
 
+/* I2C speed register = (10 / (24.4 * 16 * I2C_speed)) */
+#define I2C_SPEED_REGISTER 7
+
 static int it930x_frontend_attach(struct dvb_usb_adapter *adap)
 {
struct state *state = adap_to_priv(adap);
@@ -1208,13 +1211,13 @@ static int it930x_frontend_attach(struct 
dvb_usb_adapter *adap)
 
dev_dbg(&intf->dev, "adap->id=%d\n", adap->id);
 
-   /* I2C master bus 2 clock speed 300k */
-   ret = af9035_wr_reg(d, 0x00f6a7, 0x07);
+   /* I2C master bus 2 clock speed ~300k */
+   ret = af9035_wr_reg(d, 0x00f6a7, I2C_SPEED_REGISTER);
if (ret < 0)
goto err;
 
-   /* I2C master bus 1,3 clock speed 300k */
-   ret = af9035_wr_reg(d, 0x00f103, 0x07);
+   /* I2C master bus 1,3 clock speed ~300k */
+   ret = af9035_wr_reg(d, 0x00f103, I2C_SPEED_REGISTER);
if (ret < 0)
goto err;
 
-- 
2.20.1



[PATCH 0/3] Add support for Logilink VG0022A

2019-10-03 Thread Gon Solo
These three patches make the Logilink VG0022A work.
Being cheap hardware a bogus chip version is returned but this is catched in
the driver.

Gon Solo (3):
  af9035: Better explain how i2c bus speed is computed.
  s2157: Handle bogus chip version.
  af9035: Add Logilink VG0022A id.

 drivers/media/tuners/si2157.c | 19 ---
 drivers/media/usb/dvb-usb-v2/af9035.c | 13 +
 2 files changed, 21 insertions(+), 11 deletions(-)

-- 
2.20.1



[PATCH 2/3] [PATCH] s2157: Handle bogus chip version.

2019-10-03 Thread Gon Solo
On some hardware bogus chip version numbers are returned.
Try to continue without firmware.

Signed-off-by: Gon Solo 
---
 drivers/media/tuners/si2157.c | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index e87040d6eca7..615bc8a75c64 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -129,13 +129,14 @@ static int si2157_init(struct dvb_frontend *fe)
chip_id = cmd.args[1] << 24 | cmd.args[2] << 16 | cmd.args[3] << 8 |
cmd.args[4] << 0;
 
-   #define SI2177_A30 ('A' << 24 | 77 << 16 | '3' << 8 | '0' << 0)
-   #define SI2158_A20 ('A' << 24 | 58 << 16 | '2' << 8 | '0' << 0)
-   #define SI2148_A20 ('A' << 24 | 48 << 16 | '2' << 8 | '0' << 0)
-   #define SI2157_A30 ('A' << 24 | 57 << 16 | '3' << 8 | '0' << 0)
-   #define SI2147_A30 ('A' << 24 | 47 << 16 | '3' << 8 | '0' << 0)
-   #define SI2146_A10 ('A' << 24 | 46 << 16 | '1' << 8 | '0' << 0)
-   #define SI2141_A10 ('A' << 24 | 41 << 16 | '1' << 8 | '0' << 0)
+   #define SI2177_A30 ('A' << 24 |  77 << 16 | '3' << 8 | '0' << 0)
+   #define SI2158_A20 ('A' << 24 |  58 << 16 | '2' << 8 | '0' << 0)
+   #define SI2148_A20 ('A' << 24 |  48 << 16 | '2' << 8 | '0' << 0)
+   #define SI2157_A30 ('A' << 24 |  57 << 16 | '3' << 8 | '0' << 0)
+   #define SI2147_A30 ('A' << 24 |  47 << 16 | '3' << 8 | '0' << 0)
+   #define SI2146_A10 ('A' << 24 |  46 << 16 | '1' << 8 | '0' << 0)
+   #define SI2141_A10 ('A' << 24 |  41 << 16 | '1' << 8 | '0' << 0)
+   #define SI_BOGUS   (255 << 24 | 255 << 16 | 255 << 8 | 255 << 0)
 
switch (chip_id) {
case SI2158_A20:
@@ -148,6 +149,10 @@ static int si2157_init(struct dvb_frontend *fe)
case SI2177_A30:
fw_name = SI2157_A30_FIRMWARE;
break;
+   case SI_BOGUS:
+   dev_info(&client->dev, "Bogus chip version, trying with no 
firmware\n");
+   fw_name = NULL;
+   break;
case SI2157_A30:
case SI2147_A30:
case SI2146_A10:
-- 
2.20.1



Re: [PATCH] si2157: Add support for Logilink VG0022A.

2019-10-03 Thread Gon Solo
> well, you could try to increase the timeout - although 100 ms seems a lot
> of time to me.

I tried 5s, still no change.

Would it be possible to include my patch, possibly with a warning like
"bogus chip version, trying with no firmware"?

g



Re: [PATCH] si2157: Add support for Logilink VG0022A.

2019-10-03 Thread Gon Solo
Hi!

 
> Btw, could you please try the enclosed hack and post the results?
 
[  210.178948] si2168 1-0067: downloading firmware from file 
'dvb-demod-si2168-b40-01.fw'
[  212.404011] si2168 1-0067: firmware version: B 4.0.25
[  212.656467] si2157 2-0063: Needed to wait 100 ms to get chip version
[  212.656470] si2157 2-0063: Unable to retrieve chip version

:(

g



[PATCH 0/1] Testing timing patch for Logilink VG0022A

2019-10-03 Thread Gon Solo
Hi!

I tested the following patch on a Ubuntu Disco Dingo kernel.
Unfortunately it fails with the following error message:

[3.715233] dvb_usb_af9035 2-1:1.0: prechip_version=83 chip_version=01 
chip_type=9306
[3.718385] usb 2-1: dvb_usb_v2: found a 'Logilink VG0022A' in warm state
[3.718479] usb 2-1: dvb_usb_v2: will pass the complete MPEG2 transport 
stream to the software demuxer
[3.718544] dvbdev: DVB: registering new adapter (Logilink VG0022A)
[3.720006] usbcore: registered new interface driver usbserial_generic
[3.720018] usbserial: USB Serial support registered for generic
[3.729819] si2168 1-0067: probe failed = -5
[3.729826] si2168: probe of 1-0067 failed with error -5
[3.731138] usbcore: registered new interface driver dvb_usb_af9035
[3.732728] usbcore: registered new interface driver btusb
[3.742576] media: Linux media interface: v0.10

Did I forget something or is it just not working?

Anyway, thanks for your effort. Can we try something else?

g


Gon Solo (1):
  Test Mauros timing patch.

 drivers/media/tuners/si2157.c | 32 ---
 drivers/media/usb/dvb-usb-v2/af9035.c | 14 
 2 files changed, 29 insertions(+), 17 deletions(-)

-- 
2.20.1



[PATCH 1/1] Test Mauros timing patch.

2019-10-03 Thread Gon Solo
Signed-off-by: Gon Solo 
---
 drivers/media/tuners/si2157.c | 32 ---
 drivers/media/usb/dvb-usb-v2/af9035.c | 14 
 2 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index d389f1fc237a..9e20727b7e84 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -75,6 +75,24 @@ static int si2157_cmd_execute(struct i2c_client *client, 
struct si2157_cmd *cmd)
return ret;
 }
 
+static int si2157_power_up(struct si2157_dev *dev, struct i2c_client *client)
+{
+   struct si2157_cmd cmd;
+
+   if (dev->chiptype == SI2157_CHIPTYPE_SI2146) {
+   memcpy(cmd.args, "\xc0\x05\x01\x00\x00\x0b\x00\x00\x01", 9);
+   cmd.wlen = 9;
+   } else if (dev->chiptype == SI2157_CHIPTYPE_SI2141) {
+   memcpy(cmd.args, "\xc0\x00\x0d\x0e\x00\x01\x01\x01\x01\x03", 
10);
+   cmd.wlen = 10;
+   } else {
+   memcpy(cmd.args, 
"\xc0\x00\x0c\x00\x00\x01\x01\x01\x01\x01\x01\x02\x00\x00\x01", 15);
+   cmd.wlen = 15;
+   }
+   cmd.rlen = 1;
+   return si2157_cmd_execute(client, &cmd);
+}
+
 static int si2157_init(struct dvb_frontend *fe)
 {
struct i2c_client *client = fe->tuner_priv;
@@ -102,19 +120,7 @@ static int si2157_init(struct dvb_frontend *fe)
if (uitmp == dev->if_frequency / 1000)
goto warm;
 
-   /* power up */
-   if (dev->chiptype == SI2157_CHIPTYPE_SI2146) {
-   memcpy(cmd.args, "\xc0\x05\x01\x00\x00\x0b\x00\x00\x01", 9);
-   cmd.wlen = 9;
-   } else if (dev->chiptype == SI2157_CHIPTYPE_SI2141) {
-   memcpy(cmd.args, "\xc0\x00\x0d\x0e\x00\x01\x01\x01\x01\x03", 
10);
-   cmd.wlen = 10;
-   } else {
-   memcpy(cmd.args, 
"\xc0\x00\x0c\x00\x00\x01\x01\x01\x01\x01\x01\x02\x00\x00\x01", 15);
-   cmd.wlen = 15;
-   }
-   cmd.rlen = 1;
-   ret = si2157_cmd_execute(client, &cmd);
+   ret = si2157_power_up(dev, client);
if (ret)
goto err;
 
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c 
b/drivers/media/usb/dvb-usb-v2/af9035.c
index 80d3bd3a0f24..c4d4994e0079 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -1207,6 +1207,9 @@ static int af9035_frontend_attach(struct dvb_usb_adapter 
*adap)
return ret;
 }
 
+/* I2C speed register = (10 / (24.4 * 16 * I2C_speed)) */
+#define I2C_SPEED_REGISTER 26
+
 static int it930x_frontend_attach(struct dvb_usb_adapter *adap)
 {
struct state *state = adap_to_priv(adap);
@@ -1575,13 +1578,13 @@ static int it930x_tuner_attach(struct dvb_usb_adapter 
*adap)
 
dev_dbg(&intf->dev, "adap->id=%d\n", adap->id);
 
-   /* I2C master bus 2 clock speed 300k */
-   ret = af9035_wr_reg(d, 0x00f6a7, 0x07);
+   /* I2C master bus 2 clock speed ~100k */
+   ret = af9035_wr_reg(d, 0x00f6a7, I2C_SPEED_REGISTER);
if (ret < 0)
goto err;
 
-   /* I2C master bus 1,3 clock speed 300k */
-   ret = af9035_wr_reg(d, 0x00f103, 0x07);
+   /* I2C master bus 1,3 clock speed ~100k */
+   ret = af9035_wr_reg(d, 0x00f103, I2C_SPEED_REGISTER);
if (ret < 0)
goto err;
 
@@ -2128,6 +2131,9 @@ static const struct usb_device_id af9035_id_table[] = {
/* IT930x devices */
{ DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9303,
&it930x_props, "ITE 9303 Generic", NULL) },
+
+   { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x0100,
+   &it930x_props, "Logilink VG0022A", NULL) },
{ }
 };
 MODULE_DEVICE_TABLE(usb, af9035_id_table);
-- 
2.20.1



[PATCH] si2157: Add support for Logilink VG0022A.

2019-10-02 Thread Gon Solo
---
 drivers/media/tuners/si2157.c | 68 +--
 drivers/media/tuners/si2157_priv.h|  1 +
 drivers/media/usb/dvb-usb-v2/af9035.c | 47 ++
 3 files changed, 90 insertions(+), 26 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index e87040d6eca7..8f9df2485d51 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -66,6 +66,24 @@ static int si2157_cmd_execute(struct i2c_client *client, 
struct si2157_cmd *cmd)
return ret;
 }
 
+static int si2157_power_up(struct si2157_dev *dev, struct i2c_client *client)
+{
+   struct si2157_cmd cmd;
+
+   if (dev->chiptype == SI2157_CHIPTYPE_SI2146) {
+   memcpy(cmd.args, "\xc0\x05\x01\x00\x00\x0b\x00\x00\x01", 9);
+   cmd.wlen = 9;
+   } else if (dev->chiptype == SI2157_CHIPTYPE_SI2141) {
+   memcpy(cmd.args, "\xc0\x00\x0d\x0e\x00\x01\x01\x01\x01\x03", 
10);
+   cmd.wlen = 10;
+   } else {
+   memcpy(cmd.args, 
"\xc0\x00\x0c\x00\x00\x01\x01\x01\x01\x01\x01\x02\x00\x00\x01", 15);
+   cmd.wlen = 15;
+   }
+   cmd.rlen = 1;
+   return si2157_cmd_execute(client, &cmd);
+}
+
 static int si2157_init(struct dvb_frontend *fe)
 {
struct i2c_client *client = fe->tuner_priv;
@@ -75,7 +93,7 @@ static int si2157_init(struct dvb_frontend *fe)
struct si2157_cmd cmd;
const struct firmware *fw;
const char *fw_name;
-   unsigned int uitmp, chip_id;
+   unsigned int uitmp;
 
dev_dbg(&client->dev, "\n");
 
@@ -93,19 +111,7 @@ static int si2157_init(struct dvb_frontend *fe)
if (uitmp == dev->if_frequency / 1000)
goto warm;
 
-   /* power up */
-   if (dev->chiptype == SI2157_CHIPTYPE_SI2146) {
-   memcpy(cmd.args, "\xc0\x05\x01\x00\x00\x0b\x00\x00\x01", 9);
-   cmd.wlen = 9;
-   } else if (dev->chiptype == SI2157_CHIPTYPE_SI2141) {
-   memcpy(cmd.args, "\xc0\x00\x0d\x0e\x00\x01\x01\x01\x01\x03", 
10);
-   cmd.wlen = 10;
-   } else {
-   memcpy(cmd.args, 
"\xc0\x00\x0c\x00\x00\x01\x01\x01\x01\x01\x01\x02\x00\x00\x01", 15);
-   cmd.wlen = 15;
-   }
-   cmd.rlen = 1;
-   ret = si2157_cmd_execute(client, &cmd);
+   ret = si2157_power_up(dev, client);
if (ret)
goto err;
 
@@ -118,17 +124,6 @@ static int si2157_init(struct dvb_frontend *fe)
goto err;
}
 
-   /* query chip revision */
-   memcpy(cmd.args, "\x02", 1);
-   cmd.wlen = 1;
-   cmd.rlen = 13;
-   ret = si2157_cmd_execute(client, &cmd);
-   if (ret)
-   goto err;
-
-   chip_id = cmd.args[1] << 24 | cmd.args[2] << 16 | cmd.args[3] << 8 |
-   cmd.args[4] << 0;
-
#define SI2177_A30 ('A' << 24 | 77 << 16 | '3' << 8 | '0' << 0)
#define SI2158_A20 ('A' << 24 | 58 << 16 | '2' << 8 | '0' << 0)
#define SI2148_A20 ('A' << 24 | 48 << 16 | '2' << 8 | '0' << 0)
@@ -137,7 +132,7 @@ static int si2157_init(struct dvb_frontend *fe)
#define SI2146_A10 ('A' << 24 | 46 << 16 | '1' << 8 | '0' << 0)
#define SI2141_A10 ('A' << 24 | 41 << 16 | '1' << 8 | '0' << 0)
 
-   switch (chip_id) {
+   switch (dev->chip_id) {
case SI2158_A20:
case SI2148_A20:
fw_name = SI2158_A20_FIRMWARE;
@@ -456,6 +451,27 @@ static int si2157_probe(struct i2c_client *client,
memcpy(&fe->ops.tuner_ops, &si2157_ops, sizeof(struct dvb_tuner_ops));
fe->tuner_priv = client;
 
+   ret = si2157_power_up(dev, client);
+   if (ret)
+   goto err;
+   /* query chip revision */
+   /* hack: do it here because after the si2168 gets 0101, commands will
+* still be executed here but no result
+*/
+   memcpy(cmd.args, "\x02", 1);
+   cmd.wlen = 1;
+   cmd.rlen = 13;
+   ret = si2157_cmd_execute(client, &cmd);
+   if (ret)
+   goto err_kfree;
+   dev->chip_id = cmd.args[1] << 24 |
+   cmd.args[2] << 16 |
+   cmd.args[3] << 8 |
+   cmd.args[4] << 0;
+   dev_info(&client->dev, "found a 'Silicon Labs Si21%d-%c%c%c'\n",
+   cmd.args[2], cmd.args[1], cmd.args[3], cmd.args[4]);
+
+
 #ifdef CONFIG_MEDIA_CONTROLLER
if (cfg->mdev) {
dev->mdev = cfg->mdev;
diff --git a/drivers/media/tuners/si2157_priv.h 
b/drivers/media/tuners/si2157_priv.h
index 2bda903358da..9ab7c88b01b4 100644
--- a/drivers/media/tuners/si2157_priv.h
+++ b/drivers/media/tuners/si2157_priv.h
@@ -28,6 +28,7 @@ struct si2157_dev {
u8 chiptype;
u8 if_port;
u32 if_frequency;
+   u32 chip_id;
struct delayed_work stat_work;
 
 #if defined(CONFIG_MEDIA_CONTROLLER)
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c 
b/drivers/media/usb/dvb-usb-v2/af9035.c
index 3afd18

[PATCH] si2157: Add support for Logilink VG0022A.

2019-10-02 Thread Gon Solo
Dear Mauro!

Thanks for your reply, I tried to address most of your concerns,
so please bear with me (especially this is my first email with
git send-email). :)

> First of all, don't attach a patch. Instead, just send it with a decent
> emailer (with won't mangle whitespaces) or use git send-email...

Done.

> You shouldn't just blindly comment out some code, as this will very likely
> break support for all other devices supported by the driver...

Done. I extracted power_up into its own function, chip querying is now
done in probe. I don't have enough knowledge about hardware to do the
right thing on my own. If there is anybody willing to guide me I will
spend some time on it.

The original patch where the problem is discussed is
https://lkml.kernel.org/lkml/1489616530-4025-1-git-send-email-andr...@kemnade.info

> ... yet, looking on what you've done, it seems that you're actually
> adding support for a different tuner at the si2157 driver.
> If this is the case, this should be on a separate patch, and in a way
> that it will become clear that it won't break support for any existing
> device.

I'm not entirely sure how to split this up. Can you give some advice?

> Why did you do such change? dev_dbg can already print the function, and
> much more. See:

Thanks for the link. I removed these lines.

> The above seems specific for your device. You need to check if the device
> is USB_VID_DEXATEK, running the code only on such case.

Done. Though I'm not sure whether I did it the right way.

Thanks for all the advice, I hope this will be included eventually.
g