aboutsummaryrefslogtreecommitdiffstats
path: root/parse-displayid-block.cpp
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2021-01-28 10:36:30 +0100
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2021-01-28 10:36:30 +0100
commit526a72d9e1f60dab364d1a2179ea1933eee1f463 (patch)
tree602e279d999f662bf046995382d6cd95c8db52af /parse-displayid-block.cpp
parent770cfb947ea9d9eb5cda57a87dc66d13c60cfefc (diff)
edid-decode: improve DisplayID native format handling
The DisplayID 1.3 reporting of the native format was off by 1. Also check if the resolution is either all 0 (no native format specified) or all non-0. Finally check for consistency with the reported native resolution by the CTA block. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'parse-displayid-block.cpp')
-rw-r--r--parse-displayid-block.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/parse-displayid-block.cpp b/parse-displayid-block.cpp
index 36985e2..ca3e73d 100644
--- a/parse-displayid-block.cpp
+++ b/parse-displayid-block.cpp
@@ -590,8 +590,15 @@ void edid_state::parse_displayid_display_device(const unsigned char *x)
printf(" The backlight may be switched on and off\n");
if (x[4] & 0x04)
printf(" The backlight's intensity can be controlled\n");
- printf(" Display native pixel format: %ux%u\n",
- x[5] | (x[6] << 8), x[7] | (x[8] << 8));
+ 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);
+ }
printf(" Aspect ratio and orientation:\n");
printf(" Aspect Ratio: %.2f\n", (100 + x[9]) / 100.0);
unsigned char v = x[0x0a];
@@ -1114,8 +1121,15 @@ void edid_state::parse_displayid_parameters_v2(const unsigned char *x,
else
printf(" Image size: %.1f mm x %.1f mm\n",
hor_size / 10.0, vert_size / 10.0);
- printf(" Pixels: %d x %d\n",
- (x[8] << 8) + x[7], (x[10] << 8) + x[9]);
+ 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);
+ }
unsigned char v = x[11];
printf(" Scan Orientation: ");
switch (v & 0x07) {

Privacy Policy