All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC v2 00/10] V4L2 mem-to-mem ioctl helpers
@ 2013-10-12 12:31 Sylwester Nawrocki
  2013-10-12 12:31 ` [PATCH RFC v2 01/10] V4L: Add mem2mem ioctl and file operation helpers Sylwester Nawrocki
                   ` (10 more replies)
  0 siblings, 11 replies; 19+ messages in thread
From: Sylwester Nawrocki @ 2013-10-12 12:31 UTC (permalink / raw)
  To: linux-media
  Cc: hverkuil, pawel, javier.martin, m.szyprowski, shaik.ameer,
	arun.kk, k.debski, p.zabel, kyungmin.park, linux-samsung-soc,
	Sylwester Nawrocki

Hello,

This patch set adds ioctl helpers to the v4l2-mem2mem module so the
video mem-to-mem drivers can be simplified by removing functions that
are only a pass-through to the v4l2_m2m_* calls. In addition some of
the vb2 helper functions can be used as well.

These helpers are similar to the videobuf2 ioctl helpers introduced
in commit 4c1ffcaad5 "[media] videobuf2-core: add helper functions".

Currently the requirements to use helper function introduced in this
patch set is that both OUTPUT and CAPTURE vb2 buffer queues must use
same lock and the driver uses struct v4l2_fh.

I have only tested the first four patches in this series, Tested-by
for the mx2-emmaprp, exynos-gsc, s5p-g2d drivers are appreciated.

This patch series can be also found at:
 git://linuxtv.org/snawrocki/samsung.git m2m-helpers-v3

Changes since original version include addition of related cleanup
patches, added helper function for create_buf ioctl and m2m context
pointer from struct v4l2_fh is now reused and related field from the
drivers' private data structure is removed.

Thank you for all reviews. I plan to queue the first four patches for
next kernel release early this week. For the mx2-emmaprp, exynos-gsc,
s5p-g2d driver feedback is needed from someone who can actually test
the changes. Any Tested-by for those drivers would be appreciated.

Thanks,
Sylwester

Sylwester Nawrocki (10):
  V4L: Add mem2mem ioctl and file operation helpers
  mem2mem_testdev: Use mem-to-mem ioctl and vb2 helpers
  exynos4-is: Use mem-to-mem ioctl helpers
  s5p-jpeg: Use mem-to-mem ioctl helpers
  mx2-emmaprp: Use struct v4l2_fh
  mx2-emmaprp: Use mem-to-mem ioctl helpers
  exynos-gsc: Configure default image format at device open()
  exynos-gsc: Remove GSC_{SRC, DST}_FMT flags
  exynos-gsc: Use mem-to-mem ioctl helpers
  s5p-g2d: Use mem-to-mem ioctl helpers

 drivers/media/platform/exynos-gsc/gsc-core.c  |   10 +-
 drivers/media/platform/exynos-gsc/gsc-core.h  |   14 --
 drivers/media/platform/exynos-gsc/gsc-m2m.c   |  232 ++++++++-----------------
 drivers/media/platform/exynos4-is/fimc-core.h |    2 -
 drivers/media/platform/exynos4-is/fimc-m2m.c  |  148 +++-------------
 drivers/media/platform/mem2mem_testdev.c      |  152 +++-------------
 drivers/media/platform/mx2_emmaprp.c          |  185 ++++++--------------
 drivers/media/platform/s5p-g2d/g2d.c          |  124 +++-----------
 drivers/media/platform/s5p-g2d/g2d.h          |    1 -
 drivers/media/platform/s5p-jpeg/jpeg-core.c   |  134 +++------------
 drivers/media/platform/s5p-jpeg/jpeg-core.h   |    2 -
 drivers/media/v4l2-core/v4l2-mem2mem.c        |  118 +++++++++++++
 include/media/v4l2-fh.h                       |    4 +
 include/media/v4l2-mem2mem.h                  |   24 +++
 14 files changed, 382 insertions(+), 768 deletions(-)

--
1.7.4.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH RFC v2 01/10] V4L: Add mem2mem ioctl and file operation helpers
  2013-10-12 12:31 [PATCH RFC v2 00/10] V4L2 mem-to-mem ioctl helpers Sylwester Nawrocki
@ 2013-10-12 12:31 ` Sylwester Nawrocki
  2013-10-12 12:38   ` [PATCH RFC v2.1 " Sylwester Nawrocki
  2013-10-12 12:31 ` [PATCH RFC v2 02/10] mem2mem_testdev: Use mem-to-mem ioctl and vb2 helpers Sylwester Nawrocki
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 19+ messages in thread
From: Sylwester Nawrocki @ 2013-10-12 12:31 UTC (permalink / raw)
  To: linux-media
  Cc: hverkuil, pawel, javier.martin, m.szyprowski, shaik.ameer,
	arun.kk, k.debski, p.zabel, kyungmin.park, linux-samsung-soc,
	Sylwester Nawrocki

This patch adds ioctl helpers to the V4L2 mem-to-mem API, so we can avoid
several ioctl handlers in the mem-to-mem video node drivers that are simply
a pass-through to the v4l2_m2m_* calls. These helpers will only be useful
for drivers that use same mutex for both OUTPUT and CAPTURE queue, which
is the case for all currently in tree v4l2 m2m drivers. In order to use
the helpers the drivers are required to use struct v4l2_fh.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
---
Changes since v1:
 - added v4l2_m2m_ioctl_create_buf().
---
 drivers/media/v4l2-core/v4l2-mem2mem.c |  118 ++++++++++++++++++++++++++++++++
 include/media/v4l2-fh.h                |    4 +
 include/media/v4l2-mem2mem.h           |   24 +++++++
 3 files changed, 146 insertions(+), 0 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c
index 7c43712..b7414cf 100644
--- a/drivers/media/v4l2-core/v4l2-mem2mem.c
+++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
@@ -544,6 +544,8 @@ unsigned int v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
 
 	if (m2m_ctx->m2m_dev->m2m_ops->unlock)
 		m2m_ctx->m2m_dev->m2m_ops->unlock(m2m_ctx->priv);
+	else if (m2m_ctx->q_lock)
+		mutex_unlock(m2m_ctx->q_lock);
 
 	if (list_empty(&src_q->done_list))
 		poll_wait(file, &src_q->done_wq, wait);
@@ -552,6 +554,8 @@ unsigned int v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
 
 	if (m2m_ctx->m2m_dev->m2m_ops->lock)
 		m2m_ctx->m2m_dev->m2m_ops->lock(m2m_ctx->priv);
+	else if (m2m_ctx->q_lock)
+		mutex_lock(m2m_ctx->q_lock);
 
 	spin_lock_irqsave(&src_q->done_lock, flags);
 	if (!list_empty(&src_q->done_list))
@@ -679,6 +683,13 @@ struct v4l2_m2m_ctx *v4l2_m2m_ctx_init(struct v4l2_m2m_dev *m2m_dev,
 
 	if (ret)
 		goto err;
+	/*
+	 * If both queues use same mutex assign it as the common buffer
+	 * queues lock to the m2m context. This lock is used in the
+	 * v4l2_m2m_ioctl_* helpers.
+	 */
+	if (out_q_ctx->q.lock == cap_q_ctx->q.lock)
+		m2m_ctx->q_lock = out_q_ctx->q.lock;
 
 	return m2m_ctx;
 err:
@@ -726,3 +737,110 @@ void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx, struct vb2_buffer *vb)
 }
 EXPORT_SYMBOL_GPL(v4l2_m2m_buf_queue);
 
+/* Videobuf2 ioctl helpers */
+
+int v4l2_m2m_ioctl_reqbufs(struct file *file, void *priv,
+				struct v4l2_requestbuffers *rb)
+{
+	struct v4l2_fh *fh = file->private_data;
+	return v4l2_m2m_reqbufs(file, fh->m2m_ctx, rb);
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_reqbufs);
+
+int v4l2_m2m_ioctl_create_bufs(struct file *file, void *priv,
+				struct v4l2_create_buffers *create)
+{
+	struct v4l2_fh *fh = file->private_data;
+	return v4l2_m2m_create_bufs(file, fh->m2m_ctx, create);
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_create_bufs);
+
+int v4l2_m2m_ioctl_querybuf(struct file *file, void *priv,
+				struct v4l2_buffer *buf)
+{
+	struct v4l2_fh *fh = file->private_data;
+	return v4l2_m2m_querybuf(file, fh->m2m_ctx, buf);
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_querybuf);
+
+int v4l2_m2m_ioctl_qbuf(struct file *file, void *priv,
+				struct v4l2_buffer *buf)
+{
+	struct v4l2_fh *fh = file->private_data;
+	return v4l2_m2m_qbuf(file, fh->m2m_ctx, buf);
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_qbuf);
+
+int v4l2_m2m_ioctl_dqbuf(struct file *file, void *priv,
+				struct v4l2_buffer *buf)
+{
+	struct v4l2_fh *fh = file->private_data;
+	return v4l2_m2m_dqbuf(file, fh->m2m_ctx, buf);
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_dqbuf);
+
+int v4l2_m2m_ioctl_expbuf(struct file *file, void *priv,
+				struct v4l2_exportbuffer *eb)
+{
+	struct v4l2_fh *fh = file->private_data;
+	return v4l2_m2m_expbuf(file, fh->m2m_ctx, eb);
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_expbuf);
+
+int v4l2_m2m_ioctl_streamon(struct file *file, void *priv,
+				enum v4l2_buf_type type)
+{
+	struct v4l2_fh *fh = file->private_data;
+	return v4l2_m2m_streamon(file, fh->m2m_ctx, type);
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_streamon);
+
+int v4l2_m2m_ioctl_streamoff(struct file *file, void *priv,
+				enum v4l2_buf_type type)
+{
+	struct v4l2_fh *fh = file->private_data;
+	return v4l2_m2m_streamoff(file, fh->m2m_ctx, type);
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_streamoff);
+
+/*
+ * v4l2_file_operations helpers. It is assumed here same lock is used
+ * for the output and the capture buffer queue.
+ */
+
+int v4l2_m2m_fop_mmap(struct file *file, struct vm_area_struct *vma)
+{
+	struct v4l2_fh *fh = file->private_data;
+	struct v4l2_m2m_ctx *m2m_ctx = fh->m2m_ctx;
+	int ret;
+
+	if (m2m_ctx->q_lock && mutex_lock_interruptible(m2m_ctx->q_lock))
+		return -ERESTARTSYS;
+
+	ret = v4l2_m2m_mmap(file, m2m_ctx, vma);
+
+	if (m2m_ctx->q_lock)
+		mutex_unlock(m2m_ctx->q_lock);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_fop_mmap);
+
+unsigned int v4l2_m2m_fop_poll(struct file *file, poll_table *wait)
+{
+	struct v4l2_fh *fh = file->private_data;
+	struct v4l2_m2m_ctx *m2m_ctx = fh->m2m_ctx;
+	unsigned int ret;
+
+	if (m2m_ctx->q_lock)
+		mutex_lock(m2m_ctx->q_lock);
+
+	ret = v4l2_m2m_poll(file, m2m_ctx, wait);
+
+	if (m2m_ctx->q_lock)
+		mutex_unlock(m2m_ctx->q_lock);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_fop_poll);
+
diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
index a62ee18..d942f79 100644
--- a/include/media/v4l2-fh.h
+++ b/include/media/v4l2-fh.h
@@ -43,6 +43,10 @@ struct v4l2_fh {
 	struct list_head	available; /* Dequeueable event */
 	unsigned int		navailable;
 	u32			sequence;
+
+#if IS_ENABLED(CONFIG_V4L2_MEM2MEM_DEV)
+	struct v4l2_m2m_ctx	*m2m_ctx;
+#endif
 };
 
 /*
diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h
index 44542a2..12ea5a6 100644
--- a/include/media/v4l2-mem2mem.h
+++ b/include/media/v4l2-mem2mem.h
@@ -64,6 +64,9 @@ struct v4l2_m2m_queue_ctx {
 };
 
 struct v4l2_m2m_ctx {
+	/* optional cap/out vb2 queues lock */
+	struct mutex			*q_lock;
+
 /* private: internal use only */
 	struct v4l2_m2m_dev		*m2m_dev;
 
@@ -229,5 +232,26 @@ static inline void *v4l2_m2m_dst_buf_remove(struct v4l2_m2m_ctx *m2m_ctx)
 	return v4l2_m2m_buf_remove(&m2m_ctx->cap_q_ctx);
 }
 
+/* v4l2 ioctl helpers */
+
+int v4l2_m2m_ioctl_reqbufs(struct file *file, void *priv,
+				struct v4l2_requestbuffers *rb);
+int v4l2_m2m_ioctl_create_bufs(struct file *file, void *fh,
+				struct v4l2_create_buffers *create);
+int v4l2_m2m_ioctl_querybuf(struct file *file, void *fh,
+				struct v4l2_buffer *buf);
+int v4l2_m2m_ioctl_expbuf(struct file *file, void *fh,
+				struct v4l2_exportbuffer *eb);
+int v4l2_m2m_ioctl_qbuf(struct file *file, void *fh,
+				struct v4l2_buffer *buf);
+int v4l2_m2m_ioctl_dqbuf(struct file *file, void *fh,
+				struct v4l2_buffer *buf);
+int v4l2_m2m_ioctl_streamon(struct file *file, void *fh,
+				enum v4l2_buf_type type);
+int v4l2_m2m_ioctl_streamoff(struct file *file, void *fh,
+				enum v4l2_buf_type type);
+int v4l2_m2m_fop_mmap(struct file *file, struct vm_area_struct *vma);
+unsigned int v4l2_m2m_fop_poll(struct file *file, poll_table *wait);
+
 #endif /* _MEDIA_V4L2_MEM2MEM_H */
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC v2 02/10] mem2mem_testdev: Use mem-to-mem ioctl and vb2 helpers
  2013-10-12 12:31 [PATCH RFC v2 00/10] V4L2 mem-to-mem ioctl helpers Sylwester Nawrocki
  2013-10-12 12:31 ` [PATCH RFC v2 01/10] V4L: Add mem2mem ioctl and file operation helpers Sylwester Nawrocki
@ 2013-10-12 12:31 ` Sylwester Nawrocki
  2013-10-16 11:31   ` Kamil Debski
  2013-10-12 12:31 ` [PATCH RFC v2 03/10] exynos4-is: Use mem-to-mem ioctl helpers Sylwester Nawrocki
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 19+ messages in thread
From: Sylwester Nawrocki @ 2013-10-12 12:31 UTC (permalink / raw)
  To: linux-media
  Cc: hverkuil, pawel, javier.martin, m.szyprowski, shaik.ameer,
	arun.kk, k.debski, p.zabel, kyungmin.park, linux-samsung-soc,
	Sylwester Nawrocki

Simplify the driver by using the m2m ioctl and vb2 helpers.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
Changes since v1:
 - dropped now redundant struct m2mtest_ctx::m2m_ctx field.
---
 drivers/media/platform/mem2mem_testdev.c |  152 ++++++------------------------
 1 files changed, 28 insertions(+), 124 deletions(-)

diff --git a/drivers/media/platform/mem2mem_testdev.c b/drivers/media/platform/mem2mem_testdev.c
index 6a17676..a348c07 100644
--- a/drivers/media/platform/mem2mem_testdev.c
+++ b/drivers/media/platform/mem2mem_testdev.c
@@ -177,8 +177,6 @@ struct m2mtest_ctx {
 
 	enum v4l2_colorspace	colorspace;
 
-	struct v4l2_m2m_ctx	*m2m_ctx;
-
 	/* Source and destination queue data */
 	struct m2mtest_q_data   q_data[2];
 };
@@ -342,8 +340,8 @@ static int job_ready(void *priv)
 {
 	struct m2mtest_ctx *ctx = priv;
 
-	if (v4l2_m2m_num_src_bufs_ready(ctx->m2m_ctx) < ctx->translen
-	    || v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx) < ctx->translen) {
+	if (v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx) < ctx->translen
+	    || v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx) < ctx->translen) {
 		dprintk(ctx->dev, "Not enough buffers available\n");
 		return 0;
 	}
@@ -359,21 +357,6 @@ static void job_abort(void *priv)
 	ctx->aborting = 1;
 }
 
-static void m2mtest_lock(void *priv)
-{
-	struct m2mtest_ctx *ctx = priv;
-	struct m2mtest_dev *dev = ctx->dev;
-	mutex_lock(&dev->dev_mutex);
-}
-
-static void m2mtest_unlock(void *priv)
-{
-	struct m2mtest_ctx *ctx = priv;
-	struct m2mtest_dev *dev = ctx->dev;
-	mutex_unlock(&dev->dev_mutex);
-}
-
-
 /* device_run() - prepares and starts the device
  *
  * This simulates all the immediate preparations required before starting
@@ -386,8 +369,8 @@ static void device_run(void *priv)
 	struct m2mtest_dev *dev = ctx->dev;
 	struct vb2_buffer *src_buf, *dst_buf;
 
-	src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
-	dst_buf = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
+	src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
+	dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
 
 	device_process(ctx, src_buf, dst_buf);
 
@@ -409,8 +392,8 @@ static void device_isr(unsigned long priv)
 		return;
 	}
 
-	src_vb = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx);
-	dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx);
+	src_vb = v4l2_m2m_src_buf_remove(curr_ctx->fh.m2m_ctx);
+	dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->fh.m2m_ctx);
 
 	curr_ctx->num_processed++;
 
@@ -423,7 +406,7 @@ static void device_isr(unsigned long priv)
 	    || curr_ctx->aborting) {
 		dprintk(curr_ctx->dev, "Finishing transaction\n");
 		curr_ctx->num_processed = 0;
-		v4l2_m2m_job_finish(m2mtest_dev->m2m_dev, curr_ctx->m2m_ctx);
+		v4l2_m2m_job_finish(m2mtest_dev->m2m_dev, curr_ctx->fh.m2m_ctx);
 	} else {
 		device_run(curr_ctx);
 	}
@@ -491,7 +474,7 @@ static int vidioc_g_fmt(struct m2mtest_ctx *ctx, struct v4l2_format *f)
 	struct vb2_queue *vq;
 	struct m2mtest_q_data *q_data;
 
-	vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
+	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
 	if (!vq)
 		return -EINVAL;
 
@@ -594,7 +577,7 @@ static int vidioc_s_fmt(struct m2mtest_ctx *ctx, struct v4l2_format *f)
 	struct m2mtest_q_data *q_data;
 	struct vb2_queue *vq;
 
-	vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
+	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
 	if (!vq)
 		return -EINVAL;
 
@@ -648,52 +631,6 @@ static int vidioc_s_fmt_vid_out(struct file *file, void *priv,
 	return ret;
 }
 
-static int vidioc_reqbufs(struct file *file, void *priv,
-			  struct v4l2_requestbuffers *reqbufs)
-{
-	struct m2mtest_ctx *ctx = file2ctx(file);
-
-	return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
-}
-
-static int vidioc_querybuf(struct file *file, void *priv,
-			   struct v4l2_buffer *buf)
-{
-	struct m2mtest_ctx *ctx = file2ctx(file);
-
-	return v4l2_m2m_querybuf(file, ctx->m2m_ctx, buf);
-}
-
-static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
-{
-	struct m2mtest_ctx *ctx = file2ctx(file);
-
-	return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
-}
-
-static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
-{
-	struct m2mtest_ctx *ctx = file2ctx(file);
-
-	return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
-}
-
-static int vidioc_streamon(struct file *file, void *priv,
-			   enum v4l2_buf_type type)
-{
-	struct m2mtest_ctx *ctx = file2ctx(file);
-
-	return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
-}
-
-static int vidioc_streamoff(struct file *file, void *priv,
-			    enum v4l2_buf_type type)
-{
-	struct m2mtest_ctx *ctx = file2ctx(file);
-
-	return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
-}
-
 static int m2mtest_s_ctrl(struct v4l2_ctrl *ctrl)
 {
 	struct m2mtest_ctx *ctx =
@@ -748,14 +685,14 @@ static const struct v4l2_ioctl_ops m2mtest_ioctl_ops = {
 	.vidioc_try_fmt_vid_out	= vidioc_try_fmt_vid_out,
 	.vidioc_s_fmt_vid_out	= vidioc_s_fmt_vid_out,
 
-	.vidioc_reqbufs		= vidioc_reqbufs,
-	.vidioc_querybuf	= vidioc_querybuf,
+	.vidioc_reqbufs		= v4l2_m2m_ioctl_reqbufs,
+	.vidioc_querybuf	= v4l2_m2m_ioctl_querybuf,
+	.vidioc_qbuf		= v4l2_m2m_ioctl_qbuf,
+	.vidioc_dqbuf		= v4l2_m2m_ioctl_dqbuf,
 
-	.vidioc_qbuf		= vidioc_qbuf,
-	.vidioc_dqbuf		= vidioc_dqbuf,
+	.vidioc_streamon	= v4l2_m2m_ioctl_streamon,
+	.vidioc_streamoff	= v4l2_m2m_ioctl_streamoff,
 
-	.vidioc_streamon	= vidioc_streamon,
-	.vidioc_streamoff	= vidioc_streamoff,
 	.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
 	.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
 };
@@ -818,27 +755,15 @@ static int m2mtest_buf_prepare(struct vb2_buffer *vb)
 static void m2mtest_buf_queue(struct vb2_buffer *vb)
 {
 	struct m2mtest_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
-	v4l2_m2m_buf_queue(ctx->m2m_ctx, vb);
-}
-
-static void m2mtest_wait_prepare(struct vb2_queue *q)
-{
-	struct m2mtest_ctx *ctx = vb2_get_drv_priv(q);
-	m2mtest_unlock(ctx);
-}
-
-static void m2mtest_wait_finish(struct vb2_queue *q)
-{
-	struct m2mtest_ctx *ctx = vb2_get_drv_priv(q);
-	m2mtest_lock(ctx);
+	v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vb);
 }
 
 static struct vb2_ops m2mtest_qops = {
 	.queue_setup	 = m2mtest_queue_setup,
 	.buf_prepare	 = m2mtest_buf_prepare,
 	.buf_queue	 = m2mtest_buf_queue,
-	.wait_prepare	 = m2mtest_wait_prepare,
-	.wait_finish	 = m2mtest_wait_finish,
+	.wait_prepare	 = vb2_ops_wait_prepare,
+	.wait_finish	 = vb2_ops_wait_finish,
 };
 
 static int queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq)
@@ -853,6 +778,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *ds
 	src_vq->ops = &m2mtest_qops;
 	src_vq->mem_ops = &vb2_vmalloc_memops;
 	src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+	src_vq->lock = &ctx->dev->dev_mutex;
 
 	ret = vb2_queue_init(src_vq);
 	if (ret)
@@ -865,6 +791,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *ds
 	dst_vq->ops = &m2mtest_qops;
 	dst_vq->mem_ops = &vb2_vmalloc_memops;
 	dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+	dst_vq->lock = &ctx->dev->dev_mutex;
 
 	return vb2_queue_init(dst_vq);
 }
@@ -936,10 +863,10 @@ static int m2mtest_open(struct file *file)
 	ctx->q_data[V4L2_M2M_DST] = ctx->q_data[V4L2_M2M_SRC];
 	ctx->colorspace = V4L2_COLORSPACE_REC709;
 
-	ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init);
+	ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init);
 
-	if (IS_ERR(ctx->m2m_ctx)) {
-		rc = PTR_ERR(ctx->m2m_ctx);
+	if (IS_ERR(ctx->fh.m2m_ctx)) {
+		rc = PTR_ERR(ctx->fh.m2m_ctx);
 
 		v4l2_ctrl_handler_free(hdl);
 		kfree(ctx);
@@ -949,7 +876,8 @@ static int m2mtest_open(struct file *file)
 	v4l2_fh_add(&ctx->fh);
 	atomic_inc(&dev->num_inst);
 
-	dprintk(dev, "Created instance %p, m2m_ctx: %p\n", ctx, ctx->m2m_ctx);
+	dprintk(dev, "Created instance: %p, m2m_ctx: %p\n",
+		ctx, ctx->fh.m2m_ctx);
 
 open_unlock:
 	mutex_unlock(&dev->dev_mutex);
@@ -967,7 +895,7 @@ static int m2mtest_release(struct file *file)
 	v4l2_fh_exit(&ctx->fh);
 	v4l2_ctrl_handler_free(&ctx->hdl);
 	mutex_lock(&dev->dev_mutex);
-	v4l2_m2m_ctx_release(ctx->m2m_ctx);
+	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
 	mutex_unlock(&dev->dev_mutex);
 	kfree(ctx);
 
@@ -976,34 +904,13 @@ static int m2mtest_release(struct file *file)
 	return 0;
 }
 
-static unsigned int m2mtest_poll(struct file *file,
-				 struct poll_table_struct *wait)
-{
-	struct m2mtest_ctx *ctx = file2ctx(file);
-
-	return v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
-}
-
-static int m2mtest_mmap(struct file *file, struct vm_area_struct *vma)
-{
-	struct m2mtest_dev *dev = video_drvdata(file);
-	struct m2mtest_ctx *ctx = file2ctx(file);
-	int res;
-
-	if (mutex_lock_interruptible(&dev->dev_mutex))
-		return -ERESTARTSYS;
-	res = v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
-	mutex_unlock(&dev->dev_mutex);
-	return res;
-}
-
 static const struct v4l2_file_operations m2mtest_fops = {
 	.owner		= THIS_MODULE,
 	.open		= m2mtest_open,
 	.release	= m2mtest_release,
-	.poll		= m2mtest_poll,
+	.poll		= v4l2_m2m_fop_poll,
 	.unlocked_ioctl	= video_ioctl2,
-	.mmap		= m2mtest_mmap,
+	.mmap		= v4l2_m2m_fop_mmap,
 };
 
 static struct video_device m2mtest_videodev = {
@@ -1019,8 +926,6 @@ static struct v4l2_m2m_ops m2m_ops = {
 	.device_run	= device_run,
 	.job_ready	= job_ready,
 	.job_abort	= job_abort,
-	.lock		= m2mtest_lock,
-	.unlock		= m2mtest_unlock,
 };
 
 static int m2mtest_probe(struct platform_device *pdev)
@@ -1134,4 +1039,3 @@ static int __init m2mtest_init(void)
 
 module_init(m2mtest_init);
 module_exit(m2mtest_exit);
-
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC v2 03/10] exynos4-is: Use mem-to-mem ioctl helpers
  2013-10-12 12:31 [PATCH RFC v2 00/10] V4L2 mem-to-mem ioctl helpers Sylwester Nawrocki
  2013-10-12 12:31 ` [PATCH RFC v2 01/10] V4L: Add mem2mem ioctl and file operation helpers Sylwester Nawrocki
  2013-10-12 12:31 ` [PATCH RFC v2 02/10] mem2mem_testdev: Use mem-to-mem ioctl and vb2 helpers Sylwester Nawrocki
@ 2013-10-12 12:31 ` Sylwester Nawrocki
  2013-10-16 11:31   ` Kamil Debski
  2013-10-12 12:31 ` [PATCH RFC v2 04/10] s5p-jpeg: " Sylwester Nawrocki
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 19+ messages in thread
From: Sylwester Nawrocki @ 2013-10-12 12:31 UTC (permalink / raw)
  To: linux-media
  Cc: hverkuil, pawel, javier.martin, m.szyprowski, shaik.ameer,
	arun.kk, k.debski, p.zabel, kyungmin.park, linux-samsung-soc,
	Sylwester Nawrocki

Simplify the FIMC mem-to-mem driver by using the m2m ioctl
and vb2 helpers.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
Changes since v1:
 - use m2m context pointer from struct v4l2_fh.
---
 drivers/media/platform/exynos4-is/fimc-core.h |    2 -
 drivers/media/platform/exynos4-is/fimc-m2m.c  |  148 +++++--------------------
 2 files changed, 26 insertions(+), 124 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-core.h b/drivers/media/platform/exynos4-is/fimc-core.h
index 3d376fa..1790fb4 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.h
+++ b/drivers/media/platform/exynos4-is/fimc-core.h
@@ -481,7 +481,6 @@ struct fimc_ctrls {
  * @flags:		additional flags for image conversion
  * @state:		flags to keep track of user configuration
  * @fimc_dev:		the FIMC device this context applies to
- * @m2m_ctx:		memory-to-memory device context
  * @fh:			v4l2 file handle
  * @ctrls:		v4l2 controls structure
  */
@@ -502,7 +501,6 @@ struct fimc_ctx {
 	u32			flags;
 	u32			state;
 	struct fimc_dev		*fimc_dev;
-	struct v4l2_m2m_ctx	*m2m_ctx;
 	struct v4l2_fh		fh;
 	struct fimc_ctrls	ctrls;
 };
diff --git a/drivers/media/platform/exynos4-is/fimc-m2m.c b/drivers/media/platform/exynos4-is/fimc-m2m.c
index 8d33b68..9da95bd 100644
--- a/drivers/media/platform/exynos4-is/fimc-m2m.c
+++ b/drivers/media/platform/exynos4-is/fimc-m2m.c
@@ -44,17 +44,17 @@ void fimc_m2m_job_finish(struct fimc_ctx *ctx, int vb_state)
 {
 	struct vb2_buffer *src_vb, *dst_vb;
 
-	if (!ctx || !ctx->m2m_ctx)
+	if (!ctx || !ctx->fh.m2m_ctx)
 		return;
 
-	src_vb = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
-	dst_vb = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
+	src_vb = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
+	dst_vb = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
 
 	if (src_vb && dst_vb) {
 		v4l2_m2m_buf_done(src_vb, vb_state);
 		v4l2_m2m_buf_done(dst_vb, vb_state);
 		v4l2_m2m_job_finish(ctx->fimc_dev->m2m.m2m_dev,
-				    ctx->m2m_ctx);
+				    ctx->fh.m2m_ctx);
 	}
 }
 
@@ -123,12 +123,12 @@ static void fimc_device_run(void *priv)
 		fimc_prepare_dma_offset(ctx, df);
 	}
 
