Re: [PATCH] media: ti-vpe: Use mem-to-mem ioctl helpers

2014-12-19 Thread Hans Verkuil
Hi Prabhakar,

I haven't seen any movement with Nikhil's patches, so it is probably better if
you just post a new version of this patch based on the latest media_tree.

This patch no longer applies cleanly.

Regards,

Hans

On 12/01/2014 12:23 PM, Hans Verkuil wrote:
 On 11/18/2014 02:00 PM, Lad, Prabhakar wrote:
 This patch does the following:

 1: Simplify the vpe mem-to-mem driver by using the m2m ioctl
and vb2 helpers.
 2: Minor code cleanup
 
 FYI: I want to postpone this patch until Nikhil's ti-vpe changes are in 
 (assuming
 that will happen soon). I think his series conflicts with this, and it is 
 likely
 to be easier for you to rebase once his code is in.
 
 Regards,
 
   Hans
 

 Signed-off-by: Lad, Prabhakar prabhakar.cse...@gmail.com
 ---
  drivers/media/platform/ti-vpe/vpe.c | 152 
 +++-
  1 file changed, 47 insertions(+), 105 deletions(-)

 diff --git a/drivers/media/platform/ti-vpe/vpe.c 
 b/drivers/media/platform/ti-vpe/vpe.c
 index 74b858d..faf38d4 100644
 --- a/drivers/media/platform/ti-vpe/vpe.c
 +++ b/drivers/media/platform/ti-vpe/vpe.c
 @@ -21,6 +21,7 @@
  #include linux/dma-mapping.h
  #include linux/err.h
  #include linux/fs.h
 +#include linux/of.h
  #include linux/interrupt.h
  #include linux/io.h
  #include linux/ioctl.h
 @@ -377,7 +378,6 @@ struct vpe_dev {
  struct vpe_ctx {
  struct v4l2_fh  fh;
  struct vpe_dev  *dev;
 -struct v4l2_m2m_ctx *m2m_ctx;
  struct v4l2_ctrl_handler hdl;
  
  unsigned intfield;  /* current field */
 @@ -916,8 +916,8 @@ static int job_ready(void *priv)
   * When called by m2m framework, this will always satisy, but when
   * called from vpe_irq, this might fail. (src stream with zero buffers)
   */
 -if (v4l2_m2m_num_src_bufs_ready(ctx-m2m_ctx) = 0 ||
 -v4l2_m2m_num_dst_bufs_ready(ctx-m2m_ctx) = 0)
 +if (v4l2_m2m_num_src_bufs_ready(ctx-fh.m2m_ctx) = 0 ||
 +v4l2_m2m_num_dst_bufs_ready(ctx-fh.m2m_ctx) = 0)
  return 0;
  
  return 1;
 @@ -1155,14 +1155,14 @@ static void device_run(void *priv)
   * in the same buffer. (so that job_ready won't fail)
   * It will be removed when using bottom field
   */
 -ctx-src_vbs[0] = v4l2_m2m_next_src_buf(ctx-m2m_ctx);
 +ctx-src_vbs[0] = v4l2_m2m_next_src_buf(ctx-fh.m2m_ctx);
  WARN_ON(ctx-src_vbs[0] == NULL);
  } else {
 -ctx-src_vbs[0] = v4l2_m2m_src_buf_remove(ctx-m2m_ctx);
 +ctx-src_vbs[0] = v4l2_m2m_src_buf_remove(ctx-fh.m2m_ctx);
  WARN_ON(ctx-src_vbs[0] == NULL);
  }
  
 -ctx-dst_vb = v4l2_m2m_dst_buf_remove(ctx-m2m_ctx);
 +ctx-dst_vb = v4l2_m2m_dst_buf_remove(ctx-fh.m2m_ctx);
  WARN_ON(ctx-dst_vb == NULL);
  
  if (ctx-deinterlacing) {
 @@ -1422,7 +1422,7 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
  finished:
  vpe_dbg(ctx-dev, finishing transaction\n);
  ctx-bufs_completed = 0;
 -v4l2_m2m_job_finish(dev-m2m_dev, ctx-m2m_ctx);
 +v4l2_m2m_job_finish(dev-m2m_dev, ctx-fh.m2m_ctx);
  handled:
  return IRQ_HANDLED;
  }
 @@ -1483,7 +1483,7 @@ static int vpe_g_fmt(struct file *file, void *priv, 
 struct v4l2_format *f)
  struct vpe_q_data *q_data;
  int i;
  
 -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;
  
 @@ -1624,7 +1624,7 @@ static int __vpe_s_fmt(struct vpe_ctx *ctx, struct 
 v4l2_format *f)
  struct vb2_queue *vq;
  int i;
  
 -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;
  
 @@ -1852,55 +1852,6 @@ static int vpe_s_selection(struct file *file, void 
 *fh,
  return set_srcdst_params(ctx);
  }
  
 -static int vpe_reqbufs(struct file *file, void *priv,
 -   struct v4l2_requestbuffers *reqbufs)
 -{
 -struct vpe_ctx *ctx = file2ctx(file);
 -
 -return v4l2_m2m_reqbufs(file, ctx-m2m_ctx, reqbufs);
 -}
 -
 -static int vpe_querybuf(struct file *file, void *priv, struct v4l2_buffer 
 *buf)
 -{
 -struct vpe_ctx *ctx = file2ctx(file);
 -
 -return v4l2_m2m_querybuf(file, ctx-m2m_ctx, buf);
 -}
 -
 -static int vpe_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
 -{
 -struct vpe_ctx *ctx = file2ctx(file);
 -
 -return v4l2_m2m_qbuf(file, ctx-m2m_ctx, buf);
 -}
 -
 -static int vpe_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
 -{
 -struct vpe_ctx *ctx = file2ctx(file);
 -
 -return v4l2_m2m_dqbuf(file, ctx-m2m_ctx, buf);
 -}
 -
 -static int vpe_streamon(struct file *file, void *priv, enum v4l2_buf_type 
 type)
 -{
 -struct vpe_ctx *ctx = file2ctx(file);
 -
 -if (ctx-deinterlacing)
 -config_edi_input_mode(ctx, 0x0);
 -
 -return v4l2_m2m_streamon(file, ctx-m2m_ctx, type);
 -}
 -
 

Re: [PATCH] media: ti-vpe: Use mem-to-mem ioctl helpers

2014-12-19 Thread Prabhakar Lad
Hi Hans,

On Fri, Dec 19, 2014 at 4:42 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 Hi Prabhakar,

 I haven't seen any movement with Nikhil's patches, so it is probably better if
 you just post a new version of this patch based on the latest media_tree.

I was about to do that, as I was not able to utilize my holidays
in proper way :D

Thanks,
--Prabhakar Lad
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] media: ti-vpe: Use mem-to-mem ioctl helpers

2014-12-01 Thread Hans Verkuil
On 11/18/2014 02:00 PM, Lad, Prabhakar wrote:
 This patch does the following:
 
 1: Simplify the vpe mem-to-mem driver by using the m2m ioctl
and vb2 helpers.
 2: Minor code cleanup

FYI: I want to postpone this patch until Nikhil's ti-vpe changes are in 
(assuming
that will happen soon). I think his series conflicts with this, and it is likely
to be easier for you to rebase once his code is in.

Regards,

Hans

 
 Signed-off-by: Lad, Prabhakar prabhakar.cse...@gmail.com
 ---
  drivers/media/platform/ti-vpe/vpe.c | 152 
 +++-
  1 file changed, 47 insertions(+), 105 deletions(-)
 
 diff --git a/drivers/media/platform/ti-vpe/vpe.c 
 b/drivers/media/platform/ti-vpe/vpe.c
 index 74b858d..faf38d4 100644
 --- a/drivers/media/platform/ti-vpe/vpe.c
 +++ b/drivers/media/platform/ti-vpe/vpe.c
 @@ -21,6 +21,7 @@
  #include linux/dma-mapping.h
  #include linux/err.h
  #include linux/fs.h
 +#include linux/of.h
  #include linux/interrupt.h
  #include linux/io.h
  #include linux/ioctl.h
 @@ -377,7 +378,6 @@ struct vpe_dev {
  struct vpe_ctx {
   struct v4l2_fh  fh;
   struct vpe_dev  *dev;
 - struct v4l2_m2m_ctx *m2m_ctx;
   struct v4l2_ctrl_handler hdl;
  
   unsigned intfield;  /* current field */
 @@ -916,8 +916,8 @@ static int job_ready(void *priv)
* When called by m2m framework, this will always satisy, but when
* called from vpe_irq, this might fail. (src stream with zero buffers)
*/
 - if (v4l2_m2m_num_src_bufs_ready(ctx-m2m_ctx) = 0 ||
 - v4l2_m2m_num_dst_bufs_ready(ctx-m2m_ctx) = 0)
 + if (v4l2_m2m_num_src_bufs_ready(ctx-fh.m2m_ctx) = 0 ||
 + v4l2_m2m_num_dst_bufs_ready(ctx-fh.m2m_ctx) = 0)
   return 0;
  
   return 1;
 @@ -1155,14 +1155,14 @@ static void device_run(void *priv)
* in the same buffer. (so that job_ready won't fail)
* It will be removed when using bottom field
*/
 - ctx-src_vbs[0] = v4l2_m2m_next_src_buf(ctx-m2m_ctx);
 + ctx-src_vbs[0] = v4l2_m2m_next_src_buf(ctx-fh.m2m_ctx);
   WARN_ON(ctx-src_vbs[0] == NULL);
   } else {
 - ctx-src_vbs[0] = v4l2_m2m_src_buf_remove(ctx-m2m_ctx);
 + ctx-src_vbs[0] = v4l2_m2m_src_buf_remove(ctx-fh.m2m_ctx);
   WARN_ON(ctx-src_vbs[0] == NULL);
   }
  
 - ctx-dst_vb = v4l2_m2m_dst_buf_remove(ctx-m2m_ctx);
 + ctx-dst_vb = v4l2_m2m_dst_buf_remove(ctx-fh.m2m_ctx);
   WARN_ON(ctx-dst_vb == NULL);
  
   if (ctx-deinterlacing) {
 @@ -1422,7 +1422,7 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
  finished:
   vpe_dbg(ctx-dev, finishing transaction\n);
   ctx-bufs_completed = 0;
 - v4l2_m2m_job_finish(dev-m2m_dev, ctx-m2m_ctx);
 + v4l2_m2m_job_finish(dev-m2m_dev, ctx-fh.m2m_ctx);
  handled:
   return IRQ_HANDLED;
  }
 @@ -1483,7 +1483,7 @@ static int vpe_g_fmt(struct file *file, void *priv, 
 struct v4l2_format *f)
   struct vpe_q_data *q_data;
   int i;
  
 - 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;
  
 @@ -1624,7 +1624,7 @@ static int __vpe_s_fmt(struct vpe_ctx *ctx, struct 
 v4l2_format *f)
   struct vb2_queue *vq;
   int i;
  
 - 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;
  
 @@ -1852,55 +1852,6 @@ static int vpe_s_selection(struct file *file, void *fh,
   return set_srcdst_params(ctx);
  }
  
 -static int vpe_reqbufs(struct file *file, void *priv,
 -struct v4l2_requestbuffers *reqbufs)
 -{
 - struct vpe_ctx *ctx = file2ctx(file);
 -
 - return v4l2_m2m_reqbufs(file, ctx-m2m_ctx, reqbufs);
 -}
 -
 -static int vpe_querybuf(struct file *file, void *priv, struct v4l2_buffer 
 *buf)
 -{
 - struct vpe_ctx *ctx = file2ctx(file);
 -
 - return v4l2_m2m_querybuf(file, ctx-m2m_ctx, buf);
 -}
 -
 -static int vpe_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
 -{
 - struct vpe_ctx *ctx = file2ctx(file);
 -
 - return v4l2_m2m_qbuf(file, ctx-m2m_ctx, buf);
 -}
 -
 -static int vpe_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
 -{
 - struct vpe_ctx *ctx = file2ctx(file);
 -
 - return v4l2_m2m_dqbuf(file, ctx-m2m_ctx, buf);
 -}
 -
 -static int vpe_streamon(struct file *file, void *priv, enum v4l2_buf_type 
 type)
 -{
 - struct vpe_ctx *ctx = file2ctx(file);
 -
 - if (ctx-deinterlacing)
 - config_edi_input_mode(ctx, 0x0);
 -
 - return v4l2_m2m_streamon(file, ctx-m2m_ctx, type);
 -}
 -
 -static int vpe_streamoff(struct file *file, void *priv, enum v4l2_buf_type 
 type)
 -{
 - struct vpe_ctx *ctx = file2ctx(file);
 -
 - vpe_dump_regs(ctx-dev);
 - vpdma_dump_regs(ctx-dev-vpdma);
 -
 - return 

[PATCH] media: ti-vpe: Use mem-to-mem ioctl helpers

2014-11-18 Thread Lad, Prabhakar
This patch does the following:

1: Simplify the vpe mem-to-mem driver by using the m2m ioctl
   and vb2 helpers.
2: Minor code cleanup

Signed-off-by: Lad, Prabhakar prabhakar.cse...@gmail.com
---
 drivers/media/platform/ti-vpe/vpe.c | 152 +++-
 1 file changed, 47 insertions(+), 105 deletions(-)

diff --git a/drivers/media/platform/ti-vpe/vpe.c 
b/drivers/media/platform/ti-vpe/vpe.c
index 74b858d..faf38d4 100644
--- a/drivers/media/platform/ti-vpe/vpe.c
+++ b/drivers/media/platform/ti-vpe/vpe.c
@@ -21,6 +21,7 @@
 #include linux/dma-mapping.h
 #include linux/err.h
 #include linux/fs.h
+#include linux/of.h
 #include linux/interrupt.h
 #include linux/io.h
 #include linux/ioctl.h
@@ -377,7 +378,6 @@ struct vpe_dev {
 struct vpe_ctx {
struct v4l2_fh  fh;
struct vpe_dev  *dev;
-   struct v4l2_m2m_ctx *m2m_ctx;
struct v4l2_ctrl_handler hdl;
 
unsigned intfield;  /* current field */
@@ -916,8 +916,8 @@ static int job_ready(void *priv)
 * When called by m2m framework, this will always satisy, but when
 * called from vpe_irq, this might fail. (src stream with zero buffers)
 */
-   if (v4l2_m2m_num_src_bufs_ready(ctx-m2m_ctx) = 0 ||
-   v4l2_m2m_num_dst_bufs_ready(ctx-m2m_ctx) = 0)
+   if (v4l2_m2m_num_src_bufs_ready(ctx-fh.m2m_ctx) = 0 ||
+   v4l2_m2m_num_dst_bufs_ready(ctx-fh.m2m_ctx) = 0)
return 0;
 
return 1;
@@ -1155,14 +1155,14 @@ static void device_run(void *priv)
 * in the same buffer. (so that job_ready won't fail)
 * It will be removed when using bottom field
 */
-   ctx-src_vbs[0] = v4l2_m2m_next_src_buf(ctx-m2m_ctx);
+   ctx-src_vbs[0] = v4l2_m2m_next_src_buf(ctx-fh.m2m_ctx);
WARN_ON(ctx-src_vbs[0] == NULL);
} else {
-   ctx-src_vbs[0] = v4l2_m2m_src_buf_remove(ctx-m2m_ctx);
+   ctx-src_vbs[0] = v4l2_m2m_src_buf_remove(ctx-fh.m2m_ctx);
WARN_ON(ctx-src_vbs[0] == NULL);
}
 
-   ctx-dst_vb = v4l2_m2m_dst_buf_remove(ctx-m2m_ctx);
+   ctx-dst_vb = v4l2_m2m_dst_buf_remove(ctx-fh.m2m_ctx);
WARN_ON(ctx-dst_vb == NULL);
 
if (ctx-deinterlacing) {
@@ -1422,7 +1422,7 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
 finished:
vpe_dbg(ctx-dev, finishing transaction\n);
ctx-bufs_completed = 0;
-   v4l2_m2m_job_finish(dev-m2m_dev, ctx-m2m_ctx);
+   v4l2_m2m_job_finish(dev-m2m_dev, ctx-fh.m2m_ctx);
 handled:
return IRQ_HANDLED;
 }
@@ -1483,7 +1483,7 @@ static int vpe_g_fmt(struct file *file, void *priv, 
struct v4l2_format *f)
struct vpe_q_data *q_data;
int i;
 
-   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;
 
@@ -1624,7 +1624,7 @@ static int __vpe_s_fmt(struct vpe_ctx *ctx, struct 
v4l2_format *f)
struct vb2_queue *vq;
int i;
 
-   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;
 
@@ -1852,55 +1852,6 @@ static int vpe_s_selection(struct file *file, void *fh,
return set_srcdst_params(ctx);
 }
 
-static int vpe_reqbufs(struct file *file, void *priv,
-  struct v4l2_requestbuffers *reqbufs)
-{
-   struct vpe_ctx *ctx = file2ctx(file);
-
-   return v4l2_m2m_reqbufs(file, ctx-m2m_ctx, reqbufs);
-}
-
-static int vpe_querybuf(struct file *file, void *priv, struct v4l2_buffer *buf)
-{
-   struct vpe_ctx *ctx = file2ctx(file);
-
-   return v4l2_m2m_querybuf(file, ctx-m2m_ctx, buf);
-}
-
-static int vpe_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
-{
-   struct vpe_ctx *ctx = file2ctx(file);
-
-   return v4l2_m2m_qbuf(file, ctx-m2m_ctx, buf);
-}
-
-static int vpe_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
-{
-   struct vpe_ctx *ctx = file2ctx(file);
-
-   return v4l2_m2m_dqbuf(file, ctx-m2m_ctx, buf);
-}
-
-static int vpe_streamon(struct file *file, void *priv, enum v4l2_buf_type type)
-{
-   struct vpe_ctx *ctx = file2ctx(file);
-
-   if (ctx-deinterlacing)
-   config_edi_input_mode(ctx, 0x0);
-
-   return v4l2_m2m_streamon(file, ctx-m2m_ctx, type);
-}
-
-static int vpe_streamoff(struct file *file, void *priv, enum v4l2_buf_type 
type)
-{
-   struct vpe_ctx *ctx = file2ctx(file);
-
-   vpe_dump_regs(ctx-dev);
-   vpdma_dump_regs(ctx-dev-vpdma);
-
-   return v4l2_m2m_streamoff(file, ctx-m2m_ctx, type);
-}
-
 /*
  * defines number of buffers/frames a context can process with VPE before
  * switching to a different context. default value is 1 buffer per context
@@ -1945,16 +1896,15 @@ static const struct v4l2_ioctl_ops vpe_ioctl_ops = {
.vidioc_g_selection