Add func intel_csc_equal() to compare hw/sw CSC coeff values.

Cc: Swati Sharma <swati2.sha...@intel.com>
Cc: Uma Shankar <uma.shan...@intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.mo...@intel.com>
---
 drivers/gpu/drm/i915/display/intel_color.c | 51 +++++++++++++++++++---
 drivers/gpu/drm/i915/display/intel_color.h |  3 ++
 2 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_color.c 
b/drivers/gpu/drm/i915/display/intel_color.c
index 17bb08e9cf64..54dfd3523272 100644
--- a/drivers/gpu/drm/i915/display/intel_color.c
+++ b/drivers/gpu/drm/i915/display/intel_color.c
@@ -348,16 +348,11 @@ static void icl_load_csc_matrix(const struct 
intel_crtc_state *crtc_state)
                       crtc_state->csc_mode);
 }
 
-static void chv_load_cgm_csc(struct intel_crtc *crtc,
-                            const struct drm_property_blob *blob)
+static void chv_csc_convert_ctm(const struct drm_color_ctm *ctm, u16 coeffs[9])
 {
-       struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
-       const struct drm_color_ctm *ctm = blob->data;
-       enum pipe pipe = crtc->pipe;
-       u16 coeffs[9];
        int i;
 
-       for (i = 0; i < ARRAY_SIZE(coeffs); i++) {
+       for (i = 0; i < 9; i++) {
                u64 abs_coeff = ((1ULL << 63) - 1) & ctm->matrix[i];
 
                /* Round coefficient. */
@@ -374,6 +369,17 @@ static void chv_load_cgm_csc(struct intel_crtc *crtc,
                coeffs[i] |= ((abs_coeff >> 32) & 7) << 12;
                coeffs[i] |= (abs_coeff >> 20) & 0xfff;
        }
+}
+
+static void chv_load_cgm_csc(struct intel_crtc *crtc,
+                            const struct drm_property_blob *blob)
+{
+       struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
+       const struct drm_color_ctm *ctm = blob->data;
+       enum pipe pipe = crtc->pipe;
+       u16 coeffs[9];
+
+       chv_csc_convert_ctm(ctm, coeffs);
 
        intel_de_write(dev_priv, CGM_PIPE_CSC_COEFF01(pipe),
                       coeffs[1] << 16 | coeffs[0]);
@@ -1792,6 +1798,37 @@ bool intel_color_lut_equal(struct drm_property_blob 
*blob1,
        return true;
 }
 
+bool intel_csc_equal(const struct intel_crtc_state *current_config,
+                    struct drm_property_blob *blob1,
+                    struct drm_property_blob *blob2)
+{
+       struct drm_i915_private *dev_priv = 
to_i915(current_config->uapi.crtc->dev);
+       struct drm_color_ctm *ctm1, *ctm2;
+       u16 coeffs[9];
+       int i;
+
+       if (!blob1 != !blob2)
+               return false;
+
+       if (!blob1)
+               return true;
+
+       ctm1 = blob1->data;
+       ctm2 = blob2->data;
+
+       if (IS_CHERRYVIEW(dev_priv))
+               chv_csc_convert_ctm(ctm1, coeffs);
+       else
+               ilk_csc_convert_ctm(current_config, coeffs);
+
+       for (i = 0; i < 9; i++) {
+               if (abs(coeffs[i] - ctm2->matrix[i]))
+                       return false;
+       }
+
+       return true;
+}
+
 static struct drm_property_blob *i9xx_read_lut_8(struct intel_crtc *crtc)
 {
        struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
diff --git a/drivers/gpu/drm/i915/display/intel_color.h 
b/drivers/gpu/drm/i915/display/intel_color.h
index 173727aaa24d..e6bd9aa0c04a 100644
--- a/drivers/gpu/drm/i915/display/intel_color.h
+++ b/drivers/gpu/drm/i915/display/intel_color.h
@@ -21,5 +21,8 @@ int intel_color_get_gamma_bit_precision(const struct 
intel_crtc_state *crtc_stat
 bool intel_color_lut_equal(struct drm_property_blob *blob1,
                           struct drm_property_blob *blob2,
                           u32 gamma_mode, u32 bit_precision);
+bool intel_csc_equal(const struct intel_crtc_state *crtc_state,
+                          struct drm_property_blob *blob1,
+                          struct drm_property_blob *blob2);
 
 #endif /* __INTEL_COLOR_H__ */
-- 
2.20.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to