diff mbox series

[1/4] v4l2-tracer: add VIDIOC_ENUM_FRAMESIZES

Message ID c1c3471986bf570ee866cfd6666efc4bc6644b2d.1686102391.git.deborah.brouwer@collabora.com (mailing list archive)
State New, archived
Headers show
Series v4l2-tracer: add tracing for frames/events | expand

Commit Message

Deborah Brouwer June 7, 2023, 2:11 a.m. UTC
Add tracing and retracing for VIDIOC_ENUM_FRAMESIZES ioctl.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
 utils/v4l2-tracer/libv4l2tracer.cpp  |  1 +
 utils/v4l2-tracer/retrace.cpp        | 15 +++++++++++++++
 utils/v4l2-tracer/trace.cpp          |  3 +++
 utils/v4l2-tracer/v4l2-tracer-gen.pl | 11 ++++++++++-
 4 files changed, 29 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/utils/v4l2-tracer/libv4l2tracer.cpp b/utils/v4l2-tracer/libv4l2tracer.cpp
index 63c1812e..6edec7f4 100644
--- a/utils/v4l2-tracer/libv4l2tracer.cpp
+++ b/utils/v4l2-tracer/libv4l2tracer.cpp
@@ -40,6 +40,7 @@  const std::list<unsigned long> ioctls = {
 	VIDIOC_G_EXT_CTRLS,
 	VIDIOC_S_EXT_CTRLS,
 	VIDIOC_TRY_EXT_CTRLS,
+	VIDIOC_ENUM_FRAMESIZES,
 	VIDIOC_ENCODER_CMD,
 	VIDIOC_TRY_ENCODER_CMD,
 	VIDIOC_CREATE_BUFS,
diff --git a/utils/v4l2-tracer/retrace.cpp b/utils/v4l2-tracer/retrace.cpp
index 51c8ad37..7003ca70 100644
--- a/utils/v4l2-tracer/retrace.cpp
+++ b/utils/v4l2-tracer/retrace.cpp
@@ -966,6 +966,18 @@  void retrace_vidioc_s_ext_ctrls(int fd_retrace, json_object *ioctl_args)
 	}
 }
 
+void retrace_vidioc_enum_framesizes(int fd_retrace, json_object *ioctl_args)
+{
+	struct v4l2_frmsizeenum *ptr = retrace_v4l2_frmsizeenum_gen(ioctl_args);
+
+	ioctl(fd_retrace, VIDIOC_ENUM_FRAMESIZES, ptr);
+
+	if (is_verbose() || (errno != 0))
+		perror("VIDIOC_ENUM_FRAMESIZES");
+
+	free(ptr);
+}
+
 void retrace_vidioc_try_encoder_cmd(int fd_retrace, json_object *ioctl_args)
 {
 	struct v4l2_encoder_cmd *ptr = retrace_v4l2_encoder_cmd_gen(ioctl_args);
@@ -1272,6 +1284,9 @@  void retrace_ioctl(json_object *syscall_obj)
 	case VIDIOC_S_EXT_CTRLS:
 		retrace_vidioc_s_ext_ctrls(fd_retrace, ioctl_args_user);
 		break;
+	case VIDIOC_ENUM_FRAMESIZES:
+		retrace_vidioc_enum_framesizes(fd_retrace, ioctl_args_user);
+		break;
 	case VIDIOC_TRY_ENCODER_CMD:
 		retrace_vidioc_try_encoder_cmd(fd_retrace, ioctl_args_user);
 		break;
diff --git a/utils/v4l2-tracer/trace.cpp b/utils/v4l2-tracer/trace.cpp
index acf4cc98..78db2554 100644
--- a/utils/v4l2-tracer/trace.cpp
+++ b/utils/v4l2-tracer/trace.cpp
@@ -589,6 +589,9 @@  json_object *trace_ioctl_args(unsigned long cmd, void *arg)
 	case VIDIOC_S_EXT_CTRLS:
 		trace_v4l2_ext_controls(arg, ioctl_args);
 		break;
+	case VIDIOC_ENUM_FRAMESIZES:
+		trace_v4l2_frmsizeenum_gen(arg, ioctl_args);
+		break;
 	case VIDIOC_TRY_ENCODER_CMD:
 	case VIDIOC_ENCODER_CMD:
 		trace_v4l2_encoder_cmd_gen(arg, ioctl_args);
diff --git a/utils/v4l2-tracer/v4l2-tracer-gen.pl b/utils/v4l2-tracer/v4l2-tracer-gen.pl
index 8c6f7cb5..aaa112c1 100755
--- a/utils/v4l2-tracer/v4l2-tracer-gen.pl
+++ b/utils/v4l2-tracer/v4l2-tracer-gen.pl
@@ -193,7 +193,7 @@  sub get_val_def_name {
 		}
 		return "nullptr"; # will print as hex string
 	}
-	if ($member =~ /pixelformat/) {
+	if ($member eq "pixelformat" || $member eq "pixel_format") {
 		return "v4l2_pix_fmt_val_def";
 	}
 	if ($member =~ /cmd/) {
@@ -363,6 +363,15 @@  sub handle_union {
 		printf $fh_retrace_cpp "\tdefault:\n\t\tbreak;\n\t}\n";
 	}
 
+	if ($struct_name eq "v4l2_frmsizeenum") {
+		printf $fh_trace_cpp "\tswitch (p->type) {\n";
+		printf $fh_trace_cpp "\tcase V4L2_FRMSIZE_TYPE_DISCRETE:\n";
+		printf $fh_trace_cpp "\t\ttrace_v4l2_frmsize_discrete_gen(&p->discrete, %s_obj);\n\t\tbreak;\n", $struct_name;
+		printf $fh_trace_cpp "\tcase V4L2_FRMSIZE_TYPE_STEPWISE:\n\tcase V4L2_FRMSIZE_TYPE_CONTINUOUS:\n";
+		printf $fh_trace_cpp "\t\ttrace_v4l2_frmsize_stepwise_gen(&p->stepwise, %s_obj);\n\t\tbreak;\n", $struct_name;
+		printf $fh_trace_cpp "\tdefault:\n\t\tbreak;\n\t}\n";
+	}
+
 	return $suppress_union;
 }