Re: [PATCH v7 5/8] [media] vcodec: mediatek: Add Mediatek V4L2 Video Encoder Driver
Hi Wucheng, On Mon, 2016-04-25 at 13:42 +0800, Wu-Cheng Li (李務誠) wrote: > > > > > > ... > > > > > > > +static int fops_vcodec_open(struct file *file) > > > > +{ > > > > + struct video_device *vfd = video_devdata(file); > > > > + struct mtk_vcodec_dev *dev = video_drvdata(file); > > > > + struct mtk_vcodec_ctx *ctx = NULL; > > > > + int ret = 0; > > > > + > > > > + if (dev->instance_mask == ~0UL) { > > > > + /* ffz Undefined if no zero exists, err handling here */ > > > > + mtk_v4l2_err("Too many open contexts"); > > > > + ret = -EBUSY; > > > > + goto err_alloc; > > > > > > I'm not happy seeing this here. You should always be able to open the > > > device. > > > I would expect to see a check like this in e.g. start_streaming, since > > > that's > > > where you start to use the hardware for real, and checking if you have > > > enough > > > resources there is perfectly fine. > > > > > > If this is an artificial constraint (i.e. not based on a real hardware > > > limitation), > > > then it should perhaps just be dropped. Such constraints tend to be > > > pointless. > > > If you want to encode 20 streams simultaneously, then why not? It will be > > > very > > > slow, but that's not this driver's problem :-) > > > > > We use ffz to get instance index. > > This only make sure that instance id is correct since in ffz > > description, > > "Undefined if no zero exists, so code should check against ~0UL first." > > In this case, it may not be able to move to start_streaming. > > Any suggestion that how we do this? > The instance index is only used for printing the debug information. > No? If that's the case, you can remove instance index and print > mtk_vcodec_ctx address for debugging. > > Got it, will remove it in next version. best regards, Tiffany > > > > > > + } > > > > + > > > > + mutex_lock(&dev->dev_mutex); > > > > + > > > > + ctx = devm_kzalloc(&dev->plat_dev->dev, sizeof(*ctx), GFP_KERNEL); > > > > > > Why is this a devm_ call? It is not managed by a device, so it seems to > > > me that > > > a regular kzalloc is good enough here. > > > > > > > + if (!ctx) { > > > > + ret = -ENOMEM; > > > > + goto err_alloc; > > > > + } > > > > + > > > > + ctx->idx = ffz(dev->instance_mask); > > > > + v4l2_fh_init(&ctx->fh, video_devdata(file)); > > > > + file->private_data = &ctx->fh; > > > > + v4l2_fh_add(&ctx->fh); > > > > + INIT_LIST_HEAD(&ctx->list); > > > > + ctx->dev = dev; > > > > + init_waitqueue_head(&ctx->queue); > > > > + > > > > + if (vfd == dev->vfd_enc) { > > > > + ctx->type = MTK_INST_ENCODER; > > > > + ret = mtk_vcodec_enc_ctrls_setup(ctx); > > > > + if (ret) { > > > > + mtk_v4l2_err("Failed to setup controls() (%d)", > > > > + ret); > > > > + goto err_ctrls_setup; > > > > + } > > > > + ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev_enc, ctx, > > > > + > > > > &mtk_vcodec_enc_queue_init); > > > > + if (IS_ERR(ctx->m2m_ctx)) { > > > > + ret = PTR_ERR(ctx->m2m_ctx); > > > > + mtk_v4l2_err("Failed to v4l2_m2m_ctx_init() (%d)", > > > > + ret); > > > > + goto err_m2m_ctx_init; > > > > + } > > > > + mtk_vcodec_enc_set_default_params(ctx); > > > > + } else { > > > > + mtk_v4l2_err("Invalid vfd !"); > > > > > > This shouldn't be possible at all. I would just drop the 'if (vfd == > > > dev->vfd_enc)' check. > > Got it, will remove in next version. > > > > > > > > > + ret = -ENOENT; > > > > + goto err_m2m_ctx_init; > > > > + } > > > > + > > > > + if (v4l2_fh_is_singular(&ctx->fh)) { > > > > + ret = vpu_load_firmware(dev->vpu_plat_dev); > > > > + if (ret < 0) { > > > > + /* > > > > + * Return 0 if downloading firmware successfully, > > > > + * otherwise it is failed > > > > + */ > > > > + mtk_v4l2_err("vpu_load_firmware failed!"); > > > > + goto err_load_fw; > > > > + } > > > > > > The fw load seems to be a one-time thing, but here it is done every time > > > someone opens the device and nobody else had it open. > > > > > > If this is a one time thing, then using a bool 'loaded_fw' makes more > > > sense. > > > > > More than one module use vpu firmware, encoder/decoder/mdp...etc. > > If this is first encode instance, we need to check and load vpu > > firmware. > > vpu_load_firmware will check and load firmware when necessary. > > > > best regards, > > Tiffany > > > > + > > > > + dev->enc_capability = > > > > + vpu_get_venc_hw_capa(dev->vpu_plat_dev); > > > > + mtk_v4l2_debug(0, "encoder capability %x", > > > > dev->enc_capa
Re: [PATCH v7 5/8] [media] vcodec: mediatek: Add Mediatek V4L2 Video Encoder Driver
> > > > ... > > > > > +static int fops_vcodec_open(struct file *file) > > > +{ > > > + struct video_device *vfd = video_devdata(file); > > > + struct mtk_vcodec_dev *dev = video_drvdata(file); > > > + struct mtk_vcodec_ctx *ctx = NULL; > > > + int ret = 0; > > > + > > > + if (dev->instance_mask == ~0UL) { > > > + /* ffz Undefined if no zero exists, err handling here */ > > > + mtk_v4l2_err("Too many open contexts"); > > > + ret = -EBUSY; > > > + goto err_alloc; > > > > I'm not happy seeing this here. You should always be able to open the > > device. > > I would expect to see a check like this in e.g. start_streaming, since > > that's > > where you start to use the hardware for real, and checking if you have > > enough > > resources there is perfectly fine. > > > > If this is an artificial constraint (i.e. not based on a real hardware > > limitation), > > then it should perhaps just be dropped. Such constraints tend to be > > pointless. > > If you want to encode 20 streams simultaneously, then why not? It will be > > very > > slow, but that's not this driver's problem :-) > > > We use ffz to get instance index. > This only make sure that instance id is correct since in ffz > description, > "Undefined if no zero exists, so code should check against ~0UL first." > In this case, it may not be able to move to start_streaming. > Any suggestion that how we do this? The instance index is only used for printing the debug information. No? If that's the case, you can remove instance index and print mtk_vcodec_ctx address for debugging. > > > > > + } > > > + > > > + mutex_lock(&dev->dev_mutex); > > > + > > > + ctx = devm_kzalloc(&dev->plat_dev->dev, sizeof(*ctx), GFP_KERNEL); > > > > Why is this a devm_ call? It is not managed by a device, so it seems to me > > that > > a regular kzalloc is good enough here. > > > > > + if (!ctx) { > > > + ret = -ENOMEM; > > > + goto err_alloc; > > > + } > > > + > > > + ctx->idx = ffz(dev->instance_mask); > > > + v4l2_fh_init(&ctx->fh, video_devdata(file)); > > > + file->private_data = &ctx->fh; > > > + v4l2_fh_add(&ctx->fh); > > > + INIT_LIST_HEAD(&ctx->list); > > > + ctx->dev = dev; > > > + init_waitqueue_head(&ctx->queue); > > > + > > > + if (vfd == dev->vfd_enc) { > > > + ctx->type = MTK_INST_ENCODER; > > > + ret = mtk_vcodec_enc_ctrls_setup(ctx); > > > + if (ret) { > > > + mtk_v4l2_err("Failed to setup controls() (%d)", > > > + ret); > > > + goto err_ctrls_setup; > > > + } > > > + ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev_enc, ctx, > > > +&mtk_vcodec_enc_queue_init); > > > + if (IS_ERR(ctx->m2m_ctx)) { > > > + ret = PTR_ERR(ctx->m2m_ctx); > > > + mtk_v4l2_err("Failed to v4l2_m2m_ctx_init() (%d)", > > > + ret); > > > + goto err_m2m_ctx_init; > > > + } > > > + mtk_vcodec_enc_set_default_params(ctx); > > > + } else { > > > + mtk_v4l2_err("Invalid vfd !"); > > > > This shouldn't be possible at all. I would just drop the 'if (vfd == > > dev->vfd_enc)' check. > Got it, will remove in next version. > > > > > > + ret = -ENOENT; > > > + goto err_m2m_ctx_init; > > > + } > > > + > > > + if (v4l2_fh_is_singular(&ctx->fh)) { > > > + ret = vpu_load_firmware(dev->vpu_plat_dev); > > > + if (ret < 0) { > > > + /* > > > + * Return 0 if downloading firmware successfully, > > > + * otherwise it is failed > > > + */ > > > + mtk_v4l2_err("vpu_load_firmware failed!"); > > > + goto err_load_fw; > > > + } > > > > The fw load seems to be a one-time thing, but here it is done every time > > someone opens the device and nobody else had it open. > > > > If this is a one time thing, then using a bool 'loaded_fw' makes more sense. > > > More than one module use vpu firmware, encoder/decoder/mdp...etc. > If this is first encode instance, we need to check and load vpu > firmware. > vpu_load_firmware will check and load firmware when necessary. > > best regards, > Tiffany > > > + > > > + dev->enc_capability = > > > + vpu_get_venc_hw_capa(dev->vpu_plat_dev); > > > + mtk_v4l2_debug(0, "encoder capability %x", > > > dev->enc_capability); > > > + } > > > + > > > + mtk_v4l2_debug(2, "Create instance [%d]@%p m2m_ctx=%p ", > > > +ctx->idx, ctx, ctx->m2m_ctx); > > > + set_bit(ctx->idx, &dev->instance_mask); > > > + dev->num_instances++; > > > + list_add(&ctx->list, &dev->ctx_list); > > > + > > > + mutex_unlock(&dev->dev_mutex); > > > + mtk_v4l2_debug(0, "%s encoder [%d]", dev_name(&dev->plat_
Re: [PATCH v7 5/8] [media] vcodec: mediatek: Add Mediatek V4L2 Video Encoder Driver
Hi Hans, On Fri, 2016-04-22 at 15:47 +0200, Hans Verkuil wrote: > On 04/22/2016 06:25 AM, Tiffany Lin wrote: > > Add v4l2 layer encoder driver for MT8173 > > > > Signed-off-by: Tiffany Lin > > > > --- > > drivers/media/platform/Kconfig | 16 + > > drivers/media/platform/Makefile|2 + > > drivers/media/platform/mtk-vcodec/Makefile | 14 + > > drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h | 339 + > > drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 1301 > > > > drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.h | 59 + > > .../media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c | 467 +++ > > .../media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c | 137 +++ > > .../media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h | 26 + > > .../media/platform/mtk-vcodec/mtk_vcodec_intr.c| 56 + > > .../media/platform/mtk-vcodec/mtk_vcodec_intr.h| 27 + > > .../media/platform/mtk-vcodec/mtk_vcodec_util.c| 96 ++ > > .../media/platform/mtk-vcodec/mtk_vcodec_util.h| 87 ++ > > drivers/media/platform/mtk-vcodec/venc_drv_base.h | 62 + > > drivers/media/platform/mtk-vcodec/venc_drv_if.c| 107 ++ > > drivers/media/platform/mtk-vcodec/venc_drv_if.h| 165 +++ > > drivers/media/platform/mtk-vcodec/venc_ipi_msg.h | 210 > > 17 files changed, 3171 insertions(+) > > create mode 100644 drivers/media/platform/mtk-vcodec/Makefile > > create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h > > create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c > > create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.h > > create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c > > create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c > > create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h > > create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.c > > create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.h > > create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c > > create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h > > create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_base.h > > create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_if.c > > create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_if.h > > create mode 100644 drivers/media/platform/mtk-vcodec/venc_ipi_msg.h > > > > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c > > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c > > new file mode 100644 > > index 000..b2b662c > > --- /dev/null > > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c > > @@ -0,0 +1,1301 @@ > > +/* V4L2 specification suggests the driver corrects the format struct if > > any of > > + * the dimensions is unsupported > > + */ > > +static int vidioc_try_fmt(struct v4l2_format *f, struct mtk_video_fmt *fmt) > > +{ > > + struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; > > + int i; > > + > > + pix_fmt_mp->field = V4L2_FIELD_NONE; > > + > > + if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { > > + pix_fmt_mp->num_planes = 1; > > + pix_fmt_mp->plane_fmt[0].bytesperline = 0; > > + } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { > > + int tmp_w, tmp_h; > > + > > + pix_fmt_mp->height = clamp(pix_fmt_mp->height, > > + MTK_VENC_MIN_H, > > + MTK_VENC_MAX_H); > > + pix_fmt_mp->width = clamp(pix_fmt_mp->width, > > + MTK_VENC_MIN_W, > > + MTK_VENC_MAX_W); > > Strange indentation. I see this in more places. Can you check this and fix > where needed? > I will fix all this strange indentation in next version. > > + > > + /* find next closer width align 16, heign align 32, size align > > + * 64 rectangle > > + */ > > + tmp_w = pix_fmt_mp->width; > > + tmp_h = pix_fmt_mp->height; > > + v4l_bound_align_image(&pix_fmt_mp->width, > > + MTK_VENC_MIN_W, > > + MTK_VENC_MAX_W, 4, > > + &pix_fmt_mp->height, > > + MTK_VENC_MIN_H, > > + MTK_VENC_MAX_H, 5, 6); > > + > > ... > > > +static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv, > > +struct v4l2_format *f) > > +{ > > + struct mtk_video_fmt *fmt; > > + > > + fmt = mtk_venc_find_format(f); > > + if (!fmt) { > > + f->fmt.pix.pix
Re: [PATCH v7 5/8] [media] vcodec: mediatek: Add Mediatek V4L2 Video Encoder Driver
On 04/22/2016 06:25 AM, Tiffany Lin wrote: > Add v4l2 layer encoder driver for MT8173 > > Signed-off-by: Tiffany Lin > > --- > drivers/media/platform/Kconfig | 16 + > drivers/media/platform/Makefile|2 + > drivers/media/platform/mtk-vcodec/Makefile | 14 + > drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h | 339 + > drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 1301 > > drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.h | 59 + > .../media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c | 467 +++ > .../media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c | 137 +++ > .../media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h | 26 + > .../media/platform/mtk-vcodec/mtk_vcodec_intr.c| 56 + > .../media/platform/mtk-vcodec/mtk_vcodec_intr.h| 27 + > .../media/platform/mtk-vcodec/mtk_vcodec_util.c| 96 ++ > .../media/platform/mtk-vcodec/mtk_vcodec_util.h| 87 ++ > drivers/media/platform/mtk-vcodec/venc_drv_base.h | 62 + > drivers/media/platform/mtk-vcodec/venc_drv_if.c| 107 ++ > drivers/media/platform/mtk-vcodec/venc_drv_if.h| 165 +++ > drivers/media/platform/mtk-vcodec/venc_ipi_msg.h | 210 > 17 files changed, 3171 insertions(+) > create mode 100644 drivers/media/platform/mtk-vcodec/Makefile > create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h > create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c > create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.h > create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c > create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c > create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h > create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.c > create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.h > create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c > create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h > create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_base.h > create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_if.c > create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_if.h > create mode 100644 drivers/media/platform/mtk-vcodec/venc_ipi_msg.h > > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c > new file mode 100644 > index 000..b2b662c > --- /dev/null > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c > @@ -0,0 +1,1301 @@ > +/* V4L2 specification suggests the driver corrects the format struct if any > of > + * the dimensions is unsupported > + */ > +static int vidioc_try_fmt(struct v4l2_format *f, struct mtk_video_fmt *fmt) > +{ > + struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; > + int i; > + > + pix_fmt_mp->field = V4L2_FIELD_NONE; > + > + if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { > + pix_fmt_mp->num_planes = 1; > + pix_fmt_mp->plane_fmt[0].bytesperline = 0; > + } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { > + int tmp_w, tmp_h; > + > + pix_fmt_mp->height = clamp(pix_fmt_mp->height, > + MTK_VENC_MIN_H, > + MTK_VENC_MAX_H); > + pix_fmt_mp->width = clamp(pix_fmt_mp->width, > + MTK_VENC_MIN_W, > + MTK_VENC_MAX_W); Strange indentation. I see this in more places. Can you check this and fix where needed? > + > + /* find next closer width align 16, heign align 32, size align > + * 64 rectangle > + */ > + tmp_w = pix_fmt_mp->width; > + tmp_h = pix_fmt_mp->height; > + v4l_bound_align_image(&pix_fmt_mp->width, > + MTK_VENC_MIN_W, > + MTK_VENC_MAX_W, 4, > + &pix_fmt_mp->height, > + MTK_VENC_MIN_H, > + MTK_VENC_MAX_H, 5, 6); > + ... > +static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv, > + struct v4l2_format *f) > +{ > + struct mtk_video_fmt *fmt; > + > + fmt = mtk_venc_find_format(f); > + if (!fmt) { > + f->fmt.pix.pixelformat = mtk_video_formats[OUT_FMT_IDX].fourcc; > + fmt = mtk_venc_find_format(f); > + } > + if (!f->fmt.pix_mp.colorspace) > + f->fmt.pix_mp.colorspace = V4L2_COLORSPACE_REC709; > + f->fmt.pix_mp.ycbcr_enc = V4L2_YCBCR_ENC_
Re: [PATCH v7 5/8] [media] vcodec: mediatek: Add Mediatek V4L2 Video Encoder Driver
Hi, [auto build test WARNING on linuxtv-media/master] [also build test WARNING on v4.6-rc4 next-20160421] [if your patch is applied to the wrong git tree, please drop us a note to help improving the system] url: https://github.com/0day-ci/linux/commits/Tiffany-Lin/Add-MT8173-Video-Encoder-Driver-and-VPU-Driver/20160422-123111 base: git://linuxtv.org/media_tree.git master config: i386-allyesconfig (attached as .config) reproduce: # save the attached .config to linux build tree make ARCH=i386 All warnings (new ones prefixed by >>): drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c: In function 'mtk_venc_encode_header': >> drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c:896:43: warning: format >> '%lx' expects argument of type 'long unsigned int', but argument 9 has type >> 'size_t {aka unsigned int}' [-Wformat=] drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c: In function 'mtk_venc_worker': drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c:1046:43: warning: format '%lx' expects argument of type 'long unsigned int', but argument 7 has type 'size_t {aka unsigned int}' [-Wformat=] drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c:1046:43: warning: format '%lx' expects argument of type 'long unsigned int', but argument 10 has type 'size_t {aka unsigned int}' [-Wformat=] drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c:1046:43: warning: format '%lx' expects argument of type 'long unsigned int', but argument 13 has type 'size_t {aka unsigned int}' [-Wformat=] vim +896 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 880 struct mtk_vcodec_ctx *ctx = priv; 881 int ret; 882 struct vb2_buffer *dst_buf; 883 struct mtk_vcodec_mem bs_buf; 884 struct venc_done_result enc_result; 885 886 dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx); 887 if (!dst_buf) { 888 mtk_v4l2_debug(1, "No dst buffer"); 889 return -EINVAL; 890 } 891 892 bs_buf.va = vb2_plane_vaddr(dst_buf, 0); 893 bs_buf.dma_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 0); 894 bs_buf.size = (size_t)dst_buf->planes[0].length; 895 > 896 mtk_v4l2_debug(1, 897 "[%d] buf idx=%d va=0x%p dma_addr=0x%llx size=0x%lx", 898 ctx->idx, 899 dst_buf->index, bs_buf.va, 900 (u64)bs_buf.dma_addr, 901 bs_buf.size); 902 903 ret = venc_if_encode(ctx, 904 VENC_START_OPT_ENCODE_SEQUENCE_HEADER, --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
[PATCH v7 5/8] [media] vcodec: mediatek: Add Mediatek V4L2 Video Encoder Driver
Add v4l2 layer encoder driver for MT8173 Signed-off-by: Tiffany Lin --- drivers/media/platform/Kconfig | 16 + drivers/media/platform/Makefile|2 + drivers/media/platform/mtk-vcodec/Makefile | 14 + drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h | 339 + drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 1301 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.h | 59 + .../media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c | 467 +++ .../media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c | 137 +++ .../media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h | 26 + .../media/platform/mtk-vcodec/mtk_vcodec_intr.c| 56 + .../media/platform/mtk-vcodec/mtk_vcodec_intr.h| 27 + .../media/platform/mtk-vcodec/mtk_vcodec_util.c| 96 ++ .../media/platform/mtk-vcodec/mtk_vcodec_util.h| 87 ++ drivers/media/platform/mtk-vcodec/venc_drv_base.h | 62 + drivers/media/platform/mtk-vcodec/venc_drv_if.c| 107 ++ drivers/media/platform/mtk-vcodec/venc_drv_if.h| 165 +++ drivers/media/platform/mtk-vcodec/venc_ipi_msg.h | 210 17 files changed, 3171 insertions(+) create mode 100644 drivers/media/platform/mtk-vcodec/Makefile create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.h create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.c create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.h create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_base.h create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_if.c create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_if.h create mode 100644 drivers/media/platform/mtk-vcodec/venc_ipi_msg.h diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig index 74c3575..13b765a 100644 --- a/drivers/media/platform/Kconfig +++ b/drivers/media/platform/Kconfig @@ -165,6 +165,22 @@ config VIDEO_MEDIATEK_VPU To compile this driver as a module, choose M here: the module will be called mtk-vpu. +config VIDEO_MEDIATEK_VCODEC + tristate "Mediatek Video Codec driver" + depends on VIDEO_DEV && VIDEO_V4L2 + depends on ARCH_MEDIATEK || COMPILE_TEST + select VIDEOBUF2_DMA_CONTIG + select V4L2_MEM2MEM_DEV + select VIDEO_MEDIATEK_VPU + default n + ---help--- + Mediatek video codec driver provides HW capability to + encode and decode in a range of video formats + This driver rely on VPU driver to communicate with VPU. + + To compile this driver as a module, choose M here: the + module will be called mtk-vcodec + config VIDEO_MEM2MEM_DEINTERLACE tristate "Deinterlace support" depends on VIDEO_DEV && VIDEO_V4L2 && DMA_ENGINE diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile index 2efb7b1..6e735fe 100644 --- a/drivers/media/platform/Makefile +++ b/drivers/media/platform/Makefile @@ -58,3 +58,5 @@ obj-$(CONFIG_VIDEO_XILINX)+= xilinx/ ccflags-y += -I$(srctree)/drivers/media/i2c obj-$(CONFIG_VIDEO_MEDIATEK_VPU) += mtk-vpu/ + +obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC)+= mtk-vcodec/ diff --git a/drivers/media/platform/mtk-vcodec/Makefile b/drivers/media/platform/mtk-vcodec/Makefile new file mode 100644 index 000..d04433be --- /dev/null +++ b/drivers/media/platform/mtk-vcodec/Makefile @@ -0,0 +1,14 @@ + +obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-enc.o mtk-vcodec-common.o + + + +mtk-vcodec-enc-y := mtk_vcodec_enc.o \ + mtk_vcodec_enc_drv.o \ + mtk_vcodec_enc_pm.o \ + venc_drv_if.o \ + +mtk-vcodec-common-y := mtk_vcodec_intr.o \ + mtk_vcodec_util.o\ + +ccflags-y += -I$(srctree)/drivers/media/platform/mtk-vpu diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h new file mode 100644 index 000..bf41ff3 --- /dev/null +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h @@ -0,0 +1,339 @@ +/* +* 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 wa