[PATCH 5/5] v4l2-tracer: add INPUT and OUTPUT ioctls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add tracing and retracing for: VIDIOC_ENUMINPUT, VIDIOC_ENUMOUTPUT,
VIDIOC_G_INPUT, VIDIOC_S_INPUT, VIDIOC_G_OUTPUT, VIDIOC_S_OUTPUT.

Signed-off-by: Deborah Brouwer <deborah.brouwer@xxxxxxxxxxxxx>
---
 utils/v4l2-tracer/libv4l2tracer.cpp  |  6 ++
 utils/v4l2-tracer/retrace.cpp        | 84 ++++++++++++++++++++++++++++
 utils/v4l2-tracer/trace.cpp          | 18 ++++++
 utils/v4l2-tracer/v4l2-tracer-gen.pl | 39 +++++++++++++
 4 files changed, 147 insertions(+)

diff --git a/utils/v4l2-tracer/libv4l2tracer.cpp b/utils/v4l2-tracer/libv4l2tracer.cpp
index 6b438628..5d0817b2 100644
--- a/utils/v4l2-tracer/libv4l2tracer.cpp
+++ b/utils/v4l2-tracer/libv4l2tracer.cpp
@@ -24,9 +24,15 @@ const std::list<unsigned long> ioctls = {
 	VIDIOC_DQBUF,
 	VIDIOC_G_PARM,
 	VIDIOC_S_PARM,
+	VIDIOC_ENUMINPUT,
 	VIDIOC_G_CTRL,
 	VIDIOC_S_CTRL,
 	VIDIOC_QUERYCTRL,
+	VIDIOC_G_INPUT,
+	VIDIOC_S_INPUT,
+	VIDIOC_G_OUTPUT,
+	VIDIOC_S_OUTPUT,
+	VIDIOC_ENUMOUTPUT,
 	VIDIOC_G_CROP,
 	VIDIOC_S_CROP,
 	VIDIOC_TRY_FMT,
diff --git a/utils/v4l2-tracer/retrace.cpp b/utils/v4l2-tracer/retrace.cpp
index 36a218d3..29ac4a38 100644
--- a/utils/v4l2-tracer/retrace.cpp
+++ b/utils/v4l2-tracer/retrace.cpp
@@ -614,6 +614,17 @@ void retrace_vidioc_queryctrl(int fd_retrace, json_object *ioctl_args)
 	free(ptr);
 }
 
+void retrace_vidioc_enuminput(int fd_retrace, json_object *ioctl_args)
+{
+	struct v4l2_input *ptr = retrace_v4l2_input_gen(ioctl_args);
+	ioctl(fd_retrace, VIDIOC_ENUMINPUT, ptr);
+
+	if (is_verbose() || (errno != 0))
+		perror("VIDIOC_ENUMINPUT");
+
+	free(ptr);
+}
+
 void retrace_vidioc_g_control(int fd_retrace, json_object *ioctl_args)
 {
 	struct v4l2_control *ptr = retrace_v4l2_control_gen(ioctl_args);
@@ -636,6 +647,61 @@ void retrace_vidioc_s_control(int fd_retrace, json_object *ioctl_args)
 	free(ptr);
 }
 
