Re: [PATCH 2/3] [media] af9035: init i2c already in it930x_frontend_attach

2017-05-04 Thread Andreas Kemnade
On Wed, 15 Mar 2017 23:22:09 +0100
Andreas Kemnade  wrote:

> i2c bus is already needed when the frontend is probed,
> so init it already in it930x_frontend_attach
> That prevents errors like
>  si2168: probe of 6-0067 failed with error -5
> 
> Signed-off-by: Andreas Kemnade 

seems to be also needed for the
CINERGY TC2 Stick
Quoting from 
https://www.linuxmintusers.de/index.php?topic=41074.30

Mar 26 12:44:14 minimoose kernel: [  732.884876] usb 1-3: dvb_usb_v2: found a 
'TerraTec Cinergy TC2 Stick' in warm state
Mar 26 12:44:14 minimoose kernel: [  732.885012] usb 1-3: dvb_usb_v2: will pass 
the complete MPEG2 transport stream to the software demuxer
Mar 26 12:44:14 minimoose kernel: [  732.885245] dvbdev: DVB: registering new 
adapter (TerraTec Cinergy TC2 Stick)
Mar 26 12:44:14 minimoose kernel: [  732.885254] usb 1-3: media controller 
created
Mar 26 12:44:14 minimoose kernel: [  732.886117] dvbdev: 
dvb_create_media_entity: media entity 'dvb-demux' registered.
Mar 26 12:44:14 minimoose kernel: [  732.890589] si2168: probe of 8-0067 failed 
with error -5


Regards,
Andreas Kemnade


pgpF5dcxduV9N.pgp
Description: OpenPGP digital signature


Re: [PATCH 1/3] [media] si2157: get chip id during probing

2017-05-15 Thread Andreas Kemnade
Hi,

On Sun, 23 Apr 2017 15:19:21 +0300
Antti Palosaari  wrote:

> On 03/16/2017 12:22 AM, Andreas Kemnade wrote:
> > If the si2157 is behind a e.g. si2168, the si2157 will
> > at least in some situations not be readable after the si268
> > got the command 0101. It still accepts commands but the answer
> > is just ff. So read the chip id before that so the
> > information is not lost.
> > 
> > The following line in kernel output is a symptome
> > of that problem:
> > si2157 7-0063: unknown chip version Si21255-\x\x\x
> That is hackish solution :( Somehow I2C reads should be get working 
> rather than making this kind of work-around. Returning 0xff to i2c reads 
> means that signal strength also shows some wrong static value?
> 
Also this is needed for the Terratec CinergyTC2.
I see the ff even on windows. So it cannot be solved by usb-sniffing of
a working system, so, again how should we proceed?

a) not support dvb sticks which do not work with your preferred
   order of initialization.

b) change order of initialisation (maybe optionally add a flag like
   INIT_TUNER_BEFORE_DEMOD to avoid risk of breaking other things)

c) something like the current patch.

d) while(!i2c_readable(tuner)) {
 write_random_data_to_demod();
 write_random_data_it9306_bridge();
   }
   remember_random_data();


There was not much feedback here.

An excerpt from my windows sniff logs:
ep: 02 l:   15 GEN_I2C_WR 00 0603c61201
ep: 02 l:0
ep: 81 l:0
ep: 81 l:5 042300dcff
ep: 02 l:9 GEN_I2C_RD 00 0603c6
ep: 02 l:0
ep: 81 l:0
ep: 81 l:   11 0a240080ff5b02
ep: 02 l:   15 GEN_I2C_WR 00 0603c6140011070300
ep: 02 l:0
ep: 81 l:0
ep: 81 l:5 042500daff
ep: 02 l:9 GEN_I2C_RD 00 0403c6
ep: 02 l:0
ep: 81 l:0
ep: 81 l:9 08260080ff5901

here you see all the  from the device.



Regards,
Andreas


pgpDyMS3sfzP5.pgp
Description: OpenPGP digital signature


[PATCH RFC] dvb: af9035.c: Logilink vg0022a to device id table

2017-03-09 Thread Andreas Kemnade
Ths adds the logilink VG00022a dvb-t dongle to the device table.
The dongle contains (checked by removing the case)
IT9303
SI2168
  214730

