[PATCH 2/2] drm/i915: Validate userspace-provided color management LUT's

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We currently program userspace-provided gamma and degamma LUT's into our
hardware without really checking to see whether they satisfy our
hardware's rules.  We should try to catch tables that are invalid for
our hardware early and reject the atomic transaction.

All of our platforms that accept a degamma LUT expect that the entries
in the LUT are always flat or increasing, never decreasing.  Also, our
GLK and ICL platforms only accept degamma tables with r=g=b entries; so
we should also add the relevant checks for that in anticipation of
degamma support landing for those platforms.

Cc: Uma Shankar <uma.shankar@xxxxxxxxx>
Cc: Swati Sharma <swati2.sharma@xxxxxxxxx>
Signed-off-by: Matt Roper <matthew.d.roper@xxxxxxxxx>
---
 drivers/gpu/drm/i915/intel_color.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_color.c b/drivers/gpu/drm/i915/intel_color.c
index 1d572e83db7f..041bb5d6a6cd 100644
--- a/drivers/gpu/drm/i915/intel_color.c
+++ b/drivers/gpu/drm/i915/intel_color.c
@@ -610,6 +610,24 @@ int intel_color_check(struct intel_crtc_state *crtc_state)
 	degamma_length = INTEL_INFO(dev_priv)->color.degamma_lut_size;
 	gamma_length = INTEL_INFO(dev_priv)->color.gamma_lut_size;
 
+	/*
+	 * GLK and gen11 only accept a single value for red, green, and
+	 * blue in the degamma table.  Make sure userspace didn't try to
+	 * pass us something we can't handle.
+	 */
+	if (IS_GEMINILAKE(dev_priv) || INTEL_GEN(dev_priv) >= 11) {
+		if (!drm_color_lut_has_equal_channels(crtc_state->base.degamma_lut)) {
+			DRM_DEBUG_KMS("All degamma entries must have equal r/g/b\n");
+			return -EINVAL;
+		}
+	}
+
+	/* All platforms require that the degamma curve be non-decreasing */
+	if (!drm_color_lut_is_increasing(crtc_state->base.degamma_lut)) {
+		DRM_DEBUG_KMS("Degamma curve must never decrease.\n");
+		return -EINVAL;
+	}
+
 	/*
 	 * We allow both degamma & gamma luts at the right size or
 	 * NULL.
-- 
2.14.4

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux