From patchwork Mon May 9 12:03:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843383 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 59856C433F5 for ; Mon, 9 May 2022 12:03:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8E39610EE35; Mon, 9 May 2022 12:03:36 +0000 (UTC) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id A363D10EE35; Mon, 9 May 2022 12:03:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097815; x=1683633815; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=82X9mfDtRVWQVamwSCwdjYtoVRrvsVNtYWlh6IX24s0=; b=KxAHqyogtf61H8FSPeoVUddV7CZJCr0opFk4Yq6iyEseNH729H6w1RwC cGB2jL/tafJXUhHWsYTIAemehCmgE5TiLCsFyORoEN2yvz9XwpiUpQBGj sVlx4inQ52zMvuA85BhWzEXNIGQjTwp6AIdkIx9Qxr33guFNfHmo8RLjh PjXvkrq/xysNkR5G1uyP8qQL2p4KHOnc6e/VaNrmMtkV1HOGBH9Z99gM+ 1Cs00RslRGmKJBaNuR5CAn1bL9uSM4K1yMlkrDwWsFNmFhinvXKoFU/38 AV8oDXr05JRUWIdE4xH/kbTbjwTzekWDhdyWYDBUEdxeyU6A7ELEVghQz Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="355456514" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="355456514" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:03:35 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="592054694" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:03:33 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:00 +0300 Message-Id: <3a7ba2217134b0ab4c4c72e4333231a4e0616e88.1652097712.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 01/25] drm/edid: use else-if in CTA extension parsing 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" Only one of the conditions can be true. Suggested-by: Ville Syrjälä Signed-off-by: Jani Nikula Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/drm_edid.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 47d121e99201..efc1999b9573 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -5473,16 +5473,16 @@ static void drm_parse_cea_ext(struct drm_connector *connector, if (cea_db_is_hdmi_vsdb(db)) drm_parse_hdmi_vsdb_video(connector, data); - if (cea_db_is_hdmi_forum_vsdb(db) || - cea_db_is_hdmi_forum_scdb(db)) + else if (cea_db_is_hdmi_forum_vsdb(db) || + cea_db_is_hdmi_forum_scdb(db)) drm_parse_hdmi_forum_scds(connector, data); - if (cea_db_is_microsoft_vsdb(db)) + else if (cea_db_is_microsoft_vsdb(db)) drm_parse_microsoft_vsdb(connector, data); - if (cea_db_is_y420cmdb(db)) + else if (cea_db_is_y420cmdb(db)) drm_parse_y420cmdb_bitmap(connector, data); - if (cea_db_is_vcdb(db)) + else if (cea_db_is_vcdb(db)) drm_parse_vcdb(connector, data); - if (cea_db_is_hdmi_hdr_metadata_block(db)) + else if (cea_db_is_hdmi_hdr_metadata_block(db)) drm_parse_hdr_metadata_block(connector, data); } cea_db_iter_end(&iter); From patchwork Mon May 9 12:03:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843384 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 BC4E8C433EF for ; Mon, 9 May 2022 12:03:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 34E0610EE4B; Mon, 9 May 2022 12:03:41 +0000 (UTC) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id BB25610EE4B; Mon, 9 May 2022 12:03:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097820; x=1683633820; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+I/C+1PUxSZTnur4lDxq85dL5tzYTSnZQZIvhIOkCD0=; b=SiJlYw1QsFN+t4IojmA1qgfXPMX9x8lbhj31UQ7EYfmNkVARNAWhfSbA dDEqgHcmdskAaIwCd/gLSIXbiAbvlRtA5g3B4BQIHS+YMveE4fEd0gblp 2US42GDtznsZFpF4BcNYeRdPjQXQ2WxuUezXWPS+5dbTv+Spmf2cmegov doyMCzIsFO+n+Ktb0Yt3OwBbzr3SwdlCNd7AqvLdtD6s1CVCksL504HhP rb9Qajdq4NzdXc3ENanQp20gub+NTI9k3MPh5GtygPJFxEFWTLQo4NwiA mwZpq/8GLY7i+OiUMcUvNzvt7QuohhQ32KvZl3V3TytcN5AqO9CabDH/d w==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="256563567" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="256563567" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:03:40 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="565030951" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:03:38 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:01 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 02/25] drm/edid: convert drm_for_each_detailed_block() to edid iter 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" We have an iterator for this, use it. It does include the base block, but its tag is 0 and will be skipped. Signed-off-by: Jani Nikula Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/drm_edid.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index efc1999b9573..dcef92c8887a 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2574,6 +2574,8 @@ vtb_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure) static void drm_for_each_detailed_block(const struct edid *edid, detailed_cb *cb, void *closure) { + struct drm_edid_iter edid_iter; + const u8 *ext; int i; if (edid == NULL) @@ -2582,9 +2584,8 @@ drm_for_each_detailed_block(const struct edid *edid, detailed_cb *cb, void *clos for (i = 0; i < EDID_DETAILED_TIMINGS; i++) cb(&(edid->detailed_timings[i]), closure); - for (i = 0; i < edid_extension_block_count(edid); i++) { - const u8 *ext = edid_extension_block_data(edid, i); - + drm_edid_iter_begin(edid, &edid_iter); + drm_edid_iter_for_each(ext, &edid_iter) { switch (*ext) { case CEA_EXT: cea_for_each_detailed_block(ext, cb, closure); @@ -2596,6 +2597,7 @@ drm_for_each_detailed_block(const struct edid *edid, detailed_cb *cb, void *clos break; } } + drm_edid_iter_end(&edid_iter); } static void From patchwork Mon May 9 12:03:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843385 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 C2800C4332F for ; Mon, 9 May 2022 12:03:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 361B010EE64; Mon, 9 May 2022 12:03:47 +0000 (UTC) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id B245F10EE64; Mon, 9 May 2022 12:03:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097825; x=1683633825; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HgeNDGzi+0QMpiQwoNnEG61MqqkOaM1jTupHUWhlaQ8=; b=JM/DCoyn1YC2NC44VOmTJEsYxvxDLnxKaFBgO5g4li2cVwJXfUjVXyKt ctGRW07pGnlUhzLA4uXcBjPcmr7Ub2PxGj41LZD+UExo/l0mVuydRUiUj 2BZCnU+lvQO3m10JcOINMgCQ256VcbyCY8F52YCPvv+PlPZpuRvGxCr7f 0qBj+e2ty+8Pc+dT0bJ+ELR24Pj/ZHBMwTHy8Is7btr0dGNXlc/yZvoSy aHC3xtOhngRRpk8CrakMTx3VX7bBIMoYKNYDucwJ4fRbk8lUxw2AEoddb x0zvn5DE7IfVh/2RANCOOg3rJNRclW8t0Fhx9tYU9kC2ZI1hVsXc0zfK8 g==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="355456556" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="355456556" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:03:45 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="540628012" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:03:43 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:02 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 03/25] drm/edid: add struct drm_edid container 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" Introduce new opaque type struct drm_edid to encapsulate the EDID data and the size allocated for it. The contents will be private to drm_edid.c. There are a number of reasons for adding a container around struct edid: * struct edid is a raw blob pointer to data that usually originates outside of the kernel. Its size is contained within the structure. * There's no way to attach meta information (such as allocated memory size) to struct edid. * Validation of the EDID blob and its size become crucial, and it's spread all over the subsystem, with varying levels of accuracy. * HDMI Forum has introduced an HF-EEODB extension that defines an override EDID size within an EDID extension. The size allocated for an EDID depends on whether the allocator understands the HF-EEODB extension. Given a struct edid *, it's impossible to know how much memory was actually allocated for it. There are also some reasons for making the container type struct drm_edid opaque and private to drm_edid.c: * Have only one place for creating and parsing the EDID, to avoid duplicating bugs. * Prepare for reading a pure DisplayID 2.0 from its own DDC address, and adding it within the same struct drm_edid container, transparently, and for all drivers. * With the idea that the drm_edid objects are immutable during their lifetimes, it will be possible to refcount them and reduce EDID copying everywhere (this is left for future work). Initially, just add the type. In follow-up, we'll start converting the guts of drm_edid.c to use it, and finally add interfaces around it. Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index dcef92c8887a..480fd9fbe412 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -1567,6 +1567,15 @@ static const struct drm_display_mode edid_4k_modes[] = { /*** DDC fetch and block validation ***/ +/* + * The opaque EDID type, internal to drm_edid.c. + */ +struct drm_edid { + /* Size allocated for edid */ + size_t size; + const struct edid *edid; +}; + static int edid_extension_block_count(const struct edid *edid) { return edid->extensions; From patchwork Mon May 9 12:03:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843386 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 B8442C433EF for ; Mon, 9 May 2022 12:03:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1176110EE68; Mon, 9 May 2022 12:03:52 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4867C10EE68; Mon, 9 May 2022 12:03:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097830; x=1683633830; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VqXXpce1WjRUgzEhWSM3qk067V1CTj8Lo71IUfBzbZc=; b=PXjdLS2f6WDYXxKB/iuvwexyLPduShY6+xKpqmkaugwpOZO44X3xQPjQ Lpc31QNrWAELWl2NbqNJanIE7licAO/gsPA8Scc1tf168TEJsSZ8UZoTs mlKW507RsztFo+8ksquX5ujDfxSUmyylzTmPm5IV17+fxeGUHvUzZuEE1 0zLhv310Drr8JU93FCOBqb61D3C9+LejL2gdmBSpODO/r2f19gXIwZKtC bfQGGxDb/Klwn2fN9wjQFd9MssS0QlblBvn2k84CJDjr34K7OtbPlXNVM eqodnVIHtHSnvW37xZy2flMmhJ96Oveir4xCF+WtddDZDxaa84Lw3Cq7l A==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="249565922" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="249565922" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:03:49 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="565030991" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:03:47 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:03 +0300 Message-Id: <000452fddedbaf7f473ac25d4dde2502e60b8e39.1652097712.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 04/25] drm/edid: start propagating drm_edid to lower levels 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" We'll need to propagate drm_edid everywhere. This is a clunky start, but a start nonetheless. We'll eventually convert all of the EDID parsing to struct drm_edid. Initially, we'll just create the struct drm_edid in stack. This will be the compat layer for legacy struct edid code. In the future, we'll have EDID read return drm_edid objects. v2: Add legacy init helper. Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 480fd9fbe412..f48f1f1a1fa7 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -1608,6 +1608,24 @@ static const void *edid_extension_block_data(const struct edid *edid, int index) return edid_block_data(edid, index + 1); } +/* + * Initializer helper for legacy interfaces, where we have no choice but to + * trust edid size. Not for general purpose use. + */ +static const struct drm_edid *drm_edid_legacy_init(struct drm_edid *drm_edid, + const struct edid *edid) +{ + if (!edid) + return NULL; + + memset(drm_edid, 0, sizeof(*drm_edid)); + + drm_edid->edid = edid; + drm_edid->size = edid_size(edid); + + return drm_edid; +} + /* * EDID base and extension block iterator. * @@ -5814,17 +5832,20 @@ static int add_displayid_detailed_modes(struct drm_connector *connector, } static int drm_edid_connector_update(struct drm_connector *connector, - const struct edid *edid) + const struct drm_edid *drm_edid) { + const struct edid *edid; int num_modes = 0; u32 quirks; - if (edid == NULL) { + if (!drm_edid) { drm_reset_display_info(connector); clear_eld(connector); return 0; } + edid = drm_edid->edid; + /* * CEA-861-F adds ycbcr capability map block, for HDMI 2.0 sinks. * To avoid multiple parsing of same block, lets parse that map @@ -5890,13 +5911,16 @@ static int drm_edid_connector_update(struct drm_connector *connector, */ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid) { + struct drm_edid drm_edid; + if (edid && !drm_edid_is_valid(edid)) { drm_warn(connector->dev, "%s: EDID invalid.\n", connector->name); edid = NULL; } - return drm_edid_connector_update(connector, edid); + return drm_edid_connector_update(connector, + drm_edid_legacy_init(&drm_edid, edid)); } EXPORT_SYMBOL(drm_add_edid_modes); From patchwork Mon May 9 12:03:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843387 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 9082DC433F5 for ; Mon, 9 May 2022 12:03:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DDC0A10EE6E; Mon, 9 May 2022 12:03:56 +0000 (UTC) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id ED66D10EE6E; Mon, 9 May 2022 12:03:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097835; x=1683633835; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Wi7m8l6GUkj+rtNVLqCc8oY+HOk9xGMs6NxEDFvyn0c=; b=k3VKRnxefcfbfHySp66VxVTkcQTFNSr412cvjUJLq6ou9d+XhwaZjrUl dPf0IHa5HyepEUcxnqYOXz5MwzoUPb/aQNq+MrpJD+C1mXx9m1loMiBGp 8u7zGjdzOQQUgjfpMjy/Ja1QDPFiaKoqDNyGtTeUhbxkCopwKXUKhSO67 c8dvUrX2zzdXDbOucn5kCVvNZ4Oje6XGkObHskeGtBSVGRrjsQS1YdFAQ RlYHhAgxaClSRwdUE0ARARxNDTn3pXhkxTWEz8tX294OAK8v70mJe9KJW tYrWH98keyVaQndQ1RyZh9WwsrQdvjenrK3EIpX4E/DuUTv9MdhX534jt g==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="269167447" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="269167447" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:03:54 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="738134608" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:03:52 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:04 +0300 Message-Id: <5a24629a6788de873c3f01d391b9b2e856d2eb57.1652097712.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 05/25] drm/edid: keep propagating drm_edid to display info 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" We'll need to propagate drm_edid everywhere. v2: Use drm_edid_legacy_init() Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 48 +++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index f48f1f1a1fa7..96e3f9327044 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2437,13 +2437,13 @@ EXPORT_SYMBOL(drm_edid_duplicate); /** * edid_get_quirks - return quirk flags for a given EDID - * @edid: EDID to process + * @drm_edid: EDID to process * * This tells subsequent routines what fixes they need to apply. */ -static u32 edid_get_quirks(const struct edid *edid) +static u32 edid_get_quirks(const struct drm_edid *drm_edid) { - u32 panel_id = edid_extract_panel_id(edid); + u32 panel_id = edid_extract_panel_id(drm_edid->edid); const struct edid_quirk *quirk; int i; @@ -5466,7 +5466,7 @@ static void drm_parse_microsoft_vsdb(struct drm_connector *connector, } static void drm_parse_cea_ext(struct drm_connector *connector, - const struct edid *edid) + const struct drm_edid *drm_edid) { struct drm_display_info *info = &connector->display_info; struct drm_edid_iter edid_iter; @@ -5474,7 +5474,7 @@ static void drm_parse_cea_ext(struct drm_connector *connector, struct cea_db_iter iter; const u8 *edid_ext; - drm_edid_iter_begin(edid, &edid_iter); + drm_edid_iter_begin(drm_edid->edid, &edid_iter); drm_edid_iter_for_each(edid_ext, &edid_iter) { if (edid_ext[0] != CEA_EXT) continue; @@ -5495,7 +5495,7 @@ static void drm_parse_cea_ext(struct drm_connector *connector, } drm_edid_iter_end(&edid_iter); - cea_db_iter_edid_begin(edid, &iter); + cea_db_iter_edid_begin(drm_edid->edid, &iter); cea_db_iter_for_each(db, &iter) { /* FIXME: convert parsers to use struct cea_db */ const u8 *data = (const u8 *)db; @@ -5541,16 +5541,15 @@ void get_monitor_range(const struct detailed_timing *timing, monitor_range->max_vfreq = range->max_vfreq; } -static -void drm_get_monitor_range(struct drm_connector *connector, - const struct edid *edid) +static void drm_get_monitor_range(struct drm_connector *connector, + const struct drm_edid *drm_edid) { struct drm_display_info *info = &connector->display_info; - if (!version_greater(edid, 1, 1)) + if (!version_greater(drm_edid->edid, 1, 1)) return; - drm_for_each_detailed_block(edid, get_monitor_range, + drm_for_each_detailed_block(drm_edid->edid, get_monitor_range, &info->monitor_range); DRM_DEBUG_KMS("Supported Monitor Refresh rate range is %d Hz - %d Hz\n", @@ -5610,12 +5609,13 @@ static void drm_parse_vesa_mso_data(struct drm_connector *connector, info->mso_stream_count, info->mso_pixel_overlap); } -static void drm_update_mso(struct drm_connector *connector, const struct edid *edid) +static void drm_update_mso(struct drm_connector *connector, + const struct drm_edid *drm_edid) { const struct displayid_block *block; struct displayid_iter iter; - displayid_iter_edid_begin(edid, &iter); + displayid_iter_edid_begin(drm_edid->edid, &iter); displayid_iter_for_each(block, &iter) { if (block->tag == DATA_BLOCK_2_VENDOR_SPECIFIC) drm_parse_vesa_mso_data(connector, block); @@ -5654,18 +5654,20 @@ drm_reset_display_info(struct drm_connector *connector) info->mso_pixel_overlap = 0; } -u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid) +static u32 update_display_info(struct drm_connector *connector, + const struct drm_edid *drm_edid) { struct drm_display_info *info = &connector->display_info; + const struct edid *edid = drm_edid->edid; - u32 quirks = edid_get_quirks(edid); + u32 quirks = edid_get_quirks(drm_edid); drm_reset_display_info(connector); info->width_mm = edid->width_cm * 10; info->height_mm = edid->height_cm * 10; - drm_get_monitor_range(connector, edid); + drm_get_monitor_range(connector, drm_edid); if (edid->revision < 3) goto out; @@ -5674,7 +5676,7 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi goto out; info->color_formats |= DRM_COLOR_FORMAT_RGB444; - drm_parse_cea_ext(connector, edid); + drm_parse_cea_ext(connector, drm_edid); /* * Digital sink with "DFP 1.x compliant TMDS" according to EDID 1.3? @@ -5727,7 +5729,7 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi if (edid->features & DRM_EDID_FEATURE_RGB_YCRCB422) info->color_formats |= DRM_COLOR_FORMAT_YCBCR422; - drm_update_mso(connector, edid); + drm_update_mso(connector, drm_edid); out: if (quirks & EDID_QUIRK_NON_DESKTOP) { @@ -5739,6 +5741,14 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi return quirks; } +u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid) +{ + struct drm_edid drm_edid; + + return update_display_info(connector, + drm_edid_legacy_init(&drm_edid, edid)); +} + static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *dev, struct displayid_detailed_timings_1 *timings, bool type_7) @@ -5851,7 +5861,7 @@ static int drm_edid_connector_update(struct drm_connector *connector, * To avoid multiple parsing of same block, lets parse that map * from sink info, before parsing CEA modes. */ - quirks = drm_add_display_info(connector, edid); + quirks = update_display_info(connector, drm_edid); /* Depends on info->cea_rev set by drm_add_display_info() above */ drm_edid_to_eld(connector, edid); From patchwork Mon May 9 12:03:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843388 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 75771C433EF for ; Mon, 9 May 2022 12:04:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E7EE110EE7B; Mon, 9 May 2022 12:04:00 +0000 (UTC) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id BC27A10EE7B; Mon, 9 May 2022 12:03:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097839; x=1683633839; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vnNXBNxE0aNt8VeQiIpq51UIvY9/m5L7/30H2a8Tj+s=; b=fo+jQ9O6+bm3VSMmKQF0jT7Wxy/p31cwyvAuxr9xmUdDILZR85SQvH9H 3MXNDVeXhczGG62f2zQwPPpG8gWlTq9EQ7oEBoRmTHJUsBCCq8f15L3uj UDni0vK0DzC4rYH91rwOhp4Rb5WclFRz4j+rSYXGc4ho0yeiz7YjNbJlJ WP2vUr3HlqSVKobQLvuhibBhaN+6yny8VyE/v5mIWlJlzWcbyVPyd0bXS sB9O2lFkniMs8HCCWAMjjr3uLFb130s0IdCg3GCHsMYJn7npT+7P0vw72 PLo8DAWHj+SGvHjzlZ8JRWBGXYEp6GNGNr7SJNNxk5fJcDAT78HNsQESX w==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="269167462" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="269167462" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:03:59 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="696464289" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:03:57 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:05 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 06/25] drm/edid: propagate drm_edid to drm_edid_to_eld() 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" We'll need to propagate drm_edid everywhere. Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 96e3f9327044..e4fdf742645b 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -4883,13 +4883,13 @@ static void clear_eld(struct drm_connector *connector) /* * drm_edid_to_eld - build ELD from EDID * @connector: connector corresponding to the HDMI/DP sink - * @edid: EDID to parse + * @drm_edid: EDID to parse * * Fill the ELD (EDID-Like Data) buffer for passing to the audio driver. The * HDCP and Port_ID ELD fields are left for the graphics driver to fill in. */ static void drm_edid_to_eld(struct drm_connector *connector, - const struct edid *edid) + const struct drm_edid *drm_edid) { const struct drm_display_info *info = &connector->display_info; const struct cea_db *db; @@ -4900,10 +4900,10 @@ static void drm_edid_to_eld(struct drm_connector *connector, clear_eld(connector); - if (!edid) + if (!drm_edid) return; - mnl = get_monitor_name(edid, &eld[DRM_ELD_MONITOR_NAME_STRING]); + mnl = get_monitor_name(drm_edid->edid, &eld[DRM_ELD_MONITOR_NAME_STRING]); DRM_DEBUG_KMS("ELD monitor %s\n", &eld[DRM_ELD_MONITOR_NAME_STRING]); eld[DRM_ELD_CEA_EDID_VER_MNL] = info->cea_rev << DRM_ELD_CEA_EDID_VER_SHIFT; @@ -4911,12 +4911,12 @@ static void drm_edid_to_eld(struct drm_connector *connector, eld[DRM_ELD_VER] = DRM_ELD_VER_CEA861D; - eld[DRM_ELD_MANUFACTURER_NAME0] = edid->mfg_id[0]; - eld[DRM_ELD_MANUFACTURER_NAME1] = edid->mfg_id[1]; - eld[DRM_ELD_PRODUCT_CODE0] = edid->prod_code[0]; - eld[DRM_ELD_PRODUCT_CODE1] = edid->prod_code[1]; + eld[DRM_ELD_MANUFACTURER_NAME0] = drm_edid->edid->mfg_id[0]; + eld[DRM_ELD_MANUFACTURER_NAME1] = drm_edid->edid->mfg_id[1]; + eld[DRM_ELD_PRODUCT_CODE0] = drm_edid->edid->prod_code[0]; + eld[DRM_ELD_PRODUCT_CODE1] = drm_edid->edid->prod_code[1]; - cea_db_iter_edid_begin(edid, &iter); + cea_db_iter_edid_begin(drm_edid->edid, &iter); cea_db_iter_for_each(db, &iter) { const u8 *data = cea_db_data(db); int len = cea_db_payload_len(db); @@ -5864,7 +5864,7 @@ static int drm_edid_connector_update(struct drm_connector *connector, quirks = update_display_info(connector, drm_edid); /* Depends on info->cea_rev set by drm_add_display_info() above */ - drm_edid_to_eld(connector, edid); + drm_edid_to_eld(connector, drm_edid); /* * EDID spec says modes should be preferred in this order: From patchwork Mon May 9 12:03:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843389 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 54A77C433EF for ; Mon, 9 May 2022 12:04:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C03B210EE80; Mon, 9 May 2022 12:04:07 +0000 (UTC) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1D23010EE80; Mon, 9 May 2022 12:04:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097846; x=1683633846; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9+JmVTDQNVacTE6RcaVVgM0oj2YDTMjAWcxi2cF+47A=; b=TAui6V28PrUUB8qpu33Vp+yaObs5wVF86Xi/bSqCi29Nwx+j+6OFU49H HqhCuI+llIo53WJHHXWc17Ljyy/l7uq5Jx2HOypBD4BoivJc3q9GRpUjG RymwkSwNfDetCL9mp6je6a60HK2bl0W/SvnZmZhPi8J16pqZU/Rowa1yq oAI67eHYof/RU2C3L+p1xywrxrQrjkZ0Xs95rltQoHWwGrRzSz2q1MdvE PVcBjxhgRYtnJG3LUtCVIvaFrRPI18uFDUfRPXnqPLwjuPjp3ku4TVQvI ozV596nXYxyCMlr217Yyi0EgqxXvYiXObIyqjgXftuCDuCtYyEj5uAKox Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="329622740" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="329622740" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:05 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="519195069" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:03 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:06 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 07/25] drm/edid: convert drm_edid_connector_update() to drm_edid fully 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" We'll need to propagate drm_edid everywhere. Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 95 ++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 49 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index e4fdf742645b..f54699422bca 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3253,16 +3253,16 @@ do_inferred_modes(const struct detailed_timing *timing, void *c) } } -static int -add_inferred_modes(struct drm_connector *connector, const struct edid *edid) +static int add_inferred_modes(struct drm_connector *connector, + const struct drm_edid *drm_edid) { struct detailed_mode_closure closure = { .connector = connector, - .edid = edid, + .edid = drm_edid->edid, }; - if (version_greater(edid, 1, 0)) - drm_for_each_detailed_block(edid, do_inferred_modes, &closure); + if (version_greater(drm_edid->edid, 1, 0)) + drm_for_each_detailed_block(drm_edid->edid, do_inferred_modes, &closure); return closure.modes; } @@ -3312,10 +3312,11 @@ do_established_modes(const struct detailed_timing *timing, void *c) * bitmap of the supported "established modes" list (defined above). Tease them * out and add them to the global modes list. */ -static int -add_established_modes(struct drm_connector *connector, const struct edid *edid) +static int add_established_modes(struct drm_connector *connector, + const struct drm_edid *drm_edid) { struct drm_device *dev = connector->dev; + const struct edid *edid = drm_edid->edid; unsigned long est_bits = edid->established_timings.t1 | (edid->established_timings.t2 << 8) | ((edid->established_timings.mfg_rsvd & 0x80) << 9); @@ -3338,7 +3339,7 @@ add_established_modes(struct drm_connector *connector, const struct edid *edid) } if (version_greater(edid, 1, 0)) - drm_for_each_detailed_block(edid, do_established_modes, + drm_for_each_detailed_block(drm_edid->edid, do_established_modes, &closure); return modes + closure.modes; @@ -3373,28 +3374,28 @@ do_standard_modes(const struct detailed_timing *timing, void *c) * using the appropriate standard (DMT, GTF, or CVT). Grab them from EDID and * add them to the list. */ -static int -add_standard_modes(struct drm_connector *connector, const struct edid *edid) +static int add_standard_modes(struct drm_connector *connector, + const struct drm_edid *drm_edid) { int i, modes = 0; struct detailed_mode_closure closure = { .connector = connector, - .edid = edid, + .edid = drm_edid->edid, }; for (i = 0; i < EDID_STD_TIMINGS; i++) { struct drm_display_mode *newmode; - newmode = drm_mode_std(connector, edid, - &edid->standard_timings[i]); + newmode = drm_mode_std(connector, drm_edid->edid, + &drm_edid->edid->standard_timings[i]); if (newmode) { drm_mode_probed_add(connector, newmode); modes++; } } - if (version_greater(edid, 1, 0)) - drm_for_each_detailed_block(edid, do_standard_modes, + if (version_greater(drm_edid->edid, 1, 0)) + drm_for_each_detailed_block(drm_edid->edid, do_standard_modes, &closure); /* XXX should also look for standard codes in VTB blocks */ @@ -3466,15 +3467,15 @@ do_cvt_mode(const struct detailed_timing *timing, void *c) } static int -add_cvt_modes(struct drm_connector *connector, const struct edid *edid) +add_cvt_modes(struct drm_connector *connector, const struct drm_edid *drm_edid) { struct detailed_mode_closure closure = { .connector = connector, - .edid = edid, + .edid = drm_edid->edid, }; - if (version_greater(edid, 1, 2)) - drm_for_each_detailed_block(edid, do_cvt_mode, &closure); + if (version_greater(drm_edid->edid, 1, 2)) + drm_for_each_detailed_block(drm_edid->edid, do_cvt_mode, &closure); /* XXX should also look for CVT codes in VTB blocks */ @@ -3519,22 +3520,21 @@ do_detailed_mode(const struct detailed_timing *timing, void *c) * @edid: EDID block to scan * @quirks: quirks to apply */ -static int -add_detailed_modes(struct drm_connector *connector, const struct edid *edid, - u32 quirks) +static int add_detailed_modes(struct drm_connector *connector, + const struct drm_edid *drm_edid, u32 quirks) { struct detailed_mode_closure closure = { .connector = connector, - .edid = edid, + .edid = drm_edid->edid, .preferred = true, .quirks = quirks, }; - if (closure.preferred && !version_greater(edid, 1, 3)) + if (closure.preferred && !version_greater(drm_edid->edid, 1, 3)) closure.preferred = - (edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING); + (drm_edid->edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING); - drm_for_each_detailed_block(edid, do_detailed_mode, &closure); + drm_for_each_detailed_block(drm_edid->edid, do_detailed_mode, &closure); return closure.modes; } @@ -3588,7 +3588,7 @@ const u8 *drm_find_edid_extension(const struct edid *edid, } /* Return true if the EDID has a CTA extension or a DisplayID CTA data block */ -static bool drm_edid_has_cta_extension(const struct edid *edid) +static bool drm_edid_has_cta_extension(const struct drm_edid *drm_edid) { const struct displayid_block *block; struct displayid_iter iter; @@ -3596,11 +3596,11 @@ static bool drm_edid_has_cta_extension(const struct edid *edid) bool found = false; /* Look for a top level CEA extension block */ - if (drm_find_edid_extension(edid, CEA_EXT, &ext_index)) + if (drm_find_edid_extension(drm_edid->edid, CEA_EXT, &ext_index)) return true; /* CEA blocks can also be found embedded in a DisplayID block */ - displayid_iter_edid_begin(edid, &iter); + displayid_iter_edid_begin(drm_edid->edid, &iter); displayid_iter_for_each(block, &iter) { if (block->tag == DATA_BLOCK_CTA) { found = true; @@ -3874,8 +3874,8 @@ static bool drm_valid_hdmi_vic(u8 vic) return vic > 0 && vic < ARRAY_SIZE(edid_4k_modes); } -static int -add_alternate_cea_modes(struct drm_connector *connector, const struct edid *edid) +static int add_alternate_cea_modes(struct drm_connector *connector, + const struct drm_edid *drm_edid) { struct drm_device *dev = connector->dev; struct drm_display_mode *mode, *tmp; @@ -3883,7 +3883,7 @@ add_alternate_cea_modes(struct drm_connector *connector, const struct edid *edid int modes = 0; /* Don't add CTA modes if the CTA extension block is missing */ - if (!drm_edid_has_cta_extension(edid)) + if (!drm_edid_has_cta_extension(drm_edid)) return 0; /* @@ -4666,14 +4666,14 @@ static void drm_parse_y420cmdb_bitmap(struct drm_connector *connector, hdmi->y420_cmdb_map = map; } -static int -add_cea_modes(struct drm_connector *connector, const struct edid *edid) +static int add_cea_modes(struct drm_connector *connector, + const struct drm_edid *drm_edid) { const struct cea_db *db; struct cea_db_iter iter; int modes = 0; - cea_db_iter_edid_begin(edid, &iter); + cea_db_iter_edid_begin(drm_edid->edid, &iter); cea_db_iter_for_each(db, &iter) { const u8 *hdmi = NULL, *video = NULL; u8 hdmi_len = 0, video_len = 0; @@ -5824,13 +5824,13 @@ static int add_displayid_detailed_1_modes(struct drm_connector *connector, } static int add_displayid_detailed_modes(struct drm_connector *connector, - const struct edid *edid) + const struct drm_edid *drm_edid) { const struct displayid_block *block; struct displayid_iter iter; int num_modes = 0; - displayid_iter_edid_begin(edid, &iter); + displayid_iter_edid_begin(drm_edid->edid, &iter); displayid_iter_for_each(block, &iter) { if (block->tag == DATA_BLOCK_TYPE_1_DETAILED_TIMING || block->tag == DATA_BLOCK_2_TYPE_7_DETAILED_TIMING) @@ -5844,7 +5844,6 @@ static int add_displayid_detailed_modes(struct drm_connector *connector, static int drm_edid_connector_update(struct drm_connector *connector, const struct drm_edid *drm_edid) { - const struct edid *edid; int num_modes = 0; u32 quirks; @@ -5854,8 +5853,6 @@ static int drm_edid_connector_update(struct drm_connector *connector, return 0; } - edid = drm_edid->edid; - /* * CEA-861-F adds ycbcr capability map block, for HDMI 2.0 sinks. * To avoid multiple parsing of same block, lets parse that map @@ -5880,15 +5877,15 @@ static int drm_edid_connector_update(struct drm_connector *connector, * * XXX order for additional mode types in extension blocks? */ - num_modes += add_detailed_modes(connector, edid, quirks); - num_modes += add_cvt_modes(connector, edid); - num_modes += add_standard_modes(connector, edid); - num_modes += add_established_modes(connector, edid); - num_modes += add_cea_modes(connector, edid); - num_modes += add_alternate_cea_modes(connector, edid); - num_modes += add_displayid_detailed_modes(connector, edid); - if (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF) - num_modes += add_inferred_modes(connector, edid); + num_modes += add_detailed_modes(connector, drm_edid, quirks); + num_modes += add_cvt_modes(connector, drm_edid); + num_modes += add_standard_modes(connector, drm_edid); + num_modes += add_established_modes(connector, drm_edid); + num_modes += add_cea_modes(connector, drm_edid); + num_modes += add_alternate_cea_modes(connector, drm_edid); + num_modes += add_displayid_detailed_modes(connector, drm_edid); + if (drm_edid->edid->features & DRM_EDID_FEATURE_DEFAULT_GTF) + num_modes += add_inferred_modes(connector, drm_edid); if (quirks & (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75)) edid_fixup_preferred(connector, quirks); From patchwork Mon May 9 12:03:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843393 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 ABB44C433EF for ; Mon, 9 May 2022 12:04:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D9FA410EEBF; Mon, 9 May 2022 12:04:29 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 320F110EE94; Mon, 9 May 2022 12:04:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097866; x=1683633866; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sqTfDA6od/vzBsvfTa88yJL0XJ4ZCW0ZxL65nRgKaK0=; b=WRjDaSH1yZAArnLR4YmG9UoqkORQuhxIkhYTMlkR0Ume2FjvPLyrDaCw xQpXuUr3hzyjpmDOMuV/O8KH1PR5lCn97bfIEsuAhtyFOF2eeRFzKw9rK voAffXU6ueWw8UNzWE/++tVmCVXUlAkrr09gbzmS0MMrbDaRTMTH9LJCx nBHoZFXiZU3y12n6+ROwfic0dwyPUoTJWRPwfZapb+i912q5Osu+3kK6M 0axKRKOtLe1lQNqf28j6dJy0vpdixbqiI2BZg5epEZIEg1LbYGHyV5zxl /py8V4FmHYpL3OFIv9BCAwthxHjXHLFrPAWuIfgO9dgAsgknauf5Cg8Zp Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="268958042" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="268958042" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:11 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="550993008" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:09 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:07 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 08/25] drm/edid: convert struct detailed_mode_closure to drm_edid 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" We'll need to propagate drm_edid everywhere. Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index f54699422bca..c2887012add0 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -96,7 +96,7 @@ static int oui(u8 first, u8 second, u8 third) struct detailed_mode_closure { struct drm_connector *connector; - const struct edid *edid; + const struct drm_edid *drm_edid; bool preferred; u32 quirks; int modes; @@ -3226,25 +3226,25 @@ do_inferred_modes(const struct detailed_timing *timing, void *c) return; closure->modes += drm_dmt_modes_for_range(closure->connector, - closure->edid, + closure->drm_edid->edid, timing); - if (!version_greater(closure->edid, 1, 1)) + if (!version_greater(closure->drm_edid->edid, 1, 1)) return; /* GTF not defined yet */ switch (range->flags) { case 0x02: /* secondary gtf, XXX could do more */ case 0x00: /* default gtf */ closure->modes += drm_gtf_modes_for_range(closure->connector, - closure->edid, + closure->drm_edid->edid, timing); break; case 0x04: /* cvt, only in 1.4+ */ - if (!version_greater(closure->edid, 1, 3)) + if (!version_greater(closure->drm_edid->edid, 1, 3)) break; closure->modes += drm_cvt_modes_for_range(closure->connector, - closure->edid, + closure->drm_edid->edid, timing); break; case 0x01: /* just the ranges, no formula */ @@ -3258,7 +3258,7 @@ static int add_inferred_modes(struct drm_connector *connector, { struct detailed_mode_closure closure = { .connector = connector, - .edid = drm_edid->edid, + .drm_edid = drm_edid, }; if (version_greater(drm_edid->edid, 1, 0)) @@ -3323,7 +3323,7 @@ static int add_established_modes(struct drm_connector *connector, int i, modes = 0; struct detailed_mode_closure closure = { .connector = connector, - .edid = edid, + .drm_edid = drm_edid, }; for (i = 0; i <= EDID_EST_TIMINGS; i++) { @@ -3351,7 +3351,6 @@ do_standard_modes(const struct detailed_timing *timing, void *c) struct detailed_mode_closure *closure = c; const struct detailed_non_pixel *data = &timing->data.other_data; struct drm_connector *connector = closure->connector; - const struct edid *edid = closure->edid; int i; if (!is_display_descriptor(timing, EDID_DETAIL_STD_MODES)) @@ -3361,7 +3360,7 @@ do_standard_modes(const struct detailed_timing *timing, void *c) const struct std_timing *std = &data->data.timings[i]; struct drm_display_mode *newmode; - newmode = drm_mode_std(connector, edid, std); + newmode = drm_mode_std(connector, closure->drm_edid->edid, std); if (newmode) { drm_mode_probed_add(connector, newmode); closure->modes++; @@ -3380,7 +3379,7 @@ static int add_standard_modes(struct drm_connector *connector, int i, modes = 0; struct detailed_mode_closure closure = { .connector = connector, - .edid = drm_edid->edid, + .drm_edid = drm_edid, }; for (i = 0; i < EDID_STD_TIMINGS; i++) { @@ -3471,7 +3470,7 @@ add_cvt_modes(struct drm_connector *connector, const struct drm_edid *drm_edid) { struct detailed_mode_closure closure = { .connector = connector, - .edid = drm_edid->edid, + .drm_edid = drm_edid, }; if (version_greater(drm_edid->edid, 1, 2)) @@ -3494,7 +3493,7 @@ do_detailed_mode(const struct detailed_timing *timing, void *c) return; newmode = drm_mode_detailed(closure->connector->dev, - closure->edid, timing, + closure->drm_edid->edid, timing, closure->quirks); if (!newmode) return; @@ -3525,7 +3524,7 @@ static int add_detailed_modes(struct drm_connector *connector, { struct detailed_mode_closure closure = { .connector = connector, - .edid = drm_edid->edid, + .drm_edid = drm_edid, .preferred = true, .quirks = quirks, }; From patchwork Mon May 9 12:03:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843390 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 E7281C433F5 for ; Mon, 9 May 2022 12:04:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 691FA10E487; Mon, 9 May 2022 12:04:17 +0000 (UTC) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 76B2F10EE90; Mon, 9 May 2022 12:04:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097856; x=1683633856; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wtfG02UbYRHP0rHfM0XwTThLqP0C5LUYodFejnkxU/k=; b=RTZ9qltEQGMmzJt6/35q4Eq6SKp7kc2GIInbIUw+ONry4BYxdJt8tu+1 QudNmpXKo0KMEKsYTgnHgG0SwsOKKdfMrYMRGm/A7ANj1ihjmtth6XkSM fv6tSwTMn/ZZ83W10Rl/Q6lpRgt72279cbEwXs2zlUtfmxWSrkMS+Bz4D XhVAQzpaRrOMmekOjcKCWhbtTprJ4Fu3sL/PQDZv+QJBLUxbxke1X4wKB PjeK3OtBmQBffHGnZhyHAeRuvvGyRn6hjXlaFCvmagcjhd7h3dphed92Z B4G5gN+OUbJnYKMnxQ1nt5WsrbxgyaWZuD4xmyRjd6c9Umd4+1dOP4hTR g==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="355456644" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="355456644" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:16 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="601935231" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:14 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:08 +0300 Message-Id: <6e4625d529ee4bfb2f6ebbfef5fb707d65a0554d.1652097712.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 09/25] drm/edid: convert drm_mode_detailed() to drm_edid 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" We'll need to propagate drm_edid everywhere. Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index c2887012add0..8acdb08a8571 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2928,7 +2928,7 @@ drm_mode_do_interlace_quirk(struct drm_display_mode *mode, * drm_display_mode. */ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev, - const struct edid *edid, + const struct drm_edid *drm_edid, const struct detailed_timing *timing, u32 quirks) { @@ -3016,8 +3016,8 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev, } if (quirks & EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE) { - mode->width_mm = edid->width_cm * 10; - mode->height_mm = edid->height_cm * 10; + mode->width_mm = drm_edid->edid->width_cm * 10; + mode->height_mm = drm_edid->edid->height_cm * 10; } mode->type = DRM_MODE_TYPE_DRIVER; @@ -3493,7 +3493,7 @@ do_detailed_mode(const struct detailed_timing *timing, void *c) return; newmode = drm_mode_detailed(closure->connector->dev, - closure->drm_edid->edid, timing, + closure->drm_edid, timing, closure->quirks); if (!newmode) return; From patchwork Mon May 9 12:03:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843391 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 1D221C433EF for ; Mon, 9 May 2022 12:04:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 29AF710EE91; Mon, 9 May 2022 12:04:23 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id B2B8210EE35; Mon, 9 May 2022 12:04:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097861; x=1683633861; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3gh1qeGaKZJIKdHf+x0jY08FUOydLVhyY74+iQcK1Sw=; b=SvN6Ogyj1eu8SWt2+NmoPcaT6/PxVij8iPAzFx8HZ+YiVj2aQM/t9kQb CEj+PJbm9UHGiN/NNfhsdDFXYZi9+tzaUyaVQAG4HW86uih/KWuTidIot IQMV2Lp27eqFdjJuzbnv+toNYdpoFE8jvKDbjjf4NyqemrTRSZR0z4Z48 5sFkfqubRBKmtRo6SxUbHM1LDhy6GV+bkM8dYvGaNmv9oUJ7u1wl6DrkM LQEN3eCd3frcJySFK2jGRS0lrY1KBURCcILXDDRK0GXPPc6NymcqoHROn FHfAUvBuzkelJDvu7RtbD0luwzMAI+66aZtQ/epwgX077n3Z+PL2Y1ma1 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="266618254" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="266618254" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:21 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="738134742" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:19 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:09 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 10/25] drm/edid: convert drm_dmt_modes_for_range() to drm_edid 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" We'll need to propagate drm_edid everywhere. Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 8acdb08a8571..5d8744a7b62e 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3121,16 +3121,16 @@ static bool valid_inferred_mode(const struct drm_connector *connector, return ok; } -static int -drm_dmt_modes_for_range(struct drm_connector *connector, const struct edid *edid, - const struct detailed_timing *timing) +static int drm_dmt_modes_for_range(struct drm_connector *connector, + const struct drm_edid *drm_edid, + const struct detailed_timing *timing) { int i, modes = 0; struct drm_display_mode *newmode; struct drm_device *dev = connector->dev; for (i = 0; i < ARRAY_SIZE(drm_dmt_modes); i++) { - if (mode_in_range(drm_dmt_modes + i, edid, timing) && + if (mode_in_range(drm_dmt_modes + i, drm_edid->edid, timing) && valid_inferred_mode(connector, drm_dmt_modes + i)) { newmode = drm_mode_duplicate(dev, &drm_dmt_modes[i]); if (newmode) { @@ -3226,7 +3226,7 @@ do_inferred_modes(const struct detailed_timing *timing, void *c) return; closure->modes += drm_dmt_modes_for_range(closure->connector, - closure->drm_edid->edid, + closure->drm_edid, timing); if (!version_greater(closure->drm_edid->edid, 1, 1)) From patchwork Mon May 9 12:03:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843392 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 5AD59C433F5 for ; Mon, 9 May 2022 12:04:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B02C610EE94; Mon, 9 May 2022 12:04:27 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 66C9410EE9E; Mon, 9 May 2022 12:04:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097866; x=1683633866; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5yHaI1nKrawDEghgxdQlWaGJ28fwoT1Eyj30sB3mVOA=; b=JaqiG7pQw8K7YNm+troVuF02fnYQW44RHx9pTS583Hdzqi36S5vy/Qke htTP08pnXqPQc64zbyKjASNVp8QZ9lN7akKOzJDEFNotZtzyCzKLJb28T tkjGwbSPY9R9L8K8u9Q94jm6mcyqG30/+q9ebhmHGnAQLR9Q62SVZwYBh Sxf83dY0TDYdJOxytHmJ2ZJ/7aQT1OpfqqnlgO6vS0/M81dZcPioL4OPA OFOn6TZCf2Uxvs3gY46pxQPdeq/22h1kCplHgJYZhPuiYYNwvnjJQZIfp eM6n1Dz6Zb1Ugfn3WAXg+8/EE6BqpmWhyHTCFwcFSKNJxVqLFlmigwsv5 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="268693437" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="268693437" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:26 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="696464671" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:24 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:10 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 11/25] drm/edid: convert drm_gtf_modes_for_range() to drm_edid 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" We'll need to propagate drm_edid everywhere. Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 5d8744a7b62e..037102a4d0b5 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3156,9 +3156,9 @@ void drm_mode_fixup_1366x768(struct drm_display_mode *mode) } } -static int -drm_gtf_modes_for_range(struct drm_connector *connector, const struct edid *edid, - const struct detailed_timing *timing) +static int drm_gtf_modes_for_range(struct drm_connector *connector, + const struct drm_edid *drm_edid, + const struct detailed_timing *timing) { int i, modes = 0; struct drm_display_mode *newmode; @@ -3172,7 +3172,7 @@ drm_gtf_modes_for_range(struct drm_connector *connector, const struct edid *edid return modes; drm_mode_fixup_1366x768(newmode); - if (!mode_in_range(newmode, edid, timing) || + if (!mode_in_range(newmode, drm_edid->edid, timing) || !valid_inferred_mode(connector, newmode)) { drm_mode_destroy(dev, newmode); continue; @@ -3236,7 +3236,7 @@ do_inferred_modes(const struct detailed_timing *timing, void *c) case 0x02: /* secondary gtf, XXX could do more */ case 0x00: /* default gtf */ closure->modes += drm_gtf_modes_for_range(closure->connector, - closure->drm_edid->edid, + closure->drm_edid, timing); break; case 0x04: /* cvt, only in 1.4+ */ From patchwork Mon May 9 12:03:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843394 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 82590C433F5 for ; Mon, 9 May 2022 12:04:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1B2EB10EEA6; Mon, 9 May 2022 12:04:36 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0830A10EEB6; Mon, 9 May 2022 12:04:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097875; x=1683633875; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Yazu71PAC8XEBhLVbfq25r8P51wcfXsSqbmFGiVVO7c=; b=iv5K3aMcJsAWZQbcgHMZx5tAy0EDAvhNA1XWlIGjHagA4JGqW9OAWRr7 2TzMtRlve+/XrEwgX0bM+iF4bCnAtWFTy1pjy63P8Py/42jvgZ1HIG3MR 5GqEDgSEH4pvHZR/9S83zvPX09bnIZE8wGR/SbDbVc1j4skks+Tu3nwmZ OzlcrAWJlImYtuQbRh5qGR21X8U8pyFlsbXv+NEjtRqO1oxzh0e6gNN1l eiKJ8FvwKVwPayrwibk5KHksbnw2fRXjE6qMIcExPH1DILa3HgDc4caxW GOD2wgy6gSYILqZMbjzc8ppzuGUoxk7h/3oCrWl/wugtvHUvyqmKDI6oK A==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="268693526" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="268693526" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:34 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="656731905" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:32 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:11 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 12/25] drm/edid: convert drm_cvt_modes_for_range() to drm_edid 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" We'll need to propagate drm_edid everywhere. Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 037102a4d0b5..51d918c66a26 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3185,14 +3185,14 @@ static int drm_gtf_modes_for_range(struct drm_connector *connector, return modes; } -static int -drm_cvt_modes_for_range(struct drm_connector *connector, const struct edid *edid, - const struct detailed_timing *timing) +static int drm_cvt_modes_for_range(struct drm_connector *connector, + const struct drm_edid *drm_edid, + const struct detailed_timing *timing) { int i, modes = 0; struct drm_display_mode *newmode; struct drm_device *dev = connector->dev; - bool rb = drm_monitor_supports_rb(edid); + bool rb = drm_monitor_supports_rb(drm_edid->edid); for (i = 0; i < ARRAY_SIZE(extra_modes); i++) { const struct minimode *m = &extra_modes[i]; @@ -3202,7 +3202,7 @@ drm_cvt_modes_for_range(struct drm_connector *connector, const struct edid *edid return modes; drm_mode_fixup_1366x768(newmode); - if (!mode_in_range(newmode, edid, timing) || + if (!mode_in_range(newmode, drm_edid->edid, timing) || !valid_inferred_mode(connector, newmode)) { drm_mode_destroy(dev, newmode); continue; @@ -3244,7 +3244,7 @@ do_inferred_modes(const struct detailed_timing *timing, void *c) break; closure->modes += drm_cvt_modes_for_range(closure->connector, - closure->drm_edid->edid, + closure->drm_edid, timing); break; case 0x01: /* just the ranges, no formula */ From patchwork Mon May 9 12:03:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843395 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 593E6C433EF for ; Mon, 9 May 2022 12:04:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BF17D10EEB8; Mon, 9 May 2022 12:04:40 +0000 (UTC) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6057710EEC2; Mon, 9 May 2022 12:04:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097879; x=1683633879; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6KiU8gOfrG3whqxXGyEQLj8ELtFqtVdqqBIwfFlQhOY=; b=XSGoXZ/PT9/qysRYc/fzyiZ6jYc4sOKWmqrcCLqfZhbuQXjF6qgM+2p7 0wRFyogRfntTZVkA9dsjjeCeddMsPTKP+QtmDIsI0bxDaCOb+SbbfdOs3 4R45gE+XA/h+Hs9cF6694blSUuFwa7HZLGa6yrzGfi/s+UuUzReF11hbA ecNFaZVz0vpLhtE3HxZ10baLN76F+1cAiNIMUfRTKGfSjUjFsZeLKK8gl 5h9ECy/3gcmuXaT+tE3IfC7KWV7ldu0PCeVG/LDO08y4dkgksHXLIME68 IOx68sq2/XG57yqzKHqDK2gH/Hp3gPs8Fu452Vda1ViDWWckmjmiOA1zw w==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="355456752" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="355456752" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:38 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="519195402" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:36 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:12 +0300 Message-Id: <9fb970d108a8bb666b87a590c74f480e0fd81cc8.1652097712.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 13/25] drm/edid: convert drm_mode_std() and children to drm_edid 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" We'll need to propagate drm_edid everywhere. Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 52 ++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 51d918c66a26..bea8f33c58ad 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2673,11 +2673,11 @@ find_gtf2(const struct detailed_timing *descriptor, void *data) /* Secondary GTF curve kicks in above some break frequency */ static int -drm_gtf2_hbreak(const struct edid *edid) +drm_gtf2_hbreak(const struct drm_edid *drm_edid) { const struct detailed_timing *descriptor = NULL; - drm_for_each_detailed_block(edid, find_gtf2, &descriptor); + drm_for_each_detailed_block(drm_edid->edid, find_gtf2, &descriptor); BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.gtf2.hfreq_start_khz) != 12); @@ -2685,11 +2685,11 @@ drm_gtf2_hbreak(const struct edid *edid) } static int -drm_gtf2_2c(const struct edid *edid) +drm_gtf2_2c(const struct drm_edid *drm_edid) { const struct detailed_timing *descriptor = NULL; - drm_for_each_detailed_block(edid, find_gtf2, &descriptor); + drm_for_each_detailed_block(drm_edid->edid, find_gtf2, &descriptor); BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.gtf2.c) != 13); @@ -2697,11 +2697,11 @@ drm_gtf2_2c(const struct edid *edid) } static int -drm_gtf2_m(const struct edid *edid) +drm_gtf2_m(const struct drm_edid *drm_edid) { const struct detailed_timing *descriptor = NULL; - drm_for_each_detailed_block(edid, find_gtf2, &descriptor); + drm_for_each_detailed_block(drm_edid->edid, find_gtf2, &descriptor); BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.gtf2.m) != 14); @@ -2709,11 +2709,11 @@ drm_gtf2_m(const struct edid *edid) } static int -drm_gtf2_k(const struct edid *edid) +drm_gtf2_k(const struct drm_edid *drm_edid) { const struct detailed_timing *descriptor = NULL; - drm_for_each_detailed_block(edid, find_gtf2, &descriptor); + drm_for_each_detailed_block(drm_edid->edid, find_gtf2, &descriptor); BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.gtf2.k) != 16); @@ -2721,11 +2721,11 @@ drm_gtf2_k(const struct edid *edid) } static int -drm_gtf2_2j(const struct edid *edid) +drm_gtf2_2j(const struct drm_edid *drm_edid) { const struct detailed_timing *descriptor = NULL; - drm_for_each_detailed_block(edid, find_gtf2, &descriptor); + drm_for_each_detailed_block(drm_edid->edid, find_gtf2, &descriptor); BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.gtf2.j) != 17); @@ -2733,12 +2733,14 @@ drm_gtf2_2j(const struct edid *edid) } /* Get standard timing level (CVT/GTF/DMT). */ -static int standard_timing_level(const struct edid *edid) +static int standard_timing_level(const struct drm_edid *drm_edid) { + const struct edid *edid = drm_edid->edid; + if (edid->revision >= 2) { if (edid->revision >= 4 && (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF)) return LEVEL_CVT; - if (drm_gtf2_hbreak(edid)) + if (drm_gtf2_hbreak(drm_edid)) return LEVEL_GTF2; if (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF) return LEVEL_GTF; @@ -2770,9 +2772,9 @@ static int drm_mode_hsync(const struct drm_display_mode *mode) * Take the standard timing params (in this case width, aspect, and refresh) * and convert them into a real mode using CVT/GTF/DMT. */ -static struct drm_display_mode * -drm_mode_std(struct drm_connector *connector, const struct edid *edid, - const struct std_timing *t) +static struct drm_display_mode *drm_mode_std(struct drm_connector *connector, + const struct drm_edid *drm_edid, + const struct std_timing *t) { struct drm_device *dev = connector->dev; struct drm_display_mode *m, *mode = NULL; @@ -2782,7 +2784,7 @@ drm_mode_std(struct drm_connector *connector, const struct edid *edid, >> EDID_TIMING_ASPECT_SHIFT; unsigned vfreq = (t->vfreq_aspect & EDID_TIMING_VFREQ_MASK) >> EDID_TIMING_VFREQ_SHIFT; - int timing_level = standard_timing_level(edid); + int timing_level = standard_timing_level(drm_edid); if (bad_std_timing(t->hsize, t->vfreq_aspect)) return NULL; @@ -2793,7 +2795,7 @@ drm_mode_std(struct drm_connector *connector, const struct edid *edid, vrefresh_rate = vfreq + 60; /* the vdisplay is calculated based on the aspect ratio */ if (aspect_ratio == 0) { - if (edid->revision < 3) + if (drm_edid->edid->revision < 3) vsize = hsize; else vsize = (hsize * 10) / 16; @@ -2836,7 +2838,7 @@ drm_mode_std(struct drm_connector *connector, const struct edid *edid, } /* check whether it can be found in default mode table */ - if (drm_monitor_supports_rb(edid)) { + if (drm_monitor_supports_rb(drm_edid->edid)) { mode = drm_mode_find_dmt(dev, hsize, vsize, vrefresh_rate, true); if (mode) @@ -2862,14 +2864,14 @@ drm_mode_std(struct drm_connector *connector, const struct edid *edid, mode = drm_gtf_mode(dev, hsize, vsize, vrefresh_rate, 0, 0); if (!mode) return NULL; - if (drm_mode_hsync(mode) > drm_gtf2_hbreak(edid)) { + if (drm_mode_hsync(mode) > drm_gtf2_hbreak(drm_edid)) { drm_mode_destroy(dev, mode); mode = drm_gtf_mode_complex(dev, hsize, vsize, vrefresh_rate, 0, 0, - drm_gtf2_m(edid), - drm_gtf2_2c(edid), - drm_gtf2_k(edid), - drm_gtf2_2j(edid)); + drm_gtf2_m(drm_edid), + drm_gtf2_2c(drm_edid), + drm_gtf2_k(drm_edid), + drm_gtf2_2j(drm_edid)); } break; case LEVEL_CVT: @@ -3360,7 +3362,7 @@ do_standard_modes(const struct detailed_timing *timing, void *c) const struct std_timing *std = &data->data.timings[i]; struct drm_display_mode *newmode; - newmode = drm_mode_std(connector, closure->drm_edid->edid, std); + newmode = drm_mode_std(connector, closure->drm_edid, std); if (newmode) { drm_mode_probed_add(connector, newmode); closure->modes++; @@ -3385,7 +3387,7 @@ static int add_standard_modes(struct drm_connector *connector, for (i = 0; i < EDID_STD_TIMINGS; i++) { struct drm_display_mode *newmode; - newmode = drm_mode_std(connector, drm_edid->edid, + newmode = drm_mode_std(connector, drm_edid, &drm_edid->edid->standard_timings[i]); if (newmode) { drm_mode_probed_add(connector, newmode); From patchwork Mon May 9 12:03:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843396 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 6EC31C433EF for ; Mon, 9 May 2022 12:04:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4586510EEE5; Mon, 9 May 2022 12:04:45 +0000 (UTC) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 661BB10EEE0; Mon, 9 May 2022 12:04:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097884; x=1683633884; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kOyXWZinlsi4z3i9F7AOiRllbEsMh4HdMJuUcE6zefs=; b=ew+rAQZtegbzspzE1UIUmuZLFt1yelpd4wpJPkHC4U6wC0fKcj1PvD/D NUX3vlHkrk6SEIuEmIbLPKVy2xmQQHOfQsFZtlTxWUu5ORlfSPeJGi9wi eDhV8VseViAiCD3DoBtRXCo8J/gZX4/evp8DPvmiCHoSTRoe0hYtPitY5 3vIIXP3w0CklcFAhXn3RxANBfOMqi2VNok7OPXIKFGfCUI1MIi5M2iNw4 nbeRwCh+psH2HBLIGo9NCqnr8/jyszB863FjVkddE5YFQKuE1/MtLD0JT Gas+zYKpbr6IR/hubZdWCrCKRQdj9bh6ViiecUGSuAfW5uHckx7YyxgRQ Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="256563815" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="256563815" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:43 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="550993103" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:41 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:13 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 14/25] drm/edid: convert mode_in_range() and drm_monitor_supports_rb() to drm_edid 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" We'll need to propagate drm_edid everywhere. Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index bea8f33c58ad..364949e146a9 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2645,16 +2645,16 @@ is_rb(const struct detailed_timing *descriptor, void *data) /* EDID 1.4 defines this explicitly. For EDID 1.3, we guess, badly. */ static bool -drm_monitor_supports_rb(const struct edid *edid) +drm_monitor_supports_rb(const struct drm_edid *drm_edid) { - if (edid->revision >= 4) { + if (drm_edid->edid->revision >= 4) { bool ret = false; - drm_for_each_detailed_block(edid, is_rb, &ret); + drm_for_each_detailed_block(drm_edid->edid, is_rb, &ret); return ret; } - return ((edid->input & DRM_EDID_INPUT_DIGITAL) != 0); + return ((drm_edid->edid->input & DRM_EDID_INPUT_DIGITAL) != 0); } static void @@ -2838,7 +2838,7 @@ static struct drm_display_mode *drm_mode_std(struct drm_connector *connector, } /* check whether it can be found in default mode table */ - if (drm_monitor_supports_rb(drm_edid->edid)) { + if (drm_monitor_supports_rb(drm_edid)) { mode = drm_mode_find_dmt(dev, hsize, vsize, vrefresh_rate, true); if (mode) @@ -3077,10 +3077,11 @@ range_pixel_clock(const struct edid *edid, const u8 *t) return t[9] * 10000 + 5001; } -static bool -mode_in_range(const struct drm_display_mode *mode, const struct edid *edid, - const struct detailed_timing *timing) +static bool mode_in_range(const struct drm_display_mode *mode, + const struct drm_edid *drm_edid, + const struct detailed_timing *timing) { + const struct edid *edid = drm_edid->edid; u32 max_clock; const u8 *t = (const u8 *)timing; @@ -3099,7 +3100,7 @@ mode_in_range(const struct drm_display_mode *mode, const struct edid *edid, if (t[13] && mode->hdisplay > 8 * (t[13] + (256 * (t[12]&0x3)))) return false; - if (mode_is_rb(mode) && !drm_monitor_supports_rb(edid)) + if (mode_is_rb(mode) && !drm_monitor_supports_rb(drm_edid)) return false; return true; @@ -3132,7 +3133,7 @@ static int drm_dmt_modes_for_range(struct drm_connector *connector, struct drm_device *dev = connector->dev; for (i = 0; i < ARRAY_SIZE(drm_dmt_modes); i++) { - if (mode_in_range(drm_dmt_modes + i, drm_edid->edid, timing) && + if (mode_in_range(drm_dmt_modes + i, drm_edid, timing) && valid_inferred_mode(connector, drm_dmt_modes + i)) { newmode = drm_mode_duplicate(dev, &drm_dmt_modes[i]); if (newmode) { @@ -3174,7 +3175,7 @@ static int drm_gtf_modes_for_range(struct drm_connector *connector, return modes; drm_mode_fixup_1366x768(newmode); - if (!mode_in_range(newmode, drm_edid->edid, timing) || + if (!mode_in_range(newmode, drm_edid, timing) || !valid_inferred_mode(connector, newmode)) { drm_mode_destroy(dev, newmode); continue; @@ -3194,7 +3195,7 @@ static int drm_cvt_modes_for_range(struct drm_connector *connector, int i, modes = 0; struct drm_display_mode *newmode; struct drm_device *dev = connector->dev; - bool rb = drm_monitor_supports_rb(drm_edid->edid); + bool rb = drm_monitor_supports_rb(drm_edid); for (i = 0; i < ARRAY_SIZE(extra_modes); i++) { const struct minimode *m = &extra_modes[i]; @@ -3204,7 +3205,7 @@ static int drm_cvt_modes_for_range(struct drm_connector *connector, return modes; drm_mode_fixup_1366x768(newmode); - if (!mode_in_range(newmode, drm_edid->edid, timing) || + if (!mode_in_range(newmode, drm_edid, timing) || !valid_inferred_mode(connector, newmode)) { drm_mode_destroy(dev, newmode); continue; From patchwork Mon May 9 12:03:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843398 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 BEEC8C433F5 for ; Mon, 9 May 2022 12:05:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0BE3910E487; Mon, 9 May 2022 12:05:04 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 25B0710EEF9; Mon, 9 May 2022 12:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097903; x=1683633903; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=y6527320DXjS/K1KKLYGDj1NI6tuGeHfVEt42F+CDNA=; b=Z9JQvEML/C/E4FjJC6HLEd0HMC8pe/olQW0tHJbhvyhp3jOdROc9CWO8 MGuTVj1roM3hZADQrbZOLe+ESUu14l8wCg3biabaTQ+n7R0AzM0IF3Svy 6ugVrPrIW5pQjRr719Iq7T/o4sB+GD6F79c76B+X1VIoHTGuxQks0sBID +Yv9/ppsW5yMoJGLkgASGUp5HasK32yZizFrvJQdAxajxJxcu9Rip5GOw iKNnMOc2d93cebod+c9QUT3QSQNdet/pBx8wATEiTSPnP1dslzuJQx/T7 VYZxr+HlyuFFdyg8ix5Ofs4b+CDjEh3elb5LDBmhJv2g3ruxWpoJYXkUV A==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="251074466" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="251074466" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:48 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="601935460" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:46 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:14 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 15/25] drm/edid: convert get_monitor_name() to drm_edid 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" We'll need to propagate drm_edid everywhere. v2: Drop incorrect NULL name check (Dan Carpenter) Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 364949e146a9..e3ff0f31a614 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -4830,15 +4830,15 @@ monitor_name(const struct detailed_timing *timing, void *data) *res = timing->data.other_data.data.str.str; } -static int get_monitor_name(const struct edid *edid, char name[13]) +static int get_monitor_name(const struct drm_edid *drm_edid, char name[13]) { const char *edid_name = NULL; int mnl; - if (!edid || !name) + if (!drm_edid || !name) return 0; - drm_for_each_detailed_block(edid, monitor_name, &edid_name); + drm_for_each_detailed_block(drm_edid->edid, monitor_name, &edid_name); for (mnl = 0; edid_name && mnl < 13; mnl++) { if (edid_name[mnl] == 0x0a) break; @@ -4858,14 +4858,22 @@ static int get_monitor_name(const struct edid *edid, char name[13]) */ void drm_edid_get_monitor_name(const struct edid *edid, char *name, int bufsize) { - int name_length; - char buf[13]; + int name_length = 0; if (bufsize <= 0) return; - name_length = min(get_monitor_name(edid, buf), bufsize - 1); - memcpy(name, buf, name_length); + if (edid) { + char buf[13]; + struct drm_edid drm_edid = { + .edid = edid, + .size = edid_size(edid), + }; + + name_length = min(get_monitor_name(&drm_edid, buf), bufsize - 1); + memcpy(name, buf, name_length); + } + name[name_length] = '\0'; } EXPORT_SYMBOL(drm_edid_get_monitor_name); @@ -4905,7 +4913,7 @@ static void drm_edid_to_eld(struct drm_connector *connector, if (!drm_edid) return; - mnl = get_monitor_name(drm_edid->edid, &eld[DRM_ELD_MONITOR_NAME_STRING]); + mnl = get_monitor_name(drm_edid, &eld[DRM_ELD_MONITOR_NAME_STRING]); DRM_DEBUG_KMS("ELD monitor %s\n", &eld[DRM_ELD_MONITOR_NAME_STRING]); eld[DRM_ELD_CEA_EDID_VER_MNL] = info->cea_rev << DRM_ELD_CEA_EDID_VER_SHIFT; From patchwork Mon May 9 12:03:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843400 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 82833C433EF for ; Mon, 9 May 2022 12:05:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4257D10EEFD; Mon, 9 May 2022 12:05:06 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8BD3E10E487; Mon, 9 May 2022 12:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097903; x=1683633903; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Wc8hNVmaBYkdQ6rSRpf1GF1qqlCU2JBshnNhGtTCXvs=; b=NrOU3IcwkagJddbkgGuOtiRLorf6FwszV6zA6/9wRMpAVf2d3BuojqPt QSoodGKyDAub24RHJ+lfFr2EL5MsJnrJiElOJLvBrqDh+NIrkmffzCs05 OJvo/l8kT/xmFe6Kk99T9LaPf/7JqxORtMFOIfpVJ158mhf2a7pV8HE/x egIMQbkuzaGKJxxnkJIDfdThHgLu5ZYR44MxnRw6qqYN+HuivIAK9ZXZG 4zJMfmsp+f4o+pVTrzFG80wAVxEBsdjfR1pxkGrD8XOu5j01Y38lCDpEQ PDPiV33+znVvc7z0wioF43f4SI+YhBCoYNHLN1ipk803knBd1KswmGQ/p A==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="251074488" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="251074488" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:53 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="669115883" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:51 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:15 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 16/25] drm/edid: convert drm_for_each_detailed_block() to drm_edid 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" We'll need to propagate drm_edid everywhere. v2: Fix checkpatch warning on superfluous parens Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index e3ff0f31a614..61551ce0db88 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2598,20 +2598,20 @@ vtb_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure) cb((const struct detailed_timing *)(det_base + 18 * i), closure); } -static void -drm_for_each_detailed_block(const struct edid *edid, detailed_cb *cb, void *closure) +static void drm_for_each_detailed_block(const struct drm_edid *drm_edid, + detailed_cb *cb, void *closure) { struct drm_edid_iter edid_iter; const u8 *ext; int i; - if (edid == NULL) + if (!drm_edid) return; for (i = 0; i < EDID_DETAILED_TIMINGS; i++) - cb(&(edid->detailed_timings[i]), closure); + cb(&drm_edid->edid->detailed_timings[i], closure); - drm_edid_iter_begin(edid, &edid_iter); + drm_edid_iter_begin(drm_edid->edid, &edid_iter); drm_edid_iter_for_each(ext, &edid_iter) { switch (*ext) { case CEA_EXT: @@ -2650,7 +2650,7 @@ drm_monitor_supports_rb(const struct drm_edid *drm_edid) if (drm_edid->edid->revision >= 4) { bool ret = false; - drm_for_each_detailed_block(drm_edid->edid, is_rb, &ret); + drm_for_each_detailed_block(drm_edid, is_rb, &ret); return ret; } @@ -2677,7 +2677,7 @@ drm_gtf2_hbreak(const struct drm_edid *drm_edid) { const struct detailed_timing *descriptor = NULL; - drm_for_each_detailed_block(drm_edid->edid, find_gtf2, &descriptor); + drm_for_each_detailed_block(drm_edid, find_gtf2, &descriptor); BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.gtf2.hfreq_start_khz) != 12); @@ -2689,7 +2689,7 @@ drm_gtf2_2c(const struct drm_edid *drm_edid) { const struct detailed_timing *descriptor = NULL; - drm_for_each_detailed_block(drm_edid->edid, find_gtf2, &descriptor); + drm_for_each_detailed_block(drm_edid, find_gtf2, &descriptor); BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.gtf2.c) != 13); @@ -2701,7 +2701,7 @@ drm_gtf2_m(const struct drm_edid *drm_edid) { const struct detailed_timing *descriptor = NULL; - drm_for_each_detailed_block(drm_edid->edid, find_gtf2, &descriptor); + drm_for_each_detailed_block(drm_edid, find_gtf2, &descriptor); BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.gtf2.m) != 14); @@ -2713,7 +2713,7 @@ drm_gtf2_k(const struct drm_edid *drm_edid) { const struct detailed_timing *descriptor = NULL; - drm_for_each_detailed_block(drm_edid->edid, find_gtf2, &descriptor); + drm_for_each_detailed_block(drm_edid, find_gtf2, &descriptor); BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.gtf2.k) != 16); @@ -2725,7 +2725,7 @@ drm_gtf2_2j(const struct drm_edid *drm_edid) { const struct detailed_timing *descriptor = NULL; - drm_for_each_detailed_block(drm_edid->edid, find_gtf2, &descriptor); + drm_for_each_detailed_block(drm_edid, find_gtf2, &descriptor); BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.gtf2.j) != 17); @@ -3265,7 +3265,7 @@ static int add_inferred_modes(struct drm_connector *connector, }; if (version_greater(drm_edid->edid, 1, 0)) - drm_for_each_detailed_block(drm_edid->edid, do_inferred_modes, &closure); + drm_for_each_detailed_block(drm_edid, do_inferred_modes, &closure); return closure.modes; } @@ -3342,7 +3342,7 @@ static int add_established_modes(struct drm_connector *connector, } if (version_greater(edid, 1, 0)) - drm_for_each_detailed_block(drm_edid->edid, do_established_modes, + drm_for_each_detailed_block(drm_edid, do_established_modes, &closure); return modes + closure.modes; @@ -3397,7 +3397,7 @@ static int add_standard_modes(struct drm_connector *connector, } if (version_greater(drm_edid->edid, 1, 0)) - drm_for_each_detailed_block(drm_edid->edid, do_standard_modes, + drm_for_each_detailed_block(drm_edid, do_standard_modes, &closure); /* XXX should also look for standard codes in VTB blocks */ @@ -3477,7 +3477,7 @@ add_cvt_modes(struct drm_connector *connector, const struct drm_edid *drm_edid) }; if (version_greater(drm_edid->edid, 1, 2)) - drm_for_each_detailed_block(drm_edid->edid, do_cvt_mode, &closure); + drm_for_each_detailed_block(drm_edid, do_cvt_mode, &closure); /* XXX should also look for CVT codes in VTB blocks */ @@ -3536,7 +3536,7 @@ static int add_detailed_modes(struct drm_connector *connector, closure.preferred = (drm_edid->edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING); - drm_for_each_detailed_block(drm_edid->edid, do_detailed_mode, &closure); + drm_for_each_detailed_block(drm_edid, do_detailed_mode, &closure); return closure.modes; } @@ -4838,7 +4838,7 @@ static int get_monitor_name(const struct drm_edid *drm_edid, char name[13]) if (!drm_edid || !name) return 0; - drm_for_each_detailed_block(drm_edid->edid, monitor_name, &edid_name); + drm_for_each_detailed_block(drm_edid, monitor_name, &edid_name); for (mnl = 0; edid_name && mnl < 13; mnl++) { if (edid_name[mnl] == 0x0a) break; @@ -5559,7 +5559,7 @@ static void drm_get_monitor_range(struct drm_connector *connector, if (!version_greater(drm_edid->edid, 1, 1)) return; - drm_for_each_detailed_block(drm_edid->edid, get_monitor_range, + drm_for_each_detailed_block(drm_edid, get_monitor_range, &info->monitor_range); DRM_DEBUG_KMS("Supported Monitor Refresh rate range is %d Hz - %d Hz\n", From patchwork Mon May 9 12:03:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843397 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 68CF5C433F5 for ; Mon, 9 May 2022 12:05:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C4A3010EEEA; Mon, 9 May 2022 12:04:59 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9774D10EE68; Mon, 9 May 2022 12:04:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097898; x=1683633898; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XO01sFGZFgBwjSKmt7DnzUDNl+nCnCuzVQg24cqbuws=; b=KDhafAU+iy3MvEPl/GgiWikSw2ef4e2C5BqhZSLz7neHLfSWcg4KqMVd 68rwOnj0xkOyi5vKcmHcua+Z7E15/qpdTySRXiyHm5/KtdQhnH77G+fs1 Cq3Tf4WbmsdBIhDdgGY6x2YXADuOo0umwvTQ5L8dyUjpmn6xhJhrT8ZQm qcpQuOG6w5T6dhz4/jUyoz4E7s87qhalpd2FdTi9JeG0k6SmI6GVTu9/+ 3qcMF2ykdh/rjIB8sOdKHSGNBut4VfIQAbpquH+QafapgL5jd+NqxlFnk D8YxYgMIj3a8l1cJxu4LgVD2I8fxzK8thYO73Cmdo58bQAgCd+YSXD1FP A==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="332062962" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="332062962" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:58 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="656733121" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:04:56 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:16 +0300 Message-Id: <14aa1e44caa2e9c1b54c2f2a471d2fd7d3f62d5d.1652097712.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 17/25] drm/edid: add drm_edid helper for drm_edid_to_sad() 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" We'll need to propagate drm_edid everywhere. v2: Handle NULL EDID pointer (Ville, CI) Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 61551ce0db88..dee09359bbc3 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -4972,24 +4972,14 @@ static void drm_edid_to_eld(struct drm_connector *connector, drm_eld_size(eld), total_sad_count); } -/** - * drm_edid_to_sad - extracts SADs from EDID - * @edid: EDID to parse - * @sads: pointer that will be set to the extracted SADs - * - * Looks for CEA EDID block and extracts SADs (Short Audio Descriptors) from it. - * - * Note: The returned pointer needs to be freed using kfree(). - * - * Return: The number of found SADs or negative number on error. - */ -int drm_edid_to_sad(const struct edid *edid, struct cea_sad **sads) +static int _drm_edid_to_sad(const struct drm_edid *drm_edid, + struct cea_sad **sads) { const struct cea_db *db; struct cea_db_iter iter; int count = 0; - cea_db_iter_edid_begin(edid, &iter); + cea_db_iter_edid_begin(drm_edid ? drm_edid->edid : NULL, &iter); cea_db_iter_for_each(db, &iter) { if (cea_db_tag(db) == CTA_DB_AUDIO) { int j; @@ -5015,6 +5005,24 @@ int drm_edid_to_sad(const struct edid *edid, struct cea_sad **sads) return count; } + +/** + * drm_edid_to_sad - extracts SADs from EDID + * @edid: EDID to parse + * @sads: pointer that will be set to the extracted SADs + * + * Looks for CEA EDID block and extracts SADs (Short Audio Descriptors) from it. + * + * Note: The returned pointer needs to be freed using kfree(). + * + * Return: The number of found SADs or negative number on error. + */ +int drm_edid_to_sad(const struct edid *edid, struct cea_sad **sads) +{ + struct drm_edid drm_edid; + + return _drm_edid_to_sad(drm_edid_legacy_init(&drm_edid, edid), sads); +} EXPORT_SYMBOL(drm_edid_to_sad); /** From patchwork Mon May 9 12:03:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843399 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 02F0FC433EF for ; Mon, 9 May 2022 12:05:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CF8AF10EF11; Mon, 9 May 2022 12:05:06 +0000 (UTC) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id A648C10EEF8; Mon, 9 May 2022 12:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097903; x=1683633903; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=h8iBJUXGwnHpWaWNo2pD5dakHk8nvuh4ZAe9dBCLh88=; b=E/9mS9+rFASOhCkwNpVX43zYf8Q0yubEieOs2b5JsJvw3sGXRb6GLGYc hNQ3Nj+fOwZ6X4zHZnd+LoNcz8S5mPP4PkaOyLm3BvZ7mwuYGS38n+MO8 ohvQKh76XZ+pfRlo7oif4n8h/irZfJXplFX3SjmwmoWFmuz59Fue/lWCs L5+NnrMfO8B6tE5sBwlVXZZCXtV1O+JscGXHqis69fl0u7OE8xEt11W8d 1jF7dXFne7biUMghM5wpYEeGCMqMt4Q67UQ/fM9qF8MiANPH2Kiyw+S/p H6ajap4x+bZQonXbl74vQYo0rZjeGRyCva5pVFP9ea497BTV83ecyqiGc g==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="256563903" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="256563903" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:05:02 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="622937093" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:05:00 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:17 +0300 Message-Id: <770d095c93274969c4b86480e07044e16a7b5760.1652097712.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 18/25] drm/edid: add drm_edid helper for drm_edid_to_speaker_allocation() 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" We'll need to propagate drm_edid everywhere.' v2: Handle NULL EDID pointer (Ville, CI) Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index dee09359bbc3..5cc851f6d3b3 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -5025,25 +5025,14 @@ int drm_edid_to_sad(const struct edid *edid, struct cea_sad **sads) } EXPORT_SYMBOL(drm_edid_to_sad); -/** - * drm_edid_to_speaker_allocation - extracts Speaker Allocation Data Blocks from EDID - * @edid: EDID to parse - * @sadb: pointer to the speaker block - * - * Looks for CEA EDID block and extracts the Speaker Allocation Data Block from it. - * - * Note: The returned pointer needs to be freed using kfree(). - * - * Return: The number of found Speaker Allocation Blocks or negative number on - * error. - */ -int drm_edid_to_speaker_allocation(const struct edid *edid, u8 **sadb) +static int _drm_edid_to_speaker_allocation(const struct drm_edid *drm_edid, + u8 **sadb) { const struct cea_db *db; struct cea_db_iter iter; int count = 0; - cea_db_iter_edid_begin(edid, &iter); + cea_db_iter_edid_begin(drm_edid ? drm_edid->edid : NULL, &iter); cea_db_iter_for_each(db, &iter) { if (cea_db_tag(db) == CTA_DB_SPEAKER && cea_db_payload_len(db) == 3) { @@ -5061,6 +5050,26 @@ int drm_edid_to_speaker_allocation(const struct edid *edid, u8 **sadb) return count; } + +/** + * drm_edid_to_speaker_allocation - extracts Speaker Allocation Data Blocks from EDID + * @edid: EDID to parse + * @sadb: pointer to the speaker block + * + * Looks for CEA EDID block and extracts the Speaker Allocation Data Block from it. + * + * Note: The returned pointer needs to be freed using kfree(). + * + * Return: The number of found Speaker Allocation Blocks or negative number on + * error. + */ +int drm_edid_to_speaker_allocation(const struct edid *edid, u8 **sadb) +{ + struct drm_edid drm_edid; + + return _drm_edid_to_speaker_allocation(drm_edid_legacy_init(&drm_edid, edid), + sadb); +} EXPORT_SYMBOL(drm_edid_to_speaker_allocation); /** From patchwork Mon May 9 12:03:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843401 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 0C669C433EF for ; Mon, 9 May 2022 12:05:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8DE7010EF10; Mon, 9 May 2022 12:05:13 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id AB2D110EF10; Mon, 9 May 2022 12:05:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097910; x=1683633910; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4e/H+M/w7GyoXGTbcexhRPemupb4qMGVT74NWpudlzc=; b=fyorAYKZbyT1YNwlIuQxJ3Gdxuvr2ua/HzuU5k+dqHsWU+P/pE4i+9Iw vWr5jZn7XWv4pkJMgEr5n7Vl/IXZ9zulCfqxQhcJBAdlpn5KmYSklm+Sl 38CUODe3M5LyF95LFikDWcUcqTQP/47KdcgQXCIOmoNTENpy6sHgMzOpm NmVdPLQVR3a/Cr7EuBPYzt1nnhfzzV2TL+pSzyQYDiNR7GMx1SOW8Cuxr Q15NYTLVctyvA8SoTloZqkr/0JwdE+B5f76We+ZcaoIWjGJ6bA0luSxYM 1Pn2RTOkVzFslz2r+oXEZVTb2n7KjMQpPw4r/uqpXMB0eLEQmtiaxSHWO A==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="248930340" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="248930340" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:05:07 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="570130359" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:05:05 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:18 +0300 Message-Id: <2fbee0d7b544b44ef0866bb154beefac5d260bec.1652097712.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 19/25] drm/edid: add drm_edid helper for drm_detect_hdmi_monitor() 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" We'll need to propagate drm_edid everywhere. v2: Handle NULL EDID pointer (Ville, CI) Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 5cc851f6d3b3..fc74159cd426 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -5113,18 +5113,7 @@ int drm_av_sync_delay(struct drm_connector *connector, } EXPORT_SYMBOL(drm_av_sync_delay); -/** - * drm_detect_hdmi_monitor - detect whether monitor is HDMI - * @edid: monitor EDID information - * - * Parse the CEA extension according to CEA-861-B. - * - * Drivers that have added the modes parsed from EDID to drm_display_info - * should use &drm_display_info.is_hdmi instead of calling this function. - * - * Return: True if the monitor is HDMI, false if not or unknown. - */ -bool drm_detect_hdmi_monitor(const struct edid *edid) +static bool _drm_detect_hdmi_monitor(const struct drm_edid *drm_edid) { const struct cea_db *db; struct cea_db_iter iter; @@ -5134,7 +5123,7 @@ bool drm_detect_hdmi_monitor(const struct edid *edid) * Because HDMI identifier is in Vendor Specific Block, * search it from all data blocks of CEA extension. */ - cea_db_iter_edid_begin(edid, &iter); + cea_db_iter_edid_begin(drm_edid ? drm_edid->edid : NULL, &iter); cea_db_iter_for_each(db, &iter) { if (cea_db_is_hdmi_vsdb(db)) { hdmi = true; @@ -5145,6 +5134,24 @@ bool drm_detect_hdmi_monitor(const struct edid *edid) return hdmi; } + +/** + * drm_detect_hdmi_monitor - detect whether monitor is HDMI + * @edid: monitor EDID information + * + * Parse the CEA extension according to CEA-861-B. + * + * Drivers that have added the modes parsed from EDID to drm_display_info + * should use &drm_display_info.is_hdmi instead of calling this function. + * + * Return: True if the monitor is HDMI, false if not or unknown. + */ +bool drm_detect_hdmi_monitor(const struct edid *edid) +{ + struct drm_edid drm_edid; + + return _drm_detect_hdmi_monitor(drm_edid_legacy_init(&drm_edid, edid)); +} EXPORT_SYMBOL(drm_detect_hdmi_monitor); /** From patchwork Mon May 9 12:03:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843402 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 C9CCAC433FE for ; Mon, 9 May 2022 12:05:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 88BAB10EE91; Mon, 9 May 2022 12:05:14 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2270610EE80; Mon, 9 May 2022 12:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097913; x=1683633913; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CBkr+Ea8nCYUX9AuKEIgdBn+frRHRM3xELIaB/RD7pc=; b=iWS8+oZ2lOv+J5f8aooKFBPc+sMYuDq2bM0DWltqciptqqDgXZS/rd6q I1oJqvpiZgTtHGgQTiD0c5YvBYwH4Q6tdjNyHh1fmnX9LFucNnGPyvSdC JegP3Qe0kfwokeYg6xSU2lGOwLwMer+Xu9e2zaSpiqJNfQvUKVyGUKUpp v8yezboHmZ4YLNynGX7wHklKOOjVtvnuZijzsYz/KxPJ2lSgMa9YwPvdY 8j5qyUpUse0IrEqBhxH2nlgoTqyGEx/g3ag1ZBq8m5UkZo0VJE48yzY8Y V6mri0Xtgrhj8sLbk63lob4PPGedqu3pbEz6nF+dPnuFF5txsj9j0OXfj Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="267869388" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="267869388" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:05:12 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="669116231" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:05:10 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:19 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 20/25] drm/edid: add drm_edid helper for drm_detect_monitor_audio() 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" We'll need to propagate drm_edid everywhere. v2: Handle NULL EDID pointer (Ville, CI) Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index fc74159cd426..f072cfba9dd9 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -5154,19 +5154,7 @@ bool drm_detect_hdmi_monitor(const struct edid *edid) } EXPORT_SYMBOL(drm_detect_hdmi_monitor); -/** - * drm_detect_monitor_audio - check monitor audio capability - * @edid: EDID block to scan - * - * Monitor should have CEA extension block. - * If monitor has 'basic audio', but no CEA audio blocks, it's 'basic - * audio' only. If there is any audio extension block and supported - * audio format, assume at least 'basic audio' support, even if 'basic - * audio' is not defined in EDID. - * - * Return: True if the monitor supports audio, false otherwise. - */ -bool drm_detect_monitor_audio(const struct edid *edid) +static bool _drm_detect_monitor_audio(const struct drm_edid *drm_edid) { struct drm_edid_iter edid_iter; const struct cea_db *db; @@ -5174,7 +5162,7 @@ bool drm_detect_monitor_audio(const struct edid *edid) const u8 *edid_ext; bool has_audio = false; - drm_edid_iter_begin(edid, &edid_iter); + drm_edid_iter_begin(drm_edid ? drm_edid->edid : NULL, &edid_iter); drm_edid_iter_for_each(edid_ext, &edid_iter) { if (edid_ext[0] == CEA_EXT) { has_audio = edid_ext[3] & EDID_BASIC_AUDIO; @@ -5189,7 +5177,7 @@ bool drm_detect_monitor_audio(const struct edid *edid) goto end; } - cea_db_iter_edid_begin(edid, &iter); + cea_db_iter_edid_begin(drm_edid ? drm_edid->edid : NULL, &iter); cea_db_iter_for_each(db, &iter) { if (cea_db_tag(db) == CTA_DB_AUDIO) { const u8 *data = cea_db_data(db); @@ -5207,6 +5195,25 @@ bool drm_detect_monitor_audio(const struct edid *edid) end: return has_audio; } + +/** + * drm_detect_monitor_audio - check monitor audio capability + * @edid: EDID block to scan + * + * Monitor should have CEA extension block. + * If monitor has 'basic audio', but no CEA audio blocks, it's 'basic + * audio' only. If there is any audio extension block and supported + * audio format, assume at least 'basic audio' support, even if 'basic + * audio' is not defined in EDID. + * + * Return: True if the monitor supports audio, false otherwise. + */ +bool drm_detect_monitor_audio(const struct edid *edid) +{ + struct drm_edid drm_edid; + + return _drm_detect_monitor_audio(drm_edid_legacy_init(&drm_edid, edid)); +} EXPORT_SYMBOL(drm_detect_monitor_audio); From patchwork Mon May 9 12:03:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843403 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 80B3CC433F5 for ; Mon, 9 May 2022 12:05:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 72E1710EF59; Mon, 9 May 2022 12:05:19 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id BCADD10EF36; Mon, 9 May 2022 12:05:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097917; x=1683633917; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=377riFLDGOx+3N8DE56v6GlHwMdxk1ZvQoI94qjVehc=; b=bhZf+voNO+KJGqqzfhSuBVUFDYn9CeYLWGtpUweHs3Cx0wDSpsDKOZy0 4f7u3d/KEixGcoss88P9jaqW2Q5IMgF7eYQezqmvIP75dtguuIN0CuEXk A9n4CvTqOvNEggWtAHyZmiS/Pe81td1pRGKxTO0TIq+jRWOHLrIrTNinM 8qI1PBf+3ZjPUlOYtGSU54BIkyShnWX9MJRdXSCRYn2AdKVbL8v0ZEdnd VMcn5JZxMRcic9unYK6IwJZWvkOmDIqtlpcy7b7pomsjHs3/dL/O2y7ga Ivi8TpBm5UOukWalgCakL7nsq3OvpQCUcJGRkdzicfweIy/NEm+A9/xBQ Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="267869407" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="267869407" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:05:16 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="622937404" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:05:14 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:20 +0300 Message-Id: <7d9f060815086e1e4ea037dbfb9fd8ad54d1f25e.1652097712.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 21/25] drm/edid: convert cea_db_iter_edid_begin() to drm_edid 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" We'll need to propagate drm_edid everywhere. v2: Handle NULL drm_edid Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index f072cfba9dd9..bd14010ed1c5 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -4448,12 +4448,13 @@ static bool cea_db_is_vendor(const struct cea_db *db, int vendor_oui) oui(data[2], data[1], data[0]) == vendor_oui; } -static void cea_db_iter_edid_begin(const struct edid *edid, struct cea_db_iter *iter) +static void cea_db_iter_edid_begin(const struct drm_edid *drm_edid, + struct cea_db_iter *iter) { memset(iter, 0, sizeof(*iter)); - drm_edid_iter_begin(edid, &iter->edid_iter); - displayid_iter_edid_begin(edid, &iter->displayid_iter); + drm_edid_iter_begin(drm_edid ? drm_edid->edid : NULL, &iter->edid_iter); + displayid_iter_edid_begin(drm_edid ? drm_edid->edid : NULL, &iter->displayid_iter); } static const struct cea_db * @@ -4675,7 +4676,7 @@ static int add_cea_modes(struct drm_connector *connector, struct cea_db_iter iter; int modes = 0; - cea_db_iter_edid_begin(drm_edid->edid, &iter); + cea_db_iter_edid_begin(drm_edid, &iter); cea_db_iter_for_each(db, &iter) { const u8 *hdmi = NULL, *video = NULL; u8 hdmi_len = 0, video_len = 0; @@ -4926,7 +4927,7 @@ static void drm_edid_to_eld(struct drm_connector *connector, eld[DRM_ELD_PRODUCT_CODE0] = drm_edid->edid->prod_code[0]; eld[DRM_ELD_PRODUCT_CODE1] = drm_edid->edid->prod_code[1]; - cea_db_iter_edid_begin(drm_edid->edid, &iter); + cea_db_iter_edid_begin(drm_edid, &iter); cea_db_iter_for_each(db, &iter) { const u8 *data = cea_db_data(db); int len = cea_db_payload_len(db); @@ -4979,7 +4980,7 @@ static int _drm_edid_to_sad(const struct drm_edid *drm_edid, struct cea_db_iter iter; int count = 0; - cea_db_iter_edid_begin(drm_edid ? drm_edid->edid : NULL, &iter); + cea_db_iter_edid_begin(drm_edid, &iter); cea_db_iter_for_each(db, &iter) { if (cea_db_tag(db) == CTA_DB_AUDIO) { int j; @@ -5032,7 +5033,7 @@ static int _drm_edid_to_speaker_allocation(const struct drm_edid *drm_edid, struct cea_db_iter iter; int count = 0; - cea_db_iter_edid_begin(drm_edid ? drm_edid->edid : NULL, &iter); + cea_db_iter_edid_begin(drm_edid, &iter); cea_db_iter_for_each(db, &iter) { if (cea_db_tag(db) == CTA_DB_SPEAKER && cea_db_payload_len(db) == 3) { @@ -5123,7 +5124,7 @@ static bool _drm_detect_hdmi_monitor(const struct drm_edid *drm_edid) * Because HDMI identifier is in Vendor Specific Block, * search it from all data blocks of CEA extension. */ - cea_db_iter_edid_begin(drm_edid ? drm_edid->edid : NULL, &iter); + cea_db_iter_edid_begin(drm_edid, &iter); cea_db_iter_for_each(db, &iter) { if (cea_db_is_hdmi_vsdb(db)) { hdmi = true; @@ -5177,7 +5178,7 @@ static bool _drm_detect_monitor_audio(const struct drm_edid *drm_edid) goto end; } - cea_db_iter_edid_begin(drm_edid ? drm_edid->edid : NULL, &iter); + cea_db_iter_edid_begin(drm_edid, &iter); cea_db_iter_for_each(db, &iter) { if (cea_db_tag(db) == CTA_DB_AUDIO) { const u8 *data = cea_db_data(db); @@ -5536,7 +5537,7 @@ static void drm_parse_cea_ext(struct drm_connector *connector, } drm_edid_iter_end(&edid_iter); - cea_db_iter_edid_begin(drm_edid->edid, &iter); + cea_db_iter_edid_begin(drm_edid, &iter); cea_db_iter_for_each(db, &iter) { /* FIXME: convert parsers to use struct cea_db */ const u8 *data = (const u8 *)db; From patchwork Mon May 9 12:03:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843404 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 C73F1C433EF for ; Mon, 9 May 2022 12:05:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 60AD010EF60; Mon, 9 May 2022 12:05:23 +0000 (UTC) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9ADA210EF18; Mon, 9 May 2022 12:05:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097921; x=1683633921; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=crxphi9DPRapv44g2oK30KY4En+Qnv+ue1NtbhYohrA=; b=CfTfxOcKpi6fcN7DB11Kry9CATiCw/xmb3kdR4L2MjPY05dHtXLGvhHX r3/gEtopVV5lM5Xl/4mpNsMsGogIQEdB5afgQ1aalGeOAvk9ryw9DP1j9 kMwysF3r4NsN+ifxqlUlmd35z2hXVDVQAwS00/nNfOJ8PwFQPLcR/RRM6 b6NqFlngFY575inS5yLTG/mLl20VzA28xw36gfHsp/zbBG/9n8cbubwqe LQZuEjyVPCFpdK0bR/hVqYA835TI3ziGUrVLOzs8mcgom2jTd/Ny5RwEn Yx0augDzBA477QTf9FOn+qZ2DOGorRtjcicZQUl0E596fgYDIE5pWJasM g==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="269167795" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="269167795" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:05:21 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="813447983" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:05:19 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:21 +0300 Message-Id: <24dfb5fd9026ebef573bb55b368b94e56cae5cec.1652097712.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 22/25] drm/edid: convert drm_edid_iter_begin() to drm_edid 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" We'll need to propagate drm_edid everywhere. v2: Rebase Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index bd14010ed1c5..d857d1d74c82 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -1632,36 +1632,36 @@ static const struct drm_edid *drm_edid_legacy_init(struct drm_edid *drm_edid, * struct drm_edid_iter iter; * const u8 *block; * - * drm_edid_iter_begin(edid, &iter); + * drm_edid_iter_begin(drm_edid, &iter); * drm_edid_iter_for_each(block, &iter) { * // do stuff with block * } * drm_edid_iter_end(&iter); */ struct drm_edid_iter { - const struct edid *edid; + const struct drm_edid *drm_edid; /* Current block index. */ int index; }; -static void drm_edid_iter_begin(const struct edid *edid, +static void drm_edid_iter_begin(const struct drm_edid *drm_edid, struct drm_edid_iter *iter) { memset(iter, 0, sizeof(*iter)); - iter->edid = edid; + iter->drm_edid = drm_edid; } static const void *__drm_edid_iter_next(struct drm_edid_iter *iter) { const void *block = NULL; - if (!iter->edid) + if (!iter->drm_edid) return NULL; - if (iter->index < edid_block_count(iter->edid)) - block = edid_block_data(iter->edid, iter->index++); + if (iter->index < edid_block_count(iter->drm_edid->edid)) + block = edid_block_data(iter->drm_edid->edid, iter->index++); return block; } @@ -2611,7 +2611,7 @@ static void drm_for_each_detailed_block(const struct drm_edid *drm_edid, for (i = 0; i < EDID_DETAILED_TIMINGS; i++) cb(&drm_edid->edid->detailed_timings[i], closure); - drm_edid_iter_begin(drm_edid->edid, &edid_iter); + drm_edid_iter_begin(drm_edid, &edid_iter); drm_edid_iter_for_each(ext, &edid_iter) { switch (*ext) { case CEA_EXT: @@ -4453,7 +4453,7 @@ static void cea_db_iter_edid_begin(const struct drm_edid *drm_edid, { memset(iter, 0, sizeof(*iter)); - drm_edid_iter_begin(drm_edid ? drm_edid->edid : NULL, &iter->edid_iter); + drm_edid_iter_begin(drm_edid, &iter->edid_iter); displayid_iter_edid_begin(drm_edid ? drm_edid->edid : NULL, &iter->displayid_iter); } @@ -5163,7 +5163,7 @@ static bool _drm_detect_monitor_audio(const struct drm_edid *drm_edid) const u8 *edid_ext; bool has_audio = false; - drm_edid_iter_begin(drm_edid ? drm_edid->edid : NULL, &edid_iter); + drm_edid_iter_begin(drm_edid, &edid_iter); drm_edid_iter_for_each(edid_ext, &edid_iter) { if (edid_ext[0] == CEA_EXT) { has_audio = edid_ext[3] & EDID_BASIC_AUDIO; @@ -5516,7 +5516,7 @@ static void drm_parse_cea_ext(struct drm_connector *connector, struct cea_db_iter iter; const u8 *edid_ext; - drm_edid_iter_begin(drm_edid->edid, &edid_iter); + drm_edid_iter_begin(drm_edid, &edid_iter); drm_edid_iter_for_each(edid_ext, &edid_iter) { if (edid_ext[0] != CEA_EXT) continue; From patchwork Mon May 9 12:03:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843405 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 85BE2C433EF for ; Mon, 9 May 2022 12:05:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AA5CD10EF62; Mon, 9 May 2022 12:05:28 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id B1EDD10EF62; Mon, 9 May 2022 12:05:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097927; x=1683633927; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WZbK4QZW/WLKdDBTqagySWJE47DzSAYZxbqq02NMCrM=; b=mCRJm2yMf8lMXWTofzp6ZyzJo973VXE9EhSwmWW2Zl636FIQ67kNNv5u aURNoPQtWjkF+X8p7I9Czp0Za1CqJVY11pM/VMB20Pr9xO4htHFTF2OK3 mwL3q7KofWeSU7xf9WQLboqFc2TP/TLWl5vNZSfiC9qiBaLjC0R6XFdvq RqkMprJZjdcTFNHY5koqPb7VsqGVbwZ0jJXv1yydcjO8zCsPt+kiqx2g7 F49nxU1XWCHuv86rQEbmnJDCUc7P6mAP5DgDeFJV80uiw+WsyIUwwAAjd 0u3194k6PBGYiaPC3AiPcZ7Pt+3QOTvLIKjWpK7x9E/i/3s1e+Anpix74 g==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="268693750" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="268693750" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:05:25 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="893859447" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:05:23 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:22 +0300 Message-Id: <5b36683b656446a4d9a172d4dca1cf9aca08a48b.1652097712.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 23/25] drm/edid: add drm_edid helper for drm_update_tile_info() 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" We'll need to propagate drm_edid everywhere. v2: Handle NULL EDID pointer (Ville, CI) Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index d857d1d74c82..26ac4d262e31 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -6364,15 +6364,15 @@ static void drm_parse_tiled_block(struct drm_connector *connector, } } -void drm_update_tile_info(struct drm_connector *connector, - const struct edid *edid) +static void _drm_update_tile_info(struct drm_connector *connector, + const struct drm_edid *drm_edid) { const struct displayid_block *block; struct displayid_iter iter; connector->has_tile = false; - displayid_iter_edid_begin(edid, &iter); + displayid_iter_edid_begin(drm_edid ? drm_edid->edid : NULL, &iter); displayid_iter_for_each(block, &iter) { if (block->tag == DATA_BLOCK_TILED_DISPLAY) drm_parse_tiled_block(connector, block); @@ -6384,3 +6384,11 @@ void drm_update_tile_info(struct drm_connector *connector, connector->tile_group = NULL; } } + +void drm_update_tile_info(struct drm_connector *connector, + const struct edid *edid) +{ + struct drm_edid drm_edid; + + _drm_update_tile_info(connector, drm_edid_legacy_init(&drm_edid, edid)); +} From patchwork Mon May 9 12:03:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843406 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 29C00C433EF for ; Mon, 9 May 2022 12:05:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 817C510EF82; Mon, 9 May 2022 12:05:32 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id E2D9810EF73; Mon, 9 May 2022 12:05:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097930; x=1683633930; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DI5fBZDdIKx36Ze3Wk15+15a+MNShICmOKaTUNzVYtc=; b=TvzH4190szalyEhOsdhtZ5t6wGRjzfWKTWMw4cBTUvTwrPTpmOI21OHH rG3rm2rzl11YylFShSNVJabmjLupmrZw65yEsloNFzsO4R6TCiWHgW/0e FM+okUeoD6aj1vXyhOI7Hhhph5OmqKdV7dOVfaS/yCi/Amv8ys+vMItzV L4VTRvlvglaUnt3kNCgD7V47/BLPlpdNbEcJ0iQClpdVp+2JL9/bt6IL3 /kRYPHsmu9AtIDeuiXakmi47RIhx8Cj3HdkWy+ttIILDaSipuiVmAOKyg nrvM/3K2yUK7DzSaCAvx2xLKijGOJYzP9mj6/g9l/gGO2V4605E+cwi/X Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="249566345" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="249566345" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:05:30 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="570130486" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:05:28 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:23 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 24/25] drm/displayid: convert to drm_edid 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" We'll need to propagate drm_edid everywhere. v2: Rebase Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_displayid.c | 16 ++++++++-------- drivers/gpu/drm/drm_edid.c | 17 ++++++++++------- include/drm/drm_displayid.h | 6 +++--- include/drm/drm_edid.h | 6 ++++-- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/drm_displayid.c b/drivers/gpu/drm/drm_displayid.c index 32da557b960f..38ea8203df45 100644 --- a/drivers/gpu/drm/drm_displayid.c +++ b/drivers/gpu/drm/drm_displayid.c @@ -33,11 +33,11 @@ static int validate_displayid(const u8 *displayid, int length, int idx) return 0; } -static const u8 *drm_find_displayid_extension(const struct edid *edid, +static const u8 *drm_find_displayid_extension(const struct drm_edid *drm_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(drm_edid, DISPLAYID_EXT, ext_index); const struct displayid_header *base; int ret; @@ -58,12 +58,12 @@ static const u8 *drm_find_displayid_extension(const struct edid *edid, return displayid; } -void displayid_iter_edid_begin(const struct edid *edid, +void displayid_iter_edid_begin(const struct drm_edid *drm_edid, struct displayid_iter *iter) { memset(iter, 0, sizeof(*iter)); - iter->edid = edid; + iter->drm_edid = drm_edid; } static const struct displayid_block * @@ -88,7 +88,7 @@ __displayid_iter_next(struct displayid_iter *iter) { const struct displayid_block *block; - if (!iter->edid) + if (!iter->drm_edid) return NULL; if (iter->section) { @@ -96,7 +96,7 @@ __displayid_iter_next(struct displayid_iter *iter) block = displayid_iter_block(iter); if (WARN_ON(!block)) { iter->section = NULL; - iter->edid = NULL; + iter->drm_edid = NULL; return NULL; } @@ -109,12 +109,12 @@ __displayid_iter_next(struct displayid_iter *iter) } for (;;) { - iter->section = drm_find_displayid_extension(iter->edid, + iter->section = drm_find_displayid_extension(iter->drm_edid, &iter->length, &iter->idx, &iter->ext_index); if (!iter->section) { - iter->edid = NULL; + iter->drm_edid = NULL; return NULL; } diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 26ac4d262e31..a44818f44718 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3563,10 +3563,13 @@ static int add_detailed_modes(struct drm_connector *connector, /* * Search EDID for CEA extension block. + * + * FIXME: Prefer not returning pointers to raw EDID data. */ -const u8 *drm_find_edid_extension(const struct edid *edid, +const u8 *drm_find_edid_extension(const struct drm_edid *drm_edid, int ext_id, int *ext_index) { + const struct edid *edid = drm_edid ? drm_edid->edid : NULL; const u8 *edid_ext = NULL; int i; @@ -3598,11 +3601,11 @@ static bool drm_edid_has_cta_extension(const struct drm_edid *drm_edid) bool found = false; /* Look for a top level CEA extension block */ - if (drm_find_edid_extension(drm_edid->edid, CEA_EXT, &ext_index)) + if (drm_find_edid_extension(drm_edid, CEA_EXT, &ext_index)) return true; /* CEA blocks can also be found embedded in a DisplayID block */ - displayid_iter_edid_begin(drm_edid->edid, &iter); + displayid_iter_edid_begin(drm_edid, &iter); displayid_iter_for_each(block, &iter) { if (block->tag == DATA_BLOCK_CTA) { found = true; @@ -4454,7 +4457,7 @@ static void cea_db_iter_edid_begin(const struct drm_edid *drm_edid, memset(iter, 0, sizeof(*iter)); drm_edid_iter_begin(drm_edid, &iter->edid_iter); - displayid_iter_edid_begin(drm_edid ? drm_edid->edid : NULL, &iter->displayid_iter); + displayid_iter_edid_begin(drm_edid, &iter->displayid_iter); } static const struct cea_db * @@ -5657,7 +5660,7 @@ static void drm_update_mso(struct drm_connector *connector, const struct displayid_block *block; struct displayid_iter iter; - displayid_iter_edid_begin(drm_edid->edid, &iter); + displayid_iter_edid_begin(drm_edid, &iter); displayid_iter_for_each(block, &iter) { if (block->tag == DATA_BLOCK_2_VENDOR_SPECIFIC) drm_parse_vesa_mso_data(connector, block); @@ -5872,7 +5875,7 @@ static int add_displayid_detailed_modes(struct drm_connector *connector, struct displayid_iter iter; int num_modes = 0; - displayid_iter_edid_begin(drm_edid->edid, &iter); + displayid_iter_edid_begin(drm_edid, &iter); displayid_iter_for_each(block, &iter) { if (block->tag == DATA_BLOCK_TYPE_1_DETAILED_TIMING || block->tag == DATA_BLOCK_2_TYPE_7_DETAILED_TIMING) @@ -6372,7 +6375,7 @@ static void _drm_update_tile_info(struct drm_connector *connector, connector->has_tile = false; - displayid_iter_edid_begin(drm_edid ? drm_edid->edid : NULL, &iter); + displayid_iter_edid_begin(drm_edid, &iter); displayid_iter_for_each(block, &iter) { if (block->tag == DATA_BLOCK_TILED_DISPLAY) drm_parse_tiled_block(connector, block); diff --git a/include/drm/drm_displayid.h b/include/drm/drm_displayid.h index 7ffbd9f7bfc7..49649eb8447e 100644 --- a/include/drm/drm_displayid.h +++ b/include/drm/drm_displayid.h @@ -25,7 +25,7 @@ #include #include -struct edid; +struct drm_edid; #define VESA_IEEE_OUI 0x3a0292 @@ -141,7 +141,7 @@ struct displayid_vesa_vendor_specific_block { /* DisplayID iteration */ struct displayid_iter { - const struct edid *edid; + const struct drm_edid *drm_edid; const u8 *section; int length; @@ -149,7 +149,7 @@ struct displayid_iter { int ext_index; }; -void displayid_iter_edid_begin(const struct edid *edid, +void displayid_iter_edid_begin(const struct drm_edid *drm_edid, struct displayid_iter *iter); const struct displayid_block * __displayid_iter_next(struct displayid_iter *iter); diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index c3204a58fb09..c61e75ab8f63 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -28,6 +28,7 @@ #include struct drm_device; +struct drm_edid; struct i2c_adapter; #define EDID_LENGTH 128 @@ -578,8 +579,9 @@ struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev, 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); +/* Interface based on struct drm_edid */ +const u8 *drm_find_edid_extension(const struct drm_edid *drm_edid, + int ext_id, int *ext_index); #endif /* __DRM_EDID_H__ */ From patchwork Mon May 9 12:03:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12843407 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 E222EC433EF for ; Mon, 9 May 2022 12:05:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4419C10EF83; Mon, 9 May 2022 12:05:36 +0000 (UTC) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2D6D910EF83; Mon, 9 May 2022 12:05:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652097935; x=1683633935; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ta+Xw9BacgmGlgYy81SBKCqrU7A4H8gu8t0RaXxA+nw=; b=TsIGsbDNMYEAbMoR7cgWbU9o6qNOE8FqW7UfH1xl1/5nf6zxjww1Rf7T h2SDrr5ZpB8/FyxvtWzvHu622VX3r3THJ4brCQYsXY8RztX/k3JxYuOhs V/1oYlJdtd4z702QkM6LfsrPrcUeJt0cp2fHWGGjMkZpzdNM8aaW+W/Og +1Skdoj5U2TJ20MDca7T1d8Y70KUL8QVmbhY3tAko1k4piJ0iYDpsUNug 99wV97ObjJY1UwfKyQ2XIpAZixjCHnzZOt5gM6xT8D4m92Oh1Rs5b0Hef HZQiu+AVMxkaIUQow2Og13jC4QOo4AoxESh3En1LSksCc8fkRjQM293bj w==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="294253515" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="294253515" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:05:34 -0700 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="813448039" Received: from csawicki-mobl.ger.corp.intel.com (HELO localhost) ([10.249.129.3]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 05:05:33 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 9 May 2022 15:03:24 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 25/25] drm/edid: convert version_greater() to drm_edid 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" We'll need to propagate drm_edid everywhere. Also make version_greater() a function for type safety. Signed-off-by: Jani Nikula Reviewed-by: Ankit Nautiyal --- drivers/gpu/drm/drm_edid.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index a44818f44718..429078bcf372 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -45,10 +45,6 @@ #include "drm_crtc_internal.h" -#define version_greater(edid, maj, min) \ - (((edid)->version > (maj)) || \ - ((edid)->version == (maj) && (edid)->revision > (min))) - static int oui(u8 first, u8 second, u8 third) { return (first << 16) | (second << 8) | third; @@ -1576,6 +1572,15 @@ struct drm_edid { const struct edid *edid; }; +static bool version_greater(const struct drm_edid *drm_edid, + u8 version, u8 revision) +{ + const struct edid *edid = drm_edid->edid; + + return edid->version > version || + (edid->version == version && edid->revision > revision); +} + static int edid_extension_block_count(const struct edid *edid) { return edid->extensions; @@ -3232,7 +3237,7 @@ do_inferred_modes(const struct detailed_timing *timing, void *c) closure->drm_edid, timing); - if (!version_greater(closure->drm_edid->edid, 1, 1)) + if (!version_greater(closure->drm_edid, 1, 1)) return; /* GTF not defined yet */ switch (range->flags) { @@ -3243,7 +3248,7 @@ do_inferred_modes(const struct detailed_timing *timing, void *c) timing); break; case 0x04: /* cvt, only in 1.4+ */ - if (!version_greater(closure->drm_edid->edid, 1, 3)) + if (!version_greater(closure->drm_edid, 1, 3)) break; closure->modes += drm_cvt_modes_for_range(closure->connector, @@ -3264,7 +3269,7 @@ static int add_inferred_modes(struct drm_connector *connector, .drm_edid = drm_edid, }; - if (version_greater(drm_edid->edid, 1, 0)) + if (version_greater(drm_edid, 1, 0)) drm_for_each_detailed_block(drm_edid, do_inferred_modes, &closure); return closure.modes; @@ -3341,7 +3346,7 @@ static int add_established_modes(struct drm_connector *connector, } } - if (version_greater(edid, 1, 0)) + if (version_greater(drm_edid, 1, 0)) drm_for_each_detailed_block(drm_edid, do_established_modes, &closure); @@ -3396,7 +3401,7 @@ static int add_standard_modes(struct drm_connector *connector, } } - if (version_greater(drm_edid->edid, 1, 0)) + if (version_greater(drm_edid, 1, 0)) drm_for_each_detailed_block(drm_edid, do_standard_modes, &closure); @@ -3476,7 +3481,7 @@ add_cvt_modes(struct drm_connector *connector, const struct drm_edid *drm_edid) .drm_edid = drm_edid, }; - if (version_greater(drm_edid->edid, 1, 2)) + if (version_greater(drm_edid, 1, 2)) drm_for_each_detailed_block(drm_edid, do_cvt_mode, &closure); /* XXX should also look for CVT codes in VTB blocks */ @@ -3532,7 +3537,7 @@ static int add_detailed_modes(struct drm_connector *connector, .quirks = quirks, }; - if (closure.preferred && !version_greater(drm_edid->edid, 1, 3)) + if (closure.preferred && !version_greater(drm_edid, 1, 3)) closure.preferred = (drm_edid->edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING); @@ -5591,7 +5596,7 @@ static void drm_get_monitor_range(struct drm_connector *connector, { struct drm_display_info *info = &connector->display_info; - if (!version_greater(drm_edid->edid, 1, 1)) + if (!version_greater(drm_edid, 1, 1)) return; drm_for_each_detailed_block(drm_edid, get_monitor_range,