From patchwork Wed Jul 23 18:05:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sharma, Shashank" X-Patchwork-Id: 4612491 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F041AC0514 for ; Wed, 23 Jul 2014 18:02:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3295C20103 for ; Wed, 23 Jul 2014 18:02:19 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id F2E03201C7 for ; Wed, 23 Jul 2014 18:02:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 60B916E68B; Wed, 23 Jul 2014 11:02:12 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id 5787D6E68B for ; Wed, 23 Jul 2014 11:02:11 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 23 Jul 2014 11:01:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,718,1400050800"; d="scan'208";a="574341377" Received: from shashanks-desktop.iind.intel.com ([10.223.26.11]) by fmsmga002.fm.intel.com with ESMTP; 23 Jul 2014 11:00:54 -0700 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 Date: Wed, 23 Jul 2014 23:35:03 +0530 Message-Id: <1406138705-17334-10-git-send-email-shashank.sharma@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1406138705-17334-1-git-send-email-shashank.sharma@intel.com> References: <1406138705-17334-1-git-send-email-shashank.sharma@intel.com> Cc: =indranil.mukherjee@intel.com Subject: [Intel-gfx] [PATCH 09/11] drm/i915: Add set plane property functions X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Shashank Sharma Color manager's plane level correction properties are registered as plane property. So its required to have a .set_property function in plane functions. This patch adds: 1. A .set_property function for intel_plane, intel_plane_set_property which checks if a plane property is of type color property, it calls color manager's plane level set_property handler function. 2. A intel_clrmgr_set_plane_property, which will extract the data to be set, and then pass it to appropriate set_property function Signed-off-by: Shashank Sharma --- drivers/gpu/drm/i915/intel_clrmgr.c | 47 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_clrmgr.h | 11 +++++++++ drivers/gpu/drm/i915/intel_sprite.c | 41 ++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) diff --git a/drivers/gpu/drm/i915/intel_clrmgr.c b/drivers/gpu/drm/i915/intel_clrmgr.c index eb18ee2..d0d952b 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_plane_property(struct intel_plane *intel_plane, + 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_plane, 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; +} + bool intel_clrmgr_set_pipe_property(struct intel_crtc *intel_crtc, struct clrmgr_regd_prop *cp, uint64_t value) { diff --git a/drivers/gpu/drm/i915/intel_clrmgr.h b/drivers/gpu/drm/i915/intel_clrmgr.h index d962585..c1de823 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_plane_property +* Set value of a registered plane property +* input: +* - intel_plane: the plane with which the property is attached +* - cp: registered color property +* - value: value to be set +*/ +bool intel_clrmgr_set_plane_property(struct intel_plane *intel_plane, + struct clrmgr_regd_prop *cp, uint64_t value); + +/* * intel_clrmgr_set_pipe_property * Set value of a registered CRTC property * input: diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c index 168c665..affb429 100644 --- a/drivers/gpu/drm/i915/intel_sprite.c +++ b/drivers/gpu/drm/i915/intel_sprite.c @@ -36,6 +36,7 @@ #include "intel_drv.h" #include #include "i915_drv.h" +#include "intel_clrmgr.h" static int usecs_to_scanlines(const struct drm_display_mode *mode, int usecs) { @@ -1180,6 +1181,45 @@ out_unlock: return ret; } +int intel_plane_set_property(struct drm_plane *plane, + struct drm_property *property, uint64_t val) +{ + int ret = 0; + int count = 0; + struct clrmgr_regd_prop *cp; + struct intel_plane *intel_plane = to_intel_plane(plane); + struct clrmgr_status *status = intel_plane->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 manager property */ + while (count < status->no_of_properties) { + cp = status->cp[count++]; + if (property == cp->property) { + /* Found it, now set it */ + if (intel_clrmgr_set_plane_property(intel_plane, + 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; +} + void intel_plane_restore(struct drm_plane *plane) { struct intel_plane *intel_plane = to_intel_plane(plane); @@ -1206,6 +1246,7 @@ static const struct drm_plane_funcs intel_plane_funcs = { .update_plane = intel_update_plane, .disable_plane = intel_disable_plane, .destroy = intel_destroy_plane, + .set_property = intel_plane_set_property }; static uint32_t ilk_plane_formats[] = {