All of lore.kernel.org
 help / color / mirror / Atom feed
From: shashank.sharma@intel.com
To: intel-gfx@lists.freedesktop.org, ville.syrjala@linux.intel.com,
	damien.lespiau@intel.com, daniel.vetter@intel.com,
	shobhit.kumar@intel.com, satheeshakrishna.m@intel.com
Cc: =indranil.mukherjee@intel.com
Subject: [PATCH 08/11] drm/i915: Add CRTC set property functions
Date: Wed, 23 Jul 2014 23:35:02 +0530	[thread overview]
Message-ID: <1406138705-17334-9-git-send-email-shashank.sharma@intel.com> (raw)
In-Reply-To: <1406138705-17334-1-git-send-email-shashank.sharma@intel.com>

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

Color manager's pipe level correction properties are
registered as CRTC property. So its required to have a
.set_crtc function in CRTC functions.

This patch adds:
1. A .set_property function for intel_crtc, intel_crtc_set_property
   which checks if a CRTC property is of type color property, it
   calls color manager's pipe level set_property handler function.
2. A intel_clrmgr_set_pipe_property, which will extract the data
   to be set, and then pass it to appropriate set_property function.

Signed-off-by: Shashank Sharma <shashank.sharma@intel.com>
---
 drivers/gpu/drm/i915/intel_clrmgr.c  | 47 ++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_clrmgr.h  | 11 +++++++++
 drivers/gpu/drm/i915/intel_display.c | 45 ++++++++++++++++++++++++++++++++++
 3 files changed, 103 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_clrmgr.c b/drivers/gpu/drm/i915/intel_clrmgr.c
index a4c8f0f..eb18ee2 100644
--- a/drivers/gpu/drm/i915/intel_clrmgr.c
+++ b/drivers/gpu/drm/i915/intel_clrmgr.c
@@ -654,6 +654,53 @@ intel_attach_pipe_color_correction(struct intel_crtc *intel_crtc)
 	kfree(features);
 }
 
