| 1 |
/* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 |
|
| 3 |
#ifndef __DRM_GEM_ATOMIC_HELPER_H__ |
| 4 |
#define __DRM_GEM_ATOMIC_HELPER_H__ |
| 5 |
|
| 6 |
#include <linux/iosys-map.h> |
| 7 |
|
| 8 |
#include <drm/drm_format_helper.h> |
| 9 |
#include <drm/drm_fourcc.h> |
| 10 |
#include <drm/drm_plane.h> |
| 11 |
|
| 12 |
struct drm_simple_display_pipe; |
| 13 |
|
| 14 |
/* |
| 15 |
* Plane Helpers |
| 16 |
*/ |
| 17 |
|
| 18 |
int drm_gem_plane_helper_prepare_fb(struct drm_plane *plane, struct drm_plane_state *state); |
| 19 |
|
| 20 |
/* |
| 21 |
* Helpers for planes with shadow buffers |
| 22 |
*/ |
| 23 |
|
| 24 |
/** |
| 25 |
* DRM_SHADOW_PLANE_MAX_WIDTH - Maximum width of a plane's shadow buffer in pixels |
| 26 |
* |
| 27 |
* For drivers with shadow planes, the maximum width of the framebuffer is |
| 28 |
* usually independent from hardware limitations. Drivers can initialize struct |
| 29 |
* drm_mode_config.max_width from DRM_SHADOW_PLANE_MAX_WIDTH. |
| 30 |
*/ |
| 31 |
#define DRM_SHADOW_PLANE_MAX_WIDTH (4096u) |
| 32 |
|
| 33 |
/** |
| 34 |
* DRM_SHADOW_PLANE_MAX_HEIGHT - Maximum height of a plane's shadow buffer in scanlines |
| 35 |
* |
| 36 |
* For drivers with shadow planes, the maximum height of the framebuffer is |
| 37 |
* usually independent from hardware limitations. Drivers can initialize struct |
| 38 |
* drm_mode_config.max_height from DRM_SHADOW_PLANE_MAX_HEIGHT. |
| 39 |
*/ |
| 40 |
#define DRM_SHADOW_PLANE_MAX_HEIGHT (4096u) |
| 41 |
|
| 42 |
/** |
| 43 |
* struct drm_shadow_plane_state - plane state for planes with shadow buffers |
| 44 |
* |
| 45 |
* For planes that use a shadow buffer, struct drm_shadow_plane_state |
| 46 |
* provides the regular plane state plus mappings of the shadow buffer |
| 47 |
* into kernel address space. |
| 48 |
*/ |
| 49 |
struct drm_shadow_plane_state { |
| 50 |
/** @base: plane state */ |
| 51 |
struct drm_plane_state base; |
| 52 |
|
| 53 |
/** |
| 54 |
* @fmtcnv_state: Format-conversion state |
| 55 |
* |
| 56 |
* Per-plane state for format conversion. |
| 57 |
* Flags for copying shadow buffers into backend storage. Also holds |
| 58 |
* temporary storage for format conversion. |
| 59 |
*/ |
| 60 |
struct drm_format_conv_state fmtcnv_state; |
| 61 |
|
| 62 |
/* Transitional state - do not export or duplicate */ |
| 63 |
|
| 64 |
/** |
| 65 |
* @map: Mappings of the plane's framebuffer BOs in to kernel address space |
| 66 |
* |
| 67 |
* The memory mappings stored in map should be established in the plane's |
| 68 |
* prepare_fb callback and removed in the cleanup_fb callback. |
| 69 |
*/ |
| 70 |
struct iosys_map map[DRM_FORMAT_MAX_PLANES]; |
| 71 |
|
| 72 |
/** |
| 73 |
* @data: Address of each framebuffer BO's data |
| 74 |
* |
| 75 |
* The address of the data stored in each mapping. This is different |
| 76 |
* for framebuffers with non-zero offset fields. |
| 77 |
*/ |
| 78 |
struct iosys_map data[DRM_FORMAT_MAX_PLANES]; |
| 79 |
}; |
| 80 |
|
| 81 |
/** |
| 82 |
* to_drm_shadow_plane_state - upcasts from struct drm_plane_state |
| 83 |
* @state: the plane state |
| 84 |
*/ |
| 85 |
static inline struct drm_shadow_plane_state * |
| 86 |
to_drm_shadow_plane_state(struct drm_plane_state *state) |
| 87 |
{ |
| 88 |
return container_of(state, struct drm_shadow_plane_state, base); |
| 89 |
} |
| 90 |
|
| 91 |
void __drm_gem_duplicate_shadow_plane_state(struct drm_plane *plane, |
| 92 |
struct drm_shadow_plane_state *new_shadow_plane_state); |
| 93 |
void __drm_gem_destroy_shadow_plane_state(struct drm_shadow_plane_state *shadow_plane_state); |
| 94 |
void __drm_gem_reset_shadow_plane(struct drm_plane *plane, |
| 95 |
struct drm_shadow_plane_state *shadow_plane_state); |
| 96 |
|
| 97 |
void drm_gem_reset_shadow_plane(struct drm_plane *plane); |
| 98 |
struct drm_plane_state *drm_gem_duplicate_shadow_plane_state(struct drm_plane *plane); |
| 99 |
void drm_gem_destroy_shadow_plane_state(struct drm_plane *plane, |
| 100 |
struct drm_plane_state *plane_state); |
| 101 |
|
| 102 |
/** |
| 103 |
* DRM_GEM_SHADOW_PLANE_FUNCS - |
| 104 |
* Initializes struct drm_plane_funcs for shadow-buffered planes |
| 105 |
* |
| 106 |
* Drivers may use GEM BOs as shadow buffers over the framebuffer memory. This |
| 107 |
* macro initializes struct drm_plane_funcs to use the rsp helper functions. |
| 108 |
*/ |
| 109 |
#define DRM_GEM_SHADOW_PLANE_FUNCS \ |
| 110 |
.reset = drm_gem_reset_shadow_plane, \ |
| 111 |
.atomic_duplicate_state = drm_gem_duplicate_shadow_plane_state, \ |
| 112 |
.atomic_destroy_state = drm_gem_destroy_shadow_plane_state |
| 113 |
|
| 114 |
int drm_gem_begin_shadow_fb_access(struct drm_plane *plane, struct drm_plane_state *plane_state); |
| 115 |
void drm_gem_end_shadow_fb_access(struct drm_plane *plane, struct drm_plane_state *plane_state); |
| 116 |
|
| 117 |
/** |
| 118 |
* DRM_GEM_SHADOW_PLANE_HELPER_FUNCS - |
| 119 |
* Initializes struct drm_plane_helper_funcs for shadow-buffered planes |
| 120 |
* |
| 121 |
* Drivers may use GEM BOs as shadow buffers over the framebuffer memory. This |
| 122 |
* macro initializes struct drm_plane_helper_funcs to use the rsp helper |
| 123 |
* functions. |
| 124 |
*/ |
| 125 |
#define DRM_GEM_SHADOW_PLANE_HELPER_FUNCS \ |
| 126 |
.begin_fb_access = drm_gem_begin_shadow_fb_access, \ |
| 127 |
.end_fb_access = drm_gem_end_shadow_fb_access |
| 128 |
|
| 129 |
int drm_gem_simple_kms_begin_shadow_fb_access(struct drm_simple_display_pipe *pipe, |
| 130 |
struct drm_plane_state *plane_state); |
| 131 |
void drm_gem_simple_kms_end_shadow_fb_access(struct drm_simple_display_pipe *pipe, |
| 132 |
struct drm_plane_state *plane_state); |
| 133 |
void drm_gem_simple_kms_reset_shadow_plane(struct drm_simple_display_pipe *pipe); |
| 134 |
struct drm_plane_state * |
| 135 |
drm_gem_simple_kms_duplicate_shadow_plane_state(struct drm_simple_display_pipe *pipe); |
| 136 |
void drm_gem_simple_kms_destroy_shadow_plane_state(struct drm_simple_display_pipe *pipe, |
| 137 |
struct drm_plane_state *plane_state); |
| 138 |
|
| 139 |
/** |
| 140 |
* DRM_GEM_SIMPLE_DISPLAY_PIPE_SHADOW_PLANE_FUNCS - |
| 141 |
* Initializes struct drm_simple_display_pipe_funcs for shadow-buffered planes |
| 142 |
* |
| 143 |
* Drivers may use GEM BOs as shadow buffers over the framebuffer memory. This |
| 144 |
* macro initializes struct drm_simple_display_pipe_funcs to use the rsp helper |
| 145 |
* functions. |
| 146 |
*/ |
| 147 |
#define DRM_GEM_SIMPLE_DISPLAY_PIPE_SHADOW_PLANE_FUNCS \ |
| 148 |
.begin_fb_access = drm_gem_simple_kms_begin_shadow_fb_access, \ |
| 149 |
.end_fb_access = drm_gem_simple_kms_end_shadow_fb_access, \ |
| 150 |
.reset_plane = drm_gem_simple_kms_reset_shadow_plane, \ |
| 151 |
.duplicate_plane_state = drm_gem_simple_kms_duplicate_shadow_plane_state, \ |
| 152 |
.destroy_plane_state = drm_gem_simple_kms_destroy_shadow_plane_state |
| 153 |
|
| 154 |
#endif /* __DRM_GEM_ATOMIC_HELPER_H__ */ |