* [PATCH 0/2] tuner-xc2028: Fix xc3028 timeouts
@ 2014-01-06 10:01 Mauro Carvalho Chehab
2014-01-06 10:01 ` [PATCH 1/2] tuner-xc2028: Don't try to sleep twice Mauro Carvalho Chehab
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2014-01-06 10:01 UTC (permalink / raw)
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab
When xc2028/3028 is powered down, it won't response to any command, until
a firmware is loaded. That means that reading frontend status will fail
with a timeout.
Also, any trial to put the device to sleep twice will fail.
This small series fix those two bugs.
Mauro Carvalho Chehab (2):
tuner-xc2028: Don't try to sleep twice
tuner-xc2028: Don't read status if device is powered down
drivers/media/tuners/tuner-xc2028.c | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
--
1.8.3.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] tuner-xc2028: Don't try to sleep twice
2014-01-06 10:01 [PATCH 0/2] tuner-xc2028: Fix xc3028 timeouts Mauro Carvalho Chehab
@ 2014-01-06 10:01 ` Mauro Carvalho Chehab
2014-01-06 10:01 ` [PATCH 2/2] tuner-xc2028: Don't read status if device is powered down Mauro Carvalho Chehab
2014-01-06 16:15 ` [PATCH 0/2] tuner-xc2028: Fix xc3028 timeouts Mauro Carvalho Chehab
2 siblings, 0 replies; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2014-01-06 10:01 UTC (permalink / raw)
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab
Only send a power down command for the device if it is not already
in power down state. That prevents a timeout when trying to talk
with the device.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
---
drivers/media/tuners/tuner-xc2028.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/media/tuners/tuner-xc2028.c b/drivers/media/tuners/tuner-xc2028.c
index 1057da54c6e0..75afab718ba6 100644
--- a/drivers/media/tuners/tuner-xc2028.c
+++ b/drivers/media/tuners/tuner-xc2028.c
@@ -709,6 +709,8 @@ static int load_scode(struct dvb_frontend *fe, unsigned int type,
return 0;
}
+static int xc2028_sleep(struct dvb_frontend *fe);
+
static int check_firmware(struct dvb_frontend *fe, unsigned int type,
v4l2_std_id std, __u16 int_freq)
{
@@ -881,7 +883,7 @@ read_not_reliable:
return 0;
fail:
- priv->state = XC2028_SLEEP;
+ priv->state = XC2028_NO_FIRMWARE;
memset(&priv->cur_fw, 0, sizeof(priv->cur_fw));
if (retry_count < 8) {
@@ -891,6 +893,9 @@ fail:
goto retry;
}
+ /* Firmware didn't load. Put the device to sleep */
+ xc2028_sleep(fe);
+
if (rc == -ENOENT)
rc = -EINVAL;
return rc;
@@ -1276,6 +1281,10 @@ static int xc2028_sleep(struct dvb_frontend *fe)
if (no_poweroff || priv->ctrl.disable_power_mgmt)
return 0;
+ /* Device is already in sleep mode */
+ if (priv->state == XC2028_SLEEP)
+ return 0;
+
tuner_dbg("Putting xc2028/3028 into poweroff mode.\n");
if (debug > 1) {
tuner_dbg("Printing sleep stack trace:\n");
@@ -1289,7 +1298,8 @@ static int xc2028_sleep(struct dvb_frontend *fe)
else
rc = send_seq(priv, {0x80, XREG_POWER_DOWN, 0x00, 0x00});
- priv->state = XC2028_SLEEP;
+ if (rc >= 0)
+ priv->state = XC2028_SLEEP;
mutex_unlock(&priv->lock);
@@ -1357,7 +1367,7 @@ static void load_firmware_cb(const struct firmware *fw,
if (rc < 0)
return;
- priv->state = XC2028_SLEEP;
+ priv->state = XC2028_ACTIVE;
}
static int xc2028_set_config(struct dvb_frontend *fe, void *priv_cfg)
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] tuner-xc2028: Don't read status if device is powered down
2014-01-06 10:01 [PATCH 0/2] tuner-xc2028: Fix xc3028 timeouts Mauro Carvalho Chehab
2014-01-06 10:01 ` [PATCH 1/2] tuner-xc2028: Don't try to sleep twice Mauro Carvalho Chehab
@ 2014-01-06 10:01 ` Mauro Carvalho Chehab
2014-01-06 16:15 ` [PATCH 0/2] tuner-xc2028: Fix xc3028 timeouts Mauro Carvalho Chehab
2 siblings, 0 replies; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2014-01-06 10:01 UTC (permalink / raw)
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab
That removes those timeout errors:
[ 3675.930940] xc2028 19-0061: Device is Xceive 3028 version 1.0, firmware version 2.7
[ 3676.060487] xc2028 19-0061: divisor= 00 00 8d d0 (freq=567.250)
[ 3676.349449] xc2028 19-0061: Putting xc2028/3028 into poweroff mode.
[ 3698.247645] xc2028 19-0061: xc2028_get_reg 0002 called
[ 3698.253276] em2860 #0: I2C transfer timeout on writing to addr 0xc2
[ 3698.253301] xc2028 19-0061: i2c input error: rc = -121 (should be 2)
[ 3698.253327] xc2028 19-0061: xc2028_signal called
[ 3698.253339] xc2028 19-0061: xc2028_get_reg 0002 called
[ 3698.259283] em2860 #0: I2C transfer timeout on writing to addr 0xc2
[ 3698.259312] xc2028 19-0061: i2c input error: rc = -121 (should be 2)
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
---
drivers/media/tuners/tuner-xc2028.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/drivers/media/tuners/tuner-xc2028.c b/drivers/media/tuners/tuner-xc2028.c
index 75afab718ba6..cca508d4aafb 100644
--- a/drivers/media/tuners/tuner-xc2028.c
+++ b/drivers/media/tuners/tuner-xc2028.c
@@ -267,6 +267,7 @@ static int check_device_status(struct xc2028_data *priv)
case XC2028_WAITING_FIRMWARE:
return -EAGAIN;
case XC2028_ACTIVE:
+ return 1;
case XC2028_SLEEP:
return 0;
case XC2028_NODEV:
@@ -913,6 +914,12 @@ static int xc2028_signal(struct dvb_frontend *fe, u16 *strength)
if (rc < 0)
return rc;
+ /* If the device is sleeping, no channel is tuned */
+ if (!rc) {
+ *strength = 0;
+ return 0;
+ }
+
mutex_lock(&priv->lock);
/* Sync Lock Indicator */
@@ -960,6 +967,12 @@ static int xc2028_get_afc(struct dvb_frontend *fe, s32 *afc)
if (rc < 0)
return rc;
+ /* If the device is sleeping, no channel is tuned */
+ if (!rc) {
+ *afc = 0;
+ return 0;
+ }
+
mutex_lock(&priv->lock);
/* Sync Lock Indicator */
@@ -1277,12 +1290,12 @@ static int xc2028_sleep(struct dvb_frontend *fe)
if (rc < 0)
return rc;
- /* Avoid firmware reload on slow devices or if PM disabled */
- if (no_poweroff || priv->ctrl.disable_power_mgmt)
+ /* Device is already in sleep mode */
+ if (!rc)
return 0;
- /* Device is already in sleep mode */
- if (priv->state == XC2028_SLEEP)
+ /* Avoid firmware reload on slow devices or if PM disabled */
+ if (no_poweroff || priv->ctrl.disable_power_mgmt)
return 0;
tuner_dbg("Putting xc2028/3028 into poweroff mode.\n");
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] tuner-xc2028: Fix xc3028 timeouts
2014-01-06 10:01 [PATCH 0/2] tuner-xc2028: Fix xc3028 timeouts Mauro Carvalho Chehab
2014-01-06 10:01 ` [PATCH 1/2] tuner-xc2028: Don't try to sleep twice Mauro Carvalho Chehab
2014-01-06 10:01 ` [PATCH 2/2] tuner-xc2028: Don't read status if device is powered down Mauro Carvalho Chehab
@ 2014-01-06 16:15 ` Mauro Carvalho Chehab
2 siblings, 0 replies; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2014-01-06 16:15 UTC (permalink / raw)
To: Frank Schäfer; +Cc: Linux Media Mailing List, Mauro Carvalho Chehab
Em Mon, 06 Jan 2014 08:01:31 -0200
Mauro Carvalho Chehab <m.chehab@samsung.com> escreveu:
> When xc2028/3028 is powered down, it won't response to any command, until
> a firmware is loaded. That means that reading frontend status will fail
> with a timeout.
>
> Also, any trial to put the device to sleep twice will fail.
>
> This small series fix those two bugs.
>
> Mauro Carvalho Chehab (2):
> tuner-xc2028: Don't try to sleep twice
> tuner-xc2028: Don't read status if device is powered down
>
> drivers/media/tuners/tuner-xc2028.c | 29 ++++++++++++++++++++++++++---
> 1 file changed, 26 insertions(+), 3 deletions(-)
>
It turns that the errors I was experiencing with tvp5150 on HVR-950 seem
to be a reflex of the xc3028 errors, as they disappeared after this fix.
I suspect that the tvp5150 reads were sent too fast to em28xx, while it
was still trying to do a read on the powered down xc3028.
That could likely mean that the code at em28xx I2C read would need to
wait for a longer time, or that we may need to send an ACK to em28xx
I2C, via register 0x06 bit 7.
Anyway, as everything is working fine, I'm just dropping the I2C
retry logic. I don't intend to work on any other fixup patch for I2C.
However, as the bug seems to still be hidden somewhere there, better to
have an option to turn on debug messages for timeouts.
Regards,
Mauro
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-01-06 16:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-06 10:01 [PATCH 0/2] tuner-xc2028: Fix xc3028 timeouts Mauro Carvalho Chehab
2014-01-06 10:01 ` [PATCH 1/2] tuner-xc2028: Don't try to sleep twice Mauro Carvalho Chehab
2014-01-06 10:01 ` [PATCH 2/2] tuner-xc2028: Don't read status if device is powered down Mauro Carvalho Chehab
2014-01-06 16:15 ` [PATCH 0/2] tuner-xc2028: Fix xc3028 timeouts Mauro Carvalho Chehab
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).