[U-Boot] [PATCH 4/5] edid: Add an edid_check_checksum() helper function

Hans de Goede hdegoede at redhat.com
Mon Nov 24 17:14:18 CET 2014


Add a helper function to check the checksum of an EDID data block.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 common/edid.c  | 11 +++++++++++
 include/edid.h |  9 +++++++++
 2 files changed, 20 insertions(+)

diff --git a/common/edid.c b/common/edid.c
index e41cd3e..e5d35b2 100644
--- a/common/edid.c
+++ b/common/edid.c
@@ -353,3 +353,14 @@ int edid_dtd_to_fbmode(struct edid_detailed_timing *t,
 
 	return 0;
 }
+
+int edid_check_checksum(u8 *edid_block)
+{
+	u8 checksum = 0;
+	int i;
+
+	for (i = 0; i < 128; i++)
+		checksum += edid_block[i];
+
+	return (checksum == 0) ? 0 : -EINVAL;
+}
diff --git a/include/edid.h b/include/edid.h
index d66f76b..b32f42c 100644
--- a/include/edid.h
+++ b/include/edid.h
@@ -273,4 +273,13 @@ int edid_get_ranges(struct edid1_info *edid, unsigned int *hmin,
 int edid_dtd_to_fbmode(struct edid_detailed_timing *t,
 		       struct fb_videomode *mode, char *name, int name_len);
 
+/**
+ * Check checksum of a 128 bytes EDID data block
+ *
+ * @param edid_block	EDID block data
+ *
+ * @return 0 on success, or a negative errno on error
+ */
+int edid_check_checksum(u8 *edid_block);
+
 #endif /* __EDID_H_ */
-- 
2.1.0



More information about the U-Boot mailing list