for_each_old...tor_in_state(9)
π for_each_oldnew_connector_in_state(9) β the Kernel API Manual, but make it make sense π
okay bestie so you're in the Linux kernel API manual (yep, the Kernel API Manual) and you clicked on for_each_old...tor_in_state(9) β no worries, the full name is for_each_oldnew_connector_in_state, the header just truncates it because apparently man page headers have a character limit and no chill π anyway. This one's a macro. It's giving "loop over everything" energy. Let's go π¦
β¨ NAME β¨
for_each_oldnew_connector_in_state β iterate over all connectors in an atomic update.
That's it. That's the whole vibe. It's a for-each loop but for connectors, and it's atomic about it. Iconic. π
πΈ SYNOPSIS πΈ
for_each_oldnew_connector_in_state (__state , connector ,
old_connector_state , new_connector_state , __i );
Five things go in. Do not lose track of them, bestie, I'm serious π
π ARGUMENTS π
__stateβ astruct drm_atomic_commitpointer. The whole atomic update situation lives in here, and this is the thing you're iterating over. Main character energy fr fr πconnectorβ astruct drm_connectoriteration cursor. Like, this is the little pointer that walks down the list as the loop runs. It's the cursor. It scrolls. Slay. π±οΈold_connector_stateβ astruct drm_connector_stateiteration cursor, specifically for the old state. The before pic πΈnew_connector_stateβ astruct drm_connector_stateiteration cursor, specifically for the new state. The after pic β¨__iβ anintiteration cursor, and it is explicitly "for macro-internal use" only. So likeβ¦ hands off, bestie. That's the macro's business, not yours. Don't touch the internals π ββοΈ (iykyk)
π DESCRIPTION π
So what does it do?
It iterates over all connectors in an atomic update, tracking both the old state and the new state at the same time. Two cursors, one loop, zero crumbs. π
Why would you even want that? Because sometimes you actually need to consider the state delta β like, what changed between old and new β and this macro hands you both sides so you can compare without doing extra work. Literally so convenient.
The manpage calls out one specific place this matters: atomic check functions. That's the exact spot where you'd be looking at the difference between the old and new state, so this is your macro. Periodt. π₯
π SEE ALSO π
The kernel file this baby lives in: ./include/drm/drm_atomic.h π
And the whole extended friend group (this list is long, bestie, but we ride for every single one of them, no skipping π«Ά):
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_old_connector_in_state(9)for_each_new_connector_in_state(9)for_each_oldnew_crtc_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)
lowkey that's a whole group chat right there π but they're all relevant, I promise β go read them, they ate π
and that's the page, bestie!! π this cutie comes to you from ./include/drm and it's dated October 2026 β mwah, go write some atomic check functions, you've got this πβ¨ππ¦π
π¦ 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