aboutsummaryrefslogtreecommitdiffstats
path: root/parse-displayid-block.cpp
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2021-10-01 11:15:04 +0200
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2021-10-01 11:15:04 +0200
commit46a55672e67541886c55830260e90924c7ecd94f (patch)
treeff697960a77d8db5ed2cf3267aed5f8d1474518b /parse-displayid-block.cpp
parent4993146962b86550a982993b8f660f0a16e4e7b2 (diff)
edid-decode: rework the -n option
Improve the native resolution reporting: include DisplayID native resolutions in the report, and if all the listed native resolutions are all the same, then just report that. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'parse-displayid-block.cpp')
-rw-r--r--parse-displayid-block.cpp50
1 files changed, 34 insertions, 16 deletions
diff --git a/parse-displayid-block.cpp b/parse-displayid-block.cpp
index c8cea53..f4b8ca5 100644
--- a/parse-displayid-block.cpp
+++ b/parse-displayid-block.cpp
@@ -130,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]);
@@ -141,8 +161,10 @@ void edid_state::parse_displayid_parameters(const unsigned char *x)
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]);
+ 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);
@@ -591,13 +613,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];
@@ -1122,13 +1143,10 @@ void edid_state::parse_displayid_parameters_v2(const unsigned char *x,
hor_size / 10.0, vert_size / 10.0);
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) {

Privacy Policy