Currently the bpc for the HDMI link is picked only from the bpcs that fit
the FRL link uncompressed. No bpc is found for a mode that needs DSC on
the HDMI link, even though an HDMI 2.1 PCON can decode the DP stream and
encode DSC 1.2 for the HDMI sink.

If the DP stream is compressed and no bpc fits the HDMI link
uncompressed, pick the highest bpc the PCON can encode for the HDMI
link. The PCON can't encode an uncompressed stream, so this is done only
in the pass that compresses the DP stream, after the uncompressed bpcs
are tried.

The mode valid check still prunes such modes. The next change lets them
through.

Signed-off-by: Ankit Nautiyal <[email protected]>
---
 drivers/gpu/drm/i915/display/intel_dp.c | 43 ++++++++++++++++++++++---
 1 file changed, 39 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c 
b/drivers/gpu/drm/i915/display/intel_dp.c
index f2505b707cad..94744ead1a6e 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -1302,6 +1302,20 @@ intel_dp_pcon_dsc_enc_compute(struct intel_dp *intel_dp,
        return true;
 }
 
+/*
+ * Whether the PCON can compress a stream that doesn't fit the HDMI FRL link
+ * uncompressed. The DP stream has to be compressed for that as well.
+ */
+static bool
+intel_dp_hdmi_dsc_possible(struct intel_dp *intel_dp,
+                          const struct drm_display_mode *mode, int pixel_clock,
+                          int bpc, enum intel_output_format sink_format)
+{
+       return intel_dp_pcon_sink_support_frl(intel_dp) &&
+               intel_dp_pcon_dsc_enc_compute(intel_dp, mode, pixel_clock, bpc,
+                                             sink_format, NULL);
+}
+
 static enum drm_mode_status
 intel_dp_hdmi_bw_valid(struct intel_dp *intel_dp,
                       int target_clock, int bpc,
@@ -1835,9 +1849,11 @@ bool intel_dp_supports_dsc(struct intel_dp *intel_dp,
 
 static int intel_dp_hdmi_compute_bpc(struct intel_dp *intel_dp,
                                     const struct intel_crtc_state *crtc_state,
-                                    int bpc, bool respect_downstream_limits)
+                                    int bpc, bool respect_downstream_limits,
+                                    bool dsc)
 {
        int clock = crtc_state->hw.adjusted_mode.crtc_clock;
+       int max_bpc;
 
        /*
         * Current bpc could already be below 8bpc due to
@@ -1854,6 +1870,8 @@ static int intel_dp_hdmi_compute_bpc(struct intel_dp 
*intel_dp,
        if (!respect_downstream_limits)
                bpc = 8;
 
+       max_bpc = bpc;
+
        for (; bpc >= 8; bpc -= 2) {
                if (intel_hdmi_bpc_possible(crtc_state, bpc,
                                            intel_dp_has_hdmi_sink(intel_dp)) &&
@@ -1862,12 +1880,27 @@ static int intel_dp_hdmi_compute_bpc(struct intel_dp 
*intel_dp,
                        return bpc;
        }
 
+       /*
+        * No bpc fits the HDMI link uncompressed. If the DP stream is 
compressed
+        * the PCON may be able to compress the stream for the HDMI link as 
well.
+        */
+       if (!dsc || !respect_downstream_limits)
+               return -EINVAL;
+
+       for (bpc = max_bpc; bpc >= 8; bpc -= 2) {
+               if (intel_hdmi_bpc_possible(crtc_state, bpc,
+                                           intel_dp_has_hdmi_sink(intel_dp)) &&
+                   intel_dp_hdmi_dsc_possible(intel_dp, 
&crtc_state->hw.adjusted_mode,
+                                              clock, bpc, 
crtc_state->sink_format))
+                       return bpc;
+       }
+
        return -EINVAL;
 }
 
 static int intel_dp_max_bpp(struct intel_dp *intel_dp,
                            const struct intel_crtc_state *crtc_state,
-                           bool respect_downstream_limits)
+                           bool respect_downstream_limits, bool dsc)
 {
        struct intel_display *display = to_intel_display(intel_dp);
        struct intel_connector *connector = intel_dp->attached_connector;
@@ -1882,7 +1915,8 @@ static int intel_dp_max_bpp(struct intel_dp *intel_dp,
                int max_hdmi_bpc;
 
                max_hdmi_bpc = intel_dp_hdmi_compute_bpc(intel_dp, crtc_state, 
bpc,
-                                                        
respect_downstream_limits);
+                                                        
respect_downstream_limits,
+                                                        dsc);
                if (max_hdmi_bpc < 0)
                        return 0;
 
@@ -2964,7 +2998,8 @@ intel_dp_compute_config_limits(struct intel_dp *intel_dp,
                limits->pipe.max_bpp = min(crtc_state->max_pipe_bpp, 24);
        } else {
                limits->pipe.max_bpp = intel_dp_max_bpp(intel_dp, crtc_state,
-                                                       
respect_downstream_limits);
+                                                       
respect_downstream_limits,
+                                                       dsc);
        }
 
        if (!dsc && intel_dp_in_hdr_mode(conn_state)) {
-- 
2.50.1

Reply via email to