aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--get-edid.h2
-rw-r--r--monitor-get-edid-using-vbe.c21
-rw-r--r--vbe.c15
4 files changed, 28 insertions, 13 deletions
diff --git a/NEWS b/NEWS
index df0871b..5259594 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,9 @@
was caused by a bug in the removed code)
o fix the retrieval of VBE vendor strings when using the LRMI interface
o retrieve up to 4 EDID extension blocks
+ o add --skip-vbe-check for skipping call for VBE info; useful if
+ calling the program multiple times for different ports
+ o on failure, return exit status 2 if no successful VBE calls were made
- monitor-parse-edid:
o print EDID version and the number of EDID extension blocks
diff --git a/get-edid.h b/get-edid.h
index b61dc98..2f72f0e 100644
--- a/get-edid.h
+++ b/get-edid.h
@@ -3,4 +3,4 @@
int verbose;
-int get_edid(char *edid, int port);
+int get_edid(char *edid, int port, int skip_vbe_check);
diff --git a/monitor-get-edid-using-vbe.c b/monitor-get-edid-using-vbe.c
index c70e663..abd9e9a 100644
--- a/monitor-get-edid-using-vbe.c
+++ b/monitor-get-edid-using-vbe.c
@@ -17,6 +17,7 @@ int main(int argc, char **argv)
{
char edid[(1 + MAX_EXTENSION_COUNT) * EDID_BLOCK_SIZE];
int try_in_console = 0;
+ int skip_vbe_check = 0;
int port = 0;
int i;
@@ -25,16 +26,18 @@ int main(int argc, char **argv)
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, "--skip-vbe-check") == 0) skip_vbe_check = 1;
else if (strcmp(arg, "-h") == 0 ||
strcmp(arg, "--help") == 0) {
- printf("usage: monitor-get-edid [-v] [--port <0-3>] [--try-in-console]\n");
+ printf("usage: monitor-get-edid [-v] [--port <0-3>] [--try-in-console]\n"
+ " [--skip-vbe-check]\n");
exit(1);
}
}
- int size = get_edid(edid, port);
+ int size = get_edid(edid, port, skip_vbe_check);
- if (!size && try_in_console) {
+ if (size <= 0 && try_in_console) {
int non_X_console = 1;
struct vt_stat current;
int fd = open("/dev/console", O_RDWR);
@@ -45,7 +48,7 @@ int main(int argc, char **argv)
ioctl(fd, VT_ACTIVATE, non_X_console) == 0 &&
ioctl(fd, VT_WAITACTIVE, non_X_console) == 0) {
/* retrying */
- size = get_edid(edid, port);
+ size = get_edid(edid, port, skip_vbe_check);
/* restore */
if (ioctl(fd, VT_ACTIVATE, current.v_active) == 0)
@@ -54,7 +57,13 @@ int main(int argc, char **argv)
close(fd);
}
- if (size) write(1, edid, size);
+ if (size > 0) {
+ write(1, edid, size);
+ return 0;
+ }
- return size ? 0 : 1;
+ /* return 1 when VBE call was ok but not EDID call;
+ * calling program can then speedup call on other ports with --skip-vbe-check;
+ * also, calling program knows no ports work if the VBE call failed */
+ return size < 0 ? 2 : 1;
}
diff --git a/vbe.c b/vbe.c
index 56882d3..57c9ac9 100644
--- a/vbe.c
+++ b/vbe.c
@@ -260,20 +260,23 @@ static int vbe_get_edid_info(char *edid, int port, int block)
return 1;
}
-int get_edid(char *edid, int port)
+int get_edid(char *edid, int port, int skip_vbe_check)
{
int i, extensions;
int ok = 0;
if (getuid() != 0) {
fprintf(stderr, "you must be root to run this program\n");
- return 0;
+ return -1;
}
- ok =
- (box_is_xbox() || (vbe_check_vbe_info() &&
- vbe_check_ddc_capabilities(port))) &&
- vbe_get_edid_info(edid, port, 0);
+ if (!box_is_xbox() && !skip_vbe_check) {
+ if (!vbe_check_vbe_info())
+ return -1;
+ }
+
+ ok = vbe_check_ddc_capabilities(port) &&
+ vbe_get_edid_info(edid, port, 0);
if (!ok)
return 0;