[PATCH 01/10] INTEL_DII: drm/color: Add pipe degamma mode property

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


Add degamma mode property for CRTC. This is an enum property with
values as blob_id's. The blob that the blob id refers to is used
to pass information regarding the mode supported and the range of
degamma mode supported with number of lut coefficients to the user
space. The userspace can select any of the supported degamma mode
using this enum property.

Signed-off-by: Borah, Chaitanya Kumar <chaitanya.kumar.borah at intel.com>
---
 drivers/gpu/drm/drm_atomic_uapi.c |  5 ++++
 drivers/gpu/drm/drm_color_mgmt.c  | 43 ++++++++++++++++++++++++++-----
 include/drm/drm_color_mgmt.h      | 11 +++++---
 include/drm/drm_crtc.h            | 19 +++++++++++++-
 4 files changed, 67 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index ba881f783ebded..e657eb860f0ace 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -477,6 +477,9 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
 	} else if (property == crtc->gamma_mode_property) {
 		state->gamma_mode = val;
 		state->color_mgmt_changed |= true;
+	} else if (property == crtc->degamma_mode_property) {
+		state->degamma_mode = val;
+		state->color_mgmt_changed |= true;
 	} else if (property == config->prop_out_fence_ptr) {
 		s32 __user *fence_ptr = u64_to_user_ptr(val);
 
@@ -518,6 +521,8 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,
 		*val = state->vrr_enabled;
 	else if (property == crtc->gamma_mode_property)
 		*val = state->gamma_mode;
+	else if (property == crtc->degamma_mode_property)
+		*val = state->degamma_mode;
 	else if (property == config->degamma_lut_property)
 		*val = (state->degamma_lut) ? state->degamma_lut->base.id : 0;
 	else if (property == config->ctm_property)
diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index fb62b0625b610c..309a5067fb21fe 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -218,17 +218,48 @@ int drm_color_create_gamma_mode_property(struct drm_crtc *crtc,
 }
 EXPORT_SYMBOL(drm_color_create_gamma_mode_property);
 
-int drm_color_add_gamma_mode_range(struct drm_crtc *crtc,
-				   const char *name,
-				   const struct drm_color_lut_range *ranges,
-				   size_t length)
+void drm_crtc_attach_degamma_mode_property(struct drm_crtc *crtc)
+{
+	if (!crtc->degamma_mode_property)
+		return;
+
+	drm_object_attach_property(&crtc->base,
+				   crtc->degamma_mode_property, 0);
+}
+EXPORT_SYMBOL(drm_crtc_attach_degamma_mode_property);
+
+int drm_color_create_degamma_mode_property(struct drm_crtc *crtc,
+					   int num_values)
+{
+	struct drm_property *prop;
+
+	prop = drm_property_create(crtc->dev,
+				   DRM_MODE_PROP_ENUM,
+				   "DEGAMMA_MODE", num_values);
+	if (!prop)
+		return -ENOMEM;
+
+	crtc->degamma_mode_property = prop;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_color_create_degamma_mode_property);
+
+int drm_color_add_gamma_degamma_mode_range(struct drm_crtc *crtc,
+					   const char *name,
+					   const struct drm_color_lut_range *ranges,
+					   size_t length, enum lut_type type)
 {
 	struct drm_property_blob *blob;
 	struct drm_property *prop;
 	int num_ranges = length / sizeof(ranges[0]);
 	int i, ret, num_types_0;
 
-	prop = crtc->gamma_mode_property;
+	if (type == LUT_TYPE_DEGAMMA)
+		prop = crtc->degamma_mode_property;
+	else
+		prop = crtc->gamma_mode_property;
+
 	if (!prop)
 		return -EINVAL;
 
@@ -264,7 +295,7 @@ int drm_color_add_gamma_mode_range(struct drm_crtc *crtc,
 
 	return 0;
 }
-EXPORT_SYMBOL(drm_color_add_gamma_mode_range);
+EXPORT_SYMBOL(drm_color_add_gamma_degamma_mode_range);
 
 /**
  * drm_mode_crtc_set_gamma_size - set the gamma table size
diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
index db68f42f6d121a..8599e063974037 100644
--- a/include/drm/drm_color_mgmt.h
+++ b/include/drm/drm_color_mgmt.h
@@ -77,10 +77,13 @@ static inline int drm_color_lut_size(const struct drm_property_blob *blob)
 int drm_color_create_gamma_mode_property(struct drm_crtc *crtc,
 					 int num_values);
 void drm_crtc_attach_gamma_mode_property(struct drm_crtc *crtc);
-int drm_color_add_gamma_mode_range(struct drm_crtc *crtc,
-				   const char *name,
-				   const struct drm_color_lut_range *ranges,
-				   size_t length);
+int drm_color_create_degamma_mode_property(struct drm_crtc *crtc,
+					   int num_values);
+void drm_crtc_attach_degamma_mode_property(struct drm_crtc *crtc);
+int drm_color_add_gamma_degamma_mode_range(struct drm_crtc *crtc,
+					   const char *name,
+					   const struct drm_color_lut_range *ranges,
+					   size_t length, enum lut_type type);
 
 enum drm_color_encoding {
 	DRM_COLOR_YCBCR_BT601,
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 27dcc92667992a..e20c4d396071d7 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -277,6 +277,16 @@ struct drm_crtc_state {
 	/** Gamma mode type programmed on the pipe */
 	u32 gamma_mode_type;
 
+	/**
+	 * @degamma_mode: This is a blob_id and exposes the platform capabilities
+	 * wrt to various degamma modes and the respective lut ranges. This also
+	 * helps user select a degamma mode amongst the supported ones.
+	 */
+	u32 degamma_mode;
+
+	/** @degamma_mode_type: degamma mode type programmed on the pipe */
+	u32 degamma_mode_type;
+
 	/**
 	 * @degamma_lut:
 	 *
@@ -1140,11 +1150,18 @@ struct drm_crtc {
 
 	/**
 	 * @gamma_mode_property: Optional CRTC property to enumerate and
-	 * select the mode of the crtc gamma/degmama LUTs. This also exposes
+	 * select the mode of the crtc gamma LUTs. This also exposes
 	 * the lut ranges of the various supported gamma modes to userspace.
 	 */
 	struct drm_property *gamma_mode_property;
 
+	/**
+	 * @degamma_mode_property: Optional CRTC property to enumerate and
+	 * select the mode of the crtc degmama LUTs. This also exposes
+	 * the lut ranges of the various supported gamma modes to userspace.
+	 */
+	struct drm_property *degamma_mode_property;
+
 	/**
 	 * @state:
 	 *
-- 
2.25.1



More information about the Intel-gfx-trybot mailing list