From patchwork Tue Nov 3 12:50:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 1393021 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=RG5P2N7T; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CQV5819Dvz9sSs for ; Tue, 3 Nov 2020 23:50:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CDB0482517; Tue, 3 Nov 2020 13:50:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="RG5P2N7T"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 768BD82521; Tue, 3 Nov 2020 13:50:47 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 86B00823EF for ; Tue, 3 Nov 2020 13:50:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jbrunet@baylibre.com Received: by mail-wm1-x342.google.com with SMTP id c18so12617211wme.2 for ; Tue, 03 Nov 2020 04:50:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZXuKtlY7dd7Egvz+GmA/h5bAeA6Pp+4URf5NxpwAh5s=; b=RG5P2N7TvpV5EH2hOltW/VRwQcd7/CXUXKBVlfuCGjz9UtRT8P8HNODatMx3lQ+7tG wfzzH/FJjEmVwJI3k422R3Pbz5Lkq/P9Uov9S6Cc5914ZEDfZVB+Fh60zGPW9Xgvz2Fg BmtXuRElZ/Mqb0BJ9sQSP2l5V9E1tpQof1CamMEAElmMJh6hYMj1TU864zkI2Lc9X66o PLlwjv12QJSbIDikdhyeSjoc0SZUePTG6+sn393NhJndVr0dT4/ynaDQNZrS0pYsNK8q T0nXarjY9Byk1y1xESE8e+ypi3R7/Wv/1OEAgUGl6aInsW+MCU5gU5aCC00Kd6nk6F90 QdQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZXuKtlY7dd7Egvz+GmA/h5bAeA6Pp+4URf5NxpwAh5s=; b=iOUv0CfLOv8DDIySOvri60Um4sNL+exUFmyhoWBF48E2wMN05mv0qFbmSlX6JHS1he mmd7YicWRaE+rF5eWDZUdWo7VutHT5QUbJgSzKY5QM2B0A7Jnzt/HbHgPHeSnugKtuxN dSv2WxW0L4EmW0/fT4K8jaGK77GWsN0byQJaNoy5l/JgTlivK01H+AoSTxxoiyxtEpM4 uwIPntgIr96nRL/8+2YtrnmBC5hHceojjR0KdIIOX0bs6I/Xa6p/WITg7MjAx0vteLPx Xdbt/c52KRLrzc9Dpo8JYzgJCkZvpVKvaNMloJ3VKTZf0yulmgpHImaUHIcbhrZTJQl9 DvTQ== X-Gm-Message-State: AOAM531EYsud1XAzsW31wBRe2fkxcQ8ZdxCAbVKXh2gFUGltgOJNZtZz AeukqR7G11VRpaI6dKf1m+/QAldF0ey3vcXl X-Google-Smtp-Source: ABdhPJyHr3lDEXLUnRAi8lGkjcRwIC26ecZlzKsmpq3qh0atsohcorHyH2rjsABinIZgOEM1I/M2UA== X-Received: by 2002:a7b:cb54:: with SMTP id v20mr3496432wmj.149.1604407843820; Tue, 03 Nov 2020 04:50:43 -0800 (PST) Received: from starbuck.lan (253.35.17.109.rev.sfr.net. [109.17.35.253]) by smtp.googlemail.com with ESMTPSA id o10sm2828032wma.47.2020.11.03.04.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 04:50:43 -0800 (PST) From: Jerome Brunet To: u-boot@lists.denx.de Cc: Jerome Brunet , Da Xue Subject: [PATCH] edid: investigate dtd from cea861 extension if necessary Date: Tue, 3 Nov 2020 13:50:31 +0100 Message-Id: <20201103125031.248144-1-jbrunet@baylibre.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean If no valid detailed timing can be found in the edid base block, check the detailed timing provided in the cea861 extension block, if any. Reported-by: Da Xue Tested-by: Da Xue Signed-off-by: Jerome Brunet --- common/edid.c | 72 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 23 deletions(-) diff --git a/common/edid.c b/common/edid.c index 553ab8fd01a1..7dd0c924c24a 100644 --- a/common/edid.c +++ b/common/edid.c @@ -169,6 +169,33 @@ static bool cea_is_hdmi_vsdb_present(struct edid_cea861_info *info) return false; } +bool edid_get_dtd_timing_validate(struct edid_monitor_descriptor *desc, + unsigned int dtd_count, + struct display_timing *timing, + bool (*mode_valid)(void *priv, + const struct display_timing *timing), + void *mode_valid_priv) +{ + bool timing_done = false; + int i; + + for (i = 0; i < dtd_count; i++, desc++) { + if (desc->zero_flag_1 != 0) { + decode_timing((u8 *)desc, timing); + if (mode_valid) + timing_done = mode_valid(mode_valid_priv, + timing); + else + timing_done = true; + + if (timing_done) + break; + } + } + + return timing_done; +} + int edid_get_timing_validate(u8 *buf, int buf_size, struct display_timing *timing, int *panel_bits_per_colourp, @@ -177,8 +204,9 @@ int edid_get_timing_validate(u8 *buf, int buf_size, void *mode_valid_priv) { struct edid1_info *edid = (struct edid1_info *)buf; + struct edid_cea861_info *info = NULL; + struct edid_monitor_descriptor *desc; bool timing_done; - int i; if (buf_size < sizeof(*edid) || edid_check_info(edid)) { debug("%s: Invalid buffer\n", __func__); @@ -190,24 +218,27 @@ int edid_get_timing_validate(u8 *buf, int buf_size, return -ENOENT; } - /* Look for detailed timing */ - timing_done = false; - for (i = 0; i < 4; i++) { - struct edid_monitor_descriptor *desc; + desc = edid->monitor_details.descriptor; + timing_done = edid_get_dtd_timing_validate(desc, 4, timing, + mode_valid, mode_valid_priv); - desc = &edid->monitor_details.descriptor[i]; - if (desc->zero_flag_1 != 0) { - decode_timing((u8 *)desc, timing); - if (mode_valid) - timing_done = mode_valid(mode_valid_priv, - timing); - else - timing_done = true; + if (edid->extension_flag && (buf_size >= EDID_EXT_SIZE)) { + info = (struct edid_cea861_info *)(buf + sizeof(*edid)); - if (timing_done) - break; - } + if (info->extension_tag != EDID_CEA861_EXTENSION_TAG) + info = NULL; + } + + /* Check CEA861 info block for timing if don't have one yet */ + if (info && !timing_done && info->dtd_offset) { + unsigned int dtd_count = EDID_CEA861_DTD_COUNT(*info); + + desc = (struct edid_monitor_descriptor *)((u8 *)info + + info->dtd_offset); + timing_done = edid_get_dtd_timing_validate(desc, dtd_count, timing, + mode_valid, mode_valid_priv); } + if (!timing_done) return -EINVAL; @@ -225,13 +256,8 @@ int edid_get_timing_validate(u8 *buf, int buf_size, } timing->hdmi_monitor = false; - if (edid->extension_flag && (buf_size >= EDID_EXT_SIZE)) { - struct edid_cea861_info *info = - (struct edid_cea861_info *)(buf + sizeof(*edid)); - - if (info->extension_tag == EDID_CEA861_EXTENSION_TAG) - timing->hdmi_monitor = cea_is_hdmi_vsdb_present(info); - } + if (info) + timing->hdmi_monitor = cea_is_hdmi_vsdb_present(info); return 0; }