5353#include <linux/reset.h>
5454#include <sound/dmaengine_pcm.h>
5555#include <sound/hdmi-codec.h>
56+ #include <sound/jack.h>
5657#include <sound/pcm_drm_eld.h>
5758#include <sound/pcm_params.h>
5859#include <sound/soc.h>
@@ -392,6 +393,12 @@ static void vc4_hdmi_handle_hotplug(struct vc4_hdmi *vc4_hdmi,
392393 struct drm_connector * connector = & vc4_hdmi -> connector ;
393394 int ret ;
394395
396+ /*
397+ * Needs to be called for both connects and disconnects for HDMI
398+ * audio hotplug to work correctly.
399+ */
400+ drm_atomic_helper_connector_hdmi_hotplug (connector , status );
401+
395402 /*
396403 * NOTE: This function should really be called with vc4_hdmi->mutex
397404 * held, but doing so results in reentrancy issues since
@@ -411,8 +418,6 @@ static void vc4_hdmi_handle_hotplug(struct vc4_hdmi *vc4_hdmi,
411418 return ;
412419 }
413420
414- drm_atomic_helper_connector_hdmi_hotplug (connector , status );
415-
416421 cec_s_phys_addr (vc4_hdmi -> cec_adap ,
417422 connector -> display_info .source_physical_address , false);
418423
@@ -2234,6 +2239,22 @@ static const struct drm_connector_hdmi_audio_funcs vc4_hdmi_audio_funcs = {
22342239 .shutdown = vc4_hdmi_audio_shutdown ,
22352240};
22362241
2242+ static int vc4_hdmi_codec_init (struct snd_soc_pcm_runtime * rtd )
2243+ {
2244+ struct vc4_hdmi * vc4_hdmi = snd_soc_card_get_drvdata (rtd -> card );
2245+ struct snd_soc_component * component = snd_soc_rtd_to_codec (rtd , 0 )-> component ;
2246+ int ret ;
2247+
2248+ ret = snd_soc_card_jack_new (rtd -> card , "HDMI Jack" , SND_JACK_LINEOUT ,
2249+ & vc4_hdmi -> hdmi_jack );
2250+ if (ret ) {
2251+ dev_err (rtd -> dev , "HDMI Jack creation failed: %d\n" , ret );
2252+ return ret ;
2253+ }
2254+
2255+ return snd_soc_component_set_jack (component , & vc4_hdmi -> hdmi_jack , NULL );
2256+ }
2257+
22372258static int vc4_hdmi_audio_init (struct vc4_hdmi * vc4_hdmi )
22382259{
22392260 const struct vc4_hdmi_register * mai_data =
@@ -2348,6 +2369,8 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)
23482369 dai_link -> codecs -> name = dev_name (& vc4_hdmi -> connector .hdmi_audio .codec_pdev -> dev );
23492370 dai_link -> platforms -> name = dev_name (dev );
23502371
2372+ dai_link -> init = vc4_hdmi_codec_init ;
2373+
23512374 card -> dai_link = dai_link ;
23522375 card -> num_links = 1 ;
23532376 card -> name = vc4_hdmi -> variant -> card_name ;
0 commit comments