16dd7b6ceSThomas Zimmermann /* SPDX-License-Identifier: GPL-2.0-or-later */ 26dd7b6ceSThomas Zimmermann 36dd7b6ceSThomas Zimmermann #ifndef __DRM_GEM_ATOMIC_HELPER_H__ 46dd7b6ceSThomas Zimmermann #define __DRM_GEM_ATOMIC_HELPER_H__ 56dd7b6ceSThomas Zimmermann 66dd7b6ceSThomas Zimmermann #include <linux/dma-buf-map.h> 76dd7b6ceSThomas Zimmermann 86dd7b6ceSThomas Zimmermann #include <drm/drm_plane.h> 96dd7b6ceSThomas Zimmermann 106dd7b6ceSThomas Zimmermann struct drm_simple_display_pipe; 116dd7b6ceSThomas Zimmermann 126dd7b6ceSThomas Zimmermann /* 13820c1707SThomas Zimmermann * Plane Helpers 14820c1707SThomas Zimmermann */ 15820c1707SThomas Zimmermann 16820c1707SThomas Zimmermann int drm_gem_plane_helper_prepare_fb(struct drm_plane *plane, struct drm_plane_state *state); 17820c1707SThomas Zimmermann int drm_gem_simple_display_pipe_prepare_fb(struct drm_simple_display_pipe *pipe, 18820c1707SThomas Zimmermann struct drm_plane_state *plane_state); 19820c1707SThomas Zimmermann 20820c1707SThomas Zimmermann /* 216dd7b6ceSThomas Zimmermann * Helpers for planes with shadow buffers 226dd7b6ceSThomas Zimmermann */ 236dd7b6ceSThomas Zimmermann 246dd7b6ceSThomas Zimmermann /** 256dd7b6ceSThomas Zimmermann * struct drm_shadow_plane_state - plane state for planes with shadow buffers 266dd7b6ceSThomas Zimmermann * 276dd7b6ceSThomas Zimmermann * For planes that use a shadow buffer, struct drm_shadow_plane_state 286dd7b6ceSThomas Zimmermann * provides the regular plane state plus mappings of the shadow buffer 296dd7b6ceSThomas Zimmermann * into kernel address space. 306dd7b6ceSThomas Zimmermann */ 316dd7b6ceSThomas Zimmermann struct drm_shadow_plane_state { 326dd7b6ceSThomas Zimmermann /** @base: plane state */ 336dd7b6ceSThomas Zimmermann struct drm_plane_state base; 346dd7b6ceSThomas Zimmermann 356dd7b6ceSThomas Zimmermann /* Transitional state - do not export or duplicate */ 366dd7b6ceSThomas Zimmermann 376dd7b6ceSThomas Zimmermann /** 386dd7b6ceSThomas Zimmermann * @map: Mappings of the plane's framebuffer BOs in to kernel address space 396dd7b6ceSThomas Zimmermann * 406dd7b6ceSThomas Zimmermann * The memory mappings stored in map should be established in the plane's 416dd7b6ceSThomas Zimmermann * prepare_fb callback and removed in the cleanup_fb callback. 426dd7b6ceSThomas Zimmermann */ 436dd7b6ceSThomas Zimmermann struct dma_buf_map map[4]; 446dd7b6ceSThomas Zimmermann }; 456dd7b6ceSThomas Zimmermann 466dd7b6ceSThomas Zimmermann /** 476dd7b6ceSThomas Zimmermann * to_drm_shadow_plane_state - upcasts from struct drm_plane_state 486dd7b6ceSThomas Zimmermann * @state: the plane state 496dd7b6ceSThomas Zimmermann */ 506dd7b6ceSThomas Zimmermann static inline struct drm_shadow_plane_state * 516dd7b6ceSThomas Zimmermann to_drm_shadow_plane_state(struct drm_plane_state *state) 526dd7b6ceSThomas Zimmermann { 536dd7b6ceSThomas Zimmermann return container_of(state, struct drm_shadow_plane_state, base); 546dd7b6ceSThomas Zimmermann } 556dd7b6ceSThomas Zimmermann 56*b7156502SThomas Zimmermann void __drm_gem_duplicate_shadow_plane_state(struct drm_plane *plane, 57*b7156502SThomas Zimmermann struct drm_shadow_plane_state *new_shadow_plane_state); 58*b7156502SThomas Zimmermann void __drm_gem_destroy_shadow_plane_state(struct drm_shadow_plane_state *shadow_plane_state); 59*b7156502SThomas Zimmermann void __drm_gem_reset_shadow_plane(struct drm_plane *plane, 60*b7156502SThomas Zimmermann struct drm_shadow_plane_state *shadow_plane_state); 61*b7156502SThomas Zimmermann 629dc9067dSThomas Zimmermann void drm_gem_reset_shadow_plane(struct drm_plane *plane); 639dc9067dSThomas Zimmermann struct drm_plane_state *drm_gem_duplicate_shadow_plane_state(struct drm_plane *plane); 649dc9067dSThomas Zimmermann void drm_gem_destroy_shadow_plane_state(struct drm_plane *plane, 659dc9067dSThomas Zimmermann struct drm_plane_state *plane_state); 669dc9067dSThomas Zimmermann 679dc9067dSThomas Zimmermann /** 689dc9067dSThomas Zimmermann * DRM_GEM_SHADOW_PLANE_FUNCS - 699dc9067dSThomas Zimmermann * Initializes struct drm_plane_funcs for shadow-buffered planes 709dc9067dSThomas Zimmermann * 719dc9067dSThomas Zimmermann * Drivers may use GEM BOs as shadow buffers over the framebuffer memory. This 729dc9067dSThomas Zimmermann * macro initializes struct drm_plane_funcs to use the rsp helper functions. 739dc9067dSThomas Zimmermann */ 749dc9067dSThomas Zimmermann #define DRM_GEM_SHADOW_PLANE_FUNCS \ 759dc9067dSThomas Zimmermann .reset = drm_gem_reset_shadow_plane, \ 769dc9067dSThomas Zimmermann .atomic_duplicate_state = drm_gem_duplicate_shadow_plane_state, \ 779dc9067dSThomas Zimmermann .atomic_destroy_state = drm_gem_destroy_shadow_plane_state 789dc9067dSThomas Zimmermann 799dc9067dSThomas Zimmermann int drm_gem_prepare_shadow_fb(struct drm_plane *plane, struct drm_plane_state *plane_state); 809dc9067dSThomas Zimmermann void drm_gem_cleanup_shadow_fb(struct drm_plane *plane, struct drm_plane_state *plane_state); 819dc9067dSThomas Zimmermann 829dc9067dSThomas Zimmermann /** 839dc9067dSThomas Zimmermann * DRM_GEM_SHADOW_PLANE_HELPER_FUNCS - 849dc9067dSThomas Zimmermann * Initializes struct drm_plane_helper_funcs for shadow-buffered planes 859dc9067dSThomas Zimmermann * 869dc9067dSThomas Zimmermann * Drivers may use GEM BOs as shadow buffers over the framebuffer memory. This 879dc9067dSThomas Zimmermann * macro initializes struct drm_plane_helper_funcs to use the rsp helper 889dc9067dSThomas Zimmermann * functions. 899dc9067dSThomas Zimmermann */ 909dc9067dSThomas Zimmermann #define DRM_GEM_SHADOW_PLANE_HELPER_FUNCS \ 919dc9067dSThomas Zimmermann .prepare_fb = drm_gem_prepare_shadow_fb, \ 929dc9067dSThomas Zimmermann .cleanup_fb = drm_gem_cleanup_shadow_fb 939dc9067dSThomas Zimmermann 946dd7b6ceSThomas Zimmermann int drm_gem_simple_kms_prepare_shadow_fb(struct drm_simple_display_pipe *pipe, 956dd7b6ceSThomas Zimmermann struct drm_plane_state *plane_state); 966dd7b6ceSThomas Zimmermann void drm_gem_simple_kms_cleanup_shadow_fb(struct drm_simple_display_pipe *pipe, 976dd7b6ceSThomas Zimmermann struct drm_plane_state *plane_state); 986dd7b6ceSThomas Zimmermann void drm_gem_simple_kms_reset_shadow_plane(struct drm_simple_display_pipe *pipe); 996dd7b6ceSThomas Zimmermann struct drm_plane_state * 1006dd7b6ceSThomas Zimmermann drm_gem_simple_kms_duplicate_shadow_plane_state(struct drm_simple_display_pipe *pipe); 1016dd7b6ceSThomas Zimmermann void drm_gem_simple_kms_destroy_shadow_plane_state(struct drm_simple_display_pipe *pipe, 1026dd7b6ceSThomas Zimmermann struct drm_plane_state *plane_state); 1036dd7b6ceSThomas Zimmermann 1046dd7b6ceSThomas Zimmermann /** 1056dd7b6ceSThomas Zimmermann * DRM_GEM_SIMPLE_DISPLAY_PIPE_SHADOW_PLANE_FUNCS - 1066dd7b6ceSThomas Zimmermann * Initializes struct drm_simple_display_pipe_funcs for shadow-buffered planes 1076dd7b6ceSThomas Zimmermann * 1086dd7b6ceSThomas Zimmermann * Drivers may use GEM BOs as shadow buffers over the framebuffer memory. This 1096dd7b6ceSThomas Zimmermann * macro initializes struct drm_simple_display_pipe_funcs to use the rsp helper 1106dd7b6ceSThomas Zimmermann * functions. 1116dd7b6ceSThomas Zimmermann */ 1126dd7b6ceSThomas Zimmermann #define DRM_GEM_SIMPLE_DISPLAY_PIPE_SHADOW_PLANE_FUNCS \ 1136dd7b6ceSThomas Zimmermann .prepare_fb = drm_gem_simple_kms_prepare_shadow_fb, \ 1146dd7b6ceSThomas Zimmermann .cleanup_fb = drm_gem_simple_kms_cleanup_shadow_fb, \ 1156dd7b6ceSThomas Zimmermann .reset_plane = drm_gem_simple_kms_reset_shadow_plane, \ 1166dd7b6ceSThomas Zimmermann .duplicate_plane_state = drm_gem_simple_kms_duplicate_shadow_plane_state, \ 1176dd7b6ceSThomas Zimmermann .destroy_plane_state = drm_gem_simple_kms_destroy_shadow_plane_state 1186dd7b6ceSThomas Zimmermann 1196dd7b6ceSThomas Zimmermann #endif /* __DRM_GEM_ATOMIC_HELPER_H__ */ 120