From: Thomas Zimmermann <tzimmermann@suse.de>
To: Icenowy Zheng <uwu@icenowy.me>,
Andrzej Hajda <andrzej.hajda@intel.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Robert Foss <rfoss@kernel.org>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Drew Fustini <fustini@kernel.org>, Guo Ren <guoren@kernel.org>,
Fu Wei <wefu@redhat.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>,
Dmitry Baryshkov <lumag@kernel.org>,
Michal Wilczynski <m.wilczynski@samsung.com>,
Luca Ceresoli <luca.ceresoli@bootlin.com>,
Han Gao <rabenda.cn@gmail.com>, Yao Zi <ziyao@disroot.org>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
devicetree@vger.kernel.org, linux-riscv@lists.infradead.org,
Han Gao <gaohan@iscas.ac.cn>
Subject: Re: [PATCH v5 3/9] drm: verisilicon: add a driver for Verisilicon display controllers
Date: Wed, 28 Jan 2026 08:50:40 +0100 [thread overview]
Message-ID: <6c037a3d-8061-422b-827b-c3795dd89477@suse.de> (raw)
In-Reply-To: <7bffdc45628fec9dd8175f696d3a68aa1e12f0a2.camel@icenowy.me>
Hi
Am 22.01.26 um 10:47 schrieb Icenowy Zheng:
> 在 2026-01-21星期三的 13:56 +0100,Thomas Zimmermann写道:
>
> =================== 8< ====================
>>> +void drm_format_to_vs_format(u32 drm_format, struct vs_format
>>> *vs_format)
>>> +{
>>> + switch (drm_format) {
>>> + case DRM_FORMAT_XRGB4444:
>>> + case DRM_FORMAT_RGBX4444:
>>> + case DRM_FORMAT_XBGR4444:
>>> + case DRM_FORMAT_BGRX4444:
>>> + vs_format->color = VSDC_COLOR_FORMAT_X4R4G4B4;
>>> + break;
>>> + case DRM_FORMAT_ARGB4444:
>>> + case DRM_FORMAT_RGBA4444:
>>> + case DRM_FORMAT_ABGR4444:
>>> + case DRM_FORMAT_BGRA4444:
>>> + vs_format->color = VSDC_COLOR_FORMAT_A4R4G4B4;
>>> + break;
>>> + case DRM_FORMAT_XRGB1555:
>>> + case DRM_FORMAT_RGBX5551:
>>> + case DRM_FORMAT_XBGR1555:
>>> + case DRM_FORMAT_BGRX5551:
>>> + vs_format->color = VSDC_COLOR_FORMAT_X1R5G5B5;
>>> + break;
>>> + case DRM_FORMAT_ARGB1555:
>>> + case DRM_FORMAT_RGBA5551:
>>> + case DRM_FORMAT_ABGR1555:
>>> + case DRM_FORMAT_BGRA5551:
>>> + vs_format->color = VSDC_COLOR_FORMAT_A1R5G5B5;
>>> + break;
>>> + case DRM_FORMAT_RGB565:
>>> + case DRM_FORMAT_BGR565:
>>> + vs_format->color = VSDC_COLOR_FORMAT_R5G6B5;
>>> + break;
>>> + case DRM_FORMAT_XRGB8888:
>>> + case DRM_FORMAT_RGBX8888:
>>> + case DRM_FORMAT_XBGR8888:
>>> + case DRM_FORMAT_BGRX8888:
>>> + vs_format->color = VSDC_COLOR_FORMAT_X8R8G8B8;
>>> + break;
>>> + case DRM_FORMAT_ARGB8888:
>>> + case DRM_FORMAT_RGBA8888:
>>> + case DRM_FORMAT_ABGR8888:
>>> + case DRM_FORMAT_BGRA8888:
>>> + vs_format->color = VSDC_COLOR_FORMAT_A8R8G8B8;
>>> + break;
>>> + case DRM_FORMAT_ARGB2101010:
>>> + case DRM_FORMAT_RGBA1010102:
>>> + case DRM_FORMAT_ABGR2101010:
>>> + case DRM_FORMAT_BGRA1010102:
>>> + vs_format->color = VSDC_COLOR_FORMAT_A2R10G10B10;
>>> + break;
>>> + default:
>>> + DRM_WARN("Unexpected drm format!\n");
>> drm_warn(). If this can be invoked from user space,easily, better use
>> drm_dbg()
> This function is called during atomic_update of planes, and I think in
> this case the unknown formats should already be rejected because
> they're not advertised for any planes.
>
> Did I get it right on this?
Yes. In principle you should never reach the default case. This message
is only for testing internally.
What I usually do is to compute such internal values in the atomic_check
helper and then store them in the respective state. Here, you'd need a
custom struct vs_plane_state to hold them. If the format conversion
fails in atomic_check, it can still return an errno code to user space.
Doing this throughout the driver pushes all/most fail states before the
'magic barrier.' [1]
[1]
https://elixir.bootlin.com/linux/v6.19-rc5/source/drivers/gpu/drm/drm_atomic_helper.c#L2278
>
>>> + }
>>> +
>>> + switch (drm_format) {
>>> + case DRM_FORMAT_RGBX4444:
>>> + case DRM_FORMAT_RGBA4444:
>>> + case DRM_FORMAT_RGBX5551:
>>> + case DRM_FORMAT_RGBA5551:
>>> + case DRM_FORMAT_RGBX8888:
>>> + case DRM_FORMAT_RGBA8888:
>>> + case DRM_FORMAT_RGBA1010102:
>>> + vs_format->swizzle = VSDC_SWIZZLE_RGBA;
>>> + break;
>>> + case DRM_FORMAT_XBGR4444:
>>> + case DRM_FORMAT_ABGR4444:
>>> + case DRM_FORMAT_XBGR1555:
>>> + case DRM_FORMAT_ABGR1555:
>>> + case DRM_FORMAT_BGR565:
>>> + case DRM_FORMAT_XBGR8888:
>>> + case DRM_FORMAT_ABGR8888:
>>> + case DRM_FORMAT_ABGR2101010:
>>> + vs_format->swizzle = VSDC_SWIZZLE_ABGR;
>>> + break;
>>> + case DRM_FORMAT_BGRX4444:
>>> + case DRM_FORMAT_BGRA4444:
>>> + case DRM_FORMAT_BGRX5551:
>>> + case DRM_FORMAT_BGRA5551:
>>> + case DRM_FORMAT_BGRX8888:
>>> + case DRM_FORMAT_BGRA8888:
>>> + case DRM_FORMAT_BGRA1010102:
>>> + vs_format->swizzle = VSDC_SWIZZLE_BGRA;
>>> + break;
>>> + default:
>>> + /* N/A for YUV formats */
>>> + vs_format->swizzle = VSDC_SWIZZLE_ARGB;
>>> + }
>>> +
>>> + /* N/A for non-YUV formats */
>>> + vs_format->uv_swizzle = false;
>>> +}
These values could also go into vs_plane_state.
Best regard
Thomas
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
next prev parent reply other threads:[~2026-01-28 7:50 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-16 4:37 [PATCH v5 0/9] Verisilicon DC8200 driver (and adaption to TH1520) Icenowy Zheng
2026-01-16 4:37 ` [PATCH v5 1/9] dt-bindings: vendor-prefixes: add verisilicon Icenowy Zheng
2026-01-16 4:37 ` [PATCH v5 2/9] dt-bindings: display: add verisilicon,dc Icenowy Zheng
2026-01-21 2:21 ` Rob Herring (Arm)
2026-01-16 4:37 ` [PATCH v5 3/9] drm: verisilicon: add a driver for Verisilicon display controllers Icenowy Zheng
2026-01-21 12:56 ` Thomas Zimmermann
2026-01-22 7:06 ` Icenowy Zheng
2026-01-22 7:31 ` Thomas Zimmermann
2026-01-22 7:32 ` Thomas Zimmermann
2026-01-22 7:37 ` Icenowy Zheng
2026-01-22 7:43 ` Thomas Zimmermann
2026-01-22 9:23 ` Icenowy Zheng
2026-01-22 10:39 ` Thomas Zimmermann
2026-01-22 11:30 ` Icenowy Zheng
2026-01-22 9:28 ` Icenowy Zheng
2026-01-28 7:42 ` Thomas Zimmermann
2026-01-22 9:47 ` Icenowy Zheng
2026-01-22 9:52 ` Icenowy Zheng
2026-01-28 7:50 ` Thomas Zimmermann [this message]
2026-01-16 4:37 ` [PATCH v5 4/9] dt-bindings: display/bridge: add binding for TH1520 HDMI controller Icenowy Zheng
2026-01-16 4:37 ` [PATCH v5 5/9] drm/bridge: add a driver for T-Head " Icenowy Zheng
2026-01-16 4:37 ` [PATCH v5 6/9] riscv: dts: thead: add DPU and HDMI device tree nodes Icenowy Zheng
2026-01-16 4:37 ` [PATCH v5 7/9] riscv: dts: thead: lichee-pi-4a: enable HDMI Icenowy Zheng
2026-01-16 4:37 ` [PATCH v5 8/9] MAINTAINERS: assign myself as maintainer for verisilicon DC driver Icenowy Zheng
2026-01-16 4:37 ` [PATCH v5 9/9] mailmap: map all Icenowy Zheng's mail addresses Icenowy Zheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6c037a3d-8061-422b-827b-c3795dd89477@suse.de \
--to=tzimmermann@suse.de \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=fustini@kernel.org \
--cc=gaohan@iscas.ac.cn \
--cc=guoren@kernel.org \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=luca.ceresoli@bootlin.com \
--cc=lumag@kernel.org \
--cc=m.wilczynski@samsung.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=p.zabel@pengutronix.de \
--cc=rabenda.cn@gmail.com \
--cc=rfoss@kernel.org \
--cc=robh@kernel.org \
--cc=simona@ffwll.ch \
--cc=uwu@icenowy.me \
--cc=wefu@redhat.com \
--cc=ziyao@disroot.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®