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