Enable Plane Input CSC for ICL
Subsystems (3)
v7 cover Enable Plane Input CSC for ICL
This patch series enables plane input csc feature for ICL. This is needed for YUV to RGB conversion on bottom 3 planes on ICL, other planes are handled in the legacy way using fixed function hardware.
This series enables color conversion for Full Range YUV data, limited range handling will be done as a separate patch.
v2: Separated the patch into 2 parts as per Maarten's comments. Addressed Ville and Maarten's review comment.
v3: Redesigned the register macro definition as per Matt's comment. Addressed Maarten's review comment.
v4: Added support for Limited Range Color Handling.
v5: Fixed Matt and Maarten's review comments.
v6: Added human readable matrix values for YUV to RGB Conversion along with just the bspec register values, as per Matt's suggestion.
v7: Refactored the code, move csc coefficient programming function to intel_sprite.c and made it static as per Ville's review comment.
This has been verified and tested by Maarten and the change is working as expected.
Uma Shankar (2):
drm/i915/icl: Define Plane Input CSC Coefficient Registers drm/i915/icl: Enable Plane Input CSC for YUV to RGB Conversion
drivers/gpu/drm/i915/i915_reg.h | 50 +++++++++++++++++ drivers/gpu/drm/i915/intel_color.c | 9 +++ drivers/gpu/drm/i915/intel_display.c | 20 ++++--- drivers/gpu/drm/i915/intel_sprite.c | 104 +++++++++++++++++++++++++++++++++++ 4 files changed, 176 insertions(+), 7 deletions(-)
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v7 1/2 drm/i915/icl: Define Plane Input CSC Coefficient Registers
Defined the plane input csc coefficient registers and macros. 6 registers are used to program a total of 9 coefficients, added macros to define each of them for all the planes supporting the feature on pipes. On ICL, bottom 3 planes have this capability.
v2: Segregated the register macro definition as separate patch as per Maarten's suggestion.
v3: Removed a redundant 3rd Pipe register definition and simplified the equally spaced register definition by adding an offset as per Matt's comment.
v4: No Change
v5: Renamed the register Macro as per Matt's suggestion.
v6: No Change
v7: No Change
--- drivers/gpu/drm/i915/i915_reg.h | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +50 -0
@@ -6569,6 +6569,7 @@ enum {#define _PLANE_COLOR_CTL_3_A 0x703CC/* GLK+ */ #define PLANE_COLOR_PIPE_GAMMA_ENABLE (1 << 30)/* Pre-ICL */ #define PLANE_COLOR_YUV_RANGE_CORRECTION_DISABLE (1 << 28) +#define PLANE_COLOR_INPUT_CSC_ENABLE (1 << 20)/* ICL+ */ #define PLANE_COLOR_PIPE_CSC_ENABLE (1 << 23)/* Pre-ICL */ #define PLANE_COLOR_CSC_MODE_BYPASS (0 << 17)#define PLANE_COLOR_CSC_MODE_YUV601_TO_RGB709 (1 << 17)
@@ -6585,6 +6586,55 @@ enum {#define _PLANE_NV12_BUF_CFG_1_A 0x70278#define _PLANE_NV12_BUF_CFG_2_A 0x70378 +/* Input CSC Register Definitions */ +#define _PLANE_INPUT_CSC_RY_GY_1_A 0x701E0 +#define _PLANE_INPUT_CSC_RY_GY_2_A 0x702E0 + +#define _PLANE_INPUT_CSC_RY_GY_1_B 0x711E0 +#define _PLANE_INPUT_CSC_RY_GY_2_B 0x712E0 + +#define _PLANE_INPUT_CSC_RY_GY_1 (pipe) \ + _PIPE(pipe, _PLANE_INPUT_CSC_RY_GY_1_A, \ + _PLANE_INPUT_CSC_RY_GY_1_B) +#define _PLANE_INPUT_CSC_RY_GY_2 (pipe) \ + _PIPE(pipe, _PLANE_INPUT_CSC_RY_GY_2_A, \ + _PLANE_INPUT_CSC_RY_GY_2_B) + +#define PLANE_INPUT_CSC_COEFF (pipe, plane, index) \ + _MMIO_PLANE(plane, _PLANE_INPUT_CSC_RY_GY_1(pipe) + (index) * 4, \ + _PLANE_INPUT_CSC_RY_GY_2(pipe) + (index) * 4) + +#define _PLANE_INPUT_CSC_PREOFF_HI_1_A 0x701F8 +#define _PLANE_INPUT_CSC_PREOFF_HI_2_A 0x702F8 + +#define _PLANE_INPUT_CSC_PREOFF_HI_1_B 0x711F8 +#define _PLANE_INPUT_CSC_PREOFF_HI_2_B 0x712F8 + +#define _PLANE_INPUT_CSC_PREOFF_HI_1 (pipe) \ + _PIPE(pipe, _PLANE_INPUT_CSC_PREOFF_HI_1_A, \ + _PLANE_INPUT_CSC_PREOFF_HI_1_B) +#define _PLANE_INPUT_CSC_PREOFF_HI_2 (pipe) \ + _PIPE(pipe, _PLANE_INPUT_CSC_PREOFF_HI_2_A, \ + _PLANE_INPUT_CSC_PREOFF_HI_2_B) +#define PLANE_INPUT_CSC_PREOFF (pipe, plane, index) \ + _MMIO_PLANE(plane, _PLANE_INPUT_CSC_PREOFF_HI_1(pipe) + (index) * 4, \ + _PLANE_INPUT_CSC_PREOFF_HI_2(pipe) + (index) * 4) + +#define _PLANE_INPUT_CSC_POSTOFF_HI_1_A 0x70204 +#define _PLANE_INPUT_CSC_POSTOFF_HI_2_A 0x70304 + +#define _PLANE_INPUT_CSC_POSTOFF_HI_1_B 0x71204 +#define _PLANE_INPUT_CSC_POSTOFF_HI_2_B 0x71304 + +#define _PLANE_INPUT_CSC_POSTOFF_HI_1 (pipe) \ + _PIPE(pipe, _PLANE_INPUT_CSC_POSTOFF_HI_1_A, \ + _PLANE_INPUT_CSC_POSTOFF_HI_1_B) +#define _PLANE_INPUT_CSC_POSTOFF_HI_2 (pipe) \ + _PIPE(pipe, _PLANE_INPUT_CSC_POSTOFF_HI_2_A, \ + _PLANE_INPUT_CSC_POSTOFF_HI_2_B) +#define PLANE_INPUT_CSC_POSTOFF (pipe, plane, index) \ + _MMIO_PLANE(plane, _PLANE_INPUT_CSC_POSTOFF_HI_1(pipe) + (index) * 4, \ + _PLANE_INPUT_CSC_POSTOFF_HI_2(pipe) + (index) * 4)#define _PLANE_CTL_1_B 0x71180#define _PLANE_CTL_2_B 0x71280
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v7 2/2 drm/i915/icl: Enable Plane Input CSC for YUV to RGB Conversion
In reply to Uma ShankarPlane input CSC needs to be enabled to convert frambuffers from YUV to RGB. This is needed for bottom 3 planes on ICL, rest of the planes have hardcoded conversion and taken care by the legacy code.
This patch defines the co-efficient values for YUV to RGB conversion in BT709 and BT601 formats. It programs the coefficients and enables the plane input csc unit in hardware.
This has been verified and tested by Maarten and the change is working as expecpted.
v2: Addressed Maarten's and Ville's review comments and added the coefficients in a 2D array instead of independent Macros.
v3: Added individual coefficient matrix (9 values) instead of 6 register values as per Maarten's comment. Also addresed a shift issue with B channel coefficient.
v4: Added support for Limited Range Color Handling
v5: Fixed Matt and Maarten's review comments.
v6: Added human readable matrix values for YUV to RGB Conversion along with just the bspec register values, as per Matt's suggestion.
v7: Refactored the code, move csc coefficient programming function to intel_sprite.c and made it static as per Ville's review comment.
--- drivers/gpu/drm/i915/intel_display.c | 17 +++++-- drivers/gpu/drm/i915/intel_sprite.c | 99 ++++++++++++++++++++++++++++++++++++ include/drm/drm_color_mgmt.h | 9 ++++ 3 files changed, 120 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_display.c +12 -5
@@ -3666,6 +3666,7 @@ u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state,struct drm_i915_private *dev_priv =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 ;if (INTEL_GEN (dev_priv) <11 ) {
@@ -3675,14 +3676,20 @@ u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state, plane_color_ctl |=PLANE_COLOR_PLANE_GAMMA_DISABLE ; plane_color_ctl |=glk_plane_color_ctl_alpha (plane_state); -if (fb->format->is_yuv) { -if (plane_state->base.color_encoding ==DRM_COLOR_YCBCR_BT709 ) - plane_color_ctl |=PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709 ; +if (fb->format->is_yuv && !icl_is_hdr_plane (plane)) { +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 ; + plane_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 ; + plane_color_ctl |= +PLANE_COLOR_YUV_RANGE_CORRECTION_DISABLE ; + }else if (fb->format->is_yuv) { + plane_color_ctl |=PLANE_COLOR_INPUT_CSC_ENABLE ; }return plane_color_ctl;
drivers/gpu/drm/i915/intel_sprite.c +99 -0
122 lines not on this page · raw message
include/drm/drm_color_mgmt.h +9 -0
@@ -29,6 +29,15 @@struct drm_crtc ;struct drm_plane ; +/* Preoffset values for YUV to RGB Conversion */ +#define PREOFF_YUV_TO_RGB_HI 0x1800 +#define PREOFF_YUV_TO_RGB_ME 0x1F00 +#define PREOFF_YUV_TO_RGB_LO 0x1800 + +#define ROFF (x) (((x) & 0xffff) << 16) +#define GOFF (x) (((x) & 0xffff) << 0) +#define BOFF (x) (((x) & 0xffff) << 16) +uint32_t drm_color_lut_extract (uint32_t user_input,uint32_t bit_precision); void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [v7 2/2] drm/i915/icl: Enable Plane Input CSC for YUV to RGB Conversion
Quoted 158 lines · Uma Shankar
Plane input CSC needs to be enabled to convert frambuffers from YUV to RGB. This is needed for bottom 3 planes on ICL, rest of the planes have hardcoded conversion and taken care by the legacy code.
This patch defines the co-efficient values for YUV to RGB conversion in BT709 and BT601 formats. It programs the coefficients and enables the plane input csc unit in hardware.
This has been verified and tested by Maarten and the change is working as expecpted.
v2: Addressed Maarten's and Ville's review comments and added the coefficients in a 2D array instead of independent Macros.
v3: Added individual coefficient matrix (9 values) instead of 6 register values as per Maarten's comment. Also addresed a shift issue with B channel coefficient.
v4: Added support for Limited Range Color Handling
v5: Fixed Matt and Maarten's review comments.
v6: Added human readable matrix values for YUV to RGB Conversion along with just the bspec register values, as per Matt's suggestion.
v7: Refactored the code, move csc coefficient programming function to
intel_sprite.cand made it static as per Ville's review comment.Signed-off-by Uma Shankar <[email protected]>Reviewed-by Matt Roper <[email protected]>Reviewed-by Maarten Lankhorst <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 17 +++++-- drivers/gpu/drm/i915/intel_sprite.c | 99 ++++++++++++++++++++++++++++++++++++ include/drm/drm_color_mgmt.h | 9 ++++ 3 files changed, 120 insertions(+), 5 deletions(-)drivers/gpu/drm/i915/intel_display.c +12
-5@@ -3666,6 +3666,7 @@ u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state,struct drm_i915_private *dev_priv =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 ;if (INTEL_GEN (dev_priv) <11 ) {@@ -3675,14 +3676,20 @@ u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state, plane_color_ctl |=PLANE_COLOR_PLANE_GAMMA_DISABLE ; plane_color_ctl |=glk_plane_color_ctl_alpha (plane_state); -if (fb->format->is_yuv) { -if (plane_state->base.color_encoding ==DRM_COLOR_YCBCR_BT709 ) - plane_color_ctl |=PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709 ; +if (fb->format->is_yuv && !icl_is_hdr_plane (plane)) { +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 ; + plane_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 ; + plane_color_ctl |= +PLANE_COLOR_YUV_RANGE_CORRECTION_DISABLE ; + }else if (fb->format->is_yuv) { + plane_color_ctl |=PLANE_COLOR_INPUT_CSC_ENABLE ; }return plane_color_ctl;drivers/gpu/drm/i915/intel_sprite.c +66
-0@@ -40,6 +40,7 @@#include "intel_frontbuffer.h" #include <drm/i915_drm.h> #include "i915_drv.h" +#include <drm/drm_color_mgmt.h> int intel_usecs_to_scanlines (const struct drm_display_mode *adjusted_mode,int usecs)@@ -458,11 +459,106 @@ int intel_plane_check_src_coordinates(struct intel_plane_state *plane_state)spin_unlock_irqrestore (&dev_priv->uncore.lock, irqflags); } +static void +icl_program_input_csc_coeff (const struct intel_crtc_state *crtc_state, +const struct intel_plane_state *plane_state) +{ +struct drm_i915_private *dev_priv = +to_i915 (plane_state->base.plane->dev); +struct intel_crtc *crtc =to_intel_crtc (crtc_state->base.crtc); +enum pipe pipe = crtc->pipe; +struct intel_plane *intel_plane = +to_intel_plane (plane_state->base.plane); +enum plane_id plane = intel_plane->id; + +static const u16 input_csc_matrix[][9 ] = { +/* +* BT.601 full range YCbCr -> full range RGB +* The matrix required is : +* [1.000, 0.000, 1.371, +* 1.000, -0.336, -0.698, +* 1.000, 1.732, 0.0000] +*/ + [DRM_COLOR_YCBCR_BT601 ] = { +0x7AF8 ,0x7800 ,0x0 , +0x8B28 ,0x7800 ,0x9AC0 , +0x0 ,0x7800 ,0x7DD8 , + }, +/* +* BT.709 full range YCbCr -> full range RGB +* The matrix required is : +* [1.000, 0.000, 1.574, +* 1.000, -0.187, -0.468, +* 1.000, 1.855, 0.0000] +*/ + [DRM_COLOR_YCBCR_BT709 ] = { +0x7C98 ,0x7800 ,0x0 , +0x9EF8 ,0x7800 ,0xABF8 , +0x0 ,0x7800 ,0x7ED8 , + }, + }; + +/* Matrix for Limited Range to Full Range Conversion */ +static const u16 input_csc_matrix_lr[][9 ] = { +/* +* BT.601 Limted range YCbCr -> full range RGB +* The matrix required is : +* [1.164384, 0.000, 1.596370, +* 1.138393, -0.382500, -0.794598, +* 1.138393, 1.971696, 0.0000] +*/ + [DRM_COLOR_YCBCR_BT601 ] = { +0x7CC8 ,0x7950 ,0x0 , +0x8CB8 ,0x7918 ,0x9C40 , +0x0 ,0x7918 ,0x7FC8 , + }, +/* +* BT.709 Limited range YCbCr -> full range RGB +* The matrix required is : +* [1.164, 0.000, 1.833671, +* 1.138393, -0.213249, -0.532909, +* 1.138393, 2.112402, 0.0000] +*/ + [DRM_COLOR_YCBCR_BT709 ] = { +0x7EA8 ,0x7950 ,0x0 , +0x8888 ,0x7918 ,0xADA8 , +0x0 ,0x7918 ,0x6870 , + },
drivers/gpu/drm/i915/intel_sprite.c int intel_plane_check_src_coordinates(struct intel_plane_state *plane_state) · line 536
Quoted 10 lines
drivers/gpu/drm/i915/intel_sprite.c +10
-0+ }; +const u16 *csc; + +if (plane_state->base.color_range ==DRM_COLOR_YCBCR_FULL_RANGE ) + csc = input_csc_matrix[plane_state->base.color_encoding]; +else + csc = input_csc_matrix_lr[plane_state->base.color_encoding]; + +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,0 ),ROFF (csc[0 ]) | +GOFF (csc[1 ]));
Make all of these I915_WRITE_FW() and ...
Quoted 29 lines
drivers/gpu/drm/i915/intel_sprite.c +20
-0+I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,1 ),BOFF (csc[2 ])); +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,2 ),ROFF (csc[3 ]) | +GOFF (csc[4 ])); +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,3 ),BOFF (csc[5 ])); +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,4 ),ROFF (csc[6 ]) | +GOFF (csc[7 ])); +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,5 ),BOFF (csc[8 ])); + +I915_WRITE (PLANE_INPUT_CSC_PREOFF (pipe, plane,0 ), +PREOFF_YUV_TO_RGB_HI ); +I915_WRITE (PLANE_INPUT_CSC_PREOFF (pipe, plane,1 ), +PREOFF_YUV_TO_RGB_ME ); +I915_WRITE (PLANE_INPUT_CSC_PREOFF (pipe, plane,2 ), +PREOFF_YUV_TO_RGB_LO ); +I915_WRITE (PLANE_INPUT_CSC_POSTOFF (pipe, plane,0 ),0x0 ); +I915_WRITE (PLANE_INPUT_CSC_POSTOFF (pipe, plane,1 ),0x0 ); +I915_WRITE (PLANE_INPUT_CSC_POSTOFF (pipe, plane,2 ),0x0 ); +} +void skl_update_plane (struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state) { +const struct drm_framebuffer *fb = plane_state->base.fb;int color_plane =0 ;if (plane_state->linked_plane) {
drivers/gpu/drm/i915/intel_sprite.c int intel_plane_check_src_coordinates(struct intel_plane_state *plane_state) · line 570
Quoted 5 lines
drivers/gpu/drm/i915/intel_sprite.c +2
-0@@ -470,6 +566,9 @@ int intel_plane_check_src_coordinates(struct intel_plane_state *plane_state) color_plane =1 ; } +if (fb->format->is_yuv &&icl_is_hdr_plane (plane)) +icl_program_input_csc_coeff (crtc_state, plane_state);
... call this from within the spinlocked section of skl_program_plane().
Quoted 31 lines
drivers/gpu/drm/i915/intel_sprite.c +1
-0+skl_program_plane (plane, crtc_state, plane_state, color_plane, false, plane_state->ctl); }include/drm/drm_color_mgmt.h +9
-0@@ -29,6 +29,15 @@struct drm_crtc ;struct drm_plane ; +/* Preoffset values for YUV to RGB Conversion */ +#define PREOFF_YUV_TO_RGB_HI 0x1800 +#define PREOFF_YUV_TO_RGB_ME 0x1F00 +#define PREOFF_YUV_TO_RGB_LO 0x1800 + +#define ROFF (x) (((x) & 0xffff) << 16) +#define GOFF (x) (((x) & 0xffff) << 0) +#define BOFF (x) (((x) & 0xffff) << 16) +uint32_t drm_color_lut_extract (uint32_t user_input,uint32_t bit_precision); void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,Signature · 6 lines
1.9.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
Re: [v7 2/2] drm/i915/icl: Enable Plane Input CSC for YUV to RGB Conversion
Quoted 185 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, November 1, 2018 3:17 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; Syrjala, Ville <[email protected]>; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v7 2/2] drm/i915/icl: Enable Plane Input CSC for YUV to RGB ConversionQuoted 28 lines · Uma Shankar
Plane input CSC needs to be enabled to convert frambuffers from YUV to RGB. This is needed for bottom 3 planes on ICL, rest of the planes have hardcoded conversion and taken care by the legacy code.
This patch defines the co-efficient values for YUV to RGB conversion in BT709 and BT601 formats. It programs the coefficients and enables the plane input csc unit in hardware.
This has been verified and tested by Maarten and the change is working as expecpted.
v2: Addressed Maarten's and Ville's review comments and added the coefficients in a 2D array instead of independent Macros.
v3: Added individual coefficient matrix (9 values) instead of 6 register values as per Maarten's comment. Also addresed a shift issue with B channel coefficient.
v4: Added support for Limited Range Color Handling
v5: Fixed Matt and Maarten's review comments.
v6: Added human readable matrix values for YUV to RGB Conversion along with just the bspec register values, as per Matt's suggestion.
v7: Refactored the code, move csc coefficient programming function to
intel_sprite.cand made it static as per Ville's review comment.Quoted 7 lines
Signed-off-by Uma Shankar <[email protected]>Reviewed-by Matt Roper <[email protected]>Reviewed-by Maarten Lankhorst <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 17 +++++--
drivers/gpu/drm/i915/intel_sprite.c| 99++++++++++++++++++++++++++++++++++++
drivers/gpu/drm/i915/intel_display.c u32 glk_plane_color_ctl(const struct intel_crtc_state
Quoted 9 lines
include/drm/drm_color_mgmt.h | 9 ++++ 3 files changed, 120 insertions(+), 5 deletions(-)drivers/gpu/drm/i915/intel_display.c +0
-0@@ -3666,6 +3666,7 @@ u32 glk_plane_color_ctl(const struct intel_crtc_state
*crtc_state,drivers/gpu/drm/i915/intel_display.c u32 glk_plane_color_ctl(const struct
Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +1
-0struct drm_i915_private *dev_priv =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 ;if (INTEL_GEN (dev_priv) <11 ) {@@ -3675,14 +3676,20 @@ u32 glk_plane_color_ctl(const struct
intel_crtc_state*crtc_state,drivers/gpu/drm/i915/intel_display.c u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state,
Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +0
-2plane_color_ctl |=PLANE_COLOR_PLANE_GAMMA_DISABLE ; plane_color_ctl |=glk_plane_color_ctl_alpha (plane_state); -if (fb->format->is_yuv) { - if (plane_state->base.color_encoding ==
DRM_COLOR_YCBCR_BT709)drivers/gpu/drm/i915/intel_display.c u32 glk_plane_color_ctl(const struct · line 3680
Quoted 1 line
drivers/gpu/drm/i915/intel_display.c +0
-1- plane_color_ctl |=
PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709;drivers/gpu/drm/i915/intel_display.c u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state,
Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +5
-0+if (fb->format->is_yuv && !icl_is_hdr_plane (plane)) { +if (plane_state->base.color_encoding == +DRM_COLOR_YCBCR_BT709 ) + plane_color_ctl |= +PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709;drivers/gpu/drm/i915/intel_display.c u32 glk_plane_color_ctl(const struct · line 3682
Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +0
-1else - plane_color_ctl |=
PLANE_COLOR_CSC_MODE_YUV601_TO_RGB709;drivers/gpu/drm/i915/intel_display.c u32 glk_plane_color_ctl(const struct · line 3686
Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +2
-0+ plane_color_ctl |= +PLANE_COLOR_CSC_MODE_YUV601_TO_RGB709;drivers/gpu/drm/i915/intel_display.c u32 glk_plane_color_ctl(const struct · line 3687
Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +0
-0if (plane_state->base.color_range ==
DRM_COLOR_YCBCR_FULL_RANGE)drivers/gpu/drm/i915/intel_display.c u32 glk_plane_color_ctl(const struct · line 3684
Quoted 1 line
drivers/gpu/drm/i915/intel_display.c +0
-1- plane_color_ctl |=
PLANE_COLOR_YUV_RANGE_CORRECTION_DISABLE;drivers/gpu/drm/i915/intel_sprite.c int intel_plane_check_src_coordinates(struct
Quoted 21 lines
drivers/gpu/drm/i915/intel_display.c +4
-0+ plane_color_ctl |= +PLANE_COLOR_YUV_RANGE_CORRECTION_DISABLE ; + }else if (fb->format->is_yuv) { + plane_color_ctl |=PLANE_COLOR_INPUT_CSC_ENABLE ; }return plane_color_ctl;drivers/gpu/drm/i915/intel_sprite.c +1
-0@@ -40,6 +40,7 @@#include "intel_frontbuffer.h" #include <drm/i915_drm.h> #include "i915_drv.h" +#include <drm/drm_color_mgmt.h> int intel_usecs_to_scanlines (const struct drm_display_mode *adjusted_mode,int usecs)@@ -458,11 +459,106 @@ int intel_plane_check_src_coordinates(struct
intel_plane_state*plane_state)Quoted 60 lines
drivers/gpu/drm/i915/intel_sprite.c +58
-0spin_unlock_irqrestore (&dev_priv->uncore.lock, irqflags); } +static void +icl_program_input_csc_coeff (const struct intel_crtc_state *crtc_state, +const struct intel_plane_state *plane_state) { +struct drm_i915_private *dev_priv = +to_i915 (plane_state->base.plane->dev); +struct intel_crtc *crtc =to_intel_crtc (crtc_state->base.crtc); +enum pipe pipe = crtc->pipe; +struct intel_plane *intel_plane = +to_intel_plane (plane_state->base.plane); +enum plane_id plane = intel_plane->id; + +static const u16 input_csc_matrix[][9 ] = { +/* +* BT.601 full range YCbCr -> full range RGB +* The matrix required is : +* [1.000, 0.000, 1.371, +* 1.000, -0.336, -0.698, +* 1.000, 1.732, 0.0000] +*/ + [DRM_COLOR_YCBCR_BT601 ] = { +0x7AF8 ,0x7800 ,0x0 , +0x8B28 ,0x7800 ,0x9AC0 , +0x0 ,0x7800 ,0x7DD8 , + }, +/* +* BT.709 full range YCbCr -> full range RGB +* The matrix required is : +* [1.000, 0.000, 1.574, +* 1.000, -0.187, -0.468, +* 1.000, 1.855, 0.0000] +*/ + [DRM_COLOR_YCBCR_BT709 ] = { +0x7C98 ,0x7800 ,0x0 , +0x9EF8 ,0x7800 ,0xABF8 , +0x0 ,0x7800 ,0x7ED8 , + }, + }; + +/* Matrix for Limited Range to Full Range Conversion */ +static const u16 input_csc_matrix_lr[][9 ] = { +/* +* BT.601 Limted range YCbCr -> full range RGB +* The matrix required is : +* [1.164384, 0.000, 1.596370, +* 1.138393, -0.382500, -0.794598, +* 1.138393, 1.971696, 0.0000] +*/ + [DRM_COLOR_YCBCR_BT601 ] = { +0x7CC8 ,0x7950 ,0x0 , +0x8CB8 ,0x7918 ,0x9C40 , +0x0 ,0x7918 ,0x7FC8 , + }, +/* +* BT.709 Limited range YCbCr -> full range RGB +* The matrix required is : +* [1.164, 0.000, 1.833671, +* 1.138393, -0.213249, -0.532909, +* 1.138393, 2.112402, 0.0000] drivers/gpu/drm/i915/intel_sprite.c int intel_plane_check_src_coordinates(struct intel_plane_state *plane_state)
Quoted 10 lines
drivers/gpu/drm/i915/intel_sprite.c +10
-0+*/ + [DRM_COLOR_YCBCR_BT709 ] = { +0x7EA8 ,0x7950 ,0x0 , +0x8888 ,0x7918 ,0xADA8 , +0x0 ,0x7918 ,0x6870 , + }, + }; +const u16 *csc; + + if (plane_state->base.color_range ==
DRM_COLOR_YCBCR_FULL_RANGE)
Quoted 8 lines
drivers/gpu/drm/i915/intel_sprite.c int intel_plane_check_src_coordinates(struct intel_plane_state *plane_state) · line 536
Quoted 6 lines
drivers/gpu/drm/i915/intel_sprite.c +6
-0+ csc = input_csc_matrix[plane_state->base.color_encoding]; + else + csc = input_csc_matrix_lr[plane_state->base.color_encoding]; + +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,0 ),ROFF (csc[0 ]) | +GOFF (csc[1 ]));Make all of these
I915_WRITE_FW()and ...
Sure, will update these.
Quoted 28 lines
drivers/gpu/drm/i915/intel_sprite.c int intel_plane_check_src_coordinates(struct
Quoted 27 lines
drivers/gpu/drm/i915/intel_sprite.c +19
-0+I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,1 ),BOFF (csc[2 ])); +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,2 ),ROFF (csc[3 ]) | +GOFF (csc[4 ])); +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,3 ),BOFF (csc[5 ])); +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,4 ),ROFF (csc[6 ]) | +GOFF (csc[7 ])); +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,5 ),BOFF (csc[8 ])); + +I915_WRITE (PLANE_INPUT_CSC_PREOFF (pipe, plane,0 ), +PREOFF_YUV_TO_RGB_HI ); +I915_WRITE (PLANE_INPUT_CSC_PREOFF (pipe, plane,1 ), +PREOFF_YUV_TO_RGB_ME ); +I915_WRITE (PLANE_INPUT_CSC_PREOFF (pipe, plane,2 ), +PREOFF_YUV_TO_RGB_LO ); +I915_WRITE (PLANE_INPUT_CSC_POSTOFF (pipe, plane,0 ),0x0 ); +I915_WRITE (PLANE_INPUT_CSC_POSTOFF (pipe, plane,1 ),0x0 ); +I915_WRITE (PLANE_INPUT_CSC_POSTOFF (pipe, plane,2 ),0x0 ); } +void skl_update_plane (struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state) { +const struct drm_framebuffer *fb = plane_state->base.fb;int color_plane =0 ;if (plane_state->linked_plane) {@@ -470,6 +566,9 @@ int intel_plane_check_src_coordinates(struct
intel_plane_state*plane_state)
Quoted 7 lines
drivers/gpu/drm/i915/intel_sprite.c int intel_plane_check_src_coordinates(struct intel_plane_state *plane_state) · line 570
Quoted 5 lines
drivers/gpu/drm/i915/intel_sprite.c +2
-0color_plane =1 ; } +if (fb->format->is_yuv &&icl_is_hdr_plane (plane)) +icl_program_input_csc_coeff (crtc_state, plane_state);... call this from within the spinlocked section of
skl_program_plane().
Ok, will update and resend.
Quoted 27 lines
Quoted 27 lines
drivers/gpu/drm/i915/intel_sprite.c +1
-0+skl_program_plane (plane, crtc_state, plane_state, color_plane, false, plane_state->ctl); } diff --git
a/include/drm/drm_color_mgmt.hb/include/drm/drm_color_mgmt.hindex 90ef999..3e17381 100644include/drm/drm_color_mgmt.h +9
-0@@ -29,6 +29,15 @@struct drm_crtc ;struct drm_plane ; +/* Preoffset values for YUV to RGB Conversion */ +#define PREOFF_YUV_TO_RGB_HI 0x1800 +#define PREOFF_YUV_TO_RGB_ME 0x1F00 +#define PREOFF_YUV_TO_RGB_LO 0x1800 + +#define ROFF (x) (((x) & 0xffff) << 16) +#define GOFF (x) (((x) & 0xffff) << 0) +#define BOFF (x) (((x) & 0xffff) << 16) +uint32_t drm_color_lut_extract (uint32_t user_input,uint32_t bit_precision);void drm_crtc_enable_color_mgmt(struct
drm_crtc*crtc,
--
1.9.1
Quoted 8 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
Re: [v7 2/2] drm/i915/icl: Enable Plane Input CSC for YUV to RGB Conversion
In reply to Uma ShankarQuoted 211 lines · Uma Shankar
Plane input CSC needs to be enabled to convert frambuffers from YUV to RGB. This is needed for bottom 3 planes on ICL, rest of the planes have hardcoded conversion and taken care by the legacy code.
This patch defines the co-efficient values for YUV to RGB conversion in BT709 and BT601 formats. It programs the coefficients and enables the plane input csc unit in hardware.
This has been verified and tested by Maarten and the change is working as expecpted.
v2: Addressed Maarten's and Ville's review comments and added the coefficients in a 2D array instead of independent Macros.
v3: Added individual coefficient matrix (9 values) instead of 6 register values as per Maarten's comment. Also addresed a shift issue with B channel coefficient.
v4: Added support for Limited Range Color Handling
v5: Fixed Matt and Maarten's review comments.
v6: Added human readable matrix values for YUV to RGB Conversion along with just the bspec register values, as per Matt's suggestion.
v7: Refactored the code, move csc coefficient programming function to
intel_sprite.cand made it static as per Ville's review comment.Signed-off-by Uma Shankar <[email protected]>Reviewed-by Matt Roper <[email protected]>Reviewed-by Maarten Lankhorst <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 17 +++++-- drivers/gpu/drm/i915/intel_sprite.c | 99 ++++++++++++++++++++++++++++++++++++ include/drm/drm_color_mgmt.h | 9 ++++ 3 files changed, 120 insertions(+), 5 deletions(-)drivers/gpu/drm/i915/intel_display.c +12
-5@@ -3666,6 +3666,7 @@ u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state,struct drm_i915_private *dev_priv =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 ;if (INTEL_GEN (dev_priv) <11 ) {@@ -3675,14 +3676,20 @@ u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state, plane_color_ctl |=PLANE_COLOR_PLANE_GAMMA_DISABLE ; plane_color_ctl |=glk_plane_color_ctl_alpha (plane_state); -if (fb->format->is_yuv) { -if (plane_state->base.color_encoding ==DRM_COLOR_YCBCR_BT709 ) - plane_color_ctl |=PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709 ; +if (fb->format->is_yuv && !icl_is_hdr_plane (plane)) { +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 ; + plane_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 ; + plane_color_ctl |= +PLANE_COLOR_YUV_RANGE_CORRECTION_DISABLE ; + }else if (fb->format->is_yuv) { + plane_color_ctl |=PLANE_COLOR_INPUT_CSC_ENABLE ; }return plane_color_ctl;drivers/gpu/drm/i915/intel_sprite.c +99
-0@@ -40,6 +40,7 @@#include "intel_frontbuffer.h" #include <drm/i915_drm.h> #include "i915_drv.h" +#include <drm/drm_color_mgmt.h> int intel_usecs_to_scanlines (const struct drm_display_mode *adjusted_mode,int usecs)@@ -458,11 +459,106 @@ int intel_plane_check_src_coordinates(struct intel_plane_state *plane_state)spin_unlock_irqrestore (&dev_priv->uncore.lock, irqflags); } +static void +icl_program_input_csc_coeff (const struct intel_crtc_state *crtc_state, +const struct intel_plane_state *plane_state) +{ +struct drm_i915_private *dev_priv = +to_i915 (plane_state->base.plane->dev); +struct intel_crtc *crtc =to_intel_crtc (crtc_state->base.crtc); +enum pipe pipe = crtc->pipe; +struct intel_plane *intel_plane = +to_intel_plane (plane_state->base.plane); +enum plane_id plane = intel_plane->id; + +static const u16 input_csc_matrix[][9 ] = { +/* +* BT.601 full range YCbCr -> full range RGB +* The matrix required is : +* [1.000, 0.000, 1.371, +* 1.000, -0.336, -0.698, +* 1.000, 1.732, 0.0000] +*/ + [DRM_COLOR_YCBCR_BT601 ] = { +0x7AF8 ,0x7800 ,0x0 , +0x8B28 ,0x7800 ,0x9AC0 , +0x0 ,0x7800 ,0x7DD8 , + }, +/* +* BT.709 full range YCbCr -> full range RGB +* The matrix required is : +* [1.000, 0.000, 1.574, +* 1.000, -0.187, -0.468, +* 1.000, 1.855, 0.0000] +*/ + [DRM_COLOR_YCBCR_BT709 ] = { +0x7C98 ,0x7800 ,0x0 , +0x9EF8 ,0x7800 ,0xABF8 , +0x0 ,0x7800 ,0x7ED8 , + }, + }; + +/* Matrix for Limited Range to Full Range Conversion */ +static const u16 input_csc_matrix_lr[][9 ] = { +/* +* BT.601 Limted range YCbCr -> full range RGB +* The matrix required is : +* [1.164384, 0.000, 1.596370, +* 1.138393, -0.382500, -0.794598, +* 1.138393, 1.971696, 0.0000] +*/ + [DRM_COLOR_YCBCR_BT601 ] = { +0x7CC8 ,0x7950 ,0x0 , +0x8CB8 ,0x7918 ,0x9C40 , +0x0 ,0x7918 ,0x7FC8 , + }, +/* +* BT.709 Limited range YCbCr -> full range RGB +* The matrix required is : +* [1.164, 0.000, 1.833671, +* 1.138393, -0.213249, -0.532909, +* 1.138393, 2.112402, 0.0000] +*/ + [DRM_COLOR_YCBCR_BT709 ] = { +0x7EA8 ,0x7950 ,0x0 , +0x8888 ,0x7918 ,0xADA8 , +0x0 ,0x7918 ,0x6870 , + }, + }; +const u16 *csc; + +if (plane_state->base.color_range ==DRM_COLOR_YCBCR_FULL_RANGE ) + csc = input_csc_matrix[plane_state->base.color_encoding]; +else + csc = input_csc_matrix_lr[plane_state->base.color_encoding]; + +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,0 ),ROFF (csc[0 ]) | +GOFF (csc[1 ])); +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,1 ),BOFF (csc[2 ])); +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,2 ),ROFF (csc[3 ]) | +GOFF (csc[4 ])); +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,3 ),BOFF (csc[5 ])); +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,4 ),ROFF (csc[6 ]) | +GOFF (csc[7 ])); +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,5 ),BOFF (csc[8 ])); + +I915_WRITE (PLANE_INPUT_CSC_PREOFF (pipe, plane,0 ), +PREOFF_YUV_TO_RGB_HI ); +I915_WRITE (PLANE_INPUT_CSC_PREOFF (pipe, plane,1 ), +PREOFF_YUV_TO_RGB_ME ); +I915_WRITE (PLANE_INPUT_CSC_PREOFF (pipe, plane,2 ), +PREOFF_YUV_TO_RGB_LO ); +I915_WRITE (PLANE_INPUT_CSC_POSTOFF (pipe, plane,0 ),0x0 ); +I915_WRITE (PLANE_INPUT_CSC_POSTOFF (pipe, plane,1 ),0x0 ); +I915_WRITE (PLANE_INPUT_CSC_POSTOFF (pipe, plane,2 ),0x0 ); +} +void skl_update_plane (struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state) { +const struct drm_framebuffer *fb = plane_state->base.fb;int color_plane =0 ;if (plane_state->linked_plane) {@@ -470,6 +566,9 @@ int intel_plane_check_src_coordinates(struct intel_plane_state *plane_state) color_plane =1 ; } +if (fb->format->is_yuv &&icl_is_hdr_plane (plane)) +icl_program_input_csc_coeff (crtc_state, plane_state); +skl_program_plane (plane, crtc_state, plane_state, color_plane, false, plane_state->ctl); }include/drm/drm_color_mgmt.h +0
-0
include/drm/drm_color_mgmt.h line 35
Quoted 7 lines
include/drm/drm_color_mgmt.h +4
-0@@ -29,6 +29,15 @@struct drm_crtc ;struct drm_plane ; +/* Preoffset values for YUV to RGB Conversion */ +#define PREOFF_YUV_TO_RGB_HI 0x1800 +#define PREOFF_YUV_TO_RGB_ME 0x1F00 +#define PREOFF_YUV_TO_RGB_LO 0x1800
Why are these here when all the other numbers are in icl_program_input_csc_coeff()? I'd rather just put everything into icl_program_input_csc_coeff().
Quoted 15 lines
include/drm/drm_color_mgmt.h +5
-0+ +#define ROFF (x) (((x) & 0xffff) << 16) +#define GOFF (x) (((x) & 0xffff) << 0) +#define BOFF (x) (((x) & 0xffff) << 16) +uint32_t drm_color_lut_extract (uint32_t user_input,uint32_t bit_precision); void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,Signature · 6 lines
1.9.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
Re: [v7 2/2] drm/i915/icl: Enable Plane Input CSC for YUV to RGB Conversion
Quoted 235 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, November 1, 2018 3:21 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; Syrjala, Ville <[email protected]>; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v7 2/2] drm/i915/icl: Enable Plane Input CSC for YUV to RGB ConversionQuoted 28 lines · Uma Shankar
Plane input CSC needs to be enabled to convert frambuffers from YUV to RGB. This is needed for bottom 3 planes on ICL, rest of the planes have hardcoded conversion and taken care by the legacy code.
This patch defines the co-efficient values for YUV to RGB conversion in BT709 and BT601 formats. It programs the coefficients and enables the plane input csc unit in hardware.
This has been verified and tested by Maarten and the change is working as expecpted.
v2: Addressed Maarten's and Ville's review comments and added the coefficients in a 2D array instead of independent Macros.
v3: Added individual coefficient matrix (9 values) instead of 6 register values as per Maarten's comment. Also addresed a shift issue with B channel coefficient.
v4: Added support for Limited Range Color Handling
v5: Fixed Matt and Maarten's review comments.
v6: Added human readable matrix values for YUV to RGB Conversion along with just the bspec register values, as per Matt's suggestion.
v7: Refactored the code, move csc coefficient programming function to
intel_sprite.cand made it static as per Ville's review comment.Quoted 7 lines
Signed-off-by Uma Shankar <[email protected]>Reviewed-by Matt Roper <[email protected]>Reviewed-by Maarten Lankhorst <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 17 +++++--
drivers/gpu/drm/i915/intel_sprite.c| 99++++++++++++++++++++++++++++++++++++
drivers/gpu/drm/i915/intel_display.c u32 glk_plane_color_ctl(const struct intel_crtc_state
Quoted 9 lines
include/drm/drm_color_mgmt.h | 9 ++++ 3 files changed, 120 insertions(+), 5 deletions(-)drivers/gpu/drm/i915/intel_display.c +0
-0@@ -3666,6 +3666,7 @@ u32 glk_plane_color_ctl(const struct intel_crtc_state
*crtc_state,drivers/gpu/drm/i915/intel_display.c u32 glk_plane_color_ctl(const struct
Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +1
-0struct drm_i915_private *dev_priv =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 ;if (INTEL_GEN (dev_priv) <11 ) {@@ -3675,14 +3676,20 @@ u32 glk_plane_color_ctl(const struct
intel_crtc_state*crtc_state,drivers/gpu/drm/i915/intel_display.c u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state,
Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +0
-2plane_color_ctl |=PLANE_COLOR_PLANE_GAMMA_DISABLE ; plane_color_ctl |=glk_plane_color_ctl_alpha (plane_state); -if (fb->format->is_yuv) { - if (plane_state->base.color_encoding ==
DRM_COLOR_YCBCR_BT709)drivers/gpu/drm/i915/intel_display.c u32 glk_plane_color_ctl(const struct · line 3680
Quoted 1 line
drivers/gpu/drm/i915/intel_display.c +0
-1- plane_color_ctl |=
PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709;drivers/gpu/drm/i915/intel_display.c u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state,
Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +5
-0+if (fb->format->is_yuv && !icl_is_hdr_plane (plane)) { +if (plane_state->base.color_encoding == +DRM_COLOR_YCBCR_BT709 ) + plane_color_ctl |= +PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709;drivers/gpu/drm/i915/intel_display.c u32 glk_plane_color_ctl(const struct · line 3682
Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +0
-1else - plane_color_ctl |=
PLANE_COLOR_CSC_MODE_YUV601_TO_RGB709;drivers/gpu/drm/i915/intel_display.c u32 glk_plane_color_ctl(const struct · line 3686
Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +2
-0+ plane_color_ctl |= +PLANE_COLOR_CSC_MODE_YUV601_TO_RGB709;drivers/gpu/drm/i915/intel_display.c u32 glk_plane_color_ctl(const struct · line 3687
Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +0
-0if (plane_state->base.color_range ==
DRM_COLOR_YCBCR_FULL_RANGE)drivers/gpu/drm/i915/intel_display.c u32 glk_plane_color_ctl(const struct · line 3684
Quoted 1 line
drivers/gpu/drm/i915/intel_display.c +0
-1- plane_color_ctl |=
PLANE_COLOR_YUV_RANGE_CORRECTION_DISABLE;drivers/gpu/drm/i915/intel_sprite.c int intel_plane_check_src_coordinates(struct
Quoted 21 lines
drivers/gpu/drm/i915/intel_display.c +4
-0+ plane_color_ctl |= +PLANE_COLOR_YUV_RANGE_CORRECTION_DISABLE ; + }else if (fb->format->is_yuv) { + plane_color_ctl |=PLANE_COLOR_INPUT_CSC_ENABLE ; }return plane_color_ctl;drivers/gpu/drm/i915/intel_sprite.c +1
-0@@ -40,6 +40,7 @@#include "intel_frontbuffer.h" #include <drm/i915_drm.h> #include "i915_drv.h" +#include <drm/drm_color_mgmt.h> int intel_usecs_to_scanlines (const struct drm_display_mode *adjusted_mode,int usecs)@@ -458,11 +459,106 @@ int intel_plane_check_src_coordinates(struct
intel_plane_state*plane_state)Quoted 60 lines
drivers/gpu/drm/i915/intel_sprite.c +58
-0spin_unlock_irqrestore (&dev_priv->uncore.lock, irqflags); } +static void +icl_program_input_csc_coeff (const struct intel_crtc_state *crtc_state, +const struct intel_plane_state *plane_state) { +struct drm_i915_private *dev_priv = +to_i915 (plane_state->base.plane->dev); +struct intel_crtc *crtc =to_intel_crtc (crtc_state->base.crtc); +enum pipe pipe = crtc->pipe; +struct intel_plane *intel_plane = +to_intel_plane (plane_state->base.plane); +enum plane_id plane = intel_plane->id; + +static const u16 input_csc_matrix[][9 ] = { +/* +* BT.601 full range YCbCr -> full range RGB +* The matrix required is : +* [1.000, 0.000, 1.371, +* 1.000, -0.336, -0.698, +* 1.000, 1.732, 0.0000] +*/ + [DRM_COLOR_YCBCR_BT601 ] = { +0x7AF8 ,0x7800 ,0x0 , +0x8B28 ,0x7800 ,0x9AC0 , +0x0 ,0x7800 ,0x7DD8 , + }, +/* +* BT.709 full range YCbCr -> full range RGB +* The matrix required is : +* [1.000, 0.000, 1.574, +* 1.000, -0.187, -0.468, +* 1.000, 1.855, 0.0000] +*/ + [DRM_COLOR_YCBCR_BT709 ] = { +0x7C98 ,0x7800 ,0x0 , +0x9EF8 ,0x7800 ,0xABF8 , +0x0 ,0x7800 ,0x7ED8 , + }, + }; + +/* Matrix for Limited Range to Full Range Conversion */ +static const u16 input_csc_matrix_lr[][9 ] = { +/* +* BT.601 Limted range YCbCr -> full range RGB +* The matrix required is : +* [1.164384, 0.000, 1.596370, +* 1.138393, -0.382500, -0.794598, +* 1.138393, 1.971696, 0.0000] +*/ + [DRM_COLOR_YCBCR_BT601 ] = { +0x7CC8 ,0x7950 ,0x0 , +0x8CB8 ,0x7918 ,0x9C40 , +0x0 ,0x7918 ,0x7FC8 , + }, +/* +* BT.709 Limited range YCbCr -> full range RGB +* The matrix required is : +* [1.164, 0.000, 1.833671, +* 1.138393, -0.213249, -0.532909, +* 1.138393, 2.112402, 0.0000] drivers/gpu/drm/i915/intel_sprite.c int intel_plane_check_src_coordinates(struct intel_plane_state *plane_state)
Quoted 10 lines
drivers/gpu/drm/i915/intel_sprite.c +10
-0+*/ + [DRM_COLOR_YCBCR_BT709 ] = { +0x7EA8 ,0x7950 ,0x0 , +0x8888 ,0x7918 ,0xADA8 , +0x0 ,0x7918 ,0x6870 , + }, + }; +const u16 *csc; + + if (plane_state->base.color_range ==
DRM_COLOR_YCBCR_FULL_RANGE)drivers/gpu/drm/i915/intel_sprite.c int intel_plane_check_src_coordinates(struct
Quoted 33 lines
drivers/gpu/drm/i915/intel_sprite.c +25
-0+ csc = input_csc_matrix[plane_state->base.color_encoding]; + else + csc = input_csc_matrix_lr[plane_state->base.color_encoding]; + +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,0 ),ROFF (csc[0 ]) | +GOFF (csc[1 ])); +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,1 ),BOFF (csc[2 ])); +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,2 ),ROFF (csc[3 ]) | +GOFF (csc[4 ])); +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,3 ),BOFF (csc[5 ])); +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,4 ),ROFF (csc[6 ]) | +GOFF (csc[7 ])); +I915_WRITE (PLANE_INPUT_CSC_COEFF (pipe, plane,5 ),BOFF (csc[8 ])); + +I915_WRITE (PLANE_INPUT_CSC_PREOFF (pipe, plane,0 ), +PREOFF_YUV_TO_RGB_HI ); +I915_WRITE (PLANE_INPUT_CSC_PREOFF (pipe, plane,1 ), +PREOFF_YUV_TO_RGB_ME ); +I915_WRITE (PLANE_INPUT_CSC_PREOFF (pipe, plane,2 ), +PREOFF_YUV_TO_RGB_LO ); +I915_WRITE (PLANE_INPUT_CSC_POSTOFF (pipe, plane,0 ),0x0 ); +I915_WRITE (PLANE_INPUT_CSC_POSTOFF (pipe, plane,1 ),0x0 ); +I915_WRITE (PLANE_INPUT_CSC_POSTOFF (pipe, plane,2 ),0x0 ); } +void skl_update_plane (struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state) { +const struct drm_framebuffer *fb = plane_state->base.fb;int color_plane =0 ;if (plane_state->linked_plane) {@@ -470,6 +566,9 @@ int intel_plane_check_src_coordinates(struct
intel_plane_state*plane_state)Quoted 16 lines
drivers/gpu/drm/i915/intel_sprite.c +3
-0color_plane =1 ; } +if (fb->format->is_yuv &&icl_is_hdr_plane (plane)) +icl_program_input_csc_coeff (crtc_state, plane_state); +skl_program_plane (plane, crtc_state, plane_state, color_plane, false, plane_state->ctl); } diff --git
a/include/drm/drm_color_mgmt.hb/include/drm/drm_color_mgmt.hindex 90ef999..3e17381 100644include/drm/drm_color_mgmt.h +0
-0@@ -29,6 +29,15 @@struct drm_crtc ;struct drm_plane ;
Quoted 8 lines
include/drm/drm_color_mgmt.h line 35
Quoted 4 lines
include/drm/drm_color_mgmt.h +4
-0+/* Preoffset values for YUV to RGB Conversion */ +#define PREOFF_YUV_TO_RGB_HI 0x1800 +#define PREOFF_YUV_TO_RGB_ME 0x1F00 +#define PREOFF_YUV_TO_RGB_LO 0x1800Why are these here when all the other numbers are in
icl_program_input_csc_coeff()? I'd rather just put everything intoicl_program_input_csc_coeff().
Sure, will move this around. Thanks..
Regards,
Uma Shankar
Quoted 12 lines
Quoted 12 lines
include/drm/drm_color_mgmt.h +5
-0+ +#define ROFF (x) (((x) & 0xffff) << 16) +#define GOFF (x) (((x) & 0xffff) << 0) +#define BOFF (x) (((x) & 0xffff) << 16) +uint32_t drm_color_lut_extract (uint32_t user_input,uint32_t bit_precision);void drm_crtc_enable_color_mgmt(struct
drm_crtc*crtc,
--
1.9.1
Quoted 8 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
Patchwork
CI✗ Fi.CI.BAT: failure for Enable Plane Input CSC for ICL (rev6)
In reply to Uma Shankar== Series Details ==
== Series Details ==
Series: Enable Plane Input CSC for ICL (rev6)
URL : https://patchwork.freedesktop.org/series/51463/
State : failure
== Summary ==
Applying: drm/i915/icl: Define Plane Input CSC Coefficient Registers
Applying: drm/i915/icl: Enable Plane Input CSC for YUV to RGB Conversion Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/intel_display.c
M drivers/gpu/drm/i915/intel_sprite.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/gpu/drm/i915/intel_sprite.c
CONFLICT (content): Merge conflict in drivers/gpu/drm/i915/intel_sprite.c Auto-merging drivers/gpu/drm/i915/intel_display.c
error: Failed to merge in the changes.
Patch failed at 0002 drm/i915/icl: Enable Plane Input CSC for YUV to RGB Conversion Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx