1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright (c) 2020 Intel Corporation
5 * sof_sdw_hdmi - Helpers to handle HDMI from generic machine driver
8 #include <linux/device.h>
9 #include <linux/errno.h>
10 #include <linux/kernel.h>
11 #include <linux/list.h>
12 #include <sound/soc.h>
13 #include <sound/soc-acpi.h>
14 #include <sound/jack.h>
15 #include "sof_sdw_common.h"
16 #include "../../codecs/hdac_hdmi.h"
17 #include "hda_dsp_common.h"
19 static struct snd_soc_jack hdmi
[MAX_HDMI_NUM
];
22 struct list_head head
;
23 struct snd_soc_dai
*codec_dai
;
27 int sof_sdw_hdmi_init(struct snd_soc_pcm_runtime
*rtd
)
29 struct mc_private
*ctx
= snd_soc_card_get_drvdata(rtd
->card
);
30 struct snd_soc_dai
*dai
= asoc_rtd_to_codec(rtd
, 0);
33 pcm
= devm_kzalloc(rtd
->card
->dev
, sizeof(*pcm
), GFP_KERNEL
);
37 /* dai_link id is 1:1 mapped to the PCM device */
38 pcm
->device
= rtd
->dai_link
->id
;
41 list_add_tail(&pcm
->head
, &ctx
->hdmi_pcm_list
);
47 int sof_sdw_hdmi_card_late_probe(struct snd_soc_card
*card
)
49 struct mc_private
*ctx
= snd_soc_card_get_drvdata(card
);
51 struct snd_soc_component
*component
= NULL
;
53 char jack_name
[NAME_SIZE
];
55 if (!ctx
->idisp_codec
)
58 if (list_empty(&ctx
->hdmi_pcm_list
))
61 pcm
= list_first_entry(&ctx
->hdmi_pcm_list
, struct hdmi_pcm
,
63 component
= pcm
->codec_dai
->component
;
65 if (ctx
->common_hdmi_codec_drv
)
66 return hda_dsp_hdmi_build_controls(card
, component
);
68 list_for_each_entry(pcm
, &ctx
->hdmi_pcm_list
, head
) {
69 component
= pcm
->codec_dai
->component
;
70 snprintf(jack_name
, sizeof(jack_name
),
71 "HDMI/DP, pcm=%d Jack", pcm
->device
);
72 err
= snd_soc_card_jack_new(card
, jack_name
,
73 SND_JACK_AVOUT
, &hdmi
[i
],
79 err
= snd_jack_add_new_kctl(hdmi
[i
].jack
,
80 jack_name
, SND_JACK_AVOUT
);
82 dev_warn(component
->dev
, "failed creating Jack kctl\n");
84 err
= hdac_hdmi_jack_init(pcm
->codec_dai
, pcm
->device
,
95 return hdac_hdmi_jack_port_init(component
, &card
->dapm
);