The result is in cold state:

 usb 1-6: new high-speed USB device number 15 using xhci_hcd
 usb 1-6: New USB device found, idVendor=1d19, idProduct=0100
 usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
 usb 1-6: Product: TS Aggregator
 usb 1-6: Manufacturer: ITE Tech., Inc.
 usb 1-6: SerialNumber: 
 dvb_usb_af9035 1-6:1.0: prechip_version=83 chip_version=01 chip_type=9306
 dvb_usb_af9035 1-6:1.0: ts mode=5 not supported, defaulting to single tuner 
mode!
 usb 1-6: dvb_usb_v2: found a 'Logilink VG0022A' in cold state
 usb 1-6: dvb_usb_v2: downloading firmware from file 'dvb-usb-it9303-01.fw'
 dvb_usb_af9035 1-6:1.0: firmware version=1.4.0.0
 usb 1-6: dvb_usb_v2: found a 'Logilink VG0022A' in warm state
 usb 1-6: dvb_usb_v2: will pass the complete MPEG2 transport stream to the 
software demuxer
 dvbdev: DVB: registering new adapter (Logilink VG0022A)
 si2168: probe of 6-0067 failed with error -5

when warmed up by connecing it via  a powered usb hub to win7 and
then attaching the same usb hub to a linux machine:

 usb 1-6.2: New USB device found, idVendor=1d19, idProduct=0100
 usb 1-6.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
 usb 1-6.2: Product: TS Aggregator
 usb 1-6.2: Manufacturer: ITE Tech., Inc.
 usb 1-6.2: SerialNumber: 
 dvb_usb_af9035 1-6.2:1.0: prechip_version=83 chip_version=01 chip_type=9306
 dvb_usb_af9035 1-6.2:1.0: ts mode=5 not supported, defaulting to single tuner 
mode!
 usb 1-6.2: dvb_usb_v2: found a 'Logilink VG0022A' in warm state
 usb 1-6.2: dvb_usb_v2: will pass the complete MPEG2 transport stream to the 
software demuxer
 dvbdev: DVB: registering new adapter (Logilink VG0022A)
 i2c i2c-6: Added multiplexed i2c bus 7
 si2168 6-0067: Silicon Labs Si2168-B40 successfully identified
 si2168 6-0067: firmware version: B 4.0.2
 usb 1-6.2: DVB: registering adapter 0 frontend 0 (Silicon Labs Si2168)...
 si2157 7-0063: Silicon Labs Si2147/2148/2157/2158 successfully attached
 usb 1-6.2: dvb_usb_v2: 'Logilink VG0022A' successfully initialized and 
connected
 si2168 6-0067: Direct firmware load for dvb-demod-si2168-b40-01.fw failed with 
error -2
 si2168 6-0067: Direct firmware load for dvb-demod-si2168-02.fw failed with 
error -2
 si2168 6-0067: firmware file 'dvb-demod-si2168-02.fw' not found
 si2157 7-0063: found a 'Silicon Labs Si2147-A30'
 si2157 7-0063: firmware version: 3.0.5

same with the firmware for the si2168 available:
 usb 1-6.2: new high-speed USB device number 12 using xhci_hcd
 usb 1-6.2: New USB device found, idVendor=1d19, idProduct=0100
 usb 1-6.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
 usb 1-6.2: Product: TS Aggregator
 usb 1-6.2: Manufacturer: ITE Tech., Inc.
 usb 1-6.2: SerialNumber: 
 dvb_usb_af9035 1-6.2:1.0: prechip_version=83 chip_version=01 chip_type=9306
 dvb_usb_af9035 1-6.2:1.0: ts mode=5 not supported, defaulting to single tuner 
mode!
 usb 1-6.2: dvb_usb_v2: found a 'Logilink VG0022A' in warm state
 usb 1-6.2: dvb_usb_v2: will pass the complete MPEG2 transport stream to the 
software demuxer
 dvbdev: DVB: registering new adapter (Logilink VG0022A)
 i2c i2c-6: Added multiplexed i2c bus 7
 si2168 6-0067: Silicon Labs Si2168-B40 successfully identified
 si2168 6-0067: firmware version: B 4.0.2
 usb 1-6.2: DVB: registering adapter 0 frontend 0 (Silicon Labs Si2168)...
 si2157 7-0063: Silicon Labs Si2147/2148/2157/2158 successfully attached
 usb 1-6.2: dvb_usb_v2: 'Logilink VG0022A' successfully initialized and 
