From patchwork Tue Sep 25 15:04:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Federico Vaga X-Patchwork-Id: 1504801 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 826183FCFC for ; Tue, 25 Sep 2012 15:01:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756331Ab2IYPBC (ORCPT ); Tue, 25 Sep 2012 11:01:02 -0400 Received: from mail-ee0-f46.google.com ([74.125.83.46]:37376 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750840Ab2IYPBA (ORCPT ); Tue, 25 Sep 2012 11:01:00 -0400 Received: by eekb15 with SMTP id b15so961460eek.19 for ; Tue, 25 Sep 2012 08:00:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=o5KKLtI/IW1BtJkO4QXr7PVHbkVbAAwr/UuzJlvbxw4=; b=jlF3G6TffEomOamAjZuTh5Q0mPV6tXtSzaOmCCEx3ASVevj4dMXrWVmXir6qHndPOc t703sdRHXWgNEslK0t2JwM8k4ATi4ZcPsAUK+gzzLIaGTcCcipm6MUSkb9DHdJlqmdlb 0SEddkYOyOq469u74fK/RIek0DesdDVJnDkUWXLbi7UPvFJ4FGM8hXMa18Lyn85/qxua 5P1iQCYA2LxR/DZJJOSF23SXW7EbD8cQR964QYdYutu2MsQbkws2O/qJp7I+wvFvdtkE +5rmoJKWw9d0fvAfHyBTnt1sFlUAd+U22OnqyxbgCD8WVWo5TbFhVI+8oR3zzysXXTzo ZNBw== Received: by 10.14.224.135 with SMTP id x7mr10116867eep.34.1348585259406; Tue, 25 Sep 2012 08:00:59 -0700 (PDT) Received: from harkonnen.fastwebnet.it (2-225-41-194.ip174.fastwebnet.it. [2.225.41.194]) by mx.google.com with ESMTPS id 9sm1540270eei.12.2012.09.25.08.00.57 (version=SSLv3 cipher=OTHER); Tue, 25 Sep 2012 08:00:58 -0700 (PDT) From: Federico Vaga To: Mauro Carvalho Chehab , Pawel Osciak , Marek Szyprowski , Hans Verkuil Cc: Giancarlo Asnaghi , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Corbet , Federico Vaga Subject: [PATCH v3 1/4] v4l: vb2: add prepare/finish callbacks to allocators Date: Tue, 25 Sep 2012 17:04:00 +0200 Message-Id: <1348585440-5385-1-git-send-email-federico.vaga@gmail.com> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1348484332-8106-1-git-send-email-federico.vaga@gmail.com> References: <1348484332-8106-1-git-send-email-federico.vaga@gmail.com> 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 Acked-by: Federico Vaga --- drivers/media/v4l2-core/videobuf2-core.c | 11 +++++++++++ include/media/videobuf2-core.h | 7 +++++++ 2 file modificati, 18 inserzioni(+) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 4da3df6..079fa79 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -790,6 +790,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; @@ -800,6 +801,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; @@ -975,9 +980,15 @@ static int __qbuf_mmap(struct vb2_buffer *vb, const struct v4l2_buffer *b) 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 8dd9b6c..2508609 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -41,6 +41,10 @@ struct vb2_fileio_data; * argument to other ops in this structure * @put_userptr: inform the allocator that a USERPTR buffer will no longer * be used + * @prepare: called every time the buffer is passed from userspace to the + * driver, usefull 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 @@ -65,6 +69,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 *(*vaddr)(void *buf_priv); void *(*cookie)(void *buf_priv);