From nobody Mon Sep 28 17:49:30 2026 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0693248034A for ; Wed, 19 Aug 2026 15:28:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787153292; cv=none; b=a8XjL4V8wDE42hwtA32u8bhdb2xxuCH1rTpH6AYE3+6R9JJ1qpizBChstQiI4BsFtor3+kwcc0T4D/iH08iIzrlpySJjHxgVX/uZhWOexKhqv5UmvEHDNbzLKMtTc+0hp3808cCjJOdzeUSfZPOob0TGdbmAhHDqltolFbSG9JI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787153292; c=relaxed/simple; bh=B6Pe+yxzn2tORwlGVgICYqclGje223dLGMWCyG3CUKk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=aOxCnEB7r5aeRUPwgfCmvE9mHYb8zdZ32Q+SsQKWGQTFX3c/LGnjrEAaq/TBbqXWBetR38bzCLPRnRkl/9B7sPELkh2GF2B7FZPrBhysSiRhs36/ULq96aFz0t6DacGl+ujT/j92LMN8bX7ood31ISq7KAUwfo7SlMXXq46OH7E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nHB5S+P8; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nHB5S+P8" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-49557167508so12367935e9.1 for ; Wed, 19 Aug 2026 08:28:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787153288; x=1787758088; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=4O6b3uVfHCg73+g5tRn+qNdLjjRqVvCx0BGFx/lfSs4=; b=nHB5S+P8s6L0hwgs2eskR7Qb0ovG/qGQO0LekhYpAornmY/UteQ0PtifbijKNnEE3r 7/YEW3gWheq8NqFkm5Xjm5bNHKl93zCGMSh/3fh/gs2WZ2lSA3Ab46dwr4KRlTaeL+ll o44J4J2JZagjbD4JrvjdBW3AsdB1cuqUQsS9hQKQT7z8S1trXtVBZfGo5k1bIz6xAFzl L3hX3r+3JWl75a7cHPvFZeEQy+9Cl7WGO+puZ7NoqhumVtKkUMayMKdTLEZEZn0022ZG LHevfINcJGH7iVztzLMNhBTlf44mDjknlck6V4/kdnLZHDw8Dc5l3jZbB6Aihtea7GD0 PYLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787153288; x=1787758088; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=4O6b3uVfHCg73+g5tRn+qNdLjjRqVvCx0BGFx/lfSs4=; b=Y+w7e9eG/5GOZRX+GMidFwCG12/wIKWQhziQVoaN1SVM+u0LiOomDJgyVXmRpITOcb RoZyfKv2AX92CYYeb5blQoVR/5w6nO9cY/oA/hHl4rSUKdAI4rZTOQekr8qVfAvvdOBN mtHsUBJN/52YIx3rA8OlPAweEicv4XgS3bN3NjPnnVyi9qKp8z/yBMU20AaNYd5W4Rnx I8yL/MjgrLpQFfPdXsvJTfMr1nKfmr487vdnxZQYU7vcTWMxz5Y4UBHvKSGotCU9aXLj 3QGIwzJY1XWjK0kCIEcgRsiTHVsuB0KluPmBFc/BnHpjCAi/qW4uq2li+Oj1XvxU3Qny w1OA== X-Forwarded-Encrypted: i=1; AHgh+Rq1PThmGmU/pqO37vs8oK2SWM13WNLXaXi8a3TLk2ICYZcLfERNtAQkAiFjtL9Y1ahSTzDbwS3u8/0tYb8=@vger.kernel.org X-Gm-Message-State: AOJu0YzD1EXCb0Q9bkkHvTjF7O8Ri0RTwgt9TwBZ4GOML+N+c7DFZDN/ cx25oj8rvEj3mfgGHkIihahTGGOuTmorSsqIUO5961Hh0U3mKVRU880z X-Gm-Gg: AR+sD10Le3byv31cCRENiLI/pYY8P3KPqpsebGyupE7iiiilC+3Xer167bdeda6MI+t 5Zm/2okAeisVo48hRfdD9N1rPfpfIifAvbexnvw4m3KnonRs7rxJOkfHmFw0zmpGWaSaO90wRNo hHBYC6EU273ex3Y7QSTGMYu0ySp2w1ANoWTusXuEn2rg/60c/EGOE8mAHzpcd+CewwRv4iIfM/T DxTH4hqAOJYqt130K5fMfFj26dLo6QPeEP1n2WndnKztzY05llBqMNLxBL/8Czy7TZQzgw2emSp n4zSLwN7s4xBtzAs+y9wBt6DFxzSHYPPnT8VozHKvHN3C4QRKFjXm6J+eSgsmvddJQ2dvkbkLGD NgRjHx2mH/1D+mu4OODpfnLZ8Hks5zxc7YU197/mcuKaJBRqF0g+VPzAovQfN2/6842+V/4CLtb Vc7zkz19cI0bFFNo4N6l8kduKE4X0iAW6AHxm0LfAAPWKluyPAG2VoptS421BzyBU+dg0AbdhUH 2FrnpNxGw== X-Received: by 2002:a05:600c:c493:b0:499:7aa7:eaa7 with SMTP id 5b1f17b1804b1-499aa20c7b1mr95860655e9.15.1787153287944; Wed, 19 Aug 2026 08:28:07 -0700 (PDT) Received: from localhost.localdomain ([95.43.220.235]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-499a9dff4c1sm47667655e9.3.2026.08.19.08.28.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2026 08:28:07 -0700 (PDT) From: Ivaylo Dimitrov To: Tomi Valkeinen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Jaroslav Kysela , Takashi Iwai , Jarkko Nikula , Sen Wang , Liam Girdwood , Mark Brown , Jakub Kicinski , Alex Deucher Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org, linux-omap@vger.kernel.org, Ivaylo Dimitrov Subject: [PATCH v2] drm/omap: Report HDMI hotplug events to the ASoC HDMI codec Date: Wed, 19 Aug 2026 18:27:55 +0300 Message-Id: <20260819152755.231754-1-ivo.g.dimitrov.75@gmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The OMAP HDMI audio driver currently has no way of reporting HDMI cable hotplug events to ASoC. As a result, user space cannot detect HDMI audio availability through the standard jack mechanism and audio policy managers cannot automatically route audio to or from the HDMI output. Add an optional HPD callback to `omap_hdmi_audio_pdata` and invoke it from the DRM HDMI bridge whenever the connector status changes. The HDMI audio driver registers an ASoC jack and reports `SND_JACK_AVOUT` state changes in response to these notifications. Also fix the disconnect path by taking a runtime PM reference before updating the CEC physical address. Signed-off-by: Ivaylo Dimitrov Acked-by: Mark Brown --- drivers/gpu/drm/omapdrm/dss/hdmi.h | 6 +++ drivers/gpu/drm/omapdrm/dss/hdmi4.c | 29 ++++++++++--- drivers/gpu/drm/omapdrm/dss/hdmi5.c | 36 ++++++++++++--- drivers/gpu/drm/omapdrm/dss/hdmi_common.c | 14 ++++++ include/sound/omap-hdmi-audio.h | 1 + sound/soc/ti/omap-hdmi.c | 53 +++++++++++++++++++++-- 6 files changed, 124 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi.h b/drivers/gpu/drm/omapdrm/d= ss/hdmi.h index c4a4e07f0b99..a79d4590611f 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi.h +++ b/drivers/gpu/drm/omapdrm/dss/hdmi.h @@ -15,6 +15,7 @@ #include #include #include +#include =20 #include "omapdss.h" #include "dss.h" @@ -368,6 +369,8 @@ struct omap_hdmi { struct drm_bridge bridge; =20 struct platform_device *audio_pdev; + struct mutex audio_lock; + void (*audio_abort_cb)(struct device *dev); int wp_idlemode; =20 @@ -380,6 +383,9 @@ struct omap_hdmi { bool display_enabled; }; =20 +void hdmi_audio_hpd_notify(struct omap_hdmi *hdmi, + enum drm_connector_status status); + #define drm_bridge_to_hdmi(b) container_of(b, struct omap_hdmi, bridge) =20 #endif diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/= dss/hdmi4.c index e306247ed8a0..e0e077397b77 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c @@ -433,8 +433,15 @@ static void hdmi4_bridge_hpd_notify(struct drm_bridge = *bridge, { struct omap_hdmi *hdmi =3D drm_bridge_to_hdmi(bridge); =20 - if (status =3D=3D connector_status_disconnected) + hdmi_audio_hpd_notify(hdmi, status); + + if (status =3D=3D connector_status_disconnected) { + if (hdmi_runtime_get(hdmi)) + return; + hdmi4_cec_set_phys_addr(&hdmi->core, CEC_PHYS_ADDR_INVALID); + hdmi_runtime_put(hdmi); + } } =20 static const struct drm_edid *hdmi4_bridge_edid_read(struct drm_bridge *br= idge, @@ -626,12 +633,17 @@ static int hdmi_audio_register(struct omap_hdmi *hdmi) .ops =3D &hdmi_audio_ops, }; =20 + guard(mutex)(&hdmi->audio_lock); hdmi->audio_pdev =3D platform_device_register_data( &hdmi->pdev->dev, "omap-hdmi-audio", PLATFORM_DEVID_AUTO, &pdata, sizeof(pdata)); =20 - if (IS_ERR(hdmi->audio_pdev)) - return PTR_ERR(hdmi->audio_pdev); + if (IS_ERR(hdmi->audio_pdev)) { + int err =3D PTR_ERR(hdmi->audio_pdev); + + hdmi->audio_pdev =3D NULL; + return err; + } =20 return 0; } @@ -688,8 +700,14 @@ static void hdmi4_unbind(struct device *dev, struct de= vice *master, void *data) =20 dss_debugfs_remove_file(hdmi->debugfs); =20 - if (hdmi->audio_pdev) - platform_device_unregister(hdmi->audio_pdev); + scoped_guard(mutex, &hdmi->audio_lock) { + if (hdmi->audio_pdev) { + struct platform_device *pdev =3D hdmi->audio_pdev; + + hdmi->audio_pdev =3D NULL; + platform_device_unregister(pdev); + } + } =20 hdmi4_cec_uninit(&hdmi->core); hdmi_pll_uninit(&hdmi->pll); @@ -770,6 +788,7 @@ static int hdmi4_probe(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, hdmi); =20 mutex_init(&hdmi->lock); + mutex_init(&hdmi->audio_lock); spin_lock_init(&hdmi->audio_playing_lock); =20 r =3D hdmi4_probe_of(hdmi); diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/= dss/hdmi5.c index ab2d4eb6787f..76aedc1c9ba1 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c @@ -425,6 +425,14 @@ static void hdmi5_bridge_disable(struct drm_bridge *br= idge, mutex_unlock(&hdmi->lock); } =20 +static void hdmi5_bridge_hpd_notify(struct drm_bridge *bridge, + enum drm_connector_status status) +{ + struct omap_hdmi *hdmi =3D drm_bridge_to_hdmi(bridge); + + hdmi_audio_hpd_notify(hdmi, status); +} + static const struct drm_edid *hdmi5_bridge_edid_read(struct drm_bridge *br= idge, struct drm_connector *connector) { @@ -475,6 +483,7 @@ static const struct drm_bridge_funcs hdmi5_bridge_funcs= =3D { .atomic_reset =3D drm_atomic_helper_bridge_reset, .atomic_enable =3D hdmi5_bridge_enable, .atomic_disable =3D hdmi5_bridge_disable, + .hpd_notify =3D hdmi5_bridge_hpd_notify, .edid_read =3D hdmi5_bridge_edid_read, }; =20 @@ -601,12 +610,18 @@ static int hdmi_audio_register(struct omap_hdmi *hdmi) .ops =3D &hdmi_audio_ops, }; =20 - hdmi->audio_pdev =3D platform_device_register_data( - &hdmi->pdev->dev, "omap-hdmi-audio", PLATFORM_DEVID_AUTO, - &pdata, sizeof(pdata)); + scoped_guard(mutex, &hdmi->audio_lock) { + hdmi->audio_pdev =3D platform_device_register_data( + &hdmi->pdev->dev, "omap-hdmi-audio", + PLATFORM_DEVID_AUTO, &pdata, sizeof(pdata)); =20 - if (IS_ERR(hdmi->audio_pdev)) - return PTR_ERR(hdmi->audio_pdev); + if (IS_ERR(hdmi->audio_pdev)) { + int err =3D PTR_ERR(hdmi->audio_pdev); + + hdmi->audio_pdev =3D NULL; + return err; + } + } =20 hdmi_runtime_get(hdmi); hdmi->wp_idlemode =3D @@ -654,8 +669,14 @@ static void hdmi5_unbind(struct device *dev, struct de= vice *master, void *data) =20 dss_debugfs_remove_file(hdmi->debugfs); =20 - if (hdmi->audio_pdev) - platform_device_unregister(hdmi->audio_pdev); + scoped_guard(mutex, &hdmi->audio_lock) { + if (hdmi->audio_pdev) { + struct platform_device *pdev =3D hdmi->audio_pdev; + + hdmi->audio_pdev =3D NULL; + platform_device_unregister(pdev); + } + } =20 hdmi_pll_uninit(&hdmi->pll); } @@ -735,6 +756,7 @@ static int hdmi5_probe(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, hdmi); =20 mutex_init(&hdmi->lock); + mutex_init(&hdmi->audio_lock); spin_lock_init(&hdmi->audio_playing_lock); =20 r =3D hdmi5_probe_of(hdmi); diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_common.c b/drivers/gpu/drm/om= apdrm/dss/hdmi_common.c index 3ecde23ac604..e9adc5775913 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi_common.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_common.c @@ -147,3 +147,17 @@ int hdmi_compute_acr(u32 pclk, u32 sample_freq, u32 *n= , u32 *cts) =20 return 0; } + +void hdmi_audio_hpd_notify(struct omap_hdmi *hdmi, + enum drm_connector_status status) +{ + guard(mutex)(&hdmi->audio_lock); + + if (hdmi->audio_pdev) { + struct device *dev =3D &hdmi->audio_pdev->dev; + struct omap_hdmi_audio_pdata *ha =3D dev_get_platdata(dev); + + if (ha->audio_hpd) + ha->audio_hpd(dev, status =3D=3D connector_status_connected); + } +} diff --git a/include/sound/omap-hdmi-audio.h b/include/sound/omap-hdmi-audi= o.h index e5f82044a404..8dca92360ee0 100644 --- a/include/sound/omap-hdmi-audio.h +++ b/include/sound/omap-hdmi-audio.h @@ -34,6 +34,7 @@ struct omap_hdmi_audio_pdata { phys_addr_t audio_dma_addr; =20 const struct omap_hdmi_audio_ops *ops; + void (*audio_hpd)(struct device *dev, bool connected); }; =20 #endif /* __OMAP_HDMI_AUDIO_H__ */ diff --git a/sound/soc/ti/omap-hdmi.c b/sound/soc/ti/omap-hdmi.c index e60f5b483fc5..90ce12a81246 100644 --- a/sound/soc/ti/omap-hdmi.c +++ b/sound/soc/ti/omap-hdmi.c @@ -17,6 +17,7 @@ #include #include #include +#include #include =20 #include "sdma-pcm.h" @@ -35,6 +36,8 @@ struct hdmi_audio_data { =20 struct mutex current_stream_lock; struct snd_pcm_substream *current_stream; + struct snd_soc_jack jack; + atomic_t jack_state; }; =20 static @@ -262,6 +265,34 @@ static void hdmi_dai_shutdown(struct snd_pcm_substream= *substream, ad->current_stream =3D NULL; } =20 +static void hdmi_audio_hpd(struct device *dev, bool connected) +{ + struct hdmi_audio_data *ad =3D dev_get_drvdata(dev); + + if (atomic_xchg(&ad->jack_state, connected) =3D=3D connected) + return; + + snd_soc_jack_report(&ad->jack, + connected ? SND_JACK_AVOUT : 0, SND_JACK_AVOUT); + dev_dbg(dev, "HDMI %s\n", connected ? "CONNECTED" : "DISCONNECTED"); +} + +static int hdmi_audio_dai_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_card *card =3D rtd->card; + struct hdmi_audio_data *ad =3D snd_soc_card_get_drvdata(rtd->card); + int ret; + + ret =3D snd_soc_card_jack_new( + card, "HDMI", SND_JACK_AVOUT, &ad->jack); + if (ret < 0) { + dev_err(card->dev, "Cannot create HDMI jack: %i\n", ret); + return ret; + } + + return 0; +} + static const struct snd_soc_dai_ops hdmi_dai_ops =3D { .startup =3D hdmi_dai_startup, .hw_params =3D hdmi_dai_hw_params, @@ -371,28 +402,44 @@ static int omap_hdmi_audio_probe(struct platform_devi= ce *pdev) card->dai_link->stream_name =3D card->name; card->dai_link->cpus->dai_name =3D dev_name(ad->dssdev); card->dai_link->platforms->name =3D dev_name(ad->dssdev); + card->dai_link->init =3D hdmi_audio_dai_init; card->num_links =3D 1; card->dev =3D dev; =20 + atomic_set(&ad->jack_state, -1); + ad->card =3D card; + + snd_soc_card_set_drvdata(card, ad); ret =3D devm_snd_soc_register_card(dev, card); if (ret) { dev_err(dev, "snd_soc_register_card failed (%d)\n", ret); return ret; } =20 - ad->card =3D card; - snd_soc_card_set_drvdata(card, ad); - dev_set_drvdata(dev, ad); =20 + ha->audio_hpd =3D hdmi_audio_hpd; + return 0; } =20 +static void omap_hdmi_audio_remove(struct platform_device *pdev) +{ + struct omap_hdmi_audio_pdata *ha =3D pdev->dev.platform_data; + + /* + * hdmi4_unbind() holds audio lock across platform_device_unregister(), + * so audio_hpd() cannot run concurrently with this callback. + */ + ha->audio_hpd =3D NULL; +} + static struct platform_driver hdmi_audio_driver =3D { .driver =3D { .name =3D DRV_NAME, }, .probe =3D omap_hdmi_audio_probe, + .remove =3D omap_hdmi_audio_remove, }; =20 module_platform_driver(hdmi_audio_driver); --=20 2.25.1