From 5ed5fa10600f0140b317ec07be6f24739c11bd18 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 4 Mar 2015 10:07:19 +0000 Subject: mode: Retrieve only the current information for a Connector Add a new API that allows the caller to skip any forced probing, which may require slow i2c to a remote display, and only report the currently active mode and encoder for a Connector. This is often the information of interest and is much, much faster than re-retrieving the link status and EDIDs, e.g. if the caller only wishes to count the number of active outputs. v2: Fix error path to avoid double free after a failed GETCONNECTOR ioctl. v3: Daniel strongly disapproved of my disjoint in behaviour between GetConnector and GetConnectorCurrent, and considering how best to make a drop in replacement for drmmode_output_init() convinced me keeping the API as consistent as possible was the right approach. v4: Avoid probing on the second calls to GETCONNECTOR for unconnected outputs. Signed-off-by: Chris Wilson Cc: Daniel Vetter Cc: Damien Lespiau Cc: David Herrmann Reviewed-by: Daniel Vetter --- tests/modeprint/modeprint.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'tests/modeprint/modeprint.c') diff --git a/tests/modeprint/modeprint.c b/tests/modeprint/modeprint.c index de59cbd1..e6c6553b 100644 --- a/tests/modeprint/modeprint.c +++ b/tests/modeprint/modeprint.c @@ -43,6 +43,7 @@ #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) +int current; int connectors; int full_props; int edid; @@ -272,7 +273,7 @@ static int printRes(int fd, drmModeResPtr res) if (connectors) { for (i = 0; i < res->count_connectors; i++) { - connector = drmModeGetConnector(fd, res->connectors[i]); + connector = (current ? drmModeGetConnectorCurrent : drmModeGetConnector) (fd, res->connectors[i]); if (!connector) printf("Could not get connector %i\n", res->connectors[i]); @@ -331,6 +332,7 @@ static int printRes(int fd, drmModeResPtr res) static void args(int argc, char **argv) { + int defaults = 1; int i; fbs = 0; @@ -341,32 +343,41 @@ static void args(int argc, char **argv) full_modes = 0; full_props = 0; connectors = 0; + current = 0; module_name = argv[1]; for (i = 2; i < argc; i++) { if (strcmp(argv[i], "-fb") == 0) { fbs = 1; + defaults = 0; } else if (strcmp(argv[i], "-crtcs") == 0) { crtcs = 1; + defaults = 0; } else if (strcmp(argv[i], "-cons") == 0) { connectors = 1; modes = 1; + defaults = 0; } else if (strcmp(argv[i], "-modes") == 0) { connectors = 1; modes = 1; + defaults = 0; } else if (strcmp(argv[i], "-full") == 0) { connectors = 1; modes = 1; full_modes = 1; + defaults = 0; } else if (strcmp(argv[i], "-props") == 0) { connectors = 1; full_props = 1; + defaults = 0; } else if (strcmp(argv[i], "-edids") == 0) { connectors = 1; edid = 1; + defaults = 0; } else if (strcmp(argv[i], "-encoders") == 0) { encoders = 1; + defaults = 0; } else if (strcmp(argv[i], "-v") == 0) { fbs = 1; edid = 1; @@ -376,10 +387,13 @@ static void args(int argc, char **argv) full_modes = 1; full_props = 1; connectors = 1; + defaults = 0; + } else if (strcmp(argv[i], "-current") == 0) { + current = 1; } } - if (argc == 2) { + if (defaults) { fbs = 1; edid = 1; crtcs = 1; -- cgit v1.2.3