1*6dd7b6ceSThomas Zimmermann /* SPDX-License-Identifier: GPL-2.0-or-later */ 2*6dd7b6ceSThomas Zimmermann 3*6dd7b6ceSThomas Zimmermann #ifndef __DRM_GEM_ATOMIC_HELPER_H__ 4*6dd7b6ceSThomas Zimmermann #define __DRM_GEM_ATOMIC_HELPER_H__ 5*6dd7b6ceSThomas Zimmermann 6*6dd7b6ceSThomas Zimmermann #include <linux/dma-buf-map.h> 7*6dd7b6ceSThomas Zimmermann 8*6dd7b6ceSThomas Zimmermann #include <drm/drm_plane.h> 9*6dd7b6ceSThomas Zimmermann 10*6dd7b6ceSThomas Zimmermann struct drm_simple_display_pipe; 11*6dd7b6ceSThomas Zimmermann 12*6dd7b6ceSThomas Zimmermann /* 13*6dd7b6ceSThomas Zimmermann * Helpers for planes with shadow buffers 14*6dd7b6ceSThomas Zimmermann */ 15*6dd7b6ceSThomas Zimmermann 16*6dd7b6ceSThomas Zimmermann /** 17*6dd7b6ceSThomas Zimmermann * struct drm_shadow_plane_state - plane state for planes with shadow buffers 18*6dd7b6ceSThomas Zimmermann * 19*6dd7b6ceSThomas Zimmermann * For planes that use a shadow buffer, struct drm_shadow_plane_state 20*6dd7b6ceSThomas Zimmermann * provides the regular plane state plus mappings of the shadow buffer 21*6dd7b6ceSThomas Zimmermann * into kernel address space. 22*6dd7b6ceSThomas Zimmermann */ 23*6dd7b6ceSThomas Zimmermann struct drm_shadow_plane_state { 24*6dd7b6ceSThomas Zimmermann /** @base: plane state */ 25*6dd7b6ceSThomas Zimmermann struct drm_plane_state base; 26*6dd7b6ceSThomas Zimmermann 27*6dd7b6ceSThomas Zimmermann /* Transitional state - do not export or duplicate */ 28*6dd7b6ceSThomas Zimmermann 29*6dd7b6ceSThomas Zimmermann /** 30*6dd7b6ceSThomas Zimmermann * @map: Mappings of the plane's framebuffer BOs in to kernel address space 31*6dd7b6ceSThomas Zimmermann * 32*6dd7b6ceSThomas Zimmermann * The memory mappings stored in map should be established in the plane's 33*6dd7b6ceSThomas Zimmermann * prepare_fb callback and removed in the cleanup_fb callback. 34*6dd7b6ceSThomas Zimmermann */ 35*6dd7b6ceSThomas Zimmermann struct dma_buf_map map[4]; 36*6dd7b6ceSThomas Zimmermann }; 37*6dd7b6ceSThomas Zimmermann 38*6dd7b6ceSThomas Zimmermann /** 39*6dd7b6ceSThomas Zimmermann * to_drm_shadow_plane_state - upcasts from struct drm_plane_state 40*6dd7b6ceSThomas Zimmermann * @state: the plane state 41*6dd7b6ceSThomas Zimmermann */ 42*6dd7b6ceSThomas Zimmermann static inline struct drm_shadow_plane_state * 43*6dd7b6ceSThomas Zimmermann to_drm_shadow_plane_state(struct drm_plane_state *state) 44*6dd7b6ceSThomas Zimmermann { 45*6dd7b6ceSThomas Zimmermann return container_of(state, struct drm_shadow_plane_state, base); 46*6dd7b6ceSThomas Zimmermann } 47*6dd7b6ceSThomas Zimmermann 48*6dd7b6ceSThomas Zimmermann int drm_gem_simple_kms_prepare_shadow_fb(struct drm_simple_display_pipe *pipe, 49*6dd7b6ceSThomas Zimmermann struct drm_plane_state *plane_state); 50*6dd7b6ceSThomas Zimmermann void drm_gem_simple_kms_cleanup_shadow_fb(struct drm_simple_display_pipe *pipe, 51*6dd7b6ceSThomas Zimmermann struct drm_plane_state *plane_state); 52*6dd7b6ceSThomas Zimmermann void drm_gem_simple_kms_reset_shadow_plane(struct drm_simple_display_pipe *pipe); 53*6dd7b6ceSThomas Zimmermann struct drm_plane_state * 54*6dd7b6ceSThomas Zimmermann drm_gem_simple_kms_duplicate_shadow_plane_state(struct drm_simple_display_pipe *pipe); 55*6dd7b6ceSThomas Zimmermann void drm_gem_simple_kms_destroy_shadow_plane_state(struct drm_simple_display_pipe *pipe, 56*6dd7b6ceSThomas Zimmermann struct drm_plane_state *plane_state); 57*6dd7b6ceSThomas Zimmermann 58*6dd7b6ceSThomas Zimmermann /** 59*6dd7b6ceSThomas Zimmermann * DRM_GEM_SIMPLE_DISPLAY_PIPE_SHADOW_PLANE_FUNCS - 60*6dd7b6ceSThomas Zimmermann * Initializes struct drm_simple_display_pipe_funcs for shadow-buffered planes 61*6dd7b6ceSThomas Zimmermann * 62*6dd7b6ceSThomas Zimmermann * Drivers may use GEM BOs as shadow buffers over the framebuffer memory. This 63*6dd7b6ceSThomas Zimmermann * macro initializes struct drm_simple_display_pipe_funcs to use the rsp helper 64*6dd7b6ceSThomas Zimmermann * functions. 65*6dd7b6ceSThomas Zimmermann */ 66*6dd7b6ceSThomas Zimmermann #define DRM_GEM_SIMPLE_DISPLAY_PIPE_SHADOW_PLANE_FUNCS \ 67*6dd7b6ceSThomas Zimmermann .prepare_fb = drm_gem_simple_kms_prepare_shadow_fb, \ 68*6dd7b6ceSThomas Zimmermann .cleanup_fb = drm_gem_simple_kms_cleanup_shadow_fb, \ 69*6dd7b6ceSThomas Zimmermann .reset_plane = drm_gem_simple_kms_reset_shadow_plane, \ 70*6dd7b6ceSThomas Zimmermann .duplicate_plane_state = drm_gem_simple_kms_duplicate_shadow_plane_state, \ 71*6dd7b6ceSThomas Zimmermann .destroy_plane_state = drm_gem_simple_kms_destroy_shadow_plane_state 72*6dd7b6ceSThomas Zimmermann 73*6dd7b6ceSThomas Zimmermann #endif /* __DRM_GEM_ATOMIC_HELPER_H__ */ 74