From: Paul Kocialkowski <paulk@sys-base.io>
To: devicetree@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org
Cc: Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Nicolas Dufresne <nicolas.dufresne@collabora.com>,
Benjamin Gaignard <benjamin.gaignard@collabora.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@kernel.org>,
Marco Felsch <m.felsch@pengutronix.de>,
Michael Tretter <m.tretter@pengutronix.de>,
Paul Kocialkowski <paulk@sys-base.io>
Subject: [PATCH 11/14] media: verisilicon: Add common encoder parm and frameintervals ioctls
Date: Fri, 22 May 2026 12:16:50 +0200 [thread overview]
Message-ID: <20260522101653.2565125-12-paulk@sys-base.io> (raw)
In-Reply-To: <20260522101653.2565125-1-paulk@sys-base.io>
This introduces the required encoder ioctls for configuring the
frame rate (via the parm timeperframe field) and enumerating available
frame rates (via enum_frameintervals) for the encoder.
Signed-off-by: Paul Kocialkowski <paulk@sys-base.io>
---
drivers/media/platform/verisilicon/hantro.h | 3 +
.../media/platform/verisilicon/hantro_drv.c | 3 +
.../media/platform/verisilicon/hantro_v4l2.c | 99 +++++++++++++++++++
3 files changed, 105 insertions(+)
diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/platform/verisilicon/hantro.h
index e0fdc4535b2d..badd0b13988c 100644
--- a/drivers/media/platform/verisilicon/hantro.h
+++ b/drivers/media/platform/verisilicon/hantro.h
@@ -258,6 +258,9 @@ struct hantro_ctx {
struct v4l2_pix_format_mplane dst_fmt;
struct v4l2_pix_format_mplane ref_fmt;
+ struct v4l2_fract src_timeperframe;
+ struct v4l2_fract dst_timeperframe;
+
struct v4l2_ctrl_handler ctrl_handler;
int jpeg_quality;
int bit_depth;
diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 6f72e25fa88c..d798ba361b25 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -923,8 +923,11 @@ static int hantro_add_func(struct hantro_dev *vpu, unsigned int funcid)
vpu->decoder = func;
v4l2_disable_ioctl(vfd, VIDIOC_TRY_ENCODER_CMD);
v4l2_disable_ioctl(vfd, VIDIOC_ENCODER_CMD);
+ v4l2_disable_ioctl(vfd, VIDIOC_ENUM_FRAMEINTERVALS);
v4l2_disable_ioctl(vfd, VIDIOC_G_SELECTION);
v4l2_disable_ioctl(vfd, VIDIOC_S_SELECTION);
+ v4l2_disable_ioctl(vfd, VIDIOC_G_PARM);
+ v4l2_disable_ioctl(vfd, VIDIOC_S_PARM);
}
video_set_drvdata(vfd, vpu);
diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c
index 1001feee5c07..2125f2913d9a 100644
--- a/drivers/media/platform/verisilicon/hantro_v4l2.c
+++ b/drivers/media/platform/verisilicon/hantro_v4l2.c
@@ -213,6 +213,41 @@ static int vidioc_enum_framesizes(struct file *file, void *priv,
return 0;
}
+static int vidioc_enum_frameintervals(struct file *file, void *priv,
+ struct v4l2_frmivalenum *fival)
+{
+ struct v4l2_frmsizeenum fsize = { 0 };
+ unsigned int width = fival->width;
+ unsigned int height = fival->height;
+ int ret;
+
+ if (fival->index > 0)
+ return -EINVAL;
+
+ /* First check that the provided format and dimensions are valid. */
+ fsize.pixel_format = fival->pixel_format;
+ ret = vidioc_enum_framesizes(file, priv, &fsize);
+ if (ret)
+ return ret;
+
+ if (width < fsize.stepwise.min_width ||
+ width > fsize.stepwise.max_width ||
+ height < fsize.stepwise.min_height ||
+ height > fsize.stepwise.max_height)
+ return -EINVAL;
+
+ /* Any possible frame interval is acceptable. */
+ fival->type = V4L2_FRMIVAL_TYPE_CONTINUOUS;
+ fival->stepwise.min.numerator = 1;
+ fival->stepwise.min.denominator = USHRT_MAX;
+ fival->stepwise.max.numerator = USHRT_MAX;
+ fival->stepwise.max.denominator = 1;
+ fival->stepwise.step.numerator = 1;
+ fival->stepwise.step.denominator = 1;
+
+ return 0;
+}
+
static int vidioc_enum_fmt(struct file *file, void *priv,
struct v4l2_fmtdesc *f, bool capture)
@@ -484,10 +519,23 @@ hantro_reset_raw_fmt(struct hantro_ctx *ctx, int bit_depth, bool need_postproc)
return ret;
}
+static void
+hantro_reset_timeperframe(struct hantro_ctx *ctx)
+{
+ struct v4l2_fract *timeperframe = &ctx->src_timeperframe;
+ struct v4l2_fract *timeperframe_propagate = &ctx->dst_timeperframe;
+
+ timeperframe->numerator = 1;
+ timeperframe->denominator = 25;
+
+ *timeperframe_propagate = *timeperframe;
+}
+
void hantro_reset_fmts(struct hantro_ctx *ctx)
{
hantro_reset_encoded_fmt(ctx);
hantro_reset_raw_fmt(ctx, HANTRO_DEFAULT_BIT_DEPTH, HANTRO_AUTO_POSTPROC);
+ hantro_reset_timeperframe(ctx);
}
static void
@@ -739,6 +787,54 @@ static int vidioc_s_selection(struct file *file, void *priv,
return 0;
}
+static int vidioc_g_parm(struct file *file, void *priv,
+ struct v4l2_streamparm *parm)
+{
+ struct hantro_ctx *ctx = file_to_ctx(file);
+ struct v4l2_fract *timeperframe;
+
+ if (V4L2_TYPE_IS_OUTPUT(parm->type)) {
+ timeperframe = &ctx->src_timeperframe;
+ parm->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
+ parm->parm.output.timeperframe = *timeperframe;
+ } else {
+ timeperframe = &ctx->dst_timeperframe;
+ parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
+ parm->parm.capture.timeperframe = *timeperframe;
+ }
+
+ return 0;
+}
+
+static int vidioc_s_parm(struct file *file, void *priv,
+ struct v4l2_streamparm *parm)
+{
+ struct hantro_ctx *ctx = file_to_ctx(file);
+ struct v4l2_fract *timeperframe_propagate;
+ struct v4l2_fract *timeperframe_ctx;
+ struct v4l2_fract *timeperframe;
+
+ if (V4L2_TYPE_IS_OUTPUT(parm->type)) {
+ parm->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
+ timeperframe = &parm->parm.output.timeperframe;
+ timeperframe_ctx = &ctx->src_timeperframe;
+ timeperframe_propagate = &ctx->dst_timeperframe;
+ } else {
+ parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
+ timeperframe = &parm->parm.capture.timeperframe;
+ timeperframe_ctx = &ctx->dst_timeperframe;
+ timeperframe_propagate = NULL;
+ }
+
+ *timeperframe_ctx = *timeperframe;
+
+ /* Propagate from source to destination. */
+ if (timeperframe_propagate)
+ *timeperframe_propagate = *timeperframe;
+
+ return 0;
+}
+
static const struct v4l2_event hantro_eos_event = {
.type = V4L2_EVENT_EOS
};
@@ -774,6 +870,7 @@ static int vidioc_encoder_cmd(struct file *file, void *priv,
const struct v4l2_ioctl_ops hantro_ioctl_ops = {
.vidioc_querycap = vidioc_querycap,
.vidioc_enum_framesizes = vidioc_enum_framesizes,
+ .vidioc_enum_frameintervals = vidioc_enum_frameintervals,
.vidioc_try_fmt_vid_cap_mplane = vidioc_try_fmt_cap_mplane,
.vidioc_try_fmt_vid_out_mplane = vidioc_try_fmt_out_mplane,
@@ -801,6 +898,8 @@ const struct v4l2_ioctl_ops hantro_ioctl_ops = {
.vidioc_g_selection = vidioc_g_selection,
.vidioc_s_selection = vidioc_s_selection,
+ .vidioc_g_parm = vidioc_g_parm,
+ .vidioc_s_parm = vidioc_s_parm,
.vidioc_decoder_cmd = v4l2_m2m_ioctl_stateless_decoder_cmd,
.vidioc_try_decoder_cmd = v4l2_m2m_ioctl_stateless_try_decoder_cmd,
--
2.53.0
next prev parent reply other threads:[~2026-05-22 10:18 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-22 10:16 [PATCH 00/14] media: Add V4L2 H.264 stateless encode and VC8000E support Paul Kocialkowski
2026-05-22 10:16 ` [PATCH 01/14] media: h264: Add a more generic reflist builder init Paul Kocialkowski
2026-05-22 10:16 ` [PATCH 02/14] media: uapi: Add H.264 stateless encode support Paul Kocialkowski
2026-05-22 10:16 ` [PATCH 03/14] media: h264: Add SPS video definitions Paul Kocialkowski
2026-05-22 10:16 ` [PATCH 04/14] media: h264: Add stateless encode core Paul Kocialkowski
2026-05-22 10:16 ` [PATCH 05/14] media: h264: Add stateless encode rbsp Paul Kocialkowski
2026-05-22 10:16 ` [PATCH 06/14] media: h264: Add stateless encode reference management Paul Kocialkowski
2026-05-22 10:16 ` [PATCH 07/14] media: h264: Add stateless encode rate control Paul Kocialkowski
2026-05-22 10:16 ` [PATCH 08/14] media: verisilicon: Report default pixel coding for non-JPEG and fix JPEG case Paul Kocialkowski
2026-05-22 10:16 ` [PATCH 09/14] media: verisilicon: Cancel job with runtime pm put/clk disable on failure Paul Kocialkowski
2026-05-22 10:16 ` [PATCH 10/14] media: hantro: use hantro_decoded_buffer only for dst_vq Paul Kocialkowski
2026-05-22 10:16 ` Paul Kocialkowski [this message]
2026-05-22 10:16 ` [PATCH 12/14] media: verisilicon: Add support for the VC8000E H.264 encoder Paul Kocialkowski
2026-05-22 10:16 ` [PATCH 13/14] media: verilisicon: imx8m: Add support for the VC8000E on i.MX8MP Paul Kocialkowski
2026-05-22 10:16 ` [PATCH 14/14] arm64: dts: imx8mp: add VC8000E encoder node Paul Kocialkowski
2026-05-22 11:28 ` Fabio Estevam
2026-05-22 14:47 ` [PATCH 00/14] media: Add V4L2 H.264 stateless encode and VC8000E support Nicolas Dufresne
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=20260522101653.2565125-12-paulk@sys-base.io \
--to=paulk@sys-base.io \
--cc=benjamin.gaignard@collabora.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=hverkuil@kernel.org \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=m.felsch@pengutronix.de \
--cc=m.tretter@pengutronix.de \
--cc=mchehab@kernel.org \
--cc=nicolas.dufresne@collabora.com \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
/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