From patchwork Thu Jul 4 13:52:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 1127549 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.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=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="KtWFbORV"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45ffb34F7Qz9sPD for ; Thu, 4 Jul 2019 23:53:51 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id CC0DCC21DD4; Thu, 4 Jul 2019 13:52:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id DF259C21BE5; Thu, 4 Jul 2019 13:52:27 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 49B1AC21C3F; Thu, 4 Jul 2019 13:52:19 +0000 (UTC) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by lists.denx.de (Postfix) with ESMTPS id C6C73C21C6A for ; Thu, 4 Jul 2019 13:52:15 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id x4so6717323wrt.6 for ; Thu, 04 Jul 2019 06:52:15 -0700 (PDT) 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:in-reply-to:references :mime-version:content-transfer-encoding; bh=bbfQ+Jmc8Su62WVi81909SfTWTAk8T56gH/qadrUWbk=; b=KtWFbORVctxdgFA0sqvB5nB3eFdFhP2j3Bo8+c2GOR11xL3wm4flnMdGAScDbvoLvf e+eBzDJkt+xdsNPEs76Ld+s1Q7UTalW6j+5QEqGeGOACsVZ9kKTeCx3uOwzVA7benUbG 85cttu+/eHLa/B/pRPIIx0ovBuY8+6lntl+EnN4gUmt93cMSFIkgywdxi2ASWnngF3yz V7ZZUURSmYaCfg6B01x3Dw/yGThCdne+oe7lUa5BFkolc1Oe31Hbjrdt2xcboU1T3+tr cqdCylhZUtE05XSa6/kp/J0aRI5JKFlMgrUAf7U0HdUBZTbYISOrLA+EP3t12jk4nRnL 8zFw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=bbfQ+Jmc8Su62WVi81909SfTWTAk8T56gH/qadrUWbk=; b=P8D/oQXph+8pnQGn04aDKBmbBRQ57L+8yqBOZLIlGPsxY/XFRhtML428Bh3laE0L8g J9tAtOm1EE+8JHdFG+6xaT2WjYwJKdSmSeKFVZY7LUAoJ2juDQ/eTOjeoiZhyIO9VuOk lpHSbaTJc3nNzxuI0IAdTFz0EE/R2jDajfJl8pX2bQZ58VDrt516A0B34tNnKa4Yi+LO UI6HIj9taAgXnaiIZlUhvdBnaRL2yjiXhIeFspGbYZTvkT1ODMdSzL7/xoIGAIlSwhb+ NIiL6CgOQ7kkEZyloQPrRwpyDKsrmhDYKYeKHukHwYI58ene7pVFT7QZB3Ml51tp8kTg 91UA== X-Gm-Message-State: APjAAAVMdwPMemiR2Xh0DnfA3hNym7e6KAqkWPhiD2ifycRNZByufL9g BGNOFI3uu8HV6YyHtMQc9VSGLQ== X-Google-Smtp-Source: APXvYqznuzkcBXdARAF2H6FEs+oMU1w04lxWjEyZtnY0eV4aswTfXxO8JXTRlYGg55csQCQl1TaeVQ== X-Received: by 2002:a5d:468a:: with SMTP id u10mr34528329wrq.177.1562248335250; Thu, 04 Jul 2019 06:52:15 -0700 (PDT) Received: from localhost.localdomain (176-150-251-154.abo.bbox.fr. [176.150.251.154]) by smtp.gmail.com with ESMTPSA id x11sm4793199wmi.26.2019.07.04.06.52.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Jul 2019 06:52:13 -0700 (PDT) From: Neil Armstrong To: agust@denx.de Date: Thu, 4 Jul 2019 15:52:06 +0200 Message-Id: <20190704135208.32104-2-narmstrong@baylibre.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190704135208.32104-1-narmstrong@baylibre.com> References: <20190704135208.32104-1-narmstrong@baylibre.com> MIME-Version: 1.0 Cc: u-boot@lists.denx.de, u-boot-amlogic@groups.io Subject: [U-Boot] [PATCH 1/3] edid: add edid_get_timing_validate() variant to filter out edid modes X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" The original edid_get_timing() function returns the first valid timing, but on some plaforms, we could only supports a subset of the listed monitot's navite timing. Let's introduce a edid_get_timing_validate() adding a mode_valid callback including a private cookie pointer. If the callback returns false, the current timing is discared and the next one is checked. If no valid & supported timings are found, the function would return an error. Signed-off-by: Neil Armstrong --- common/edid.c | 22 +++++++++++++++++++--- include/edid.h | 22 ++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/common/edid.c b/common/edid.c index 90d1167f6e..f244d26e04 100644 --- a/common/edid.c +++ b/common/edid.c @@ -168,8 +168,12 @@ static bool cea_is_hdmi_vsdb_present(struct edid_cea861_info *info) return false; } -int edid_get_timing(u8 *buf, int buf_size, struct display_timing *timing, - int *panel_bits_per_colourp) +int edid_get_timing_validate(u8 *buf, int buf_size, + struct display_timing *timing, + int *panel_bits_per_colourp, + bool (*mode_valid)(void *priv, + const struct display_timing *timing), + void *mode_valid_priv) { struct edid1_info *edid = (struct edid1_info *)buf; bool timing_done; @@ -193,7 +197,11 @@ int edid_get_timing(u8 *buf, int buf_size, struct display_timing *timing, desc = &edid->monitor_details.descriptor[i]; if (desc->zero_flag_1 != 0) { decode_timing((u8 *)desc, timing); - timing_done = true; + if (mode_valid) + timing_done = mode_valid(mode_valid_priv, + timing); + else + timing_done = true; break; } } @@ -225,6 +233,14 @@ int edid_get_timing(u8 *buf, int buf_size, struct display_timing *timing, return 0; } +int edid_get_timing(u8 *buf, int buf_size, struct display_timing *timing, + int *panel_bits_per_colourp) +{ + return edid_get_timing_validate(buf, buf_size, timing, + panel_bits_per_colourp, NULL, NULL); +} + + /** * Snip the tailing whitespace/return of a string. * diff --git a/include/edid.h b/include/edid.h index f05d2b82f2..2562733061 100644 --- a/include/edid.h +++ b/include/edid.h @@ -306,6 +306,28 @@ int edid_get_ranges(struct edid1_info *edid, unsigned int *hmin, struct display_timing; +/** + * edid_get_timing_validate() - Get basic digital display parameters with + * mode selection callback + * + * @param buf Buffer containing EDID data + * @param buf_size Size of buffer in bytes + * @param timing Place to put preferring timing information + * @param panel_bits_per_colourp Place to put the number of bits per + * colour supported by the panel. This will be set to + * -1 if not available + * @param mode_valid Callback validating mode, returning true is mode is + * supported, false otherwise. + * @parem valid_priv Pointer to private data for mode_valid callback + * @return 0 if timings are OK, -ve on error + */ +int edid_get_timing_validate(u8 *buf, int buf_size, + struct display_timing *timing, + int *panel_bits_per_colourp, + bool (*mode_valid)(void *priv, + const struct display_timing *timing), + void *mode_valid_priv); + /** * edid_get_timing() - Get basic digital display parameters *