diff mbox series

[v2,17/29] edid-decode: replace first_block with block_number

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

Commit Message

joevt Sept. 26, 2021, 8:33 a.m. UTC
track progress instead of milestones.

With a flag like first_block, you can only know if you're at the first block or not.
But with a progressing value like block_number, you can know when you're at the first block or second block etc. and you can know how many blocks have been done.
We'll also replace last_block_was_hdmi_vsdb in a later commit.
Both of these changes will cleanup the hdmi block.

Signed-off-by: Joe van Tunen <joevt@shaw.ca>
---
 edid-decode.h       |  5 +++--
 parse-cta-block.cpp | 10 +++++-----
 2 files changed, 8 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/edid-decode.h b/edid-decode.h
index ccf8558..dbc00c2 100644
--- a/edid-decode.h
+++ b/edid-decode.h
@@ -154,7 +154,8 @@  struct edid_state {
 		cta.has_vic_1 = cta.first_svd_might_be_preferred = cta.has_sldb =
 			cta.has_hdmi = cta.has_vcdb = cta.has_vfpdb = false;
 		cta.last_block_was_hdmi_vsdb = cta.have_hf_vsdb = cta.have_hf_scdb = false;
-		cta.first_block = cta.first_svd = true;
+		cta.block_number = 0;
+		cta.first_svd = true;
 		cta.supported_hdmi_vic_codes = cta.supported_hdmi_vic_vsb_codes = 0;
 		memset(cta.vics, 0, sizeof(cta.vics));
 		memset(cta.preparsed_has_vic, 0, sizeof(cta.preparsed_has_vic));
@@ -259,7 +260,7 @@  struct edid_state {
 		unsigned short preparsed_phys_addr;
 		bool last_block_was_hdmi_vsdb;
 		bool have_hf_vsdb, have_hf_scdb;
-		bool first_block;
+		unsigned block_number;
 		bool first_svd;
 		unsigned supported_hdmi_vic_codes;
 		unsigned supported_hdmi_vic_vsb_codes;
diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp
index 607e42b..13b3b73 100644
--- a/parse-cta-block.cpp
+++ b/parse-cta-block.cpp
@@ -2131,7 +2131,7 @@  void edid_state::cta_block(const unsigned char *x, bool duplicate)
 		if (oui == 0x000c03) {
 			cta_hdmi_block(x, length);
 			cta.last_block_was_hdmi_vsdb = 1;
-			cta.first_block = 0;
+			cta.block_number++;
 			// The HDMI OUI is present, so this EDID represents an HDMI
 			// interface. And HDMI interfaces must use EDID version 1.3
 			// according to the HDMI Specification, so check for this.
@@ -2194,7 +2194,7 @@  void edid_state::cta_block(const unsigned char *x, bool duplicate)
 	case 0x778:
 		cta_hf_eeodb(x, length);
 		// This must be the first CTA-861 block
-		if (!cta.first_block)
+		if (cta.block_number > 0)
 			fail("Block starts at a wrong offset.\n");
 		break;
 	case 0x779:
@@ -2216,7 +2216,7 @@  void edid_state::cta_block(const unsigned char *x, bool duplicate)
 		hex_block("    ", x, length);
 	}
 
-	cta.first_block = 0;
+	cta.block_number++;
 	cta.last_block_was_hdmi_vsdb = 0;
 }
 
@@ -2333,11 +2333,11 @@  void edid_state::parse_cta_block(const unsigned char *x)
 //				msg(!cta.has_hdmi, "If YCbCr support is indicated, then both 4:2:2 and 4:4:4 %s be supported.\n",
 //				    cta.has_hdmi ? "shall" : "should");
 			printf("  Native detailed modes: %u\n", x[3] & 0x0f);
-			if (cta.first_block)
+			if (cta.block_number == 0)
 				cta.byte3 = x[3];
 			else if (x[3] != cta.byte3)
 				fail("Byte 3 must be the same for all CTA-861 Extension Blocks.\n");
-			if (cta.first_block) {
+			if (cta.block_number == 0) {
 				unsigned native_dtds = x[3] & 0x0f;
 
 				cta.native_timings.clear();