[PATCH] [media] mtk-vcodec: fix vp9 decode error

2017-07-19 Thread Tiffany Lin
Fix The camera has a blurry screen phenomenon when
we video chat with apprtc using vp9 codec

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   | 37 --
 1 file changed, 35 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c 
b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
index 1daee12..bc8349b 100644
--- a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
@@ -31,6 +31,7 @@
 #define MAX_NUM_REF_FRAMES 8
 #define VP9_MAX_FRM_BUF_NUM 9
 #define VP9_MAX_FRM_BUF_NODE_NUM (VP9_MAX_FRM_BUF_NUM * 2)
+#define VP9_SEG_ID_SZ 0x12000
 
 /**
  * struct vp9_dram_buf - contains buffer info for vpu
@@ -132,6 +133,7 @@ struct vp9_sf_ref_fb {
  * @frm_num : decoded frame number, include sub-frame count (AP-R, VPU-W)
  * @mv_buf : motion vector working buffer (AP-W, VPU-R)
  * @frm_refs : maintain three reference buffer info (AP-R/W, VPU-R/W)
+ * @seg_id_buf : segmentation map working buffer (AP-W, VPU-R)
  */
 struct vdec_vp9_vsi {
unsigned char sf_bs_buf[VP9_SUPER_FRAME_BS_SZ];
@@ -167,11 +169,14 @@ struct vdec_vp9_vsi {
struct vp9_dram_buf mv_buf;
 
struct vp9_ref_buf frm_refs[REFS_PER_FRAME];
+   struct vp9_dram_buf seg_id_buf;
+
 };
 
 /*
  * struct vdec_vp9_inst - vp9 decode instance
  * @mv_buf : working buffer for mv
+ * @seg_id_buf : working buffer for segmentation map
  * @dec_fb : vdec_fb node to link fb to different fb_xxx_list
  * @available_fb_node_list : current available vdec_fb node
  * @fb_use_list : current used or referenced vdec_fb
@@ -187,6 +192,7 @@ struct vdec_vp9_vsi {
  */
 struct vdec_vp9_inst {
struct mtk_vcodec_mem mv_buf;
+   struct mtk_vcodec_mem seg_id_buf;
 
struct vdec_fb_node dec_fb[VP9_MAX_FRM_BUF_NODE_NUM];
struct list_head available_fb_node_list;
@@ -388,13 +394,11 @@ static bool vp9_alloc_work_buf(struct vdec_vp9_inst *inst)
vsi->buf_h);
 
mem = >mv_buf;
-
if (mem->va)
mtk_vcodec_mem_free(inst->ctx, mem);
 
mem->size = ((vsi->buf_w / 64) *
(vsi->buf_h / 64) + 2) * 36 * 16;
-
result = mtk_vcodec_mem_alloc(inst->ctx, mem);
if (result) {
mem->size = 0;
@@ -406,6 +410,24 @@ static bool vp9_alloc_work_buf(struct vdec_vp9_inst *inst)
vsi->mv_buf.pa = (unsigned long)mem->dma_addr;
vsi->mv_buf.sz = (unsigned int)mem->size;
 
+
+   mem = >seg_id_buf;
+   if (mem->va)
+   mtk_vcodec_mem_free(inst->ctx, mem);
+
+   mem->size = VP9_SEG_ID_SZ;
+   result = mtk_vcodec_mem_alloc(inst->ctx, mem);
+   if (result) {
+   mem->size = 0;
+   mtk_vcodec_err(inst, "Cannot allocate seg_id_buf");
+   return false;
+   }
+   /* Set the va again */
+   vsi->seg_id_buf.va = (unsigned long)mem->va;
+   vsi->seg_id_buf.pa = (unsigned long)mem->dma_addr;
+   vsi->seg_id_buf.sz = (unsigned int)mem->size;
+
+
vp9_free_all_sf_ref_fb(inst);
vsi->sf_next_ref_fb_idx = vp9_get_sf_ref_fb(inst);
 
@@ -653,6 +675,12 @@ static void vp9_reset(struct vdec_vp9_inst *inst)
inst->vsi->mv_buf.va = (unsigned long)inst->mv_buf.va;
inst->vsi->mv_buf.pa = (unsigned long)inst->mv_buf.dma_addr;
inst->vsi->mv_buf.sz = (unsigned long)inst->mv_buf.size;
+
+   /* Set the va again, since vpu_dec_reset will clear seg_id_buf in vpu */
+   inst->vsi->seg_id_buf.va = (unsigned long)inst->seg_id_buf.va;
+   inst->vsi->seg_id_buf.pa = (unsigned long)inst->seg_id_buf.dma_addr;
+   inst->vsi->seg_id_buf.sz = (unsigned long)inst->seg_id_buf.size;
+
 }
 
 static void init_all_fb_lists(struct vdec_vp9_inst *inst)
@@ -752,6 +780,10 @@ static void vdec_vp9_deinit(unsigned long h_vdec)
if (mem->va)
mtk_vcodec_mem_free(inst->ctx, mem);
 
+   mem = >seg_id_buf;
+   if (mem->va)
+   mtk_vcodec_mem_free(inst->ctx, mem);
+
vp9_free_all_sf_ref_fb(inst);
vp9_free_inst(inst);
 }