-	src_vb = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
+	src_vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
 	ret = fimc_prepare_addr(ctx, src_vb, sf, &sf->paddr);
 	if (ret)
 		goto dma_unlock;
 
-	dst_vb = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
+	dst_vb = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
 	ret = fimc_prepare_addr(ctx, dst_vb, df, &df->paddr);
 	if (ret)
 		goto dma_unlock;
@@ -219,31 +219,15 @@ static int fimc_buf_prepare(struct vb2_buffer *vb)
 static void fimc_buf_queue(struct vb2_buffer *vb)
 {
 	struct fimc_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
-
-	dbg("ctx: %p, ctx->state: 0x%x", ctx, ctx->state);
-
-	if (ctx->m2m_ctx)
-		v4l2_m2m_buf_queue(ctx->m2m_ctx, vb);
-}
-
-static void fimc_lock(struct vb2_queue *vq)
-{
-	struct fimc_ctx *ctx = vb2_get_drv_priv(vq);
-	mutex_lock(&ctx->fimc_dev->lock);
-}
-
-static void fimc_unlock(struct vb2_queue *vq)
-{
-	struct fimc_ctx *ctx = vb2_get_drv_priv(vq);
-	mutex_unlock(&ctx->fimc_dev->lock);
+	v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vb);
 }
 
 static struct vb2_ops fimc_qops = {
 	.queue_setup	 = fimc_queue_setup,
 	.buf_prepare	 = fimc_buf_prepare,
 	.buf_queue	 = fimc_buf_queue,
-	.wait_prepare	 = fimc_unlock,
-	.wait_finish	 = fimc_lock,
+	.wait_prepare	 = vb2_ops_wait_prepare,
+	.wait_finish	 = vb2_ops_wait_finish,
 	.stop_streaming	 = stop_streaming,
 	.start_streaming = start_streaming,
 };
