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.
35 * .. code-block:: c
50 * into the HW's framebuffer memory during an atomic update. This requires
52 * cannot be established by commit-tail functions, such as atomic_update,
55 * The helpers for shadow-buffered planes establish and release mappings,
57 * for commit-tail functions.
59 * Shadow-buffered planes can easily be enabled by using the provided macros
61 * These macros set up the plane and plane-helper callbacks to point to the
62 * shadow-buffer helpers.
64 * .. code-block:: c
78 * In the driver's atomic-update function, shadow-buffer mappings are available
82 * .. code-block:: c
87 * struct drm_plane_state *plane_state = plane->state;
91 * // access shadow buffer via shadow_plane_state->map
94 * A mapping address for each of the framebuffer's buffer object is stored in
100 * callbacks. Access to shadow-buffer mappings is similar to regular
103 * .. code-block:: c
117 * // access shadow buffer via shadow_plane_state->map
126 * drm_gem_plane_helper_prepare_fb() - Prepare a GEM backed framebuffer
136 * There is no need for &drm_plane_helper_funcs.cleanup_fb hook for simple
137 * GEM based framebuffer drivers which have their buffers always pinned in
146 struct dma_fence *fence = dma_fence_get(state->fence); in drm_gem_plane_helper_prepare_fb()
151 if (!state->fb) in drm_gem_plane_helper_prepare_fb()
159 * which is important to make explicit fencing use-cases work: One in drm_gem_plane_helper_prepare_fb()
169 for (i = 0; i < state->fb->format->num_planes; ++i) { in drm_gem_plane_helper_prepare_fb()
170 struct drm_gem_object *obj = drm_gem_fb_get_obj(state->fb, i); in drm_gem_plane_helper_prepare_fb()
174 ret = -EINVAL; in drm_gem_plane_helper_prepare_fb()
178 ret = dma_resv_get_singleton(obj->resv, usage, &new); in drm_gem_plane_helper_prepare_fb()
186 ret = -ENOMEM; in drm_gem_plane_helper_prepare_fb()
191 fence = &chain->base; in drm_gem_plane_helper_prepare_fb()
198 dma_fence_put(state->fence); in drm_gem_plane_helper_prepare_fb()
199 state->fence = fence; in drm_gem_plane_helper_prepare_fb()
209 * drm_gem_simple_display_pipe_prepare_fb - prepare_fb helper for &drm_simple_display_pipe
210 * @pipe: Simple display pipe
225 return drm_gem_plane_helper_prepare_fb(&pipe->plane, plane_state); in drm_gem_simple_display_pipe_prepare_fb()
230 * Shadow-buffered Planes
234 * __drm_gem_duplicate_shadow_plane_state - duplicates shadow-buffered plane state
236 * @new_shadow_plane_state: the new shadow-buffered plane state
238 * This function duplicates shadow-buffered plane state. This is helpful for drivers
250 __drm_atomic_helper_plane_duplicate_state(plane, &new_shadow_plane_state->base); in __drm_gem_duplicate_shadow_plane_state()
255 * drm_gem_duplicate_shadow_plane_state - duplicates shadow-buffered plane state
259 * shadow-buffered planes. It assumes the existing state to be of type
274 struct drm_plane_state *plane_state = plane->state; in drm_gem_duplicate_shadow_plane_state()
285 return &new_shadow_plane_state->base; in drm_gem_duplicate_shadow_plane_state()
290 * __drm_gem_destroy_shadow_plane_state - cleans up shadow-buffered plane state
291 * @shadow_plane_state: the shadow-buffered plane state
293 * This function cleans up shadow-buffered plane state. Helpful for drivers that
298 __drm_atomic_helper_plane_destroy_state(&shadow_plane_state->base); in __drm_gem_destroy_shadow_plane_state()
303 * drm_gem_destroy_shadow_plane_state - deletes shadow-buffered plane state
308 * for shadow-buffered planes. It expects that mappings of shadow buffers
323 * __drm_gem_reset_shadow_plane - resets a shadow-buffered plane
325 * @shadow_plane_state: the shadow-buffered plane state
327 * This function resets state for shadow-buffered planes. Helpful
333 __drm_atomic_helper_plane_reset(plane, &shadow_plane_state->base); in __drm_gem_reset_shadow_plane()
338 * drm_gem_reset_shadow_plane - resets a shadow-buffered plane
342 * shadow-buffered planes. It assumes the current plane state to be
350 if (plane->state) { in drm_gem_reset_shadow_plane()
351 drm_gem_destroy_shadow_plane_state(plane, plane->state); in drm_gem_reset_shadow_plane()
352 plane->state = NULL; /* must be set to NULL here */ in drm_gem_reset_shadow_plane()
363 * drm_gem_prepare_shadow_fb - prepares shadow framebuffers
368 * maps all buffer objects of the plane's framebuffer into kernel address
370 * framebuffer will be synchronized as part of the atomic commit.
380 struct drm_framebuffer *fb = plane_state->fb; in drm_gem_prepare_shadow_fb()
390 return drm_gem_fb_vmap(fb, shadow_plane_state->map, shadow_plane_state->data); in drm_gem_prepare_shadow_fb()
395 * drm_gem_cleanup_shadow_fb - releases shadow framebuffers
400 * This function unmaps all buffer objects of the plane's framebuffer.
407 struct drm_framebuffer *fb = plane_state->fb; in drm_gem_cleanup_shadow_fb()
412 drm_gem_fb_vunmap(fb, shadow_plane_state->map); in drm_gem_cleanup_shadow_fb()
417 * drm_gem_simple_kms_prepare_shadow_fb - prepares shadow framebuffers
418 * @pipe: the simple display pipe
422 * maps all buffer objects of the plane's framebuffer into kernel address
424 * framebuffer will be synchronized as part of the atomic commit.
434 return drm_gem_prepare_shadow_fb(&pipe->plane, plane_state); in drm_gem_simple_kms_prepare_shadow_fb()
439 * drm_gem_simple_kms_cleanup_shadow_fb - releases shadow framebuffers
440 * @pipe: the simple display pipe
444 * This function unmaps all buffer objects of the plane's framebuffer.
451 drm_gem_cleanup_shadow_fb(&pipe->plane, plane_state); in drm_gem_simple_kms_cleanup_shadow_fb()
456 * drm_gem_simple_kms_reset_shadow_plane - resets a shadow-buffered plane
457 * @pipe: the simple display pipe
460 * for shadow-buffered planes.
464 drm_gem_reset_shadow_plane(&pipe->plane); in drm_gem_simple_kms_reset_shadow_plane()
469 * drm_gem_simple_kms_duplicate_shadow_plane_state - duplicates shadow-buffered plane state
470 * @pipe: the simple display pipe
473 * for shadow-buffered planes. It does not duplicate existing mappings of the shadow
483 return drm_gem_duplicate_shadow_plane_state(&pipe->plane); in drm_gem_simple_kms_duplicate_shadow_plane_state()
488 * drm_gem_simple_kms_destroy_shadow_plane_state - resets shadow-buffered plane state
489 * @pipe: the simple display pipe
493 * for shadow-buffered planes. It expects that mappings of shadow buffers
499 drm_gem_destroy_shadow_plane_state(&pipe->plane, plane_state); in drm_gem_simple_kms_destroy_shadow_plane_state()