public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Detlev Casanova <detlev.casanova@collabora.com>
To: linux-kernel@vger.kernel.org
Cc: Nicolas Dufresne <nicolas.dufresne@collabora.com>,
	Benjamin Gaignard <benjamin.gaignard@collabora.com>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Heiko Stuebner <heiko@sntech.de>,
	Daniel Almeida <daniel.almeida@collabora.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Hans Verkuil <hverkuil@kernel.org>,
	Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
	Ricardo Ribalda <ribalda@chromium.org>,
	Yunke Cao <yunkec@google.com>,
	Detlev Casanova <detlev.casanova@collabora.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Pavan Bobba <opensource206@gmail.com>,
	James Cowgill <james.cowgill@blaize.com>,
	Ma Ke <make24@iscas.ac.cn>,
	Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
	Daniel Scally <dan.scally@ideasonboard.com>,
	linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-trace-kernel@vger.kernel.org, kernel@collabora.com
Subject: [PATCH 11/11] media: hantro: Add fdinfo callback
Date: Thu, 12 Feb 2026 11:23:28 -0500	[thread overview]
Message-ID: <20260212162328.192217-12-detlev.casanova@collabora.com> (raw)
In-Reply-To: <20260212162328.192217-1-detlev.casanova@collabora.com>

The fdinfo shows the number of buffers in each queue and the total amount
of video buffer memory.

