Re: [PATCH 3/7] [Media] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-04-19 Thread tiffany lin
Hi Nicolas,

On Mon, 2016-04-18 at 13:48 -0400, Nicolas Dufresne wrote:
> Le lundi 18 avril 2016 à 16:22 +0800, tiffany lin a écrit :
> > > > We are plaining to remove m2m framework in th feature, although
> > we think
> > > 
> > > Remove it for just the decoder driver or both encoder and decoder?
> > > 
> > Remove it from decoder driver.
> 
> Did you look at how CODA handle it (drivers/media/platform/coda/coda-
> common.c) ? I don't know any detail, but they do have the same issue
> and use both v4l2_m2m_fop_poll and v4l2_m2m_fop_mmap.
> 
I check coda-common.c, it use v4l2_m2m_set_src_buffered to allow
device_run be triggered without OUTPUT buffer.

Double check the patch "[media] mem2mem: add support for hardware
buffered queue".
This patch make m2m framework could support that
1. out-of-order frames, causing a few mem2mem device runs in the
beginning, that don't produce any decompressed buffer at the v4l2
capture side.
2. the last few frames can be decoded from the bitstream with mem2mem
device runs that don't need a new input buffer at the v4l2 output side.

This is similar our requirement that we want start decode without
CAPTURE buffer.
Is there any restriction that when v4l2_m2m_set_src_buffered can be
used?



best regards,
Tiffany

> cheers,
> 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 3/7] [Media] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-04-18 Thread Nicolas Dufresne
Le lundi 18 avril 2016 à 16:22 +0800, tiffany lin a écrit :
> > > We are plaining to remove m2m framework in th feature, although
> we think
> > 
> > Remove it for just the decoder driver or both encoder and decoder?
> > 
> Remove it from decoder driver.

Did you look at how CODA handle it (drivers/media/platform/coda/coda-
common.c) ? I don't know any detail, but they do have the same issue
and use both v4l2_m2m_fop_poll and v4l2_m2m_fop_mmap.

cheers,
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 3/7] [Media] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-04-18 Thread tiffany lin
Hi Hans,

