From: Uma Shankar <uma.shankar@intel.com>
To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: ville.syrjala@intel.com, emil.l.velikov@gmail.com,
Uma Shankar <uma.shankar@intel.com>,
maarten.lankhorst@intel.com
Subject: [v7 16/16] drm/i915: Enable Plane CSC
Date: Fri, 29 Mar 2019 01:46:14 +0530 [thread overview]
Message-ID: <1553804174-2651-17-git-send-email-uma.shankar@intel.com> (raw)
In-Reply-To: <1553804174-2651-1-git-send-email-uma.shankar@intel.com>
Implement plane CSC on ICL.
Signed-off-by: Uma Shankar <uma.shankar@intel.com>
---
drivers/gpu/drm/i915/i915_reg.h | 1 +
drivers/gpu/drm/i915/intel_color.c | 86 ++++++++++++++++++++++++++++++++++++
drivers/gpu/drm/i915/intel_display.c | 3 ++
3 files changed, 90 insertions(+)
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 657232bd..f82a5bc 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -6750,6 +6750,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_PLANE_CSC_ENABLE (1 << 21) /* ICL+ */
#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)
diff --git a/drivers/gpu/drm/i915/intel_color.c b/drivers/gpu/drm/i915/intel_color.c
index aa73f88..ed21d98 100644
--- a/drivers/gpu/drm/i915/intel_color.c
+++ b/drivers/gpu/drm/i915/intel_color.c
@@ -606,6 +606,90 @@ static void bdw_load_plane_gamma_lut(const struct drm_plane_state *state,
}
}
+static void icl_load_plane_csc_matrix(const struct drm_plane_state *state)
+{
+ struct drm_i915_private *dev_priv = to_i915(state->plane->dev);
+ enum pipe pipe = to_intel_plane(state->plane)->pipe;
+ enum plane_id plane = to_intel_plane(state->plane)->id;
+ u16 coeffs[9] = {};
+ u16 postoff = 0;
+ int i;
+
+ if (state->ctm) {
+ struct drm_color_ctm *ctm = state->ctm->data;
+ const u64 *input;
+
+ input = ctm->matrix;
+
+ /*
+ * Convert fixed point S31.32 input to format supported by the
+ * hardware.
+ */
+ for (i = 0; i < ARRAY_SIZE(coeffs); i++) {
+ u64 abs_coeff = ((1ULL << 63) - 1) & input[i];
+
+ /*
+ * Clamp input value to min/max supported by
+ * hardware.
+ */
+ abs_coeff = clamp_val(abs_coeff, 0, CTM_COEFF_4_0 - 1);
+
+ /* sign bit */
+ if (CTM_COEFF_NEGATIVE(input[i]))
+ coeffs[i] |= 1 << 15;
+
+ if (abs_coeff < CTM_COEFF_0_125)
+ coeffs[i] |= (3 << 12) |
+ ILK_CSC_COEFF_FP(abs_coeff, 12);
+ else if (abs_coeff < CTM_COEFF_0_25)
+ coeffs[i] |= (2 << 12) |
+ ILK_CSC_COEFF_FP(abs_coeff, 11);
+ else if (abs_coeff < CTM_COEFF_0_5)
+ coeffs[i] |= (1 << 12) |
+ ILK_CSC_COEFF_FP(abs_coeff, 10);
+ else if (abs_coeff < CTM_COEFF_1_0)
+ coeffs[i] |= ILK_CSC_COEFF_FP(abs_coeff, 9);
+ else if (abs_coeff < CTM_COEFF_2_0)
+ coeffs[i] |= (7 << 12) |
+ ILK_CSC_COEFF_FP(abs_coeff, 8);
+ else
+ coeffs[i] |= (6 << 12) |
+ ILK_CSC_COEFF_FP(abs_coeff, 7);
+ }
+ } else {
+ /*
+ * Load an identity matrix if no coefficients are provided.
+ *
+ * TODO: Check what kind of values actually come out of the
+ * pipe with these coeff/postoff values and adjust to get the
+ * best accuracy. Perhaps we even need to take the bpc value
+ * into consideration.
+ */
+ for (i = 0; i < 3; i++)
+ coeffs[i * 3 + i] = ILK_CSC_COEFF_1_0;
+ }
+
+ I915_WRITE(PLANE_CSC_COEFF(pipe, plane, 0),
+ coeffs[0] << 16 | coeffs[1]);
+ I915_WRITE(PLANE_CSC_COEFF(pipe, plane, 1), coeffs[2] << 16);
+
+ I915_WRITE(PLANE_CSC_COEFF(pipe, plane, 3),
+ coeffs[3] << 16 | coeffs[4]);
+ I915_WRITE(PLANE_CSC_COEFF(pipe, plane, 4), coeffs[5] << 16);
+
+ I915_WRITE(PLANE_CSC_COEFF(pipe, plane, 5),
+ coeffs[6] << 16 | coeffs[7]);
+ I915_WRITE(PLANE_CSC_COEFF(pipe, plane, 6), coeffs[8] << 16);
+
+ I915_WRITE(PLANE_CSC_PREOFF(pipe, plane, 0), 0);
+ I915_WRITE(PLANE_CSC_PREOFF(pipe, plane, 1), 0);
+ I915_WRITE(PLANE_CSC_PREOFF(pipe, plane, 2), 0);
+
+ I915_WRITE(PLANE_CSC_POSTOFF(pipe, plane, 0), postoff);
+ I915_WRITE(PLANE_CSC_POSTOFF(pipe, plane, 1), postoff);
+ I915_WRITE(PLANE_CSC_POSTOFF(pipe, plane, 2), postoff);
+}
+
/* Loads the palette/gamma unit for the CRTC on Broadwell+. */
static void broadwell_load_plane_luts(const struct drm_plane_state *state)
{
@@ -777,6 +861,8 @@ static void icl_load_plane_luts(const struct drm_plane_state *state)
plane_state->gamma_mode |= PLANE_COLOR_PLANE_PRECSC_GAMMA_ENABLE;
plane_state->gamma_mode |= ~PLANE_COLOR_PLANE_GAMMA_DISABLE;
+
+ icl_load_plane_csc_matrix(state);
}
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 6b37052..83c9d51 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -3834,6 +3834,9 @@ u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state,
plane_color_ctl |= PLANE_COLOR_INPUT_CSC_ENABLE;
}
+ if (plane_state->base.ctm)
+ plane_color_ctl |= PLANE_COLOR_PLANE_CSC_ENABLE;
+
return plane_color_ctl;
}
--
1.9.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2019-03-28 20:16 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-28 20:15 [v7 00/16] Add Plane Color Properties Uma Shankar
2019-03-28 20:15 ` ✗ Fi.CI.BAT: failure for Add Plane Color Properties (rev7) Patchwork
2019-03-28 20:15 ` [v7 01/16] drm: Add Enhanced Gamma LUT precision structure Uma Shankar
2019-08-13 9:41 ` [v7, " james qian wang (Arm Technology China)
2019-08-14 14:29 ` Shankar, Uma
2019-08-19 7:59 ` james qian wang (Arm Technology China)
2019-03-28 20:16 ` [v7 02/16] drm: Add Plane Degamma properties Uma Shankar
2019-03-28 20:16 ` [v7 03/16] drm: Add Plane CTM property Uma Shankar
2019-03-28 20:16 ` [v7 04/16] drm: Add Plane Gamma properties Uma Shankar
2019-03-28 20:16 ` [v7 05/16] drm: Define helper function for plane color enabling Uma Shankar
2019-03-28 20:16 ` [v7 06/16] drm/i915: Enable plane color features Uma Shankar
2019-03-28 20:16 ` [v7 07/16] drm/i915: Implement Plane Gamma for Bdw and Gen9 platforms Uma Shankar
2019-03-28 20:16 ` [v7 08/16] drm/i915: Load plane color luts from atomic flip Uma Shankar
2019-03-28 20:16 ` [v7 09/16] drm/i915: Add plane color capabilities Uma Shankar
2019-03-28 20:16 ` [v7 10/16] drm/i915/icl: Add ICL Plane Degamma Register definition Uma Shankar
2019-03-28 20:16 ` [v7 11/16] drm/i915/icl: Enable Plane Degamma Uma Shankar
2019-03-28 20:16 ` [v7 12/16] drm/i915/icl: Add Plane Gamma Register Definitions Uma Shankar
2019-03-28 20:16 ` [v7 13/16] drm/i915/icl: Implement Plane Gamma Uma Shankar
2019-03-28 20:16 ` [v7 14/16] drm/i915: Enable Plane Gamma/Degamma Uma Shankar
2019-03-28 20:16 ` [v7 15/16] drm/i915: Define Plane CSC Registers Uma Shankar
2019-03-28 20:16 ` Uma Shankar [this message]
2019-06-14 16:17 ` [v7 00/16] Add Plane Color Properties Ezequiel Garcia
2019-06-14 21:22 ` Ezequiel Garcia
2019-06-19 6:20 ` Shankar, Uma
2019-06-19 13:18 ` Ezequiel Garcia
2019-06-19 15:03 ` Ville Syrjälä
2019-06-19 15:33 ` Ezequiel Garcia
2019-06-19 16:29 ` Ville Syrjälä
2019-06-20 13:42 ` Shankar, Uma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1553804174-2651-17-git-send-email-uma.shankar@intel.com \
--to=uma.shankar@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=maarten.lankhorst@intel.com \
--cc=ville.syrjala@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox