From patchwork Wed Oct 10 14:46:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Stanislawski X-Patchwork-Id: 12118 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 29FDF24189 for ; Wed, 10 Oct 2012 14:53:11 +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 95777A18502 for ; Wed, 10 Oct 2012 14:53:10 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so1002096iej.11 for ; Wed, 10 Oct 2012 07:53:10 -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:x-auditid :from:to:date:message-id:x-mailer:in-reply-to:references :x-brightmail-tracker:cc:subject:x-beenthere:x-mailman-version :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-gm-message-state; bh=J9Db+x6bV1Z5r3hUZBk9wcIKFiyUo0Hkxckd8a5pHuA=; b=ftZniDRBCr9Vg4RfWROsHWqQRTdF29jHyfWWNL4O6Wr4WBKO83s5T7sANB7DFQogEh twQDkhMktoo/aoOFVoQuIPUIRIrzXB7JR/lxLnwxpKDyVc3EQRMhagl7dKLwJfmxpwFI M4THLbopWjMiDzGfNZGh4KAjXHVfnPn6ugEiQxNfXv8rZJ4Q4hAqRFK0MBJjf9qgCpTL PKPWz7RXmybMy4nyItoVdxs110r8lCZ8fhzid62Oc+K5E/CP/15wljp9Z+pGC2zDkul9 fMwd4JzHwQMWE46pOtJA+1gag0RDUIJ0dgJK+mHTYdKpHkgjN7Fz066uif8Mh+q4efLz Gn6Q== Received: by 10.50.77.138 with SMTP id s10mr5467899igw.70.1349880790065; Wed, 10 Oct 2012 07:53:10 -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.67.148 with SMTP id n20csp236126igt; Wed, 10 Oct 2012 07:53:09 -0700 (PDT) Received: by 10.204.3.213 with SMTP id 21mr4700797bko.121.1349880788364; Wed, 10 Oct 2012 07:53:08 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id go13si2851828bkc.9.2012.10.10.07.53.07; Wed, 10 Oct 2012 07:53:08 -0700 (PDT) Received-SPF: neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) client-ip=91.189.95.16; Authentication-Results: mx.google.com; spf=neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) smtp.mail=linaro-mm-sig-bounces@lists.linaro.org Received: from localhost ([127.0.0.1] helo=mombin.canonical.com) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TLxej-0001PT-Fu; Wed, 10 Oct 2012 14:53:05 +0000 Received: from mailout2.samsung.com ([203.254.224.25]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TLxeg-0001PJ-WE for linaro-mm-sig@lists.linaro.org; Wed, 10 Oct 2012 14:53:03 +0000 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MBO00GH6MODP590@mailout2.samsung.com> for linaro-mm-sig@lists.linaro.org; Wed, 10 Oct 2012 23:53:01 +0900 (KST) X-AuditID: cbfee61a-b7f726d000000ec7-eb-50758bcc1dba Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id EB.B9.03783.CCB85705; Wed, 10 Oct 2012 23:53:01 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MBO002YDME0EC70@mmp1.samsung.com> for linaro-mm-sig@lists.linaro.org; Wed, 10 Oct 2012 23:53:00 +0900 (KST) From: Tomasz Stanislawski To: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Date: Wed, 10 Oct 2012 16:46:28 +0200 Message-id: <1349880405-26049-10-git-send-email-t.stanislaws@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1349880405-26049-1-git-send-email-t.stanislaws@samsung.com> References: <1349880405-26049-1-git-send-email-t.stanislaws@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMJMWRmVeSWpSXmKPExsVy+t9jAd2z3aUBBtOuMlt8ufKQyYHR4/a/ x8wBjFFcNimpOZllqUX6dglcGfPub2AsmCxesXLGNJYGxkbhLkZODgkBE4mzWz4yQthiEhfu rWcDsYUEFjFK3NwT3sXIBWSvZZJYf62DCSTBBtRwbMlnsAYRAQeJ03dnMYMUMQusYZZ4sfIG WLewgJ/E4TkbwBpYBFQl5m1bywxi8wp4SjxZ3c8MsU1e4un9PrB6TqD4hXnTmSE2e0j8X7+Z aQIj7wJGhlWMoqkFyQXFSem5hnrFibnFpXnpesn5uZsYwV5/JrWDcWWDxSFGAQ5GJR7ejKiS ACHWxLLiytxDjBIczEoivKY+pQFCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeZs9UgKEBNITS1Kz U1MLUotgskwcnFINjJultojpuSxddH17XgNb48avR8o79e3fyXN4lEg0vv/3uWvNkXs1+f/D wkpWcXOuujpv5Y0AScc5L/v2TT4cGnpY+lKMEI+73K2VNzUWB5fOSQnhvFNYstJToV75wJF2 r33Hd566f+cf7/bN24TnzVh+MG7ByfrNjtMiLjq52KfvDF18801yf78SS3FGoqEWc1FxIgAw PW999gEAAA== Cc: k.debski@samsung.com, s.nawrocki@samsung.com, pawel@osciak.com, sumit.semwal@ti.com, mchehab@redhat.com, robdclark@gmail.com, linaro-mm-sig@lists.linaro.org, kyungmin.park@samsung.com, laurent.pinchart@ideasonboard.com, airlied@redhat.com, remi@remlab.net Subject: [Linaro-mm-sig] [PATCHv10 09/26] v4l: vb2: add prepare/finish callbacks to allocators X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Unified memory management interest group." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQkMuDAdN27H8av+uhRR5TgtHILIr2HA3ZGT9IHFWXKYx2nhBaIp61/poIQO4NLX+mQ0ie8F From: Marek Szyprowski This patch adds support for prepare/finish callbacks in VB2 allocators. These callback are used for buffer flushing. Signed-off-by: Marek Szyprowski Acked-by: Laurent Pinchart Acked-by: Hans Verkuil --- drivers/media/v4l2-core/videobuf2-core.c | 11 +++++++++++ include/media/videobuf2-core.h | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index a51dad6..613dea1 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -844,6 +844,7 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state) { struct vb2_queue *q = vb->vb2_queue; unsigned long flags; + unsigned int plane; if (vb->state != VB2_BUF_STATE_ACTIVE) return; @@ -854,6 +855,10 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state) dprintk(4, "Done processing on buffer %d, state: %d\n", vb->v4l2_buf.index, vb->state); + /* sync buffers */ + for (plane = 0; plane < vb->num_planes; ++plane) + call_memop(q, finish, vb->planes[plane].mem_priv); + /* Add the buffer to the done buffers list */ spin_lock_irqsave(&q->done_lock, flags); vb->state = state; @@ -1136,9 +1141,15 @@ err: static void __enqueue_in_driver(struct vb2_buffer *vb) { struct vb2_queue *q = vb->vb2_queue; + unsigned int plane; vb->state = VB2_BUF_STATE_ACTIVE; atomic_inc(&q->queued_count); + + /* sync buffers */ + for (plane = 0; plane < vb->num_planes; ++plane) + call_memop(q, prepare, vb->planes[plane].mem_priv); + q->ops->buf_queue(vb); } diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 689ae4a..24b9c90 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -56,6 +56,10 @@ struct vb2_fileio_data; * dmabuf * @unmap_dmabuf: releases access control to the dmabuf - allocator is notified * that this driver is done using the dmabuf for now + * @prepare: called every time the buffer is passed from userspace to the + * driver, useful for cache synchronisation, optional + * @finish: called every time the buffer is passed back from the driver + * to the userspace, also optional * @vaddr: return a kernel virtual address to a given memory buffer * associated with the passed private structure or NULL if no * such mapping exists @@ -82,6 +86,9 @@ struct vb2_mem_ops { unsigned long size, int write); void (*put_userptr)(void *buf_priv); + void (*prepare)(void *buf_priv); + void (*finish)(void *buf_priv); + void *(*attach_dmabuf)(void *alloc_ctx, struct dma_buf *dbuf, unsigned long size, int write); void (*detach_dmabuf)(void *buf_priv);