From patchwork Thu Jun 14 13:37:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Stanislawski X-Patchwork-Id: 9284 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 7C44F23E1B for ; Thu, 14 Jun 2012 13:38:25 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 34398A185A8 for ; Thu, 14 Jun 2012 13:38:25 +0000 (UTC) Received: by yhpp61 with SMTP id p61so1577835yhp.11 for ; Thu, 14 Jun 2012 06:38:24 -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:date:from :in-reply-to:to:message-id:x-mailer:references:x-tm-as-mml: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=tCuA1dy2qJ73vZlOBDgQ21wy9gYf0IXMojd+Zy6G7ag=; b=TJs26oG/N34NDoke1C091YK6YGoXrndhQ4CZpeGO/070P6NGO7JPlvYFcr+cmt1Gvw in2SITsRsZAVn8P8q8wxB/tyFiepKqyH72TfWY+PxqNTKhPCTIC8cJhN2kx9vaGqgllR fHYyxqfreaJ7Wj6UKNhxjin39lmLQ+C20cwvJ1Z/nrXBEALmYY/+s02cVoQPp2RxEiQW HNSoAsxgg02xjJvHkpVd/coxCtifsJqkG6SRIjaarPm3mfq0oIBEndKBhBPpVCBngctd n6RYFNYqOV9llOj8jdtVwLuVVTo1vcA7M5c9oqx9BGD+Ca8ctqPWwES1aWlf9KqvYhDs QaXA== Received: by 10.50.87.227 with SMTP id bb3mr767239igb.57.1339681104607; Thu, 14 Jun 2012 06:38:24 -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.231.24.148 with SMTP id v20csp85242ibb; Thu, 14 Jun 2012 06:38:22 -0700 (PDT) Received: by 10.204.148.74 with SMTP id o10mr1109013bkv.111.1339681100911; Thu, 14 Jun 2012 06:38:20 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id gw17si4930324bkc.103.2012.06.14.06.38.19; Thu, 14 Jun 2012 06:38:20 -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 1SfAFd-0006ru-J3; Thu, 14 Jun 2012 13:38:17 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SfAFZ-0006qF-0G for linaro-mm-sig@lists.linaro.org; Thu, 14 Jun 2012 13:38:13 +0000 Received: from euspt1 (mailout1.w1.samsung.com [210.118.77.11]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M5M00LS80KH1760@mailout1.w1.samsung.com> for linaro-mm-sig@lists.linaro.org; Thu, 14 Jun 2012 14:38:42 +0100 (BST) Received: from linux.samsung.com ([106.116.38.10]) by spt1.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0M5M00HPS0JMM6@spt1.w1.samsung.com> for linaro-mm-sig@lists.linaro.org; Thu, 14 Jun 2012 14:38:10 +0100 (BST) Received: from mcdsrvbld02.digital.local (unknown [106.116.37.23]) by linux.samsung.com (Postfix) with ESMTP id 5C17E27016C; Thu, 14 Jun 2012 15:42:38 +0200 (CEST) Date: Thu, 14 Jun 2012 15:37:43 +0200 From: Tomasz Stanislawski In-reply-to: <1339681069-8483-1-git-send-email-t.stanislaws@samsung.com> To: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Message-id: <1339681069-8483-10-git-send-email-t.stanislaws@samsung.com> X-Mailer: git-send-email 1.7.10 References: <1339681069-8483-1-git-send-email-t.stanislaws@samsung.com> X-TM-AS-MML: No Cc: 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, g.liakhovetski@gmx.de Subject: [Linaro-mm-sig] [PATCHv7 09/15] 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: ALoCoQkMwvvcg5/BqTjOc5ogyIlYandJNBIMV5lI3x1J1SrbkA1GEL+vJzoi0nsQlyMnw6cCyVi+ 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 f43cfa4..d60ed25 100644 --- a/drivers/media/video/videobuf2-core.c +++ b/drivers/media/video/videobuf2-core.c @@ -845,6 +845,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; @@ -855,6 +856,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; @@ -1137,9 +1142,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 859bbaf..d079f92 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);