From mboxrd@z Thu Jan 1 00:00:00 1970 From: Todd Previte Subject: [PATCH 02/12] drm/i915: Add a function to compute the EDID checksum for Displayport compliance Date: Mon, 14 Jul 2014 12:10:37 -0700 Message-ID: <1405365047-6866-3-git-send-email-tprevite@gmail.com> References: <1405365047-6866-1-git-send-email-tprevite@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-pd0-f171.google.com (mail-pd0-f171.google.com [209.85.192.171]) by gabe.freedesktop.org (Postfix) with ESMTP id 37D716E463 for ; Mon, 14 Jul 2014 12:11:20 -0700 (PDT) Received: by mail-pd0-f171.google.com with SMTP id z10so3435350pdj.2 for ; Mon, 14 Jul 2014 12:11:20 -0700 (PDT) In-Reply-To: <1405365047-6866-1-git-send-email-tprevite@gmail.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org This function computes the EDID checksum for a block of EDID data. This function is necessary for Displayport compliance testing as it does not not require the complete EDID checking functionality provided by the DRM layer functions. Signed-off-by: Todd Previte --- drivers/gpu/drm/i915/intel_dp.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 0d11145..f61502e 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -3328,6 +3328,29 @@ intel_dp_get_sink_irq(struct intel_dp *intel_dp, u8 *sink_irq_vector) sink_irq_vector, 1) == 1; } +static bool intel_dp_compute_edid_checksum(uint8_t *edid_data, uint8_t *edid_checksum) +{ + uint32_t byte_total = 0; + uint8_t i = 0; + bool edid_ok = true; + + /* Compute byte total w/o the checksum value*/ + for (i = 0; i < EDID_LENGTH - 2; i++) + byte_total += edid_data[i]; + + DRM_DEBUG_KMS("Displayport: EDID total = %d, EDID checksum = %d\n", byte_total, edid_data[EDID_LENGTH - 1]); + + /* Compute the checksum */ + *edid_checksum = 256 - (byte_total % 256); + + if (*edid_checksum != edid_data[EDID_LENGTH - 1]) { + DRM_DEBUG_KMS("Displayport: Invalid EDID checksum %d, should be %d\n", edid_data[EDID_LENGTH - 1], *edid_checksum); + edid_ok = false; + } + + return edid_ok; +} + /* Displayport compliance testing - Link training */ static uint8_t intel_dp_autotest_link_training(struct intel_dp *intel_dp) -- 1.9.1