From nobody Mon May 11 03:38:08 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8207EC433FE for ; Fri, 15 Apr 2022 15:48:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355633AbiDOPu2 (ORCPT ); Fri, 15 Apr 2022 11:50:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355285AbiDOPuX (ORCPT ); Fri, 15 Apr 2022 11:50:23 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4332898F43 for ; Fri, 15 Apr 2022 08:47:55 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id t1so11091847wra.4 for ; Fri, 15 Apr 2022 08:47:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eVzMG+zpu3+1hRtFVA+ruZ6wFZcWgleiqmePRHdUybo=; b=qZz7Q6sxtsctCU+AZWdIgKNJKHt4F7pgzRWBWcwwkztrzO4hMxC+3y6bM+aQbE2xPm ZgDOt/of8dP232h4DWHKBZdrlFl7mr/rHPWLMlTUAIgQShx/CLBs7x04LE2hA4klZfjd W3bXY/m5KdcR0T/MgcaxM6ZN3LAMge79NTXnUcoGdGzzo1aJuBQrv7EwuBB0yst9SEeQ SqZ5p94yOj0JYqxZpDZUQrI50oNOazZEPOOIs36FyidDLsR1wcEYZqF52fn0aTdqFSru f/OHnqPmd3EHYQVhLnCWJUJ+ZdbHsz4kHAKKZict87s4Il+PYOPtJNePZ6nVOBeHy0PA d8Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eVzMG+zpu3+1hRtFVA+ruZ6wFZcWgleiqmePRHdUybo=; b=wTSiT5q2AxApe0ParW98yAeGdD5XM2A2kBWBbQ3A1PSJLOI59KW9v7+Op8pi3pYFcc 0JEwF0f4QE7qeibEm1razX8p2WGfjcrI8kqSej66bCDaoOSxWl58Vm5N25MFI9MCX66n hQ+hluphmV2ScsVGGbJstcSiV/ClyqWG100C5ZWJFWIFq/t54JWBy8B6c6r5iLv/IZi6 f0MISJN3IqdVNBTSRmPIKS/G432cl8th32+lLE/hYP7SrD3fc16haCPz8TFJQiXFLLQ5 8yeDltQPj7Ru7TXCYLsYLQFF7dIBBbCIEht++SFTZn+yQx1/JD+D/Lc7xnmj6Kl0XMoz ZFyA== X-Gm-Message-State: AOAM533L21vdI+cp3Eugc0OoBpcXfE95KSmiwD5niZ5+/w6Inmq67Cz4 yh+Wxq3Qoz2ETVIrEbL/M7U= X-Google-Smtp-Source: ABdhPJy53CGJvYDdnX2i/uwKm+d/NbMdizBcSF/BiT2v5dFHuYNgxTBoU3cJqgveJRQqMg297/59Kw== X-Received: by 2002:a5d:5705:0:b0:207:a299:27e2 with SMTP id a5-20020a5d5705000000b00207a29927e2mr5877936wrv.59.1650037673765; Fri, 15 Apr 2022 08:47:53 -0700 (PDT) Received: from localhost.localdomain ([94.73.37.128]) by smtp.gmail.com with ESMTPSA id a7-20020adffb87000000b00207982c7f4dsm4349655wrr.67.2022.04.15.08.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 08:47:53 -0700 (PDT) From: =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= To: emma@anholt.net Cc: mripard@kernel.org, laurent.pinchart@ideasonboard.com, airlied@linux.ie, daniel@ffwll.ch, p.zabel@pengutronix.de, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= Subject: [PATCH v2 1/2] drm/vc4: hdmi: Replace drm_detect_hdmi_monitor() with is_hdmi Date: Fri, 15 Apr 2022 17:47:44 +0200 Message-Id: <20220415154745.170597-2-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220415154745.170597-1-jose.exposito89@gmail.com> References: <20220415154745.170597-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Once EDID is parsed, the monitor HDMI support information is cached in drm_display_info.is_hdmi by drm_parse_hdmi_vsdb_video(). This driver calls drm_detect_hdmi_monitor() to receive the same information and stores its own cached value, which is less efficient. Avoid calling drm_detect_hdmi_monitor() and use drm_display_info.is_hdmi instead. drm_detect_hdmi_monitor() is called in vc4_hdmi_connector_detect() and vc4_hdmi_connector_get_modes(). In both cases it is safe to rely on drm_display_info.is_hdmi as shown by ftrace: $ sudo trace-cmd record -p function_graph -l "vc4_hdmi_*" -l "drm_*" vc4_hdmi_connector_detect: vc4_hdmi_connector_detect() { drm_get_edid() { drm_connector_update_edid_property() { drm_add_display_info() { drm_reset_display_info(); drm_for_each_detailed_block.part.0(); drm_parse_cea_ext() { drm_find_cea_extension(); drm_parse_hdmi_vsdb_video(); /* drm_display_info.is_hdmi is cached here */ } } } } /* drm_display_info.is_hdmi is used here */ } vc4_hdmi_connector_get_modes: vc4_hdmi_connector_get_modes() { drm_get_edid() { drm_connector_update_edid_property() { drm_add_display_info() { drm_reset_display_info(); drm_for_each_detailed_block.part.0(); drm_parse_cea_ext() { drm_find_cea_extension(); drm_parse_hdmi_vsdb_video(); /* drm_display_info.is_hdmi is cached here */ } } } } /* drm_display_info.is_hdmi is used here */ drm_connector_update_edid_property(); } Signed-off-by: Jos=C3=A9 Exp=C3=B3sito --- drivers/gpu/drm/vc4/vc4_hdmi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 6c58b0fd13fb..ecdb1ffc2023 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -216,7 +216,7 @@ vc4_hdmi_connector_detect(struct drm_connector *connect= or, bool force) =20 if (edid) { cec_s_phys_addr_from_edid(vc4_hdmi->cec_adap, edid); - vc4_hdmi->encoder.hdmi_monitor =3D drm_detect_hdmi_monitor(edid); + vc4_hdmi->encoder.hdmi_monitor =3D connector->display_info.is_hdmi; kfree(edid); } } @@ -255,7 +255,7 @@ static int vc4_hdmi_connector_get_modes(struct drm_conn= ector *connector) goto out; } =20 - vc4_encoder->hdmi_monitor =3D drm_detect_hdmi_monitor(edid); + vc4_encoder->hdmi_monitor =3D connector->display_info.is_hdmi; =20 drm_connector_update_edid_property(connector, edid); ret =3D drm_add_edid_modes(connector, edid); --=20 2.25.1 From nobody Mon May 11 03:38:08 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D2FEC433FE for ; Fri, 15 Apr 2022 15:48:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355637AbiDOPuc (ORCPT ); Fri, 15 Apr 2022 11:50:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355626AbiDOPuZ (ORCPT ); Fri, 15 Apr 2022 11:50:25 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08F12986F1 for ; Fri, 15 Apr 2022 08:47:56 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id x18so3247620wrc.0 for ; Fri, 15 Apr 2022 08:47:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z3NAus3DBQ3rA5abnaly1KYO3d+31BXc2jT1/06zaWU=; b=gMVKNG8Sn7N8Cr8qoxwKxQEKVfdJZOjuX2zRtTioOhvs0ImnH98R2BnSStp58MnElU xU/rsr8ge2E733Mmqp7rU5uPl09/PmmY1PGllmUdILYJIIEUhsBFePA1jE4pUxwMen1U nXZWPrXahH1TwZ7LhU1BmHrDGHPMtYCt0p/Ndft70fMuyrKWJhR6O25NqXObJKrM52Dq AYzHhOfe4aLMZgD9D7aR2DY4KAC2rQFYjlhuhj5PG8PbfkNdtLDGCX1z2vWI1S2NTZ2N cUtpopQ1gU/hSKPaf7f8viiwkxxaX74ED9fon5Y5alcWwdJZUMEdh93XkuxiWiUmxTRk qWdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z3NAus3DBQ3rA5abnaly1KYO3d+31BXc2jT1/06zaWU=; b=1mHiXiU3yt3j9o9SxeTdxvMPkqo3ERT08HTDG/D7vlxyQM88WyPbzZvpS0j+DVl0WB NR4fWdKMFngsnBLkIY/gD1Vw2Xc2V+1DU/FaBF+BIQPgxXSNX99RyGnGnsvhyHjbvmBu nBDMQYO5aJLRBr7LDfvbGNUk1+PlxpkPDSu9yp1vtm63H8Z3q08tJKfFMTtm5KpYtQ0y OqKg14atkO74U0eM/yBN9nKwqbJdapLzYgZC6nFT8KaT1bir3tSpPbLye3+tz1WGNlsW P8EQZ7Y6bc4t8bOgq9nhWnMxHAEcO5IXLLwTN7QOSwXd4cTdn1PhrLLh3Hh5diWLVTcw QY2w== X-Gm-Message-State: AOAM533Lk8rrT+Xw4MRGya6BzfAKbGaKcx2XeU0vZp2++N9F85KOaw0m kk2WL/8e4oQsel1+7kO96NHky1YhdXE= X-Google-Smtp-Source: ABdhPJyW2x2EFgqpv5A2q/Gy87tMC0ikN/Nmxu3gJ86Y5Z1liA26skS+/lodxtTsH/reQnsjkBwVFw== X-Received: by 2002:adf:cc88:0:b0:207:a46c:ad8d with SMTP id p8-20020adfcc88000000b00207a46cad8dmr5699598wrj.95.1650037674611; Fri, 15 Apr 2022 08:47:54 -0700 (PDT) Received: from localhost.localdomain ([94.73.37.128]) by smtp.gmail.com with ESMTPSA id a7-20020adffb87000000b00207982c7f4dsm4349655wrr.67.2022.04.15.08.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 08:47:54 -0700 (PDT) From: =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= To: emma@anholt.net Cc: mripard@kernel.org, laurent.pinchart@ideasonboard.com, airlied@linux.ie, daniel@ffwll.ch, p.zabel@pengutronix.de, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= Subject: [PATCH v2 2/2] drm/vc4: hdmi: Remove vc4_hdmi_encoder.hdmi_monitor Date: Fri, 15 Apr 2022 17:47:45 +0200 Message-Id: <20220415154745.170597-3-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220415154745.170597-1-jose.exposito89@gmail.com> References: <20220415154745.170597-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The vc4_hdmi_encoder.hdmi_monitor field was used to cache the value returned by drm_detect_hdmi_monitor() in order to avoid calling it multiple times. Now that drm_detect_hdmi_monitor() has been replaced with drm_display_info.is_hdmi, there is no need to cache it in the driver encoder struct. Remove vc4_hdmi_encoder.hdmi_monitor and use drm_display_info.is_hdmi instead. Signed-off-by: Jos=C3=A9 Exp=C3=B3sito --- drivers/gpu/drm/vc4/vc4_hdmi.c | 17 ++++++----------- drivers/gpu/drm/vc4/vc4_hdmi.h | 1 - 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index ecdb1ffc2023..9c73a211ae80 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -107,9 +107,9 @@ static bool vc4_hdmi_mode_needs_scrambling(const struct= drm_display_mode *mode) static bool vc4_hdmi_is_full_range_rgb(struct vc4_hdmi *vc4_hdmi, const struct drm_display_mode *mode) { - struct vc4_hdmi_encoder *vc4_encoder =3D &vc4_hdmi->encoder; + struct drm_display_info *display =3D &vc4_hdmi->connector.display_info; =20 - return !vc4_encoder->hdmi_monitor || + return !display->is_hdmi || drm_default_rgb_quant_range(mode) =3D=3D HDMI_QUANTIZATION_RANGE_FULL; } =20 @@ -216,7 +216,6 @@ vc4_hdmi_connector_detect(struct drm_connector *connect= or, bool force) =20 if (edid) { cec_s_phys_addr_from_edid(vc4_hdmi->cec_adap, edid); - vc4_hdmi->encoder.hdmi_monitor =3D connector->display_info.is_hdmi; kfree(edid); } } @@ -242,7 +241,6 @@ static void vc4_hdmi_connector_destroy(struct drm_conne= ctor *connector) static int vc4_hdmi_connector_get_modes(struct drm_connector *connector) { struct vc4_hdmi *vc4_hdmi =3D connector_to_vc4_hdmi(connector); - struct vc4_hdmi_encoder *vc4_encoder =3D &vc4_hdmi->encoder; int ret =3D 0; struct edid *edid; =20 @@ -255,8 +253,6 @@ static int vc4_hdmi_connector_get_modes(struct drm_conn= ector *connector) goto out; } =20 - vc4_encoder->hdmi_monitor =3D connector->display_info.is_hdmi; - drm_connector_update_edid_property(connector, edid); ret =3D drm_add_edid_modes(connector, edid); kfree(edid); @@ -578,13 +574,12 @@ static void vc4_hdmi_set_infoframes(struct drm_encode= r *encoder) static bool vc4_hdmi_supports_scrambling(struct drm_encoder *encoder, struct drm_display_mode *mode) { - struct vc4_hdmi_encoder *vc4_encoder =3D to_vc4_hdmi_encoder(encoder); struct vc4_hdmi *vc4_hdmi =3D encoder_to_vc4_hdmi(encoder); struct drm_display_info *display =3D &vc4_hdmi->connector.display_info; =20 lockdep_assert_held(&vc4_hdmi->mutex); =20 - if (!vc4_encoder->hdmi_monitor) + if (!display->is_hdmi) return false; =20 if (!display->hdmi.scdc.supported || @@ -1147,7 +1142,7 @@ static void vc4_hdmi_encoder_post_crtc_enable(struct = drm_encoder *encoder, { struct vc4_hdmi *vc4_hdmi =3D encoder_to_vc4_hdmi(encoder); struct drm_display_mode *mode =3D &vc4_hdmi->saved_adjusted_mode; - struct vc4_hdmi_encoder *vc4_encoder =3D to_vc4_hdmi_encoder(encoder); + struct drm_display_info *display =3D &vc4_hdmi->connector.display_info; bool hsync_pos =3D mode->flags & DRM_MODE_FLAG_PHSYNC; bool vsync_pos =3D mode->flags & DRM_MODE_FLAG_PVSYNC; unsigned long flags; @@ -1168,7 +1163,7 @@ static void vc4_hdmi_encoder_post_crtc_enable(struct = drm_encoder *encoder, HDMI_WRITE(HDMI_VID_CTL, HDMI_READ(HDMI_VID_CTL) & ~VC4_HD_VID_CTL_BLANKPIX); =20 - if (vc4_encoder->hdmi_monitor) { + if (display->is_hdmi) { HDMI_WRITE(HDMI_SCHEDULER_CONTROL, HDMI_READ(HDMI_SCHEDULER_CONTROL) | VC4_HDMI_SCHEDULER_CONTROL_MODE_HDMI); @@ -1195,7 +1190,7 @@ static void vc4_hdmi_encoder_post_crtc_enable(struct = drm_encoder *encoder, "!VC4_HDMI_SCHEDULER_CONTROL_HDMI_ACTIVE\n"); } =20 - if (vc4_encoder->hdmi_monitor) { + if (display->is_hdmi) { spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); =20 WARN_ON(!(HDMI_READ(HDMI_SCHEDULER_CONTROL) & diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h index 1076faeab616..44977002445f 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.h +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h @@ -11,7 +11,6 @@ /* VC4 HDMI encoder KMS struct */ struct vc4_hdmi_encoder { struct vc4_encoder base; - bool hdmi_monitor; }; =20 static inline struct vc4_hdmi_encoder * --=20 2.25.1