Intel-GFX Archive on 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: [v8][PATCH 03/10] drm/i915/display: Add func to compare hw/sw gamma lut
Date: Mon, 26 Aug 2019 11:56:05 +0530	[thread overview]
Message-ID: <1566800772-18412-4-git-send-email-swati2.sharma@intel.com> (raw)
In-Reply-To: <1566800772-18412-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 enteries comparsion
will be different for different gamma modes, add gamma mode dependent
checks.

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

diff --git a/drivers/gpu/drm/i915/display/intel_color.c b/drivers/gpu/drm/i915/display/intel_color.c
index d2c1297..27727a1 100644
--- a/drivers/gpu/drm/i915/display/intel_color.c
+++ b/drivers/gpu/drm/i915/display/intel_color.c
@@ -1450,6 +1450,77 @@ int intel_color_get_gamma_bit_precision(const struct intel_crtc_state *crtc_stat
 	return 0;
 }
 
+static inline bool err_check(struct drm_color_lut *sw_lut,
+			     struct drm_color_lut *hw_lut, u32 err)
+{
+	return ((abs((long)hw_lut->red - sw_lut->red)) <= err) &&
+		((abs((long)hw_lut->blue - sw_lut->blue)) <= err) &&
+		((abs((long)hw_lut->green - sw_lut->green)) <= err);
+}
+
+static inline bool intel_color_lut_entry_equal(struct drm_color_lut *sw_lut,
+					       struct drm_color_lut *hw_lut,
+					       int hw_lut_size, u32 err)
+{
+	int i;
+
+	for (i = 0; i < hw_lut_size; i++) {
+		if (!err_check(&hw_lut[i], &sw_lut[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 *sw_lut, *hw_lut;
+	int sw_lut_size, hw_lut_size;
+	u32 err;
+
+	if (!blob1 != !blob2)
+		return false;
+
+	if (!blob1)
+		return true;
+
+	sw_lut_size = drm_color_lut_size(blob1);
+	hw_lut_size = drm_color_lut_size(blob2);
+
+	switch (gamma_mode) {
+	case GAMMA_MODE_MODE_8BIT:
+	case GAMMA_MODE_MODE_10BIT:
+		if (sw_lut_size != hw_lut_size)
+			return false;
+		else
+			break;
+	default:
+		MISSING_CASE(gamma_mode);
+			return false;
+	}
+
+	sw_lut = blob1->data;
+	hw_lut = blob2->data;
+
+	err = 0xffff >> bit_precision;
+
+	switch (gamma_mode) {
+	case GAMMA_MODE_MODE_8BIT:
+	case GAMMA_MODE_MODE_10BIT:
+		if (!intel_color_lut_entry_equal(sw_lut, hw_lut, hw_lut_size, err))
+				return false;
+		else
+				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-08-26  6:36 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-26  6:26 [v8][PATCH 00/10] drm/i915: adding state checker for gamma lut value Swati Sharma
2019-08-26  6:26 ` [v8][PATCH 01/10] drm/i915/display: Add func to get gamma bit precision Swati Sharma
2019-08-28 13:22   ` Shankar, Uma
2019-08-26  6:26 ` [v8][PATCH 02/10] drm/i915/display: Add debug log for color parameters Swati Sharma
2019-08-28 14:07   ` Shankar, Uma
2019-08-26  6:26 ` Swati Sharma [this message]
2019-08-28 15:22   ` [v8][PATCH 03/10] drm/i915/display: Add func to compare hw/sw gamma lut Shankar, Uma
2019-08-26  6:26 ` [v8][PATCH 04/10] drm/i915/display: Add macro to compare gamma hw/sw lut Swati Sharma
2019-08-28 15:35   ` Shankar, Uma
2019-08-26  6:26 ` [v8][PATCH 05/10] drm/i915/display: Extract i9xx_read_luts() Swati Sharma
2019-08-28 15:55   ` Shankar, Uma
2019-08-28 20:29     ` Sharma, Swati2
2019-08-29 15:15       ` Shankar, Uma
2019-08-26  6:26 ` [v8][PATCH 06/10] drm/i91/display: Extract i965_read_luts() Swati Sharma
2019-08-28 16:08   ` Shankar, Uma
2019-08-28 16:11     ` Shankar, Uma
2019-08-28 20:48     ` Sharma, Swati2
2019-08-28 21:48       ` Sharma, Swati2
2019-08-26  6:26 ` [v8][PATCH 09/10] drm/i915/display: Extract glk_read_luts() Swati Sharma
2019-08-28 16:30   ` Shankar, Uma
2019-08-26  6:26 ` [v8][PATCH 10/10] FOR_TESTING_ONLY: Print rgb values of hw and sw blobs Swati Sharma
2019-08-26  6:44 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: adding state checker for gamma lut value Patchwork
2019-08-26  6:49 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-08-26  7:08 ` ✓ Fi.CI.BAT: success " Patchwork
2019-08-26  9:13 ` ✓ Fi.CI.IGT: " Patchwork
2019-08-28 13:11 ` [v8][PATCH 00/10] " Shankar, Uma
     [not found] ` <1566800772-18412-8-git-send-email-swati2.sharma@intel.com>
2019-08-28 16:16   ` [v8][PATCH 07/10] drm/i915/display: Extract chv_read_luts() Shankar, Uma
     [not found] ` <1566800772-18412-9-git-send-email-swati2.sharma@intel.com>
2019-08-28 16:24   ` [v8][PATCH 08/10] drm/i915/display: Extract ilk_read_luts() 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=1566800772-18412-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox