From patchwork Thu May 16 22:16:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 1936250 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; dkim=pass (2048-bit key; unprotected) header.d=flygoat.com header.i=@flygoat.com header.a=rsa-sha256 header.s=fm1 header.b=hAGprsLC; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=i5aokhM/; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VgPbG3vH0z20KF for ; Fri, 17 May 2024 08:17:14 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5F3478848A; Fri, 17 May 2024 00:16:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=flygoat.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=flygoat.com header.i=@flygoat.com header.b="hAGprsLC"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="i5aokhM/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 81F1F8847A; Fri, 17 May 2024 00:16:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from fhigh2-smtp.messagingengine.com (fhigh2-smtp.messagingengine.com [103.168.172.153]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4840F8847B for ; Fri, 17 May 2024 00:16:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jiaxun.yang@flygoat.com Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 6F21D114017D; Thu, 16 May 2024 18:16:44 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 16 May 2024 18:16:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1715897804; x=1715984204; bh=5wsVYl5DYfdbbACTlhcq9RQbKafVnqIAW4RQkST78R0=; b= hAGprsLCYqkx6FvM2BpBDWbc2pRQX6iXPl0JQQQecQpInwDoWdHx1BwzzGjHIX0A 9VmQfdC5Bf4NV7H4oZpxOLUJV/eooZtkR/0/D0iJYFYcWKh3p+oy++//FpPFaOch C4ATmPqc97+b1UBM8m+wCx/pcvpDAM6YRZQ19U9OmdKaoy1qFZ40IrddWgqW+kpm ceuhhQwlDt9DPVaXOpdFiguP1IsvRlWP0awVM6ro/dBFdiikZKZbWCLlviGilaFr 7f1iHxSIZ7De3CDDYFwZZvkGNWfr3d4Fa38J+7SQbYXTnJ2An+ZIAXTOqY8tg3VW Z2dZ9257fC2G1bP2PVumjg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1715897804; x= 1715984204; bh=5wsVYl5DYfdbbACTlhcq9RQbKafVnqIAW4RQkST78R0=; b=i 5aokhM/2BB3m7/bAwS8EqeIdKtidMxGV3oQtHNl1oCjz62926EEPgCM7ve8hFGn8 dxx2wXwwj2aX8AAOPtd9N94Kemj7UGYdSqrF7wDWx6ClR8MIZ6kIyrBD2KQDNe8R TPhknWBn8MArBodIjEBMKgz1YvIfitBkBgrHIv+VvmqKd0AeQXBVJ/J6fAu5Hqdq 1Khw4LrdW77fO7vyZfaZSBzTo9wwvDtyTgsnx4uy7C2bZek8bm6f4jYesnsKLT4k UvWbbctJnClrcA5Ra3fHh5DxPVXiw84ywii+7H+m1tmE/FUgTw91tVk4xXiiOHRe 1zbRF4sMFaokpXAc0W+Dw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdehvddgtdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeflihgr gihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqne cuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffekgedugefhtdduudeghfeu veegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 16 May 2024 18:16:42 -0400 (EDT) From: Jiaxun Yang Date: Thu, 16 May 2024 23:16:41 +0100 Subject: [PATCH 1/6] video: Move generated bmp headers to include/generated MIME-Version: 1.0 Message-Id: <20240516-rework-video-format-v1-1-f69822b742a3@flygoat.com> References: <20240516-rework-video-format-v1-0-f69822b742a3@flygoat.com> In-Reply-To: <20240516-rework-video-format-v1-0-f69822b742a3@flygoat.com> To: u-boot@lists.denx.de Cc: Tom Rini , Heiko Schocher , Marcel Ziswiler , Anatolij Gustschin , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Jiaxun Yang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3231; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=8kOE+ZUuYQfNp37iE630ezhBV00SMxcRgIDOSD1Rr0s=; b=owGbwMvMwCHmXMhTe71c8zDjabUkhjS31tNCr3K0mny7BHMm9eb22r4SknNNFsvZWvqYefprn rv+EU87SlkYxDgYZMUUWUIElPo2NF5ccP1B1h+YOaxMIEMYuDgFYCKayxkZ9ldyfNes6X+T0KvT OvuSydNlad8OZD6/NW/vx5dG7akNdYwMc96uDe6Nrw+8e7Zxy8ys+DD+9JzUe6lyOQ08lc+m2rD wAAA= X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 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.8 at phobos.denx.de X-Virus-Status: Clean Emphasis that those headers are generated. Also naturally gitignore them. Signed-off-by: Jiaxun Yang Reviewed-by: Tom Rini Reviewed-by: Heiko Schocher --- Makefile | 2 +- board/aristainetos/aristainetos.c | 2 +- board/toradex/common/tdx-common.c | 2 +- common/splash.c | 4 ++-- tools/Makefile | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 44deb339af19..77f3fead7f26 100644 --- a/Makefile +++ b/Makefile @@ -2191,7 +2191,7 @@ CLEAN_DIRS += $(MODVERDIR) \ $(foreach d, spl tpl vpl, $(patsubst %,$d/%, \ $(filter-out include, $(shell ls -1 $d 2>/dev/null)))) -CLEAN_FILES += include/autoconf.mk* include/bmp_logo.h include/bmp_logo_data.h \ +CLEAN_FILES += include/autoconf.mk* include/generated/bmp_*.h \ include/config.h include/generated/env.* drivers/video/u_boot_logo.S \ tools/version.h u-boot* MLO* SPL System.map fit-dtb.blob* \ u-boot-ivt.img.log u-boot-dtb.imx.log SPL.log u-boot.imx.log \ diff --git a/board/aristainetos/aristainetos.c b/board/aristainetos/aristainetos.c index 8cfac9fbb342..bd7f00dfc0fe 100644 --- a/board/aristainetos/aristainetos.c +++ b/board/aristainetos/aristainetos.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -40,6 +39,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; diff --git a/board/toradex/common/tdx-common.c b/board/toradex/common/tdx-common.c index a6b45cdab810..ffd5946b4ec8 100644 --- a/board/toradex/common/tdx-common.c +++ b/board/toradex/common/tdx-common.c @@ -12,9 +12,9 @@ #include #ifdef CONFIG_VIDEO -#include #include #include +#include #endif #include "tdx-cfg-block.h" diff --git a/common/splash.c b/common/splash.c index c5591293634a..096fcba09913 100644 --- a/common/splash.c +++ b/common/splash.c @@ -62,7 +62,7 @@ static struct splash_location default_splash_locations[] = { #ifdef CONFIG_VIDEO_LOGO -#include +#include static int splash_video_logo_load(void) { @@ -121,7 +121,7 @@ void splash_get_pos(int *x, int *y) #if CONFIG_IS_ENABLED(VIDEO) && !CONFIG_IS_ENABLED(HIDE_LOGO_VERSION) #ifdef CONFIG_VIDEO_LOGO -#include +#include #endif #include #include diff --git a/tools/Makefile b/tools/Makefile index 6a4280e3668f..edbe3fabc105 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -283,8 +283,8 @@ always := $(hostprogs-y) hostprogs-y += printinitialenv # Generated LCD/video logo -LOGO_H = $(objtree)/include/bmp_logo.h -LOGO_DATA_H = $(objtree)/include/bmp_logo_data.h +LOGO_H = $(objtree)/include/generated/bmp_logo.h +LOGO_DATA_H = $(objtree)/include/generated/bmp_logo_data.h LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H) LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_DATA_H) From patchwork Thu May 16 22:16:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 1936249 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; dkim=pass (2048-bit key; unprotected) header.d=flygoat.com header.i=@flygoat.com header.a=rsa-sha256 header.s=fm1 header.b=irWu4sYj; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=k0nQq/Es; dkim-atps=neutral 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=patchwork.ozlabs.org) Received: from phobos.denx.de (unknown [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 (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VgPbD6MyLz20KF for ; Fri, 17 May 2024 08:17:12 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EF4928848B; Fri, 17 May 2024 00:16:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=flygoat.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=flygoat.com header.i=@flygoat.com header.b="irWu4sYj"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="k0nQq/Es"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3DECE88481; Fri, 17 May 2024 00:16:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from fhigh2-smtp.messagingengine.com (fhigh2-smtp.messagingengine.com [103.168.172.153]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D5F328847A for ; Fri, 17 May 2024 00:16:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jiaxun.yang@flygoat.com Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.nyi.internal (Postfix) with ESMTP id F04B91140184; Thu, 16 May 2024 18:16:45 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 16 May 2024 18:16:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1715897805; x=1715984205; bh=kYWxF9QMnStIYpC5yIe1GHvig56tidVm3UveflL5Krc=; b= irWu4sYj2dMZUWVa7VeOuvNSUWDk4b87YiD2LINC6e4IrRPscuMFcqDLSqxTHlNp fXvqWyOH+YaIEo9KiN9xF5gJUK9H/qfjuq0nD70OC11oM/hVIpH4VQEynBorsIT1 AW0h5YRD3UGJPKql/pCskAsqxtXgQbWQxLP1H0KQDT1HoOb/zsVS2+JQCkiAVcN+ I+Cdbe/lek6xPrcQvq2/gHtUsHimrRIMQrTl0T8R2c5DkpBLZe7LlMdRn7x9Cygu xYrGV8S45BKmVnsVdCjf/AvDBZlK+N/BO7fRKGOyswKM+a94YpXzeh1d6ZuwRbHO X3Frt7pMuzaDwbGk4NFabw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1715897805; x= 1715984205; bh=kYWxF9QMnStIYpC5yIe1GHvig56tidVm3UveflL5Krc=; b=k 0nQq/Esa42oXDBuX13XkCv5twNP9LfxT4icMdm9TgNOi6k3LBw1+fT2s1iCIfrm0 qwK65ht4418KazZNAnlhJV/iYku11ufIPtAYCClzovFPzddA49pl8iGHaUUhq81Q JCs9XKUc+gCVKDUkoBIFsvwy/xRQsmwWsoeGGPFlGuriI8BwV3I/ag6IARtoom9J wZK7Wp0L6ytYS6YY1DgJ+ZKWLrgcKN5lCGEKDLkbNMsfR11WEHvrIOBoqcP3yNsa /o+bvkMslDDOBow0RnHTXFEEZAnbFP5wKhQOLYiOUSkKLG9tXwcHPR/ZiTqkYmxc H3SjNe2KCbb7NXcefqZNg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdehvddgtdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeflihgr gihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqne cuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffekgedugefhtdduudeghfeu veegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 16 May 2024 18:16:44 -0400 (EDT) From: Jiaxun Yang Date: Thu, 16 May 2024 23:16:42 +0100 Subject: [PATCH 2/6] video: Add gitignore for u_boot_logo.S MIME-Version: 1.0 Message-Id: <20240516-rework-video-format-v1-2-f69822b742a3@flygoat.com> References: <20240516-rework-video-format-v1-0-f69822b742a3@flygoat.com> In-Reply-To: <20240516-rework-video-format-v1-0-f69822b742a3@flygoat.com> To: u-boot@lists.denx.de Cc: Tom Rini , Heiko Schocher , Marcel Ziswiler , Anatolij Gustschin , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Jiaxun Yang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=401; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=tcd/wXsBWhX/O8cZaJ86SBcB0LzNjhFS4SNjPeb1KY0=; b=owGbwMvMwCHmXMhTe71c8zDjabUkhjS31tNh84W4W9vF3sjOq4pvfuAUcKRu56JHn1ur5jcvn vkjP6Wno5SFQYyDQVZMkSVEQKlvQ+PFBdcfZP2BmcPKBDKEgYtTACYy8QAjwzyb03Zv50nP+bAx Ieb69Jd+Lkz8qYLL6pzf7L3kuWW7iRsjw/pFShWLDjy2v8z1NGeVbGfdlzeNk7bXuulY9il3Oc9 VZgEA X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 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.8 at phobos.denx.de X-Virus-Status: Clean We don't want this generated file to be tracked by git. Signed-off-by: Jiaxun Yang --- drivers/video/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/video/.gitignore b/drivers/video/.gitignore new file mode 100644 index 000000000000..163c491c7630 --- /dev/null +++ b/drivers/video/.gitignore @@ -0,0 +1 @@ +u_boot_logo.S From patchwork Thu May 16 22:16:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 1936251 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; dkim=pass (2048-bit key; unprotected) header.d=flygoat.com header.i=@flygoat.com header.a=rsa-sha256 header.s=fm1 header.b=k9+UmVxI; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=LhiZlSod; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VgPbR21sbz20KF for ; Fri, 17 May 2024 08:17:23 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D1D1F884A1; Fri, 17 May 2024 00:16:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=flygoat.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=flygoat.com header.i=@flygoat.com header.b="k9+UmVxI"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="LhiZlSod"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 052CB8847C; Fri, 17 May 2024 00:16:51 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from fhigh2-smtp.messagingengine.com (fhigh2-smtp.messagingengine.com [103.168.172.153]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9C21788489 for ; Fri, 17 May 2024 00:16:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jiaxun.yang@flygoat.com Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 7883C1140172; Thu, 16 May 2024 18:16:47 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 16 May 2024 18:16:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1715897807; x=1715984207; bh=cx6KTyuWLtq92wkDpy0t17BPvamyQHPgH0ZYbGrOQgI=; b= k9+UmVxINPP+QRrr6vbfiu9/VSAF7b49oC4DJGhO/Z6ytXwy+pqwri92QpUwaqmE Uyc/xFSMOeovHnyaUMDeK5uHXQhWGfqlpFMkYMN3yk3EZAlbMIS0gEHWNunjuwhq JXnDgTxBMlKyKwaJHkM0n6If7pmgvCDtG3fST3grxZ2s9eF3CZnHNVfTKNGtU8Qt q1pDjpNrSgO/7MdJ5q5SD+r7bHrLVogFz6pLDDMJmOJGJPSiUYo+3psfmIPSG7g5 2pRzMKZS9tOh1RNjglGxIwJXTFLSsfU2S9aZgIz4nBvzJMlJ9wHK9e7yLkjUKy80 ezl3StpNLvOYjh4THurAfw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1715897807; x= 1715984207; bh=cx6KTyuWLtq92wkDpy0t17BPvamyQHPgH0ZYbGrOQgI=; b=L hiZlSodq/4+f0H9f07JQ9vHFX7es85FTlwVhX7PDQPagX8vtwpR0ofr7vYi/ydAA oiKGY9sqOFBP125EavxRdeLcPB7z/AqlpXAaM4WJ6Jhly5RAW60ecIGFoWoyM+aT EMB1Gwcqph22fbuB/r/WjtN2QVQDbV6O8/pDu7OCxhU5I21XtUEOyMNQldohLJkQ 4VvoHPs/g2MaYpVvtmOMmjXd6W41zSLJ8+/ppqhOhUawLKJ/2wV1XO0/dJHkdDC3 ZYb7CcTiwQ0raq+F5jpCtIKdWHELDx6TnoEUQq1fZqozKGpJk+zloT2RVEYvXz2T K1Dl7GlRosIGHwNmyhMEA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdehvddgtdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeflihgr gihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqne cuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffekgedugefhtdduudeghfeu veegffegudekjeelnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilh hfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 16 May 2024 18:16:46 -0400 (EDT) From: Jiaxun Yang Date: Thu, 16 May 2024 23:16:43 +0100 Subject: [PATCH 3/6] video: Rework pixel format handling MIME-Version: 1.0 Message-Id: <20240516-rework-video-format-v1-3-f69822b742a3@flygoat.com> References: <20240516-rework-video-format-v1-0-f69822b742a3@flygoat.com> In-Reply-To: <20240516-rework-video-format-v1-0-f69822b742a3@flygoat.com> To: u-boot@lists.denx.de Cc: Tom Rini , Heiko Schocher , Marcel Ziswiler , Anatolij Gustschin , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Jiaxun Yang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=11394; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=otZHMksbPsU6qJ/VOMyrFf23Ej+VHX83CSs48DyjRKw=; b=owGbwMvMwCHmXMhTe71c8zDjabUkhjS31tOf8trzLwnPkNvubv9HUfcY53Gt8JWl/vXrbk+Md Ze4E3Wto5SFQYyDQVZMkSVEQKlvQ+PFBdcfZP2BmcPKBDKEgYtTACaiPoeR4V/0Fo9D5w0Y4/6u q32wrvvKxOYE1p3iGl8PfTT8z+Wx8j0jw7mkHwYTZ3bs292lX6xc8ekR29WdNZcnnnzW8snWY+v SUk4A X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 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.8 at phobos.denx.de X-Virus-Status: Clean Our current approach on naming pixel formats and handling them is a little bit confusing, we don't consider endian for framebuffers. Using Linux's naming approach instead to improve robustness of the system, also consider both endians for all pixel formats. Formats and RGB->Pixel conversion functions are stripped to video_format.h so we can include them in sdl.c without pull in all u-boot headers, and inline those conversion functions everywhere. Signed-off-by: Jiaxun Yang --- drivers/video/console_truetype.c | 4 +- drivers/video/simplefb.c | 2 +- drivers/video/video-uclass.c | 38 +++------ drivers/video/video_bmp.c | 6 +- include/video.h | 31 +------- include/video_format.h | 161 +++++++++++++++++++++++++++++++++++++++ lib/efi_loader/efi_gop.c | 2 +- 7 files changed, 179 insertions(+), 65 deletions(-) diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index c435162d3f94..ac0556ba1352 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -397,7 +397,7 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y, if (vid_priv->colour_bg) val = 255 - val; - if (vid_priv->format == VIDEO_X2R10G10B10) + if (vid_priv->format == VIDEO_XRGB2101010) out = val << 2 | val << 12 | val << 22; else out = val | val << 8 | val << 16; @@ -923,7 +923,7 @@ static int truetype_set_cursor_visible(struct udevice *dev, bool visible, for (i = 0; i < width; i++) { int out; - if (vid_priv->format == VIDEO_X2R10G10B10) + if (vid_priv->format == VIDEO_XRGB2101010) out = val << 2 | val << 12 | val << 22; else out = val | val << 8 | val << 16; diff --git a/drivers/video/simplefb.c b/drivers/video/simplefb.c index cb518b149cb5..5bbde0e8a9f9 100644 --- a/drivers/video/simplefb.c +++ b/drivers/video/simplefb.c @@ -72,7 +72,7 @@ static int simple_video_probe(struct udevice *dev) } else if (strcmp(format, "a2r10g10b10") == 0 || strcmp(format, "x2r10g10b10") == 0) { uc_priv->bpix = VIDEO_BPP32; - uc_priv->format = VIDEO_X2R10G10B10; + uc_priv->format = VIDEO_XRGB2101010; } else { log_err("%s: invalid format: %s\n", __func__, format); return -EINVAL; diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index ff1382f4a43b..513766b30fb1 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -65,13 +65,6 @@ struct video_uc_priv { ulong video_ptr; }; -/** struct vid_rgb - Describes a video colour */ -struct vid_rgb { - u32 r; - u32 g; - u32 b; -}; - void video_set_flush_dcache(struct udevice *dev, bool flush) { struct video_priv *priv = dev_get_uclass_priv(dev); @@ -259,7 +252,7 @@ int video_clear(struct udevice *dev) return 0; } -static const struct vid_rgb colours[VID_COLOUR_COUNT] = { +static const struct video_rgb colours[VID_COLOUR_COUNT] = { { 0x00, 0x00, 0x00 }, /* black */ { 0xc0, 0x00, 0x00 }, /* red */ { 0x00, 0xc0, 0x00 }, /* green */ @@ -281,30 +274,17 @@ static const struct vid_rgb colours[VID_COLOUR_COUNT] = { u32 video_index_to_colour(struct video_priv *priv, enum colour_idx idx) { switch (priv->bpix) { + case VIDEO_BPP8: + if (CONFIG_IS_ENABLED(VIDEO_BPP8)) + return video_rgb_to_pixel8(priv->format, colours[idx]); + break; case VIDEO_BPP16: - if (CONFIG_IS_ENABLED(VIDEO_BPP16)) { - return ((colours[idx].r >> 3) << 11) | - ((colours[idx].g >> 2) << 5) | - ((colours[idx].b >> 3) << 0); - } + if (CONFIG_IS_ENABLED(VIDEO_BPP16)) + return video_rgb_to_pixel16(priv->format, colours[idx]); break; case VIDEO_BPP32: - if (CONFIG_IS_ENABLED(VIDEO_BPP32)) { - switch (priv->format) { - case VIDEO_X2R10G10B10: - return (colours[idx].r << 22) | - (colours[idx].g << 12) | - (colours[idx].b << 2); - case VIDEO_RGBA8888: - return (colours[idx].r << 24) | - (colours[idx].g << 16) | - (colours[idx].b << 8) | 0xff; - default: - return (colours[idx].r << 16) | - (colours[idx].g << 8) | - (colours[idx].b << 0); - } - } + if (CONFIG_IS_ENABLED(VIDEO_BPP32)) + return video_rgb_to_pixel32(priv->format, colours[idx]); break; default: break; diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c index ad512d99a1b9..83380a87fd2b 100644 --- a/drivers/video/video_bmp.c +++ b/drivers/video/video_bmp.c @@ -80,7 +80,7 @@ static void write_pix8(u8 *fb, uint bpix, enum video_format eformat, *fb++ = cte->red; *fb++ = cte->green; *fb++ = cte->blue; - } else if (eformat == VIDEO_X2R10G10B10) { + } else if (eformat == VIDEO_XRGB2101010) { *(u32 *)fb = get_bmp_col_x2r10g10b10(cte); } else if (eformat == VIDEO_RGBA8888) { *(u32 *)fb = get_bmp_col_rgba8888(cte); @@ -385,7 +385,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, (bmap[0] >> 3); bmap += 3; fb += 2; - } else if (eformat == VIDEO_X2R10G10B10) { + } else if (eformat == VIDEO_XRGB2101010) { u32 pix; pix = *bmap++ << 2U; @@ -422,7 +422,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, if (CONFIG_IS_ENABLED(BMP_32BPP)) { for (i = 0; i < height; ++i) { for (j = 0; j < width; j++) { - if (eformat == VIDEO_X2R10G10B10) { + if (eformat == VIDEO_XRGB2101010) { u32 pix; pix = *bmap++ << 2U; diff --git a/include/video.h b/include/video.h index 4d8df9baaada..d22d6ce5fd3c 100644 --- a/include/video.h +++ b/include/video.h @@ -8,6 +8,8 @@ #define _VIDEO_H_ #include +#include +#include struct udevice; @@ -44,35 +46,6 @@ enum video_polarity { VIDEO_ACTIVE_LOW, /* Pins are active low */ }; -/* - * Bits per pixel selector. Each value n is such that the bits-per-pixel is - * 2 ^ n - */ -enum video_log2_bpp { - VIDEO_BPP1 = 0, - VIDEO_BPP2, - VIDEO_BPP4, - VIDEO_BPP8, - VIDEO_BPP16, - VIDEO_BPP32, -}; - -/* - * Convert enum video_log2_bpp to bytes and bits. Note we omit the outer - * brackets to allow multiplication by fractional pixels. - */ -#define VNBYTES(bpix) ((1 << (bpix)) / 8) - -#define VNBITS(bpix) (1 << (bpix)) - -enum video_format { - VIDEO_UNKNOWN, - VIDEO_RGBA8888, - VIDEO_X8B8G8R8, - VIDEO_X8R8G8B8, - VIDEO_X2R10G10B10, -}; - /** * struct video_priv - Device information used by the video uclass * diff --git a/include/video_format.h b/include/video_format.h new file mode 100644 index 000000000000..34a0609765c9 --- /dev/null +++ b/include/video_format.h @@ -0,0 +1,161 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (c) 2024 Jiaxun Yang + */ + +#ifndef _VIDEO_FORMAT_H_ +#define _VIDEO_FORMAT_H_ + +#include + +/* + * Bits per pixel selector. Each value n is such that the bits-per-pixel is + * 2 ^ n + */ +enum video_log2_bpp { + VIDEO_BPP8 = 3, + VIDEO_BPP16, + VIDEO_BPP32, +}; + +/* + * Convert enum video_log2_bpp to bytes and bits. Note we omit the outer + * brackets to allow multiplication by fractional pixels. + */ +#define VNBYTES(bpix) ((1 << (bpix)) / 8) + +#define VNBITS(bpix) (1 << (bpix)) + +/* Struct video_rgb - Describes a video colour, always 8 bpc */ +struct video_rgb { + uint8_t r; + uint8_t g; + uint8_t b; +}; + +/* Naming respects linux/include/uapi/drm/drm_fourcc.h */ +enum video_format { + VIDEO_DEFAULT = 0, + VIDEO_RGB332, /* [7:0] R:G:B 3:3:2 */ + VIDEO_RGB565, /* [15:0] R:G:B 5:6:5 little endian */ + VIDEO_RGB565_BE, /* [15:0] R:G:B 5:6:5 big endian */ + VIDEO_XRGB8888, /* [31:0] x:R:G:B 8:8:8:8 little endian */ + VIDEO_BGRX8888, /* [31:0] B:G:R:x 8:8:8:8 little endian */ + VIDEO_XRGB8888_BE = VIDEO_BGRX8888, + VIDEO_XBGR8888, /* [31:0] x:B:G:R 8:8:8:8 little endian */ + VIDEO_RGBA8888, /* [31:0] R:G:B:A 8:8:8:8 little endian */ + VIDEO_XRGB2101010, /* [31:0] x:R:G:B 2:10:10:10 little endian */ + VIDEO_XRGB2101010_BE, /* [31:0] x:R:G:B 2:10:10:10 big endian */ + VIDEO_FMT_END +}; + +/** + * video_rgb_to_pixel8() - convert a RGB color to a 8 bit pixel's + * memory representation. + * + * @video_format Format of pixel + * @rgb RGB color + * Return: color value + */ +static inline uint8_t video_rgb_to_pixel8(enum video_format format, + struct video_rgb rgb) +{ + switch (format) { + case VIDEO_DEFAULT: + case VIDEO_RGB332: + return ((rgb.r >> 5) << 5) | + ((rgb.g >> 5) << 2) | + (rgb.b >> 6); + default: + break; + } + return 0; +} + +/** + * video_rgb_to_pixel16() - convert a RGB color to a 16 bit pixel's + * memory representation. + * + * @video_format Format of pixel + * @rgb RGB color + * Return: color value + */ +static inline uint16_t video_rgb_to_pixel16(enum video_format format, + struct video_rgb rgb) +{ + unsigned int val = 0; + + /* Handle layout first */ + switch (format) { + case VIDEO_DEFAULT: + case VIDEO_RGB565: + case VIDEO_RGB565_BE: + val = ((rgb.r >> 3) << 11) | + ((rgb.g >> 2) << 5) | + ((rgb.b >> 3) << 0); + break; + default: + break; + } + + /* Then handle endian */ + switch (format) { + case VIDEO_RGB565_BE: + return cpu_to_be16(val); + default: + return cpu_to_le16(val); + } + +} + +/** + * video_rgb_to_pixel32() - convert a RGB color to a 32 bit pixel's + * memory representation. + * + * @video_format Format of pixel + * @rgb RGB color + * Return: color value + */ +static inline uint32_t video_rgb_to_pixel32(enum video_format format, + struct video_rgb rgb) +{ + unsigned int val = 0; + + /* Handle layout first */ + switch (format) { +#ifdef __LITTLE_ENDIAN + case VIDEO_DEFAULT: +#endif + case VIDEO_XRGB8888: + val = (rgb.r << 16) | (rgb.g << 8) | rgb.b; + break; +#ifdef __BIG_ENDIAN + case VIDEO_DEFAULT: +#endif + case VIDEO_BGRX8888: + val = (rgb.b << 24) | (rgb.g << 8) | (rgb.r << 8); + break; + case VIDEO_XBGR8888: + val = (rgb.b << 16) | (rgb.g << 8) | rgb.b; + break; + case VIDEO_RGBA8888: + val = (rgb.r << 24) | (rgb.g << 16) | (rgb.b << 8) | 0xff; + break; + case VIDEO_XRGB2101010: + case VIDEO_XRGB2101010_BE: + val = (rgb.r << 22) | (rgb.g << 12) | (rgb.b << 2); + default: + break; + } + + /* Then handle endian */ + switch (format) { + case VIDEO_XRGB2101010_BE: + return cpu_to_be32(val); + default: + return cpu_to_le32(val); + } + + return 0; +} +#endif diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c index 41e12fa72460..fec48804a472 100644 --- a/lib/efi_loader/efi_gop.c +++ b/lib/efi_loader/efi_gop.c @@ -531,7 +531,7 @@ efi_status_t efi_gop_register(void) gopobj->info.height = row; if (bpix == VIDEO_BPP32) { - if (format == VIDEO_X2R10G10B10) { + if (format == VIDEO_XRGB2101010) { gopobj->info.pixel_format = EFI_GOT_BITMASK; gopobj->info.pixel_bitmask[0] = 0x3ff00000; /* red */ gopobj->info.pixel_bitmask[1] = 0x000ffc00; /* green */ From patchwork Thu May 16 22:16:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 1936252 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; dkim=pass (2048-bit key; unprotected) header.d=flygoat.com header.i=@flygoat.com header.a=rsa-sha256 header.s=fm1 header.b=BCiFXmTx; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=UyV7ewNA; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VgPbd3v4nz20KF for ; Fri, 17 May 2024 08:17:33 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 560A088495; Fri, 17 May 2024 00:16:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=flygoat.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=flygoat.com header.i=@flygoat.com header.b="BCiFXmTx"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="UyV7ewNA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3750388497; Fri, 17 May 2024 00:16:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from fhigh2-smtp.messagingengine.com (fhigh2-smtp.messagingengine.com [103.168.172.153]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E55E88847A for ; Fri, 17 May 2024 00:16:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jiaxun.yang@flygoat.com Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 0A0991140186; Thu, 16 May 2024 18:16:49 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 16 May 2024 18:16:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1715897809; x=1715984209; bh=RIToTcx8S7EMX/U/a+0E86JecOPTDCi3li8eEj2AIKA=; b= BCiFXmTx+EMPvVh2hL9igraVk/JVpoKR+dla2gnRNfzpqkc4iUESqBmZDWoRzmOw ch3YwOf+e/N3bE62YG3N87X4r52DVDNG3ecR5o1Oqr0IHiFl4NozRoM8vbtV1n7G ESMsoc+lr6z3MvJPl9AJ1FnUMhWFDStzyy6bGCekqH/IiyoLbLCQYtSnJ6o8Op63 zEId2iWMYUF9dnR9T9lf8qqr7nFLv2R2AVcekmRlPc5MoXalw42PHi6MFXDGSEHz 264gML/jVtu0KkpIFE5T0V+Bh/ggnxqMHYHtGPe3ELw1nmcem1lHbP6aC1TZeVJF HSwkOVOFUWY+XjTp0V6O4Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1715897809; x= 1715984209; bh=RIToTcx8S7EMX/U/a+0E86JecOPTDCi3li8eEj2AIKA=; b=U yV7ewNAlfuN7n0XRu5qD81rTXMXM+lrb7vCsEonC5bOR9EBn8zAPMamaBxj5bHNG piDZh2Jm7R6n/Rxt0GBKY3Wnb4Nn+2mj0LSNi5pWeQ/jBn4OSN4tn/NWbiKKD2Yo KRu11gAkBr3gS8MkMdxnIXwUdFFWSCJBDlBJUmlMdTBfPkB7JR0AGm2+Vkl1qaKH tO/y46X7qTbOO4xFoXd7NuFGGMdcn+D2rb4iqDGT5dlxw77lkzUWSXubnAjxZn1x y9vywQnHPnMneszH/uKlE/C9hEMheO0lixVNwaAeqBNlSiyzwrvjzDehk9enH6fw kk7bdlgM5IaQPYr/t2Xxg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdehvddgtdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeflihgr gihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqne cuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffekgedugefhtdduudeghfeu veegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 16 May 2024 18:16:47 -0400 (EDT) From: Jiaxun Yang Date: Thu, 16 May 2024 23:16:44 +0100 Subject: [PATCH 4/6] video: bmp: Rework with video_rgb_to_pixel_* MIME-Version: 1.0 Message-Id: <20240516-rework-video-format-v1-4-f69822b742a3@flygoat.com> References: <20240516-rework-video-format-v1-0-f69822b742a3@flygoat.com> In-Reply-To: <20240516-rework-video-format-v1-0-f69822b742a3@flygoat.com> To: u-boot@lists.denx.de Cc: Tom Rini , Heiko Schocher , Marcel Ziswiler , Anatolij Gustschin , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Jiaxun Yang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=9710; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=AiJIKmsI55RYZc6lMlOxT37G66wNzSr76seeFsulxzE=; b=owGbwMvMwCHmXMhTe71c8zDjabUkhjS31tMGs6QmSeywf+u7MNoxK8q924Wf+9vSkMVL1T/4X p23OnBbRykLgxgHg6yYIkuIgFLfhsaLC64/yPoDM4eVCWQIAxenAEwk5Rgjw9RryosDcw8J7FPm KH9YL5eixOf6v4evWb7wpUZwfFOQO8MfPgtWHgc/Z5/p0Q3bWYMLdQ9ULHx2Y6LMrtkai09enxb HDAA= X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 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.8 at phobos.denx.de X-Virus-Status: Clean Using RGB to pixel conversion function provided in previous patch to implement frame buffer writing functions. Massively simplifed the code, also get rid of limitations on bmp_bpix vs display_bpix. Test cases are also corrected to refect a tiny change in color quantization. Signed-off-by: Jiaxun Yang --- drivers/video/video_bmp.c | 201 +++++++++++++--------------------------------- test/dm/video.c | 4 +- 2 files changed, 59 insertions(+), 146 deletions(-) diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c index 83380a87fd2b..80c276aaf231 100644 --- a/drivers/video/video_bmp.c +++ b/drivers/video/video_bmp.c @@ -17,42 +17,6 @@ #define BMP_RLE8_EOBMP 1 #define BMP_RLE8_DELTA 2 -/** - * get_bmp_col_16bpp() - Convert a colour-table entry into a 16bpp pixel value - * - * Return: value to write to the 16bpp frame buffer for this palette entry - */ -static uint get_bmp_col_16bpp(struct bmp_color_table_entry cte) -{ - return ((cte.red << 8) & 0xf800) | - ((cte.green << 3) & 0x07e0) | - ((cte.blue >> 3) & 0x001f); -} - -/** - * get_bmp_col_x2r10g10b10() - Convert a colour-table entry into a x2r10g10b10 pixel value - * - * Return: value to write to the x2r10g10b10 frame buffer for this palette entry - */ -static u32 get_bmp_col_x2r10g10b10(struct bmp_color_table_entry *cte) -{ - return ((cte->red << 22U) | - (cte->green << 12U) | - (cte->blue << 2U)); -} - -/** - * get_bmp_col_rgba8888() - Convert a colour-table entry into a rgba8888 pixel value - * - * Return: value to write to the rgba8888 frame buffer for this palette entry - */ -static u32 get_bmp_col_rgba8888(struct bmp_color_table_entry *cte) -{ - return ((cte->red) | - (cte->green << 8U) | - (cte->blue << 16U) | 0xff << 24U); -} - /** * write_pix8() - Write a pixel from a BMP image into the framebuffer * @@ -63,33 +27,37 @@ static u32 get_bmp_col_rgba8888(struct bmp_color_table_entry *cte) * @palette: BMP palette table * @bmap: Pointer to BMP bitmap position to write. This contains a single byte * which is either written directly (bpix == 8) or used to look up the - * palette to get a colour to write + * palette to get a colour to write, NULL if it's a pseudo palette with one entry. */ static void write_pix8(u8 *fb, uint bpix, enum video_format eformat, struct bmp_color_table_entry *palette, u8 *bmap) { - if (bpix == 8) { - *fb++ = *bmap; - } else if (bpix == 16) { - *(u16 *)fb = get_bmp_col_16bpp(palette[*bmap]); - } else { - /* Only support big endian */ - struct bmp_color_table_entry *cte = &palette[*bmap]; - - if (bpix == 24) { - *fb++ = cte->red; - *fb++ = cte->green; - *fb++ = cte->blue; - } else if (eformat == VIDEO_XRGB2101010) { - *(u32 *)fb = get_bmp_col_x2r10g10b10(cte); - } else if (eformat == VIDEO_RGBA8888) { - *(u32 *)fb = get_bmp_col_rgba8888(cte); - } else { - *fb++ = cte->blue; - *fb++ = cte->green; - *fb++ = cte->red; - *fb++ = 0; - } + const int entry = bmap ? *bmap : 0; + const struct video_rgb rgb = { + .r = palette[entry].red, + .g = palette[entry].green, + .b = palette[entry].blue + }; + + switch (bpix) { +#if CONFIG_IS_ENABLED(VIDEO_BPP8) + case 8: + *(u8 *)fb = video_rgb_to_pixel8(eformat, rgb); + break; +#endif +#if CONFIG_IS_ENABLED(VIDEO_BPP16) + case 16: + *(u16 *)fb = video_rgb_to_pixel16(eformat, rgb); + break; +#endif +#if CONFIG_IS_ENABLED(VIDEO_BPP32) + case 32: + *(u32 *)fb = video_rgb_to_pixel32(eformat, rgb); + break; +#endif + default: + log_debug("Unsupported BPP %d for BMP\n", bpix); + break; } } @@ -266,6 +234,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, unsigned colours, bpix, bmp_bpix; enum video_format eformat; struct bmp_color_table_entry *palette; + struct bmp_color_table_entry pseudo_cte __maybe_unused; int hdr_size; int ret; @@ -293,21 +262,6 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, return -EINVAL; } - /* - * We support displaying 8bpp and 24bpp BMPs on 16bpp LCDs - * and displaying 24bpp BMPs on 32bpp LCDs - */ - if (bpix != bmp_bpix && - !(bmp_bpix == 8 && bpix == 16) && - !(bmp_bpix == 8 && bpix == 24) && - !(bmp_bpix == 8 && bpix == 32) && - !(bmp_bpix == 24 && bpix == 16) && - !(bmp_bpix == 24 && bpix == 32)) { - printf("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n", - bpix, colours); - return -EPERM; - } - debug("Display-bmp: %d x %d with %d colours, display %d\n", (int)width, (int)height, (int)colours, 1 << bpix); @@ -354,10 +308,10 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, for (j = 0; j < width; j++) { write_pix8(fb, bpix, eformat, palette, bmap); bmap++; - fb += bpix / 8; + fb += bpix / BITS_PER_BYTE; } bmap += (padded_width - width); - fb -= byte_width + priv->line_length; + fb -= priv->line_length + width * (bpix / BITS_PER_BYTE); } break; case 16: @@ -365,93 +319,52 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, for (i = 0; i < height; ++i) { schedule(); for (j = 0; j < width; j++) { - *fb++ = *bmap++; - *fb++ = *bmap++; + u16 bmp_rgb = le16_to_cpu(*(u16 *)bmap); + /* RGB565 */ + pseudo_cte.red = ((bmp_rgb & 0xf800) >> 11) << 3; + pseudo_cte.green = ((bmp_rgb & 0x7e0) >> 5) << 2; + pseudo_cte.blue = (bmp_rgb & 0x1F) << 3; + write_pix8(fb, bpix, eformat, &pseudo_cte, NULL); + fb += (bpix / BITS_PER_BYTE); + bmap += (bmp_bpix / BITS_PER_BYTE); } bmap += (padded_width - width); - fb -= width * 2 + priv->line_length; + fb -= priv->line_length + width * (bpix / BITS_PER_BYTE); } } break; case 24: if (CONFIG_IS_ENABLED(BMP_24BPP)) { for (i = 0; i < height; ++i) { + schedule(); for (j = 0; j < width; j++) { - if (bpix == 16) { - /* 16bit 565RGB format */ - *(u16 *)fb = ((bmap[2] >> 3) - << 11) | - ((bmap[1] >> 2) << 5) | - (bmap[0] >> 3); - bmap += 3; - fb += 2; - } else if (eformat == VIDEO_XRGB2101010) { - u32 pix; - - pix = *bmap++ << 2U; - pix |= *bmap++ << 12U; - pix |= *bmap++ << 22U; - *fb++ = pix & 0xff; - *fb++ = (pix >> 8) & 0xff; - *fb++ = (pix >> 16) & 0xff; - *fb++ = pix >> 24; - } else if (eformat == VIDEO_RGBA8888) { - u32 pix; - - pix = *bmap++ << 8U; /* blue */ - pix |= *bmap++ << 16U; /* green */ - pix |= *bmap++ << 24U; /* red */ - - *fb++ = (pix >> 24) & 0xff; - *fb++ = (pix >> 16) & 0xff; - *fb++ = (pix >> 8) & 0xff; - *fb++ = 0xff; - } else { - *fb++ = *bmap++; - *fb++ = *bmap++; - *fb++ = *bmap++; - *fb++ = 0; - } + pseudo_cte.blue = *bmap++; + pseudo_cte.green = *bmap++; + pseudo_cte.red = *bmap++; + write_pix8(fb, bpix, eformat, &pseudo_cte, NULL); + fb += (bpix / BITS_PER_BYTE); } - fb -= priv->line_length + width * (bpix / 8); bmap += (padded_width - width); + fb -= priv->line_length + width * (bpix / BITS_PER_BYTE); } } break; case 32: if (CONFIG_IS_ENABLED(BMP_32BPP)) { for (i = 0; i < height; ++i) { + schedule(); for (j = 0; j < width; j++) { - if (eformat == VIDEO_XRGB2101010) { - u32 pix; - - pix = *bmap++ << 2U; - pix |= *bmap++ << 12U; - pix |= *bmap++ << 22U; - pix |= (*bmap++ >> 6) << 30U; - *fb++ = pix & 0xff; - *fb++ = (pix >> 8) & 0xff; - *fb++ = (pix >> 16) & 0xff; - *fb++ = pix >> 24; - } else if (eformat == VIDEO_RGBA8888) { - u32 pix; - - pix = *bmap++ << 8U; /* blue */ - pix |= *bmap++ << 16U; /* green */ - pix |= *bmap++ << 24U; /* red */ - bmap++; - *fb++ = (pix >> 24) & 0xff; - *fb++ = (pix >> 16) & 0xff; - *fb++ = (pix >> 8) & 0xff; - *fb++ = 0xff; /* opacity */ - } else { - *fb++ = *bmap++; - *fb++ = *bmap++; - *fb++ = *bmap++; - *fb++ = *bmap++; - } + u32 bmp_rgb = le32_to_cpu(*(u32 *)bmap); + /* RGBX8888 */ + pseudo_cte.red = (bmp_rgb >> 24) & 0xff; + pseudo_cte.green = (bmp_rgb >> 16) & 0xff; + pseudo_cte.blue = (bmp_rgb >> 8) & 0xff; + write_pix8(fb, bpix, eformat, &pseudo_cte, NULL); + fb += (bpix / BITS_PER_BYTE); + bmap += (bmp_bpix / BITS_PER_BYTE); } - fb -= priv->line_length + width * (bpix / 8); + bmap += (padded_width - width); + fb -= priv->line_length + width * (bpix / BITS_PER_BYTE); } } break; diff --git a/test/dm/video.c b/test/dm/video.c index 7dfbeb9555d1..0da96aec5efd 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -400,7 +400,7 @@ static int dm_test_video_bmp8(struct unit_test_state *uts) ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr)); ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); - ut_asserteq(1247, compress_frame_buffer(uts, dev)); + ut_asserteq(1118, compress_frame_buffer(uts, dev)); return 0; } @@ -541,7 +541,7 @@ static int dm_test_video_comp_bmp8(struct unit_test_state *uts) ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr)); ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); - ut_asserteq(1247, compress_frame_buffer(uts, dev)); + ut_asserteq(1118, compress_frame_buffer(uts, dev)); return 0; } From patchwork Thu May 16 22:16:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 1936253 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; dkim=pass (2048-bit key; unprotected) header.d=flygoat.com header.i=@flygoat.com header.a=rsa-sha256 header.s=fm1 header.b=MdmkaJ6x; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=gED7wXYY; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VgPbr5t1Bz20KF for ; Fri, 17 May 2024 08:17:44 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B92F188494; Fri, 17 May 2024 00:16:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=flygoat.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=flygoat.com header.i=@flygoat.com header.b="MdmkaJ6x"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="gED7wXYY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3E2848847B; Fri, 17 May 2024 00:16:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_FILL_THIS_FORM_SHORT autolearn=ham autolearn_force=no version=3.4.2 Received: from fout5-smtp.messagingengine.com (fout5-smtp.messagingengine.com [103.168.172.148]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BDF0C88491 for ; Fri, 17 May 2024 00:16:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jiaxun.yang@flygoat.com Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfout.nyi.internal (Postfix) with ESMTP id A71D31380184; Thu, 16 May 2024 18:16:50 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 16 May 2024 18:16:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1715897810; x=1715984210; bh=/B7QpgLfj2l1sn9wJiqnDVdHhhA13qlL8R0kHEjbYXY=; b= MdmkaJ6xNT/1cKhexD4/wPF1Z01laBASm13E1HQjJC0o+zjb88hxXDQCIGaqWvw5 z/Zr9FeAXHfY1aF5fCdxoiQ6+DPJi6qdJ84NQAZtc9nD3fOUIGbUvLg1ijdewMm0 FlC8XHR/xoDKapYfVi7pjyP7Db1ZIeNGhRBIQSqGwsL44b4kuB4cm/mlsiNeH07n MWsmXN3FrZU215Ok1xksQYPgdJtR2V8VYWEwye2JqH+PeSFUMRIaLHAzQ7diFQrx CHJ7oj32JK5d18fdAcbXKu2z1RkVZzKv1EYz+O9jTK126qrHgrY5aYiNrA06RX1v bB+xBRGoBLvE41ZxpWhLCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1715897810; x= 1715984210; bh=/B7QpgLfj2l1sn9wJiqnDVdHhhA13qlL8R0kHEjbYXY=; b=g ED7wXYYXEt9SfpyaVnyDBk6OSas4HGb3c8EszM/ERC8yAPErHaA65SqyaS7WHri9 jMxYAvVAEZpO+xQu85BJVhN7319AyLk6QPiz2amL5eFgVkq1KBKThhNXIhROg9sf DNGsV/H1V0p5k6Rm2r2xda1xw1Vubq0TmWBzQMWkAvHMdSVOjwg0XwO4/68VcO2v 0Wg3aFAzAbyv3dmT9/urXtsj/EYUkOPdAGduruSFHyk/GwOPEphrpbM9Cdb4/sIQ b9F/NkxB/9oYMrnebP6vgn5XU7/t9FLOjuYYv1tAOfKXkemBXlAOKS8jtLWl4oL6 D3Dy7uCDN69L5Up25sl3g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdehvddgtdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeflihgr gihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqne cuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffekgedugefhtdduudeghfeu veegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 16 May 2024 18:16:49 -0400 (EDT) From: Jiaxun Yang Date: Thu, 16 May 2024 23:16:45 +0100 Subject: [PATCH 5/6] video: sandbox_sdl: Implement more pixel formats MIME-Version: 1.0 Message-Id: <20240516-rework-video-format-v1-5-f69822b742a3@flygoat.com> References: <20240516-rework-video-format-v1-0-f69822b742a3@flygoat.com> In-Reply-To: <20240516-rework-video-format-v1-0-f69822b742a3@flygoat.com> To: u-boot@lists.denx.de Cc: Tom Rini , Heiko Schocher , Marcel Ziswiler , Anatolij Gustschin , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Jiaxun Yang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=12049; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=l39ZOItc7oFrTAeegqkKKERMnmrQXcphoW8P6qKV080=; b=owGbwMvMwCHmXMhTe71c8zDjabUkhjS31tNvfWpM9x3eVSp87fj+AGWhVd/sT5rb3jS6av4ks NlOtz+to5SFQYyDQVZMkSVEQKlvQ+PFBdcfZP2BmcPKBDKEgYtTACby5w0jw9tnrP909ipMiP1Z nDxZVUKgNVJu8scc7rlfV7b++LT/rTDDf0/fcK7ptjPqqs7KbbZbbxXkxLz9c/GOnNDNuhrm17W iuQA= X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 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.8 at phobos.denx.de X-Virus-Status: Clean Support most of possible pixel formats so we can test them in sandbox. Signed-off-by: Jiaxun Yang --- arch/sandbox/cpu/sdl.c | 58 +++++++++++++++++++++++++++++++++++++----- arch/sandbox/include/asm/sdl.h | 17 ++++++++----- drivers/video/sandbox_sdl.c | 16 +++++++----- include/dm/test.h | 2 ++ test/dm/video.c | 14 +++++----- 5 files changed, 81 insertions(+), 26 deletions(-) diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c index ed84646bdab7..436c0448de1f 100644 --- a/arch/sandbox/cpu/sdl.c +++ b/arch/sandbox/cpu/sdl.c @@ -5,8 +5,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -69,6 +71,47 @@ static struct sdl_info { int src_depth; } sdl; +static inline SDL_PixelFormatEnum sandbox_video_format(int l2bbp, int format) +{ + switch (l2bbp) { + case VIDEO_BPP8: + switch (format) { + case VIDEO_DEFAULT: + case VIDEO_RGB332: + return SDL_PIXELFORMAT_RGB332; + } + case VIDEO_BPP16: + switch (format) { + case VIDEO_DEFAULT: + case VIDEO_RGB565: + return SDL_PIXELFORMAT_RGB565; + default: + break; + } + break; + case VIDEO_BPP32: + switch (format) { + case VIDEO_DEFAULT: + case VIDEO_XRGB8888: + return SDL_PIXELFORMAT_RGB888; + case VIDEO_BGRX8888: + return SDL_PIXELFORMAT_BGRX8888; + case VIDEO_XBGR8888: + return SDL_PIXELFORMAT_BGR888; + case VIDEO_RGBA8888: + return SDL_PIXELFORMAT_RGBA8888; + case VIDEO_XRGB2101010: + return SDL_PIXELFORMAT_ARGB2101010; + default: + break; + } + default: + break; + } + + return SDL_PIXELFORMAT_UNKNOWN; +} + static void sandbox_sdl_poll_events(void) { /* @@ -122,9 +165,10 @@ int sandbox_sdl_remove_display(void) } int sandbox_sdl_init_display(int width, int height, int log2_bpp, - bool double_size) + int format, bool double_size) { struct sandbox_state *state = state_get_current(); + SDL_PixelFormatEnum sdl_format; int err; if (!width || !state->show_lcd) @@ -135,6 +179,12 @@ int sandbox_sdl_init_display(int width, int height, int log2_bpp, if (sdl.renderer) sandbox_sdl_remove_display(); + sdl_format = sandbox_video_format(log2_bpp, format); + if (sdl_format == SDL_PIXELFORMAT_UNKNOWN) { + printf("Unsupported video format\n"); + return -EINVAL; + } + if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) { printf("Unable to initialise SDL LCD: %s\n", SDL_GetError()); return -EPERM; @@ -153,8 +203,6 @@ int sandbox_sdl_init_display(int width, int height, int log2_bpp, printf("Unable to init hinting: %s", SDL_GetError()); sdl.src_depth = 1 << log2_bpp; - if (log2_bpp != 4 && log2_bpp != 5) - log2_bpp = 5; sdl.depth = 1 << log2_bpp; sdl.pitch = sdl.width * sdl.depth / 8; sdl.screen = SDL_CreateWindow("U-Boot", SDL_WINDOWPOS_UNDEFINED, @@ -174,9 +222,7 @@ int sandbox_sdl_init_display(int width, int height, int log2_bpp, return -EIO; } - sdl.texture = SDL_CreateTexture(sdl.renderer, log2_bpp == 4 ? - SDL_PIXELFORMAT_RGB565 : - SDL_PIXELFORMAT_RGB888, + sdl.texture = SDL_CreateTexture(sdl.renderer, sdl_format, SDL_TEXTUREACCESS_STREAMING, width, height); if (!sdl.texture) { diff --git a/arch/sandbox/include/asm/sdl.h b/arch/sandbox/include/asm/sdl.h index ee4991f7c24a..7b4f26f994da 100644 --- a/arch/sandbox/include/asm/sdl.h +++ b/arch/sandbox/include/asm/sdl.h @@ -24,7 +24,7 @@ * and -EPERM if the video failed to come up. */ int sandbox_sdl_init_display(int width, int height, int log2_bpp, - bool double_size); + int format, bool double_size); /** * sandbox_sdl_remove_display() - Remove the SDL screen @@ -89,12 +89,13 @@ int sandbox_sdl_sound_stop(void); int sandbox_sdl_sound_init(int rate, int channels); /** - * sandbox_sdl_set_bpp() - Set the depth of the sandbox display + * sandbox_sdl_set_pixel() - Set depth and format of the sandbox display * * The device must not be active when this function is called. It activiates it * before returning. * - * This updates the depth value and adjusts a few other settings accordingly. + * This updates the depth value and pixel format for the sandbox display, then + * it adjusts a few other settings accordingly. * It must be called before the display is probed. * * @dev: Device to adjust @@ -102,11 +103,12 @@ int sandbox_sdl_sound_init(int rate, int channels); * Return: 0 if the device was already active, other error if it fails to probe * after the change */ -int sandbox_sdl_set_bpp(struct udevice *dev, enum video_log2_bpp l2bpp); +int sandbox_sdl_set_pixel(struct udevice *dev, enum video_log2_bpp l2bpp, + enum video_format format); #else static inline int sandbox_sdl_init_display(int width, int height, int log2_bpp, - bool double_size) + int format, bool double_size) { return -ENODEV; } @@ -151,8 +153,9 @@ static inline int sandbox_sdl_sound_init(int rate, int channels) return -ENODEV; } -static inline int sandbox_sdl_set_bpp(struct udevice *dev, - enum video_log2_bpp l2bpp) +static inline int sandbox_sdl_set_pixel(struct udevice *dev, + enum video_log2_bpp l2bpp, + enum video_format format) { return -ENOSYS; } diff --git a/drivers/video/sandbox_sdl.c b/drivers/video/sandbox_sdl.c index 69dfa9302735..ddd72a14de83 100644 --- a/drivers/video/sandbox_sdl.c +++ b/drivers/video/sandbox_sdl.c @@ -31,7 +31,7 @@ static int sandbox_sdl_probe(struct udevice *dev) int ret; ret = sandbox_sdl_init_display(plat->xres, plat->yres, plat->bpix, - state->double_lcd); + plat->format, state->double_lcd); if (ret) { puts("LCD init failed\n"); return ret; @@ -39,6 +39,7 @@ static int sandbox_sdl_probe(struct udevice *dev) uc_priv->xsize = plat->xres; uc_priv->ysize = plat->yres; uc_priv->bpix = plat->bpix; + uc_priv->format = plat->format; uc_priv->rot = plat->rot; uc_priv->vidconsole_drv_name = plat->vidconsole_drv_name; uc_priv->font_size = plat->font_size; @@ -48,12 +49,14 @@ static int sandbox_sdl_probe(struct udevice *dev) return 0; } -static void set_bpp(struct udevice *dev, enum video_log2_bpp l2bpp) +static void set_pixel(struct udevice *dev, enum video_log2_bpp l2bpp, + enum video_format format) { struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); struct sandbox_sdl_plat *plat = dev_get_plat(dev); plat->bpix = l2bpp; + plat->format = format; uc_plat->size = plat->xres * plat->yres * VNBYTES(plat->bpix); @@ -61,7 +64,7 @@ static void set_bpp(struct udevice *dev, enum video_log2_bpp l2bpp) * Set up to the maximum size we'll ever need. This is a strange case. * The video memory is allocated by video_post_bind() called from * board_init_r(). If a test changes the reoslution so it needs more - * memory later (with sandbox_sdl_set_bpp()), it is too late to make + * memory later (with sandbox_sdl_set_pixel()), it is too late to make * the frame buffer larger. * * So use a maximum size here. @@ -79,7 +82,8 @@ static void set_bpp(struct udevice *dev, enum video_log2_bpp l2bpp) uc_plat->size *= 2; } -int sandbox_sdl_set_bpp(struct udevice *dev, enum video_log2_bpp l2bpp) +int sandbox_sdl_set_pixel(struct udevice *dev, enum video_log2_bpp l2bpp, + enum video_format format) { struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); int ret; @@ -89,7 +93,7 @@ int sandbox_sdl_set_bpp(struct udevice *dev, enum video_log2_bpp l2bpp) sandbox_sdl_remove_display(); uc_plat->hide_logo = true; - set_bpp(dev, l2bpp); + set_pixel(dev, l2bpp, format); ret = device_probe(dev); if (ret) @@ -122,7 +126,7 @@ static int sandbox_sdl_bind(struct udevice *dev) l2bpp = dev_read_u32_default(dev, "log2-depth", VIDEO_BPP16); plat->rot = dev_read_u32_default(dev, "rotate", 0); - set_bpp(dev, l2bpp); + set_pixel(dev, l2bpp, VIDEO_DEFAULT); return ret; } diff --git a/include/dm/test.h b/include/dm/test.h index 02737411a164..87568d741d49 100644 --- a/include/dm/test.h +++ b/include/dm/test.h @@ -153,6 +153,7 @@ extern struct unit_test_state global_dm_test_state; * @xres: Width of display in pixels * @yres: Height of display in pixels * @bpix: Log2 of bits per pixel (enum video_log2_bpp) + * @format: Pixel format (enum video_format) * @rot: Console rotation (0=normal orientation, 1=90 degrees clockwise, * 2=upside down, 3=90 degree counterclockwise) * @vidconsole_drv_name: Name of video console driver (set by tests) @@ -162,6 +163,7 @@ struct sandbox_sdl_plat { int xres; int yres; int bpix; + int format; int rot; const char *vidconsole_drv_name; int font_size; diff --git a/test/dm/video.c b/test/dm/video.c index 0da96aec5efd..47a8df511e8b 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -395,7 +395,7 @@ static int dm_test_video_bmp8(struct unit_test_state *uts) ut_assertok(uclass_find_first_device(UCLASS_VIDEO, &dev)); ut_assertnonnull(dev); - ut_assertok(sandbox_sdl_set_bpp(dev, VIDEO_BPP8)); + ut_assertok(sandbox_sdl_set_pixel(dev, VIDEO_BPP8, VIDEO_DEFAULT)); ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr)); @@ -416,7 +416,7 @@ static int dm_test_video_bmp16(struct unit_test_state *uts) ut_assertok(uclass_find_first_device(UCLASS_VIDEO, &dev)); ut_assertnonnull(dev); - ut_assertok(sandbox_sdl_set_bpp(dev, VIDEO_BPP16)); + ut_assertok(sandbox_sdl_set_pixel(dev, VIDEO_BPP16, VIDEO_DEFAULT)); ut_assertok(read_file(uts, "tools/logos/denx-16bpp.bmp.gz", &src)); ut_assertok(gunzip(map_sysmem(dst, 0), dst_len, map_sysmem(src, 0), @@ -439,7 +439,7 @@ static int dm_test_video_bmp24(struct unit_test_state *uts) ut_assertok(uclass_find_first_device(UCLASS_VIDEO, &dev)); ut_assertnonnull(dev); - ut_assertok(sandbox_sdl_set_bpp(dev, VIDEO_BPP16)); + ut_assertok(sandbox_sdl_set_pixel(dev, VIDEO_BPP16, VIDEO_DEFAULT)); ut_assertok(read_file(uts, "tools/logos/denx-24bpp.bmp.gz", &src)); ut_assertok(gunzip(map_sysmem(dst, 0), dst_len, map_sysmem(src, 0), @@ -462,7 +462,7 @@ static int dm_test_video_bmp24_32(struct unit_test_state *uts) ut_assertok(uclass_find_first_device(UCLASS_VIDEO, &dev)); ut_assertnonnull(dev); - ut_assertok(sandbox_sdl_set_bpp(dev, VIDEO_BPP32)); + ut_assertok(sandbox_sdl_set_pixel(dev, VIDEO_BPP32, VIDEO_DEFAULT)); ut_assertok(read_file(uts, "tools/logos/denx-24bpp.bmp.gz", &src)); ut_assertok(gunzip(map_sysmem(dst, 0), dst_len, map_sysmem(src, 0), @@ -483,7 +483,7 @@ static int dm_test_video_bmp32(struct unit_test_state *uts) ut_assertok(uclass_find_first_device(UCLASS_VIDEO, &dev)); ut_assertnonnull(dev); - ut_assertok(sandbox_sdl_set_bpp(dev, VIDEO_BPP32)); + ut_assertok(sandbox_sdl_set_pixel(dev, VIDEO_BPP32, VIDEO_DEFAULT)); ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr)); ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); @@ -517,7 +517,7 @@ static int dm_test_video_comp_bmp32(struct unit_test_state *uts) ut_assertok(uclass_find_first_device(UCLASS_VIDEO, &dev)); ut_assertnonnull(dev); - ut_assertok(sandbox_sdl_set_bpp(dev, VIDEO_BPP32)); + ut_assertok(sandbox_sdl_set_pixel(dev, VIDEO_BPP32, VIDEO_DEFAULT)); ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr)); @@ -536,7 +536,7 @@ static int dm_test_video_comp_bmp8(struct unit_test_state *uts) ut_assertok(uclass_find_first_device(UCLASS_VIDEO, &dev)); ut_assertnonnull(dev); - ut_assertok(sandbox_sdl_set_bpp(dev, VIDEO_BPP8)); + ut_assertok(sandbox_sdl_set_pixel(dev, VIDEO_BPP8, VIDEO_DEFAULT)); ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr)); From patchwork Thu May 16 22:16:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 1936254 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; dkim=pass (2048-bit key; unprotected) header.d=flygoat.com header.i=@flygoat.com header.a=rsa-sha256 header.s=fm1 header.b=MzsJChoO; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=ce7z+UTo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VgPc41ssDz20KF for ; Fri, 17 May 2024 08:17:56 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 40F9A88490; Fri, 17 May 2024 00:16:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=flygoat.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=flygoat.com header.i=@flygoat.com header.b="MzsJChoO"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="ce7z+UTo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D1752884B2; Fri, 17 May 2024 00:16:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from fout5-smtp.messagingengine.com (fout5-smtp.messagingengine.com [103.168.172.148]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E3E5988497 for ; Fri, 17 May 2024 00:16:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jiaxun.yang@flygoat.com Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.nyi.internal (Postfix) with ESMTP id 217A81381490; Thu, 16 May 2024 18:16:52 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 16 May 2024 18:16:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1715897812; x=1715984212; bh=ze5ngytg22cjvD1Nv+QLVnxU/YWOFZVAcX/MOEWHU9I=; b= MzsJChoOsoX6sLlZq+0AU1b8WRNluzORML0dVFVnuF9q3pbMrGlMHTTHiYvMOFSi Fw3Mewu1LScxL1NXwhaU1Oln/0C3MSvHhJxxHzhEOL8G7WyLnGmlOCDdubL/3GJo Bt7qDVHG0/iupsQW2HAOymUssaIEcT+AjFFJxWXU1qYytjrbbBptg33lR1RdPXI8 dyYH8vV5pkbGAsb4NgSf1qq4rmtkpMvWeCR5JH4lVDzH2QWzqlVhDElOh5DCpQgb 1muYFjOhALllCe1FxUidoHMlQH20eDCYTS5R1lVBut73FY+pynTJ/zeG0P/283I3 UMZnyWNDZBf6/RBhOxkqig== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1715897812; x= 1715984212; bh=ze5ngytg22cjvD1Nv+QLVnxU/YWOFZVAcX/MOEWHU9I=; b=c e7z+UToPhN/B/5PZ6KYezgc0qSQ1IF37iKOBF8n7/58kOZcJpY45Rdzz4JaQhwPi Ey5uM01K1ugM/BUDsHiG5Bd3yFkJZrH1dnjHmGVO3GBWpNtPcjsVDH7UONcCPw4q nfc0eb8Mjy5wH9t9gBeFNsK+1JJPKZCHQ0B7NDFU3hZuuJF4bwsnzLVNBo8M+qWZ qncZqSwUSYxuUTUYucWfYzOXe3leUjN/Wc2dkJD2iXiDIbz08XV7B2L6sMYyptRp O+vDA+ai5alO+Fqn6ObimrHkHz6ceGCY311vN2l+w2HobACnq89X/C2NmQu9orFb yRKlmrL54lHug7ueydShg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdehvddgtdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeflihgr gihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqne cuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffekgedugefhtdduudeghfeu veegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 16 May 2024 18:16:50 -0400 (EDT) From: Jiaxun Yang Date: Thu, 16 May 2024 23:16:46 +0100 Subject: [PATCH 6/6] video: bochs: Setup framebuffer endian MIME-Version: 1.0 Message-Id: <20240516-rework-video-format-v1-6-f69822b742a3@flygoat.com> References: <20240516-rework-video-format-v1-0-f69822b742a3@flygoat.com> In-Reply-To: <20240516-rework-video-format-v1-0-f69822b742a3@flygoat.com> To: u-boot@lists.denx.de Cc: Tom Rini , Heiko Schocher , Marcel Ziswiler , Anatolij Gustschin , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Jiaxun Yang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1193; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=uXUkYoxewDtt2lIZLTm3YxBjI1nWZJYFhbEQwgQyN3o=; b=owGbwMvMwCHmXMhTe71c8zDjabUkhjS31tNXN+Xl50y0u/OB68iSi/+06017WKWcr5m+c/yb7 lDzaYpfRykLgxgHg6yYIkuIgFLfhsaLC64/yPoDM4eVCWQIAxenAEzkuhHDf68vLMeyzt89pveO 8Z/zbqvyG38kXNy+2Ek4MQZq33effoiRoem/fJrFvMXzn3dZ24copc52X3/56In4v8qqNzwbzs5 jYwEA X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 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.8 at phobos.denx.de X-Virus-Status: Clean So the current situation on endian of bochs framebufer is a little bit complex. QEMU defaulted to little endian for both endian hardware except on powerpc, but provided an endian swich register allows OS to switch endian. Since we can't guarantee the endian switch register is functional, my approach is to default to little endian framebuffer for ISAs except powerpc and perform endian switch to match this assumption. Signed-off-by: Jiaxun Yang --- drivers/video/bochs.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/video/bochs.c b/drivers/video/bochs.c index 00e673a4db08..c315c5477b14 100644 --- a/drivers/video/bochs.c +++ b/drivers/video/bochs.c @@ -65,6 +65,14 @@ static int bochs_init_fb(struct udevice *dev) uc_priv->ysize = ysize; uc_priv->bpix = VIDEO_BPP32; +#if defined(__powerpc__) && defined(__BIG_ENDIAN) + uc_priv->format = VIDEO_XRGB8888_BE; + writel(0xbebebebe, mmio + 0x604); +#else + uc_priv->format = VIDEO_XRGB8888; + writel(0x1e1e1e1e, mmio + 0x604); +#endif + /* setup video mode */ bochs_write(mmio, INDEX_ENABLE, 0); bochs_write(mmio, INDEX_BANK, 0);