From: Boris Brezillon <boris.brezillon@collabora.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hans.verkuil@cisco.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Sakari Ailus <sakari.ailus@iki.fi>,
linux-media@vger.kernel.org
Cc: Tomasz Figa <tfiga@chromium.org>,
Nicolas Dufresne <nicolas@ndufresne.ca>,
kernel@collabora.com,
Paul Kocialkowski <paul.kocialkowski@bootlin.com>,
Maxime Ripard <maxime.ripard@bootlin.com>,
Ezequiel Garcia <ezequiel@collabora.com>,
Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@siol.net>,
Alexandre Courbot <acourbot@chromium.org>,
Thierry Reding <thierry.reding@gmail.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
Boris Brezillon <boris.brezillon@collabora.com>
Subject: [RFC PATCH 4/5] media: v4l2: Provide helpers for H264 codecs
Date: Mon, 5 Aug 2019 11:48:26 +0200 [thread overview]
Message-ID: <20190805094827.11205-5-boris.brezillon@collabora.com> (raw)
In-Reply-To: <20190805094827.11205-1-boris.brezillon@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
---
drivers/media/v4l2-core/Kconfig | 5 +
drivers/media/v4l2-core/Makefile | 1 +
.../media/v4l2-core/v4l2-mem2mem-h264-codec.c | 47 ++++++++
include/media/v4l2-mem2mem-h264-codec.h | 100 ++++++++++++++++++
4 files changed, 153 insertions(+)
create mode 100644 drivers/media/v4l2-core/v4l2-mem2mem-h264-codec.c
create mode 100644 include/media/v4l2-mem2mem-h264-codec.h
diff --git a/drivers/media/v4l2-core/Kconfig b/drivers/media/v4l2-core/Kconfig
index 2ee185b58c72..3841df2d9ac2 100644
--- a/drivers/media/v4l2-core/Kconfig
+++ b/drivers/media/v4l2-core/Kconfig
@@ -49,6 +49,11 @@ config V4L2_MEM2MEM_CODEC
bool
depends on V4L2_MEM2MEM_DEV
+config V4L2_MEM2MEM_H264_CODEC
+ bool
+ depends on V4L2_MEM2MEM_DEV
+ select V4L2_MEM2MEM_CODEC
+
# Used by LED subsystem flash drivers
config V4L2_FLASH_LED_CLASS
tristate "V4L2 flash API for LED flash class devices"
diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile
index 9c18fed9ea5a..67672adf2b78 100644
--- a/drivers/media/v4l2-core/Makefile
+++ b/drivers/media/v4l2-core/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_VIDEO_TUNER) += tuner.o
v4l2-mem2mem-y = v4l2-mem2mem-core.o
v4l2-mem2mem-$(CONFIG_V4L2_MEM2MEM_CODEC) += v4l2-mem2mem-codec.o
+v4l2-mem2mem-$(CONFIG_V4L2_MEM2MEM_H264_CODEC) += v4l2-mem2mem-h264-codec.o
obj-$(CONFIG_V4L2_MEM2MEM_DEV) += v4l2-mem2mem.o
obj-$(CONFIG_V4L2_FLASH_LED_CLASS) += v4l2-flash-led-class.o
diff --git a/drivers/media/v4l2-core/v4l2-mem2mem-h264-codec.c b/drivers/media/v4l2-core/v4l2-mem2mem-h264-codec.c
new file mode 100644
index 000000000000..d53d69825646
--- /dev/null
+++ b/drivers/media/v4l2-core/v4l2-mem2mem-h264-codec.c
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Memory-to-memory H264 codec framework for Video for Linux 2.
+ *
+ * Helper functions for H264 codec devices that use memory buffers for both
+ * source and destination.
+ *
+ * Copyright (c) 2019 Collabora Ltd.
+ *
+ * Author:
+ * Boris Brezillon <boris.brezillon@collabora.com>
+ */
+
+#include <linux/types.h>
+#include <media/v4l2-mem2mem-h264-codec.h>
+
+/**
+ * v4l2_m2m_h264_decode_run_preamble() - H264 decode run preamble
+ * @ctx: the context this run is triggered on
+ * @run: the H264 decode run object
+ *
+ * Initialize all @run fields (controls and src/dst bufs attached to this run).
+ */
+void v4l2_m2m_h264_decode_run_preamble(struct v4l2_m2m_codec_ctx *ctx,
+ struct v4l2_m2m_h264_decode_run *run)
+{
+ struct v4l2_ctrl *ctrl;
+
+ ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl,
+ V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS);
+ run->decode_params = ctrl ? ctrl->p_cur.p : NULL;
+ ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl,
+ V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS);
+ run->slices_params = ctrl ? ctrl->p_cur.p : NULL;
+ ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl,
+ V4L2_CID_MPEG_VIDEO_H264_SPS);
+ run->sps = ctrl ? ctrl->p_cur.p : NULL;
+ ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl,
+ V4L2_CID_MPEG_VIDEO_H264_PPS);
+ run->pps = ctrl ? ctrl->p_cur.p : NULL;
+ ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl,
+ V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX);
+ run->scaling_matrix = ctrl ? ctrl->p_cur.p : NULL;
+
+ v4l2_m2m_codec_run_preamble(ctx, &run->base);
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_h264_decode_run_preamble);
diff --git a/include/media/v4l2-mem2mem-h264-codec.h b/include/media/v4l2-mem2mem-h264-codec.h
new file mode 100644
index 000000000000..922e75d682ed
--- /dev/null
+++ b/include/media/v4l2-mem2mem-h264-codec.h
@@ -0,0 +1,100 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Memory-to-memory H264 codec framework for Video for Linux 2.
+ *
+ * Helper functions for H264 codec devices that use memory buffers for both
+ * source and destination.
+ *
+ * Copyright (c) 2019 Collabora Ltd.
+ *
+ * Author:
+ * Boris Brezillon <boris.brezillon@collabora.com>
+ */
+
+#ifndef _MEDIA_V4L2_MEM2MEM_H264_CODEC_H
+#define _MEDIA_V4L2_MEM2MEM_H264_CODEC_H
+
+#include <media/h264-ctrls.h>
+#include <media/v4l2-mem2mem-codec.h>
+
+/**
+ * struct v4l2_m2m_h264_decode_run - H264 decode run
+ * @base: inherit from v4l2_m2m_codec_run
+ * @decode_params: H264 decode params for this run
+ * @slices_params: H264 slices params for this run
+ * @sps: H264 SPS params for this run
+ * @pps: H264 PPS params for this run
+ * @scaling_matrix: H264 scaling matrix params for this run
+ */
+struct v4l2_m2m_h264_decode_run {
+ struct v4l2_m2m_codec_run base;
+ const struct v4l2_ctrl_h264_decode_params *decode_params;
+ const struct v4l2_ctrl_h264_slice_params *slices_params;
+ const struct v4l2_ctrl_h264_sps *sps;
+ const struct v4l2_ctrl_h264_pps *pps;
+ const struct v4l2_ctrl_h264_scaling_matrix *scaling_matrix;
+};
+
+void v4l2_m2m_h264_decode_run_preamble(struct v4l2_m2m_codec_ctx *ctx,
+ struct v4l2_m2m_h264_decode_run *run);
+
+/**
+ * v4l2_m2m_h264_decode_run_postamble() - H264 decode postamble
+ * @ctx: the codex this run was triggered on
+ * @run: the H264 decode run object
+ *
+ * Finish the run.
+ */
+static inline void
+v4l2_m2m_h264_decode_run_postamble(struct v4l2_m2m_codec_ctx *ctx,
+ struct v4l2_m2m_h264_decode_run *run)
+{
+ v4l2_m2m_codec_run_postamble(ctx, &run->base);
+}
+
+#define V4L2_M2M_H264_DEC_DECODE_PARAMS_CTRL \
+ { \
+ .per_request = true, \
+ .mandatory = true, \
+ .cfg.id = V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS, \
+ }
+
+#define V4L2_M2M_H264_DEC_SLICE_PARAMS_CTRL \
+ { \
+ .per_request = true, \
+ .mandatory = true, \
+ .cfg.id = V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS, \
+ .cfg.dims[0] = V4L2_H264_MAX_SLICES_PER_FRAME, \
+ }
+
+#define V4L2_M2M_H264_DEC_SPS_CTRL \
+ { \
+ .per_request = true, \
+ .mandatory = true, \
+ .cfg.id = V4L2_CID_MPEG_VIDEO_H264_SPS, \
+ }
+
+#define V4L2_M2M_H264_DEC_PPS_CTRL \
+ { \
+ .per_request = true, \
+ .mandatory = true, \
+ .cfg.id = V4L2_CID_MPEG_VIDEO_H264_PPS, \
+ }
+
+#define V4L2_M2M_H264_DEC_SCALING_MATRIX_CTRL \
+ { \
+ .per_request = true, \
+ .mandatory = true, \
+ .cfg.id = V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX, \
+ }
+
+#define V4L2_M2M_H264_DEC_MODE_CTRL(_unsupported_modes, _default_mode) \
+ { \
+ .mandatory = true, \
+ .cfg.id = V4L2_CID_MPEG_VIDEO_H264_DECODING_MODE, \
+ .cfg.max = V4L2_MPEG_VIDEO_H264_FRAME_BASED_DECODING, \
+ .cfg.menu_skip_mask = _unsupported_modes, \
+ .cfg.def = _default_mode, \
+ }
+
+#endif /* _MEDIA_V4L2_MEM2MEM_H264_CODEC_H */
--
2.21.0
next prev parent reply other threads:[~2019-08-05 9:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-05 9:48 [RFC PATCH 0/5] media: v4l2: Add m2m codec helpers Boris Brezillon
2019-08-05 9:48 ` [RFC PATCH 1/5] media: vb2: Add a helper to get the vb2 buffer attached to a request Boris Brezillon
2019-08-05 13:12 ` Hans Verkuil
2019-08-05 14:13 ` Boris Brezillon
2019-08-05 16:56 ` Hans Verkuil
2019-08-05 9:48 ` [RFC PATCH 2/5] media: v4l2: Prepare things for addition of m2m codec helpers Boris Brezillon
2019-08-05 9:48 ` [RFC PATCH 3/5] media: v4l2: Add " Boris Brezillon
2019-08-05 16:53 ` Hans Verkuil
2019-08-05 17:59 ` Boris Brezillon
2019-08-05 9:48 ` Boris Brezillon [this message]
2019-08-05 9:48 ` [RFC PATCH 5/5] media: rockchip: Add the rkvdec driver Boris Brezillon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190805094827.11205-5-boris.brezillon@collabora.com \
--to=boris.brezillon@collabora.com \
--cc=acourbot@chromium.org \
--cc=ezequiel@collabora.com \
--cc=hans.verkuil@cisco.com \
--cc=jernej.skrabec@siol.net \
--cc=jonas@kwiboo.se \
--cc=kernel@collabora.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=maxime.ripard@bootlin.com \
--cc=mchehab@kernel.org \
--cc=nicolas@ndufresne.ca \
--cc=p.zabel@pengutronix.de \
--cc=paul.kocialkowski@bootlin.com \
--cc=sakari.ailus@iki.fi \
--cc=tfiga@chromium.org \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox