Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/sysfb: Add custom plane state

The plane-state type struct drm_sysfb_plane_state will store the
helper for blitting to the scanout buffer.

v2:
- add variable for duplicated shadow-plane state (Javier)
- fix build error

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://lore.kernel.org/r/20250918154207.84714-2-tzimmermann@suse.de

+69 -2
+19 -1
drivers/gpu/drm/sysfb/drm_sysfb_helper.h
··· 10 10 11 11 #include <drm/drm_crtc.h> 12 12 #include <drm/drm_device.h> 13 + #include <drm/drm_gem_atomic_helper.h> 13 14 #include <drm/drm_modes.h> 14 15 15 16 struct drm_format_info; ··· 94 93 * Plane 95 94 */ 96 95 96 + struct drm_sysfb_plane_state { 97 + struct drm_shadow_plane_state base; 98 + }; 99 + 100 + static inline struct drm_sysfb_plane_state * 101 + to_drm_sysfb_plane_state(struct drm_plane_state *base) 102 + { 103 + return container_of(to_drm_shadow_plane_state(base), struct drm_sysfb_plane_state, base); 104 + } 105 + 97 106 size_t drm_sysfb_build_fourcc_list(struct drm_device *dev, 98 107 const u32 *native_fourccs, size_t native_nfourccs, 99 108 u32 *fourccs_out, size_t nfourccs_out); ··· 131 120 .atomic_disable = drm_sysfb_plane_helper_atomic_disable, \ 132 121 .get_scanout_buffer = drm_sysfb_plane_helper_get_scanout_buffer 133 122 123 + void drm_sysfb_plane_reset(struct drm_plane *plane); 124 + struct drm_plane_state *drm_sysfb_plane_atomic_duplicate_state(struct drm_plane *plane); 125 + void drm_sysfb_plane_atomic_destroy_state(struct drm_plane *plane, 126 + struct drm_plane_state *plane_state); 127 + 134 128 #define DRM_SYSFB_PLANE_FUNCS \ 129 + .reset = drm_sysfb_plane_reset, \ 135 130 .update_plane = drm_atomic_helper_update_plane, \ 136 131 .disable_plane = drm_atomic_helper_disable_plane, \ 137 - DRM_GEM_SHADOW_PLANE_FUNCS 132 + .atomic_duplicate_state = drm_sysfb_plane_atomic_duplicate_state, \ 133 + .atomic_destroy_state = drm_sysfb_plane_atomic_destroy_state 138 134 139 135 /* 140 136 * CRTC
+50 -1
drivers/gpu/drm/sysfb/drm_sysfb_modeset.c
··· 11 11 #include <drm/drm_edid.h> 12 12 #include <drm/drm_fourcc.h> 13 13 #include <drm/drm_framebuffer.h> 14 - #include <drm/drm_gem_atomic_helper.h> 15 14 #include <drm/drm_gem_framebuffer_helper.h> 16 15 #include <drm/drm_panic.h> 17 16 #include <drm/drm_print.h> ··· 184 185 } 185 186 EXPORT_SYMBOL(drm_sysfb_build_fourcc_list); 186 187 188 + static void drm_sysfb_plane_state_destroy(struct drm_sysfb_plane_state *sysfb_plane_state) 189 + { 190 + __drm_gem_destroy_shadow_plane_state(&sysfb_plane_state->base); 191 + 192 + kfree(sysfb_plane_state); 193 + } 194 + 187 195 int drm_sysfb_plane_helper_atomic_check(struct drm_plane *plane, 188 196 struct drm_atomic_state *new_state) 189 197 { ··· 326 320 return 0; 327 321 } 328 322 EXPORT_SYMBOL(drm_sysfb_plane_helper_get_scanout_buffer); 323 + 324 + void drm_sysfb_plane_reset(struct drm_plane *plane) 325 + { 326 + struct drm_sysfb_plane_state *sysfb_plane_state; 327 + 328 + if (plane->state) 329 + drm_sysfb_plane_state_destroy(to_drm_sysfb_plane_state(plane->state)); 330 + 331 + sysfb_plane_state = kzalloc(sizeof(*sysfb_plane_state), GFP_KERNEL); 332 + if (sysfb_plane_state) 333 + __drm_gem_reset_shadow_plane(plane, &sysfb_plane_state->base); 334 + else 335 + __drm_gem_reset_shadow_plane(plane, NULL); 336 + } 337 + EXPORT_SYMBOL(drm_sysfb_plane_reset); 338 + 339 + struct drm_plane_state *drm_sysfb_plane_atomic_duplicate_state(struct drm_plane *plane) 340 + { 341 + struct drm_device *dev = plane->dev; 342 + struct drm_plane_state *plane_state = plane->state; 343 + struct drm_sysfb_plane_state *new_sysfb_plane_state; 344 + struct drm_shadow_plane_state *new_shadow_plane_state; 345 + 346 + if (drm_WARN_ON(dev, !plane_state)) 347 + return NULL; 348 + 349 + new_sysfb_plane_state = kzalloc(sizeof(*new_sysfb_plane_state), GFP_KERNEL); 350 + if (!new_sysfb_plane_state) 351 + return NULL; 352 + new_shadow_plane_state = &new_sysfb_plane_state->base; 353 + 354 + __drm_gem_duplicate_shadow_plane_state(plane, new_shadow_plane_state); 355 + 356 + return &new_shadow_plane_state->base; 357 + } 358 + EXPORT_SYMBOL(drm_sysfb_plane_atomic_duplicate_state); 359 + 360 + void drm_sysfb_plane_atomic_destroy_state(struct drm_plane *plane, 361 + struct drm_plane_state *plane_state) 362 + { 363 + drm_sysfb_plane_state_destroy(to_drm_sysfb_plane_state(plane_state)); 364 + } 365 + EXPORT_SYMBOL(drm_sysfb_plane_atomic_destroy_state); 329 366 330 367 /* 331 368 * CRTC