From patchwork Mon Oct 8 19:50:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 12044 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 2658B23FB3 for ; Mon, 8 Oct 2012 19:51:18 +0000 (UTC) Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by fiordland.canonical.com (Postfix) with ESMTP id 9BCD6A18B70 for ; Mon, 8 Oct 2012 19:51:17 +0000 (UTC) Received: by mail-pa0-f52.google.com with SMTP id hz10so4789256pad.11 for ; Mon, 08 Oct 2012 12:51:17 -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=6dH6GfJW+B/8C+yJ+ieqNoA1ugF1IEXmGDXX/dotvIY=; b=XHvL4CXkcQDdTCkUGgvhsCkwKsQQic+4YI9iTcs1VAAvUceYc1fJq7yxqF4/PhMhoC ES9LSujXmSFRHDTUn/RDLLdoU0YbfYJpz3MY/Jvfr727WlEkf7Lmc3Q3bHsu7NqiiGYa RhKVLyXMA3gr9CoDCl2OewPT8VNTSTfZ9eN7oVN8JWUHJr3Jv7Qnlx49bNkbPmhCWvcD ae+AyPxxJxemA1hAyCYNX0xV12mhlcaPeKQ4VU3aeNNS9lSAPe/5tr9dS2tgcdZNCMhx twl+Sd93cB82ZR7pZoyxrUrBbyQLG6U2rQTCBjl0xTNKZv0i6+Du9bBg34m5JCLyjjRT M4rg== Received: by 10.68.212.71 with SMTP id ni7mr55601872pbc.81.1349725877322; Mon, 08 Oct 2012 12:51:17 -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.68.34.137 with SMTP id z9csp314475pbi; Mon, 8 Oct 2012 12:51:16 -0700 (PDT) Received: by 10.182.117.74 with SMTP id kc10mr1009271obb.63.1349725874993; Mon, 08 Oct 2012 12:51:14 -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 b5si4948733obl.208.2012.10.08.12.51.14 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 08 Oct 2012 12:51:14 -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 tb18so4877681obb.37 for ; Mon, 08 Oct 2012 12:51:14 -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=6dH6GfJW+B/8C+yJ+ieqNoA1ugF1IEXmGDXX/dotvIY=; b=ZxeZtZEzgTWGbYDJQD5RBIhKidkfE9BSMhDfReDyAgg+IZ1QPWwRjst7MXKUAZySRP P2AB4wCveJnnulgzGqfepTahz4DbLkqnVfROOuENWe1AbhKEJA4BirpmIg1Ya8FMm1Jf AZ1jrgmMip8346k8P6m00phA5WIpWG21+4fndZ/dhAS87aQL+mV7EHsau6EL8i2KTWkv Mi17ruwdU7aJE7kewJw4UGh1p7Dc1Fg73RAZEVQKPc5Hbg5/Ll3RAqP/PXxZ1E9JfZmt hvkyZxLuMALYRwAJ/8oIDzmFqb/8NFQy7BVvnzAAVrz9i2xd7Dqfsd1XWi7t3iAPHSDx 5Yqw== Received: by 10.182.69.73 with SMTP id c9mr1008929obu.33.1349725874651; Mon, 08 Oct 2012 12:51:14 -0700 (PDT) Received: from localhost (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id x1sm14930555oef.8.2012.10.08.12.51.13 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 08 Oct 2012 12:51:14 -0700 (PDT) Sender: Rob Clark From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: patches@linaro.org, airlied@linux.ie, daniel.vetter@ffwll.ch, bskeggs@redhat.com, inki.dae@samsung.com, laurent.pinchart@ideasonboard.com, s.hauer@pengutronix.de, gregkh@linuxfoundation.org, Rob Clark Subject: [PATCH 01/11] drm: add drm_send_vblank_event() helper Date: Mon, 8 Oct 2012 14:50:39 -0500 Message-Id: <1349725849-22433-2-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1349725849-22433-1-git-send-email-rob.clark@linaro.org> References: <1349725849-22433-1-git-send-email-rob.clark@linaro.org> X-Gm-Message-State: ALoCoQlSiZhA/oaBtsbjQ5vd6MJG4oDFrkKAHx0WR1zKmP+n/cGnDEkKoFCC0B1VmNhVvuCsAlDk From: Rob Clark A helper that drivers can use to send vblank event after a pageflip. If the driver doesn't support proper vblank irq based time/seqn then just pass -1 for the pipe # to get do_gettimestamp() behavior (since there are a lot of drivers that don't use drm_vblank_count_and_time()) Also an internal send_vblank_event() helper for the various other code paths within drm_irq that also need to send vblank events. Signed-off-by: Rob Clark --- drivers/gpu/drm/drm_irq.c | 65 +++++++++++++++++++++++++++++---------------- include/drm/drmP.h | 2 ++ 2 files changed, 44 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 076c4a8..7a00d94 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -802,6 +802,43 @@ u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc, } EXPORT_SYMBOL(drm_vblank_count_and_time); +static void send_vblank_event(struct drm_pending_vblank_event *e, + unsigned long seq, struct timeval *now) +{ + e->event.sequence = seq; + e->event.tv_sec = now->tv_sec; + e->event.tv_usec = now->tv_usec; + + list_add_tail(&e->base.link, + &e->base.file_priv->event_list); + wake_up_interruptible(&e->base.file_priv->event_wait); + trace_drm_vblank_event_delivered(e->base.pid, e->pipe, + e->event.sequence); +} + +/** + * drm_send_vblank_event - helper to send vblank event after pageflip + * @dev: DRM device + * @crtc: CRTC in question + * @e: the event to send + * + * Updates sequence # and timestamp on event, and sends it to userspace. + */ +void drm_send_vblank_event(struct drm_device *dev, int crtc, + struct drm_pending_vblank_event *e) +{ + struct timeval now; + unsigned int seq; + if (crtc >= 0) { + seq = drm_vblank_count_and_time(dev, crtc, &now); + } else { + seq = 0; + do_gettimeofday(&now); + } + send_vblank_event(e, seq, &now); +} +EXPORT_SYMBOL(drm_send_vblank_event); + /** * drm_update_vblank_count - update the master vblank counter * @dev: DRM device @@ -955,15 +992,9 @@ void drm_vblank_off(struct drm_device *dev, int crtc) DRM_DEBUG("Sending premature vblank event on disable: \ wanted %d, current %d\n", e->event.sequence, seq); - - e->event.sequence = seq; - e->event.tv_sec = now.tv_sec; - e->event.tv_usec = now.tv_usec; + list_del(&e->base.link); drm_vblank_put(dev, e->pipe); - list_move_tail(&e->base.link, &e->base.file_priv->event_list); - wake_up_interruptible(&e->base.file_priv->event_wait); - trace_drm_vblank_event_delivered(e->base.pid, e->pipe, - e->event.sequence); + send_vblank_event(e, seq, &now); } spin_unlock_irqrestore(&dev->vbl_lock, irqflags); @@ -1107,15 +1138,8 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe, e->event.sequence = vblwait->request.sequence; if ((seq - vblwait->request.sequence) <= (1 << 23)) { - e->event.sequence = seq; - e->event.tv_sec = now.tv_sec; - e->event.tv_usec = now.tv_usec; drm_vblank_put(dev, pipe); - list_add_tail(&e->base.link, &e->base.file_priv->event_list); - wake_up_interruptible(&e->base.file_priv->event_wait); - vblwait->reply.sequence = seq; - trace_drm_vblank_event_delivered(current->pid, pipe, - vblwait->request.sequence); + send_vblank_event(e, seq, &now); } else { /* drm_handle_vblank_events will call drm_vblank_put */ list_add_tail(&e->base.link, &dev->vblank_event_list); @@ -1256,14 +1280,9 @@ static void drm_handle_vblank_events(struct drm_device *dev, int crtc) DRM_DEBUG("vblank event on %d, current %d\n", e->event.sequence, seq); - e->event.sequence = seq; - e->event.tv_sec = now.tv_sec; - e->event.tv_usec = now.tv_usec; + list_del(&e->base.link); drm_vblank_put(dev, e->pipe); - list_move_tail(&e->base.link, &e->base.file_priv->event_list); - wake_up_interruptible(&e->base.file_priv->event_wait); - trace_drm_vblank_event_delivered(e->base.pid, e->pipe, - e->event.sequence); + send_vblank_event(e, seq, &now); } spin_unlock_irqrestore(&dev->event_lock, flags); diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 05af0e7..ee8f927 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -1437,6 +1437,8 @@ extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq); extern u32 drm_vblank_count(struct drm_device *dev, int crtc); extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc, struct timeval *vblanktime); +extern void drm_send_vblank_event(struct drm_device *dev, int crtc, + struct drm_pending_vblank_event *e); extern bool drm_handle_vblank(struct drm_device *dev, int crtc); extern int drm_vblank_get(struct drm_device *dev, int crtc); extern void drm_vblank_put(struct drm_device *dev, int crtc);