diff options
author | Hans Verkuil <hverkuil-cisco@xs4all.nl> | 2021-12-15 10:33:58 +0100 |
---|---|---|
committer | Hans Verkuil <hverkuil-cisco@xs4all.nl> | 2021-12-15 10:33:58 +0100 |
commit | 6c905930e8e9bdf485f857ea8aadcaffbfd0943d (patch) | |
tree | b20af52577eecbb1a8c5f0d66a73d08e9aa2db78 | |
parent | 4251e70b56f5c8cf92b538a1aa3950c7463aede1 (diff) | |
download | v4l-utils-6c905930e8e9bdf485f857ea8aadcaffbfd0943d.tar.gz |
v4l2-ctl: support edid-decode output as --set-edid input
v4l2-ctl can now read EDID output from edid-decode as a file format
with --set-edid file=<edid-file>.
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r-- | utils/v4l2-ctl/v4l2-ctl-edid.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/utils/v4l2-ctl/v4l2-ctl-edid.cpp b/utils/v4l2-ctl/v4l2-ctl-edid.cpp index 96659377..c9f827dc 100644 --- a/utils/v4l2-ctl/v4l2-ctl-edid.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-edid.cpp @@ -246,7 +246,9 @@ static void edid_add_block(struct v4l2_edid *e) static void read_edid_file(FILE *f, struct v4l2_edid *e) { + static const char *ignore_chars = ",:;"; char value[3] = { 0 }; + char buf[256]; unsigned i = 0; int c; @@ -254,6 +256,19 @@ static void read_edid_file(FILE *f, struct v4l2_edid *e) e->edid = nullptr; e->blocks = 0; + /* + * Skip the first line if it matches the edid-decode output. + * After that first line the hex dump starts, and that's what we + * want to use here. + * + * This makes it possible to use the edid-decode output as EDID + * file. + */ + if (fgets(buf, sizeof(buf), f) && + !strstr(buf, "EDID (hex):") && + !strstr(buf, "edid-decode (hex):")) + fseek(f, SEEK_SET, 0); + while ((c = fgetc(f)) != EOF) { if (sformat == RAW) { if (i % 256 == 0) @@ -265,8 +280,10 @@ static void read_edid_file(FILE *f, struct v4l2_edid *e) /* Handle '0x' prefix */ if ((i & 1) && value[0] == '0' && (c == 'x' || c == 'X')) i--; - if (!isxdigit(c)) + if (isspace(c) || strchr(ignore_chars, c)) continue; + if (!isxdigit(c)) + break; if (i & 0x01) { value[1] = c; if (i % 256 == 1) |