Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 
0003 #ifndef __DRM_GEM_ATOMIC_HELPER_H__
0004 #define __DRM_GEM_ATOMIC_HELPER_H__
0005 
0006 #include <linux/iosys-map.h>
0007 
0008 #include <drm/drm_fourcc.h>
0009 #include <drm/drm_plane.h>
0010 
0011 struct drm_simple_display_pipe;
0012 
0013 /*
0014  * Plane Helpers
0015  */
0016 
0017 int drm_gem_plane_helper_prepare_fb(struct drm_plane *plane, struct drm_plane_state *state);
0018 int drm_gem_simple_display_pipe_prepare_fb(struct drm_simple_display_pipe *pipe,
0019                        struct drm_plane_state *plane_state);
0020 
0021 /*
0022  * Helpers for planes with shadow buffers
0023  */
0024 
0025 /**
0026  * DRM_SHADOW_PLANE_MAX_WIDTH - Maximum width of a plane's shadow buffer in pixels
0027  *
0028  * For drivers with shadow planes, the maximum width of the framebuffer is
0029  * usually independent from hardware limitations. Drivers can initialize struct
0030  * drm_mode_config.max_width from DRM_SHADOW_PLANE_MAX_WIDTH.
0031  */
0032 #define DRM_SHADOW_PLANE_MAX_WIDTH  (4096u)
0033 
0034 /**
0035  * DRM_SHADOW_PLANE_MAX_HEIGHT - Maximum height of a plane's shadow buffer in scanlines
0036  *
0037  * For drivers with shadow planes, the maximum height of the framebuffer is
0038  * usually independent from hardware limitations. Drivers can initialize struct
0039  * drm_mode_config.max_height from DRM_SHADOW_PLANE_MAX_HEIGHT.
0040  */
0041 #define DRM_SHADOW_PLANE_MAX_HEIGHT (4096u)
0042 
0043 /**
0044  * struct drm_shadow_plane_state - plane state for planes with shadow buffers
0045  *
0046  * For planes that use a shadow buffer, struct drm_shadow_plane_state
0047  * provides the regular plane state plus mappings of the shadow buffer
0048  * into kernel address space.
0049  */
0050 struct drm_shadow_plane_state {
0051     /** @base: plane state */
0052     struct drm_plane_state base;
0053 
0054     /* Transitional state - do not export or duplicate */
0055 
0056     /**
0057      * @map: Mappings of the plane's framebuffer BOs in to kernel address space
0058      *
0059      * The memory mappings stored in map should be established in the plane's
0060      * prepare_fb callback and removed in the cleanup_fb callback.
0061      */
0062     struct iosys_map map[DRM_FORMAT_MAX_PLANES];
0063 
0064     /**
0065      * @data: Address of each framebuffer BO's data
0066      *
0067      * The address of the data stored in each mapping. This is different
0068      * for framebuffers with non-zero offset fields.
0069      */
0070     struct iosys_map data[DRM_FORMAT_MAX_PLANES];
0071 };
0072 
0073 /**
0074  * to_drm_shadow_plane_state - upcasts from struct drm_plane_state
0075  * @state: the plane state
0076  */
0077 static inline struct drm_shadow_plane_state *
0078 to_drm_shadow_plane_state(struct drm_plane_state *state)
0079 {
0080     return container_of(state, struct drm_shadow_plane_state, base);
0081 }
0082 
0083 void __drm_gem_duplicate_shadow_plane_state(struct drm_plane *plane,
0084                         struct drm_shadow_plane_state *new_shadow_plane_state);
0085 void __drm_gem_destroy_shadow_plane_state(struct drm_shadow_plane_state *shadow_plane_state);
0086 void __drm_gem_reset_shadow_plane(struct drm_plane *plane,
0087                   struct drm_shadow_plane_state *shadow_plane_state);
0088 
0089 void drm_gem_reset_shadow_plane(struct drm_plane *plane);
0090 struct drm_plane_state *drm_gem_duplicate_shadow_plane_state(struct drm_plane *plane);
0091 void drm_gem_destroy_shadow_plane_state(struct drm_plane *plane,
0092                     struct drm_plane_state *plane_state);
0093 
0094 /**
0095  * DRM_GEM_SHADOW_PLANE_FUNCS -
0096  *  Initializes struct drm_plane_funcs for shadow-buffered planes
0097  *
0098  * Drivers may use GEM BOs as shadow buffers over the framebuffer memory. This
0099  * macro initializes struct drm_plane_funcs to use the rsp helper functions.
0100  */
0101 #define DRM_GEM_SHADOW_PLANE_FUNCS \
0102     .reset = drm_gem_reset_shadow_plane, \
0103     .atomic_duplicate_state = drm_gem_duplicate_shadow_plane_state, \
0104     .atomic_destroy_state = drm_gem_destroy_shadow_plane_state
0105 
0106 int drm_gem_prepare_shadow_fb(struct drm_plane *plane, struct drm_plane_state *plane_state);
0107 void drm_gem_cleanup_shadow_fb(struct drm_plane *plane, struct drm_plane_state *plane_state);
0108 
0109 /**
0110  * DRM_GEM_SHADOW_PLANE_HELPER_FUNCS -
0111  *  Initializes struct drm_plane_helper_funcs for shadow-buffered planes
0112  *
0113  * Drivers may use GEM BOs as shadow buffers over the framebuffer memory. This
0114  * macro initializes struct drm_plane_helper_funcs to use the rsp helper
0115  * functions.
0116  */
0117 #define DRM_GEM_SHADOW_PLANE_HELPER_FUNCS \
0118     .prepare_fb = drm_gem_prepare_shadow_fb, \
0119     .cleanup_fb = drm_gem_cleanup_shadow_fb
0120 
0121 int drm_gem_simple_kms_prepare_shadow_fb(struct drm_simple_display_pipe *pipe,
0122                      struct drm_plane_state *plane_state);
0123 void drm_gem_simple_kms_cleanup_shadow_fb(struct drm_simple_display_pipe *pipe,
0124                       struct drm_plane_state *plane_state);
0125 void drm_gem_simple_kms_reset_shadow_plane(struct drm_simple_display_pipe *pipe);
0126 struct drm_plane_state *
0127 drm_gem_simple_kms_duplicate_shadow_plane_state(struct drm_simple_display_pipe *pipe);
0128 void drm_gem_simple_kms_destroy_shadow_plane_state(struct drm_simple_display_pipe *pipe,
0129                            struct drm_plane_state *plane_state);
0130 
0131 /**
0132  * DRM_GEM_SIMPLE_DISPLAY_PIPE_SHADOW_PLANE_FUNCS -
0133  *  Initializes struct drm_simple_display_pipe_funcs for shadow-buffered planes
0134  *
0135  * Drivers may use GEM BOs as shadow buffers over the framebuffer memory. This
0136  * macro initializes struct drm_simple_display_pipe_funcs to use the rsp helper
0137  * functions.
0138  */
0139 #define DRM_GEM_SIMPLE_DISPLAY_PIPE_SHADOW_PLANE_FUNCS \
0140     .prepare_fb = drm_gem_simple_kms_prepare_shadow_fb, \
0141     .cleanup_fb = drm_gem_simple_kms_cleanup_shadow_fb, \
0142     .reset_plane = drm_gem_simple_kms_reset_shadow_plane, \
0143     .duplicate_plane_state = drm_gem_simple_kms_duplicate_shadow_plane_state, \
0144     .destroy_plane_state = drm_gem_simple_kms_destroy_shadow_plane_state
0145 
0146 #endif /* __DRM_GEM_ATOMIC_HELPER_H__ */