+void retrace_vidioc_g_input(int fd_retrace, json_object *ioctl_args)
+{
+	int input = 0;
+	ioctl(fd_retrace, VIDIOC_G_INPUT, &input);
+
+	if (is_verbose() || (errno != 0))
+		perror("VIDIOC_G_INPUT");
+}
+
+void retrace_vidioc_s_input(int fd_retrace, json_object *ioctl_args)
+{
+	int input = 0;
+	json_object *input_obj;
+	if (json_object_object_get_ex(ioctl_args, "input", &input_obj))
+		input = json_object_get_int(input_obj);
+
+	ioctl(fd_retrace, VIDIOC_S_INPUT, &input);
+
+	if (is_verbose() || (errno != 0))
+		perror("VIDIOC_S_INPUT");
+}
+
+void retrace_vidioc_g_output(int fd_retrace, json_object *ioctl_args)
+{
+	int output = 0;
+	ioctl(fd_retrace, VIDIOC_G_OUTPUT, &output);
+
+	if (is_verbose() || (errno != 0))
+		perror("VIDIOC_G_OUTPUT");
+}
+
+void retrace_vidioc_s_output(int fd_retrace, json_object *ioctl_args)
+{
+	int output = 0;
+	json_object *output_obj;
+	if (json_object_object_get_ex(ioctl_args, "output", &output_obj))
+		output = json_object_get_int(output_obj);
+
+	ioctl(fd_retrace, VIDIOC_S_OUTPUT, &output);
+
+	if (is_verbose() || (errno != 0))
+		perror("VIDIOC_S_OUTPUT");
+}
+
+void retrace_vidioc_enumoutput(int fd_retrace, json_object *ioctl_args)
+{
+	struct v4l2_output *ptr = retrace_v4l2_output_gen(ioctl_args);
+	ioctl(fd_retrace, VIDIOC_ENUMOUTPUT, ptr);
+
+	if (is_verbose() || (errno != 0))
+		perror("VIDIOC_ENUMOUTPUT");
+
+	free(ptr);
+}
+
 void retrace_vidioc_g_crop(int fd_retrace, json_object *ioctl_args)
 {
 	struct v4l2_crop *ptr = retrace_v4l2_crop_gen(ioctl_args);
@@ -1165,6 +1231,9 @@ void retrace_ioctl(json_object *syscall_obj)
 	case VIDIOC_S_PARM:
 		retrace_vidioc_s_parm(fd_retrace, ioctl_args_user);
 		break;
+	case VIDIOC_ENUMINPUT:
+		retrace_vidioc_enuminput(fd_retrace, ioctl_args_user);
+		break;
 	case VIDIOC_G_CTRL:
 		retrace_vidioc_g_control(fd_retrace, ioctl_args_user);
 		break;
@@ -1174,6 +1243,21 @@ void retrace_ioctl(json_object *syscall_obj)
 	case VIDIOC_QUERYCTRL:
 		retrace_vidioc_queryctrl(fd_retrace, ioctl_args_user);
 		break;
+	case VIDIOC_G_INPUT:
+		retrace_vidioc_g_input(fd_retrace, ioctl_args_user);
+		break;
+	case VIDIOC_S_INPUT:
+		retrace_vidioc_s_input(fd_retrace, ioctl_args_user);
+		break;
+	case VIDIOC_G_OUTPUT:
+		retrace_vidioc_g_output(fd_retrace, ioctl_args_user);
+		break;
+	case VIDIOC_S_OUTPUT:
+		retrace_vidioc_s_output(fd_retrace, ioctl_args_user);
+		break;
+	case VIDIOC_ENUMOUTPUT:
+		retrace_vidioc_enumoutput(fd_retrace, ioctl_args_user);
+		break;
 	case VIDIOC_G_CROP:
 		retrace_vidioc_g_crop(fd_retrace, ioctl_args_user);
 		break;
diff --git a/utils/v4l2-tracer/trace.cpp b/utils/v4l2-tracer/trace.cpp
index 4896751b..a393d0d4 100644
--- a/utils/v4l2-tracer/trace.cpp
+++ b/utils/v4l2-tracer/trace.cpp
@@ -556,6 +556,9 @@ json_object *trace_ioctl_args(unsigned long cmd, void *arg)
 	case VIDIOC_S_PARM:
 		trace_v4l2_streamparm(arg, ioctl_args);
 		break;
+	case VIDIOC_ENUMINPUT:
+		trace_v4l2_input_gen(arg, ioctl_args);
+		break;
 	case VIDIOC_G_CTRL:
 	case VIDIOC_S_CTRL:
 		trace_v4l2_control_gen(arg, ioctl_args);
@@ -563,6 +566,21 @@ json_object *trace_ioctl_args(unsigned long cmd, void *arg)
 	case VIDIOC_QUERYCTRL:
 		trace_v4l2_queryctrl_gen(arg, ioctl_args);
 		break;
+	case VIDIOC_G_INPUT:
+	case VIDIOC_S_INPUT: {
+		int *input = static_cast<int*>(arg);
+		json_object_object_add(ioctl_args, "input", json_object_new_int(*input));
+		break;
+	}
+	case VIDIOC_G_OUTPUT:
+	case VIDIOC_S_OUTPUT: {
+		int *output = static_cast<int*>(arg);
+		json_object_object_add(ioctl_args, "output", json_object_new_int(*output));
+		break;
+	}
+	case VIDIOC_ENUMOUTPUT:
+		trace_v4l2_output_gen(arg, ioctl_args);
+		break;
 	case VIDIOC_G_CROP:
 	case VIDIOC_S_CROP:
 		trace_v4l2_crop_gen(arg, ioctl_args);
diff --git a/utils/v4l2-tracer/v4l2-tracer-gen.pl b/utils/v4l2-tracer/v4l2-tracer-gen.pl
index 66d46f0c..7a47f116 100755
--- a/utils/v4l2-tracer/v4l2-tracer-gen.pl
+++ b/utils/v4l2-tracer/v4l2-tracer-gen.pl
@@ -156,6 +156,12 @@ sub get_val_def_name {
 		if ($struct_name eq "v4l2_frmivalenum") {
 			return "v4l2_frmivaltypes_val_def";
 		}
+		if ($struct_name eq "v4l2_input") {
+			return $val_def_name = "input_type_val_def";
+		}
+		if ($struct_name eq "v4l2_output") {
+			return $val_def_name = "output_type_val_def";
+		}
 		return "nullptr"; # will print as hex string
 	}
 	# special treatment for struct v4l2_input which has members named both "tuner" and "type"
@@ -209,6 +215,9 @@ sub get_val_def_name {
 	if ($member =~ /xfer_func/) {
 		return "v4l2_xfer_func_val_def";
 	}
+	if (($member eq "status") && ($struct_name eq "v4l2_input")) {
+		$val_def_name = "input_field_val_def";
+	}
 	return "";
 }
 
@@ -824,11 +833,41 @@ while (<>) {
 		flag_def_gen("V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS");
 		next;
 	}
+	if (grep {/^#define V4L2_STD_PAL_B\s+/} $_) {
+		printf $fh_common_info_h "constexpr flag_def std_flag_def[] = {\n";
+		flag_def_gen("V4L2_STD_ALL");
+		next
+	}
 	if (grep {/^#define V4L2_MODE_HIGHQUALITY\s+/} $_) {
 		printf $fh_common_info_h "constexpr val_def streamparm_val_def[] = {\n";
 		val_def_gen("V4L2_CAP_TIMEPERFRAME");
 		next;
 	}
+	if (grep {/^#define V4L2_INPUT_TYPE_TUNER\s+/} $_) {
+		printf $fh_common_info_h "constexpr val_def input_type_val_def[] = {\n";
+		val_def_gen("V4L2_INPUT_TYPE_TOUCH");
+		next
+	}
+	if (grep {/^#define V4L2_IN_ST_NO_POWER\s+/} $_) {
+		printf $fh_common_info_h "constexpr val_def input_field_val_def[] = {\n";
+		val_def_gen("V4L2_IN_ST_VTR");
+		next
+	}
+	if (grep {/^#define V4L2_IN_CAP_DV_TIMINGS\s+/} $_) {
+		printf $fh_common_info_h "constexpr flag_def input_cap_flag_def[] = {\n";
+		flag_def_gen("V4L2_IN_CAP_NATIVE_SIZE");
+		next
+	}
+	if (grep {/^#define V4L2_OUTPUT_TYPE_MODULATOR\s+/} $_) {
+		printf $fh_common_info_h "constexpr val_def output_type_val_def[] = {\n";
+		val_def_gen("V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY");
+		next
+	}
+	if (grep {/^#define V4L2_OUT_CAP_DV_TIMINGS\s+/} $_) {
+		printf $fh_common_info_h "constexpr flag_def output_cap_flag_def[] = {\n";
+		flag_def_gen("V4L2_OUT_CAP_NATIVE_SIZE");
+		next
+	}
 	if (grep {/^#define V4L2_ENC_CMD_START\s+/} $_) {
 		printf $fh_common_info_h "constexpr val_def encoder_cmd_val_def[] = {\n";
 		val_def_gen("V4L2_ENC_CMD_RESUME");
-- 
2.39.0




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux