[PATCH i-g-t 2/3] benchmarks/kms_fb_stress: Add command line options to change the planes and writeback formats

Arthur Grillo arthurgrillo at riseup.net
Mon Feb 26 19:42:18 UTC 2024


Currently, the plane formats are hard-coded, with no possibility of
changing them when running the benchmark. Change that by adding command
line options to change the planes and writeback formats.

Signed-off-by: Arthur Grillo <arthurgrillo at riseup.net>
---
 benchmarks/kms_fb_stress.c | 50 ++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 46 insertions(+), 4 deletions(-)

diff --git a/benchmarks/kms_fb_stress.c b/benchmarks/kms_fb_stress.c
index 8fea10ef069f..073104b8e4f8 100644
--- a/benchmarks/kms_fb_stress.c
+++ b/benchmarks/kms_fb_stress.c
@@ -125,7 +125,7 @@ static void set_crtc_size(struct data_t *data)
 	igt_assert_f(0, "CRTC size %dx%d not supported\n", crtc->width, crtc->height);
 }
 
-static struct kms_t default_kms = {
+static const struct kms_t default_kms = {
 	.crtc = {
 		.width = 4096, .height = 2160,
 	},
@@ -159,14 +159,56 @@ static struct kms_t default_kms = {
 	},
 };
 
+static int opt_handler(int opt, int opt_index, void *_data)
+{
+	struct data_t *data = _data;
+	struct kms_t *kms =  &data->kms;
+
+	*kms = default_kms;
+
+	switch (opt) {
+	case 'p':
+		kms->primary.format = igt_drm_format_str_to_format(optarg);
+		break;
+	case 'a':
+		kms->overlay_a.format = igt_drm_format_str_to_format(optarg);
+		break;
+	case 'b':
+		kms->overlay_b.format = igt_drm_format_str_to_format(optarg);
+		break;
+	case 'w':
+		kms->writeback.format = igt_drm_format_str_to_format(optarg);
+		break;
+	default:
+		return IGT_OPT_HANDLER_ERROR;
+	}
+
+	return IGT_OPT_HANDLER_SUCCESS;
+}
+
+static const char *help_str =
+	"  --primary-format\t\tSelect the primary plane format (default: XRGB8888)\n"
+	"  --overlay-a-format\t\tSelect the overlay A plane format (default: XRGB16161616)\n"
+	"  --overlay-b-format\t\tSelect the overlay B plane format (default: ARGB8888)\n"
+	"  --writeback-format\t\tSelect the writeback format (default: XRGB8888)\n";
+
+static const struct option long_options[] = {
+	{ .name = "primary-format", .has_arg = true, .val = 'p'},
+	{ .name = "overlay-a-format", .has_arg = true, .val = 'a'},
+	{ .name = "overlay-b-format", .has_arg = true, .val = 'b'},
+	{ .name = "writeback-format", .has_arg = true, .val = 'w'},
+	{}
+};
+
+static struct data_t data = {
+	.kms = default_kms,
+};
 
-igt_simple_main
+igt_simple_main_args(NULL, long_options, help_str, opt_handler, &data)
 {
-	struct data_t data = {0};
 	struct timespec then, now;
 	double elapsed;
 
-	data.kms = default_kms;
 
 	data.fd = drm_open_driver_master(DRIVER_ANY);
 

-- 
2.43.0



More information about the igt-dev mailing list