From patchwork Mon Nov 24 16:14:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 414034 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 6B622140161 for ; Tue, 25 Nov 2014 03:15:25 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 67D8D4B67D; Mon, 24 Nov 2014 17:15:08 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2x15ic8+B+qB; Mon, 24 Nov 2014 17:15:08 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 59E1F4B663; Mon, 24 Nov 2014 17:14:52 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 923964B608 for ; Mon, 24 Nov 2014 17:14:43 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LZ0aFbozEB+C for ; Mon, 24 Nov 2014 17:14:43 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by theia.denx.de (Postfix) with ESMTPS id 0DAD84B60B for ; Mon, 24 Nov 2014 17:14:40 +0100 (CET) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAOGETKm027254 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 24 Nov 2014 11:14:29 -0500 Received: from shalem.localdomain.com (vpn1-6-228.ams2.redhat.com [10.36.6.228]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sAOGELBs016819; Mon, 24 Nov 2014 11:14:27 -0500 From: Hans de Goede To: Anatolij Gustschin , Ian Campbell Date: Mon, 24 Nov 2014 17:14:18 +0100 Message-Id: <1416845659-11781-5-git-send-email-hdegoede@redhat.com> In-Reply-To: <1416845659-11781-1-git-send-email-hdegoede@redhat.com> References: <1416845659-11781-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 4/5] edid: Add an edid_check_checksum() helper function X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Add a helper function to check the checksum of an EDID data block. Signed-off-by: Hans de Goede --- 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_ */