From: Simon Farnsworth <simon.farnsworth@onelan.co.uk>
To: dri-devel@lists.freedesktop.org
Subject: [PATCH edid-decode] Read extension blocks in xrandr EDID property
Date: Tue, 26 Nov 2013 11:25:49 +0000 [thread overview]
Message-ID: <1385465149-4331-1-git-send-email-simon.farnsworth@onelan.co.uk> (raw)
Extend the parsing of the xrandr EDID property block to read extension
blocks, not just the basic block.
Signed-off-by: Simon Farnsworth <simon.farnsworth@onelan.co.uk>
---
edid-decode.c | 45 ++++++++++++++++++++++++++++++++-------------
1 file changed, 32 insertions(+), 13 deletions(-)
diff --git a/edid-decode.c b/edid-decode.c
index 4265843..e26ad3e 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -1126,38 +1126,56 @@ extract_edid(int fd)
start = strstr(ret, "EDID_DATA:");
if (start == NULL)
start = strstr(ret, "EDID:");
- /* Look for xrandr --verbose output (8 lines of 16 hex bytes) */
+ /* Look for xrandr --verbose output (lines of 16 hex bytes) */
if (start != NULL) {
const char indentation1[] = " ";
const char indentation2[] = "\t\t";
+ /* Used to detect that we've gone past the EDID property */
+ const char half_indentation1[] = " ";
+ const char half_indentation2[] = "\t";
const char *indentation;
char *s;
- out = malloc(128);
- if (out == NULL) {
- free(ret);
- return NULL;
- }
-
- for (i = 0; i < 8; i++) {
+ lines = 0;
+ for (i = 0;; i++) {
int j;
- /* Get the next start of the line of EDID hex. */
+ /* Get the next start of the line of EDID hex, assuming spaces for indentation */
s = strstr(start, indentation = indentation1);
- if (!s)
+ /* Did we skip the start of another property? */
+ if (s && s > strstr(start, half_indentation1))
+ break;
+
+ /* If we failed, retry assuming tabs for indentation */
+ if (!s) {
s = strstr(start, indentation = indentation2);
- if (s == NULL) {
+ /* Did we skip the start of another property? */
+ if (s && s > strstr(start, half_indentation2))
+ break;
+ }
+
+ if (!s)
+ break;
+
+ lines++;
+ start = s + strlen(indentation);
+
+ s = realloc(out, lines * 16);
+ if (!s) {
free(ret);
free(out);
return NULL;
}
- start = s + strlen(indentation);
-
+ out = (unsigned char *)s;
c = start;
for (j = 0; j < 16; j++) {
char buf[3];
/* Read a %02x from the log */
if (!isxdigit(c[0]) || !isxdigit(c[1])) {
+ if (j != 0) {
+ lines--;
+ break;
+ }
free(ret);
free(out);
return NULL;
@@ -1171,6 +1189,7 @@ extract_edid(int fd)
}
free(ret);
+ edid_lines = lines;
return out;
}
--
1.8.3.1
next reply other threads:[~2013-11-26 12:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-26 11:25 Simon Farnsworth [this message]
2013-12-17 23:37 ` [PATCH edid-decode] Read extension blocks in xrandr EDID property Damien Lespiau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1385465149-4331-1-git-send-email-simon.farnsworth@onelan.co.uk \
--to=simon.farnsworth@onelan.co.uk \
--cc=dri-devel@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).