diff mbox series

[20/20] drm/i915/dp: Check if force_dsc_output_format is possible

Message ID 20230728041150.2524032-21-ankit.k.nautiyal@intel.com (mailing list archive)
State New, archived
Headers show
Series DSC misc fixes | expand

Commit Message

Nautiyal, Ankit K July 28, 2023, 4:11 a.m. UTC
Currently for testing an output format with DSC, we just force the
output format, without checking if it can be supported.
This also creates an issue where there is a PCON which might need to
convert from forced output format to the format to sink format.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
---
 drivers/gpu/drm/i915/display/intel_dp.c | 30 +++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

Comments

Stanislav Lisovskiy Aug. 7, 2023, 12:25 p.m. UTC | #1
On Fri, Jul 28, 2023 at 09:41:50AM +0530, Ankit Nautiyal wrote:
> Currently for testing an output format with DSC, we just force the
> output format, without checking if it can be supported.
> This also creates an issue where there is a PCON which might need to
> convert from forced output format to the format to sink format.
> 
> Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>

Reviewed-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>

> ---
>  drivers/gpu/drm/i915/display/intel_dp.c | 30 +++++++++++++++++++++++--
>  1 file changed, 28 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> index 0299b378ba6e..1aee27c0fb55 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -935,16 +935,42 @@ dfp_can_convert_from_ycbcr444(struct intel_dp *intel_dp,
>  	return false;
>  }
>  
> +static bool
> +dfp_can_convert(struct intel_dp *intel_dp,
> +		enum intel_output_format output_format,
> +		enum intel_output_format sink_format)
> +{
> +	switch (output_format) {
> +	case INTEL_OUTPUT_FORMAT_RGB:
> +		return dfp_can_convert_from_rgb(intel_dp, sink_format);
> +	case INTEL_OUTPUT_FORMAT_YCBCR444:
> +		return dfp_can_convert_from_ycbcr444(intel_dp, sink_format);
> +	default:
> +		MISSING_CASE(output_format);
> +		return false;
> +	}
> +
> +	return false;
> +}
> +
>  static enum intel_output_format
>  intel_dp_output_format(struct intel_connector *connector,
>  		       enum intel_output_format sink_format)
>  {
>  	struct intel_dp *intel_dp = intel_attached_dp(connector);
>  	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
> +	enum intel_output_format force_dsc_output_format =
> +		intel_dp->force_dsc_output_format;
>  	enum intel_output_format output_format;
> +	if (force_dsc_output_format) {
> +		if (source_can_output(intel_dp, force_dsc_output_format) &&
> +		    (!drm_dp_is_branch(intel_dp->dpcd) ||
> +		     sink_format != force_dsc_output_format ||
> +		     dfp_can_convert(intel_dp, force_dsc_output_format, sink_format)))
> +			return force_dsc_output_format;
>  
> -	if (intel_dp->force_dsc_output_format)
> -		return intel_dp->force_dsc_output_format;
> +		drm_dbg_kms(&i915->drm, "Cannot force DSC output format\n");
> +	}
>  
>  	if (sink_format == INTEL_OUTPUT_FORMAT_RGB ||
>  	    dfp_can_convert_from_rgb(intel_dp, sink_format))
> -- 
> 2.40.1
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 0299b378ba6e..1aee27c0fb55 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -935,16 +935,42 @@  dfp_can_convert_from_ycbcr444(struct intel_dp *intel_dp,
 	return false;
 }
 
+static bool
+dfp_can_convert(struct intel_dp *intel_dp,
+		enum intel_output_format output_format,
+		enum intel_output_format sink_format)
+{
+	switch (output_format) {
+	case INTEL_OUTPUT_FORMAT_RGB:
+		return dfp_can_convert_from_rgb(intel_dp, sink_format);
+	case INTEL_OUTPUT_FORMAT_YCBCR444:
+		return dfp_can_convert_from_ycbcr444(intel_dp, sink_format);
+	default:
+		MISSING_CASE(output_format);
+		return false;
+	}
+
+	return false;
+}
+
 static enum intel_output_format
 intel_dp_output_format(struct intel_connector *connector,
 		       enum intel_output_format sink_format)
 {
 	struct intel_dp *intel_dp = intel_attached_dp(connector);
 	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
+	enum intel_output_format force_dsc_output_format =
+		intel_dp->force_dsc_output_format;
 	enum intel_output_format output_format;
+	if (force_dsc_output_format) {
+		if (source_can_output(intel_dp, force_dsc_output_format) &&
+		    (!drm_dp_is_branch(intel_dp->dpcd) ||
+		     sink_format != force_dsc_output_format ||
+		     dfp_can_convert(intel_dp, force_dsc_output_format, sink_format)))
+			return force_dsc_output_format;
 
-	if (intel_dp->force_dsc_output_format)
-		return intel_dp->force_dsc_output_format;
+		drm_dbg_kms(&i915->drm, "Cannot force DSC output format\n");
+	}
 
 	if (sink_format == INTEL_OUTPUT_FORMAT_RGB ||
 	    dfp_can_convert_from_rgb(intel_dp, sink_format))