drivers/gpu/drm/drm_crtc.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_crtc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_crtc.c- Extension
.c- Size
- 27469 bytes
- Lines
- 994
- 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/ctype.hlinux/list.hlinux/slab.hlinux/export.hlinux/dma-fence.hlinux/uaccess.hdrm/drm_blend.hdrm/drm_crtc.hdrm/drm_edid.hdrm/drm_fourcc.hdrm/drm_framebuffer.hdrm/drm_managed.hdrm/drm_modeset_lock.hdrm/drm_atomic.hdrm/drm_auth.hdrm/drm_debugfs_crc.hdrm/drm_drv.hdrm/drm_print.hdrm/drm_file.hdrm_crtc_internal.hdrm_internal.h
Detected Declarations
function Copyrightfunction drm_crtc_force_disablefunction drm_crtc_register_allfunction drm_for_each_crtcfunction drm_crtc_unregister_allfunction drm_for_each_crtcfunction drm_crtc_crc_initfunction drm_crtc_crc_finifunction resourcesfunction drm_crtc_initfunction drmm_crtc_init_with_planes_cleanupfunction __drmm_crtc_init_with_planesfunction drm_crtc_initfunction drm_crtc_cleanupfunction drm_mode_getcrtcfunction __drm_mode_set_config_internalfunction drm_for_each_crtcfunction drm_mode_set_config_internalfunction drm_crtc_check_viewportfunction drm_mode_setcrtcfunction drm_mode_crtc_set_obj_propfunction BITfunction drm_crtc_create_sharpness_strength_propertyfunction drm_crtc_in_clone_modeexport drm_crtc_from_indexexport drm_crtc_init_with_planesexport drmm_crtc_init_with_planesexport __drmm_crtc_alloc_with_planesexport drm_crtc_cleanupexport drm_mode_set_config_internalexport drm_crtc_check_viewportexport drm_crtc_create_scaling_filter_propertyexport drm_crtc_create_sharpness_strength_propertyexport drm_crtc_in_clone_mode
Annotated Snippet
if (crtc->state->enable) {
drm_mode_convert_to_umode(&crtc_resp->mode, &crtc->state->mode);
crtc_resp->mode_valid = 1;
} else {
crtc_resp->mode_valid = 0;
}
} else {
crtc_resp->x = crtc->x;
crtc_resp->y = crtc->y;
if (crtc->enabled) {
drm_mode_convert_to_umode(&crtc_resp->mode, &crtc->mode);
crtc_resp->mode_valid = 1;
} else {
crtc_resp->mode_valid = 0;
}
}
if (!file_priv->aspect_ratio_allowed)
crtc_resp->mode.flags &= ~DRM_MODE_FLAG_PIC_AR_MASK;
drm_modeset_unlock(&crtc->mutex);
return 0;
}
static int __drm_mode_set_config_internal(struct drm_mode_set *set,
struct drm_modeset_acquire_ctx *ctx)
{
struct drm_crtc *crtc = set->crtc;
struct drm_framebuffer *fb;
struct drm_crtc *tmp;
int ret;
WARN_ON(drm_drv_uses_atomic_modeset(crtc->dev));
/*
* NOTE: ->set_config can also disable other crtcs (if we steal all
* connectors from it), hence we need to refcount the fbs across all
* crtcs. Atomic modeset will have saner semantics ...
*/
drm_for_each_crtc(tmp, crtc->dev) {
struct drm_plane *plane = tmp->primary;
plane->old_fb = plane->fb;
}
fb = set->fb;
ret = crtc->funcs->set_config(set, ctx);
if (ret == 0) {
struct drm_plane *plane = crtc->primary;
plane->crtc = fb ? crtc : NULL;
plane->fb = fb;
}
drm_for_each_crtc(tmp, crtc->dev) {
struct drm_plane *plane = tmp->primary;
if (plane->fb)
drm_framebuffer_get(plane->fb);
if (plane->old_fb)
drm_framebuffer_put(plane->old_fb);
plane->old_fb = NULL;
}
return ret;
}
/**
* drm_mode_set_config_internal - helper to call &drm_mode_config_funcs.set_config
* @set: modeset config to set
*
* This is a little helper to wrap internal calls to the
* &drm_mode_config_funcs.set_config driver interface. The only thing it adds is
* correct refcounting dance.
*
* This should only be used by non-atomic legacy drivers.
*
* Returns:
* Zero on success, negative errno on failure.
*/
int drm_mode_set_config_internal(struct drm_mode_set *set)
{
WARN_ON(drm_drv_uses_atomic_modeset(set->crtc->dev));
return __drm_mode_set_config_internal(set, NULL);
}
EXPORT_SYMBOL(drm_mode_set_config_internal);
Annotation
- Immediate include surface: `linux/ctype.h`, `linux/list.h`, `linux/slab.h`, `linux/export.h`, `linux/dma-fence.h`, `linux/uaccess.h`, `drm/drm_blend.h`, `drm/drm_crtc.h`.
- Detected declarations: `function Copyright`, `function drm_crtc_force_disable`, `function drm_crtc_register_all`, `function drm_for_each_crtc`, `function drm_crtc_unregister_all`, `function drm_for_each_crtc`, `function drm_crtc_crc_init`, `function drm_crtc_crc_fini`, `function resources`, `function drm_crtc_init`.
- 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.