Skip to content

Commit 72b2d2a

Browse files
committed
drm/i915/dp: Factor out helpers to compute the link limits
Factor out helpers that DP / DP_MST encoders can use to compute the link rate/lane count and bpp limits. A follow-up patch will call these to recalculate the limits if DSC compression is required. Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Imre Deak <imre.deak@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230921195159.2646027-2-imre.deak@intel.com
1 parent f83b94d commit 72b2d2a

2 files changed

Lines changed: 68 additions & 45 deletions

File tree

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

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2188,29 +2188,25 @@ int intel_dp_dsc_compute_config(struct intel_dp *intel_dp,
21882188
return 0;
21892189
}
21902190

2191-
static int
2192-
intel_dp_compute_link_config(struct intel_encoder *encoder,
2193-
struct intel_crtc_state *pipe_config,
2194-
struct drm_connector_state *conn_state,
2195-
bool respect_downstream_limits)
2191+
static void
2192+
intel_dp_compute_config_limits(struct intel_dp *intel_dp,
2193+
struct intel_crtc_state *crtc_state,
2194+
bool respect_downstream_limits,
2195+
struct link_config_limits *limits)
21962196
{
2197-
struct drm_i915_private *i915 = to_i915(encoder->base.dev);
2198-
struct intel_crtc *crtc = to_intel_crtc(pipe_config->uapi.crtc);
2197+
struct drm_i915_private *i915 = dp_to_i915(intel_dp);
21992198
const struct drm_display_mode *adjusted_mode =
2200-
&pipe_config->hw.adjusted_mode;
2201-
struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
2202-
struct link_config_limits limits;
2203-
bool joiner_needs_dsc = false;
2204-
int ret;
2199+
&crtc_state->hw.adjusted_mode;
22052200

2206-
limits.min_rate = intel_dp_common_rate(intel_dp, 0);
2207-
limits.max_rate = intel_dp_max_link_rate(intel_dp);
2201+
limits->min_rate = intel_dp_common_rate(intel_dp, 0);
2202+
limits->max_rate = intel_dp_max_link_rate(intel_dp);
22082203

2209-
limits.min_lane_count = 1;
2210-
limits.max_lane_count = intel_dp_max_lane_count(intel_dp);
2204+
limits->min_lane_count = 1;
2205+
limits->max_lane_count = intel_dp_max_lane_count(intel_dp);
22112206

2212-
limits.min_bpp = intel_dp_min_bpp(pipe_config->output_format);
2213-
limits.max_bpp = intel_dp_max_bpp(intel_dp, pipe_config, respect_downstream_limits);
2207+
limits->min_bpp = intel_dp_min_bpp(crtc_state->output_format);
2208+
limits->max_bpp = intel_dp_max_bpp(intel_dp, crtc_state,
2209+
respect_downstream_limits);
22142210

22152211
if (intel_dp->use_max_params) {
22162212
/*
@@ -2221,16 +2217,35 @@ intel_dp_compute_link_config(struct intel_encoder *encoder,
22212217
* configuration, and typically on older panels these
22222218
* values correspond to the native resolution of the panel.
22232219
*/
2224-
limits.min_lane_count = limits.max_lane_count;
2225-
limits.min_rate = limits.max_rate;
2220+
limits->min_lane_count = limits->max_lane_count;
2221+
limits->min_rate = limits->max_rate;
22262222
}
22272223

2228-
intel_dp_adjust_compliance_config(intel_dp, pipe_config, &limits);
2224+
intel_dp_adjust_compliance_config(intel_dp, crtc_state, limits);
22292225

22302226
drm_dbg_kms(&i915->drm, "DP link computation with max lane count %i "
22312227
"max rate %d max bpp %d pixel clock %iKHz\n",
2232-
limits.max_lane_count, limits.max_rate,
2233-
limits.max_bpp, adjusted_mode->crtc_clock);
2228+
limits->max_lane_count, limits->max_rate,
2229+
limits->max_bpp, adjusted_mode->crtc_clock);
2230+
}
2231+
2232+
static int
2233+
intel_dp_compute_link_config(struct intel_encoder *encoder,
2234+
struct intel_crtc_state *pipe_config,
2235+
struct drm_connector_state *conn_state,
2236+
bool respect_downstream_limits)
2237+
{
2238+
struct drm_i915_private *i915 = to_i915(encoder->base.dev);
2239+
struct intel_crtc *crtc = to_intel_crtc(pipe_config->uapi.crtc);
2240+
const struct drm_display_mode *adjusted_mode =
2241+
&pipe_config->hw.adjusted_mode;
2242+
struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
2243+
struct link_config_limits limits;
2244+
bool joiner_needs_dsc = false;
2245+
int ret;
2246+
2247+
intel_dp_compute_config_limits(intel_dp, pipe_config,
2248+
respect_downstream_limits, &limits);
22342249

22352250
if (intel_dp_need_bigjoiner(intel_dp, adjusted_mode->crtc_hdisplay,
22362251
adjusted_mode->crtc_clock))

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

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,35 @@ static int intel_dp_mst_update_slots(struct intel_encoder *encoder,
293293
return 0;
294294
}
295295

296+
static void
297+
intel_dp_mst_compute_config_limits(struct intel_dp *intel_dp,
298+
struct intel_crtc_state *crtc_state,
299+
struct link_config_limits *limits)
300+
{
301+
/*
302+
* for MST we always configure max link bw - the spec doesn't
303+
* seem to suggest we should do otherwise.
304+
*/
305+
limits->min_rate = limits->max_rate =
306+
intel_dp_max_link_rate(intel_dp);
307+
308+
limits->min_lane_count = limits->max_lane_count =
309+
intel_dp_max_lane_count(intel_dp);
310+
311+
limits->min_bpp = intel_dp_min_bpp(crtc_state->output_format);
312+
/*
313+
* FIXME: If all the streams can't fit into the link with
314+
* their current pipe_bpp we should reduce pipe_bpp across
315+
* the board until things start to fit. Until then we
316+
* limit to <= 8bpc since that's what was hardcoded for all
317+
* MST streams previously. This hack should be removed once
318+
* we have the proper retry logic in place.
319+
*/
320+
limits->max_bpp = min(crtc_state->pipe_bpp, 24);
321+
322+
intel_dp_adjust_compliance_config(intel_dp, crtc_state, limits);
323+
}
324+
296325
static int intel_dp_mst_compute_config(struct intel_encoder *encoder,
297326
struct intel_crtc_state *pipe_config,
298327
struct drm_connector_state *conn_state)
@@ -312,28 +341,7 @@ static int intel_dp_mst_compute_config(struct intel_encoder *encoder,
312341
pipe_config->output_format = INTEL_OUTPUT_FORMAT_RGB;
313342
pipe_config->has_pch_encoder = false;
314343

315-
/*
316-
* for MST we always configure max link bw - the spec doesn't
317-
* seem to suggest we should do otherwise.
318-
*/
319-
limits.min_rate =
320-
limits.max_rate = intel_dp_max_link_rate(intel_dp);
321-
322-
limits.min_lane_count =
323-
limits.max_lane_count = intel_dp_max_lane_count(intel_dp);
324-
325-
limits.min_bpp = intel_dp_min_bpp(pipe_config->output_format);
326-
/*
327-
* FIXME: If all the streams can't fit into the link with
328-
* their current pipe_bpp we should reduce pipe_bpp across
329-
* the board until things start to fit. Until then we
330-
* limit to <= 8bpc since that's what was hardcoded for all
331-
* MST streams previously. This hack should be removed once
332-
* we have the proper retry logic in place.
333-
*/
334-
limits.max_bpp = min(pipe_config->pipe_bpp, 24);
335-
336-
intel_dp_adjust_compliance_config(intel_dp, pipe_config, &limits);
344+
intel_dp_mst_compute_config_limits(intel_dp, pipe_config, &limits);
337345

338346
ret = intel_dp_mst_compute_link_config(encoder, pipe_config,
339347
conn_state, &limits);

0 commit comments

Comments
 (0)