summaryrefslogtreecommitdiff
path: root/drivers/gpu
diff options
context:
space:
mode:
authorIcenowy Zheng <zhengxingda@iscas.ac.cn>2026-03-31 09:01:26 +0300
committerThomas Zimmermann <tzimmermann@suse.de>2026-05-04 14:30:59 +0300
commitc0d650bd0e67048dba04cdc21e8d77aef1ff0d5f (patch)
treef7cb9ce62c3a5862f331ee687b05a3737274c1f0 /drivers/gpu
parenteae3903e33797a28d0d37e693d4314d58338918e (diff)
downloadlinux-c0d650bd0e67048dba04cdc21e8d77aef1ff0d5f.tar.xz
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@iscas.ac.cn> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://patch.msgid.link/20260331060126.1291966-5-zhengxingda@iscas.ac.cn
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/verisilicon/vs_plane.c7
-rw-r--r--drivers/gpu/drm/verisilicon/vs_plane.h2
-rw-r--r--drivers/gpu/drm/verisilicon/vs_primary_plane.c36
3 files changed, 33 insertions, 12 deletions
diff --git a/drivers/gpu/drm/verisilicon/vs_plane.c b/drivers/gpu/drm/verisilicon/vs_plane.c
index 7c6b905c9e1f..d81f7b8f4c65 100644
--- a/drivers/gpu/drm/verisilicon/vs_plane.c
+++ b/drivers/gpu/drm/verisilicon/vs_plane.c
@@ -129,17 +129,22 @@ dma_addr_t vs_fb_get_dma_addr(struct drm_framebuffer *fb,
struct drm_plane_state *vs_plane_duplicate_state(struct drm_plane *plane)
{
- struct vs_plane_state *vs_state;
+ struct vs_plane_state *vs_state, *vs_state_old;
if (drm_WARN_ON(plane->dev, !plane->state))
return NULL;
+ vs_state_old = to_vs_plane_state(plane->state);
+
vs_state = kzalloc_obj(*vs_state, GFP_KERNEL);
if (!vs_state)
return NULL;
__drm_atomic_helper_plane_duplicate_state(plane, &vs_state->base);
+ memcpy(&vs_state->format, &vs_state_old->format,
+ sizeof(struct vs_format));
+
return &vs_state->base;
}
diff --git a/drivers/gpu/drm/verisilicon/vs_plane.h b/drivers/gpu/drm/verisilicon/vs_plane.h
index 48ed8fc754d1..f18c36ef4cd9 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 *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 421d6f9dc547..3576dd524f5c 100644
--- a/drivers/gpu/drm/verisilicon/vs_primary_plane.c
+++ b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
@@ -25,17 +25,32 @@ 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 = to_vs_plane_state(new_plane_state);
+ struct drm_framebuffer *fb = new_plane_state->fb;
struct drm_crtc *crtc = new_plane_state->crtc;
struct drm_crtc_state *crtc_state = NULL;
+ int ret;
if (crtc)
crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
- return drm_atomic_helper_check_plane_state(new_plane_state,
- crtc_state,
- DRM_PLANE_NO_SCALING,
- DRM_PLANE_NO_SCALING,
- false, true);
+ ret = drm_atomic_helper_check_plane_state(new_plane_state,
+ crtc_state,
+ DRM_PLANE_NO_SCALING,
+ DRM_PLANE_NO_SCALING,
+ false, true);
+ if (ret)
+ return ret;
+
+ if (!new_plane_state->visible)
+ return 0;
+
+ ret = drm_format_to_vs_format(fb->format->format,
+ &new_vs_plane_state->format);
+ if (drm_WARN_ON_ONCE(plane->dev, ret))
+ return ret;
+
+ return 0;
}
static void vs_primary_plane_commit(struct vs_dc *dc, unsigned int output)
@@ -84,11 +99,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 = 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;
@@ -101,16 +116,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);