Skip to contentSkip to conversation

drm/i915/GLK: Properly handle plane CSC for BT2020 framebuffers

PATCH New Shashank Sharma 3 participants 10 messages May 7, 2019 – May 9, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 drm/i915/GLK: Properly handle plane CSC for BT2020 framebuffers

Framebuffer formats P01x are supported by GLK, but the function which handles CSC on plane color control register, still expectes the input buffer to be REC709. This can cause inaccurate output for direct P01x flips.

This patch checks if the color_encoding property is set to YCBCR_2020, and enables the corresponding color conversion mode on plane CSC.

PS: renamed variable plane_color_ctl to color_ctl for 80 char stuff.

V2: Expose the YCBCR_BT2020 value in enum values of supported encoding
formats.
V3: Fixed the missing BIT() while setting supported_encodings
(Lukas, team Kodi)

Cc Ville Syrjala <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Uma Shankar <[email protected]>
---
 drivers/gpu/drm/i915/intel_display.c | 26 ++++++++++++++++----------
 drivers/gpu/drm/i915/intel_sprite.c  | 10 ++++++++--
 2 files changed, 24 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/intel_display.c +16 -10
index dd65d7c521c1..2d4d3128bf1f 100644
@@ -3868,24 +3868,30 @@ u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state,
 		to_i915(plane_state->base.plane->dev);
 	const struct drm_framebuffer *fb = plane_state->base.fb;
 	struct intel_plane *plane = to_intel_plane(plane_state->base.plane);
-	u32 plane_color_ctl = 0;
+	u32 color_ctl = 0;
 
-	plane_color_ctl |= PLANE_COLOR_PLANE_GAMMA_DISABLE;
-	plane_color_ctl |= glk_plane_color_ctl_alpha(plane_state);
+	color_ctl |= PLANE_COLOR_PLANE_GAMMA_DISABLE;
+	color_ctl |= glk_plane_color_ctl_alpha(plane_state);
 
 	if (fb->format->is_yuv && !icl_is_hdr_plane(dev_priv, plane->id)) {
-		if (plane_state->base.color_encoding == DRM_COLOR_YCBCR_BT709)
-			plane_color_ctl |= PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709;
-		else
-			plane_color_ctl |= PLANE_COLOR_CSC_MODE_YUV601_TO_RGB709;
+		switch (plane_state->base.color_encoding) {
+		case DRM_COLOR_YCBCR_BT709:
+			color_ctl |= PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709;
+			break;
+		case DRM_COLOR_YCBCR_BT2020:
+			color_ctl |= PLANE_COLOR_CSC_MODE_YUV2020_TO_RGB2020;
+			break;
+		default:
+			color_ctl |= PLANE_COLOR_CSC_MODE_YUV601_TO_RGB709;
+		}
 
 		if (plane_state->base.color_range == DRM_COLOR_YCBCR_FULL_RANGE)
-			plane_color_ctl |= PLANE_COLOR_YUV_RANGE_CORRECTION_DISABLE;
+			color_ctl |= PLANE_COLOR_YUV_RANGE_CORRECTION_DISABLE;
 	} else if (fb->format->is_yuv) {
-		plane_color_ctl |= PLANE_COLOR_INPUT_CSC_ENABLE;
+		color_ctl |= PLANE_COLOR_INPUT_CSC_ENABLE;
 	}
 
-	return plane_color_ctl;
+	return color_ctl;
 }
 
 static int
drivers/gpu/drm/i915/intel_sprite.c +8 -2
index 2913e89280d7..44aaeac1b2ed 100644
@@ -2238,6 +2238,7 @@ skl_universal_plane_create(struct drm_i915_private *dev_priv,
 	struct intel_plane *plane;
 	enum drm_plane_type plane_type;
 	unsigned int supported_rotations;
+	unsigned int supported_encodings;
 	unsigned int possible_crtcs;
 	const u64 *modifiers;
 	const u32 *formats;
@@ -2325,9 +2326,14 @@ skl_universal_plane_create(struct drm_i915_private *dev_priv,
 					   DRM_MODE_ROTATE_0,
 					   supported_rotations);
 
+	supported_encodings = BIT(DRM_COLOR_YCBCR_BT601) |
+			      BIT(DRM_COLOR_YCBCR_BT709);
+
+	if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv))
+		supported_encodings |= BIT(DRM_COLOR_YCBCR_BT2020);
+
 	drm_plane_create_color_properties(&plane->base,
-					  BIT(DRM_COLOR_YCBCR_BT601) |
-					  BIT(DRM_COLOR_YCBCR_BT709),
+					  supported_encodings,
 					  BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
 					  BIT(DRM_COLOR_YCBCR_FULL_RANGE),
 					  DRM_COLOR_YCBCR_BT709,
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 1/1 drm/i915/icl: Handle YCbCr to RGB conversion for BT2020 case

From: Uma Shankar <[email protected]>

Currently input csc for YCbCR to RGB conversion handles only BT601 and Bt709. Extending it to support BT2020 as well.

---
 drivers/gpu/drm/i915/intel_sprite.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/gpu/drm/i915/intel_sprite.c +24 -0
index 44aaeac1b2ed..2536e757bec2 100644
@@ -433,6 +433,18 @@ icl_program_input_csc(struct intel_plane *plane,
 			0x9EF8, 0x7800, 0xABF8,
 			0x0, 0x7800,  0x7ED8,
 		},
+		/*
+		 * BT.2020 full range YCbCr -> full range RGB
+		 * The matrix required is :
+		 * [1.000, 0.000, 1.474,
+		 *  1.000, -0.1645, -0.5713,
+		 *  1.000, 1.8814, 0.0000]
+		 */
+		[DRM_COLOR_YCBCR_BT2020] = {
+			0x7BC8, 0x7800, 0x0,
+			0x8928, 0x7800, 0xAA88,
+			0x0, 0x7800, 0x7F10,
+		},
 	};
 
 	/* Matrix for Limited Range to Full Range Conversion */
@@ -461,6 +473,18 @@ icl_program_input_csc(struct intel_plane *plane,
 			0x8888, 0x7918, 0xADA8,
 			0x0, 0x7918,  0x6870,
 		},
+		/*
+		 * BT.2020 Limited range YCbCr -> full range RGB
+		 * The matrix required is :
+		 * [1.164, 0.000, 1.717,
+		 *  1.138, -0.1873, -0.6504,
+		 *  1.1380, 2.1417, 0.0000]
+		 */
+		[DRM_COLOR_YCBCR_BT2020] = {
+			0x7DC0, 0x7950, 0x0,
+			0x8A68, 0x7918, 0xAC00,
+			0x0, 0x7918, 0x6890,
+		},
 	};
 	const u16 *csc;
 
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

Re: [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for BT2020 case

Quoted 35 lines · Shashank Sharma

From: Uma Shankar <[email protected]>

Currently input csc for YCbCR to RGB conversion handles only BT601 and Bt709. Extending it to support BT2020 as well.

---
 drivers/gpu/drm/i915/intel_sprite.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/gpu/drm/i915/intel_sprite.c +12 -0
index 44aaeac1b2ed..2536e757bec2 100644
@@ -433,6 +433,18 @@ icl_program_input_csc(struct intel_plane *plane,
 			0x9EF8, 0x7800, 0xABF8,
 			0x0, 0x7800,  0x7ED8,
 		},
+		/*
+		 * BT.2020 full range YCbCr -> full range RGB
+		 * The matrix required is :
+		 * [1.000, 0.000, 1.474,
+		 *  1.000, -0.1645, -0.5713,
+		 *  1.000, 1.8814, 0.0000]
+		 */
+		[DRM_COLOR_YCBCR_BT2020] = {
+			0x7BC8, 0x7800, 0x0,
+			0x8928, 0x7800, 0xAA88,
+			0x0, 0x7800, 0x7F10,
+		},
 	};
 
 	/* Matrix for Limited Range to Full Range Conversion */

drivers/gpu/drm/i915/intel_sprite.c icl_program_input_csc(struct intel_plane *plane, · line 481

Quoted 9 lines
drivers/gpu/drm/i915/intel_sprite.c +6 -0
@@ -461,6 +473,18 @@ icl_program_input_csc(struct intel_plane *plane,
 			0x8888, 0x7918, 0xADA8,
 			0x0, 0x7918,  0x6870,
 		},
+		/*
+		 * BT.2020 Limited range YCbCr -> full range RGB
+		 * The matrix required is :
+		 * [1.164, 0.000, 1.717,
+		 *  1.138, -0.1873, -0.6504,
+		 *  1.1380, 2.1417, 0.0000]

Where are those 1.138 coming from?

Quoted 16 lines
drivers/gpu/drm/i915/intel_sprite.c +6 -0
+		 */
+		[DRM_COLOR_YCBCR_BT2020] = {
+			0x7DC0, 0x7950, 0x0,
+			0x8A68, 0x7918, 0xAC00,
+			0x0, 0x7918, 0x6890,
+		},
 	};
 	const u16 *csc;
 
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

Re: [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for BT2020 case

Quoted 46 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Ville Syrjälä
Sent: Tuesday, May 7, 2019 7:37 PM
To: Sharma, Shashank <[email protected]>
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for BT2020 case

Quoted 34 lines · Shashank Sharma

From: Uma Shankar <[email protected]>

Currently input csc for YCbCR to RGB conversion handles only BT601 and Bt709. Extending it to support BT2020 as well.

---
 drivers/gpu/drm/i915/intel_sprite.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/gpu/drm/i915/intel_sprite.c +12 -0
index 44aaeac1b2ed..2536e757bec2 100644
@@ -433,6 +433,18 @@ icl_program_input_csc(struct intel_plane *plane,
 			0x9EF8, 0x7800, 0xABF8,
 			0x0, 0x7800,  0x7ED8,
 		},
+		/*
+		 * BT.2020 full range YCbCr -> full range RGB
+		 * The matrix required is :
+		 * [1.000, 0.000, 1.474,
+		 *  1.000, -0.1645, -0.5713,
+		 *  1.000, 1.8814, 0.0000]
+		 */
+		[DRM_COLOR_YCBCR_BT2020] = {
+			0x7BC8, 0x7800, 0x0,
+			0x8928, 0x7800, 0xAA88,
+			0x0, 0x7800, 0x7F10,
+		},
 	};
 
