for_each_ol...rtc_in_state(9)
π for_each_ol...rtc_in_state(9) β like, the Kernel API Manual one, bestie β¨
Okay so picture this: you're deep in the kernel docs (the Kernel API Manual, to be exact) and you stumble on for_each_oldnew_crtc_in_state. It's a macro. It's iconic. It's giving "I loop so you don't have to." Let's get into it π
β¨ NAME β¨
for_each_oldnew_crtc_in_state β the macro that iterates over all CRTCs in an atomic update π¦
πΈ SYNOPSIS πΈ
for_each_oldnew_crtc_in_state (__state , crtc , old_crtc_state ,
new_crtc_state , __i );
π ARGUMENTS π
__stateβ astruct drm_atomic_commitpointer. Yep, the whole commit, the main character πcrtcβ astruct drm_crtciteration cursor. It's your little walking pointer through the loop π«old_crtc_stateβ astruct drm_crtc_stateiteration cursor, but for the old state. The before pics πΈnew_crtc_stateβ astruct drm_crtc_stateiteration cursor, but for the new state. The glow-up β¨__iβ anintiteration cursor, strictly for macro-internal use. Don't touch, don't look at it, it's doing its job π
π DESCRIPTION π
So this macro iterates over all the CRTCs in an atomic update, and β here's the slay β it tracks both the old state and the new state at the same time. Two cursors, one loop, zero drama π
Where is that even useful? Anywhere the state delta actually matters, lowkey. Like, for example, in atomic check functions. That's the vibe. That's the whole point. Periodt π«Ά
π¦ SEE ALSO π¦
The kernel file ./include/drm/drm_atomic.h and honestly a whole friend group of related stuff β no cap, here's every single one π
struct drm_crtc_commit(9)struct drm_private_state_funcs(9)struct drm_private_obj(9)drm_for_each_privobj(9)struct drm_private_state(9)struct drm_atomic_commit(9)drm_crtc_commit_get(9)drm_crtc_commit_put(9)drm_atomic_commit_get(9)drm_atomic_commit_put(9)drm_atomic_get_old_crtc_state(9)drm_atomic_get_new_crtc_state(9)drm_atomic_get_old_plane_state(9)drm_atomic_get_new_plane_state(9)drm_atomic_get_old_connector_state(9)drm_atomic_get_new_connector_state(9)__drm_atomic_get_current_plane_state(9)for_each_oldnew_connector_in_state(9)for_each_old_connector_in_state(9)for_each_new_connector_in_state(9)for_each_old_crtc_in_state(9)for_each_new_crtc_in_state(9)for_each_oldnew_colorop_in_state(9)for_each_new_colorop_in_state(9)for_each_oldnew_plane_in_state(9)for_each_oldnew_plane_in_state_reverse(9)for_each_new_plane_in_state_reverse(9)for_each_old_plane_in_state(9)for_each_new_plane_in_state(9)for_each_oldnew_private_obj_in_state(9)for_each_old_private_obj_in_state(9)for_each_new_private_obj_in_state(9)drm_atomic_crtc_needs_modeset(9)drm_atomic_crtc_effectively_active(9)struct drm_bus_cfg(9)struct drm_bridge_state(9)
Bestie reminder: __i is macro-internal. Do not pass your own thing in there, do not get cute with it, just let the macro cook π
And that's the whole page, mwah π signin' off from ./include/drm β that's the source, and the date on this baddie is October 2026, and it's all filed under for_each_ol...rtc_in_state(9). Slay, go read your kernel headers πβ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms