aboutsummaryrefslogtreecommitdiffstats
path: root/parse-displayid-block.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'parse-displayid-block.cpp')
-rw-r--r--parse-displayid-block.cpp660
1 files changed, 374 insertions, 286 deletions
diff --git a/parse-displayid-block.cpp b/parse-displayid-block.cpp
index 5c81294..0f39830 100644
--- a/parse-displayid-block.cpp
+++ b/parse-displayid-block.cpp
@@ -81,12 +81,6 @@ void edid_state::parse_displayid_product_id(const unsigned char *x)
check_displayid_datablock_revision(x[1]);
dispid.has_product_identification = true;
- if (dispid.version >= 0x20) {
- unsigned oui = (x[3] << 16) | (x[4] << 8) | x[5];
- printf(" Vendor OUI %s\n", ouitohex(oui).c_str());
- } else {
- printf(" Vendor ID: %c%c%c\n", x[3], x[4], x[5]);
- }
printf(" Product Code: %u\n", x[6] | (x[7] << 8));
unsigned sn = x[8] | (x[9] << 8) | (x[10] << 16) | (x[11] << 24);
if (sn) {
@@ -136,6 +130,26 @@ static void print_flag_lines(const char *indent, const char *label,
}
}
+void edid_state::set_displayid_native_res(unsigned w, unsigned h)
+{
+ if (dispid.native_width &&
+ (dispid.native_width != w || dispid.native_height != h)) {
+ fail("Native resolution mismatch: %ux%u -> %ux%u.\n",
+ dispid.native_width, dispid.native_height, w, h);
+ return;
+ }
+
+ if (!w && !h)
+ return;
+
+ if (!w ^ !h) {
+ fail("Invalid Native Pixel Format %ux%u.\n", w, h);
+ } else {
+ dispid.native_width = w;
+ dispid.native_height = h;
+ }
+}
+
void edid_state::parse_displayid_parameters(const unsigned char *x)
{
check_displayid_datablock_revision(x[1]);
@@ -143,12 +157,22 @@ void edid_state::parse_displayid_parameters(const unsigned char *x)
if (!check_displayid_datablock_length(x, 12, 12))
return;
+ if (dispid.has_display_parameters)
+ fail("Duplicate Display Parameters Data Block.\n");
dispid.has_display_parameters = true;
+ dispid.image_width = (x[4] << 8) + x[3];
+ dispid.image_height = (x[6] << 8) + x[5];
+ if (dispid.image_width > image_width ||
+ dispid.image_height > image_height) {
+ image_width = dispid.image_width;
+ image_height = dispid.image_height;
+ }
printf(" Image size: %.1f mm x %.1f mm\n",
- ((x[4] << 8) + x[3]) / 10.0,
- ((x[6] << 8) + x[5]) / 10.0);
- printf(" Pixels: %d x %d\n",
- (x[8] << 8) + x[7], (x[10] << 8) + x[9]);
+ dispid.image_width / 10.0, dispid.image_height / 10.0);
+ unsigned w = (x[8] << 8) + x[7];
+ unsigned h = (x[10] << 8) + x[9];
+ printf(" Display native pixel format: %ux%u\n", w, h);
+ set_displayid_native_res(w, h);
print_flag_lines(" ", " Feature support flags:",
x[11], feature_support_flags);
@@ -597,13 +621,12 @@ void edid_state::parse_displayid_display_device(const unsigned char *x)
printf(" The backlight's intensity can be controlled\n");
unsigned w = x[5] | (x[6] << 8);
unsigned h = x[7] | (x[8] << 8);
- if (w && h) {
- printf(" Display native pixel format: %ux%u\n", w + 1, h + 1);
- dispid.native_width = w + 1;
- dispid.native_height = h + 1;
- } else if (w || h) {
- fail("Invalid Native Pixel Format %ux%u.\n", w, h);
- }
+
+ if (w) w++;
+ if (h) h++;
+
+ printf(" Display native pixel format: %ux%u\n", w, h);
+ set_displayid_native_res(w, h);
printf(" Aspect ratio and orientation:\n");
printf(" Aspect Ratio: %.2f\n", (100 + x[9]) / 100.0);
unsigned char v = x[0x0a];
@@ -1115,26 +1138,35 @@ void edid_state::parse_displayid_parameters_v2(const unsigned char *x,
{
if (!check_displayid_datablock_length(x, 29, 29))
return;
+ if (dispid.has_display_parameters)
+ fail("Duplicate Display Parameters Data Block.\n");
+ dispid.has_display_parameters = true;
unsigned hor_size = (x[4] << 8) + x[3];
unsigned vert_size = (x[6] << 8) + x[5];
- dispid.has_display_parameters = true;
- if (x[1] & 0x80)
- printf(" Image size: %u mm x %u mm\n",
- hor_size, vert_size);
- else
+ dispid.image_width = hor_size;
+ dispid.image_height = vert_size;
+ if (x[1] & 0x80) {
+ printf(" Image size: %u mm x %u mm\n", hor_size, vert_size);
+ dispid.image_width *= 10;
+ dispid.image_height *= 10;
+ } else {
printf(" Image size: %.1f mm x %.1f mm\n",
hor_size / 10.0, vert_size / 10.0);
+ }
+ if (dispid.image_width > image_width ||
+ dispid.image_height > image_height) {
+ image_width = dispid.image_width;
+ image_height = dispid.image_height;
+ }
+
unsigned w = (x[8] << 8) + x[7];
unsigned h = (x[10] << 8) + x[9];
- if (w && h) {
- printf(" Native Format: %ux%u\n", w, h);
- dispid.native_width = w;
- dispid.native_height = h;
- } else if (w || h) {
- fail("Invalid Native Format %ux%u.\n", w, h);
- }
+
+ printf(" Display native pixel format: %ux%u\n", w, h);
+ set_displayid_native_res(w, h);
+
unsigned char v = x[11];
printf(" Scan Orientation: ");
switch (v & 0x07) {
@@ -1368,6 +1400,48 @@ void edid_state::parse_displayid_ContainerID(const unsigned char *x)
}
}
+// tag 0x2b
+
+void edid_state::parse_displayid_adaptive_sync(const unsigned char *x)
+{
+ check_displayid_datablock_revision(x[1], 0x70);
+
+ unsigned size = 6 + ((x[1] >> 4) & 0x7);
+ unsigned len = x[2];
+ unsigned descriptor = 1;
+
+ x += 3;
+ if (len % size)
+ fail("DisplayID payload length %u is not a multiple of %u.\n", len, size);
+ while (len >= size) {
+ printf(" Descriptor #%u:\n", descriptor++);
+
+ printf(" %sNative Panel Range\n", (x[0] & 1) ? "" : "Non-");
+ unsigned v = (x[0] >> 2) & 3;
+ switch (v) {
+ case 0: printf(" Fixed Average V-Total\n"); break;
+ case 1: printf(" Fixed Average V-Total and Adaptive V-Total\n"); break;
+ default:
+ printf(" Reserved %u\n", v);
+ fail("Use of reserved value %u.\n", v);
+ break;
+ }
+ if (x[0] & 0x10)
+ printf(" Supports Seamless Transition\n");
+ if (x[0] & 0x02)
+ printf(" 'Max Single Frame Duration Increase' field value without jitter impact\n");
+ if (x[0] & 0x20)
+ printf(" 'Max Single Frame Duration Decrease' field value without jitter impact\n");
+ printf(" Max Duration Increase: %.2f ms\n", x[1] / 4.0);
+ printf(" Max Duration Decrease: %.2f ms\n", x[5] / 4.0);
+ printf(" Min Refresh Rate: %u Hz\n", x[2]);
+ printf(" Max Refresh Rate: %u Hz\n", 1 + x[3] + (x[4] & 3) * 256);
+
+ len -= size;
+ x += size;
+ }
+}
+
// tag 0x32
void edid_state::parse_displayid_type_10_timing(const unsigned char *x,
@@ -1423,24 +1497,24 @@ void edid_state::parse_displayid_type_10_timing(const unsigned char *x,
s += ", YCbCr 4:2:0";
unsigned refresh = 1 + x[5] + (sz == 6 ? 0 : ((x[6] & 3) << 8));
- double add_vert_time = 0;
if (sz > 6 && rb == RB_CVT_V3) {
unsigned delta_hblank = (x[6] >> 2) & 7;
- if (rb_h_blank == 80)
+ if ((x[6] >> 5) & 7)
+ fail("Bits 5-7 of byte 6 must be 0.\n");
+ if (rb != RB_CVT_V3) {
+ if ((x[6] >> 2) & 7)
+ fail("Bits 2-4 of byte 6 must be 0.\n");
+ } else if (rb_h_blank == 80)
rb_h_blank = 80 + 8 * delta_hblank;
else if (delta_hblank <= 5)
rb_h_blank = 160 + 8 * delta_hblank;
else
rb_h_blank = 160 - (delta_hblank - 5) * 8;
-
- unsigned vblank_time_perc = (x[6] >> 5) & 7;
-
- add_vert_time = (vblank_time_perc * 10000.0) / refresh;
}
- edid_cvt_mode(refresh, t, rb_h_blank, add_vert_time);
+ edid_cvt_mode(refresh, t, rb_h_blank);
print_timings(" ", &t, "CVT", s.c_str());
if (is_cta) {
@@ -1514,15 +1588,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)
@@ -1609,13 +1675,265 @@ void edid_state::preparse_displayid_block(const unsigned char *x)
}
}
+unsigned edid_state::displayid_block(const unsigned version, const unsigned char *x, unsigned length)
+{
+ unsigned i;
+ unsigned tag = x[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;
+ unsigned ouinum;
+
+ switch (tag) {
+ // DisplayID 1.3:
+ case 0x00:
+ data_block_oui("Product Identification Data Block (" + utohex(tag) + ")",
+ x + 3, len, &ouinum, true, true, true);
+ dooutputname = false;
+ hasoui = true;
+ 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;
+ case 0x04: data_block = "Video Timing Modes Type 2 - Detailed Timings Data Block"; break;
+ case 0x05: data_block = "Video Timing Modes Type 3 - Short Timings Data Block"; break;
+ case 0x06: data_block = "Video Timing Modes Type 4 - DMT Timings Data Block"; break;
+ case 0x07: data_block = "Supported Timing Modes Type 1 - VESA DMT Timings Data Block"; break;
+ case 0x08: data_block = "Supported Timing Modes Type 2 - CTA-861 Timings Data Block"; break;
+ case 0x09: data_block = "Video Timing Range Data Block"; break;
+ case 0x0a: data_block = "Product Serial Number Data Block"; break;
+ case 0x0b: data_block = "GP ASCII String Data Block"; break;
+ case 0x0c: data_block = "Display Device Data Data Block"; break;
+ case 0x0d: data_block = "Interface Power Sequencing Data Block"; break;
+ case 0x0e: data_block = "Transfer Characteristics Data Block"; break;
+ case 0x0f: data_block = "Display Interface Data Block"; break;
+ case 0x10: data_block = "Stereo Display Interface Data Block (" + utohex(tag) + ")"; break;
+ case 0x11: data_block = "Video Timing Modes Type 5 - Short Timings Data Block"; break;
+ case 0x12: data_block = "Tiled Display Topology Data Block (" + utohex(tag) + ")"; break;
+ 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_oui("Product Identification Data Block (" + utohex(tag) + ")",
+ x + 3, len, &ouinum, false, false, true);
+ dooutputname = false;
+ hasoui = true;
+ 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;
+ case 0x24: data_block = "Video Timing Modes Type 9 - Formula-based Timings Data Block"; break;
+ case 0x25: data_block = "Dynamic Video Timing Range Limits Data Block"; break;
+ case 0x26: data_block = "Display Interface Features Data Block"; break;
+ case 0x27: data_block = "Stereo Display Interface Data Block (" + utohex(tag) + ")"; break;
+ case 0x28: data_block = "Tiled Display Topology Data Block (" + utohex(tag) + ")"; break;
+ case 0x29: data_block = "ContainerID Data Block"; break;
+ 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
+ data_block_oui("Vendor-Specific Data Block (" + utohex(tag) + ")",
+ x + 3, len, &ouinum, false, false, true);
+ dooutputname = false;
+ hasoui = true;
+ tag |= ouinum;
+ break;
+ case 0x7f: // DisplayID 1.3
+ data_block_oui("Vendor-Specific Data Block (" + utohex(tag) + ")",
+ x + 3, len, &ouinum, false, true, true);
+ dooutputname = false;
+ hasoui = true;
+ tag |= ouinum;
+ break;
+ // 0x80 RESERVED
+ case 0x81: data_block = "CTA-861 DisplayID Data Block"; break;
+ // 0x82 .. 0xff RESERVED
+ default: data_block = "Unknown DisplayID Data Block (" + utohex(tag) + ", length " + std::to_string(len) + ")"; break;
+ }
+
+ if (length < 3) {
+ // Report a problem when the remaining bytes are not 0.
+ data_block.clear(); // Probably not a Data Block so clear this.
+ if (tag || (length > 1 && x[1])) {
+ printf(" Filler:\n");
+ fail("Not enough bytes remain (%d) for a DisplayID data block and the DisplayID filler is non-0.\n", length);
+ hex_block(" ", x, length);
+ }
+ return length;
+ }
+
+ if (length < len + 3) {
+ data_block.clear(); // Probably not a Data Block so clear this.
+ printf(" Filler:\n");
+ fail("The length of this DisplayID data block (%d) exceeds the number of bytes remaining (%d).\n", len + 3, length);
+ hex_block(" ", x, length);
+ return length;
+ }
+
+ if (!tag && !len) {
+ // A Product Identification Data Block with no payload bytes is not valid - assume this is the end.
+ data_block.clear(); // Probably not a Product Identification Data Block so clear this.
+ if (!memchk(x, length)) {
+ printf(" Filler:\n");
+ fail("Non-0 filler bytes in the DisplayID block.\n");
+ hex_block(" ", x, length);
+ }
+ return length;
+ }
+
+ if (dooutputname && data_block.length())
+ printf(" %s:\n", data_block.c_str());
+
+ 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_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;
+
+ switch (tag) {
+ case 0x00: parse_displayid_product_id(x); break;
+ case 0x01: parse_displayid_parameters(x); break;
+ case 0x02: parse_displayid_color_characteristics(x); break;
+ case 0x03:
+ check_displayid_datablock_revision(x[1], 0, block_rev & 1);
+ for (i = 0; i < len / 20; i++)
+ parse_displayid_type_1_7_timing(&x[3 + (i * 20)], false, block_rev);
+ break;
+ case 0x04:
+ check_displayid_datablock_revision(x[1]);
+ for (i = 0; i < len / 11; i++)
+ parse_displayid_type_2_timing(&x[3 + (i * 11)]);
+ break;
+ case 0x05:
+ check_displayid_datablock_revision(x[1], 0, block_rev & 1);
+ for (i = 0; i < len / 3; i++)
+ parse_displayid_type_3_timing(&x[3 + (i * 3)]);
+ break;
+ case 0x06:
+ check_displayid_datablock_revision(x[1], 0xc0, 1);
+ for (i = 0; i < len; i++)
+ parse_displayid_type_4_8_timing((x[1] & 0xc0) >> 6, x[3 + i]);
+ break;
+ case 0x07:
+ check_displayid_datablock_revision(x[1]);
+ for (i = 0; i < min(len, 10) * 8; i++)
+ if (x[3 + i / 8] & (1 << (i % 8))) {
+ char type[16];
+ sprintf(type, "DMT 0x%02x", i + 1);
+ print_timings(" ", find_dmt_id(i + 1), type);
+ }
+ break;
+ case 0x08:
+ check_displayid_datablock_revision(x[1]);
+ for (i = 0; i < min(len, 8) * 8; i++)
+ if (x[3 + i / 8] & (1 << (i % 8))) {
+ char type[16];
+ sprintf(type, "VIC %3u", i + 1);
+ print_timings(" ", find_vic_id(i + 1), type);
+ }
+ break;
+ case 0x09: parse_displayid_video_timing_range_limits(x); break;
+ case 0x0a:
+ case 0x0b: parse_displayid_string(x); break;
+ case 0x0c: parse_displayid_display_device(x); break;
+ case 0x0d: parse_displayid_intf_power_sequencing(x); break;
+ case 0x0e: parse_displayid_transfer_characteristics(x); break;
+ case 0x0f: parse_displayid_display_intf(x); break;
+ case 0x10: parse_displayid_stereo_display_intf(x); break;
+ case 0x11:
+ check_displayid_datablock_revision(x[1]);
+ for (i = 0; i < len / 7; i++)
+ parse_displayid_type_5_timing(&x[3 + (i * 7)]);
+ break;
+ case 0x12: parse_displayid_tiled_display_topology(x, false); break;
+ case 0x13:
+ check_displayid_datablock_revision(x[1]);
+ for (i = 0; i < len; i += (x[3 + i + 2] & 0x40) ? 17 : 14)
+ parse_displayid_type_6_timing(&x[3 + i]);
+ break;
+ case 0x20: parse_displayid_product_id(x); break;
+ case 0x21:
+ if (block_rev >= 1)
+ check_displayid_datablock_revision(x[1], 0x80, 1);
+ else
+ check_displayid_datablock_revision(x[1], 0x80, 0);
+ parse_displayid_parameters_v2(x, block_rev);
+ break;
+ case 0x22: {
+ unsigned sz = 20;
+
+ if (block_rev >= 2)
+ check_displayid_datablock_revision(x[1], 0x08, 2);
+ else if (block_rev == 1)
+ check_displayid_datablock_revision(x[1], 0x08, 1);
+ else
+ check_displayid_datablock_revision(x[1]);
+ sz += (x[1] & 0x70) >> 4;
+ if (block_rev >= 1 && (x[1] & 0x08))
+ printf(" These timings support DSC pass-through\n");
+ for (i = 0; i < len / sz; i++)
+ parse_displayid_type_1_7_timing(&x[3 + i * sz], true, block_rev);
+ break;
+ }
+ case 0x23:
+ if (block_rev)
+ check_displayid_datablock_revision(x[1], 0xe8, 1);
+ else
+ check_displayid_datablock_revision(x[1], 0xc8);
+ if (x[1] & 0x08) {
+ for (i = 0; i < len / 2; i++)
+ parse_displayid_type_4_8_timing((x[1] & 0xc0) >> 6,
+ x[3 + i * 2] |
+ (x[4 + i * 2] << 8));
+ } else {
+ for (i = 0; i < len; i++)
+ parse_displayid_type_4_8_timing((x[1] & 0xc0) >> 6,
+ x[3 + i]);
+ }
+ break;
+ case 0x24:
+ check_displayid_datablock_revision(x[1]);
+ for (i = 0; i < len / 6; i++)
+ parse_displayid_type_9_timing(&x[3 + i * 6]);
+ break;
+ case 0x25: parse_displayid_dynamic_video_timings_range_limits(x); break;
+ case 0x26: parse_displayid_interface_features(x); break;
+ case 0x27: parse_displayid_stereo_display_intf(x); break;
+ case 0x28: parse_displayid_tiled_display_topology(x, true); break;
+ case 0x29: parse_displayid_ContainerID(x); break;
+ case 0x2b: parse_displayid_adaptive_sync(x); break;
+ case 0x32: {
+ unsigned sz = 6 + ((x[1] & 0x70) >> 4);
+
+ check_displayid_datablock_revision(x[1], 0x70);
+ for (i = 0; i < len / sz; i++)
+ 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;
+ default: hex_block(" ", x + 3 + (hasoui ? 3 : 0), (len > (hasoui ? 3 : 0)) ? len - (hasoui ? 3 : 0) : 0); break;
+ }
+
+ if ((tag == 0x00 || tag == 0x20) &&
+ (!dispid.is_base_block || dispid.block_number > 0))
+ fail("%s is required to be the first DisplayID Data Block.\n",
+ data_block.c_str());
+
+ dispid.block_number++;
+ return len + 3;
+}
+
void edid_state::parse_displayid_block(const unsigned char *x)
{
unsigned version = x[1];
unsigned length = x[2];
unsigned prod_type = x[3]; // future check: based on type, check for required data blocks
unsigned ext_count = x[4];
- unsigned i;
printf(" Version: %u.%u\n Extension Count: %u\n",
version >> 4, version & 0xf, ext_count);
@@ -1647,246 +1965,10 @@ void edid_state::parse_displayid_block(const unsigned char *x)
length = 121;
}
- unsigned offset = 5;
- bool first_data_block = true;
- while (length > 0) {
- unsigned tag = x[offset];
- unsigned oui = 0;
-
- switch (tag) {
- // DisplayID 1.3:
- case 0x00: data_block = "Product Identification Data Block (" + utohex(tag) + ")"; 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;
- case 0x04: data_block = "Video Timing Modes Type 2 - Detailed Timings Data Block"; break;
- case 0x05: data_block = "Video Timing Modes Type 3 - Short Timings Data Block"; break;
- case 0x06: data_block = "Video Timing Modes Type 4 - DMT Timings Data Block"; break;
- case 0x07: data_block = "Supported Timing Modes Type 1 - VESA DMT Timings Data Block"; break;
- case 0x08: data_block = "Supported Timing Modes Type 2 - CTA-861 Timings Data Block"; break;
- case 0x09: data_block = "Video Timing Range Data Block"; break;
- case 0x0a: data_block = "Product Serial Number Data Block"; break;
- case 0x0b: data_block = "GP ASCII String Data Block"; break;
- case 0x0c: data_block = "Display Device Data Data Block"; break;
- case 0x0d: data_block = "Interface Power Sequencing Data Block"; break;
- case 0x0e: data_block = "Transfer Characteristics Data Block"; break;
- case 0x0f: data_block = "Display Interface Data Block"; break;
- case 0x10: data_block = "Stereo Display Interface Data Block (" + utohex(tag) + ")"; break;
- case 0x11: data_block = "Video Timing Modes Type 5 - Short Timings Data Block"; break;
- case 0x12: data_block = "Tiled Display Topology Data Block (" + utohex(tag) + ")"; break;
- 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 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;
- case 0x24: data_block = "Video Timing Modes Type 9 - Formula-based Timings Data Block"; break;
- case 0x25: data_block = "Dynamic Video Timing Range Limits Data Block"; break;
- case 0x26: data_block = "Display Interface Features Data Block"; break;
- case 0x27: data_block = "Stereo Display Interface Data Block (" + utohex(tag) + ")"; break;
- case 0x28: data_block = "Tiled Display Topology Data Block (" + utohex(tag) + ")"; break;
- case 0x29: data_block = "ContainerID 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
- if ((tag == 0x7e && version >= 0x20) ||
- (tag == 0x7f && version < 0x20)) {
- oui = (x[offset + 3] << 16) + (x[offset + 4] << 8) + x[offset + 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 = std::string("Vendor-Specific Data Block (") + name + ")";
- else
- data_block = "Vendor-Specific Data Block, OUI " + ouitohex(oui);
- if (reversed)
- fail((std::string("OUI ") + ouitohex(oui) + " is in the wrong byte order.\n").c_str());
- } else {
- data_block = "Unknown DisplayID Data Block (" + utohex(tag) + ")";
- }
- break;
- // 0x80 RESERVED
- case 0x81: data_block = "CTA-861 DisplayID Data Block (" + utohex(tag) + ")"; break;
- // 0x82 .. 0xff RESERVED
- default: data_block = "Unknown DisplayID Data Block (" + utohex(tag) + ")"; break;
- }
-
- if (version >= 0x20 && (tag < 0x20 || tag == 0x7f))
- fail("Use of DisplayID v1.x tag for DisplayID v%u.%u.\n",
- version >> 4, version & 0xf);
- if (version < 0x20 && tag >= 0x20 && tag <= 0x7e)
- fail("Use of DisplayID v2.0 tag for DisplayID v%u.%u.\n",
- version >> 4, version & 0xf);
-
- if (length < 3) {
- // report a problem when the remaining bytes are not 0.
- if (tag || x[offset + 1]) {
- fail("Not enough bytes remain (%d) for a DisplayID data block or the DisplayID filler is non-0.\n", length);
- }
- break;
- }
-
- unsigned block_rev = x[offset + 1] & 0x07;
- unsigned len = x[offset + 2];
-
- if (length < len + 3) {
- fail("The length of this DisplayID data block (%d) exceeds the number of bytes remaining (%d).\n", len + 3, length);
- break;
- }
-
- if (!tag && !len) {
- // A Product Identification Data Block with no payload bytes is not valid - assume this is the end.
- if (!memchk(x + offset, length)) {
- fail("Non-0 filler bytes in the DisplayID block.\n");
- }
- break;
- }
-
- printf(" %s:\n", data_block.c_str());
-
- switch (tag) {
- case 0x00: parse_displayid_product_id(x + offset); break;
- case 0x01: parse_displayid_parameters(x + offset); break;
- case 0x02: parse_displayid_color_characteristics(x + offset); break;
- case 0x03:
- check_displayid_datablock_revision(x[offset + 1], 0, block_rev & 1);
- for (i = 0; i < len / 20; i++)
- parse_displayid_type_1_7_timing(&x[offset + 3 + (i * 20)], false, block_rev);
- break;
- case 0x04:
- check_displayid_datablock_revision(x[offset + 1]);
- for (i = 0; i < len / 11; i++)
- parse_displayid_type_2_timing(&x[offset + 3 + (i * 11)]);
- break;
- case 0x05:
- check_displayid_datablock_revision(x[offset + 1], 0, block_rev & 1);
- for (i = 0; i < len / 3; i++)
- parse_displayid_type_3_timing(&x[offset + 3 + (i * 3)]);
- break;
- case 0x06:
- check_displayid_datablock_revision(x[offset + 1], 0xc0, 1);
- for (i = 0; i < len; i++)
- parse_displayid_type_4_8_timing((x[offset + 1] & 0xc0) >> 6, x[offset + 3 + i]);
- break;
- case 0x07:
- check_displayid_datablock_revision(x[offset + 1]);
- for (i = 0; i < min(len, 10) * 8; i++)
- if (x[offset + 3 + i / 8] & (1 << (i % 8))) {
- char type[16];
- sprintf(type, "DMT 0x%02x", i + 1);
- print_timings(" ", find_dmt_id(i + 1), type);
- }
- break;
- case 0x08:
- check_displayid_datablock_revision(x[offset + 1]);
- for (i = 0; i < min(len, 8) * 8; i++)
- if (x[offset + 3 + i / 8] & (1 << (i % 8))) {
- char type[16];
- sprintf(type, "VIC %3u", i + 1);
- print_timings(" ", find_vic_id(i + 1), type);
- }
- break;
- case 0x09: parse_displayid_video_timing_range_limits(x + offset); break;
- case 0x0a:
- case 0x0b: parse_displayid_string(x + offset); break;
- case 0x0c: parse_displayid_display_device(x + offset); break;
- case 0x0d: parse_displayid_intf_power_sequencing(x + offset); break;
- case 0x0e: parse_displayid_transfer_characteristics(x + offset); break;
- case 0x0f: parse_displayid_display_intf(x + offset); break;
- case 0x10: parse_displayid_stereo_display_intf(x + offset); break;
- case 0x11:
- check_displayid_datablock_revision(x[offset + 1]);
- for (i = 0; i < len / 7; i++)
- parse_displayid_type_5_timing(&x[offset + 3 + (i * 7)]);
- break;
- case 0x12: parse_displayid_tiled_display_topology(x + offset, false); break;
- case 0x13:
- check_displayid_datablock_revision(x[offset + 1]);
- for (i = 0; i < len; i += (x[offset + 3 + i + 2] & 0x40) ? 17 : 14)
- parse_displayid_type_6_timing(&x[offset + 3 + i]);
- break;
- case 0x20: parse_displayid_product_id(x + offset); break;
- case 0x21:
- if (block_rev >= 1)
- check_displayid_datablock_revision(x[offset + 1], 0x80, 1);
- else
- check_displayid_datablock_revision(x[offset + 1], 0x80, 0);
- parse_displayid_parameters_v2(x + offset, block_rev);
- break;
- case 0x22: {
- unsigned sz = 20;
-
- if (block_rev >= 2)
- check_displayid_datablock_revision(x[offset + 1], 0x08, 2);
- else if (block_rev == 1)
- check_displayid_datablock_revision(x[offset + 1], 0x08, 1);
- else
- check_displayid_datablock_revision(x[offset + 1]);
- sz += (x[offset + 1] & 0x70) >> 4;
- if (block_rev >= 1 && (x[offset + 1] & 0x08))
- printf(" These timings support DSC pass-through\n");
- for (i = 0; i < len / sz; i++)
- parse_displayid_type_1_7_timing(&x[offset + 3 + i * sz], true, block_rev);
- break;
- }
- case 0x23:
- if (block_rev)
- check_displayid_datablock_revision(x[offset + 1], 0xe8, 1);
- else
- check_displayid_datablock_revision(x[offset + 1], 0xc8);
- if (x[offset + 1] & 0x08) {
- for (i = 0; i < len / 2; i++)
- parse_displayid_type_4_8_timing((x[offset + 1] & 0xc0) >> 6,
- x[offset + 3 + i * 2] |
- (x[offset + 4 + i * 2] << 8));
- } else {
- for (i = 0; i < len; i++)
- parse_displayid_type_4_8_timing((x[offset + 1] & 0xc0) >> 6,
- x[offset + 3 + i]);
- }
- break;
- case 0x24:
- check_displayid_datablock_revision(x[offset + 1]);
- for (i = 0; i < len / 6; i++)
- parse_displayid_type_9_timing(&x[offset + 3 + i * 6]);
- break;
- case 0x25: parse_displayid_dynamic_video_timings_range_limits(x + offset); break;
- case 0x26: parse_displayid_interface_features(x + offset); break;
- case 0x27: parse_displayid_stereo_display_intf(x + offset); break;
- case 0x28: parse_displayid_tiled_display_topology(x + offset, true); break;
- case 0x29: parse_displayid_ContainerID(x + offset); break;
- case 0x32: {
- unsigned sz = 6 + ((x[offset + 1] & 0x70) >> 4);
-
- check_displayid_datablock_revision(x[offset + 1], 0x70);
- for (i = 0; i < len / sz; i++)
- parse_displayid_type_10_timing(&x[offset + 3 + i * sz], sz);
- break;
- }
- case 0x81: parse_displayid_cta_data_block(x + offset); break;
- case 0x7e:
- if (oui == 0x3a0292) {
- parse_displayid_vesa(x + offset);
- break;
- }
- // fall-through
- default: hex_block(" ", x + offset + 3, len); break;
- }
-
- if ((tag == 0x00 || tag == 0x20) &&
- (!dispid.is_base_block || !first_data_block))
- fail("%s is required to be the first DisplayID Data Block.\n",
- data_block.c_str());
- length -= len + 3;
- offset += len + 3;
- first_data_block = false;
+ unsigned len;
+ for (const unsigned char *y = x + 5; length > 0; y += len) {
+ len = displayid_block(version, y, length);
+ length -= len;
}
/*
@@ -1918,4 +2000,10 @@ void edid_state::check_displayid_blocks()
dispid.version >= 0x20 ? "VII" : "I");
if (dispid.preferred_timings.empty())
fail("DisplayID expects at least one preferred timing.\n");
+ if (dispid.image_width && dispid.image_width < 25600 && dispid.image_height < 25600 &&
+ (abs((int)dispid.image_width - (int)base.max_display_width_mm * 10) >= 100 ||
+ abs((int)dispid.image_height - (int)base.max_display_height_mm * 10) >= 100))
+ fail("Image size mismatch: DisplayID: %.1fx%.1fmm Base EDID: %u.0x%u.0mm.\n",
+ dispid.image_width / 10.0, dispid.image_height / 10.0,
+ base.max_display_width_mm, base.max_display_height_mm);
}

Privacy Policy