From: Charvi Mehta <charvi.mehta@arm.com>
To: linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Charvi Mehta <charvi.mehta@arm.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Vincenzo Frascino <vincenzo.frascino@arm.com>,
Rathinavel Sankaralingam <rath.sankaralingam@arm.com>,
Shobhit Pandey <shobhit.pandey@arm.com>
Subject: [RFC PATCH 06/28] media: mali-vpu: implement format query ioctls
Date: Thu, 19 Nov 2026 15:37:36 +0000 [thread overview]
Message-ID: <20261119153758.1426673-7-charvi.mehta@arm.com> (raw)
In-Reply-To: <20261119153758.1426673-1-charvi.mehta@arm.com>
Expose H.264 as the decoder OUTPUT format and YUV420M, NV12M, NV21M as the
CAPTURE formats through VIDIOC_ENUM_FMT.
Implement VIDIOC_ENUM_FRAMESIZES to report the variant-specific stepwise
frame size limits. Add VIDIOC_G_FMT support to return the current source
and destination formats for each session.
Signed-off-by: Charvi Mehta <charvi.mehta@arm.com>
---
.../platform/arm/mali-vpu/mali-vpu-session.h | 5 +
.../platform/arm/mali-vpu/mali-vpu-vidioc.c | 152 ++++++++++++++++--
2 files changed, 146 insertions(+), 11 deletions(-)
diff --git a/drivers/media/platform/arm/mali-vpu/mali-vpu-session.h b/drivers/media/platform/arm/mali-vpu/mali-vpu-session.h
index dfd1833f884af..f8a602cb59006 100644
--- a/drivers/media/platform/arm/mali-vpu/mali-vpu-session.h
+++ b/drivers/media/platform/arm/mali-vpu/mali-vpu-session.h
@@ -49,4 +49,9 @@ struct mali_vpu_session {
int mali_vpu_session_init(struct mali_vpu_session *sess);
void mali_vpu_session_cleanup(struct mali_vpu_session *sess);
+static inline struct mali_vpu_session *mali_vpu_get_session(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct mali_vpu_session, fh);
+}
+
#endif /* __MALI_VPU_SESSION_H__ */
diff --git a/drivers/media/platform/arm/mali-vpu/mali-vpu-vidioc.c b/drivers/media/platform/arm/mali-vpu/mali-vpu-vidioc.c
index aaf604beff93a..b993255b8c817 100644
--- a/drivers/media/platform/arm/mali-vpu/mali-vpu-vidioc.c
+++ b/drivers/media/platform/arm/mali-vpu/mali-vpu-vidioc.c
@@ -12,7 +12,9 @@
#include <media/v4l2-ioctl.h>
#include <media/v4l2-mem2mem.h>
+#include "mali-vpu-formats.h"
#include "mali-vpu-session.h"
+#include "mali-vpu-variant.h"
#include "mali-vpu-vidioc.h"
static int mali_vpu_open(struct file *filp)
@@ -56,8 +58,7 @@ static int mali_vpu_open(struct file *filp)
static int mali_vpu_release(struct file *filp)
{
- struct mali_vpu_session *sess = container_of(file_to_v4l2_fh(filp),
- struct mali_vpu_session, fh);
+ struct mali_vpu_session *sess = mali_vpu_get_session(filp);
mali_vpu_session_cleanup(sess);
v4l2_fh_del(&sess->fh, filp);
@@ -105,14 +106,143 @@ static int mali_vpu_querycap(struct file *filp, void *fh,
return 0;
}
+static int mali_vpu_enum_fmt(struct file *filp, void *fh,
+ struct v4l2_fmtdesc *f)
+{
+ struct mali_vpu_session *sess = mali_vpu_get_session(filp);
+ const struct mali_vpu_format_list *fmt_list;
+
+ switch (f->type) {
+ case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
+ fmt_list = &sess->port_src.supported_fmts;
+ break;
+ case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
+ fmt_list = &sess->port_dst.supported_fmts;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (f->index >= fmt_list->num_fmts)
+ return -EINVAL;
+
+ f->pixelformat = fmt_list->fmts[f->index].fourcc;
+ f->flags = fmt_list->fmts[f->index].flags;
+ return 0;
+}
+
+static const struct v4l2_format *mali_vpu_get_port_fmt(struct mali_vpu_session *sess,
+ u32 type)
+{
+ const struct mali_vpu_port *port;
+
+ switch (type) {
+ case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
+ port = &sess->port_src;
+ break;
+ case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
+ port = &sess->port_dst;
+ break;
+ default:
+ return NULL;
+ }
+
+ return &port->curr_fmt;
+}
+
+static int mali_vpu_g_fmt(struct file *filp, void *fh, struct v4l2_format *fmt)
+{
+ struct mali_vpu_session *sess = mali_vpu_get_session(filp);
+ const struct v4l2_format *port_fmt;
+ int ret = 0;
+
+ mutex_lock(&sess->vq_lock);
+
+ port_fmt = mali_vpu_get_port_fmt(sess, fmt->type);
+ if (port_fmt)
+ *fmt = *port_fmt;
+ else
+ ret = -EINVAL;
+
+ mutex_unlock(&sess->vq_lock);
+ return ret;
+}
+
+static const struct mali_vpu_format_desc *mali_vpu_find_format(struct mali_vpu_session *sess,
+ u32 pixfmt, u32 type)
+{
+ const struct mali_vpu_format_desc *fmt_list;
+ u32 num_fmts;
+ u32 i;
+
+ switch (type) {
+ case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
+ fmt_list = sess->port_src.supported_fmts.fmts;
+ num_fmts = sess->port_src.supported_fmts.num_fmts;
+ break;
+ case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
+ fmt_list = sess->port_dst.supported_fmts.fmts;
+ num_fmts = sess->port_dst.supported_fmts.num_fmts;
+ break;
+ default:
+ return NULL;
+ }
+
+ for (i = 0; i < num_fmts; i++) {
+ if (fmt_list[i].fourcc == pixfmt)
+ return &fmt_list[i];
+ }
+
+ return NULL;
+}
+
+static int mali_vpu_validate_format(struct mali_vpu_session *sess, u32 pixfmt)
+{
+ const struct mali_vpu_format_desc *fmt;
+
+ fmt = mali_vpu_find_format(sess, pixfmt, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
+ if (!fmt) {
+ fmt = mali_vpu_find_format(sess, pixfmt, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
+ if (!fmt)
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int mali_vpu_enum_framesizes(struct file *filp, void *fh,
+ struct v4l2_frmsizeenum *fsize)
+{
+ struct mali_vpu_session *sess = mali_vpu_get_session(filp);
+ const struct mali_vpu_framesize_caps *fmsz = &sess->vpu_dev->variant->frmsz_caps;
+ int ret;
+
+ if (fsize->index)
+ return -EINVAL;
+
+ ret = mali_vpu_validate_format(sess, fsize->pixel_format);
+ if (ret)
+ return ret;
+
+ fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
+ fsize->stepwise = fmsz->stepwise;
+
+ return 0;
+}
+
const struct v4l2_ioctl_ops mali_vpu_ioctl_ops_dec = {
- .vidioc_querycap = mali_vpu_querycap,
- .vidioc_reqbufs = v4l2_m2m_ioctl_reqbufs,
- .vidioc_querybuf = v4l2_m2m_ioctl_querybuf,
- .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
- .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf,
- .vidioc_expbuf = v4l2_m2m_ioctl_expbuf,
- .vidioc_qbuf = v4l2_m2m_ioctl_qbuf,
- .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf,
- .vidioc_remove_bufs = v4l2_m2m_ioctl_remove_bufs,
+ .vidioc_querycap = mali_vpu_querycap,
+ .vidioc_enum_fmt_vid_out = mali_vpu_enum_fmt,
+ .vidioc_enum_fmt_vid_cap = mali_vpu_enum_fmt,
+ .vidioc_g_fmt_vid_out_mplane = mali_vpu_g_fmt,
+ .vidioc_g_fmt_vid_cap_mplane = mali_vpu_g_fmt,
+ .vidioc_reqbufs = v4l2_m2m_ioctl_reqbufs,
+ .vidioc_querybuf = v4l2_m2m_ioctl_querybuf,
+ .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
+ .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf,
+ .vidioc_expbuf = v4l2_m2m_ioctl_expbuf,
+ .vidioc_qbuf = v4l2_m2m_ioctl_qbuf,
+ .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf,
+ .vidioc_remove_bufs = v4l2_m2m_ioctl_remove_bufs,
+ .vidioc_enum_framesizes = mali_vpu_enum_framesizes,
};
--
2.43.0
next prev parent reply other threads:[~2026-11-19 15:38 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 15:37 [RFC PATCH 00/28] media: add arm Mali-V76 video decoder driver Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 01/28] dt-bindings: media: add Arm Mali-V76 VPU Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 02/28] media: mali-vpu: add Mali VPU platform driver Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 03/28] media: mali-vpu: register V4L2 decoder device and add querycap ioctl Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 04/28] media: mali-vpu: initialize decoder format state Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 05/28] media: mali-vpu: add V4L2 mem2mem and VB2 queue support Charvi Mehta
2026-11-19 15:37 ` Charvi Mehta [this message]
2026-11-19 15:37 ` [RFC PATCH 07/28] media: mali-vpu: implement TRY_FMT and S_FMT ioctls Charvi Mehta
2026-11-19 15:55 ` sashiko-bot
2026-11-19 15:37 ` [RFC PATCH 08/28] media: mali-vpu: register V76 decoder controls and introduce UAPI controls Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 09/28] media: mali-vpu: add MMU software page table manager Charvi Mehta
2026-11-19 15:59 ` sashiko-bot
2026-11-19 15:37 ` [RFC PATCH 10/28] media: mali-vpu: add firmware cache infrastructure Charvi Mehta
2026-11-19 15:50 ` sashiko-bot
2026-11-19 15:37 ` [RFC PATCH 11/28] media: mali-vpu: load firmware for decoder sessions Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 12/28] media: mali-vpu: prepare firmware address space Charvi Mehta
2026-11-19 15:57 ` sashiko-bot
2026-11-19 15:37 ` [RFC PATCH 13/28] media: mali-vpu: add firmware message transport Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 14/28] media: mali-vpu: route decoder controls to firmware Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 15/28] media: mali-vpu: handle firmware RPC requests Charvi Mehta
2026-11-19 15:51 ` sashiko-bot
2026-11-19 15:37 ` [RFC PATCH 16/28] media: mali-vpu: add LSID hardware support Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 17/28] media: mali-vpu: add single session scheduler Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 18/28] media: mali-vpu: handle firmware interrupts Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 19/28] media: mali-vpu: start decoder firmware through LSID scheduling Charvi Mehta
2026-11-19 16:03 ` sashiko-bot
2026-11-19 15:37 ` [RFC PATCH 20/28] media: mali-vpu: implement vb2 buffer queue handling Charvi Mehta
2026-11-19 16:06 ` sashiko-bot
2026-11-19 15:37 ` [RFC PATCH 21/28] media: mali-vpu: handle firmware buffer exchange Charvi Mehta
2026-11-19 15:58 ` sashiko-bot
2026-11-19 15:37 ` [RFC PATCH 22/28] media: mali-vpu: handle fatal firmware error Charvi Mehta
2026-11-19 16:07 ` sashiko-bot
2026-11-19 15:37 ` [RFC PATCH 23/28] media: mali-vpu: propagate buffer metadata Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 24/28] media: mali-vpu: add decoder EOS and DRC handling Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 25/28] media: mali-vpu: handle firmware buffer parameters Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 26/28] media: mali-vpu: handle firmware event responses Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 27/28] media: mali-vpu: add stateful decoder state machine Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 28/28] media: MAINTAINERS: add Arm Mali-V76 VPU driver Charvi Mehta
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=20261119153758.1426673-7-charvi.mehta@arm.com \
--to=charvi.mehta@arm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=rath.sankaralingam@arm.com \
--cc=robh@kernel.org \
--cc=shobhit.pandey@arm.com \
--cc=vincenzo.frascino@arm.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