]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/i915/dp: Add helper to compute num pipes required
authorAnkit Nautiyal <ankit.k.nautiyal@intel.com>
Thu, 26 Sep 2024 13:43:22 +0000 (19:13 +0530)
committerAnkit Nautiyal <ankit.k.nautiyal@intel.com>
Mon, 30 Sep 2024 14:06:45 +0000 (19:36 +0530)
Add a helper to compute the number of pipes required.
This will depend on whether the joiner is required or is forced through
the debugfs. If no joiner is required the helper returns 1.

v2:
-Return 1 if no joiner is required. (Ville)
-Change the suffix from joined_pipes to num_pipes. (Ville)
-Use number of pipes while calculating joined_pipe masks and
max_dotclk. (Ville)
v3: Simplify and rename the helper to intel_dp_num_joined_pipes(). Ville
v4: Remove redundant 'fallthrough' statement. (Ville)

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240926134322.3728021-5-ankit.k.nautiyal@intel.com
drivers/gpu/drm/i915/display/intel_display_debugfs.c
drivers/gpu/drm/i915/display/intel_dp.c
drivers/gpu/drm/i915/display/intel_dp.h
drivers/gpu/drm/i915/display/intel_dp_mst.c

index ae3715f0f1d8e1b072124bd1cc690d7bd3cfe324..5923bbc232be345922118a477823b654711110b3 100644 (file)
@@ -1343,6 +1343,7 @@ static ssize_t i915_joiner_write(struct file *file,
 
        switch (force_joined_pipes) {
        case 0:
+       case 1:
        case 2:
                connector->force_joined_pipes = force_joined_pipes;
                break;
index a1a64758d30d17749586cdf29e5f4537c3a3280d..f2a2541c10918c68f03f31f011245bc08f56b506 100644 (file)
@@ -1264,17 +1264,30 @@ intel_dp_mode_valid_downstream(struct intel_connector *connector,
        return MODE_OK;
 }
 
-bool intel_dp_need_joiner(struct intel_dp *intel_dp,
-                         struct intel_connector *connector,
-                         int hdisplay, int clock)
+static
+bool intel_dp_needs_bigjoiner(struct intel_dp *intel_dp,
+                             struct intel_connector *connector,
+                             int hdisplay, int clock)
 {
        struct drm_i915_private *i915 = dp_to_i915(intel_dp);
 
        if (!intel_dp_has_joiner(intel_dp))
                return false;
 
-       return clock > i915->display.cdclk.max_dotclk_freq || hdisplay > 5120 ||
-              connector->force_joined_pipes == 2;
+       return clock > i915->display.cdclk.max_dotclk_freq || hdisplay > 5120;
+}
+
+int intel_dp_num_joined_pipes(struct intel_dp *intel_dp,
+                             struct intel_connector *connector,
+                             int hdisplay, int clock)
+{
+       if (connector->force_joined_pipes)
+               return connector->force_joined_pipes;
+
+       if (intel_dp_needs_bigjoiner(intel_dp, connector, hdisplay, clock))
+               return 2;
+
+       return 1;
 }
 
 bool intel_dp_has_dsc(const struct intel_connector *connector)
@@ -1311,7 +1324,7 @@ intel_dp_mode_valid(struct drm_connector *_connector,
        u16 dsc_max_compressed_bpp = 0;
        u8 dsc_slice_count = 0;
        enum drm_mode_status status;
-       bool dsc = false, joiner = false;
+       bool dsc = false;
        int num_joined_pipes;
 
        status = intel_cpu_transcoder_mode_valid(dev_priv, mode);
@@ -1333,13 +1346,9 @@ intel_dp_mode_valid(struct drm_connector *_connector,
                target_clock = fixed_mode->clock;
        }
 
-       if (intel_dp_need_joiner(intel_dp, connector,
-                                mode->hdisplay, target_clock)) {
-               joiner = true;
-               max_dotclk *= 2;
-       }
-
-       num_joined_pipes = joiner ? 2 : 1;
+       num_joined_pipes = intel_dp_num_joined_pipes(intel_dp, connector,
+                                                    mode->hdisplay, target_clock);
+       max_dotclk *= num_joined_pipes;
 
        if (target_clock > max_dotclk)
                return MODE_CLOCK_HIGH;
@@ -2507,12 +2516,11 @@ intel_dp_compute_link_config(struct intel_encoder *encoder,
            !intel_dp_supports_fec(intel_dp, connector, pipe_config))
                return -EINVAL;
 
-       if (intel_dp_need_joiner(intel_dp, connector,
-                                adjusted_mode->crtc_hdisplay,
-                                adjusted_mode->crtc_clock))
-               pipe_config->joiner_pipes = GENMASK(crtc->pipe + 1, crtc->pipe);
-
-       num_joined_pipes = intel_crtc_num_joined_pipes(pipe_config);
+       num_joined_pipes = intel_dp_num_joined_pipes(intel_dp, connector,
+                                                    adjusted_mode->crtc_hdisplay,
+                                                    adjusted_mode->crtc_clock);
+       if (num_joined_pipes > 1)
+               pipe_config->joiner_pipes = GENMASK(crtc->pipe + num_joined_pipes - 1, crtc->pipe);
 
        joiner_needs_dsc = intel_dp_joiner_needs_dsc(i915, num_joined_pipes);
 
index 3b869429e575661f671881fa464a64dedf9c2755..53d1217800ef30b4057fbcb568d2a0c44180ec93 100644 (file)
@@ -151,9 +151,9 @@ int intel_dp_dsc_sink_max_compressed_bpp(const struct intel_connector *connector
 u8 intel_dp_dsc_get_slice_count(const struct intel_connector *connector,
                                int mode_clock, int mode_hdisplay,
                                int num_joined_pipes);
-bool intel_dp_need_joiner(struct intel_dp *intel_dp,
-                         struct intel_connector *connector,
-                         int hdisplay, int clock);
+int intel_dp_num_joined_pipes(struct intel_dp *intel_dp,
+                             struct intel_connector *connector,
+                             int hdisplay, int clock);
 
 static inline unsigned int intel_dp_unused_lane_mask(int lane_count)
 {
index 732d7543ad0644ae3e40112ce2b89e15fd2cde53..4765bda154c155232097ff648bff04183afb4e97 100644 (file)
@@ -581,12 +581,11 @@ static int intel_dp_mst_compute_config(struct intel_encoder *encoder,
        if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
                return -EINVAL;
 
-       if (intel_dp_need_joiner(intel_dp, connector,
-                                adjusted_mode->crtc_hdisplay,
-                                adjusted_mode->crtc_clock))
-               pipe_config->joiner_pipes = GENMASK(crtc->pipe + 1, crtc->pipe);
-
-       num_joined_pipes = intel_crtc_num_joined_pipes(pipe_config);
+       num_joined_pipes = intel_dp_num_joined_pipes(intel_dp, connector,
+                                                    adjusted_mode->crtc_hdisplay,
+                                                    adjusted_mode->crtc_clock);
+       if (num_joined_pipes > 1)
+               pipe_config->joiner_pipes = GENMASK(crtc->pipe + num_joined_pipes - 1, crtc->pipe);
 
        pipe_config->sink_format = INTEL_OUTPUT_FORMAT_RGB;
        pipe_config->output_format = INTEL_OUTPUT_FORMAT_RGB;
@@ -1428,7 +1427,7 @@ intel_dp_mst_mode_valid_ctx(struct drm_connector *connector,
        int max_dotclk = to_i915(connector->dev)->display.cdclk.max_dotclk_freq;
        int max_rate, mode_rate, max_lanes, max_link_clock;
        int ret;
-       bool dsc = false, joiner = false;
+       bool dsc = false;
        u16 dsc_max_compressed_bpp = 0;
        u8 dsc_slice_count = 0;
        int target_clock = mode->clock;
@@ -1472,13 +1471,9 @@ intel_dp_mst_mode_valid_ctx(struct drm_connector *connector,
         *   corresponding link capabilities of the sink) in case the
         *   stream is uncompressed for it by the last branch device.
         */
-       if (intel_dp_need_joiner(intel_dp, intel_connector,
-                                mode->hdisplay, target_clock)) {
-               joiner = true;
-               max_dotclk *= 2;
-       }
-
-       num_joined_pipes = joiner ? 2 : 1;
+       num_joined_pipes = intel_dp_num_joined_pipes(intel_dp, intel_connector,
+                                                    mode->hdisplay, target_clock);
+       max_dotclk *= num_joined_pipes;
 
        ret = drm_modeset_lock(&mgr->base.lock, ctx);
        if (ret)