Skip to content

Commit fa7a7a1

Browse files
committed
drm/i915: Add helper to modeset a set of pipes
Add intel_modeset_pipes_in_mask_early() to modeset a provided set of pipes, used in a follow-up patch. As opposed to intel_modeset_all_pipes() which modesets only the active pipes - others don't requiring programming the HW - modeset all enabled pipes in intel_modeset_pipes_in_mask_early() which may need to recompute their state even if they are not active (that is in the DPMS off state). While at it add DocBook descriptions for the two exported functions. v2: - Add a flag controlling if active planes are force updated as well. - Add DockBook descriptions. v3: - For clarity use _early/_late suffixes for the exported functions instead of the update_active_planes parameter. (Ville) v4: - In intel_modeset_pipes_in_mask_early() update only the crtc flags relevant to the early phase. (Ville) - Rename intel_modeset_all_pipes() in a separate patch. Cc: Ville Syrjälä <[email protected]> Reviewed-by: Ville Syrjälä <[email protected]> Signed-off-by: Imre Deak <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 592b9bf commit fa7a7a1

File tree

2 files changed

+83
-21
lines changed

2 files changed

+83
-21
lines changed

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

Lines changed: 81 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5458,16 +5458,90 @@ intel_verify_planes(struct intel_atomic_state *state)
54585458
plane_state->uapi.visible);
54595459
}
54605460

5461+
static int intel_modeset_pipe(struct intel_atomic_state *state,
5462+
struct intel_crtc_state *crtc_state,
5463+
const char *reason)
5464+
{
5465+
struct drm_i915_private *i915 = to_i915(state->base.dev);
5466+
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
5467+
int ret;
5468+
5469+
drm_dbg_kms(&i915->drm, "[CRTC:%d:%s] Full modeset due to %s\n",
5470+
crtc->base.base.id, crtc->base.name, reason);
5471+
5472+
ret = drm_atomic_add_affected_connectors(&state->base,
5473+
&crtc->base);
5474+
if (ret)
5475+
return ret;
5476+
5477+
ret = intel_dp_mst_add_topology_state_for_crtc(state, crtc);
5478+
if (ret)
5479+
return ret;
5480+
5481+
ret = intel_atomic_add_affected_planes(state, crtc);
5482+
if (ret)
5483+
return ret;
5484+
5485+
crtc_state->uapi.mode_changed = true;
5486+
5487+
return 0;
5488+
}
5489+
5490+
/**
5491+
* intel_modeset_pipes_in_mask_early - force a full modeset on a set of pipes
5492+
* @state: intel atomic state
5493+
* @reason: the reason for the full modeset
5494+
* @mask: mask of pipes to modeset
5495+
*
5496+
* Add pipes in @mask to @state and force a full modeset on the enabled ones
5497+
* due to the description in @reason.
5498+
* This function can be called only before new plane states are computed.
5499+
*
5500+
* Returns 0 in case of success, negative error code otherwise.
5501+
*/
5502+
int intel_modeset_pipes_in_mask_early(struct intel_atomic_state *state,
5503+
const char *reason, u8 mask)
5504+
{
5505+
struct drm_i915_private *i915 = to_i915(state->base.dev);
5506+
struct intel_crtc *crtc;
5507+
5508+
for_each_intel_crtc_in_pipe_mask(&i915->drm, crtc, mask) {
5509+
struct intel_crtc_state *crtc_state;
5510+
int ret;
5511+
5512+
crtc_state = intel_atomic_get_crtc_state(&state->base, crtc);
5513+
if (IS_ERR(crtc_state))
5514+
return PTR_ERR(crtc_state);
5515+
5516+
if (!crtc_state->hw.enable ||
5517+
intel_crtc_needs_modeset(crtc_state))
5518+
continue;
5519+
5520+
ret = intel_modeset_pipe(state, crtc_state, reason);
5521+
if (ret)
5522+
return ret;
5523+
}
5524+
5525+
return 0;
5526+
}
5527+
5528+
/**
5529+
* intel_modeset_all_pipes - force a full modeset on all pipes
5530+
* @state: intel atomic state
5531+
* @reason: the reason for the full modeset
5532+
*
5533+
* Add all pipes to @state and force a full modeset on the active ones due to
5534+
* the description in @reason.
5535+
* This function can be called only after new plane states are computed already.
5536+
*
5537+
* Returns 0 in case of success, negative error code otherwise.
5538+
*/
54615539
int intel_modeset_all_pipes(struct intel_atomic_state *state,
54625540
const char *reason)
54635541
{
54645542
struct drm_i915_private *dev_priv = to_i915(state->base.dev);
54655543
struct intel_crtc *crtc;
54665544

5467-
/*
5468-
* Add all pipes to the state, and force
5469-
* a modeset on all the active ones.
5470-
*/
54715545
for_each_intel_crtc(&dev_priv->drm, crtc) {
54725546
struct intel_crtc_state *crtc_state;
54735547
int ret;
@@ -5480,27 +5554,13 @@ int intel_modeset_all_pipes(struct intel_atomic_state *state,
54805554
intel_crtc_needs_modeset(crtc_state))
54815555
continue;
54825556

5483-
drm_dbg_kms(&dev_priv->drm, "[CRTC:%d:%s] Full modeset due to %s\n",
5484-
crtc->base.base.id, crtc->base.name, reason);
5557+
ret = intel_modeset_pipe(state, crtc_state, reason);
5558+
if (ret)
5559+
return ret;
54855560

5486-
crtc_state->uapi.mode_changed = true;
54875561
crtc_state->update_pipe = false;
54885562
crtc_state->update_m_n = false;
54895563
crtc_state->update_lrr = false;
5490-
5491-
ret = drm_atomic_add_affected_connectors(&state->base,
5492-
&crtc->base);
5493-
if (ret)
5494-
return ret;
5495-
5496-
ret = intel_dp_mst_add_topology_state_for_crtc(state, crtc);
5497-
if (ret)
5498-
return ret;
5499-
5500-
ret = intel_atomic_add_affected_planes(state, crtc);
5501-
if (ret)
5502-
return ret;
5503-
55045564
crtc_state->update_planes |= crtc_state->active_planes;
55055565
crtc_state->async_flip_planes = 0;
55065566
crtc_state->do_async_flip = false;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,8 @@ void intel_plane_fixup_bitmasks(struct intel_crtc_state *crtc_state);
511511
void intel_update_watermarks(struct drm_i915_private *i915);
512512

513513
/* modesetting */
514+
int intel_modeset_pipes_in_mask_early(struct intel_atomic_state *state,
515+
const char *reason, u8 pipe_mask);
514516
int intel_modeset_all_pipes(struct intel_atomic_state *state,
515517
const char *reason);
516518
void intel_modeset_get_crtc_power_domains(struct intel_crtc_state *crtc_state,

0 commit comments

Comments
 (0)