diff mbox series

[15/28] edid-decode: change unknown CTA block names

Message ID 20210924233149.10028-16-joevt@shaw.ca (mailing list archive)
State New, archived
Headers show
Series bug fixes, additions, changes | expand

Commit Message

joevt Sept. 24, 2021, 11:31 p.m. UTC
Make consistent the Unknown CTA-861 Data Block names and warnings.

- Add " Data Block" suffix for normal tags (like unknown extended tags and known normal tags have).
- Put tag in parenthesis (like unknown extended tags).
- Output colon after unknown block name (like known tags).
- Make warning same as block name (so the block mentioned in the warning section can be found more easily in the edid output).

1) Unknown normal tags:
Before:
- name: "Unknown CTA-861 tag 0x$$"
- warning: "Unknown CTA-861 Data Block #."
After:
"Unknown CTA-861 Data Block (tag 0x$$):" (with period instead of colon for warning)

2) Unknown extended tags:
Before:
- name: "Unknown CTA-861 @Data Block (extended tag 0x$$)" (@ = "", "Video-Related ", "Audio-Related ", "HDMI-Related ")
- warning: "Unknown Extended CTA-861 Data Block 0x$$."
After:
- "Unknown CTA-861 @Data Block (extended tag 0x$$):" (with period instead of colon for warning)

We still have the following from a previous commit:
3) Truncated extended tag (when length is not enough to get the extended tag):
Before:
name: "Unknown CTA-861 Data Block (extended tag truncated):"
failure: "Extended tag cannot have zero length."

Since the name is different than the failure message, we should set data_block so both are output to the failure section:
After:
failure: "Unknown CTA-861 Data Block (extended tag truncated): Extended tag cannot have zero length."

Signed-off-by: Joe van Tunen <joevt@shaw.ca>
---
 parse-cta-block.cpp | 33 ++++++++++++---------------------
 1 file changed, 12 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp
index a53dc43..a3690d7 100644
--- a/parse-cta-block.cpp
+++ b/parse-cta-block.cpp
@@ -2021,7 +2021,7 @@  void edid_state::cta_block(const unsigned char *x, bool duplicate)
 	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.clear(); 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.clear(); break;
@@ -2052,22 +2052,16 @@  void edid_state::cta_block(const unsigned char *x, bool duplicate)
 
 	default:
 		data_block.clear();
-		if (tag < 0x700) {
-			printf("  Unknown CTA-861 tag 0x%02x\n", tag);
-			warn("Unknown CTA-861 Data Block %u.\n", tag);
-		}
-		else {
-			if (tag < 0x70d)
-				printf("  Unknown CTA-861 Video-Related");
-			else if (tag < 0x720)
-				printf("  Unknown CTA-861 Audio-Related");
-			else if (tag >= 0x778 && tag <= 0x77f)
-				printf("  Unknown CTA-861 HDMI-Related");
-			else
-				printf("  Unknown CTA-861");
-			printf(" Data Block (extended tag 0x%02x)\n", tag & 0xff);
-			warn("Unknown Extended CTA-861 Data Block 0x%02x.\n", tag & 0xff);
-		}
+		std::string unknown_name;
+		     if (tag < 0x700) unknown_name = "Unknown CTA-861 Data Block";
+		else if (tag < 0x70d) unknown_name = "Unknown CTA-861 Video-Related Data Block";
+		else if (tag < 0x720) unknown_name = "Unknown CTA-861 Audio-Related Data Block";
+		else if (tag < 0x778) unknown_name = "Unknown CTA-861 Data Block";
+		else if (tag < 0x780) unknown_name = "Unknown CTA-861 HDMI-Related Data Block";
+		else                  unknown_name = "Unknown CTA-861 Data Block";
+		unknown_name += std::string(" (") + (extended ? "extended " : "") + "tag " + utohex(tag & 0xff) + ")";
+		printf("  %s:\n", unknown_name.c_str());
+		warn("%s.\n", unknown_name.c_str());
 	}
 
 	if (data_block.length())
@@ -2132,10 +2126,7 @@  void edid_state::cta_block(const unsigned char *x, bool duplicate)
 		break;
 	case 0x04: cta_sadb(x, length); break;
 	case 0x05: cta_vesa_dtcdb(x, length); break;
-	case 0x07:
-		printf("  Unknown CTA-861 Data Block (extended tag truncated):\n");
-		fail("Extended tag cannot have zero length.\n");
-		break;
+	case 0x07: fail("Extended tag cannot have zero length.\n"); break;
 	case 0x700: cta_vcdb(x, length); break;
 	case 0x701:
 		data_block_o("Vendor-Specific Video Data Block");