Skip to content

Commit 6b1cd15

Browse files
vsyrjalalutzbichler
authored andcommitted
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ä <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: Ankit Nautiyal <[email protected]>
1 parent 0a00038 commit 6b1cd15

File tree

3 files changed

+45
-35
lines changed

3 files changed

+45
-35
lines changed

drivers/gpu/drm/i915/display/intel_dsb.c

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,6 @@ static bool pre_commit_is_vrr_active(struct intel_atomic_state *state,
109109
return old_crtc_state->vrr.enable && !intel_crtc_vrr_disabling(state, crtc);
110110
}
111111

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-
131112
static int dsb_vblank_delay(const struct intel_crtc_state *crtc_state)
132113
{
133114
return intel_mode_vblank_delay(&crtc_state->hw.adjusted_mode);
@@ -136,7 +117,8 @@ static int dsb_vblank_delay(const struct intel_crtc_state *crtc_state)
136117
static int dsb_vtotal(struct intel_atomic_state *state,
137118
struct intel_crtc *crtc)
138119
{
139-
const struct intel_crtc_state *crtc_state = pre_commit_crtc_state(state, crtc);
120+
const struct intel_crtc_state *crtc_state =
121+
intel_pre_commit_crtc_state(state, crtc);
140122

141123
if (pre_commit_is_vrr_active(state, crtc))
142124
return intel_vrr_vmax_vtotal(crtc_state);
@@ -147,7 +129,8 @@ static int dsb_vtotal(struct intel_atomic_state *state,
147129
static int dsb_dewake_scanline_start(struct intel_atomic_state *state,
148130
struct intel_crtc *crtc)
149131
{
150-
const struct intel_crtc_state *crtc_state = pre_commit_crtc_state(state, crtc);
132+
const struct intel_crtc_state *crtc_state =
133+
intel_pre_commit_crtc_state(state, crtc);
151134
struct drm_i915_private *i915 = to_i915(state->base.dev);
152135
unsigned int latency = skl_watermark_max_latency(i915, 0);
153136

@@ -158,15 +141,17 @@ static int dsb_dewake_scanline_start(struct intel_atomic_state *state,
158141
static int dsb_dewake_scanline_end(struct intel_atomic_state *state,
159142
struct intel_crtc *crtc)
160143
{
161-
const struct intel_crtc_state *crtc_state = pre_commit_crtc_state(state, crtc);
144+
const struct intel_crtc_state *crtc_state =
145+
intel_pre_commit_crtc_state(state, crtc);
162146

163147
return intel_mode_vdisplay(&crtc_state->hw.adjusted_mode);
164148
}
165149

166150
static int dsb_scanline_to_hw(struct intel_atomic_state *state,
167151
struct intel_crtc *crtc, int scanline)
168152
{
169-
const struct intel_crtc_state *crtc_state = pre_commit_crtc_state(state, crtc);
153+
const struct intel_crtc_state *crtc_state =
154+
intel_pre_commit_crtc_state(state, crtc);
170155
int vtotal = dsb_vtotal(state, crtc);
171156

172157
return (scanline + vtotal - intel_crtc_scanline_offset(crtc_state)) % vtotal;
@@ -531,7 +516,8 @@ void intel_dsb_vblank_evade(struct intel_atomic_state *state,
531516
struct intel_dsb *dsb)
532517
{
533518
struct intel_crtc *crtc = dsb->crtc;
534-
const struct intel_crtc_state *crtc_state = pre_commit_crtc_state(state, crtc);
519+
const struct intel_crtc_state *crtc_state =
520+
intel_pre_commit_crtc_state(state, crtc);
535521
/* FIXME calibrate sensibly */
536522
int latency = intel_usecs_to_scanlines(&crtc_state->hw.adjusted_mode, 20);
537523
int vblank_delay = dsb_vblank_delay(crtc_state);
@@ -623,7 +609,8 @@ void intel_dsb_wait_vblank_delay(struct intel_atomic_state *state,
623609
struct intel_dsb *dsb)
624610
{
625611
struct intel_crtc *crtc = dsb->crtc;
626-
const struct intel_crtc_state *crtc_state = pre_commit_crtc_state(state, crtc);
612+
const struct intel_crtc_state *crtc_state =
613+
intel_pre_commit_crtc_state(state, crtc);
627614
int usecs = intel_scanlines_to_usecs(&crtc_state->hw.adjusted_mode,
628615
dsb_vblank_delay(crtc_state)) + 1;
629616

drivers/gpu/drm/i915/display/intel_vblank.c

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,32 @@ int intel_mode_vblank_delay(const struct drm_display_mode *mode)
596596
return intel_mode_vblank_start(mode) - intel_mode_vdisplay(mode);
597597
}
598598

599+
static const struct intel_crtc_state *
600+
pre_commit_crtc_state(const struct intel_crtc_state *old_crtc_state,
601+
const struct intel_crtc_state *new_crtc_state)
602+
{
603+
/*
604+
* During fastsets/etc. the transcoder is still
605+
* running with the old timings at this point.
606+
*/
607+
if (intel_crtc_needs_modeset(new_crtc_state))
608+
return new_crtc_state;
609+
else
610+
return old_crtc_state;
611+
}
612+
613+
const struct intel_crtc_state *
614+
intel_pre_commit_crtc_state(struct intel_atomic_state *state,
615+
struct intel_crtc *crtc)
616+
{
617+
const struct intel_crtc_state *old_crtc_state =
618+
intel_atomic_get_old_crtc_state(state, crtc);
619+
const struct intel_crtc_state *new_crtc_state =
620+
intel_atomic_get_new_crtc_state(state, crtc);
621+
622+
return pre_commit_crtc_state(old_crtc_state, new_crtc_state);
623+
}
624+
599625
void intel_vblank_evade_init(const struct intel_crtc_state *old_crtc_state,
600626
const struct intel_crtc_state *new_crtc_state,
601627
struct intel_vblank_evade_ctx *evade)
@@ -611,16 +637,8 @@ void intel_vblank_evade_init(const struct intel_crtc_state *old_crtc_state,
611637
display->platform.cherryview) &&
612638
intel_crtc_has_type(new_crtc_state, INTEL_OUTPUT_DSI);
613639

614-
/*
615-
* During fastsets/etc. the transcoder is still
616-
* running with the old timings at this point.
617-
*
618-
* TODO: maybe just use the active timings here?
619-
*/
620-
if (intel_crtc_needs_modeset(new_crtc_state))
621-
crtc_state = new_crtc_state;
622-
else
623-
crtc_state = old_crtc_state;
640+
/* TODO: maybe just use the active timings here? */
641+
crtc_state = pre_commit_crtc_state(old_crtc_state, new_crtc_state);
624642

625643
adjusted_mode = &crtc_state->hw.adjusted_mode;
626644

drivers/gpu/drm/i915/display/intel_vblank.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
struct drm_crtc;
1313
struct drm_display_mode;
14+
struct intel_atomic_state;
1415
struct intel_crtc;
1516
struct intel_crtc_state;
1617

@@ -43,4 +44,8 @@ void intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state,
4344
bool vrr_enable);
4445
int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state);
4546

47+
const struct intel_crtc_state *
48+
intel_pre_commit_crtc_state(struct intel_atomic_state *state,
49+
struct intel_crtc *crtc);
50+
4651
#endif /* __INTEL_VBLANK_H__ */

0 commit comments

Comments
 (0)