diff mbox series

[v3,15/17] drm/amd/display: Add default case for output_color_space switch

Message ID 20230307151107.49649-16-harry.wentland@amd.com (mailing list archive)
State New, archived
Headers show
Series Enable Colorspace connector property in amdgpu | expand

Commit Message

Harry Wentland March 7, 2023, 3:11 p.m. UTC
Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Cc: Pekka Paalanen <ppaalanen@gmail.com>
Cc: Sebastian Wick <sebastian.wick@redhat.com>
Cc: Vitaly.Prosyak@amd.com
Cc: Joshua Ashton <joshua@froggi.es>
Cc: dri-devel@lists.freedesktop.org
Cc: amd-gfx@lists.freedesktop.org
Reviewed-By: Joshua Ashton <joshua@froggi.es>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 43 ++++++++++---------
 1 file changed, 22 insertions(+), 21 deletions(-)

Comments

Pekka Paalanen March 8, 2023, 9:35 a.m. UTC | #1
On Tue, 7 Mar 2023 10:11:05 -0500
Harry Wentland <harry.wentland@amd.com> wrote:

> Signed-off-by: Harry Wentland <harry.wentland@amd.com>
> Cc: Pekka Paalanen <ppaalanen@gmail.com>
> Cc: Sebastian Wick <sebastian.wick@redhat.com>
> Cc: Vitaly.Prosyak@amd.com
> Cc: Joshua Ashton <joshua@froggi.es>
> Cc: dri-devel@lists.freedesktop.org
> Cc: amd-gfx@lists.freedesktop.org
> Reviewed-By: Joshua Ashton <joshua@froggi.es>

Hi,

why?

Isn't the bitmask of supported values supposed to stop arbitrary values
from coming through?

Why handle unsupported values like DEFAULT instead of as a kernel bug?

If this is only to stop compiler warnings of not handling all enum
values in a switch, is the commit ordering in this series even
bisectable?


Thanks,
pq