@@ -385,7 +369,7 @@ static int fimc_m2m_s_fmt_mplane(struct file *file, void *fh,
 	if (ret)
 		return ret;
 
-	vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
+	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
 
 	if (vb2_is_busy(vq)) {
 		v4l2_err(&fimc->m2m.vfd, "queue (%d) busy\n", f->type);
@@ -410,56 +394,6 @@ static int fimc_m2m_s_fmt_mplane(struct file *file, void *fh,
 	return 0;
 }
 
-static int fimc_m2m_reqbufs(struct file *file, void *fh,
-			    struct v4l2_requestbuffers *reqbufs)
-{
-	struct fimc_ctx *ctx = fh_to_ctx(fh);
-	return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
-}
-
-static int fimc_m2m_querybuf(struct file *file, void *fh,
-			     struct v4l2_buffer *buf)
-{
-	struct fimc_ctx *ctx = fh_to_ctx(fh);
-	return v4l2_m2m_querybuf(file, ctx->m2m_ctx, buf);
-}
-
-static int fimc_m2m_qbuf(struct file *file, void *fh,
-			 struct v4l2_buffer *buf)
-{
-	struct fimc_ctx *ctx = fh_to_ctx(fh);
-	return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
-}
-
-static int fimc_m2m_dqbuf(struct file *file, void *fh,
-			  struct v4l2_buffer *buf)
-{
-	struct fimc_ctx *ctx = fh_to_ctx(fh);
-	return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
-}
-
-static int fimc_m2m_expbuf(struct file *file, void *fh,
-			    struct v4l2_exportbuffer *eb)
-{
-	struct fimc_ctx *ctx = fh_to_ctx(fh);
-	return v4l2_m2m_expbuf(file, ctx->m2m_ctx, eb);
-}
-
-
-static int fimc_m2m_streamon(struct file *file, void *fh,
-			     enum v4l2_buf_type type)
-{
-	struct fimc_ctx *ctx = fh_to_ctx(fh);
-	return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
-}
-
-static int fimc_m2m_streamoff(struct file *file, void *fh,
-			    enum v4l2_buf_type type)
-{
-	struct fimc_ctx *ctx = fh_to_ctx(fh);
-	return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
-}
-
 static int fimc_m2m_cropcap(struct file *file, void *fh,
 			    struct v4l2_cropcap *cr)
 {
@@ -598,13 +532,13 @@ static const struct v4l2_ioctl_ops fimc_m2m_ioctl_ops = {
 	.vidioc_try_fmt_vid_out_mplane	= fimc_m2m_try_fmt_mplane,
 	.vidioc_s_fmt_vid_cap_mplane	= fimc_m2m_s_fmt_mplane,
 	.vidioc_s_fmt_vid_out_mplane	= fimc_m2m_s_fmt_mplane,
-	.vidioc_reqbufs			= fimc_m2m_reqbufs,
-	.vidioc_querybuf		= fimc_m2m_querybuf,
-	.vidioc_qbuf			= fimc_m2m_qbuf,
-	.vidioc_dqbuf			= fimc_m2m_dqbuf,
-	.vidioc_expbuf			= fimc_m2m_expbuf,
-	.vidioc_streamon		= fimc_m2m_streamon,
-	.vidioc_streamoff		= fimc_m2m_streamoff,
+	.vidioc_reqbufs			= v4l2_m2m_ioctl_reqbufs,
+	.vidioc_querybuf		= v4l2_m2m_ioctl_querybuf,
+	.vidioc_qbuf			= v4l2_m2m_ioctl_qbuf,
+	.vidioc_dqbuf			= v4l2_m2m_ioctl_dqbuf,
+	.vidioc_expbuf			= v4l2_m2m_ioctl_expbuf,
+	.vidioc_streamon		= v4l2_m2m_ioctl_streamon,
+	.vidioc_streamoff		= v4l2_m2m_ioctl_streamoff,
 	.vidioc_g_crop			= fimc_m2m_g_crop,
 	.vidioc_s_crop			= fimc_m2m_s_crop,
 	.vidioc_cropcap			= fimc_m2m_cropcap
@@ -624,6 +558,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
 	src_vq->mem_ops = &vb2_dma_contig_memops;
 	src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
 	src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+	src_vq->lock = &ctx->fimc_dev->lock;
 
 	ret = vb2_queue_init(src_vq);
 	if (ret)
@@ -636,6 +571,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
 	dst_vq->mem_ops = &vb2_dma_contig_memops;
 	dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
 	dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+	dst_vq->lock = &ctx->fimc_dev->lock;
 
 	return vb2_queue_init(dst_vq);
 }
@@ -708,9 +644,9 @@ static int fimc_m2m_open(struct file *file)
 	ctx->out_path = FIMC_IO_DMA;
 	ctx->scaler.enabled = 1;
 
-	ctx->m2m_ctx = v4l2_m2m_ctx_init(fimc->m2m.m2m_dev, ctx, queue_init);
-	if (IS_ERR(ctx->m2m_ctx)) {
-		ret = PTR_ERR(ctx->m2m_ctx);
+	ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(fimc->m2m.m2m_dev, ctx, queue_init);
+	if (IS_ERR(ctx->fh.m2m_ctx)) {
+		ret = PTR_ERR(ctx->fh.m2m_ctx);
 		goto error_c;
 	}
 
@@ -725,7 +661,7 @@ static int fimc_m2m_open(struct file *file)
 	return 0;
 
 error_m2m_ctx:
-	v4l2_m2m_ctx_release(ctx->m2m_ctx);
+	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
 error_c:
 	fimc_ctrls_delete(ctx);
 error_fh:
@@ -747,7 +683,7 @@ static int fimc_m2m_release(struct file *file)
 
 	mutex_lock(&fimc->lock);
 
-	v4l2_m2m_ctx_release(ctx->m2m_ctx);
+	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
 	fimc_ctrls_delete(ctx);
 	v4l2_fh_del(&ctx->fh);
 	v4l2_fh_exit(&ctx->fh);
@@ -760,45 +696,13 @@ static int fimc_m2m_release(struct file *file)
 	return 0;
 }
 
-static unsigned int fimc_m2m_poll(struct file *file,
-				  struct poll_table_struct *wait)
-{
-	struct fimc_ctx *ctx = fh_to_ctx(file->private_data);
-	struct fimc_dev *fimc = ctx->fimc_dev;
-	int ret;
-
-	if (mutex_lock_interruptible(&fimc->lock))
-		return -ERESTARTSYS;
-
-	ret = v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
-	mutex_unlock(&fimc->lock);
-
-	return ret;
-}
-
-
-static int fimc_m2m_mmap(struct file *file, struct vm_area_struct *vma)
-{
-	struct fimc_ctx *ctx = fh_to_ctx(file->private_data);
-	struct fimc_dev *fimc = ctx->fimc_dev;
-	int ret;
-
-	if (mutex_lock_interruptible(&fimc->lock))
-		return -ERESTARTSYS;
-
-	ret = v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
-	mutex_unlock(&fimc->lock);
-
-	return ret;
-}
-
 static const struct v4l2_file_operations fimc_m2m_fops = {
 	.owner		= THIS_MODULE,
 	.open		= fimc_m2m_open,
 	.release	= fimc_m2m_release,
-	.poll		= fimc_m2m_poll,
+	.poll		= v4l2_m2m_fop_poll,
 	.unlocked_ioctl	= video_ioctl2,
-	.mmap		= fimc_m2m_mmap,
+	.mmap		= v4l2_m2m_fop_mmap,
 };
 
 static struct v4l2_m2m_ops m2m_ops = {
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC v2 04/10] s5p-jpeg: Use mem-to-mem ioctl helpers
  2013-10-12 12:31 [PATCH RFC v2 00/10] V4L2 mem-to-mem ioctl helpers Sylwester Nawrocki
                   ` (2 preceding siblings ...)
  2013-10-12 12:31 ` [PATCH RFC v2 03/10] exynos4-is: Use mem-to-mem ioctl helpers Sylwester Nawrocki
@ 2013-10-12 12:31 ` Sylwester Nawrocki
  2013-10-16 11:31   ` Kamil Debski
  2013-10-12 12:31 ` [PATCH RFC v2 05/10] mx2-emmaprp: Use struct v4l2_fh Sylwester Nawrocki
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 19+ messages in thread
From: Sylwester Nawrocki @ 2013-10-12 12:31 UTC (permalink / raw)
  To: linux-media
  Cc: hverkuil, pawel, javier.martin, m.szyprowski, shaik.ameer,
	arun.kk, k.debski, p.zabel, kyungmin.park, linux-samsung-soc,
	Sylwester Nawrocki

Simplify the driver by using the m2m ioctl and vb2 helpers.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
Changes since v1:
 - use m2m context pointer from struct v4l2_fh.
---
 drivers/media/platform/s5p-jpeg/jpeg-core.c |  134 +++++----------------------
 drivers/media/platform/s5p-jpeg/jpeg-core.h |    2 -
 2 files changed, 24 insertions(+), 112 deletions(-)

diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index 15d2396..160af4e 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -316,9 +316,9 @@ static int s5p_jpeg_open(struct file *file)
 	if (ret < 0)
 		goto error;
 
-	ctx->m2m_ctx = v4l2_m2m_ctx_init(jpeg->m2m_dev, ctx, queue_init);
-	if (IS_ERR(ctx->m2m_ctx)) {
-		ret = PTR_ERR(ctx->m2m_ctx);
+	ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(jpeg->m2m_dev, ctx, queue_init);
+	if (IS_ERR(ctx->fh.m2m_ctx)) {
+		ret = PTR_ERR(ctx->fh.m2m_ctx);
 		goto error;
 	}
 
@@ -342,7 +342,7 @@ static int s5p_jpeg_release(struct file *file)
 	struct s5p_jpeg_ctx *ctx = fh_to_ctx(file->private_data);
 
 	mutex_lock(&jpeg->lock);
-	v4l2_m2m_ctx_release(ctx->m2m_ctx);
+	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
 	mutex_unlock(&jpeg->lock);
 	v4l2_ctrl_handler_free(&ctx->ctrl_handler);
 	v4l2_fh_del(&ctx->fh);
@@ -352,39 +352,13 @@ static int s5p_jpeg_release(struct file *file)
 	return 0;
 }
 
-static unsigned int s5p_jpeg_poll(struct file *file,
-				 struct poll_table_struct *wait)
-{
-	struct s5p_jpeg *jpeg = video_drvdata(file);
-	struct s5p_jpeg_ctx *ctx = fh_to_ctx(file->private_data);
-	unsigned int res;
-
-	mutex_lock(&jpeg->lock);
-	res = v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
-	mutex_unlock(&jpeg->lock);
-	return res;
-}
-
-static int s5p_jpeg_mmap(struct file *file, struct vm_area_struct *vma)
-{
-	struct s5p_jpeg *jpeg = video_drvdata(file);
-	struct s5p_jpeg_ctx *ctx = fh_to_ctx(file->private_data);
-	int ret;
-
-	if (mutex_lock_interruptible(&jpeg->lock))
-		return -ERESTARTSYS;
-	ret = v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
-	mutex_unlock(&jpeg->lock);
-	return ret;
-}
-
 static const struct v4l2_file_operations s5p_jpeg_fops = {
 	.owner		= THIS_MODULE,
 	.open		= s5p_jpeg_open,
 	.release	= s5p_jpeg_release,
-	.poll		= s5p_jpeg_poll,
+	.poll		= v4l2_m2m_fop_poll,
 	.unlocked_ioctl	= video_ioctl2,
-	.mmap		= s5p_jpeg_mmap,
+	.mmap		= v4l2_m2m_fop_mmap,
 };
 
 /*
@@ -589,7 +563,7 @@ static int s5p_jpeg_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
 	struct v4l2_pix_format *pix = &f->fmt.pix;
 	struct s5p_jpeg_ctx *ct = fh_to_ctx(priv);
 
-	vq = v4l2_m2m_get_vq(ct->m2m_ctx, f->type);
+	vq = v4l2_m2m_get_vq(ct->fh.m2m_ctx, f->type);
 	if (!vq)
 		return -EINVAL;
 
@@ -745,7 +719,7 @@ static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct, struct v4l2_format *f)
 	struct s5p_jpeg_q_data *q_data = NULL;
 	struct v4l2_pix_format *pix = &f->fmt.pix;
 
-	vq = v4l2_m2m_get_vq(ct->m2m_ctx, f->type);
+	vq = v4l2_m2m_get_vq(ct->fh.m2m_ctx, f->type);
 	if (!vq)
 		return -EINVAL;
 
@@ -792,53 +766,6 @@ static int s5p_jpeg_s_fmt_vid_out(struct file *file, void *priv,
 	return s5p_jpeg_s_fmt(fh_to_ctx(priv), f);
 }
 
-static int s5p_jpeg_reqbufs(struct file *file, void *priv,
-			  struct v4l2_requestbuffers *reqbufs)
-{
-	struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
-
-	return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
-}
-
-static int s5p_jpeg_querybuf(struct file *file, void *priv,
-			   struct v4l2_buffer *buf)
-{
-	struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
-
-	return v4l2_m2m_querybuf(file, ctx->m2m_ctx, buf);
-}
-
-static int s5p_jpeg_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
-{
-	struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
-
-	return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
-}
-
-static int s5p_jpeg_dqbuf(struct file *file, void *priv,
-			  struct v4l2_buffer *buf)
-{
-	struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
-
-	return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
-}
-
-static int s5p_jpeg_streamon(struct file *file, void *priv,
-			   enum v4l2_buf_type type)
-{
-	struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
-
-	return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
-}
-
-static int s5p_jpeg_streamoff(struct file *file, void *priv,
-			    enum v4l2_buf_type type)
-{
-	struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
-
-	return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
-}
-
 static int s5p_jpeg_g_selection(struct file *file, void *priv,
 			 struct v4l2_selection *s)
 {
@@ -972,14 +899,13 @@ static const struct v4l2_ioctl_ops s5p_jpeg_ioctl_ops = {
 	.vidioc_s_fmt_vid_cap		= s5p_jpeg_s_fmt_vid_cap,
 	.vidioc_s_fmt_vid_out		= s5p_jpeg_s_fmt_vid_out,
 
-	.vidioc_reqbufs			= s5p_jpeg_reqbufs,
-	.vidioc_querybuf		= s5p_jpeg_querybuf,
+	.vidioc_reqbufs			= v4l2_m2m_ioctl_reqbufs,
+	.vidioc_querybuf		= v4l2_m2m_ioctl_querybuf,
+	.vidioc_qbuf			= v4l2_m2m_ioctl_qbuf,
+	.vidioc_dqbuf			= v4l2_m2m_ioctl_dqbuf,
 
-	.vidioc_qbuf			= s5p_jpeg_qbuf,
-	.vidioc_dqbuf			= s5p_jpeg_dqbuf,
-
-	.vidioc_streamon		= s5p_jpeg_streamon,
-	.vidioc_streamoff		= s5p_jpeg_streamoff,
+	.vidioc_streamon		= v4l2_m2m_ioctl_streamon,
+	.vidioc_streamoff		= v4l2_m2m_ioctl_streamoff,
 
 	.vidioc_g_selection		= s5p_jpeg_g_selection,
 };
@@ -997,8 +923,8 @@ static void s5p_jpeg_device_run(void *priv)
 	struct vb2_buffer *src_buf, *dst_buf;
 	unsigned long src_addr, dst_addr;
 
-	src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
-	dst_buf = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
+	src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
+	dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
 	src_addr = vb2_dma_contig_plane_dma_addr(src_buf, 0);
 	dst_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 0);
 
@@ -1170,22 +1096,8 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb)
 				      );
 		q_data->size = q_data->w * q_data->h * q_data->fmt->depth >> 3;
 	}
-	if (ctx->m2m_ctx)
-		v4l2_m2m_buf_queue(ctx->m2m_ctx, vb);
-}
-
-static void s5p_jpeg_wait_prepare(struct vb2_queue *vq)
-{
-	struct s5p_jpeg_ctx *ctx = vb2_get_drv_priv(vq);
-
-	mutex_unlock(&ctx->jpeg->lock);
-}
-
-static void s5p_jpeg_wait_finish(struct vb2_queue *vq)
-{
-	struct s5p_jpeg_ctx *ctx = vb2_get_drv_priv(vq);
 
-	mutex_lock(&ctx->jpeg->lock);
+	v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vb);
 }
 
 static int s5p_jpeg_start_streaming(struct vb2_queue *q, unsigned int count)
@@ -1211,8 +1123,8 @@ static struct vb2_ops s5p_jpeg_qops = {
 	.queue_setup		= s5p_jpeg_queue_setup,
 	.buf_prepare		= s5p_jpeg_buf_prepare,
 	.buf_queue		= s5p_jpeg_buf_queue,
-	.wait_prepare		= s5p_jpeg_wait_prepare,
-	.wait_finish		= s5p_jpeg_wait_finish,
+	.wait_prepare		= vb2_ops_wait_prepare,
+	.wait_finish		= vb2_ops_wait_finish,
 	.start_streaming	= s5p_jpeg_start_streaming,
 	.stop_streaming		= s5p_jpeg_stop_streaming,
 };
@@ -1230,6 +1142,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
 	src_vq->ops = &s5p_jpeg_qops;
 	src_vq->mem_ops = &vb2_dma_contig_memops;
 	src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+	src_vq->lock = &ctx->jpeg->lock;
 
 	ret = vb2_queue_init(src_vq);
 	if (ret)
@@ -1242,6 +1155,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
 	dst_vq->ops = &s5p_jpeg_qops;
 	dst_vq->mem_ops = &vb2_dma_contig_memops;
 	dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+	dst_vq->lock = &ctx->jpeg->lock;
 
 	return vb2_queue_init(dst_vq);
 }
@@ -1267,8 +1181,8 @@ static irqreturn_t s5p_jpeg_irq(int irq, void *dev_id)
 
 	curr_ctx = v4l2_m2m_get_curr_priv(jpeg->m2m_dev);
 
-	src_buf = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx);
-	dst_buf = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx);
+	src_buf = v4l2_m2m_src_buf_remove(curr_ctx->fh.m2m_ctx);
+	dst_buf = v4l2_m2m_dst_buf_remove(curr_ctx->fh.m2m_ctx);
 
 	if (curr_ctx->mode == S5P_JPEG_ENCODE)
 		enc_jpeg_too_large = jpeg_enc_stream_stat(jpeg->regs);
@@ -1296,7 +1210,7 @@ static irqreturn_t s5p_jpeg_irq(int irq, void *dev_id)
 	if (curr_ctx->mode == S5P_JPEG_ENCODE)
 		vb2_set_plane_payload(dst_buf, 0, payload_size);
 	v4l2_m2m_buf_done(dst_buf, state);
-	v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->m2m_ctx);
+	v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx);
 
 	curr_ctx->subsampling = jpeg_get_subsampling_mode(jpeg->regs);
 	spin_unlock(&jpeg->slock);
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.h b/drivers/media/platform/s5p-jpeg/jpeg-core.h
index 8a4013e..4a4776b 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.h
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.h
@@ -115,7 +115,6 @@ struct s5p_jpeg_q_data {
  * @jpeg:		JPEG IP device for this context
  * @mode:		compression (encode) operation or decompression (decode)
  * @compr_quality:	destination image quality in compression (encode) mode
- * @m2m_ctx:		mem2mem device context
  * @out_q:		source (output) queue information
  * @cap_fmt:		destination (capture) queue queue information
  * @hdr_parsed:		set if header has been parsed during decompression
@@ -127,7 +126,6 @@ struct s5p_jpeg_ctx {
 	unsigned short		compr_quality;
 	unsigned short		restart_interval;
 	unsigned short		subsampling;
-	struct v4l2_m2m_ctx	*m2m_ctx;
 	struct s5p_jpeg_q_data	out_q;
 	struct s5p_jpeg_q_data	cap_q;
 	struct v4l2_fh		fh;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC v2 05/10] mx2-emmaprp: Use struct v4l2_fh
  2013-10-12 12:31 [PATCH RFC v2 00/10] V4L2 mem-to-mem ioctl helpers Sylwester Nawrocki
                   ` (3 preceding siblings ...)
  2013-10-12 12:31 ` [PATCH RFC v2 04/10] s5p-jpeg: " Sylwester Nawrocki
@ 2013-10-12 12:31 ` Sylwester Nawrocki
  2013-10-12 12:31 ` [PATCH RFC v2 06/10] mx2-emmaprp: Use mem-to-mem ioctl helpers Sylwester Nawrocki
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Sylwester Nawrocki @ 2013-10-12 12:31 UTC (permalink / raw)
  To: linux-media
  Cc: hverkuil, pawel, javier.martin, m.szyprowski, shaik.ameer,
	arun.kk, k.debski, p.zabel, kyungmin.park, linux-samsung-soc,
	Sylwester Nawrocki

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/media/platform/mx2_emmaprp.c |   54 ++++++++++++++++++++++-----------
 1 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/drivers/media/platform/mx2_emmaprp.c b/drivers/media/platform/mx2_emmaprp.c
index c690435..e91a4d5 100644
--- a/drivers/media/platform/mx2_emmaprp.c
+++ b/drivers/media/platform/mx2_emmaprp.c
@@ -221,9 +221,12 @@ struct emmaprp_ctx {
 	/* Abort requested by m2m */
 	int			aborting;
 	struct emmaprp_q_data	q_data[2];
+	struct v4l2_fh		fh;
 	struct v4l2_m2m_ctx	*m2m_ctx;
 };

+#define fh_to_ctx(__fh) container_of(__fh, struct emmaprp_ctx, fh)
+
 static struct emmaprp_q_data *get_q_data(struct emmaprp_ctx *ctx,
 					 enum v4l2_buf_type type)
 {
@@ -478,13 +481,15 @@ static int vidioc_g_fmt(struct emmaprp_ctx *ctx, struct v4l2_format *f)
 static int vidioc_g_fmt_vid_out(struct file *file, void *priv,
 				struct v4l2_format *f)
 {
-	return vidioc_g_fmt(priv, f);
+	struct emmaprp_ctx *ctx = fh_to_ctx(priv);
+	return vidioc_g_fmt(ctx, f);
 }

 static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
 				struct v4l2_format *f)
 {
-	return vidioc_g_fmt(priv, f);
+	struct emmaprp_ctx *ctx = fh_to_ctx(priv);
+	return vidioc_g_fmt(ctx, f);
 }

 static int vidioc_try_fmt(struct v4l2_format *f)
@@ -524,8 +529,8 @@ static int vidioc_try_fmt(struct v4l2_format *f)
 static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
 				  struct v4l2_format *f)
 {
+	struct emmaprp_ctx *ctx = fh_to_ctx(priv);
 	struct emmaprp_fmt *fmt;
-	struct emmaprp_ctx *ctx = priv;

 	fmt = find_format(f);
 	if (!fmt || !(fmt->types & MEM2MEM_CAPTURE)) {
@@ -541,8 +546,8 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
 static int vidioc_try_fmt_vid_out(struct file *file, void *priv,
 				  struct v4l2_format *f)
 {
+	struct emmaprp_ctx *ctx = fh_to_ctx(priv);
 	struct emmaprp_fmt *fmt;
-	struct emmaprp_ctx *ctx = priv;

 	fmt = find_format(f);
 	if (!fmt || !(fmt->types & MEM2MEM_OUTPUT)) {
@@ -561,7 +566,7 @@ static int vidioc_s_fmt(struct emmaprp_ctx *ctx, struct v4l2_format *f)
 	struct vb2_queue *vq;
 	int ret;

-	vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
+	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
 	if (!vq)
 		return -EINVAL;

@@ -596,25 +601,27 @@ static int vidioc_s_fmt(struct emmaprp_ctx *ctx, struct v4l2_format *f)
 static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
 				struct v4l2_format *f)
 {
+	struct emmaprp_ctx *ctx = fh_to_ctx(priv);
 	int ret;

 	ret = vidioc_try_fmt_vid_cap(file, priv, f);
 	if (ret)
 		return ret;

-	return vidioc_s_fmt(priv, f);
+	return vidioc_s_fmt(ctx, f);
 }

 static int vidioc_s_fmt_vid_out(struct file *file, void *priv,
 				struct v4l2_format *f)
 {
+	struct emmaprp_ctx *ctx = fh_to_ctx(priv);
 	int ret;

 	ret = vidioc_try_fmt_vid_out(file, priv, f);
 	if (ret)
 		return ret;

-	return vidioc_s_fmt(priv, f);
+	return vidioc_s_fmt(ctx, f);
 }

 static int vidioc_reqbufs(struct file *file, void *priv,
@@ -790,27 +797,28 @@ static int emmaprp_open(struct file *file)
 {
 	struct emmaprp_dev *pcdev = video_drvdata(file);
 	struct emmaprp_ctx *ctx;
+	int ret;

 	ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
 	if (!ctx)
 		return -ENOMEM;

-	file->private_data = ctx;
-	ctx->dev = pcdev;
-
 	if (mutex_lock_interruptible(&pcdev->dev_mutex)) {
-		kfree(ctx);
-		return -ERESTARTSYS;
+		ret = -ERESTARTSYS;
+		goto err_free;
 	}

+	v4l2_fh_init(&ctx->fh, pcdev->vfd);
+	file->private_data = &ctx->fh;
+	v4l2_fh_add(&ctx->fh);
+
+	ctx->dev = pcdev;
+
 	ctx->m2m_ctx = v4l2_m2m_ctx_init(pcdev->m2m_dev, ctx, &queue_init);

 	if (IS_ERR(ctx->m2m_ctx)) {
-		int ret = PTR_ERR(ctx->m2m_ctx);
-
-		mutex_unlock(&pcdev->dev_mutex);
-		kfree(ctx);
-		return ret;
+		ret = PTR_ERR(ctx->m2m_ctx);
+		goto err_fh;
 	}

 	clk_prepare_enable(pcdev->clk_emma_ipg);
@@ -822,12 +830,20 @@ static int emmaprp_open(struct file *file)
 	dprintk(pcdev, "Created instance %p, m2m_ctx: %p\n", ctx, ctx->m2m_ctx);

 	return 0;
+
+err_fh:
+	v4l2_fh_del(&ctx->fh);
+	v4l2_fh_exit(&ctx->fh);
+err_free:
+	kfree(ctx);
+	mutex_unlock(&pcdev->dev_mutex);
+	return ret;
 }

 static int emmaprp_release(struct file *file)
 {
+	struct emmaprp_ctx *ctx = fh_to_ctx(file->private_data);
 	struct emmaprp_dev *pcdev = video_drvdata(file);
-	struct emmaprp_ctx *ctx = file->private_data;

 	dprintk(pcdev, "Releasing instance %p\n", ctx);

@@ -835,6 +851,8 @@ static int emmaprp_release(struct file *file)
 	clk_disable_unprepare(pcdev->clk_emma_ahb);
 	clk_disable_unprepare(pcdev->clk_emma_ipg);
 	v4l2_m2m_ctx_release(ctx->m2m_ctx);
+	v4l2_fh_del(&ctx->fh);
+	v4l2_fh_exit(&ctx->fh);
 	mutex_unlock(&pcdev->dev_mutex);
 	kfree(ctx);

--
1.7.4.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC v2 06/10] mx2-emmaprp: Use mem-to-mem ioctl helpers
  2013-10-12 12:31 [PATCH RFC v2 00/10] V4L2 mem-to-mem ioctl helpers Sylwester Nawrocki
                   ` (4 preceding siblings ...)
  2013-10-12 12:31 ` [PATCH RFC v2 05/10] mx2-emmaprp: Use struct v4l2_fh Sylwester Nawrocki
@ 2013-10-12 12:31 ` Sylwester Nawrocki
  2013-10-12 12:31 ` [PATCH RFC v2 07/10] exynos-gsc: Configure default image format at device open() Sylwester Nawrocki
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Sylwester Nawrocki @ 2013-10-12 12:31 UTC (permalink / raw)
  To: linux-media
  Cc: hverkuil, pawel, javier.martin, m.szyprowski, shaik.ameer,
	arun.kk, k.debski, p.zabel, kyungmin.park, linux-samsung-soc,
	Sylwester Nawrocki

Simplify the driver by using the m2m ioctl and vb2 helpers.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
Changes since v1:
 - dropped m2m_ctx member of struct emmaprp_ctx; the patch is now
   complete and there are better chances it actually works.
---
 drivers/media/platform/mx2_emmaprp.c |  135 ++++++----------------------------
 1 files changed, 24 insertions(+), 111 deletions(-)

diff --git a/drivers/media/platform/mx2_emmaprp.c b/drivers/media/platform/mx2_emmaprp.c
index e91a4d5..43a437c 100644
--- a/drivers/media/platform/mx2_emmaprp.c
+++ b/drivers/media/platform/mx2_emmaprp.c
@@ -222,7 +222,6 @@ struct emmaprp_ctx {
 	int			aborting;
 	struct emmaprp_q_data	q_data[2];
 	struct v4l2_fh		fh;
-	struct v4l2_m2m_ctx	*m2m_ctx;
 };
 
 #define fh_to_ctx(__fh) container_of(__fh, struct emmaprp_ctx, fh)
@@ -253,21 +252,7 @@ static void emmaprp_job_abort(void *priv)
 
 	dprintk(pcdev, "Aborting task\n");
 
-	v4l2_m2m_job_finish(pcdev->m2m_dev, ctx->m2m_ctx);
-}
-
-static void emmaprp_lock(void *priv)
-{
-	struct emmaprp_ctx *ctx = priv;
-	struct emmaprp_dev *pcdev = ctx->dev;
-	mutex_lock(&pcdev->dev_mutex);
-}
-
-static void emmaprp_unlock(void *priv)
-{
-	struct emmaprp_ctx *ctx = priv;
-	struct emmaprp_dev *pcdev = ctx->dev;
-	mutex_unlock(&pcdev->dev_mutex);
+	v4l2_m2m_job_finish(pcdev->m2m_dev, ctx->fh.m2m_ctx);
 }
 
 static inline void emmaprp_dump_regs(struct emmaprp_dev *pcdev)
@@ -302,8 +287,8 @@ static void emmaprp_device_run(void *priv)
 	dma_addr_t p_in, p_out;
 	u32 tmp;
 
-	src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
-	dst_buf = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
+	src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
+	dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
 
 	s_q_data = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
 	s_width	= s_q_data->width;
@@ -377,8 +362,8 @@ static irqreturn_t emmaprp_irq(int irq_emma, void *data)
 			pr_err("PrP bus error occurred, this transfer is probably corrupted\n");
 			writel(PRP_CNTL_SWRST, pcdev->base_emma + PRP_CNTL);
 		} else if (irqst & PRP_INTR_ST_CH2B1CI) { /* buffer ready */
-			src_vb = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx);
-			dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx);
+			src_vb = v4l2_m2m_src_buf_remove(curr_ctx->fh.m2m_ctx);
+			dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->fh.m2m_ctx);
 
 			src_vb->v4l2_buf.timestamp = dst_vb->v4l2_buf.timestamp;
 			src_vb->v4l2_buf.timecode = dst_vb->v4l2_buf.timecode;
@@ -390,7 +375,7 @@ static irqreturn_t emmaprp_irq(int irq_emma, void *data)
 		}
 	}
 
-	v4l2_m2m_job_finish(pcdev->m2m_dev, curr_ctx->m2m_ctx);
+	v4l2_m2m_job_finish(pcdev->m2m_dev, curr_ctx->fh.m2m_ctx);
 	return IRQ_HANDLED;
 }
 
@@ -459,7 +444,7 @@ static int vidioc_g_fmt(struct emmaprp_ctx *ctx, struct v4l2_format *f)
 	struct vb2_queue *vq;
 	struct emmaprp_q_data *q_data;
 
-	vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
+	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
 	if (!vq)
 		return -EINVAL;
 
@@ -624,52 +609,6 @@ static int vidioc_s_fmt_vid_out(struct file *file, void *priv,
 	return vidioc_s_fmt(ctx, f);
 }
 
-static int vidioc_reqbufs(struct file *file, void *priv,
-			  struct v4l2_requestbuffers *reqbufs)
-{
-	struct emmaprp_ctx *ctx = priv;
-
-	return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
-}
-
-static int vidioc_querybuf(struct file *file, void *priv,
-			   struct v4l2_buffer *buf)
-{
-	struct emmaprp_ctx *ctx = priv;
-
-	return v4l2_m2m_querybuf(file, ctx->m2m_ctx, buf);
-}
-
-static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
-{
-	struct emmaprp_ctx *ctx = priv;
-
-	return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
-}
-
-static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
-{
-	struct emmaprp_ctx *ctx = priv;
-
-	return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
-}
-
-static int vidioc_streamon(struct file *file, void *priv,
-			   enum v4l2_buf_type type)
-{
-	struct emmaprp_ctx *ctx = priv;
-
-	return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
-}
-
-static int vidioc_streamoff(struct file *file, void *priv,
-			    enum v4l2_buf_type type)
-{
-	struct emmaprp_ctx *ctx = priv;
-
-	return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
-}
-
 static const struct v4l2_ioctl_ops emmaprp_ioctl_ops = {
 	.vidioc_querycap	= vidioc_querycap,
 
@@ -683,14 +622,13 @@ static const struct v4l2_ioctl_ops emmaprp_ioctl_ops = {
 	.vidioc_try_fmt_vid_out	= vidioc_try_fmt_vid_out,
 	.vidioc_s_fmt_vid_out	= vidioc_s_fmt_vid_out,
 
-	.vidioc_reqbufs		= vidioc_reqbufs,
-	.vidioc_querybuf	= vidioc_querybuf,
-
-	.vidioc_qbuf		= vidioc_qbuf,
-	.vidioc_dqbuf		= vidioc_dqbuf,
+	.vidioc_reqbufs		= v4l2_m2m_ioctl_reqbufs,
+	.vidioc_querybuf	= v4l2_m2m_ioctl_querybuf,
+	.vidioc_qbuf		= v4l2_m2m_ioctl_qbuf,
+	.vidioc_dqbuf		= v4l2_m2m_ioctl_dqbuf,
 
-	.vidioc_streamon	= vidioc_streamon,
-	.vidioc_streamoff	= vidioc_streamoff,
+	.vidioc_streamon	= v4l2_m2m_ioctl_streamon,
+	.vidioc_streamoff	= v4l2_m2m_ioctl_streamoff,
 };
 
 
@@ -752,7 +690,7 @@ static int emmaprp_buf_prepare(struct vb2_buffer *vb)
 static void emmaprp_buf_queue(struct vb2_buffer *vb)
 {
 	struct emmaprp_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
-	v4l2_m2m_buf_queue(ctx->m2m_ctx, vb);
+	v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vb);
 }
 
 static struct vb2_ops emmaprp_qops = {
@@ -774,6 +712,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
 	src_vq->ops = &emmaprp_qops;
 	src_vq->mem_ops = &vb2_dma_contig_memops;
 	src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+	src_vq->lock = &ctx->dev->dev_mutex;
 
 	ret = vb2_queue_init(src_vq);
 	if (ret)
@@ -786,6 +725,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
 	dst_vq->ops = &emmaprp_qops;
 	dst_vq->mem_ops = &vb2_dma_contig_memops;
 	dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+	dst_vq->lock = &ctx->dev->dev_mutex;
 
 	return vb2_queue_init(dst_vq);
 }
@@ -814,10 +754,10 @@ static int emmaprp_open(struct file *file)
 
 	ctx->dev = pcdev;
 
-	ctx->m2m_ctx = v4l2_m2m_ctx_init(pcdev->m2m_dev, ctx, &queue_init);
+	ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(pcdev->m2m_dev, ctx, &queue_init);
 
-	if (IS_ERR(ctx->m2m_ctx)) {
-		ret = PTR_ERR(ctx->m2m_ctx);
+	if (IS_ERR(ctx->fh.m2m_ctx)) {
+		ret = PTR_ERR(ctx->fh.m2m_ctx);
 		goto err_fh;
 	}
 
@@ -827,7 +767,8 @@ static int emmaprp_open(struct file *file)
 	ctx->q_data[V4L2_M2M_DST].fmt = &formats[0];
 	mutex_unlock(&pcdev->dev_mutex);
 
-	dprintk(pcdev, "Created instance %p, m2m_ctx: %p\n", ctx, ctx->m2m_ctx);
+	dprintk(pcdev, "Created instance %p, m2m_ctx: %p\n",
+		ctx, ctx->fh.m2m_ctx);
 
 	return 0;
 
@@ -850,7 +791,7 @@ static int emmaprp_release(struct file *file)
 	mutex_lock(&pcdev->dev_mutex);
 	clk_disable_unprepare(pcdev->clk_emma_ahb);
 	clk_disable_unprepare(pcdev->clk_emma_ipg);
-	v4l2_m2m_ctx_release(ctx->m2m_ctx);
+	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
 	v4l2_fh_del(&ctx->fh);
 	v4l2_fh_exit(&ctx->fh);
 	mutex_unlock(&pcdev->dev_mutex);
@@ -859,39 +800,13 @@ static int emmaprp_release(struct file *file)
 	return 0;
 }
 
-static unsigned int emmaprp_poll(struct file *file,
-				 struct poll_table_struct *wait)
-{
-	struct emmaprp_dev *pcdev = video_drvdata(file);
-	struct emmaprp_ctx *ctx = file->private_data;
-	unsigned int res;
-
-	mutex_lock(&pcdev->dev_mutex);
-	res = v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
-	mutex_unlock(&pcdev->dev_mutex);
-	return res;
-}
-
-static int emmaprp_mmap(struct file *file, struct vm_area_struct *vma)
-{
-	struct emmaprp_dev *pcdev = video_drvdata(file);
-	struct emmaprp_ctx *ctx = file->private_data;
-	int ret;
-
-	if (mutex_lock_interruptible(&pcdev->dev_mutex))
-		return -ERESTARTSYS;
-	ret = v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
-	mutex_unlock(&pcdev->dev_mutex);
-	return ret;
-}
-
 static const struct v4l2_file_operations emmaprp_fops = {
 	.owner		= THIS_MODULE,
 	.open		= emmaprp_open,
 	.release	= emmaprp_release,
-	.poll		= emmaprp_poll,
+	.poll		= v4l2_m2m_fop_poll,
 	.unlocked_ioctl	= video_ioctl2,
-	.mmap		= emmaprp_mmap,
+	.mmap		= v4l2_m2m_fop_mmap,
 };
 
 static struct video_device emmaprp_videodev = {
@@ -906,8 +821,6 @@ static struct video_device emmaprp_videodev = {
 static struct v4l2_m2m_ops m2m_ops = {
 	.device_run	= emmaprp_device_run,
 	.job_abort	= emmaprp_job_abort,
-	.lock		= emmaprp_lock,
-	.unlock		= emmaprp_unlock,
 };
 
 static int emmaprp_probe(struct platform_device *pdev)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC v2 07/10] exynos-gsc: Configure default image format at device open()
  2013-10-12 12:31 [PATCH RFC v2 00/10] V4L2 mem-to-mem ioctl helpers Sylwester Nawrocki
                   ` (5 preceding siblings ...)
  2013-10-12 12:31 ` [PATCH RFC v2 06/10] mx2-emmaprp: Use mem-to-mem ioctl helpers Sylwester Nawrocki
@ 2013-10-12 12:31 ` Sylwester Nawrocki
  2013-10-12 12:31 ` [PATCH RFC v2 08/10] exynos-gsc: Remove GSC_{SRC, DST}_FMT flags Sylwester Nawrocki
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Sylwester Nawrocki @ 2013-10-12 12:31 UTC (permalink / raw)
  To: linux-media
  Cc: hverkuil, pawel, javier.martin, m.szyprowski, shaik.ameer,
	arun.kk, k.debski, p.zabel, kyungmin.park, linux-samsung-soc,
	Sylwester Nawrocki

There should be always some valid image format set on a video device.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
 drivers/media/platform/exynos-gsc/gsc-m2m.c |   34 ++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index e576ff2..48e1c34 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -605,6 +605,32 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
 	return vb2_queue_init(dst_vq);
 }
 
+static int gsc_m2m_set_default_format(struct gsc_ctx *ctx)
+{
+	struct v4l2_pix_format_mplane pixm = {
+		.pixelformat	= V4L2_PIX_FMT_RGB32,
+		.width		= 800,
+		.height		= 600,
+		.plane_fmt[0]	= {
+			.bytesperline = 800 * 4,
+			.sizeimage = 800 * 4 * 600,
+		},
+	};
+	const struct gsc_fmt *fmt;
+
+	fmt = find_fmt(&pixm.pixelformat, NULL, 0);
+	if (!fmt)
+		return -EINVAL;
+
+	gsc_set_frame_size(&ctx->s_frame, pixm.width, pixm.height);
+	ctx->s_frame.payload[0] = pixm.plane_fmt[0].sizeimage;
+
+	gsc_set_frame_size(&ctx->d_frame, pixm.width, pixm.height);
+	ctx->d_frame.payload[0] = pixm.plane_fmt[0].sizeimage;
+
+	return 0;
+}
+
 static int gsc_m2m_open(struct file *file)
 {
 	struct gsc_dev *gsc = video_drvdata(file);
@@ -638,7 +664,7 @@ static int gsc_m2m_open(struct file *file)
 	ctx->d_frame.fmt = get_format(0);
 	/* Setup the device context for mem2mem mode. */
 	ctx->state = GSC_CTX_M2M;
-	ctx->flags = 0;
+	ctx->flags = GSC_PARAMS;
 	ctx->in_path = GSC_DMA;
 	ctx->out_path = GSC_DMA;
 
@@ -652,11 +678,17 @@ static int gsc_m2m_open(struct file *file)
 	if (gsc->m2m.refcnt++ == 0)
 		set_bit(ST_M2M_OPEN, &gsc->state);
 
+	ret = gsc_m2m_set_default_format(ctx);
+	if (ret)
+		goto error_m2m_rel;
+
 	pr_debug("gsc m2m driver is opened, ctx(0x%p)", ctx);
 
 	mutex_unlock(&gsc->lock);
 	return 0;
 
+error_m2m_rel:
+	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
 error_ctrls:
 	gsc_ctrls_delete(ctx);
 error_fh:
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC v2 08/10] exynos-gsc: Remove GSC_{SRC, DST}_FMT flags
  2013-10-12 12:31 [PATCH RFC v2 00/10] V4L2 mem-to-mem ioctl helpers Sylwester Nawrocki
                   ` (6 preceding siblings ...)
  2013-10-12 12:31 ` [PATCH RFC v2 07/10] exynos-gsc: Configure default image format at device open() Sylwester Nawrocki
@ 2013-10-12 12:31 ` Sylwester Nawrocki
  2013-10-12 12:31 ` [PATCH RFC v2 09/10] exynos-gsc: Use mem-to-mem ioctl helpers Sylwester Nawrocki
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Sylwester Nawrocki @ 2013-10-12 12:31 UTC (permalink / raw)
  To: linux-media
  Cc: hverkuil, pawel, javier.martin, m.szyprowski, shaik.ameer,
	arun.kk, k.debski, p.zabel, kyungmin.park, linux-samsung-soc,
	Sylwester Nawrocki

The GSC_SRC_FMT, GSC_DST_FMT flags are currently set in VIDIOC_S_FMT ioctl
and cleared in VIDIOC_REQBUFS(0). In between the flags are used to figure out
if scaling ratio check need to be performed. This an incorrect behaviour as
it should be assumed there is always a valid configuration on a video device.
Fix this by removing those flags and also remove an unused 'frame' local
variable.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
 drivers/media/platform/exynos-gsc/gsc-core.c |   10 ++----
 drivers/media/platform/exynos-gsc/gsc-core.h |    2 -
 drivers/media/platform/exynos-gsc/gsc-m2m.c  |   46 +++++++++-----------------
 3 files changed, 19 insertions(+), 39 deletions(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c b/drivers/media/platform/exynos-gsc/gsc-core.c
index 9d0cc04..d0bba73 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.c
+++ b/drivers/media/platform/exynos-gsc/gsc-core.c
@@ -698,7 +698,6 @@ static int __gsc_s_ctrl(struct gsc_ctx *ctx, struct v4l2_ctrl *ctrl)
 {
 	struct gsc_dev *gsc = ctx->gsc_dev;
 	struct gsc_variant *variant = gsc->variant;
-	unsigned int flags = GSC_DST_FMT | GSC_SRC_FMT;
 	int ret = 0;
 
 	if (ctrl->flags & V4L2_CTRL_FLAG_INACTIVE)
@@ -714,18 +713,15 @@ static int __gsc_s_ctrl(struct gsc_ctx *ctx, struct v4l2_ctrl *ctrl)
 		break;
 
 	case V4L2_CID_ROTATE:
-		if ((ctx->state & flags) == flags) {
-			ret = gsc_check_scaler_ratio(variant,
+		ret = gsc_check_scaler_ratio(variant,
 					ctx->s_frame.crop.width,
 					ctx->s_frame.crop.height,
 					ctx->d_frame.crop.width,
 					ctx->d_frame.crop.height,
 					ctx->gsc_ctrls.rotate->val,
 					ctx->out_path);
-
-			if (ret)
-				return -EINVAL;
-		}
+		if (ret < 0)
+			return ret;
 
 		ctx->rotation = ctrl->val;
 		break;
diff --git a/drivers/media/platform/exynos-gsc/gsc-core.h b/drivers/media/platform/exynos-gsc/gsc-core.h
index 76435d3..c79b3cb 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.h
+++ b/drivers/media/platform/exynos-gsc/gsc-core.h
@@ -41,8 +41,6 @@
 #define DEFAULT_CSC_RANGE		1
 
 #define GSC_PARAMS			(1 << 0)
-#define GSC_SRC_FMT			(1 << 1)
-#define GSC_DST_FMT			(1 << 2)
 #define GSC_CTX_M2M			(1 << 3)
 #define GSC_CTX_STOP_REQ		(1 << 6)
 
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index 48e1c34..78bcb92 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -341,11 +341,7 @@ static int gsc_m2m_s_fmt_mplane(struct file *file, void *fh,
 		frame->payload[i] = pix->plane_fmt[i].sizeimage;
 
 	gsc_set_frame_size(frame, pix->width, pix->height);
-
-	if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
-		gsc_ctx_state_lock_set(GSC_PARAMS | GSC_DST_FMT, ctx);
-	else
-		gsc_ctx_state_lock_set(GSC_PARAMS | GSC_SRC_FMT, ctx);
+	gsc_ctx_state_lock_set(GSC_PARAMS, ctx);
 
 	pr_debug("f_w: %d, f_h: %d", frame->f_width, frame->f_height);
 
@@ -357,22 +353,14 @@ static int gsc_m2m_reqbufs(struct file *file, void *fh,
 {
 	struct gsc_ctx *ctx = fh_to_ctx(fh);
 	struct gsc_dev *gsc = ctx->gsc_dev;
-	struct gsc_frame *frame;
 	u32 max_cnt;
 
 	max_cnt = (reqbufs->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) ?
 		gsc->variant->in_buf_cnt : gsc->variant->out_buf_cnt;
 	if (reqbufs->count > max_cnt) {
 		return -EINVAL;
-	} else if (reqbufs->count == 0) {
-		if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
-			gsc_ctx_state_lock_clear(GSC_SRC_FMT, ctx);
-		else
-			gsc_ctx_state_lock_clear(GSC_DST_FMT, ctx);
 	}
 
-	frame = ctx_get_frame(ctx, reqbufs->type);
-
 	return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
 }
 
@@ -527,24 +515,22 @@ static int gsc_m2m_s_selection(struct file *file, void *fh,
 	}
 
 	/* Check to see if scaling ratio is within supported range */
-	if (gsc_ctx_state_is_set(GSC_DST_FMT | GSC_SRC_FMT, ctx)) {
-		if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
-			ret = gsc_check_scaler_ratio(variant, cr.c.width,
-				cr.c.height, ctx->d_frame.crop.width,
-				ctx->d_frame.crop.height,
-				ctx->gsc_ctrls.rotate->val, ctx->out_path);
-		} else {
-			ret = gsc_check_scaler_ratio(variant,
-				ctx->s_frame.crop.width,
-				ctx->s_frame.crop.height, cr.c.width,
-				cr.c.height, ctx->gsc_ctrls.rotate->val,
-				ctx->out_path);
-		}
+	if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
+		ret = gsc_check_scaler_ratio(variant, cr.c.width,
+			cr.c.height, ctx->d_frame.crop.width,
+			ctx->d_frame.crop.height,
+			ctx->gsc_ctrls.rotate->val, ctx->out_path);
+	} else {
+		ret = gsc_check_scaler_ratio(variant,
+			ctx->s_frame.crop.width,
+			ctx->s_frame.crop.height, cr.c.width,
+			cr.c.height, ctx->gsc_ctrls.rotate->val,
+			ctx->out_path);
+	}
 
-		if (ret) {
-			pr_err("Out of scaler range");
-			return -EINVAL;
-		}
+	if (ret < 0) {
+		pr_err("Out of scaler range");
+		return ret;
 	}
 
 	frame->crop = cr.c;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC v2 09/10] exynos-gsc: Use mem-to-mem ioctl helpers
  2013-10-12 12:31 [PATCH RFC v2 00/10] V4L2 mem-to-mem ioctl helpers Sylwester Nawrocki
                   ` (7 preceding siblings ...)
  2013-10-12 12:31 ` [PATCH RFC v2 08/10] exynos-gsc: Remove GSC_{SRC, DST}_FMT flags Sylwester Nawrocki
@ 2013-10-12 12:31 ` Sylwester Nawrocki
  2013-10-12 12:32 ` [PATCH RFC v2 10/10] s5p-g2d: " Sylwester Nawrocki
  2013-10-17 17:19 ` [PATCH RFC v2 00/10] V4L2 " Sylwester Nawrocki
  10 siblings, 0 replies; 19+ messages in thread
From: Sylwester Nawrocki @ 2013-10-12 12:31 UTC (permalink / raw)
  To: linux-media
  Cc: hverkuil, pawel, javier.martin, m.szyprowski, shaik.ameer,
	arun.kk, k.debski, p.zabel, kyungmin.park, linux-samsung-soc,
	Sylwester Nawrocki

Simplify the driver by using the m2m ioctl and vb2 helpers.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
Changes since v1:
 - removed unused gsc_m2m_reqbufs() function.
---
 drivers/media/platform/exynos-gsc/gsc-core.h |   12 --
 drivers/media/platform/exynos-gsc/gsc-m2m.c  |  152 +++++---------------------
 2 files changed, 27 insertions(+), 137 deletions(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-core.h b/drivers/media/platform/exynos-gsc/gsc-core.h
index c79b3cb..c4540a8 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.h
+++ b/drivers/media/platform/exynos-gsc/gsc-core.h
@@ -463,18 +463,6 @@ static inline void gsc_hw_clear_irq(struct gsc_dev *dev, int irq)
 	writel(cfg, dev->regs + GSC_IRQ);
 }
 
-static inline void gsc_lock(struct vb2_queue *vq)
-{
-	struct gsc_ctx *ctx = vb2_get_drv_priv(vq);
-	mutex_lock(&ctx->gsc_dev->lock);
-}
-
-static inline void gsc_unlock(struct vb2_queue *vq)
-{
-	struct gsc_ctx *ctx = vb2_get_drv_priv(vq);
-	mutex_unlock(&ctx->gsc_dev->lock);
-}
-
 static inline bool gsc_ctx_state_is_set(u32 mask, struct gsc_ctx *ctx)
 {
 	unsigned long flags;
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index 78bcb92..42da08c 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -73,11 +73,11 @@ void gsc_m2m_job_finish(struct gsc_ctx *ctx, int vb_state)
 {
 	struct vb2_buffer *src_vb, *dst_vb;
 
-	if (!ctx || !ctx->m2m_ctx)
+	if (!ctx || !ctx->fh.m2m_ctx)
 		return;
 
-	src_vb = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
-	dst_vb = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
+	src_vb = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
+	dst_vb = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
 
 	if (src_vb && dst_vb) {
 		src_vb->v4l2_buf.timestamp = dst_vb->v4l2_buf.timestamp;
@@ -87,7 +87,7 @@ void gsc_m2m_job_finish(struct gsc_ctx *ctx, int vb_state)
 		v4l2_m2m_buf_done(dst_vb, vb_state);
 
 		v4l2_m2m_job_finish(ctx->gsc_dev->m2m.m2m_dev,
-				    ctx->m2m_ctx);
+				    ctx->fh.m2m_ctx);
 	}
 }
 
@@ -111,12 +111,12 @@ static int gsc_get_bufs(struct gsc_ctx *ctx)
 	s_frame = &ctx->s_frame;
 	d_frame = &ctx->d_frame;
 
-	src_vb = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
+	src_vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
 	ret = gsc_prepare_addr(ctx, src_vb, s_frame, &s_frame->addr);
 	if (ret)
 		return ret;
 
-	dst_vb = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
+	dst_vb = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
 	ret = gsc_prepare_addr(ctx, dst_vb, d_frame, &d_frame->addr);
 	if (ret)
 		return ret;
@@ -251,19 +251,15 @@ static int gsc_m2m_buf_prepare(struct vb2_buffer *vb)
 static void gsc_m2m_buf_queue(struct vb2_buffer *vb)
 {
 	struct gsc_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
-
-	pr_debug("ctx: %p, ctx->state: 0x%x", ctx, ctx->state);
-
-	if (ctx->m2m_ctx)
-		v4l2_m2m_buf_queue(ctx->m2m_ctx, vb);
+	v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vb);
 }
 
 static struct vb2_ops gsc_m2m_qops = {
 	.queue_setup	 = gsc_m2m_queue_setup,
 	.buf_prepare	 = gsc_m2m_buf_prepare,
 	.buf_queue	 = gsc_m2m_buf_queue,
-	.wait_prepare	 = gsc_unlock,
-	.wait_finish	 = gsc_lock,
+	.wait_prepare	 = vb2_ops_wait_prepare,
+	.wait_finish	 = vb2_ops_wait_finish,
 	.stop_streaming	 = gsc_m2m_stop_streaming,
 	.start_streaming = gsc_m2m_start_streaming,
 };
@@ -319,7 +315,7 @@ static int gsc_m2m_s_fmt_mplane(struct file *file, void *fh,
 	if (ret)
 		return ret;
 
-	vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
+	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
 
 	if (vb2_is_streaming(vq)) {
 		pr_err("queue (%d) busy", f->type);
@@ -348,73 +344,6 @@ static int gsc_m2m_s_fmt_mplane(struct file *file, void *fh,
 	return 0;
 }
 
-static int gsc_m2m_reqbufs(struct file *file, void *fh,
-			  struct v4l2_requestbuffers *reqbufs)
-{
-	struct gsc_ctx *ctx = fh_to_ctx(fh);
-	struct gsc_dev *gsc = ctx->gsc_dev;
-	u32 max_cnt;
-
-	max_cnt = (reqbufs->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) ?
-		gsc->variant->in_buf_cnt : gsc->variant->out_buf_cnt;
-	if (reqbufs->count > max_cnt) {
-		return -EINVAL;
-	}
-
-	return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
-}
-
-static int gsc_m2m_expbuf(struct file *file, void *fh,
-				struct v4l2_exportbuffer *eb)
-{
-	struct gsc_ctx *ctx = fh_to_ctx(fh);
-	return v4l2_m2m_expbuf(file, ctx->m2m_ctx, eb);
-}
-
-static int gsc_m2m_querybuf(struct file *file, void *fh,
-					struct v4l2_buffer *buf)
-{
-	struct gsc_ctx *ctx = fh_to_ctx(fh);
-	return v4l2_m2m_querybuf(file, ctx->m2m_ctx, buf);
-}
-
-static int gsc_m2m_qbuf(struct file *file, void *fh,
-			  struct v4l2_buffer *buf)
-{
-	struct gsc_ctx *ctx = fh_to_ctx(fh);
-	return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
-}
-
-static int gsc_m2m_dqbuf(struct file *file, void *fh,
-			   struct v4l2_buffer *buf)
-{
-	struct gsc_ctx *ctx = fh_to_ctx(fh);
-	return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
-}
-
-static int gsc_m2m_streamon(struct file *file, void *fh,
-			   enum v4l2_buf_type type)
-{
-	struct gsc_ctx *ctx = fh_to_ctx(fh);
-
-	/* The source and target color format need to be set */
-	if (V4L2_TYPE_IS_OUTPUT(type)) {
-		if (!gsc_ctx_state_is_set(GSC_SRC_FMT, ctx))
-			return -EINVAL;
-	} else if (!gsc_ctx_state_is_set(GSC_DST_FMT, ctx)) {
-		return -EINVAL;
-	}
-
-	return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
-}
-
-static int gsc_m2m_streamoff(struct file *file, void *fh,
-			    enum v4l2_buf_type type)
-{
-	struct gsc_ctx *ctx = fh_to_ctx(fh);
-	return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
-}
-
 /* Return 1 if rectangle a is enclosed in rectangle b, or 0 otherwise. */
 static int is_rectangle_enclosed(struct v4l2_rect *a, struct v4l2_rect *b)
 {
@@ -549,13 +478,15 @@ static const struct v4l2_ioctl_ops gsc_m2m_ioctl_ops = {
 	.vidioc_try_fmt_vid_out_mplane	= gsc_m2m_try_fmt_mplane,
 	.vidioc_s_fmt_vid_cap_mplane	= gsc_m2m_s_fmt_mplane,
 	.vidioc_s_fmt_vid_out_mplane	= gsc_m2m_s_fmt_mplane,
-	.vidioc_reqbufs			= gsc_m2m_reqbufs,
-	.vidioc_expbuf                  = gsc_m2m_expbuf,
-	.vidioc_querybuf		= gsc_m2m_querybuf,
-	.vidioc_qbuf			= gsc_m2m_qbuf,
-	.vidioc_dqbuf			= gsc_m2m_dqbuf,
-	.vidioc_streamon		= gsc_m2m_streamon,
-	.vidioc_streamoff		= gsc_m2m_streamoff,
+
+	.vidioc_reqbufs			= v4l2_m2m_ioctl_reqbufs,
+	.vidioc_querybuf		= v4l2_m2m_ioctl_querybuf,
+	.vidioc_expbuf			= v4l2_m2m_ioctl_expbuf,
+	.vidioc_qbuf			= v4l2_m2m_ioctl_qbuf,
+	.vidioc_dqbuf			= v4l2_m2m_ioctl_dqbuf,
+
+	.vidioc_streamon		= v4l2_m2m_ioctl_streamon,
+	.vidioc_streamoff		= v4l2_m2m_ioctl_streamoff,
 	.vidioc_g_selection		= gsc_m2m_g_selection,
 	.vidioc_s_selection		= gsc_m2m_s_selection
 };
@@ -574,6 +505,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
 	src_vq->mem_ops = &vb2_dma_contig_memops;
 	src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
 	src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+	src_vq->lock = &ctx->gsc_dev->lock;
 
 	ret = vb2_queue_init(src_vq);
 	if (ret)
@@ -587,6 +519,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
 	dst_vq->mem_ops = &vb2_dma_contig_memops;
 	dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
 	dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+	dst_vq->lock = &ctx->gsc_dev->lock;
 
 	return vb2_queue_init(dst_vq);
 }
@@ -654,10 +587,10 @@ static int gsc_m2m_open(struct file *file)
 	ctx->in_path = GSC_DMA;
 	ctx->out_path = GSC_DMA;
 
-	ctx->m2m_ctx = v4l2_m2m_ctx_init(gsc->m2m.m2m_dev, ctx, queue_init);
-	if (IS_ERR(ctx->m2m_ctx)) {
+	ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(gsc->m2m.m2m_dev, ctx, queue_init);
+	if (IS_ERR(ctx->fh.m2m_ctx)) {
 		pr_err("Failed to initialize m2m context");
-		ret = PTR_ERR(ctx->m2m_ctx);
+		ret = PTR_ERR(ctx->fh.m2m_ctx);
 		goto error_ctrls;
 	}
 
@@ -696,7 +629,7 @@ static int gsc_m2m_release(struct file *file)
 
 	mutex_lock(&gsc->lock);
 
-	v4l2_m2m_ctx_release(ctx->m2m_ctx);
+	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
 	gsc_ctrls_delete(ctx);
 	v4l2_fh_del(&ctx->fh);
 	v4l2_fh_exit(&ctx->fh);
@@ -709,44 +642,13 @@ static int gsc_m2m_release(struct file *file)
 	return 0;
 }
 
-static unsigned int gsc_m2m_poll(struct file *file,
-					struct poll_table_struct *wait)
-{
-	struct gsc_ctx *ctx = fh_to_ctx(file->private_data);
-	struct gsc_dev *gsc = ctx->gsc_dev;
-	int ret;
-
-	if (mutex_lock_interruptible(&gsc->lock))
-		return -ERESTARTSYS;
-
-	ret = v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
-	mutex_unlock(&gsc->lock);
-
-	return ret;
-}
-
-static int gsc_m2m_mmap(struct file *file, struct vm_area_struct *vma)
-{
-	struct gsc_ctx *ctx = fh_to_ctx(file->private_data);
-	struct gsc_dev *gsc = ctx->gsc_dev;
-	int ret;
-
-	if (mutex_lock_interruptible(&gsc->lock))
-		return -ERESTARTSYS;
-
-	ret = v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
-	mutex_unlock(&gsc->lock);
-
-	return ret;
-}
-
 static const struct v4l2_file_operations gsc_m2m_fops = {
 	.owner		= THIS_MODULE,
 	.open		= gsc_m2m_open,
 	.release	= gsc_m2m_release,
-	.poll		= gsc_m2m_poll,
+	.poll		= v4l2_m2m_fop_poll,
 	.unlocked_ioctl	= video_ioctl2,
-	.mmap		= gsc_m2m_mmap,
+	.mmap		= v4l2_m2m_fop_mmap,
 };
 
 static struct v4l2_m2m_ops gsc_m2m_ops = {
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC v2 10/10] s5p-g2d: Use mem-to-mem ioctl helpers
  2013-10-12 12:31 [PATCH RFC v2 00/10] V4L2 mem-to-mem ioctl helpers Sylwester Nawrocki
                   ` (8 preceding siblings ...)
  2013-10-12 12:31 ` [PATCH RFC v2 09/10] exynos-gsc: Use mem-to-mem ioctl helpers Sylwester Nawrocki
@ 2013-10-12 12:32 ` Sylwester Nawrocki
  2013-10-16 11:31   ` Kamil Debski
  2013-10-17 17:19 ` [PATCH RFC v2 00/10] V4L2 " Sylwester Nawrocki
  10 siblings, 1 reply; 19+ messages in thread
From: Sylwester Nawrocki @ 2013-10-12 12:32 UTC (permalink / raw)
  To: linux-media
  Cc: hverkuil, pawel, javier.martin, m.szyprowski, shaik.ameer,
	arun.kk, k.debski, p.zabel, kyungmin.park, linux-samsung-soc,
	Sylwester Nawrocki

Simplify the driver by using the m2m ioctl and vb2 helpers.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
Changes since v1:
 - use m2m context pointer from struct v4l2_fh.
---
 drivers/media/platform/s5p-g2d/g2d.c |  124 ++++++----------------------------
 drivers/media/platform/s5p-g2d/g2d.h |    1 -
 2 files changed, 21 insertions(+), 104 deletions(-)

diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c
index fd6289d..9c12008 100644
--- a/drivers/media/platform/s5p-g2d/g2d.c
+++ b/drivers/media/platform/s5p-g2d/g2d.c
@@ -136,10 +136,9 @@ static int g2d_buf_prepare(struct vb2_buffer *vb)
 static void g2d_buf_queue(struct vb2_buffer *vb)
 {
 	struct g2d_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
-	v4l2_m2m_buf_queue(ctx->m2m_ctx, vb);
+	v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vb);
 }
 
-
 static struct vb2_ops g2d_qops = {
 	.queue_setup	= g2d_queue_setup,
 	.buf_prepare	= g2d_buf_prepare,
@@ -159,6 +158,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
 	src_vq->mem_ops = &vb2_dma_contig_memops;
 	src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
 	src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+	src_vq->lock = &ctx->dev->mutex;
 
 	ret = vb2_queue_init(src_vq);
 	if (ret)
@@ -171,6 +171,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
 	dst_vq->mem_ops = &vb2_dma_contig_memops;
 	dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
 	dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+	dst_vq->lock = &ctx->dev->mutex;
 
 	return vb2_queue_init(dst_vq);
 }
@@ -253,9 +254,9 @@ static int g2d_open(struct file *file)
 		kfree(ctx);
 		return -ERESTARTSYS;
 	}
-	ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init);
-	if (IS_ERR(ctx->m2m_ctx)) {
-		ret = PTR_ERR(ctx->m2m_ctx);
+	ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init);
+	if (IS_ERR(ctx->fh.m2m_ctx)) {
+		ret = PTR_ERR(ctx->fh.m2m_ctx);
 		mutex_unlock(&dev->mutex);
 		kfree(ctx);
 		return ret;
@@ -324,7 +325,7 @@ static int vidioc_g_fmt(struct file *file, void *prv, struct v4l2_format *f)
 	struct vb2_queue *vq;
 	struct g2d_frame *frm;
 
-	vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
+	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
 	if (!vq)
 		return -EINVAL;
 	frm = get_frame(ctx, f->type);
@@ -384,7 +385,7 @@ static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
 	ret = vidioc_try_fmt(file, prv, f);
 	if (ret)
 		return ret;
-	vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
+	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
 	if (vb2_is_busy(vq)) {
 		v4l2_err(&dev->v4l2_dev, "queue (%d) bust\n", f->type);
 		return -EBUSY;
@@ -410,72 +411,6 @@ static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
 	return 0;
 }
 
-static unsigned int g2d_poll(struct file *file, struct poll_table_struct *wait)
-{
-	struct g2d_ctx *ctx = fh2ctx(file->private_data);
-	struct g2d_dev *dev = ctx->dev;
-	unsigned int res;
-
-	mutex_lock(&dev->mutex);
-	res = v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
-	mutex_unlock(&dev->mutex);
-	return res;
-}
-
-static int g2d_mmap(struct file *file, struct vm_area_struct *vma)
-{
-	struct g2d_ctx *ctx = fh2ctx(file->private_data);
-	struct g2d_dev *dev = ctx->dev;
-	int ret;
-
-	if (mutex_lock_interruptible(&dev->mutex))
-		return -ERESTARTSYS;
-	ret = v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
-	mutex_unlock(&dev->mutex);
-	return ret;
-}
-
-static int vidioc_reqbufs(struct file *file, void *priv,
-			struct v4l2_requestbuffers *reqbufs)
-{
-	struct g2d_ctx *ctx = priv;
-	return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
-}
-
-static int vidioc_querybuf(struct file *file, void *priv,
-			struct v4l2_buffer *buf)
-{
-	struct g2d_ctx *ctx = priv;
-	return v4l2_m2m_querybuf(file, ctx->m2m_ctx, buf);
-}
-
-static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
-{
-	struct g2d_ctx *ctx = priv;
-	return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
-}
-
-static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
-{
-	struct g2d_ctx *ctx = priv;
-	return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
-}
-
-
-static int vidioc_streamon(struct file *file, void *priv,
-					enum v4l2_buf_type type)
-{
-	struct g2d_ctx *ctx = priv;
-	return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
-}
-
-static int vidioc_streamoff(struct file *file, void *priv,
-					enum v4l2_buf_type type)
-{
-	struct g2d_ctx *ctx = priv;
-	return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
-}
-
 static int vidioc_cropcap(struct file *file, void *priv,
 					struct v4l2_cropcap *cr)
 {
@@ -551,20 +486,6 @@ static int vidioc_s_crop(struct file *file, void *prv, const struct v4l2_crop *c
 	return 0;
 }
 
-static void g2d_lock(void *prv)
-{
-	struct g2d_ctx *ctx = prv;
-	struct g2d_dev *dev = ctx->dev;
-	mutex_lock(&dev->mutex);
-}
-
-static void g2d_unlock(void *prv)
-{
-	struct g2d_ctx *ctx = prv;
-	struct g2d_dev *dev = ctx->dev;
-	mutex_unlock(&dev->mutex);
-}
-
 static void job_abort(void *prv)
 {
 	struct g2d_ctx *ctx = prv;
@@ -589,8 +510,8 @@ static void device_run(void *prv)
 
 	dev->curr = ctx;
 
-	src = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
-	dst = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
+	src = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
+	dst = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
 
 	clk_enable(dev->gate);
 	g2d_reset(dev);
@@ -631,8 +552,8 @@ static irqreturn_t g2d_isr(int irq, void *prv)
 
 	BUG_ON(ctx == NULL);
 
-	src = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
-	dst = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
+	src = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
+	dst = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
 
 	BUG_ON(src == NULL);
 	BUG_ON(dst == NULL);
@@ -642,7 +563,7 @@ static irqreturn_t g2d_isr(int irq, void *prv)
 
 	v4l2_m2m_buf_done(src, VB2_BUF_STATE_DONE);
 	v4l2_m2m_buf_done(dst, VB2_BUF_STATE_DONE);
-	v4l2_m2m_job_finish(dev->m2m_dev, ctx->m2m_ctx);
+	v4l2_m2m_job_finish(dev->m2m_dev, ctx->fh.m2m_ctx);
 
 	dev->curr = NULL;
 	wake_up(&dev->irq_queue);
@@ -653,9 +574,9 @@ static const struct v4l2_file_operations g2d_fops = {
 	.owner		= THIS_MODULE,
 	.open		= g2d_open,
 	.release	= g2d_release,
-	.poll		= g2d_poll,
+	.poll		= v4l2_m2m_fop_poll,
 	.unlocked_ioctl	= video_ioctl2,
-	.mmap		= g2d_mmap,
+	.mmap		= v4l2_m2m_fop_mmap,
 };
 
 static const struct v4l2_ioctl_ops g2d_ioctl_ops = {
@@ -671,14 +592,13 @@ static const struct v4l2_ioctl_ops g2d_ioctl_ops = {
 	.vidioc_try_fmt_vid_out		= vidioc_try_fmt,
 	.vidioc_s_fmt_vid_out		= vidioc_s_fmt,
 
-	.vidioc_reqbufs			= vidioc_reqbufs,
-	.vidioc_querybuf		= vidioc_querybuf,
-
-	.vidioc_qbuf			= vidioc_qbuf,
-	.vidioc_dqbuf			= vidioc_dqbuf,
+	.vidioc_reqbufs			= v4l2_m2m_ioctl_reqbufs,
+	.vidioc_querybuf		= v4l2_m2m_ioctl_querybuf,
+	.vidioc_qbuf			= v4l2_m2m_ioctl_qbuf,
+	.vidioc_dqbuf			= v4l2_m2m_ioctl_dqbuf,
 
-	.vidioc_streamon		= vidioc_streamon,
-	.vidioc_streamoff		= vidioc_streamoff,
+	.vidioc_streamon		= v4l2_m2m_ioctl_streamon,
+	.vidioc_streamoff		= v4l2_m2m_ioctl_streamoff,
 
 	.vidioc_g_crop			= vidioc_g_crop,
 	.vidioc_s_crop			= vidioc_s_crop,
@@ -697,8 +617,6 @@ static struct video_device g2d_videodev = {
 static struct v4l2_m2m_ops g2d_m2m_ops = {
 	.device_run	= device_run,
 	.job_abort	= job_abort,
-	.lock		= g2d_lock,
-	.unlock		= g2d_unlock,
 };
 
 static const struct of_device_id exynos_g2d_match[];
diff --git a/drivers/media/platform/s5p-g2d/g2d.h b/drivers/media/platform/s5p-g2d/g2d.h
index 300ca05..b0e52ab 100644
--- a/drivers/media/platform/s5p-g2d/g2d.h
+++ b/drivers/media/platform/s5p-g2d/g2d.h
@@ -57,7 +57,6 @@ struct g2d_frame {
 struct g2d_ctx {
 	struct v4l2_fh fh;
 	struct g2d_dev		*dev;
-	struct v4l2_m2m_ctx	*m2m_ctx;
 	struct g2d_frame	in;
 	struct g2d_frame	out;
 	struct v4l2_ctrl	*ctrl_hflip;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC v2.1 01/10] V4L: Add mem2mem ioctl and file operation helpers
  2013-10-12 12:31 ` [PATCH RFC v2 01/10] V4L: Add mem2mem ioctl and file operation helpers Sylwester Nawrocki
@ 2013-10-12 12:38   ` Sylwester Nawrocki
  2013-10-16 11:31     ` Kamil Debski
  0 siblings, 1 reply; 19+ messages in thread
From: Sylwester Nawrocki @ 2013-10-12 12:38 UTC (permalink / raw)
  To: linux-media
  Cc: hverkuil, pawel, javier.martin, m.szyprowski, shaik.ameer,
	arun.kk, k.debski, p.zabel, kyungmin.park, linux-samsung-soc,
	Sylwester Nawrocki

This patch adds ioctl helpers to the V4L2 mem-to-mem API, so we can avoid
several ioctl handlers in the mem-to-mem video node drivers that are simply
a pass-through to the v4l2_m2m_* calls. These helpers will only be useful
for drivers that use same mutex for both OUTPUT and CAPTURE queue, which
is the case for all currently in tree v4l2 m2m drivers. In order to use
the helpers the drivers are required to use struct v4l2_fh.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
---
Changes since v1:
 - added v4l2_m2m_ioctl_create_buf().

This time with the whitespace adjustments I missed to merge into
the first patch.
---
 drivers/media/v4l2-core/v4l2-mem2mem.c |  126 ++++++++++++++++++++++++++++++++
 include/media/v4l2-fh.h                |    4 +
 include/media/v4l2-mem2mem.h           |   24 ++++++
 3 files changed, 154 insertions(+), 0 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c
index 7c43712..7494ee3 100644
--- a/drivers/media/v4l2-core/v4l2-mem2mem.c
+++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
@@ -544,6 +544,8 @@ unsigned int v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,

 	if (m2m_ctx->m2m_dev->m2m_ops->unlock)
 		m2m_ctx->m2m_dev->m2m_ops->unlock(m2m_ctx->priv);
+	else if (m2m_ctx->q_lock)
+		mutex_unlock(m2m_ctx->q_lock);

 	if (list_empty(&src_q->done_list))
 		poll_wait(file, &src_q->done_wq, wait);
@@ -552,6 +554,8 @@ unsigned int v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,

 	if (m2m_ctx->m2m_dev->m2m_ops->lock)
 		m2m_ctx->m2m_dev->m2m_ops->lock(m2m_ctx->priv);
+	else if (m2m_ctx->q_lock)
+		mutex_lock(m2m_ctx->q_lock);

 	spin_lock_irqsave(&src_q->done_lock, flags);
 	if (!list_empty(&src_q->done_list))
@@ -679,6 +683,13 @@ struct v4l2_m2m_ctx *v4l2_m2m_ctx_init(struct v4l2_m2m_dev *m2m_dev,

 	if (ret)
 		goto err;
+	/*
+	 * If both queues use same mutex assign it as the common buffer
+	 * queues lock to the m2m context. This lock is used in the
+	 * v4l2_m2m_ioctl_* helpers.
+	 */
+	if (out_q_ctx->q.lock == cap_q_ctx->q.lock)
+		m2m_ctx->q_lock = out_q_ctx->q.lock;

 	return m2m_ctx;
 err:
@@ -726,3 +737,118 @@ void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx, struct vb2_buffer *vb)
 }
 EXPORT_SYMBOL_GPL(v4l2_m2m_buf_queue);

+/* Videobuf2 ioctl helpers */
+
+int v4l2_m2m_ioctl_reqbufs(struct file *file, void *priv,
+				struct v4l2_requestbuffers *rb)
+{
+	struct v4l2_fh *fh = file->private_data;
+
+	return v4l2_m2m_reqbufs(file, fh->m2m_ctx, rb);
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_reqbufs);
+
+int v4l2_m2m_ioctl_create_bufs(struct file *file, void *priv,
+				struct v4l2_create_buffers *create)
+{
+	struct v4l2_fh *fh = file->private_data;
+
+	return v4l2_m2m_create_bufs(file, fh->m2m_ctx, create);
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_create_bufs);
+
+int v4l2_m2m_ioctl_querybuf(struct file *file, void *priv,
+				struct v4l2_buffer *buf)
+{
+	struct v4l2_fh *fh = file->private_data;
+
+	return v4l2_m2m_querybuf(file, fh->m2m_ctx, buf);
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_querybuf);
+
+int v4l2_m2m_ioctl_qbuf(struct file *file, void *priv,
+				struct v4l2_buffer *buf)
+{
+	struct v4l2_fh *fh = file->private_data;
+
+	return v4l2_m2m_qbuf(file, fh->m2m_ctx, buf);
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_qbuf);
+
+int v4l2_m2m_ioctl_dqbuf(struct file *file, void *priv,
+				struct v4l2_buffer *buf)
+{
+	struct v4l2_fh *fh = file->private_data;
+
+	return v4l2_m2m_dqbuf(file, fh->m2m_ctx, buf);
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_dqbuf);
+
+int v4l2_m2m_ioctl_expbuf(struct file *file, void *priv,
+				struct v4l2_exportbuffer *eb)
+{
+	struct v4l2_fh *fh = file->private_data;
+
+	return v4l2_m2m_expbuf(file, fh->m2m_ctx, eb);
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_expbuf);
+
+int v4l2_m2m_ioctl_streamon(struct file *file, void *priv,
+				enum v4l2_buf_type type)
+{
+	struct v4l2_fh *fh = file->private_data;
+
+	return v4l2_m2m_streamon(file, fh->m2m_ctx, type);
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_streamon);
+
+int v4l2_m2m_ioctl_streamoff(struct file *file, void *priv,
+				enum v4l2_buf_type type)
+{
+	struct v4l2_fh *fh = file->private_data;
+
+	return v4l2_m2m_streamoff(file, fh->m2m_ctx, type);
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_streamoff);
+
+/*
+ * v4l2_file_operations helpers. It is assumed here same lock is used
+ * for the output and the capture buffer queue.
+ */
+
+int v4l2_m2m_fop_mmap(struct file *file, struct vm_area_struct *vma)
+{
+	struct v4l2_fh *fh = file->private_data;
+	struct v4l2_m2m_ctx *m2m_ctx = fh->m2m_ctx;
+	int ret;
+
+	if (m2m_ctx->q_lock && mutex_lock_interruptible(m2m_ctx->q_lock))
+		return -ERESTARTSYS;
+
+	ret = v4l2_m2m_mmap(file, m2m_ctx, vma);
+
+	if (m2m_ctx->q_lock)
+		mutex_unlock(m2m_ctx->q_lock);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_fop_mmap);
+
+unsigned int v4l2_m2m_fop_poll(struct file *file, poll_table *wait)
+{
+	struct v4l2_fh *fh = file->private_data;
+	struct v4l2_m2m_ctx *m2m_ctx = fh->m2m_ctx;
+	unsigned int ret;
+
+	if (m2m_ctx->q_lock)
+		mutex_lock(m2m_ctx->q_lock);
+
+	ret = v4l2_m2m_poll(file, m2m_ctx, wait);
+
+	if (m2m_ctx->q_lock)
+		mutex_unlock(m2m_ctx->q_lock);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_fop_poll);
+
diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
index a62ee18..d942f79 100644
--- a/include/media/v4l2-fh.h
+++ b/include/media/v4l2-fh.h
@@ -43,6 +43,10 @@ struct v4l2_fh {
 	struct list_head	available; /* Dequeueable event */
 	unsigned int		navailable;
 	u32			sequence;
+
+#if IS_ENABLED(CONFIG_V4L2_MEM2MEM_DEV)
+	struct v4l2_m2m_ctx	*m2m_ctx;
+#endif
 };

 /*
diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h
index 44542a2..12ea5a6 100644
--- a/include/media/v4l2-mem2mem.h
+++ b/include/media/v4l2-mem2mem.h
@@ -64,6 +64,9 @@ struct v4l2_m2m_queue_ctx {
 };

 struct v4l2_m2m_ctx {
+	/* optional cap/out vb2 queues lock */
+	struct mutex			*q_lock;
+
 /* private: internal use only */
 	struct v4l2_m2m_dev		*m2m_dev;

@@ -229,5 +232,26 @@ static inline void *v4l2_m2m_dst_buf_remove(struct v4l2_m2m_ctx *m2m_ctx)
 	return v4l2_m2m_buf_remove(&m2m_ctx->cap_q_ctx);
 }

+/* v4l2 ioctl helpers */
+
+int v4l2_m2m_ioctl_reqbufs(struct file *file, void *priv,
+				struct v4l2_requestbuffers *rb);
+int v4l2_m2m_ioctl_create_bufs(struct file *file, void *fh,
+				struct v4l2_create_buffers *create);
+int v4l2_m2m_ioctl_querybuf(struct file *file, void *fh,
+				struct v4l2_buffer *buf);
+int v4l2_m2m_ioctl_expbuf(struct file *file, void *fh,
+				struct v4l2_exportbuffer *eb);
+int v4l2_m2m_ioctl_qbuf(struct file *file, void *fh,
+				struct v4l2_buffer *buf);
+int v4l2_m2m_ioctl_dqbuf(struct file *file, void *fh,
+				struct v4l2_buffer *buf);
+int v4l2_m2m_ioctl_streamon(struct file *file, void *fh,
+				enum v4l2_buf_type type);
+int v4l2_m2m_ioctl_streamoff(struct file *file, void *fh,
+				enum v4l2_buf_type type);
+int v4l2_m2m_fop_mmap(struct file *file, struct vm_area_struct *vma);
+unsigned int v4l2_m2m_fop_poll(struct file *file, poll_table *wait);
+
 #endif /* _MEDIA_V4L2_MEM2MEM_H */

--
1.7.4.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* RE: [PATCH RFC v2.1 01/10] V4L: Add mem2mem ioctl and file operation helpers
  2013-10-12 12:38   ` [PATCH RFC v2.1 " Sylwester Nawrocki
@ 2013-10-16 11:31     ` Kamil Debski
  0 siblings, 0 replies; 19+ messages in thread
From: Kamil Debski @ 2013-10-16 11:31 UTC (permalink / raw)
  To: 'Sylwester Nawrocki', linux-media
  Cc: hverkuil, pawel, javier.martin, Marek Szyprowski, shaik.ameer,
	arun.kk, p.zabel, kyungmin.park, linux-samsung-soc,
	Sylwester Nawrocki

> From: linux-media-owner@vger.kernel.org [mailto:linux-media-
> owner@vger.kernel.org] On Behalf Of Sylwester Nawrocki
> Sent: Saturday, October 12, 2013 2:39 PM
> Subject: [PATCH RFC v2.1 01/10] V4L: Add mem2mem ioctl and file
> operation helpers
> 
> This patch adds ioctl helpers to the V4L2 mem-to-mem API, so we can
> avoid several ioctl handlers in the mem-to-mem video node drivers that
> are simply a pass-through to the v4l2_m2m_* calls. These helpers will
> only be useful for drivers that use same mutex for both OUTPUT and
> CAPTURE queue, which is the case for all currently in tree v4l2 m2m
> drivers. In order to use the helpers the drivers are required to use
> struct v4l2_fh.
> 
> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Acked-by: Kamil Debski <k.debski@samsung.com>

> ---
> Changes since v1:
>  - added v4l2_m2m_ioctl_create_buf().
> 
> This time with the whitespace adjustments I missed to merge into the
> first patch.
> ---
>  drivers/media/v4l2-core/v4l2-mem2mem.c |  126
> ++++++++++++++++++++++++++++++++
>  include/media/v4l2-fh.h                |    4 +
>  include/media/v4l2-mem2mem.h           |   24 ++++++
>  3 files changed, 154 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c
> b/drivers/media/v4l2-core/v4l2-mem2mem.c
> index 7c43712..7494ee3 100644
> --- a/drivers/media/v4l2-core/v4l2-mem2mem.c
> +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
> @@ -544,6 +544,8 @@ unsigned int v4l2_m2m_poll(struct file *file,
> struct v4l2_m2m_ctx *m2m_ctx,
> 
>  	if (m2m_ctx->m2m_dev->m2m_ops->unlock)
>  		m2m_ctx->m2m_dev->m2m_ops->unlock(m2m_ctx->priv);
> +	else if (m2m_ctx->q_lock)
> +		mutex_unlock(m2m_ctx->q_lock);
> 
>  	if (list_empty(&src_q->done_list))
>  		poll_wait(file, &src_q->done_wq, wait); @@ -552,6 +554,8 @@
> unsigned int v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx
> *m2m_ctx,
> 
>  	if (m2m_ctx->m2m_dev->m2m_ops->lock)
>  		m2m_ctx->m2m_dev->m2m_ops->lock(m2m_ctx->priv);
> +	else if (m2m_ctx->q_lock)
> +		mutex_lock(m2m_ctx->q_lock);
> 
>  	spin_lock_irqsave(&src_q->done_lock, flags);
>  	if (!list_empty(&src_q->done_list))
> @@ -679,6 +683,13 @@ struct v4l2_m2m_ctx *v4l2_m2m_ctx_init(struct
> v4l2_m2m_dev *m2m_dev,
> 
>  	if (ret)
>  		goto err;
> +	/*
> +	 * If both queues use same mutex assign it as the common buffer
> +	 * queues lock to the m2m context. This lock is used in the
> +	 * v4l2_m2m_ioctl_* helpers.
> +	 */
> +	if (out_q_ctx->q.lock == cap_q_ctx->q.lock)
> +		m2m_ctx->q_lock = out_q_ctx->q.lock;
> 
>  	return m2m_ctx;
>  err:
> @@ -726,3 +737,118 @@ void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx
> *m2m_ctx, struct vb2_buffer *vb)  }
> EXPORT_SYMBOL_GPL(v4l2_m2m_buf_queue);
> 
> +/* Videobuf2 ioctl helpers */
> +
> +int v4l2_m2m_ioctl_reqbufs(struct file *file, void *priv,
> +				struct v4l2_requestbuffers *rb)
> +{
> +	struct v4l2_fh *fh = file->private_data;
> +
> +	return v4l2_m2m_reqbufs(file, fh->m2m_ctx, rb); }
> +EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_reqbufs);
> +
> +int v4l2_m2m_ioctl_create_bufs(struct file *file, void *priv,
> +				struct v4l2_create_buffers *create) {
> +	struct v4l2_fh *fh = file->private_data;
> +
> +	return v4l2_m2m_create_bufs(file, fh->m2m_ctx, create); }
> +EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_create_bufs);
> +
> +int v4l2_m2m_ioctl_querybuf(struct file *file, void *priv,
> +				struct v4l2_buffer *buf)
> +{
> +	struct v4l2_fh *fh = file->private_data;
> +
> +	return v4l2_m2m_querybuf(file, fh->m2m_ctx, buf); }
> +EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_querybuf);
> +
> +int v4l2_m2m_ioctl_qbuf(struct file *file, void *priv,
> +				struct v4l2_buffer *buf)
> +{
> +	struct v4l2_fh *fh = file->private_data;
> +
> +	return v4l2_m2m_qbuf(file, fh->m2m_ctx, buf); }
> +EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_qbuf);
> +
> +int v4l2_m2m_ioctl_dqbuf(struct file *file, void *priv,
> +				struct v4l2_buffer *buf)
> +{
> +	struct v4l2_fh *fh = file->private_data;
> +
> +	return v4l2_m2m_dqbuf(file, fh->m2m_ctx, buf); }
> +EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_dqbuf);
> +
> +int v4l2_m2m_ioctl_expbuf(struct file *file, void *priv,
> +				struct v4l2_exportbuffer *eb)
> +{
> +	struct v4l2_fh *fh = file->private_data;
> +
> +	return v4l2_m2m_expbuf(file, fh->m2m_ctx, eb); }
> +EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_expbuf);
> +
> +int v4l2_m2m_ioctl_streamon(struct file *file, void *priv,
> +				enum v4l2_buf_type type)
> +{
> +	struct v4l2_fh *fh = file->private_data;
> +
> +	return v4l2_m2m_streamon(file, fh->m2m_ctx, type); }
> +EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_streamon);
> +
> +int v4l2_m2m_ioctl_streamoff(struct file *file, void *priv,
> +				enum v4l2_buf_type type)
> +{
> +	struct v4l2_fh *fh = file->private_data;
> +
> +	return v4l2_m2m_streamoff(file, fh->m2m_ctx, type); }
> +EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_streamoff);
> +
> +/*
> + * v4l2_file_operations helpers. It is assumed here same lock is used
> + * for the output and the capture buffer queue.
> + */
> +
> +int v4l2_m2m_fop_mmap(struct file *file, struct vm_area_struct *vma) {
> +	struct v4l2_fh *fh = file->private_data;
> +	struct v4l2_m2m_ctx *m2m_ctx = fh->m2m_ctx;
> +	int ret;
> +
> +	if (m2m_ctx->q_lock && mutex_lock_interruptible(m2m_ctx->q_lock))
> +		return -ERESTARTSYS;
> +
> +	ret = v4l2_m2m_mmap(file, m2m_ctx, vma);
> +
> +	if (m2m_ctx->q_lock)
> +		mutex_unlock(m2m_ctx->q_lock);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(v4l2_m2m_fop_mmap);
> +
> +unsigned int v4l2_m2m_fop_poll(struct file *file, poll_table *wait) {
> +	struct v4l2_fh *fh = file->private_data;
> +	struct v4l2_m2m_ctx *m2m_ctx = fh->m2m_ctx;
> +	unsigned int ret;
> +
> +	if (m2m_ctx->q_lock)
> +		mutex_lock(m2m_ctx->q_lock);
> +
> +	ret = v4l2_m2m_poll(file, m2m_ctx, wait);
> +
> +	if (m2m_ctx->q_lock)
> +		mutex_unlock(m2m_ctx->q_lock);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(v4l2_m2m_fop_poll);
> +
> diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h index
> a62ee18..d942f79 100644
> --- a/include/media/v4l2-fh.h
> +++ b/include/media/v4l2-fh.h
> @@ -43,6 +43,10 @@ struct v4l2_fh {
>  	struct list_head	available; /* Dequeueable event */
>  	unsigned int		navailable;
>  	u32			sequence;
> +
> +#if IS_ENABLED(CONFIG_V4L2_MEM2MEM_DEV)
> +	struct v4l2_m2m_ctx	*m2m_ctx;
> +#endif
>  };
> 
>  /*
> diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-
> mem2mem.h index 44542a2..12ea5a6 100644
> --- a/include/media/v4l2-mem2mem.h
> +++ b/include/media/v4l2-mem2mem.h
> @@ -64,6 +64,9 @@ struct v4l2_m2m_queue_ctx {  };
> 
>  struct v4l2_m2m_ctx {
> +	/* optional cap/out vb2 queues lock */
> +	struct mutex			*q_lock;
> +
>  /* private: internal use only */
>  	struct v4l2_m2m_dev		*m2m_dev;
> 
> @@ -229,5 +232,26 @@ static inline void *v4l2_m2m_dst_buf_remove(struct
> v4l2_m2m_ctx *m2m_ctx)
>  	return v4l2_m2m_buf_remove(&m2m_ctx->cap_q_ctx);
>  }
> 
> +/* v4l2 ioctl helpers */
> +
> +int v4l2_m2m_ioctl_reqbufs(struct file *file, void *priv,
> +				struct v4l2_requestbuffers *rb);
> +int v4l2_m2m_ioctl_create_bufs(struct file *file, void *fh,
> +				struct v4l2_create_buffers *create); int
> +v4l2_m2m_ioctl_querybuf(struct file *file, void *fh,
> +				struct v4l2_buffer *buf);
> +int v4l2_m2m_ioctl_expbuf(struct file *file, void *fh,
> +				struct v4l2_exportbuffer *eb);
> +int v4l2_m2m_ioctl_qbuf(struct file *file, void *fh,
> +				struct v4l2_buffer *buf);
> +int v4l2_m2m_ioctl_dqbuf(struct file *file, void *fh,
> +				struct v4l2_buffer *buf);
> +int v4l2_m2m_ioctl_streamon(struct file *file, void *fh,
> +				enum v4l2_buf_type type);
> +int v4l2_m2m_ioctl_streamoff(struct file *file, void *fh,
> +				enum v4l2_buf_type type);
> +int v4l2_m2m_fop_mmap(struct file *file, struct vm_area_struct *vma);
> +unsigned int v4l2_m2m_fop_poll(struct file *file, poll_table *wait);
> +
>  #endif /* _MEDIA_V4L2_MEM2MEM_H */
> 
> --
> 1.7.4.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media"
> in the body of a message to majordomo@vger.kernel.org More majordomo
> info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH RFC v2 02/10] mem2mem_testdev: Use mem-to-mem ioctl and vb2 helpers
  2013-10-12 12:31 ` [PATCH RFC v2 02/10] mem2mem_testdev: Use mem-to-mem ioctl and vb2 helpers Sylwester Nawrocki
@ 2013-10-16 11:31   ` Kamil Debski
  0 siblings, 0 replies; 19+ messages in thread
