From patchwork Wed Jul 23 18:04:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sharma, Shashank" X-Patchwork-Id: 4612421 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 203EE9F2B8 for ; Wed, 23 Jul 2014 18:01:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9093E201C7 for ; Wed, 23 Jul 2014 18:01:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id ACCBF20103 for ; Wed, 23 Jul 2014 18:01:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 554B06E373; Wed, 23 Jul 2014 11:01:50 -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 A55456E373 for ; Wed, 23 Jul 2014 11:01:48 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 23 Jul 2014 11:01:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,718,1400050800"; d="scan'208";a="574340949" Received: from shashanks-desktop.iind.intel.com ([10.223.26.11]) by fmsmga002.fm.intel.com with ESMTP; 23 Jul 2014 11:00:34 -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:57 +0530 Message-Id: <1406138705-17334-4-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 03/11] drm/i915: Register plane level color properties 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 In valleyview we have three possible sprite plane level color correction: 1. Contrast 2. Brightness What this patch does: 1. This patch adds software infrastructure to register plane level color correction properties per plane. Adding a new function, intel_attach_plane_color_correction to register the plane level color correction properties. 2. Adding a pointer in intel_plane structure to store this property. 3. Adding structure gen6_plane_color_corrections, which contains different plane level correction values for VLV. Signed-off-by: Shashank Sharma --- drivers/gpu/drm/i915/intel_clrmgr.c | 125 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_clrmgr.h | 8 +++ drivers/gpu/drm/i915/intel_drv.h | 3 + 3 files changed, 136 insertions(+) diff --git a/drivers/gpu/drm/i915/intel_clrmgr.c b/drivers/gpu/drm/i915/intel_clrmgr.c index 8d02a62..0aa3734 100644 --- a/drivers/gpu/drm/i915/intel_clrmgr.c +++ b/drivers/gpu/drm/i915/intel_clrmgr.c @@ -53,6 +53,41 @@ struct clrmgr_property gen6_pipe_color_corrections[] = { }, }; +/* +* Gen6 plane level properties: +* - Contrast adjustment for all sprite planes. +* - Brightness adjustment for all sprite planes. +* - Hue and Saturation adjustment for all sprite planes. +*/ +struct clrmgr_property gen6_plane_color_corrections[] = { + + { + .tweak_id = contrast, + .type = DRM_MODE_PROP_RANGE, + .max = CLRMGR_PROP_RANGE_MAX, + .min = 0, + .len = VLV_CB_MAX_VALS, + .name = "contrast", + }, + { + .tweak_id = brightness, + .type = DRM_MODE_PROP_RANGE, + .max = CLRMGR_PROP_RANGE_MAX, + .min = 0, + .len = VLV_CB_MAX_VALS, + .name = "brightness", + }, + { + .tweak_id = hue_saturation, + .type = DRM_MODE_PROP_RANGE, + .max = CLRMGR_PROP_RANGE_MAX, + .min = 0, + .len = VLV_HS_MAX_VALS, + .name = "hue-saturation", + } +}; + + struct drm_property *intel_clrmgr_register(struct drm_device *dev, struct drm_mode_object *obj, struct clrmgr_property *cp) { @@ -92,6 +127,96 @@ error: return NULL; } +bool intel_clrmgr_register_plane_property(struct intel_plane *intel_plane, + struct clrmgr_reg_request *features) +{ + u32 count = 0; + struct clrmgr_property *cp; + struct clrmgr_regd_prop *regd_property; + struct drm_property *property; + struct drm_device *dev = intel_plane->base.dev; + struct drm_mode_object *obj = &intel_plane->base.base; + struct clrmgr_status *status = intel_plane->color_status; + + /* Color manager initialized? */ + if (!status) { + DRM_ERROR("Register request without plane init ?\n"); + return false; + } + + /* Validate input */ + if (!features || !features->no_of_properties) { + DRM_ERROR("Invalid input to register plane property\n"); + return false; + } + + /* Create drm property */ + while (count < features->no_of_properties) { + cp = &features->cp[count++]; + property = intel_clrmgr_register(dev, obj, cp); + if (!property) { + DRM_ERROR("Failed to register property %s\n", + property->name); + goto error; + } + + /* Add the property in global pipe status */ + regd_property = kzalloc(sizeof(struct clrmgr_regd_prop), + GFP_KERNEL); + regd_property->property = property; + regd_property->enabled = false; + regd_property->set_property = cp->set_property; + status->cp[status->no_of_properties++] = regd_property; + } + + /* Successfully registered all */ + DRM_DEBUG_DRIVER("Registered color properties on plane %d\n", + intel_plane->plane); + return true; + +error: + if (--count) { + DRM_ERROR("Can only register following properties:\n"); + while (count--) + DRM_ERROR("%s", status->cp[count]->property->name); + } else + DRM_ERROR("Can not register any property\n"); + return false; +} + +void +intel_attach_plane_color_correction(struct intel_plane *intel_plane) +{ + struct clrmgr_reg_request *features; + + /* Color manager initialized? */ + if (!intel_plane->color_status) { + DRM_ERROR("Color manager not initialized for plane %d\n", + intel_plane->plane); + return; + } + + DRM_DEBUG_DRIVER("\n"); + features = kzalloc(sizeof(struct clrmgr_reg_request), GFP_KERNEL); + if (!features) { + DRM_ERROR("No memory for plane color features\n"); + return; + } + + features->no_of_properties = ARRAY_SIZE(gen6_plane_color_corrections); + memcpy(features->cp, gen6_plane_color_corrections, + features->no_of_properties * + sizeof(struct clrmgr_property)); + + /* Register plane level color properties */ + if (!intel_clrmgr_register_plane_property(intel_plane, features)) + DRM_ERROR("Register plane color property failed\n"); + else + DRM_DEBUG_DRIVER("Attached colot corrections for plane %d\n", + intel_plane->plane); + kfree(features); +} + bool intel_clrmgr_register_pipe_property(struct intel_crtc *intel_crtc, struct clrmgr_reg_request *features) diff --git a/drivers/gpu/drm/i915/intel_clrmgr.h b/drivers/gpu/drm/i915/intel_clrmgr.h index 7cb2798..28fea24 100644 --- a/drivers/gpu/drm/i915/intel_clrmgr.h +++ b/drivers/gpu/drm/i915/intel_clrmgr.h @@ -38,6 +38,8 @@ /* Framework defs */ #define CLRMGR_PROP_MAX 10 #define CLRMGR_PROP_NAME_MAX 128 +#define CLRMGR_PROP_RANGE_MAX 0xFFFFFFFFFFFFFFFF + /* CSC / Wide gamut */ #define VLV_CSC_MATRIX_MAX_VALS 9 @@ -48,6 +50,12 @@ #define VLV_10BIT_GAMMA_MAX_VALS (VLV_10BIT_GAMMA_MAX_INDEX + \ CLRMGR_GAMMA_GCMAX_VAL) +/* Sprite Contrast and Brightness Registers */ +#define VLV_CB_MAX_VALS 1 + +/* Sprite Hue and Saturation Registers */ +#define VLV_HS_MAX_VALS 1 + /* Color manager features */ enum clrmgr_tweaks { csc = 0, diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 698801a..ed35cdf 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -474,6 +474,9 @@ struct intel_plane { struct drm_intel_sprite_colorkey *key); void (*get_colorkey)(struct drm_plane *plane, struct drm_intel_sprite_colorkey *key); + + /* color-correction */ + struct clrmgr_status *color_status; }; struct intel_watermark_params {