aboutsummaryrefslogtreecommitdiffstats
path: root/parse-displayid-block.cpp
diff options
context:
space:
mode:
authorjoevt <joevt@shaw.ca>2021-09-26 01:33:25 -0700
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2021-09-27 13:17:09 +0200
commit01199b2ea0cf890af083ec57133f2ce7e70e4950 (patch)
tree6ea200e7f7e204e6c16bf0d140a35cc2b7f1a3dd /parse-displayid-block.cpp
parentb81361285b98b3a7636f033c52f94172add06892 (diff)
edid-decode: make OUI enum
Instead of a 3 byte value, create an enumeration of known OUIs. This way, it can be combined with tag value to identify a data block type with a single value. This value can be used in a switch statement or other places (see later commits). - The list of known OUIs is in a new file oui.h. It contains the 3 byte value, a enum base name for the enum, and the OUI name. - The oui.h can be included in other source files for different purposes be changing the oneoui macro. It's used in edid-decode.h to define the enumeration. - Function oui_name uses oui.h to convert an OUI to the enum value. Removed the reverse parameter - OUI byte order is now handled by the caller, data_block_oui. - data_block_oui is modified to do the following: - It will return the oui enumeration. - It is made suitable for OUIs in DisplayID data blocks. - The ignorezeos flag is only true for the DisplayID "Product Identification Data Block". If the data block is zeros then it's probably not a data block so ignore it. For "Product Identification Data Block", the OUI doesn't change the interpretation of the data block so caller (displayid_block) then immediately clears the OUI enum. - The do_ascii flag is true for DisplayID v1.2 data blocks (section 4.1.1 of the DisplayID 1.3 spec says Manufacturer/Vendor ID is ASCII). - The big_endian flag is true for DisplayID v2.0 data blocks and false for CTA-861 data blocks. - It always outputs the block name first so that fails and warnings will appear after the block name instead of before. data_block_oui does the following: - It gets the OUI bytes in the order determined by the big_endian flag. An OUI is a 24 bit number. - It gets a PNP ID value (ASCII) with the same 3 bytes. A PNP ID in oui.h is a 32 bit number (3 characters [A-Z] followed by a NULL) so it cannot be confused with an OUI in the same file. - If bytes of the OUI extend beyond the end of the block then they are assumed to be zero, and it does not try to convert the OUI to a name, and the enum result is 0 which is invalid, and the PNP result is "?" which is invalid. - It tries to match the OUI. If that doesn't match then it tries to match the reversed OUI. If DisplayID v1.2 then it also tries to match PNP if the other two didn't match. - If ASCII is expected (DisplayID v1.2) and found, the output block name is "block_name, PNP ID 'ABC'". It is output with a colon as usual. - The "Unknown block_name, OUI %s." warning message is replaced by "Unknown OUI %s." (or with "Unknown OUI %s (possible PNP %s)." if ASCII is expected and %the OUI is valid ASCII). In either case, the warning is prefixed by %"block_name, OUI %s:" or "block_name, PNP ID %s:" in the warnings and %failures section. - The "Invalid length %u < 3." fail message is replaced by "Data block length (%d) is not enough to contain an OUI.". - The "OUI %s is in the wrong byte order" fail message (which is missing the trailing period) is replaced with "Endian-ness (be|le) of OUI is different than expected (le|be)." - In parse-cta-block.cpp and parse-displayid-block.cpp, in the first switch statement, any tag with an OUI has its block name output by data_block_oui so they'll set dooutputname to false to stop the block name from being output again. - In parse-displayid-block.cpp, don't include OUI in hex dump of unknown data block types. Signed-off-by: Joe van Tunen <joevt@shaw.ca> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> [hverkuil: changed fail("Expected PNP ID but found OUI.") to warn()]
Diffstat (limited to 'parse-displayid-block.cpp')
-rw-r--r--parse-displayid-block.cpp46
1 files changed, 16 insertions, 30 deletions
diff --git a/parse-displayid-block.cpp b/parse-displayid-block.cpp
index 269444b..597005e 100644
--- a/parse-displayid-block.cpp
+++ b/parse-displayid-block.cpp
@@ -1651,16 +1651,23 @@ void edid_state::preparse_displayid_block(const unsigned char *x)
}
}
+#define data_block_o(n, a, b) \
+do { \
+ data_block_oui(n, x + 3, len, &ouinum, tag == 0, a, b); \
+ dooutputname = false; \
+} while (0)
+
unsigned edid_state::displayid_block(const unsigned version, const unsigned char *x, unsigned length)
{
unsigned i;
unsigned tag = x[0];
- unsigned oui = 0;
+ unsigned ouinum = 0;
+ bool dooutputname = true;
unsigned len = (length < 3) ? 0 : x[2];
switch (tag) {
// DisplayID 1.3:
- case 0x00: data_block = "Product Identification Data Block (" + utohex(tag) + ")"; break;
+ case 0x00: data_block_o("Product Identification Data Block (" + utohex(tag) + ")", true, false); ouinum = 0; 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;
@@ -1682,7 +1689,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 = "Product Identification Data Block (" + utohex(tag) + ")"; break;
+ case 0x20: data_block_o("Product Identification Data Block (" + utohex(tag) + ")", false, false); ouinum = 0; 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;
@@ -1695,26 +1702,8 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char
case 0x2b: data_block = "Adaptive Sync Data Block"; break;
case 0x32: data_block = "Video Timing Modes Type 10 - Formula-based Timings Data Block"; break;
// 0x2a .. 0x7d RESERVED for Additional VESA-defined Data Blocks
- case 0x7e: // DisplayID 2.0
- case 0x7f: // DisplayID 1.3
- {
- oui = (x[3] << 16) + (x[4] << 8) + x[5];
- const char *name = oui_name(oui);
- bool reversed = false;
-
- if (!name) {
- name = oui_name(oui, true);
- if (name)
- reversed = true;
- }
- if (name)
- data_block = "Vendor-Specific Data Block (" + utohex(tag) + ") (" + name + ")";
- else
- data_block = "Vendor-Specific Data Block (" + utohex(tag) + "), OUI " + ouitohex(oui);
- if (reversed)
- fail((std::string("OUI ") + ouitohex(oui) + " is in the wrong byte order.\n").c_str());
- }
- break;
+ case 0x7e: data_block_o("Vendor-Specific Data Block (" + utohex(tag) + ")", false, true); break; // DisplayID 2.0
+ case 0x7f: data_block_o("Vendor-Specific Data Block (" + utohex(tag) + ")", true, false); break; // DisplayID 1.3
// 0x80 RESERVED
case 0x81: data_block = "CTA-861 DisplayID Data Block"; break;
// 0x82 .. 0xff RESERVED
@@ -1751,6 +1740,7 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char
return length;
}
+ if (dooutputname && data_block.length())
printf(" %s:\n", data_block.c_str());
if (version >= 0x20 && (tag < 0x20 || tag == 0x7f))
@@ -1762,6 +1752,7 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char
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;
@@ -1882,14 +1873,9 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char
parse_displayid_type_10_timing(&x[3 + i * sz], sz);
break;
}
+ case 0x7e|kOUI_VESA: parse_displayid_vesa(x); break;
case 0x81: parse_displayid_cta_data_block(x); break;
- case 0x7e:
- if (oui == 0x3a0292) {
- parse_displayid_vesa(x);
- break;
- }
- // fall-through
- default: hex_block(" ", x + 3, len); break;
+ default: hex_block(" ", x + 3 + (ouinum ? 3 : 0), len - (ouinum ? 3 : 0)); break;
}
if ((tag == 0x00 || tag == 0x20) &&

Privacy Policy