The DSC encoder of a PCON is enabled through DPCD 3052h[1], together
with an optional PPS override in DPCD 3052h[3:2]. The existing helpers
only ever set these bits.

Add a helper to clear both, so that a driver can switch the encoder off
when the PCON does not need to encode the stream.

Signed-off-by: Ankit Nautiyal <[email protected]>
---
 drivers/gpu/drm/display/drm_dp_helper.c | 23 +++++++++++++++++++++++
 include/drm/display/drm_dp_helper.h     |  1 +
 2 files changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/display/drm_dp_helper.c 
b/drivers/gpu/drm/display/drm_dp_helper.c
index 2b6ce05556b0..e810addf52bc 100644
--- a/drivers/gpu/drm/display/drm_dp_helper.c
+++ b/drivers/gpu/drm/display/drm_dp_helper.c
@@ -4161,6 +4161,29 @@ int drm_dp_pcon_pps_override_param(struct drm_dp_aux 
*aux, u8 pps_param[6])
 }
 EXPORT_SYMBOL(drm_dp_pcon_pps_override_param);
 
+/**
+ * drm_dp_pcon_dsc_enc_disable() - Disable the DSC encoder of a PCON
+ * @aux: DisplayPort AUX channel
+ *
+ * Disable the DSC encoder of a PCON, along with the encoder PPS override.
+ *
+ * Returns 0 on success, else returns negative error code.
+ */
+int drm_dp_pcon_dsc_enc_disable(struct drm_dp_aux *aux)
+{
+       u8 buf;
+       int ret;
+
+       ret = drm_dp_dpcd_read_byte(aux, DP_PROTOCOL_CONVERTER_CONTROL_2, &buf);
+       if (ret < 0)
+               return ret;
+
+       buf &= ~(DP_PCON_ENABLE_DSC_ENCODER | 
DP_PCON_ENCODER_PPS_OVERRIDE_MASK);
+
+       return drm_dp_dpcd_write_byte(aux, DP_PROTOCOL_CONVERTER_CONTROL_2, 
buf);
+}
+EXPORT_SYMBOL(drm_dp_pcon_dsc_enc_disable);
+
 /*
  * drm_dp_pcon_convert_rgb_to_ycbcr() - Configure the PCon to convert RGB to 
Ycbcr
  * @aux: displayPort AUX channel
diff --git a/include/drm/display/drm_dp_helper.h 
b/include/drm/display/drm_dp_helper.h
index f497c9f3a550..32c95f657631 100644
--- a/include/drm/display/drm_dp_helper.h
+++ b/include/drm/display/drm_dp_helper.h
@@ -1019,6 +1019,7 @@ int drm_dp_pcon_dsc_bpp_incr(const u8 
pcon_dsc_dpcd[DP_PCON_DSC_ENCODER_CAP_SIZE
 int drm_dp_pcon_pps_default(struct drm_dp_aux *aux);
 int drm_dp_pcon_pps_override_buf(struct drm_dp_aux *aux, u8 pps_buf[128]);
 int drm_dp_pcon_pps_override_param(struct drm_dp_aux *aux, u8 pps_param[6]);
+int drm_dp_pcon_dsc_enc_disable(struct drm_dp_aux *aux);
 bool drm_dp_downstream_rgb_to_ycbcr_conversion(const u8 
dpcd[DP_RECEIVER_CAP_SIZE],
                                               const u8 port_cap[4], u8 
color_spc);
 int drm_dp_pcon_convert_rgb_to_ycbcr(struct drm_dp_aux *aux, u8 color_spc);
-- 
2.50.1

Reply via email to