drivers/gpu/drm/i915/display/intel_vblank.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/display/intel_vblank.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/display/intel_vblank.c- Extension
.c- Size
- 25625 bytes
- Lines
- 806
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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
linux/iopoll.hdrm/drm_print.hdrm/drm_vblank.hintel_color.hintel_crtc.hintel_de.hintel_display_jiffies.hintel_display_regs.hintel_display_types.hintel_display_utils.hintel_vblank.hintel_vrr.h
Detected Declarations
function counterfunction g4x_get_vblank_counterfunction intel_crtc_scanlines_since_frame_timestampfunction __intel_get_crtc_scanline_from_timestampfunction intel_crtc_scanline_offsetfunction intel_de_read_fwfunction platformsfunction intel_vblank_section_exitfunction intel_vblank_section_enterfunction intel_crtc_get_vblank_timestampfunction intel_get_crtc_scanlinefunction pipe_scanline_is_movingfunction wait_for_pipe_scanline_movingfunction intel_wait_for_pipe_scanline_stoppedfunction intel_wait_for_pipe_scanline_movingfunction intel_crtc_active_timingsfunction intel_crtc_update_active_timingsfunction intel_mode_vdisplayfunction intel_mode_vblank_startfunction intel_mode_vblank_endfunction intel_mode_vtotalfunction intel_mode_vblank_delayfunction pre_commit_crtc_statefunction intel_pre_commit_crtc_statefunction vrr_vblank_startfunction intel_vblank_evade_initfunction intel_vblank_evadefunction intel_crtc_vblank_length
Annotated Snippet
if (temp != position) {
position = temp;
break;
}
}
}
/*
* See update_scanline_offset() for the details on the
* scanline_offset adjustment.
*/
return (position + vtotal + crtc->scanline_offset) % vtotal;
}
/*
* The uncore version of the spin lock functions is used to decide
* whether we need to lock the uncore lock or not. This is only
* needed in i915, not in Xe.
*
* This lock in i915 is needed because some old platforms (at least
* IVB and possibly HSW as well), which are not supported in Xe, need
* all register accesses to the same cacheline to be serialized,
* otherwise they may hang.
*/
#ifdef I915
static void intel_vblank_section_enter(struct intel_display *display)
__acquires(uncore->lock)
{
struct intel_uncore *uncore = to_intel_uncore(display->drm);
spin_lock(&uncore->lock);
}
static void intel_vblank_section_exit(struct intel_display *display)
__releases(uncore->lock)
{
struct intel_uncore *uncore = to_intel_uncore(display->drm);
spin_unlock(&uncore->lock);
}
#else
static void intel_vblank_section_enter(struct intel_display *display)
{
}
static void intel_vblank_section_exit(struct intel_display *display)
{
}
#endif
static bool i915_get_crtc_scanoutpos(struct drm_crtc *_crtc,
bool in_vblank_irq,
int *vpos, int *hpos,
ktime_t *stime, ktime_t *etime,
const struct drm_display_mode *mode)
{
struct intel_display *display = to_intel_display(_crtc->dev);
struct intel_crtc *crtc = to_intel_crtc(_crtc);
enum pipe pipe = crtc->pipe;
int position;
int vbl_start, vbl_end, hsync_start, htotal, vtotal;
unsigned long irqflags;
bool use_scanline_counter = DISPLAY_VER(display) >= 5 ||
display->platform.g4x || DISPLAY_VER(display) == 2 ||
crtc->mode_flags & I915_MODE_FLAG_USE_SCANLINE_COUNTER;
if (drm_WARN_ON(display->drm, !mode->crtc_clock)) {
drm_dbg(display->drm,
"trying to get scanoutpos for disabled pipe %c\n",
pipe_name(pipe));
return false;
}
htotal = mode->crtc_htotal;
hsync_start = mode->crtc_hsync_start;
vtotal = intel_mode_vtotal(mode);
vbl_start = intel_mode_vblank_start(mode);
vbl_end = intel_mode_vblank_end(mode);
/*
* Enter vblank critical section, as we will do multiple
* timing critical raw register reads, potentially with
* preemption disabled, so the following code must not block.
*/
local_irq_save(irqflags);
intel_vblank_section_enter(display);
/* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */
/* Get optional system timestamp before query. */
if (stime)
*stime = ktime_get();
Annotation
- Immediate include surface: `linux/iopoll.h`, `drm/drm_print.h`, `drm/drm_vblank.h`, `intel_color.h`, `intel_crtc.h`, `intel_de.h`, `intel_display_jiffies.h`, `intel_display_regs.h`.
- Detected declarations: `function counter`, `function g4x_get_vblank_counter`, `function intel_crtc_scanlines_since_frame_timestamp`, `function __intel_get_crtc_scanline_from_timestamp`, `function intel_crtc_scanline_offset`, `function intel_de_read_fw`, `function platforms`, `function intel_vblank_section_exit`, `function intel_vblank_section_enter`, `function intel_crtc_get_vblank_timestamp`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source 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.