Skip to contentSkip to conversation

v4l2-compliance: Add an option to override the driver name.

PATCH New Brian Daniels 1 participant 1 message Oct 29 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 v4l2-compliance: Add an option to override the driver name.

When using the virtio-media driver, the host and a guest VM are used, with the guest VM proxying requests to a host device. The driver name in the guest VM is reported as "virtio-media", when really its proxying requests to a driver with a different name (for example, "uvcvideo"). For the test to pass, v4l2-compliance needs to know the driver name of the device on the host because it changes its behavior depending on the driver under test.

With the new --is-uvc and --is-vivid options, the name of the host driver can be overriden so the test running in the guest can adapt accordingly.

Assisted-by LLM
---
 utils/v4l2-compliance/v4l2-compliance.1.in |  6 +++++
 utils/v4l2-compliance/v4l2-compliance.cpp  | 28 ++++++++++++++++++----
 2 files changed, 29 insertions(+), 5 deletions(-)
utils/v4l2-compliance/v4l2-compliance.1.in +6 -0
index c23e5323..2e89b049 100644
@@ -178,6 +178,12 @@ Highlight OK/warn/fail/FAIL strings with colors. OK is marked green, warn is
 marked bold, and fail/FAIL are marked bright red if enabled. \fI<when>\fR can
 be \fIalways\fR, \fInever\fR, or \fIauto\fR (the default).
 .TP
+\fB\-\-is\-uvc\fR
+Run the tests as if the detected driver name was "uvcvideo".
+.TP
+\fB\-\-is\-vivid\fR
+Run the tests as if the detected driver name was "vivid".
+.TP
 \fB\-n\fR, \fB\-\-no\-warnings\fR
 Turn off warning messages. They are still counted in the summary, but you won't see them.
 .TP
utils/v4l2-compliance/v4l2-compliance.cpp +23 -5
index d6c2f61d..e9e84363 100644
@@ -66,7 +66,9 @@ enum Option {
 	OptExitOnWarn = 'W',
 	OptMediaBusInfo = 'z',
 	OptExpBufMediaBusInfo = 'Z',
-	OptStreamFrom = 128,
+	OptIsUvc = 128,
+	OptIsVivid,
+	OptStreamFrom,
 	OptStreamFromHdr,
 	OptVersion,
 	OptLast = 256
@@ -85,8 +87,8 @@ bool show_warnings = true;
 bool show_colors;
 bool exit_on_fail;
 bool exit_on_warn;
-bool is_vivid;
-bool is_uvcvideo;
+bool is_vivid = false;
+bool is_uvcvideo = false;
 int media_fd = -1;
 unsigned warnings;
 bool has_mmu = true;
@@ -132,6 +134,8 @@ static struct option long_options[] = {
 	{"help", no_argument, nullptr, OptHelp},
 	{"verbose", no_argument, nullptr, OptVerbose},
 	{"color", required_argument, nullptr, OptColor},
+	{"is-uvc", no_argument, nullptr, OptIsUvc},
+	{"is-vivid", no_argument, nullptr, OptIsVivid},
 	{"no-warnings", no_argument, nullptr, OptNoWarnings},
 	{"no-progress", no_argument, nullptr, OptNoProgress},
 	{"exit-on-fail", no_argument, nullptr, OptExitOnFail},
@@ -265,6 +269,8 @@ static void usage()
 	printf("  -h, --help         Display this help message.\n");
 	printf("  -C, --color <when> Highlight OK/warn/fail/FAIL strings with colors\n");
 	printf("                     <when> can be set to always, never, or auto (the default)\n");
+	printf("  --is-uvc           Run the tests as if the detected driver name was \"uvcvideo\".\n");
+	printf("  --is-vivid         Run the tests as if the detected driver name was \"vivid\".\n");
 	printf("  -n, --no-warnings  Turn off warning messages.\n");
 	printf("  -P, --no-progress  Turn off progress messages.\n");
 	printf("  -T, --trace        Trace all called ioctls.\n");
@@ -998,8 +1004,10 @@ void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_
 	if (node.is_v4l2()) {
 		doioctl(&node, VIDIOC_QUERYCAP, &vcap);
 		driver = reinterpret_cast<const char *>(vcap.driver);
-		is_uvcvideo = driver == "uvcvideo";
-		is_vivid = driver == "vivid";
+		if (!options[OptIsUvc] && !options[OptIsVivid]) {
+			is_uvcvideo = driver == "uvcvideo";
+			is_vivid = driver == "vivid";
+		}
 		node.bus_info = reinterpret_cast<const char *>(vcap.bus_info);
 		determine_codec_mask(node);
 	} else if (node.is_subdev()) {
@@ -1830,6 +1838,12 @@ int main(int argc, char **argv)
 				std::exit(EXIT_FAILURE);
 			}
 			break;
+		case OptIsUvc:
+			is_uvcvideo = true;
+			break;
+		case OptIsVivid:
+			is_vivid = true;
+			break;
 		case OptNoWarnings:
 			show_warnings = false;
 			break;
@@ -1869,6 +1883,10 @@ int main(int argc, char **argv)
 		usage();
 		std::exit(EXIT_FAILURE);
 	}
+	if (options[OptIsUvc] && options[OptIsVivid]) {
+		fprintf(stderr, "Options --is-uvc and --is-vivid are mutually exclusive.\n");
+		std::exit(EXIT_FAILURE);
+	}
 
 	print_sha();
 	printf("\n");

base-commit: be3d75c02de67a75d2a8cf4e5e1e70b6faa798dd

Signature · 1 line
2.56.0.317.g454f8302e1-goog