drivers/gpu/drm/vc4/vc4_plane.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vc4/vc4_plane.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vc4/vc4_plane.c- Extension
.c- Size
- 77519 bytes
- Lines
- 2621
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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
drm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_atomic_uapi.hdrm/drm_blend.hdrm/drm_drv.hdrm/drm_fb_dma_helper.hdrm/drm_fourcc.hdrm/drm_framebuffer.hdrm/drm_gem_atomic_helper.hdrm/drm_print.hvc4_drv.hvc4_regs.h
Detected Declarations
function vc4_get_scaling_modefunction plane_enabledfunction vc4_plane_release_upm_idafunction vc4_plane_destroy_statefunction vc4_plane_resetfunction vc4_dlist_counter_incrementfunction vc4_dlist_writefunction vc4_get_scl_fieldfunction vc4_plane_margins_adjfunction vc4_plane_setup_clipping_and_scalingfunction vc4_write_tpzfunction vc4_write_ppffunction __vc4_lbm_sizefunction vc4_lbm_words_per_componentfunction vc4_lbm_componentsfunction vc4_lbm_channel_sizefunction __vc6_lbm_sizefunction vc4_lbm_sizefunction vc6_upm_sizefunction vc4_write_scaling_parametersfunction vc4_plane_calc_loadfunction vc4_plane_allocate_lbmfunction vc6_plane_allocate_upmfunction vc6_plane_free_upmfunction vc4_hvs4_get_alpha_blend_modefunction vc4_hvs5_get_alpha_blend_modefunction vc4_hvs6_get_alpha_mask_modefunction vc4_plane_mode_setfunction requiredfunction vc6_plane_get_csc_modefunction vc6_plane_mode_setfunction vc4_plane_atomic_checkfunction vc4_plane_atomic_updatefunction vc4_plane_dlist_sizefunction vc4_plane_async_set_fbfunction vc4_plane_atomic_async_updatefunction vc4_plane_atomic_async_checkfunction vc4_prepare_fbfunction vc4_cleanup_fbfunction vc4_format_mod_supportedfunction vc4_plane_create_additional_planesfunction drm_for_each_crtc
Annotated Snippet
if (!vc4_state->dlist) {
kfree(vc4_state);
return NULL;
}
vc4_state->dlist_size = vc4_state->dlist_count;
}
return &vc4_state->base;
}
static void vc4_plane_release_upm_ida(struct vc4_hvs *hvs, unsigned int upm_handle)
{
struct vc4_upm_refcounts *refcount = &hvs->upm_refcounts[upm_handle];
unsigned long irqflags;
spin_lock_irqsave(&hvs->mm_lock, irqflags);
drm_mm_remove_node(&refcount->upm);
spin_unlock_irqrestore(&hvs->mm_lock, irqflags);
refcount->upm.start = 0;
refcount->upm.size = 0;
refcount->size = 0;
ida_free(&hvs->upm_handles, upm_handle);
}
static void vc4_plane_destroy_state(struct drm_plane *plane,
struct drm_plane_state *state)
{
struct vc4_dev *vc4 = to_vc4_dev(plane->dev);
struct vc4_hvs *hvs = vc4->hvs;
struct vc4_plane_state *vc4_state = to_vc4_plane_state(state);
unsigned int i;
if (drm_mm_node_allocated(&vc4_state->lbm)) {
unsigned long irqflags;
spin_lock_irqsave(&hvs->mm_lock, irqflags);
drm_mm_remove_node(&vc4_state->lbm);
spin_unlock_irqrestore(&hvs->mm_lock, irqflags);
}
for (i = 0; i < DRM_FORMAT_MAX_PLANES; i++) {
struct vc4_upm_refcounts *refcount;
if (!vc4_state->upm_handle[i])
continue;
refcount = &hvs->upm_refcounts[vc4_state->upm_handle[i]];
if (refcount_dec_and_test(&refcount->refcount))
vc4_plane_release_upm_ida(hvs, vc4_state->upm_handle[i]);
}
kfree(vc4_state->dlist);
__drm_atomic_helper_plane_destroy_state(&vc4_state->base);
kfree(state);
}
/* Called during init to allocate the plane's atomic state. */
static void vc4_plane_reset(struct drm_plane *plane)
{
struct vc4_plane_state *vc4_state;
if (plane->state)
__drm_atomic_helper_plane_destroy_state(plane->state);
kfree(plane->state);
vc4_state = kzalloc_obj(*vc4_state);
if (!vc4_state)
return;
__drm_atomic_helper_plane_reset(plane, &vc4_state->base);
}
static void vc4_dlist_counter_increment(struct vc4_plane_state *vc4_state)
{
if (vc4_state->dlist_count == vc4_state->dlist_size) {
u32 new_size = max(4u, vc4_state->dlist_count * 2);
u32 *new_dlist = kmalloc_array(new_size, 4, GFP_KERNEL);
if (!new_dlist)
return;
memcpy(new_dlist, vc4_state->dlist, vc4_state->dlist_count * 4);
kfree(vc4_state->dlist);
vc4_state->dlist = new_dlist;
vc4_state->dlist_size = new_size;
}
Annotation
- Immediate include surface: `drm/drm_atomic.h`, `drm/drm_atomic_helper.h`, `drm/drm_atomic_uapi.h`, `drm/drm_blend.h`, `drm/drm_drv.h`, `drm/drm_fb_dma_helper.h`, `drm/drm_fourcc.h`, `drm/drm_framebuffer.h`.
- Detected declarations: `function vc4_get_scaling_mode`, `function plane_enabled`, `function vc4_plane_release_upm_ida`, `function vc4_plane_destroy_state`, `function vc4_plane_reset`, `function vc4_dlist_counter_increment`, `function vc4_dlist_write`, `function vc4_get_scl_field`, `function vc4_plane_margins_adj`, `function vc4_plane_setup_clipping_and_scaling`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source 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.