All of lore.kernel.org
 help / color / mirror / Atom feed
From: Swati Sharma <swati2.sharma@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: jani.nikula@intel.com, daniel.vetter@ffwll.ch,
	ankit.k.nautiyal@intel.com
Subject: [v10][PATCH 3/8] drm/i915/display: Add func to compare hw/sw gamma lut
Date: Wed,  4 Sep 2019 00:52:53 +0530	[thread overview]
Message-ID: <1567538578-4489-4-git-send-email-swati2.sharma@intel.com> (raw)
In-Reply-To: <1567538578-4489-1-git-send-email-swati2.sharma@intel.com>

Add func intel_color_lut_equal() to compare hw/sw gamma
lut values. Since hw/sw gamma lut sizes and lut entries comparison
will be different for different gamma modes, add gamma mode dependent
checks.

v3:  -Rebase
v4:  -Renamed intel_compare_color_lut() to intel_color_lut_equal() [Jani]
     -Added the default label above the correct label [Jani]
     -Corrected smatch warn "variable dereferenced before check"
      [Dan Carpenter]
v5:  -Added condition (!blob1 && !blob2) return true [Jani]
v6:  -Made patch11 as patch3 [Jani]
v8:  -Split patch 3 into 4 patches
     -Optimized blob check condition [Ville]
v9:  -Exclude spilt gamma mode (bdw and ivb platforms)
      as there is exception in way gamma values are written in
      hardware [Ville]
     -Added exception made in commit [Uma]
     -Dropped else, character limit and indentation [Uma]
     -Added multi segmented gama mode for icl+ platforms [Uma]
v10: -Dropped multi segmented mode for icl+ platforms [Jani]
     -Removed references of sw and hw state in compare code [Jani]
     -Dropped inline from func [Jani]

Signed-off-by: Swati Sharma <swati2.sharma@intel.com>
---
 drivers/gpu/drm/i915/display/intel_color.c | 72 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_color.h |  6 +++
 2 files changed, 78 insertions(+)

diff --git a/drivers/gpu/drm/i915/display/intel_color.c b/drivers/gpu/drm/i915/display/intel_color.c
index b5c0c65..1ab561d 100644
--- a/drivers/gpu/drm/i915/display/intel_color.c
+++ b/drivers/gpu/drm/i915/display/intel_color.c
@@ -1431,6 +1431,78 @@ int intel_color_get_gamma_bit_precision(const struct intel_crtc_state *crtc_stat
 	return 0;
 }
 
+static bool err_check(struct drm_color_lut *lut1,
+		      struct drm_color_lut *lut2, u32 err)
+{
+	return ((abs((long)lut2->red - lut1->red)) <= err) &&
+		((abs((long)lut2->blue - lut1->blue)) <= err) &&
+		((abs((long)lut2->green - lut1->green)) <= err);
+}
+
+static bool intel_color_lut_entry_equal(struct drm_color_lut *lut1,
+					struct drm_color_lut *lut2,
+					int lut_size, u32 err)
+{
+	int i;
+
+	for (i = 0; i < lut_size; i++) {
+		if (!err_check(&lut1[i], &lut2[i], err))
+			return false;
+	}
+
+	return true;
+}
+
+bool intel_color_lut_equal(struct drm_property_blob *blob1,
+			   struct drm_property_blob *blob2,
+			   u32 gamma_mode, u32 bit_precision)
+{
+	struct drm_color_lut *lut1, *lut2;
+	int lut_size1, lut_size2;
+	u32 err;
+
+	if (!blob1 != !blob2)
+		return false;
+
+	if (!blob1)
+		return true;
+
+	lut_size1 = drm_color_lut_size(blob1);
+	lut_size2 = drm_color_lut_size(blob2);
+
+	/* check sw and hw lut size */
+	switch (gamma_mode) {
+	case GAMMA_MODE_MODE_8BIT:
+	case GAMMA_MODE_MODE_10BIT:
+		if (lut_size1 != lut_size2)
+			return false;
+		break;
+	default:
+		MISSING_CASE(gamma_mode);
+			return false;
+	}
+
+	lut1 = blob1->data;
+	lut2 = blob2->data;
+
+	err = 0xffff >> bit_precision;
+
+	/* check sw and hw lut entry to be equal */
+	switch (gamma_mode) {
+	case GAMMA_MODE_MODE_8BIT:
+	case GAMMA_MODE_MODE_10BIT:
+		if (!intel_color_lut_entry_equal(lut1, lut2,
+						 lut_size2, err))
+			return false;
+		break;
+	default:
+		MISSING_CASE(gamma_mode);
+			return false;
+	}
+
+	return true;
+}
+
 void intel_color_init(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 0226d3a..173727a 100644
--- a/drivers/gpu/drm/i915/display/intel_color.h
+++ b/drivers/gpu/drm/i915/display/intel_color.h
@@ -6,8 +6,11 @@
 #ifndef __INTEL_COLOR_H__
 #define __INTEL_COLOR_H__
 
+#include <linux/types.h>
+
 struct intel_crtc_state;
 struct intel_crtc;
+struct drm_property_blob;
 
 void intel_color_init(struct intel_crtc *crtc);
 int intel_color_check(struct intel_crtc_state *crtc_state);
@@ -15,5 +18,8 @@
 void intel_color_load_luts(const struct intel_crtc_state *crtc_state);
 void intel_color_get_config(struct intel_crtc_state *crtc_state);
 int intel_color_get_gamma_bit_precision(const struct intel_crtc_state *crtc_state);
+bool intel_color_lut_equal(struct drm_property_blob *blob1,
+			   struct drm_property_blob *blob2,
+			   u32 gamma_mode, u32 bit_precision);
 
 #endif /* __INTEL_COLOR_H__ */
-- 
1.9.1

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

  parent reply	other threads:[~2019-09-03 19:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-03 19:22 [v10][PATCH 0/8] drm/i915: adding state checker for gamma lut values Swati Sharma
2019-09-03 19:22 ` [v10][PATCH 1/8] drm/i915/display: Add func to get gamma bit precision Swati Sharma
2019-09-03 19:22 ` [v10][PATCH 2/8] drm/i915/display: Add debug log for color parameters Swati Sharma
2019-09-03 19:22 ` Swati Sharma [this message]
2019-09-03 19:22 ` [v10][PATCH 4/8] drm/i915/display: Add macro to compare gamma hw/sw lut Swati Sharma
2019-09-03 19:22 ` [v10][PATCH 5/8] drm/i915/display: Extract i9xx_read_luts() Swati Sharma
2019-09-03 19:22 ` [v10][PATCH 6/8] drm/i915/display: Extract ilk_read_luts() Swati Sharma
2019-09-03 19:22 ` [v10][PATCH 7/8] drm/i915/display: Extract glk_read_luts() Swati Sharma
2019-09-03 19:22 ` [v10][PATCH 8/8] FOR_TESTING_ONLY: Print rgb values of hw and sw blobs Swati Sharma
2019-09-03 21:38 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: adding state checker for gamma lut values (rev14) Patchwork
2019-09-03 22:01 ` ✓ Fi.CI.BAT: success " Patchwork
2019-09-04  3:56 ` ✓ Fi.CI.IGT: " Patchwork
2019-09-04  9:30 ` [v10][PATCH 0/8] drm/i915: adding state checker for gamma lut values Jani Nikula
2019-09-04  9:45   ` Sharma, Swati2

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=1567538578-4489-4-git-send-email-swati2.sharma@intel.com \
    --to=swati2.sharma@intel.com \
    --cc=ankit.k.nautiyal@intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.