STRUCT DRM_VBLANK_CRTC(9)
πΈ NAME πΈ
okay bestie, welcome to struct drm_vblank_crtc(9) from the Kernel API Manual β this is the page all about vblank tracking for a CRTC. π
π¦ SYNOPSIS π¦
struct drm_vblank_crtc {
struct drm_device *dev;
wait_queue_head_t queue;
struct timer_list disable_timer;
seqlock_t seqlock;
atomic64_t count;
ktime_t time;
atomic_t refcount;
u32 last;
u32 max_vblank_count;
unsigned int inmodeset;
unsigned int pipe;
int framedur_ns;
int linedur_ns;
struct drm_display_mode hwmode;
struct drm_vblank_crtc_config config;
bool enabled;
struct kthread_worker *worker;
struct list_head pending_work;
wait_queue_head_t work_wait_queue;
struct drm_vblank_crtc_timer vblank_timer;
};
π Members π
devβ Pointer to thedrm_device. literally the link back to the big device energy. β¨queueβ Wait queue for vblank waiters. the little hangout spot where the vblank waiters wait their turn. π«Άdisable_timerβ Disable timer for the delayed vblank disabling hysteresis logic. Vblank disabling is controlled throughdrm_vblank_crtc_config.offdelay_msand the setting of thedrm_device.max_vblank_countvalue. yes, it's giving delayed-disabling hysteresis realness. πseqlockβ Protect vblank count and time. no cap, keepcountandtimesafe. πcountβ Current software vblank counter.
Note that for a given vblank counter value drm_crtc_handle_vblank and drm_crtc_vblank_count or drm_crtc_vblank_count_and_time provide a barrier: Any writes done before calling drm_crtc_handle_vblank will be visible to callers of the later functions, iff the vblank count is the same or a later one.
IMPORTANT: This guarantee requires barriers, therefore never access this field directly. Use drm_crtc_vblank_count instead. bestie please do not touch the counter with your bare hands π
timeβ Vblank timestamp corresponding tocount. the matching timestamp bestie to the counter's main character moment. βrefcountβ Number of users/waiters of the vblank interrupt. Only when this refcount reaches0can the hardware interrupt be disabled usingdisable_timer. zero means the party's over and the interrupt can finally go night-night. πlastβ Protected bydrm_device.vbl_lock, used for wraparound handling. wraparound business, handled under lock. πmax_vblank_countβ Maximum value of the vblank registers for this crtc. This value+1will result in a wrap-around of the vblank register. It is used by the vblank core to handle wrap-arounds.
If set to zero the vblank core will try to guess the elapsed vblanks between times when the vblank interrupt is disabled through high-precision timestamps. That approach is suffering from small races and imprecision over longer time periods, hence exposing a hardware vblank counter is always recommended.
This is the runtime configurable per-crtc maximum set through drm_crtc_set_max_vblank_count. If this is used the driver must leave the device wide drm_device.max_vblank_count at zero.
If non-zero, drm_crtc_funcs.get_vblank_counter must be set. rule, okay? π
inmodesetβ Tracks whether the vblank is disabled due to a modeset. For legacy driver bit2additionally tracks whether an additional temporary vblank reference has been acquired to paper over the hardware counter resetting/jumping. KMS drivers should instead just calldrm_crtc_vblank_offanddrm_crtc_vblank_on, which explicitly save and restore the vblank count. legacy drivers, this is your lore. π§pipeβdrm_crtc_indexof thedrm_crtccorresponding to this structure. the CRTC's index, iykyk. π«framedur_nsβ Frame/Field duration in ns, used bydrm_crtc_vblank_helper_get_vblank_timestampand computed bydrm_calc_timestamping_constants. nanoseconds of frame/field duration, slay. πlinedur_nsβ Line duration in ns, used bydrm_crtc_vblank_helper_get_vblank_timestampand computed bydrm_calc_timestamping_constants. nanoseconds of line duration, also slay. πhwmodeβ Cache of the current hardware display mode. Only valid whenenabledis set. This is used by helpers likedrm_crtc_vblank_helper_get_vblank_timestamp. We can't just access the hardware mode by e.g. looking atdrm_crtc_state.adjusted_mode, because that one is really hard to get from interrupt context. so we cache the hardware mode like the organized icon we are. πconfigβ Stores vblank configuration values for a given CRTC. Also, seedrm_crtc_vblank_on_config. πenabledβ Tracks the enabling state of the correspondingdrm_crtcto avoid double-disabling and hence corrupting saved state. Needed by drivers not using atomic KMS, since those might go through their CRTC disabling functions multiple times. no double-disabling, no corrupted saved state, periodt. πworkerβ Thekthread_workerused for executing vblank works. the worker bee of vblank works. πpending_workβ A list of scheduleddrm_vblank_workitems that are waiting for a future vblank. future-vblank plans, queued up. π¦work_wait_queueβ The wait queue used for signaling that adrm_vblank_workitem has either finished executing, or was cancelled. finished or cancelled, the queue lets everyone know. π«Άvblank_timerβ Holds the state of the vblank timer. yep, timer state lives here. β°
π Description π
This structure tracks the vblank state for one CRTC. one CRTC, one vblank-state situation. π
Note that for historical reasons β the vblank handling code is still shared with legacy/non-kms drivers β this is a free-standing structure not directly connected to struct drm_crtc. But all public interface functions are taking a struct drm_crtc to hide this implementation detail. so yeah, it's lowkey independent but the public API keeps it covered. π
π SEE ALSO π
- Kernel file
./include/drm/drm_vblank.hstructdrm_pending_vblank_event(9), structdrm_vblank_crtc_config(9), structdrm_vblank_crtc_timer(9)
Source/version: ./include/drm, dated October 2026 β mwah bestie, that's the page ππ
π¦ 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