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.
- 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/dma-resv.hlinux/dma-fence-chain.hlinux/export.hdrm/drm_atomic_state_helper.hdrm/drm_atomic_uapi.hdrm/drm_framebuffer.hdrm/drm_gem.hdrm/drm_gem_atomic_helper.hdrm/drm_gem_framebuffer_helper.hdrm/drm_simple_kms_helper.hdrm_internal.h
Detected Declarations
function drm_gem_plane_helper_prepare_fbfunction __drm_gem_duplicate_shadow_plane_statefunction drm_gem_duplicate_shadow_plane_statefunction __drm_gem_destroy_shadow_plane_statefunction drm_gem_destroy_shadow_plane_statefunction __drm_gem_reset_shadow_planefunction drm_gem_reset_shadow_planefunction drm_gem_end_shadow_fb_accessfunction drm_gem_begin_shadow_fb_accessfunction drm_gem_begin_shadow_fb_accessfunction drm_gem_simple_kms_begin_shadow_fb_accessfunction drm_gem_simple_kms_reset_shadow_planefunction drm_gem_simple_kms_duplicate_shadow_plane_statefunction drm_gem_simple_kms_destroy_shadow_plane_stateexport drm_gem_plane_helper_prepare_fbexport __drm_gem_duplicate_shadow_plane_stateexport drm_gem_duplicate_shadow_plane_stateexport __drm_gem_destroy_shadow_plane_stateexport drm_gem_destroy_shadow_plane_stateexport __drm_gem_reset_shadow_planeexport drm_gem_reset_shadow_planeexport drm_gem_begin_shadow_fb_accessexport drm_gem_end_shadow_fb_accessexport drm_gem_simple_kms_begin_shadow_fb_accessexport drm_gem_simple_kms_end_shadow_fb_accessexport drm_gem_simple_kms_reset_shadow_planeexport drm_gem_simple_kms_duplicate_shadow_plane_stateexport drm_gem_simple_kms_destroy_shadow_plane_state
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
- Immediate include surface: `linux/dma-resv.h`, `linux/dma-fence-chain.h`, `linux/export.h`, `drm/drm_atomic_state_helper.h`, `drm/drm_atomic_uapi.h`, `drm/drm_framebuffer.h`, `drm/drm_gem.h`, `drm/drm_gem_atomic_helper.h`.
- Detected declarations: `function drm_gem_plane_helper_prepare_fb`, `function __drm_gem_duplicate_shadow_plane_state`, `function drm_gem_duplicate_shadow_plane_state`, `function __drm_gem_destroy_shadow_plane_state`, `function drm_gem_destroy_shadow_plane_state`, `function __drm_gem_reset_shadow_plane`, `function drm_gem_reset_shadow_plane`, `function drm_gem_end_shadow_fb_access`, `function drm_gem_begin_shadow_fb_access`, `function drm_gem_begin_shadow_fb_access`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.