connected
 si2168 6-0067: downloading firmware from file 'dvb-demod-si2168-b40-01.fw'
 si2168 6-0067: firmware version: B 4.0.11
 si2157 7-0063: unknown chip version Si21255-\x\x\x
 si2157 7-0063: unknown chip version Si21255-\xffff\xffff\xffff

so firmware uploading to the si2168 somehow messes things up

Signed-off-by: Andreas Kemnade 
---
 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 c673726..ed674b8 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -2141,6 +2141,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) },
{ }
 };
 MODULE_DEVICE_TABLE(usb, af9035_id_table);
-- 
2.1.4



Re: [PATCH RFC] dvb: af9035.c: Logilink vg0022a to device id table

2017-03-13 Thread Andreas Kemnade
On Thu,  9 Mar 2017 17:51:14 +0100
Andreas Kemnade  wrote:

> Ths adds the logilink VG00022a dvb-t dongle to the device table.
> The dongle contains (checked by removing the case)
> IT9303
> SI2168
>   214730
> 
> The result is in cold state:
> 
>  usb 1-6: new high-speed USB device number 15 using xhci_hcd
>  usb 1-6: New USB device found, idVendor=1d19, idProduct=0100
>  usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
>  usb 1-6: Product: TS Aggregator
>  usb 1-6: Manufacturer: ITE Tech., Inc.
>  usb 1-6: SerialNumber: 
>  dvb_usb_af9035 1-6:1.0: prechip_version=83 chip_version=01 chip_type=9306
>  dvb_usb_af9035 1-6:1.0: ts mode=5 not supported, defaulting to single tuner 
> mode!
>  usb 1-6: dvb_usb_v2: found a 'Logilink VG0022A' in cold state
>  usb 1-6: dvb_usb_v2: downloading firmware from file 'dvb-usb-it9303-01.fw'
>  dvb_usb_af9035 1-6:1.0: firmware version=1.4.0.0
>  usb 1-6: dvb_usb_v2: found a 'Logilink VG0022A' in warm state
>  usb 1-6: dvb_usb_v2: will pass the complete MPEG2 transport stream to the 
> software demuxer
>  dvbdev: DVB: registering new adapter (Logilink VG0022A)
>  si2168: probe of 6-0067 failed with error -5
> 
> when warmed up by connecing it via  a powered usb hub to win7 and
> then attaching the same usb hub to a linux machine:
> 
with some fixes in af9035.c I already get the same state as with warm
up by win7. I just need to find out which changes are really necessary
and convert it into a clean patch.

> so firmware uploading to the si2168 somehow messes things up
> 
I experimented a lot here and I found this:
If 0101 is not sent to the si2168 you can get answers from the
Si2147-A30. 
After the 0101 is sent to the si2147-A30 it will still execute
commands but you will not get the answer back through the si2168.
You just get ff.

After moving the chip id readout from si2157_init to si2157_probe,
scanning for stations works. So the si2147-A30 seems to react on
commands. 

Regards,
Andreas Kemnade


pgp27dH4ipAAt.pgp
Description: OpenPGP digital signature


[PATCH 2/3] [media] af9035: init i2c already in it930x_frontend_attach

2017-03-15 Thread Andreas Kemnade
i2c bus is already needed when the frontend is probed,
so init it already in it930x_frontend_attach
That prevents errors like
 si2168: probe of 6-0067 failed with error -5

Signed-off-by: Andreas Kemnade 
---
 drivers/media/usb/dvb-usb-v2/af9035.c | 43 ++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c 
b/drivers/media/usb/dvb-usb-v2/af9035.c
index 4df9486..a95f4b2 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -1214,8 +1214,49 @@ static int it930x_frontend_attach(struct dvb_usb_adapter 
*adap)
struct si2168_config si2168_config;
struct i2c_adapter *adapter;
 
