Thread (29 messages) 29 messages, 3 authors, 2021-10-11

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

From: Ming Qian <ming.qian@nxp.com>
Date: 2021-09-24 01:47:57
Also in: linux-devicetree, linux-media, lkml

-----Original Message-----
From: Nicolas Dufresne [mailto:nicolas@ndufresne.ca]
Sent: Thursday, September 23, 2021 10:23 PM
To: Ming Qian <ming.qian@nxp.com>; mchehab@kernel.org;
shawnguo@kernel.org; robh+dt@kernel.org; s.hauer@pengutronix.de
Cc: hverkuil-cisco@xs4all.nl; kernel@pengutronix.de; festevam@gmail.com;
dl-linux-imx [off-list ref]; Aisheng Dong [off-list ref];
linux-media@vger.kernel.org; linux-kernel@vger.kernel.org;
devicetree@vger.kernel.org; linux-arm-kernel@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 :
quoted
This consists of video encoder implementation plus encoder controls.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Shijie Qin <redacted>
Signed-off-by: Zhou Peng <eagle.zhou@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)
quoted
+#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&amp;data=04%7C01%7Cming.qian%40nxp.com%7Cb1b9aac4f17a446f1
cf008d97e9d975d%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6
37680037585331278%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwM
DAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata
=AlH44y9iNomGKenkm4%2F1sfowhqX%2Fivc3z4FTlCgilfA%3D&amp;reserved
=0

This currently confuses GStreamer and prevent encoding.
OK, I'll try to support V4L2_PIX_FMT_NV12M in the next version

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help