2021-02-08 14:55:34 +03:00
/* SPDX-License-Identifier: GPL-2.0-or-later */
# ifndef __DRM_GEM_ATOMIC_HELPER_H__
# define __DRM_GEM_ATOMIC_HELPER_H__
2022-02-04 20:05:41 +03:00
# include <linux/iosys-map.h>
2021-02-08 14:55:34 +03:00
2023-10-09 17:06:31 +03:00
# include <drm/drm_format_helper.h>
2021-07-30 21:35:07 +03:00
# include <drm/drm_fourcc.h>
2021-02-08 14:55:34 +03:00
# include <drm/drm_plane.h>
struct drm_simple_display_pipe ;
2021-02-22 17:17:56 +03:00
/*
* Plane Helpers
*/
int drm_gem_plane_helper_prepare_fb ( struct drm_plane * plane , struct drm_plane_state * state ) ;
2021-02-08 14:55:34 +03:00
/*
* Helpers for planes with shadow buffers
*/
2021-11-10 13:37:01 +03:00
/**
* DRM_SHADOW_PLANE_MAX_WIDTH - Maximum width of a plane ' s shadow buffer in pixels
*
* For drivers with shadow planes , the maximum width of the framebuffer is
* usually independent from hardware limitations . Drivers can initialize struct
* drm_mode_config . max_width from DRM_SHADOW_PLANE_MAX_WIDTH .
*/
# define DRM_SHADOW_PLANE_MAX_WIDTH (4096u)
/**
* DRM_SHADOW_PLANE_MAX_HEIGHT - Maximum height of a plane ' s shadow buffer in scanlines
*
* For drivers with shadow planes , the maximum height of the framebuffer is
* usually independent from hardware limitations . Drivers can initialize struct
* drm_mode_config . max_height from DRM_SHADOW_PLANE_MAX_HEIGHT .
*/
# define DRM_SHADOW_PLANE_MAX_HEIGHT (4096u)
2021-02-08 14:55:34 +03:00
/**
* struct drm_shadow_plane_state - plane state for planes with shadow buffers
*
* For planes that use a shadow buffer , struct drm_shadow_plane_state
* provides the regular plane state plus mappings of the shadow buffer
* into kernel address space .
*/
struct drm_shadow_plane_state {
/** @base: plane state */
struct drm_plane_state base ;
2023-10-09 17:06:31 +03:00
/**
* @ fmtcnv_state : Format - conversion state
*
* Per - plane state for format conversion .
* Flags for copying shadow buffers into backend storage . Also holds
* temporary storage for format conversion .
*/
struct drm_format_conv_state fmtcnv_state ;
2021-02-08 14:55:34 +03:00
/* Transitional state - do not export or duplicate */
/**
* @ map : Mappings of the plane ' s framebuffer BOs in to kernel address space
*
* The memory mappings stored in map should be established in the plane ' s
* prepare_fb callback and removed in the cleanup_fb callback .
*/
2022-02-04 20:05:41 +03:00
struct iosys_map map [ DRM_FORMAT_MAX_PLANES ] ;
2021-08-03 15:59:18 +03:00
/**
* @ data : Address of each framebuffer BO ' s data
*
* The address of the data stored in each mapping . This is different
* for framebuffers with non - zero offset fields .
*/
2022-02-04 20:05:41 +03:00
struct iosys_map data [ DRM_FORMAT_MAX_PLANES ] ;
2021-02-08 14:55:34 +03:00
} ;
/**
* to_drm_shadow_plane_state - upcasts from struct drm_plane_state
* @ state : the plane state
*/
static inline struct drm_shadow_plane_state *
to_drm_shadow_plane_state ( struct drm_plane_state * state )
{
return container_of ( state , struct drm_shadow_plane_state , base ) ;
}
2021-07-05 10:46:30 +03:00
void __drm_gem_duplicate_shadow_plane_state ( struct drm_plane * plane ,
struct drm_shadow_plane_state * new_shadow_plane_state ) ;
void __drm_gem_destroy_shadow_plane_state ( struct drm_shadow_plane_state * shadow_plane_state ) ;
void __drm_gem_reset_shadow_plane ( struct drm_plane * plane ,
struct drm_shadow_plane_state * shadow_plane_state ) ;
2021-02-09 15:10:41 +03:00
void drm_gem_reset_shadow_plane ( struct drm_plane * plane ) ;
struct drm_plane_state * drm_gem_duplicate_shadow_plane_state ( struct drm_plane * plane ) ;
void drm_gem_destroy_shadow_plane_state ( struct drm_plane * plane ,
struct drm_plane_state * plane_state ) ;
/**
* DRM_GEM_SHADOW_PLANE_FUNCS -
* Initializes struct drm_plane_funcs for shadow - buffered planes
*
* Drivers may use GEM BOs as shadow buffers over the framebuffer memory . This
* macro initializes struct drm_plane_funcs to use the rsp helper functions .
*/
# define DRM_GEM_SHADOW_PLANE_FUNCS \
. reset = drm_gem_reset_shadow_plane , \
. atomic_duplicate_state = drm_gem_duplicate_shadow_plane_state , \
. atomic_destroy_state = drm_gem_destroy_shadow_plane_state
2022-10-25 13:17:37 +03:00
int drm_gem_begin_shadow_fb_access ( struct drm_plane * plane , struct drm_plane_state * plane_state ) ;
void drm_gem_end_shadow_fb_access ( struct drm_plane * plane , struct drm_plane_state * plane_state ) ;
2021-02-09 15:10:41 +03:00
/**
* DRM_GEM_SHADOW_PLANE_HELPER_FUNCS -
* Initializes struct drm_plane_helper_funcs for shadow - buffered planes
*
* Drivers may use GEM BOs as shadow buffers over the framebuffer memory . This
* macro initializes struct drm_plane_helper_funcs to use the rsp helper
* functions .
*/
# define DRM_GEM_SHADOW_PLANE_HELPER_FUNCS \
2022-10-25 13:17:37 +03:00
. begin_fb_access = drm_gem_begin_shadow_fb_access , \
. end_fb_access = drm_gem_end_shadow_fb_access
2021-02-09 15:10:41 +03:00
2022-10-25 13:17:37 +03:00
int drm_gem_simple_kms_begin_shadow_fb_access ( struct drm_simple_display_pipe * pipe ,
struct drm_plane_state * plane_state ) ;
void drm_gem_simple_kms_end_shadow_fb_access ( struct drm_simple_display_pipe * pipe ,
struct drm_plane_state * plane_state ) ;
2021-02-08 14:55:34 +03:00
void drm_gem_simple_kms_reset_shadow_plane ( struct drm_simple_display_pipe * pipe ) ;
struct drm_plane_state *
drm_gem_simple_kms_duplicate_shadow_plane_state ( struct drm_simple_display_pipe * pipe ) ;
void drm_gem_simple_kms_destroy_shadow_plane_state ( struct drm_simple_display_pipe * pipe ,
struct drm_plane_state * plane_state ) ;
/**
* DRM_GEM_SIMPLE_DISPLAY_PIPE_SHADOW_PLANE_FUNCS -
* Initializes struct drm_simple_display_pipe_funcs for shadow - buffered planes
*
* Drivers may use GEM BOs as shadow buffers over the framebuffer memory . This
* macro initializes struct drm_simple_display_pipe_funcs to use the rsp helper
* functions .
*/
# define DRM_GEM_SIMPLE_DISPLAY_PIPE_SHADOW_PLANE_FUNCS \
2022-10-25 13:17:37 +03:00
. begin_fb_access = drm_gem_simple_kms_begin_shadow_fb_access , \
. end_fb_access = drm_gem_simple_kms_end_shadow_fb_access , \
2021-02-08 14:55:34 +03:00
. reset_plane = drm_gem_simple_kms_reset_shadow_plane , \
. duplicate_plane_state = drm_gem_simple_kms_duplicate_shadow_plane_state , \
. destroy_plane_state = drm_gem_simple_kms_destroy_shadow_plane_state
# endif /* __DRM_GEM_ATOMIC_HELPER_H__ */