From: Kamil Debski @ 2013-10-16 11:31 UTC (permalink / raw)
  To: 'Sylwester Nawrocki', linux-media
  Cc: hverkuil, pawel, javier.martin, Marek Szyprowski, shaik.ameer,
	arun.kk, p.zabel, kyungmin.park, linux-samsung-soc,
	Sylwester Nawrocki

> From: linux-media-owner@vger.kernel.org [mailto:linux-media-
> owner@vger.kernel.org] On Behalf Of Sylwester Nawrocki
> Sent: Saturday, October 12, 2013 2:32 PM
> Subject: [PATCH RFC v2 02/10] mem2mem_testdev: Use mem-to-mem ioctl and
> vb2 helpers
> 
> Simplify the driver by using the m2m ioctl and vb2 helpers.
> 
> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>

Acked-by: Kamil Debski <k.debski@samsung.com>

> ---
> Changes since v1:
>  - dropped now redundant struct m2mtest_ctx::m2m_ctx field.
> ---
>  drivers/media/platform/mem2mem_testdev.c |  152 ++++++----------------
> --------
>  1 files changed, 28 insertions(+), 124 deletions(-)
> 
> diff --git a/drivers/media/platform/mem2mem_testdev.c
> b/drivers/media/platform/mem2mem_testdev.c
> index 6a17676..a348c07 100644
> --- a/drivers/media/platform/mem2mem_testdev.c
> +++ b/drivers/media/platform/mem2mem_testdev.c
> @@ -177,8 +177,6 @@ struct m2mtest_ctx {
> 
>  	enum v4l2_colorspace	colorspace;
> 
> -	struct v4l2_m2m_ctx	*m2m_ctx;
> -
>  	/* Source and destination queue data */
>  	struct m2mtest_q_data   q_data[2];
>  };
> @@ -342,8 +340,8 @@ static int job_ready(void *priv)  {
>  	struct m2mtest_ctx *ctx = priv;
> 
> -	if (v4l2_m2m_num_src_bufs_ready(ctx->m2m_ctx) < ctx->translen
> -	    || v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx) < ctx->translen)
> {
> +	if (v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx) < ctx->translen
> +	    || v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx) < ctx-
> >translen) {
>  		dprintk(ctx->dev, "Not enough buffers available\n");
>  		return 0;
>  	}
> @@ -359,21 +357,6 @@ static void job_abort(void *priv)
>  	ctx->aborting = 1;
>  }
> 
> -static void m2mtest_lock(void *priv)
> -{
> -	struct m2mtest_ctx *ctx = priv;
> -	struct m2mtest_dev *dev = ctx->dev;
> -	mutex_lock(&dev->dev_mutex);
> -}
> -
> -static void m2mtest_unlock(void *priv)
> -{
> -	struct m2mtest_ctx *ctx = priv;
> -	struct m2mtest_dev *dev = ctx->dev;
> -	mutex_unlock(&dev->dev_mutex);
> -}
> -
> -
>  /* device_run() - prepares and starts the device
>   *
>   * This simulates all the immediate preparations required before
> starting @@ -386,8 +369,8 @@ static void device_run(void *priv)
>  	struct m2mtest_dev *dev = ctx->dev;
>  	struct vb2_buffer *src_buf, *dst_buf;
> 
> -	src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
> -	dst_buf = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
> +	src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
> +	dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
> 
>  	device_process(ctx, src_buf, dst_buf);
> 
> @@ -409,8 +392,8 @@ static void device_isr(unsigned long priv)
>  		return;
>  	}
> 
> -	src_vb = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx);
> -	dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx);
> +	src_vb = v4l2_m2m_src_buf_remove(curr_ctx->fh.m2m_ctx);
> +	dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->fh.m2m_ctx);
> 
>  	curr_ctx->num_processed++;
> 
> @@ -423,7 +406,7 @@ static void device_isr(unsigned long priv)
>  	    || curr_ctx->aborting) {
>  		dprintk(curr_ctx->dev, "Finishing transaction\n");
>  		curr_ctx->num_processed = 0;
> -		v4l2_m2m_job_finish(m2mtest_dev->m2m_dev, curr_ctx-
> >m2m_ctx);
> +		v4l2_m2m_job_finish(m2mtest_dev->m2m_dev, curr_ctx-
> >fh.m2m_ctx);
>  	} else {
>  		device_run(curr_ctx);
>  	}
> @@ -491,7 +474,7 @@ static int vidioc_g_fmt(struct m2mtest_ctx *ctx,
> struct v4l2_format *f)
>  	struct vb2_queue *vq;
>  	struct m2mtest_q_data *q_data;
> 
> -	vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
> +	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
>  	if (!vq)
>  		return -EINVAL;
> 
> @@ -594,7 +577,7 @@ static int vidioc_s_fmt(struct m2mtest_ctx *ctx,
> struct v4l2_format *f)
>  	struct m2mtest_q_data *q_data;
>  	struct vb2_queue *vq;
> 
> -	vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
> +	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
>  	if (!vq)
>  		return -EINVAL;
> 
> @@ -648,52 +631,6 @@ static int vidioc_s_fmt_vid_out(struct file *file,
> void *priv,
>  	return ret;
>  }
> 
> -static int vidioc_reqbufs(struct file *file, void *priv,
> -			  struct v4l2_requestbuffers *reqbufs)
> -{
> -	struct m2mtest_ctx *ctx = file2ctx(file);
> -
> -	return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
> -}
> -
> -static int vidioc_querybuf(struct file *file, void *priv,
> -			   struct v4l2_buffer *buf)
> -{
> -	struct m2mtest_ctx *ctx = file2ctx(file);
> -
> -	return v4l2_m2m_querybuf(file, ctx->m2m_ctx, buf);
> -}
> -
> -static int vidioc_qbuf(struct file *file, void *priv, struct
> v4l2_buffer *buf) -{
> -	struct m2mtest_ctx *ctx = file2ctx(file);
> -
> -	return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
> -}
> -
> -static int vidioc_dqbuf(struct file *file, void *priv, struct
> v4l2_buffer *buf) -{
> -	struct m2mtest_ctx *ctx = file2ctx(file);
> -
> -	return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
> -}
> -
> -static int vidioc_streamon(struct file *file, void *priv,
> -			   enum v4l2_buf_type type)
> -{
> -	struct m2mtest_ctx *ctx = file2ctx(file);
> -
> -	return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
> -}
> -
> -static int vidioc_streamoff(struct file *file, void *priv,
> -			    enum v4l2_buf_type type)
> -{
> -	struct m2mtest_ctx *ctx = file2ctx(file);
> -
> -	return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
> -}
> -
>  static int m2mtest_s_ctrl(struct v4l2_ctrl *ctrl)  {
>  	struct m2mtest_ctx *ctx =
> @@ -748,14 +685,14 @@ static const struct v4l2_ioctl_ops
> m2mtest_ioctl_ops = {
>  	.vidioc_try_fmt_vid_out	= vidioc_try_fmt_vid_out,
>  	.vidioc_s_fmt_vid_out	= vidioc_s_fmt_vid_out,
> 
> -	.vidioc_reqbufs		= vidioc_reqbufs,
> -	.vidioc_querybuf	= vidioc_querybuf,
> +	.vidioc_reqbufs		= v4l2_m2m_ioctl_reqbufs,
> +	.vidioc_querybuf	= v4l2_m2m_ioctl_querybuf,
> +	.vidioc_qbuf		= v4l2_m2m_ioctl_qbuf,
> +	.vidioc_dqbuf		= v4l2_m2m_ioctl_dqbuf,
> 
> -	.vidioc_qbuf		= vidioc_qbuf,
> -	.vidioc_dqbuf		= vidioc_dqbuf,
> +	.vidioc_streamon	= v4l2_m2m_ioctl_streamon,
> +	.vidioc_streamoff	= v4l2_m2m_ioctl_streamoff,
> 
> -	.vidioc_streamon	= vidioc_streamon,
> -	.vidioc_streamoff	= vidioc_streamoff,
>  	.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
>  	.vidioc_unsubscribe_event = v4l2_event_unsubscribe,  }; @@ -
> 818,27 +755,15 @@ static int m2mtest_buf_prepare(struct vb2_buffer *vb)
> static void m2mtest_buf_queue(struct vb2_buffer *vb)  {
>  	struct m2mtest_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
> -	v4l2_m2m_buf_queue(ctx->m2m_ctx, vb);
> -}
> -
> -static void m2mtest_wait_prepare(struct vb2_queue *q) -{
> -	struct m2mtest_ctx *ctx = vb2_get_drv_priv(q);
> -	m2mtest_unlock(ctx);
> -}
> -
> -static void m2mtest_wait_finish(struct vb2_queue *q) -{
> -	struct m2mtest_ctx *ctx = vb2_get_drv_priv(q);
> -	m2mtest_lock(ctx);
> +	v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vb);
>  }
> 
>  static struct vb2_ops m2mtest_qops = {
>  	.queue_setup	 = m2mtest_queue_setup,
>  	.buf_prepare	 = m2mtest_buf_prepare,
>  	.buf_queue	 = m2mtest_buf_queue,
> -	.wait_prepare	 = m2mtest_wait_prepare,
> -	.wait_finish	 = m2mtest_wait_finish,
> +	.wait_prepare	 = vb2_ops_wait_prepare,
> +	.wait_finish	 = vb2_ops_wait_finish,
>  };
> 
>  static int queue_init(void *priv, struct vb2_queue *src_vq, struct
> vb2_queue *dst_vq) @@ -853,6 +778,7 @@ static int queue_init(void *priv,
> struct vb2_queue *src_vq, struct vb2_queue *ds
>  	src_vq->ops = &m2mtest_qops;
>  	src_vq->mem_ops = &vb2_vmalloc_memops;
>  	src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> +	src_vq->lock = &ctx->dev->dev_mutex;
> 
>  	ret = vb2_queue_init(src_vq);
>  	if (ret)
> @@ -865,6 +791,7 @@ static int queue_init(void *priv, struct vb2_queue
> *src_vq, struct vb2_queue *ds
>  	dst_vq->ops = &m2mtest_qops;
>  	dst_vq->mem_ops = &vb2_vmalloc_memops;
>  	dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> +	dst_vq->lock = &ctx->dev->dev_mutex;
> 
>  	return vb2_queue_init(dst_vq);
>  }
> @@ -936,10 +863,10 @@ static int m2mtest_open(struct file *file)
>  	ctx->q_data[V4L2_M2M_DST] = ctx->q_data[V4L2_M2M_SRC];
>  	ctx->colorspace = V4L2_COLORSPACE_REC709;
> 
> -	ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init);
> +	ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx,
> &queue_init);
> 
> -	if (IS_ERR(ctx->m2m_ctx)) {
> -		rc = PTR_ERR(ctx->m2m_ctx);
> +	if (IS_ERR(ctx->fh.m2m_ctx)) {
> +		rc = PTR_ERR(ctx->fh.m2m_ctx);
> 
>  		v4l2_ctrl_handler_free(hdl);
>  		kfree(ctx);
> @@ -949,7 +876,8 @@ static int m2mtest_open(struct file *file)
>  	v4l2_fh_add(&ctx->fh);
>  	atomic_inc(&dev->num_inst);
> 
> -	dprintk(dev, "Created instance %p, m2m_ctx: %p\n", ctx, ctx-
> >m2m_ctx);
> +	dprintk(dev, "Created instance: %p, m2m_ctx: %p\n",
> +		ctx, ctx->fh.m2m_ctx);
> 
>  open_unlock:
>  	mutex_unlock(&dev->dev_mutex);
> @@ -967,7 +895,7 @@ static int m2mtest_release(struct file *file)
>  	v4l2_fh_exit(&ctx->fh);
>  	v4l2_ctrl_handler_free(&ctx->hdl);
>  	mutex_lock(&dev->dev_mutex);
> -	v4l2_m2m_ctx_release(ctx->m2m_ctx);
> +	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
>  	mutex_unlock(&dev->dev_mutex);
>  	kfree(ctx);
> 
> @@ -976,34 +904,13 @@ static int m2mtest_release(struct file *file)
>  	return 0;
>  }
> 
> -static unsigned int m2mtest_poll(struct file *file,
> -				 struct poll_table_struct *wait)
> -{
> -	struct m2mtest_ctx *ctx = file2ctx(file);
> -
> -	return v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
> -}
> -
> -static int m2mtest_mmap(struct file *file, struct vm_area_struct *vma)
> -{
> -	struct m2mtest_dev *dev = video_drvdata(file);
> -	struct m2mtest_ctx *ctx = file2ctx(file);
> -	int res;
> -
> -	if (mutex_lock_interruptible(&dev->dev_mutex))
> -		return -ERESTARTSYS;
> -	res = v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
> -	mutex_unlock(&dev->dev_mutex);
> -	return res;
> -}
> -
>  static const struct v4l2_file_operations m2mtest_fops = {
>  	.owner		= THIS_MODULE,
>  	.open		= m2mtest_open,
>  	.release	= m2mtest_release,
> -	.poll		= m2mtest_poll,
> +	.poll		= v4l2_m2m_fop_poll,
>  	.unlocked_ioctl	= video_ioctl2,
> -	.mmap		= m2mtest_mmap,
> +	.mmap		= v4l2_m2m_fop_mmap,
>  };
> 
>  static struct video_device m2mtest_videodev = { @@ -1019,8 +926,6 @@
> static struct v4l2_m2m_ops m2m_ops = {
>  	.device_run	= device_run,
>  	.job_ready	= job_ready,
>  	.job_abort	= job_abort,
> -	.lock		= m2mtest_lock,
> -	.unlock		= m2mtest_unlock,
>  };
> 
>  static int m2mtest_probe(struct platform_device *pdev) @@ -1134,4
> +1039,3 @@ static int __init m2mtest_init(void)
> 
>  module_init(m2mtest_init);
>  module_exit(m2mtest_exit);
> -
> --
> 1.7.4.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media"
> in the body of a message to majordomo@vger.kernel.org More majordomo
> info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH RFC v2 03/10] exynos4-is: Use mem-to-mem ioctl helpers
  2013-10-12 12:31 ` [PATCH RFC v2 03/10] exynos4-is: Use mem-to-mem ioctl helpers Sylwester Nawrocki
@ 2013-10-16 11:31   ` Kamil Debski
  0 siblings, 0 replies; 19+ messages in thread
From: Kamil Debski @ 2013-10-16 11:31 UTC (permalink / raw)
  To: 'Sylwester Nawrocki', linux-media
  Cc: hverkuil, pawel, javier.martin, Marek Szyprowski, shaik.ameer,
	arun.kk, p.zabel, kyungmin.park, linux-samsung-soc,
	Sylwester Nawrocki

> From: linux-media-owner@vger.kernel.org [mailto:linux-media-
> owner@vger.kernel.org] On Behalf Of Sylwester Nawrocki
> Sent: Saturday, October 12, 2013 2:32 PM
> Subject: [PATCH RFC v2 03/10] exynos4-is: Use mem-to-mem ioctl helpers
> 
> Simplify the FIMC mem-to-mem driver by using the m2m ioctl and vb2
> helpers.
> 
> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>

Acked-by: Kamil Debski <k.debski@samsung.com>

> ---
> Changes since v1:
>  - use m2m context pointer from struct v4l2_fh.
> ---
>  drivers/media/platform/exynos4-is/fimc-core.h |    2 -
>  drivers/media/platform/exynos4-is/fimc-m2m.c  |  148 +++++------------
> --------
>  2 files changed, 26 insertions(+), 124 deletions(-)
> 
> diff --git a/drivers/media/platform/exynos4-is/fimc-core.h
> b/drivers/media/platform/exynos4-is/fimc-core.h
> index 3d376fa..1790fb4 100644
> --- a/drivers/media/platform/exynos4-is/fimc-core.h
> +++ b/drivers/media/platform/exynos4-is/fimc-core.h
> @@ -481,7 +481,6 @@ struct fimc_ctrls {
>   * @flags:		additional flags for image conversion
>   * @state:		flags to keep track of user configuration
>   * @fimc_dev:		the FIMC device this context applies to
> - * @m2m_ctx:		memory-to-memory device context
>   * @fh:			v4l2 file handle
>   * @ctrls:		v4l2 controls structure
>   */
> @@ -502,7 +501,6 @@ struct fimc_ctx {
>  	u32			flags;
>  	u32			state;
>  	struct fimc_dev		*fimc_dev;
> -	struct v4l2_m2m_ctx	*m2m_ctx;
>  	struct v4l2_fh		fh;
>  	struct fimc_ctrls	ctrls;
>  };
> diff --git a/drivers/media/platform/exynos4-is/fimc-m2m.c
> b/drivers/media/platform/exynos4-is/fimc-m2m.c
> index 8d33b68..9da95bd 100644
> --- a/drivers/media/platform/exynos4-is/fimc-m2m.c
> +++ b/drivers/media/platform/exynos4-is/fimc-m2m.c
> @@ -44,17 +44,17 @@ void fimc_m2m_job_finish(struct fimc_ctx *ctx, int
> vb_state)  {
>  	struct vb2_buffer *src_vb, *dst_vb;
> 
> -	if (!ctx || !ctx->m2m_ctx)
> +	if (!ctx || !ctx->fh.m2m_ctx)
>  		return;
> 
> -	src_vb = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
> -	dst_vb = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
> +	src_vb = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
> +	dst_vb = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
> 
>  	if (src_vb && dst_vb) {
>  		v4l2_m2m_buf_done(src_vb, vb_state);
>  		v4l2_m2m_buf_done(dst_vb, vb_state);
>  		v4l2_m2m_job_finish(ctx->fimc_dev->m2m.m2m_dev,
> -				    ctx->m2m_ctx);
> +				    ctx->fh.m2m_ctx);
>  	}
>  }
> 
> @@ -123,12 +123,12 @@ static void fimc_device_run(void *priv)
>  		fimc_prepare_dma_offset(ctx, df);
>  	}
> 
> -	src_vb = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
> +	src_vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
>  	ret = fimc_prepare_addr(ctx, src_vb, sf, &sf->paddr);
>  	if (ret)
>  		goto dma_unlock;
> 
> -	dst_vb = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
> +	dst_vb = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
>  	ret = fimc_prepare_addr(ctx, dst_vb, df, &df->paddr);
>  	if (ret)
>  		goto dma_unlock;
> @@ -219,31 +219,15 @@ static int fimc_buf_prepare(struct vb2_buffer *vb)
> static void fimc_buf_queue(struct vb2_buffer *vb)  {
>  	struct fimc_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
> -
> -	dbg("ctx: %p, ctx->state: 0x%x", ctx, ctx->state);
> -
> -	if (ctx->m2m_ctx)
> -		v4l2_m2m_buf_queue(ctx->m2m_ctx, vb);
> -}
> -
> -static void fimc_lock(struct vb2_queue *vq) -{
> -	struct fimc_ctx *ctx = vb2_get_drv_priv(vq);
> -	mutex_lock(&ctx->fimc_dev->lock);
> -}
> -
> -static void fimc_unlock(struct vb2_queue *vq) -{
> -	struct fimc_ctx *ctx = vb2_get_drv_priv(vq);
> -	mutex_unlock(&ctx->fimc_dev->lock);
> +	v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vb);
>  }
> 
>  static struct vb2_ops fimc_qops = {
>  	.queue_setup	 = fimc_queue_setup,
>  	.buf_prepare	 = fimc_buf_prepare,
>  	.buf_queue	 = fimc_buf_queue,
> -	.wait_prepare	 = fimc_unlock,
> -	.wait_finish	 = fimc_lock,
> +	.wait_prepare	 = vb2_ops_wait_prepare,
> +	.wait_finish	 = vb2_ops_wait_finish,
>  	.stop_streaming	 = stop_streaming,
>  	.start_streaming = start_streaming,
>  };
> @@ -385,7 +369,7 @@ static int fimc_m2m_s_fmt_mplane(struct file *file,
> void *fh,
>  	if (ret)
>  		return ret;
> 
> -	vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
> +	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
> 
>  	if (vb2_is_busy(vq)) {
>  		v4l2_err(&fimc->m2m.vfd, "queue (%d) busy\n", f->type); @@
> -410,56 +394,6 @@ static int fimc_m2m_s_fmt_mplane(struct file *file,
> void *fh,
>  	return 0;
>  }
> 
> -static int fimc_m2m_reqbufs(struct file *file, void *fh,
> -			    struct v4l2_requestbuffers *reqbufs)
> -{
> -	struct fimc_ctx *ctx = fh_to_ctx(fh);
> -	return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
> -}
> -
> -static int fimc_m2m_querybuf(struct file *file, void *fh,
> -			     struct v4l2_buffer *buf)
> -{
> -	struct fimc_ctx *ctx = fh_to_ctx(fh);
> -	return v4l2_m2m_querybuf(file, ctx->m2m_ctx, buf);
> -}
> -
> -static int fimc_m2m_qbuf(struct file *file, void *fh,
> -			 struct v4l2_buffer *buf)
> -{
> -	struct fimc_ctx *ctx = fh_to_ctx(fh);
> -	return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
> -}
> -
> -static int fimc_m2m_dqbuf(struct file *file, void *fh,
> -			  struct v4l2_buffer *buf)
> -{
> -	struct fimc_ctx *ctx = fh_to_ctx(fh);
> -	return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
> -}
> -
> -static int fimc_m2m_expbuf(struct file *file, void *fh,
> -			    struct v4l2_exportbuffer *eb)
> -{
> -	struct fimc_ctx *ctx = fh_to_ctx(fh);
> -	return v4l2_m2m_expbuf(file, ctx->m2m_ctx, eb);
> -}
> -
> -
> -static int fimc_m2m_streamon(struct file *file, void *fh,
> -			     enum v4l2_buf_type type)
> -{
> -	struct fimc_ctx *ctx = fh_to_ctx(fh);
> -	return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
> -}
> -
> -static int fimc_m2m_streamoff(struct file *file, void *fh,
> -			    enum v4l2_buf_type type)
> -{
> -	struct fimc_ctx *ctx = fh_to_ctx(fh);
> -	return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
> -}
> -
>  static int fimc_m2m_cropcap(struct file *file, void *fh,
>  			    struct v4l2_cropcap *cr)
>  {
> @@ -598,13 +532,13 @@ static const struct v4l2_ioctl_ops
> fimc_m2m_ioctl_ops = {
>  	.vidioc_try_fmt_vid_out_mplane	= fimc_m2m_try_fmt_mplane,
>  	.vidioc_s_fmt_vid_cap_mplane	= fimc_m2m_s_fmt_mplane,
>  	.vidioc_s_fmt_vid_out_mplane	= fimc_m2m_s_fmt_mplane,
> -	.vidioc_reqbufs			= fimc_m2m_reqbufs,
> -	.vidioc_querybuf		= fimc_m2m_querybuf,
> -	.vidioc_qbuf			= fimc_m2m_qbuf,
> -	.vidioc_dqbuf			= fimc_m2m_dqbuf,
> -	.vidioc_expbuf			= fimc_m2m_expbuf,
> -	.vidioc_streamon		= fimc_m2m_streamon,
> -	.vidioc_streamoff		= fimc_m2m_streamoff,
> +	.vidioc_reqbufs			= v4l2_m2m_ioctl_reqbufs,
> +	.vidioc_querybuf		= v4l2_m2m_ioctl_querybuf,
> +	.vidioc_qbuf			= v4l2_m2m_ioctl_qbuf,
> +	.vidioc_dqbuf			= v4l2_m2m_ioctl_dqbuf,
> +	.vidioc_expbuf			= v4l2_m2m_ioctl_expbuf,
> +	.vidioc_streamon		= v4l2_m2m_ioctl_streamon,
> +	.vidioc_streamoff		= v4l2_m2m_ioctl_streamoff,
>  	.vidioc_g_crop			= fimc_m2m_g_crop,
>  	.vidioc_s_crop			= fimc_m2m_s_crop,
>  	.vidioc_cropcap			= fimc_m2m_cropcap
> @@ -624,6 +558,7 @@ static int queue_init(void *priv, struct vb2_queue
> *src_vq,
>  	src_vq->mem_ops = &vb2_dma_contig_memops;
>  	src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
>  	src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> +	src_vq->lock = &ctx->fimc_dev->lock;
> 
>  	ret = vb2_queue_init(src_vq);
>  	if (ret)
> @@ -636,6 +571,7 @@ static int queue_init(void *priv, struct vb2_queue
> *src_vq,
>  	dst_vq->mem_ops = &vb2_dma_contig_memops;
>  	dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
>  	dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> +	dst_vq->lock = &ctx->fimc_dev->lock;
> 
>  	return vb2_queue_init(dst_vq);
>  }
> @@ -708,9 +644,9 @@ static int fimc_m2m_open(struct file *file)
>  	ctx->out_path = FIMC_IO_DMA;
>  	ctx->scaler.enabled = 1;
> 
> -	ctx->m2m_ctx = v4l2_m2m_ctx_init(fimc->m2m.m2m_dev, ctx,
> queue_init);
> -	if (IS_ERR(ctx->m2m_ctx)) {
> -		ret = PTR_ERR(ctx->m2m_ctx);
> +	ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(fimc->m2m.m2m_dev, ctx,
> queue_init);
> +	if (IS_ERR(ctx->fh.m2m_ctx)) {
> +		ret = PTR_ERR(ctx->fh.m2m_ctx);
>  		goto error_c;
>  	}
> 
> @@ -725,7 +661,7 @@ static int fimc_m2m_open(struct file *file)
>  	return 0;
> 
>  error_m2m_ctx:
> -	v4l2_m2m_ctx_release(ctx->m2m_ctx);
> +	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
>  error_c:
>  	fimc_ctrls_delete(ctx);
>  error_fh:
> @@ -747,7 +683,7 @@ static int fimc_m2m_release(struct file *file)
> 
>  	mutex_lock(&fimc->lock);
> 
> -	v4l2_m2m_ctx_release(ctx->m2m_ctx);
> +	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
>  	fimc_ctrls_delete(ctx);
>  	v4l2_fh_del(&ctx->fh);
>  	v4l2_fh_exit(&ctx->fh);
> @@ -760,45 +696,13 @@ static int fimc_m2m_release(struct file *file)
>  	return 0;
>  }
> 
> -static unsigned int fimc_m2m_poll(struct file *file,
> -				  struct poll_table_struct *wait)
> -{
> -	struct fimc_ctx *ctx = fh_to_ctx(file->private_data);
> -	struct fimc_dev *fimc = ctx->fimc_dev;
> -	int ret;
> -
> -	if (mutex_lock_interruptible(&fimc->lock))
> -		return -ERESTARTSYS;
> -
> -	ret = v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
> -	mutex_unlock(&fimc->lock);
> -
> -	return ret;
> -}
> -
> -
> -static int fimc_m2m_mmap(struct file *file, struct vm_area_struct *vma)
> -{
> -	struct fimc_ctx *ctx = fh_to_ctx(file->private_data);
> -	struct fimc_dev *fimc = ctx->fimc_dev;
> -	int ret;
> -
> -	if (mutex_lock_interruptible(&fimc->lock))
> -		return -ERESTARTSYS;
> -
> -	ret = v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
> -	mutex_unlock(&fimc->lock);
> -
> -	return ret;
> -}
> -
>  static const struct v4l2_file_operations fimc_m2m_fops = {
>  	.owner		= THIS_MODULE,
>  	.open		= fimc_m2m_open,
>  	.release	= fimc_m2m_release,
> -	.poll		= fimc_m2m_poll,
> +	.poll		= v4l2_m2m_fop_poll,
>  	.unlocked_ioctl	= video_ioctl2,
> -	.mmap		= fimc_m2m_mmap,
> +	.mmap		= v4l2_m2m_fop_mmap,
>  };
> 
>  static struct v4l2_m2m_ops m2m_ops = {
> --
> 1.7.4.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media"
> in the body of a message to majordomo@vger.kernel.org More majordomo
> info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH RFC v2 04/10] s5p-jpeg: Use mem-to-mem ioctl helpers
  2013-10-12 12:31 ` [PATCH RFC v2 04/10] s5p-jpeg: " Sylwester Nawrocki
@ 2013-10-16 11:31   ` Kamil Debski
  0 siblings, 0 replies; 19+ messages in thread
From: Kamil Debski @ 2013-10-16 11:31 UTC (permalink / raw)
  To: 'Sylwester Nawrocki', linux-media
  Cc: hverkuil, pawel, javier.martin, Marek Szyprowski, shaik.ameer,
	arun.kk, p.zabel, kyungmin.park, linux-samsung-soc,
	Sylwester Nawrocki

> From: linux-media-owner@vger.kernel.org [mailto:linux-media-
> owner@vger.kernel.org] On Behalf Of Sylwester Nawrocki
> Sent: Saturday, October 12, 2013 2:32 PM
> Subject: [PATCH RFC v2 04/10] s5p-jpeg: Use mem-to-mem ioctl helpers
> 
> Simplify the driver by using the m2m ioctl and vb2 helpers.
> 
> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>

Acked-by: Kamil Debski <k.debski@samsung.com>

> ---
> Changes since v1:
>  - use m2m context pointer from struct v4l2_fh.
> ---
>  drivers/media/platform/s5p-jpeg/jpeg-core.c |  134 +++++--------------
> --------
>  drivers/media/platform/s5p-jpeg/jpeg-core.h |    2 -
>  2 files changed, 24 insertions(+), 112 deletions(-)
> 
> diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c
> b/drivers/media/platform/s5p-jpeg/jpeg-core.c
> index 15d2396..160af4e 100644
> --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
> +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
> @@ -316,9 +316,9 @@ static int s5p_jpeg_open(struct file *file)
>  	if (ret < 0)
>  		goto error;
> 
> -	ctx->m2m_ctx = v4l2_m2m_ctx_init(jpeg->m2m_dev, ctx, queue_init);
> -	if (IS_ERR(ctx->m2m_ctx)) {
> -		ret = PTR_ERR(ctx->m2m_ctx);
> +	ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(jpeg->m2m_dev, ctx,
> queue_init);
> +	if (IS_ERR(ctx->fh.m2m_ctx)) {
> +		ret = PTR_ERR(ctx->fh.m2m_ctx);
>  		goto error;
>  	}
> 
> @@ -342,7 +342,7 @@ static int s5p_jpeg_release(struct file *file)
>  	struct s5p_jpeg_ctx *ctx = fh_to_ctx(file->private_data);
> 
>  	mutex_lock(&jpeg->lock);
> -	v4l2_m2m_ctx_release(ctx->m2m_ctx);
> +	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
>  	mutex_unlock(&jpeg->lock);
>  	v4l2_ctrl_handler_free(&ctx->ctrl_handler);
>  	v4l2_fh_del(&ctx->fh);
> @@ -352,39 +352,13 @@ static int s5p_jpeg_release(struct file *file)
>  	return 0;
>  }
> 
> -static unsigned int s5p_jpeg_poll(struct file *file,
> -				 struct poll_table_struct *wait)
> -{
> -	struct s5p_jpeg *jpeg = video_drvdata(file);
> -	struct s5p_jpeg_ctx *ctx = fh_to_ctx(file->private_data);
> -	unsigned int res;
> -
> -	mutex_lock(&jpeg->lock);
> -	res = v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
> -	mutex_unlock(&jpeg->lock);
> -	return res;
> -}
> -
> -static int s5p_jpeg_mmap(struct file *file, struct vm_area_struct *vma)
> -{
> -	struct s5p_jpeg *jpeg = video_drvdata(file);
> -	struct s5p_jpeg_ctx *ctx = fh_to_ctx(file->private_data);
> -	int ret;
> -
> -	if (mutex_lock_interruptible(&jpeg->lock))
> -		return -ERESTARTSYS;
> -	ret = v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
> -	mutex_unlock(&jpeg->lock);
> -	return ret;
> -}
> -
>  static const struct v4l2_file_operations s5p_jpeg_fops = {
>  	.owner		= THIS_MODULE,
>  	.open		= s5p_jpeg_open,
>  	.release	= s5p_jpeg_release,
> -	.poll		= s5p_jpeg_poll,
> +	.poll		= v4l2_m2m_fop_poll,
>  	.unlocked_ioctl	= video_ioctl2,
> -	.mmap		= s5p_jpeg_mmap,
> +	.mmap		= v4l2_m2m_fop_mmap,
>  };
> 
>  /*
> @@ -589,7 +563,7 @@ static int s5p_jpeg_g_fmt(struct file *file, void
> *priv, struct v4l2_format *f)
>  	struct v4l2_pix_format *pix = &f->fmt.pix;
>  	struct s5p_jpeg_ctx *ct = fh_to_ctx(priv);
> 
> -	vq = v4l2_m2m_get_vq(ct->m2m_ctx, f->type);
> +	vq = v4l2_m2m_get_vq(ct->fh.m2m_ctx, f->type);
>  	if (!vq)
>  		return -EINVAL;
> 
> @@ -745,7 +719,7 @@ static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct,
> struct v4l2_format *f)
>  	struct s5p_jpeg_q_data *q_data = NULL;
>  	struct v4l2_pix_format *pix = &f->fmt.pix;
> 
> -	vq = v4l2_m2m_get_vq(ct->m2m_ctx, f->type);
> +	vq = v4l2_m2m_get_vq(ct->fh.m2m_ctx, f->type);
>  	if (!vq)
>  		return -EINVAL;
> 
> @@ -792,53 +766,6 @@ static int s5p_jpeg_s_fmt_vid_out(struct file
> *file, void *priv,
>  	return s5p_jpeg_s_fmt(fh_to_ctx(priv), f);  }
> 
> -static int s5p_jpeg_reqbufs(struct file *file, void *priv,
> -			  struct v4l2_requestbuffers *reqbufs)
> -{
> -	struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
> -
> -	return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
> -}
> -
> -static int s5p_jpeg_querybuf(struct file *file, void *priv,
> -			   struct v4l2_buffer *buf)
> -{
> -	struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
> -
> -	return v4l2_m2m_querybuf(file, ctx->m2m_ctx, buf);
> -}
> -
> -static int s5p_jpeg_qbuf(struct file *file, void *priv, struct
> v4l2_buffer *buf) -{
> -	struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
> -
> -	return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
> -}
> -
> -static int s5p_jpeg_dqbuf(struct file *file, void *priv,
> -			  struct v4l2_buffer *buf)
> -{
> -	struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
> -
> -	return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
> -}
> -
> -static int s5p_jpeg_streamon(struct file *file, void *priv,
> -			   enum v4l2_buf_type type)
> -{
> -	struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
> -
> -	return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
> -}
> -
> -static int s5p_jpeg_streamoff(struct file *file, void *priv,
> -			    enum v4l2_buf_type type)
> -{
> -	struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
> -
> -	return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
> -}
> -
>  static int s5p_jpeg_g_selection(struct file *file, void *priv,
>  			 struct v4l2_selection *s)
>  {
> @@ -972,14 +899,13 @@ static const struct v4l2_ioctl_ops
> s5p_jpeg_ioctl_ops = {
>  	.vidioc_s_fmt_vid_cap		= s5p_jpeg_s_fmt_vid_cap,
>  	.vidioc_s_fmt_vid_out		= s5p_jpeg_s_fmt_vid_out,
> 
> -	.vidioc_reqbufs			= s5p_jpeg_reqbufs,
> -	.vidioc_querybuf		= s5p_jpeg_querybuf,
> +	.vidioc_reqbufs			= v4l2_m2m_ioctl_reqbufs,
> +	.vidioc_querybuf		= v4l2_m2m_ioctl_querybuf,
> +	.vidioc_qbuf			= v4l2_m2m_ioctl_qbuf,
> +	.vidioc_dqbuf			= v4l2_m2m_ioctl_dqbuf,
> 
> -	.vidioc_qbuf			= s5p_jpeg_qbuf,
> -	.vidioc_dqbuf			= s5p_jpeg_dqbuf,
> -
> -	.vidioc_streamon		= s5p_jpeg_streamon,
> -	.vidioc_streamoff		= s5p_jpeg_streamoff,
> +	.vidioc_streamon		= v4l2_m2m_ioctl_streamon,
> +	.vidioc_streamoff		= v4l2_m2m_ioctl_streamoff,
> 
>  	.vidioc_g_selection		= s5p_jpeg_g_selection,
>  };
> @@ -997,8 +923,8 @@ static void s5p_jpeg_device_run(void *priv)
>  	struct vb2_buffer *src_buf, *dst_buf;
>  	unsigned long src_addr, dst_addr;
> 
> -	src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
> -	dst_buf = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
> +	src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
> +	dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
>  	src_addr = vb2_dma_contig_plane_dma_addr(src_buf, 0);
>  	dst_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 0);
> 
> @@ -1170,22 +1096,8 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer
> *vb)
>  				      );
>  		q_data->size = q_data->w * q_data->h * q_data->fmt->depth >>
> 3;
>  	}
> -	if (ctx->m2m_ctx)
> -		v4l2_m2m_buf_queue(ctx->m2m_ctx, vb);
> -}
> -
> -static void s5p_jpeg_wait_prepare(struct vb2_queue *vq) -{
> -	struct s5p_jpeg_ctx *ctx = vb2_get_drv_priv(vq);
> -
> -	mutex_unlock(&ctx->jpeg->lock);
> -}
> -
> -static void s5p_jpeg_wait_finish(struct vb2_queue *vq) -{
> -	struct s5p_jpeg_ctx *ctx = vb2_get_drv_priv(vq);
> 
> -	mutex_lock(&ctx->jpeg->lock);
> +	v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vb);
>  }
> 
>  static int s5p_jpeg_start_streaming(struct vb2_queue *q, unsigned int
> count) @@ -1211,8 +1123,8 @@ static struct vb2_ops s5p_jpeg_qops = {
>  	.queue_setup		= s5p_jpeg_queue_setup,
>  	.buf_prepare		= s5p_jpeg_buf_prepare,
>  	.buf_queue		= s5p_jpeg_buf_queue,
> -	.wait_prepare		= s5p_jpeg_wait_prepare,
> -	.wait_finish		= s5p_jpeg_wait_finish,
> +	.wait_prepare		= vb2_ops_wait_prepare,
> +	.wait_finish		= vb2_ops_wait_finish,
>  	.start_streaming	= s5p_jpeg_start_streaming,
>  	.stop_streaming		= s5p_jpeg_stop_streaming,
>  };
> @@ -1230,6 +1142,7 @@ static int queue_init(void *priv, struct
> vb2_queue *src_vq,
>  	src_vq->ops = &s5p_jpeg_qops;
>  	src_vq->mem_ops = &vb2_dma_contig_memops;
>  	src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> +	src_vq->lock = &ctx->jpeg->lock;
> 
>  	ret = vb2_queue_init(src_vq);
>  	if (ret)
> @@ -1242,6 +1155,7 @@ static int queue_init(void *priv, struct
> vb2_queue *src_vq,
>  	dst_vq->ops = &s5p_jpeg_qops;
>  	dst_vq->mem_ops = &vb2_dma_contig_memops;
>  	dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> +	dst_vq->lock = &ctx->jpeg->lock;
> 
>  	return vb2_queue_init(dst_vq);
>  }
> @@ -1267,8 +1181,8 @@ static irqreturn_t s5p_jpeg_irq(int irq, void
> *dev_id)
> 
>  	curr_ctx = v4l2_m2m_get_curr_priv(jpeg->m2m_dev);
> 
> -	src_buf = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx);
> -	dst_buf = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx);
> +	src_buf = v4l2_m2m_src_buf_remove(curr_ctx->fh.m2m_ctx);
> +	dst_buf = v4l2_m2m_dst_buf_remove(curr_ctx->fh.m2m_ctx);
> 
>  	if (curr_ctx->mode == S5P_JPEG_ENCODE)
>  		enc_jpeg_too_large = jpeg_enc_stream_stat(jpeg->regs); @@ -
> 1296,7 +1210,7 @@ static irqreturn_t s5p_jpeg_irq(int irq, void *dev_id)
>  	if (curr_ctx->mode == S5P_JPEG_ENCODE)
>  		vb2_set_plane_payload(dst_buf, 0, payload_size);
>  	v4l2_m2m_buf_done(dst_buf, state);
> -	v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->m2m_ctx);
> +	v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx);
> 
>  	curr_ctx->subsampling = jpeg_get_subsampling_mode(jpeg->regs);
>  	spin_unlock(&jpeg->slock);
> diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.h
> b/drivers/media/platform/s5p-jpeg/jpeg-core.h
> index 8a4013e..4a4776b 100644
> --- a/drivers/media/platform/s5p-jpeg/jpeg-core.h
> +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.h
> @@ -115,7 +115,6 @@ struct s5p_jpeg_q_data {
>   * @jpeg:		JPEG IP device for this context
>   * @mode:		compression (encode) operation or decompression
> (decode)
>   * @compr_quality:	destination image quality in compression
> (encode) mode
> - * @m2m_ctx:		mem2mem device context
>   * @out_q:		source (output) queue information
>   * @cap_fmt:		destination (capture) queue queue information
>   * @hdr_parsed:		set if header has been parsed during
> decompression
> @@ -127,7 +126,6 @@ struct s5p_jpeg_ctx {
>  	unsigned short		compr_quality;
>  	unsigned short		restart_interval;
>  	unsigned short		subsampling;
> -	struct v4l2_m2m_ctx	*m2m_ctx;
>  	struct s5p_jpeg_q_data	out_q;
>  	struct s5p_jpeg_q_data	cap_q;
>  	struct v4l2_fh		fh;
> --
> 1.7.4.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media"
> in the body of a message to majordomo@vger.kernel.org More majordomo
> info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH RFC v2 10/10] s5p-g2d: Use mem-to-mem ioctl helpers
  2013-10-12 12:32 ` [PATCH RFC v2 10/10] s5p-g2d: " Sylwester Nawrocki
@ 2013-10-16 11:31   ` Kamil Debski
  0 siblings, 0 replies; 19+ messages in thread
From: Kamil Debski @ 2013-10-16 11:31 UTC (permalink / raw)
  To: 'Sylwester Nawrocki', linux-media
  Cc: hverkuil, pawel, javier.martin, Marek Szyprowski, shaik.ameer,
	arun.kk, p.zabel, kyungmin.park, linux-samsung-soc,
	Sylwester Nawrocki

> From: linux-media-owner@vger.kernel.org [mailto:linux-media-
> owner@vger.kernel.org] On Behalf Of Sylwester Nawrocki
> Sent: Saturday, October 12, 2013 2:32 PM
> Subject: [PATCH RFC v2 10/10] s5p-g2d: Use mem-to-mem ioctl helpers
> 
> Simplify the driver by using the m2m ioctl and vb2 helpers.
> 
> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>

Acked-by: Kamil Debski <k.debski@samsung.com>

> ---
> Changes since v1:
>  - use m2m context pointer from struct v4l2_fh.
> ---
>  drivers/media/platform/s5p-g2d/g2d.c |  124 ++++++--------------------
> --------
>  drivers/media/platform/s5p-g2d/g2d.h |    1 -
>  2 files changed, 21 insertions(+), 104 deletions(-)
> 
> diff --git a/drivers/media/platform/s5p-g2d/g2d.c
> b/drivers/media/platform/s5p-g2d/g2d.c
> index fd6289d..9c12008 100644
> --- a/drivers/media/platform/s5p-g2d/g2d.c
> +++ b/drivers/media/platform/s5p-g2d/g2d.c
> @@ -136,10 +136,9 @@ static int g2d_buf_prepare(struct vb2_buffer *vb)
> static void g2d_buf_queue(struct vb2_buffer *vb)  {
>  	struct g2d_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
> -	v4l2_m2m_buf_queue(ctx->m2m_ctx, vb);
> +	v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vb);
>  }
> 
> -
>  static struct vb2_ops g2d_qops = {
>  	.queue_setup	= g2d_queue_setup,
>  	.buf_prepare	= g2d_buf_prepare,
> @@ -159,6 +158,7 @@ static int queue_init(void *priv, struct vb2_queue
> *src_vq,
>  	src_vq->mem_ops = &vb2_dma_contig_memops;
>  	src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
>  	src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> +	src_vq->lock = &ctx->dev->mutex;
> 
>  	ret = vb2_queue_init(src_vq);
>  	if (ret)
> @@ -171,6 +171,7 @@ static int queue_init(void *priv, struct vb2_queue
> *src_vq,
>  	dst_vq->mem_ops = &vb2_dma_contig_memops;
>  	dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
>  	dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> +	dst_vq->lock = &ctx->dev->mutex;
> 
>  	return vb2_queue_init(dst_vq);
>  }
> @@ -253,9 +254,9 @@ static int g2d_open(struct file *file)
>  		kfree(ctx);
>  		return -ERESTARTSYS;
>  	}
> -	ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init);
> -	if (IS_ERR(ctx->m2m_ctx)) {
> -		ret = PTR_ERR(ctx->m2m_ctx);
> +	ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx,
> &queue_init);
> +	if (IS_ERR(ctx->fh.m2m_ctx)) {
> +		ret = PTR_ERR(ctx->fh.m2m_ctx);
>  		mutex_unlock(&dev->mutex);
>  		kfree(ctx);
>  		return ret;
> @@ -324,7 +325,7 @@ static int vidioc_g_fmt(struct file *file, void
> *prv, struct v4l2_format *f)
>  	struct vb2_queue *vq;
>  	struct g2d_frame *frm;
> 
> -	vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
> +	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
>  	if (!vq)
>  		return -EINVAL;
>  	frm = get_frame(ctx, f->type);
> @@ -384,7 +385,7 @@ static int vidioc_s_fmt(struct file *file, void
> *prv, struct v4l2_format *f)
>  	ret = vidioc_try_fmt(file, prv, f);
>  	if (ret)
>  		return ret;
> -	vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
> +	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
>  	if (vb2_is_busy(vq)) {
>  		v4l2_err(&dev->v4l2_dev, "queue (%d) bust\n", f->type);
>  		return -EBUSY;
> @@ -410,72 +411,6 @@ static int vidioc_s_fmt(struct file *file, void
> *prv, struct v4l2_format *f)
>  	return 0;
>  }
> 
> -static unsigned int g2d_poll(struct file *file, struct
> poll_table_struct *wait) -{
> -	struct g2d_ctx *ctx = fh2ctx(file->private_data);
> -	struct g2d_dev *dev = ctx->dev;
> -	unsigned int res;
> -
> -	mutex_lock(&dev->mutex);
> -	res = v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
> -	mutex_unlock(&dev->mutex);
> -	return res;
> -}
> -
> -static int g2d_mmap(struct file *file, struct vm_area_struct *vma) -{
> -	struct g2d_ctx *ctx = fh2ctx(file->private_data);
> -	struct g2d_dev *dev = ctx->dev;
> -	int ret;
> -
> -	if (mutex_lock_interruptible(&dev->mutex))
> -		return -ERESTARTSYS;
> -	ret = v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
> -	mutex_unlock(&dev->mutex);
> -	return ret;
> -}
> -
> -static int vidioc_reqbufs(struct file *file, void *priv,
> -			struct v4l2_requestbuffers *reqbufs)
> -{
> -	struct g2d_ctx *ctx = priv;
> -	return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
> -}
> -
> -static int vidioc_querybuf(struct file *file, void *priv,
> -			struct v4l2_buffer *buf)
> -{
> -	struct g2d_ctx *ctx = priv;
> -	return v4l2_m2m_querybuf(file, ctx->m2m_ctx, buf);
> -}
> -
> -static int vidioc_qbuf(struct file *file, void *priv, struct
> v4l2_buffer *buf) -{
> -	struct g2d_ctx *ctx = priv;
> -	return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
> -}
> -
> -static int vidioc_dqbuf(struct file *file, void *priv, struct
> v4l2_buffer *buf) -{
> -	struct g2d_ctx *ctx = priv;
> -	return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
> -}
> -
> -
> -static int vidioc_streamon(struct file *file, void *priv,
> -					enum v4l2_buf_type type)
> -{
> -	struct g2d_ctx *ctx = priv;
> -	return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
> -}
> -
> -static int vidioc_streamoff(struct file *file, void *priv,
> -					enum v4l2_buf_type type)
> -{
> -	struct g2d_ctx *ctx = priv;
> -	return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
> -}
> -
>  static int vidioc_cropcap(struct file *file, void *priv,
>  					struct v4l2_cropcap *cr)
>  {
> @@ -551,20 +486,6 @@ static int vidioc_s_crop(struct file *file, void
> *prv, const struct v4l2_crop *c
>  	return 0;
>  }
> 
> -static void g2d_lock(void *prv)
> -{
> -	struct g2d_ctx *ctx = prv;
> -	struct g2d_dev *dev = ctx->dev;
> -	mutex_lock(&dev->mutex);
> -}
> -
> -static void g2d_unlock(void *prv)
> -{
> -	struct g2d_ctx *ctx = prv;
> -	struct g2d_dev *dev = ctx->dev;
> -	mutex_unlock(&dev->mutex);
> -}
> -
>  static void job_abort(void *prv)
>  {
>  	struct g2d_ctx *ctx = prv;
> @@ -589,8 +510,8 @@ static void device_run(void *prv)
> 
>  	dev->curr = ctx;
> 
> -	src = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
> -	dst = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
> +	src = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
> +	dst = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
> 
>  	clk_enable(dev->gate);
>  	g2d_reset(dev);
> @@ -631,8 +552,8 @@ static irqreturn_t g2d_isr(int irq, void *prv)
> 
>  	BUG_ON(ctx == NULL);
> 
> -	src = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
> -	dst = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
> +	src = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
> +	dst = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
> 
>  	BUG_ON(src == NULL);
>  	BUG_ON(dst == NULL);
> @@ -642,7 +563,7 @@ static irqreturn_t g2d_isr(int irq, void *prv)
> 
>  	v4l2_m2m_buf_done(src, VB2_BUF_STATE_DONE);
>  	v4l2_m2m_buf_done(dst, VB2_BUF_STATE_DONE);
> -	v4l2_m2m_job_finish(dev->m2m_dev, ctx->m2m_ctx);
> +	v4l2_m2m_job_finish(dev->m2m_dev, ctx->fh.m2m_ctx);
> 
>  	dev->curr = NULL;
>  	wake_up(&dev->irq_queue);
> @@ -653,9 +574,9 @@ static const struct v4l2_file_operations g2d_fops =
> {
>  	.owner		= THIS_MODULE,
>  	.open		= g2d_open,
>  	.release	= g2d_release,
> -	.poll		= g2d_poll,
> +	.poll		= v4l2_m2m_fop_poll,
>  	.unlocked_ioctl	= video_ioctl2,
> -	.mmap		= g2d_mmap,
> +	.mmap		= v4l2_m2m_fop_mmap,
>  };
> 
>  static const struct v4l2_ioctl_ops g2d_ioctl_ops = { @@ -671,14
> +592,13 @@ static const struct v4l2_ioctl_ops g2d_ioctl_ops = {
>  	.vidioc_try_fmt_vid_out		= vidioc_try_fmt,
>  	.vidioc_s_fmt_vid_out		= vidioc_s_fmt,
> 
> -	.vidioc_reqbufs			= vidioc_reqbufs,
> -	.vidioc_querybuf		= vidioc_querybuf,
> -
> -	.vidioc_qbuf			= vidioc_qbuf,
> -	.vidioc_dqbuf			= vidioc_dqbuf,
> +	.vidioc_reqbufs			= v4l2_m2m_ioctl_reqbufs,
> +	.vidioc_querybuf		= v4l2_m2m_ioctl_querybuf,
> +	.vidioc_qbuf			= v4l2_m2m_ioctl_qbuf,
> +	.vidioc_dqbuf			= v4l2_m2m_ioctl_dqbuf,
> 
> -	.vidioc_streamon		= vidioc_streamon,
> -	.vidioc_streamoff		= vidioc_streamoff,
> +	.vidioc_streamon		= v4l2_m2m_ioctl_streamon,
> +	.vidioc_streamoff		= v4l2_m2m_ioctl_streamoff,
> 
>  	.vidioc_g_crop			= vidioc_g_crop,
>  	.vidioc_s_crop			= vidioc_s_crop,
> @@ -697,8 +617,6 @@ static struct video_device g2d_videodev = {  static
> struct v4l2_m2m_ops g2d_m2m_ops = {
>  	.device_run	= device_run,
>  	.job_abort	= job_abort,
> -	.lock		= g2d_lock,
> -	.unlock		= g2d_unlock,
>  };
> 
>  static const struct of_device_id exynos_g2d_match[]; diff --git
> a/drivers/media/platform/s5p-g2d/g2d.h b/drivers/media/platform/s5p-
> g2d/g2d.h
> index 300ca05..b0e52ab 100644
> --- a/drivers/media/platform/s5p-g2d/g2d.h
> +++ b/drivers/media/platform/s5p-g2d/g2d.h
> @@ -57,7 +57,6 @@ struct g2d_frame {
>  struct g2d_ctx {
>  	struct v4l2_fh fh;
>  	struct g2d_dev		*dev;
> -	struct v4l2_m2m_ctx	*m2m_ctx;
>  	struct g2d_frame	in;
>  	struct g2d_frame	out;
>  	struct v4l2_ctrl	*ctrl_hflip;
> --
> 1.7.4.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media"
> in the body of a message to majordomo@vger.kernel.org More majordomo
> info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH RFC v2 00/10] V4L2 mem-to-mem ioctl helpers
  2013-10-12 12:31 [PATCH RFC v2 00/10] V4L2 mem-to-mem ioctl helpers Sylwester Nawrocki
                   ` (9 preceding siblings ...)
  2013-10-12 12:32 ` [PATCH RFC v2 10/10] s5p-g2d: " Sylwester Nawrocki
@ 2013-10-17 17:19 ` Sylwester Nawrocki
  2013-10-17 17:27   ` Hans Verkuil
  10 siblings, 1 reply; 19+ messages in thread
From: Sylwester Nawrocki @ 2013-10-17 17:19 UTC (permalink / raw)
  To: hverkuil
  Cc: linux-media, pawel, javier.martin, m.szyprowski, shaik.ameer,
	arun.kk, k.debski, p.zabel, kyungmin.park, linux-samsung-soc

Hi Hans,

Can I still add your Ack to updated patches 2, 3, 4, 10 ?

Thanks,
Sylwester

On 12/10/13 14:31, Sylwester Nawrocki wrote:
> Hello,
> 
> This patch set adds ioctl helpers to the v4l2-mem2mem module so the
> video mem-to-mem drivers can be simplified by removing functions that
> are only a pass-through to the v4l2_m2m_* calls. In addition some of
> the vb2 helper functions can be used as well.
> 
> These helpers are similar to the videobuf2 ioctl helpers introduced
> in commit 4c1ffcaad5 "[media] videobuf2-core: add helper functions".
> 
> Currently the requirements to use helper function introduced in this
> patch set is that both OUTPUT and CAPTURE vb2 buffer queues must use
> same lock and the driver uses struct v4l2_fh.
> 
> I have only tested the first four patches in this series, Tested-by
> for the mx2-emmaprp, exynos-gsc, s5p-g2d drivers are appreciated.
> 
> This patch series can be also found at:
>  git://linuxtv.org/snawrocki/samsung.git m2m-helpers-v3
> 
> Changes since original version include addition of related cleanup
> patches, added helper function for create_buf ioctl and m2m context
> pointer from struct v4l2_fh is now reused and related field from the
> drivers' private data structure is removed.
> 
> Thank you for all reviews. I plan to queue the first four patches for
> next kernel release early this week. For the mx2-emmaprp, exynos-gsc,
> s5p-g2d driver feedback is needed from someone who can actually test
> the changes. Any Tested-by for those drivers would be appreciated.
> 
> Thanks,
> Sylwester
> 
> Sylwester Nawrocki (10):
>   V4L: Add mem2mem ioctl and file operation helpers
>   mem2mem_testdev: Use mem-to-mem ioctl and vb2 helpers
>   exynos4-is: Use mem-to-mem ioctl helpers
>   s5p-jpeg: Use mem-to-mem ioctl helpers
>   mx2-emmaprp: Use struct v4l2_fh
>   mx2-emmaprp: Use mem-to-mem ioctl helpers
>   exynos-gsc: Configure default image format at device open()
>   exynos-gsc: Remove GSC_{SRC, DST}_FMT flags
>   exynos-gsc: Use mem-to-mem ioctl helpers
>   s5p-g2d: Use mem-to-mem ioctl helpers
> 
>  drivers/media/platform/exynos-gsc/gsc-core.c  |   10 +-
>  drivers/media/platform/exynos-gsc/gsc-core.h  |   14 --
>  drivers/media/platform/exynos-gsc/gsc-m2m.c   |  232 ++++++++-----------------
>  drivers/media/platform/exynos4-is/fimc-core.h |    2 -
>  drivers/media/platform/exynos4-is/fimc-m2m.c  |  148 +++-------------
>  drivers/media/platform/mem2mem_testdev.c      |  152 +++-------------
>  drivers/media/platform/mx2_emmaprp.c          |  185 ++++++--------------
>  drivers/media/platform/s5p-g2d/g2d.c          |  124 +++-----------
>  drivers/media/platform/s5p-g2d/g2d.h          |    1 -
>  drivers/media/platform/s5p-jpeg/jpeg-core.c   |  134 +++------------
>  drivers/media/platform/s5p-jpeg/jpeg-core.h   |    2 -
>  drivers/media/v4l2-core/v4l2-mem2mem.c        |  118 +++++++++++++
>  include/media/v4l2-fh.h                       |    4 +
>  include/media/v4l2-mem2mem.h                  |   24 +++
>  14 files changed, 382 insertions(+), 768 deletions(-)
> 
> --
> 1.7.4.1

-- 
Sylwester Nawrocki
Samsung R&D Institute Poland

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH RFC v2 00/10] V4L2 mem-to-mem ioctl helpers
  2013-10-17 17:19 ` [PATCH RFC v2 00/10] V4L2 " Sylwester Nawrocki
@ 2013-10-17 17:27   ` Hans Verkuil
  0 siblings, 0 replies; 19+ messages in thread
From: Hans Verkuil @ 2013-10-17 17:27 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: linux-media, pawel, javier.martin, m.szyprowski, shaik.ameer,
	arun.kk, k.debski, p.zabel, kyungmin.park, linux-samsung-soc

Hi Sylwester,

> Hi Hans,
>
> Can I still add your Ack to updated patches 2, 3, 4, 10 ?

Yes, that's OK.

Regards,

    Hans

>
> Thanks,
> Sylwester
>
> On 12/10/13 14:31, Sylwester Nawrocki wrote:
>> Hello,
>>
>> This patch set adds ioctl helpers to the v4l2-mem2mem module so the
>> video mem-to-mem drivers can be simplified by removing functions that
>> are only a pass-through to the v4l2_m2m_* calls. In addition some of
>> the vb2 helper functions can be used as well.
>>
>> These helpers are similar to the videobuf2 ioctl helpers introduced
>> in commit 4c1ffcaad5 "[media] videobuf2-core: add helper functions".
>>
>> Currently the requirements to use helper function introduced in this
>> patch set is that both OUTPUT and CAPTURE vb2 buffer queues must use
>> same lock and the driver uses struct v4l2_fh.
>>
>> I have only tested the first four patches in this series, Tested-by
>> for the mx2-emmaprp, exynos-gsc, s5p-g2d drivers are appreciated.
>>
>> This patch series can be also found at:
>>  git://linuxtv.org/snawrocki/samsung.git m2m-helpers-v3
>>
>> Changes since original version include addition of related cleanup
>> patches, added helper function for create_buf ioctl and m2m context
>> pointer from struct v4l2_fh is now reused and related field from the
>> drivers' private data structure is removed.
>>
>> Thank you for all reviews. I plan to queue the first four patches for
>> next kernel release early this week. For the mx2-emmaprp, exynos-gsc,
>> s5p-g2d driver feedback is needed from someone who can actually test
>> the changes. Any Tested-by for those drivers would be appreciated.
>>
>> Thanks,
>> Sylwester
>>
>> Sylwester Nawrocki (10):
>>   V4L: Add mem2mem ioctl and file operation helpers
>>   mem2mem_testdev: Use mem-to-mem ioctl and vb2 helpers
>>   exynos4-is: Use mem-to-mem ioctl helpers
>>   s5p-jpeg: Use mem-to-mem ioctl helpers
>>   mx2-emmaprp: Use struct v4l2_fh
>>   mx2-emmaprp: Use mem-to-mem ioctl helpers
>>   exynos-gsc: Configure default image format at device open()
>>   exynos-gsc: Remove GSC_{SRC, DST}_FMT flags
>>   exynos-gsc: Use mem-to-mem ioctl helpers
>>   s5p-g2d: Use mem-to-mem ioctl helpers
>>
>>  drivers/media/platform/exynos-gsc/gsc-core.c  |   10 +-
>>  drivers/media/platform/exynos-gsc/gsc-core.h  |   14 --
>>  drivers/media/platform/exynos-gsc/gsc-m2m.c   |  232
>> ++++++++-----------------
>>  drivers/media/platform/exynos4-is/fimc-core.h |    2 -
>>  drivers/media/platform/exynos4-is/fimc-m2m.c  |  148 +++-------------
>>  drivers/media/platform/mem2mem_testdev.c      |  152 +++-------------
>>  drivers/media/platform/mx2_emmaprp.c          |  185
>> ++++++--------------
>>  drivers/media/platform/s5p-g2d/g2d.c          |  124 +++-----------
>>  drivers/media/platform/s5p-g2d/g2d.h          |    1 -
>>  drivers/media/platform/s5p-jpeg/jpeg-core.c   |  134 +++------------
>>  drivers/media/platform/s5p-jpeg/jpeg-core.h   |    2 -
>>  drivers/media/v4l2-core/v4l2-mem2mem.c        |  118 +++++++++++++
>>  include/media/v4l2-fh.h                       |    4 +
>>  include/media/v4l2-mem2mem.h                  |   24 +++
>>  14 files changed, 382 insertions(+), 768 deletions(-)
>>
>> --
>> 1.7.4.1
>
> --
> Sylwester Nawrocki
> Samsung R&D Institute Poland
>



^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2013-10-17 17:27 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-12 12:31 [PATCH RFC v2 00/10] V4L2 mem-to-mem ioctl helpers Sylwester Nawrocki
2013-10-12 12:31 ` [PATCH RFC v2 01/10] V4L: Add mem2mem ioctl and file operation helpers Sylwester Nawrocki
2013-10-12 12:38   ` [PATCH RFC v2.1 " Sylwester Nawrocki
2013-10-16 11:31     ` Kamil Debski
2013-10-12 12:31 ` [PATCH RFC v2 02/10] mem2mem_testdev: Use mem-to-mem ioctl and vb2 helpers Sylwester Nawrocki
2013-10-16 11:31   ` Kamil Debski
2013-10-12 12:31 ` [PATCH RFC v2 03/10] exynos4-is: Use mem-to-mem ioctl helpers Sylwester Nawrocki
2013-10-16 11:31   ` Kamil Debski
2013-10-12 12:31 ` [PATCH RFC v2 04/10] s5p-jpeg: " Sylwester Nawrocki
2013-10-16 11:31   ` Kamil Debski
2013-10-12 12:31 ` [PATCH RFC v2 05/10] mx2-emmaprp: Use struct v4l2_fh Sylwester Nawrocki
2013-10-12 12:31 ` [PATCH RFC v2 06/10] mx2-emmaprp: Use mem-to-mem ioctl helpers Sylwester Nawrocki
2013-10-12 12:31 ` [PATCH RFC v2 07/10] exynos-gsc: Configure default image format at device open() Sylwester Nawrocki
2013-10-12 12:31 ` [PATCH RFC v2 08/10] exynos-gsc: Remove GSC_{SRC, DST}_FMT flags Sylwester Nawrocki
2013-10-12 12:31 ` [PATCH RFC v2 09/10] exynos-gsc: Use mem-to-mem ioctl helpers Sylwester Nawrocki
2013-10-12 12:32 ` [PATCH RFC v2 10/10] s5p-g2d: " Sylwester Nawrocki
2013-10-16 11:31   ` Kamil Debski
2013-10-17 17:19 ` [PATCH RFC v2 00/10] V4L2 " Sylwester Nawrocki
2013-10-17 17:27   ` Hans Verkuil

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.