From patchwork Sat Feb 22 10:29:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13986584 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 EE691C021B2 for ; Sat, 22 Feb 2025 10:29:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4B6B610E0D0; Sat, 22 Feb 2025 10:29:54 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; secure) header.d=gmx.net header.i=wahrenst@gmx.net header.b="QJuogXv3"; dkim-atps=neutral Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0097D10E0D0 for ; Sat, 22 Feb 2025 10:29:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1740220174; x=1740824974; i=wahrenst@gmx.net; bh=RVF+waKK5ZBI1JS3kddeE8jXPtiMFH4dzYwp19EAyb8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-Id: MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=QJuogXv3iqfxnRBQgvmFgvM6l5rGRgTJycaFshuA2SYpjXcUo2jrCCTKGABJQV0B yX6ctWeFSZGW4qXjMEXs7exHCBnYr6e5wRFvCsd8HLlVJJOYi7SJ+tyWltoX+46no Hazf3Owl301SRCLSoWcEgXPiqUgK9qRVKFguVU7yYq4B4BH98eaQDkFFqx0Vp5O5t Wz3WHyVSO5JqB1zFKivxulPB6gzWY69wZ2F6dvxfPzeXJoHsdj/whbSAJdMyRZ+Cs dORxzhP7O4Ta3KDofF6ni71hr7sxzQeJ50ThITdCnC7E0iU6gR3eqf2hj51ZSmWce /d+Kgu0hSqF9NH6ZUQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.251.153]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MXp5a-1tp8q22uqK-00Stsi; Sat, 22 Feb 2025 11:29:34 +0100 From: Stefan Wahren To: Maxime Ripard , Dave Stevenson , =?utf-8?q?Ma=C3=ADra_Canal?= , Maarten Lankhorst , Thomas Zimmermann Cc: David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org, kernel-list@raspberrypi.com, linux-sound@vger.kernel.org, David Turner , Stefan Wahren Subject: [PATCH RFC] drm/vc4: hdmi: Add jack detection to HDMI audio driver Date: Sat, 22 Feb 2025 11:29:21 +0100 Message-Id: <20250222102921.75496-1-wahrenst@gmx.net> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:gapLJoOGDRGX1NZ2CoyUGA3VVYaDHoroP8hRvYOm7gbv0Vtv7lI uNtyouTviXbwrB2oOz0K/4x/4onRyVPDYgjqxefWWFtfHKgIW4k+YKvEX0cJ/mCz1mVi2Pl qbGn3yOtGMFlQHvly7ADF4drTmeW+l/+A4HPfYnlifeMHSR0GDs7FbJqz0WtOQOOaWJVmKB m4JarOO4pjVjQ2py65iHQ== UI-OutboundReport: notjunk:1;M01:P0:t0Nv7QICJJI=;2YDOopp0CjdueF5YNRMgRjAD6Mn OUaWrQ2XKlHRbzKnQD1WPvqi5GsenDNbWzXsn0Ag8wcljlft6KpfoEZ8LJaVGStBZbvltR3y5 KbafBj1/65dZCdtrivlmMP2PGxdtD5Qj8zFAsnWHokhkFq80rQkyd7kxJIWK3TRwK4HmlmWqW 9hCgMIPkslVAGlf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NY ihaGc9VUgl1JzKOK7KUNIgbhNQiWcHT4bAwpOvBLpcME3W2nQnINQjJmNaBjQsHu4iT70beG/ CEdeDikQbj4kb3C2gPO2FZ3hP8LzUwHYHXHOAi/qpedtp1cas3QlcC3Vukt+NlBlPBadC7nvA egB6VlE0aHHUiOYrtIjRz8Z9mU5xmyxXydh/Qwk4noHNlt9sBYuRGHH3+Uhq1yYTebDDpsveH Aehfs7Q== 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" From: David Turner Add ALSA jack detection to the vc4-hdmi audio driver so userspace knows when to add/remove HDMI audio devices. Signed-off-by: David Turner Signed-off-by: Stefan Wahren --- drivers/gpu/drm/vc4/vc4_hdmi.c | 26 ++++++++++++++++++++++++-- drivers/gpu/drm/vc4/vc4_hdmi.h | 7 +++++++ 2 files changed, 31 insertions(+), 2 deletions(-) -- 2.34.1 diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 47d9ada98430..d24ae86d799e 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -386,6 +387,12 @@ static void vc4_hdmi_handle_hotplug(struct vc4_hdmi *vc4_hdmi, struct drm_connector *connector = &vc4_hdmi->connector; int ret; + /* + * Needs to be called for both connects and disconnects for HDMI + * audio hotplug to work correctly. + */ + drm_atomic_helper_connector_hdmi_hotplug(connector, status); + /* * NOTE: This function should really be called with vc4_hdmi->mutex * held, but doing so results in reentrancy issues since @@ -405,8 +412,6 @@ static void vc4_hdmi_handle_hotplug(struct vc4_hdmi *vc4_hdmi, return; } - drm_atomic_helper_connector_hdmi_hotplug(connector, status); - cec_s_phys_addr(vc4_hdmi->cec_adap, connector->display_info.source_physical_address, false); @@ -2203,6 +2208,22 @@ static const struct drm_connector_hdmi_audio_funcs vc4_hdmi_audio_funcs = { .shutdown = vc4_hdmi_audio_shutdown, }; +static int vc4_hdmi_codec_init(struct snd_soc_pcm_runtime *rtd) +{ + struct vc4_hdmi *vc4_hdmi = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component; + int ret; + + ret = snd_soc_card_jack_new(rtd->card, "HDMI Jack", SND_JACK_LINEOUT, + &vc4_hdmi->hdmi_jack); + if (ret) { + dev_err(rtd->dev, "HDMI Jack creation failed: %d\n", ret); + return ret; + } + + return snd_soc_component_set_jack(component, &vc4_hdmi->hdmi_jack, NULL); +} + static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi) { const struct vc4_hdmi_register *mai_data = @@ -2316,6 +2337,7 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi) dai_link->cpus->dai_name = dev_name(dev); dai_link->codecs->name = dev_name(&vc4_hdmi->connector.hdmi_audio.codec_pdev->dev); dai_link->platforms->name = dev_name(dev); + dai_link->init = vc4_hdmi_codec_init; card->dai_link = dai_link; card->num_links = 1; diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h index e3d989ca302b..a31157c99bee 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.h +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include "vc4_drv.h" @@ -211,6 +212,12 @@ struct vc4_hdmi { * KMS hooks. Protected by @mutex. */ enum hdmi_colorspace output_format; + + /** + * @hdmi_jack: Represents the connection state of the HDMI plug, for + * ALSA jack detection. + */ + struct snd_soc_jack hdmi_jack; }; #define connector_to_vc4_hdmi(_connector) \