Skip to content

Commit

Permalink
Allow a second command line argument to dump EDID binary
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
  • Loading branch information
jeremyhu committed Oct 8, 2011
1 parent d65ad6a commit cc36404
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions edid-decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,20 +856,37 @@ static void dump_breakdown(unsigned char *edid)

int main(int argc, char **argv)
{
int fd;
int fd, ofd;
unsigned char *edid;
unsigned char *x;
time_t the_time;
struct tm *ptm;
int analog, i;

if (argc != 2) {
fd = 0;
} else {
if ((fd = open(argv[1], O_RDONLY)) == -1) {
perror(argv[1]);
switch (argc) {
case 1:
fd = 0;
ofd = -1;
break;
case 2:
if ((fd = open(argv[1], O_RDONLY)) == -1) {
perror(argv[1]);
return 1;
}
break;
case 3:
if ((fd = open(argv[1], O_RDONLY)) == -1) {
perror(argv[1]);
return 1;
}
if ((ofd = open(argv[2], O_WRONLY)) == -1) {
perror(argv[2]);
return 1;
}
break;
default:
fprintf(stderr, "What do you want from me?\n");
return 1;
}
}

edid = extract_edid(fd);
Expand All @@ -880,6 +897,11 @@ int main(int argc, char **argv)
if (fd != 0)
close(fd);

if (ofd != -1) {
write(ofd, edid, edid_lines * 16);
close(ofd);
}

dump_breakdown(edid);

if (!edid || memcmp(edid, "\x00\xFF\xFF\xFF\xFF\xFF\xFF\x00", 8)) {
Expand Down

0 comments on commit cc36404

Please sign in to comment.