aboutsummaryrefslogtreecommitdiffstats
path: root/parse-displayid-block.cpp
diff options
context:
space:
mode:
authorjoevt <joevt@shaw.ca>2021-09-26 01:33:26 -0700
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2021-09-27 13:18:27 +0200
commit268453d4d9f06de4840729c4cc2bcd31f2ed4616 (patch)
treeddc97dba9ef5976a0cf86745e91e2baed5c311d9 /parse-displayid-block.cpp
parent01199b2ea0cf890af083ec57133f2ce7e70e4950 (diff)
edid-decode: more OUI changes
Since OUI is part of the tag, we can make the following changes: - Replace cta.last_block_was_hdmi_vsdb with cta.previous_cta_tag. Instead of remembering if the last tag was HDMI VSDB, we can just always remember the last tag value and compare it to the HDMI VSDB tag value. With this change, we can clean up the HDMI VSDB case statement (remove the two lines that also exist at the end of the switch and change the return to a break. - Change found_tags from std::set to std::vector. std::vector not only remembers all the flags, but also their order so you could use it to find the number of tags or the first tag (replace block_number?) or the last tag (replace previous_cta_tag?). We could replace previous_cta_tag except found_tags is separate for DisplayID block for some reason, while previous_cta_tag is used for CTA data blocks in both CTA blocks and DisplayID blocks. Maybe there should be only one found_tags, like there is only one previous_cta_tag. - Remove duplicate parameter from cta_block. Instead, pass the list of found_tags that we want to check for duplicates. This way, the tag value doesn't need to be recalculated. - For blocks with OUI that we don't know how to parse, skip OUI even if it is zero. Make sure length passed to hex_block is not negative. Signed-off-by: Joe van Tunen <joevt@shaw.ca> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'parse-displayid-block.cpp')
-rw-r--r--parse-displayid-block.cpp27
1 files changed, 11 insertions, 16 deletions
diff --git a/parse-displayid-block.cpp b/parse-displayid-block.cpp
index 597005e..a38c90e 100644
--- a/parse-displayid-block.cpp
+++ b/parse-displayid-block.cpp
@@ -1556,15 +1556,7 @@ void edid_state::parse_displayid_cta_data_block(const unsigned char *x)
x += 3;
for (i = 0; i < len; i += (x[i] & 0x1f) + 1) {
- unsigned tag = (x[i] & 0xe0) << 3;
-
- if (tag == 0x700)
- tag |= x[i + 1];
- bool duplicate = dispid.found_tags.find(tag) != dispid.found_tags.end();
-
- cta_block(x + i, duplicate);
- if (!duplicate)
- dispid.found_tags.insert(tag);
+ cta_block(x + i, dispid.found_tags);
}
if (i != len)
@@ -1653,21 +1645,25 @@ void edid_state::preparse_displayid_block(const unsigned char *x)
#define data_block_o(n, a, b) \
do { \
+ unsigned ouinum; \
data_block_oui(n, x + 3, len, &ouinum, tag == 0, a, b); \
dooutputname = false; \
+ if (tag != 0x00 && tag != 0x20) tag |= ouinum; \
+ hasoui = true; \
} while (0)
unsigned edid_state::displayid_block(const unsigned version, const unsigned char *x, unsigned length)
{
unsigned i;
unsigned tag = x[0];
- unsigned ouinum = 0;
+ unsigned tag_version = (tag < 0x20) ? 1 : (tag < 0x7f) ? 2 : (tag < 0x80) ? 1 : 0;
bool dooutputname = true;
unsigned len = (length < 3) ? 0 : x[2];
+ bool hasoui = false;
switch (tag) {
// DisplayID 1.3:
- case 0x00: data_block_o("Product Identification Data Block (" + utohex(tag) + ")", true, false); ouinum = 0; break;
+ case 0x00: data_block_o("Product Identification Data Block (" + utohex(tag) + ")", true, false); break;
case 0x01: data_block = "Display Parameters Data Block (" + utohex(tag) + ")"; break;
case 0x02: data_block = "Color Characteristics Data Block"; break;
case 0x03: data_block = "Video Timing Modes Type 1 - Detailed Timings Data Block"; break;
@@ -1689,7 +1685,7 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char
case 0x13: data_block = "Video Timing Modes Type 6 - Detailed Timings Data Block"; break;
// 0x14 .. 0x7e RESERVED for Additional VESA-defined Data Blocks
// DisplayID 2.0
- case 0x20: data_block_o("Product Identification Data Block (" + utohex(tag) + ")", false, false); ouinum = 0; break;
+ case 0x20: data_block_o("Product Identification Data Block (" + utohex(tag) + ")", false, false); break;
case 0x21: data_block = "Display Parameters Data Block (" + utohex(tag) + ")"; break;
case 0x22: data_block = "Video Timing Modes Type 7 - Detailed Timings Data Block"; break;
case 0x23: data_block = "Video Timing Modes Type 8 - Enumerated Timing Codes Data Block"; break;
@@ -1743,16 +1739,15 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char
if (dooutputname && data_block.length())
printf(" %s:\n", data_block.c_str());
- if (version >= 0x20 && (tag < 0x20 || tag == 0x7f))
+ if (version >= 0x20 && tag_version == 1)
fail("Use of DisplayID v1.x tag for DisplayID v%u.%u.\n",
version >> 4, version & 0xf);
- if (version < 0x20 && tag >= 0x20 && tag <= 0x7e)
+ if (version < 0x20 && tag_version == 2)
fail("Use of DisplayID v2.0 tag for DisplayID v%u.%u.\n",
version >> 4, version & 0xf);
unsigned block_rev = x[1] & 0x07;
- tag |= ouinum;
switch (tag) {
case 0x00: parse_displayid_product_id(x); break;
case 0x01: parse_displayid_parameters(x); break;
@@ -1875,7 +1870,7 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char
}
case 0x7e|kOUI_VESA: parse_displayid_vesa(x); break;
case 0x81: parse_displayid_cta_data_block(x); break;
- default: hex_block(" ", x + 3 + (ouinum ? 3 : 0), len - (ouinum ? 3 : 0)); break;
+ default: hex_block(" ", x + 3 + (hasoui ? 3 : 0), (len > (hasoui ? 3 : 0)) ? len - (hasoui ? 3 : 0) : 0); break;
}
if ((tag == 0x00 || tag == 0x20) &&

Privacy Policy