From patchwork Tue Oct 2 14:27:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Stanislawski X-Patchwork-Id: 11930 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 EDA1F1A52FC for ; Tue, 2 Oct 2012 14:29:07 +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 9CB04A186F4 for ; Tue, 2 Oct 2012 14:29:07 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so14258231iej.11 for ; Tue, 02 Oct 2012 07:29:07 -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=4DJBAytr2vaCgIfD0U8xgBOes5W/zksay1+dYhT/nac=; b=OaFvxtn6H+vYZn8z/tzkI/ZSr+XVOMXbf3Qq6uAL1wIoZ8CkncrASKMWZJh+tNPvfy LPPv+tB5BQeAUKtng52D0tZgLgxa22eXzfCQin7QpTdzeZyeVAUrkrBsWP3T6iRgy3X6 dv6lfd5+3bxRP2FT2QxaBltC48R+kTjKUObAZwS8R0Wf6YSy4ho13qz0X2748qrgSYBL 0VKruHC8vm8l8zkFmqUvUrJDzwoFwe33Z+r27hA2GbDGiU8bxDnlGKEv79lnH1nItjA5 4mkUXfEOLfiriBIpwmJPtNFmYMgVlT95UaPv2VtZQR3FB8i4E/zbVg3n63GB3iVkfbxM DNIg== Received: by 10.50.155.136 with SMTP id vw8mr8332582igb.28.1349188147232; Tue, 02 Oct 2012 07:29:07 -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 ex8csp84975igc; Tue, 2 Oct 2012 07:29:06 -0700 (PDT) Received: by 10.216.195.170 with SMTP id p42mr10284766wen.132.1349188145280; Tue, 02 Oct 2012 07:29:05 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id fh9si2523902wib.27.2012.10.02.07.29.04; Tue, 02 Oct 2012 07:29:05 -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 1TJ3T4-0004eJ-SZ; Tue, 02 Oct 2012 14:29:03 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TJ3T3-0004e5-8G for linaro-mm-sig@lists.linaro.org; Tue, 02 Oct 2012 14:29:01 +0000 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MB9001UQS8AFGL0@mailout4.samsung.com> for linaro-mm-sig@lists.linaro.org; Tue, 02 Oct 2012 23:28:59 +0900 (KST) X-AuditID: cbfee61a-b7f726d000000ec7-16-506afa2a1206 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 73.9E.03783.A2AFA605; Tue, 02 Oct 2012 23:28:58 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MB9005A7S65K790@mmp2.samsung.com> for linaro-mm-sig@lists.linaro.org; Tue, 02 Oct 2012 23:28:58 +0900 (KST) From: Tomasz Stanislawski To: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Date: Tue, 02 Oct 2012 16:27:20 +0200 Message-id: <1349188056-4886-10-git-send-email-t.stanislaws@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1349188056-4886-1-git-send-email-t.stanislaws@samsung.com> References: <1349188056-4886-1-git-send-email-t.stanislaws@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCJMWRmVeSWpSXmKPExsVy+t9jQV2tX1kBBhsnWFt8ufKQyYHR4/a/ x8wBjFFcNimpOZllqUX6dglcGU9/b2QqOClWcX3KLbYGxkNCXYycHBICJhIP1l9mhrDFJC7c W8/WxcjFISQwnVHiR9cUJghnLZNE2/EbTCBVbEAdx5Z8ZgSxRQQcJE7fncUMUsQssIZZ4sXK G2wgCWEBX4ntG/+xg9gsAqoS7a9+g8V5BTwkPrzcxwqxTl7i6f0+sDgnUPznkwssILaQgLvE nuVNbBMYeRcwMqxiFE0tSC4oTkrPNdQrTswtLs1L10vOz93ECPb7M6kdjCsbLA4xCnAwKvHw 7jyZGSDEmlhWXJl7iFGCg1lJhNf6flaAEG9KYmVValF+fFFpTmrxIUZpDhYlcd5mj5QAIYH0 xJLU7NTUgtQimCwTB6dUA6PLpwCP+UE3F3Ix8PO+E9a9eLJ9h8VWvpo7/97fUD32Y4cB99eg pJipFfInJWWtRSqedeT8+hH7dPWLU57G0b90a3YmfduyaP/3wM1bQhvmVFgfvdCtst18rjTP tvc9q8KszpzXZ8mN2H15dYmawpTpnkKtSzdJBP9nP+3nfoM59O6UXc51j92UWIozEg21mIuK EwGLkB1N9wEAAA== 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] [PATCHv9 09/25] 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: ALoCoQmUv4mvBf2c8qXyHRKRanw2ekrOota88nhzcyX66dNq1/53c2VO0XofWi2K3Ks4FwsiTPFu 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 --- drivers/media/video/videobuf2-core.c | 11 +++++++++++ include/media/videobuf2-core.h | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c index 901bc56..05da3b4 100644 --- a/drivers/media/video/videobuf2-core.c +++ b/drivers/media/video/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; @@ -1148,9 +1153,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 84f11f2..c306fec 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 everytime the buffer is passed from userspace to the + * driver, usefull for cache synchronisation, optional + * @finish: called everytime 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);