[Intel-gfx] [PATCH 01/11] drm/i915: Color manager framework for valleyview

shashank.sharma at intel.com shashank.sharma at intel.com
Wed Jul 23 20:04:55 CEST 2014


From: Shashank Sharma <shashank.sharma at intel.com>

Color manager is a framework which adds color correction
and tuning capabilities in I915 driver. This framework creates
DRM properties for each color correction property, and allows
userspace to tune the display appearance.

This is the first patch of the series, what this patch does is:
1. Create 2 new files
	intel_clrmgr.c
	intel_clrmgr.h
2. Add color manager init function, this functions allocates
   memory to save an array of color properties. This is called
   during the CRTC init and Plane init time.
3. Add color manager exit function. This function free's the
   memory allocated by init function, and registered color
   properties.
4. Some data structure definitions, in header.
Signed-off-by: Shashank Sharma <shashank.sharma at intel.com>
---
 drivers/gpu/drm/i915/Makefile       |  3 +-
 drivers/gpu/drm/i915/intel_clrmgr.c | 79 +++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_clrmgr.h | 83 +++++++++++++++++++++++++++++++++++++
 3 files changed, 164 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/i915/intel_clrmgr.c
 create mode 100644 drivers/gpu/drm/i915/intel_clrmgr.h

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 91bd167..7fa9c58 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -45,7 +45,8 @@ i915-y += intel_bios.o \
 	  intel_modes.o \
 	  intel_overlay.o \
 	  intel_sideband.o \
-	  intel_sprite.o
+	  intel_sprite.o \
+	  intel_clrmgr.o
 i915-$(CONFIG_ACPI)		+= intel_acpi.o intel_opregion.o
 i915-$(CONFIG_DRM_I915_FBDEV)	+= intel_fbdev.o
 
diff --git a/drivers/gpu/drm/i915/intel_clrmgr.c b/drivers/gpu/drm/i915/intel_clrmgr.c
new file mode 100644
index 0000000..09a168d
--- /dev/null
+++ b/drivers/gpu/drm/i915/intel_clrmgr.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ * ======
+ * Shashank Sharma <shashank.sharma at intel.com>
+ * Uma Shankar <uma.shankar at intel.com>
+ * Shobhit Kumar <shobhit.kumar at intel.com>
+ * Sonika Jindal <sonika.jindal at intel.com>
+ */
+
+#include "i915_drm.h"
+#include "i915_drv.h"
+#include "i915_reg.h"
+#include "intel_clrmgr.h"
+
+struct clrmgr_status *intel_clrmgr_init(struct drm_device *dev)
+{
+	struct clrmgr_status *status;
+
+	/* Todo: extend this framework for other gen devices also */
+	if (!IS_VALLEYVIEW(dev)) {
+		DRM_ERROR("Color manager is supported for VLV for now\n");
+		return NULL;
+	}
+
+	/* Allocate and attach color status tracker */
+	status = kzalloc(sizeof(struct clrmgr_status), GFP_KERNEL);
+	if (!status) {
+		DRM_ERROR("Out of memory, cant init color manager\n");
+		return NULL;
+	}
+	DRM_DEBUG_DRIVER("\n");
+	return status;
+}
+
+void intel_clrmgr_exit(struct drm_device *dev, struct clrmgr_status *status)
+{
+	u32 count = 0;
+	struct clrmgr_regd_prop *cp;
+
+	if (!status)
+		return;
+
+	/* First free the DRM property, then status */
+	while (count < status->no_of_properties) {
+		cp = status->cp[count++];
+
+		/* Destroy DRM property */
+		drm_property_destroy(dev, cp->property);
+
+		/* Release the color property */
+		kfree(status->cp[count]);
+		status->cp[count] = NULL;
+	}
+
+	/* Now free the status itself */
+	kfree(status);
+	DRM_DEBUG_DRIVER("\n");
+}
diff --git a/drivers/gpu/drm/i915/intel_clrmgr.h b/drivers/gpu/drm/i915/intel_clrmgr.h
new file mode 100644
index 0000000..6a36c8d
--- /dev/null
+++ b/drivers/gpu/drm/i915/intel_clrmgr.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ * =====
+ * Shashank Sharma <shashank.sharma at intel.com>
+ * Uma Shankar <uma.shankar at intel.com>
+ * Shobhit Kumar <shobhit.kumar at intel.com>
+ * Sonika Jindal <sonika.jindal at intel.com>
+ */
+
+#ifndef _I915_CLR_MNGR_H_
+#define _I915_CLR_MNGR_H_
+
+#include "drmP.h"
+#include "intel_drv.h"
+#include <linux/errno.h>
+
+/* Framework defs */
+#define CLRMGR_PROP_MAX				10
+
+/*
+* clrmgr_regd_propery structure
+* This structure encapsulates drm_property, and some
+* additional values which are required during the runtime
+* after registration, to set a value.
+*/
+struct clrmgr_regd_prop {
+	bool enabled;
+	struct drm_property *property;
+	/*
+	* A void * is first arg, so that the same function ptr can be used
+	* for both crtc_property and plane_property
+	*/
+	bool (*set_property)(void *,
+		struct clrmgr_regd_prop *prop, u64 *data);
+};
+
+/* Status of color properties on pipe at any time */
+struct clrmgr_status {
+	u32 no_of_properties;
+	struct clrmgr_regd_prop *cp[CLRMGR_PROP_MAX];
+};
+
+
+/*
+* intel_clrmgr_init:
+* Allocate memory to save color correction
+* properties for that CRTC.
+* input: struct drm_device
+*/
+struct clrmgr_status *intel_clrmgr_init(struct drm_device *dev);
+
+/*
+* intel_clrmgr_exit
+* Free allocated memory for color status
+* Should be called from CRTC/Plane .destroy function
+* input:
+* - drm_device *
+* - status : color status on that CRTC/Plane
+*/
+void intel_clrmgr_exit(struct drm_device *dev, struct clrmgr_status *status);
+
+#endif
-- 
1.9.1




More information about the Intel-gfx mailing list