Skip to content

Commit

Permalink
Support providing the EDID in hex (without log formatting)
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 6535739 commit 0b19978
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions edid-decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,41 @@ extract_edid(int fd)
return out;
}

/* Is the EDID provided in hex? */
for (i = 0; i < 32 && isxdigit(ret[i]); i++);
if (i == 32) {
out = malloc(size >> 1);
if (out == NULL) {
free(ret);
return NULL;
}

for (c=ret; *c; c++) {
char buf[3];

if (*c == '\n')
continue;

/* Read a %02x from the log */
if (!isxdigit(c[0]) || !isxdigit(c[1])) {
free(ret);
free(out);
return NULL;
}

buf[0] = c[0];
buf[1] = c[1];
buf[2] = 0;

out[out_index++] = strtol(buf, NULL, 16);
c++;
}

free(ret);
edid_lines = out_index >> 4;
return out;
}

/* wait, is this a log file? */
for (i = 0; i < 8; i++) {
if (!isascii(ret[i])) {
Expand Down

0 comments on commit 0b19978

Please sign in to comment.