[v6 14/16] drm/i915: Enable Plane Gamma/Degamma

Uma Shankar
2019-03-19T08:19:46Z

Update the plane gamma and degamma feature in the
plane state and eventually program to PLANE_COLOR_CTL.

Signed-off-by: Uma Shankar <uma.shankar@intel.com>
---
drivers/gpu/drm/i915/i915_reg.h | 1 +
drivers/gpu/drm/i915/intel_color.c | 6 ++++++
drivers/gpu/drm/i915/intel_display.c | 6 +++++-
3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 019227b..7e2e746 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -6757,6 +6757,7 @@ enum {
#define PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709 (2 << 17)
#define PLANE_COLOR_CSC_MODE_YUV2020_TO_RGB2020 (3 << 17)
#define PLANE_COLOR_CSC_MODE_RGB709_TO_RGB2020 (4 << 17)
+#define PLANE_COLOR_PLANE_PRECSC_GAMMA_ENABLE (1 << 14)
#define PLANE_COLOR_PLANE_GAMMA_DISABLE (1 << 13)
#define PLANE_COLOR_ALPHA_MASK (0x3 << 4)
#define PLANE_COLOR_ALPHA_DISABLE (0 << 4)
diff --git a/drivers/gpu/drm/i915/intel_color.c b/drivers/gpu/drm/i915/intel_color.c
index 22790b4..aa73f88 100644
--- a/drivers/gpu/drm/i915/intel_color.c
+++ b/drivers/gpu/drm/i915/intel_color.c
@@ -769,8 +769,14 @@ static void icl_load_plane_gamma_lut(const struct drm_plane_state *state,
/* Loads the palette/gamma unit for the CRTC on Gen11+. */
static void icl_load_plane_luts(const struct drm_plane_state *state)
{
+ struct intel_plane_state *plane_state =
+ to_intel_plane_state(state);
+
icl_load_plane_degamma_lut(state, 0);
icl_load_plane_gamma_lut(state, 0);
+
+ plane_state->gamma_mode |= PLANE_COLOR_PLANE_PRECSC_GAMMA_ENABLE;
+ plane_state->gamma_mode |= ~PLANE_COLOR_PLANE_GAMMA_DISABLE;
}

static void glk_load_degamma_lut(const struct intel_crtc_state *crtc_state)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 2c44ce4..78d161e 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -3805,7 +3805,11 @@ u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state,
struct intel_plane *plane = to_intel_plane(plane_state->base.plane);
u32 plane_color_ctl = 0;

- plane_color_ctl |= PLANE_COLOR_PLANE_GAMMA_DISABLE;
+ if (INTEL_GEN(dev_priv) <= 11)
+ plane_color_ctl |= PLANE_COLOR_PLANE_GAMMA_DISABLE;
+ else
+ plane_color_ctl |= plane_state->gamma_mode;
+
plane_color_ctl |= glk_plane_color_ctl_alpha(plane_state);

if (fb->format->is_yuv && !icl_is_hdr_plane(dev_priv, plane->id)) {