From patchwork Thu Feb 20 12:37:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sharma, Shashank" X-Patchwork-Id: 3686851 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 3244FBF13A for ; Thu, 20 Feb 2014 12:35:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5050C20114 for ; Thu, 20 Feb 2014 12:35:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7071120170 for ; Thu, 20 Feb 2014 12:35:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 10304FB23E; Thu, 20 Feb 2014 04:35:09 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 63EF2F9D86 for ; Thu, 20 Feb 2014 04:34:50 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 20 Feb 2014 04:30:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,512,1389772800"; d="scan'208";a="486539095" Received: from shashanks-desktop.iind.intel.com ([10.223.25.92]) by orsmga002.jf.intel.com with ESMTP; 20 Feb 2014 04:34:46 -0800 From: Shashank Sharma To: intel-gfx@lists.freedesktop.org Date: Thu, 20 Feb 2014 18:07:25 +0530 Message-Id: <1392899847-2641-5-git-send-email-shashank.sharma@intel.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1392899847-2641-1-git-send-email-shashank.sharma@intel.com> References: <1392899847-2641-1-git-send-email-shashank.sharma@intel.com> Cc: uma.shankar@intel.com Subject: [Intel-gfx] [PATCH 4/6] drm/i915: Color manager: brightness/contrast X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.8 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 This patch is third extension to color manager framework. It adds implementataion of color manager property "Brightness and Contrast correctio"n in intel color manager framework. Signed-off-by: Shashank Sharma --- drivers/gpu/drm/i915/intel_clrmgr.c | 98 ++++++++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_clrmgr.c b/drivers/gpu/drm/i915/intel_clrmgr.c index 1297e60..db13e2b 100644 --- a/drivers/gpu/drm/i915/intel_clrmgr.c +++ b/drivers/gpu/drm/i915/intel_clrmgr.c @@ -134,25 +134,119 @@ static int get_no_of_pipes(struct drm_device *dev) return 0; } +/* Check Sprite status */ +static bool is_sprite_enabled(struct drm_i915_private *dev_priv, + enum pipe pipe, enum plane plane) +{ + int reg; + u32 val; + + reg = SPCNTR(pipe, plane); + val = I915_READ(reg); + return val & SP_ENABLE; +} + static bool intel_clrmgr_disable_hs(struct drm_device *dev, int identifier) { return true; } -static bool intel_clrmgr_disable_cb(struct drm_device *dev, int identifier) +static bool intel_clrmgr_enable_hs(struct drm_device *dev, int identifier) { return true; } -static bool intel_clrmgr_enable_hs(struct drm_device *dev, int identifier) +/* Tune Contrast Brightness Value for Sprite */ +int intel_sprite_cb_adjust(struct drm_device *dev, + struct cont_brightlut *cb_ptr) +{ + drm_i915_private_t *dev_priv = dev->dev_private; + + if (!dev_priv || !cb_ptr) { + DRM_ERROR("Contrast Brightness: Invalid Arguments\n"); + return -EINVAL; + } + + switch (cb_ptr->sprite_no) { + /* Sprite plane */ + case sprite_a: + if (is_sprite_enabled(dev_priv, PIPE_A, SPRITE_PLANE_A)) + I915_WRITE(SPRITEA_CB_REG, cb_ptr->val); + break; + + case sprite_b: + if (is_sprite_enabled(dev_priv, PIPE_A, SPRITE_PLANE_B)) + I915_WRITE(SPRITEB_CB_REG, cb_ptr->val); + break; + + case sprite_c: + if (is_sprite_enabled(dev_priv, PIPE_B, SPRITE_PLANE_C)) + I915_WRITE(SPRITEC_CB_REG, cb_ptr->val); + break; + + case sprite_d: + if (is_sprite_enabled(dev_priv, PIPE_B, SPRITE_PLANE_D)) + I915_WRITE(SPRITED_CB_REG, cb_ptr->val); + break; + + default: + DRM_ERROR("Invalid Sprite Number\n"); + return -EINVAL; + } + + return 0; +} + +/* Disable correction for contrast/brightness */ +static bool intel_clrmgr_disable_cb(struct drm_device *dev, int identifier) { + struct cont_brightlut cb; + drm_i915_private_t *dev_priv = dev->dev_private; + struct clrmgr_pipe_status *pstatus = dev_priv->clrmgr_status.pstatus; + + if (!pstatus) { + DRM_ERROR("Clrmgr: color manager not initialized"); + return false; + } + + cb.sprite_no = identifier; + cb.val = CB_DEFAULT_VAL; + + if (intel_sprite_cb_adjust(dev, &cb)) { + DRM_ERROR("\nClrmgr: Contrast/Brigtness disable failed"); + return false; + } + + pstatus->cb_enabled = false; return true; + } + +/* Enable correction for contrast/brightness */ static bool intel_clrmgr_enable_cb(struct drm_device *dev, int identifier) { + struct cont_brightlut cb; + drm_i915_private_t *dev_priv = dev->dev_private; + struct clrmgr_pipe_status *pstatus = dev_priv->clrmgr_status.pstatus; + + if (!pstatus) { + DRM_ERROR("Clrmgr: color manager not initialized"); + return false; + } + + cb.sprite_no = identifier; + cb.val = clrmgr_luts[clrmgr_cb][CB_MAX_COEFF_COUNT-1]; + + if (intel_sprite_cb_adjust(dev, &cb)) { + DRM_ERROR("\nClrmgr: Contrast/Brigtness enable failed"); + return false; + } + + pstatus->cb_enabled = true; return true; } + /* Reset palette registers for gamma disabling */ static int intel_clrmgr_reset_lut(struct drm_device *dev) {