Skip to content

Commit a193477

Browse files
jnikularodrigovivi
authored andcommitted
drm/i915/dsc: abstract helpers to get bigjoiner primary/secondary crtc
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: 8a029c1 ("drm/i915/dp: Modify VDSC helpers to configure DSC for Bigjoiner slave") Fixes: d961eb2 ("drm/i915/bigjoiner: atomic commit changes for uncompressed joiner") Cc: Animesh Manna <[email protected]> Cc: Manasi Navare <[email protected]> Cc: Vandita Kulkarni <[email protected]> Reviewed-by: Manasi Navare <[email protected]> Signed-off-by: Jani Nikula <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 1720322) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent 2328e1b commit a193477

File tree

4 files changed

+40
-16
lines changed

4 files changed

+40
-16
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9618,7 +9618,6 @@ static int intel_atomic_check_bigjoiner(struct intel_atomic_state *state,
96189618
struct intel_crtc_state *old_crtc_state,
96199619
struct intel_crtc_state *new_crtc_state)
96209620
{
9621-
struct drm_i915_private *dev_priv = to_i915(state->base.dev);
96229621
struct intel_crtc_state *slave_crtc_state, *master_crtc_state;
96239622
struct intel_crtc *slave, *master;
96249623

@@ -9634,15 +9633,15 @@ static int intel_atomic_check_bigjoiner(struct intel_atomic_state *state,
96349633
if (!new_crtc_state->bigjoiner)
96359634
return 0;
96369635

9637-
if (1 + crtc->pipe >= INTEL_NUM_PIPES(dev_priv)) {
9636+
slave = intel_dsc_get_bigjoiner_secondary(crtc);
9637+
if (!slave) {
96389638
DRM_DEBUG_KMS("[CRTC:%d:%s] Big joiner configuration requires "
96399639
"CRTC + 1 to be used, doesn't exist\n",
96409640
crtc->base.base.id, crtc->base.name);
96419641
return -EINVAL;
96429642
}
96439643

9644-
slave = new_crtc_state->bigjoiner_linked_crtc =
9645-
intel_get_crtc_for_pipe(dev_priv, crtc->pipe + 1);
9644+
new_crtc_state->bigjoiner_linked_crtc = slave;
96469645
slave_crtc_state = intel_atomic_get_crtc_state(&state->base, slave);
96479646
master = crtc;
96489647
if (IS_ERR(slave_crtc_state))

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,14 @@ vlv_pipe_to_channel(enum pipe pipe)
17231723
}
17241724
}
17251725

1726+
static inline bool intel_pipe_valid(struct drm_i915_private *i915, enum pipe pipe)
1727+
{
1728+
return (pipe >= 0 &&
1729+
pipe < ARRAY_SIZE(i915->pipe_to_crtc_mapping) &&
1730+
INTEL_INFO(i915)->pipe_mask & BIT(pipe) &&
1731+
i915->pipe_to_crtc_mapping[pipe]);
1732+
}
1733+
17261734
static inline struct intel_crtc *
17271735
intel_get_first_crtc(struct drm_i915_private *dev_priv)
17281736
{

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

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,27 @@ static i915_reg_t dss_ctl2_reg(const struct intel_crtc_state *crtc_state)
11061106
return is_pipe_dsc(crtc_state) ? ICL_PIPE_DSS_CTL2(pipe) : DSS_CTL2;
11071107
}
11081108

1109+
static struct intel_crtc *
1110+
_get_crtc_for_pipe(struct drm_i915_private *i915, enum pipe pipe)
1111+
{
1112+
if (!intel_pipe_valid(i915, pipe))
1113+
return NULL;
1114+
1115+
return intel_get_crtc_for_pipe(i915, pipe);
1116+
}
1117+
1118+
struct intel_crtc *
1119+
intel_dsc_get_bigjoiner_secondary(const struct intel_crtc *primary_crtc)
1120+
{
1121+
return _get_crtc_for_pipe(to_i915(primary_crtc->base.dev), primary_crtc->pipe + 1);
1122+
}
1123+
1124+
static struct intel_crtc *
1125+
intel_dsc_get_bigjoiner_primary(const struct intel_crtc *secondary_crtc)
1126+
{
1127+
return _get_crtc_for_pipe(to_i915(secondary_crtc->base.dev), secondary_crtc->pipe - 1);
1128+
}
1129+
11091130
void intel_uncompressed_joiner_enable(const struct intel_crtc_state *crtc_state)
11101131
{
11111132
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)
11781199
dss_ctl1 = intel_de_read(dev_priv, dss_ctl1_reg(crtc_state));
11791200
if (dss_ctl1 & UNCOMPRESSED_JOINER_MASTER) {
11801201
crtc_state->bigjoiner = true;
1181-
if (!WARN_ON(INTEL_NUM_PIPES(dev_priv) == crtc->pipe + 1))
1182-
crtc_state->bigjoiner_linked_crtc =
1183-
intel_get_crtc_for_pipe(dev_priv, crtc->pipe + 1);
1202+
crtc_state->bigjoiner_linked_crtc = intel_dsc_get_bigjoiner_secondary(crtc);
1203+
drm_WARN_ON(&dev_priv->drm, !crtc_state->bigjoiner_linked_crtc);
11841204
} else if (dss_ctl1 & UNCOMPRESSED_JOINER_SLAVE) {
11851205
crtc_state->bigjoiner = true;
11861206
crtc_state->bigjoiner_slave = true;
1187-
if (!WARN_ON(crtc->pipe == PIPE_A))
1188-
crtc_state->bigjoiner_linked_crtc =
1189-
intel_get_crtc_for_pipe(dev_priv, crtc->pipe - 1);
1207+
crtc_state->bigjoiner_linked_crtc = intel_dsc_get_bigjoiner_primary(crtc);
1208+
drm_WARN_ON(&dev_priv->drm, !crtc_state->bigjoiner_linked_crtc);
11901209
}
11911210
}
11921211

