#include #include #include #include #include #include #include #include #include #include #include #include "get-edid.h" #include "hd.h" int verbose = 0; int main(int argc, char **argv) { char edid[256]; int try_in_console = 0; int port = 0; int i; /* Hardware Data defaults */ hd_data_t hd_data; hd_data.flags.biosvram = 0; /* don't map video BIOS RAM */ hd_data.flags.nobioscrc = 1; /* don't check VBIOS CRC */ hd_data.flags.cpuemu = 1; /* use CPU emulator everywhere... */ #ifdef __i386__ hd_data.flags.cpuemu = 0; /* ... but ia32, unless VBIOS CRC is invalid */ #endif for (i = 1; i < argc; i++) { const char *arg = argv[i]; if (strcmp(arg, "-v") == 0) verbose = 1; else if (strcmp(arg, "--port") == 0 && i+1 < argc) port = atoi(argv[++i]); else if (strcmp(arg, "--try-in-console") == 0) try_in_console = 1; else if (strcmp(arg, "--map-bios-vram") == 0) hd_data.flags.biosvram = 1; else if (strcmp(arg, "--check-bios-crc") == 0) hd_data.flags.nobioscrc = 0; else if (strcmp(arg, "--use-cpuemu") == 0) hd_data.flags.cpuemu = 1; else if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) { printf("usage: monitor-get-edid [-v] [--port <0-3>]\n"); exit(1); } } int size = get_edid(&hd_data, edid, port); 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, ¤t) == 0 && current.v_active >= first_X_console && ioctl(fd, VT_ACTIVATE, non_X_console) == 0 && ioctl(fd, VT_WAITACTIVE, non_X_console) == 0) { /* retrying */ size = get_edid(&hd_data, edid, port); /* 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; }