> ---
>  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 43 ++++++++++---------
>  1 file changed, 22 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 7f77e226f1eb..a15b26962496 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -5308,7 +5308,29 @@ get_output_color_space(const struct dc_crtc_timing *dc_crtc_timing,
>  	enum dc_color_space color_space = COLOR_SPACE_SRGB;
>  
>  	switch (connector_state->colorspace) {
> +	case DRM_MODE_COLORIMETRY_BT601_YCC:
> +		if (dc_crtc_timing->flags.Y_ONLY)
> +			color_space = COLOR_SPACE_YCBCR601_LIMITED;
> +		else
> +			color_space = COLOR_SPACE_YCBCR601;
> +		break;
> +	case DRM_MODE_COLORIMETRY_BT709_YCC:
> +		if (dc_crtc_timing->flags.Y_ONLY)
> +			color_space = COLOR_SPACE_YCBCR709_LIMITED;
> +		else
> +			color_space = COLOR_SPACE_YCBCR709;
> +		break;
> +	case DRM_MODE_COLORIMETRY_OPRGB:
> +		color_space = COLOR_SPACE_ADOBERGB;
> +		break;
> +	case DRM_MODE_COLORIMETRY_BT2020:
> +		color_space = COLOR_SPACE_2020_RGB_FULLRANGE;
> +		break;
> +	case DRM_MODE_COLORIMETRY_BT2020_DEPRECATED:
> +		color_space = COLOR_SPACE_2020_YCBCR;
> +		break;
>  	case DRM_MODE_COLORIMETRY_DEFAULT: // ITU601
> +	default:
>  		if (dc_crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB) {
>  			color_space = COLOR_SPACE_SRGB;
>  		/*
> @@ -5330,27 +5352,6 @@ get_output_color_space(const struct dc_crtc_timing *dc_crtc_timing,
>  				color_space = COLOR_SPACE_YCBCR601;
>  		}
>  		break;
> -	case DRM_MODE_COLORIMETRY_BT601_YCC:
> -		if (dc_crtc_timing->flags.Y_ONLY)
> -			color_space = COLOR_SPACE_YCBCR601_LIMITED;
> -		else
> -			color_space = COLOR_SPACE_YCBCR601;
> -		break;
> -	case DRM_MODE_COLORIMETRY_BT709_YCC:
> -		if (dc_crtc_timing->flags.Y_ONLY)
> -			color_space = COLOR_SPACE_YCBCR709_LIMITED;
> -		else
> -			color_space = COLOR_SPACE_YCBCR709;
> -		break;
> -	case DRM_MODE_COLORIMETRY_OPRGB:
> -		color_space = COLOR_SPACE_ADOBERGB;
> -		break;
> -	case DRM_MODE_COLORIMETRY_BT2020:
> -		color_space = COLOR_SPACE_2020_RGB_FULLRANGE;
> -		break;
> -	case DRM_MODE_COLORIMETRY_BT2020_DEPRECATED:
> -		color_space = COLOR_SPACE_2020_YCBCR;
> -		break;
>  	}
>  
>  	return color_space;
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 7f77e226f1eb..a15b26962496 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -5308,7 +5308,29 @@  get_output_color_space(const struct dc_crtc_timing *dc_crtc_timing,
 	enum dc_color_space color_space = COLOR_SPACE_SRGB;
 
 	switch (connector_state->colorspace) {
+	case DRM_MODE_COLORIMETRY_BT601_YCC:
+		if (dc_crtc_timing->flags.Y_ONLY)
+			color_space = COLOR_SPACE_YCBCR601_LIMITED;
+		else
+			color_space = COLOR_SPACE_YCBCR601;
+		break;
+	case DRM_MODE_COLORIMETRY_BT709_YCC:
+		if (dc_crtc_timing->flags.Y_ONLY)
+			color_space = COLOR_SPACE_YCBCR709_LIMITED;
+		else
+			color_space = COLOR_SPACE_YCBCR709;
+		break;
+	case DRM_MODE_COLORIMETRY_OPRGB:
+		color_space = COLOR_SPACE_ADOBERGB;
+		break;
+	case DRM_MODE_COLORIMETRY_BT2020:
+		color_space = COLOR_SPACE_2020_RGB_FULLRANGE;
+		break;
+	case DRM_MODE_COLORIMETRY_BT2020_DEPRECATED:
+		color_space = COLOR_SPACE_2020_YCBCR;
+		break;
 	case DRM_MODE_COLORIMETRY_DEFAULT: // ITU601
+	default:
 		if (dc_crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB) {
 			color_space = COLOR_SPACE_SRGB;
 		/*
@@ -5330,27 +5352,6 @@  get_output_color_space(const struct dc_crtc_timing *dc_crtc_timing,
 				color_space = COLOR_SPACE_YCBCR601;
 		}
 		break;
-	case DRM_MODE_COLORIMETRY_BT601_YCC:
-		if (dc_crtc_timing->flags.Y_ONLY)
-			color_space = COLOR_SPACE_YCBCR601_LIMITED;
-		else
-			color_space = COLOR_SPACE_YCBCR601;
-		break;
-	case DRM_MODE_COLORIMETRY_BT709_YCC:
-		if (dc_crtc_timing->flags.Y_ONLY)
-			color_space = COLOR_SPACE_YCBCR709_LIMITED;
-		else
-			color_space = COLOR_SPACE_YCBCR709;
-		break;
-	case DRM_MODE_COLORIMETRY_OPRGB:
-		color_space = COLOR_SPACE_ADOBERGB;
-		break;
-	case DRM_MODE_COLORIMETRY_BT2020:
-		color_space = COLOR_SPACE_2020_RGB_FULLRANGE;
-		break;
-	case DRM_MODE_COLORIMETRY_BT2020_DEPRECATED:
-		color_space = COLOR_SPACE_2020_YCBCR;
-		break;
 	}
 
 	return color_space;