From patchwork Tue Oct 9 00:13:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 12055 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 5EF4723EF8 for ; Tue, 9 Oct 2012 00:14:04 +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 A343CA180A6 for ; Tue, 9 Oct 2012 00:14:03 +0000 (UTC) Received: by mail-pa0-f52.google.com with SMTP id hz10so4996013pad.11 for ; Mon, 08 Oct 2012 17:14:02 -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 :x-gm-message-state; bh=3BjUi7Owbqcw5wwXqVKKufNJoCrup1JWQt7w2VJuEoE=; b=KiI22V+idyXTwm50sZcCrTI2J1EZ8Z2gCqAiZ1goITZwKM/ew/Vw2IHHetEp2If1G1 XHkom9rLEeAnfYaPe/BYECyorqfRPZJoQ6ZMViF5wYybK96dTgjuh1cgAv7xY1aWsajc Vz1wBYhLs2sa4Rh3UrdKUd88sKLQAXBRmy+/cWxkM5vo9SGC+38tLQVBfXqAO0nCCoW4 vW/FGd32HqNQBEn68Tgsolzn1nwhBNLFkaZsWtFW+hRlDjmX+Yoo3nbjZ6RZ88SgWMjB 4ygt99Bq8xPy41MBMjKZm5b1rQRrtORbhm/gUz4HRStXhg5cK+WRU0cZnYf6OmHivo15 1dBQ== Received: by 10.66.88.233 with SMTP id bj9mr47294252pab.72.1349741642701; Mon, 08 Oct 2012 17:14:02 -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 z9csp347621pbi; Mon, 8 Oct 2012 17:14:02 -0700 (PDT) Received: by 10.182.51.65 with SMTP id i1mr1477822obo.45.1349741641459; Mon, 08 Oct 2012 17:14:01 -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 b5si5446413obl.118.2012.10.08.17.13.59 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 08 Oct 2012 17:14:00 -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 tb18so5134507obb.37 for ; Mon, 08 Oct 2012 17:13:59 -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; bh=3BjUi7Owbqcw5wwXqVKKufNJoCrup1JWQt7w2VJuEoE=; b=hbA0iuOj/ADrjqv4Qg53fUbYMbvEb6DgEzTLQ/FgrY5403tiYy8PMlSrYstfNZS5kt 46j1t+8SBiijjyY3fI9LDpXsOKAaljdl2/3R9ts1D4k1gtsXpWHuk0GeGXs9QI8GaPvn faKLU0pe9fWqUSWeA7vFb0lDHQEQFFvtY80+5Uns2e4A0vhFzjXmI3pQH5f4xGruJbTE wMsk+Me8i1grV1Wz8ycaQWREm0STOntHg5iYhJaKnI1jQITH5VLhCeMQK9lCASU3sNaj J7uTQcNNIBh9h6VdfcFw6TD4C4eazTZPYxbapVhFx3HVQI5Vr7QmG2Luv8yPjg5WBwR9 EdYw== Received: by 10.182.47.66 with SMTP id b2mr1455536obn.34.1349741639565; Mon, 08 Oct 2012 17:13:59 -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 s10sm140344oea.8.2012.10.08.17.13.58 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 08 Oct 2012 17:13:58 -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 (v2) Date: Mon, 8 Oct 2012 19:13:43 -0500 Message-Id: <1349741623-28185-1-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQmFN35NdcY3m6TMsYzioRopLv6uSZHNUv9q26qp6KKk9ZgRwoGqe8HbRCuZKMYWXXpKy144 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. v1: original v2: add back 'vblwait->reply.sequence = seq' which should not have been deleted Signed-off-by: Rob Clark --- drivers/gpu/drm/drm_irq.c | 64 +++++++++++++++++++++++++++++---------------- include/drm/drmP.h | 2 ++ 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 076c4a8..0e6e804 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,9 @@ 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); + send_vblank_event(e, seq, &now); vblwait->reply.sequence = seq; - trace_drm_vblank_event_delivered(current->pid, pipe, - vblwait->request.sequence); } else { /* drm_handle_vblank_events will call drm_vblank_put */ list_add_tail(&e->base.link, &dev->vblank_event_list); @@ -1256,14 +1281,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);