]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
edid: Add an edid_check_checksum() helper function
authorHans de Goede <hdegoede@redhat.com>
Mon, 24 Nov 2014 12:47:13 +0000 (13:47 +0100)
committerHans de Goede <hdegoede@redhat.com>
Wed, 14 Jan 2015 13:56:38 +0000 (14:56 +0100)
Add a helper function to check the checksum of an EDID data block.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Anatolij Gustschin <agust@denx.de>
common/edid.c
include/edid.h

index e66108f24a482b61ae99febd321418e38fe275c3..df797fcdd5bae35e1eaea9c2f6d3d631c0bff73a 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <common.h>
 #include <edid.h>
+#include <errno.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
 
@@ -29,6 +30,17 @@ int edid_check_info(struct edid1_info *edid_info)
        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;
+}
+
 int edid_get_ranges(struct edid1_info *edid, unsigned int *hmin,
                    unsigned int *hmax, unsigned int *vmin,
                    unsigned int *vmax)
index d3cc5232dec8e87d18fab5f394d34d90f3267414..a69f43a20648381f79c3131acc018f9e477e1d84 100644 (file)
@@ -245,6 +245,15 @@ void edid_print_info(struct edid1_info *edid_info);
  */
 int edid_check_info(struct edid1_info *info);
 
+/**
+ * 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);
+
 /**
  * Get the horizontal and vertical rate ranges of the monitor.
  *