drivers/gpu/drm/drm_vblank_helper.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_vblank_helper.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_vblank_helper.c- Extension
.c- Size
- 5759 bytes
- Lines
- 177
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
drm/drm_atomic.hdrm/drm_crtc.hdrm/drm_managed.hdrm/drm_modeset_helper_vtables.hdrm/drm_print.hdrm/drm_vblank.hdrm/drm_vblank_helper.h
Detected Declarations
function drm_vblank_initfunction drm_crtc_vblank_atomic_enablefunction drm_crtc_vblank_atomic_disablefunction drm_crtc_vblank_helper_enable_vblank_timerfunction drm_crtc_vblank_helper_disable_vblank_timerfunction drm_crtc_helper_get_vblank_timestamp_from_timerexport drm_crtc_vblank_atomic_flushexport drm_crtc_vblank_atomic_enableexport drm_crtc_vblank_atomic_disableexport drm_crtc_vblank_helper_enable_vblank_timerexport drm_crtc_vblank_helper_disable_vblank_timerexport drm_crtc_vblank_helper_get_vblank_timestamp_from_timer
Annotated Snippet
// SPDX-License-Identifier: MIT
#include <drm/drm_atomic.h>
#include <drm/drm_crtc.h>
#include <drm/drm_managed.h>
#include <drm/drm_modeset_helper_vtables.h>
#include <drm/drm_print.h>
#include <drm/drm_vblank.h>
#include <drm/drm_vblank_helper.h>
/**
* DOC: overview
*
* The vblank helper library provides functions for supporting vertical
* blanking in DRM drivers.
*
* For vblank timers, several callback implementations are available.
* Drivers enable support for vblank timers by setting the vblank callbacks
* in struct &drm_crtc_funcs to the helpers provided by this library. The
* initializer macro DRM_CRTC_VBLANK_TIMER_FUNCS does this conveniently.
* The driver further has to send the VBLANK event from its atomic_flush
* callback and control vblank from the CRTC's atomic_enable and atomic_disable
* callbacks. The callbacks are located in struct &drm_crtc_helper_funcs.
* The vblank helper library provides implementations of these callbacks
* for drivers without further requirements. The initializer macro
* DRM_CRTC_HELPER_VBLANK_FUNCS sets them coveniently.
*
* Once the driver enables vblank support with drm_vblank_init(), each
* CRTC's vblank timer fires according to the programmed display mode. By
* default, the vblank timer invokes drm_crtc_handle_vblank(). Drivers with
* more specific requirements can set their own handler function in
* struct &drm_crtc_helper_funcs.handle_vblank_timeout.
*/
/*
* VBLANK helpers
*/
/**
* drm_crtc_vblank_atomic_flush -
* Implements struct &drm_crtc_helper_funcs.atomic_flush
* @crtc: The CRTC
* @state: The atomic state to apply
*
* The helper drm_crtc_vblank_atomic_flush() implements atomic_flush of
* struct drm_crtc_helper_funcs for CRTCs that only need to send out a
* VBLANK event.
*
* See also struct &drm_crtc_helper_funcs.atomic_flush.
*/
void drm_crtc_vblank_atomic_flush(struct drm_crtc *crtc,
struct drm_atomic_commit *state)
{
struct drm_device *dev = crtc->dev;
struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
struct drm_pending_vblank_event *event;
spin_lock_irq(&dev->event_lock);
event = crtc_state->event;
crtc_state->event = NULL;
if (event) {
if (drm_crtc_vblank_get(crtc) == 0)
drm_crtc_arm_vblank_event(crtc, event);
else
drm_crtc_send_vblank_event(crtc, event);
}
spin_unlock_irq(&dev->event_lock);
}
EXPORT_SYMBOL(drm_crtc_vblank_atomic_flush);
/**
* drm_crtc_vblank_atomic_enable - Implements struct &drm_crtc_helper_funcs.atomic_enable
* @crtc: The CRTC
* @state: The atomic state
*
* The helper drm_crtc_vblank_atomic_enable() implements atomic_enable
* of struct drm_crtc_helper_funcs for CRTCs the only need to enable VBLANKs.
*
* See also struct &drm_crtc_helper_funcs.atomic_enable.
*/
void drm_crtc_vblank_atomic_enable(struct drm_crtc *crtc,
struct drm_atomic_commit *state)
{
drm_crtc_vblank_on(crtc);
}
EXPORT_SYMBOL(drm_crtc_vblank_atomic_enable);
Annotation
- Immediate include surface: `drm/drm_atomic.h`, `drm/drm_crtc.h`, `drm/drm_managed.h`, `drm/drm_modeset_helper_vtables.h`, `drm/drm_print.h`, `drm/drm_vblank.h`, `drm/drm_vblank_helper.h`.
- Detected declarations: `function drm_vblank_init`, `function drm_crtc_vblank_atomic_enable`, `function drm_crtc_vblank_atomic_disable`, `function drm_crtc_vblank_helper_enable_vblank_timer`, `function drm_crtc_vblank_helper_disable_vblank_timer`, `function drm_crtc_helper_get_vblank_timestamp_from_timer`, `export drm_crtc_vblank_atomic_flush`, `export drm_crtc_vblank_atomic_enable`, `export drm_crtc_vblank_atomic_disable`, `export drm_crtc_vblank_helper_enable_vblank_timer`.
- 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.