drivers/gpu/drm/drm_gem_atomic_helper.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_gem_atomic_helper.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/drm_gem_atomic_helper.c
Extension
.c
Size
15648 bytes
Lines
457
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (!obj) {
			ret = -EINVAL;
			goto error;
		}

		ret = dma_resv_get_singleton(obj->resv, usage, &new);
		if (ret)
			goto error;

		if (new && fence) {
			struct dma_fence_chain *chain = dma_fence_chain_alloc();

			if (!chain) {
				ret = -ENOMEM;
				goto error;
			}

			dma_fence_chain_init(chain, fence, new, 1);
			fence = &chain->base;

		} else if (new) {
			fence = new;
		}
	}

	dma_fence_put(state->fence);
	state->fence = fence;
	return 0;

error:
	dma_fence_put(fence);
	return ret;
}
EXPORT_SYMBOL_GPL(drm_gem_plane_helper_prepare_fb);

/*
 * Shadow-buffered Planes
 */

/**
 * __drm_gem_duplicate_shadow_plane_state - duplicates shadow-buffered plane state
 * @plane: the plane
 * @new_shadow_plane_state: the new shadow-buffered plane state
 *
 * This function duplicates shadow-buffered plane state. This is helpful for drivers
 * that subclass struct drm_shadow_plane_state.
 *
 * The function does not duplicate existing mappings of the shadow buffers.
 * Mappings are maintained during the atomic commit by the plane's prepare_fb
 * and cleanup_fb helpers. See drm_gem_prepare_shadow_fb() and drm_gem_cleanup_shadow_fb()
 * for corresponding helpers.
 */
void
__drm_gem_duplicate_shadow_plane_state(struct drm_plane *plane,
				       struct drm_shadow_plane_state *new_shadow_plane_state)
{
	struct drm_plane_state *plane_state = plane->state;
	struct drm_shadow_plane_state *shadow_plane_state =
		to_drm_shadow_plane_state(plane_state);

	__drm_atomic_helper_plane_duplicate_state(plane, &new_shadow_plane_state->base);

	drm_format_conv_state_copy(&new_shadow_plane_state->fmtcnv_state,
				   &shadow_plane_state->fmtcnv_state);
}
EXPORT_SYMBOL(__drm_gem_duplicate_shadow_plane_state);

/**
 * drm_gem_duplicate_shadow_plane_state - duplicates shadow-buffered plane state
 * @plane: the plane
 *
 * This function implements struct &drm_plane_funcs.atomic_duplicate_state for
 * shadow-buffered planes. It assumes the existing state to be of type
 * struct drm_shadow_plane_state and it allocates the new state to be of this
 * type.
 *
 * The function does not duplicate existing mappings of the shadow buffers.
 * Mappings are maintained during the atomic commit by the plane's prepare_fb
 * and cleanup_fb helpers. See drm_gem_prepare_shadow_fb() and drm_gem_cleanup_shadow_fb()
 * for corresponding helpers.
 *
 * Returns:
 * A pointer to a new plane state on success, or NULL otherwise.
 */
struct drm_plane_state *
drm_gem_duplicate_shadow_plane_state(struct drm_plane *plane)
{
	struct drm_plane_state *plane_state = plane->state;
	struct drm_shadow_plane_state *new_shadow_plane_state;

Annotation

Implementation Notes