From patchwork Wed Mar 19 00:22:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Roper X-Patchwork-Id: 3849951 Return-Path: X-Original-To: patchwork-dri-devel@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 5C5DB9F38E for ; Wed, 19 Mar 2014 00:22:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4BFD620386 for ; Wed, 19 Mar 2014 00:22:07 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7FEC520394 for ; Wed, 19 Mar 2014 00:22:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D71F14A1F4; Tue, 18 Mar 2014 17:22:00 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id E5DA84A201; Tue, 18 Mar 2014 17:21:57 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 18 Mar 2014 17:17:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,681,1389772800"; d="scan'208";a="502684241" Received: from mdroper-hswdev.fm.intel.com (HELO mdroper-hswdev) ([10.1.134.215]) by orsmga002.jf.intel.com with ESMTP; 18 Mar 2014 17:21:57 -0700 Received: from mattrope by mdroper-hswdev with local (Exim 4.82) (envelope-from ) id 1WQ4I6-0004W5-92; Tue, 18 Mar 2014 17:23:30 -0700 From: Matt Roper To: dri-devel@lists.freedesktop.org Subject: [RFCv3 14/14] drm/i915: Add cursor handlers and create cursor at crtc init Date: Tue, 18 Mar 2014 17:22:59 -0700 Message-Id: <1395188579-17191-15-git-send-email-matthew.d.roper@intel.com> X-Mailer: git-send-email 1.8.5.1 In-Reply-To: <1395188579-17191-1-git-send-email-matthew.d.roper@intel.com> References: <1395188579-17191-1-git-send-email-matthew.d.roper@intel.com> Cc: Intel Graphics Development X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 Cc: Intel Graphics Development Signed-off-by: Matt Roper --- drivers/gpu/drm/i915/intel_display.c | 90 +++++++++++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index f661469..36bee38 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -10781,11 +10781,98 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev, return &primary->base; } +static int +intel_cursor_plane_update(struct drm_plane *plane, struct drm_crtc *crtc, + struct drm_framebuffer *fb, int crtc_x, int crtc_y, + unsigned int crtc_w, unsigned int crtc_h, + uint32_t src_x, uint32_t src_y, + uint32_t src_w, uint32_t src_h) +{ + int ret; + + /* setplane API takes shifted source rectangle values; unshift them */ + src_x >>= 16; + src_y >>= 16; + src_w >>= 16; + src_h >>= 16; + + /* Cursor planes are locked to their owning CRTC */ + if (plane->possible_crtcs != drm_crtc_mask(crtc)) { + DRM_DEBUG_KMS("Cannot change cursor plane CRTC\n"); + return -EINVAL; + } + + /* Current hardware can't scale the cursor plane. */ + if (crtc_w != src_w || crtc_h != src_h) { + DRM_DEBUG_KMS("Can't scale cursor plane\n"); + return -EINVAL; + } + + ret = cursor_set_common(crtc, crtc->cursor, fb); + if (ret) + return ret; + + intel_crtc_cursor_move(crtc, crtc_x, crtc_y); + intel_crtc_update_cursor(crtc, fb); + + return 0; +} + +static int +intel_cursor_plane_disable(struct drm_plane *plane) +{ + if (!plane->fb) + return 0; + + BUG_ON(!plane->crtc); + + return cursor_set_common(plane->crtc, plane, NULL); +} + +static void intel_cursor_plane_destroy(struct drm_plane *plane) +{ + struct intel_plane *intel_plane = to_intel_plane(plane); + intel_cursor_plane_disable(plane); + drm_plane_cleanup(plane); + kfree(intel_plane); +} + +static const struct drm_plane_funcs intel_cursor_plane_funcs = { + .update_plane = intel_cursor_plane_update, + .disable_plane = intel_cursor_plane_disable, + .destroy = intel_cursor_plane_destroy, +}; + +static const uint32_t cursor_formats[] = { + DRM_FORMAT_ARGB8888, +}; + +static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev, + int pipe) +{ + struct intel_plane *cursor; + + cursor = kzalloc(sizeof(*cursor), GFP_KERNEL); + if (cursor == NULL) + return NULL; + + cursor->can_scale = false; + cursor->pipe = pipe; + cursor->plane = pipe; + + drm_plane_init(dev, &cursor->base, 0, + &intel_cursor_plane_funcs, cursor_formats, + ARRAY_SIZE(cursor_formats), + DRM_PLANE_TYPE_CURSOR); + return &cursor->base; +} + static void intel_crtc_init(struct drm_device *dev, int pipe) { drm_i915_private_t *dev_priv = dev->dev_private; struct intel_crtc *intel_crtc; struct drm_plane *primary; + struct drm_plane *cursor; int i, ret; intel_crtc = kzalloc(sizeof(*intel_crtc), GFP_KERNEL); @@ -10793,7 +10880,8 @@ static void intel_crtc_init(struct drm_device *dev, int pipe) return; primary = intel_primary_plane_create(dev, pipe); - ret = drm_crtc_init(dev, &intel_crtc->base, primary, NULL, + cursor = intel_cursor_plane_create(dev, pipe); + ret = drm_crtc_init(dev, &intel_crtc->base, primary, cursor, &intel_crtc_funcs); if (ret) { drm_crtc_cleanup(&intel_crtc->base);