meta-st-stm32mp/recipes-graphics/drm/libdrm/0001-tests-modetest-automat...

124 lines
3.5 KiB
Diff

From 93a5788758bf97e1017c34fbda54e1e66f301f32 Mon Sep 17 00:00:00 2001
From: Christophe Priouzeau <christophe.priouzeau@foss.st.com>
Date: Thu, 9 Sep 2021 14:26:39 +0200
Subject: [PATCH 1/4] tests/modetest: automatic configuration
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Add a new option to set automatically a mode using default crtc,
encoder and mode.
Signed-off-by: Yannick Fertré <yannick.fertre@st.com>
---
tests/modetest/modetest.c | 54 +++++++++++++++++++++++++++++++++++++--
1 file changed, 52 insertions(+), 2 deletions(-)
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 2c83bd0..f11095b 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -1990,7 +1990,7 @@ static void parse_fill_patterns(char *arg)
static void usage(char *name)
{
- fprintf(stderr, "usage: %s [-acDdefMPpsCvrw]\n", name);
+ fprintf(stderr, "usage: %s [-acDdefMPpsCvrwA]\n", name);
fprintf(stderr, "\n Query options:\n\n");
fprintf(stderr, "\t-c\tlist connectors\n");
@@ -2012,12 +2012,13 @@ static void usage(char *name)
fprintf(stderr, "\t-d\tdrop master after mode set\n");
fprintf(stderr, "\t-M module\tuse the given driver\n");
fprintf(stderr, "\t-D device\tuse the given device\n");
+ fprintf(stderr, "\t-A Set a mode using default crtc, encoder and mode.\n");
fprintf(stderr, "\n\tDefault is to dump all info.\n");
exit(0);
}
-static char optstr[] = "acdD:efF:M:P:ps:Cvrw:";
+static char optstr[] = "acdD:efF:M:P:ps:Cvrw:A";
int main(int argc, char **argv)
{
@@ -2039,6 +2040,7 @@ int main(int argc, char **argv)
struct plane_arg *plane_args = NULL;
struct property_arg *prop_args = NULL;
unsigned int args = 0;
+ bool auto_configuration = false;
int ret;
memset(&dev, 0, sizeof dev);
@@ -2133,12 +2135,18 @@ int main(int argc, char **argv)
prop_count++;
break;
+ case 'A':
+ auto_configuration = true;
+ break;
default:
usage(argv[0]);
break;
}
}
+ if (auto_configuration)
+ use_atomic = false;
+
/* Dump all the details when no* arguments are provided. */
if (!args)
encoders = connectors = crtcs = planes = framebuffers = 1;
@@ -2201,6 +2209,48 @@ int main(int argc, char **argv)
return 1;
}
+#define connector_status_connected 1
+ if (auto_configuration) {
+ struct resources *resources = dev.resources;
+ drmModeConnector *connector;
+ char auto_arg[32];
+ int j;
+
+ if (!resources->count_connectors ||
+ !resources->count_crtcs) {
+ fprintf(stderr, "Cannot find connector or crtc\n");
+ return 1;
+ }
+
+ for (j = 0; j < resources->count_connectors; j++) {
+ connector = resources->connectors[j].connector;
+ if(connector->connection == connector_status_connected)
+ break;
+ }
+
+ if (!connector->count_modes) {
+ fprintf(stderr, "Cannot find mode\n");
+ return 1;
+ }
+
+ snprintf(auto_arg, sizeof(auto_arg) - 1, "%d@%d:%s-%d@%s\n",
+ connector->connector_id, resources->crtcs[0].crtc->crtc_id,
+ connector->modes[0].name, connector->modes[0].vrefresh,
+ "XR24");
+
+ pipe_args = realloc(pipe_args, sizeof *pipe_args);
+ if (pipe_args == NULL) {
+ fprintf(stderr, "memory allocation failed\n");
+ return 2;
+ }
+ memset(&pipe_args[count], 0, sizeof(*pipe_args));
+
+ if (parse_connector(&pipe_args[count], auto_arg) < 0)
+ return 3;
+ /* fix to one plane without atomic */
+ count = 1;
+ }
+
if (set_preferred || count)
set_mode(&dev, pipe_args, count);
--
2.25.1