diff mbox series

[06/10] edid-decode: Dump hex of unknown CTA Vendor-Specific blocks

Message ID 20191123164604.268-7-joevt@shaw.ca (mailing list archive)
State New, archived
Headers show
Series edid-decode: bug fixes, additions, changes | expand

Commit Message

joevt Nov. 23, 2019, 4:46 p.m. UTC
- Unknown CTA Vendor-Specific blocks will output as hex. With this, two EDIDs with different data will not be considered equal.
- Added hex_block to output hex for blocks of data that are not decoded.

Signed-off-by: Joe van Tunen <joevt@shaw.ca>
---
 edid-decode.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/edid-decode.c b/edid-decode.c
index 4d6fe29..ce404cd 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -1934,6 +1934,18 @@  static void cta_hdr10plus(const unsigned char *x, unsigned length)
 	printf("    Application Version: %u\n", x[0]);
 }
 
+static void hex_block(const unsigned char *x, unsigned int length)
+{
+	if (length) {
+		for (int i = 0; i < length; i++)
+			printf("%02x", x[i]);
+		printf("  ");
+		for (int i = 0; i < length; i++)
+			printf("%c", x[i] >= ' ' && x[i] <= '~' ? x[i] : '.');
+		printf("\n");
+	}
+}
+
 DEFINE_FIELD("YCbCr quantization", YCbCr_quantization, 7, 7,
 	     { 0, "No Data" },
 	     { 1, "Selectable (via AVI YQ)" });
@@ -2321,7 +2333,9 @@  static void cta_block(const unsigned char *x)
 			cta_hf_scdb(x + 4, length - 3);
 			have_hf_vsdb = 1;
 		} else {
-			printf("\n");
+			printf(" (unknown)\n");
+			printf("    ");
+			hex_block(x + 4, length - 3);
 		}
 		break;
 	case 0x04:
@@ -2348,7 +2362,9 @@  static void cta_block(const unsigned char *x)
 				printf(" (HDR10+)\n");
 				cta_hdr10plus(x + 5, length - 4);
 			} else {
-				printf("\n");
+				printf(" (unknown)\n");
+				printf("    ");
+				hex_block(x + 5, length - 4);
 			}
 			break;
 		case 0x02: