From: Andrew.Jackson@arm.com (Andrew Jackson)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] drm: i2c: tda998x: Retry fetching the EDID if it fails first time.
Date: Tue, 18 Nov 2014 17:41:26 +0000 [thread overview]
Message-ID: <546B84C6.3090809@arm.com> (raw)
Fetching the EDID from a connected monitor is an automated thing
with NXP TDA19988. But on some boards the fetching fails for the
first time silently without any indication that an error has occured.
More than that, subsequent fetches of the EDID succeed until the
monitor(s) are unplugged.
Add a function to validate the read EDID and retry if the block
retrieved is not valid.
Signed-off-by: Andrew Jackson <Andrew.Jackson@arm.com>
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
---
drivers/gpu/drm/i2c/tda998x_drv.c | 36 ++++++++++++++++++++++++++++--------
1 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
index d476279..025adc0 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -1066,11 +1066,36 @@ static int read_edid_block(struct tda998x_priv *priv, uint8_t *buf, int blk)
return 0;
}
+static int
+read_validate_edid_block(struct tda998x_priv *priv, uint8_t *buf, int blk)
+{
+ bool print_bad_edid = drm_debug & DRM_UT_KMS;
+ int ret;
+ int retries = 1;
+
+ do
+ {
+ bool print_bad = print_bad_edid && (retries == 0);
+
+ ret = read_edid_block(priv, buf, blk);
+ /* Fail on I2C error */
+ if (ret)
+ break;
+
+ /* But retry checksum errored blocks */
+ if (drm_edid_block_valid(buf, blk, print_bad))
+ break;
+ else
+ ret = -EINVAL;
+ } while (retries-- > 0);
+
+ return ret;
+}
+
static uint8_t *do_get_edid(struct tda998x_priv *priv)
{
int j, valid_extensions = 0;
uint8_t *block, *new;
- bool print_bad_edid = drm_debug & DRM_UT_KMS;
if ((block = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL)
return NULL;
@@ -1079,10 +1104,7 @@ static uint8_t *do_get_edid(struct tda998x_priv *priv)
reg_clear(priv, REG_TX4, TX4_PD_RAM);
/* base block fetch */
- if (read_edid_block(priv, block, 0))
- goto fail;
-
- if (!drm_edid_block_valid(block, 0, print_bad_edid))
+ if (read_validate_edid_block(priv, block, 0))
goto fail;
/* if there's no extensions, we're done */
@@ -1096,10 +1118,8 @@ static uint8_t *do_get_edid(struct tda998x_priv *priv)
for (j = 1; j <= block[0x7e]; j++) {
uint8_t *ext_block = block + (valid_extensions + 1) * EDID_LENGTH;
- if (read_edid_block(priv, ext_block, j))
- goto fail;
- if (!drm_edid_block_valid(ext_block, j, print_bad_edid))
+ if (read_validate_edid_block(priv, ext_block, j))
goto fail;
valid_extensions++;
--
1.7.1
next reply other threads:[~2014-11-18 17:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-18 17:41 Andrew Jackson [this message]
2014-11-28 8:19 ` [PATCH] drm: i2c: tda998x: Retry fetching the EDID if it fails first time Jean-Francois Moine
2014-11-28 9:02 ` Andrew Jackson
2014-11-29 10:41 ` Jean-Francois Moine
2014-12-01 13:19 ` Andrew Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=546B84C6.3090809@arm.com \
--to=andrew.jackson@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).