From patchwork Wed Jul 23 18:04:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Sharma, Shashank" X-Patchwork-Id: 4612391 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 338609F2B8 for ; Wed, 23 Jul 2014 18:01:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 63B6C201C0 for ; Wed, 23 Jul 2014 18:01:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7660A20103 for ; Wed, 23 Jul 2014 18:01:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AE4686E2E8; Wed, 23 Jul 2014 11:01:32 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 217246E373 for ; Wed, 23 Jul 2014 11:01:32 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 23 Jul 2014 11:01:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,718,1400050800"; d="scan'208";a="574340781" Received: from shashanks-desktop.iind.intel.com ([10.223.26.11]) by fmsmga002.fm.intel.com with ESMTP; 23 Jul 2014 11:00:28 -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:34:55 +0530 Message-Id: <1406138705-17334-2-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> MIME-Version: 1.0 Cc: =indranil.mukherjee@intel.com Subject: [Intel-gfx] [PATCH 01/11] drm/i915: Color manager framework for valleyview 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: , 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 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 --- 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 + * Uma Shankar + * Shobhit Kumar + * Sonika Jindal + */ + +#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 + * Uma Shankar + * Shobhit Kumar + * Sonika Jindal + */ + +#ifndef _I915_CLR_MNGR_H_ +#define _I915_CLR_MNGR_H_ + +#include "drmP.h" +#include "intel_drv.h" +#include + +/* 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