Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3997094ybc; Tue, 26 Nov 2019 02:02:48 -0800 (PST) X-Google-Smtp-Source: APXvYqy6jsYkA/U8cJcvCbl+yb7mwBx9+K4ZpixJVX3Nd0VqEHyORcXiZlyYiLbWvWxuDEpXFS+2 X-Received: by 2002:a17:906:9458:: with SMTP id z24mr41730014ejx.289.1574762568533; Tue, 26 Nov 2019 02:02:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574762568; cv=none; d=google.com; s=arc-20160816; b=q19vwxLCjneEbMTCd78sOqF8uAMvHMTVO40Tm3HJfUy37EoRRR4c5Dtz/gk6FKiKEc bfjm9s9MG6oyJ+mcA342hWtpTAEGOgVmv4grUVHhg8dZ4T5QrBJsv3zoMMV/YHLlaLQt viHJKdrU3D3SEOJKhzPuCdDw25qSzgsx1hhI53yxTs4bRCY6QVKhFWBWiI93/dT9pioy XFG/q6dVfJscGBaf4Y/3TtjdhfjQOO+ZEcV+CZccZNDf6nMRc+/iBRVvqr6YTQUdxOUd Y3q5QJaveTxW9eUDIjeWV3nqILW0k2Muc2YUA4v1nw60ksoGeQP7lJKjiLxlaJStU6KI MObw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:mime-version:message-id:date:subject :cc:from; bh=zNGilz/6uImtoWTTvCVMm2iqkmo5S1644yDyPpnKTjU=; b=UPvne7nI+6DdwbcOv1os4jLveqSMBYw6mreD47JWxRXNCnyJ4mBQqe7NP4RBuDYwmb TIDaFPySgEzRucDFZk+8HesHehfF8bS33RnVHwNSKF2ozzpcvL+yyFWckI3rvzjEAlCd pb2rzYMpHKC15mGQSZ9F4AB/LeQ93LIZR2J2PVQDW1hNKamHcA6eC8avoEOTJ9euwA4P ZpCcD5VP9idqEqLeNXLd7XyEWuaBmVwsUDrhmPoqHthPTAJnY1GbJCZATSJUjYQvyirr w2//8rxKT3ViSWWIz3n1tPY6H2VTzm3VecVLHJl12/Xcw8KJuammy22XjVVo3jAyj2PH Aeqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qc22si6437817ejb.151.2019.11.26.02.02.21; Tue, 26 Nov 2019 02:02:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727701AbfKZJ6O (ORCPT + 99 others); Tue, 26 Nov 2019 04:58:14 -0500 Received: from 60-251-196-230.HINET-IP.hinet.net ([60.251.196.230]:32276 "EHLO ironport.ite.com.tw" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727397AbfKZJ6O (ORCPT ); Tue, 26 Nov 2019 04:58:14 -0500 Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 26 Nov 2019 17:58:12 +0800 Received: from csbcas.internal.ite.com.tw (csbcas2.internal.ite.com.tw [192.168.65.47]) by mse.ite.com.tw with ESMTP id xAQ9w0kU081586; Tue, 26 Nov 2019 17:58:00 +0800 (GMT-8) (envelope-from allen.chen@ite.com.tw) Received: from allen-VirtualBox.internal.ite.com.tw (192.168.70.14) by csbcas2.internal.ite.com.tw (192.168.65.45) with Microsoft SMTP Server (TLS) id 14.3.352.0; Tue, 26 Nov 2019 17:58:01 +0800 From: allen CC: Allen Chen , Pi-Hsun Shih , Jau-Chih Tseng , Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , "open list:DRM DRIVERS" , open list Subject: [PATCH] drm/edid: fixup EDID 1.3 and 1.4 judge reduced-blanking timings logic Date: Tue, 26 Nov 2019 17:46:12 +0800 Message-ID: <1574761572-26585-1-git-send-email-allen.chen@ite.com.tw> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.168.70.14] X-MAIL: mse.ite.com.tw xAQ9w0kU081586 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org According to VESA ENHANCED EXTENDED DISPLAY IDENTIFICATION DATA STANDARD (Defines EDID Structure Version 1, Revision 4) page: 39 How to determine whether the monitor support RB timing or not? EDID 1.4 First: read detailed timing descriptor and make sure byte 0 = 0x00, byte 1 = 0x00, byte 2 = 0x00 and byte 3 = 0xFD Second: read EDID bit 0 in feature support byte at address 18h = 1 and detailed timing descriptor byte 10 = 0x04 Third: if EDID bit 0 in feature support byte = 1 && detailed timing descriptor byte 10 = 0x04 then we can check byte 15, if bit 4 in byte 15 = 1 is support RB if EDID bit 0 in feature support byte != 1 || detailed timing descriptor byte 10 != 0x04, then byte 15 can not be used The linux code is_rb function not follow the VESA's rule Signed-off-by: Allen Chen Reported-by: kbuild test robot --- drivers/gpu/drm/drm_edid.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index f5926bf..e11e585 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -93,6 +93,12 @@ struct detailed_mode_closure { int modes; }; +struct edid_support_rb_closure { + struct edid *edid; + bool valid_support_rb; + bool support_rb; +}; + #define LEVEL_DMT 0 #define LEVEL_GTF 1 #define LEVEL_GTF2 2 @@ -2017,23 +2023,41 @@ struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev, } } +static bool +is_display_descriptor(const u8 *r, u8 tag) +{ + return (!r[0] && !r[1] && !r[2] && r[3] == tag) ? true : false; +} + static void is_rb(struct detailed_timing *t, void *data) { u8 *r = (u8 *)t; - if (r[3] == EDID_DETAIL_MONITOR_RANGE) - if (r[15] & 0x10) - *(bool *)data = true; + struct edid_support_rb_closure *closure = data; + struct edid *edid = closure->edid; + + if (is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE)) { + if (edid->features & BIT(0) && r[10] == BIT(2)) { + closure->valid_support_rb = true; + closure->support_rb = (r[15] & 0x10) ? true : false; + } + } } /* EDID 1.4 defines this explicitly. For EDID 1.3, we guess, badly. */ static bool drm_monitor_supports_rb(struct edid *edid) { + struct edid_support_rb_closure closure = { + .edid = edid, + .valid_support_rb = false, + .support_rb = false, + }; + if (edid->revision >= 4) { - bool ret = false; - drm_for_each_detailed_block((u8 *)edid, is_rb, &ret); - return ret; + drm_for_each_detailed_block((u8 *)edid, is_rb, &closure); + if (closure.valid_support_rb) + return closure.support_rb; } return ((edid->input & DRM_EDID_INPUT_DIGITAL) != 0); -- 1.9.1