From patchwork Tue Nov 18 17:41:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jackson X-Patchwork-Id: 5331901 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 01C619F1E1 for ; Tue, 18 Nov 2014 17:44:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2ADA6201BC for ; Tue, 18 Nov 2014 17:43:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3EAD820125 for ; Tue, 18 Nov 2014 17:43:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xqmmt-0001Xz-Dy; Tue, 18 Nov 2014 17:41:59 +0000 Received: from fw-tnat.cambridge.arm.com ([217.140.96.21] helo=cam-smtp0.cambridge.arm.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xqmmq-0001Sd-Vr for linux-arm-kernel@lists.infradead.org; Tue, 18 Nov 2014 17:41:57 +0000 Received: from [10.1.193.37] (e106787-lin.cambridge.arm.com [10.1.193.37]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id sAIHfREb029956; Tue, 18 Nov 2014 17:41:27 GMT Message-ID: <546B84C6.3090809@arm.com> Date: Tue, 18 Nov 2014 17:41:26 +0000 From: Andrew Jackson User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: Russell King - ARM Linux , Dave Airlie , "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH] drm: i2c: tda998x: Retry fetching the EDID if it fails first time. X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141118_094157_346309_76093D33 X-CRM114-Status: GOOD ( 15.75 ) X-Spam-Score: -2.3 (--) Cc: Liviu Dudau , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Liviu Dudau --- 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++;