-   dev_dbg(&intf->dev, "adap->id=%d\n", adap->id);
+   dev_dbg(&intf->dev, "%s  adap->id=%d\n", __func__, adap->id);
+
+   /* I2C master bus 2 clock speed 300k */
+   ret = af9035_wr_reg(d, 0x00f6a7, 0x07);
+   if (ret < 0)
+   goto err;
+
+   /* I2C master bus 1,3 clock speed 300k */
+   ret = af9035_wr_reg(d, 0x00f103, 0x07);
+   if (ret < 0)
+   goto err;
+
+   /* set gpio11 low */
+   ret = af9035_wr_reg_mask(d, 0xd8d4, 0x01, 0x01);
+   if (ret < 0)
+   goto err;
+
+   ret = af9035_wr_reg_mask(d, 0xd8d5, 0x01, 0x01);
+   if (ret < 0)
+   goto err;
+
+   ret = af9035_wr_reg_mask(d, 0xd8d3, 0x01, 0x01);
+   if (ret < 0)
+   goto err;
 
+   /* Tuner enable using gpiot2_en, gpiot2_on and gpiot2_o (reset) */
+   ret = af9035_wr_reg_mask(d, 0xd8b8, 0x01, 0x01);
+   if (ret < 0)
+   goto err;
+
+   ret = af9035_wr_reg_mask(d, 0xd8b9, 0x01, 0x01);
+   if (ret < 0)
+   goto err;
+
+   ret = af9035_wr_reg_mask(d, 0xd8b7, 0x00, 0x01);
+   if (ret < 0)
+   goto err;
+
+   msleep(200);
+
+   ret = af9035_wr_reg_mask(d, 0xd8b7, 0x01, 0x01);
+   if (ret < 0)
+   goto err;
memset(&si2168_config, 0, sizeof(si2168_config));
si2168_config.i2c_adapter = &adapter;
si2168_config.fe = &adap->fe[0];
-- 
2.1.4



[PATCH 0/3] support for Logilink VG0022a DVB-T2 stick

2017-03-15 Thread Andreas Kemnade
Hi all,
here are some patches needed for supporting the
Logilink VG0022A DVB-T2 stick.
As the combination of chips in that stick is not
uncommon, the first two patches might also fix problems
for similar hardware.

Andreas Kemnade (3):
  [media] si2157: get chip id during probing
  [media] af9035: init i2c already in it930x_frontend_attach
  [media] af9035: add Logilink vg0022a to device id table

 drivers/media/tuners/si2157.c | 54 +--
 drivers/media/tuners/si2157_priv.h|  7 +
 drivers/media/usb/dvb-usb-v2/af9035.c | 45 -
 3 files changed, 83 insertions(+), 23 deletions(-)

-- 
2.1.4



[PATCH 3/3] [media] af9035: add Logilink vg0022a to device id table

2017-03-15 Thread Andreas Kemnade
Ths adds the logilink VG00022a dvb-t dongle to the device table.
The dongle contains (checked by removing the case)
IT9303
SI2168
  214730

Signed-off-by: Andreas Kemnade 
---
 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 a95f4b2..db93e59 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -2165,6 +2165,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) },
{ }
 };
 MODULE_DEVICE_TABLE(usb, af9035_id_table);
-- 
2.1.4



[PATCH 1/3] [media] si2157: get chip id during probing

2017-03-15 Thread Andreas Kemnade
If the si2157 is behind a e.g. si2168, the si2157 will
at least in some situations not be readable after the si268
got the command 0101. It still accepts commands but the answer
is just ff. So read the chip id before that so the
information is not lost.

The following line in kernel output is a symptome
of that problem:
si2157 7-0063: unknown chip version Si21255-\x\x\x

Signed-off-by: Andreas Kemnade 
---
 drivers/media/tuners/si2157.c  | 54 ++
 drivers/media/tuners/si2157_priv.h |  7 +
 2 files changed, 39 insertions(+), 22 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index 57b2508..0da7a33 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -84,7 +84,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");
 
@@ -115,24 +115,7 @@ static int si2157_init(struct dvb_frontend *fe)
if (ret)
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 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)
-
-   switch (chip_id) {
+   switch (dev->chip_id) {
case SI2158_A20:
case SI2148_A20:
fw_name = SI2158_A20_FIRMWARE;
@@ -150,9 +133,6 @@ static int si2157_init(struct dvb_frontend *fe)
goto err;
}
 
-   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]);
-
if (fw_name == NULL)
goto skip_fw_download;
 
@@ -444,6 +424,36 @@ static int si2157_probe(struct i2c_client *client,
 
memcpy(&fe->ops.tuner_ops, &si2157_ops, sizeof(struct dvb_tuner_ops));
fe->tuner_priv = client;
+   /* 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 {
+   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);
+   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) {
diff --git a/drivers/media/tuners/si2157_priv.h 
b/drivers/media/tuners/si2157_priv.h
index d6b2c7b..54c1a856 100644
--- a/drivers/media/tuners/si2157_priv.h
+++ b/drivers/media/tuners/si2157_priv.h
@@ -30,6 +30,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)
@@ -43,6 +44,12 @@ struct si2157_dev {
 #define SI2157_CHIPTYPE_SI2157 0
 #define SI2157_CHIPTYPE_SI2146 1
 
+#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)
+
 /* firmware command struct */
 #define SI2157_ARGLEN  30
 struct si2157_cmd {
-- 
2.1.4



Re: [PATCH 0/3] support for Logilink VG0022a DVB-T2 stick

2017-04-10 Thread Andreas Kemnade
ping

On Wed, 15 Mar 2017 23:22:07 +0100
Andreas Kemnade  wrote:

> Hi all,
> here are some patches needed for supporting the
> Logilink VG0022A DVB-T2 stick.
> As the combination of chips in that stick is not
> uncommon, the first two patches might also fix problems
> for similar hardware.
> 
> Andreas Kemnade (3):
>   [media] si2157: get chip id during probing
>   [media] af9035: init i2c already in it930x_frontend_attach
>   [media] af9035: add Logilink vg0022a to device id table
> 
>  drivers/media/tuners/si2157.c | 54 
> +--
>  drivers/media/tuners/si2157_priv.h|  7 +
>  drivers/media/usb/dvb-usb-v2/af9035.c | 45 -
>  3 files changed, 83 insertions(+), 23 deletions(-)
> 



pgpWXfZ3ZwVSm.pgp
Description: OpenPGP digital signature


Re: [PATCH 1/3] [media] si2157: get chip id during probing

2017-04-23 Thread Andreas Kemnade
On Sun, 23 Apr 2017 15:19:21 +0300
Antti Palosaari  wrote:

> On 03/16/2017 12:22 AM, Andreas Kemnade wrote:
> > If the si2157 is behind a e.g. si2168, the si2157 will
> > at least in some situations not be readable after the si268
> > got the command 0101. It still accepts commands but the answer
> > is just ff. So read the chip id before that so the
> > information is not lost.
> > 
> > The following line in kernel output is a symptome
> > of that problem:
> > si2157 7-0063: unknown chip version Si21255-\x\x\x
> That is hackish solution :( Somehow I2C reads should be get working 
> rather than making this kind of work-around. Returning 0xff to i2c reads 
> means that signal strength also shows some wrong static value?
> 
dvb-fe-tool -m is like this:

Lock   (0x1f) Signal= -1.00dBm C/N= 19.25dB UCB= 6061140 postBER= 40.0x10^-6

Signal strength is static.

Yes, I do not like my solution, too.
Also i2c reads from the windows driver from the si2157 after that 0101
command give such problems. I have checked my usb logs again.
So the question is where a better solution can come from.
I do not find a proper datasheet of the si2157 or the si2168.

Just for reference: the stick is labeled VG0022a.
The usb strings are like that:
  idVendor   0x1d19 Dexatek Technology Ltd.
  idProduct  0x0100 
  bcdDevice1.00
  iManufacturer   1 ITE Tech., Inc.
  iProduct2 TS Aggregator
  iSerial 3 AF010202071

if that may lead to some information.

Regards,
Andreas


pgpxIyxmq9Vjg.pgp
Description: OpenPGP digital signature


[PATCH RFC] media: omap3isp: Fix high idle current

2019-01-09 Thread Andreas Kemnade
On the GTA04, current consumption rose by about 30mA when the omap3_isp
module was loaded and the v4l device was not accessed and even no
camera attached.
Module removal fixed it again. Slowing down the removal process reveals
that calling isp_detach_iommu() is required to have low
current. So isp_attach/detach_iommu() to moved to the get()/put()
functions.
This all has strange side effects. The hwmod seems to be accessible
using /dev/mem if the iommu calls in their original place. With
the modified placement it is not.
In a very old setup with a 3.7 kernel which
has the iommu calls at the same place as our current kernel,
the memory is not accessible.
Note: isp_get()/put() calls seem to be balanced.

But at the current wonky gta04 setup (with a not upstreamed
image sensor driver)which also has other problems, CAM
reports address holes. So I have no clear idea whether this patch
is right or not.

Signed-off-by: Andreas Kemnade 
---
 drivers/media/platform/omap3isp/isp.c | 28 +++-
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/media/platform/omap3isp/isp.c 
b/drivers/media/platform/omap3isp/isp.c
index 13f2828d880d..b837ca5604ad 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -88,6 +88,10 @@ static void isp_save_ctx(struct isp_device *isp);
 
 static void isp_restore_ctx(struct isp_device *isp);
 
+static int isp_attach_iommu(struct isp_device *isp);
+
+static void isp_detach_iommu(struct isp_device *isp);
+
 static const struct isp_res_mapping isp_res_maps[] = {
{
.isp_rev = ISP_REVISION_2_0,
@@ -1407,6 +1411,14 @@ static struct isp_device *__omap3isp_get(struct 
isp_device *isp, bool irq)
__isp = NULL;
goto out;
}
+   /* IOMMU */
+   if (isp_attach_iommu(isp) < 0) {
+   dev_err(isp->dev, "unable to attach to IOMMU\n");
+   isp_disable_clocks(isp);
+   __isp = NULL;
+   goto out;
+   }
+
 
/* We don't want to restore context before saving it! */
if (isp->has_context)
@@ -1453,6 +1465,7 @@ static void __omap3isp_put(struct isp_device *isp, bool 
save_ctx)
if (!media_entity_enum_empty(&isp->crashed) ||
isp->stop_failure)
isp_reset(isp);
+   isp_detach_iommu(isp);
isp_disable_clocks(isp);
}
mutex_unlock(&isp->isp_mutex);
@@ -1999,10 +2012,6 @@ static int isp_remove(struct platform_device *pdev)
isp_cleanup_modules(isp);
isp_xclk_cleanup(isp);
 
-   __omap3isp_get(isp, false);
-   isp_detach_iommu(isp);
-   __omap3isp_put(isp, false);
-
media_entity_enum_cleanup(&isp->crashed);
v4l2_async_notifier_cleanup(&isp->notifier);
 
@@ -2313,19 +2322,12 @@ static int isp_probe(struct platform_device *pdev)
isp->mmio_hist_base_phys =
mem->start + isp_res_maps[m].offset[OMAP3_ISP_IOMEM_HIST];
 
-   /* IOMMU */
-   ret = isp_attach_iommu(isp);
-   if (ret < 0) {
-   dev_err(&pdev->dev, "unable to attach to IOMMU\n");
-   goto error_isp;
-   }
-
/* Interrupt */
ret = platform_get_irq(pdev, 0);
if (ret <= 0) {
dev_err(isp->dev, "No IRQ resource\n");
ret = -ENODEV;
-   goto error_iommu;
+   goto error_isp;
}
isp->irq_num = ret;
 
@@ -2339,7 +2341,7 @@ static int isp_probe(struct platform_device *pdev)
/* Entities */
ret = isp_initialize_modules(isp);
if (ret < 0)
-   goto error_iommu;
+   goto error_isp;
 
ret = isp_register_entities(isp);
if (ret < 0)
-- 
2.11.0



Re: [PATCH V3 1/2] init i2c already in it930x_frontend_attach

2019-03-05 Thread Andreas Kemnade
Hi Jose,

On Tue, 05 Mar 2019 19:37:25 +0100
Jose Alberto Reguero  wrote:

> i2c bus is already needed when the frontend is probed, so init it already in 
> it930x_frontend_attach.That prevents errors like
> si2168: probe of 6-0067 failed with error -5
> 
> Andreas, can I have your Signed-off-by?
> 
ok, it was already there, but again:

Signed-off-by: Andreas Kemnade 

> 
> From: Andreas Kemnade 
> Signed-off-by: Jose Alberto Reguero 
> 
> diff -upr linux/drivers/media/usb/dvb-usb-v2/af9035.c 
> linux.new/drivers/media/usb/dvb-usb-v2/af9035.c
> --- linux/drivers/media/usb/dvb-usb-v2/af9035.c   2018-09-12 
> 07:40:12.0 +0200
> +++ linux.new/drivers/media/usb/dvb-usb-v2/af9035.c   2019-02-20 
> 16:45:17.467869437 +0100
> @@ -1218,6 +1218,48 @@ static int it930x_frontend_attach(struct
>  
>   dev_dbg(&intf->dev, "adap->id=%d\n", adap->id);
>  
> + /* I2C master bus 2 clock speed 300k */
> + ret = af9035_wr_reg(d, 0x00f6a7, 0x07);
> + if (ret < 0)
> + goto err;
> +
> + /* I2C master bus 1,3 clock speed 300k */
> + ret = af9035_wr_reg(d, 0x00f103, 0x07);
> + if (ret < 0)
> + goto err;
> +
> + /* set gpio11 low */
> + ret = af9035_wr_reg_mask(d, 0xd8d4, 0x01, 0x01);
> + if (ret < 0)
> + goto err;
> +
> + ret = af9035_wr_reg_mask(d, 0xd8d5, 0x01, 0x01);
> + if (ret < 0)
> + goto err;
> +
> + ret = af9035_wr_reg_mask(d, 0xd8d3, 0x01, 0x01);
> + if (ret < 0)
> + goto err;
> +
> + /* Tuner enable using gpiot2_en, gpiot2_on and gpiot2_o (reset) */
> + ret = af9035_wr_reg_mask(d, 0xd8b8, 0x01, 0x01);
> + if (ret < 0)
> + goto err;
> +
> + ret = af9035_wr_reg_mask(d, 0xd8b9, 0x01, 0x01);
> + if (ret < 0)
> + goto err;
> +
> + ret = af9035_wr_reg_mask(d, 0xd8b7, 0x00, 0x01);
> + if (ret < 0)
> + goto err;
> +
> + msleep(200);
> +
> + ret = af9035_wr_reg_mask(d, 0xd8b7, 0x01, 0x01);
> + if (ret < 0)
> + goto err;
> +
>   memset(&si2168_config, 0, sizeof(si2168_config));
>   si2168_config.i2c_adapter = &adapter;
>   si2168_config.fe = &adap->fe[0];
> @@ -1575,48 +1617,6 @@ static int it930x_tuner_attach(struct dv
>  
>   dev_dbg(&intf->dev, "adap->id=%d\n", adap->id);
>  
> - /* I2C master bus 2 clock speed 300k */
> - ret = af9035_wr_reg(d, 0x00f6a7, 0x07);
> - if (ret < 0)
> - goto err;
> -
> - /* I2C master bus 1,3 clock speed 300k */
> - ret = af9035_wr_reg(d, 0x00f103, 0x07);
> - if (ret < 0)
> - goto err;
> -
> - /* set gpio11 low */
> - ret = af9035_wr_reg_mask(d, 0xd8d4, 0x01, 0x01);
> - if (ret < 0)
> - goto err;
> -
> - ret = af9035_wr_reg_mask(d, 0xd8d5, 0x01, 0x01);
> - if (ret < 0)
> - goto err;
> -
> - ret = af9035_wr_reg_mask(d, 0xd8d3, 0x01, 0x01);
> - if (ret < 0)
> - goto err;
> -
> - /* Tuner enable using gpiot2_en, gpiot2_on and gpiot2_o (reset) */
> - ret = af9035_wr_reg_mask(d, 0xd8b8, 0x01, 0x01);
> - if (ret < 0)
> - goto err;
> -
> - ret = af9035_wr_reg_mask(d, 0xd8b9, 0x01, 0x01);
> - if (ret < 0)
> - goto err;
> -
> - ret = af9035_wr_reg_mask(d, 0xd8b7, 0x00, 0x01);
> - if (ret < 0)
> - goto err;
> -
> - msleep(200);
> -
> - ret = af9035_wr_reg_mask(d, 0xd8b7, 0x01, 0x01);
> - if (ret < 0)
> - goto err;
> -
>   memset(&si2157_config, 0, sizeof(si2157_config));
>   si2157_config.fe = adap->fe[0];
>   si2157_config.if_port = 1;
> 



pgpvWnrHMxt4r.pgp
Description: OpenPGP digital signature