From patchwork Wed Dec 8 16:10:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Flynn X-Patchwork-Id: 392992 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oB96gqeB015487 for ; Thu, 9 Dec 2010 06:43:13 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 820869EF55 for ; Wed, 8 Dec 2010 22:42:52 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 09 Dec 2010 06:43:13 +0000 (UTC) X-Greylist: delayed 8884 seconds by postgrey-1.31 at gabe; Wed, 08 Dec 2010 10:38:29 PST Received: from mailout0.mh.bbc.co.uk (mailout0.mh.bbc.co.uk [132.185.144.151]) by gabe.freedesktop.org (Postfix) with ESMTP id 9914E9E732; Wed, 8 Dec 2010 10:38:29 -0800 (PST) Received: from gateh.kw.bbc.co.uk (gateh.kw.bbc.co.uk [132.185.132.17]) by mailout0.mh.bbc.co.uk (8.14.4/8.14.3) with ESMTP id oB8GAMGJ003836; Wed, 8 Dec 2010 16:10:22 GMT Received: from mailhub.rd.bbc.co.uk ([172.29.120.130]) by gateh.kw.bbc.co.uk (8.13.6/8.13.6) with ESMTP id oB8GALUV005035; Wed, 8 Dec 2010 16:10:22 GMT Received: from b36048.rd.bbc.co.uk ([172.29.136.48]:59338) by mailhub.rd.bbc.co.uk with esmtp (Exim 4.69) (envelope-from ) id 1PQMaz-0004Xa-Dh; Wed, 08 Dec 2010 16:10:21 +0000 Received: from davidf by b36048.rd.bbc.co.uk with local (Exim 4.69) (envelope-from ) id 1PQMaz-00081U-Bw; Wed, 08 Dec 2010 16:10:21 +0000 Date: Wed, 8 Dec 2010 16:10:21 +0000 From: David Flynn To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Subject: [PATCH] drm/i915/dp: Fix I2C/EDID handling with active DisplayPort to DVI converter Message-ID: <20101208161021.GF20844@rd.bbc.co.uk> MIME-Version: 1.0 Content-Disposition: inline X-Editor: Vim http://www.vim.org/ Organisation: Poor X-Operating-System: SunOS 5.10 SUNW,Sun-Fire-V210 User-Agent: Mutt/1.5.20 (2009-06-14) X-Mailman-Approved-At: Wed, 08 Dec 2010 22:41:29 -0800 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index c8e0055..186cdc7 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -482,6 +482,7 @@ intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode, int msg_bytes; int reply_bytes; int ret; + unsigned retry; /* Set up the command byte */ if (mode & MODE_I2C_READ) @@ -513,7 +514,7 @@ intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode, break; } - for (;;) { + for (retry = 5; retry; retry--) { ret = intel_dp_aux_ch(intel_dp, msg, msg_bytes, reply, reply_bytes); @@ -521,6 +522,21 @@ intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode, DRM_DEBUG_KMS("aux_ch failed %d\n", ret); return ret; } + switch (reply[0] & AUX_NATIVE_REPLY_MASK) { + case AUX_NATIVE_REPLY_ACK: + /* I2C-over-AUX Reply field is only valid when paired with AUX ACK.*/ + break; + case AUX_NATIVE_REPLY_NACK: + DRM_DEBUG_KMS("aux_ch nack\n"); + return -EREMOTEIO; + case AUX_NATIVE_REPLY_DEFER: + udelay(100); + continue; + default: + DRM_ERROR("aux_ch invalid reply 0x%02x\n", reply[0]); + return -EREMOTEIO; + } + switch (reply[0] & AUX_I2C_REPLY_MASK) { case AUX_I2C_REPLY_ACK: if (mode == MODE_I2C_READ) { @@ -528,17 +544,20 @@ intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode, } return reply_bytes - 1; case AUX_I2C_REPLY_NACK: - DRM_DEBUG_KMS("aux_ch nack\n"); + DRM_DEBUG_KMS("aux_i2c nack\n"); return -EREMOTEIO; case AUX_I2C_REPLY_DEFER: - DRM_DEBUG_KMS("aux_ch defer\n"); + DRM_DEBUG_KMS("aux_i2c defer\n"); udelay(100); break; default: - DRM_ERROR("aux_ch invalid reply 0x%02x\n", reply[0]); + DRM_ERROR("aux_i2c invalid reply 0x%02x\n", reply[0]); return -EREMOTEIO; } } + + DRM_ERROR("too many retries, giving up\n"); + return -EREMOTEIO; } static int