summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIcenowy Zheng <zhengxingda@iscas.ac.cn>2026-03-31 09:01:24 +0300
committerThomas Zimmermann <tzimmermann@suse.de>2026-05-04 14:30:59 +0300
commit1a2e37548077640262489c4e96dc8df877452e20 (patch)
treefa3b91ddefbea384971cc5d7c2fec0a82b9de319
parent2c23455d5aaa10eff69aa75200d5177e84640189 (diff)
downloadlinux-1a2e37548077640262489c4e96dc8df877452e20.tar.xz
drm: verisilicon: subclass drm_plane_state
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> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://patch.msgid.link/20260331060126.1291966-3-zhengxingda@iscas.ac.cn
-rw-r--r--drivers/gpu/drm/verisilicon/vs_plane.c43
-rw-r--r--drivers/gpu/drm/verisilicon/vs_plane.h14
-rw-r--r--drivers/gpu/drm/verisilicon/vs_primary_plane.c6
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 fa88ed14e41d..7c6b905c9e1f 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 a88cc19f2202..48ed8fc754d1 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 e8fcb5958615..bad0bc5e3242 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,
};