From: Icenowy Zheng <zhengxingda@iscas.ac.cn>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Icenowy Zheng <uwu@icenowy.me>,
Icenowy Zheng <zhengxingda@iscas.ac.cn>
Subject: [PATCH drm-misc-next v4 2/4] drm: verisilicon: subclass drm_plane_state
Date: Tue, 31 Mar 2026 14:01:24 +0800 [thread overview]
Message-ID: <20260331060126.1291966-3-zhengxingda@iscas.ac.cn> (raw)
In-Reply-To: <20260331060126.1291966-1-zhengxingda@iscas.ac.cn>
Create a subclass of drm_plane_state to store hardware-specific state
information (e.g. hardware plane format settings) in the future.
Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
---
Changes in v4:
- Add code clearing plane->state pointer after freeing it.
- Add Thomas's R-b.
Changes in v3:
- Switch to drm_WARN_ON().
- Stop to memdup the state.
- Move the code freeing the existing plane state to the branch checking
whether it's not NULL.
- Rename the typecast function to `to_vs_plane_state()`.
Changes in v2:
- Add the #include clause for atomic state helpers, which was wrongly
placed in the previous patch in v1.
- Switch to kzalloc_obj helper for allocating the state.
drivers/gpu/drm/verisilicon/vs_plane.c | 43 +++++++++++++++++++
drivers/gpu/drm/verisilicon/vs_plane.h | 14 ++++++
.../gpu/drm/verisilicon/vs_primary_plane.c | 6 +--
3 files changed, 60 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/verisilicon/vs_plane.c b/drivers/gpu/drm/verisilicon/vs_plane.c
index fa88ed14e41d7..7c6b905c9e1fa 100644
--- a/drivers/gpu/drm/verisilicon/vs_plane.c
+++ b/drivers/gpu/drm/verisilicon/vs_plane.c
@@ -6,9 +6,11 @@
#include <linux/errno.h>
#include <linux/printk.h>
+#include <drm/drm_atomic_state_helper.h>
#include <drm/drm_fb_dma_helper.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_gem_dma_helper.h>
+#include <drm/drm_print.h>
#include "vs_plane.h"
@@ -124,3 +126,44 @@ dma_addr_t vs_fb_get_dma_addr(struct drm_framebuffer *fb,
return dma_addr;
}
+
+struct drm_plane_state *vs_plane_duplicate_state(struct drm_plane *plane)
+{
+ struct vs_plane_state *vs_state;
+
+ if (drm_WARN_ON(plane->dev, !plane->state))
+ return NULL;
+
+ vs_state = kzalloc_obj(*vs_state, GFP_KERNEL);
+ if (!vs_state)
+ return NULL;
+
+ __drm_atomic_helper_plane_duplicate_state(plane, &vs_state->base);
+
+ return &vs_state->base;
+}
+
+void vs_plane_destroy_state(struct drm_plane *plane,
+ struct drm_plane_state *state)
+{
+ __drm_atomic_helper_plane_destroy_state(state);
+ kfree(state);
+}
+
+/* Called during init to allocate the plane's atomic state. */
+void vs_plane_reset(struct drm_plane *plane)
+{
+ struct vs_plane_state *vs_state;
+
+ if (plane->state) {
+ __drm_atomic_helper_plane_destroy_state(plane->state);
+ kfree(plane->state);
+ plane->state = NULL;
+ }
+
+ vs_state = kzalloc_obj(*vs_state, GFP_KERNEL);
+ if (!vs_state)
+ return;
+
+ __drm_atomic_helper_plane_reset(plane, &vs_state->base);
+}
diff --git a/drivers/gpu/drm/verisilicon/vs_plane.h b/drivers/gpu/drm/verisilicon/vs_plane.h
index a88cc19f2202e..48ed8fc754d18 100644
--- a/drivers/gpu/drm/verisilicon/vs_plane.h
+++ b/drivers/gpu/drm/verisilicon/vs_plane.h
@@ -63,10 +63,24 @@ struct vs_format {
bool uv_swizzle;
};
+struct vs_plane_state {
+ struct drm_plane_state base;
+};
+
+static inline struct vs_plane_state *to_vs_plane_state(struct drm_plane_state *state)
+{
+ return container_of(state, struct vs_plane_state, base);
+}
+
int drm_format_to_vs_format(u32 drm_format, struct vs_format *vs_format);
dma_addr_t vs_fb_get_dma_addr(struct drm_framebuffer *fb,
const struct drm_rect *src_rect);
+struct drm_plane_state *vs_plane_duplicate_state(struct drm_plane *plane);
+void vs_plane_destroy_state(struct drm_plane *plane,
+ struct drm_plane_state *state);
+void vs_plane_reset(struct drm_plane *plane);
+
struct drm_plane *vs_primary_plane_init(struct drm_device *dev, struct vs_dc *dc);
#endif /* _VS_PLANE_H_ */
diff --git a/drivers/gpu/drm/verisilicon/vs_primary_plane.c b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
index e8fcb5958615c..bad0bc5e3242d 100644
--- a/drivers/gpu/drm/verisilicon/vs_primary_plane.c
+++ b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
@@ -145,10 +145,10 @@ static const struct drm_plane_helper_funcs vs_primary_plane_helper_funcs = {
};
static const struct drm_plane_funcs vs_primary_plane_funcs = {
- .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
- .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
+ .atomic_destroy_state = vs_plane_destroy_state,
+ .atomic_duplicate_state = vs_plane_duplicate_state,
.disable_plane = drm_atomic_helper_disable_plane,
- .reset = drm_atomic_helper_plane_reset,
+ .reset = vs_plane_reset,
.update_plane = drm_atomic_helper_update_plane,
};
--
2.52.0
next prev parent reply other threads:[~2026-03-31 6:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 6:01 [PATCH drm-misc-next v4 0/4] drm: verisilicon: convert drm_format to vs_format in atomic_check Icenowy Zheng
2026-03-31 6:01 ` [PATCH drm-misc-next v4 1/4] drm: verisilicon: make vs_format conversion function return int Icenowy Zheng
2026-03-31 6:44 ` Claude review: " Claude Code Review Bot
2026-03-31 6:01 ` Icenowy Zheng [this message]
2026-03-31 6:44 ` Claude review: drm: verisilicon: subclass drm_plane_state Claude Code Review Bot
2026-03-31 6:01 ` [PATCH drm-misc-next v4 3/4] drm: verisilicon: call atomic helper's plane state check even if no CRTC Icenowy Zheng
2026-03-31 6:44 ` Claude review: " Claude Code Review Bot
2026-03-31 6:01 ` [PATCH drm-misc-next v4 4/4] drm: verisilicon: fill plane's vs_format in atomic_check Icenowy Zheng
2026-03-31 6:44 ` Claude review: " Claude Code Review Bot
2026-03-31 6:27 ` [PATCH drm-misc-next v4 0/4] drm: verisilicon: convert drm_format to " Thomas Zimmermann
2026-03-31 6:44 ` Claude review: " Claude Code Review Bot
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=20260331060126.1291966-3-zhengxingda@iscas.ac.cn \
--to=zhengxingda@iscas.ac.cn \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
--cc=uwu@icenowy.me \
/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