aboutsummaryrefslogtreecommitdiffstats
path: root/monitor-get-edid-using-vbe.c
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2006-01-06 11:21:23 +0000
committerPascal Rigaux <pixel@mandriva.com>2006-01-06 11:21:23 +0000
commit44eacabbffe8127f528a9f09593910233d55cd86 (patch)
treeecd833f408b02b5f22b950d2d08655426fe252af /monitor-get-edid-using-vbe.c
parent53c3590bd16fd8a0392974b8c08961ea18c91b9b (diff)
downloadmonitor-edid-44eacabbffe8127f528a9f09593910233d55cd86.tar
monitor-edid-44eacabbffe8127f528a9f09593910233d55cd86.tar.gz
monitor-edid-44eacabbffe8127f528a9f09593910233d55cd86.tar.bz2
monitor-edid-44eacabbffe8127f528a9f09593910233d55cd86.tar.xz
monitor-edid-44eacabbffe8127f528a9f09593910233d55cd86.zip
- monitor-get-edid is now a perl script able to probe /proc/acpi/video
(or /proc/device-tree on PPC) - binary monitor-get-edid is now monitor-get-edid-using-vbe - monitor-edid is able to get more than one head
Diffstat (limited to 'monitor-get-edid-using-vbe.c')
-rw-r--r--monitor-get-edid-using-vbe.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/monitor-get-edid-using-vbe.c b/monitor-get-edid-using-vbe.c
new file mode 100644
index 0000000..50366f2
--- /dev/null
+++ b/monitor-get-edid-using-vbe.c
@@ -0,0 +1,56 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <sys/ioctl.h>
+#include <sys/vt.h>
+#include "get-edid.h"
+
+int verbose = 0;
+
+int main(int argc, char **argv)
+{
+ char edid[256];
+ int try_in_console = 0;
+ int i;
+
+ for (i = 1; i < argc; i++)
+ if (strcmp(argv[i], "-v") == 0) verbose = 1;
+ else if (strcmp(argv[i], "--try-in-console") == 0) try_in_console = 1;
+ else if (strcmp(argv[i], "-h") == 0 ||
+ strcmp(argv[i], "--help") == 0) {
+ printf("usage: monitor-get-edid [-v]\n");
+ exit(1);
+ }
+
+ int size = get_edid(edid);
+
+ if (!size && try_in_console) {
+ int non_X_console = 1;
+ int first_X_console = 7;
+ struct vt_stat current;
+ int fd = open("/dev/console", O_RDWR);
+
+ if (ioctl(fd, VT_GETSTATE, &current) == 0 &&
+ current.v_state >= first_X_console &&
+ ioctl(fd, VT_ACTIVATE, non_X_console) == 0 &&
+ ioctl(fd, VT_WAITACTIVE, non_X_console) == 0) {
+ /* retrying */
+ size = get_edid(edid);
+
+ /* restore */
+ ioctl(fd, VT_ACTIVATE, current.v_active) == 0 &&
+ ioctl(fd, VT_WAITACTIVE, current.v_active) == 0;
+ }
+ close(fd);
+ }
+
+ if (size) write(1, edid, size);
+
+ return size ? 0 : 1;
+}