[EXT] Re: [PATCH v9 07/13] media: amphion: add v4l2 m2m vpu encoder stateful driver

Ming Qian ming.qian at nxp.com
Thu Sep 23 18:47:51 PDT 2021


> -----Original Message-----
> From: Nicolas Dufresne [mailto:nicolas at ndufresne.ca]
> Sent: Thursday, September 23, 2021 10:23 PM
> To: Ming Qian <ming.qian at nxp.com>; mchehab at kernel.org;
> shawnguo at kernel.org; robh+dt at kernel.org; s.hauer at pengutronix.de
> Cc: hverkuil-cisco at xs4all.nl; kernel at pengutronix.de; festevam at gmail.com;
> dl-linux-imx <linux-imx at nxp.com>; Aisheng Dong <aisheng.dong at nxp.com>;
> linux-media at vger.kernel.org; linux-kernel at vger.kernel.org;
> devicetree at vger.kernel.org; linux-arm-kernel at lists.infradead.org
> Subject: [EXT] Re: [PATCH v9 07/13] media: amphion: add v4l2 m2m vpu
> encoder stateful driver
> 
> Caution: EXT Email
> 
> Le lundi 13 septembre 2021 à 17:11 +0800, Ming Qian a écrit :
> > This consists of video encoder implementation plus encoder controls.
> >
> > Signed-off-by: Ming Qian <ming.qian at nxp.com>
> > Signed-off-by: Shijie Qin <shijie.qin at nxp.com>
> > Signed-off-by: Zhou Peng <eagle.zhou at nxp.com>
> > ---
> >  drivers/media/platform/amphion/venc.c | 1382
> > +++++++++++++++++++++++++
> >  1 file changed, 1382 insertions(+)
> >  create mode 100644 drivers/media/platform/amphion/venc.c
> >
> > diff --git a/drivers/media/platform/amphion/venc.c
> > b/drivers/media/platform/amphion/venc.c
> > new file mode 100644
> > index 000000000000..fdc9a59009ba
> > --- /dev/null
> > +++ b/drivers/media/platform/amphion/venc.c
> > @@ -0,0 +1,1382 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Copyright 2020-2021 NXP
> > + */
> > +
> > +#define TAG          "ENC"
> > +
> > +#include <linux/init.h>
> > +#include <linux/interconnect.h>
> > +#include <linux/ioctl.h>
> > +#include <linux/list.h>
> > +#include <linux/kernel.h>
> > +#include <linux/module.h>
> > +#include <linux/delay.h>
> > +#include <linux/videodev2.h>
> > +#include <linux/ktime.h>
> > +#include <media/v4l2-device.h>
> > +#include <media/v4l2-event.h>
> > +#include <media/v4l2-mem2mem.h>
> > +#include <media/v4l2-ioctl.h>
> > +#include <media/videobuf2-v4l2.h>
> > +#include <media/videobuf2-dma-contig.h> #include
> > +<media/videobuf2-vmalloc.h> #include "vpu.h"
> > +#include "vpu_defs.h"
> > +#include "vpu_core.h"
> > +#include "vpu_helpers.h"
> > +#include "vpu_v4l2.h"
> > +#include "vpu_cmds.h"
> > +#include "vpu_rpc.h"
> > +#include "vpu_log.h"
> > +
> > +#define VENC_OUTPUT_ENABLE   (1 << 0)
> > +#define VENC_CAPTURE_ENABLE  (1 << 1)
> > +#define VENC_ENABLE_MASK     (VENC_OUTPUT_ENABLE |
> VENC_CAPTURE_ENABLE)
> > +#define VENC_MAX_BUF_CNT     8
> > +
> > +struct venc_t {
> > +     struct vpu_encode_params params;
> > +     u32 request_key_frame;
> > +     u32 input_ready;
> > +     u32 cpb_size;
> > +     bool bitrate_change;
> > +
> > +     struct vpu_buffer enc[VENC_MAX_BUF_CNT];
> > +     struct vpu_buffer ref[VENC_MAX_BUF_CNT];
> > +     struct vpu_buffer act[VENC_MAX_BUF_CNT];
> > +     struct list_head frames;
> > +     u32 frame_count;
> > +     u32 encode_count;
> > +     u32 ready_count;
> > +     u32 enable;
> > +     u32 stopped;
> > +
> > +     u32 skipped_count;
> > +     u32 skipped_bytes;
> > +
> > +     wait_queue_head_t wq;
> > +};
> > +
> > +struct venc_frame_t {
> > +     struct list_head list;
> > +     struct vpu_enc_pic_info info;
> > +     u32 bytesused;
> > +     s64 timestamp;
> > +};
> > +
> > +static const struct vpu_format venc_formats[] = {
> > +     {
> > +             .pixfmt = V4L2_PIX_FMT_NV12,
> > +             .num_planes = 2,
> > +             .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> 
> pixmp->num_planes is the number of allocation. V4L2_PIX_FMT_NV12 must
> pixmp->come with
> 1 allocation and [0] V4L2_PIX_FMT_NV12M must come with 2 allocations.
> 
> [0]
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ke
> rnel.org%2Fdoc%2Fhtml%2Fv4.10%2Fmedia%2Fuapi%2Fv4l%2Fpixfmt-nv12m
> .html&data=04%7C01%7Cming.qian%40nxp.com%7Cb1b9aac4f17a446f1
> cf008d97e9d975d%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6
> 37680037585331278%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwM
> DAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata
> =AlH44y9iNomGKenkm4%2F1sfowhqX%2Fivc3z4FTlCgilfA%3D&reserved
> =0
> 
> This currently confuses GStreamer and prevent encoding.
> 
OK, I'll try to support V4L2_PIX_FMT_NV12M in the next version



More information about the linux-arm-kernel mailing list