[PATCH 08/10] INTEL_DII: drm/i915/mtl: Add check for 24 bit precision DG LUT

Borah, Chaitanya Kumar chaitanya.kumar.borah at intel.com
Wed Sep 14 12:48:01 UTC 2022


There are two scenarios when 24 bit degamma lut will be configured
correctly.

1. New user space must select "extended degamma" as degamma mode,
set advance degamma client capability flag.

2. Legacy user space sends lut values without setting advance
degamma client capability and without selecting a degamma mode

Any other combinations should lead to error. The patch adds checks
for these conditions

Signed-off-by: Borah, Chaitanya Kumar <chaitanya.kumar.borah at intel.com>
---
 drivers/gpu/drm/i915/display/intel_color.c | 45 +++++++++++++++++++++-
 1 file changed, 43 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_color.c b/drivers/gpu/drm/i915/display/intel_color.c
index 016e67c2aa5343..ecab52ed715428 100644
--- a/drivers/gpu/drm/i915/display/intel_color.c
+++ b/drivers/gpu/drm/i915/display/intel_color.c
@@ -1541,6 +1541,27 @@ static int check_luts(const struct intel_crtc_state *crtc_state)
 	return 0;
 }
 
+static int mtl_check_degamma_lut(const struct intel_crtc_state *crtc_state)
+{
+	const struct drm_property_blob *degamma_lut_blob = crtc_state->hw.gamma_lut;
+
+	if (!degamma_lut_blob)
+		return 0;
+
+	if (crtc_state->uapi.degamma_mode_type == DEGAMMA_MODE_24BIT &&
+	    crtc_state->uapi.advance_degamma_mode_active)
+		return 0;
+
+	/* 16 bit LUT value usecase */
+	if (crtc_state->uapi.degamma_mode_type == 0 &&
+	    !crtc_state->uapi.advance_degamma_mode_active)
+		return 0;
+
+	DRM_ERROR("%s check failed\n", __func__);
+
+	return -EINVAL;
+}
+
 static u32 i9xx_gamma_mode(struct intel_crtc_state *crtc_state)
 {
 	if (!crtc_state->gamma_enable ||
@@ -1859,7 +1880,8 @@ static int icl_color_check(struct intel_crtc_state *crtc_state)
 {
 	struct drm_device *dev = crtc_state->uapi.crtc->dev;
 	struct drm_i915_private *dev_priv = to_i915(dev);
-	struct drm_property *property = crtc_state->uapi.crtc->gamma_mode_property;
+	struct drm_property *gamma_mode_property = crtc_state->uapi.crtc->gamma_mode_property;
+	struct drm_property *degamma_mode_property = crtc_state->uapi.crtc->degamma_mode_property;
 	struct drm_property_enum *prop_enum;
 	u32 index = 0;
 	int ret;
@@ -1868,8 +1890,27 @@ static int icl_color_check(struct intel_crtc_state *crtc_state)
 	if (ret)
 		return ret;
 
+	if (DISPLAY_VER(dev_priv) >= 14) {
+		list_for_each_entry(prop_enum, &degamma_mode_property->enum_list, head) {
+			if (prop_enum->value == crtc_state->uapi.degamma_mode) {
+				if (!strcmp(prop_enum->name,
+					    "extended degamma")) {
+					crtc_state->uapi.degamma_mode_type =
+						DEGAMMA_MODE_24BIT;
+					drm_dbg_kms(dev,
+						    "extended degamma enabled\n");
+				}
+				break;
+			}
+		}
+
+		ret = mtl_check_degamma_lut(crtc_state);
+		if (ret)
+			return ret;
+	}
+
 	if (DISPLAY_VER(dev_priv) >= 13) {
-		list_for_each_entry(prop_enum, &property->enum_list, head) {
+		list_for_each_entry(prop_enum, &gamma_mode_property->enum_list, head) {
 			if (prop_enum->value == crtc_state->uapi.gamma_mode) {
 				if (!strcmp(prop_enum->name,
 					    "logarithmic gamma")) {
-- 
2.25.1



More information about the Intel-gfx-trybot mailing list