]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915/dsc: abstract helpers to get bigjoiner primary/secondary crtc
authorJani Nikula <jani.nikula@intel.com>
Thu, 10 Jun 2021 09:05:28 +0000 (12:05 +0300)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Mon, 28 Jun 2021 11:43:52 +0000 (07:43 -0400)
Add a single point of truth for figuring out the primary/secondary crtc
for bigjoiner instead of duplicating the magic pipe +/- 1 in multiple
places.

Also fix the pipe validity checks to properly take non-contiguous pipes
into account. The current checks may theoretically overflow
i915->pipe_to_crtc_mapping[pipe], albeit with a warning, due to fused
off pipes, as INTEL_NUM_PIPES() returns the actual number of pipes on
the platform, and the check is for INTEL_NUM_PIPES() == pipe + 1.

Prefer primary/secondary terminology going forward.

v2:
- Improved abstractions for pipe validity etc.

Fixes: 8a029c113b17 ("drm/i915/dp: Modify VDSC helpers to configure DSC for Bigjoiner slave")
Fixes: d961eb20adb6 ("drm/i915/bigjoiner: atomic commit changes for uncompressed joiner")
Cc: Animesh Manna <animesh.manna@intel.com>
Cc: Manasi Navare <manasi.d.navare@intel.com>
Cc: Vandita Kulkarni <vandita.kulkarni@intel.com>
Reviewed-by: Manasi Navare <manasi.dl.navare@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210610090528.20511-1-jani.nikula@intel.com
(cherry picked from commit 17203224f0536cf223dc5789028d04a768d96ec3)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/i915/display/intel_display.c
drivers/gpu/drm/i915/display/intel_display_types.h
drivers/gpu/drm/i915/display/intel_vdsc.c
drivers/gpu/drm/i915/display/intel_vdsc.h

index 362bff9beb5ce28d44b1fccd87adef1852e05696..3bad4e00f7be4f234e4125a0cdec33c71f91e8cd 100644 (file)
@@ -9618,7 +9618,6 @@ static int intel_atomic_check_bigjoiner(struct intel_atomic_state *state,
                                        struct intel_crtc_state *old_crtc_state,
                                        struct intel_crtc_state *new_crtc_state)
 {
-       struct drm_i915_private *dev_priv = to_i915(state->base.dev);
        struct intel_crtc_state *slave_crtc_state, *master_crtc_state;
        struct intel_crtc *slave, *master;
 
@@ -9634,15 +9633,15 @@ static int intel_atomic_check_bigjoiner(struct intel_atomic_state *state,
        if (!new_crtc_state->bigjoiner)
                return 0;
 
-       if (1 + crtc->pipe >= INTEL_NUM_PIPES(dev_priv)) {
+       slave = intel_dsc_get_bigjoiner_secondary(crtc);
+       if (!slave) {
                DRM_DEBUG_KMS("[CRTC:%d:%s] Big joiner configuration requires "
                              "CRTC + 1 to be used, doesn't exist\n",
                              crtc->base.base.id, crtc->base.name);
                return -EINVAL;
        }
 
-       slave = new_crtc_state->bigjoiner_linked_crtc =
-               intel_get_crtc_for_pipe(dev_priv, crtc->pipe + 1);
+       new_crtc_state->bigjoiner_linked_crtc = slave;
        slave_crtc_state = intel_atomic_get_crtc_state(&state->base, slave);
        master = crtc;
        if (IS_ERR(slave_crtc_state))
index ee7cbdd7db875cd64ccd7fce294e0f4c714812a5..04613864cbe88480341e5e9fdeb58c93c3eb32de 100644 (file)
@@ -1723,6 +1723,14 @@ vlv_pipe_to_channel(enum pipe pipe)
        }
 }
 
+static inline bool intel_pipe_valid(struct drm_i915_private *i915, enum pipe pipe)
+{
+       return (pipe >= 0 &&
+               pipe < ARRAY_SIZE(i915->pipe_to_crtc_mapping) &&
+               INTEL_INFO(i915)->pipe_mask & BIT(pipe) &&
+               i915->pipe_to_crtc_mapping[pipe]);
+}
+
 static inline struct intel_crtc *
 intel_get_first_crtc(struct drm_i915_private *dev_priv)
 {
index 7121b66bf96de0c87fb705b0e61f126043099c53..85749370508c3a100ad751202b25a8521e572cee 100644 (file)
@@ -1106,6 +1106,27 @@ static i915_reg_t dss_ctl2_reg(const struct intel_crtc_state *crtc_state)
        return is_pipe_dsc(crtc_state) ? ICL_PIPE_DSS_CTL2(pipe) : DSS_CTL2;
 }
 
+static struct intel_crtc *
+_get_crtc_for_pipe(struct drm_i915_private *i915, enum pipe pipe)
+{
+       if (!intel_pipe_valid(i915, pipe))
+               return NULL;
+
+       return intel_get_crtc_for_pipe(i915, pipe);
+}
+
+struct intel_crtc *
+intel_dsc_get_bigjoiner_secondary(const struct intel_crtc *primary_crtc)
+{
+       return _get_crtc_for_pipe(to_i915(primary_crtc->base.dev), primary_crtc->pipe + 1);
+}
+
+static struct intel_crtc *
+intel_dsc_get_bigjoiner_primary(const struct intel_crtc *secondary_crtc)
+{
+       return _get_crtc_for_pipe(to_i915(secondary_crtc->base.dev), secondary_crtc->pipe - 1);
+}
+
 void intel_uncompressed_joiner_enable(const struct intel_crtc_state *crtc_state)
 {
        struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
@@ -1178,15 +1199,13 @@ void intel_uncompressed_joiner_get_config(struct intel_crtc_state *crtc_state)
        dss_ctl1 = intel_de_read(dev_priv, dss_ctl1_reg(crtc_state));
        if (dss_ctl1 & UNCOMPRESSED_JOINER_MASTER) {
                crtc_state->bigjoiner = true;
-               if (!WARN_ON(INTEL_NUM_PIPES(dev_priv) == crtc->pipe + 1))
-                       crtc_state->bigjoiner_linked_crtc =
-                               intel_get_crtc_for_pipe(dev_priv, crtc->pipe + 1);
+               crtc_state->bigjoiner_linked_crtc = intel_dsc_get_bigjoiner_secondary(crtc);
+               drm_WARN_ON(&dev_priv->drm, !crtc_state->bigjoiner_linked_crtc);
        } else if (dss_ctl1 & UNCOMPRESSED_JOINER_SLAVE) {
                crtc_state->bigjoiner = true;
                crtc_state->bigjoiner_slave = true;
-               if (!WARN_ON(crtc->pipe == PIPE_A))
-                       crtc_state->bigjoiner_linked_crtc =
-                               intel_get_crtc_for_pipe(dev_priv, crtc->pipe - 1);
+               crtc_state->bigjoiner_linked_crtc = intel_dsc_get_bigjoiner_primary(crtc);
+               drm_WARN_ON(&dev_priv->drm, !crtc_state->bigjoiner_linked_crtc);
        }
 }
 
@@ -1224,14 +1243,11 @@ void intel_dsc_get_config(struct intel_crtc_state *crtc_state)
 
                if (!(dss_ctl1 & MASTER_BIG_JOINER_ENABLE)) {
                        crtc_state->bigjoiner_slave = true;
-                       if (!WARN_ON(crtc->pipe == PIPE_A))
-                               crtc_state->bigjoiner_linked_crtc =
-                                       intel_get_crtc_for_pipe(dev_priv, crtc->pipe - 1);
+                       crtc_state->bigjoiner_linked_crtc = intel_dsc_get_bigjoiner_primary(crtc);
                } else {
-                       if (!WARN_ON(INTEL_NUM_PIPES(dev_priv) == crtc->pipe + 1))
-                               crtc_state->bigjoiner_linked_crtc =
-                                       intel_get_crtc_for_pipe(dev_priv, crtc->pipe + 1);
+                       crtc_state->bigjoiner_linked_crtc = intel_dsc_get_bigjoiner_secondary(crtc);
                }
+               drm_WARN_ON(&dev_priv->drm, !crtc_state->bigjoiner_linked_crtc);
        }
 
        /* FIXME: add more state readout as needed */
index fe4d455612532ce4e3310ba00f67b866b1126970..dfb1fd38deb4782b32dfaab04104f9bc727f945a 100644 (file)
@@ -22,5 +22,6 @@ void intel_uncompressed_joiner_get_config(struct intel_crtc_state *crtc_state);
 void intel_dsc_get_config(struct intel_crtc_state *crtc_state);
 enum intel_display_power_domain
 intel_dsc_power_domain(const struct intel_crtc_state *crtc_state);
+struct intel_crtc *intel_dsc_get_bigjoiner_secondary(const struct intel_crtc *primary_crtc);
 
 #endif /* __INTEL_VDSC_H__ */