Quoted 13 lines

drivers/gpu/drm/i915/intel_sprite.c icl_program_input_csc(struct intel_plane *plane, · line 481

Quoted 11 lines
drivers/gpu/drm/i915/intel_sprite.c +7 -0
 	/* Matrix for Limited Range to Full Range Conversion */ @@ -461,6
+473,18 @@ icl_program_input_csc(struct intel_plane *plane,
 			0x8888, 0x7918, 0xADA8,
 			0x0, 0x7918,  0x6870,
 		},
+		/*
+		 * BT.2020 Limited range YCbCr -> full range RGB
+		 * The matrix required is :
+		 * [1.164, 0.000, 1.717,
+		 *  1.138, -0.1873, -0.6504,
+		 *  1.1380, 2.1417, 0.0000]

Where are those 1.138 coming from?

Hi Ville,
This is the original YCBCR to RGB BT2020 matrix:

{
        1.00000000000,  0.00000000000,  1.47460000000,
        1.00000000000,  -0.16455312684, -0.57135312684,
        1.00000000000,  1.88140000000,  0.00000000000
};

We have to convert Limited Range YCbCr to Full Range RGB. Hence we need to apply a scale factor:
yscalefactor = 219.0 * normalizingfactor;
cbcrscalefactor = 224.0 * normalizingfactor;

/* Scale factors are inverted for LR to FR conversion */ yscalefactor = 1.0 / yscalefactor; cbcrscalefactor = 1.0 / cbcrscalefactor;

This yields the above results.

Regards,
Uma Shankar

Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/i915/intel_sprite.c +6 -1
+		 */
+		[DRM_COLOR_YCBCR_BT2020] = {
+			0x7DC0, 0x7950, 0x0,
+			0x8A68, 0x7918, 0xAC00,
+			0x0, 0x7918, 0x6890,
+		},
 	};
 	const u16 *csc;
 
--

2.17.1

Quoted 12 lines
Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

Re: [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for BT2020 case

Quoted 72 lines · Uma
Quoted 46 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Ville Syrjälä
Sent: Tuesday, May 7, 2019 7:37 PM
To: Sharma, Shashank <[email protected]>
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for BT2020 case

Quoted 34 lines · Shashank Sharma

From: Uma Shankar <[email protected]>

Currently input csc for YCbCR to RGB conversion handles only BT601 and Bt709. Extending it to support BT2020 as well.

---
 drivers/gpu/drm/i915/intel_sprite.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/gpu/drm/i915/intel_sprite.c +12 -0
index 44aaeac1b2ed..2536e757bec2 100644
@@ -433,6 +433,18 @@ icl_program_input_csc(struct intel_plane *plane,
 			0x9EF8, 0x7800, 0xABF8,
 			0x0, 0x7800,  0x7ED8,
 		},
+		/*
+		 * BT.2020 full range YCbCr -> full range RGB
+		 * The matrix required is :
+		 * [1.000, 0.000, 1.474,
+		 *  1.000, -0.1645, -0.5713,
+		 *  1.000, 1.8814, 0.0000]
+		 */
+		[DRM_COLOR_YCBCR_BT2020] = {
+			0x7BC8, 0x7800, 0x0,
+			0x8928, 0x7800, 0xAA88,
+			0x0, 0x7800, 0x7F10,
+		},
 	};
 
Quoted 13 lines

