HYL_OK3568_LINUX/buildroot/package/libdrm/0002-modetest-Speed-up-dumping-info.patch
2025-05-10 21:49:39 +08:00

154 lines
4.6 KiB
Diff

From 65b545d762100c4012c2f8176f5c296d5bfcbdc4 Mon Sep 17 00:00:00 2001
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Date: Sat, 15 Dec 2018 12:20:01 +0800
Subject: [PATCH 2/5] modetest: Speed up dumping info
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
tests/modetest/modetest.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 8ff6c80..5291ca0 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -50,6 +50,7 @@
#include <strings.h>
#include <errno.h>
#include <poll.h>
+#include <fcntl.h>
#include <sys/time.h>
#if HAVE_SYS_SELECT_H
#include <sys/select.h>
@@ -71,6 +72,10 @@
static enum util_fill_pattern primary_fill = UTIL_PATTERN_SMPTE;
static enum util_fill_pattern secondary_fill = UTIL_PATTERN_TILES;
+int encoders = 0, connectors = 0, crtcs = 0, planes = 0, fbs = 0;
+int dump_only;
+#define need_resource(type) (!dump_only || type##s)
+
struct crtc {
drmModeCrtc *crtc;
drmModeObjectProperties *props;
@@ -485,7 +490,7 @@ static void dump_crtcs(struct device *dev)
printf("\n");
}
-static void dump_framebuffers(struct device *dev)
+static void dump_fbs(struct device *dev)
{
drmModeFB *fb;
int i;
@@ -554,6 +559,7 @@ static void free_resources(struct resources *res)
return;
#define free_resource(_res, type, Type) \
+ if (need_resource(type)) \
do { \
if (!(_res)->type##s) \
break; \
@@ -566,6 +572,7 @@ static void free_resources(struct resources *res)
} while (0)
#define free_properties(_res, type) \
+ if (need_resource(type)) \
do { \
for (i = 0; i < (int)(_res)->count_##type##s; ++i) { \
unsigned int j; \
@@ -578,10 +585,10 @@ static void free_resources(struct resources *res)
free_properties(res, plane);
free_resource(res, plane, Plane);
-
free_properties(res, connector);
free_properties(res, crtc);
+ if (need_resource(connector))
for (i = 0; i < res->count_connectors; i++)
free(res->connectors[i].name);
@@ -630,6 +637,7 @@ static struct resources *get_resources(struct device *dev)
}
#define get_resource(_res, __res, type, Type) \
+ if (need_resource(type)) \
do { \
for (i = 0; i < (int)(_res)->count_##type##s; ++i) { \
uint32_t type##id = (__res)->type##s[i]; \
@@ -650,6 +658,7 @@ static struct resources *get_resources(struct device *dev)
drmModeFreeResources(_res);
/* Set the name of all connectors based on the type name and the per-type ID. */
+ if (need_resource(connector))
for (i = 0; i < res->count_connectors; i++) {
struct connector *connector = &res->connectors[i];
drmModeConnector *conn = connector->connector;
@@ -663,6 +672,7 @@ static struct resources *get_resources(struct device *dev)
}
#define get_properties(_res, type, Type) \
+ if (need_resource(type)) \
do { \
for (i = 0; i < (int)(_res)->count_##type##s; ++i) { \
struct type *obj = &res->type##s[i]; \
@@ -690,6 +700,7 @@ static struct resources *get_resources(struct device *dev)
get_properties(res, crtc, CRTC);
get_properties(res, connector, CONNECTOR);
+ if (need_resource(crtc))
for (i = 0; i < res->count_crtcs; ++i)
res->crtcs[i].mode = &res->crtcs[i].crtc->mode;
@@ -2026,7 +2037,6 @@ int main(int argc, char **argv)
struct device dev;
int c;
- int encoders = 0, connectors = 0, crtcs = 0, planes = 0, framebuffers = 0;
int drop_master = 0;
int test_vsync = 0;
int test_cursor = 0;
@@ -2070,7 +2080,7 @@ int main(int argc, char **argv)
encoders = 1;
break;
case 'f':
- framebuffers = 1;
+ fbs = 1;
break;
case 'F':
parse_fill_patterns(optarg);
@@ -2143,7 +2153,7 @@ int main(int argc, char **argv)
/* Dump all the details when no* arguments are provided. */
if (!args)
- encoders = connectors = crtcs = planes = framebuffers = 1;
+ encoders = connectors = crtcs = planes = fbs = 1;
if (test_vsync && !count) {
fprintf(stderr, "page flipping requires at least one -s option.\n");
@@ -2159,7 +2169,11 @@ int main(int argc, char **argv)
return -1;
}
- dev.fd = util_open(device, module);
+ dump_only = !count && !plane_count && !prop_count;
+ if (dump_only && !device && !module)
+ dev.fd = open("/dev/dri/card0", O_RDWR);
+ else
+ dev.fd = util_open(device, module);
if (dev.fd < 0)
return -1;
@@ -2186,7 +2200,7 @@ int main(int argc, char **argv)
dump_resource(&dev, connectors);
dump_resource(&dev, crtcs);
dump_resource(&dev, planes);
- dump_resource(&dev, framebuffers);
+ dump_resource(&dev, fbs);
for (i = 0; i < prop_count; ++i)
set_property(&dev, &prop_args[i]);
--
2.20.1