[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260210141300.749013-4-zhengxingda@iscas.ac.cn>
Date: Tue, 10 Feb 2026 22:13:00 +0800
From: Icenowy Zheng <zhengxingda@...as.ac.cn>
To: Icenowy Zheng <zhengxingda@...as.ac.cn>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>,
Simona Vetter <simona@...ll.ch>
Cc: dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org
Subject: [PATCH drm-misc-next 3/3] drm: verisilicon: fill plane's vs_format in atomic_check
Move the conversion from drm_format to vs_format to atomic_check, which
is before the point of no return and can properly bail out.
Signed-off-by: Icenowy Zheng <zhengxingda@...as.ac.cn>
---
drivers/gpu/drm/verisilicon/vs_plane.h | 2 ++
drivers/gpu/drm/verisilicon/vs_primary_plane.c | 18 ++++++++++++------
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/verisilicon/vs_plane.h b/drivers/gpu/drm/verisilicon/vs_plane.h
index 12848a72af576..df4b248b52954 100644
--- a/drivers/gpu/drm/verisilicon/vs_plane.h
+++ b/drivers/gpu/drm/verisilicon/vs_plane.h
@@ -65,6 +65,8 @@ struct vs_format {
struct vs_plane_state {
struct drm_plane_state base;
+
+ struct vs_format format;
};
static inline struct vs_plane_state *state_to_vs_plane_state(struct drm_plane_state *state)
diff --git a/drivers/gpu/drm/verisilicon/vs_primary_plane.c b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
index bad0bc5e3242d..b5bc6b0078fc3 100644
--- a/drivers/gpu/drm/verisilicon/vs_primary_plane.c
+++ b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
@@ -25,12 +25,19 @@ static int vs_primary_plane_atomic_check(struct drm_plane *plane,
{
struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
plane);
+ struct vs_plane_state *new_vs_plane_state = state_to_vs_plane_state(new_plane_state);
struct drm_crtc *crtc = new_plane_state->crtc;
struct drm_crtc_state *crtc_state;
+ int ret;
if (!crtc)
return 0;
+ ret = drm_format_to_vs_format(new_plane_state->fb->format->format,
+ &new_vs_plane_state->format);
+ if (ret)
+ return ret;
+
crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
if (WARN_ON(!crtc_state))
return -EINVAL;
@@ -88,11 +95,11 @@ static void vs_primary_plane_atomic_update(struct drm_plane *plane,
{
struct drm_plane_state *state = drm_atomic_get_new_plane_state(atomic_state,
plane);
+ struct vs_plane_state *vs_state = state_to_vs_plane_state(state);
struct drm_framebuffer *fb = state->fb;
struct drm_crtc *crtc = state->crtc;
struct vs_dc *dc;
struct vs_crtc *vcrtc;
- struct vs_format fmt;
unsigned int output;
dma_addr_t dma_addr;
@@ -105,16 +112,15 @@ static void vs_primary_plane_atomic_update(struct drm_plane *plane,
output = vcrtc->id;
dc = vcrtc->dc;
- drm_format_to_vs_format(state->fb->format->format, &fmt);
-
regmap_update_bits(dc->regs, VSDC_FB_CONFIG(output),
VSDC_FB_CONFIG_FMT_MASK,
- VSDC_FB_CONFIG_FMT(fmt.color));
+ VSDC_FB_CONFIG_FMT(vs_state->format.color));
regmap_update_bits(dc->regs, VSDC_FB_CONFIG(output),
VSDC_FB_CONFIG_SWIZZLE_MASK,
- VSDC_FB_CONFIG_SWIZZLE(fmt.swizzle));
+ VSDC_FB_CONFIG_SWIZZLE(vs_state->format.swizzle));
regmap_assign_bits(dc->regs, VSDC_FB_CONFIG(output),
- VSDC_FB_CONFIG_UV_SWIZZLE_EN, fmt.uv_swizzle);
+ VSDC_FB_CONFIG_UV_SWIZZLE_EN,
+ vs_state->format.uv_swizzle);
dma_addr = vs_fb_get_dma_addr(fb, &state->src);
--
2.52.0
Powered by blists - more mailing lists