drivers/gpu/drm/drm_plane.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_plane.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_plane.c- Extension
.c- Size
- 57949 bytes
- Lines
- 1880
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/export.hlinux/slab.hlinux/uaccess.hdrm/drm_plane.hdrm/drm_drv.hdrm/drm_print.hdrm/drm_framebuffer.hdrm/drm_file.hdrm/drm_crtc.hdrm/drm_fourcc.hdrm/drm_managed.hdrm/drm_vblank.hdrm_crtc_internal.h
Detected Declarations
function Copyrightfunction drm_for_each_planefunction formats_ptrfunction modifiers_ptrfunction boolfunction driversfunction __drm_universal_plane_initfunction drm_plane_cleanupfunction drmm_universal_plane_alloc_releasefunction drm_plane_register_allfunction drm_for_each_planefunction drm_plane_unregister_allfunction drm_for_each_planefunction drm_plane_cleanupfunction drm_plane_from_indexfunction drm_atomic_helper_disable_planefunction drm_mode_plane_set_obj_propfunction drm_mode_getplane_resfunction drm_mode_getplanefunction drm_plane_has_formatfunction __setplane_checkfunction drm_any_plane_has_formatfunction drm_for_each_planefunction __setplane_internalfunction __setplane_atomicfunction setplane_internalfunction drm_mode_setplanefunction drm_mode_cursor_universalfunction drm_mode_cursor_commonfunction drm_mode_cursor_ioctlfunction drm_mode_cursor2_ioctlfunction drm_mode_page_flip_ioctlfunction updatefunction drm_plane_get_damage_clips_countfunction __drm_plane_get_damage_clipsfunction drm_atomic_helper_damage_iter_initfunction drm_create_scaling_filter_propfunction BITfunction drm_plane_add_size_hints_propertyfunction drm_plane_create_color_pipeline_propertyexport drm_universal_plane_initexport __drmm_universal_plane_allocexport __drm_universal_plane_allocexport drm_plane_cleanupexport drm_plane_from_indexexport drm_plane_force_disableexport drm_mode_plane_set_obj_propexport drm_plane_has_format
Annotated Snippet
if (!dev->mode_config.fb_modifiers_not_supported) {
format_modifiers = default_modifiers;
format_modifier_count = ARRAY_SIZE(default_modifiers);
}
}
/* autoset the cap and check for consistency across all planes */
drm_WARN_ON(dev, config->fb_modifiers_not_supported &&
format_modifier_count);
plane->modifier_count = format_modifier_count;
plane->modifiers = kmalloc_array(format_modifier_count,
sizeof(*plane->modifiers),
GFP_KERNEL);
if (format_modifier_count && !plane->modifiers) {
DRM_DEBUG_KMS("out of memory when allocating plane\n");
kfree(plane->format_types);
drm_mode_object_unregister(dev, &plane->base);
return -ENOMEM;
}
if (name) {
plane->name = kvasprintf(GFP_KERNEL, name, ap);
} else {
plane->name = kasprintf(GFP_KERNEL, "plane-%d",
drm_num_planes(dev));
}
if (!plane->name) {
kfree(plane->format_types);
kfree(plane->modifiers);
drm_mode_object_unregister(dev, &plane->base);
return -ENOMEM;
}
memcpy(plane->format_types, formats, format_count * sizeof(uint32_t));
plane->format_count = format_count;
memcpy(plane->modifiers, format_modifiers,
format_modifier_count * sizeof(format_modifiers[0]));
plane->possible_crtcs = possible_crtcs;
plane->type = type;
list_add_tail(&plane->head, &config->plane_list);
plane->index = config->num_total_plane++;
drm_object_attach_property(&plane->base,
config->plane_type_property,
plane->type);
if (drm_core_check_feature(dev, DRIVER_ATOMIC)) {
drm_object_attach_property(&plane->base, config->prop_fb_id, 0);
drm_object_attach_property(&plane->base, config->prop_in_fence_fd, -1);
drm_object_attach_property(&plane->base, config->prop_crtc_id, 0);
drm_object_attach_property(&plane->base, config->prop_crtc_x, 0);
drm_object_attach_property(&plane->base, config->prop_crtc_y, 0);
drm_object_attach_property(&plane->base, config->prop_crtc_w, 0);
drm_object_attach_property(&plane->base, config->prop_crtc_h, 0);
drm_object_attach_property(&plane->base, config->prop_src_x, 0);
drm_object_attach_property(&plane->base, config->prop_src_y, 0);
drm_object_attach_property(&plane->base, config->prop_src_w, 0);
drm_object_attach_property(&plane->base, config->prop_src_h, 0);
}
if (drm_core_check_feature(dev, DRIVER_CURSOR_HOTSPOT) &&
type == DRM_PLANE_TYPE_CURSOR) {
drm_plane_create_hotspot_properties(plane);
}
if (format_modifier_count) {
blob = create_in_format_blob(dev, plane,
plane->funcs->format_mod_supported);
if (!IS_ERR(blob))
drm_object_attach_property(&plane->base,
config->modifiers_property,
blob->base.id);
}
if (plane->funcs->format_mod_supported_async) {
blob = create_in_format_blob(dev, plane,
plane->funcs->format_mod_supported_async);
if (!IS_ERR(blob))
drm_object_attach_property(&plane->base,
config->async_modifiers_property,
blob->base.id);
}
return 0;
}
/**
Annotation
- Immediate include surface: `linux/export.h`, `linux/slab.h`, `linux/uaccess.h`, `drm/drm_plane.h`, `drm/drm_drv.h`, `drm/drm_print.h`, `drm/drm_framebuffer.h`, `drm/drm_file.h`.
- Detected declarations: `function Copyright`, `function drm_for_each_plane`, `function formats_ptr`, `function modifiers_ptr`, `function bool`, `function drivers`, `function __drm_universal_plane_init`, `function drm_plane_cleanup`, `function drmm_universal_plane_alloc_release`, `function drm_plane_register_all`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.