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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F765C433EF for ; Mon, 25 Oct 2021 14:11:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E859460F70 for ; Mon, 25 Oct 2021 14:11:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E859460F70 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BC4F96E03A; Mon, 25 Oct 2021 14:11:51 +0000 (UTC) Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2A1686E063 for ; Mon, 25 Oct 2021 14:11:36 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id 7508F5805BE; Mon, 25 Oct 2021 10:11:35 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 25 Oct 2021 10:11:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=/DaMsh8ayKxva qkX74ptS4WXCO/EEx+iDCGiXC/BLa4=; b=T/QaoiVLYTe2kqFofXzlceqZPImVb 54Z4A4hd2lOgs8kA/QrPLCALXOx+WPZqXLeDOWbC1vda3giwnxsuWf3bViJOAVYi mJg0gi/r+u0C425PtFpIWXK6ISn35TJVyhdOikY/mjbLU86SUk2p0Wo8Jzd/kSx2 QNsxfDIc4KvE4nozI1Iz1Ef/KeRiEgDez84pWYf0yys1FGmQZKja0e2os4yijz4F w8c1xtpk/78BML6gpNArUWe3rYHwDvAIJwGH+81uOSId6MWcSoLdrPc76kUhLmHt dC1zyJOu8HfC59KRe5NPp99ha/3Lb6TpsKcnOdz10ZxccmINqIgQ7/FkQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=/DaMsh8ayKxvaqkX74ptS4WXCO/EEx+iDCGiXC/BLa4=; b=fcPybdzg X3ziJ4I293B5riBPuXMo838lVdZbWOByLMNfuA6E0RB6/fmNOqkSL3CPwqdAPUhm 0881vxBpwbaoUokLBxOZOfloRU/aiIJqKE5wbatGWBua7jBkX0uwGWnuKRFnJukg XwTDM0y/c4oMR9eoFApS/6UMLAngOSgM+5Rc14jjzoHMLE6fSwNWHvGIlsWhMd55 uXsKrepSQu1f/KznCCUgli+nJT6JxTPs+GYIVqn3qOWRBpqqq4tB+sz/Bu+bxHMS UD9wAyKt7no3TebYfgclsKV+ofvPkh24go9Ke0N5IEguND6uzoDoALpnCcP072bS Ev8WMwdol/BpkQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvdefhedgheehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmh grgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 25 Oct 2021 10:11:34 -0400 (EDT) From: Maxime Ripard To: Daniel Vetter , David Airlie , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard Cc: Dave Stevenson , Phil Elwell , Tim Gover , Dom Cobley , dri-devel@lists.freedesktop.org, Sudip Mukherjee Subject: [PATCH 8/9] drm/vc4: hdmi: Introduce an output_enabled flag Date: Mon, 25 Oct 2021 16:11:12 +0200 Message-Id: <20211025141113.702757-9-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211025141113.702757-1-maxime@cerno.tech> References: <20211025141113.702757-1-maxime@cerno.tech> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We currently poke at encoder->crtc in the ALSA code path to determine whether the HDMI output is enabled or not, and thus whether we should allow the audio output. However, that pointer is deprecated and shouldn't really be used by atomic drivers anymore. Since we have the infrastructure in place now, let's just create a flag that we toggle to report whether the controller is currently enabled and use that instead of encoder->crtc in ALSA. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_hdmi.c | 16 ++++++++++++---- drivers/gpu/drm/vc4/vc4_hdmi.h | 6 ++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 291fad018be3..8fb8e7e57f9c 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -724,6 +724,11 @@ static void vc4_hdmi_encoder_post_crtc_powerdown(struct drm_encoder *encoder, static void vc4_hdmi_encoder_disable(struct drm_encoder *encoder) { + struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); + + mutex_lock(&vc4_hdmi->mutex); + vc4_hdmi->output_enabled = false; + mutex_unlock(&vc4_hdmi->mutex); } static void vc4_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, bool enable) @@ -1217,6 +1222,11 @@ static void vc4_hdmi_encoder_post_crtc_enable(struct drm_encoder *encoder, static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) { + struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); + + mutex_lock(&vc4_hdmi->mutex); + vc4_hdmi->output_enabled = true; + mutex_unlock(&vc4_hdmi->mutex); } static void vc4_hdmi_encoder_atomic_mode_set(struct drm_encoder *encoder, @@ -1396,14 +1406,12 @@ static inline struct vc4_hdmi *dai_to_hdmi(struct snd_soc_dai *dai) static bool vc4_hdmi_audio_can_stream(struct vc4_hdmi *vc4_hdmi) { - struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base; - lockdep_assert_held(&vc4_hdmi->mutex); /* - * The encoder doesn't have a CRTC until the first modeset. + * If the controller is disabled, prevent any ALSA output. */ - if (!encoder->crtc) + if (!vc4_hdmi->output_enabled) return false; /* diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h index a43cc5614d19..5d3e97703e8d 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.h +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h @@ -203,6 +203,12 @@ struct vc4_hdmi { * for use by ALSA hooks and interrupt handlers. Protected by @mutex. */ struct drm_display_mode saved_adjusted_mode; + + /** + * @output_enabled: Is the HDMI controller currently active? + * Protected by @mutex. + */ + bool output_enabled; }; static inline struct vc4_hdmi * -- 2.31.1