From patchwork Thu Mar 10 14:54:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lee, Shawn C" X-Patchwork-Id: 12776485 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 5B360C433F5 for ; Thu, 10 Mar 2022 14:40:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D034E10E3B9; Thu, 10 Mar 2022 14:40:49 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5D3D710E3B9; Thu, 10 Mar 2022 14:40:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646923248; x=1678459248; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=OO7CUgRacgTgzfNxHOnXUsaKV28w3k+CiE7QJx0HIbE=; b=IAAw30HTLSkdAS5WNjVTfgPZ233vmr+FHizGjeT73MnhL2LmL222HH3U HLHBXeQOv2z9wHLzCdWfxRnXRS3jtsQZ3wake2KnMZVtW1xqYmc3ltPqB 5vuN6ubQrM/IoJFaMZNzFsINQtMULAJDKduqgHXxlFS3Wk7Njmcw9dzoi OIvNoYHf5do3fqPanMwsofJozTjnh+z6nUxxHvHMTLWP8eu13mC6rQIPe gGKUbj55JbXpZ4r5nzJMRDFkH7wsNIzyWdG1szckeYzURwQiQZYNLx7Hk PoIXwUwXMJRbXrcA2HlerSK4NcoEgzYPtbrZdumUBBNUZLITTXI0cF9rv w==; X-IronPort-AV: E=McAfee;i="6200,9189,10281"; a="255000895" X-IronPort-AV: E=Sophos;i="5.90,170,1643702400"; d="scan'208";a="255000895" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2022 06:40:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,170,1643702400"; d="scan'208";a="538477309" Received: from shawnle1-build-machine.itwn.intel.com ([10.5.253.78]) by orsmga007.jf.intel.com with ESMTP; 10 Mar 2022 06:40:46 -0800 From: Lee Shawn C To: dri-devel@lists.freedesktop.org Date: Thu, 10 Mar 2022 22:54:20 +0800 Message-Id: <20220310145424.32643-2-shawn.c.lee@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220310145424.32643-1-shawn.c.lee@intel.com> References: <20220310145424.32643-1-shawn.c.lee@intel.com> Subject: [Intel-gfx] [v5 1/5] drm/edid: seek for available CEA block from specific EDID block index 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: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" drm_find_cea_extension() always look for a top level CEA block. Pass ext_index from caller then this function to search next available CEA ext block from a specific EDID block pointer. Cc: Jani Nikula Cc: Ville Syrjala Cc: Ankit Nautiyal Cc: intel-gfx Signed-off-by: Lee Shawn C --- drivers/gpu/drm/drm_edid.c | 42 ++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 561f53831e29..1251226d9284 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3353,16 +3353,14 @@ const u8 *drm_find_edid_extension(const struct edid *edid, return edid_ext; } -static const u8 *drm_find_cea_extension(const struct edid *edid) +static const u8 *drm_find_cea_extension(const struct edid *edid, int *ext_index) { const struct displayid_block *block; struct displayid_iter iter; const u8 *cea; - int ext_index = 0; - /* Look for a top level CEA extension block */ - /* FIXME: make callers iterate through multiple CEA ext blocks? */ - cea = drm_find_edid_extension(edid, CEA_EXT, &ext_index); + /* Look for a CEA extension block from ext_index */ + cea = drm_find_edid_extension(edid, CEA_EXT, ext_index); if (cea) return cea; @@ -3643,10 +3641,10 @@ add_alternate_cea_modes(struct drm_connector *connector, struct edid *edid) struct drm_device *dev = connector->dev; struct drm_display_mode *mode, *tmp; LIST_HEAD(list); - int modes = 0; + int modes = 0, ext_index = 0; /* Don't add CEA modes if the CEA extension block is missing */ - if (!drm_find_cea_extension(edid)) + if (!drm_find_cea_extension(edid, &ext_index)) return 0; /* @@ -4321,11 +4319,11 @@ static void drm_parse_y420cmdb_bitmap(struct drm_connector *connector, static int add_cea_modes(struct drm_connector *connector, struct edid *edid) { - const u8 *cea = drm_find_cea_extension(edid); - const u8 *db, *hdmi = NULL, *video = NULL; + const u8 *cea, *db, *hdmi = NULL, *video = NULL; u8 dbl, hdmi_len, video_len = 0; - int modes = 0; + int modes = 0, ext_index = 0; + cea = drm_find_cea_extension(edid, &ext_index); if (cea && cea_revision(cea) >= 3) { int i, start, end; @@ -4562,7 +4560,7 @@ static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid) uint8_t *eld = connector->eld; const u8 *cea; const u8 *db; - int total_sad_count = 0; + int total_sad_count = 0, ext_index = 0; int mnl; int dbl; @@ -4571,7 +4569,7 @@ static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid) if (!edid) return; - cea = drm_find_cea_extension(edid); + cea = drm_find_cea_extension(edid, &ext_index); if (!cea) { DRM_DEBUG_KMS("ELD: no CEA Extension found\n"); return; @@ -4655,11 +4653,11 @@ static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid) */ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads) { - int count = 0; + int count = 0, ext_index = 0; int i, start, end, dbl; const u8 *cea; - cea = drm_find_cea_extension(edid); + cea = drm_find_cea_extension(edid, &ext_index); if (!cea) { DRM_DEBUG_KMS("SAD: no CEA Extension found\n"); return 0; @@ -4717,11 +4715,11 @@ EXPORT_SYMBOL(drm_edid_to_sad); */ int drm_edid_to_speaker_allocation(struct edid *edid, u8 **sadb) { - int count = 0; + int count = 0, ext_index = 0; int i, start, end, dbl; const u8 *cea; - cea = drm_find_cea_extension(edid); + cea = drm_find_cea_extension(edid, &ext_index); if (!cea) { DRM_DEBUG_KMS("SAD: no CEA Extension found\n"); return 0; @@ -4814,9 +4812,9 @@ bool drm_detect_hdmi_monitor(struct edid *edid) { const u8 *edid_ext; int i; - int start_offset, end_offset; + int start_offset, end_offset, ext_index = 0; - edid_ext = drm_find_cea_extension(edid); + edid_ext = drm_find_cea_extension(edid, &ext_index); if (!edid_ext) return false; @@ -4853,9 +4851,9 @@ bool drm_detect_monitor_audio(struct edid *edid) const u8 *edid_ext; int i, j; bool has_audio = false; - int start_offset, end_offset; + int start_offset, end_offset, ext_index = 0; - edid_ext = drm_find_cea_extension(edid); + edid_ext = drm_find_cea_extension(edid, &ext_index); if (!edid_ext) goto end; @@ -5177,9 +5175,9 @@ static void drm_parse_cea_ext(struct drm_connector *connector, { struct drm_display_info *info = &connector->display_info; const u8 *edid_ext; - int i, start, end; + int i, start, end, ext_index = 0; - edid_ext = drm_find_cea_extension(edid); + edid_ext = drm_find_cea_extension(edid, &ext_index); if (!edid_ext) return; From patchwork Thu Mar 10 14:54:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lee, Shawn C" X-Patchwork-Id: 12776486 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 9B53AC433EF for ; Thu, 10 Mar 2022 14:40:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 52FF710E500; Thu, 10 Mar 2022 14:40:52 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id DCACF10E4B6; Thu, 10 Mar 2022 14:40:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646923250; x=1678459250; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=xBMBHLykf2aZhi3CbZZ4IHwAix+rQR1KrLmH8hizEwQ=; b=emWoZZcmfghWI3Apb684oOfTBzjfGG/whRkh0xyBVO5oVa4qMIXUWu7M 1NkKb8//P5+LwXxBc6bOv1g+PhwKamlA7qfZRRwFJal9hdqgMwGsLEfGO 4LTZl5njWnogaVGxIk7I+CX8uiD7seUufB5dpQm3zUtNi29NvZnupr+y3 aT3qWFyiNC/NK7IxW7bX+qRgjzjZRSnK82TYbugIPNxb0D4GNJ8r7EEAK wHrWq6A23bupdjaVjtoUAmKM1mKru+hgXO80SEnUMIS/ME5rgijrq4Q9B AkYqzpCdHk3oloyhcdWbEwcdZ7WhIkQZOKW5YrMA1ueOVVgHOAc67uSNO w==; X-IronPort-AV: E=McAfee;i="6200,9189,10281"; a="255000901" X-IronPort-AV: E=Sophos;i="5.90,170,1643702400"; d="scan'208";a="255000901" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2022 06:40:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,170,1643702400"; d="scan'208";a="538477319" Received: from shawnle1-build-machine.itwn.intel.com ([10.5.253.78]) by orsmga007.jf.intel.com with ESMTP; 10 Mar 2022 06:40:48 -0800 From: Lee Shawn C To: dri-devel@lists.freedesktop.org Date: Thu, 10 Mar 2022 22:54:21 +0800 Message-Id: <20220310145424.32643-3-shawn.c.lee@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220310145424.32643-1-shawn.c.lee@intel.com> References: <20220310145424.32643-1-shawn.c.lee@intel.com> Subject: [Intel-gfx] [v5 2/5] drm/edid: parse multiple CEA extension block 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: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Try to find and parse more CEA ext blocks if edid->extensions is greater than one. v2: split prvious patch to two. And do CEA block parsing in this one. v3: simplify this patch based on previous change. v4: refine patch v3. Cc: Jani Nikula Cc: Ville Syrjala Cc: Ankit Nautiyal Cc: intel-gfx Signed-off-by: Lee Shawn C --- drivers/gpu/drm/drm_edid.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 1251226d9284..7b672166fab4 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -4319,16 +4319,22 @@ static void drm_parse_y420cmdb_bitmap(struct drm_connector *connector, static int add_cea_modes(struct drm_connector *connector, struct edid *edid) { - const u8 *cea, *db, *hdmi = NULL, *video = NULL; - u8 dbl, hdmi_len, video_len = 0; int modes = 0, ext_index = 0; - cea = drm_find_cea_extension(edid, &ext_index); - if (cea && cea_revision(cea) >= 3) { + for (;;) { + const u8 *cea, *db, *hdmi = NULL, *video = NULL; + u8 dbl, hdmi_len = 0, video_len = 0; int i, start, end; + cea = drm_find_cea_extension(edid, &ext_index); + if (!cea) + break; + + if (cea_revision(cea) < 3) + continue; + if (cea_db_offsets(cea, &start, &end)) - return 0; + continue; for_each_cea_db(cea, i, start, end) { db = &cea[i]; @@ -4350,15 +4356,15 @@ add_cea_modes(struct drm_connector *connector, struct edid *edid) dbl - 1); } } - } - /* - * We parse the HDMI VSDB after having added the cea modes as we will - * be patching their flags when the sink supports stereo 3D. - */ - if (hdmi) - modes += do_hdmi_vsdb_modes(connector, hdmi, hdmi_len, video, - video_len); + /* + * We parse the HDMI VSDB after having added the cea modes as we will + * be patching their flags when the sink supports stereo 3D. + */ + if (hdmi) + modes += do_hdmi_vsdb_modes(connector, hdmi, hdmi_len, video, + video_len); + } return modes; } From patchwork Thu Mar 10 14:54:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lee, Shawn C" X-Patchwork-Id: 12776487 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 94CE9C433F5 for ; Thu, 10 Mar 2022 14:40:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1575310E4E6; Thu, 10 Mar 2022 14:40:53 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7ACB510E500; Thu, 10 Mar 2022 14:40:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646923251; x=1678459251; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=PjXOns8y8Uexz+3pudx/WekgLrLyTp1UYIu/OLTvosE=; b=DFSI9AwcobeNqHEo//5S7Kic46aYz5d3USVEyUi32JT2mswIQR9TNyAB hSIEFgnMSKs72EEJ9JorqJPV9ccCLpP1ObTMAKD56muH/1Ue9tDSequnk W/m/cQxmEbufz6Na645+zzBPsvCXRYEPgyPjPcVl03P26AEw6LfhGwHPa dN9VvErW916cKWYipvS4PstyYQN1GxZqHSI6DAl2Ott+8vq0zQdUqIeiL A+PNOB1P/b+6FvgH/zHSxAZVwTJULrc0zYyFe1cFWRfgt1hMY3cwNoVFl UGhSC/6CHBc9bc1Begn0cDdDb/hSAcZ9zC9IdnH/qqGhY/TcvLi212QFQ g==; X-IronPort-AV: E=McAfee;i="6200,9189,10281"; a="255000905" X-IronPort-AV: E=Sophos;i="5.90,170,1643702400"; d="scan'208";a="255000905" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2022 06:40:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,170,1643702400"; d="scan'208";a="538477326" Received: from shawnle1-build-machine.itwn.intel.com ([10.5.253.78]) by orsmga007.jf.intel.com with ESMTP; 10 Mar 2022 06:40:49 -0800 From: Lee Shawn C To: dri-devel@lists.freedesktop.org Date: Thu, 10 Mar 2022 22:54:22 +0800 Message-Id: <20220310145424.32643-4-shawn.c.lee@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220310145424.32643-1-shawn.c.lee@intel.com> References: <20220310145424.32643-1-shawn.c.lee@intel.com> Subject: [Intel-gfx] [v5 3/5] drm/edid: read HF-EEODB ext block 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: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" According to HDMI 2.1 spec. "The HDMI Forum EDID Extension Override Data Block (HF-EEODB) is utilized by Sink Devices to provide an alternate method to indicate an EDID Extension Block count larger than 1, while avoiding the need to present a VESA Block Map in the first E-EDID Extension Block." It is a mandatory for HDMI 2.1 protocol compliance as well. This patch help to know how many HF_EEODB blocks report by sink and read allo HF_EEODB blocks back. v2: support to find CEA block, check EEODB block format, and return available block number in drm_edid_read_hf_eeodb_blk_count(). Cc: Jani Nikula Cc: Ville Syrjala Cc: Ankit Nautiyal Cc: intel-gfx Signed-off-by: Lee Shawn C --- drivers/gpu/drm/drm_connector.c | 8 +++- drivers/gpu/drm/drm_edid.c | 71 +++++++++++++++++++++++++++++++-- include/drm/drm_edid.h | 2 +- 3 files changed, 74 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index a50c82bc2b2f..16011023c12e 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -2129,7 +2129,7 @@ int drm_connector_update_edid_property(struct drm_connector *connector, const struct edid *edid) { struct drm_device *dev = connector->dev; - size_t size = 0; + size_t size = 0, hf_eeodb_blk_count; int ret; const struct edid *old_edid; @@ -2137,8 +2137,12 @@ int drm_connector_update_edid_property(struct drm_connector *connector, if (connector->override_edid) return 0; - if (edid) + if (edid) { size = EDID_LENGTH * (1 + edid->extensions); + hf_eeodb_blk_count = drm_edid_read_hf_eeodb_blk_count(edid); + if (hf_eeodb_blk_count) + size = EDID_LENGTH * (1 + hf_eeodb_blk_count); + } /* Set the display info, using edid if available, otherwise * resetting the values to defaults. This duplicates the work diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 7b672166fab4..38b041c8b4ad 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -1992,6 +1992,7 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, { int i, j = 0, valid_extensions = 0; u8 *edid, *new; + size_t hf_eeodb_blk_count; struct edid *override; override = drm_get_override_edid(connector); @@ -2051,7 +2052,35 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, } kfree(edid); + return (struct edid *)new; + } + + hf_eeodb_blk_count = drm_edid_read_hf_eeodb_blk_count((struct edid *)edid); + if (hf_eeodb_blk_count >= 2) { + new = krealloc(edid, (hf_eeodb_blk_count + 1) * EDID_LENGTH, GFP_KERNEL); + if (!new) + goto out; edid = new; + + valid_extensions = hf_eeodb_blk_count - 1; + for (j = 2; j <= hf_eeodb_blk_count; j++) { + u8 *block = edid + j * EDID_LENGTH; + + for (i = 0; i < 4; i++) { + if (get_edid_block(data, block, j, EDID_LENGTH)) + goto out; + if (drm_edid_block_valid(block, j, false, NULL)) + break; + } + + if (i == 4) + valid_extensions--; + } + + if (valid_extensions != hf_eeodb_blk_count - 1) { + DRM_ERROR("Not able to retrieve proper EDID contain HF-EEODB data.\n"); + goto out; + } } return (struct edid *)edid; @@ -3315,15 +3344,17 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid, #define VIDEO_BLOCK 0x02 #define VENDOR_BLOCK 0x03 #define SPEAKER_BLOCK 0x04 -#define HDR_STATIC_METADATA_BLOCK 0x6 -#define USE_EXTENDED_TAG 0x07 -#define EXT_VIDEO_CAPABILITY_BLOCK 0x00 +#define EXT_VIDEO_CAPABILITY_BLOCK 0x00 +#define HDR_STATIC_METADATA_BLOCK 0x06 +#define USE_EXTENDED_TAG 0x07 #define EXT_VIDEO_DATA_BLOCK_420 0x0E -#define EXT_VIDEO_CAP_BLOCK_Y420CMDB 0x0F +#define EXT_VIDEO_CAP_BLOCK_Y420CMDB 0x0F +#define EXT_VIDEO_HF_EEODB_DATA_BLOCK 0x78 #define EDID_BASIC_AUDIO (1 << 6) #define EDID_CEA_YCRCB444 (1 << 5) #define EDID_CEA_YCRCB422 (1 << 4) #define EDID_CEA_VCDB_QS (1 << 6) +#define HF_EEODB_LENGTH 2 /* * Search EDID for CEA extension block. @@ -4273,9 +4304,41 @@ static bool cea_db_is_y420vdb(const u8 *db) return true; } +static bool cea_db_is_hdmi_forum_eeodb(const u8 *db) +{ + if (cea_db_tag(db) != USE_EXTENDED_TAG) + return false; + + if (cea_db_payload_len(db) != HF_EEODB_LENGTH) + return false; + + if (cea_db_extended_tag(db) != EXT_VIDEO_HF_EEODB_DATA_BLOCK) + return false; + + return true; +} + #define for_each_cea_db(cea, i, start, end) \ for ((i) = (start); (i) < (end) && (i) + cea_db_payload_len(&(cea)[(i)]) < (end); (i) += cea_db_payload_len(&(cea)[(i)]) + 1) +size_t drm_edid_read_hf_eeodb_blk_count(const struct edid *edid) +{ + const u8 *cea; + int i, start, end, ext_index = 0; + + if (edid->extensions) { + cea = drm_find_cea_extension(edid, &ext_index); + + if (cea && !cea_db_offsets(cea, &start, &end)) + for_each_cea_db(cea, i, start, end) + if (cea_db_is_hdmi_forum_eeodb(&cea[i])) + return cea[i + 2]; + } + + return 0; +} +EXPORT_SYMBOL_GPL(drm_edid_read_hf_eeodb_blk_count); + static void drm_parse_y420cmdb_bitmap(struct drm_connector *connector, const u8 *db) { diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index 144c495b99c4..5549da7bd7be 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -592,6 +592,6 @@ drm_display_mode_from_cea_vic(struct drm_device *dev, u8 video_code); const u8 *drm_find_edid_extension(const struct edid *edid, int ext_id, int *ext_index); - +size_t drm_edid_read_hf_eeodb_blk_count(const struct edid *edid); #endif /* __DRM_EDID_H__ */ From patchwork Thu Mar 10 14:54:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lee, Shawn C" X-Patchwork-Id: 12776488 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7A61AC433EF for ; Thu, 10 Mar 2022 14:41:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6924010E59C; Thu, 10 Mar 2022 14:40:54 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1F12F10E59C; Thu, 10 Mar 2022 14:40:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646923253; x=1678459253; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=lVi3/LZhIoiVuRL9lpdIKh/NyprssCzn296KmfFfG+E=; b=KWU7ULmibOjgmSpWEYaQ1CvNgwPZnrRyyQayST0kfIq/OSPOjlz2cQx3 rMdOLoX9iegMRT+KsJvWQxuC2avkD8qUYeNVc3TPLhgCn7FUvJq4gpKIf Ymm8Q72ABVmuWnI0+/n7RoyYcxjgahhmnaDbjDLMHkyvMUJrFzsujmSvc bxeXacVCcuxqnjMUHYj+E/tqXl+k3zqv822JD8lAKQN9Xp980fv9v6QZH uVwlT4xeeGGxoBGWpgEX/HZWEaL81+EVGQbQbJuMEtj8WFdg0dKr8D4Yn TrmsXIFNFCLvREklMAOdErBIVVO4KFWiFtQ8kvK9DLaO5ER4frcg9I3y6 Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10281"; a="255000914" X-IronPort-AV: E=Sophos;i="5.90,170,1643702400"; d="scan'208";a="255000914" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2022 06:40:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,170,1643702400"; d="scan'208";a="538477334" Received: from shawnle1-build-machine.itwn.intel.com ([10.5.253.78]) by orsmga007.jf.intel.com with ESMTP; 10 Mar 2022 06:40:51 -0800 From: Lee Shawn C To: dri-devel@lists.freedesktop.org Date: Thu, 10 Mar 2022 22:54:23 +0800 Message-Id: <20220310145424.32643-5-shawn.c.lee@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220310145424.32643-1-shawn.c.lee@intel.com> References: <20220310145424.32643-1-shawn.c.lee@intel.com> Subject: [Intel-gfx] [v5 4/5] drm/edid: parse HF-EEODB CEA extension block 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: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" While adding CEA modes, try to get available EEODB block number. Then based on it to parse numbers of ext blocks, retrieve CEA information and add more CEA modes. Cc: Jani Nikula Cc: Ville Syrjala Cc: Ankit Nautiyal Cc: intel-gfx Signed-off-by: Lee Shawn C --- drivers/gpu/drm/drm_displayid.c | 5 ++++- drivers/gpu/drm/drm_edid.c | 35 +++++++++++++++++++-------------- include/drm/drm_edid.h | 2 +- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/drm_displayid.c b/drivers/gpu/drm/drm_displayid.c index 32da557b960f..dc649a9efaa2 100644 --- a/drivers/gpu/drm/drm_displayid.c +++ b/drivers/gpu/drm/drm_displayid.c @@ -37,7 +37,10 @@ static const u8 *drm_find_displayid_extension(const struct edid *edid, int *length, int *idx, int *ext_index) { - const u8 *displayid = drm_find_edid_extension(edid, DISPLAYID_EXT, ext_index); + const u8 *displayid = drm_find_edid_extension(edid, + DISPLAYID_EXT, + ext_index, + edid->extensions); const struct displayid_header *base; int ret; diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 38b041c8b4ad..1da1239c21cb 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3360,23 +3360,23 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid, * Search EDID for CEA extension block. */ const u8 *drm_find_edid_extension(const struct edid *edid, - int ext_id, int *ext_index) + int ext_id, int *ext_index, int ext_blk_num) { const u8 *edid_ext = NULL; int i; /* No EDID or EDID extensions */ - if (edid == NULL || edid->extensions == 0) + if (edid == NULL || edid->extensions == 0 || *ext_index >= ext_blk_num) return NULL; /* Find CEA extension */ - for (i = *ext_index; i < edid->extensions; i++) { + for (i = *ext_index; i < ext_blk_num; i++) { edid_ext = (const u8 *)edid + EDID_LENGTH * (i + 1); if (edid_ext[0] == ext_id) break; } - if (i >= edid->extensions) + if (i >= ext_blk_num) return NULL; *ext_index = i + 1; @@ -3384,14 +3384,15 @@ const u8 *drm_find_edid_extension(const struct edid *edid, return edid_ext; } -static const u8 *drm_find_cea_extension(const struct edid *edid, int *ext_index) +static const u8 *drm_find_cea_extension(const struct edid *edid, + int *ext_index, int ext_blk_num) { const struct displayid_block *block; struct displayid_iter iter; const u8 *cea; /* Look for a CEA extension block from ext_index */ - cea = drm_find_edid_extension(edid, CEA_EXT, ext_index); + cea = drm_find_edid_extension(edid, CEA_EXT, ext_index, ext_blk_num); if (cea) return cea; @@ -3675,7 +3676,7 @@ add_alternate_cea_modes(struct drm_connector *connector, struct edid *edid) int modes = 0, ext_index = 0; /* Don't add CEA modes if the CEA extension block is missing */ - if (!drm_find_cea_extension(edid, &ext_index)) + if (!drm_find_cea_extension(edid, &ext_index, edid->extensions)) return 0; /* @@ -4327,7 +4328,7 @@ size_t drm_edid_read_hf_eeodb_blk_count(const struct edid *edid) int i, start, end, ext_index = 0; if (edid->extensions) { - cea = drm_find_cea_extension(edid, &ext_index); + cea = drm_find_cea_extension(edid, &ext_index, edid->extensions); if (cea && !cea_db_offsets(cea, &start, &end)) for_each_cea_db(cea, i, start, end) @@ -4383,13 +4384,17 @@ static int add_cea_modes(struct drm_connector *connector, struct edid *edid) { int modes = 0, ext_index = 0; + int ext_blk_num = drm_edid_read_hf_eeodb_blk_count(edid); + + if (!ext_blk_num) + ext_blk_num = edid->extensions; for (;;) { const u8 *cea, *db, *hdmi = NULL, *video = NULL; u8 dbl, hdmi_len = 0, video_len = 0; int i, start, end; - cea = drm_find_cea_extension(edid, &ext_index); + cea = drm_find_cea_extension(edid, &ext_index, ext_blk_num); if (!cea) break; @@ -4638,7 +4643,7 @@ static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid) if (!edid) return; - cea = drm_find_cea_extension(edid, &ext_index); + cea = drm_find_cea_extension(edid, &ext_index, edid->extensions); if (!cea) { DRM_DEBUG_KMS("ELD: no CEA Extension found\n"); return; @@ -4726,7 +4731,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads) int i, start, end, dbl; const u8 *cea; - cea = drm_find_cea_extension(edid, &ext_index); + cea = drm_find_cea_extension(edid, &ext_index, edid->extensions); if (!cea) { DRM_DEBUG_KMS("SAD: no CEA Extension found\n"); return 0; @@ -4788,7 +4793,7 @@ int drm_edid_to_speaker_allocation(struct edid *edid, u8 **sadb) int i, start, end, dbl; const u8 *cea; - cea = drm_find_cea_extension(edid, &ext_index); + cea = drm_find_cea_extension(edid, &ext_index, edid->extensions); if (!cea) { DRM_DEBUG_KMS("SAD: no CEA Extension found\n"); return 0; @@ -4883,7 +4888,7 @@ bool drm_detect_hdmi_monitor(struct edid *edid) int i; int start_offset, end_offset, ext_index = 0; - edid_ext = drm_find_cea_extension(edid, &ext_index); + edid_ext = drm_find_cea_extension(edid, &ext_index, edid->extensions); if (!edid_ext) return false; @@ -4922,7 +4927,7 @@ bool drm_detect_monitor_audio(struct edid *edid) bool has_audio = false; int start_offset, end_offset, ext_index = 0; - edid_ext = drm_find_cea_extension(edid, &ext_index); + edid_ext = drm_find_cea_extension(edid, &ext_index, edid->extensions); if (!edid_ext) goto end; @@ -5246,7 +5251,7 @@ static void drm_parse_cea_ext(struct drm_connector *connector, const u8 *edid_ext; int i, start, end, ext_index = 0; - edid_ext = drm_find_cea_extension(edid, &ext_index); + edid_ext = drm_find_cea_extension(edid, &ext_index, edid->extensions); if (!edid_ext) return; diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index 5549da7bd7be..5555b27e92f9 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -591,7 +591,7 @@ struct drm_display_mode * drm_display_mode_from_cea_vic(struct drm_device *dev, u8 video_code); const u8 *drm_find_edid_extension(const struct edid *edid, - int ext_id, int *ext_index); + int ext_id, int *ext_index, int ext_blk_num); size_t drm_edid_read_hf_eeodb_blk_count(const struct edid *edid); #endif /* __DRM_EDID_H__ */ From patchwork Thu Mar 10 14:54:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lee, Shawn C" X-Patchwork-Id: 12776489 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7F17CC433FE for ; Thu, 10 Mar 2022 14:41:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5A5C910E69D; Thu, 10 Mar 2022 14:40:59 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8F58110E5E3; Thu, 10 Mar 2022 14:40:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646923254; x=1678459254; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=LQJrEnL3/tc58OpLr74freQ+0vVozgeWnkoeKoqw96w=; b=lP8P2SBGKPex7Syff9sSW0uuflE4qu0wonwApyUS26TtyGNTj4bFOPst Z3sTxTzVrJ0cbo4I/FaAff+k8nG0SkLgMAnkDElTYkH+aOXBes42ZJfdo dvHkCDnxgFqoSqz1rgWadpHdCJ9+mi+xaWtuC7Lj59i8MkMobfA1Albnv 6hbL5u3tNRE96PwkY3q1X7IedSQL4fDqVbSVeM/mVu56XhBxGV88IcvXM 71hiEi+4o2wvL3W4cB5CNbmVozAe4/JfiOwtkXz+D855m768O2m/fQkTr 0tSCELC9HsT4PNtp3o5NobE4mY0LnnUwNwS6BieeX+HTGJVAkEYn/go8v A==; X-IronPort-AV: E=McAfee;i="6200,9189,10281"; a="255000919" X-IronPort-AV: E=Sophos;i="5.90,170,1643702400"; d="scan'208";a="255000919" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2022 06:40:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,170,1643702400"; d="scan'208";a="538477346" Received: from shawnle1-build-machine.itwn.intel.com ([10.5.253.78]) by orsmga007.jf.intel.com with ESMTP; 10 Mar 2022 06:40:53 -0800 From: Lee Shawn C To: dri-devel@lists.freedesktop.org Date: Thu, 10 Mar 2022 22:54:24 +0800 Message-Id: <20220310145424.32643-6-shawn.c.lee@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220310145424.32643-1-shawn.c.lee@intel.com> References: <20220310145424.32643-1-shawn.c.lee@intel.com> Subject: [Intel-gfx] [v5 5/5] drm/edid: check for HF-SCDB block 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: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Find HF-SCDB information in CEA extensions block. And retrieve Max_TMDS_Character_Rate that support by sink device. v2: HF-SCDB and HF-VSDBS carry the same SCDS data. Reuse drm_parse_hdmi_forum_vsdb() to parse this packet. Cc: Jani Nikula Cc: Ville Syrjala Cc: Ankit Nautiyal Cc: intel-gfx Signed-off-by: Lee Shawn C --- drivers/gpu/drm/drm_edid.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 1da1239c21cb..f1d5180ee5a9 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3350,6 +3350,7 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid, #define EXT_VIDEO_DATA_BLOCK_420 0x0E #define EXT_VIDEO_CAP_BLOCK_Y420CMDB 0x0F #define EXT_VIDEO_HF_EEODB_DATA_BLOCK 0x78 +#define EXT_VIDEO_HF_SCDB_DATA_BLOCK 0x79 #define EDID_BASIC_AUDIO (1 << 6) #define EDID_CEA_YCRCB444 (1 << 5) #define EDID_CEA_YCRCB422 (1 << 4) @@ -4277,6 +4278,20 @@ static bool cea_db_is_vcdb(const u8 *db) return true; } +static bool cea_db_is_hdmi_forum_scdb(const u8 *db) +{ + if (cea_db_tag(db) != USE_EXTENDED_TAG) + return false; + + if (cea_db_payload_len(db) < 7) + return false; + + if (cea_db_extended_tag(db) != EXT_VIDEO_HF_SCDB_DATA_BLOCK) + return false; + + return true; +} + static bool cea_db_is_y420cmdb(const u8 *db) { if (cea_db_tag(db) != USE_EXTENDED_TAG) @@ -5272,7 +5287,8 @@ static void drm_parse_cea_ext(struct drm_connector *connector, if (cea_db_is_hdmi_vsdb(db)) drm_parse_hdmi_vsdb_video(connector, db); - if (cea_db_is_hdmi_forum_vsdb(db)) + if (cea_db_is_hdmi_forum_vsdb(db) || + cea_db_is_hdmi_forum_scdb(db)) drm_parse_hdmi_forum_vsdb(connector, db); if (cea_db_is_microsoft_vsdb(db)) drm_parse_microsoft_vsdb(connector, db);