Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915: Consolidate intel_pre_commit_crtc_state()

We have approximately two copies of pre_commit_crtc_state(),
one in the DSB code, the other in the vblank evasion code.
Combine them into one. The slight difference between the two
is that vblank evasion doesn't have a full atomic state (when
called from the legacy cursor code), so it gets the old and
new crtc state passed in by hand.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241210211007.5976-11-ville.syrjala@linux.intel.com
Reviewed-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>

+45 -35
+12 -25
drivers/gpu/drm/i915/display/intel_dsb.c
··· 109 109 return old_crtc_state->vrr.enable && !intel_crtc_vrr_disabling(state, crtc); 110 110 } 111 111 112 - static const struct intel_crtc_state * 113 - pre_commit_crtc_state(struct intel_atomic_state *state, 114 - struct intel_crtc *crtc) 115 - { 116 - const struct intel_crtc_state *old_crtc_state = 117 - intel_atomic_get_old_crtc_state(state, crtc); 118 - const struct intel_crtc_state *new_crtc_state = 119 - intel_atomic_get_new_crtc_state(state, crtc); 120 - 121 - /* 122 - * During fastsets/etc. the transcoder is still 123 - * running with the old timings at this point. 124 - */ 125 - if (intel_crtc_needs_modeset(new_crtc_state)) 126 - return new_crtc_state; 127 - else 128 - return old_crtc_state; 129 - } 130 - 131 112 static int dsb_vblank_delay(const struct intel_crtc_state *crtc_state) 132 113 { 133 114 return intel_mode_vblank_delay(&crtc_state->hw.adjusted_mode); ··· 117 136 static int dsb_vtotal(struct intel_atomic_state *state, 118 137 struct intel_crtc *crtc) 119 138 { 120 - const struct intel_crtc_state *crtc_state = pre_commit_crtc_state(state, crtc); 139 + const struct intel_crtc_state *crtc_state = 140 + intel_pre_commit_crtc_state(state, crtc); 121 141 122 142 if (pre_commit_is_vrr_active(state, crtc)) 123 143 return intel_vrr_vmax_vtotal(crtc_state); ··· 129 147 static int dsb_dewake_scanline_start(struct intel_atomic_state *state, 130 148 struct intel_crtc *crtc) 131 149 { 132 - const struct intel_crtc_state *crtc_state = pre_commit_crtc_state(state, crtc); 150 + const struct intel_crtc_state *crtc_state = 151 + intel_pre_commit_crtc_state(state, crtc); 133 152 struct drm_i915_private *i915 = to_i915(state->base.dev); 134 153 unsigned int latency = skl_watermark_max_latency(i915, 0); 135 154 ··· 141 158 static int dsb_dewake_scanline_end(struct intel_atomic_state *state, 142 159 struct intel_crtc *crtc) 143 160 { 144 - const struct intel_crtc_state *crtc_state = pre_commit_crtc_state(state, crtc); 161 + const struct intel_crtc_state *crtc_state = 162 + intel_pre_commit_crtc_state(state, crtc); 145 163 146 164 return intel_mode_vdisplay(&crtc_state->hw.adjusted_mode); 147 165 } ··· 150 166 static int dsb_scanline_to_hw(struct intel_atomic_state *state, 151 167 struct intel_crtc *crtc, int scanline) 152 168 { 153 - const struct intel_crtc_state *crtc_state = pre_commit_crtc_state(state, crtc); 169 + const struct intel_crtc_state *crtc_state = 170 + intel_pre_commit_crtc_state(state, crtc); 154 171 int vtotal = dsb_vtotal(state, crtc); 155 172 156 173 return (scanline + vtotal - intel_crtc_scanline_offset(crtc_state)) % vtotal; ··· 516 531 struct intel_dsb *dsb) 517 532 { 518 533 struct intel_crtc *crtc = dsb->crtc; 519 - const struct intel_crtc_state *crtc_state = pre_commit_crtc_state(state, crtc); 534 + const struct intel_crtc_state *crtc_state = 535 + intel_pre_commit_crtc_state(state, crtc); 520 536 /* FIXME calibrate sensibly */ 521 537 int latency = intel_usecs_to_scanlines(&crtc_state->hw.adjusted_mode, 20); 522 538 int vblank_delay = dsb_vblank_delay(crtc_state); ··· 609 623 struct intel_dsb *dsb) 610 624 { 611 625 struct intel_crtc *crtc = dsb->crtc; 612 - const struct intel_crtc_state *crtc_state = pre_commit_crtc_state(state, crtc); 626 + const struct intel_crtc_state *crtc_state = 627 + intel_pre_commit_crtc_state(state, crtc); 613 628 int usecs = intel_scanlines_to_usecs(&crtc_state->hw.adjusted_mode, 614 629 dsb_vblank_delay(crtc_state)) + 1; 615 630
+28 -10
drivers/gpu/drm/i915/display/intel_vblank.c
··· 602 602 return intel_mode_vblank_start(mode) - intel_mode_vdisplay(mode); 603 603 } 604 604 605 + static const struct intel_crtc_state * 606 + pre_commit_crtc_state(const struct intel_crtc_state *old_crtc_state, 607 + const struct intel_crtc_state *new_crtc_state) 608 + { 609 + /* 610 + * During fastsets/etc. the transcoder is still 611 + * running with the old timings at this point. 612 + */ 613 + if (intel_crtc_needs_modeset(new_crtc_state)) 614 + return new_crtc_state; 615 + else 616 + return old_crtc_state; 617 + } 618 + 619 + const struct intel_crtc_state * 620 + intel_pre_commit_crtc_state(struct intel_atomic_state *state, 621 + struct intel_crtc *crtc) 622 + { 623 + const struct intel_crtc_state *old_crtc_state = 624 + intel_atomic_get_old_crtc_state(state, crtc); 625 + const struct intel_crtc_state *new_crtc_state = 626 + intel_atomic_get_new_crtc_state(state, crtc); 627 + 628 + return pre_commit_crtc_state(old_crtc_state, new_crtc_state); 629 + } 630 + 605 631 void intel_vblank_evade_init(const struct intel_crtc_state *old_crtc_state, 606 632 const struct intel_crtc_state *new_crtc_state, 607 633 struct intel_vblank_evade_ctx *evade) ··· 643 617 display->platform.cherryview) && 644 618 intel_crtc_has_type(new_crtc_state, INTEL_OUTPUT_DSI); 645 619 646 - /* 647 - * During fastsets/etc. the transcoder is still 648 - * running with the old timings at this point. 649 - * 650 - * TODO: maybe just use the active timings here? 651 - */ 652 - if (intel_crtc_needs_modeset(new_crtc_state)) 653 - crtc_state = new_crtc_state; 654 - else 655 - crtc_state = old_crtc_state; 620 + /* TODO: maybe just use the active timings here? */ 621 + crtc_state = pre_commit_crtc_state(old_crtc_state, new_crtc_state); 656 622 657 623 adjusted_mode = &crtc_state->hw.adjusted_mode; 658 624
+5
drivers/gpu/drm/i915/display/intel_vblank.h
··· 11 11 12 12 struct drm_crtc; 13 13 struct drm_display_mode; 14 + struct intel_atomic_state; 14 15 struct intel_crtc; 15 16 struct intel_crtc_state; 16 17 ··· 43 42 void intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state, 44 43 bool vrr_enable); 45 44 int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state); 45 + 46 + const struct intel_crtc_state * 47 + intel_pre_commit_crtc_state(struct intel_atomic_state *state, 48 + struct intel_crtc *crtc); 46 49 47 50 #endif /* __INTEL_VBLANK_H__ */