drivers/gpu/drm/i915/intel_sprite.c icl_program_input_csc(struct intel_plane *plane, · line 481

Quoted 11 lines
drivers/gpu/drm/i915/intel_sprite.c +7 -0
 	/* Matrix for Limited Range to Full Range Conversion */ @@ -461,6
+473,18 @@ icl_program_input_csc(struct intel_plane *plane,
 			0x8888, 0x7918, 0xADA8,
 			0x0, 0x7918,  0x6870,
 		},
+		/*
+		 * BT.2020 Limited range YCbCr -> full range RGB
+		 * The matrix required is :
+		 * [1.164, 0.000, 1.717,
+		 *  1.138, -0.1873, -0.6504,
+		 *  1.1380, 2.1417, 0.0000]

Where are those 1.138 coming from?

Hi Ville,
This is the original YCBCR to RGB BT2020 matrix:

{
        1.00000000000,  0.00000000000,  1.47460000000,
        1.00000000000,  -0.16455312684, -0.57135312684,
        1.00000000000,  1.88140000000,  0.00000000000
};

We have to convert Limited Range YCbCr to Full Range RGB. Hence we need to apply a scale factor:
yscalefactor = 219.0 * normalizingfactor;
cbcrscalefactor = 224.0 * normalizingfactor;

Quoted 5 lines

/* Scale factors are inverted for LR to FR conversion */ yscalefactor = 1.0 / yscalefactor; cbcrscalefactor = 1.0 / cbcrscalefactor;

This yields the above results.

Those are the coefficients for Y, so they should still be the same for all three output channels.

igt_color_encoding gives me:

|1.1644, 0.0000, 1.6787,|
|1.1644,-0.1873,-0.6504,|
|1.1644, 2.1418, 0.0000,|

Looks like we're also misprogramming the Y pre-offset for the full range YCbCr case.

Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

Re: [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for BT2020 case

Quoted 91 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, May 7, 2019 9:08 PM
To: Shankar, Uma <[email protected]>
Cc: Sharma, Shashank <[email protected]>; intel- [email protected]
Subject: Re: [Intel-gfx] [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for BT2020 case

Quoted 61 lines · Uma
Quoted 47 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Ville Syrjälä
Sent: Tuesday, May 7, 2019 7:37 PM
To: Sharma, Shashank <[email protected]>
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for
BT2020 case

Quoted 34 lines · Shashank Sharma

From: Uma Shankar <[email protected]>

Currently input csc for YCbCR to RGB conversion handles only BT601 and Bt709. Extending it to support BT2020 as well.

---
 drivers/gpu/drm/i915/intel_sprite.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/gpu/drm/i915/intel_sprite.c +12 -0
index 44aaeac1b2ed..2536e757bec2 100644
@@ -433,6 +433,18 @@ icl_program_input_csc(struct intel_plane *plane,
 			0x9EF8, 0x7800, 0xABF8,
 			0x0, 0x7800,  0x7ED8,
 		},
+		/*
+		 * BT.2020 full range YCbCr -> full range RGB
+		 * The matrix required is :
+		 * [1.000, 0.000, 1.474,
+		 *  1.000, -0.1645, -0.5713,
+		 *  1.000, 1.8814, 0.0000]
+		 */
+		[DRM_COLOR_YCBCR_BT2020] = {
+			0x7BC8, 0x7800, 0x0,
+			0x8928, 0x7800, 0xAA88,
+			0x0, 0x7800, 0x7F10,
+		},
 	};
 
Quoted 13 lines

drivers/gpu/drm/i915/intel_sprite.c icl_program_input_csc(struct intel_plane *plane, · line 481

Quoted 11 lines
drivers/gpu/drm/i915/intel_sprite.c +7 -0
 	/* Matrix for Limited Range to Full Range Conversion */ @@ -461,6
+473,18 @@ icl_program_input_csc(struct intel_plane *plane,
 			0x8888, 0x7918, 0xADA8,
 			0x0, 0x7918,  0x6870,
 		},
+		/*
+		 * BT.2020 Limited range YCbCr -> full range RGB
+		 * The matrix required is :
+		 * [1.164, 0.000, 1.717,
+		 *  1.138, -0.1873, -0.6504,
+		 *  1.1380, 2.1417, 0.0000]

Where are those 1.138 coming from?

Quoted 8 lines

Hi Ville,
This is the original YCBCR to RGB BT2020 matrix:

{
        1.00000000000,  0.00000000000,  1.47460000000,
        1.00000000000,  -0.16455312684, -0.57135312684,
        1.00000000000,  1.88140000000,  0.00000000000 };

We have to convert Limited Range YCbCr to Full Range RGB. Hence we need to

apply a scale factor:

Quoted 8 lines

yscalefactor = 219.0 * normalizingfactor; cbcrscalefactor = 224.0 *
normalizingfactor;

/* Scale factors are inverted for LR to FR conversion */
yscalefactor = 1.0 / yscalefactor; cbcrscalefactor = 1.0 / cbcrscalefactor;

This yields the above results.

Quoted 7 lines

Those are the coefficients for Y, so they should still be the same for all three output channels.

igt_color_encoding gives me:

|1.1644, 0.0000, 1.6787,|
|1.1644,-0.1873,-0.6504,|
|1.1644, 2.1418, 0.0000,|

Ok, I used the igt_color_encoding method and able to get values what you got. Will update the matrix. Thanks Ville.

Quoted 1 line

Looks like we're also misprogramming the Y pre-offset for the full range YCbCr case.

For full range, I am getting same values as programmed above. Looks ok, can you double check.

Regards,
Uma Shankar

Quoted 3 lines

--
Ville Syrjälä
Intel

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#6 lore raw

Re: [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for BT2020 case

Quoted 99 lines · Uma
Quoted 91 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, May 7, 2019 9:08 PM
To: Shankar, Uma <[email protected]>
Cc: Sharma, Shashank <[email protected]>; intel- [email protected]
Subject: Re: [Intel-gfx] [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for BT2020 case

Quoted 61 lines · Uma
Quoted 47 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Ville Syrjälä
Sent: Tuesday, May 7, 2019 7:37 PM
To: Sharma, Shashank <[email protected]>
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for
BT2020 case

Quoted 34 lines · Shashank Sharma

From: Uma Shankar <[email protected]>

Currently input csc for YCbCR to RGB conversion handles only BT601 and Bt709. Extending it to support BT2020 as well.

---
 drivers/gpu/drm/i915/intel_sprite.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/gpu/drm/i915/intel_sprite.c +12 -0
index 44aaeac1b2ed..2536e757bec2 100644
@@ -433,6 +433,18 @@ icl_program_input_csc(struct intel_plane *plane,
 			0x9EF8, 0x7800, 0xABF8,
 			0x0, 0x7800,  0x7ED8,
 		},
+		/*
+		 * BT.2020 full range YCbCr -> full range RGB
+		 * The matrix required is :
+		 * [1.000, 0.000, 1.474,
+		 *  1.000, -0.1645, -0.5713,
+		 *  1.000, 1.8814, 0.0000]
+		 */
+		[DRM_COLOR_YCBCR_BT2020] = {
+			0x7BC8, 0x7800, 0x0,
+			0x8928, 0x7800, 0xAA88,
+			0x0, 0x7800, 0x7F10,
+		},
 	};
 
Quoted 13 lines

drivers/gpu/drm/i915/intel_sprite.c icl_program_input_csc(struct intel_plane *plane, · line 481

Quoted 11 lines
drivers/gpu/drm/i915/intel_sprite.c +7 -0
 	/* Matrix for Limited Range to Full Range Conversion */ @@ -461,6
+473,18 @@ icl_program_input_csc(struct intel_plane *plane,
 			0x8888, 0x7918, 0xADA8,
 			0x0, 0x7918,  0x6870,
 		},
+		/*
+		 * BT.2020 Limited range YCbCr -> full range RGB
+		 * The matrix required is :
+		 * [1.164, 0.000, 1.717,
+		 *  1.138, -0.1873, -0.6504,
+		 *  1.1380, 2.1417, 0.0000]

Where are those 1.138 coming from?

Quoted 8 lines

Hi Ville,
This is the original YCBCR to RGB BT2020 matrix:

{
        1.00000000000,  0.00000000000,  1.47460000000,
        1.00000000000,  -0.16455312684, -0.57135312684,
        1.00000000000,  1.88140000000,  0.00000000000 };

We have to convert Limited Range YCbCr to Full Range RGB. Hence we need to

apply a scale factor:

Quoted 8 lines

yscalefactor = 219.0 * normalizingfactor; cbcrscalefactor = 224.0 *
normalizingfactor;

/* Scale factors are inverted for LR to FR conversion */
yscalefactor = 1.0 / yscalefactor; cbcrscalefactor = 1.0 / cbcrscalefactor;

This yields the above results.

Quoted 7 lines

Those are the coefficients for Y, so they should still be the same for all three output channels.

igt_color_encoding gives me:

|1.1644, 0.0000, 1.6787,|
|1.1644,-0.1873,-0.6504,|
|1.1644, 2.1418, 0.0000,|
Quoted 5 lines

Ok, I used the igt_color_encoding method and able to get values what you got. Will update the matrix. Thanks Ville.

Quoted 1 line

Looks like we're also misprogramming the Y pre-offset for the full range YCbCr case.

For full range, I am getting same values as programmed above. Looks ok, can you double check.

The matrix itself looks OK (some minor rounding differences perhaps, but nothing major). But the Y preoffset should be zero for full range YCbCr.

Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw

Re: [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for BT2020 case

Quoted 118 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, May 9, 2019 8:28 PM
To: Shankar, Uma <[email protected]>
Cc: Sharma, Shashank <[email protected]>; intel- [email protected]
Subject: Re: [Intel-gfx] [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for BT2020 case

Quoted 106 lines · Uma
Quoted 95 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, May 7, 2019 9:08 PM
To: Shankar, Uma <[email protected]>
Cc: Sharma, Shashank <[email protected]>; intel- [email protected]
Subject: Re: [Intel-gfx] [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for
BT2020 case

Quoted 65 lines · Uma
Quoted 48 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Ville Syrjälä
Sent: Tuesday, May 7, 2019 7:37 PM
To: Sharma, Shashank <[email protected]>
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for
BT2020 case

Quoted 35 lines · Shashank Sharma

From: Uma Shankar <[email protected]>

Currently input csc for YCbCR to RGB conversion handles only BT601 and Bt709. Extending it to support BT2020 as well.

---
 drivers/gpu/drm/i915/intel_sprite.c | 24
++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/gpu/drm/i915/intel_sprite.c +12 -0
index 44aaeac1b2ed..2536e757bec2 100644
@@ -433,6 +433,18 @@ icl_program_input_csc(struct intel_plane *plane,
 			0x9EF8, 0x7800, 0xABF8,
 			0x0, 0x7800,  0x7ED8,
 		},
+		/*
+		 * BT.2020 full range YCbCr -> full range RGB
+		 * The matrix required is :
+		 * [1.000, 0.000, 1.474,
+		 *  1.000, -0.1645, -0.5713,
+		 *  1.000, 1.8814, 0.0000]
+		 */
+		[DRM_COLOR_YCBCR_BT2020] = {
+			0x7BC8, 0x7800, 0x0,
+			0x8928, 0x7800, 0xAA88,
+			0x0, 0x7800, 0x7F10,
+		},
 	};
 
Quoted 14 lines

drivers/gpu/drm/i915/intel_sprite.c icl_program_input_csc(struct intel_plane *plane, · line 481

Quoted 12 lines
drivers/gpu/drm/i915/intel_sprite.c +7 -1
 	/* Matrix for Limited Range to Full Range Conversion */ @@
-461,6
+473,18 @@ icl_program_input_csc(struct intel_plane *plane,
 			0x8888, 0x7918, 0xADA8,
 			0x0, 0x7918,  0x6870,
 		},
+		/*
+		 * BT.2020 Limited range YCbCr -> full range RGB
+		 * The matrix required is :
+		 * [1.164, 0.000, 1.717,
+		 *  1.138, -0.1873, -0.6504,
+		 *  1.1380, 2.1417, 0.0000]

Where are those 1.138 coming from?

Hi Ville,
This is the original YCBCR to RGB BT2020 matrix:

Quoted 7 lines
{
        1.00000000000,  0.00000000000,  1.47460000000,
        1.00000000000,  -0.16455312684, -0.57135312684,
        1.00000000000,  1.88140000000,  0.00000000000 };

We have to convert Limited Range YCbCr to Full Range RGB. Hence we need to

apply a scale factor:

Quoted 8 lines

yscalefactor = 219.0 * normalizingfactor; cbcrscalefactor = 224.0
* normalizingfactor;

/* Scale factors are inverted for LR to FR conversion */
yscalefactor = 1.0 / yscalefactor; cbcrscalefactor = 1.0 / cbcrscalefactor;

This yields the above results.

Quoted 7 lines

Those are the coefficients for Y, so they should still be the same for all three output channels.

igt_color_encoding gives me:

|1.1644, 0.0000, 1.6787,|
|1.1644,-0.1873,-0.6504,|
|1.1644, 2.1418, 0.0000,|

Ok, I used the igt_color_encoding method and able to get values what you got. Will update the matrix. Thanks Ville.

Quoted 7 lines
Quoted 1 line
Quoted 1 line

Looks like we're also misprogramming the Y pre-offset for the full range YCbCr

case.

Quoted 1 line

For full range, I am getting same values as programmed above. Looks ok, can you

double check.

The matrix itself looks OK (some minor rounding differences perhaps, but nothing major). But the Y preoffset should be zero for full range YCbCr.

Hi Ville,
This is what I got for Full Range from igt_color_encoding. m4.d[m(row=0, col=0)] = 1.000000
m4.d[m(row=1, col=0)] = 1.000000
m4.d[m(row=2, col=0)] = 1.000000
m4.d[m(row=3, col=0)] = 0.000000
m4.d[m(row=0, col=1)] = 0.000000
m4.d[m(row=1, col=1)] = -0.164553
m4.d[m(row=2, col=1)] = 1.881400
m4.d[m(row=3, col=1)] = 0.000000
m4.d[m(row=0, col=2)] = 1.474600
m4.d[m(row=1, col=2)] = -0.571353
m4.d[m(row=2, col=2)] = 0.000000
m4.d[m(row=3, col=2)] = 0.000000
m4.d[m(row=0, col=3)] = -188.748810
m4.d[m(row=1, col=3)] = 94.195992
m4.d[m(row=2, col=3)] = -240.819199
m4.d[m(row=3, col=3)] = 1.000000

which matches our table. This is the argument list for :
struct igt_mat4 m4 = igt_ycbcr_to_rgb_matrix(DRM_FORMAT_YUV420,

                                     DRM_FORMAT_XRGB8888,
                                       IGT_COLOR_YCBCR_BT2020,
                                       IGT_COLOR_YCBCR_FULL_RANGE);

Am I am missing something ?

Regards,
Uma Shankar

Quoted 2 lines

Ville Syrjälä
Intel

_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw

Re: [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for BT2020 case

Quoted 145 lines · Uma
Quoted 118 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, May 9, 2019 8:28 PM
To: Shankar, Uma <[email protected]>
Cc: Sharma, Shashank <[email protected]>; intel- [email protected]
Subject: Re: [Intel-gfx] [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for BT2020 case

Quoted 106 lines · Uma
Quoted 95 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, May 7, 2019 9:08 PM
To: Shankar, Uma <[email protected]>
Cc: Sharma, Shashank <[email protected]>; intel- [email protected]
Subject: Re: [Intel-gfx] [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for
BT2020 case

Quoted 65 lines · Uma
Quoted 48 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Ville Syrjälä
Sent: Tuesday, May 7, 2019 7:37 PM
To: Sharma, Shashank <[email protected]>
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for
BT2020 case

Quoted 35 lines · Shashank Sharma

From: Uma Shankar <[email protected]>

Currently input csc for YCbCR to RGB conversion handles only BT601 and Bt709. Extending it to support BT2020 as well.

---
 drivers/gpu/drm/i915/intel_sprite.c | 24
++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/gpu/drm/i915/intel_sprite.c +12 -0
index 44aaeac1b2ed..2536e757bec2 100644
@@ -433,6 +433,18 @@ icl_program_input_csc(struct intel_plane *plane,
 			0x9EF8, 0x7800, 0xABF8,
 			0x0, 0x7800,  0x7ED8,
 		},
+		/*
+		 * BT.2020 full range YCbCr -> full range RGB
+		 * The matrix required is :
+		 * [1.000, 0.000, 1.474,
+		 *  1.000, -0.1645, -0.5713,
+		 *  1.000, 1.8814, 0.0000]
+		 */
+		[DRM_COLOR_YCBCR_BT2020] = {
+			0x7BC8, 0x7800, 0x0,
+			0x8928, 0x7800, 0xAA88,
+			0x0, 0x7800, 0x7F10,
+		},
 	};
 
Quoted 14 lines

drivers/gpu/drm/i915/intel_sprite.c icl_program_input_csc(struct intel_plane *plane,

Quoted 12 lines
drivers/gpu/drm/i915/intel_sprite.c +7 -1
 	/* Matrix for Limited Range to Full Range Conversion */ @@
-461,6
+473,18 @@ icl_program_input_csc(struct intel_plane *plane,
 			0x8888, 0x7918, 0xADA8,
 			0x0, 0x7918,  0x6870,
 		},
+		/*
+		 * BT.2020 Limited range YCbCr -> full range RGB
+		 * The matrix required is :
+		 * [1.164, 0.000, 1.717,
+		 *  1.138, -0.1873, -0.6504,
+		 *  1.1380, 2.1417, 0.0000]

Where are those 1.138 coming from?

Hi Ville,
This is the original YCBCR to RGB BT2020 matrix:

Quoted 7 lines
{
        1.00000000000,  0.00000000000,  1.47460000000,
        1.00000000000,  -0.16455312684, -0.57135312684,
        1.00000000000,  1.88140000000,  0.00000000000 };

We have to convert Limited Range YCbCr to Full Range RGB. Hence we need to

apply a scale factor:

Quoted 8 lines

yscalefactor = 219.0 * normalizingfactor; cbcrscalefactor = 224.0
* normalizingfactor;

/* Scale factors are inverted for LR to FR conversion */
yscalefactor = 1.0 / yscalefactor; cbcrscalefactor = 1.0 / cbcrscalefactor;

This yields the above results.

Quoted 7 lines

Those are the coefficients for Y, so they should still be the same for all three output channels.

igt_color_encoding gives me:

|1.1644, 0.0000, 1.6787,|
|1.1644,-0.1873,-0.6504,|
|1.1644, 2.1418, 0.0000,|

Ok, I used the igt_color_encoding method and able to get values what you got. Will update the matrix. Thanks Ville.

Quoted 7 lines
Quoted 1 line
Quoted 1 line

Looks like we're also misprogramming the Y pre-offset for the full range YCbCr

case.

Quoted 1 line

For full range, I am getting same values as programmed above. Looks ok, can you

double check.

The matrix itself looks OK (some minor rounding differences perhaps, but nothing major). But the Y preoffset should be zero for full range YCbCr.

Hi Ville,
This is what I got for Full Range from igt_color_encoding. m4.d[m(row=0, col=0)] = 1.000000
m4.d[m(row=1, col=0)] = 1.000000
m4.d[m(row=2, col=0)] = 1.000000
m4.d[m(row=3, col=0)] = 0.000000
m4.d[m(row=0, col=1)] = 0.000000
m4.d[m(row=1, col=1)] = -0.164553
m4.d[m(row=2, col=1)] = 1.881400
m4.d[m(row=3, col=1)] = 0.000000
m4.d[m(row=0, col=2)] = 1.474600
m4.d[m(row=1, col=2)] = -0.571353
m4.d[m(row=2, col=2)] = 0.000000
m4.d[m(row=3, col=2)] = 0.000000
m4.d[m(row=0, col=3)] = -188.748810
m4.d[m(row=1, col=3)] = 94.195992
m4.d[m(row=2, col=3)] = -240.819199
m4.d[m(row=3, col=3)] = 1.000000

Quoted 7 lines

which matches our table. This is the argument list for :
struct igt_mat4 m4 = igt_ycbcr_to_rgb_matrix(DRM_FORMAT_YUV420,

                                     DRM_FORMAT_XRGB8888,
                                       IGT_COLOR_YCBCR_BT2020,
                                       IGT_COLOR_YCBCR_FULL_RANGE);

Am I am missing something ?

I'm talking about

	I915_WRITE_FW(PLANE_INPUT_CSC_PREOFF(pipe, plane_id, 1),
		      PREOFF_YUV_TO_RGB_ME);

not sure what you're talking about :)

Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#9 lore raw

Re: [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for BT2020 case

Quoted 168 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, May 9, 2019 9:00 PM
To: Shankar, Uma <[email protected]>
Cc: Sharma, Shashank <[email protected]>; intel- [email protected]
Subject: Re: [Intel-gfx] [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for BT2020 case

Quoted 156 lines · Uma
Quoted 123 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, May 9, 2019 8:28 PM
To: Shankar, Uma <[email protected]>
Cc: Sharma, Shashank <[email protected]>; intel- [email protected]
Subject: Re: [Intel-gfx] [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for
BT2020 case

Quoted 100 lines · Uma
Quoted 100 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, May 7, 2019 9:08 PM
To: Shankar, Uma <[email protected]>
Cc: Sharma, Shashank <[email protected]>; intel- [email protected]
Subject: Re: [Intel-gfx] [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for
BT2020 case

Quoted 66 lines · Uma
Quoted 49 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]]
On Behalf Of Ville Syrjälä
Sent: Tuesday, May 7, 2019 7:37 PM
To: Sharma, Shashank <[email protected]>
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH] drm/i915/icl: Handle YCbCr to RGB conversion for
BT2020 case

Quoted 35 lines · Shashank Sharma

From: Uma Shankar <[email protected]>

Currently input csc for YCbCR to RGB conversion handles only BT601 and Bt709. Extending it to support BT2020 as well.

---
 drivers/gpu/drm/i915/intel_sprite.c | 24
++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/gpu/drm/i915/intel_sprite.c +12 -0
index 44aaeac1b2ed..2536e757bec2 100644
@@ -433,6 +433,18 @@ icl_program_input_csc(struct intel_plane *plane,
 			0x9EF8, 0x7800, 0xABF8,
 			0x0, 0x7800,  0x7ED8,
 		},
+		/*
+		 * BT.2020 full range YCbCr -> full range RGB
+		 * The matrix required is :
+		 * [1.000, 0.000, 1.474,
+		 *  1.000, -0.1645, -0.5713,
+		 *  1.000, 1.8814, 0.0000]
+		 */
+		[DRM_COLOR_YCBCR_BT2020] = {
+			0x7BC8, 0x7800, 0x0,
+			0x8928, 0x7800, 0xAA88,
+			0x0, 0x7800, 0x7F10,
+		},
 	};
 
Quoted 14 lines

drivers/gpu/drm/i915/intel_sprite.c icl_program_input_csc(struct intel_plane *plane,

Quoted 12 lines
drivers/gpu/drm/i915/intel_sprite.c +7 -1
 	/* Matrix for Limited Range to Full Range Conversion */ @@
-461,6
+473,18 @@ icl_program_input_csc(struct intel_plane *plane,
 			0x8888, 0x7918, 0xADA8,
 			0x0, 0x7918,  0x6870,
 		},
+		/*
+		 * BT.2020 Limited range YCbCr -> full range RGB
+		 * The matrix required is :
+		 * [1.164, 0.000, 1.717,
+		 *  1.138, -0.1873, -0.6504,
+		 *  1.1380, 2.1417, 0.0000]

Where are those 1.138 coming from?

Hi Ville,
This is the original YCBCR to RGB BT2020 matrix:

Quoted 7 lines
{
        1.00000000000,  0.00000000000,  1.47460000000,
        1.00000000000,  -0.16455312684, -0.57135312684,
        1.00000000000,  1.88140000000,  0.00000000000 };

We have to convert Limited Range YCbCr to Full Range RGB. Hence we need to

apply a scale factor:

Quoted 9 lines

yscalefactor = 219.0 * normalizingfactor; cbcrscalefactor =
224.0
* normalizingfactor;

/* Scale factors are inverted for LR to FR conversion */
yscalefactor = 1.0 / yscalefactor; cbcrscalefactor = 1.0 / cbcrscalefactor;

This yields the above results.

Those are the coefficients for Y, so they should still be the same for all three output channels.

Quoted 10 lines
Quoted 4 lines

igt_color_encoding gives me:

|1.1644, 0.0000, 1.6787,|
|1.1644,-0.1873,-0.6504,|
|1.1644, 2.1418, 0.0000,|

Ok, I used the igt_color_encoding method and able to get values what you got. Will update the matrix. Thanks Ville.

Quoted 2 lines

Looks like we're also misprogramming the Y pre-offset for the full range YCbCr

Quoted 7 lines

case.

Quoted 2 lines

For full range, I am getting same values as programmed above. Looks ok, can you

double check.

The matrix itself looks OK (some minor rounding differences perhaps, but nothing major). But the Y preoffset should be zero for full range YCbCr.

Hi Ville,
This is what I got for Full Range from igt_color_encoding. m4.d[m(row=0, col=0)] = 1.000000
m4.d[m(row=1, col=0)] = 1.000000
m4.d[m(row=2, col=0)] = 1.000000
m4.d[m(row=3, col=0)] = 0.000000
m4.d[m(row=0, col=1)] = 0.000000
m4.d[m(row=1, col=1)] = -0.164553
m4.d[m(row=2, col=1)] = 1.881400
m4.d[m(row=3, col=1)] = 0.000000
m4.d[m(row=0, col=2)] = 1.474600
m4.d[m(row=1, col=2)] = -0.571353
m4.d[m(row=2, col=2)] = 0.000000
m4.d[m(row=3, col=2)] = 0.000000
m4.d[m(row=0, col=3)] = -188.748810
m4.d[m(row=1, col=3)] = 94.195992
m4.d[m(row=2, col=3)] = -240.819199
m4.d[m(row=3, col=3)] = 1.000000

which matches our table. This is the argument list for :
struct igt_mat4 m4 = igt_ycbcr_to_rgb_matrix(DRM_FORMAT_YUV420,

                                     DRM_FORMAT_XRGB8888,
                                       IGT_COLOR_YCBCR_BT2020,
                                       IGT_COLOR_YCBCR_FULL_RANGE);
Quoted 7 lines
Quoted 1 line

Am I am missing something ?

I'm talking about

	I915_WRITE_FW(PLANE_INPUT_CSC_PREOFF(pipe, plane_id, 1),
		      PREOFF_YUV_TO_RGB_ME);

not sure what you're talking about :)

Aah, I was pre-occupied with coefficient discussion itself :). Got it now, will update that and send out the next version.

Regards,
Uma Shankar

Quoted 3 lines

--
Ville Syrjälä
Intel

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx