From patchwork Tue Aug 14 15:34:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Stanislawski X-Patchwork-Id: 1321231 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id E01DC40210 for ; Tue, 14 Aug 2012 15:36:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755311Ab2HNPgZ (ORCPT ); Tue, 14 Aug 2012 11:36:25 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:62547 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751785Ab2HNPgY (ORCPT ); Tue, 14 Aug 2012 11:36:24 -0400 Received: from epcpsbgm1.samsung.com (mailout1.samsung.com [203.254.224.24]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M8R005SA4ON2TE0@mailout1.samsung.com> for linux-media@vger.kernel.org; Wed, 15 Aug 2012 00:36:23 +0900 (KST) X-AuditID: cbfee61a-b7fc66d0000043b7-f9-502a70772374 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 94.6D.17335.7707A205; Wed, 15 Aug 2012 00:36:23 +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 <0M8R004J44MBC810@mmp1.samsung.com> for linux-media@vger.kernel.org; Wed, 15 Aug 2012 00:36:23 +0900 (KST) From: Tomasz Stanislawski To: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: airlied@redhat.com, m.szyprowski@samsung.com, t.stanislaws@samsung.com, kyungmin.park@samsung.com, laurent.pinchart@ideasonboard.com, sumit.semwal@ti.com, daeinki@gmail.com, daniel.vetter@ffwll.ch, robdclark@gmail.com, pawel@osciak.com, linaro-mm-sig@lists.linaro.org, hverkuil@xs4all.nl, remi@remlab.net, subashrp@gmail.com, mchehab@redhat.com, g.liakhovetski@gmx.de, dmitriyz@google.com, s.nawrocki@samsung.com, k.debski@samsung.com Subject: [PATCHv8 09/26] v4l: vb2: add prepare/finish callbacks to allocators Date: Tue, 14 Aug 2012 17:34:39 +0200 Message-id: <1344958496-9373-10-git-send-email-t.stanislaws@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1344958496-9373-1-git-send-email-t.stanislaws@samsung.com> References: <1344958496-9373-1-git-send-email-t.stanislaws@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEJMWRmVeSWpSXmKPExsVy+t9jAd3yAq0Ag/VXVC16NmxldWD0+LxJ LoAxissmJTUnsyy1SN8ugSvj/KG5bAUnxSoezWhibGA8JNTFyMkhIWAi0fOmmx3CFpO4cG89 WxcjF4eQwCJGiWvLX0E5q5gk/rWsZAOpYgPqOLbkMyOILSLgIHH67ixmkCJmgUPMEvt7X4ON EhbwlVh+6gMLiM0ioCqxqWUXK4jNK+Ah0f9rAyPEOnmJp/f7wIZyAsVfbuoGinMAbXOXWPjT fwIj7wJGhlWMoqkFyQXFSem5hnrFibnFpXnpesn5uZsYwT5/JrWDcWWDxSFGAQ5GJR5ehTTN ACHWxLLiytxDjBIczEoivEVBWgFCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeY29v/oLCaQnlqRm p6YWpBbBZJk4OKUaGMuC92mJ1d1ZnRI3s1g+Ntdg14QGkX77toPccx6oOy9kMGK52ZIY1fmg Yfoj1T2bw/kz36b3qZ8PVOrXT15VGSsRIeGzZW3q32Xlptx6bP53q7ZHrinb1r17++/FkRy7 eqOEbKxsDv16NnnfjYM3/cUD7/yI1J9xZZ7oAvupiRZ/j2348EBfR4mlOCPRUIu5qDgRAHU0 nSX1AQAA X-TM-AS-MML: No Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 a5d5081..aed21e4 100644 --- a/drivers/media/video/videobuf2-core.c +++ b/drivers/media/video/videobuf2-core.c @@ -850,6 +850,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; @@ -860,6 +861,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; @@ -1138,9 +1143,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);