On Mon, 2016-04-18 at 09:32 +0200, Hans Verkuil wrote:
> On 04/18/2016 07:40 AM, tiffany lin wrote:
> > 
> > snipped.
> > 
> >>> +
> >>> +void mtk_vcodec_dec_set_default_params(struct mtk_vcodec_ctx *ctx)
> >>> +{
> >>> + struct mtk_q_data *q_data;
> >>> +
> >>> + ctx->m2m_ctx->q_lock = >dev->dev_mutex;
> >>> + ctx->fh.m2m_ctx = ctx->m2m_ctx;
> >>> + ctx->fh.ctrl_handler = >ctrl_hdl;
> >>> + INIT_WORK(>decode_work, mtk_vdec_worker);
> >>> +
> >>> + q_data = >q_data[MTK_Q_DATA_SRC];
> >>> + memset(q_data, 0, sizeof(struct mtk_q_data));
> >>> + q_data->visible_width = DFT_CFG_WIDTH;
> >>> + q_data->visible_height = DFT_CFG_HEIGHT;
> >>> + q_data->fmt = _video_formats[OUT_FMT_IDX];
> >>> + q_data->colorspace = V4L2_COLORSPACE_REC709;
> >>> + q_data->field = V4L2_FIELD_NONE;
> >>> + ctx->q_data[MTK_Q_DATA_DST].sizeimage[0] =
> >>> + DFT_CFG_WIDTH * DFT_CFG_HEIGHT;
> >>> + ctx->q_data[MTK_Q_DATA_DST].bytesperline[0] = 0;
> >>> +
> >>> +
> >>> + q_data = >q_data[MTK_Q_DATA_DST];
> >>> + memset(q_data, 0, sizeof(struct mtk_q_data));
> >>> + q_data->visible_width = DFT_CFG_WIDTH;
> >>> + q_data->visible_height = DFT_CFG_HEIGHT;
> >>> + q_data->coded_width = DFT_CFG_WIDTH;
> >>> + q_data->coded_height = DFT_CFG_HEIGHT;
> >>> + q_data->colorspace = V4L2_COLORSPACE_REC709;
> >>> + q_data->field = V4L2_FIELD_NONE;
> >>> +
> >>> + q_data->fmt = _video_formats[CAP_FMT_IDX];
> >>> +
> >>> + v4l_bound_align_image(_data->coded_width,
> >>> + MTK_VDEC_MIN_W,
> >>> + MTK_VDEC_MAX_W, 4,
> >>> + _data->coded_height,
> >>> + MTK_VDEC_MIN_H,
> >>> + MTK_VDEC_MAX_H, 5, 6);
> >>> +
> >>> + q_data->sizeimage[0] = q_data->coded_width * q_data->coded_height;
> >>> + q_data->bytesperline[0] = q_data->coded_width;
> >>> + q_data->sizeimage[1] = q_data->sizeimage[0] / 2;
> >>> + q_data->bytesperline[1] = q_data->coded_width;
> >>> +
> >>> +}
> >>> +
> >>> +static int vidioc_vdec_streamon(struct file *file, void *priv,
> >>> + enum v4l2_buf_type type)
> >>> +{
> >>> + struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> >>> +
> >>> + mtk_v4l2_debug(3, "[%d] (%d)", ctx->idx, type);
> >>> +
> >>> + return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
> >>> +}
> >>> +
> >>> +static int vidioc_vdec_streamoff(struct file *file, void *priv,
> >>> +  enum v4l2_buf_type type)
> >>> +{
> >>> + struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> >>> +
> >>> + mtk_v4l2_debug(3, "[%d] (%d)", ctx->idx, type);
> >>> + return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
> >>> +}
> >>> +
> >>> +static int vidioc_vdec_reqbufs(struct file *file, void *priv,
> >>> +struct v4l2_requestbuffers *reqbufs)
> >>> +{
> >>> + struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> >>> + int ret;
> >>> +
> >>> + mtk_v4l2_debug(3, "[%d] (%d) count=%d", ctx->idx,
> >>> +  reqbufs->type, reqbufs->count);
> >>> + ret = v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
> >>> +
> >>> + return ret;
> >>> +}
> >>
> >> Please use the v4l2_m2m_ioctl_* helper functions were applicable.
> >>
> > 
> > 
> > 
> > snipped.
> >>> +static unsigned int fops_vcodec_poll(struct file *file,
> >>> +  struct poll_table_struct *wait)
> >>> +{
> >>> + struct mtk_vcodec_ctx *ctx = fh_to_ctx(file->private_data);
> >>> + struct mtk_vcodec_dev *dev = ctx->dev;
> >>> + int ret;
> >>> +
> >>> + mutex_lock(>dev_mutex);
> >>> + ret = v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
> >>> + mutex_unlock(>dev_mutex);
> >>> +
> >>> + return ret;
> >>> +}
> >>> +
> >>> +static int fops_vcodec_mmap(struct file *file, struct vm_area_struct 
> >>> *vma)
> >>> +{
> >>> + struct mtk_vcodec_ctx *ctx = fh_to_ctx(file->private_data);
> >>> +
> >>> + return v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
> >>> +}
> >>> +
> >>> +static const struct v4l2_file_operations mtk_vcodec_fops = {
> >>> + .owner  = THIS_MODULE,
> >>> + .open   = fops_vcodec_open,
> >>> + .release= fops_vcodec_release,
> >>> + .poll   = fops_vcodec_poll,
> >>> + .unlocked_ioctl = video_ioctl2,
> >>> + .mmap   = fops_vcodec_mmap,
> >>
> >> You should be able to use the v4l2_m2m_fop helper functions for poll and 
> >> mmap.
> >>
> > 
> > Hi Hans,
> > 
> > We are plaining to remove m2m framework in th feature, although we think
> 
> Remove it for just the decoder driver or both encoder and decoder?
> 
Remove it from decoder driver.

> > it is easy to use and could save a lot of code similar to what m2m
> > framework implemented and reduce code size.
> > The main reason is that in v4l2_m2m_try_schedule, it required that at
> > least one output buffer and one capture buffer to run device_run.
> > We want to start device_run without capture buffer queued.
> 

Re: [PATCH 3/7] [Media] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-04-18 Thread Hans Verkuil
On 04/18/2016 07:40 AM, tiffany lin wrote:
> 
> snipped.
> 
>>> +
>>> +void mtk_vcodec_dec_set_default_params(struct mtk_vcodec_ctx *ctx)
>>> +{
>>> +   struct mtk_q_data *q_data;
>>> +
>>> +   ctx->m2m_ctx->q_lock = >dev->dev_mutex;
>>> +   ctx->fh.m2m_ctx = ctx->m2m_ctx;
>>> +   ctx->fh.ctrl_handler = >ctrl_hdl;
>>> +   INIT_WORK(>decode_work, mtk_vdec_worker);
>>> +
>>> +   q_data = >q_data[MTK_Q_DATA_SRC];
>>> +   memset(q_data, 0, sizeof(struct mtk_q_data));
>>> +   q_data->visible_width = DFT_CFG_WIDTH;
>>> +   q_data->visible_height = DFT_CFG_HEIGHT;
>>> +   q_data->fmt = _video_formats[OUT_FMT_IDX];
>>> +   q_data->colorspace = V4L2_COLORSPACE_REC709;
>>> +   q_data->field = V4L2_FIELD_NONE;
>>> +   ctx->q_data[MTK_Q_DATA_DST].sizeimage[0] =
>>> +   DFT_CFG_WIDTH * DFT_CFG_HEIGHT;
>>> +   ctx->q_data[MTK_Q_DATA_DST].bytesperline[0] = 0;
>>> +
>>> +
>>> +   q_data = >q_data[MTK_Q_DATA_DST];
>>> +   memset(q_data, 0, sizeof(struct mtk_q_data));
>>> +   q_data->visible_width = DFT_CFG_WIDTH;
>>> +   q_data->visible_height = DFT_CFG_HEIGHT;
>>> +   q_data->coded_width = DFT_CFG_WIDTH;
>>> +   q_data->coded_height = DFT_CFG_HEIGHT;
>>> +   q_data->colorspace = V4L2_COLORSPACE_REC709;
>>> +   q_data->field = V4L2_FIELD_NONE;
>>> +
>>> +   q_data->fmt = _video_formats[CAP_FMT_IDX];
>>> +
>>> +   v4l_bound_align_image(_data->coded_width,
>>> +   MTK_VDEC_MIN_W,
>>> +   MTK_VDEC_MAX_W, 4,
>>> +   _data->coded_height,
>>> +   MTK_VDEC_MIN_H,
>>> +   MTK_VDEC_MAX_H, 5, 6);
>>> +
>>> +   q_data->sizeimage[0] = q_data->coded_width * q_data->coded_height;
>>> +   q_data->bytesperline[0] = q_data->coded_width;
>>> +   q_data->sizeimage[1] = q_data->sizeimage[0] / 2;
>>> +   q_data->bytesperline[1] = q_data->coded_width;
>>> +
>>> +}
>>> +
>>> +static int vidioc_vdec_streamon(struct file *file, void *priv,
>>> +   enum v4l2_buf_type type)
>>> +{
>>> +   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
>>> +
>>> +   mtk_v4l2_debug(3, "[%d] (%d)", ctx->idx, type);
>>> +
>>> +   return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
>>> +}
>>> +
>>> +static int vidioc_vdec_streamoff(struct file *file, void *priv,
>>> +enum v4l2_buf_type type)
>>> +{
>>> +   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
>>> +
>>> +   mtk_v4l2_debug(3, "[%d] (%d)", ctx->idx, type);
>>> +   return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
>>> +}
>>> +
>>> +static int vidioc_vdec_reqbufs(struct file *file, void *priv,
>>> +  struct v4l2_requestbuffers *reqbufs)
>>> +{
>>> +   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
>>> +   int ret;
>>> +
>>> +   mtk_v4l2_debug(3, "[%d] (%d) count=%d", ctx->idx,
>>> +reqbufs->type, reqbufs->count);
>>> +   ret = v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
>>> +
>>> +   return ret;
>>> +}
>>
>> Please use the v4l2_m2m_ioctl_* helper functions were applicable.
>>
> 
> 
> 
> snipped.
>>> +static unsigned int fops_vcodec_poll(struct file *file,
>>> +struct poll_table_struct *wait)
>>> +{
>>> +   struct mtk_vcodec_ctx *ctx = fh_to_ctx(file->private_data);
>>> +   struct mtk_vcodec_dev *dev = ctx->dev;
>>> +   int ret;
>>> +
>>> +   mutex_lock(>dev_mutex);
>>> +   ret = v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
>>> +   mutex_unlock(>dev_mutex);
>>> +
>>> +   return ret;
>>> +}
>>> +
>>> +static int fops_vcodec_mmap(struct file *file, struct vm_area_struct *vma)
>>> +{
>>> +   struct mtk_vcodec_ctx *ctx = fh_to_ctx(file->private_data);
>>> +
>>> +   return v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
>>> +}
>>> +
>>> +static const struct v4l2_file_operations mtk_vcodec_fops = {
>>> +   .owner  = THIS_MODULE,
>>> +   .open   = fops_vcodec_open,
>>> +   .release= fops_vcodec_release,
>>> +   .poll   = fops_vcodec_poll,
>>> +   .unlocked_ioctl = video_ioctl2,
>>> +   .mmap   = fops_vcodec_mmap,
>>
>> You should be able to use the v4l2_m2m_fop helper functions for poll and 
>> mmap.
>>
> 
> Hi Hans,
> 
> We are plaining to remove m2m framework in th feature, although we think

Remove it for just the decoder driver or both encoder and decoder?

> it is easy to use and could save a lot of code similar to what m2m
> framework implemented and reduce code size.
> The main reason is that in v4l2_m2m_try_schedule, it required that at
> least one output buffer and one capture buffer to run device_run.
> We want to start device_run without capture buffer queued.

I assume the reason is that you need to get the resolution etc. information
from the encoded stream? Without a capture buffer you can't actually decode
a frame, but that's probably not what this is about.

> Is there any suggestion that we 

Re: [PATCH 3/7] [Media] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-04-17 Thread tiffany lin

snipped.

> > +
> > +void mtk_vcodec_dec_set_default_params(struct mtk_vcodec_ctx *ctx)
> > +{
> > +   struct mtk_q_data *q_data;
> > +
> > +   ctx->m2m_ctx->q_lock = >dev->dev_mutex;
> > +   ctx->fh.m2m_ctx = ctx->m2m_ctx;
> > +   ctx->fh.ctrl_handler = >ctrl_hdl;
> > +   INIT_WORK(>decode_work, mtk_vdec_worker);
> > +
> > +   q_data = >q_data[MTK_Q_DATA_SRC];
> > +   memset(q_data, 0, sizeof(struct mtk_q_data));
> > +   q_data->visible_width = DFT_CFG_WIDTH;
> > +   q_data->visible_height = DFT_CFG_HEIGHT;
> > +   q_data->fmt = _video_formats[OUT_FMT_IDX];
> > +   q_data->colorspace = V4L2_COLORSPACE_REC709;
> > +   q_data->field = V4L2_FIELD_NONE;
> > +   ctx->q_data[MTK_Q_DATA_DST].sizeimage[0] =
> > +   DFT_CFG_WIDTH * DFT_CFG_HEIGHT;
> > +   ctx->q_data[MTK_Q_DATA_DST].bytesperline[0] = 0;
> > +
> > +
> > +   q_data = >q_data[MTK_Q_DATA_DST];
> > +   memset(q_data, 0, sizeof(struct mtk_q_data));
> > +   q_data->visible_width = DFT_CFG_WIDTH;
> > +   q_data->visible_height = DFT_CFG_HEIGHT;
> > +   q_data->coded_width = DFT_CFG_WIDTH;
> > +   q_data->coded_height = DFT_CFG_HEIGHT;
> > +   q_data->colorspace = V4L2_COLORSPACE_REC709;
> > +   q_data->field = V4L2_FIELD_NONE;
> > +
> > +   q_data->fmt = _video_formats[CAP_FMT_IDX];
> > +
> > +   v4l_bound_align_image(_data->coded_width,
> > +   MTK_VDEC_MIN_W,
> > +   MTK_VDEC_MAX_W, 4,
> > +   _data->coded_height,
> > +   MTK_VDEC_MIN_H,
> > +   MTK_VDEC_MAX_H, 5, 6);
> > +
> > +   q_data->sizeimage[0] = q_data->coded_width * q_data->coded_height;
> > +   q_data->bytesperline[0] = q_data->coded_width;
> > +   q_data->sizeimage[1] = q_data->sizeimage[0] / 2;
> > +   q_data->bytesperline[1] = q_data->coded_width;
> > +
> > +}
> > +
> > +static int vidioc_vdec_streamon(struct file *file, void *priv,
> > +   enum v4l2_buf_type type)
> > +{
> > +   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> > +
> > +   mtk_v4l2_debug(3, "[%d] (%d)", ctx->idx, type);
> > +
> > +   return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
> > +}
> > +
> > +static int vidioc_vdec_streamoff(struct file *file, void *priv,
> > +enum v4l2_buf_type type)
> > +{
> > +   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> > +
> > +   mtk_v4l2_debug(3, "[%d] (%d)", ctx->idx, type);
> > +   return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
> > +}
> > +
> > +static int vidioc_vdec_reqbufs(struct file *file, void *priv,
> > +  struct v4l2_requestbuffers *reqbufs)
> > +{
> > +   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> > +   int ret;
> > +
> > +   mtk_v4l2_debug(3, "[%d] (%d) count=%d", ctx->idx,
> > +reqbufs->type, reqbufs->count);
> > +   ret = v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
> > +
> > +   return ret;
> > +}
> 
> Please use the v4l2_m2m_ioctl_* helper functions were applicable.
> 



snipped.
> > +static unsigned int fops_vcodec_poll(struct file *file,
> > +struct poll_table_struct *wait)
> > +{
> > +   struct mtk_vcodec_ctx *ctx = fh_to_ctx(file->private_data);
> > +   struct mtk_vcodec_dev *dev = ctx->dev;
> > +   int ret;
> > +
> > +   mutex_lock(>dev_mutex);
> > +   ret = v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
> > +   mutex_unlock(>dev_mutex);
> > +
> > +   return ret;
> > +}
> > +
> > +static int fops_vcodec_mmap(struct file *file, struct vm_area_struct *vma)
> > +{
> > +   struct mtk_vcodec_ctx *ctx = fh_to_ctx(file->private_data);
> > +
> > +   return v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
> > +}
> > +
> > +static const struct v4l2_file_operations mtk_vcodec_fops = {
> > +   .owner  = THIS_MODULE,
> > +   .open   = fops_vcodec_open,
> > +   .release= fops_vcodec_release,
> > +   .poll   = fops_vcodec_poll,
> > +   .unlocked_ioctl = video_ioctl2,
> > +   .mmap   = fops_vcodec_mmap,
> 
> You should be able to use the v4l2_m2m_fop helper functions for poll and mmap.
> 

Hi Hans,

We are plaining to remove m2m framework in th feature, although we think
it is easy to use and could save a lot of code similar to what m2m
framework implemented and reduce code size.
The main reason is that in v4l2_m2m_try_schedule, it required that at
least one output buffer and one capture buffer to run device_run.
We want to start device_run without capture buffer queued.
Is there any suggestion that we could use m2m framework but trigger
device_run with only output buffer.
Or we need to remove m2m and write our own implementation.



snipped.


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  

Re: [PATCH 3/7] [Media] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-04-17 Thread tiffany lin
Hi Hans,

On Fri, 2016-04-15 at 16:27 +0200, Hans Verkuil wrote:
> On 04/13/2016 02:01 PM, Tiffany Lin wrote:
> > Add v4l2 layer decoder driver for MT8173
> > 
> > Signed-off-by: Tiffany Lin 
> > ---
> >  drivers/media/platform/mtk-vcodec/Makefile |   10 +-
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 1429 
> > 
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h |   81 ++
> >  .../media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c |  469 +++
> >  .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c  |  153 +++
> >  .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h  |   28 +
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |   98 +-
> >  drivers/media/platform/mtk-vcodec/vdec_drv_base.h  |   56 +
> >  drivers/media/platform/mtk-vcodec/vdec_drv_if.c|  113 ++
> >  drivers/media/platform/mtk-vcodec/vdec_drv_if.h|   93 ++
> >  drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h   |   86 ++
> >  11 files changed, 2596 insertions(+), 20 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..0499413
> > --- /dev/null
> > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> > @@ -0,0 +1,1429 @@
> > +/*
> > +* Copyright (c) 2016 MediaTek Inc.
> > +* Author: PC Chen 
> > +* Tiffany Lin 
> > +*
> > +* 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"
> > +
> > +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,
> > +   },
> > +};
> > +#define OUT_FMT_IDX0
> > +#define CAP_FMT_IDX3
> > +
> > +#define VCODEC_CAPABILITY_4K_DISABLED  0x10
> > +#define VCODEC_DEC_4K_CODED_WIDTH  4096U
> > +#define VCODEC_DEC_4K_CODED_HEIGHT 2304U
> > +
> > +#define MTK_VDEC_MIN_W 64U
> > +#define MTK_VDEC_MIN_H 64U
> > +#define MTK_VDEC_MAX_W 2048U
> > +#define MTK_VDEC_MAX_H 1088U
> > +#define DFT_CFG_WIDTH  MTK_VDEC_MIN_W
> > +#define DFT_CFG_HEIGHT MTK_VDEC_MIN_H
> > +
> > +static const struct mtk_codec_framesizes mtk_vdec_framesizes[] = {
> > +   {
> > +   .fourcc = V4L2_PIX_FMT_H264,
> > +   .stepwise = {  MTK_VDEC_MIN_W, MTK_VDEC_MAX_W, 16,
> > +   

Re: [PATCH 3/7] [Media] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-04-15 Thread Hans Verkuil
On 04/13/2016 02:01 PM, Tiffany Lin wrote:
> Add v4l2 layer decoder driver for MT8173
> 
> Signed-off-by: Tiffany Lin 
> ---
>  drivers/media/platform/mtk-vcodec/Makefile |   10 +-
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 1429 
> 
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h |   81 ++
>  .../media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c |  469 +++
>  .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c  |  153 +++
>  .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h  |   28 +
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |   98 +-
>  drivers/media/platform/mtk-vcodec/vdec_drv_base.h  |   56 +
>  drivers/media/platform/mtk-vcodec/vdec_drv_if.c|  113 ++
>  drivers/media/platform/mtk-vcodec/vdec_drv_if.h|   93 ++
>  drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h   |   86 ++
>  11 files changed, 2596 insertions(+), 20 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..0499413
> --- /dev/null
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> @@ -0,0 +1,1429 @@
> +/*
> +* Copyright (c) 2016 MediaTek Inc.
> +* Author: PC Chen 
> +* Tiffany Lin 
> +*
> +* 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"
> +
> +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,
> + },
> +};
> +#define OUT_FMT_IDX  0
> +#define CAP_FMT_IDX  3
> +
> +#define VCODEC_CAPABILITY_4K_DISABLED0x10
> +#define VCODEC_DEC_4K_CODED_WIDTH4096U
> +#define VCODEC_DEC_4K_CODED_HEIGHT   2304U
> +
> +#define MTK_VDEC_MIN_W   64U
> +#define MTK_VDEC_MIN_H   64U
> +#define MTK_VDEC_MAX_W   2048U
> +#define MTK_VDEC_MAX_H   1088U
> +#define DFT_CFG_WIDTHMTK_VDEC_MIN_W
> +#define DFT_CFG_HEIGHT   MTK_VDEC_MIN_H
> +
> +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 },
> + 

[PATCH 3/7] [Media] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-04-13 Thread Tiffany Lin
Add v4l2 layer decoder driver for MT8173

Signed-off-by: Tiffany Lin 
---
 drivers/media/platform/mtk-vcodec/Makefile |   10 +-
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 1429 
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h |   81 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c |  469 +++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c  |  153 +++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h  |   28 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |   98 +-
 drivers/media/platform/mtk-vcodec/vdec_drv_base.h  |   56 +
 drivers/media/platform/mtk-vcodec/vdec_drv_if.c|  113 ++
 drivers/media/platform/mtk-vcodec/vdec_drv_if.h|   93 ++
 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h   |   86 ++
 11 files changed, 2596 insertions(+), 20 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..0499413
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -0,0 +1,1429 @@
+/*
+* Copyright (c) 2016 MediaTek Inc.
+* Author: PC Chen 
+* Tiffany Lin 
+*
+* 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"
+
+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,
+   },
+};
+#define OUT_FMT_IDX0
+#define CAP_FMT_IDX3
+
+#define VCODEC_CAPABILITY_4K_DISABLED  0x10
+#define VCODEC_DEC_4K_CODED_WIDTH  4096U
+#define VCODEC_DEC_4K_CODED_HEIGHT 2304U
+
+#define MTK_VDEC_MIN_W 64U
+#define MTK_VDEC_MIN_H 64U
+#define MTK_VDEC_MAX_W 2048U
+#define MTK_VDEC_MAX_H 1088U
+#define DFT_CFG_WIDTH  MTK_VDEC_MIN_W
+#define DFT_CFG_HEIGHT MTK_VDEC_MIN_H
+
+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_MIN_H, MTK_VDEC_MAX_H, 16 },
+   },
+};
+
+#define NUM_SUPPORTED_FRAMESIZE