From patchwork Mon May 5 18:14:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sagar.a.kamble@intel.com X-Patchwork-Id: 4116611 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 A54169F23C for ; Mon, 5 May 2014 18:13:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B505820219 for ; Mon, 5 May 2014 18:13:30 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B2C6520149 for ; Mon, 5 May 2014 18:13:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 51F0E6E081; Mon, 5 May 2014 11:13:29 -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 5F8516E081 for ; Mon, 5 May 2014 11:13:27 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 05 May 2014 11:13:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,990,1389772800"; d="scan'208";a="526354933" Received: from sagar-desktop.iind.intel.com ([10.223.82.31]) by fmsmga001.fm.intel.com with ESMTP; 05 May 2014 11:13:24 -0700 From: sagar.a.kamble@intel.com To: intel-gfx@lists.freedesktop.org Date: Mon, 5 May 2014 23:44:03 +0530 Message-Id: <1399313644-31625-3-git-send-email-sagar.a.kamble@intel.com> X-Mailer: git-send-email 1.8.5 In-Reply-To: <1399313644-31625-1-git-send-email-sagar.a.kamble@intel.com> References: <1399313644-31625-1-git-send-email-sagar.a.kamble@intel.com> Cc: ankitprasad.r.sharma@intel.com, daniel.vetter@ffwll.ch, shashidhar.hiremath@intel.com, vandita.kulkarni@intel.com, Sagar Kamble Subject: [Intel-gfx] [PATCH v1 2/3] drm/i915: Enabling constant alpha drm property 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.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 From: Sagar Kamble Testcase: kms_plane_props Cc: daniel.vetter@ffwll.ch Cc: jani.nikula@linux.intel.com Cc: ville.syrjala@linux.intel.com Cc: indranil.mukherjee@intel.com Cc: shashidhar.hiremath@intel.com Cc: vandita.kulkarni@intel.com Cc: vijay.a.purushothaman@intel.com Cc: ankitprasad.r.sharma@intel.com Signed-off-by: Sagar Kamble --- drivers/gpu/drm/i915/i915_dma.c | 9 +++++++++ drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_sprite.c | 34 +++++++++++++++++++++++++++++++++- 5 files changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 191c5e6..bd6ca0a 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c @@ -1896,6 +1896,7 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file) void i915_driver_lastclose(struct drm_device * dev) { struct drm_i915_private *dev_priv = dev->dev_private; + struct intel_plane *plane; /* On gen6+ we refuse to init without kms enabled, but then the drm core * goes right around and calls lastclose. Check for this and don't clean @@ -1904,6 +1905,14 @@ void i915_driver_lastclose(struct drm_device * dev) return; /* Restore drm properties if any to their default values */ + if (dev_priv->const_alpha_property) { + list_for_each_entry(plane, &dev->mode_config.plane_list, base.head) { + plane->const_alpha = 255; + drm_object_property_set_value(&plane->base.base, + dev_priv->const_alpha_property, + plane->const_alpha); + } + } if (drm_core_check_feature(dev, DRIVER_MODESET)) { intel_fbdev_restore_mode(dev); diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index ec82f6b..7b3d430 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1587,6 +1587,7 @@ typedef struct drm_i915_private { struct drm_property *broadcast_rgb_property; struct drm_property *force_audio_property; + struct drm_property *const_alpha_property; uint32_t hw_context_size; struct list_head context_list; diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 9f5b18d..db91c53 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -3780,6 +3780,7 @@ enum punit_power_well { #define SPRITE_INT_GAMMA_ENABLE (1<<13) #define SPRITE_TILED (1<<10) #define SPRITE_DEST_KEY (1<<2) +#define SPRITE_CONSTANT_ALPHA_ENABLE (1<<31) #define _SPRA_LINOFF 0x70284 #define _SPRA_STRIDE 0x70288 #define _SPRA_POS 0x7028c diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index bfc8073..777942d 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -416,6 +416,7 @@ struct intel_plane { unsigned int crtc_w, crtc_h; uint32_t src_x, src_y; uint32_t src_w, src_h; + uint8_t const_alpha; /* Since we need to change the watermarks before/after * enabling/disabling the planes, we need to store the parameters here diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c index c46e18d..cc7efe1 100644 --- a/drivers/gpu/drm/i915/intel_sprite.c +++ b/drivers/gpu/drm/i915/intel_sprite.c @@ -51,10 +51,12 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc, int pipe = intel_plane->pipe; int plane = intel_plane->plane; u32 sprctl; + u32 sprconstalpha; unsigned long sprsurf_offset, linear_offset; int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); sprctl = I915_READ(SPCNTR(pipe, plane)); + sprconstalpha = SPCONSTALPHA(pipe, plane); /* Mask out pixel format bits in case we change it */ sprctl &= ~SP_PIXFORMAT_MASK; @@ -104,6 +106,7 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc, break; } + I915_WRITE(sprconstalpha, (intel_plane->const_alpha | SPRITE_CONSTANT_ALPHA_ENABLE)); /* * Enable gamma to match primary/cursor plane behaviour. * FIXME should be user controllable via propertiesa. @@ -1015,7 +1018,22 @@ static int intel_plane_set_property(struct drm_plane *plane, struct drm_property *prop, uint64_t val) { + struct drm_i915_private *dev_priv = plane->dev->dev_private; + struct intel_plane *intel_plane = to_intel_plane(plane); int ret = -EINVAL; + uint8_t old_val = 255; + + if (prop == dev_priv->const_alpha_property) { + if (val >= 0 && val <= 255) { + old_val = intel_plane->const_alpha; + intel_plane->const_alpha = val & 0xFF; + ret = intel_plane_restore(plane); + if (ret) + intel_plane->const_alpha = old_val; + } else + DRM_ERROR("Invalid alpha value supplied\n"); + } + return ret; } @@ -1087,6 +1105,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) const uint32_t *plane_formats; int num_plane_formats; int ret; + struct drm_i915_private *dev_priv = dev->dev_private; if (INTEL_INFO(dev)->gen < 5) return -ENODEV; @@ -1148,6 +1167,8 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) return -ENODEV; } + intel_plane->const_alpha = 255; + intel_plane->pipe = pipe; intel_plane->plane = plane; possible_crtcs = (1 << pipe); @@ -1155,8 +1176,19 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) &intel_plane_funcs, plane_formats, num_plane_formats, false); - if (ret) + if (ret) { kfree(intel_plane); + goto out; + } + + if (!dev_priv->const_alpha_property) + dev_priv->const_alpha_property = drm_property_create_range(dev, 0, + "const-alpha", 0, 255); + if (dev_priv->const_alpha_property) + drm_object_attach_property(&intel_plane->base.base, + dev_priv->const_alpha_property, + intel_plane->const_alpha); +out: return ret; }