All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: linux-media@vger.kernel.org
Cc: Mauro Carvalho Chehab <m.chehab@samsung.com>,
	Kamil Debski <k.debski@samsung.com>,
	Fabio Estevam <fabio.estevam@freescale.com>,
	kernel@pengutronix.de, Philipp Zabel <p.zabel@pengutronix.de>
Subject: [PATCH 10/30] [media] coda: Use mem-to-mem ioctl helpers
Date: Fri, 13 Jun 2014 18:08:36 +0200	[thread overview]
Message-ID: <1402675736-15379-11-git-send-email-p.zabel@pengutronix.de> (raw)
In-Reply-To: <1402675736-15379-1-git-send-email-p.zabel@pengutronix.de>

Use the mem2mem helpers introduced to get rid of some duplicated code.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/media/platform/coda.c | 113 ++++++------------------------------------
 1 file changed, 14 insertions(+), 99 deletions(-)

diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index fe94acd..52a429f 100644
--- a/drivers/media/platform/coda.c
+++ b/drivers/media/platform/coda.c
@@ -782,22 +782,6 @@ static int coda_s_fmt_vid_out(struct file *file, void *priv,
 	return ret;
 }
 
-static int coda_reqbufs(struct file *file, void *priv,
-			struct v4l2_requestbuffers *reqbufs)
-{
-	struct coda_ctx *ctx = fh_to_ctx(priv);
-
-	return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
-}
-
-static int coda_querybuf(struct file *file, void *priv,
-			 struct v4l2_buffer *buf)
-{
-	struct coda_ctx *ctx = fh_to_ctx(priv);
-
-	return v4l2_m2m_querybuf(file, ctx->m2m_ctx, buf);
-}
-
 static int coda_qbuf(struct file *file, void *priv,
 		     struct v4l2_buffer *buf)
 {
@@ -806,14 +790,6 @@ static int coda_qbuf(struct file *file, void *priv,
 	return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
 }
 
-static int coda_expbuf(struct file *file, void *priv,
-		       struct v4l2_exportbuffer *eb)
-{
-	struct coda_ctx *ctx = fh_to_ctx(priv);
-
-	return v4l2_m2m_expbuf(file, ctx->m2m_ctx, eb);
-}
-
 static bool coda_buf_is_end_of_stream(struct coda_ctx *ctx,
 				      struct v4l2_buffer *buf)
 {
@@ -846,40 +822,6 @@ static int coda_dqbuf(struct file *file, void *priv,
 	return ret;
 }
 
-static int coda_create_bufs(struct file *file, void *priv,
-			    struct v4l2_create_buffers *create)
-{
-	struct coda_ctx *ctx = fh_to_ctx(priv);
-
-	return v4l2_m2m_create_bufs(file, ctx->m2m_ctx, create);
-}
-
-static int coda_streamon(struct file *file, void *priv,
-			 enum v4l2_buf_type type)
-{
-	struct coda_ctx *ctx = fh_to_ctx(priv);
-
-	return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
-}
-
-static int coda_streamoff(struct file *file, void *priv,
-			  enum v4l2_buf_type type)
-{
-	struct coda_ctx *ctx = fh_to_ctx(priv);
-	int ret;
-
-	/*
-	 * This indirectly calls __vb2_queue_cancel, which dequeues all buffers.
-	 * We therefore have to lock it against running hardware in this context,
-	 * which still needs the buffers.
-	 */
-	mutex_lock(&ctx->buffer_mutex);
-	ret = v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
-	mutex_unlock(&ctx->buffer_mutex);
-
-	return ret;
-}
-
 static int coda_g_selection(struct file *file, void *fh,
 			    struct v4l2_selection *s)
 {
@@ -1041,16 +983,16 @@ static const struct v4l2_ioctl_ops coda_ioctl_ops = {
 	.vidioc_try_fmt_vid_out	= coda_try_fmt_vid_out,
 	.vidioc_s_fmt_vid_out	= coda_s_fmt_vid_out,
 
-	.vidioc_reqbufs		= coda_reqbufs,
-	.vidioc_querybuf	= coda_querybuf,
+	.vidioc_reqbufs		= v4l2_m2m_ioctl_reqbufs,
+	.vidioc_querybuf	= v4l2_m2m_ioctl_querybuf,
 
 	.vidioc_qbuf		= coda_qbuf,
-	.vidioc_expbuf		= coda_expbuf,
+	.vidioc_expbuf		= v4l2_m2m_ioctl_expbuf,
 	.vidioc_dqbuf		= coda_dqbuf,
-	.vidioc_create_bufs	= coda_create_bufs,
+	.vidioc_create_bufs	= v4l2_m2m_ioctl_create_bufs,
 
-	.vidioc_streamon	= coda_streamon,
-	.vidioc_streamoff	= coda_streamoff,
+	.vidioc_streamon	= v4l2_m2m_ioctl_streamon,
+	.vidioc_streamoff	= v4l2_m2m_ioctl_streamoff,
 
 	.vidioc_g_selection	= coda_g_selection,
 
@@ -1731,18 +1673,6 @@ static void coda_buf_queue(struct vb2_buffer *vb)
 	}
 }
 
-static void coda_wait_prepare(struct vb2_queue *q)
-{
-	struct coda_ctx *ctx = vb2_get_drv_priv(q);
-	coda_unlock(ctx);
-}
-
-static void coda_wait_finish(struct vb2_queue *q)
-{
-	struct coda_ctx *ctx = vb2_get_drv_priv(q);
-	coda_lock(ctx);
-}
-
 static void coda_parabuf_write(struct coda_ctx *ctx, int index, u32 value)
 {
 	struct coda_dev *dev = ctx->dev;
@@ -2701,10 +2631,10 @@ static struct vb2_ops coda_qops = {
 	.queue_setup		= coda_queue_setup,
 	.buf_prepare		= coda_buf_prepare,
 	.buf_queue		= coda_buf_queue,
-	.wait_prepare		= coda_wait_prepare,
-	.wait_finish		= coda_wait_finish,
 	.start_streaming	= coda_start_streaming,
 	.stop_streaming		= coda_stop_streaming,
+	.wait_prepare		= vb2_ops_wait_prepare,
+	.wait_finish		= vb2_ops_wait_finish,
 };
 
 static int coda_s_ctrl(struct v4l2_ctrl *ctrl)
@@ -2827,6 +2757,7 @@ static int coda_queue_init(void *priv, struct vb2_queue *src_vq,
 	src_vq->ops = &coda_qops;
 	src_vq->mem_ops = &vb2_dma_contig_memops;
 	src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+	src_vq->lock = &ctx->dev->dev_mutex;
 
 	ret = vb2_queue_init(src_vq);
 	if (ret)
@@ -2839,6 +2770,7 @@ static int coda_queue_init(void *priv, struct vb2_queue *src_vq,
 	dst_vq->ops = &coda_qops;
 	dst_vq->mem_ops = &vb2_dma_contig_memops;
 	dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+	dst_vq->lock = &ctx->dev->dev_mutex;
 
 	return vb2_queue_init(dst_vq);
 }
@@ -2907,6 +2839,8 @@ static int coda_open(struct file *file)
 			 __func__, ret);
 		goto err_ctx_init;
 	}
+	ctx->fh.m2m_ctx = ctx->m2m_ctx;
+
 	ret = coda_ctrls_setup(ctx);
 	if (ret) {
 		v4l2_err(&dev->v4l2_dev, "failed to setup coda controls\n");
@@ -3006,32 +2940,13 @@ static int coda_release(struct file *file)
 	return 0;
 }
 
-static unsigned int coda_poll(struct file *file,
-				 struct poll_table_struct *wait)
-{
-	struct coda_ctx *ctx = fh_to_ctx(file->private_data);
-	int ret;
-
-	coda_lock(ctx);
-	ret = v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
-	coda_unlock(ctx);
-	return ret;
-}
-
-static int coda_mmap(struct file *file, struct vm_area_struct *vma)
-{
-	struct coda_ctx *ctx = fh_to_ctx(file->private_data);
-
-	return v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
-}
-
 static const struct v4l2_file_operations coda_fops = {
 	.owner		= THIS_MODULE,
 	.open		= coda_open,
 	.release	= coda_release,
-	.poll		= coda_poll,
+	.poll		= v4l2_m2m_fop_poll,
 	.unlocked_ioctl	= video_ioctl2,
-	.mmap		= coda_mmap,
+	.mmap		= v4l2_m2m_fop_mmap,
 };
 
 static void coda_finish_decode(struct coda_ctx *ctx)
-- 
2.0.0.rc2


  parent reply	other threads:[~2014-06-13 16:09 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-13 16:08 [PATCH 00/30] Initial CODA960 (i.MX6 VPU) support Philipp Zabel
2014-06-13 16:08 ` [PATCH 01/30] [media] coda: fix decoder I/P/B frame detection Philipp Zabel
2014-06-16  7:54   ` Hans Verkuil
2014-06-13 16:08 ` [PATCH 02/30] [media] coda: fix readback of CODA_RET_DEC_SEQ_FRAME_NEED Philipp Zabel
2014-06-13 16:08 ` [PATCH 03/30] [media] coda: fix h.264 quantization parameter range Philipp Zabel
2014-06-13 16:08 ` [PATCH 04/30] [media] coda: fix internal framebuffer allocation size Philipp Zabel
2014-06-13 16:08 ` [PATCH 05/30] [media] coda: simplify IRAM setup Philipp Zabel
2014-06-13 16:08 ` [PATCH 06/30] [media] coda: Add encoder/decoder support for CODA960 Philipp Zabel
2014-06-24 15:53   ` Nicolas Dufresne
2014-07-01 17:52     ` Philipp Zabel
2014-06-13 16:08 ` [PATCH 07/30] [media] coda: add selection API support for h.264 decoder Philipp Zabel
2014-06-16  8:05   ` Hans Verkuil
2014-06-13 16:08 ` [PATCH 08/30] [media] coda: add support for frame size enumeration Philipp Zabel
2014-06-16  8:08   ` Hans Verkuil
2014-06-24 15:13     ` Philipp Zabel
2014-06-13 16:08 ` [PATCH 09/30] [media] coda: add workqueue to serialize hardware commands Philipp Zabel
2014-06-13 16:08 ` Philipp Zabel [this message]
2014-06-13 16:08 ` [PATCH 11/30] [media] coda: use ctx->fh.m2m_ctx instead of ctx->m2m_ctx Philipp Zabel
2014-06-13 16:08 ` [PATCH 12/30] [media] coda: Add runtime pm support Philipp Zabel
2014-06-13 16:56   ` Sylwester Nawrocki
2014-06-13 21:07     ` Philipp Zabel
2014-06-13 16:08 ` [PATCH 13/30] [media] coda: split firmware version check out of coda_hw_init Philipp Zabel
2014-06-13 16:08 ` [PATCH 14/30] [media] coda: select GENERIC_ALLOCATOR Philipp Zabel
2014-06-13 16:08 ` [PATCH 15/30] [media] coda: add h.264 min/max qp controls Philipp Zabel
2014-06-13 16:08 ` [PATCH 16/30] [media] coda: add h.264 deblocking filter controls Philipp Zabel
2014-06-13 16:08 ` [PATCH 17/30] [media] coda: add cyclic intra refresh control Philipp Zabel
2014-06-13 16:08 ` [PATCH 18/30] [media] coda: let userspace force IDR frames by enabling the keyframe flag in the source buffer Philipp Zabel
2014-06-16  8:24   ` Hans Verkuil
2014-06-24 15:16     ` Philipp Zabel
2014-06-13 16:08 ` [PATCH 19/30] [media] v4l2-mem2mem: export v4l2_m2m_try_schedule Philipp Zabel
2014-06-13 16:08 ` [PATCH 20/30] [media] coda: try to schedule a decode run after a stop command Philipp Zabel
2014-06-13 16:08 ` [PATCH 21/30] [media] coda: add decoder timestamp queue Philipp Zabel
2014-06-13 16:08 ` [PATCH 22/30] [media] coda: alert userspace about macroblock errors Philipp Zabel
2014-06-13 16:08 ` [PATCH 23/30] [media] coda: add sequence counter offset Philipp Zabel
2014-06-13 16:08 ` [PATCH 24/30] [media] coda: use prescan_failed variable to stop stream after a timeout Philipp Zabel
2014-06-13 16:08 ` [PATCH 25/30] [media] coda: add reset control support Philipp Zabel
2014-06-13 16:08 ` [PATCH 26/30] [media] coda: add bytesperline to queue data Philipp Zabel
2014-06-13 16:08 ` [PATCH 27/30] [media] coda: allow odd width, but still round up bytesperline Philipp Zabel
2014-06-13 16:08 ` [PATCH 28/30] [media] coda: round up internal frames to multiples of macroblock size for h.264 Philipp Zabel
2014-06-13 16:08 ` [PATCH 29/30] [media] coda: increase frame stride to 16 " Philipp Zabel
2014-06-13 16:08 ` [PATCH 30/30] [media] coda: export auxiliary buffers via debugfs Philipp Zabel
2014-06-16  8:35 ` [PATCH 00/30] Initial CODA960 (i.MX6 VPU) support Hans Verkuil
2014-06-24 15:07   ` Philipp Zabel
2014-06-27  9:14     ` Hans Verkuil

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=1402675736-15379-11-git-send-email-p.zabel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=fabio.estevam@freescale.com \
    --cc=k.debski@samsung.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is 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.