From patchwork Sat Feb 4 17:41:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatolij Gustschin X-Patchwork-Id: 1737560 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=fIH07+zA; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=QwWIKG7g; 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P8KZq3mJQz23j0 for ; Sun, 5 Feb 2023 04:41:37 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 48A8E8583E; Sat, 4 Feb 2023 18:41:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1675532487; bh=l1+C/CNNsPUQp+p9R57Ux5wDntMWvmLDjEpZYnWDS0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=fIH07+zAizhAIy723EdWt3+q4VvNSiWB1/pSmbDXvhV5zS3vYWma/6TJcyR09bgg4 Ci3MQLwCBf9CnTg844thLssv7X4m1xXZYr+DuH3tcL179VKqyr3ynVVGp5Leg9Xfb1 vqAYR248xXx7Sq0LKsjSXFGUP3/zYbdjE3I/lMafghm5u+K6QGsHv9LbrEu7DaPeFw eBhqwR7gQoRL2d77Amr9BRH5ztezZmwaM94yDhMoJHKQHvTYKyMMSCPc/OaXnFTVBQ DdQH2eq/eH9Qt3kbYbCcCrta6QhnJssFzRkXYXOz0jGhcJdDA+y/giBm1DvdzD65rX 5CqspiYZIif+Q== Received: from crub.agik.hopto.org (pd95f183b.dip0.t-ipconnect.de [217.95.24.59]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: agust@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 2E306857EC; Sat, 4 Feb 2023 18:41:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1675532486; bh=l1+C/CNNsPUQp+p9R57Ux5wDntMWvmLDjEpZYnWDS0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QwWIKG7gHybnt6C4bc77krBSRxqSF9PFkFBECp21iOMpDyLrJdyhzWCgwlhALnBIC 4xLISmmSwLSWKfGeQAkkVgHDDsgqmbCY4DYrSjybhbUzJhWfPCD4uWFFNHzO46z4W6 tCwtnk9CrB0GKbbBJofoFj/5LyB7KOClN+LbrUi4XlL/Wr6jMOkpCCzMdfZEAkAXJk lJ5apDg1MlX9RdHVeQ/e4LLKu0wiNfV5TayahBj9I2Uo/nF5EPhRWmSIABpcDmMJe+ fvFzGF7JeVLqRZZwf1dh0Z/JBOPmfDJH9wBZ55EPboj+fk86DGK9RoThYxaa7Us0kT EfG4MqR4qGimA== From: Anatolij Gustschin To: u-boot@lists.denx.de Cc: Nikhil M Jain Subject: [PATCH v3 1/7] drivers: core: ofnode: Add panel timing decode. Date: Sat, 4 Feb 2023 18:41:25 +0100 Message-Id: <20230204174125.31446-1-agust@denx.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230131100520.103093-2-n-jain1@ti.com> References: <20230131100520.103093-2-n-jain1@ti.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean From: Nikhil M Jain ofnode_decode_display_timing supports reading timing parameters from subnode of display-timings node, for displays supporting multiple resolution, in case if a display supports single resolution, it fails reading directly from display-timings node, to support it ofnode_decode_panel_timing is added. Signed-off-by: Nikhil M Jain Reviewed-by: Simon Glass --- Changes in v3: - add static inline dev_decode_panel_timing() in include/dm/read.h to fix sandbox test errors when CONFIG_DM_DEV_READ_INLINE enabled drivers/core/ofnode.c | 47 +++++++++++++++++++++++++++++++++++++++++++ drivers/core/read.c | 6 ++++++ include/dm/ofnode.h | 12 +++++++++++ include/dm/read.h | 20 ++++++++++++++++++ 4 files changed, 85 insertions(+) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 4d56b1a767..d08578e9c4 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -991,6 +991,53 @@ int ofnode_decode_display_timing(ofnode parent, int index, return ret; } +int ofnode_decode_panel_timing(ofnode parent, + struct display_timing *dt) +{ + ofnode timings; + u32 val = 0; + int ret = 0; + + timings = ofnode_find_subnode(parent, "panel-timings"); + if (!ofnode_valid(timings)) + return -EINVAL; + memset(dt, 0, sizeof(*dt)); + ret |= decode_timing_property(timings, "hback-porch", &dt->hback_porch); + ret |= decode_timing_property(timings, "hfront-porch", &dt->hfront_porch); + ret |= decode_timing_property(timings, "hactive", &dt->hactive); + ret |= decode_timing_property(timings, "hsync-len", &dt->hsync_len); + ret |= decode_timing_property(timings, "vback-porch", &dt->vback_porch); + ret |= decode_timing_property(timings, "vfront-porch", &dt->vfront_porch); + ret |= decode_timing_property(timings, "vactive", &dt->vactive); + ret |= decode_timing_property(timings, "vsync-len", &dt->vsync_len); + ret |= decode_timing_property(timings, "clock-frequency", &dt->pixelclock); + dt->flags = 0; + if (!ofnode_read_u32(timings, "vsync-active", &val)) { + dt->flags |= val ? DISPLAY_FLAGS_VSYNC_HIGH : + DISPLAY_FLAGS_VSYNC_LOW; + } + if (!ofnode_read_u32(timings, "hsync-active", &val)) { + dt->flags |= val ? DISPLAY_FLAGS_HSYNC_HIGH : + DISPLAY_FLAGS_HSYNC_LOW; + } + if (!ofnode_read_u32(timings, "de-active", &val)) { + dt->flags |= val ? DISPLAY_FLAGS_DE_HIGH : + DISPLAY_FLAGS_DE_LOW; + } + if (!ofnode_read_u32(timings, "pixelclk-active", &val)) { + dt->flags |= val ? DISPLAY_FLAGS_PIXDATA_POSEDGE : + DISPLAY_FLAGS_PIXDATA_NEGEDGE; + } + if (ofnode_read_bool(timings, "interlaced")) + dt->flags |= DISPLAY_FLAGS_INTERLACED; + if (ofnode_read_bool(timings, "doublescan")) + dt->flags |= DISPLAY_FLAGS_DOUBLESCAN; + if (ofnode_read_bool(timings, "doubleclk")) + dt->flags |= DISPLAY_FLAGS_DOUBLECLK; + + return ret; +} + const void *ofnode_get_property(ofnode node, const char *propname, int *lenp) { if (ofnode_is_np(node)) diff --git a/drivers/core/read.c b/drivers/core/read.c index 3e5fea87d8..e0543bbad5 100644 --- a/drivers/core/read.c +++ b/drivers/core/read.c @@ -420,6 +420,12 @@ int dev_decode_display_timing(const struct udevice *dev, int index, return ofnode_decode_display_timing(dev_ofnode(dev), index, config); } +int dev_decode_panel_timing(const struct udevice *dev, + struct display_timing *config) +{ + return ofnode_decode_panel_timing(dev_ofnode(dev), config); +} + ofnode dev_get_phy_node(const struct udevice *dev) { return ofnode_get_phy_node(dev_ofnode(dev)); diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index fa9865602d..3f6b0843c5 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -974,6 +974,18 @@ struct display_timing; int ofnode_decode_display_timing(ofnode node, int index, struct display_timing *config); +/** + * ofnode_decode_panel_timing() - decode display timings + * + * Decode panel timings from the supplied 'panel-timings' node. + * + * @node: 'display-timing' node containing the timing subnodes + * @config: Place to put timings + * Return: 0 if OK, -FDT_ERR_NOTFOUND if not found + */ +int ofnode_decode_panel_timing(ofnode node, + struct display_timing *config); + /** * ofnode_get_property() - get a pointer to the value of a node property * diff --git a/include/dm/read.h b/include/dm/read.h index cc4f16196f..56ac076c9f 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -784,6 +784,20 @@ int dev_read_pci_bus_range(const struct udevice *dev, struct resource *res); int dev_decode_display_timing(const struct udevice *dev, int index, struct display_timing *config); +/** + * dev_decode_panel_timing() - decode panel timings + * + * Decode display timings from the supplied 'panel-timings' node. + * + * @dev: device to read DT display timings from. The node linked to the device + * contains a child node called 'display-timings' which in turn contains + * one or more display timing nodes. + * @config: place to put timings + * Return: 0 if OK, -FDT_ERR_NOTFOUND if not found + */ +int dev_decode_panel_timing(const struct udevice *dev, + struct display_timing *config); + /** * dev_get_phy_node() - Get PHY node for a MAC (if not fixed-link) * @@ -1183,6 +1197,12 @@ static inline int dev_decode_display_timing(const struct udevice *dev, return ofnode_decode_display_timing(dev_ofnode(dev), index, config); } +static inline int dev_decode_panel_timing(const struct udevice *dev, + struct display_timing *config) +{ + return ofnode_decode_panel_timing(dev_ofnode(dev), config); +} + static inline ofnode dev_get_phy_node(const struct udevice *dev) { return ofnode_get_phy_node(dev_ofnode(dev));