@@ -848,6 +880,7 @@ static int vdec_vp9_decode(unsigned long h_vdec, struct 
mtk_vcodec_mem *bs,
vsi->sf_frm_sz[idx]);
}
}
+   memset(inst->seg_id_buf.va, 0, inst->seg_id_buf.size);
ret = vpu_dec_start(>vpu, data, 3);
if (ret) {
mtk_vcodec_err(inst, "vpu_dec_start failed");
-- 
1.9.1



Re: [PATCH v2] [media] mtk-vcodec: Show mtk driver error without DEBUG definition

2017-06-19 Thread Tiffany Lin
On Tue, 2017-05-30 at 18:53 +0900, Hirokazu Honda wrote:
> A driver error message is shown without DEBUG definition
> to find an error and debug easily.
> 
> Signed-off-by: Hirokazu Honda <hi...@chromium.org>
Acked-by: Tiffany Lin <tiffany@mediatek.com>

> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h | 20 +---
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> index 237e144c194f..06c254f5c171 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> @@ -32,6 +32,15 @@ extern int mtk_v4l2_dbg_level;
>  extern bool mtk_vcodec_dbg;
>  
> 
> +#define mtk_v4l2_err(fmt, args...)\
> + pr_err("[MTK_V4L2][ERROR] %s:%d: " fmt "\n", __func__, __LINE__, \
> +##args)
> +
> +#define mtk_vcodec_err(h, fmt, args...)  
> \
> + pr_err("[MTK_VCODEC][ERROR][%d]: %s() " fmt "\n",   \
> +((struct mtk_vcodec_ctx *)h->ctx)->id, __func__, ##args)
> +
> +
>  #if defined(DEBUG)
>  
>  #define mtk_v4l2_debug(level, fmt, args...)   \
> @@ -41,11 +50,6 @@ extern bool mtk_vcodec_dbg;
>   level, __func__, __LINE__, ##args);  \
>   } while (0)
>  
> -#define mtk_v4l2_err(fmt, args...)\
> - pr_err("[MTK_V4L2][ERROR] %s:%d: " fmt "\n", __func__, __LINE__, \
> -##args)
> -
> -
>  #define mtk_v4l2_debug_enter()  mtk_v4l2_debug(3, "+")
>  #define mtk_v4l2_debug_leave()  mtk_v4l2_debug(3, "-")
>  
> @@ -57,22 +61,16 @@ extern bool mtk_vcodec_dbg;
>   __func__, ##args);  \
>   } while (0)
>  
> -#define mtk_vcodec_err(h, fmt, args...)  
> \
> - pr_err("[MTK_VCODEC][ERROR][%d]: %s() " fmt "\n",   \
> -((struct mtk_vcodec_ctx *)h->ctx)->id, __func__, ##args)
> -
>  #define mtk_vcodec_debug_enter(h)  mtk_vcodec_debug(h, "+")
>  #define mtk_vcodec_debug_leave(h)  mtk_vcodec_debug(h, "-")
>  
>  #else
>  
>  #define mtk_v4l2_debug(level, fmt, args...) {}
> -#define mtk_v4l2_err(fmt, args...) {}
>  #define mtk_v4l2_debug_enter() {}
>  #define mtk_v4l2_debug_leave() {}
>  
>  #define mtk_vcodec_debug(h, fmt, args...) {}
> -#define mtk_vcodec_err(h, fmt, args...) {}
>  #define mtk_vcodec_debug_enter(h) {}
>  #define mtk_vcodec_debug_leave(h) {}
>  




Re: [PATCH] media: mtk-vcodec: remove informative log

2017-04-21 Thread Tiffany Lin
On Wed, 2017-04-19 at 07:56 -0300, Mauro Carvalho Chehab wrote:
> Em Wed, 5 Apr 2017 19:09:59 +0800
> Tiffany Lin <tiffany@mediatek.com> escreveu:
> 
> > On Wed, 2017-04-05 at 18:54 +0800, Minghsiu Tsai wrote:
> > > Driver is stable. Remove DEBUG definition from driver.
> > > 
> > > There are debug message in /var/log/messages if DEBUG is defined,
> > > such as:
> > > [MTK_V4L2] level=0 fops_vcodec_open(),170: decoder capability 0
> > > [MTK_V4L2] level=0 fops_vcodec_open(),177: 1600.vcodec decoder [0]
> > > [MTK_V4L2] level=0 fops_vcodec_release(),200: [0] decoder
> > > 
> > > Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>  
> > Acked-by:Tiffany Lin <tiffany@mediatek.com>
> > 
> > > ---
> > >  drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h | 1 -
> > >  1 file changed, 1 deletion(-)
> > > 
> > > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h 
> > > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> > > index 7d55975..1248083 100644
> > > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> > > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> > > @@ -31,7 +31,6 @@ struct mtk_vcodec_mem {
> > >  extern int mtk_v4l2_dbg_level;
> > >  extern bool mtk_vcodec_dbg;
> > >  
> > > -#define DEBUG1
> > >  
> > >  #if defined(DEBUG)
> > >
> 
> After this patch, building the Kernel with W=1 now shows warnings:
> 
> drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c: In function 
> 'mtk_vcodec_dec_pw_on':
> drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c:114:51: warning: 
> suggest braces around empty body in an 'if' statement [-Wempty-body]
>mtk_v4l2_err("pm_runtime_get_sync fail %d", ret);
>^
> 
> I wrote a patch fixing it, as this is really a trivial issue.
> 
> Yet, after that, this one still remains:
> 
> 
> drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c: In function 
> 'mtk_vdec_pic_info_update':
> drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c:284:6: warning: variable 
> 'ret' set but not used [-Wunused-but-set-variable]
>   int ret;
>   ^~~
> 


> 
> Shouldn't be mtk_vdec_pic_info_update() returning an error code?
> 
> 
> Also, IMHO, at least errors should be shown at dmesg.
> 
Got it. We will upstream patch to fix warning and add dmesg when error.


best regards,
Tiffany

> Thanks,
> Mauro




Re: [PATCH] [media] mtk-vcodec: avoid warnings because of empty macros

2017-04-21 Thread Tiffany Lin
On Wed, 2017-04-19 at 07:56 -0300, Mauro Carvalho Chehab wrote:
> Remove those gcc warnings:
> 
>   drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c: In function 
> 'mtk_vcodec_dec_pw_on':
>   drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c:114:51: warning: 
> suggest braces around empty body in an 'if' statement [-Wempty-body]
>  mtk_v4l2_err("pm_runtime_get_sync fail %d", ret);
>  ^
> 
> By adding braces.
> 
> Signed-off-by: Mauro Carvalho Chehab <mche...@s-opensource.com>
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> index 12480837ff2e..237e144c194f 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> @@ -66,15 +66,15 @@ extern bool mtk_vcodec_dbg;
>  
>  #else
>  
> -#define mtk_v4l2_debug(level, fmt, args...)
> -#define mtk_v4l2_err(fmt, args...)
> -#define mtk_v4l2_debug_enter()
> -#define mtk_v4l2_debug_leave()
> +#define mtk_v4l2_debug(level, fmt, args...) {}
> +#define mtk_v4l2_err(fmt, args...) {}
> +#define mtk_v4l2_debug_enter() {}
> +#define mtk_v4l2_debug_leave() {}
>  
> -#define mtk_vcodec_debug(h, fmt, args...)
> -#define mtk_vcodec_err(h, fmt, args...)
> -#define mtk_vcodec_debug_enter(h)
> -#define mtk_vcodec_debug_leave(h)
> +#define mtk_vcodec_debug(h, fmt, args...) {}
> +#define mtk_vcodec_err(h, fmt, args...) {}
> +#define mtk_vcodec_debug_enter(h) {}
> +#define mtk_vcodec_debug_leave(h) {}
>  
>  #endif
>  

Acked-by: Tiffany Lin <tiffany@mediatek.com>



Re: [PATCH] media: mtk-vcodec: remove informative log

2017-04-05 Thread Tiffany Lin
On Wed, 2017-04-05 at 18:54 +0800, Minghsiu Tsai wrote:
> Driver is stable. Remove DEBUG definition from driver.
> 
> There are debug message in /var/log/messages if DEBUG is defined,
> such as:
> [MTK_V4L2] level=0 fops_vcodec_open(),170: decoder capability 0
> [MTK_V4L2] level=0 fops_vcodec_open(),177: 1600.vcodec decoder [0]
> [MTK_V4L2] level=0 fops_vcodec_release(),200: [0] decoder
> 
> Signed-off-by: Minghsiu Tsai 
Acked-by:Tiffany Lin 

> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> index 7d55975..1248083 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> @@ -31,7 +31,6 @@ struct mtk_vcodec_mem {
>  extern int mtk_v4l2_dbg_level;
>  extern bool mtk_vcodec_dbg;
>  
> -#define DEBUG1
>  
>  #if defined(DEBUG)
>  




Re: [PATCH v3 1/1] mtk-vcodec: check the vp9 decoder buffer index from VPU.

2017-03-07 Thread Tiffany Lin
On Wed, 2017-03-08 at 11:40 +0800, Wu-Cheng Li wrote:
> From: Wu-Cheng Li <wuchen...@google.com>
> 
> VPU firmware has a bug and may return invalid buffer index for
> some vp9 videos. Check the buffer indexes before accessing the
> buffer.
> 

Acked-by: Tiffany Lin <tiffany@mediatek.com>

> Signed-off-by: Wu-Cheng Li <wuchen...@chromium.org>
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 33 
> +-
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h |  2 ++
>  .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   | 26 +
>  drivers/media/platform/mtk-vcodec/vdec_drv_if.h|  2 ++
>  4 files changed, 56 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> index 502877a4b1df..a60b538686ea 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> @@ -420,6 +420,11 @@ static void mtk_vdec_worker(struct work_struct *work)
>   dst_buf->index,
>   ret, res_chg);
>   src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
> + if (ret == -EIO) {
> + mutex_lock(>lock);
> + src_buf_info->error = true;
> + mutex_unlock(>lock);
> + }
>   v4l2_m2m_buf_done(_buf_info->vb, VB2_BUF_STATE_ERROR);
>   } else if (res_chg == false) {
>   /*
> @@ -1170,8 +1175,16 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer 
> *vb)
>*/
>  
>   src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
> - v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
> - VB2_BUF_STATE_DONE);
> + if (ret == -EIO) {
> + mtk_v4l2_err("[%d] Unrecoverable error in 
> vdec_if_decode.",
> + ctx->id);
> + ctx->state = MTK_STATE_ABORT;
> + v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
> + VB2_BUF_STATE_ERROR);
> + } else {
> + v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
> + VB2_BUF_STATE_DONE);
> + }
>   mtk_v4l2_debug(ret ? 0 : 1,
>  "[%d] vdec_if_decode() src_buf=%d, size=%zu, 
> fail=%d, res_chg=%d",
>  ctx->id, src_buf->index,
> @@ -1216,16 +1229,22 @@ static void vb2ops_vdec_buf_finish(struct vb2_buffer 
> *vb)
>   struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
>   struct vb2_v4l2_buffer *vb2_v4l2;
>   struct mtk_video_dec_buf *buf;
> -
> - if (vb->vb2_queue->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> - return;
> + bool buf_error;
>  
>   vb2_v4l2 = container_of(vb, struct vb2_v4l2_buffer, vb2_buf);
>   buf = container_of(vb2_v4l2, struct mtk_video_dec_buf, vb);
>   mutex_lock(>lock);
> - buf->queued_in_v4l2 = false;
> - buf->queued_in_vb2 = false;
> + if (vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
> + buf->queued_in_v4l2 = false;
> + buf->queued_in_vb2 = false;
> + }
> + buf_error = buf->error;
>   mutex_unlock(>lock);
> +
> + if (buf_error) {
> + mtk_v4l2_err("Unrecoverable error on buffer.");
> + ctx->state = MTK_STATE_ABORT;
> + }
>  }
>  
>  static int vb2ops_vdec_buf_init(struct vb2_buffer *vb)
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> index 362f5a85762e..dc4fc1df63c5 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> @@ -50,6 +50,7 @@ struct vdec_fb {
>   * @queued_in_v4l2:  Capture buffer is in v4l2 driver, but not in vb2
>   *   queue yet
>   * @lastframe:   Intput buffer is last buffer - EOS
> + * @error:   An unrecoverable error occurs on this buffer.
>   * @frame_buffer:Decode status, and buffer information of Capture buffer
>   *
>   * Note : These status information help us track and debug buffer state
> @@ -63,6 +64,7 @@ struct mtk_video_dec_buf {
>   boolqueued_in_vb2;
>   boolqueued_in_v4l2;
>   boollastframe;
> + boolerror;
>   struct vdec_fb  frame_buffer;
>  };
>  
> 

Re: [PATCH v2 1/1] mtk-vcodec: check the vp9 decoder buffer index from VPU.

2017-03-07 Thread Tiffany Lin
On Tue, 2017-03-07 at 22:42 +0800, Wu-Cheng Li wrote:
> From: Wu-Cheng Li 
> 
> VPU firmware has a bug and may return invalid buffer index for
> some vp9 videos. Check the buffer indexes before accessing the
> buffer.
> 
> Signed-off-by: Wu-Cheng Li 
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 23 ++-
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h |  2 ++
>  .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   | 26 
> ++
>  drivers/media/platform/mtk-vcodec/vdec_drv_if.h|  2 ++
>  4 files changed, 48 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> index 502877a4b1df..8a9285a84d47 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> @@ -420,6 +420,11 @@ static void mtk_vdec_worker(struct work_struct *work)
>   dst_buf->index,
>   ret, res_chg);
>   src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
> + if (ret == -EIO) {
> + mutex_lock(>lock);
> + src_buf_info->error = true;
> + mutex_unlock(>lock);
> + }
>   v4l2_m2m_buf_done(_buf_info->vb, VB2_BUF_STATE_ERROR);
>   } else if (res_chg == false) {
>   /*
> @@ -1176,6 +1181,11 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer 
> *vb)
>  "[%d] vdec_if_decode() src_buf=%d, size=%zu, 
> fail=%d, res_chg=%d",
>  ctx->id, src_buf->index,
>  src_mem.size, ret, res_chg);
> + if (ret == -EIO) {
> + mtk_v4l2_err("[%d] Unrecoverable error in 
> vdec_if_decode.",
> + ctx->id);
> + ctx->state = MTK_STATE_ABORT;
> + }
Should we set buf status to VB2_BUF_STATE_ERROR in this case?

>   return;
>   }
>  
> @@ -1217,14 +1227,17 @@ static void vb2ops_vdec_buf_finish(struct vb2_buffer 
> *vb)
>   struct vb2_v4l2_buffer *vb2_v4l2;
>   struct mtk_video_dec_buf *buf;
>  
> - if (vb->vb2_queue->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> - return;
> -
>   vb2_v4l2 = container_of(vb, struct vb2_v4l2_buffer, vb2_buf);
>   buf = container_of(vb2_v4l2, struct mtk_video_dec_buf, vb);
>   mutex_lock(>lock);
> - buf->queued_in_v4l2 = false;
> - buf->queued_in_vb2 = false;
> + if (buf->error) {
> + mtk_v4l2_err("Unrecoverable error on buffer.");
Remove mtk_v4l2_err out of mutex_lock/mutex_unlock?


best regards,
Tiffany
> + ctx->state = MTK_STATE_ABORT;
> + }
> + if (vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
> + buf->queued_in_v4l2 = false;
> + buf->queued_in_vb2 = false;
> + }
>   mutex_unlock(>lock);
>  }
>  
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> index 362f5a85762e..dc4fc1df63c5 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> @@ -50,6 +50,7 @@ struct vdec_fb {
>   * @queued_in_v4l2:  Capture buffer is in v4l2 driver, but not in vb2
>   *   queue yet
>   * @lastframe:   Intput buffer is last buffer - EOS
> + * @error:   An unrecoverable error occurs on this buffer.
>   * @frame_buffer:Decode status, and buffer information of Capture buffer
>   *
>   * Note : These status information help us track and debug buffer state
> @@ -63,6 +64,7 @@ struct mtk_video_dec_buf {
>   boolqueued_in_vb2;
>   boolqueued_in_v4l2;
>   boollastframe;
> + boolerror;
>   struct vdec_fb  frame_buffer;
>  };
>  
> diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c 
> b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
> index e91a3b425b0c..5539b1853f16 100644
> --- a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
> +++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
> @@ -718,6 +718,26 @@ static void get_free_fb(struct vdec_vp9_inst *inst, 
> struct vdec_fb **out_fb)
>   *out_fb = fb;
>  }
>  
> +static int validate_vsi_array_indexes(struct vdec_vp9_inst *inst,
> + struct vdec_vp9_vsi *vsi) {
> + if (vsi->sf_frm_idx >= VP9_MAX_FRM_BUF_NUM - 1) {
> + mtk_vcodec_err(inst, "Invalid vsi->sf_frm_idx=%u.",
> + vsi->sf_frm_idx);
> + return -EIO;
> + }
> + if (vsi->frm_to_show_idx >= VP9_MAX_FRM_BUF_NUM) {
> + mtk_vcodec_err(inst, "Invalid vsi->frm_to_show_idx=%u.",
> + vsi->frm_to_show_idx);
> + return -EIO;
> + }
> + if (vsi->new_fb_idx 

Re: [PATCH 1/1] mtk-vcodec: check the vp9 decoder buffer index from VPU.

2017-03-07 Thread Tiffany Lin
On Tue, 2017-03-07 at 14:03 +0800, Wu-Cheng Li wrote:
> From: Wu-Cheng Li 
> 
> VPU firmware has a bug and may return invalid buffer index for
> some vp9 videos. Check the buffer indexes before accessing the
> buffer.
> 
> Signed-off-by: Wu-Cheng Li 
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |  6 +
>  .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   | 26 
> ++
>  drivers/media/platform/mtk-vcodec/vdec_drv_if.h|  2 ++
>  3 files changed, 34 insertions(+)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> index 502877a4b1df..7ebcf9e57ac7 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> @@ -1176,6 +1176,12 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer 
> *vb)
>  "[%d] vdec_if_decode() src_buf=%d, size=%zu, 
> fail=%d, res_chg=%d",
>  ctx->id, src_buf->index,
>  src_mem.size, ret, res_chg);
> +
> + if (ret == -EIO) {
> + mtk_v4l2_err("[%d] Unrecoverable error in 
> vdec_if_decode.",
> + ctx->id);
> + ctx->state = MTK_STATE_ABORT;
> + }
Could we use v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
VB2_BUF_STATE_ERROR); instead ctx->state = MTK_STATE_ABORT;
In this case, the behavior will be same as vdec_if_decode called in
mtk_vdec_worker.
And we could also get information about what output buffer make vpu
crash.

best regards,
Tiffany
>   return;
>   }
>  
> diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c 
> b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
> index e91a3b425b0c..5539b1853f16 100644
> --- a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
> +++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
> @@ -718,6 +718,26 @@ static void get_free_fb(struct vdec_vp9_inst *inst, 
> struct vdec_fb **out_fb)
>   *out_fb = fb;
>  }
>  
> +static int validate_vsi_array_indexes(struct vdec_vp9_inst *inst,
> + struct vdec_vp9_vsi *vsi) {
> + if (vsi->sf_frm_idx >= VP9_MAX_FRM_BUF_NUM - 1) {
> + mtk_vcodec_err(inst, "Invalid vsi->sf_frm_idx=%u.",
> + vsi->sf_frm_idx);
> + return -EIO;
> + }
> + if (vsi->frm_to_show_idx >= VP9_MAX_FRM_BUF_NUM) {
> + mtk_vcodec_err(inst, "Invalid vsi->frm_to_show_idx=%u.",
> + vsi->frm_to_show_idx);
> + return -EIO;
> + }
> + if (vsi->new_fb_idx >= VP9_MAX_FRM_BUF_NUM) {
> + mtk_vcodec_err(inst, "Invalid vsi->new_fb_idx=%u.",
> + vsi->new_fb_idx);
> + return -EIO;
> + }
> + return 0;
> +}
> +
>  static void vdec_vp9_deinit(unsigned long h_vdec)
>  {
>   struct vdec_vp9_inst *inst = (struct vdec_vp9_inst *)h_vdec;
> @@ -834,6 +854,12 @@ static int vdec_vp9_decode(unsigned long h_vdec, struct 
> mtk_vcodec_mem *bs,
>   goto DECODE_ERROR;
>   }
>  
> + ret = validate_vsi_array_indexes(inst, vsi);
> + if (ret) {
> + mtk_vcodec_err(inst, "Invalid values from VPU.");
> + goto DECODE_ERROR;
> + }
> +
>   if (vsi->resolution_changed) {
>   if (!vp9_alloc_work_buf(inst)) {
>   ret = -EINVAL;
> diff --git a/drivers/media/platform/mtk-vcodec/vdec_drv_if.h 
> b/drivers/media/platform/mtk-vcodec/vdec_drv_if.h
> index db6b5205ffb1..ded1154481cd 100644
> --- a/drivers/media/platform/mtk-vcodec/vdec_drv_if.h
> +++ b/drivers/media/platform/mtk-vcodec/vdec_drv_if.h
> @@ -85,6 +85,8 @@ void vdec_if_deinit(struct mtk_vcodec_ctx *ctx);
>   * @res_chg  : [out] resolution change happens if current bs have different
>   *   picture width/height
>   * Note: To flush the decoder when reaching EOF, set input bitstream as NULL.
> + *
> + * Return: 0 on success. -EIO on unrecoverable error.
>   */
>  int vdec_if_decode(struct mtk_vcodec_ctx *ctx, struct mtk_vcodec_mem *bs,
>  struct vdec_fb *fb, bool *res_chg);




Re: [PATCH -next] [media] mtk-vcodec: remove redundant return value check of platform_get_resource()

2017-02-09 Thread Tiffany Lin
On Tue, 2017-02-07 at 15:16 +, Wei Yongjun wrote:
> From: Wei Yongjun 
> 
> Remove unneeded error handling on the result of a call
> to platform_get_resource() when the value is passed to
> devm_ioremap_resource().
> 
> Signed-off-by: Wei Yongjun 
Acked-by:Tiffany Lin 

> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c | 5 -
>  1 file changed, 5 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> index aa81f3c..83f859e 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> @@ -269,11 +269,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
>  
>   for (i = VENC_SYS, j = 0; i < NUM_MAX_VCODEC_REG_BASE; i++, j++) {
>   res = platform_get_resource(pdev, IORESOURCE_MEM, j);
> - if (res == NULL) {
> - dev_err(>dev, "get memory resource failed.");
> - ret = -ENXIO;
> - goto err_res;
> - }
>   dev->reg_base[i] = devm_ioremap_resource(>dev, res);
>   if (IS_ERR((__force void *)dev->reg_base[i])) {
>   ret = PTR_ERR((__force void *)dev->reg_base[i]);
> 
> 
> 


--
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: [bug report] [media] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-11-09 Thread Tiffany Lin
Hi Hans, Dan,

On Wed, 2016-11-09 at 14:45 +0100, Hans Verkuil wrote:
> On 11/09/16 14:28, Dan Carpenter wrote:
> > Hello Tiffany Lin,
> >
> > The patch 590577a4e525: "[media] vcodec: mediatek: Add Mediatek V4L2
> > Video Decoder Driver" from Sep 2, 2016, leads to the following static
> > checker warning:
> >
> > drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c:536 
> > vidioc_vdec_qbuf()
> > error: buffer overflow 'vq->bufs' 32 <= u32max
> >
> > drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> >520  static int vidioc_vdec_qbuf(struct file *file, void *priv,
> >521  struct v4l2_buffer *buf)
> >522  {
> >523  struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> >524  struct vb2_queue *vq;
> >525  struct vb2_buffer *vb;
> >526  struct mtk_video_dec_buf *mtkbuf;
> >527  struct vb2_v4l2_buffer  *vb2_v4l2;
> >528
> >529  if (ctx->state == MTK_STATE_ABORT) {
> >530  mtk_v4l2_err("[%d] Call on QBUF after unrecoverable 
> > error",
> >531  ctx->id);
> >532  return -EIO;
> >533  }
> >534
> >535  vq = v4l2_m2m_get_vq(ctx->m2m_ctx, buf->type);
> >536  vb = vq->bufs[buf->index];
> >
> > Smatch thinks that "buf->index" comes straight from the user without
> > being checked and that this is a buffer overflow.  It seems simple
> > enough to analyse the call tree.
> >
> > __video_do_ioctl()
> > ->  v4l_qbuf()
> >   -> vidioc_vdec_qbuf()
> >
> > It seems like Smatch is correct.  I looked at a different implementation
> > of this and that one wasn't checked either so maybe there is something
> > I am not seeing.
> >
> > This has obvious security implications.  Can someone take a look at
> > this?
> 
> This is indeed wrong.
> 
> The v4l2_m2m_qbuf() call at the end of this function calls in turn 
> vb2_qbuf which
> will check the index. But if you override vidioc_qbuf (or 
> vidioc_prepare), then
> you need to check the index value.
> 
> I double-checked all cases where vidioc_qbuf was set to a 
> driver-specific function
> and this is the only driver that doesn't check the index field. In all 
> other cases
> it is either checked, or it is not used before calling into the vb1/vb2 
> framework
> which checks this.
> 
> So luckily this only concerns this driver.

Thanks for point out this issue.
As Hans' mentioned, our driver access index field in v4l2_buffer before
framework check buffer index.
We will prepare patch for this issue.


best regards,
Tiffany


> 
> Regards,
> 
>   Hans
> 
> >
> >537  vb2_v4l2 = container_of(vb, struct vb2_v4l2_buffer, 
> > vb2_buf);
> >538  mtkbuf = container_of(vb2_v4l2, struct mtk_video_dec_buf, 
> > vb);
> >539
> >540  if ((buf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) &&
> >541  (buf->m.planes[0].bytesused == 0)) {
> >542  mtkbuf->lastframe = true;
> >543  mtk_v4l2_debug(1, "[%d] (%d) id=%d lastframe=%d 
> > (%d,%d, %d) vb=%p",
> >544   ctx->id, buf->type, buf->index,
> >545   mtkbuf->lastframe, buf->bytesused,
> >546   buf->m.planes[0].bytesused, buf->length,
> >547   vb);
> >548  }
> >549
> >550  return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
> >551  }
> >
> > regards,
> > dan carpenter
> > --
> > 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
> >


--
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 v5 3/9] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-10-24 Thread Tiffany Lin
Hi Mauro,

On Mon, 2016-10-24 at 07:05 -0200, Mauro Carvalho Chehab wrote:
> Em Mon, 24 Oct 2016 11:22:08 +0800
> Tiffany Lin <tiffany@mediatek.com> escreveu:
> 
> > Hi Mauro,
> > 
> > On Fri, 2016-10-21 at 11:01 -0200, Mauro Carvalho Chehab wrote:
> > > Em Fri, 2 Sep 2016 20:19:54 +0800
> > > Tiffany Lin <tiffany@mediatek.com> escreveu:
> > >   
> > > > Add v4l2 layer decoder driver for MT8173
> > > > 
> > > > Signed-off-by: Tiffany Lin <tiffany@mediatek.com>  
> > >   
> > > > +int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
> > > > +{
> > > > +   int ret = 0;
> > > > +
> > > > +   switch (fourcc) {
> > > > +   case V4L2_PIX_FMT_H264:
> > > > +   case V4L2_PIX_FMT_VP8:
> > > > +   default:
> > > > +   return -EINVAL;
> > > > +   }  
> > > 
> > > Did you ever test this driver? The above code will *always* return
> > > -EINVAL, with will cause vidioc_vdec_s_fmt() to always fail!
> > > 
> > > I suspect that what you wanted to do, instead, is:
> > > 
> > >   switch (fourcc) {
> > >   case V4L2_PIX_FMT_H264:
> > >   case V4L2_PIX_FMT_VP8:
> > >   break;
> > >   default:
> > >   return -EINVAL;
> > >   
> > 
> > The original idea here is that vp8 and h264 are added in later patches.
> > If get this patch without later patches, it should return -EINVAL.
> 
> I noticed your idea, but next time, don't add dead code like that.
> Reviewers check patch by patch at the order they're present at the
> patch series.
> 
> So, don't add something broken by purpose, assuming that it would
> be fixed later.
> 
Got it.
> > 
> > 
> > > Btw, this patch series has also several issues that were pointed by
> > > checkpatch. Please *always* run checkpatch when submitting your work.
> > > 
> > > You should take a look at the Kernel documentation about how to
> > > submit patches, at:
> > >   https://mchehab.fedorapeople.org/kernel_docs/process/index.html
> > > 
> > > PS.: this time, I fixed the checkpatch issues for you. So, let me know
> > > if the patch below is OK, and I'll merge it at media upstream,
> > > assuming that the other patches in this series are ok.
> > >   
> > 
> > I did run checkpatch, but I don't know why these issues missed.
> > probably I run checkpatch for all files not for patches.
> > I will take a look at the documentation and keep this in mind for future
> > upstream.
> > Appreciated for your help.
> 
> Checkpatch should be run patch by patch, as we expect that all patches
> will follow the coding style and will compile fine, without introducing
> warnings.
> 
> I do compile the Kernel for every single patch I merge.
> 
Got it. I will follow this.

best regards,
Tiffany

> Regards,
> Mauro


--
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: FW: [PATCH] mtk-vcodec: fix some smatch warnings

2016-10-23 Thread Tiffany Lin


> Fix this bug:
>   drivers/media/platform/mtk-vcodec/vdec_drv_if.c:38 vdec_if_init() info: 
> ignoring unreachable code.
> 
> With is indeed a real problem that prevents the driver to work!
> 
> While here, also remove an used var, as reported by smatch:
> 
>   drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c: In function 
> 'mtk_vcodec_init_dec_pm':
>   drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c:29:17: warning: 
> variable 'dev' set but not used [-Wunused-but-set-variable]
> struct device *dev;
>^~~
> 
> Signed-off-by: Mauro Carvalho Chehab <mche...@s-opensource.com>

Acked-by: Tiffany Lin <tiffany@mediatek.com>
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c | 2 --
>  drivers/media/platform/mtk-vcodec/vdec_drv_if.c   | 1 +
>  2 files changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
> index 18182f5676d8..79ca03ac449c 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
> @@ -26,14 +26,12 @@ int mtk_vcodec_init_dec_pm(struct mtk_vcodec_dev *mtkdev) 
>  {
>   struct device_node *node;
>   struct platform_device *pdev;
> - struct device *dev;
>   struct mtk_vcodec_pm *pm;
>   int ret = 0;
>  
>   pdev = mtkdev->plat_dev;
>   pm = >pm;
>   pm->mtkdev = mtkdev;
> - dev = >dev;
>   node = of_parse_phandle(pdev->dev.of_node, "mediatek,larb", 0);
>   if (!node) {
>   mtk_v4l2_err("of_parse_phandle mediatek,larb fail!"); diff 
> --git a/drivers/media/platform/mtk-vcodec/vdec_drv_if.c 
> b/drivers/media/platform/mtk-vcodec/vdec_drv_if.c
> index 3cb04ef45144..9813b2ffd5fa 100644
> --- a/drivers/media/platform/mtk-vcodec/vdec_drv_if.c
> +++ b/drivers/media/platform/mtk-vcodec/vdec_drv_if.c
> @@ -31,6 +31,7 @@ int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int 
> fourcc)
>   switch (fourcc) {
>   case V4L2_PIX_FMT_H264:
>   case V4L2_PIX_FMT_VP8:
> + break;
>   default:
>   return -EINVAL;
>   }
> --
> 2.7.4
> 
> --
> 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


--
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 v5 3/9] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-10-23 Thread Tiffany Lin
Hi Mauro,

On Fri, 2016-10-21 at 11:01 -0200, Mauro Carvalho Chehab wrote:
> Em Fri, 2 Sep 2016 20:19:54 +0800
> Tiffany Lin <tiffany@mediatek.com> escreveu:
> 
> > Add v4l2 layer decoder driver for MT8173
> > 
> > Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
> 
> > +int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
> > +{
> > +   int ret = 0;
> > +
> > +   switch (fourcc) {
> > +   case V4L2_PIX_FMT_H264:
> > +   case V4L2_PIX_FMT_VP8:
> > +   default:
> > +   return -EINVAL;
> > +   }
> 
> Did you ever test this driver? The above code will *always* return
> -EINVAL, with will cause vidioc_vdec_s_fmt() to always fail!
> 
> I suspect that what you wanted to do, instead, is:
> 
>   switch (fourcc) {
>   case V4L2_PIX_FMT_H264:
>   case V4L2_PIX_FMT_VP8:
>   break;
>   default:
>   return -EINVAL;
> 

The original idea here is that vp8 and h264 are added in later patches.
If get this patch without later patches, it should return -EINVAL.


> Btw, this patch series has also several issues that were pointed by
> checkpatch. Please *always* run checkpatch when submitting your work.
> 
> You should take a look at the Kernel documentation about how to
> submit patches, at:
>   https://mchehab.fedorapeople.org/kernel_docs/process/index.html
> 
> PS.: this time, I fixed the checkpatch issues for you. So, let me know
> if the patch below is OK, and I'll merge it at media upstream,
> assuming that the other patches in this series are ok.
> 

I did run checkpatch, but I don't know why these issues missed.
probably I run checkpatch for all files not for patches.
I will take a look at the documentation and keep this in mind for future
upstream.
Appreciated for your help.


best regards,
Tiffany

--
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] pixfmt-reserved.rst: Improve MT21C documentation

2016-09-19 Thread Tiffany Lin
Hi Hans,

On Mon, 2016-09-19 at 09:22 +0200, Hans Verkuil wrote:
> Improve the MT21C documentation, making it clearer that this format requires 
> the MDP
> for further processing.
> 
> Also fix the fourcc (it was a fivecc :-) )
> 
reviewed-by: Tiffany Lin <tiffany@mediatek.com>

Thanks. I did not notice it become fivecc.

best regards,
Tiffany

> Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
> ---
> diff --git a/Documentation/media/uapi/v4l/pixfmt-reserved.rst 
> b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> index 0989e99..a019f15 100644
> --- a/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> +++ b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> @@ -343,13 +343,13 @@ please make a proposal on the linux-media mailing list.
> 
> -  ``V4L2_PIX_FMT_MT21C``
> 
> -   -  'MT21C'
> +   -  'MT21'
> 
> -  Compressed two-planar YVU420 format used by Mediatek MT8173.
>The compression is lossless.
> -  It is an opaque intermediate format, and MDP HW could convert
> -  V4L2_PIX_FMT_MT21C to V4L2_PIX_FMT_NV12M,
> -  V4L2_PIX_FMT_YUV420M and V4L2_PIX_FMT_YVU420.
> +  It is an opaque intermediate format and the MDP hardware must be
> +   used to convert ``V4L2_PIX_FMT_MT21C`` to ``V4L2_PIX_FMT_NV12M``,
> +  ``V4L2_PIX_FMT_YUV420M`` or ``V4L2_PIX_FMT_YVU420``.
> 
>  .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
> 


--
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 v2 2/4] docs-rst: Add compressed video formats used on MT8173 codec driver

2016-09-18 Thread Tiffany Lin
Hi Hans,

On Wed, 2016-09-14 at 13:51 +0200, Hans Verkuil wrote:
> Hi Tiffany,
> 
> On 09/09/2016 05:48 PM, Tiffany Lin wrote:
> > Add V4L2_PIX_FMT_MT21C documentation
> > 
> > Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
> > ---
> >  Documentation/media/uapi/v4l/pixfmt-reserved.rst |   10 ++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/Documentation/media/uapi/v4l/pixfmt-reserved.rst 
> > b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> > index 0dd2f7f..0989e99 100644
> > --- a/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> > +++ b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> > @@ -339,7 +339,17 @@ please make a proposal on the linux-media mailing list.
> >   array. Anything what's in between the UYVY lines is JPEG data and
> >   should be concatenated to form the JPEG stream.
> >  
> > +-  .. _V4L2-PIX-FMT-MT21C:
> >  
> > +   -  ``V4L2_PIX_FMT_MT21C``
> > +
> > +   -  'MT21C'
> > +
> > +   -  Compressed two-planar YVU420 format used by Mediatek MT8173.
> > +  The compression is lossless.
> > +  It is an opaque intermediate format, and MDP HW could convert
> 
> Is it OK if I change this to:
> 
> " and the MDP hardware must be used to convert"
> 

Yes. It's better to make it more clear how to use MT21C.
Thanks for the help.

> > +  V4L2_PIX_FMT_MT21C to V4L2_PIX_FMT_NV12M,
> > +  V4L2_PIX_FMT_YUV420M and V4L2_PIX_FMT_YVU420.
> 
> and here "and" should be replaced by "or".
> 
Yes. it should be "or". Sorry about that.


best regards,
Tiffany

> Regards,
> 
>   Hans
> 
> >  
> >  .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
> >  
> > 


--
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 0/4] Add V4L2_PIX_FMT_MT21C format for MT8173 codec driver

2016-09-13 Thread Tiffany Lin
Hi Hans,

On Thu, 2016-09-08 at 11:27 +0200, Hans Verkuil wrote:
> On 09/08/16 11:11, Tiffany Lin wrote:
> > Hi Hans,
> >
> > On Thu, 2016-09-08 at 09:21 +0200, Hans Verkuil wrote:
> >> Hi Tiffany,
> >>
> >> On 09/07/2016 08:56 AM, Tiffany Lin wrote:
> >>> This patch series add Mediatek compressed block format 
> >>> V4L2_PIX_FMT_MT21C, the
> >>> decoder driver will decoded bitstream to V4L2_PIX_FMT_MT21C format.
> >>>
> >>> User space applications could use MT8173 MDP driver to convert 
> >>> V4L2_PIX_FMT_MT21C to
> >>> V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M and V4L2_PIX_FMT_YVU420.
> >>>
> >>> MDP driver[1] is stand alone driver.
> >>>
> >>> Usage:
> >>> MT21C -> MT8173 MDP -> NV12M/YUV420M/YVU420
> >>> NV12M/NV21M/YUV420M/YVU420M -> mt8173 Encoder -> H264/VP8
> >>> H264/VP8/VP9 -> mtk8173 Decoder -> MT21C
> >>>
> >>> When encode with MT21 source, the pipeline will be:
> >>> MT21C -> MDP driver-> NV12M/NV21M/YUV420M/YVU420M -> Encoder -> H264/VP8
> >>>
> >>> When playback, the pipeline will be:
> >>> H264/VP8/VP9 -> Decoder driver -> MT21C -> MDP Driver -> DRM
> >>>
> >>> [1]https://patchwork.kernel.org/patch/9305329/
> >>>
> >>> Tiffany Lin (4):
> >>>   v4l: add Mediatek compressed video block format
> >>>   docs-rst: Add compressed video formats used on MT8173 codec driver
> >>>   vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder
> >>>   arm64: dts: mediatek: Add Video Decoder for MT8173
> >>>
> >>>  Documentation/media/uapi/v4l/pixfmt-reserved.rst   |6 +++
> >>>  arch/arm64/boot/dts/mediatek/mt8173.dtsi   |   44 
> >>> 
> >>>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |7 +++-
> >>>  drivers/media/v4l2-core/v4l2-ioctl.c   |1 +
> >>>  include/uapi/linux/videodev2.h |1 +
> >>>  5 files changed, 58 insertions(+), 1 deletion(-)
> >>>
> >>
> >> So basically the video decoder is useless without support for this format 
> >> and
> >> without the MDP driver, right?
> >>
> > Yes. It also require new vpu firmware.
> > Andrew will help release new vpu firmware include encode/decode/mdp
> > capability.
> 
> OK, then I'll park this until:
> 
> - the MT21C patch series is OK
> - the MDP patch series is OK
> - the new firmware is released
> 

> For the record: the decoder patch series is OK as far as I am concerned.
> It's in my mtkdec branch.
> 

Appreciated for your help.
We had upstream new MT21C, MDP and new VPU firmware.

MT21C patch series: https://patchwork.kernel.org/patch/9323883/
MDP patch series: https://patchwork.kernel.org/patch/9321343/
VPU firmware: https://patchwork.linuxtv.org/patch/36968/


best regards,
Tiffany



> Regards,
> 
>   Hans


--
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


[PATCH v2 4/4] arm64: dts: mediatek: Add Video Decoder for MT8173

2016-09-09 Thread Tiffany Lin
Add video decoder node for MT8173

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   44 ++
 1 file changed, 44 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 10f638f..2872cd7 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -974,6 +974,50 @@
#clock-cells = <1>;
};
 
+   vcodec_dec: vcodec@1600 {
+   compatible = "mediatek,mt8173-vcodec-dec";
+   reg = <0 0x1600 0 0x100>,   /* VDEC_SYS */
+ <0 0x1602 0 0x1000>,  /* VDEC_MISC */
+ <0 0x16021000 0 0x800>,   /* VDEC_LD */
+ <0 0x16021800 0 0x800>,   /* VDEC_TOP */
+ <0 0x16022000 0 0x1000>,  /* VDEC_CM */
+ <0 0x16023000 0 0x1000>,  /* VDEC_AD */
+ <0 0x16024000 0 0x1000>,  /* VDEC_AV */
+ <0 0x16025000 0 0x1000>,  /* VDEC_PP */
+ <0 0x16026800 0 0x800>,   /* VDEC_HWD */
+ <0 0x16027000 0 0x800>,   /* VDEC_HWQ */
+ <0 0x16027800 0 0x800>,   /* VDEC_HWB */
+ <0 0x16028400 0 0x400>;   /* VDEC_HWG */
+   interrupts = ;
+   mediatek,larb = <>;
+   iommus = < M4U_PORT_HW_VDEC_MC_EXT>,
+< M4U_PORT_HW_VDEC_PP_EXT>,
+< M4U_PORT_HW_VDEC_AVC_MV_EXT>,
+< M4U_PORT_HW_VDEC_PRED_RD_EXT>,
+< M4U_PORT_HW_VDEC_PRED_WR_EXT>,
+< M4U_PORT_HW_VDEC_UFO_EXT>,
+< M4U_PORT_HW_VDEC_VLD_EXT>,
+< M4U_PORT_HW_VDEC_VLD2_EXT>;
+   mediatek,vpu = <>;
+   power-domains = < MT8173_POWER_DOMAIN_VDEC>;
+   clocks = < CLK_APMIXED_VCODECPLL>,
+< CLK_TOP_UNIVPLL_D2>,
+< CLK_TOP_CCI400_SEL>,
+< CLK_TOP_VDEC_SEL>,
+< CLK_TOP_VCODECPLL>,
+< CLK_APMIXED_VENCPLL>,
+< CLK_TOP_VENC_LT_SEL>,
+< CLK_TOP_VCODECPLL_370P5>;
+   clock-names = "vcodecpll",
+ "univpll_d2",
+ "clk_cci400_sel",
+ "vdec_sel",
+ "vdecpll",
+ "vencpll",
+ "venc_lt_sel",
+ "vdec_bus_clk_src";
+   };
+
larb1: larb@1601 {
compatible = "mediatek,mt8173-smi-larb";
reg = <0 0x1601 0 0x1000>;
-- 
1.7.9.5

--
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


[PATCH v2 3/4] vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder

2016-09-09 Thread Tiffany Lin
Add V4L2_PIX_FMT_MT21C support

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
index 28a8453..fd3befc 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -25,7 +25,7 @@
 #include "mtk_vcodec_dec_pm.h"
 
 #define OUT_FMT_IDX0
-#define CAP_FMT_IDX0
+#define CAP_FMT_IDX3
 
 #define MTK_VDEC_MIN_W 64U
 #define MTK_VDEC_MIN_H 64U
@@ -48,6 +48,11 @@ static struct mtk_video_fmt mtk_video_formats[] = {
.type = MTK_FMT_DEC,
.num_planes = 1,
},
+   {
+   .fourcc = V4L2_PIX_FMT_MT21C,
+   .type = MTK_FMT_FRAME,
+   .num_planes = 2,
+   },
 };
 
 static const struct mtk_codec_framesizes mtk_vdec_framesizes[] = {
-- 
1.7.9.5

--
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


[PATCH v2 2/4] docs-rst: Add compressed video formats used on MT8173 codec driver

2016-09-09 Thread Tiffany Lin
Add V4L2_PIX_FMT_MT21C documentation

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 Documentation/media/uapi/v4l/pixfmt-reserved.rst |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/media/uapi/v4l/pixfmt-reserved.rst 
b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
index 0dd2f7f..0989e99 100644
--- a/Documentation/media/uapi/v4l/pixfmt-reserved.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
@@ -339,7 +339,17 @@ please make a proposal on the linux-media mailing list.
  array. Anything what's in between the UYVY lines is JPEG data and
  should be concatenated to form the JPEG stream.
 
+-  .. _V4L2-PIX-FMT-MT21C:
 
+   -  ``V4L2_PIX_FMT_MT21C``
+
+   -  'MT21C'
+
+   -  Compressed two-planar YVU420 format used by Mediatek MT8173.
+  The compression is lossless.
+  It is an opaque intermediate format, and MDP HW could convert
+  V4L2_PIX_FMT_MT21C to V4L2_PIX_FMT_NV12M,
+  V4L2_PIX_FMT_YUV420M and V4L2_PIX_FMT_YVU420.
 
 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
 
-- 
1.7.9.5

--
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


[PATCH v2 0/4] Add V4L2_PIX_FMT_MT21C format for MT8173 codec driver

2016-09-09 Thread Tiffany Lin
This patch series add Mediatek compressed block format V4L2_PIX_FMT_MT21C,
the decoder driver will decoded bitstream to V4L2_PIX_FMT_MT21C format.

User space applications could use MT8173 MDP driver to convert 
V4L2_PIX_FMT_MT21C
to V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M and V4L2_PIX_FMT_YVU420.
MDP driver[1] is stand alone driver.

Usage:
MT21C -> MT8173 MDP -> NV12M/YUV420M/YVU420 NV12M/NV21M/YUV420M/YVU420M -> 
mt8173 Encoder -> H264/VP8
H264/VP8/VP9 -> mtk8173 Decoder -> MT21C

When encode with MT21 source, the pipeline will be:
MT21C -> MDP driver-> NV12M/NV21M/YUV420M/YVU420M -> Encoder -> H264/VP8

When playback, the pipeline will be:
H264/VP8/VP9 -> Decoder driver -> MT21C -> MDP Driver -> DRM

[1]https://patchwork.kernel.org/patch/9305329/

---
v2: add more information for MT21C in docs-rst
---


Tiffany Lin (4):
  v4l: add Mediatek compressed video block format
  docs-rst: Add compressed video formats used on MT8173 codec driver
  vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder
  arm64: dts: mediatek: Add Video Decoder for MT8173

 Documentation/media/uapi/v4l/pixfmt-reserved.rst   |   10 +
 arch/arm64/boot/dts/mediatek/mt8173.dtsi   |   44 
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |7 +++-
 drivers/media/v4l2-core/v4l2-ioctl.c   |1 +
 include/uapi/linux/videodev2.h |1 +
 5 files changed, 62 insertions(+), 1 deletion(-)

-- 
1.7.9.5

--
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 0/4] Add V4L2_PIX_FMT_MT21C format for MT8173 codec driver

2016-09-08 Thread Tiffany Lin
Hi Hans,

On Thu, 2016-09-08 at 09:21 +0200, Hans Verkuil wrote:
> Hi Tiffany,
> 
> On 09/07/2016 08:56 AM, Tiffany Lin wrote:
> > This patch series add Mediatek compressed block format V4L2_PIX_FMT_MT21C, 
> > the
> > decoder driver will decoded bitstream to V4L2_PIX_FMT_MT21C format.
> > 
> > User space applications could use MT8173 MDP driver to convert 
> > V4L2_PIX_FMT_MT21C to
> > V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M and V4L2_PIX_FMT_YVU420.
> > 
> > MDP driver[1] is stand alone driver.
> > 
> > Usage:
> > MT21C -> MT8173 MDP -> NV12M/YUV420M/YVU420
> > NV12M/NV21M/YUV420M/YVU420M -> mt8173 Encoder -> H264/VP8
> > H264/VP8/VP9 -> mtk8173 Decoder -> MT21C
> > 
> > When encode with MT21 source, the pipeline will be:
> > MT21C -> MDP driver-> NV12M/NV21M/YUV420M/YVU420M -> Encoder -> H264/VP8
> > 
> > When playback, the pipeline will be:
> > H264/VP8/VP9 -> Decoder driver -> MT21C -> MDP Driver -> DRM
> > 
> > [1]https://patchwork.kernel.org/patch/9305329/
> > 
> > Tiffany Lin (4):
> >   v4l: add Mediatek compressed video block format
> >   docs-rst: Add compressed video formats used on MT8173 codec driver
> >   vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder
> >   arm64: dts: mediatek: Add Video Decoder for MT8173
> > 
> >  Documentation/media/uapi/v4l/pixfmt-reserved.rst   |6 +++
> >  arch/arm64/boot/dts/mediatek/mt8173.dtsi   |   44 
> > 
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |7 +++-
> >  drivers/media/v4l2-core/v4l2-ioctl.c   |1 +
> >  include/uapi/linux/videodev2.h |1 +
> >  5 files changed, 58 insertions(+), 1 deletion(-)
> > 
> 
> So basically the video decoder is useless without support for this format and
> without the MDP driver, right?
> 
Yes. It also require new vpu firmware.
Andrew will help release new vpu firmware include encode/decode/mdp
capability.

best regards,
Tiffany


> I'm wondering if I should hold off on merging the decoder driver until these 
> two
> are in. What is the timeline for v6 of the MDP driver?
> 
> If a v6 is posted early next week, then I have time to review and (assuming 
> it is
> OK) I can make a pull request for both this driver and the MDP driver.
> 
> If it takes longer, then there is a good chance that it will slip to 4.10. I 
> will
> have very little time in the period September 20 - October 14.
> 
> Regards,
> 
>   Hans


--
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 2/4] docs-rst: Add compressed video formats used on MT8173 codec driver

2016-09-08 Thread Tiffany Lin
Hi Hans,

On Wed, 2016-09-07 at 11:23 +0200, Hans Verkuil wrote:
> On 09/07/16 08:56, Tiffany Lin wrote:
> > Add V4L2_PIX_FMT_MT21C documentation
> >
> > Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
> > ---
> >  Documentation/media/uapi/v4l/pixfmt-reserved.rst |6 ++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/Documentation/media/uapi/v4l/pixfmt-reserved.rst 
> > b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> > index 0dd2f7f..2e21fbc 100644
> > --- a/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> > +++ b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> > @@ -339,7 +339,13 @@ please make a proposal on the linux-media mailing list.
> >   array. Anything what's in between the UYVY lines is JPEG data and
> >   should be concatenated to form the JPEG stream.
> >
> > +-  .. _V4L2-PIX-FMT-MT21C:
> >
> > +   -  ``V4L2_PIX_FMT_MT21C``
> > +
> > +   -  'MT21C'
> > +
> > +   -  Compressed two-planar YVU420 format used by Mediatek MT8173.
> 
> This really needs to be expanded.
> 
> Ideally this should reference the precise specification of this format if
> available.
> 

> It certainly should explain which HW blocks of the mediatek SoC use this
> format, it should explain that is it meant as an opaque intermediate format
> between those blocks.
> 

Yes. it is an opaque intermediate format.
VDEC HW only output MT21C format, and it need MDP HW to convert to other
standard format.

At first, we plan to put "convert MT21C to other standard format" in our
v4l2 decoder driver, actually in VPU firmware.
In this case, there is no need to expose MT21C format to user space.

But consider that MDP is a stand alone HW (interrupt, power, clk),
combine decode and format convert in one decode step impact performance.
VDEC HW and MDP HW could process different frame at same time.
MDP may also used by other modules to do format convert, not only VDEC.

That's why we need to expose MT21C to user space.
When user space application enumerate VDEC and display HW and found that
the format is not match.
It need to use MDP driver to do format convert.


> If you have some characteristics (i.e. is it lossy or lossless 
> compression, I
> presume it's lossless), then that will be useful to add as well.
> 
I will update this in next version.


best regards,
Tiffany

> We like to have as much information about formats as possible.
> 
> Regards,
> 
>   Hans
> 
> >
> >  .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
> >
> >


--
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] VPU: mediatek: fix null pointer dereference on pdev

2016-09-08 Thread Tiffany Lin
On Wed, 2016-09-07 at 18:10 +0100, Colin King wrote:
> From: Colin Ian King 
> 
> pdev is being null checked, however, prior to that it is being
> dereferenced by platform_get_drvdata.  Move the assignments of
> vpu and run to after the pdev null check to avoid a potential
> null pointer dereference.
> 

Reviewed-by:Tiffany Lin 

> Signed-off-by: Colin Ian King 
> ---
>  drivers/media/platform/mtk-vpu/mtk_vpu.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.c 
> b/drivers/media/platform/mtk-vpu/mtk_vpu.c
> index c9bf58c..43907a3 100644
> --- a/drivers/media/platform/mtk-vpu/mtk_vpu.c
> +++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
> @@ -523,9 +523,9 @@ static int load_requested_vpu(struct mtk_vpu *vpu,
>  
>  int vpu_load_firmware(struct platform_device *pdev)
>  {
> - struct mtk_vpu *vpu = platform_get_drvdata(pdev);
> + struct mtk_vpu *vpu;
>   struct device *dev = >dev;
> - struct vpu_run *run = >run;
> + struct vpu_run *run;
>   const struct firmware *vpu_fw = NULL;
>   int ret;
>  
> @@ -534,6 +534,9 @@ int vpu_load_firmware(struct platform_device *pdev)
>   return -EINVAL;
>   }
>  
> + vpu = platform_get_drvdata(pdev);
> + run = >run;
> +
>   mutex_lock(>vpu_mutex);
>   if (vpu->fw_loaded) {
>   mutex_unlock(>vpu_mutex);


--
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


[PATCH v3] vcodec: mediatek: add Maintainers entry for Mediatek MT8173 vcodec drivers

2016-09-07 Thread Tiffany Lin
Add Tiffany Lin and Andrew-CT Chen as maintainers for
Mediatek MT8173 vcodec drivers

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
Signed-off-by: Andrew-CT Chen <andrew-ct.c...@mediatek.com>
---
v3: Move MEDIATEK MEDIA DRIVER after MEDIATEK ETHERNET DRIVER to follow
alphabet sequence
v2: Rename MT8173 MEDIA DRIVER to MEDIATEK MEDIA DRIVER
---
 MAINTAINERS |9 +
 1 file changed, 9 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a16a82..14a48cc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7597,6 +7597,15 @@ L:   net...@vger.kernel.org
 S: Maintained
 F: drivers/net/ethernet/mediatek/
 
+MEDIATEK MEDIA DRIVER
+M:     Tiffany Lin <tiffany@mediatek.com>
+M: Andrew-CT Chen <andrew-ct.c...@mediatek.com>
+S: Supported
+F: drivers/media/platform/mtk-vcodec/
+F: drivers/media/platform/mtk-vpu/
+F: Documentation/devicetree/bindings/media/mediatek-vcodec.txt
+F: Documentation/devicetree/bindings/media/mediatek-vpu.txt
+
 MEDIATEK MT7601U WIRELESS LAN DRIVER
 M: Jakub Kicinski <kubak...@wp.pl>
 L: linux-wirel...@vger.kernel.org
-- 
1.7.9.5

--
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


[PATCH 3/4] vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder

2016-09-07 Thread Tiffany Lin
Add V4L2_PIX_FMT_MT21C support

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
index 28a8453..fd3befc 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -25,7 +25,7 @@
 #include "mtk_vcodec_dec_pm.h"
 
 #define OUT_FMT_IDX0
-#define CAP_FMT_IDX0
+#define CAP_FMT_IDX3
 
 #define MTK_VDEC_MIN_W 64U
 #define MTK_VDEC_MIN_H 64U
@@ -48,6 +48,11 @@ static struct mtk_video_fmt mtk_video_formats[] = {
.type = MTK_FMT_DEC,
.num_planes = 1,
},
+   {
+   .fourcc = V4L2_PIX_FMT_MT21C,
+   .type = MTK_FMT_FRAME,
+   .num_planes = 2,
+   },
 };
 
 static const struct mtk_codec_framesizes mtk_vdec_framesizes[] = {
-- 
1.7.9.5

--
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


[PATCH 0/4] Add V4L2_PIX_FMT_MT21C format for MT8173 codec driver

2016-09-07 Thread Tiffany Lin
This patch series add Mediatek compressed block format V4L2_PIX_FMT_MT21C, the
decoder driver will decoded bitstream to V4L2_PIX_FMT_MT21C format.

User space applications could use MT8173 MDP driver to convert 
V4L2_PIX_FMT_MT21C to
V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M and V4L2_PIX_FMT_YVU420.

MDP driver[1] is stand alone driver.

Usage:
MT21C -> MT8173 MDP -> NV12M/YUV420M/YVU420
NV12M/NV21M/YUV420M/YVU420M -> mt8173 Encoder -> H264/VP8
H264/VP8/VP9 -> mtk8173 Decoder -> MT21C

When encode with MT21 source, the pipeline will be:
MT21C -> MDP driver-> NV12M/NV21M/YUV420M/YVU420M -> Encoder -> H264/VP8

When playback, the pipeline will be:
H264/VP8/VP9 -> Decoder driver -> MT21C -> MDP Driver -> DRM

[1]https://patchwork.kernel.org/patch/9305329/

Tiffany Lin (4):
  v4l: add Mediatek compressed video block format
  docs-rst: Add compressed video formats used on MT8173 codec driver
  vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder
  arm64: dts: mediatek: Add Video Decoder for MT8173

 Documentation/media/uapi/v4l/pixfmt-reserved.rst   |6 +++
 arch/arm64/boot/dts/mediatek/mt8173.dtsi   |   44 
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |7 +++-
 drivers/media/v4l2-core/v4l2-ioctl.c   |1 +
 include/uapi/linux/videodev2.h |1 +
 5 files changed, 58 insertions(+), 1 deletion(-)

-- 
1.7.9.5

--
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


[PATCH 4/4] arm64: dts: mediatek: Add Video Decoder for MT8173

2016-09-07 Thread Tiffany Lin
Add video decoder node for MT8173

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   44 ++
 1 file changed, 44 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 10f638f..2872cd7 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -974,6 +974,50 @@
#clock-cells = <1>;
};
 
+   vcodec_dec: vcodec@1600 {
+   compatible = "mediatek,mt8173-vcodec-dec";
+   reg = <0 0x1600 0 0x100>,   /* VDEC_SYS */
+ <0 0x1602 0 0x1000>,  /* VDEC_MISC */
+ <0 0x16021000 0 0x800>,   /* VDEC_LD */
+ <0 0x16021800 0 0x800>,   /* VDEC_TOP */
+ <0 0x16022000 0 0x1000>,  /* VDEC_CM */
+ <0 0x16023000 0 0x1000>,  /* VDEC_AD */
+ <0 0x16024000 0 0x1000>,  /* VDEC_AV */
+ <0 0x16025000 0 0x1000>,  /* VDEC_PP */
+ <0 0x16026800 0 0x800>,   /* VDEC_HWD */
+ <0 0x16027000 0 0x800>,   /* VDEC_HWQ */
+ <0 0x16027800 0 0x800>,   /* VDEC_HWB */
+ <0 0x16028400 0 0x400>;   /* VDEC_HWG */
+   interrupts = ;
+   mediatek,larb = <>;
+   iommus = < M4U_PORT_HW_VDEC_MC_EXT>,
+< M4U_PORT_HW_VDEC_PP_EXT>,
+< M4U_PORT_HW_VDEC_AVC_MV_EXT>,
+< M4U_PORT_HW_VDEC_PRED_RD_EXT>,
+< M4U_PORT_HW_VDEC_PRED_WR_EXT>,
+< M4U_PORT_HW_VDEC_UFO_EXT>,
+< M4U_PORT_HW_VDEC_VLD_EXT>,
+< M4U_PORT_HW_VDEC_VLD2_EXT>;
+   mediatek,vpu = <>;
+   power-domains = < MT8173_POWER_DOMAIN_VDEC>;
+   clocks = < CLK_APMIXED_VCODECPLL>,
+< CLK_TOP_UNIVPLL_D2>,
+< CLK_TOP_CCI400_SEL>,
+< CLK_TOP_VDEC_SEL>,
+< CLK_TOP_VCODECPLL>,
+< CLK_APMIXED_VENCPLL>,
+< CLK_TOP_VENC_LT_SEL>,
+< CLK_TOP_VCODECPLL_370P5>;
+   clock-names = "vcodecpll",
+ "univpll_d2",
+ "clk_cci400_sel",
+ "vdec_sel",
+ "vdecpll",
+ "vencpll",
+ "venc_lt_sel",
+ "vdec_bus_clk_src";
+   };
+
larb1: larb@1601 {
compatible = "mediatek,mt8173-smi-larb";
reg = <0 0x1601 0 0x1000>;
-- 
1.7.9.5

--
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


[PATCH 1/4] v4l: add Mediatek compressed video block format

2016-09-07 Thread Tiffany Lin
Add V4L2_PIX_FMT_MT21C format used on MT8173 driver.
It is compressed format and need MT8173 MDP driver to transfer to other
standard format.

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/v4l2-core/v4l2-ioctl.c |1 +
 include/uapi/linux/videodev2.h   |1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 2bd1581..1d45c58 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1288,6 +1288,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_JPGL: descr = "JPEG Lite"; break;
case V4L2_PIX_FMT_SE401:descr = "GSPCA SE401"; break;
case V4L2_PIX_FMT_S5C_UYVY_JPG: descr = "S5C73MX interleaved 
UYVY/JPEG"; break;
+   case V4L2_PIX_FMT_MT21C:descr = "Mediatek Compressed 
Format"; break;
default:
WARN(1, "Unknown pixelformat 0x%08x\n", 
fmt->pixelformat);
if (fmt->description[0])
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 43326c3..ddd0083 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -635,6 +635,7 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_Y8I  v4l2_fourcc('Y', '8', 'I', ' ') /* Greyscale 
8-bit L/R interleaved */
 #define V4L2_PIX_FMT_Y12I v4l2_fourcc('Y', '1', '2', 'I') /* Greyscale 
12-bit L/R interleaved */
 #define V4L2_PIX_FMT_Z16  v4l2_fourcc('Z', '1', '6', ' ') /* Depth data 
16-bit */
+#define V4L2_PIX_FMT_MT21Cv4l2_fourcc('M', 'T', '2', '1') /* Mediatek 
compressed block mode  */
 
 /* SDR formats - used only for Software Defined Radio devices */
 #define V4L2_SDR_FMT_CU8  v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */
-- 
1.7.9.5

--
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


[PATCH 2/4] docs-rst: Add compressed video formats used on MT8173 codec driver

2016-09-07 Thread Tiffany Lin
Add V4L2_PIX_FMT_MT21C documentation

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 Documentation/media/uapi/v4l/pixfmt-reserved.rst |6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/media/uapi/v4l/pixfmt-reserved.rst 
b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
index 0dd2f7f..2e21fbc 100644
--- a/Documentation/media/uapi/v4l/pixfmt-reserved.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
@@ -339,7 +339,13 @@ please make a proposal on the linux-media mailing list.
  array. Anything what's in between the UYVY lines is JPEG data and
  should be concatenated to form the JPEG stream.
 
+-  .. _V4L2-PIX-FMT-MT21C:
 
+   -  ``V4L2_PIX_FMT_MT21C``
+
+   -  'MT21C'
+
+   -  Compressed two-planar YVU420 format used by Mediatek MT8173.
 
 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
 
-- 
1.7.9.5

--
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


[PATCH v2] vcodec: mediatek: add Maintainers entry for Mediatek MT8173 vcodec drivers

2016-09-07 Thread Tiffany Lin
Add Tiffany Lin and Andrew-CT Chen as maintainers for
Mediatek MT8173 vcodec drivers

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
Signed-off-by: Andrew-CT Chen <andrew-ct.c...@mediatek.com>
---
v2: Rename MT8173 MEDIA DRIVER to MEDIATEK MEDIA DRIVER
---
 MAINTAINERS |9 +
 1 file changed, 9 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a16a82..96854c1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7590,6 +7590,15 @@ F:   include/uapi/linux/meye.h
 F: include/uapi/linux/ivtv*
 F: include/uapi/linux/uvcvideo.h
 
+MEDIATEK MEDIA DRIVER
+M:     Tiffany Lin <tiffany@mediatek.com>
+M: Andrew-CT Chen <andrew-ct.c...@mediatek.com>
+S: Supported
+F: drivers/media/platform/mtk-vcodec/
+F: drivers/media/platform/mtk-vpu/
+F: Documentation/devicetree/bindings/media/mediatek-vcodec.txt
+F: Documentation/devicetree/bindings/media/mediatek-vpu.txt
+
 MEDIATEK ETHERNET DRIVER
 M: Felix Fietkau <n...@openwrt.org>
 M: John Crispin <blo...@openwrt.org>
-- 
1.7.9.5

--
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


[PATCH] vcodec: mediatek: Fix decoder compiler/sparse warnings

2016-09-07 Thread Tiffany Lin
This patch fix decoder compiler/sparse warnings

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 .../media/platform/mtk-vcodec/vdec/vdec_h264_if.c  |7 ---
 .../media/platform/mtk-vcodec/vdec/vdec_vp8_if.c   |1 +
 .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   |4 ++--
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c|6 --
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c 
b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
index 0353a47..57a842f 100644
--- a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
@@ -239,7 +239,7 @@ static void put_fb_to_free(struct vdec_h264_inst *inst, 
struct vdec_fb *fb)
mtk_vcodec_debug(inst, "[FB] put fb into free_list @(%p, %llx)",
 fb->base_y.va, (u64)fb->base_y.dma_addr);
 
-   list->fb_list[list->write_idx].vdec_fb_va = (u64)fb;
+   list->fb_list[list->write_idx].vdec_fb_va = (u64)(uintptr_t)fb;
list->write_idx = (list->write_idx == H264_MAX_FB_NUM - 1) ?
  0 : list->write_idx + 1;
list->count++;
@@ -350,7 +350,7 @@ static int vdec_h264_decode(unsigned long h_vdec, struct 
mtk_vcodec_mem *bs,
unsigned char *buf;
unsigned int buf_sz;
unsigned int data[2];
-   uint64_t vdec_fb_va = (u64)fb;
+   uint64_t vdec_fb_va = (u64)(uintptr_t)fb;
uint64_t y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0;
uint64_t c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0;
 
@@ -443,7 +443,8 @@ static void vdec_h264_get_fb(struct vdec_h264_inst *inst,
return;
}
 
-   fb = (struct vdec_fb *)list->fb_list[list->read_idx].vdec_fb_va;
+   fb = (struct vdec_fb *)
+   (uintptr_t)list->fb_list[list->read_idx].vdec_fb_va;
fb->status |= (disp_list ? FB_ST_DISPLAY : FB_ST_FREE);
 
*out_fb = fb;
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c 
b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
index d4fce3e..054d4d1 100644
--- a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
@@ -13,6 +13,7 @@
  * GNU General Public License for more details.
  */
 
+#include 
 #include "../vdec_drv_if.h"
 #include "../mtk_vcodec_util.h"
 #include "../mtk_vcodec_dec.h"
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c 
b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
index 60a7b00..ca3174d 100644
--- a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
@@ -475,7 +475,7 @@ static void vp9_swap_frm_bufs(struct vdec_vp9_inst *inst)
 */
if (frm_to_show->fb != NULL)
mtk_vcodec_err(inst,
-   "inst->cur_fb->base_y.size=%lx, 
frm_to_show->fb.base_y.size=%lx",
+   "inst->cur_fb->base_y.size=%zu, 
frm_to_show->fb.base_y.size=%zu",
inst->cur_fb->base_y.size,
frm_to_show->fb->base_y.size);
}
@@ -791,7 +791,7 @@ static int vdec_vp9_decode(unsigned long h_vdec, struct 
mtk_vcodec_mem *bs,
return -EINVAL;
}
 
-   mtk_vcodec_debug(inst, "Input BS Size = %ld", bs->size);
+   mtk_vcodec_debug(inst, "Input BS Size = %zu", bs->size);
 
while (1) {
struct vdec_fb *cur_fb = NULL;
diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c 
b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
index 0798a6b..5a24c51 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
@@ -19,7 +19,8 @@
 
 static void handle_init_ack_msg(struct vdec_vpu_ipi_init_ack *msg)
 {
-   struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *)msg->ap_inst_addr;
+   struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *)
+   (unsigned long)msg->ap_inst_addr;
 
mtk_vcodec_debug(vpu, "+ ap_inst_addr = 0x%llx", msg->ap_inst_addr);
 
@@ -38,7 +39,8 @@ static void handle_init_ack_msg(struct vdec_vpu_ipi_init_ack 
*msg)
 void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv)
 {
struct vdec_vpu_ipi_ack *msg = data;
-   struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *)msg->ap_inst_addr;
+   struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *)
+   (unsigned long)msg->ap_inst_addr;
 
mtk_vcodec_debug(vpu, "+ id=%X", ms

Re: [PATCH] vcodec: mediatek: fix odd_ptr_err.cocci warnings

2016-09-06 Thread Tiffany Lin
On Tue, 2016-09-06 at 22:51 +0800, Julia Lawall wrote:
> PTR_ERR should access the value just tested by IS_ERR
> 
> Generated by: scripts/coccinelle/tests/odd_ptr_err.cocci
> 
> CC: Tiffany Lin <tiffany@mediatek.com>
> Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
> Signed-off-by: Fengguang Wu <fengguang...@intel.com>

Reviewed-by:Tiffany Lin <tiffany@mediatek.com>

> ---
> 
>  mtk_vcodec_dec_drv.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> @@ -255,7 +255,7 @@ static int mtk_vcodec_probe(struct platf
>   }
>   dev->reg_base[i] = devm_ioremap_resource(>dev, res);
>   if (IS_ERR((__force void *)dev->reg_base[i])) {
> - ret = PTR_ERR((__force void *)dev->reg_base);
> + ret = PTR_ERR((__force void *)dev->reg_base[i]);
>   goto err_res;
>   }
>   mtk_v4l2_debug(2, "reg[%d] base=%p", i, dev->reg_base[i]);


--
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


[PATCH] vcodec: mediatek: add Maintainers entry for Mediatek MT8173 vcodec drivers

2016-09-06 Thread Tiffany Lin
Add Tiffany Lin and Andrew-CT Chen as maintainers for
Mediatek MT8173 vcodec drivers

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
Signed-off-by: Andrew-CT Chen <andrew-ct.c...@mediatek.com>
---
 MAINTAINERS |9 +
 1 file changed, 9 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a16a82..ed830c7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7590,6 +7590,15 @@ F:   include/uapi/linux/meye.h
 F: include/uapi/linux/ivtv*
 F: include/uapi/linux/uvcvideo.h
 
+MT8173 MEDIA DRIVER
+M:     Tiffany Lin <tiffany@mediatek.com>
+M: Andrew-CT Chen <andrew-ct.c...@mediatek.com>
+S: Supported
+F: drivers/media/platform/mtk-vcodec/
+F: drivers/media/platform/mtk-vpu/
+F: Documentation/devicetree/bindings/media/mediatek-vcodec.txt
+F: Documentation/devicetree/bindings/media/mediatek-vpu.txt
+
 MEDIATEK ETHERNET DRIVER
 M: Felix Fietkau <n...@openwrt.org>
 M: John Crispin <blo...@openwrt.org>
-- 
1.7.9.5

--
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


[PATCH] vcodec: mediatek: Add V4L2_CAP_TIMEPERFRAME capability setting

2016-09-05 Thread Tiffany Lin
This patch setting V4L2_CAP_TIMEPERFRAME capability in
vidioc_venc_s/g_parm functions

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
index 34fd89c..d0c2b9a 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
@@ -243,6 +243,8 @@ static int vidioc_venc_s_parm(struct file *file, void *priv,
a->parm.output.timeperframe.numerator;
ctx->param_change |= MTK_ENCODE_PARAM_FRAMERATE;
 
+   a->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
+
return 0;
 }
 
@@ -254,6 +256,7 @@ static int vidioc_venc_g_parm(struct file *file, void *priv,
if (a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
return -EINVAL;
 
+   a->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
a->parm.output.timeperframe.denominator =
ctx->enc_params.framerate_num;
a->parm.output.timeperframe.numerator =
-- 
1.7.9.5

--
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 v5 0/9] Add MT8173 Video Decoder Driver

2016-09-05 Thread Tiffany Lin
Hi Hans,

On Mon, 2016-09-05 at 13:26 +0200, Hans Verkuil wrote:
> On 09/05/2016 12:52 PM, Tiffany Lin wrote:
> > Hi Hans,
> > 
> > On Mon, 2016-09-05 at 12:09 +0200, Hans Verkuil wrote:
> >> On 09/05/2016 11:53 AM, Hans Verkuil wrote:
> >>> On 09/05/2016 11:50 AM, Tiffany Lin wrote:
> >>>> Hi Hans,
> >>>>
> >>>> On Mon, 2016-09-05 at 11:33 +0200, Hans Verkuil wrote:
> >>>>> On 09/02/2016 02:19 PM, Tiffany Lin wrote:
> >>>>>> ==
> >>>>>>  Introduction
> >>>>>> ==
> >>>>>>
> >>>>>> The purpose of this series is to add the driver for video codec hw 
> >>>>>> embedded in the Mediatek's MT8173 SoCs.
> >>>>>> Mediatek Video Codec is able to handle video decoding and encoding of 
> >>>>>> in a range of formats.
> >>>>>>
> >>>>>> This patch series rely on MTK VPU driver that have been merged in 
> >>>>>> v4.8-rc1.
> >>>>>> Mediatek Video Decoder driver rely on VPU driver to load, communicate 
> >>>>>> with VPU.
> >>>>>>
> >>>>>> Internally the driver uses videobuf2 framework, and MTK IOMMU and MTK 
> >>>>>> SMI both have been merged in v4.6-rc1.
> >>>>>>
> >>>>>> [1]https://chromium-review.googlesource.com/#/c/245241/
> >>>>>
> >>>>> This patch series fails to apply to the media_tree master (patch 3/9). 
> >>>>> Can you rebase and repost?
> >>>>>
> >>>>> I'm ready to make a pull request for this, so I hope you can fix this 
> >>>>> soon.
> >>>>>
> >>>> I saw Encoder fix patches in fixes branch.
> >>>> This patch series is base on Encoder fix patches. 
> >>>>
> >>>> [media] vcodec:mediatek: Refine VP8 encoder driver
> >>>> [media] vcodec:mediatek: Refine H264 encoder driver
> >>>> [media] vcodec:mediatek: change H264 profile default to profile high
> >>>> [media] vcodec:mediatek: Add timestamp and timecode copy for V4L2
> >>>> Encoder
> >>>> [media] vcodec:mediatek: Fix visible_height larger than coded_height
> >>>> issue in s_fmt_out
> >>>> [media] vcodec:mediatek: Fix fops_vcodec_release flow for V4L2 Encoder
> >>>> [media] vcodec:mediatek:code refine for v4l2 Encoder driver
> >>>> [media] dvb_frontend: Use memdup_user() rather than duplicating its
> >>>> implementation
> >>>>
> >>>>
> >>>> If I do not rebase decoder patch series base on Encoder fix pathces.
> >>>> Then it will fail after Encoder fix patches merged.
> >>>>
> >>>> May I know what parent patch I need to rebase to to fix this issue?
> >>>
> >>> Ah, OK. I will retest placing this on top of those fixes. I forgot about 
> >>> the
> >>> pending fixes. I'll handle this.
> >>
> >> OK, that works much better when it is on top of the fixes.
> >>
> >> Only one thing is missing: an entry in the MAINTAINERS file. Strange that 
> >> that
> >> wasn't done for the encoder driver, we must have missed that. So can you 
> >> make a
> >> patch adding the en/decoder driver to this file? I'm ready to make the pull
> >> request once I have that.
> >>
> > Got it. I will check and update it.
> > 
> > I have a question about decoder device node.
> > In v5 decoder patch series, I do not add device node patch at end of
> > patch series.
> > I plain to put it in MT21C format patch series, is it ok?
> 
> What is the reason for not adding it in the decoder patch series?
> 

It is because our decoder HW only support MT21C format.


best regards,
Tiffany

> Regards,
> 
>   Hans


--
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 v5 0/9] Add MT8173 Video Decoder Driver

2016-09-05 Thread Tiffany Lin
Hi Hans,

On Mon, 2016-09-05 at 12:09 +0200, Hans Verkuil wrote:
> On 09/05/2016 11:53 AM, Hans Verkuil wrote:
> > On 09/05/2016 11:50 AM, Tiffany Lin wrote:
> >> Hi Hans,
> >>
> >> On Mon, 2016-09-05 at 11:33 +0200, Hans Verkuil wrote:
> >>> On 09/02/2016 02:19 PM, Tiffany Lin wrote:
> >>>> ==
> >>>>  Introduction
> >>>> ==
> >>>>
> >>>> The purpose of this series is to add the driver for video codec hw 
> >>>> embedded in the Mediatek's MT8173 SoCs.
> >>>> Mediatek Video Codec is able to handle video decoding and encoding of in 
> >>>> a range of formats.
> >>>>
> >>>> This patch series rely on MTK VPU driver that have been merged in 
> >>>> v4.8-rc1.
> >>>> Mediatek Video Decoder driver rely on VPU driver to load, communicate 
> >>>> with VPU.
> >>>>
> >>>> Internally the driver uses videobuf2 framework, and MTK IOMMU and MTK 
> >>>> SMI both have been merged in v4.6-rc1.
> >>>>
> >>>> [1]https://chromium-review.googlesource.com/#/c/245241/
> >>>
> >>> This patch series fails to apply to the media_tree master (patch 3/9). 
> >>> Can you rebase and repost?
> >>>
> >>> I'm ready to make a pull request for this, so I hope you can fix this 
> >>> soon.
> >>>
> >> I saw Encoder fix patches in fixes branch.
> >> This patch series is base on Encoder fix patches. 
> >>
> >> [media] vcodec:mediatek: Refine VP8 encoder driver
> >> [media] vcodec:mediatek: Refine H264 encoder driver
> >> [media] vcodec:mediatek: change H264 profile default to profile high
> >> [media] vcodec:mediatek: Add timestamp and timecode copy for V4L2
> >> Encoder
> >> [media] vcodec:mediatek: Fix visible_height larger than coded_height
> >> issue in s_fmt_out
> >> [media] vcodec:mediatek: Fix fops_vcodec_release flow for V4L2 Encoder
> >> [media] vcodec:mediatek:code refine for v4l2 Encoder driver
> >> [media] dvb_frontend: Use memdup_user() rather than duplicating its
> >> implementation
> >>
> >>
> >> If I do not rebase decoder patch series base on Encoder fix pathces.
> >> Then it will fail after Encoder fix patches merged.
> >>
> >> May I know what parent patch I need to rebase to to fix this issue?
> > 
> > Ah, OK. I will retest placing this on top of those fixes. I forgot about the
> > pending fixes. I'll handle this.
> 
> OK, that works much better when it is on top of the fixes.
> 
> Only one thing is missing: an entry in the MAINTAINERS file. Strange that that
> wasn't done for the encoder driver, we must have missed that. So can you make 
> a
> patch adding the en/decoder driver to this file? I'm ready to make the pull
> request once I have that.
> 
Got it. I will check and update it.

I have a question about decoder device node.
In v5 decoder patch series, I do not add device node patch at end of
patch series.
I plain to put it in MT21C format patch series, is it ok?


best regards,
Tiffany



> Regards,
> 
>   Hans


--
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 v5 0/9] Add MT8173 Video Decoder Driver

2016-09-05 Thread Tiffany Lin
Hi Hans,

On Mon, 2016-09-05 at 11:33 +0200, Hans Verkuil wrote:
> On 09/02/2016 02:19 PM, Tiffany Lin wrote:
> > ==
> >  Introduction
> > ==
> > 
> > The purpose of this series is to add the driver for video codec hw embedded 
> > in the Mediatek's MT8173 SoCs.
> > Mediatek Video Codec is able to handle video decoding and encoding of in a 
> > range of formats.
> > 
> > This patch series rely on MTK VPU driver that have been merged in v4.8-rc1.
> > Mediatek Video Decoder driver rely on VPU driver to load, communicate with 
> > VPU.
> > 
> > Internally the driver uses videobuf2 framework, and MTK IOMMU and MTK SMI 
> > both have been merged in v4.6-rc1.
> > 
> > [1]https://chromium-review.googlesource.com/#/c/245241/
> 
> This patch series fails to apply to the media_tree master (patch 3/9). Can 
> you rebase and repost?
> 
> I'm ready to make a pull request for this, so I hope you can fix this soon.
> 
I saw Encoder fix patches in fixes branch.
This patch series is base on Encoder fix patches. 

[media] vcodec:mediatek: Refine VP8 encoder driver
[media] vcodec:mediatek: Refine H264 encoder driver
[media] vcodec:mediatek: change H264 profile default to profile high
[media] vcodec:mediatek: Add timestamp and timecode copy for V4L2
Encoder
[media] vcodec:mediatek: Fix visible_height larger than coded_height
issue in s_fmt_out
[media] vcodec:mediatek: Fix fops_vcodec_release flow for V4L2 Encoder
[media] vcodec:mediatek:code refine for v4l2 Encoder driver
[media] dvb_frontend: Use memdup_user() rather than duplicating its
implementation


If I do not rebase decoder patch series base on Encoder fix pathces.
Then it will fail after Encoder fix patches merged.

May I know what parent patch I need to rebase to to fix this issue?


best regards,
Tiffany

> Thanks!
> 
>   Hans
> 
> > 
> > ==
> >  Device interface
> > ==
> > 
> > In principle the driver bases on v4l2 memory-to-memory framework:
> > it provides a single video node and each opened file handle gets its own 
> > private context with separate buffer queues. Each context consist of 2 
> > buffer 
> > queues: OUTPUT (for source buffers, i.e. bitstream) and CAPTURE (for 
> > destination buffers, i.e. decoded video frames).
> > OUTPUT and CAPTURE buffer could be MMAP or DMABUF memory type.
> > 
> > Change in v5:
> > 1. Merge wucheng's V4L2_PIX_FMT_VP9 series to this series
> >V4L: add VP9 format documentation
> >v4l2-ioctl: add VP9 format description.
> >videodev2.h: add V4L2_PIX_FMT_VP9 format.
> > 2. Remove V4L2_PIX_FMT_MT21C to another series
> > 
> > Change in v4:
> > 1.Change V4L2_PIX_FMT_MT21 to v4l2_PIX_FMT_MT21C
> > 2.Fix g/s_selection implementation
> > 3.Refine code according to review comments and pass V4l2-compliance test
> > 
> > -/bin/sh: v4l2: not found
> > # v4l2-compliance -d /dev/video0
> > v4l2-compliance SHA   : fc45cdc502065bc1dfb4ef9ceb9a822bb9877bce
> > 
> > Driver Info:
> > Driver name   : mtk-vcodec-dec
> > Card type : platform:mt8173
> > Bus info  : platform:mt8173
> > Driver version: 4.8.0
> > Capabilities  : 0x84204000
> > Video Memory-to-Memory Multiplanar
> > Streaming
> > Extended Pix Format
> > Device Capabilities
> > Device Caps   : 0x04204000
> > Video Memory-to-Memory Multiplanar
> > Streaming
> > Extended Pix Format
> > 
> > Compliance test for device /dev/video0 (not using libv4l2):
> > 
> > Required ioctls:
> > test VIDIOC_QUERYCAP: OK
> > 
> > Allow for multiple opens:
> > test second video open: OK
> > test VIDIOC_QUERYCAP: OK
> > test VIDIOC_G/S_PRIORITY: OK
> > test for unlimited opens: OK
> > 
> > Debug ioctls:
> > test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
> > test VIDIOC_LOG_STATUS: OK (Not Supported)
> > 
> > Input ioctls:
> > test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
> > test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
> > test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
> > test VIDIOC_ENUMAUDIO: OK (Not Supported)
> > test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
> > test VIDIOC_G/S_AUDIO: OK (Not Supported)
> > Inputs: 0 Audio Inputs: 0 Tuners: 0
> > 
> > Output ioctls:
> > test V

[PATCH v5 8/9] Add documentation for V4L2_PIX_FMT_VP9.

2016-09-02 Thread Tiffany Lin
Add documentation for V4L2_PIX_FMT_VP9.

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
Signed-off-by: Wu-Cheng Li <wuchen...@chromium.org>
---
 Documentation/media/uapi/v4l/pixfmt-013.rst |8 
 1 file changed, 8 insertions(+)

diff --git a/Documentation/media/uapi/v4l/pixfmt-013.rst 
b/Documentation/media/uapi/v4l/pixfmt-013.rst
index bfef4f4..58e3ce6 100644
--- a/Documentation/media/uapi/v4l/pixfmt-013.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-013.rst
@@ -129,3 +129,11 @@ Compressed Formats
-  'VP80'
 
-  VP8 video elementary stream.
+
+-  .. _V4L2-PIX-FMT-VP9:
+
+   -  ``V4L2_PIX_FMT_VP9``
+
+   -  'VP90'
+
+   -  VP9 video elementary stream.
-- 
1.7.9.5

--
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


[PATCH v5 5/9] vcodec: mediatek: Add Mediatek VP8 Video Decoder Driver

2016-09-02 Thread Tiffany Lin
Add vp8 decoder driver for MT8173

Signed-off-by: PC Chen <pc.c...@mediatek.com>
Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/Makefile |1 +
 .../media/platform/mtk-vcodec/vdec/vdec_vp8_if.c   |  633 
 drivers/media/platform/mtk-vcodec/vdec_drv_if.c|3 +
 3 files changed, 637 insertions(+)
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c

diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
index 58243ed..7743c81 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -4,6 +4,7 @@ obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-dec.o \
   mtk-vcodec-common.o
 
 mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
+   vdec/vdec_vp8_if.o \
mtk_vcodec_dec_drv.o \
vdec_drv_if.o \
vdec_vpu_if.o \
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c 
b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
new file mode 100644
index 000..d4fce3e
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
@@ -0,0 +1,633 @@
+/*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: Jungchang Tsao <jungchang.t...@mediatek.com>
+ *PC Chen <pc.c...@mediatek.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include "../vdec_drv_if.h"
+#include "../mtk_vcodec_util.h"
+#include "../mtk_vcodec_dec.h"
+#include "../mtk_vcodec_intr.h"
+#include "../vdec_vpu_if.h"
+#include "../vdec_drv_base.h"
+
+/* Decoding picture buffer size (3 reference frames plus current frame) */
+#define VP8_DPB_SIZE   4
+
+/* HW working buffer size (bytes) */
+#define VP8_WORKING_BUF_SZ (45 * 4096)
+
+/* HW control register address */
+#define VP8_SEGID_DRAM_ADDR0x3c
+#define VP8_HW_VLD_ADDR0x93C
+#define VP8_HW_VLD_VALUE   0x940
+#define VP8_BSASET 0x100
+#define VP8_BSDSET 0x104
+#define VP8_RW_CKEN_SET0x0
+#define VP8_RW_DCM_CON 0x18
+#define VP8_WO_VLD_SRST0x108
+#define VP8_RW_MISC_SYS_SEL0x84
+#define VP8_RW_MISC_SPEC_CON   0xC8
+#define VP8_WO_VLD_SRST0x108
+#define VP8_RW_VP8_CTRL0xA4
+#define VP8_RW_MISC_DCM_CON0xEC
+#define VP8_RW_MISC_SRST   0xF4
+#define VP8_RW_MISC_FUNC_CON   0xCC
+
+#define VP8_MAX_FRM_BUF_NUM5
+#define VP8_MAX_FRM_BUF_NODE_NUM   (VP8_MAX_FRM_BUF_NUM * 2)
+
+/* required buffer size (bytes) to store decode information */
+#define VP8_HW_SEGMENT_DATA_SZ 272
+#define VP8_HW_SEGMENT_UINT4
+
+#define VP8_DEC_TABLE_PROC_LOOP96
+#define VP8_DEC_TABLE_UNIT 3
+#define VP8_DEC_TABLE_SZ   300
+#define VP8_DEC_TABLE_OFFSET   2
+#define VP8_DEC_TABLE_RW_UNIT  4
+
+/**
+ * struct vdec_vp8_dec_info - decode misc information
+ * @working_buf_dma   : working buffer dma address
+ * @prev_y_dma: previous decoded frame buffer Y plane address
+ * @cur_y_fb_dma  : current plane Y frame buffer dma address
+ * @cur_c_fb_dma  : current plane C frame buffer dma address
+ * @bs_dma   : bitstream dma address
+ * @bs_sz: bitstream size
+ * @resolution_changed: resolution change flag 1 - changed,  0 - not change
+ * @show_frame   : display this frame or not
+ * @wait_key_frame: wait key frame coming
+ */
+struct vdec_vp8_dec_info {
+   uint64_t working_buf_dma;
+   uint64_t prev_y_dma;
+   uint64_t cur_y_fb_dma;
+   uint64_t cur_c_fb_dma;
+   uint64_t bs_dma;
+   uint32_t bs_sz;
+   uint32_t resolution_changed;
+   uint32_t show_frame;
+   uint32_t wait_key_frame;
+};
+
+/**
+ * struct vdec_vp8_vsi - VPU shared information
+ * @dec: decoding information
+ * @pic: picture information
+ * @dec_table  : decoder coefficient table
+ * @segment_buf: segmentation buffer
+ * @load_data  : flag to indicate reload decode data
+ */
+struct vdec_vp8_vsi {
+   struct vdec_vp8_dec_info dec;
+   struct vdec_pic_info pic;
+   uint32_t dec_table[VP8_DEC_TABLE_SZ];
+   uint32_t segment_buf[VP8_HW_SEGM

[PATCH v5 6/9] videodev2.h: add V4L2_PIX_FMT_VP9 format.

2016-09-02 Thread Tiffany Lin
From: Wu-Cheng Li <wuchen...@chromium.org>

This adds VP9 video coding format, a successor to VP8.

Signed-off-by: Wu-Cheng Li <wuchen...@chromium.org>
Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 include/uapi/linux/videodev2.h |1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 5529741..43326c3 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -603,6 +603,7 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_VC1_ANNEX_G v4l2_fourcc('V', 'C', '1', 'G') /* SMPTE 421M 
Annex G compliant stream */
 #define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L') /* SMPTE 421M 
Annex L compliant stream */
 #define V4L2_PIX_FMT_VP8  v4l2_fourcc('V', 'P', '8', '0') /* VP8 */
+#define V4L2_PIX_FMT_VP9  v4l2_fourcc('V', 'P', '9', '0') /* VP9 */
 
 /*  Vendor-specific formats   */
 #define V4L2_PIX_FMT_CPIA1v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */
-- 
1.7.9.5

--
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


[PATCH v5 0/9] Add MT8173 Video Decoder Driver

2016-09-02 Thread Tiffany Lin
 Chen (1):
  VPU: mediatek: Add decode support

Tiffany Lin (10):
  dt-bindings: Add a binding for Mediatek Video Decoder
  vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver
  vcodec: mediatek: Add Mediatek H264 Video Decoder Drive
  vcodec: mediatek: Add Mediatek VP8 Video Decoder Driver
  Add documentation for V4L2_PIX_FMT_VP9.
  vcodec: mediatek: Add Mediatek VP9 Video Decoder Driver
  v4l: add Mediatek compressed video block format
  docs-rst: Add compressed video formats used on MT8173 codec driver
  vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder
  arm64: dts: mediatek: Add Video Decoder for MT8173

Wu-Cheng Li (2):
  videodev2.h: add V4L2_PIX_FMT_VP9 format.
  v4l2-ioctl: add VP9 format description.

 .../devicetree/bindings/media/mediatek-vcodec.txt  |   57 +-
 Documentation/media/uapi/v4l/pixfmt-013.rst|8 +
 Documentation/media/uapi/v4l/pixfmt-reserved.rst   |6 +
 arch/arm64/boot/dts/mediatek/mt8173.dtsi   |   44 +
 drivers/media/platform/mtk-vcodec/Makefile |   15 +-
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 1448 
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h |   88 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c |  394 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c  |  205 +++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h  |   28 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |   62 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c |8 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_intr.c|3 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_util.c|   33 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_util.h|5 +
 .../media/platform/mtk-vcodec/vdec/vdec_h264_if.c  |  506 +++
 .../media/platform/mtk-vcodec/vdec/vdec_vp8_if.c   |  633 +
 .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   |  967 +
 drivers/media/platform/mtk-vcodec/vdec_drv_base.h  |   56 +
 drivers/media/platform/mtk-vcodec/vdec_drv_if.c|  122 ++
 drivers/media/platform/mtk-vcodec/vdec_drv_if.h|  101 ++
 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h   |  103 ++
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c|  168 +++
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.h|   96 ++
 drivers/media/platform/mtk-vpu/mtk_vpu.c   |   12 +
 drivers/media/platform/mtk-vpu/mtk_vpu.h   |   27 +
 drivers/media/v4l2-core/v4l2-ioctl.c   |2 +
 include/uapi/linux/videodev2.h |2 +
 28 files changed, 5173 insertions(+), 26 deletions(-)
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_base.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_vpu_if.h

-- 
1.7.9.5

--
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


[PATCH v5 2/9] dt-bindings: Add a binding for Mediatek Video Decoder

2016-09-02 Thread Tiffany Lin
Add a DT binding documentation of Video Decoder for the
MT8173 SoC from Mediatek.

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
Acked-by: Rob Herring <r...@kernel.org>
---
 .../devicetree/bindings/media/mediatek-vcodec.txt  |   57 ++--
 1 file changed, 53 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt 
b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
index 59a47a5..46c15c5 100644
--- a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
+++ b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
@@ -1,25 +1,74 @@
 Mediatek Video Codec
 
 Mediatek Video Codec is the video codec hw present in Mediatek SoCs which
-supports high resolution encoding functionalities.
+supports high resolution encoding and decoding functionalities.
 
 Required properties:
 - compatible : "mediatek,mt8173-vcodec-enc" for encoder
+  "mediatek,mt8173-vcodec-dec" for decoder.
 - reg : Physical base address of the video codec registers and length of
   memory mapped region.
 - interrupts : interrupt number to the cpu.
 - mediatek,larb : must contain the local arbiters in the current Socs.
 - clocks : list of clock specifiers, corresponding to entries in
   the clock-names property.
-- clock-names: encoder must contain "venc_sel_src", "venc_sel",
-- "venc_lt_sel_src", "venc_lt_sel".
+- clock-names: encoder must contain "venc_sel_src", "venc_sel",,
+  "venc_lt_sel_src", "venc_lt_sel", decoder must contain "vcodecpll",
+  "univpll_d2", "clk_cci400_sel", "vdec_sel", "vdecpll", "vencpll",
+  "venc_lt_sel", "vdec_bus_clk_src".
 - iommus : should point to the respective IOMMU block with master port as
   argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
   for details.
 - mediatek,vpu : the node of video processor unit
 
+
 Example:
-vcodec_enc: vcodec@0x18002000 {
+
+vcodec_dec: vcodec@1600 {
+compatible = "mediatek,mt8173-vcodec-dec";
+reg = <0 0x1600 0 0x100>,   /*VDEC_SYS*/
+  <0 0x1602 0 0x1000>,  /*VDEC_MISC*/
+  <0 0x16021000 0 0x800>,   /*VDEC_LD*/
+  <0 0x16021800 0 0x800>,   /*VDEC_TOP*/
+  <0 0x16022000 0 0x1000>,  /*VDEC_CM*/
+  <0 0x16023000 0 0x1000>,  /*VDEC_AD*/
+  <0 0x16024000 0 0x1000>,  /*VDEC_AV*/
+  <0 0x16025000 0 0x1000>,  /*VDEC_PP*/
+  <0 0x16026800 0 0x800>,   /*VP8_VD*/
+  <0 0x16027000 0 0x800>,   /*VP6_VD*/
+  <0 0x16027800 0 0x800>,   /*VP8_VL*/
+  <0 0x16028400 0 0x400>;   /*VP9_VD*/
+interrupts = ;
+mediatek,larb = <>;
+iommus = < M4U_PORT_HW_VDEC_MC_EXT>,
+ < M4U_PORT_HW_VDEC_PP_EXT>,
+ < M4U_PORT_HW_VDEC_AVC_MV_EXT>,
+ < M4U_PORT_HW_VDEC_PRED_RD_EXT>,
+ < M4U_PORT_HW_VDEC_PRED_WR_EXT>,
+ < M4U_PORT_HW_VDEC_UFO_EXT>,
+ < M4U_PORT_HW_VDEC_VLD_EXT>,
+ < M4U_PORT_HW_VDEC_VLD2_EXT>;
+mediatek,vpu = <>;
+power-domains = < MT8173_POWER_DOMAIN_VDEC>;
+clocks = < CLK_APMIXED_VCODECPLL>,
+ < CLK_TOP_UNIVPLL_D2>,
+ < CLK_TOP_CCI400_SEL>,
+ < CLK_TOP_VDEC_SEL>,
+ < CLK_TOP_VCODECPLL>,
+ < CLK_APMIXED_VENCPLL>,
+ < CLK_TOP_VENC_LT_SEL>,
+ < CLK_TOP_VCODECPLL_370P5>;
+clock-names = "vcodecpll",
+  "univpll_d2",
+  "clk_cci400_sel",
+  "vdec_sel",
+  "vdecpll",
+  "vencpll",
+  "venc_lt_sel",
+  "vdec_bus_clk_src";
+  };
+
+  vcodec_enc: vcodec@0x18002000 {
 compatible = "mediatek,mt8173-vcodec-enc";
 reg = <0 0x18002000 0 0x1000>,/*VENC_SYS*/
   <0 0x19002000 0 0x1000>;/*VENC_LT_SYS*/
-- 
1.7.9.5

--
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


[PATCH v5 7/9] v4l2-ioctl: add VP9 format description.

2016-09-02 Thread Tiffany Lin
From: Wu-Cheng Li <wuchen...@chromium.org>

VP9 is a video coding format and a successor to VP8.

Signed-off-by: Wu-Cheng Li <wuchen...@chromium.org>
Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/v4l2-core/v4l2-ioctl.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index eb6ccc7..2bd1581 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1269,6 +1269,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_VC1_ANNEX_G:  descr = "VC-1 (SMPTE 412M Annex 
G)"; break;
case V4L2_PIX_FMT_VC1_ANNEX_L:  descr = "VC-1 (SMPTE 412M Annex 
L)"; break;
case V4L2_PIX_FMT_VP8:  descr = "VP8"; break;
+   case V4L2_PIX_FMT_VP9:  descr = "VP9"; break;
case V4L2_PIX_FMT_CPIA1:descr = "GSPCA CPiA YUV"; break;
case V4L2_PIX_FMT_WNVA: descr = "WNVA"; break;
case V4L2_PIX_FMT_SN9C10X:  descr = "GSPCA SN9C10X"; break;
-- 
1.7.9.5

--
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


[PATCH v5 3/9] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-09-02 Thread Tiffany Lin
Add v4l2 layer decoder driver for MT8173

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/Makefile |   12 +-
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 1433 
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h |   88 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c |  394 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c  |  205 +++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h  |   28 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |   62 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c |8 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_intr.c|3 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_util.c|   33 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_util.h|5 +
 drivers/media/platform/mtk-vcodec/vdec_drv_base.h  |   55 +
 drivers/media/platform/mtk-vcodec/vdec_drv_if.c|  112 ++
 drivers/media/platform/mtk-vcodec/vdec_drv_if.h|  101 ++
 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h   |  103 ++
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c|  168 +++
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.h|   96 ++
 17 files changed, 2884 insertions(+), 22 deletions(-)
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_base.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_vpu_if.h

diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
index dc5cb00..b54e823 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -1,7 +1,13 @@
 
-
-obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-enc.o mtk-vcodec-common.o
-
+obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-dec.o \
+  mtk-vcodec-enc.o \
+  mtk-vcodec-common.o
+
+mtk-vcodec-dec-y := mtk_vcodec_dec_drv.o \
+   vdec_drv_if.o \
+   vdec_vpu_if.o \
+   mtk_vcodec_dec.o \
+   mtk_vcodec_dec_pm.o \
 
 
 mtk-vcodec-enc-y := venc/venc_vp8_if.o \
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
new file mode 100644
index 000..d634e61
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -0,0 +1,1433 @@
+/*
+* Copyright (c) 2016 MediaTek Inc.
+* Author: PC Chen <pc.c...@mediatek.com>
+*     Tiffany Lin <tiffany@mediatek.com>
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*/
+
+#include 
+#include 
+#include 
+
+#include "mtk_vcodec_drv.h"
+#include "mtk_vcodec_dec.h"
+#include "mtk_vcodec_intr.h"
+#include "mtk_vcodec_util.h"
+#include "vdec_drv_if.h"
+#include "mtk_vcodec_dec_pm.h"
+
+#define OUT_FMT_IDX0
+#define CAP_FMT_IDX0
+
+#define MTK_VDEC_MIN_W 64U
+#define MTK_VDEC_MIN_H 64U
+#define DFT_CFG_WIDTH  MTK_VDEC_MIN_W
+#define DFT_CFG_HEIGHT MTK_VDEC_MIN_H
+
+static struct mtk_video_fmt mtk_video_formats[] = {
+   {
+   .fourcc = V4L2_PIX_FMT_H264,
+   .type = MTK_FMT_DEC,
+   .num_planes = 1,
+   },
+   {
+   .fourcc = V4L2_PIX_FMT_VP8,
+   .type = MTK_FMT_DEC,
+   .num_planes = 1,
+   },
+};
+
+static const struct mtk_codec_framesizes mtk_vdec_framesizes[] = {
+   {
+   .fourcc = V4L2_PIX_FMT_H264,
+   .stepwise = {  MTK_VDEC_MIN_W, MTK_VDEC_MAX_W, 16,
+   MTK_VDEC_MIN_H, MTK_VDEC_MAX_H, 16 },
+   },
+   {
+   .fourcc = V4L2_PIX_FMT_VP8,
+   .stepwise = {  MTK_VDEC_MIN_W, MTK_VDEC_MAX_W, 16,
+   MTK_VDEC_MIN_H, MTK_VDEC_MAX_H, 16 },
+   },
+};
+
+#define NUM_SUPPORTED_FRAMESIZE ARRAY_SIZE(mtk_vdec_framesizes)
+#define NUM_FORMATS ARRAY_SIZE(mtk_video_formats)
+
+static struc

[PATCH v5 1/9] VPU: mediatek: Add decode support

2016-09-02 Thread Tiffany Lin
From: Andrew-CT Chen <andrew-ct.c...@mediatek.com>

VPU driver add decode support

Signed-off-by: Andrew-CT Chen <andrew-ct.c...@mediatek.com>
Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vpu/mtk_vpu.c |   12 
 drivers/media/platform/mtk-vpu/mtk_vpu.h |   27 +++
 2 files changed, 39 insertions(+)

diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.c 
b/drivers/media/platform/mtk-vpu/mtk_vpu.c
index c9bf58c..63510de 100644
--- a/drivers/media/platform/mtk-vpu/mtk_vpu.c
+++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
@@ -134,6 +134,8 @@ struct vpu_wdt {
  *
  * @signaled:  the signal of vpu initialization completed
  * @fw_ver:VPU firmware version
+ * @dec_capability:decoder capability which is not used for now and
+ * the value is reserved for future use
  * @enc_capability:encoder capability which is not used for now and
  * the value is reserved for future use
  * @wq:wait queue for VPU initialization status
@@ -141,6 +143,7 @@ struct vpu_wdt {
 struct vpu_run {
u32 signaled;
char fw_ver[VPU_FW_VER_LEN];
+   unsigned intdec_capability;
unsigned intenc_capability;
wait_queue_head_t wq;
 };
@@ -415,6 +418,14 @@ int vpu_wdt_reg_handler(struct platform_device *pdev,
 }
 EXPORT_SYMBOL_GPL(vpu_wdt_reg_handler);
 
+unsigned int vpu_get_vdec_hw_capa(struct platform_device *pdev)
+{
+   struct mtk_vpu *vpu = platform_get_drvdata(pdev);
+
+   return vpu->run.dec_capability;
+}
+EXPORT_SYMBOL_GPL(vpu_get_vdec_hw_capa);
+
 unsigned int vpu_get_venc_hw_capa(struct platform_device *pdev)
 {
struct mtk_vpu *vpu = platform_get_drvdata(pdev);
@@ -600,6 +611,7 @@ static void vpu_init_ipi_handler(void *data, unsigned int 
len, void *priv)
 
vpu->run.signaled = run->signaled;
strncpy(vpu->run.fw_ver, run->fw_ver, VPU_FW_VER_LEN);
+   vpu->run.dec_capability = run->dec_capability;
vpu->run.enc_capability = run->enc_capability;
wake_up_interruptible(>run.wq);
 }
diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.h 
b/drivers/media/platform/mtk-vpu/mtk_vpu.h
index 5ab37f0..f457479 100644
--- a/drivers/media/platform/mtk-vpu/mtk_vpu.h
+++ b/drivers/media/platform/mtk-vpu/mtk_vpu.h
@@ -37,6 +37,18 @@ typedef void (*ipi_handler_t) (void *data,
 command to VPU.
 For other IPI below, AP should send the request
 to VPU to trigger the interrupt.
+ * @IPI_VDEC_H264:  The interrupt from vpu is to notify kernel to
+handle H264 vidoe decoder job, and vice versa.
+Decode output format is always MT21 no matter what
+the input format is.
+ * @IPI_VDEC_VP8:   The interrupt from is to notify kernel to
+handle VP8 video decoder job, and vice versa.
+Decode output format is always MT21 no matter what
+the input format is.
+ * @IPI_VDEC_VP9:   The interrupt from vpu is to notify kernel to
+handle VP9 video decoder job, and vice versa.
+Decode output format is always MT21 no matter what
+the input format is.
  * @IPI_VENC_H264:  The interrupt from vpu is to notify kernel to
 handle H264 video encoder job, and vice versa.
  * @IPI_VENC_VP8:   The interrupt fro vpu is to notify kernel to
@@ -46,6 +58,9 @@ typedef void (*ipi_handler_t) (void *data,
 
 enum ipi_id {
IPI_VPU_INIT = 0,
+   IPI_VDEC_H264,
+   IPI_VDEC_VP8,
+   IPI_VDEC_VP9,
IPI_VENC_H264,
IPI_VENC_VP8,
IPI_MAX,
@@ -55,10 +70,12 @@ enum ipi_id {
  * enum rst_id - reset id to register reset function for VPU watchdog timeout
  *
  * @VPU_RST_ENC: encoder reset id
+ * @VPU_RST_DEC: decoder reset id
  * @VPU_RST_MAX: maximum reset id
  */
 enum rst_id {
VPU_RST_ENC,
+   VPU_RST_DEC,
VPU_RST_MAX,
 };
 
@@ -125,6 +142,16 @@ struct platform_device *vpu_get_plat_device(struct 
platform_device *pdev);
 int vpu_wdt_reg_handler(struct platform_device *pdev,
void vpu_wdt_reset_func(void *),
void *priv, enum rst_id id);
+
+/**
+ * vpu_get_vdec_hw_capa - get video decoder hardware capability
+ *
+ * @pdev:  VPU platform device
+ *
+ * Return: video decoder hardware capability
+ **/
+unsigned int vpu_get_vdec_hw_capa(struct platform_device *pdev);
+
 /**
  * vpu_get_venc_hw_capa - get video encoder hardware capability
  *
-- 
1.7.9.5

--
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


[PATCH v5 9/9] vcodec: mediatek: Add Mediatek VP9 Video Decoder Driver

2016-09-02 Thread Tiffany Lin
Add vp9 decoder driver for MT8173

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/Makefile |1 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |   10 +
 .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   |  967 
 drivers/media/platform/mtk-vcodec/vdec_drv_base.h  |1 +
 drivers/media/platform/mtk-vcodec/vdec_drv_if.c|4 +
 5 files changed, 983 insertions(+)
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c

diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
index 7743c81..852d969 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -5,6 +5,7 @@ obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-dec.o \
 
 mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
vdec/vdec_vp8_if.o \
+   vdec/vdec_vp9_if.o \
mtk_vcodec_dec_drv.o \
vdec_drv_if.o \
vdec_vpu_if.o \
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
index d634e61..28a8453 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -43,6 +43,11 @@ static struct mtk_video_fmt mtk_video_formats[] = {
.type = MTK_FMT_DEC,
.num_planes = 1,
},
+   {
+   .fourcc = V4L2_PIX_FMT_VP9,
+   .type = MTK_FMT_DEC,
+   .num_planes = 1,
+   },
 };
 
 static const struct mtk_codec_framesizes mtk_vdec_framesizes[] = {
@@ -56,6 +61,11 @@ static const struct mtk_codec_framesizes 
mtk_vdec_framesizes[] = {
.stepwise = {  MTK_VDEC_MIN_W, MTK_VDEC_MAX_W, 16,
MTK_VDEC_MIN_H, MTK_VDEC_MAX_H, 16 },
},
+   {
+   .fourcc = V4L2_PIX_FMT_VP9,
+   .stepwise = {  MTK_VDEC_MIN_W, MTK_VDEC_MAX_W, 16,
+   MTK_VDEC_MIN_H, MTK_VDEC_MAX_H, 16 },
+   },
 };
 
 #define NUM_SUPPORTED_FRAMESIZE ARRAY_SIZE(mtk_vdec_framesizes)
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c 
b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
new file mode 100644
index 000..60a7b00
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
@@ -0,0 +1,967 @@
+/*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: Daniel Hsiao <daniel.hs...@mediatek.com>
+ * Kai-Sean Yang <kai-sean.y...@mediatek.com>
+ * Tiffany Lin <tiffany@mediatek.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../mtk_vcodec_intr.h"
+#include "../vdec_drv_base.h"
+#include "../vdec_vpu_if.h"
+
+#define VP9_SUPER_FRAME_BS_SZ 64
+#define MAX_VP9_DPB_SIZE   9
+
+#define REFS_PER_FRAME 3
+#define MAX_NUM_REF_FRAMES 8
+#define VP9_MAX_FRM_BUF_NUM 9
+#define VP9_MAX_FRM_BUF_NODE_NUM (VP9_MAX_FRM_BUF_NUM * 2)
+
+/**
+ * struct vp9_dram_buf - contains buffer info for vpu
+ * @va : cpu address
+ * @pa : iova address
+ * @sz : buffer size
+ * @padding : for 64 bytes alignment
+ */
+struct vp9_dram_buf {
+   unsigned long va;
+   unsigned long pa;
+   unsigned int sz;
+   unsigned int padding;
+};
+
+/**
+ * struct vp9_fb_info - contains frame buffer info
+ * @fb : frmae buffer
+ * @reserved : reserved field used by vpu
+ */
+struct vp9_fb_info {
+   struct vdec_fb *fb;
+   unsigned int reserved[32];
+};
+
+/**
+ * struct vp9_ref_cnt_buf - contains reference buffer information
+ * @buf : referenced frame buffer
+ * @ref_cnt : referenced frame buffer's reference count.
+ * When reference count=0, remove it from reference list
+ */
+struct vp9_ref_cnt_buf {
+   struct vp9_fb_info buf;
+   unsigned int ref_cnt;
+};
+
+/**
+ * struct vp9_fb_info - contains current frame's reference buffer information
+ * @buf : reference buffer
+ * @idx : reference buffer index to frm_bufs
+ * @reserved : reserved field used by vpu
+ */
+struct vp9_ref_buf {
+   struct vp9_fb_info *buf;
+   unsigned int idx;
+   unsigned int reserved[6];
+};
+
+/**
+ * struct vp9_fb_info - contains frame buffer info
+ * @fb : super frame reference frame buffer
+ * @used : this reference frame info entry is used
+ * @padding : for 64 bytes size align
+ */
+struct vp9_sf_ref_fb {
+   struct vdec_fb fb;
+   int used;
+   int padding;
+};
+
+/*
+ * st

[PATCH v5 4/9] vcodec: mediatek: Add Mediatek H264 Video Decoder Drive

2016-09-02 Thread Tiffany Lin
Add h264 decoder driver for MT8173

Signed-off-by: PC Chen <pc.c...@mediatek.com>
Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/Makefile |3 +-
 .../media/platform/mtk-vcodec/vdec/vdec_h264_if.c  |  506 
 drivers/media/platform/mtk-vcodec/vdec_drv_if.c|3 +
 3 files changed, 511 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c

diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
index b54e823..58243ed 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -3,7 +3,8 @@ obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-dec.o \
   mtk-vcodec-enc.o \
   mtk-vcodec-common.o
 
-mtk-vcodec-dec-y := mtk_vcodec_dec_drv.o \
+mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
+   mtk_vcodec_dec_drv.o \
vdec_drv_if.o \
vdec_vpu_if.o \
mtk_vcodec_dec.o \
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c 
b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
new file mode 100644
index 000..0353a47
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
@@ -0,0 +1,506 @@
+/*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: PC Chen <pc.c...@mediatek.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+
+#include "../vdec_drv_if.h"
+#include "../mtk_vcodec_util.h"
+#include "../mtk_vcodec_dec.h"
+#include "../mtk_vcodec_intr.h"
+#include "../vdec_vpu_if.h"
+#include "../vdec_drv_base.h"
+
+#define NAL_NON_IDR_SLICE  0x01
+#define NAL_IDR_SLICE  0x05
+#define NAL_H264_PPS   0x08
+#define NAL_TYPE(value)((value) & 0x1F)
+
+#define BUF_PREDICTION_SZ  (32 * 1024)
+
+#define MB_UNIT_LEN16
+
+/* motion vector size (bytes) for every macro block */
+#define HW_MB_STORE_SZ 64
+
+#define H264_MAX_FB_NUM17
+#define HDR_PARSING_BUF_SZ 1024
+
+/**
+ * struct h264_fb - h264 decode frame buffer information
+ * @vdec_fb_va  : virtual address of struct vdec_fb
+ * @y_fb_dma: dma address of Y frame buffer (luma)
+ * @c_fb_dma: dma address of C frame buffer (chroma)
+ * @poc : picture order count of frame buffer
+ * @reserved: for 8 bytes alignment
+ */
+struct h264_fb {
+   uint64_t vdec_fb_va;
+   uint64_t y_fb_dma;
+   uint64_t c_fb_dma;
+   int32_t poc;
+   uint32_t reserved;
+};
+
+/**
+ * struct h264_ring_fb_list - ring frame buffer list
+ * @fb_list   : frame buffer arrary
+ * @read_idx  : read index
+ * @write_idx : write index
+ * @count : buffer count in list
+ */
+struct h264_ring_fb_list {
+   struct h264_fb fb_list[H264_MAX_FB_NUM];
+   unsigned int read_idx;
+   unsigned int write_idx;
+   unsigned int count;
+   unsigned int reserved;
+};
+
+/**
+ * struct vdec_h264_dec_info - decode information
+ * @dpb_sz : decoding picture buffer size
+ * @resolution_changed  : resoltion change happen
+ * @realloc_mv_buf : flag to notify driver to re-allocate mv buffer
+ * @reserved   : for 8 bytes alignment
+ * @bs_dma : Input bit-stream buffer dma address
+ * @y_fb_dma   : Y frame buffer dma address
+ * @c_fb_dma   : C frame buffer dma address
+ * @vdec_fb_va : VDEC frame buffer struct virtual address
+ */
+struct vdec_h264_dec_info {
+   uint32_t dpb_sz;
+   uint32_t resolution_changed;
+   uint32_t realloc_mv_buf;
+   uint32_t reserved;
+   uint64_t bs_dma;
+   uint64_t y_fb_dma;
+   uint64_t c_fb_dma;
+   uint64_t vdec_fb_va;
+};
+
+/**
+ * struct vdec_h264_vsi - shared memory for decode information exchange
+ *between VPU and Host.
+ *The memory is allocated by VPU then mapping to Host
+ *in vpu_dec_init() and freed in vpu_dec_deinit()
+ *by VPU.
+ *AP-W/R : AP is writer/reader on this item
+ *VPU-W/R: VPU is write/reader on this item
+ * @hdr_buf  : Header parsing buffer (AP-W, VPU-R)
+ * @pred_buf_dma : HW w

Re: [PATCH v3 0/9] Add MT8173 Video Decoder Driver

2016-08-15 Thread Tiffany Lin
Hi Hans,


On Mon, 2016-08-15 at 11:07 +0200, Hans Verkuil wrote:
> On 08/15/2016 11:03 AM, Tiffany Lin wrote:
> > Hi Hans,
> > 
> > I upstream v4 on 8/10, I don't know why this version is not shown in
> > https://patchwork.kernel.org.
> > But I could see it in other link.
> > http://www.spinics.net/lists/arm-kernel/msg523095.html
> > I refine DocBook and vb2 queue_setup function in v4.
> > 
> > For the MT21 format, if I put MT21 into separate patch, this patch
> > series will build fail, I was confused how to fix this issue?
> 
> Just don't implement that pixelformat yet. I.e. everything else can be
> implemented, just don't add MT21 to the list of pixelformats. Do that in
> a separate patch at the end.
> 
> If that pixelformat isn't exposed, then nobody will use it either :-)
> 
Got it now.
Thanks a lot.


best regards,
Tiffany

> Regards,
> 
>   Hans


--
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 v3 0/9] Add MT8173 Video Decoder Driver

2016-08-15 Thread Tiffany Lin
Hi Hans,

I upstream v4 on 8/10, I don't know why this version is not shown in
https://patchwork.kernel.org.
But I could see it in other link.
http://www.spinics.net/lists/arm-kernel/msg523095.html
I refine DocBook and vb2 queue_setup function in v4.

For the MT21 format, if I put MT21 into separate patch, this patch
series will build fail, I was confused how to fix this issue?


For VP9, I will merge this three patchs to V4L2 Decoder patch series.
 * linux-media: [v1,1/3] videodev2.h: add V4L2_PIX_FMT_VP9 format.
 - http://patchwork.linuxtv.org/patch/34392/
 * linux-media: [v1,3/3] V4L: add VP9 format documentation
 - http://patchwork.linuxtv.org/patch/34393/
 * linux-media: [v1,2/3] v4l2-ioctl: add VP9 format description.
 - http://patchwork.linuxtv.org/patch/34394/


best regards,
Tiffany


On Mon, 2016-08-15 at 10:30 +0200, Hans Verkuil wrote:
> Hi Tiffany,
> 
> This needs a v4: the DocBook format has been replaced by sphinx, and I also 
> see that
> the vb2 queue_setup function is out-of-date (the allocation contexts no 
> longer exist).
> 
> There were also a lot of comments about the MT21 format. I recommend 
> splitting off the
> code adding MT21 into separate patches at the end of the patch series. That 
> way if there
> are more comments it is easy to merge everything but those patches relating 
> to MT21.
> 
> Can you also add the patches for the new V4L2_PIX_FMT_VP9 to this patch 
> series? Those
> needs to be updated as well due to the move to sphinx.
> 
> Thanks!
> 
>   Hans
> 
> On 05/30/2016 02:29 PM, Tiffany Lin wrote:
> > ==
> >  Introduction
> > ==
> > 
> > The purpose of this series is to add the driver for video codec hw embedded 
> > in the Mediatek's MT8173 SoCs.
> > Mediatek Video Codec is able to handle video decoding of in a range of 
> > formats.
> > 
> > This patch series add Mediatek block format V4L2_PIX_FMT_MT21, the decoder 
> > driver will decoded bitstream to
> > V4L2_PIX_FMT_MT21 format.
> > 
> > This patch series rely on MTK VPU driver in patch series "Add MT8173 Video 
> > Encoder Driver and VPU Driver"[1]
> > and patch "CHROMIUM: v4l: Add V4L2_PIX_FMT_VP9 definition"[2] for VP9 
> > support.
> > Mediatek Video Decoder driver rely on VPU driver to load, communicate with 
> > VPU.
> > 
> > Internally the driver uses videobuf2 framework and MTK IOMMU and MTK SMI 
> > both have been merged in v4.6-rc1.
> > 
> > [1]https://patchwork.linuxtv.org/patch/33734/
> > [2]https://chromium-review.googlesource.com/#/c/245241/
> > 
> > ==
> >  Device interface
> > ==
> > 
> > In principle the driver bases on v4l2 memory-to-memory framework:
> > it provides a single video node and each opened file handle gets its own 
> > private context with separate
> > buffer queues. Each context consist of 2 buffer queues: OUTPUT (for source 
> > buffers, i.e. bitstream)
> > and CAPTURE (for destination buffers, i.e. decoded video frames).
> > OUTPUT and CAPTURE buffer could be MMAP or DMABUF memory type.
> > VIDIOC_G_CTRL and VIDIOC_G_EXT_CTRLS return 
> > V4L2_CID_MIN_BUFFERS_FOR_CAPTURE only when dirver in MTK_STATE_HEADER
> > state, or it will return EAGAIN.
> > Driver do not support subscribe event for control 'User Controls' for now.
> > And it default support export DMABUF for other display drivers.
> > 
> > Change in v3:
> > 1. Refine vdec hw clock setting
> > 2. Refine vp9 codec driver
> > 3. Refine v4l2 codec driver
> > 
> > Change in v2:
> > 1. Add documentation for V4L2_PIX_FMT_MT21
> > 2. Remove DRM_FORMAT_MT21
> > 2. Refine code according to review comments
> > 
> > v4l2-compliance test output:
> > localhost Encode # ./v4l2-compliance -d /dev/video0
> > Driver Info:
> > Driver name   : mtk-vcodec-dec
> > Card type : platform:mt8173
> > Bus info  : platform:mt8173
> > Driver version: 4.4.0
> > Capabilities  : 0x84204000
> > Video Memory-to-Memory Multiplanar
> > Streaming
> > Extended Pix Format
> > Device Capabilities
> > Device Caps   : 0x04204000
> > Video Memory-to-Memory Multiplanar
> > Streaming
> > Extended Pix Format
> > 
> > Compliance test for device /dev/video0 (not using libv4l2):
> > 
> > Required ioctls:
> > test VIDIOC_QUERYCAP: OK
> > 
> > Allow for multiple opens:
> >   

Re: [PATCH] vcodec: mediatek: bug fix and code refine for mt8173 v4l2 Encoder

2016-08-14 Thread Tiffany Lin
Hi Hans,

On Sun, 2016-08-14 at 13:40 +0200, Hans Verkuil wrote:
> On 08/12/2016 04:35 PM, Tiffany Lin wrote:
> > This patch include fixs:
> > 1. Remove unused include in mtk_vcodec_drv.h
> > 2. Fix visible_height larger than coded_height issue in s_fmt_out
> > 3. Add timestamp and timecode copy
> > 4. Fix mtk_vcodec_vdec_release should be called after 
> > v4l2_m2m_ctx_release
> > 5. Remove unused define MTK_INST_WORK_THREAD_ABORT_DONE
> > 6. Add support V4L2_MPEG_VIDEO_H264_LEVEL_4_2
> > 4. Refine  venc_h264_if.c and venc_vp8_if.c
> 
> I would prefer it if this can be split up into separate patches, one for each 
> fix.
> 
> Also, should this be merged for v4.8 or can this wait for 4.9? When you split 
> it
> up you can use [PATCH for v4.8] as prefix for those patches that should go to 
> v4.8.
> 
I split up this patch into separate patches and resent them.
Please note there is dependency between these patches.

best regards,
Tiffany


> Regards,
> 
>   Hans
> 
> > 
> > Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
> > ---
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |1 -
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |   42 
> > 
> >  .../media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c |6 ++-
> >  .../media/platform/mtk-vcodec/mtk_vcodec_intr.h|1 -
> >  .../media/platform/mtk-vcodec/mtk_vcodec_util.c|   11 ++---
> >  .../media/platform/mtk-vcodec/venc/venc_h264_if.c  |   16 
> >  .../media/platform/mtk-vcodec/venc/venc_vp8_if.c   |   16 
> >  7 files changed, 52 insertions(+), 41 deletions(-)
> > 
> > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
> > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> > index 94f0a42..3a8e695 100644
> > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> > @@ -23,7 +23,6 @@
> >  #include 
> >  #include 
> >  
> > -#include "mtk_vcodec_util.h"
> >  
> >  #define MTK_VCODEC_DRV_NAME"mtk_vcodec_drv"
> >  #define MTK_VCODEC_ENC_NAME"mtk-vcodec-enc"
> > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > index 0a895e0..34fd89c 100644
> > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > @@ -487,7 +487,6 @@ static int vidioc_venc_s_fmt_out(struct file *file, 
> > void *priv,
> > struct mtk_q_data *q_data;
> > int ret, i;
> > struct mtk_video_fmt *fmt;
> > -   unsigned int pitch_w_div16;
> > struct v4l2_pix_format_mplane *pix_fmt_mp = >fmt.pix_mp;
> >  
> > vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
> > @@ -530,15 +529,6 @@ static int vidioc_venc_s_fmt_out(struct file *file, 
> > void *priv,
> > q_data->coded_width = f->fmt.pix_mp.width;
> > q_data->coded_height = f->fmt.pix_mp.height;
> >  
> > -   pitch_w_div16 = DIV_ROUND_UP(q_data->visible_width, 16);
> > -   if (pitch_w_div16 % 8 != 0) {
> > -   /* Adjust returned width/height, so application could correctly
> > -* allocate hw required memory
> > -*/
> > -   q_data->visible_height += 32;
> > -   vidioc_try_fmt(f, q_data->fmt);
> > -   }
> > -
> > q_data->field = f->fmt.pix_mp.field;
> > ctx->colorspace = f->fmt.pix_mp.colorspace;
> > ctx->ycbcr_enc = f->fmt.pix_mp.ycbcr_enc;
> > @@ -945,7 +935,8 @@ static int mtk_venc_encode_header(void *priv)
> >  {
> > struct mtk_vcodec_ctx *ctx = priv;
> > int ret;
> > -   struct vb2_buffer *dst_buf;
> > +   struct vb2_buffer *src_buf, *dst_buf;
> > +   struct vb2_v4l2_buffer *dst_vb2_v4l2, *src_vb2_v4l2;
> > struct mtk_vcodec_mem bs_buf;
> > struct venc_done_result enc_result;
> >  
> > @@ -978,6 +969,15 @@ static int mtk_venc_encode_header(void *priv)
> > mtk_v4l2_err("venc_if_encode failed=%d", ret);
> > return -EINVAL;
> > }
> > +   src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
> > +   if (src_buf) {
> > +   src_vb2_v4l2 = to_vb2_v4l2_buffer(src_buf);
> > +   dst_vb2_v4l2 = to_vb2_v4l2_buffer(dst_buf);
> > +   dst_buf->timestamp = src_buf->timestamp;
> > +   dst_vb2_v4l2->timecode = src_vb2_v4l2->

[PATCH for v4.8] vcodec:mediatek: Refine VP8 encoder driver

2016-08-14 Thread Tiffany Lin
This patch remove field and function that unused anymore

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 .../media/platform/mtk-vcodec/venc/venc_vp8_if.c   |   16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c 
b/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
index 60bbcd2..6d97584 100644
--- a/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
+++ b/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
@@ -56,6 +56,8 @@ enum venc_vp8_vpu_work_buf {
 
 /*
  * struct venc_vp8_vpu_config - Structure for vp8 encoder configuration
+ *  AP-W/R : AP is writer/reader on this item
+ *  VPU-W/R: VPU is write/reader on this item
  * @input_fourcc: input fourcc
  * @bitrate: target bitrate (in bps)
  * @pic_w: picture width. Picture size is visible stream resolution, in pixels,
@@ -83,14 +85,14 @@ struct venc_vp8_vpu_config {
 };
 
 /*
- * struct venc_vp8_vpu_buf -Structure for buffer information
- * @align: buffer alignment (in bytes)
+ * struct venc_vp8_vpu_buf - Structure for buffer information
+ *   AP-W/R : AP is writer/reader on this item
+ *   VPU-W/R: VPU is write/reader on this item
  * @iova: IO virtual address
  * @vpua: VPU side memory addr which is used by RC_CODE
  * @size: buffer size (in bytes)
  */
 struct venc_vp8_vpu_buf {
-   u32 align;
u32 iova;
u32 vpua;
u32 size;
@@ -98,6 +100,8 @@ struct venc_vp8_vpu_buf {
 
 /*
  * struct venc_vp8_vsi - Structure for VPU driver control and info share
+ *   AP-W/R : AP is writer/reader on this item
+ *   VPU-W/R: VPU is write/reader on this item
  * This structure is allocated in VPU side and shared to AP side.
  * @config: vp8 encoder configuration
  * @work_bufs: working buffer information in VPU side
@@ -138,12 +142,6 @@ struct venc_vp8_inst {
struct mtk_vcodec_ctx *ctx;
 };
 
-static inline void vp8_enc_write_reg(struct venc_vp8_inst *inst, u32 addr,
-u32 val)
-{
-   writel(val, inst->hw_base + addr);
-}
-
 static inline u32 vp8_enc_read_reg(struct venc_vp8_inst *inst, u32 addr)
 {
return readl(inst->hw_base + addr);
-- 
1.7.9.5

--
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


[PATCH for v4.8] vcodec:mediatek: Refine H264 encoder driver

2016-08-14 Thread Tiffany Lin
This patch :
1. remove field and function that unused anymore
2. add support V4L2_MPEG_VIDEO_H264_LEVEL_4_2

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 .../media/platform/mtk-vcodec/venc/venc_h264_if.c  |   16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c 
b/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
index 9a60052..63d4be4 100644
--- a/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
+++ b/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
@@ -61,6 +61,8 @@ enum venc_h264_bs_mode {
 
 /*
  * struct venc_h264_vpu_config - Structure for h264 encoder configuration
+ *   AP-W/R : AP is writer/reader on this item
+ *   VPU-W/R: VPU is write/reader on this item
  * @input_fourcc: input fourcc
  * @bitrate: target bitrate (in bps)
  * @pic_w: picture width. Picture size is visible stream resolution, in pixels,
@@ -94,13 +96,13 @@ struct venc_h264_vpu_config {
 
 /*
  * struct venc_h264_vpu_buf - Structure for buffer information
- * @align: buffer alignment (in bytes)
+ *AP-W/R : AP is writer/reader on this item
+ *VPU-W/R: VPU is write/reader on this item
  * @iova: IO virtual address
  * @vpua: VPU side memory addr which is used by RC_CODE
  * @size: buffer size (in bytes)
  */
 struct venc_h264_vpu_buf {
-   u32 align;
u32 iova;
u32 vpua;
u32 size;
@@ -108,6 +110,8 @@ struct venc_h264_vpu_buf {
 
 /*
  * struct venc_h264_vsi - Structure for VPU driver control and info share
+ *AP-W/R : AP is writer/reader on this item
+ *VPU-W/R: VPU is write/reader on this item
  * This structure is allocated in VPU side and shared to AP side.
  * @config: h264 encoder configuration
  * @work_bufs: working buffer information in VPU side
@@ -150,12 +154,6 @@ struct venc_h264_inst {
struct mtk_vcodec_ctx *ctx;
 };
 
-static inline void h264_write_reg(struct venc_h264_inst *inst, u32 addr,
- u32 val)
-{
-   writel(val, inst->hw_base + addr);
-}
-
 static inline u32 h264_read_reg(struct venc_h264_inst *inst, u32 addr)
 {
return readl(inst->hw_base + addr);
@@ -214,6 +212,8 @@ static unsigned int h264_get_level(struct venc_h264_inst 
*inst,
return 40;
case V4L2_MPEG_VIDEO_H264_LEVEL_4_1:
return 41;
+   case V4L2_MPEG_VIDEO_H264_LEVEL_4_2:
+   return 42;
default:
mtk_vcodec_debug(inst, "unsupported level %d", level);
return 31;
-- 
1.7.9.5

--
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


[PATCH for v4.8] vcodec:mediatek: change H264 profile default to profile high

2016-08-14 Thread Tiffany Lin
This patch change default H264 profile from V4L2_MPEG_VIDEO_H264_PROFILE_MAIN
to V4L2_MPEG_VIDEO_H264_PROFILE_HIGH

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
index 7bef7ba..284c1a7 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
@@ -1288,7 +1288,7 @@ int mtk_vcodec_enc_ctrls_setup(struct mtk_vcodec_ctx *ctx)
0, V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE);
v4l2_ctrl_new_std_menu(handler, ops, V4L2_CID_MPEG_VIDEO_H264_PROFILE,
V4L2_MPEG_VIDEO_H264_PROFILE_HIGH,
-   0, V4L2_MPEG_VIDEO_H264_PROFILE_MAIN);
+   0, V4L2_MPEG_VIDEO_H264_PROFILE_HIGH);
v4l2_ctrl_new_std_menu(handler, ops, V4L2_CID_MPEG_VIDEO_H264_LEVEL,
V4L2_MPEG_VIDEO_H264_LEVEL_4_2,
0, V4L2_MPEG_VIDEO_H264_LEVEL_4_0);
-- 
1.7.9.5

--
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


[PATCH for v4.8] vcodec:mediatek: Add timestamp and timecode copy for V4L2 Encoder

2016-08-14 Thread Tiffany Lin
This patch add copying timestamp and timecode from src buffer to dst buffer

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |   23 
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
index cd36c9e..7bef7ba 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
@@ -934,7 +934,8 @@ static int mtk_venc_encode_header(void *priv)
 {
struct mtk_vcodec_ctx *ctx = priv;
int ret;
-   struct vb2_buffer *dst_buf;
+   struct vb2_buffer *src_buf, *dst_buf;
+   struct vb2_v4l2_buffer *dst_vb2_v4l2, *src_vb2_v4l2;
struct mtk_vcodec_mem bs_buf;
struct venc_done_result enc_result;
 
@@ -967,6 +968,15 @@ static int mtk_venc_encode_header(void *priv)
mtk_v4l2_err("venc_if_encode failed=%d", ret);
return -EINVAL;
}
+   src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
+   if (src_buf) {
+   src_vb2_v4l2 = to_vb2_v4l2_buffer(src_buf);
+   dst_vb2_v4l2 = to_vb2_v4l2_buffer(dst_buf);
+   dst_buf->timestamp = src_buf->timestamp;
+   dst_vb2_v4l2->timecode = src_vb2_v4l2->timecode;
+   } else {
+   mtk_v4l2_err("No timestamp for the header buffer.");
+   }
 
ctx->state = MTK_STATE_HEADER;
dst_buf->planes[0].bytesused = enc_result.bs_size;
@@ -1059,7 +1069,7 @@ static void mtk_venc_worker(struct work_struct *work)
struct mtk_vcodec_mem bs_buf;
struct venc_done_result enc_result;
int ret, i;
-   struct vb2_v4l2_buffer *vb2_v4l2;
+   struct vb2_v4l2_buffer *dst_vb2_v4l2, *src_vb2_v4l2;
 
/* check dst_buf, dst_buf may be removed in device_run
 * to stored encdoe header so we need check dst_buf and
@@ -1099,9 +1109,14 @@ static void mtk_venc_worker(struct work_struct *work)
ret = venc_if_encode(ctx, VENC_START_OPT_ENCODE_FRAME,
 _buf, _buf, _result);
 
-   vb2_v4l2 = container_of(dst_buf, struct vb2_v4l2_buffer, vb2_buf);
+   src_vb2_v4l2 = to_vb2_v4l2_buffer(src_buf);
+   dst_vb2_v4l2 = to_vb2_v4l2_buffer(dst_buf);
+
+   dst_buf->timestamp = src_buf->timestamp;
+   dst_vb2_v4l2->timecode = src_vb2_v4l2->timecode;
+
if (enc_result.is_key_frm)
-   vb2_v4l2->flags |= V4L2_BUF_FLAG_KEYFRAME;
+   dst_vb2_v4l2->flags |= V4L2_BUF_FLAG_KEYFRAME;
 
if (ret) {
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
-- 
1.7.9.5

--
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


[PATCH for v4.8] vcodec:mediatek: Fix visible_height larger than coded_height issue in s_fmt_out

2016-08-14 Thread Tiffany Lin
The original code add extra 32 line to visible_height.
It is incorrect, 32 line should be add to coded_height.
The purpose is that user space could calcuate real buffer size needed by using
coded_width * coded_height.
But this method will make v4l2-compliance test fail, since g_fmt != s_fmt(g_fmt)
So remove extend visible_height or coded_height, user space should just
use sizeimage to get real buffer size needed

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |   10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
index a145130..cd36c9e 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
@@ -487,7 +487,6 @@ static int vidioc_venc_s_fmt_out(struct file *file, void 
*priv,
struct mtk_q_data *q_data;
int ret, i;
struct mtk_video_fmt *fmt;
-   unsigned int pitch_w_div16;
struct v4l2_pix_format_mplane *pix_fmt_mp = >fmt.pix_mp;
 
vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
@@ -530,15 +529,6 @@ static int vidioc_venc_s_fmt_out(struct file *file, void 
*priv,
q_data->coded_width = f->fmt.pix_mp.width;
q_data->coded_height = f->fmt.pix_mp.height;
 
-   pitch_w_div16 = DIV_ROUND_UP(q_data->visible_width, 16);
-   if (pitch_w_div16 % 8 != 0) {
-   /* Adjust returned width/height, so application could correctly
-* allocate hw required memory
-*/
-   q_data->visible_height += 32;
-   vidioc_try_fmt(f, q_data->fmt);
-   }
-
q_data->field = f->fmt.pix_mp.field;
ctx->colorspace = f->fmt.pix_mp.colorspace;
ctx->ycbcr_enc = f->fmt.pix_mp.ycbcr_enc;
-- 
1.7.9.5

--
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


[PATCH for v4.8] vcodec:mediatek: Fix fops_vcodec_release flow for V4L2 Encoder

2016-08-14 Thread Tiffany Lin
This patch fix that mtk_vcodec_venc_release should be called after 
v4l2_m2m_ctx_release

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |7 ++-
 .../media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c |6 +-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
index b1f0acb..a145130 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
@@ -1354,5 +1354,10 @@ int mtk_venc_lock(struct mtk_vcodec_ctx *ctx)
 
 void mtk_vcodec_enc_release(struct mtk_vcodec_ctx *ctx)
 {
-   venc_if_deinit(ctx);
+   int ret = venc_if_deinit(ctx);
+
+   if (ret)
+   mtk_v4l2_err("venc_if_deinit failed=%d", ret);
+
+   ctx->state = MTK_STATE_FREE;
 }
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
index c7806ec..5cd2151 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
@@ -218,11 +218,15 @@ static int fops_vcodec_release(struct file *file)
mtk_v4l2_debug(1, "[%d] encoder", ctx->id);
mutex_lock(>dev_mutex);
 
+   /*
+* Call v4l2_m2m_ctx_release to make sure the worker thread is not
+* running after venc_if_deinit.
+*/
+   v4l2_m2m_ctx_release(ctx->m2m_ctx);
mtk_vcodec_enc_release(ctx);
v4l2_fh_del(>fh);
v4l2_fh_exit(>fh);
v4l2_ctrl_handler_free(>ctrl_hdl);
-   v4l2_m2m_ctx_release(ctx->m2m_ctx);
 
list_del_init(>list);
dev->num_instances--;
-- 
1.7.9.5

--
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


[PATCH for v4.8] vcodec:mediatek:code refine for v4l2 Encoder driver

2016-08-14 Thread Tiffany Lin
This patch remove unused header and define from haeder files

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |1 -
 .../media/platform/mtk-vcodec/mtk_vcodec_intr.h|1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index 94f0a42..3a8e695 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -23,7 +23,6 @@
 #include 
 #include 
 
-#include "mtk_vcodec_util.h"
 
 #define MTK_VCODEC_DRV_NAME"mtk_vcodec_drv"
 #define MTK_VCODEC_ENC_NAME"mtk-vcodec-enc"
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.h
index 33e890f..1213185 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.h
@@ -16,7 +16,6 @@
 #define _MTK_VCODEC_INTR_H_
 
 #define MTK_INST_IRQ_RECEIVED  0x1
-#define MTK_INST_WORK_THREAD_ABORT_DONE0x2
 
 struct mtk_vcodec_ctx;
 
-- 
1.7.9.5

--
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


[PATCH v6] vcodec: mediatek: Add g/s_selection support for V4L2 Encoder

2016-08-14 Thread Tiffany Lin
This patch add g/s_selection for MT8173 V4L2 Encoder.
Only output queue support g/s_selection to configure crop.
The top/left of active rectangle should always be (0,0)

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
v6:
- remove unused err variable from s_selection
v5:
- remove visible_height change to a separate patch
v4:
- do not return -ERANGE and just select a rectangle that works with the
  hardware and is closest to the requested rectangle
- refine v3 note about remove visible_height modification in s_fmt_out
v3:
- add v4l2_s_selection to check constraint flags
- remove visible_height modification in s_fmt_out, it will make v4l2-compliance
  test Cropping fail becuase visible_height larger than coded_height.
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |   66 
 1 file changed, 66 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
index 3ed3f2d..b1f0acb 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
@@ -631,6 +631,69 @@ static int vidioc_try_fmt_vid_out_mplane(struct file 
*file, void *priv,
return vidioc_try_fmt(f, fmt);
 }
 
+static int vidioc_venc_g_selection(struct file *file, void *priv,
+struct v4l2_selection *s)
+{
+   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
+   struct mtk_q_data *q_data;
+
+   if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
+   return -EINVAL;
+
+   q_data = mtk_venc_get_q_data(ctx, s->type);
+   if (!q_data)
+   return -EINVAL;
+
+   switch (s->target) {
+   case V4L2_SEL_TGT_CROP_DEFAULT:
+   case V4L2_SEL_TGT_CROP_BOUNDS:
+   s->r.top = 0;
+   s->r.left = 0;
+   s->r.width = q_data->coded_width;
+   s->r.height = q_data->coded_height;
+   break;
+   case V4L2_SEL_TGT_CROP:
+   s->r.top = 0;
+   s->r.left = 0;
+   s->r.width = q_data->visible_width;
+   s->r.height = q_data->visible_height;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
+static int vidioc_venc_s_selection(struct file *file, void *priv,
+struct v4l2_selection *s)
+{
+   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
+   struct mtk_q_data *q_data;
+
+   if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
+   return -EINVAL;
+
+   q_data = mtk_venc_get_q_data(ctx, s->type);
+   if (!q_data)
+   return -EINVAL;
+
+   switch (s->target) {
+   case V4L2_SEL_TGT_CROP:
+   /* Only support crop from (0,0) */
+   s->r.top = 0;
+   s->r.left = 0;
+   s->r.width = min(s->r.width, q_data->coded_width);
+   s->r.height = min(s->r.height, q_data->coded_height);
+   q_data->visible_width = s->r.width;
+   q_data->visible_height = s->r.height;
+   break;
+   default:
+   return -EINVAL;
+   }
+   return 0;
+}
+
 static int vidioc_venc_qbuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
 {
@@ -689,6 +752,9 @@ const struct v4l2_ioctl_ops mtk_venc_ioctl_ops = {
 
.vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
.vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf,
+
+   .vidioc_g_selection = vidioc_venc_g_selection,
+   .vidioc_s_selection = vidioc_venc_s_selection,
 };
 
 static int vb2ops_venc_queue_setup(struct vb2_queue *vq,
-- 
1.7.9.5

--
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


[PATCH] vcodec: mediatek: bug fix and code refine for mt8173 v4l2 Encoder

2016-08-12 Thread Tiffany Lin
This patch include fixs:
1. Remove unused include in mtk_vcodec_drv.h
2. Fix visible_height larger than coded_height issue in s_fmt_out
3. Add timestamp and timecode copy
4. Fix mtk_vcodec_vdec_release should be called after v4l2_m2m_ctx_release
5. Remove unused define MTK_INST_WORK_THREAD_ABORT_DONE
6. Add support V4L2_MPEG_VIDEO_H264_LEVEL_4_2
4. Refine  venc_h264_if.c and venc_vp8_if.c

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |1 -
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |   42 
 .../media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c |6 ++-
 .../media/platform/mtk-vcodec/mtk_vcodec_intr.h|1 -
 .../media/platform/mtk-vcodec/mtk_vcodec_util.c|   11 ++---
 .../media/platform/mtk-vcodec/venc/venc_h264_if.c  |   16 
 .../media/platform/mtk-vcodec/venc/venc_vp8_if.c   |   16 
 7 files changed, 52 insertions(+), 41 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index 94f0a42..3a8e695 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -23,7 +23,6 @@
 #include 
 #include 
 
-#include "mtk_vcodec_util.h"
 
 #define MTK_VCODEC_DRV_NAME"mtk_vcodec_drv"
 #define MTK_VCODEC_ENC_NAME"mtk-vcodec-enc"
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
index 0a895e0..34fd89c 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
@@ -487,7 +487,6 @@ static int vidioc_venc_s_fmt_out(struct file *file, void 
*priv,
struct mtk_q_data *q_data;
int ret, i;
struct mtk_video_fmt *fmt;
-   unsigned int pitch_w_div16;
struct v4l2_pix_format_mplane *pix_fmt_mp = >fmt.pix_mp;
 
vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
@@ -530,15 +529,6 @@ static int vidioc_venc_s_fmt_out(struct file *file, void 
*priv,
q_data->coded_width = f->fmt.pix_mp.width;
q_data->coded_height = f->fmt.pix_mp.height;
 
-   pitch_w_div16 = DIV_ROUND_UP(q_data->visible_width, 16);
-   if (pitch_w_div16 % 8 != 0) {
-   /* Adjust returned width/height, so application could correctly
-* allocate hw required memory
-*/
-   q_data->visible_height += 32;
-   vidioc_try_fmt(f, q_data->fmt);
-   }
-
q_data->field = f->fmt.pix_mp.field;
ctx->colorspace = f->fmt.pix_mp.colorspace;
ctx->ycbcr_enc = f->fmt.pix_mp.ycbcr_enc;
@@ -945,7 +935,8 @@ static int mtk_venc_encode_header(void *priv)
 {
struct mtk_vcodec_ctx *ctx = priv;
int ret;
-   struct vb2_buffer *dst_buf;
+   struct vb2_buffer *src_buf, *dst_buf;
+   struct vb2_v4l2_buffer *dst_vb2_v4l2, *src_vb2_v4l2;
struct mtk_vcodec_mem bs_buf;
struct venc_done_result enc_result;
 
@@ -978,6 +969,15 @@ static int mtk_venc_encode_header(void *priv)
mtk_v4l2_err("venc_if_encode failed=%d", ret);
return -EINVAL;
}
+   src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
+   if (src_buf) {
+   src_vb2_v4l2 = to_vb2_v4l2_buffer(src_buf);
+   dst_vb2_v4l2 = to_vb2_v4l2_buffer(dst_buf);
+   dst_buf->timestamp = src_buf->timestamp;
+   dst_vb2_v4l2->timecode = src_vb2_v4l2->timecode;
+   } else {
+   mtk_v4l2_err("No timestamp for the header buffer.");
+   }
 
ctx->state = MTK_STATE_HEADER;
dst_buf->planes[0].bytesused = enc_result.bs_size;
@@ -1070,7 +1070,7 @@ static void mtk_venc_worker(struct work_struct *work)
struct mtk_vcodec_mem bs_buf;
struct venc_done_result enc_result;
int ret, i;
-   struct vb2_v4l2_buffer *vb2_v4l2;
+   struct vb2_v4l2_buffer *dst_vb2_v4l2, *src_vb2_v4l2;
 
/* check dst_buf, dst_buf may be removed in device_run
 * to stored encdoe header so we need check dst_buf and
@@ -1110,9 +1110,14 @@ static void mtk_venc_worker(struct work_struct *work)
ret = venc_if_encode(ctx, VENC_START_OPT_ENCODE_FRAME,
 _buf, _buf, _result);
 
-   vb2_v4l2 = container_of(dst_buf, struct vb2_v4l2_buffer, vb2_buf);
+   src_vb2_v4l2 = to_vb2_v4l2_buffer(src_buf);
+   dst_vb2_v4l2 = to_vb2_v4l2_buffer(dst_buf);
+
+   dst_buf->timestamp = src_buf->timestamp;
+   dst_vb2_v4l2->timecode = src_vb2_v4l2->timecode;
+
if (enc_result.is_key_frm)
-   vb2_v4l2->flags |= V4L2_BUF_FLAG_KEYFRAME;
+   dst_vb2_v4l2->flags |= V4L2_BUF_FLAG_KEYFRAME;
 
if (ret) {

[PATCH v5] vcodec: mediatek: Add g/s_selection support for V4L2 Encoder

2016-08-12 Thread Tiffany Lin
This patch add g/s_selection for MT8173 V4L2 Encoder.
Only output queue support g/s_selection to configure crop.
The top/left of active rectangle should always be (0,0).

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
v5:
- remove visible_height change to a separate patch
v4:
- do not return -ERANGE and just select a rectangle that works with the
  hardware and is closest to the requested rectangle
- refine v3 note about remove visible_height modification in s_fmt_out
v3:
- add v4l2_s_selection to check constraint flags
- remove visible_height modification in s_fmt_out, it will make v4l2-compliance
  test Cropping fail becuase visible_height larger than coded_height.
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |   67 
 1 file changed, 67 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
index 3ed3f2d..0a895e0 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
@@ -631,6 +631,70 @@ static int vidioc_try_fmt_vid_out_mplane(struct file 
*file, void *priv,
return vidioc_try_fmt(f, fmt);
 }
 
+static int vidioc_venc_g_selection(struct file *file, void *priv,
+struct v4l2_selection *s)
+{
+   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
+   struct mtk_q_data *q_data;
+
+   if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
+   return -EINVAL;
+
+   q_data = mtk_venc_get_q_data(ctx, s->type);
+   if (!q_data)
+   return -EINVAL;
+
+   switch (s->target) {
+   case V4L2_SEL_TGT_CROP_DEFAULT:
+   case V4L2_SEL_TGT_CROP_BOUNDS:
+   s->r.top = 0;
+   s->r.left = 0;
+   s->r.width = q_data->coded_width;
+   s->r.height = q_data->coded_height;
+   break;
+   case V4L2_SEL_TGT_CROP:
+   s->r.top = 0;
+   s->r.left = 0;
+   s->r.width = q_data->visible_width;
+   s->r.height = q_data->visible_height;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
+static int vidioc_venc_s_selection(struct file *file, void *priv,
+struct v4l2_selection *s)
+{
+   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
+   struct mtk_q_data *q_data;
+   int err;
+
+   if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
+   return -EINVAL;
+
+   q_data = mtk_venc_get_q_data(ctx, s->type);
+   if (!q_data)
+   return -EINVAL;
+
+   switch (s->target) {
+   case V4L2_SEL_TGT_CROP:
+   /* Only support crop from (0,0) */
+   s->r.top = 0;
+   s->r.left = 0;
+   s->r.width = min(s->r.width, q_data->coded_width);
+   s->r.height = min(s->r.height, q_data->coded_height);
+   q_data->visible_width = s->r.width;
+   q_data->visible_height = s->r.height;
+   break;
+   default:
+   return -EINVAL;
+   }
+   return 0;
+}
+
 static int vidioc_venc_qbuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
 {
@@ -689,6 +753,9 @@ const struct v4l2_ioctl_ops mtk_venc_ioctl_ops = {
 
.vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
.vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf,
+
+   .vidioc_g_selection = vidioc_venc_g_selection,
+   .vidioc_s_selection = vidioc_venc_s_selection,
 };
 
 static int vb2ops_venc_queue_setup(struct vb2_queue *vq,
-- 
1.7.9.5

--
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 v4 9/9] arm64: dts: mediatek: Add Video Decoder for MT8173

2016-08-12 Thread Tiffany Lin
Hi Matthias,

On Thu, 2016-08-11 at 17:44 +0200, Matthias Brugger wrote:
> 
> On 10/08/16 16:48, Tiffany Lin wrote:
> > Add video decoder node for MT8173
> >
> > Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
> > ---
> >  arch/arm64/boot/dts/mediatek/mt8173.dtsi |   44 
> > ++
> >  1 file changed, 44 insertions(+)
> >
> > diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
> > b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> > index 10f638f..2872cd7 100644
> > --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> > +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> > @@ -974,6 +974,50 @@
> > #clock-cells = <1>;
> > };
> >
> > +   vcodec_dec: vcodec@1600 {
> > +   compatible = "mediatek,mt8173-vcodec-dec";
> > +   reg = <0 0x1600 0 0x100>,   /* VDEC_SYS */
> > + <0 0x1602 0 0x1000>,  /* VDEC_MISC */
> > + <0 0x16021000 0 0x800>,   /* VDEC_LD */
> > + <0 0x16021800 0 0x800>,   /* VDEC_TOP */
> > + <0 0x16022000 0 0x1000>,  /* VDEC_CM */
> > + <0 0x16023000 0 0x1000>,  /* VDEC_AD */
> > + <0 0x16024000 0 0x1000>,  /* VDEC_AV */
> > + <0 0x16025000 0 0x1000>,  /* VDEC_PP */
> > + <0 0x16026800 0 0x800>,   /* VDEC_HWD */
> > + <0 0x16027000 0 0x800>,   /* VDEC_HWQ */
> > + <0 0x16027800 0 0x800>,   /* VDEC_HWB */
> > + <0 0x16028400 0 0x400>;   /* VDEC_HWG */
> > +   interrupts = ;
> > +   mediatek,larb = <>;
> > +   iommus = < M4U_PORT_HW_VDEC_MC_EXT>,
> > +< M4U_PORT_HW_VDEC_PP_EXT>,
> > +< M4U_PORT_HW_VDEC_AVC_MV_EXT>,
> > +< M4U_PORT_HW_VDEC_PRED_RD_EXT>,
> > +< M4U_PORT_HW_VDEC_PRED_WR_EXT>,
> > +< M4U_PORT_HW_VDEC_UFO_EXT>,
> > +< M4U_PORT_HW_VDEC_VLD_EXT>,
> > +< M4U_PORT_HW_VDEC_VLD2_EXT>;
> > +   mediatek,vpu = <>;
> > +   power-domains = < MT8173_POWER_DOMAIN_VDEC>;
> > +   clocks = < CLK_APMIXED_VCODECPLL>,
> > +< CLK_TOP_UNIVPLL_D2>,
> > +< CLK_TOP_CCI400_SEL>,
> > +< CLK_TOP_VDEC_SEL>,
> > +< CLK_TOP_VCODECPLL>,
> > +< CLK_APMIXED_VENCPLL>,
> > +< CLK_TOP_VENC_LT_SEL>,
> > +< CLK_TOP_VCODECPLL_370P5>;
> > +   clock-names = "vcodecpll",
> > + "univpll_d2",
> > + "clk_cci400_sel",
> > + "vdec_sel",
> > + "vdecpll",
> > + "vencpll",
> > + "venc_lt_sel",
> > + "vdec_bus_clk_src";
> > +   };
> > +
> 
> Shouldn't we set here:
> status = "disabled";
> 
> To save power on headless systems?
> 
We only power on when there is at least one decode instance created.
In this case, do we need "status = "disabled";" here?
I see some other device nodes in dtsi do not add this.
Sorry, I am just confused when should we add status for device node.


best regards,
Tiffany

> Regards,
> Matthias
> 
> > larb1: larb@1601 {
> > compatible = "mediatek,mt8173-smi-larb";
> > reg = <0 0x1601 0 0x1000>;
> >


--
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: [PATCHv2] v4l2-common: add s_selection helper function

2016-08-09 Thread Tiffany Lin
Hi Hans,

On Fri, 2016-08-05 at 15:57 +0200, Hans Verkuil wrote:
> Hi Tiffany,
> 
> We just had a long discussion about whether or not -ERANGE should be returned
> if the constraint flags could not be satisfied, and the end result was that
> the driver should not return an error in that case, but just select a 
> rectangle
> that works with the hardware and is closest to the requested rectangle.
> 
> See the irc log for the discussion:
> 
> https://linuxtv.org/irc/irclogger_log/v4l?date=2016-08-05,Fri
> 
> This will simplify your code, and I'll drop this patch for a v4l2-common 
> helper
> function, since that is no longer relevant.
> 
> I will try to find time to fix the documentation (since that's wrong) and any
> drivers that do return ERANGE.

Got it. I will refine and send a new patch.

best regards,
Tiffany

> Regards,
> 
>   Hans


--
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 v3] vcodec: mediatek: Add g/s_selection support for V4L2 Encoder

2016-08-04 Thread Tiffany Lin
Hi Hans,

On Thu, 2016-08-04 at 15:00 +0200, Hans Verkuil wrote:
> 
> On 08/04/2016 12:08 PM, Tiffany Lin wrote:
> > This patch add g/s_selection support for MT8173 v4l2 encoder
> > 
> > Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
> > ---
> > v3:
> > - add v4l2_s_selection to check constraint flags
> > - remove visible_height modification in s_fmt_out
> 
> Is this selection-related, or is this an unrelated bug fix?
> If it is the latter, then please split it up as a separate patch.
> 
> In both cases the commit log should explain a bit more why
> this s_fmt_out change is needed.
> 
This is a bug I found when I add g_selection.
It will make visible_height out of coded_height and compliance test will
fail if not include this part of modification.

The original code here is for that user space could get buffer size HW
required by using coded_width * coded_height.
But the original code here adjust visible_height and not returned as
f->fmt.pix_mp.height, it's a bug.
But if it update coded_height here, q_data->coded_height += 32;, it will
fail in s_fmt compliance test that s_fmt(g_fmt) != g_fmt.
So I decided to drop this.
User space should use sizeimage to get buffer size HW required and
coded_width/coded_height just alignment width/height that HW required.

best regards,
Tiffany


> > ---
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |   81 
> > +---
> >  1 file changed, 71 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > index 3ed3f2d..c4b8e00 100644
> > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > @@ -487,7 +487,6 @@ static int vidioc_venc_s_fmt_out(struct file *file, 
> > void *priv,
> > struct mtk_q_data *q_data;
> > int ret, i;
> > struct mtk_video_fmt *fmt;
> > -   unsigned int pitch_w_div16;
> > struct v4l2_pix_format_mplane *pix_fmt_mp = >fmt.pix_mp;
> >  
> > vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
> > @@ -530,15 +529,6 @@ static int vidioc_venc_s_fmt_out(struct file *file, 
> > void *priv,
> > q_data->coded_width = f->fmt.pix_mp.width;
> > q_data->coded_height = f->fmt.pix_mp.height;
> >  
> > -   pitch_w_div16 = DIV_ROUND_UP(q_data->visible_width, 16);
> > -   if (pitch_w_div16 % 8 != 0) {
> > -   /* Adjust returned width/height, so application could correctly
> > -* allocate hw required memory
> > -*/
> > -   q_data->visible_height += 32;
> > -   vidioc_try_fmt(f, q_data->fmt);
> > -   }
> > -
> > q_data->field = f->fmt.pix_mp.field;
> > ctx->colorspace = f->fmt.pix_mp.colorspace;
> > ctx->ycbcr_enc = f->fmt.pix_mp.ycbcr_enc;
> > @@ -631,6 +621,74 @@ static int vidioc_try_fmt_vid_out_mplane(struct file 
> > *file, void *priv,
> > return vidioc_try_fmt(f, fmt);
> >  }
> >  
> > +static int vidioc_venc_g_selection(struct file *file, void *priv,
> > +struct v4l2_selection *s)
> > +{
> > +   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> > +   struct mtk_q_data *q_data;
> > +
> > +   if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
> > +   return -EINVAL;
> > +
> > +   q_data = mtk_venc_get_q_data(ctx, s->type);
> > +   if (!q_data)
> > +   return -EINVAL;
> > +
> > +   switch (s->target) {
> > +   case V4L2_SEL_TGT_CROP_DEFAULT:
> > +   case V4L2_SEL_TGT_CROP_BOUNDS:
> > +   s->r.top = 0;
> > +   s->r.left = 0;
> > +   s->r.width = q_data->coded_width;
> > +   s->r.height = q_data->coded_height;
> > +   break;
> > +   case V4L2_SEL_TGT_CROP:
> > +   s->r.top = 0;
> > +   s->r.left = 0;
> > +   s->r.width = q_data->visible_width;
> > +   s->r.height = q_data->visible_height;
> > +   break;
> > +   default:
> > +   return -EINVAL;
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> > +static int vidioc_venc_s_selection(struct file *file, void *priv,
> > +struct v4l2_selection *s)
> > +{
> > +   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> > +   struct mtk_q_data *q_data;
> > +   struct v4l2_rect r = s->r;
> > +   int err;
> > +
> > +   if (s->type != V

[PATCH v3] vcodec: mediatek: Add g/s_selection support for V4L2 Encoder

2016-08-04 Thread Tiffany Lin
This patch add g/s_selection support for MT8173 v4l2 encoder

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
v3:
- add v4l2_s_selection to check constraint flags
- remove visible_height modification in s_fmt_out
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |   81 +---
 1 file changed, 71 insertions(+), 10 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
index 3ed3f2d..c4b8e00 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
@@ -487,7 +487,6 @@ static int vidioc_venc_s_fmt_out(struct file *file, void 
*priv,
struct mtk_q_data *q_data;
int ret, i;
struct mtk_video_fmt *fmt;
-   unsigned int pitch_w_div16;
struct v4l2_pix_format_mplane *pix_fmt_mp = >fmt.pix_mp;
 
vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
@@ -530,15 +529,6 @@ static int vidioc_venc_s_fmt_out(struct file *file, void 
*priv,
q_data->coded_width = f->fmt.pix_mp.width;
q_data->coded_height = f->fmt.pix_mp.height;
 
-   pitch_w_div16 = DIV_ROUND_UP(q_data->visible_width, 16);
-   if (pitch_w_div16 % 8 != 0) {
-   /* Adjust returned width/height, so application could correctly
-* allocate hw required memory
-*/
-   q_data->visible_height += 32;
-   vidioc_try_fmt(f, q_data->fmt);
-   }
-
q_data->field = f->fmt.pix_mp.field;
ctx->colorspace = f->fmt.pix_mp.colorspace;
ctx->ycbcr_enc = f->fmt.pix_mp.ycbcr_enc;
@@ -631,6 +621,74 @@ static int vidioc_try_fmt_vid_out_mplane(struct file 
*file, void *priv,
return vidioc_try_fmt(f, fmt);
 }
 
+static int vidioc_venc_g_selection(struct file *file, void *priv,
+struct v4l2_selection *s)
+{
+   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
+   struct mtk_q_data *q_data;
+
+   if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
+   return -EINVAL;
+
+   q_data = mtk_venc_get_q_data(ctx, s->type);
+   if (!q_data)
+   return -EINVAL;
+
+   switch (s->target) {
+   case V4L2_SEL_TGT_CROP_DEFAULT:
+   case V4L2_SEL_TGT_CROP_BOUNDS:
+   s->r.top = 0;
+   s->r.left = 0;
+   s->r.width = q_data->coded_width;
+   s->r.height = q_data->coded_height;
+   break;
+   case V4L2_SEL_TGT_CROP:
+   s->r.top = 0;
+   s->r.left = 0;
+   s->r.width = q_data->visible_width;
+   s->r.height = q_data->visible_height;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
+static int vidioc_venc_s_selection(struct file *file, void *priv,
+struct v4l2_selection *s)
+{
+   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
+   struct mtk_q_data *q_data;
+   struct v4l2_rect r = s->r;
+   int err;
+
+   if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
+   return -EINVAL;
+
+   q_data = mtk_venc_get_q_data(ctx, s->type);
+   if (!q_data)
+   return -EINVAL;
+
+   switch (s->target) {
+   case V4L2_SEL_TGT_CROP:
+   /* Only support crop from (0,0) */
+   s->r.top = 0;
+   s->r.left = 0;
+   r.width = min(r.width, q_data->coded_width);
+   r.height = min(r.height, q_data->coded_height);
+   err = v4l2_s_selection(s, );
+   if (err)
+   return err;
+   q_data->visible_width = s->r.width;
+   q_data->visible_height = s->r.height;
+   break;
+   default:
+   return -EINVAL;
+   }
+   return 0;
+}
+
 static int vidioc_venc_qbuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
 {
@@ -689,6 +747,9 @@ const struct v4l2_ioctl_ops mtk_venc_ioctl_ops = {
 
.vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
.vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf,
+
+   .vidioc_g_selection = vidioc_venc_g_selection,
+   .vidioc_s_selection = vidioc_venc_s_selection,
 };
 
 static int vb2ops_venc_queue_setup(struct vb2_queue *vq,
-- 
1.7.9.5

--
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 v3 5/9] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-08-01 Thread Tiffany Lin
Hi Hans,

On Mon, 2016-08-01 at 12:39 +0200, Hans Verkuil wrote:
> Hi Tiffany,
> 
> On 08/01/2016 11:38 AM, Tiffany Lin wrote:
> > Hi Hans,
> 
> 
> 
> >>> +static int vidioc_vdec_g_selection(struct file *file, void *priv,
> >>> + struct v4l2_selection *s)
> >>> +{
> >>> + struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> >>> +
> >>> + if (V4L2_TYPE_IS_OUTPUT(s->type))
> >>> + return -EINVAL;
> >>> +
> >>> + if (s->target != V4L2_SEL_TGT_CROP)
> >>> + return -EINVAL;
> >>
> >> How does the cropping rectangle relate to the format size? There is no 
> >> s_selection,
> >> so this doesn't make sense.
> >>
> > I want to return encoded crop information or real display region that
> > display driver could know where is padding region.
> 
> Sorry, I don't understand this.
> 
> This is a decoder, so based on the bitstream it decodes to a certain width
> and height. I assume that is what you refer to as coded_width and 
> coded_height?
> 
> If so, then what is the 'real display region' and how does it relate to the
> coded width/height?
> 
> This is probably a terminology issue but I need to understand this before I
> can decide what should be done here.
> 
We define coded_width and coded_height as frame buffer width and height.
Coded resolution is stream resolution in pixels aligned to codec format
and hardware requirements.
And we assign bytesperline as coded_width.

g_selection is for getting visible resolution for user space.
visible resolution - stream resolution of the visible picture, in
pixels, to be used for display purposes; must be smaller or equal to
coded resolution;
visible height - height for given visible resolution
visible width - width for given visible resolution

For my understand, g_fmt should return coded width/height in
pix_mp->width, pix_mp->height.
And bytesperline is coded with.
g_selection return visible width/height.
Is this understanding correct?


best regards,
Tiffany
> Regards,
> 
>   Hans
> 
> > User space use s_fmt/g_fmt  to set/get coded_width and coded_height, and
> > use g_crop to get real display region.
> > That's why I do not add s_selection.
> > 
> >> Alternatively, it could be that you are really returning 
> >> V4L2_SEL_TGT_COMPOSE_PADDED.
> >>
> > 
> > V4L2_SEL_TGT_COMPOSE_PADDED means
> > "The active area and all padding pixels that are inserted or modified by
> > hardware."
> > But I just want to return active area to user space.
> > 
> >>> +
> >>> + if (ctx->state < MTK_STATE_HEADER)
> >>> + return -EINVAL;
> >>> +
> >>> + if ((ctx->q_data[MTK_Q_DATA_SRC].fmt->fourcc == V4L2_PIX_FMT_H264) ||
> >>> + (ctx->q_data[MTK_Q_DATA_SRC].fmt->fourcc == V4L2_PIX_FMT_VP8) ||
> >>> + (ctx->q_data[MTK_Q_DATA_SRC].fmt->fourcc == V4L2_PIX_FMT_VP9)) {
> >>> +
> >>> + if (vdec_if_get_param(ctx, GET_PARAM_CROP_INFO, &(s->r))) {
> >>> + mtk_v4l2_debug(2,
> >>> + "[%d]Error!! Cannot get param : 
> >>> GET_PARAM_CROP_INFO ERR",
> >>> + ctx->id);
> >>> + s->r.left = 0;
> >>> + s->r.top = 0;
> >>> + s->r.width = ctx->picinfo.buf_w;
> >>> + s->r.height = ctx->picinfo.buf_h;
> >>> + }
> >>> + mtk_v4l2_debug(2, "Cropping info: l=%d t=%d w=%d h=%d",
> >>> + s->r.left, s->r.top, s->r.width,
> >>> + s->r.height);
> >>> + } else {
> >>> + s->r.left = 0;
> >>> + s->r.top = 0;
> >>> + s->r.width = ctx->picinfo.pic_w;
> >>> + s->r.height = ctx->picinfo.pic_h;
> >>> + mtk_v4l2_debug(2, "Cropping info: w=%d h=%d fw=%d fh=%d",
> >>> + s->r.width, s->r.height, ctx->picinfo.buf_w,
> >>> + ctx->picinfo.buf_h);
> >>> + }
> >>> + return 0;
> >>> +}


--
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 v3 5/9] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-08-01 Thread Tiffany Lin
Hi Hans,

On Fri, 2016-07-08 at 13:06 +0200, Hans Verkuil wrote:
> On 05/30/2016 02:29 PM, Tiffany Lin wrote:
> > Add v4l2 layer decoder driver for MT8173
> > 
> > Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
> > ---
> >  drivers/media/platform/mtk-vcodec/Makefile |   10 +-
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 1348 
> > 
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h |   88 ++
> >  .../media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c |  408 ++
> >  .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c  |  206 +++
> >  .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h  |   28 +
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |   88 +-
> >  .../media/platform/mtk-vcodec/mtk_vcodec_intr.c|4 +-
> >  .../media/platform/mtk-vcodec/mtk_vcodec_intr.h|2 +-
> >  .../media/platform/mtk-vcodec/mtk_vcodec_util.c|   31 +-
> >  .../media/platform/mtk-vcodec/mtk_vcodec_util.h|7 +-
> >  drivers/media/platform/mtk-vcodec/vdec_drv_base.h  |   56 +
> >  drivers/media/platform/mtk-vcodec/vdec_drv_if.c|  107 ++
> >  drivers/media/platform/mtk-vcodec/vdec_drv_if.h|  101 ++
> >  drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h   |  103 ++
> >  15 files changed, 2569 insertions(+), 18 deletions(-)
> >  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> >  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> >  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> >  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
> >  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
> >  create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_base.h
> >  create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.c
> >  create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.h
> >  create mode 100644 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
> > 
> > diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
> > b/drivers/media/platform/mtk-vcodec/Makefile
> > index dc5cb00..4c8ed2f 100644
> > --- a/drivers/media/platform/mtk-vcodec/Makefile
> > +++ b/drivers/media/platform/mtk-vcodec/Makefile
> > @@ -1,7 +1,13 @@
> >  
> >  
> > -obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-enc.o mtk-vcodec-common.o
> > -
> > +obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-dec.o \
> > +  mtk-vcodec-enc.o \
> > +  mtk-vcodec-common.o
> > +
> > +mtk-vcodec-dec-y := mtk_vcodec_dec_drv.o \
> > +   vdec_drv_if.o \
> > +   mtk_vcodec_dec.o \
> > +   mtk_vcodec_dec_pm.o \
> >  
> >  
> >  mtk-vcodec-enc-y := venc/venc_vp8_if.o \
> > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
> > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> > new file mode 100644
> > index 000..792858a
> > --- /dev/null
> > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> > @@ -0,0 +1,1348 @@
> > +/*
> > +* Copyright (c) 2016 MediaTek Inc.
> > +* Author: PC Chen <pc.c...@mediatek.com>
> > +* Tiffany Lin <tiffany@mediatek.com>
> > +*
> > +* This program is free software; you can redistribute it and/or modify
> > +* it under the terms of the GNU General Public License version 2 as
> > +* published by the Free Software Foundation.
> > +*
> > +* This program is distributed in the hope that it will be useful,
> > +* but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > +* GNU General Public License for more details.
> > +*/
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include "mtk_vcodec_drv.h"
> > +#include "mtk_vcodec_dec.h"
> > +#include "mtk_vcodec_intr.h"
> > +#include "mtk_vcodec_util.h"
> > +#include "vdec_drv_if.h"
> > +#include "mtk_vcodec_dec_pm.h"
> > +
> > +#define OUT_FMT_IDX0
> > +#define CAP_FMT_IDX3
> > +
> > +#define MTK_VDEC_MIN_W 64U
> > +#define MTK_VDEC_MIN_H 64U
> > +#define DFT_CFG_WIDTH  MTK_VDEC_MIN_W
> > +#define DFT_CFG_HEIGHT MTK_VDEC_MIN_H
> > +
> > +static struct mtk_video_fmt mtk_video_formats[] = {
> > +   {
> > +   .fourcc = V4L2_PIX_FMT_H264,
> > +   .type = MTK_FMT_

[PATCH v2] vcodec: mediatek: Add g/s_selection support for V4L2 Encoder

2016-07-29 Thread Tiffany Lin
Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |   83 ++--
 1 file changed, 78 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
index 3ed3f2d..8f09dd3 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
@@ -487,7 +487,6 @@ static int vidioc_venc_s_fmt_out(struct file *file, void 
*priv,
struct mtk_q_data *q_data;
int ret, i;
struct mtk_video_fmt *fmt;
-   unsigned int pitch_w_div16;
struct v4l2_pix_format_mplane *pix_fmt_mp = >fmt.pix_mp;
 
vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
@@ -530,13 +529,12 @@ static int vidioc_venc_s_fmt_out(struct file *file, void 
*priv,
q_data->coded_width = f->fmt.pix_mp.width;
q_data->coded_height = f->fmt.pix_mp.height;
 
-   pitch_w_div16 = DIV_ROUND_UP(q_data->visible_width, 16);
-   if (pitch_w_div16 % 8 != 0) {
+   if (q_data->visible_width % 16) {
/* Adjust returned width/height, so application could correctly
 * allocate hw required memory
 */
-   q_data->visible_height += 32;
-   vidioc_try_fmt(f, q_data->fmt);
+   q_data->coded_height += 32;
+   f->fmt.pix_mp.height += 32;
}
 
q_data->field = f->fmt.pix_mp.field;
@@ -631,6 +629,78 @@ static int vidioc_try_fmt_vid_out_mplane(struct file 
*file, void *priv,
return vidioc_try_fmt(f, fmt);
 }
 
+static int vidioc_venc_g_selection(struct file *file, void *priv,
+struct v4l2_selection *s)
+{
+   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
+   struct mtk_q_data *q_data;
+
+   if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
+   mtk_v4l2_err("Invalid s->type = %d", s->type);
+   return -EINVAL;
+   }
+
+   q_data = mtk_venc_get_q_data(ctx, s->type);
+   if (!q_data)
+   return -EINVAL;
+
+   /* crop means compose for output devices */
+   switch (s->target) {
+   case V4L2_SEL_TGT_CROP_DEFAULT:
+   case V4L2_SEL_TGT_CROP_BOUNDS:
+   s->r.top = 0;
+   s->r.left = 0;
+   s->r.width = q_data->coded_width;
+   s->r.height = q_data->coded_height;
+   break;
+   case V4L2_SEL_TGT_CROP:
+   s->r.top = 0;
+   s->r.left = 0;
+   s->r.width = q_data->visible_width;
+   s->r.height = q_data->visible_height;
+   break;
+   default:
+   mtk_v4l2_err("Invalid s->target = %d", s->target);
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
+static int vidioc_venc_s_selection(struct file *file, void *priv,
+struct v4l2_selection *s)
+{
+   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
+   struct mtk_q_data *q_data;
+
+   if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
+   mtk_v4l2_err("Invalid s->type = %d", s->type);
+   return -EINVAL;
+   }
+
+   q_data = mtk_venc_get_q_data(ctx, s->type);
+   if (!q_data)
+   return -EINVAL;
+
+   switch (s->target) {
+   case V4L2_SEL_TGT_CROP:
+   /* Only support crop from (0,0) */
+   if ((s->r.width > q_data->coded_width) ||
+   (s->r.height > q_data->coded_height)) {
+   return -ERANGE;
+   }
+   s->r.top = 0;
+   s->r.left = 0;
+   q_data->visible_width = s->r.width;
+   q_data->visible_height = s->r.height;
+   break;
+   default:
+   mtk_v4l2_err("Invalid s->target = %d", s->target);
+   return -EINVAL;
+   }
+   return 0;
+}
+
 static int vidioc_venc_qbuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
 {
@@ -689,6 +759,9 @@ const struct v4l2_ioctl_ops mtk_venc_ioctl_ops = {
 
.vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
.vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf,
+
+   .vidioc_g_selection = vidioc_venc_g_selection,
+   .vidioc_s_selection = vidioc_venc_s_selection,
 };
 
 static int vb2ops_venc_queue_setup(struct vb2_queue *vq,
-- 
1.7.9.5

--
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 v3 0/9] Add MT8173 Video Decoder Driver

2016-07-21 Thread tiffany lin
Hi Hans,

On Fri, 2016-07-08 at 13:44 +0200, Hans Verkuil wrote:
> On 07/07/2016 12:16 PM, tiffany lin wrote:
> > Hi Hans,
> > 
> > 
> > On Wed, 2016-07-06 at 15:19 +0200, Hans Verkuil wrote:
> >> Hi Tiffany,
> >>
> >> I plan to review this patch series on Friday, but one obvious question is
> >> what the reason for these failures is:
> >>
> >>> Input/Output configuration ioctls:
> >>> test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
> >>> test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
> >>> test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
> >>> test VIDIOC_G/S_EDID: OK (Not Supported)
> >>>
> >>> Control ioctls:
> >>> test VIDIOC_QUERYCTRL/MENU: OK
> >>> fail: 
> >>> ../../../v4l-utils-1.6.0/utils/v4l2-compliance/v4l2-test-controls.cpp(357):
> >>>  g_ctrl returned an error (11)
> >>> test VIDIOC_G/S_CTRL: FAIL
> >>> fail: 
> >>> ../../../v4l-utils-1.6.0/utils/v4l2-compliance/v4l2-test-controls.cpp(579):
> >>>  g_ext_ctrls returned an error (11)
> >>> test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL
> > These fails are because VIDIOC_G_CTRL and VIDIOC_G_EXT_CTRLS return
> > V4L2_CID_MIN_BUFFERS_FOR_CAPTURE only when dirver in MTK_STATE_HEADER
> > state, or it will return EAGAIN.
> > This could help user space get correct value, not default value that may
> > changed base on media content.
> 
> OK, I really don't like this. I also looked what the s5p-mfc-dec driver does 
> (the only other
> driver currently implementing this), and that returns -EINVAL.
> 
> My proposal would be to change this. If this information isn't known yet, why 
> not
> just return 0 as the value? The doc would have to be updated and (preferably) 
> also
> the s5p-mfc-dec driver. I've added Samsung devs to the Cc list, let me know 
> what you
> think.
> 
We are ok with just return 0 as the value when header not parsed yet
We will update decoder with this solution.


> > 
> >>> fail: 
> >>> ../../../v4l-utils-1.6.0/utils/v4l2-compliance/v4l2-test-controls.cpp(721):
> >>>  subscribe event for control 'User Controls' failed
> >>> test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAIL
> > Driver do not support subscribe event for control 'User Controls' for
> > now.
> > Do we need to support this?
> 
> I don't see why this would fail. It's OK to subscribe to such controls, 
> although
> you'll never get an event.
> 
After upgrade to latest v4l-utils,this test pass.

> >>> test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
> >>> Standard Controls: 2 Private Controls: 0
> >>>
> >>> Format ioctls:
> >>> test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
> >>> test VIDIOC_G/S_PARM: OK (Not Supported)
> >>> test VIDIOC_G_FBUF: OK (Not Supported)
> >>> fail: 
> >>> ../../../v4l-utils-1.6.0/utils/v4l2-compliance/v4l2-test-formats.cpp(405):
> >>>  expected EINVAL, but got 11 when getting format for buftype 9
> >>> test VIDIOC_G_FMT: FAIL
> > This is because vidioc_vdec_g_fmt only succeed when context is in
> > MTK_STATE_HEADER state, or user space cannot get correct format data
> > using this function.
> 
> Comparing this to s5p-mfc-dec I see that -EINVAL is returned in that case.
> 
> I am not opposed to using EAGAIN in s5p-mfc-dec as well. Marek, Kamil, what is
> your opinion?
> 
> > 
> >>> test VIDIOC_TRY_FMT: OK (Not Supported)
> >>> test VIDIOC_S_FMT: OK (Not Supported)
> >>> test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
> >>>
> >>> Codec ioctls:
> >>> test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
> >>> test VIDIOC_G_ENC_INDEX: OK (Not Supported)
> >>> test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
> >>>
> >>> Buffer ioctls:
> >>> test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
> >>> fail: 
> >>> ../../../v4l-utils-1.6.0/utils/v4l2-compliance/v4l2-test-buffers.cpp(500):
> >>>  q.has_expbuf(node)
> > Our OUTPUT and CAPTURE queue support both VB2_DMABUF and VB2_MMAP, u

Re: [PATCH] vcodec: mediatek: Add g/s_selection support for V4L2 Encoder

2016-07-19 Thread tiffany lin
Hi Hans,

On Mon, 2016-07-18 at 14:44 +0200, Hans Verkuil wrote:
> On 07/18/2016 02:28 PM, tiffany lin wrote:
> > Understood now.
> > 
> > Now I am trying to figure out how to make this function right.
> > Our encoder only support crop range from (0, 0) to (width, height), so
> > if s->r.top and s->r.left not 0, I will return -EINVAL.
> > 
> > 
> > Another thing is that in v4l2-compliance test, it has testLegacyCrop.
> > It looks like we still need to support 
> >  V4L2_SEL_TGT_COMPOSE_DEFAULT:
> >  V4L2_SEL_TGT_COMPOSE_BOUNDS:
> >  V4L2_SEL_TGT_COMPOSE:
> > to pass v4l2 compliance test, Or it will fail in 
> > fail: v4l2-test-formats.cpp(1318): !doioctl(node, VIDIOC_G_SELECTION,
> > )
> > fail: v4l2-test-formats.cpp(1336): testLegacyCrop(node)
> > test Cropping: FAIL
> 
> Against which kernel are you testing? In the current media_tree master
> there is a bug in drivers/media/v4l2-core/v4l2-ioctl.c, v4l_cropcap():
> 
> This code:
> 
> if (WARN_ON(!ops->vidioc_cropcap && !ops->vidioc_cropcap))
> 
> should be:
> 
> if (WARN_ON(!ops->vidioc_cropcap && !ops->vidioc_g_selection))
> 
> The fix is waiting for a pull from Linus.
> 
> Also update to the latest v4l2-compliance: I've made some changes that
> might affect this. And I added additional checks to verify if all the
> colorspace-related format fields are properly propagated from the
> output format to the capture format.
> 

Sorry, I miss this part.
After update to latest version include this fix, it can pass crop test
without supporting COMPOSE in output queue.
Appreciated for your help

best regards,
Tiffany



> Regards,
> 
>   Hans
> 
> > 
> > I don't understand the following testing code.
> > 
> > /*
> >  * If either CROPCAP or G_CROP works, then G_SELECTION should
> >  * work as well.
> >  * If neither CROPCAP nor G_CROP work, then G_SELECTION
> > shouldn't
> >  * work either.
> >  */
> > if (!doioctl(node, VIDIOC_CROPCAP, )) {
> > fail_on_test(doioctl(node, VIDIOC_G_SELECTION, ));
> > 
> > // Checks for invalid types
> > if (cap.type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
> > cap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
> > else
> > cap.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
> > fail_on_test(doioctl(node, VIDIOC_CROPCAP, ) !=
> > EINVAL);
> > cap.type = 0xff;
> > fail_on_test(doioctl(node, VIDIOC_CROPCAP, ) !=
> > EINVAL);
> > } else {
> > fail_on_test(!doioctl(node, VIDIOC_G_SELECTION, ));
> > -> fail here
> > }
> > 
> > When test OUTPUT queue, it fail because v4l_cropcap will fail when
> > s.target = V4L2_SEL_TGT_COMPOSE_BOUNDS.
> > If VIDIOC_CROPCAP ioctl fail, VIDIOC_G_SELECTION should fail.
> > But VIDIOC_G_SELECTION target on CROP not COMPOSE and it success.
> > 
> > 
> > best regards,
> > Tiffany
> > 
> > 
> > 
> >> Regards,
> >>
> >>Hans
> >>
> >>>
> >>>
> >>> static int v4l_g_crop(const struct v4l2_ioctl_ops *ops,
> >>>   struct file *file, void *fh, void *arg)
> >>> {
> >>>   struct v4l2_crop *p = arg;
> >>>   struct v4l2_selection s = {
> >>>   .type = p->type,
> >>>   };
> >>>   int ret;
> >>>
> >>>   if (ops->vidioc_g_crop)
> >>>   return ops->vidioc_g_crop(file, fh, p);
> >>>   /* simulate capture crop using selection api */
> >>>
> >>>   /* crop means compose for output devices */
> >>>   if (V4L2_TYPE_IS_OUTPUT(p->type))
> >>>   s.target = V4L2_SEL_TGT_COMPOSE_ACTIVE;
> >>>   else
> >>>   s.target = V4L2_SEL_TGT_CROP_ACTIVE;
> >>>
> >>>   ret = ops->vidioc_g_selection(file, fh, );
> >>>
> >>>   /* copying results to old structure on success */
> >>>   if (!ret)
> >>>   p->c = s.r;
> >>>   return ret;
> >>> }
> >>>
> >>> static int v4l_s_crop(const struct v4l2_ioctl_ops *ops,
> >>>   struct file *file, void *fh, void *arg)
> >>> {
> >>>   struct v4l2_crop *p = arg;
> >>>   struct v4l2_se

Re: [PATCH] vcodec: mediatek: Add g/s_selection support for V4L2 Encoder

2016-07-18 Thread tiffany lin
On Fri, 2016-07-15 at 19:50 +0200, Hans Verkuil wrote:
> On 07/14/2016 08:27 AM, tiffany lin wrote:
> > Hi Hans,
> > 
> > 
> > On Mon, 2016-07-11 at 06:32 +0200, Hans Verkuil wrote:
> >> Hi Tiffany,
> >>
> >> My apologies for the delay, but here is my review at last:
> >>
> >> On 05/30/2016 09:52 AM, Tiffany Lin wrote:
> >>> This patch add g/s_selection support for MT8173
> >>>
> >>> Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
> >>> ---
> >>>  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |   74 
> >>> 
> >>>  1 file changed, 74 insertions(+)
> >>>
> >>> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> >>> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> >>> index 6e72d73..23ef9a1 100644
> >>> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> >>> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> >>> @@ -630,6 +630,77 @@ static int vidioc_try_fmt_vid_out_mplane(struct file 
> >>> *file, void *priv,
> >>>   return vidioc_try_fmt(f, fmt);
> >>>  }
> >>>  
> >>> +static int vidioc_venc_g_selection(struct file *file, void *priv,
> >>> +  struct v4l2_selection *s)
> >>> +{
> >>> + struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> >>> + struct mtk_q_data *q_data;
> >>> +
> >>> + /* crop means compose for output devices */
> >>> + switch (s->target) {
> >>> + case V4L2_SEL_TGT_CROP_DEFAULT:
> >>> + case V4L2_SEL_TGT_CROP_BOUNDS:
> >>> + case V4L2_SEL_TGT_CROP:
> >>> + case V4L2_SEL_TGT_COMPOSE_DEFAULT:
> >>> + case V4L2_SEL_TGT_COMPOSE_BOUNDS:
> >>> + case V4L2_SEL_TGT_COMPOSE:
> >>> + if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
> >>> + mtk_v4l2_err("Invalid s->type = %d", s->type);
> >>> + return -EINVAL;
> >>> + }
> >>> + break;
> >>> + default:
> >>> + mtk_v4l2_err("Invalid s->target = %d", s->target);
> >>> + return -EINVAL;
> >>> + }
> >>> +
> >>> + q_data = mtk_venc_get_q_data(ctx, s->type);
> >>> + if (!q_data)
> >>> + return -EINVAL;
> >>> +
> >>> + s->r.top = 0;
> >>> + s->r.left = 0;
> >>> + s->r.width = q_data->visible_width;
> >>> + s->r.height = q_data->visible_height;
> >>> +
> >>> + return 0;
> >>> +}
> >>> +
> >>> +static int vidioc_venc_s_selection(struct file *file, void *priv,
> >>> +  struct v4l2_selection *s)
> >>> +{
> >>> + struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> >>> + struct mtk_q_data *q_data;
> >>> +
> >>> + switch (s->target) {
> >>> + case V4L2_SEL_TGT_CROP_DEFAULT:
> >>> + case V4L2_SEL_TGT_CROP_BOUNDS:
> >>> + case V4L2_SEL_TGT_CROP:
> >>> + case V4L2_SEL_TGT_COMPOSE_DEFAULT:
> >>> + case V4L2_SEL_TGT_COMPOSE_BOUNDS:
> >>> + case V4L2_SEL_TGT_COMPOSE:
> >>> + if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
> >>> + mtk_v4l2_err("Invalid s->type = %d", s->type);
> >>> + return -EINVAL;
> >>> + }
> >>> + break;
> >>> + default:
> >>> + mtk_v4l2_err("Invalid s->target = %d", s->target);
> >>> + return -EINVAL;
> >>> + }
> >>> +
> >>> + q_data = mtk_venc_get_q_data(ctx, s->type);
> >>> + if (!q_data)
> >>> + return -EINVAL;
> >>> +
> >>> + s->r.top = 0;
> >>> + s->r.left = 0;
> >>> + q_data->visible_width = s->r.width;
> >>> + q_data->visible_height = s->r.height;
> >>
> >> This makes no sense.
> >>
> >> See this page:
> >>
> >> https://hverkuil.home.xs4all.nl/spec/media.html#selection-api
> >>
> >> For the video output direction (memory -> HW encoder) the data source is
> >> the memory, the data sink is the HW encoder. For the video capture 
> >> direction
> >> (HW encoder -> memory) the data sou

Re: [PATCH] [media] mtk-vcodec: fix type mismatches

2016-07-14 Thread tiffany lin
On Mon, 2016-07-11 at 23:37 +0200, Arnd Bergmann wrote:
> The newly added mtk-vcodec driver produces a number of warnings in an ARM
> allmodconfig build, mainly since it assumes that dma_addr_t is 32-bit wide:
> 
> mtk-vcodec/venc/venc_vp8_if.c: In function 'vp8_enc_alloc_work_buf':
> mtk-vcodec/venc/venc_vp8_if.c:212:191: error: cast to pointer from integer of 
> different size [-Werror=int-to-pointer-cast]
> mtk-vcodec/venc/venc_h264_if.c: In function 'h264_enc_alloc_work_buf':
> mtk-vcodec/venc/venc_h264_if.c:297:190: error: cast to pointer from integer 
> of different size [-Werror=int-to-pointer-cast]
> mtk-vcodec/mtk_vcodec_enc.c: In function 'mtk_venc_worker':
> mtk-vcodec/mtk_vcodec_enc.c:1030:46: error: format '%lx' expects argument of 
> type 'long unsigned int', but argument 7 has type 'size_t {aka unsigned int}' 
> [-Werror=format=]
>   mtk_v4l2_debug(2,
> mtk-vcodec/mtk_vcodec_enc.c:1030:46: error: format '%lx' expects argument of 
> type 'long unsigned int', but argument 10 has type 'size_t {aka unsigned 
> int}' [-Werror=format=]
> mtk-vcodec/venc_vpu_if.c: In function 'vpu_enc_ipi_handler':
> mtk-vcodec/venc_vpu_if.c:40:30: error: cast to pointer from integer of 
> different size [-Werror=int-to-pointer-cast]
>   struct venc_vpu_inst *vpu = (struct venc_vpu_inst *)msg->venc_inst;
> 
> This rearranges the format strings and type casts to what they should have 
> been
> in order to avoid the warnings.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c| 8 
>  drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c | 4 ++--
>  drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c  | 4 ++--
>  drivers/media/platform/mtk-vcodec/venc_vpu_if.c   | 4 ++--
>  4 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> index 6dcae0a0a1f2..0b25a8700877 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> @@ -1028,15 +1028,15 @@ static void mtk_venc_worker(struct work_struct *work)
>   bs_buf.size = (size_t)dst_buf->planes[0].length;
>  
>   mtk_v4l2_debug(2,
> - "Framebuf VA=%p PA=%llx Size=0x%lx;VA=%p PA=0x%llx 
> Size=0x%lx;VA=%p PA=0x%llx Size=%zu",
> + "Framebuf VA=%p PA=%pad Size=0x%zx;VA=%p PA=%pad 
> Size=0x%zx;VA=%p PA=%pad Size=0x%zx",
>   frm_buf.fb_addr[0].va,
> - (u64)frm_buf.fb_addr[0].dma_addr,
> + _buf.fb_addr[0].dma_addr,
>   frm_buf.fb_addr[0].size,
>   frm_buf.fb_addr[1].va,
> - (u64)frm_buf.fb_addr[1].dma_addr,
> + _buf.fb_addr[1].dma_addr,
>   frm_buf.fb_addr[1].size,
>   frm_buf.fb_addr[2].va,
> - (u64)frm_buf.fb_addr[2].dma_addr,
> + _buf.fb_addr[2].dma_addr,
>   frm_buf.fb_addr[2].size);

Acked-by:Tiffany Lin 


>  
>   ret = venc_if_encode(ctx, VENC_START_OPT_ENCODE_FRAME,
> diff --git a/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c 
> b/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
> index f4e18bb44cb9..9a600525b3c1 100644
> --- a/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
> +++ b/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
> @@ -295,9 +295,9 @@ static int h264_enc_alloc_work_buf(struct venc_h264_inst 
> *inst)
>   wb[i].iova = inst->work_bufs[i].dma_addr;
>  
>   mtk_vcodec_debug(inst,
> -  "work_buf[%d] va=0x%p iova=0x%p size=%zu",
> +  "work_buf[%d] va=0x%p iova=%pad size=%zu",
>i, inst->work_bufs[i].va,
> -  (void *)inst->work_bufs[i].dma_addr,
> +  >work_bufs[i].dma_addr,
>inst->work_bufs[i].size);
>   }
>  
> diff --git a/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c 
> b/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
> index 431ae706a427..5b35aa1900d7 100644
> --- a/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
> +++ b/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
> @@ -210,9 +210,9 @@ static int vp8_enc_alloc_work_buf(struct venc_vp8_inst 
> *inst)
>   wb[i].iova = inst->work_bufs[i].dma_addr;
>  
>   mtk_vcodec_debug(inst,
> -  "work_bufs[%d] va=0x%p,iova=0x%p,size=%zu",
> +  "work_bufs[%d] va=0x%p,iova=%pad,size=%zu",
>i, inst->work_bufs[i].va,
> -  (void *)inst->work_bufs[i].dma_addr,
> +  >work_bufs[i].dma_addr,
>

Re: [PATCH v3 3/9] DocBook/v4l: Add compressed video formats used on MT8173 codec driver

2016-07-14 Thread tiffany lin
Hi Nicolas,

On Wed, 2016-07-13 at 09:55 -0400, Nicolas Dufresne wrote:
> Le mercredi 13 juillet 2016 à 10:00 +0800, tiffany lin a écrit :
> > Hi Nicolas,
> > 
> > On Tue, 2016-07-12 at 15:14 -0400, Nicolas Dufresne wrote:
> > > Le mardi 12 juillet 2016 à 15:08 -0400, Nicolas Dufresne a écrit :
> > > > Le mardi 12 juillet 2016 à 16:16 +0800, Wu-Cheng Li (李務誠) a écrit
> > :
> > > > > Decoder hardware produces MT21 (compressed). Image processor
> > can
> > > > > convert it to a format that can be input of display driver.
> > > > > Tiffany.
> > > > > When do you plan to upstream image processor (mtk-mdp)?
> > > > > > 
> > > > > > It can be as input format for encoder, MDP and display
> > drivers in
> > > > > our
> > > > > > platform.
> > > > > I remember display driver can only accept uncompressed MT21.
> > Right?
> > > > > Basically V4L2_PIX_FMT_MT21 is compressed and is like an opaque
> > > > > format. It's not usable until it's decompressed and converted
> > by
> > > > > image
> > > > > processor.
> > > > 
> > > > Previously it was described as MediaTek block mode, and now as a
> > > > MediaTek compressed format. It makes me think you have no idea
> > what
> > > > this pixel format really is. Is that right ?
> > > > 
> > > > The main reason why I keep asking, is that we often find
> > similarities
> > > > between what vendor like to call their proprietary formats. Doing
> > the
> > > > proper research helps not creating a mess like in Android where
> > you
> > > > have a lot of formats that all point to the same format. I
> > believe
> > > > there was the same concern when Samsung wanted to introduce their
> > Z-
> > > > flip-Z NV12 tile format. In the end they simply provided
> > sufficient
> > > > documentation so we could document it and implement software
> > > > converters
> > > > for test and validation purpose.
> > > 
> > > Here's the kind of information we want in the documentation.
> > > 
> > > https://chromium.googlesource.com/chromium/src/media/+/master/base/
> > vide
> > > o_types.h#40
> > > 
> > >   // MediaTek proprietary format. MT21 is similar to NV21 except
> > the memory
> > >   // layout and pixel layout (swizzles). 12bpp with Y plane
> > followed by a 2x2
> > >   // interleaved VU plane. Each image contains two buffers -- Y
> > plane and VU
> > >   // plane. Two planes can be non-contiguous in memory. The
> > starting addresses
> > >   // of Y plane and VU plane are 4KB alignment.
> > >   // Suppose image dimension is (width, height). For both Y plane
> > and VU plane:
> > >   // Row pitch = ((width+15)/16) * 16.
> > >   // Plane size = Row pitch * (((height+31)/32)*32)
> > > 
> > > Now obviously this is incomplete, as the swizzling need to be
> > documented of course.
> > > 
> > Because it's finally a compressed format from our codec hw, we cannot
> > describe its swizzling.
> 
> Can you clarify why it cannot be described ? I don't buy any argument
> that it's impossible to convert without hardware. Intel did document
> their compressed formats.
> 
What's the Intel compressed formats? Could you provide link so we could
reference how they provide this information.

> Debugging an integration with such format that we have literally
> decided to no make public is a pain. A lot of decoder got abandoned or
> never used because of that.
> 
> It would be nice to explain the architecture you are suggesting to make
> this decoder useful. How will userspace application be able to use your
> decoder. Will the image processor usable outside the display path ?
> People might want to do transcoding, or other relatively common task
> that does not imply a display.
> 

In MT8173 platform, it has MDP driver, it could convert
V4L2_PIX_FMT_MT21 to V4L2_PIX_FMT_NV12M or V4L2_PIX_FMT_YUV420M.

MDP is stand alone driver, it is usable outside the display path.

NV12M/YUV420M/MT21 -> MDP -> NV12M/YUV420M

NV12M/NV21M/YUV420M/YVU420M -> mt8173 Encoder -> H264/VP8

H264/VP8/VP9 -> mtk8173 Decoder -> MT21

When encode with MT21 source, the pipeline will be:
MT21 -> MDP driver-> NV12M/NV21M/YUV420M/YVU420M -> Encoder -> H264/VP8

When playback, the pipeline will be:
H264/VP8/VP9 -> Decoder driver -> MT21 -> MDP Driver -> DRM


best regards,
Tiffany


> regards,
> Nicolas
> 
> p.s.
> A small note to Wu-Cheng, the definition of the DRM format in your
> Chromium branch is not correct. DRM uses format modifier, such that the
> format is the family, in your case it's most likely NV21, and the
> modifier is the compression or tiling algorithm in place (or both as
> needed).


--
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] vcodec: mediatek: Add g/s_selection support for V4L2 Encoder

2016-07-14 Thread tiffany lin
Hi Hans,


On Mon, 2016-07-11 at 06:32 +0200, Hans Verkuil wrote:
> Hi Tiffany,
> 
> My apologies for the delay, but here is my review at last:
> 
> On 05/30/2016 09:52 AM, Tiffany Lin wrote:
> > This patch add g/s_selection support for MT8173
> > 
> > Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
> > ---
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |   74 
> > 
> >  1 file changed, 74 insertions(+)
> > 
> > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > index 6e72d73..23ef9a1 100644
> > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > @@ -630,6 +630,77 @@ static int vidioc_try_fmt_vid_out_mplane(struct file 
> > *file, void *priv,
> > return vidioc_try_fmt(f, fmt);
> >  }
> >  
> > +static int vidioc_venc_g_selection(struct file *file, void *priv,
> > +struct v4l2_selection *s)
> > +{
> > +   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> > +   struct mtk_q_data *q_data;
> > +
> > +   /* crop means compose for output devices */
> > +   switch (s->target) {
> > +   case V4L2_SEL_TGT_CROP_DEFAULT:
> > +   case V4L2_SEL_TGT_CROP_BOUNDS:
> > +   case V4L2_SEL_TGT_CROP:
> > +   case V4L2_SEL_TGT_COMPOSE_DEFAULT:
> > +   case V4L2_SEL_TGT_COMPOSE_BOUNDS:
> > +   case V4L2_SEL_TGT_COMPOSE:
> > +   if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
> > +   mtk_v4l2_err("Invalid s->type = %d", s->type);
> > +   return -EINVAL;
> > +   }
> > +   break;
> > +   default:
> > +   mtk_v4l2_err("Invalid s->target = %d", s->target);
> > +   return -EINVAL;
> > +   }
> > +
> > +   q_data = mtk_venc_get_q_data(ctx, s->type);
> > +   if (!q_data)
> > +   return -EINVAL;
> > +
> > +   s->r.top = 0;
> > +   s->r.left = 0;
> > +   s->r.width = q_data->visible_width;
> > +   s->r.height = q_data->visible_height;
> > +
> > +   return 0;
> > +}
> > +
> > +static int vidioc_venc_s_selection(struct file *file, void *priv,
> > +struct v4l2_selection *s)
> > +{
> > +   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> > +   struct mtk_q_data *q_data;
> > +
> > +   switch (s->target) {
> > +   case V4L2_SEL_TGT_CROP_DEFAULT:
> > +   case V4L2_SEL_TGT_CROP_BOUNDS:
> > +   case V4L2_SEL_TGT_CROP:
> > +   case V4L2_SEL_TGT_COMPOSE_DEFAULT:
> > +   case V4L2_SEL_TGT_COMPOSE_BOUNDS:
> > +   case V4L2_SEL_TGT_COMPOSE:
> > +   if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
> > +   mtk_v4l2_err("Invalid s->type = %d", s->type);
> > +   return -EINVAL;
> > +   }
> > +   break;
> > +   default:
> > +   mtk_v4l2_err("Invalid s->target = %d", s->target);
> > +   return -EINVAL;
> > +   }
> > +
> > +   q_data = mtk_venc_get_q_data(ctx, s->type);
> > +   if (!q_data)
> > +   return -EINVAL;
> > +
> > +   s->r.top = 0;
> > +   s->r.left = 0;
> > +   q_data->visible_width = s->r.width;
> > +   q_data->visible_height = s->r.height;
> 
> This makes no sense.
> 
> See this page:
> 
> https://hverkuil.home.xs4all.nl/spec/media.html#selection-api
> 
> For the video output direction (memory -> HW encoder) the data source is
> the memory, the data sink is the HW encoder. For the video capture direction
> (HW encoder -> memory) the data source is the HW encoder and the data sink
> is the memory.
> 
> Usually for m2m devices the video output direction may support cropping and
> the video capture direction may support composing.
> 
> It's not clear what you intend here, especially since you set left and right
> to 0. That's not what the selection operation is supposed to do.
> 
I am confused about about g/s_selection.
If application want to configure encode area and crop meta-data, it
should set crop info to OUTPUT queue, is that right?
if user space still use g/s_crop ioctl, in 
v4l_g_crop and v4l_s_crop, it set target to V4L2_SEL_TGT_COMPOSE_ACTIVE
when buf type is V4L2_TYPE_IS_OUTPUT.

It looks like when work with g/s_crop ioctl, command set to OUTPUT
buffer will use target V4L2_SEL_TGT_COMPOSE_ACTIVE.
When work with g/s_selection ictol, command set to OUTP

Re: [PATCH] [media] mtk-vcodec: fix type mismatches

2016-07-13 Thread tiffany lin
Hi Arnd,

On Wed, 2016-07-13 at 15:08 +0200, Arnd Bergmann wrote:
> On Wednesday, July 13, 2016 5:56:26 PM CEST tiffany lin wrote:
> > > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> > > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > > index 6dcae0a0a1f2..0b25a8700877 100644
> > > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > > @@ -1028,15 +1028,15 @@ static void mtk_venc_worker(struct work_struct 
> > > *work)
> > >   bs_buf.size = (size_t)dst_buf->planes[0].length;
> > >  
> > >   mtk_v4l2_debug(2,
> > > - "Framebuf VA=%p PA=%llx Size=0x%lx;VA=%p PA=0x%llx 
> > > Size=0x%lx;VA=%p PA=0x%llx Size=%zu",
> > > + "Framebuf VA=%p PA=%pad Size=0x%zx;VA=%p PA=%pad 
> > > Size=0x%zx;VA=%p PA=%pad Size=0x%zx",
> > >   frm_buf.fb_addr[0].va,
> > > - (u64)frm_buf.fb_addr[0].dma_addr,
> > > + _buf.fb_addr[0].dma_addr,
> > >   frm_buf.fb_addr[0].size,
> > >   frm_buf.fb_addr[1].va,
> > > - (u64)frm_buf.fb_addr[1].dma_addr,
> > > + _buf.fb_addr[1].dma_addr,
> > >   frm_buf.fb_addr[1].size,
> > >   frm_buf.fb_addr[2].va,
> > > - (u64)frm_buf.fb_addr[2].dma_addr,
> > > + _buf.fb_addr[2].dma_addr,
> > >   frm_buf.fb_addr[2].size);
> > This change will make debug message dump address of dma_addr field but
> > not the value of the dma_addr we want.
> > How about change it from
> > PA=%llx -> PA=%u
> > (u64)frm_buf.fb_addr[0].dma_addr -> (u32)frm_buf.fb_addr[0].dma_addr,
> > 
> 
> The %llx works fine with the cast to u64, the change above is mainly for the 
> "%lx"
> on a size_t causing a warning.
> 
> The change to %pad is done in order to use a consistent output for the
> dma_addr_t, which had a leading "0x" in two cases but not in the first
> one.
> 
> printk interprets %pad as a pointer to a dma_addr_t and prints the
> address, not the pointer to it, see Documentation/printk-formats.txt,
> which lets you avoid the type cast as well as the 0x.
> 
I understood now, I will check Documentation/printk-formats.txt.
Thanks for your explanation.


best regards,
Tiffany

>   Arnd


--
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] mtk-vcodec: fix type mismatches

2016-07-13 Thread tiffany lin
Hi Arnd,

On Mon, 2016-07-11 at 23:37 +0200, Arnd Bergmann wrote:
> The newly added mtk-vcodec driver produces a number of warnings in an ARM
> allmodconfig build, mainly since it assumes that dma_addr_t is 32-bit wide:
> 
> mtk-vcodec/venc/venc_vp8_if.c: In function 'vp8_enc_alloc_work_buf':
> mtk-vcodec/venc/venc_vp8_if.c:212:191: error: cast to pointer from integer of 
> different size [-Werror=int-to-pointer-cast]
> mtk-vcodec/venc/venc_h264_if.c: In function 'h264_enc_alloc_work_buf':
> mtk-vcodec/venc/venc_h264_if.c:297:190: error: cast to pointer from integer 
> of different size [-Werror=int-to-pointer-cast]
> mtk-vcodec/mtk_vcodec_enc.c: In function 'mtk_venc_worker':
> mtk-vcodec/mtk_vcodec_enc.c:1030:46: error: format '%lx' expects argument of 
> type 'long unsigned int', but argument 7 has type 'size_t {aka unsigned int}' 
> [-Werror=format=]
>   mtk_v4l2_debug(2,
> mtk-vcodec/mtk_vcodec_enc.c:1030:46: error: format '%lx' expects argument of 
> type 'long unsigned int', but argument 10 has type 'size_t {aka unsigned 
> int}' [-Werror=format=]
> mtk-vcodec/venc_vpu_if.c: In function 'vpu_enc_ipi_handler':
> mtk-vcodec/venc_vpu_if.c:40:30: error: cast to pointer from integer of 
> different size [-Werror=int-to-pointer-cast]
>   struct venc_vpu_inst *vpu = (struct venc_vpu_inst *)msg->venc_inst;
> 
> This rearranges the format strings and type casts to what they should have 
> been
> in order to avoid the warnings.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c| 8 
>  drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c | 4 ++--
>  drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c  | 4 ++--
>  drivers/media/platform/mtk-vcodec/venc_vpu_if.c   | 4 ++--
>  4 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> index 6dcae0a0a1f2..0b25a8700877 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> @@ -1028,15 +1028,15 @@ static void mtk_venc_worker(struct work_struct *work)
>   bs_buf.size = (size_t)dst_buf->planes[0].length;
>  
>   mtk_v4l2_debug(2,
> - "Framebuf VA=%p PA=%llx Size=0x%lx;VA=%p PA=0x%llx 
> Size=0x%lx;VA=%p PA=0x%llx Size=%zu",
> + "Framebuf VA=%p PA=%pad Size=0x%zx;VA=%p PA=%pad 
> Size=0x%zx;VA=%p PA=%pad Size=0x%zx",
>   frm_buf.fb_addr[0].va,
> - (u64)frm_buf.fb_addr[0].dma_addr,
> + _buf.fb_addr[0].dma_addr,
>   frm_buf.fb_addr[0].size,
>   frm_buf.fb_addr[1].va,
> - (u64)frm_buf.fb_addr[1].dma_addr,
> + _buf.fb_addr[1].dma_addr,
>   frm_buf.fb_addr[1].size,
>   frm_buf.fb_addr[2].va,
> - (u64)frm_buf.fb_addr[2].dma_addr,
> + _buf.fb_addr[2].dma_addr,
>   frm_buf.fb_addr[2].size);
This change will make debug message dump address of dma_addr field but
not the value of the dma_addr we want.
How about change it from
PA=%llx -> PA=%u
(u64)frm_buf.fb_addr[0].dma_addr -> (u32)frm_buf.fb_addr[0].dma_addr,

>  
>   ret = venc_if_encode(ctx, VENC_START_OPT_ENCODE_FRAME,
> diff --git a/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c 
> b/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
> index f4e18bb44cb9..9a600525b3c1 100644
> --- a/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
> +++ b/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
> @@ -295,9 +295,9 @@ static int h264_enc_alloc_work_buf(struct venc_h264_inst 
> *inst)
>   wb[i].iova = inst->work_bufs[i].dma_addr;
>  
>   mtk_vcodec_debug(inst,
> -  "work_buf[%d] va=0x%p iova=0x%p size=%zu",
> +  "work_buf[%d] va=0x%p iova=%pad size=%zu",
>i, inst->work_bufs[i].va,
> -  (void *)inst->work_bufs[i].dma_addr,
> +  >work_bufs[i].dma_addr,
>inst->work_bufs[i].size);
>   }
>  
Same as above.

best regards,
Tiffany

> diff --git a/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c 
> b/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
> index 431ae706a427..5b35aa1900d7 100644
> --- a/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
> +++ b/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
> @@ -210,9 +210,9 @@ static int vp8_enc_alloc_work_buf(struct venc_vp8_inst 
> *inst)
>   wb[i].iova = inst->work_bufs[i].dma_addr;
>  
>   mtk_vcodec_debug(inst,
> -  "work_bufs[%d] va=0x%p,iova=0x%p,size=%zu",
> +  "work_bufs[%d] va=0x%p,iova=%pad,size=%zu",
>

[PATCH] [media] mtk-vcodec: fix default OUTPUT buffer size

2016-07-13 Thread Tiffany Lin
When calculate OUTPUT buffer size in vidioc_try_fmt, it will
add more size hw need in each plane.
But in mtk_vcodec_enc_set_default_params, it do not add
same size in each plane.
This makes v4l2-compliance test fail.
This patch fix the issue.

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |   13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
index 907a6d1..3ed3f2d 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
@@ -328,10 +328,11 @@ static int vidioc_try_fmt(struct v4l2_format *f, struct 
mtk_video_fmt *fmt)
pix_fmt_mp->height += 32;
 
mtk_v4l2_debug(0,
-   "before resize width=%d, height=%d, after resize 
width=%d, height=%d, sizeimage=%d",
+   "before resize width=%d, height=%d, after resize 
width=%d, height=%d, sizeimage=%d %d",
tmp_w, tmp_h, pix_fmt_mp->width,
pix_fmt_mp->height,
-   pix_fmt_mp->width * pix_fmt_mp->height);
+   pix_fmt_mp->plane_fmt[0].sizeimage,
+   pix_fmt_mp->plane_fmt[1].sizeimage);
 
pix_fmt_mp->num_planes = fmt->num_planes;
pix_fmt_mp->plane_fmt[0].sizeimage =
@@ -1166,9 +1167,13 @@ void mtk_vcodec_enc_set_default_params(struct 
mtk_vcodec_ctx *ctx)
(q_data->coded_height + 32) <= MTK_VENC_MAX_H)
q_data->coded_height += 32;
 
-   q_data->sizeimage[0] = q_data->coded_width * q_data->coded_height;
+   q_data->sizeimage[0] =
+   q_data->coded_width * q_data->coded_height+
+   ((ALIGN(q_data->coded_width, 16) * 2) * 16);
q_data->bytesperline[0] = q_data->coded_width;
-   q_data->sizeimage[1] = q_data->sizeimage[0] / 2;
+   q_data->sizeimage[1] =
+   (q_data->coded_width * q_data->coded_height) / 2 +
+   (ALIGN(q_data->coded_width, 16) * 16);
q_data->bytesperline[1] = q_data->coded_width;
 
q_data = >q_data[MTK_Q_DATA_DST];
-- 
1.7.9.5

--
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 v3 3/9] DocBook/v4l: Add compressed video formats used on MT8173 codec driver

2016-07-12 Thread tiffany lin
On Tue, 2016-07-12 at 16:16 +0800, Wu-Cheng Li (李務誠) wrote:
> On Mon, Jul 11, 2016 at 10:56 AM, tiffany lin <tiffany@mediatek.com> 
> wrote:
> > Hi Hans,
> >
> > On Fri, 2016-07-08 at 12:23 +0200, Hans Verkuil wrote:
> >> On 05/30/2016 02:29 PM, Tiffany Lin wrote:
> >> > Add V4L2_PIX_FMT_MT21 documentation
> >> >
> >> > Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
> >> > ---
> >> >  Documentation/DocBook/media/v4l/pixfmt.xml |6 ++
> >> >  1 file changed, 6 insertions(+)
> >> >
> >> > diff --git a/Documentation/DocBook/media/v4l/pixfmt.xml 
> >> > b/Documentation/DocBook/media/v4l/pixfmt.xml
> >> > index 5a08aee..d40e0ce 100644
> >> > --- a/Documentation/DocBook/media/v4l/pixfmt.xml
> >> > +++ b/Documentation/DocBook/media/v4l/pixfmt.xml
> >> > @@ -1980,6 +1980,12 @@ array. Anything what's in between the UYVY lines 
> >> > is JPEG data and should be
> >> >  concatenated to form the JPEG stream. 
> >> >  
> >> >   
> >> > + 
> >> > +   V4L2_PIX_FMT_MT21
> >> > +   'MT21'
> >> > +   Compressed two-planar YVU420 format used by Mediatek 
> >> > MT8173
> >> > +   codec driver.
> >>
> >> Can you give a few more details? The encoder driver doesn't seem to 
> >> produce this
> >> format, so who is creating this? Where is this format documented?
> Decoder hardware produces MT21 (compressed). Image processor can
> convert it to a format that can be input of display driver. Tiffany.
> When do you plan to upstream image processor (mtk-mdp)?
> >
We are working on this. Will upstream soon.

> > It can be as input format for encoder, MDP and display drivers in our
> > platform.
> I remember display driver can only accept uncompressed MT21. Right?
> Basically V4L2_PIX_FMT_MT21 is compressed and is like an opaque
> format. It's not usable until it's decompressed and converted by image
> processor.
That's right in MT8173 platform.

best regards,
Tiffany
> > This private format is only available in our platform.
> > So I put it in "Reserved Format Identifiers" sections.
> >
> >
> > best regards,
> > Tiffany
> >
> >> Regards,
> >>
> >>   Hans
> >>
> >> > + 
> >> > 
> >> >
> >> >  
> >> >
> >
> >
> > --
> > 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


--
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 v3 3/9] DocBook/v4l: Add compressed video formats used on MT8173 codec driver

2016-07-12 Thread tiffany lin
Hi Nicolas,

On Tue, 2016-07-12 at 15:14 -0400, Nicolas Dufresne wrote:
> Le mardi 12 juillet 2016 à 15:08 -0400, Nicolas Dufresne a écrit :
> > Le mardi 12 juillet 2016 à 16:16 +0800, Wu-Cheng Li (李務誠) a écrit :
> > > Decoder hardware produces MT21 (compressed). Image processor can
> > > convert it to a format that can be input of display driver.
> > > Tiffany.
> > > When do you plan to upstream image processor (mtk-mdp)?
> > > > 
> > > > It can be as input format for encoder, MDP and display drivers in
> > > our
> > > > platform.
> > > I remember display driver can only accept uncompressed MT21. Right?
> > > Basically V4L2_PIX_FMT_MT21 is compressed and is like an opaque
> > > format. It's not usable until it's decompressed and converted by
> > > image
> > > processor.
> > 
> > Previously it was described as MediaTek block mode, and now as a
> > MediaTek compressed format. It makes me think you have no idea what
> > this pixel format really is. Is that right ?
> > 
> > The main reason why I keep asking, is that we often find similarities
> > between what vendor like to call their proprietary formats. Doing the
> > proper research helps not creating a mess like in Android where you
> > have a lot of formats that all point to the same format. I believe
> > there was the same concern when Samsung wanted to introduce their Z-
> > flip-Z NV12 tile format. In the end they simply provided sufficient
> > documentation so we could document it and implement software
> > converters
> > for test and validation purpose.
> 
> Here's the kind of information we want in the documentation.
> 
> https://chromium.googlesource.com/chromium/src/media/+/master/base/vide
> o_types.h#40
> 
>   // MediaTek proprietary format. MT21 is similar to NV21 except the memory
>   // layout and pixel layout (swizzles). 12bpp with Y plane followed by a 2x2
>   // interleaved VU plane. Each image contains two buffers -- Y plane and VU
>   // plane. Two planes can be non-contiguous in memory. The starting addresses
>   // of Y plane and VU plane are 4KB alignment.
>   // Suppose image dimension is (width, height). For both Y plane and VU 
> plane:
>   // Row pitch = ((width+15)/16) * 16.
>   // Plane size = Row pitch * (((height+31)/32)*32)
> 
> Now obviously this is incomplete, as the swizzling need to be documented of 
> course.
> 
Because it's finally a compressed format from our codec hw, we cannot
describe its swizzling.

best regards,
Tiffany

> > 
> > regards,
> > Nicolas


--
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 v3 3/9] DocBook/v4l: Add compressed video formats used on MT8173 codec driver

2016-07-12 Thread tiffany lin
Hi Nicolas,

On Tue, 2016-07-12 at 15:08 -0400, Nicolas Dufresne wrote:
> Le mardi 12 juillet 2016 à 16:16 +0800, Wu-Cheng Li (李務誠) a écrit :
> > Decoder hardware produces MT21 (compressed). Image processor can
> > convert it to a format that can be input of display driver. Tiffany.
> > When do you plan to upstream image processor (mtk-mdp)?
> > >
> > > It can be as input format for encoder, MDP and display drivers in
> > our
> > > platform.
> > I remember display driver can only accept uncompressed MT21. Right?
> > Basically V4L2_PIX_FMT_MT21 is compressed and is like an opaque
> > format. It's not usable until it's decompressed and converted by
> > image
> > processor.
> 
> Previously it was described as MediaTek block mode, and now as a
> MediaTek compressed format. It makes me think you have no idea what
> this pixel format really is. Is that right ?
> 
That's not right.
Its a compressed format as I document in "[PATCH v3 3/9] DocBook/v4l:
Add compressed video formats used on MT8173 codec driver."
In MT8173 platform, when using this format, we need Image Processor to
cover it to standard format as wucheng mentioned.
To prevent this ambiguous, I will change it to V4L2_PIX_FMT_M21C, it
means its compressed data. Is it ok?

best regards,
Tiffany

> The main reason why I keep asking, is that we often find similarities
> between what vendor like to call their proprietary formats. Doing the
> proper research helps not creating a mess like in Android where you
> have a lot of formats that all point to the same format. I believe
> there was the same concern when Samsung wanted to introduce their Z-
> flip-Z NV12 tile format. In the end they simply provided sufficient
> documentation so we could document it and implement software converters
> for test and validation purpose.
> 
> regards,
> Nicolas


--
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 -next] [media] mtk-vcodec: remove redundant dev_err call in mtk_vcodec_probe()

2016-07-12 Thread tiffany lin
Reviewed-by: Tiffany Lin <tiffany@mediatek.com>

On Tue, 2016-07-12 at 11:02 +, weiyj...@163.com wrote:
> From: Wei Yongjun <yongjun_...@trendmicro.com.cn>
> 
> There is a error message within devm_ioremap_resource
> already, so remove the dev_err call to avoid redundant
> error message.
> 
> Signed-off-by: Wei Yongjun <yongjun_...@trendmicro.com.cn>
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> index 9c10cc2..b33a931 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> @@ -279,8 +279,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
>   }
>   dev->reg_base[i] = devm_ioremap_resource(>dev, res);
>   if (IS_ERR((__force void *)dev->reg_base[i])) {
> - dev_err(>dev,
> - "devm_ioremap_resource %d failed.", i);
>   ret = PTR_ERR((__force void *)dev->reg_base[i]);
>   goto err_res;
>   }
> 
> 


--
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 -next] [media] vcodec: mediatek: Fix return value check in mtk_vcodec_init_enc_pm()

2016-07-12 Thread tiffany lin
Reviewed-by:Tiffany Lin 

On Tue, 2016-07-12 at 11:02 +, weiyj...@163.com wrote:
> From: Wei Yongjun 
> 
> In case of error, the function devm_clk_get() returns ERR_PTR()
> and not returns NULL. The NULL test in the return value check
> should be replaced with IS_ERR().
> 
> Signed-off-by: Wei Yongjun 
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
> index 2379e97..3e73e9d 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
> @@ -67,27 +67,27 @@ int mtk_vcodec_init_enc_pm(struct mtk_vcodec_dev *mtkdev)
>   pm->dev = >dev;
>  
>   pm->vencpll_d2 = devm_clk_get(>dev, "venc_sel_src");
> - if (pm->vencpll_d2 == NULL) {
> + if (IS_ERR(pm->vencpll_d2)) {
>   mtk_v4l2_err("devm_clk_get vencpll_d2 fail");
> - ret = -1;
> + ret = PTR_ERR(pm->vencpll_d2);
>   }
>  
>   pm->venc_sel = devm_clk_get(>dev, "venc_sel");
> - if (pm->venc_sel == NULL) {
> + if (IS_ERR(pm->venc_sel)) {
>   mtk_v4l2_err("devm_clk_get venc_sel fail");
> - ret = -1;
> + ret = PTR_ERR(pm->venc_sel);
>   }
>  
>   pm->univpll1_d2 = devm_clk_get(>dev, "venc_lt_sel_src");
> - if (pm->univpll1_d2 == NULL) {
> + if (IS_ERR(pm->univpll1_d2)) {
>   mtk_v4l2_err("devm_clk_get univpll1_d2 fail");
> - ret = -1;
> + ret = PTR_ERR(pm->univpll1_d2);
>   }
>  
>   pm->venc_lt_sel = devm_clk_get(>dev, "venc_lt_sel");
> - if (pm->venc_lt_sel == NULL) {
> + if (IS_ERR(pm->venc_lt_sel)) {
>   mtk_v4l2_err("devm_clk_get venc_lt_sel fail");
> - ret = -1;
> + ret = PTR_ERR(pm->venc_lt_sel);
>   }
>  
>   return ret;
> 
> 


--
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] vcodec: mediatek: Add g/s_selection support for V4L2 Encoder

2016-07-11 Thread tiffany lin
Hi Hans,

On Mon, 2016-07-11 at 06:32 +0200, Hans Verkuil wrote:
> Hi Tiffany,
> 
> My apologies for the delay, but here is my review at last:
> 
> On 05/30/2016 09:52 AM, Tiffany Lin wrote:
> > This patch add g/s_selection support for MT8173
> > 
> > Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
> > ---
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |   74 
> > 
> >  1 file changed, 74 insertions(+)
> > 
> > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > index 6e72d73..23ef9a1 100644
> > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > @@ -630,6 +630,77 @@ static int vidioc_try_fmt_vid_out_mplane(struct file 
> > *file, void *priv,
> > return vidioc_try_fmt(f, fmt);
> >  }
> >  
> > +static int vidioc_venc_g_selection(struct file *file, void *priv,
> > +struct v4l2_selection *s)
> > +{
> > +   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> > +   struct mtk_q_data *q_data;
> > +
> > +   /* crop means compose for output devices */
> > +   switch (s->target) {
> > +   case V4L2_SEL_TGT_CROP_DEFAULT:
> > +   case V4L2_SEL_TGT_CROP_BOUNDS:
> > +   case V4L2_SEL_TGT_CROP:
> > +   case V4L2_SEL_TGT_COMPOSE_DEFAULT:
> > +   case V4L2_SEL_TGT_COMPOSE_BOUNDS:
> > +   case V4L2_SEL_TGT_COMPOSE:
> > +   if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
> > +   mtk_v4l2_err("Invalid s->type = %d", s->type);
> > +   return -EINVAL;
> > +   }
> > +   break;
> > +   default:
> > +   mtk_v4l2_err("Invalid s->target = %d", s->target);
> > +   return -EINVAL;
> > +   }
> > +
> > +   q_data = mtk_venc_get_q_data(ctx, s->type);
> > +   if (!q_data)
> > +   return -EINVAL;
> > +
> > +   s->r.top = 0;
> > +   s->r.left = 0;
> > +   s->r.width = q_data->visible_width;
> > +   s->r.height = q_data->visible_height;
> > +
> > +   return 0;
> > +}
> > +
> > +static int vidioc_venc_s_selection(struct file *file, void *priv,
> > +struct v4l2_selection *s)
> > +{
> > +   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> > +   struct mtk_q_data *q_data;
> > +
> > +   switch (s->target) {
> > +   case V4L2_SEL_TGT_CROP_DEFAULT:
> > +   case V4L2_SEL_TGT_CROP_BOUNDS:
> > +   case V4L2_SEL_TGT_CROP:
> > +   case V4L2_SEL_TGT_COMPOSE_DEFAULT:
> > +   case V4L2_SEL_TGT_COMPOSE_BOUNDS:
> > +   case V4L2_SEL_TGT_COMPOSE:
> > +   if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
> > +   mtk_v4l2_err("Invalid s->type = %d", s->type);
> > +   return -EINVAL;
> > +   }
> > +   break;
> > +   default:
> > +   mtk_v4l2_err("Invalid s->target = %d", s->target);
> > +   return -EINVAL;
> > +   }
> > +
> > +   q_data = mtk_venc_get_q_data(ctx, s->type);
> > +   if (!q_data)
> > +   return -EINVAL;
> > +
> > +   s->r.top = 0;
> > +   s->r.left = 0;
> > +   q_data->visible_width = s->r.width;
> > +   q_data->visible_height = s->r.height;
> 
> This makes no sense.
> 
> See this page:
> 
> https://hverkuil.home.xs4all.nl/spec/media.html#selection-api
> 
> For the video output direction (memory -> HW encoder) the data source is
> the memory, the data sink is the HW encoder. For the video capture direction
> (HW encoder -> memory) the data source is the HW encoder and the data sink
> is the memory.
> 
> Usually for m2m devices the video output direction may support cropping and
> the video capture direction may support composing.
> 
> It's not clear what you intend here, especially since you set left and right
> to 0. That's not what the selection operation is supposed to do.
> 

We only support simple crop, but as you mentioned we need to use
g/s_selection not g/s_crop.
This provide our user space application could get/set encode region to
driver and encode region should always start from (0,0) to (width,
height).
That's why we always set top and left to 0.


best regards,
Tiffany

> Regards,
> 
>   Hans
> 
> > +
> > +   return 0;
> > +}
> > +
> >  static int vidioc_venc_qbuf(struct file *file, void *priv,
> > struct v4l2_buffer *buf)
> >  {
> > @@ -688,6 +759,9 @@ const struct v4l2_ioctl_ops mtk_venc_ioctl_ops = {
> >  
> > .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
> > .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf,
> > +
> > +   .vidioc_g_selection = vidioc_venc_g_selection,
> > +   .vidioc_s_selection = vidioc_venc_s_selection,
> >  };
> >  
> >  static int vb2ops_venc_queue_setup(struct vb2_queue *vq,
> > 


--
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 v3 0/9] Add MT8173 Video Decoder Driver

2016-07-10 Thread tiffany lin
Hi Hans,

On Fri, 2016-07-08 at 13:44 +0200, Hans Verkuil wrote:
> On 07/07/2016 12:16 PM, tiffany lin wrote:
> > Hi Hans,
> > 
> > 
> > On Wed, 2016-07-06 at 15:19 +0200, Hans Verkuil wrote:
> >> Hi Tiffany,
> >>
> >> I plan to review this patch series on Friday, but one obvious question is
> >> what the reason for these failures is:
> >>
> >>> Input/Output configuration ioctls:
> >>> test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
> >>> test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
> >>> test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
> >>> test VIDIOC_G/S_EDID: OK (Not Supported)
> >>>
> >>> Control ioctls:
> >>> test VIDIOC_QUERYCTRL/MENU: OK
> >>> fail: 
> >>> ../../../v4l-utils-1.6.0/utils/v4l2-compliance/v4l2-test-controls.cpp(357):
> >>>  g_ctrl returned an error (11)
> >>> test VIDIOC_G/S_CTRL: FAIL
> >>> fail: 
> >>> ../../../v4l-utils-1.6.0/utils/v4l2-compliance/v4l2-test-controls.cpp(579):
> >>>  g_ext_ctrls returned an error (11)
> >>> test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL
> > These fails are because VIDIOC_G_CTRL and VIDIOC_G_EXT_CTRLS return
> > V4L2_CID_MIN_BUFFERS_FOR_CAPTURE only when dirver in MTK_STATE_HEADER
> > state, or it will return EAGAIN.
> > This could help user space get correct value, not default value that may
> > changed base on media content.
> 
> OK, I really don't like this. I also looked what the s5p-mfc-dec driver does 
> (the only other
> driver currently implementing this), and that returns -EINVAL.
> 
> My proposal would be to change this. If this information isn't known yet, why 
> not
> just return 0 as the value? The doc would have to be updated and (preferably) 
> also
> the s5p-mfc-dec driver. I've added Samsung devs to the Cc list, let me know 
> what you
> think.
> 
Got it. We will return 0 as the value instead EAGAIN.

> > 
> >>> fail: 
> >>> ../../../v4l-utils-1.6.0/utils/v4l2-compliance/v4l2-test-controls.cpp(721):
> >>>  subscribe event for control 'User Controls' failed
> >>> test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAIL
> > Driver do not support subscribe event for control 'User Controls' for
> > now.
> > Do we need to support this?
> 
> I don't see why this would fail. It's OK to subscribe to such controls, 
> although
> you'll never get an event.
> 
Got it. I will rerun using latest v4l2-compliance test check this.

> >>> test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
> >>> Standard Controls: 2 Private Controls: 0
> >>>
> >>> Format ioctls:
> >>> test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
> >>> test VIDIOC_G/S_PARM: OK (Not Supported)
> >>> test VIDIOC_G_FBUF: OK (Not Supported)
> >>> fail: 
> >>> ../../../v4l-utils-1.6.0/utils/v4l2-compliance/v4l2-test-formats.cpp(405):
> >>>  expected EINVAL, but got 11 when getting format for buftype 9
> >>> test VIDIOC_G_FMT: FAIL
> > This is because vidioc_vdec_g_fmt only succeed when context is in
> > MTK_STATE_HEADER state, or user space cannot get correct format data
> > using this function.
> 
> Comparing this to s5p-mfc-dec I see that -EINVAL is returned in that case.
> 
> I am not opposed to using EAGAIN in s5p-mfc-dec as well. Marek, Kamil, what is
> your opinion?
> 
> > 
> >>> test VIDIOC_TRY_FMT: OK (Not Supported)
> >>> test VIDIOC_S_FMT: OK (Not Supported)
> >>> test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
> >>>
> >>> Codec ioctls:
> >>> test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
> >>> test VIDIOC_G_ENC_INDEX: OK (Not Supported)
> >>> test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
> >>>
> >>> Buffer ioctls:
> >>> test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
> >>> fail: 
> >>> ../../../v4l-utils-1.6.0/utils/v4l2-compliance/v4l2-test-buffers.cpp(500):
> >>>  q.has_expbuf(node)
> > Our OUTPUT and CAPTURE queue support both VB2_DMABUF and VB2_MMAP, user
> > space can select which to use in runtime.
>

Re: [PATCH 1/2] mtk-vcodec: convert driver to use the new vb2_queue dev field

2016-07-10 Thread tiffany lin

reviewed-by: Tiffany Lin <tiffany@mediatek.com>


May I know why and how we use struct device *alloc_devs[] in queue_setup
callback function?


best regards,
Tiffany

On Fri, 2016-07-08 at 21:11 +0200, Hans Verkuil wrote:
> From: Hans Verkuil <hans.verk...@cisco.com>
> 
> The patch dropping the vb2_dma_contig_init_ctx() and _cleanup_ctx()
> functions was already applied before this driver was added. So convert
> this driver as well.
> 
> Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |  3 ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 13 ++---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c | 12 
>  3 files changed, 6 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> index 78eee50..94f0a42 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> @@ -265,8 +265,6 @@ struct mtk_vcodec_ctx {
>   * @m2m_dev_enc: m2m device for encoder.
>   * @plat_dev: platform device
>   * @vpu_plat_dev: mtk vpu platform device
> - * @alloc_ctx: VB2 allocator context
> - *  (for allocations without kernel mapping).
>   * @ctx_list: list of struct mtk_vcodec_ctx
>   * @irqlock: protect data access by irq handler and work thread
>   * @curr_ctx: The context that is waiting for codec hardware
> @@ -299,7 +297,6 @@ struct mtk_vcodec_dev {
>   struct v4l2_m2m_dev *m2m_dev_enc;
>   struct platform_device *plat_dev;
>   struct platform_device *vpu_plat_dev;
> - struct vb2_alloc_ctx *alloc_ctx;
>   struct list_head ctx_list;
>   spinlock_t irqlock;
>   struct mtk_vcodec_ctx *curr_ctx;
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> index 6e72d73..6dcae0a 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> @@ -693,7 +693,8 @@ const struct v4l2_ioctl_ops mtk_venc_ioctl_ops = {
>  static int vb2ops_venc_queue_setup(struct vb2_queue *vq,
>  unsigned int *nbuffers,
>  unsigned int *nplanes,
> -unsigned int sizes[], void *alloc_ctxs[])
> +unsigned int sizes[],
> +struct device *alloc_devs[])
>  {
>   struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(vq);
>   struct mtk_q_data *q_data;
> @@ -705,17 +706,13 @@ static int vb2ops_venc_queue_setup(struct vb2_queue *vq,
>   return -EINVAL;
>  
>   if (*nplanes) {
> - for (i = 0; i < *nplanes; i++) {
> + for (i = 0; i < *nplanes; i++)
>   if (sizes[i] < q_data->sizeimage[i])
>   return -EINVAL;
> - alloc_ctxs[i] = ctx->dev->alloc_ctx;
> - }
>   } else {
>   *nplanes = q_data->fmt->num_planes;
> - for (i = 0; i < *nplanes; i++) {
> + for (i = 0; i < *nplanes; i++)
>   sizes[i] = q_data->sizeimage[i];
> - alloc_ctxs[i] = ctx->dev->alloc_ctx;
> - }
>   }
>  
>   return 0;
> @@ -1249,6 +1246,7 @@ int mtk_vcodec_enc_queue_init(void *priv, struct 
> vb2_queue *src_vq,
>   src_vq->mem_ops = _dma_contig_memops;
>   src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
>   src_vq->lock= >dev->dev_mutex;
> + src_vq->dev = >dev->plat_dev->dev;
>  
>   ret = vb2_queue_init(src_vq);
>   if (ret)
> @@ -1262,6 +1260,7 @@ int mtk_vcodec_enc_queue_init(void *priv, struct 
> vb2_queue *src_vq,
>   dst_vq->mem_ops = _dma_contig_memops;
>   dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
>   dst_vq->lock= >dev->dev_mutex;
> + dst_vq->dev = >dev->plat_dev->dev;
>  
>   return vb2_queue_init(dst_vq);
>  }
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> index 06105e9..9c10cc2 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> @@ -357,14 +357,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
>   dev->vfd_enc = vfd_enc;
>   platform_set_drvdata(pdev, dev);
>  
&g

Re: [PATCH 2/2] drivers/media/platform/Kconfig: fix VIDEO_MEDIATEK_VCODEC dependency

2016-07-10 Thread tiffany lin
On Fri, 2016-07-08 at 21:11 +0200, Hans Verkuil wrote:
> From: Hans Verkuil <hans.verk...@cisco.com>
> 
> Allow VIDEO_MEDIATEK_VCODEC to build when COMPILE_TEST is set (even
> without MTK_IOMMU).
> 
> Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
> ---
>  drivers/media/platform/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
> index 3231b25..2c2670c 100644
> --- a/drivers/media/platform/Kconfig
> +++ b/drivers/media/platform/Kconfig
> @@ -168,7 +168,7 @@ config VIDEO_MEDIATEK_VPU
>  
>  config VIDEO_MEDIATEK_VCODEC
>   tristate "Mediatek Video Codec driver"
> - depends on MTK_IOMMU
> + depends on MTK_IOMMU || COMPILE_TEST
>   depends on VIDEO_DEV && VIDEO_V4L2
>   depends on ARCH_MEDIATEK || COMPILE_TEST
>   select VIDEOBUF2_DMA_CONTIG

reviewed-by: Tiffany Lin <tiffany@mediatek.com>


--
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 1/2] mtk-vcodec: fix two compiler warnings

2016-07-10 Thread tiffany lin
On Sat, 2016-07-09 at 09:32 +0200, Hans Verkuil wrote:
> From: Hans Verkuil <hans.verk...@cisco.com>
> 
> mtk-vcodec/mtk_vcodec_enc.c: In function 'mtk_venc_worker':
> mtk-vcodec/mtk_vcodec_enc.c:1030:43: warning: format '%lx' expects argument 
> of type 'long unsigned int', but argument 7 has type 'size_t {aka unsigned 
> int}' [-Wformat=]
> mtk-vcodec/mtk_vcodec_enc.c:1030:43: warning: format '%lx' expects argument 
> of type 'long unsigned int', but argument 10 has type 'size_t {aka unsigned 
> int}' [-Wformat=]
> 
> Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> index 6dcae0a..907a6d1 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> @@ -1028,7 +1028,7 @@ static void mtk_venc_worker(struct work_struct *work)
>   bs_buf.size = (size_t)dst_buf->planes[0].length;
>  
>   mtk_v4l2_debug(2,
> - "Framebuf VA=%p PA=%llx Size=0x%lx;VA=%p PA=0x%llx 
> Size=0x%lx;VA=%p PA=0x%llx Size=%zu",
> + "Framebuf VA=%p PA=%llx Size=0x%zx;VA=%p PA=0x%llx 
> Size=0x%zx;VA=%p PA=0x%llx Size=%zu",
>   frm_buf.fb_addr[0].va,
>       (u64)frm_buf.fb_addr[0].dma_addr,
>   frm_buf.fb_addr[0].size,

reviewed-by: Tiffany Lin <tiffany@mediatek.com>

--
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 2/2] mtk-vcodec: fix compiler warning

2016-07-10 Thread tiffany lin
On Sat, 2016-07-09 at 09:32 +0200, Hans Verkuil wrote:
> From: Hans Verkuil <hans.verk...@cisco.com>
> 
> mtk-vcodec/venc_vpu_if.c:40:30: warning: cast to pointer from integer of 
> different size [-Wint-to-pointer-cast]
>   struct venc_vpu_inst *vpu = (struct venc_vpu_inst *)msg->venc_inst;
>   ^
> 
> Note: venc_inst is u64.
> 
> Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
> ---
>  drivers/media/platform/mtk-vcodec/venc_vpu_if.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/venc_vpu_if.c 
> b/drivers/media/platform/mtk-vcodec/venc_vpu_if.c
> index b92c6d2..a01c759 100644
> --- a/drivers/media/platform/mtk-vcodec/venc_vpu_if.c
> +++ b/drivers/media/platform/mtk-vcodec/venc_vpu_if.c
> @@ -37,7 +37,8 @@ static void handle_enc_encode_msg(struct venc_vpu_inst 
> *vpu, void *data)
>  static void vpu_enc_ipi_handler(void *data, unsigned int len, void *priv)
>  {
>   struct venc_vpu_ipi_msg_common *msg = data;
> - struct venc_vpu_inst *vpu = (struct venc_vpu_inst *)msg->venc_inst;
> + struct venc_vpu_inst *vpu =
> + (struct venc_vpu_inst *)(unsigned long)msg->venc_inst;
>  
reviewed-by: Tiffany Lin <tiffany@mediatek.com>

>   mtk_vcodec_debug(vpu, "msg_id %x inst %p status %d",
>msg->msg_id, vpu, msg->status);


--
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 v3 3/9] DocBook/v4l: Add compressed video formats used on MT8173 codec driver

2016-07-10 Thread tiffany lin
Hi Hans,

On Fri, 2016-07-08 at 12:23 +0200, Hans Verkuil wrote:
> On 05/30/2016 02:29 PM, Tiffany Lin wrote:
> > Add V4L2_PIX_FMT_MT21 documentation
> > 
> > Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
> > ---
> >  Documentation/DocBook/media/v4l/pixfmt.xml |6 ++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/Documentation/DocBook/media/v4l/pixfmt.xml 
> > b/Documentation/DocBook/media/v4l/pixfmt.xml
> > index 5a08aee..d40e0ce 100644
> > --- a/Documentation/DocBook/media/v4l/pixfmt.xml
> > +++ b/Documentation/DocBook/media/v4l/pixfmt.xml
> > @@ -1980,6 +1980,12 @@ array. Anything what's in between the UYVY lines is 
> > JPEG data and should be
> >  concatenated to form the JPEG stream. 
> >  
> >   
> > + 
> > +   V4L2_PIX_FMT_MT21
> > +   'MT21'
> > +   Compressed two-planar YVU420 format used by Mediatek MT8173
> > +   codec driver.
> 
> Can you give a few more details? The encoder driver doesn't seem to produce 
> this
> format, so who is creating this? Where is this format documented?
> 

It can be as input format for encoder, MDP and display drivers in our
platform.
This private format is only available in our platform.
So I put it in "Reserved Format Identifiers" sections.


best regards,
Tiffany

> Regards,
> 
>   Hans
> 
> > + 
> > 
> >
> >  
> > 


--
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 v2 2/9] [media] : v4l: add Mediatek compressed video block format

2016-07-10 Thread tiffany lin
Hi Hans,

On Fri, 2016-07-08 at 12:18 +0200, Hans Verkuil wrote:
> On 05/12/2016 01:24 PM, Tiffany Lin wrote:
> > Add V4L2_PIX_FMT_MT21 format used on MT8173 driver.
> > It is compressed format and need MT8173 MDP driver to transfer to other 
> > standard format.
> > 
> > Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
> > ---
> >  include/uapi/linux/videodev2.h |1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
> > index 8f95191..52feea6 100644
> > --- a/include/uapi/linux/videodev2.h
> > +++ b/include/uapi/linux/videodev2.h
> > @@ -625,6 +625,7 @@ struct v4l2_pix_format {
> >  #define V4L2_PIX_FMT_Y8I  v4l2_fourcc('Y', '8', 'I', ' ') /* Greyscale 
> > 8-bit L/R interleaved */
> >  #define V4L2_PIX_FMT_Y12I v4l2_fourcc('Y', '1', '2', 'I') /* Greyscale 
> > 12-bit L/R interleaved */
> >  #define V4L2_PIX_FMT_Z16  v4l2_fourcc('Z', '1', '6', ' ') /* Depth 
> > data 16-bit */
> > +#define V4L2_PIX_FMT_MT21 v4l2_fourcc('M', 'T', '2', '1') /* Mediatek 
> > compressed block mode  */
> 
> v4l2-ioctl.c should be modified as well so the correct description string is 
> filled in.
> 
Got it. I will fix this.

best regards,
Tiffany

> Regards,
> 
>   Hans
> 
> >  
> >  /* SDR formats - used only for Software Defined Radio devices */
> >  #define V4L2_SDR_FMT_CU8  v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 
> > */
> > 


--
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 v3 0/9] Add MT8173 Video Decoder Driver

2016-07-07 Thread tiffany lin
Hi Hans,


On Wed, 2016-07-06 at 15:19 +0200, Hans Verkuil wrote:
> Hi Tiffany,
> 
> I plan to review this patch series on Friday, but one obvious question is
> what the reason for these failures is:
> 
> > Input/Output configuration ioctls:
> > test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
> > test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
> > test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
> > test VIDIOC_G/S_EDID: OK (Not Supported)
> > 
> > Control ioctls:
> > test VIDIOC_QUERYCTRL/MENU: OK
> > fail: 
> > ../../../v4l-utils-1.6.0/utils/v4l2-compliance/v4l2-test-controls.cpp(357): 
> > g_ctrl returned an error (11)
> > test VIDIOC_G/S_CTRL: FAIL
> > fail: 
> > ../../../v4l-utils-1.6.0/utils/v4l2-compliance/v4l2-test-controls.cpp(579): 
> > g_ext_ctrls returned an error (11)
> > test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL
These fails are because VIDIOC_G_CTRL and VIDIOC_G_EXT_CTRLS return
V4L2_CID_MIN_BUFFERS_FOR_CAPTURE only when dirver in MTK_STATE_HEADER
state, or it will return EAGAIN.
This could help user space get correct value, not default value that may
changed base on media content.

> > fail: 
> > ../../../v4l-utils-1.6.0/utils/v4l2-compliance/v4l2-test-controls.cpp(721): 
> > subscribe event for control 'User Controls' failed
> > test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAIL
Driver do not support subscribe event for control 'User Controls' for
now.
Do we need to support this?

> > test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
> > Standard Controls: 2 Private Controls: 0
> > 
> > Format ioctls:
> > test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
> > test VIDIOC_G/S_PARM: OK (Not Supported)
> > test VIDIOC_G_FBUF: OK (Not Supported)
> > fail: 
> > ../../../v4l-utils-1.6.0/utils/v4l2-compliance/v4l2-test-formats.cpp(405): 
> > expected EINVAL, but got 11 when getting format for buftype 9
> > test VIDIOC_G_FMT: FAIL
This is because vidioc_vdec_g_fmt only succeed when context is in
MTK_STATE_HEADER state, or user space cannot get correct format data
using this function.

> > test VIDIOC_TRY_FMT: OK (Not Supported)
> > test VIDIOC_S_FMT: OK (Not Supported)
> > test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
> > 
> > Codec ioctls:
> > test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
> > test VIDIOC_G_ENC_INDEX: OK (Not Supported)
> > test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
> > 
> > Buffer ioctls:
> > test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
> > fail: 
> > ../../../v4l-utils-1.6.0/utils/v4l2-compliance/v4l2-test-buffers.cpp(500): 
> > q.has_expbuf(node)
Our OUTPUT and CAPTURE queue support both VB2_DMABUF and VB2_MMAP, user
space can select which to use in runtime.
So our driver default support v4l2_m2m_ioctl_expbuf functionality.
In v4l2-compliance test, it will check v4l2_m2m_ioctl_expbuf only valid
when node->valid_memorytype is V4L2_MEMORY_MMAP.
So when go through node->valid_memorytype is V4L2_MEMORY_DMABUF, it
fail.


best regards,
Tiffany



> > test VIDIOC_EXPBUF: FAIL
> > 
> > 
> > Total: 38, Succeeded: 33, Failed: 5, Warnings: 0
> 
> If it is due to a bug in v4l2-compliance, then let me know and I'll fix it. 
> If not,
> then it should be fixed in the driver.
> 
> Frankly, it was the presence of these failures that made me think this patch 
> series
> wasn't final. Before a v4l2 driver can be accepted in the kernel, 
> v4l2-compliance must pass.
> 
> Regards,
> 
>   Hans


--
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 v3 0/9] Add MT8173 Video Decoder Driver

2016-06-14 Thread tiffany lin
Hi Mauro,


On Wed, 2016-06-08 at 07:13 +0900, Hans Verkuil wrote:
> 
> On 06/07/2016 11:22 PM, Mauro Carvalho Chehab wrote:
> > Em Mon, 30 May 2016 20:29:14 +0800
> > Tiffany Lin <tiffany@mediatek.com> escreveu:
> >
> >> ==
> >>   Introduction
> >> ==
> >>
> >> The purpose of this series is to add the driver for video codec hw 
> >> embedded in the Mediatek's MT8173 SoCs.
> >> Mediatek Video Codec is able to handle video decoding of in a range of 
> >> formats.
> >>
> >> This patch series add Mediatek block format V4L2_PIX_FMT_MT21, the decoder 
> >> driver will decoded bitstream to
> >> V4L2_PIX_FMT_MT21 format.
> >>
> >> This patch series rely on MTK VPU driver in patch series "Add MT8173 Video 
> >> Encoder Driver and VPU Driver"[1]
> >> and patch "CHROMIUM: v4l: Add V4L2_PIX_FMT_VP9 definition"[2] for VP9 
> >> support.
> >> Mediatek Video Decoder driver rely on VPU driver to load, communicate with 
> >> VPU.
> >>
> >> Internally the driver uses videobuf2 framework and MTK IOMMU and MTK SMI 
> >> both have been merged in v4.6-rc1.
> >>
> >> [1]https://patchwork.linuxtv.org/patch/33734/
> >> [2]https://chromium-review.googlesource.com/#/c/245241/
> >
> > Hmm... I'm not seeing the firmware for this driver at the
> > linux-firmware tree:
> > 
> > https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/log/
> >
> > Nor I'm seeing any pull request for them. Did you send it?
> > I'll only merge the driver upstream after seeing such pull request.
> 
Sorry, I am not familiar with how to upstream firmware.
Do you mean we need to upstream vpu firmware first before merge encoder
driver upstream?

In
https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/tree/README,
 it mentions that 
"To submit firmware to this repository, please send either a git binary
diff or preferably a git pull request to: linux-firmw...@kernel.org and
also cc: to related mailing lists."

How we made a git pull request to linux-firmw...@kernel.org? 
How we find out related mailing lists?

best regards,
Tiffany

> Mauro, are you confusing the decoder and encoder driver? I haven't thoroughly 
> reviewed the decoder driver
> yet, so there is no pull request for the decoder driver.
> 
> The only pull request I made was for the encoder driver.
> 
> Regards,
> 
>   Hans


--
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


[PATCH v3 0/9] Add MT8173 Video Decoder Driver

2016-05-30 Thread Tiffany Lin
test VIDIOC_S_FMT: OK (Not Supported)
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
fail: 
../../../v4l-utils-1.6.0/utils/v4l2-compliance/v4l2-test-buffers.cpp(500): 
q.has_expbuf(node)
test VIDIOC_EXPBUF: FAIL


Total: 38, Succeeded: 33, Failed: 5, Warnings: 0


Andrew-CT Chen (1):
  VPU: mediatek: Add decode support

Tiffany Lin (8):
  v4l: add Mediatek compressed video block format
  DocBook/v4l: Add compressed video formats used on MT8173 codec driver
  dt-bindings: Add a binding for Mediatek Video Decoder
  vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver
  vcodec: mediatek: Add Mediatek H264 Video Decoder Driver
  vcodec: mediatek: Add Mediatek VP8 Video Decoder Driver
  vcodec: mediatek: Add Mediatek VP9 Video Decoder Driver
  arm64: dts: mediatek: Add Video Decoder for MT8173

 Documentation/DocBook/media/v4l/pixfmt.xml |6 +
 .../devicetree/bindings/media/mediatek-vcodec.txt  |   57 +-
 arch/arm64/boot/dts/mediatek/mt8173.dtsi   |   44 +
 drivers/media/platform/mtk-vcodec/Makefile |   15 +-
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 1348 
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h |   88 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c |  408 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c  |  206 +++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h  |   28 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |   88 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_intr.c|4 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_intr.h|2 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_util.c|   31 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_util.h|7 +-
 .../media/platform/mtk-vcodec/vdec/vdec_h264_if.c  |  503 
 .../media/platform/mtk-vcodec/vdec/vdec_vp8_if.c   |  630 +
 .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   |  967 ++
 drivers/media/platform/mtk-vcodec/vdec_drv_base.h  |   56 +
 drivers/media/platform/mtk-vcodec/vdec_drv_if.c|  117 ++
 drivers/media/platform/mtk-vcodec/vdec_drv_if.h|  101 ++
 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h   |  103 ++
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c|  168 +++
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.h|   96 ++
 drivers/media/platform/mtk-vpu/mtk_vpu.c   |   12 +
 drivers/media/platform/mtk-vpu/mtk_vpu.h   |   27 +
 include/uapi/linux/videodev2.h |1 +
 26 files changed, 5090 insertions(+), 23 deletions(-)
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_base.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_vpu_if.h

-- 
1.7.9.5

--
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


[PATCH v3 4/9] dt-bindings: Add a binding for Mediatek Video Decoder

2016-05-30 Thread Tiffany Lin
Add a DT binding documentation of Video Decoder for the
MT8173 SoC from Mediatek.

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
Acked-by: Rob Herring <r...@kernel.org>
---
 .../devicetree/bindings/media/mediatek-vcodec.txt  |   57 ++--
 1 file changed, 53 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt 
b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
index 59a47a5..46c15c5 100644
--- a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
+++ b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
@@ -1,25 +1,74 @@
 Mediatek Video Codec
 
 Mediatek Video Codec is the video codec hw present in Mediatek SoCs which
-supports high resolution encoding functionalities.
+supports high resolution encoding and decoding functionalities.
 
 Required properties:
 - compatible : "mediatek,mt8173-vcodec-enc" for encoder
+  "mediatek,mt8173-vcodec-dec" for decoder.
 - reg : Physical base address of the video codec registers and length of
   memory mapped region.
 - interrupts : interrupt number to the cpu.
 - mediatek,larb : must contain the local arbiters in the current Socs.
 - clocks : list of clock specifiers, corresponding to entries in
   the clock-names property.
-- clock-names: encoder must contain "venc_sel_src", "venc_sel",
-- "venc_lt_sel_src", "venc_lt_sel".
+- clock-names: encoder must contain "venc_sel_src", "venc_sel",,
+  "venc_lt_sel_src", "venc_lt_sel", decoder must contain "vcodecpll",
+  "univpll_d2", "clk_cci400_sel", "vdec_sel", "vdecpll", "vencpll",
+  "venc_lt_sel", "vdec_bus_clk_src".
 - iommus : should point to the respective IOMMU block with master port as
   argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
   for details.
 - mediatek,vpu : the node of video processor unit
 
+
 Example:
-vcodec_enc: vcodec@0x18002000 {
+
+vcodec_dec: vcodec@1600 {
+compatible = "mediatek,mt8173-vcodec-dec";
+reg = <0 0x1600 0 0x100>,   /*VDEC_SYS*/
+  <0 0x1602 0 0x1000>,  /*VDEC_MISC*/
+  <0 0x16021000 0 0x800>,   /*VDEC_LD*/
+  <0 0x16021800 0 0x800>,   /*VDEC_TOP*/
+  <0 0x16022000 0 0x1000>,  /*VDEC_CM*/
+  <0 0x16023000 0 0x1000>,  /*VDEC_AD*/
+  <0 0x16024000 0 0x1000>,  /*VDEC_AV*/
+  <0 0x16025000 0 0x1000>,  /*VDEC_PP*/
+  <0 0x16026800 0 0x800>,   /*VP8_VD*/
+  <0 0x16027000 0 0x800>,   /*VP6_VD*/
+  <0 0x16027800 0 0x800>,   /*VP8_VL*/
+  <0 0x16028400 0 0x400>;   /*VP9_VD*/
+interrupts = ;
+mediatek,larb = <>;
+iommus = < M4U_PORT_HW_VDEC_MC_EXT>,
+ < M4U_PORT_HW_VDEC_PP_EXT>,
+ < M4U_PORT_HW_VDEC_AVC_MV_EXT>,
+ < M4U_PORT_HW_VDEC_PRED_RD_EXT>,
+ < M4U_PORT_HW_VDEC_PRED_WR_EXT>,
+ < M4U_PORT_HW_VDEC_UFO_EXT>,
+ < M4U_PORT_HW_VDEC_VLD_EXT>,
+ < M4U_PORT_HW_VDEC_VLD2_EXT>;
+mediatek,vpu = <>;
+power-domains = < MT8173_POWER_DOMAIN_VDEC>;
+clocks = < CLK_APMIXED_VCODECPLL>,
+ < CLK_TOP_UNIVPLL_D2>,
+ < CLK_TOP_CCI400_SEL>,
+ < CLK_TOP_VDEC_SEL>,
+ < CLK_TOP_VCODECPLL>,
+ < CLK_APMIXED_VENCPLL>,
+ < CLK_TOP_VENC_LT_SEL>,
+ < CLK_TOP_VCODECPLL_370P5>;
+clock-names = "vcodecpll",
+  "univpll_d2",
+  "clk_cci400_sel",
+  "vdec_sel",
+  "vdecpll",
+  "vencpll",
+  "venc_lt_sel",
+  "vdec_bus_clk_src";
+  };
+
+  vcodec_enc: vcodec@0x18002000 {
 compatible = "mediatek,mt8173-vcodec-enc";
 reg = <0 0x18002000 0 0x1000>,/*VENC_SYS*/
   <0 0x19002000 0 0x1000>;/*VENC_LT_SYS*/
-- 
1.7.9.5

--
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


[PATCH v3 9/9] arm64: dts: mediatek: Add Video Decoder for MT8173

2016-05-30 Thread Tiffany Lin
Add video decoder node for MT8173

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   44 ++
 1 file changed, 44 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 348ce0e..4ac06d3 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -691,6 +691,50 @@
#clock-cells = <1>;
};
 
+   vcodec_dec: vcodec@1600 {
+   compatible = "mediatek,mt8173-vcodec-dec";
+   reg = <0 0x1600 0 0x100>,   /* VDEC_SYS */
+ <0 0x1602 0 0x1000>,  /* VDEC_MISC */
+ <0 0x16021000 0 0x800>,   /* VDEC_LD */
+ <0 0x16021800 0 0x800>,   /* VDEC_TOP */
+ <0 0x16022000 0 0x1000>,  /* VDEC_CM */
+ <0 0x16023000 0 0x1000>,  /* VDEC_AD */
+ <0 0x16024000 0 0x1000>,  /* VDEC_AV */
+ <0 0x16025000 0 0x1000>,  /* VDEC_PP */
+ <0 0x16026800 0 0x800>,   /* VDEC_HWD */
+ <0 0x16027000 0 0x800>,   /* VDEC_HWQ */
+ <0 0x16027800 0 0x800>,   /* VDEC_HWB */
+ <0 0x16028400 0 0x400>;   /* VDEC_HWG */
+   interrupts = ;
+   mediatek,larb = <>;
+   iommus = < M4U_PORT_HW_VDEC_MC_EXT>,
+< M4U_PORT_HW_VDEC_PP_EXT>,
+< M4U_PORT_HW_VDEC_AVC_MV_EXT>,
+< M4U_PORT_HW_VDEC_PRED_RD_EXT>,
+< M4U_PORT_HW_VDEC_PRED_WR_EXT>,
+< M4U_PORT_HW_VDEC_UFO_EXT>,
+< M4U_PORT_HW_VDEC_VLD_EXT>,
+< M4U_PORT_HW_VDEC_VLD2_EXT>;
+   mediatek,vpu = <>;
+   power-domains = < MT8173_POWER_DOMAIN_VDEC>;
+   clocks = < CLK_APMIXED_VCODECPLL>,
+< CLK_TOP_UNIVPLL_D2>,
+< CLK_TOP_CCI400_SEL>,
+< CLK_TOP_VDEC_SEL>,
+< CLK_TOP_VCODECPLL>,
+< CLK_APMIXED_VENCPLL>,
+< CLK_TOP_VENC_LT_SEL>,
+< CLK_TOP_VCODECPLL_370P5>;
+   clock-names = "vcodecpll",
+ "univpll_d2",
+ "clk_cci400_sel",
+ "vdec_sel",
+ "vdecpll",
+ "vencpll",
+ "venc_lt_sel",
+ "vdec_bus_clk_src";
+   };
+
larb1: larb@1601 {
compatible = "mediatek,mt8173-smi-larb";
reg = <0 0x1601 0 0x1000>;
-- 
1.7.9.5

--
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


[PATCH v3 3/9] DocBook/v4l: Add compressed video formats used on MT8173 codec driver

2016-05-30 Thread Tiffany Lin
Add V4L2_PIX_FMT_MT21 documentation

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 Documentation/DocBook/media/v4l/pixfmt.xml |6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/pixfmt.xml 
b/Documentation/DocBook/media/v4l/pixfmt.xml
index 5a08aee..d40e0ce 100644
--- a/Documentation/DocBook/media/v4l/pixfmt.xml
+++ b/Documentation/DocBook/media/v4l/pixfmt.xml
@@ -1980,6 +1980,12 @@ array. Anything what's in between the UYVY lines is JPEG 
data and should be
 concatenated to form the JPEG stream. 
 
  
+ 
+   V4L2_PIX_FMT_MT21
+   'MT21'
+   Compressed two-planar YVU420 format used by Mediatek MT8173
+   codec driver.
+ 

   
 
-- 
1.7.9.5

--
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


[PATCH v3 2/9] v4l: add Mediatek compressed video block format

2016-05-30 Thread Tiffany Lin
Add V4L2_PIX_FMT_MT21 format used on MT8173 driver.
It is compressed format and need MT8173 MDP driver to transfer to other
standard format.

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 include/uapi/linux/videodev2.h |1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 8f95191..52feea6 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -625,6 +625,7 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_Y8I  v4l2_fourcc('Y', '8', 'I', ' ') /* Greyscale 
8-bit L/R interleaved */
 #define V4L2_PIX_FMT_Y12I v4l2_fourcc('Y', '1', '2', 'I') /* Greyscale 
12-bit L/R interleaved */
 #define V4L2_PIX_FMT_Z16  v4l2_fourcc('Z', '1', '6', ' ') /* Depth data 
16-bit */
+#define V4L2_PIX_FMT_MT21 v4l2_fourcc('M', 'T', '2', '1') /* Mediatek 
compressed block mode  */
 
 /* SDR formats - used only for Software Defined Radio devices */
 #define V4L2_SDR_FMT_CU8  v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */
-- 
1.7.9.5

--
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


[PATCH v3 7/9] vcodec: mediatek: Add Mediatek VP8 Video Decoder Driver

2016-05-30 Thread Tiffany Lin
Add vp8 decoder driver for MT8173

Signed-off-by: PC Chen <pc.c...@mediatek.com>
Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/Makefile |1 +
 .../media/platform/mtk-vcodec/vdec/vdec_vp8_if.c   |  630 
 drivers/media/platform/mtk-vcodec/vdec_drv_if.c|3 +
 3 files changed, 634 insertions(+)
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c

diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
index 58243ed..7743c81 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -4,6 +4,7 @@ obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-dec.o \
   mtk-vcodec-common.o
 
 mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
+   vdec/vdec_vp8_if.o \
mtk_vcodec_dec_drv.o \
vdec_drv_if.o \
vdec_vpu_if.o \
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c 
b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
new file mode 100644
index 000..0c86df0
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
@@ -0,0 +1,630 @@
+/*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: Jungchang Tsao <jungchang.t...@mediatek.com>
+ *PC Chen <pc.c...@mediatek.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include "../mtk_vcodec_intr.h"
+#include "../vdec_vpu_if.h"
+#include "../vdec_drv_base.h"
+
+/* Decoding picture buffer size (3 reference frames plus current frame) */
+#define VP8_DPB_SIZE   4
+
+/* HW working buffer size (bytes) */
+#define VP8_WORKING_BUF_SZ (45 * 4096)
+
+/* HW control register address */
+#define VP8_SEGID_DRAM_ADDR0x3c
+#define VP8_HW_VLD_ADDR0x93C
+#define VP8_HW_VLD_VALUE   0x940
+#define VP8_BSASET 0x100
+#define VP8_BSDSET 0x104
+#define VP8_RW_CKEN_SET0x0
+#define VP8_RW_DCM_CON 0x18
+#define VP8_WO_VLD_SRST0x108
+#define VP8_RW_MISC_SYS_SEL0x84
+#define VP8_RW_MISC_SPEC_CON   0xC8
+#define VP8_WO_VLD_SRST0x108
+#define VP8_RW_VP8_CTRL0xA4
+#define VP8_RW_MISC_DCM_CON0xEC
+#define VP8_RW_MISC_SRST   0xF4
+#define VP8_RW_MISC_FUNC_CON   0xCC
+
+#define VP8_MAX_FRM_BUF_NUM5
+#define VP8_MAX_FRM_BUF_NODE_NUM   (VP8_MAX_FRM_BUF_NUM * 2)
+
+/* required buffer size (bytes) to store decode information */
+#define VP8_HW_SEGMENT_DATA_SZ 272
+#define VP8_HW_SEGMENT_UINT4
+
+#define VP8_DEC_TABLE_PROC_LOOP96
+#define VP8_DEC_TABLE_UNIT 3
+#define VP8_DEC_TABLE_SZ   300
+#define VP8_DEC_TABLE_OFFSET   2
+#define VP8_DEC_TABLE_RW_UNIT  4
+
+/**
+ * struct vdec_vp8_dec_info - decode misc information
+ * @working_buf_dma   : working buffer dma address
+ * @prev_y_dma: previous decoded frame buffer Y plane address
+ * @cur_y_fb_dma  : current plane Y frame buffer dma address
+ * @cur_c_fb_dma  : current plane C frame buffer dma address
+ * @bs_dma   : bitstream dma address
+ * @bs_sz: bitstream size
+ * @resolution_changed: resolution change flag 1 - changed,  0 - not change
+ * @show_frame   : display this frame or not
+ * @wait_key_frame: wait key frame coming
+ */
+struct vdec_vp8_dec_info {
+   uint64_t working_buf_dma;
+   uint64_t prev_y_dma;
+   uint64_t cur_y_fb_dma;
+   uint64_t cur_c_fb_dma;
+   uint64_t bs_dma;
+   uint32_t bs_sz;
+   uint32_t resolution_changed;
+   uint32_t show_frame;
+   uint32_t wait_key_frame;
+};
+
+/**
+ * struct vdec_vp8_vsi - VPU shared information
+ * @dec: decoding information
+ * @pic: picture information
+ * @dec_table  : decoder coefficient table
+ * @segment_buf: segmentation buffer
+ * @load_data  : flag to indicate reload decode data
+ */
+struct vdec_vp8_vsi {
+   struct vdec_vp8_dec_info dec;
+   struct vdec_pic_info pic;
+   uint32_t dec_table[VP8_DEC_TABLE_SZ];
+   uint32_t segment_buf[VP8_HW_SEGMENT_DATA_SZ][VP8_HW_SEGMENT_UINT];
+   uint32_t load_data;
+};
+
+/**
+ * struct vdec_vp8_hw_reg_base - HW register base
+ * @sys   

[PATCH v3 8/9] vcodec: mediatek: Add Mediatek VP9 Video Decoder Driver

2016-05-30 Thread Tiffany Lin
Add vp9 decoder driver for MT8173

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/Makefile |1 +
 .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   |  967 
 drivers/media/platform/mtk-vcodec/vdec_drv_if.c|3 +
 3 files changed, 971 insertions(+)
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c

diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
index 7743c81..852d969 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -5,6 +5,7 @@ obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-dec.o \
 
 mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
vdec/vdec_vp8_if.o \
+   vdec/vdec_vp9_if.o \
mtk_vcodec_dec_drv.o \
vdec_drv_if.o \
vdec_vpu_if.o \
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c 
b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
new file mode 100644
index 000..650b93a
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
@@ -0,0 +1,967 @@
+/*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: Daniel Hsiao <daniel.hs...@mediatek.com>
+ * Kai-Sean Yang <kai-sean.y...@mediatek.com>
+ * Tiffany Lin <tiffany@mediatek.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../mtk_vcodec_intr.h"
+#include "../vdec_drv_base.h"
+#include "../vdec_vpu_if.h"
+
+#define VP9_SUPER_FRAME_BS_SZ 64
+#define MAX_VP9_DPB_SIZE   9
+
+#define REFS_PER_FRAME 3
+#define MAX_NUM_REF_FRAMES 8
+#define VP9_MAX_FRM_BUF_NUM 9
+#define VP9_MAX_FRM_BUF_NODE_NUM (VP9_MAX_FRM_BUF_NUM * 2)
+
+/**
+ * struct vp9_dram_buf - contains buffer info for vpu
+ * @va : cpu address
+ * @pa : iova address
+ * @sz : buffer size
+ * @padding : for 64 bytes alignment
+ */
+struct vp9_dram_buf {
+   unsigned long va;
+   unsigned long pa;
+   unsigned int sz;
+   unsigned int padding;
+};
+
+/**
+ * struct vp9_fb_info - contains frame buffer info
+ * @fb : frmae buffer
+ * @reserved : reserved field used by vpu
+ */
+struct vp9_fb_info {
+   struct vdec_fb *fb;
+   unsigned int reserved[32];
+};
+
+/**
+ * struct vp9_ref_cnt_buf - contains reference buffer information
+ * @buf : referenced frame buffer
+ * @ref_cnt : referenced frame buffer's reference count.
+ * When reference count=0, remove it from reference list
+ */
+struct vp9_ref_cnt_buf {
+   struct vp9_fb_info buf;
+   unsigned int ref_cnt;
+};
+
+/**
+ * struct vp9_fb_info - contains current frame's reference buffer information
+ * @buf : reference buffer
+ * @idx : reference buffer index to frm_bufs
+ * @reserved : reserved field used by vpu
+ */
+struct vp9_ref_buf {
+   struct vp9_fb_info *buf;
+   unsigned int idx;
+   unsigned int reserved[6];
+};
+
+/**
+ * struct vp9_fb_info - contains frame buffer info
+ * @fb : super frame reference frame buffer
+ * @used : this reference frame info entry is used
+ * @padding : for 64 bytes size align
+ */
+struct vp9_sf_ref_fb {
+   struct vdec_fb fb;
+   int used;
+   int padding;
+};
+
+/*
+ * struct vdec_vp9_vsi - shared buffer between host and VPU firmware
+ * AP-W/R : AP is writer/reader on this item
+ * VPU-W/R: VPU is write/reader on this item
+ * @sf_bs_buf : super frame backup buffer (AP-W, VPU-R)
+ * @sf_ref_fb : record supoer frame reference buffer information
+ * (AP-R/W, VPU-R/W)
+ * @sf_next_ref_fb_idx : next available super frame (AP-W, VPU-R)
+ * @sf_frm_cnt : super frame count, filled by vpu (AP-R, VPU-W)
+ * @sf_frm_offset : super frame offset, filled by vpu (AP-R, VPU-W)
+ * @sf_frm_sz : super frame size, filled by vpu (AP-R, VPU-W)
+ * @sf_frm_idx : current super frame (AP-R, VPU-W)
+ * @sf_init : inform super frame info already parsed by vpu (AP-R, VPU-W)
+ * @fb : capture buffer (AP-W, VPU-R)
+ * @bs : bs buffer (AP-W, VPU-R)
+ * @cur_fb : current show capture buffer (AP-R/W, VPU-R/W)
+ * @pic_w : picture width (AP-R, VPU-W)
+ * @pic_h : picture height (AP-R, VPU-W)
+ * @buf_w : codec width (AP-R, VPU-W)
+ * @buf_h : coded height (AP-R, VPU-W)
+ * @buf_sz_y_bs : ufo compressed y plane size (AP-R, VPU-W)
+ * @buf_sz_c_bs : ufo compressed cbcr plane size (AP-R, VPU-W)
+ * @buf_len_sz_y : size used to store y plane ufo info (AP-R, VPU-W)
+ * @buf_len_sz_c : size used to store cbcr plane ufo info (

[PATCH v3 6/9] vcodec: mediatek: Add Mediatek H264 Video Decoder Driver

2016-05-30 Thread Tiffany Lin
Add h264 decoder driver for MT8173

Signed-off-by: PC Chen <pc.c...@mediatek.com>
Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/Makefile |5 +-
 .../media/platform/mtk-vcodec/vdec/vdec_h264_if.c  |  503 
 drivers/media/platform/mtk-vcodec/vdec_drv_if.c|4 +
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c|  168 +++
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.h|   96 
 5 files changed, 774 insertions(+), 2 deletions(-)
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_vpu_if.h

diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
index 4c8ed2f..58243ed 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -1,11 +1,12 @@
 
-
 obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-dec.o \
   mtk-vcodec-enc.o \
   mtk-vcodec-common.o
 
-mtk-vcodec-dec-y := mtk_vcodec_dec_drv.o \
+mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
+   mtk_vcodec_dec_drv.o \
vdec_drv_if.o \
+   vdec_vpu_if.o \
mtk_vcodec_dec.o \
mtk_vcodec_dec_pm.o \
 
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c 
b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
new file mode 100644
index 000..8de0b53
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
@@ -0,0 +1,503 @@
+/*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: PC Chen <pc.c...@mediatek.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+
+#include "../mtk_vcodec_intr.h"
+#include "../vdec_vpu_if.h"
+#include "../vdec_drv_base.h"
+
+#define NAL_NON_IDR_SLICE  0x01
+#define NAL_IDR_SLICE  0x05
+#define NAL_H264_PPS   0x08
+#define NAL_TYPE(value)((value) & 0x1F)
+
+#define BUF_PREDICTION_SZ  (32 * 1024)
+
+#define MB_UNIT_LEN16
+
+/* motion vector size (bytes) for every macro block */
+#define HW_MB_STORE_SZ 64
+
+#define H264_MAX_FB_NUM17
+#define HDR_PARSING_BUF_SZ 1024
+
+/**
+ * struct h264_fb - h264 decode frame buffer information
+ * @vdec_fb_va  : virtual address of struct vdec_fb
+ * @y_fb_dma: dma address of Y frame buffer (luma)
+ * @c_fb_dma: dma address of C frame buffer (chroma)
+ * @poc : picture order count of frame buffer
+ * @reserved: for 8 bytes alignment
+ */
+struct h264_fb {
+   uint64_t vdec_fb_va;
+   uint64_t y_fb_dma;
+   uint64_t c_fb_dma;
+   int32_t poc;
+   uint32_t reserved;
+};
+
+/**
+ * struct h264_ring_fb_list - ring frame buffer list
+ * @fb_list   : frame buffer arrary
+ * @read_idx  : read index
+ * @write_idx : write index
+ * @count : buffer count in list
+ */
+struct h264_ring_fb_list {
+   struct h264_fb fb_list[H264_MAX_FB_NUM];
+   unsigned int read_idx;
+   unsigned int write_idx;
+   unsigned int count;
+   unsigned int reserved;
+};
+
+/**
+ * struct vdec_h264_dec_info - decode information
+ * @dpb_sz : decoding picture buffer size
+ * @resolution_changed  : resoltion change happen
+ * @realloc_mv_buf : flag to notify driver to re-allocate mv buffer
+ * @reserved   : for 8 bytes alignment
+ * @bs_dma : Input bit-stream buffer dma address
+ * @y_fb_dma   : Y frame buffer dma address
+ * @c_fb_dma   : C frame buffer dma address
+ * @vdec_fb_va : VDEC frame buffer struct virtual address
+ */
+struct vdec_h264_dec_info {
+   uint32_t dpb_sz;
+   uint32_t resolution_changed;
+   uint32_t realloc_mv_buf;
+   uint32_t reserved;
+   uint64_t bs_dma;
+   uint64_t y_fb_dma;
+   uint64_t c_fb_dma;
+   uint64_t vdec_fb_va;
+};
+
+/**
+ * struct vdec_h264_vsi - shared memory for decode information exchange
+ *between VPU and Host.
+ *The memory is allocated by VPU then mapping to Host
+ *in vpu_dec_init() and freed in vpu_dec_deinit()
+ *by VPU.
+ * 

[PATCH v3 5/9] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-05-30 Thread Tiffany Lin
Add v4l2 layer decoder driver for MT8173

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/Makefile |   10 +-
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 1348 
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h |   88 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c |  408 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c  |  206 +++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h  |   28 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |   88 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_intr.c|4 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_intr.h|2 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_util.c|   31 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_util.h|7 +-
 drivers/media/platform/mtk-vcodec/vdec_drv_base.h  |   56 +
 drivers/media/platform/mtk-vcodec/vdec_drv_if.c|  107 ++
 drivers/media/platform/mtk-vcodec/vdec_drv_if.h|  101 ++
 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h   |  103 ++
 15 files changed, 2569 insertions(+), 18 deletions(-)
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_base.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h

diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
index dc5cb00..4c8ed2f 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -1,7 +1,13 @@
 
 
-obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-enc.o mtk-vcodec-common.o
-
+obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-dec.o \
+  mtk-vcodec-enc.o \
+  mtk-vcodec-common.o
+
+mtk-vcodec-dec-y := mtk_vcodec_dec_drv.o \
+   vdec_drv_if.o \
+   mtk_vcodec_dec.o \
+   mtk_vcodec_dec_pm.o \
 
 
 mtk-vcodec-enc-y := venc/venc_vp8_if.o \
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
new file mode 100644
index 000..792858a
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -0,0 +1,1348 @@
+/*
+* Copyright (c) 2016 MediaTek Inc.
+* Author: PC Chen <pc.c...@mediatek.com>
+*     Tiffany Lin <tiffany@mediatek.com>
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*/
+
+#include 
+#include 
+#include 
+
+#include "mtk_vcodec_drv.h"
+#include "mtk_vcodec_dec.h"
+#include "mtk_vcodec_intr.h"
+#include "mtk_vcodec_util.h"
+#include "vdec_drv_if.h"
+#include "mtk_vcodec_dec_pm.h"
+
+#define OUT_FMT_IDX0
+#define CAP_FMT_IDX3
+
+#define MTK_VDEC_MIN_W 64U
+#define MTK_VDEC_MIN_H 64U
+#define DFT_CFG_WIDTH  MTK_VDEC_MIN_W
+#define DFT_CFG_HEIGHT MTK_VDEC_MIN_H
+
+static struct mtk_video_fmt mtk_video_formats[] = {
+   {
+   .fourcc = V4L2_PIX_FMT_H264,
+   .type = MTK_FMT_DEC,
+   .num_planes = 1,
+   },
+   {
+   .fourcc = V4L2_PIX_FMT_VP8,
+   .type = MTK_FMT_DEC,
+   .num_planes = 1,
+   },
+   {
+   .fourcc = V4L2_PIX_FMT_VP9,
+   .type = MTK_FMT_DEC,
+   .num_planes = 1,
+   },
+   {
+   .fourcc = V4L2_PIX_FMT_MT21,
+   .type = MTK_FMT_FRAME,
+   .num_planes = 2,
+   },
+};
+
+static const struct mtk_codec_framesizes mtk_vdec_framesizes[] = {
+   {
+   .fourcc = V4L2_PIX_FMT_H264,
+   .stepwise = {  MTK_VDEC_MIN_W, MTK_VDEC_MAX_W, 16,
+   MTK_VDEC_MIN_H, MTK_VDEC_MAX_H, 16 },
+   },
+   {
+   .fourcc = V4L2_PIX_FMT_VP8,
+   .stepwise = {  MTK_VDEC_MIN_W, MTK_VDEC_MAX_W, 16,
+   MTK_VDEC_MIN_H, MTK_VDEC_MAX_H, 16 },
+   },
+   {
+   .fourcc = V4L2_PIX_FMT_VP9,
+   .stepwise = {  MTK_VDEC_MIN_W, MTK_VDEC_MAX_W, 16,
+   MTK_VDEC_

  1   2   3   >