Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp875915pxb; Thu, 21 Apr 2022 12:20:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypoEYFxHSR8RtAoIZJ2DRcTZ/BeZ+JxsLOmEPtqNXiYl08uIphVjncf9PpHB7yVo9oWW8h X-Received: by 2002:a17:907:94c9:b0:6e8:ab67:829e with SMTP id dn9-20020a17090794c900b006e8ab67829emr857407ejc.313.1650568828450; Thu, 21 Apr 2022 12:20:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650568828; cv=none; d=google.com; s=arc-20160816; b=Q3wvtpZt5UhIndP7JArtqr7Ot2g/PHTT6XN4AlyoXqDQYCFsI75SK4NzgHBVu7lUhz pRq4/R2HXA4XX27YVzx1rZkSRxMKeS0D9Ubiyd8EZLAj+NFWZVjE4f1pzNCNCrlmYy38 4xYaOBT+jFAQXJ8528AIwlbhTWdXSbkaxk2K3kdMzJOxSmENDY954NtkYXKkI+KoIIP9 zgU/hm4RsQIu9JhSCZGn7HkZTuK4CZrvY+SLGf6iKQ+mE0pDI7sE6qHtlUoRglC3cMrv U0F05/0RUyIA+8ko6/tQByEV7uuEon1Cmb4xVYSgRdpuvUTWbLoQKIP9z9Hxs2hCK9X+ pJVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vxAaLTkBoUBaCL/O3581iu7gQKfuo3i9c87P/ALffLw=; b=DP+wT51dizbK6v0Y2H5O8ljown5KtWVlNXdpDRw4eA6tfpHTWPpgIWSRj2c/7sspHa QlF/U7+XML1L9MMM2UvKO00OOvValcv/z+kj08UvpG0a9zXj6w6wPbMChUgxJmL2+S53 iygKc4n1tisAW1wlu+3Vxo/rFvEYj/92IpykalwajWcd2mYOEtlhecY0/mr3nNUQAYkV bukNajzj7TUu5f9PexUtKX3WEJz84MRT04u7P2FRUvPqs0a/sjkJpS/0gFfpoFxVQtSB jnvzdH82swQao2ysI5dGLMZpmIfteS/rAJwiNcOqWh7CxEvJJ/ADC7+VM5TkR0eHE+Mw oASg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=glNX7oyF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k25-20020a170906159900b006e00f0a2fc0si4443864ejd.818.2022.04.21.12.20.04; Thu, 21 Apr 2022 12:20:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=glNX7oyF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378233AbiDTLsa (ORCPT + 99 others); Wed, 20 Apr 2022 07:48:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377999AbiDTLs0 (ORCPT ); Wed, 20 Apr 2022 07:48:26 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED1E04162A for ; Wed, 20 Apr 2022 04:45:40 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id u17-20020a05600c211100b0038eaf4cdaaeso3493874wml.1 for ; Wed, 20 Apr 2022 04:45:40 -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=vxAaLTkBoUBaCL/O3581iu7gQKfuo3i9c87P/ALffLw=; b=glNX7oyFIiDjUhuM/RiuAr+tK3D1huhhvWxzoQlzfMk8Gksi5NXqlb2Y3BJdneoA6J UsCP2Sfbwc5F++EVTRcrOae335Zwn+ngDNnD0cGmaan2pOGxdcv9QitSYBBkWVsovkGm 0jxZGGPGbk5sxYXjX8fqVegGG2sXm/pJuDZmkAB3BBSRDB3MwBFpnim4fwcIH8OsHlB+ Ipuhq1cRD4TJKuuJYCu2j7k/C9VDTGQv2ozoUdurNkmSINkMjrNb7sxaGP6egzkZl+j7 uv/Ntefi1ZY6rOEFU7netp0P+Ta/cF9NHNx66RJEDoKMAcg79VFlIhuZ6OKW903nHptM xuBQ== 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=vxAaLTkBoUBaCL/O3581iu7gQKfuo3i9c87P/ALffLw=; b=OJK4TH4aslNiqo23myrXLq/U81lPl5F60OuiA25BW3gu8JI5hNEWg82yN6yBvR0i1C xJ7YOw2WW3J5aFUj1/8YJJ2c/qFM9cjn2wibHOR7RgsPhXpjLD5mHcuZhM+X7/bAxTgf af+tzcO126DbOAj4c1i2dWrJ6oL3bhf+h29tT/M6Pb8JBZ45zn/TfGSQGmtd/0TX2We3 99qFskpuy7W7wk4W9E8Z5PCjaXj2AdCaMfWzH3SWcCVODNvsSSDVtG/qvBEhrs/8X1UK 4YPvuut61IngYn9WbA+haimd4aMGJCaFV6mF2/Jc9JqfBLdx0oxmcEHDdJswXieTUBoC /dQQ== X-Gm-Message-State: AOAM531Dez7fzfD+sPaYo2j/AsreDcAQWV9yp5tFkt+7nxSH5zrT0OHW yQRLKCcfJTaUuXN14OJ1izL2TlfgVLW39g== X-Received: by 2002:a05:600c:1f11:b0:392:aaf8:df7c with SMTP id bd17-20020a05600c1f1100b00392aaf8df7cmr3128422wmb.148.1650455139381; Wed, 20 Apr 2022 04:45:39 -0700 (PDT) Received: from localhost.localdomain ([94.73.37.128]) by smtp.gmail.com with ESMTPSA id i74-20020adf90d0000000b0020373ba7beesm17798204wri.0.2022.04.20.04.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 04:45:39 -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 v3 1/2] drm/vc4: hdmi: Replace drm_detect_hdmi_monitor() with is_hdmi Date: Wed, 20 Apr 2022 13:44:59 +0200 Message-Id: <20220420114500.187664-2-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220420114500.187664-1-jose.exposito89@gmail.com> References: <20220420114500.187664-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 in vc4_hdmi_encoder.hdmi_monitor, which is less efficient. Avoid calling drm_detect_hdmi_monitor() and use drm_display_info.is_hdmi instead. This also allows to remove vc4_hdmi_encoder.hdmi_monitor. 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é Expósito --- 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 6c58b0fd13fb..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 = &vc4_hdmi->encoder; + struct drm_display_info *display = &vc4_hdmi->connector.display_info; - return !vc4_encoder->hdmi_monitor || + return !display->is_hdmi || drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_FULL; } @@ -216,7 +216,6 @@ vc4_hdmi_connector_detect(struct drm_connector *connector, bool force) if (edid) { cec_s_phys_addr_from_edid(vc4_hdmi->cec_adap, edid); - vc4_hdmi->encoder.hdmi_monitor = drm_detect_hdmi_monitor(edid); kfree(edid); } } @@ -242,7 +241,6 @@ static void vc4_hdmi_connector_destroy(struct drm_connector *connector) static int vc4_hdmi_connector_get_modes(struct drm_connector *connector) { struct vc4_hdmi *vc4_hdmi = connector_to_vc4_hdmi(connector); - struct vc4_hdmi_encoder *vc4_encoder = &vc4_hdmi->encoder; int ret = 0; struct edid *edid; @@ -255,8 +253,6 @@ static int vc4_hdmi_connector_get_modes(struct drm_connector *connector) goto out; } - vc4_encoder->hdmi_monitor = drm_detect_hdmi_monitor(edid); - drm_connector_update_edid_property(connector, edid); ret = drm_add_edid_modes(connector, edid); kfree(edid); @@ -578,13 +574,12 @@ static void vc4_hdmi_set_infoframes(struct drm_encoder *encoder) static bool vc4_hdmi_supports_scrambling(struct drm_encoder *encoder, struct drm_display_mode *mode) { - struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder); struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); struct drm_display_info *display = &vc4_hdmi->connector.display_info; lockdep_assert_held(&vc4_hdmi->mutex); - if (!vc4_encoder->hdmi_monitor) + if (!display->is_hdmi) return false; 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 = encoder_to_vc4_hdmi(encoder); struct drm_display_mode *mode = &vc4_hdmi->saved_adjusted_mode; - struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder); + struct drm_display_info *display = &vc4_hdmi->connector.display_info; bool hsync_pos = mode->flags & DRM_MODE_FLAG_PHSYNC; bool vsync_pos = 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); - 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"); } - if (vc4_encoder->hdmi_monitor) { + if (display->is_hdmi) { spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); 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; }; static inline struct vc4_hdmi_encoder * -- 2.25.1