From patchwork Mon Sep 10 03:03:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 11263 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 5468023E00 for ; Mon, 10 Sep 2012 03:05:34 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id DF4DDA18030 for ; Mon, 10 Sep 2012 03:05:33 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id k11so2235201iea.11 for ; Sun, 09 Sep 2012 20:05:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :dkim-signature:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=ztoVLzJJcsdqzNPmTe9oMJNkPcMV36Afnl17esas0yo=; b=h2EXI35JLCQseacpayeQnN4NBRK+VNioQp/qsNVeJI3t9He+bkPAqbl5F/zYAvwXxG 6ZvI6/gJeeleJiJp6jzPVtfx1wHDrLkvOX1f5hvrwIomG526qgV5dwZlLxQG/YpDrp55 2A+4K9K4NCwedzaKkWczUkyqbVsI0+DOSjMZUGdNzSZ/sNSVJsORCl3VXCPgUyCPTZf7 9+ON6t+3UgYq5a1Hf110/Q3cJJ43EFCnkK9WYoANMVsaD42TJUm4vCsxFAwsBJRrU6Tj xznSlKLY2hjOABDCo3YFKGurep4i0n+Md+S0OxaA7pNcaEMia0ANv5BotwqdWrjlMC1s xC3w== Received: by 10.50.45.162 with SMTP id o2mr9169774igm.0.1347246333610; Sun, 09 Sep 2012 20:05:33 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp70812igc; Sun, 9 Sep 2012 20:05:33 -0700 (PDT) Received: by 10.60.20.197 with SMTP id p5mr12944113oee.32.1347246333230; Sun, 09 Sep 2012 20:05:33 -0700 (PDT) Received: from mail-ob0-f178.google.com (mail-ob0-f178.google.com [209.85.214.178]) by mx.google.com with ESMTPS id is1si7284901obc.87.2012.09.09.20.05.33 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 09 Sep 2012 20:05:33 -0700 (PDT) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 209.85.214.178 as permitted sender) client-ip=209.85.214.178; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robdclark@gmail.com designates 209.85.214.178 as permitted sender) smtp.mail=robdclark@gmail.com; dkim=pass header.i=@gmail.com Received: by mail-ob0-f178.google.com with SMTP id wd20so2865791obb.37 for ; Sun, 09 Sep 2012 20:05:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=ztoVLzJJcsdqzNPmTe9oMJNkPcMV36Afnl17esas0yo=; b=y54di4EuYxq1P6t/PTRslnjTdj7jqKmH723874rjd1Gn0rylH1aD6ZSbmxxCRwZCwM o+Yy8bVHiLvFv30J0N4kvjGrIHx2O800veK8sl1DUBE+HWPs2cBnYgN9uH/1QEt+Q5Le T4DLJA3YUt2yAMAqVMeLqz30HDSuQDt0CCgFly3xdpX8Gs7EUP5cnDn+XLyu70mh3xfk ltYjGLjdDXi59b7dAeXcmFLeudGxnRdvWSVrqDB/B0Ruzngtob6jglS/iaaADDXyLgnz GeLaCJiPwyerrTNgg35D41psAZOzb+keIxGothiq7XwFG9St5HTtkzhZstRw3p8NbPF+ bfDA== Received: by 10.182.64.47 with SMTP id l15mr12806784obs.4.1347246333102; Sun, 09 Sep 2012 20:05:33 -0700 (PDT) Received: from localhost (ppp-70-129-131-42.dsl.rcsntx.swbell.net. [70.129.131.42]) by mx.google.com with ESMTPS id ig3sm12224837obb.0.2012.09.09.20.05.32 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 09 Sep 2012 20:05:32 -0700 (PDT) Sender: Rob Clark From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: patches@linaro.org, ville.syrjala@linux.intel.com, jbarnes@virtuousgeek.org, daniel.vetter@ffwll.ch, Rob Clark Subject: [RFC 6/9] drm: convert page_flip to properties Date: Sun, 9 Sep 2012 22:03:19 -0500 Message-Id: <1347246202-24249-7-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1347246202-24249-1-git-send-email-rob.clark@linaro.org> References: <1347246202-24249-1-git-send-email-rob.clark@linaro.org> X-Gm-Message-State: ALoCoQneU1L4exBED+plEoeJavJoq9zGI389067XKEXE0ZdLC0RfsqlcT7AI6ObuSi/nx8hGfSW2 From: Rob Clark Use atomic properties mechanism for CRTC page_flip. This by itself doesn't accomplish anything, but it avoids having multiple code paths to do the same thing when nuclear-pageflip and atomic-modeset are introduced. --- drivers/gpu/drm/drm_crtc.c | 59 +++++++++++++++++--------------------------- include/drm/drm_crtc.h | 13 ---------- 2 files changed, 23 insertions(+), 49 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index ce6fa6a..8be57e4 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -387,9 +387,7 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb) struct drm_mode_config *config = &dev->mode_config; struct drm_crtc *crtc; struct drm_plane *plane; - struct drm_mode_set set; void *state; - int ret; state = dev->driver->atomic_begin(dev); if (IS_ERR(state)) { @@ -401,12 +399,7 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb) list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { if (crtc->fb == fb) { /* should turn off the crtc */ - memset(&set, 0, sizeof(struct drm_mode_set)); - set.crtc = crtc; - set.fb = NULL; - ret = crtc->funcs->set_config(&set); - if (ret) - DRM_ERROR("failed to reset crtc %p when fb was deleted\n", crtc); + drm_mode_crtc_set_obj_prop(crtc, state, config->prop_crtc_id, 0); } } @@ -449,6 +442,7 @@ EXPORT_SYMBOL(drm_framebuffer_remove); int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, const struct drm_crtc_funcs *funcs) { + struct drm_mode_config *config = &dev->mode_config; int ret; crtc->dev = dev; @@ -466,6 +460,10 @@ int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, list_add_tail(&crtc->head, &dev->mode_config.crtc_list); dev->mode_config.num_crtc++; + drm_object_attach_property(&crtc->base, config->prop_fb_id, 0); + drm_object_attach_property(&crtc->base, config->prop_crtc_x, 0); + drm_object_attach_property(&crtc->base, config->prop_crtc_y, 0); + out: mutex_unlock(&dev->mode_config.mutex); @@ -3750,12 +3748,12 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct drm_mode_crtc_page_flip *page_flip = data; + struct drm_mode_config *config = &dev->mode_config; struct drm_mode_object *obj; struct drm_crtc *crtc; - struct drm_framebuffer *fb; struct drm_pending_vblank_event *e = NULL; unsigned long flags; - int hdisplay, vdisplay; + void *state; int ret = -EINVAL; if (page_flip->flags & ~DRM_MODE_PAGE_FLIP_FLAGS || @@ -3763,6 +3761,13 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, return -EINVAL; mutex_lock(&dev->mode_config.mutex); + + state = dev->driver->atomic_begin(dev); + if (IS_ERR(state)) { + ret = PTR_ERR(state); + goto out_unlock; + } + obj = drm_mode_object_find(dev, page_flip->crtc_id, DRM_MODE_OBJECT_CRTC); if (!obj) goto out; @@ -3777,31 +3782,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, goto out; } - if (crtc->funcs->page_flip == NULL) - goto out; - - obj = drm_mode_object_find(dev, page_flip->fb_id, DRM_MODE_OBJECT_FB); - if (!obj) - goto out; - fb = obj_to_fb(obj); - - hdisplay = crtc->mode.hdisplay; - vdisplay = crtc->mode.vdisplay; - - if (crtc->invert_dimensions) - swap(hdisplay, vdisplay); - - if (hdisplay > fb->width || - vdisplay > fb->height || - crtc->x > fb->width - hdisplay || - crtc->y > fb->height - vdisplay) { - DRM_DEBUG_KMS("Invalid fb size %ux%u for CRTC viewport %ux%u+%d+%d%s.\n", - fb->width, fb->height, hdisplay, vdisplay, crtc->x, crtc->y, - crtc->invert_dimensions ? " (inverted)" : ""); - ret = -ENOSPC; - goto out; - } - if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) { ret = -ENOMEM; spin_lock_irqsave(&dev->event_lock, flags); @@ -3829,7 +3809,12 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, (void (*) (struct drm_pending_event *)) kfree; } - ret = crtc->funcs->page_flip(crtc, fb, e); + ret = drm_mode_set_obj_prop(dev, obj, state, + config->prop_fb_id, page_flip->fb_id); + if (ret) + goto out; + + ret = dev->driver->atomic_commit(dev, state, e); if (ret) { if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) { spin_lock_irqsave(&dev->event_lock, flags); @@ -3840,6 +3825,8 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, } out: + dev->driver->atomic_end(dev, state); +out_unlock: mutex_unlock(&dev->mode_config.mutex); return ret; } diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index a2ba164..a0bec04 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -347,19 +347,6 @@ struct drm_crtc_funcs { int (*set_config)(struct drm_mode_set *set); - /* - * Flip to the given framebuffer. This implements the page - * flip ioctl described in drm_mode.h, specifically, the - * implementation must return immediately and block all - * rendering to the current fb until the flip has completed. - * If userspace set the event flag in the ioctl, the event - * argument will point to an event to send back when the flip - * completes, otherwise it will be NULL. - */ - int (*page_flip)(struct drm_crtc *crtc, - struct drm_framebuffer *fb, - struct drm_pending_vblank_event *event); - int (*set_property)(struct drm_crtc *crtc, void *state, struct drm_property *property, uint64_t val); };