Similar to the DP SST, refactor `mst_stream_compute_config()` to iterate
over joiner candidates and select the minimal joiner configuration that
satisfies the mode requirements. This prepares the logic for future changes
that will consider DSC slice overhead.

Signed-off-by: Ankit Nautiyal <[email protected]>
---
 drivers/gpu/drm/i915/display/intel_dp_mst.c | 50 +++++++++++++++++----
 1 file changed, 41 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c 
b/drivers/gpu/drm/i915/display/intel_dp_mst.c
index e9cfce00efcc..46208ee67905 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_mst.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c
@@ -695,6 +695,7 @@ static int mst_stream_compute_config(struct intel_encoder 
*encoder,
                &pipe_config->hw.adjusted_mode;
        int num_joined_pipes;
        int ret = 0;
+       int i;
 
        if (pipe_config->fec_enable &&
            !intel_dp_supports_fec(intel_dp, connector, pipe_config))
@@ -707,17 +708,48 @@ static int mst_stream_compute_config(struct intel_encoder 
*encoder,
        pipe_config->output_format = INTEL_OUTPUT_FORMAT_RGB;
        pipe_config->has_pch_encoder = false;
 
-       num_joined_pipes = intel_dp_num_joined_pipes(intel_dp, connector,
-                                                    
adjusted_mode->crtc_hdisplay,
-                                                    adjusted_mode->crtc_clock);
+       for (i = 0; i < ARRAY_SIZE(joiner_candidates); i++) {
+               enum joiner_type joiner = joiner_candidates[i];
+               int max_dotclk = display->cdclk.max_dotclk_freq;
 
-       if (num_joined_pipes > 1)
-               pipe_config->joiner_pipes = GENMASK(crtc->pipe + 
num_joined_pipes - 1, crtc->pipe);
+               ret = -EINVAL;
+
+               if (joiner == FORCED_JOINER) {
+                       if (!connector->force_joined_pipes)
+                               continue;
+                       num_joined_pipes = connector->force_joined_pipes;
+               } else {
+                       num_joined_pipes = 1 << joiner;
+               }
+
+               if ((joiner >= NO_JOINER && !intel_dp_has_joiner(intel_dp)) ||
+                   (joiner == BIG_JOINER && !HAS_BIGJOINER(display)) ||
+                   (joiner == ULTRA_JOINER && !HAS_ULTRAJOINER(display))) {
+                       break;
+               }
+
+               if (adjusted_mode->hdisplay > num_joined_pipes * 
intel_dp_hdisplay_limit(display))
+                       continue;
+
+               if (num_joined_pipes > 1)
+                       pipe_config->joiner_pipes = GENMASK(crtc->pipe + 
num_joined_pipes - 1,
+                                                           crtc->pipe);
+
+               ret = mst_stream_compute_link_for_joined_pipes(encoder,
+                                                              pipe_config,
+                                                              conn_state,
+                                                              
num_joined_pipes);
+               if (ret)
+                       continue;
+
+               max_dotclk *= num_joined_pipes;
+
+               if (adjusted_mode->clock <= max_dotclk) {
+                       ret = 0;
+                       break;
+               }
+       }
 
-       ret = mst_stream_compute_link_for_joined_pipes(encoder,
-                                                      pipe_config,
-                                                      conn_state,
-                                                      num_joined_pipes);
        if (ret)
                return ret;
 
-- 
2.45.2

Reply via email to