From patchwork Fri Jun 26 09:13:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Joshi, Kunal1" X-Patchwork-Id: 11627933 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F1D216C1 for ; Fri, 26 Jun 2020 16:10:04 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DA19820773 for ; Fri, 26 Jun 2020 16:10:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA19820773 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 50B766E139; Fri, 26 Jun 2020 16:10:04 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 69AAF6ECCD for ; Fri, 26 Jun 2020 16:10:00 +0000 (UTC) IronPort-SDR: IF6Z4+y5y271wBduj+wc69h+RHtV4UGpWQbIMwoMu2YpoffPO0PW+RpA+YYyUzbV5oM3axbmDH JGGwIdOmFDTg== X-IronPort-AV: E=McAfee;i="6000,8403,9664"; a="133758575" X-IronPort-AV: E=Sophos;i="5.75,284,1589266800"; d="scan'208";a="133758575" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2020 09:10:00 -0700 IronPort-SDR: csAEg0WcH7dBLLkd5wWZ02LOYWi9FRgEeMMYLYWCiCF2MsR5ApvfyZBiaikPN7Biyg66+lf7Yl lKyXD3TxLorw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,284,1589266800"; d="scan'208";a="479868670" Received: from unknown (HELO joshikun.iind.intel.com) ([10.223.74.209]) by fmsmga006.fm.intel.com with ESMTP; 26 Jun 2020 09:09:58 -0700 From: Kunal Joshi To: intel-gfx@lists.freedesktop.org Date: Fri, 26 Jun 2020 14:43:31 +0530 Message-Id: <20200626091333.17516-2-kunal1.joshi@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200626091333.17516-1-kunal1.joshi@intel.com> References: <20200626091333.17516-1-kunal1.joshi@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 1/3] drm: Add helper to compare edids. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: daniel.vetter@intel.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Stanislav Lisovskiy From: Stanislav Lisovskiy Many drivers would benefit from using drm helper to compare edid, rather than bothering with own implementation. v2: Added documentation for this function. Signed-off-by: Stanislav Lisovskiy --- drivers/gpu/drm/drm_edid.c | 33 +++++++++++++++++++++++++++++++++ include/drm/drm_edid.h | 9 +++++++++ 2 files changed, 42 insertions(+) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 71ae0cd6d576..920ac9ef6018 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -1615,6 +1615,39 @@ static bool drm_edid_is_zero(const u8 *in_edid, int length) return true; } +/** + * drm_edid_are_equal - compare two edid blobs. + * @edid1: pointer to first blob + * @edid2: pointer to second blob + * This helper can be used during probing to determine if + * edid had changed. + */ +bool drm_edid_are_equal(const struct edid *edid1, const struct edid *edid2) +{ + int edid1_len, edid2_len; + bool edid1_present = edid1 != NULL; + bool edid2_present = edid2 != NULL; + + if (edid1_present != edid2_present) + return false; + + if (edid1) { + + edid1_len = EDID_LENGTH * (1 + edid1->extensions); + edid2_len = EDID_LENGTH * (1 + edid2->extensions); + + if (edid1_len != edid2_len) + return false; + + if (memcmp(edid1, edid2, edid1_len)) + return false; + } + + return true; +} +EXPORT_SYMBOL(drm_edid_are_equal); + + /** * drm_edid_block_valid - Sanity check the EDID block (base or extension) * @raw_edid: pointer to raw EDID block diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index 43254319ab19..cfa4f5af49af 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -359,6 +359,15 @@ drm_load_edid_firmware(struct drm_connector *connector) } #endif +/** + * drm_edid_are_equal - compare two edid blobs. + * @edid1: pointer to first blob + * @edid2: pointer to second blob + * This helper can be used during probing to determine if + * edid had changed. + */ +bool drm_edid_are_equal(const struct edid *edid1, const struct edid *edid2); + int drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame, const struct drm_connector *connector,