drivers/gpu/drm/drm_crtc_helper.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_crtc_helper.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_crtc_helper.c- Extension
.c- Size
- 32795 bytes
- Lines
- 1065
- 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/export.hlinux/kernel.hlinux/moduleparam.hlinux/dynamic_debug.hdrm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_atomic_uapi.hdrm/drm_bridge.hdrm/drm_crtc.hdrm/drm_crtc_helper.hdrm/drm_drv.hdrm/drm_edid.hdrm/drm_encoder.hdrm/drm_fourcc.hdrm/drm_framebuffer.hdrm/drm_print.hdrm/drm_vblank.hdrm_crtc_helper_internal.h
Detected Declarations
function drm_crtc_helper_set_configfunction drm_helper_crtc_in_usefunction drm_encoder_disablefunction __drm_helper_disable_unused_functionsfunction drm_for_each_encoderfunction drm_for_each_crtcfunction drm_helper_disable_unused_functionsfunction drm_crtc_prepare_encodersfunction drm_for_each_encoderfunction drm_crtc_helper_set_configfunction drm_for_each_encoderfunction drm_for_each_encoderfunction drm_crtc_helper_atomic_checkfunction drm_crtc_helper_disablefunction drm_for_each_connector_iterfunction drm_connector_get_single_encoderfunction drm_crtc_helper_set_configfunction drm_helper_choose_encoder_dpmsfunction drm_helper_encoder_dpmsfunction drm_helper_choose_crtc_dpmsfunction drm_helper_connector_dpmsfunction statefunction drm_atomic_helper_shutdownexport drm_helper_encoder_in_useexport drm_helper_crtc_in_useexport drm_helper_disable_unused_functionsexport drm_crtc_helper_set_modeexport drm_crtc_helper_atomic_checkexport drm_crtc_helper_set_configexport drm_helper_connector_dpmsexport drm_helper_resume_force_modeexport drm_helper_force_disable_all
Annotated Snippet
if (connector->encoder == encoder) {
drm_connector_list_iter_end(&conn_iter);
return true;
}
}
drm_connector_list_iter_end(&conn_iter);
return false;
}
EXPORT_SYMBOL(drm_helper_encoder_in_use);
/**
* drm_helper_crtc_in_use - check if a given CRTC is in a mode_config
* @crtc: CRTC to check
*
* Checks whether @crtc is with the current mode setting output configuration
* in use by any connector. This doesn't mean that it is actually enabled since
* the DPMS state is tracked separately.
*
* Returns:
* True if @crtc is used, false otherwise.
*/
bool drm_helper_crtc_in_use(struct drm_crtc *crtc)
{
struct drm_encoder *encoder;
struct drm_device *dev = crtc->dev;
drm_WARN_ON(dev, drm_drv_uses_atomic_modeset(dev));
/*
* We can expect this mutex to be locked if we are not panicking.
* Locking is currently fubar in the panic handler.
*/
if (!oops_in_progress)
drm_WARN_ON(dev, !mutex_is_locked(&dev->mode_config.mutex));
drm_for_each_encoder(encoder, dev)
if (encoder->crtc == crtc && drm_helper_encoder_in_use(encoder))
return true;
return false;
}
EXPORT_SYMBOL(drm_helper_crtc_in_use);
static void
drm_encoder_disable(struct drm_encoder *encoder)
{
const struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private;
if (!encoder_funcs)
return;
if (encoder_funcs->disable)
(*encoder_funcs->disable)(encoder);
else if (encoder_funcs->dpms)
(*encoder_funcs->dpms)(encoder, DRM_MODE_DPMS_OFF);
}
static void __drm_helper_disable_unused_functions(struct drm_device *dev)
{
struct drm_encoder *encoder;
struct drm_crtc *crtc;
drm_warn_on_modeset_not_all_locked(dev);
drm_for_each_encoder(encoder, dev) {
if (!drm_helper_encoder_in_use(encoder)) {
drm_encoder_disable(encoder);
/* disconnect encoder from any connector */
encoder->crtc = NULL;
}
}
drm_for_each_crtc(crtc, dev) {
const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
crtc->enabled = drm_helper_crtc_in_use(crtc);
if (!crtc->enabled) {
if (crtc_funcs->disable)
(*crtc_funcs->disable)(crtc);
else
(*crtc_funcs->dpms)(crtc, DRM_MODE_DPMS_OFF);
crtc->primary->fb = NULL;
}
}
}
/**
* drm_helper_disable_unused_functions - disable unused objects
* @dev: DRM device
*
* This function walks through the entire mode setting configuration of @dev. It
Annotation
- Immediate include surface: `linux/export.h`, `linux/kernel.h`, `linux/moduleparam.h`, `linux/dynamic_debug.h`, `drm/drm_atomic.h`, `drm/drm_atomic_helper.h`, `drm/drm_atomic_uapi.h`, `drm/drm_bridge.h`.
- Detected declarations: `function drm_crtc_helper_set_config`, `function drm_helper_crtc_in_use`, `function drm_encoder_disable`, `function __drm_helper_disable_unused_functions`, `function drm_for_each_encoder`, `function drm_for_each_crtc`, `function drm_helper_disable_unused_functions`, `function drm_crtc_prepare_encoders`, `function drm_for_each_encoder`, `function drm_crtc_helper_set_config`.
- 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.