drivers/gpu/drm/drm_atomic_helper.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_atomic_helper.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_atomic_helper.c- Extension
.c- Size
- 127623 bytes
- Lines
- 4105
- 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/dma-fence.hlinux/ktime.hdrm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_atomic_uapi.hdrm/drm_blend.hdrm/drm_bridge.hdrm/drm_colorop.hdrm/drm_damage_helper.hdrm/drm_device.hdrm/drm_drv.hdrm/drm_framebuffer.hdrm/drm_gem_atomic_helper.hdrm/drm_panic.hdrm/drm_print.hdrm/drm_self_refresh_helper.hdrm/drm_vblank.hdrm/drm_writeback.hdrm_crtc_helper_internal.hdrm_crtc_internal.h
Detected Declarations
function Copyrightfunction handle_conflicting_encodersfunction set_best_encoderfunction steal_encoderfunction for_each_oldnew_connector_in_statefunction update_connector_routingfunction drm_atomic_helper_resumefunction mode_fixupfunction for_each_new_crtc_in_statefunction for_each_new_connector_in_statefunction for_each_new_crtc_in_statefunction mode_valid_pathfunction mode_validfunction for_each_new_connector_in_statefunction drm_atomic_check_valid_clonesfunction drm_for_each_encoder_maskfunction drm_atomic_helper_check_modesetfunction for_each_oldnew_crtc_in_statefunction for_each_oldnew_connector_in_statefunction drm_atomic_helper_check_wb_connector_statefunction drm_atomic_helper_check_plane_statefunction drm_atomic_helper_check_crtc_primary_planefunction drm_atomic_helper_check_planesfunction for_each_oldnew_plane_in_statefunction for_each_new_crtc_in_statefunction drm_atomic_helper_check_planesfunction crtc_needs_disablefunction drm_atomic_helper_commit_encoder_bridge_disablefunction for_each_oldnew_connector_in_statefunction drm_atomic_helper_commit_crtc_disablefunction for_each_oldnew_crtc_in_statefunction drm_atomic_helper_commit_encoder_bridge_post_disablefunction for_each_oldnew_connector_in_statefunction disable_outputsfunction drm_atomic_helper_update_legacy_modeset_statefunction drm_calc_timestamping_constantsfunction for_each_new_crtc_in_statefunction drm_atomic_helper_commit_crtc_set_modefunction for_each_new_crtc_in_statefunction for_each_new_connector_in_statefunction connectorfunction themfunction drm_atomic_helper_commit_writebacksfunction for_each_new_connector_in_statefunction drm_atomic_helper_commit_encoder_bridge_pre_enablefunction for_each_new_connector_in_statefunction drm_atomic_helper_commit_crtc_enablefunction for_each_oldnew_crtc_in_state
Annotated Snippet
if (new_encoder) {
if (encoder_mask & drm_encoder_mask(new_encoder)) {
drm_dbg_atomic(connector->dev,
"[ENCODER:%d:%s] on [CONNECTOR:%d:%s] already assigned\n",
new_encoder->base.id, new_encoder->name,
connector->base.id, connector->name);
return -EINVAL;
}
encoder_mask |= drm_encoder_mask(new_encoder);
}
}
if (!encoder_mask)
return 0;
/*
* Second loop, iterate over all connectors not part of the state.
*
* If a conflicting encoder is found and disable_conflicting_encoders
* is not set, an error is returned. Userspace can provide a solution
* through the atomic ioctl.
*
* If the flag is set conflicting connectors are removed from the CRTC
* and the CRTC is disabled if no encoder is left. This preserves
* compatibility with the legacy set_config behavior.
*/
drm_connector_list_iter_begin(state->dev, &conn_iter);
drm_for_each_connector_iter(connector, &conn_iter) {
struct drm_crtc_state *crtc_state;
if (drm_atomic_get_new_connector_state(state, connector))
continue;
encoder = connector->state->best_encoder;
if (!encoder || !(encoder_mask & drm_encoder_mask(encoder)))
continue;
if (!disable_conflicting_encoders) {
drm_dbg_atomic(connector->dev,
"[ENCODER:%d:%s] in use on [CRTC:%d:%s] by [CONNECTOR:%d:%s]\n",
encoder->base.id, encoder->name,
connector->state->crtc->base.id,
connector->state->crtc->name,
connector->base.id, connector->name);
ret = -EINVAL;
goto out;
}
new_conn_state = drm_atomic_get_connector_state(state, connector);
if (IS_ERR(new_conn_state)) {
ret = PTR_ERR(new_conn_state);
goto out;
}
drm_dbg_atomic(connector->dev,
"[ENCODER:%d:%s] in use on [CRTC:%d:%s], disabling [CONNECTOR:%d:%s]\n",
encoder->base.id, encoder->name,
new_conn_state->crtc->base.id, new_conn_state->crtc->name,
connector->base.id, connector->name);
crtc_state = drm_atomic_get_new_crtc_state(state, new_conn_state->crtc);
ret = drm_atomic_set_crtc_for_connector(new_conn_state, NULL);
if (ret)
goto out;
if (!crtc_state->connector_mask) {
ret = drm_atomic_set_mode_prop_for_crtc(crtc_state,
NULL);
if (ret < 0)
goto out;
crtc_state->active = false;
}
}
out:
drm_connector_list_iter_end(&conn_iter);
return ret;
}
static void
set_best_encoder(struct drm_atomic_commit *state,
struct drm_connector_state *conn_state,
struct drm_encoder *encoder)
{
struct drm_crtc_state *crtc_state;
struct drm_crtc *crtc;
Annotation
- Immediate include surface: `linux/export.h`, `linux/dma-fence.h`, `linux/ktime.h`, `drm/drm_atomic.h`, `drm/drm_atomic_helper.h`, `drm/drm_atomic_uapi.h`, `drm/drm_blend.h`, `drm/drm_bridge.h`.
- Detected declarations: `function Copyright`, `function handle_conflicting_encoders`, `function set_best_encoder`, `function steal_encoder`, `function for_each_oldnew_connector_in_state`, `function update_connector_routing`, `function drm_atomic_helper_resume`, `function mode_fixup`, `function for_each_new_crtc_in_state`, `function for_each_new_connector_in_state`.
- 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.