Signed-off-by: Detlev Casanova <detlev.casanova@collabora.com>
---
 drivers/media/platform/verisilicon/hantro.h      |  1 +
 drivers/media/platform/verisilicon/hantro_drv.c  | 15 +++++++++++++++
 drivers/media/platform/verisilicon/hantro_v4l2.c | 10 +++++++++-
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/platform/verisilicon/hantro.h
index d5cddc783688..9e9fc0658586 100644
--- a/drivers/media/platform/verisilicon/hantro.h
+++ b/drivers/media/platform/verisilicon/hantro.h
@@ -268,6 +268,7 @@ struct hantro_ctx {
 	const struct hantro_codec_ops *codec_ops;
 	struct hantro_postproc_ctx postproc;
 	bool need_postproc;
+	u64 stats_buf_memory;
 
 	/* Specific for particular codec modes. */
 	union {
diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 8dd26ca32459..86d316a8a3e8 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -17,6 +17,7 @@
 #include <linux/platform_device.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
+#include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/videodev2.h>
 #include <linux/workqueue.h>
@@ -711,6 +712,19 @@ static int hantro_release(struct file *filp)
 	return 0;
 }
 
+static void hantro_show_fdinfo(struct seq_file *m, struct file *filp)
+{
+	struct hantro_ctx *ctx =
+		container_of(filp->private_data, struct hantro_ctx, fh);
+
+	struct vb2_queue *src_q = v4l2_m2m_get_src_vq(ctx->fh.m2m_ctx);
+	struct vb2_queue *dst_q = v4l2_m2m_get_dst_vq(ctx->fh.m2m_ctx);
+
+	seq_printf(m, "src-queued-count: %04u\n", src_q->queued_count);
+	seq_printf(m, "dst-queued-count: %04u\n", dst_q->queued_count);
+	seq_printf(m, "buf-size: %llu\n", ctx->stats_buf_memory);
+}
+
 static const struct v4l2_file_operations hantro_fops = {
 	.owner = THIS_MODULE,
 	.open = hantro_open,
@@ -718,6 +732,7 @@ static const struct v4l2_file_operations hantro_fops = {
 	.poll = v4l2_m2m_fop_poll,
 	.unlocked_ioctl = video_ioctl2,
 	.mmap = v4l2_m2m_fop_mmap,
+	.show_fdinfo = hantro_show_fdinfo,
 };
 
 static const struct of_device_id of_hantro_match[] = {
diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c
index fcf3bd9bcda2..6d129613ea3d 100644
--- a/drivers/media/platform/verisilicon/hantro_v4l2.c
+++ b/drivers/media/platform/verisilicon/hantro_v4l2.c
@@ -820,18 +820,26 @@ hantro_queue_setup(struct vb2_queue *vq, unsigned int *num_buffers,
 		return -EINVAL;
 	}
 
+	ctx->stats_buf_memory = 0;
+
 	if (*num_planes) {
 		if (*num_planes != pixfmt->num_planes)
 			return -EINVAL;
-		for (i = 0; i < pixfmt->num_planes; ++i)
+		for (i = 0; i < pixfmt->num_planes; ++i) {
 			if (sizes[i] < pixfmt->plane_fmt[i].sizeimage)
 				return -EINVAL;
+			ctx->stats_buf_memory += pixfmt->plane_fmt[i].sizeimage;
+		}
+
+		ctx->stats_buf_memory *= *num_buffers;
+
 		return 0;
 	}
 
 	*num_planes = pixfmt->num_planes;
 	for (i = 0; i < pixfmt->num_planes; ++i)
 		sizes[i] = pixfmt->plane_fmt[i].sizeimage;
+
 	return 0;
 }
 
-- 
2.53.0



  parent reply	other threads:[~2026-02-12 16:24 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-12 16:23 [PATCH 00/11] v4l2: Add tracing for stateless codecs Detlev Casanova
2026-02-12 16:23 ` [PATCH 02/11] media: Reformat v4l2-requests trace event printk Detlev Casanova
2026-04-28 19:28   ` Nicolas Dufresne
2026-02-12 16:23 ` [PATCH 03/11] media: Add tgid and fd fields in v4l2_fh struct Detlev Casanova
2026-04-28 19:31   ` Nicolas Dufresne
2026-02-12 16:23 ` [PATCH 04/11] media: Add tgid and fd to the v4l2-requests trace fields Detlev Casanova
2026-04-28 19:32   ` Nicolas Dufresne
2026-02-12 16:23 ` [PATCH 05/11] media: Add missing types to v4l2_ctrl_ptr Detlev Casanova
2026-04-28 19:33   ` Nicolas Dufresne
2026-02-12 16:23 ` [PATCH 06/11] media: Trace the stateless controls when set in v4l2-ctrls-core.c Detlev Casanova
2026-04-28 19:37   ` Nicolas Dufresne
2026-02-12 16:23 ` [PATCH 07/11] media: Add stream on/off traces and run them in the ioctl Detlev Casanova
2026-02-12 16:23 ` [PATCH 08/11] media: Add HW run/done trace events Detlev Casanova
2026-02-12 16:23 ` [PATCH 09/11] media: hantro: Add v4l2_hw run/done traces Detlev Casanova
2026-02-12 16:23 ` [PATCH 10/11] media: v4l2: Add callback for show_fdinfo Detlev Casanova
2026-02-12 16:23 ` Detlev Casanova [this message]
2026-04-28 19:41   ` [PATCH 11/11] media: hantro: Add fdinfo callback Nicolas Dufresne
2026-04-28 19:52 ` [PATCH 00/11] v4l2: Add tracing for stateless codecs Nicolas Dufresne
2026-05-01 18:07   ` Detlev Casanova
     [not found] ` <20260212162328.192217-2-detlev.casanova@collabora.com>
2026-05-01 19:07   ` [PATCH 01/11] media: Move visl traces to v4l2-core Steven Rostedt

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=20260212162328.192217-12-detlev.casanova@collabora.com \
    --to=detlev.casanova@collabora.com \
    --cc=benjamin.gaignard@collabora.com \
    --cc=dan.scally@ideasonboard.com \
    --cc=daniel.almeida@collabora.com \
    --cc=heiko@sntech.de \
    --cc=hverkuil@kernel.org \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=james.cowgill@blaize.com \
    --cc=kernel@collabora.com \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=make24@iscas.ac.cn \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mchehab@kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=nicolas.dufresne@collabora.com \
    --cc=opensource206@gmail.com \
    --cc=p.zabel@pengutronix.de \
    --cc=ribalda@chromium.org \
    --cc=rostedt@goodmis.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=yunkec@google.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