+bool intel_clrmgr_set_pipe_property(struct intel_crtc *intel_crtc,
+		struct clrmgr_regd_prop *cp, uint64_t value)
+{
+	bool ret = false;
+	uint64_t *data;
+	struct drm_property *property;
+
+	/* Sanity */
+	if (!cp->property) {
+		DRM_ERROR("NULL input to set_property\n");
+		return false;
+	}
+
+	property = cp->property;
+	DRM_DEBUG_DRIVER("Property %s len:%d\n",
+		cp->property->name, cp->property->num_values);
+	data = kmalloc(sizeof(uint64_t) * (property->num_values), GFP_KERNEL);
+	if (!data) {
+		DRM_ERROR("Out of memory\n");
+		return false;
+	}
+
+	if (copy_from_user((void *)data, (const void __user *)value,
+			property->num_values * sizeof(uint64_t))) {
+		DRM_ERROR("Failed to copy all data\n");
+		ret = false;
+		goto free_and_return;
+	}
+
+	/* Now do the actual work */
+	if (cp->set_property) {
+		if (!cp->set_property((void *)intel_crtc, cp, data)) {
+			DRM_ERROR("Set property for %s failed\n",
+					cp->property->name);
+			ret = false;
+		} else {
+			ret = true;
+			cp->enabled = true;
+			DRM_DEBUG_DRIVER("Set property %s successful\n",
+				cp->property->name);
+		}
+	}
+free_and_return:
+	kfree(data);
+	return ret;
+}
+
 struct clrmgr_status *intel_clrmgr_init(struct drm_device *dev)
 {
 	struct clrmgr_status *status;
diff --git a/drivers/gpu/drm/i915/intel_clrmgr.h b/drivers/gpu/drm/i915/intel_clrmgr.h
index 6d316d2..d962585 100644
--- a/drivers/gpu/drm/i915/intel_clrmgr.h
+++ b/drivers/gpu/drm/i915/intel_clrmgr.h
@@ -212,6 +212,17 @@ bool intel_clrmgr_set_csc(void *crtc,
 	struct clrmgr_regd_prop *csc, u64 *data);
 
 /*
+* intel_clrmgr_set_pipe_property
+* Set value of a registered CRTC property
+* input:
+* - intel_crtc: the CRTC with which the property is attached
+* - cp: registered color property
+* - value: value to be set
+*/
+bool intel_clrmgr_set_pipe_property(struct intel_crtc *intel_crtc,
+		struct clrmgr_regd_prop *cp, uint64_t value);
+
+/*
 * intel_clrmgr_register_pipe_property
 * register set of properties with a CRTC
 * input:
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 99eb7ca..a6181b5 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -42,6 +42,7 @@
 #include <drm/drm_plane_helper.h>
 #include <drm/drm_rect.h>
 #include <linux/dma_remapping.h>
+#include "intel_clrmgr.h"
 
 /* Primary plane formats supported by all gen */
 #define COMMON_PRIMARY_FORMATS \
@@ -8438,6 +8439,49 @@ mode_fits_in_fbdev(struct drm_device *dev,
 #endif
 }
 
+/*
+* intel_crtc_set_property
+* Set a CRTC property, like color tweaks
+*/
+static int intel_crtc_set_property(struct drm_crtc *crtc,
+			    struct drm_property *property, uint64_t val)
+{
+	int ret = 0;
+	int count = 0;
+	struct clrmgr_regd_prop *cp;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	struct clrmgr_status *status = intel_crtc->color_status;
+
+	DRM_DEBUG_DRIVER("\n");
+
+	/* Is this color property ?*/
+	if (!status) {
+		DRM_DEBUG_DRIVER("Color manager not initialized\n");
+		ret = -1;
+		goto skip_color;
+	}
+
+	/* Color correction property */
+	while (count < status->no_of_properties) {
+		cp = status->cp[count++];
+		if (property == cp->property) {
+			/* Found it, now set it */
+			if (intel_clrmgr_set_pipe_property(intel_crtc,
+				cp, val)) {
+				DRM_DEBUG_DRIVER("Set property %s successful\n",
+					property->name);
+				return 0;
+			} else {
+				DRM_ERROR("Set CRTC property %s failed\n",
+					property->name);
+				return -1;
+			}
+		}
+	}
+skip_color:
+	return ret;
+}
+
 bool intel_get_load_detect_pipe(struct drm_connector *connector,
 				struct drm_display_mode *mode,
 				struct intel_load_detect_pipe *old,
@@ -11347,6 +11391,7 @@ static const struct drm_crtc_funcs intel_crtc_funcs = {
 	.set_config = intel_crtc_set_config,
 	.destroy = intel_crtc_destroy,
 	.page_flip = intel_crtc_page_flip,
+	.set_property = intel_crtc_set_property,
 };
 
 static bool ibx_pch_dpll_get_hw_state(struct drm_i915_private *dev_priv,
-- 
1.9.1

  parent reply	other threads:[~2014-07-23 18:01 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-23 18:04 [PATCH 00/11]: Color manager framework for I915 driver shashank.sharma
2014-07-23 18:04 ` [PATCH 01/11] drm/i915: Color manager framework for valleyview shashank.sharma
2014-07-23 18:04 ` [PATCH 02/11] drm/i915: Register pipe level color properties shashank.sharma
2014-07-25  0:02   ` Matt Roper
2014-07-23 18:04 ` [PATCH 03/11] drm/i915: Register plane " shashank.sharma
2014-07-23 18:04 ` [PATCH 04/11] drm/i915: Add color manager CSC correction shashank.sharma
2014-07-23 18:04 ` [PATCH 05/11] drm/i915: Add color manager gamma correction shashank.sharma
2014-07-23 18:05 ` [PATCH 06/11] drm/i915: Add contrast and brightness correction shashank.sharma
2014-07-23 18:05 ` [PATCH 07/11] drm/i915: Add hue and saturation correction shashank.sharma
2014-07-23 18:05 ` shashank.sharma [this message]
2014-07-23 18:05 ` [PATCH 09/11] drm/i915: Add set plane property functions shashank.sharma
2014-07-23 18:05 ` [PATCH 10/11] drm/i915: Plug-in color manager init shashank.sharma
2014-07-23 18:05 ` [PATCH 11/11] drm/i915: Plug-in color manager exit shashank.sharma
2014-07-23 18:34 ` [PATCH 00/11]: Color manager framework for I915 driver Daniel Vetter
2014-07-24  4:08   ` Sharma, Shashank
2014-07-25  0:43     ` Matt Roper
2014-07-25  4:36       ` Sharma, Shashank
2014-07-26  1:58         ` Matt Roper
2014-07-28  4:57           ` Sharma, Shashank
2014-09-09  6:23           ` [PATCH 0/4] Color manager framework shashank.sharma
2014-09-09  6:23             ` [PATCH 1/4] drm/i915: Color manager framework for valleyview shashank.sharma
2014-09-09 22:51               ` Bob Paauwe
2014-09-10  8:40                 ` Sharma, Shashank
2014-09-10 16:25                   ` Bob Paauwe
2014-09-10  1:29               ` Matt Roper
2014-09-10 11:20                 ` Sharma, Shashank
2014-09-10 21:17                   ` Matt Roper
2014-09-11  7:52                     ` Daniel Vetter
2014-09-09  6:23             ` [PATCH 2/4] drm/i915: Plug-in color manager attach shashank.sharma
2014-09-10  1:29               ` Matt Roper
2014-09-10 11:52                 ` Sharma, Shashank
2014-09-09  6:23             ` [PATCH 3/4] drm/i915: CSC color correction shashank.sharma
2014-09-09 22:51               ` Bob Paauwe
2014-09-10  8:55                 ` Sharma, Shashank
2014-09-10 16:03                   ` Bob Paauwe
2014-09-10  1:30               ` Matt Roper
2014-09-10  6:40                 ` Daniel Vetter
2014-09-10 12:05                   ` Sharma, Shashank
2014-09-10 12:13                     ` Daniel Vetter
2014-09-10 22:17               ` Matt Roper
2014-09-11  7:53                 ` Daniel Vetter
2014-09-09  6:23             ` [PATCH 4/4] drm/i915: Add set_protpery function shashank.sharma
2014-09-10  1:28             ` [PATCH 0/4] Color manager framework Matt Roper
2014-09-10 11:08               ` Sharma, Shashank
2014-09-10 18:15                 ` Matt Roper
2014-09-11  7:56                   ` Daniel Vetter
2014-09-11  8:18                     ` Sharma, Shashank
2014-09-11  8:49                       ` Daniel Vetter
2014-09-11  9:23                         ` Ville Syrjälä

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=1406138705-17334-9-git-send-email-shashank.sharma@intel.com \
    --to=shashank.sharma@intel.com \
    --cc==indranil.mukherjee@intel.com \
    --cc=damien.lespiau@intel.com \
    --cc=daniel.vetter@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=satheeshakrishna.m@intel.com \
    --cc=shobhit.kumar@intel.com \
    --cc=ville.syrjala@linux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.