linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Federico Vaga <federico.vaga@gmail.com>
To: Mauro Carvalho Chehab <mchehab@infradead.org>,
	Pawel Osciak <pawel@osciak.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Hans Verkuil <hans.verkuil@cisco.com>
Cc: Giancarlo Asnaghi <giancarlo.asnaghi@st.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jonathan Corbet <corbet@lwn.net>,
	Federico Vaga <federico.vaga@gmail.com>
Subject: [PATCH v3 1/4] v4l: vb2: add prepare/finish callbacks to allocators
Date: Tue, 25 Sep 2012 17:04:00 +0200	[thread overview]
Message-ID: <1348585440-5385-1-git-send-email-federico.vaga@gmail.com> (raw)
In-Reply-To: <1348484332-8106-1-git-send-email-federico.vaga@gmail.com>

From: Marek Szyprowski <m.szyprowski@samsung.com>

This patch adds support for prepare/finish callbacks in VB2 allocators.
These callback are used for buffer flushing.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Federico Vaga <federico.vaga@gmail.com>
---
 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);
 
-- 
1.7.11.4


      parent reply	other threads:[~2012-09-25 15:01 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-24 10:58 [PATCH v3 1/4] v4l: vb2: add prepare/finish callbacks to allocators Federico Vaga
2012-09-24 10:58 ` [PATCH v3 2/4] videobuf2-dma-streaming: new videobuf2 memory allocator Federico Vaga
2012-09-24 12:44   ` Marek Szyprowski
2012-12-04 16:04     ` Mauro Carvalho Chehab
2012-12-05 12:50       ` Federico Vaga
2012-12-05 14:25         ` Mauro Carvalho Chehab
2012-12-11 13:54           ` Federico Vaga
2012-12-18 14:41             ` Marek Szyprowski
2012-12-20 15:37               ` Federico Vaga
2013-01-01 12:52                 ` Mauro Carvalho Chehab
2013-01-03 16:13                   ` Federico Vaga
2013-01-04 13:30                     ` Federico Vaga
2013-01-06 17:04                       ` Federico Vaga
2013-01-06 23:09                       ` Alessandro Rubini
2013-01-07 19:40                         ` Jonathan Corbet
2013-01-07 20:15                           ` Mauro Carvalho Chehab
2013-01-08  6:50                             ` Marek Szyprowski
2013-01-08 14:31                               ` Jonathan Corbet
2013-01-09  7:48                                 ` Michael Olbrich
2012-09-24 10:58 ` [PATCH v3 3/4] sta2x11_vip: convert to videobuf2 and control framework Federico Vaga
2012-12-04 16:15   ` Mauro Carvalho Chehab
2012-12-05  1:12     ` Federico Vaga
2012-12-05 11:34       ` Mauro Carvalho Chehab
2012-12-05 12:24         ` Federico Vaga
2012-12-05 13:10           ` Mauro Carvalho Chehab
2012-12-05 13:27             ` Federico Vaga
2012-12-05 13:37               ` Mauro Carvalho Chehab
2012-12-05 13:45                 ` Federico Vaga
2012-12-06 18:59             ` Federico Vaga
2012-09-24 10:58 ` [PATCH v3 4/4] adv7180: remove {query/g_/s_}ctrl Federico Vaga
2012-09-24 12:46 ` [PATCH v3 1/4] v4l: vb2: add prepare/finish callbacks to allocators Marek Szyprowski
2012-09-25 15:04 ` Federico Vaga [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1348585440-5385-1-git-send-email-federico.vaga@gmail.com \
    --to=federico.vaga@gmail.com \
    --cc=corbet@lwn.net \
    --cc=giancarlo.asnaghi@st.com \
    --cc=hans.verkuil@cisco.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mchehab@infradead.org \
    --cc=pawel@osciak.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).