Lines Matching +full:buffered +full:- +full:positive
1 // SPDX-License-Identifier: MIT
3 * Copyright © 2022-2023 Intel Corporation
26 * latch double buffered registers
32 * | may be shifted forward 1-3 extra lines via TRANSCONF
39 * ----va---> <-----------------vb--------------------> <--------va-------------
40 * | | <----vs-----> |
41 …* -vbs-----> <---vbs+1---> <---vbs+2---> <-----0-----> <-----1-----> <-----2--- (scanline counter …
42 …* -vbs-2---> <---vbs-1---> <---vbs-----> <---vbs+1---> <---vbs+2---> <-----0--- (scanline counter …
43 …* -vbs-2---> <---vbs-2---> <---vbs-1---> <---vbs-----> <---vbs+1---> <---vbs+2- (scanline counter …
58 * - most events happen at the start of horizontal sync
59 * - frame start happens at the start of horizontal blank, 1-4 lines
61 * - gen3/4 pixel and frame counter are synchronized with the start
70 struct intel_display *display = to_intel_display(crtc->dev); in i915_get_vblank_counter()
72 const struct drm_display_mode *mode = &vblank->hwmode; in i915_get_vblank_counter()
73 enum pipe pipe = to_intel_crtc(crtc)->pipe; in i915_get_vblank_counter()
84 * does not like us returning non-zero frame counter values in i915_get_vblank_counter()
86 * counter. Thus we must stop non-zero values leaking out. in i915_get_vblank_counter()
88 if (!vblank->max_vblank_count) in i915_get_vblank_counter()
91 htotal = mode->crtc_htotal; in i915_get_vblank_counter()
92 hsync_start = mode->crtc_hsync_start; in i915_get_vblank_counter()
99 vbl_start -= htotal - hsync_start; in i915_get_vblank_counter()
122 struct intel_display *display = to_intel_display(crtc->dev); in g4x_get_vblank_counter()
124 enum pipe pipe = to_intel_crtc(crtc)->pipe; in g4x_get_vblank_counter()
126 if (!vblank->max_vblank_count) in g4x_get_vblank_counter()
135 struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base); in intel_crtc_scanlines_since_frame_timestamp()
136 const struct drm_display_mode *mode = &vblank->hwmode; in intel_crtc_scanlines_since_frame_timestamp()
137 u32 htotal = mode->crtc_htotal; in intel_crtc_scanlines_since_frame_timestamp()
138 u32 clock = mode->crtc_clock; in intel_crtc_scanlines_since_frame_timestamp()
154 PIPE_FRMTMSTMP(crtc->pipe)); in intel_crtc_scanlines_since_frame_timestamp()
163 PIPE_FRMTMSTMP(crtc->pipe)); in intel_crtc_scanlines_since_frame_timestamp()
166 return div_u64(mul_u32_u32(scan_curr_time - scan_prev_time, in intel_crtc_scanlines_since_frame_timestamp()
180 struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base); in __intel_get_crtc_scanline_from_timestamp()
181 const struct drm_display_mode *mode = &vblank->hwmode; in __intel_get_crtc_scanline_from_timestamp()
182 u32 vblank_start = mode->crtc_vblank_start; in __intel_get_crtc_scanline_from_timestamp()
183 u32 vtotal = mode->crtc_vtotal; in __intel_get_crtc_scanline_from_timestamp()
187 scanline = min(scanline, vtotal - 1); in __intel_get_crtc_scanline_from_timestamp()
196 struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev); in intel_crtc_scanline_offset()
201 * On most platforms it starts counting from vtotal-1 on the in intel_crtc_scanline_offset()
205 * last active line), the scanline counter will read vblank_start-1. in intel_crtc_scanline_offset()
208 * of vtotal-1, so we have to subtract one. in intel_crtc_scanline_offset()
225 return -1; in intel_crtc_scanline_offset()
239 struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base); in __intel_get_crtc_scanline()
240 const struct drm_display_mode *mode = &vblank->hwmode; in __intel_get_crtc_scanline()
241 enum pipe pipe = crtc->pipe; in __intel_get_crtc_scanline()
244 if (!crtc->active) in __intel_get_crtc_scanline()
247 if (crtc->mode_flags & I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP) in __intel_get_crtc_scanline()
284 return (position + vtotal + crtc->scanline_offset) % vtotal; in __intel_get_crtc_scanline()
299 __acquires(i915->uncore.lock) in intel_vblank_section_enter()
301 struct drm_i915_private *i915 = to_i915(display->drm); in intel_vblank_section_enter()
302 spin_lock(&i915->uncore.lock); in intel_vblank_section_enter()
306 __releases(i915->uncore.lock) in intel_vblank_section_exit()
308 struct drm_i915_private *i915 = to_i915(display->drm); in intel_vblank_section_exit()
309 spin_unlock(&i915->uncore.lock); in intel_vblank_section_exit()
327 struct intel_display *display = to_intel_display(_crtc->dev); in i915_get_crtc_scanoutpos()
328 struct drm_i915_private *dev_priv = to_i915(display->drm); in i915_get_crtc_scanoutpos()
330 enum pipe pipe = crtc->pipe; in i915_get_crtc_scanoutpos()
336 crtc->mode_flags & I915_MODE_FLAG_USE_SCANLINE_COUNTER; in i915_get_crtc_scanoutpos()
338 if (drm_WARN_ON(display->drm, !mode->crtc_clock)) { in i915_get_crtc_scanoutpos()
339 drm_dbg(display->drm, in i915_get_crtc_scanoutpos()
345 htotal = mode->crtc_htotal; in i915_get_crtc_scanoutpos()
346 hsync_start = mode->crtc_hsync_start; in i915_get_crtc_scanoutpos()
365 if (crtc->mode_flags & I915_MODE_FLAG_VRR) { in i915_get_crtc_scanoutpos()
377 position = min(crtc->vmax_vblank_start + scanlines, vtotal - 1); in i915_get_crtc_scanoutpos()
405 position = min(position, vtotal - 1); in i915_get_crtc_scanoutpos()
414 * always add htotal-hsync_start to the current pixel position. in i915_get_crtc_scanoutpos()
416 position = (position + htotal - hsync_start) % vtotal; in i915_get_crtc_scanoutpos()
431 * vblank, position will be positive counting in i915_get_crtc_scanoutpos()
435 position -= vbl_end; in i915_get_crtc_scanoutpos()
437 position += vtotal - vbl_end; in i915_get_crtc_scanoutpos()
444 *hpos = position - (*vpos * htotal); in i915_get_crtc_scanoutpos()
491 enum pipe pipe = crtc->pipe; in wait_for_pipe_scanline_moving()
495 drm_err(display->drm, in wait_for_pipe_scanline_moving()
514 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); in intel_crtc_update_active_timings()
515 u8 mode_flags = crtc_state->mode_flags; in intel_crtc_update_active_timings()
520 drm_mode_init(&adjusted_mode, &crtc_state->hw.adjusted_mode); in intel_crtc_update_active_timings()
523 drm_WARN_ON(display->drm, in intel_crtc_update_active_timings()
526 adjusted_mode.crtc_vtotal = crtc_state->vrr.vmax; in intel_crtc_update_active_timings()
527 adjusted_mode.crtc_vblank_end = crtc_state->vrr.vmax; in intel_crtc_update_active_timings()
546 spin_lock_irqsave(&display->drm->vblank_time_lock, irqflags); in intel_crtc_update_active_timings()
549 drm_calc_timestamping_constants(&crtc->base, &adjusted_mode); in intel_crtc_update_active_timings()
551 crtc->vmax_vblank_start = vmax_vblank_start; in intel_crtc_update_active_timings()
553 crtc->mode_flags = mode_flags; in intel_crtc_update_active_timings()
555 crtc->scanline_offset = intel_crtc_scanline_offset(crtc_state); in intel_crtc_update_active_timings()
557 spin_unlock_irqrestore(&display->drm->vblank_time_lock, irqflags); in intel_crtc_update_active_timings()
562 int vdisplay = mode->crtc_vdisplay; in intel_mode_vdisplay()
564 if (mode->flags & DRM_MODE_FLAG_INTERLACE) in intel_mode_vdisplay()
572 int vblank_start = mode->crtc_vblank_start; in intel_mode_vblank_start()
574 if (mode->flags & DRM_MODE_FLAG_INTERLACE) in intel_mode_vblank_start()
582 int vblank_end = mode->crtc_vblank_end; in intel_mode_vblank_end()
584 if (mode->flags & DRM_MODE_FLAG_INTERLACE) in intel_mode_vblank_end()
592 int vtotal = mode->crtc_vtotal; in intel_mode_vtotal()
594 if (mode->flags & DRM_MODE_FLAG_INTERLACE) in intel_mode_vtotal()
604 struct intel_crtc *crtc = to_intel_crtc(new_crtc_state->uapi.crtc); in intel_vblank_evade_init()
605 struct drm_i915_private *i915 = to_i915(crtc->base.dev); in intel_vblank_evade_init()
609 evade->crtc = crtc; in intel_vblank_evade_init()
611 evade->need_vlv_dsi_wa = (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915)) && in intel_vblank_evade_init()
625 adjusted_mode = &crtc_state->hw.adjusted_mode; in intel_vblank_evade_init()
627 if (crtc->mode_flags & I915_MODE_FLAG_VRR) { in intel_vblank_evade_init()
629 drm_WARN_ON(crtc->base.dev, intel_crtc_needs_modeset(new_crtc_state) || in intel_vblank_evade_init()
630 new_crtc_state->update_m_n || new_crtc_state->update_lrr); in intel_vblank_evade_init()
633 evade->vblank_start = intel_vrr_vmin_vblank_start(crtc_state); in intel_vblank_evade_init()
635 evade->vblank_start = intel_vrr_vmax_vblank_start(crtc_state); in intel_vblank_evade_init()
637 evade->vblank_start = intel_mode_vblank_start(adjusted_mode); in intel_vblank_evade_init()
641 evade->min = evade->vblank_start - intel_usecs_to_scanlines(adjusted_mode, in intel_vblank_evade_init()
643 evade->max = evade->vblank_start - 1; in intel_vblank_evade_init()
646 * M/N and TRANS_VTOTAL are double buffered on the transcoder's in intel_vblank_evade_init()
654 new_crtc_state->update_m_n || new_crtc_state->update_lrr) in intel_vblank_evade_init()
655 evade->min -= intel_mode_vblank_start(adjusted_mode) - in intel_vblank_evade_init()
662 struct intel_crtc *crtc = evade->crtc; in intel_vblank_evade()
665 wait_queue_head_t *wq = drm_crtc_vblank_waitqueue(&crtc->base); in intel_vblank_evade()
669 if (evade->min <= 0 || evade->max <= 0) in intel_vblank_evade()
681 if (scanline < evade->min || scanline > evade->max) in intel_vblank_evade()
685 drm_err(display->drm, in intel_vblank_evade()
687 pipe_name(crtc->pipe)); in intel_vblank_evade()
715 while (evade->need_vlv_dsi_wa && scanline == evade->vblank_start) in intel_vblank_evade()