aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2021-09-27 14:21:32 +0200
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2021-09-27 14:23:02 +0200
commit77c289146ec87087cb3fed1df9034ea6d92b269a (patch)
tree8dcc191667ca9e7b42546397e234aa14c6759778
parentc3e175148a7a41f67fdf76700437d8d517c3a97a (diff)
edid-decode: replace data_block_o
This is a rather ugly macro with side-effects. Drop it and code it explicitly. Also add a new warning to the Makefile to detect implicit fallthroughs in switches. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--Makefile2
-rw-r--r--parse-base-block.cpp2
-rw-r--r--parse-cta-block.cpp35
-rw-r--r--parse-displayid-block.cpp40
4 files changed, 50 insertions, 29 deletions
diff --git a/Makefile b/Makefile
index cf3d732..b6e51fc 100644
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@ EMXX ?= em++
SOURCES = edid-decode.cpp parse-base-block.cpp parse-cta-block.cpp \
parse-displayid-block.cpp parse-ls-ext-block.cpp \
parse-di-ext-block.cpp parse-vtb-ext-block.cpp calc-gtf-cvt.cpp
-WARN_FLAGS = -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter
+WARN_FLAGS = -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wimplicit-fallthrough
all: edid-decode
diff --git a/parse-base-block.cpp b/parse-base-block.cpp
index dd56eed..9e2ef4f 100644
--- a/parse-base-block.cpp
+++ b/parse-base-block.cpp
@@ -1475,7 +1475,7 @@ void edid_state::parse_base_block(const unsigned char *x)
case 0x00: printf("Monochrome or grayscale display\n"); break;
case 0x08: printf("RGB color display\n"); break;
case 0x10: printf("Non-RGB color display\n"); break;
- case 0x18: printf("Undefined display color type\n");
+ case 0x18: printf("Undefined display color type\n"); break;
}
} else {
printf(" Supported color formats: RGB 4:4:4");
diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp
index b9f4312..cfc8d91 100644
--- a/parse-cta-block.cpp
+++ b/parse-cta-block.cpp
@@ -2028,21 +2028,12 @@ static void cta_hdmi_audio_block(const unsigned char *x, unsigned length)
}
}
-#define data_block_o(n) \
- do { \
- unsigned ouinum; \
- data_block_oui(n, x, length, &ouinum); \
- x += (length < 3) ? length : 3; \
- length -= (length < 3) ? length : 3; \
- dooutputname = false; \
- tag |= ouinum; \
- } while(0)
-
void edid_state::cta_block(const unsigned char *x, std::vector<unsigned> &found_tags)
{
unsigned length = x[0] & 0x1f;
- unsigned tag=(x[0] & 0xe0) >> 5;
+ unsigned tag = (x[0] & 0xe0) >> 5;
unsigned extended = (tag == 0x07) ? 1 : 0;
+
x++;
if (extended && length) {
tag <<= 8;
@@ -2058,14 +2049,14 @@ void edid_state::cta_block(const unsigned char *x, std::vector<unsigned> &found_
switch (tag) {
case 0x01: data_block = "Audio Data Block"; audio_block = true; break;
case 0x02: data_block = "Video Data Block"; break;
- case 0x03: data_block_o("Vendor-Specific Data Block"); break;
+ case 0x03: data_block = "Vendor-Specific Data Block"; break;
case 0x04: data_block = "Speaker Allocation Data Block"; audio_block = true; break;
case 0x05: data_block = "VESA Display Transfer Characteristics Data Block"; break;
case 0x07: data_block = "Unknown CTA-861 Data Block (extended tag truncated)"; break;
case 0x700: data_block = "Video Capability Data Block"; break;
- case 0x701: data_block_o("Vendor-Specific Video Data Block"); break;
+ case 0x701: data_block = "Vendor-Specific Video Data Block"; break;
case 0x702: data_block = "VESA Video Display Device Data Block"; break;
case 0x703: data_block = "VESA Video Timing Block Extension"; break;
case 0x704: data_block = "Reserved for HDMI Video Data Block"; break;
@@ -2077,7 +2068,7 @@ void edid_state::cta_block(const unsigned char *x, std::vector<unsigned> &found_
case 0x70e: data_block = "YCbCr 4:2:0 Video Data Block"; break;
case 0x70f: data_block = "YCbCr 4:2:0 Capability Map Data Block"; break;
case 0x710: data_block = "Reserved for CTA-861 Miscellaneous Audio Fields"; break;
- case 0x711: data_block_o("Vendor-Specific Audio Data Block"); audio_block = true; break;
+ case 0x711: data_block = "Vendor-Specific Audio Data Block"; audio_block = true; break;
case 0x712: data_block = "HDMI Audio Data Block"; audio_block = true; break;
case 0x713: data_block = "Room Configuration Data Block"; audio_block = true; break;
case 0x714: data_block = "Speaker Location Data Block"; audio_block = true; break;
@@ -2102,6 +2093,22 @@ void edid_state::cta_block(const unsigned char *x, std::vector<unsigned> &found_
unknown_name += std::string(" (") + (extended ? "extended " : "") + "tag " + utohex(tag & 0xff) + ")";
printf(" %s:\n", unknown_name.c_str());
warn("%s.\n", unknown_name.c_str());
+ break;
+ }
+
+ switch (tag) {
+ case 0x03:
+ case 0x701:
+ case 0x711: {
+ unsigned ouinum;
+
+ data_block_oui(data_block, x, length, &ouinum);
+ x += (length < 3) ? length : 3;
+ length -= (length < 3) ? length : 3;
+ dooutputname = false;
+ tag |= ouinum;
+ break;
+ }
}
if (dooutputname && data_block.length())
diff --git a/parse-displayid-block.cpp b/parse-displayid-block.cpp
index 3fa0759..6a57346 100644
--- a/parse-displayid-block.cpp
+++ b/parse-displayid-block.cpp
@@ -1637,15 +1637,6 @@ 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;
@@ -1654,10 +1645,16 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char
bool dooutputname = true;
unsigned len = (length < 3) ? 0 : x[2];
bool hasoui = false;
+ unsigned ouinum;
switch (tag) {
// DisplayID 1.3:
- case 0x00: data_block_o("Product Identification Data Block (" + utohex(tag) + ")", true, false); break;
+ case 0x00:
+ data_block_oui("Product Identification Data Block (" + utohex(tag) + ")",
+ x + 3, len, &ouinum, true, true, false);
+ 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;
@@ -1679,7 +1676,12 @@ 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); break;
+ case 0x20:
+ data_block_oui("Product Identification Data Block (" + utohex(tag) + ")",
+ x + 3, len, &ouinum, false, false, false);
+ 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;
@@ -1692,8 +1694,20 @@ 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: 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
+ case 0x7e:
+ 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:
+ data_block_oui("Vendor-Specific Data Block (" + utohex(tag) + ")",
+ x + 3, len, &ouinum, false, true, false);
+ dooutputname = false;
+ hasoui = true;
+ tag |= ouinum;
+ break;
// 0x80 RESERVED
case 0x81: data_block = "CTA-861 DisplayID Data Block"; break;
// 0x82 .. 0xff RESERVED

Privacy Policy