From patchwork Wed Jul 6 23:30:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Reim X-Patchwork-Id: 951612 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p66NWcuG024736 for ; Wed, 6 Jul 2011 23:32:58 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A66119F02F for ; Wed, 6 Jul 2011 16:32:38 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-bw0-f49.google.com (mail-bw0-f49.google.com [209.85.214.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 5FFC19EAFF for ; Wed, 6 Jul 2011 16:30:44 -0700 (PDT) Received: by mail-bw0-f49.google.com with SMTP id 12so606891bwf.36 for ; Wed, 06 Jul 2011 16:30:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to:references; bh=8DzlcumOdNlCnL0KvXCQ3kVYvK6qNrIs53kU4CKXMnU=; b=vEKisqCzQi5nCkNk1KcEVSM20adG5t1IgnEfx4DG64dEpTDRLJt9BW8l5cQ+IcdIG6 iwKtDr2T+IZW2gdhJFUl5yexzYnMxlMeIgVwBjZzNnu3iZAc8Na3Q9kuI5olCUJIhWjq uUd6UsuunzfjKDwKe+cai0cSJuzN5G90hfMIA= Received: by 10.204.48.210 with SMTP id s18mr96676bkf.176.1309995043858; Wed, 06 Jul 2011 16:30:43 -0700 (PDT) Received: from localhost.localdomain (p549DAA48.dip.t-dialin.net [84.157.170.72]) by mx.google.com with ESMTPS id g13sm7952711bkd.10.2011.07.06.16.30.41 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 06 Jul 2011 16:30:42 -0700 (PDT) From: reimth@googlemail.com To: Dave Airlie , Alex Deucher , Mario Kleiner , Jean Delvare , Tyson Whitehead , Jason Wessel Subject: [PATCH 1/3] drm: Separate EDID Header Check from EDID Block Check Date: Thu, 7 Jul 2011 01:30:12 +0200 Message-Id: <1309995012-5873-4-git-send-email-reimth@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1309995012-5873-1-git-send-email-reimth@gmail.com> References: <1309995012-5873-1-git-send-email-reimth@gmail.com> In-Reply-To: References: Cc: Thomas Reim , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, stable@kernel.org 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: , MIME-Version: 1.0 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 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 06 Jul 2011 23:32:59 +0000 (UTC) From: Thomas Reim Provides function drm_edid_header_is_valid() for EDID header check and replaces EDID header check part of function drm_edid_block_valid() by a call of drm_edid_header_is_valid(). This is a prerequisite to extend DDC probing, e. g. in function radeon_ddc_probe() for Radeon devices, by a central EDID header check. Tested for kernel 2.35, 2.38 and 3.0 Signed-off-by: Thomas Reim --- drivers/gpu/drm/drm_edid.c | 24 ++++++++++++++++++------ include/drm/drm_crtc.h | 1 + 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 0929219..1bbb85b 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -127,6 +127,23 @@ static const u8 edid_header[] = { 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 }; + /* + * Sanity check the header of the base EDID block. Return 8 if the header + * is perfect, down to 0 if it's totally wrong. + */ +int drm_edid_header_is_valid(const u8 *raw_edid) +{ + int i, score = 0; + + for (i = 0; i < sizeof(edid_header); i++) + if (raw_edid[i] == edid_header[i]) + score++; + + return score; +} +EXPORT_SYMBOL(drm_edid_header_is_valid); + + /* * Sanity check the EDID block (base or extension). Return 0 if the block * doesn't check out, or 1 if it's valid. @@ -139,12 +156,7 @@ drm_edid_block_valid(u8 *raw_edid) struct edid *edid = (struct edid *)raw_edid; if (raw_edid[0] == 0x00) { - int score = 0; - - for (i = 0; i < sizeof(edid_header); i++) - if (raw_edid[i] == edid_header[i]) - score++; - + int score = drm_edid_header_is_valid(raw_edid); if (score == 8) ; else if (score >= 6) { DRM_DEBUG("Fixing EDID header, your hardware may be failing\n"); diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 33d12f8..0ec3687 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -802,6 +802,7 @@ extern struct drm_display_mode *drm_gtf_mode_complex(struct drm_device *dev, extern int drm_add_modes_noedid(struct drm_connector *connector, int hdisplay, int vdisplay); +extern int drm_edid_header_is_valid(const u8 *raw_edid); extern bool drm_edid_is_valid(struct edid *edid); struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev, int hsize, int vsize, int fresh);