Lines Matching +full:simple +full:- +full:framebuffer
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 #include <linux/dma-resv.h>
4 #include <linux/dma-fence-chain.h>
19 * The GEM atomic helpers library implements generic atomic-commit
21 * synchronization helpers, and plane state and framebuffer BO mappings
24 * Before scanout, a plane's framebuffer needs to be synchronized with
25 * possible writers that draw into the framebuffer. All drivers should
28 * the framebuffer so that the DRM core can synchronize access automatically.
32 * .. code-block:: c
42 * into the HW's framebuffer memory during an atomic update. This requires
44 * cannot be established by commit-tail functions, such as atomic_update,
47 * The helpers for shadow-buffered planes establish and release mappings,
49 * for commit-tail functions.
51 * Shadow-buffered planes can easily be enabled by using the provided macros
53 * These macros set up the plane and plane-helper callbacks to point to the
54 * shadow-buffer helpers.
56 * .. code-block:: c
70 * In the driver's atomic-update function, shadow-buffer mappings are available
74 * .. code-block:: c
79 * struct drm_plane_state *plane_state = plane->state;
83 * // access shadow buffer via shadow_plane_state->map
86 * A mapping address for each of the framebuffer's buffer object is stored in
92 * callbacks. Access to shadow-buffer mappings is similar to regular
95 * .. code-block:: c
109 * // access shadow buffer via shadow_plane_state->map
118 * drm_gem_plane_helper_prepare_fb() - Prepare a GEM backed framebuffer
128 * There is no need for &drm_plane_helper_funcs.cleanup_fb hook for simple
129 * GEM based framebuffer drivers which have their buffers always pinned in
138 struct dma_fence *fence = dma_fence_get(state->fence); in drm_gem_plane_helper_prepare_fb()
143 if (!state->fb) in drm_gem_plane_helper_prepare_fb()
151 * which is important to make explicit fencing use-cases work: One in drm_gem_plane_helper_prepare_fb()
161 for (i = 0; i < state->fb->format->num_planes; ++i) { in drm_gem_plane_helper_prepare_fb()
162 struct drm_gem_object *obj = drm_gem_fb_get_obj(state->fb, i); in drm_gem_plane_helper_prepare_fb()
166 ret = -EINVAL; in drm_gem_plane_helper_prepare_fb()
170 ret = dma_resv_get_singleton(obj->resv, usage, &new); in drm_gem_plane_helper_prepare_fb()
178 ret = -ENOMEM; in drm_gem_plane_helper_prepare_fb()
183 fence = &chain->base; in drm_gem_plane_helper_prepare_fb()
190 dma_fence_put(state->fence); in drm_gem_plane_helper_prepare_fb()
191 state->fence = fence; in drm_gem_plane_helper_prepare_fb()
201 * Shadow-buffered Planes
205 * __drm_gem_duplicate_shadow_plane_state - duplicates shadow-buffered plane state
207 * @new_shadow_plane_state: the new shadow-buffered plane state
209 * This function duplicates shadow-buffered plane state. This is helpful for drivers
221 __drm_atomic_helper_plane_duplicate_state(plane, &new_shadow_plane_state->base); in __drm_gem_duplicate_shadow_plane_state()
226 * drm_gem_duplicate_shadow_plane_state - duplicates shadow-buffered plane state
230 * shadow-buffered planes. It assumes the existing state to be of type
245 struct drm_plane_state *plane_state = plane->state; in drm_gem_duplicate_shadow_plane_state()
256 return &new_shadow_plane_state->base; in drm_gem_duplicate_shadow_plane_state()
261 * __drm_gem_destroy_shadow_plane_state - cleans up shadow-buffered plane state
262 * @shadow_plane_state: the shadow-buffered plane state
264 * This function cleans up shadow-buffered plane state. Helpful for drivers that
269 __drm_atomic_helper_plane_destroy_state(&shadow_plane_state->base); in __drm_gem_destroy_shadow_plane_state()
274 * drm_gem_destroy_shadow_plane_state - deletes shadow-buffered plane state
279 * for shadow-buffered planes. It expects that mappings of shadow buffers
294 * __drm_gem_reset_shadow_plane - resets a shadow-buffered plane
296 * @shadow_plane_state: the shadow-buffered plane state
298 * This function resets state for shadow-buffered planes. Helpful
304 __drm_atomic_helper_plane_reset(plane, &shadow_plane_state->base); in __drm_gem_reset_shadow_plane()
309 * drm_gem_reset_shadow_plane - resets a shadow-buffered plane
313 * shadow-buffered planes. It assumes the current plane state to be
321 if (plane->state) { in drm_gem_reset_shadow_plane()
322 drm_gem_destroy_shadow_plane_state(plane, plane->state); in drm_gem_reset_shadow_plane()
323 plane->state = NULL; /* must be set to NULL here */ in drm_gem_reset_shadow_plane()
334 * drm_gem_begin_shadow_fb_access - prepares shadow framebuffers for CPU access
339 * maps all buffer objects of the plane's framebuffer into kernel address
351 struct drm_framebuffer *fb = plane_state->fb; in drm_gem_begin_shadow_fb_access()
356 return drm_gem_fb_vmap(fb, shadow_plane_state->map, shadow_plane_state->data); in drm_gem_begin_shadow_fb_access()
361 * drm_gem_end_shadow_fb_access - releases shadow framebuffers from CPU access
373 struct drm_framebuffer *fb = plane_state->fb; in drm_gem_end_shadow_fb_access()
378 drm_gem_fb_vunmap(fb, shadow_plane_state->map); in drm_gem_end_shadow_fb_access()
383 * drm_gem_simple_kms_begin_shadow_fb_access - prepares shadow framebuffers for CPU access
384 * @pipe: the simple display pipe
398 return drm_gem_begin_shadow_fb_access(&pipe->plane, plane_state); in drm_gem_simple_kms_begin_shadow_fb_access()
403 * drm_gem_simple_kms_end_shadow_fb_access - releases shadow framebuffers from CPU access
404 * @pipe: the simple display pipe
416 drm_gem_end_shadow_fb_access(&pipe->plane, plane_state); in drm_gem_simple_kms_end_shadow_fb_access()
421 * drm_gem_simple_kms_reset_shadow_plane - resets a shadow-buffered plane
422 * @pipe: the simple display pipe
425 * for shadow-buffered planes.
429 drm_gem_reset_shadow_plane(&pipe->plane); in drm_gem_simple_kms_reset_shadow_plane()
434 * drm_gem_simple_kms_duplicate_shadow_plane_state - duplicates shadow-buffered plane state
435 * @pipe: the simple display pipe
438 * for shadow-buffered planes. It does not duplicate existing mappings of the shadow
448 return drm_gem_duplicate_shadow_plane_state(&pipe->plane); in drm_gem_simple_kms_duplicate_shadow_plane_state()
453 * drm_gem_simple_kms_destroy_shadow_plane_state - resets shadow-buffered plane state
454 * @pipe: the simple display pipe
458 * for shadow-buffered planes. It expects that mappings of shadow buffers
464 drm_gem_destroy_shadow_plane_state(&pipe->plane, plane_state); in drm_gem_simple_kms_destroy_shadow_plane_state()