@@ -1224,14 +1243,11 @@ void intel_dsc_get_config(struct intel_crtc_state *crtc_state)
12241243

12251244
if (!(dss_ctl1 & MASTER_BIG_JOINER_ENABLE)) {
12261245
crtc_state->bigjoiner_slave = true;
1227-
if (!WARN_ON(crtc->pipe == PIPE_A))
1228-
crtc_state->bigjoiner_linked_crtc =
1229-
intel_get_crtc_for_pipe(dev_priv, crtc->pipe - 1);
1246+
crtc_state->bigjoiner_linked_crtc = intel_dsc_get_bigjoiner_primary(crtc);
12301247
} else {
1231-
if (!WARN_ON(INTEL_NUM_PIPES(dev_priv) == crtc->pipe + 1))
1232-
crtc_state->bigjoiner_linked_crtc =
1233-
intel_get_crtc_for_pipe(dev_priv, crtc->pipe + 1);
1248+
crtc_state->bigjoiner_linked_crtc = intel_dsc_get_bigjoiner_secondary(crtc);
12341249
}
1250+
drm_WARN_ON(&dev_priv->drm, !crtc_state->bigjoiner_linked_crtc);
12351251
}
12361252

12371253
/* FIXME: add more state readout as needed */

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ void intel_uncompressed_joiner_get_config(struct intel_crtc_state *crtc_state);
2222
void intel_dsc_get_config(struct intel_crtc_state *crtc_state);
2323
enum intel_display_power_domain
2424
intel_dsc_power_domain(const struct intel_crtc_state *crtc_state);
25+
struct intel_crtc *intel_dsc_get_bigjoiner_secondary(const struct intel_crtc *primary_crtc);
2526

2627
#endif /* __INTEL_VDSC_H__ */

0 commit comments

Comments
 (0)