/* SPDX-License-Identifier: GPL-2.0-or-later */12#ifndef __DRM_GEM_ATOMIC_HELPER_H__3#define __DRM_GEM_ATOMIC_HELPER_H__45#include <linux/iosys-map.h>67#include <drm/drm_format_helper.h>8#include <drm/drm_fourcc.h>9#include <drm/drm_plane.h>1011struct drm_simple_display_pipe;1213/*14* Plane Helpers15*/1617int drm_gem_plane_helper_prepare_fb(struct drm_plane *plane, struct drm_plane_state *state);1819/*20* Helpers for planes with shadow buffers21*/2223/**24* DRM_SHADOW_PLANE_MAX_WIDTH - Maximum width of a plane's shadow buffer in pixels25*26* For drivers with shadow planes, the maximum width of the framebuffer is27* usually independent from hardware limitations. Drivers can initialize struct28* drm_mode_config.max_width from DRM_SHADOW_PLANE_MAX_WIDTH.29*/30#define DRM_SHADOW_PLANE_MAX_WIDTH (4096u)3132/**33* DRM_SHADOW_PLANE_MAX_HEIGHT - Maximum height of a plane's shadow buffer in scanlines34*35* For drivers with shadow planes, the maximum height of the framebuffer is36* usually independent from hardware limitations. Drivers can initialize struct37* drm_mode_config.max_height from DRM_SHADOW_PLANE_MAX_HEIGHT.38*/39#define DRM_SHADOW_PLANE_MAX_HEIGHT (4096u)4041/**42* struct drm_shadow_plane_state - plane state for planes with shadow buffers43*44* For planes that use a shadow buffer, struct drm_shadow_plane_state45* provides the regular plane state plus mappings of the shadow buffer46* into kernel address space.47*/48struct drm_shadow_plane_state {49/** @base: plane state */50struct drm_plane_state base;5152/**53* @fmtcnv_state: Format-conversion state54*55* Per-plane state for format conversion.56* Flags for copying shadow buffers into backend storage. Also holds57* temporary storage for format conversion.58*/59struct drm_format_conv_state fmtcnv_state;6061/* Transitional state - do not export or duplicate */6263/**64* @map: Mappings of the plane's framebuffer BOs in to kernel address space65*66* The memory mappings stored in map should be established in the plane's67* prepare_fb callback and removed in the cleanup_fb callback.68*/69struct iosys_map map[DRM_FORMAT_MAX_PLANES];7071/**72* @data: Address of each framebuffer BO's data73*74* The address of the data stored in each mapping. This is different75* for framebuffers with non-zero offset fields.76*/77struct iosys_map data[DRM_FORMAT_MAX_PLANES];78};7980/**81* to_drm_shadow_plane_state - upcasts from struct drm_plane_state82* @state: the plane state83*/84static inline struct drm_shadow_plane_state *85to_drm_shadow_plane_state(struct drm_plane_state *state)86{87return container_of(state, struct drm_shadow_plane_state, base);88}8990void __drm_gem_duplicate_shadow_plane_state(struct drm_plane *plane,91struct drm_shadow_plane_state *new_shadow_plane_state);92void __drm_gem_destroy_shadow_plane_state(struct drm_shadow_plane_state *shadow_plane_state);93void __drm_gem_reset_shadow_plane(struct drm_plane *plane,94struct drm_shadow_plane_state *shadow_plane_state);9596void drm_gem_reset_shadow_plane(struct drm_plane *plane);97struct drm_plane_state *drm_gem_duplicate_shadow_plane_state(struct drm_plane *plane);98void drm_gem_destroy_shadow_plane_state(struct drm_plane *plane,99struct drm_plane_state *plane_state);100101/**102* DRM_GEM_SHADOW_PLANE_FUNCS -103* Initializes struct drm_plane_funcs for shadow-buffered planes104*105* Drivers may use GEM BOs as shadow buffers over the framebuffer memory. This106* macro initializes struct drm_plane_funcs to use the rsp helper functions.107*/108#define DRM_GEM_SHADOW_PLANE_FUNCS \109.reset = drm_gem_reset_shadow_plane, \110.atomic_duplicate_state = drm_gem_duplicate_shadow_plane_state, \111.atomic_destroy_state = drm_gem_destroy_shadow_plane_state112113int drm_gem_begin_shadow_fb_access(struct drm_plane *plane, struct drm_plane_state *plane_state);114void drm_gem_end_shadow_fb_access(struct drm_plane *plane, struct drm_plane_state *plane_state);115116/**117* DRM_GEM_SHADOW_PLANE_HELPER_FUNCS -118* Initializes struct drm_plane_helper_funcs for shadow-buffered planes119*120* Drivers may use GEM BOs as shadow buffers over the framebuffer memory. This121* macro initializes struct drm_plane_helper_funcs to use the rsp helper122* functions.123*/124#define DRM_GEM_SHADOW_PLANE_HELPER_FUNCS \125.begin_fb_access = drm_gem_begin_shadow_fb_access, \126.end_fb_access = drm_gem_end_shadow_fb_access127128int drm_gem_simple_kms_begin_shadow_fb_access(struct drm_simple_display_pipe *pipe,129struct drm_plane_state *plane_state);130void drm_gem_simple_kms_end_shadow_fb_access(struct drm_simple_display_pipe *pipe,131struct drm_plane_state *plane_state);132void drm_gem_simple_kms_reset_shadow_plane(struct drm_simple_display_pipe *pipe);133struct drm_plane_state *134drm_gem_simple_kms_duplicate_shadow_plane_state(struct drm_simple_display_pipe *pipe);135void drm_gem_simple_kms_destroy_shadow_plane_state(struct drm_simple_display_pipe *pipe,136struct drm_plane_state *plane_state);137138/**139* DRM_GEM_SIMPLE_DISPLAY_PIPE_SHADOW_PLANE_FUNCS -140* Initializes struct drm_simple_display_pipe_funcs for shadow-buffered planes141*142* Drivers may use GEM BOs as shadow buffers over the framebuffer memory. This143* macro initializes struct drm_simple_display_pipe_funcs to use the rsp helper144* functions.145*/146#define DRM_GEM_SIMPLE_DISPLAY_PIPE_SHADOW_PLANE_FUNCS \147.begin_fb_access = drm_gem_simple_kms_begin_shadow_fb_access, \148.end_fb_access = drm_gem_simple_kms_end_shadow_fb_access, \149.reset_plane = drm_gem_simple_kms_reset_shadow_plane, \150.duplicate_plane_state = drm_gem_simple_kms_duplicate_shadow_plane_state, \151.destroy_plane_state = drm_gem_simple_kms_destroy_shadow_plane_state152153#endif /* __DRM_GEM_ATOMIC_HELPER_H__ */154155156