1 // SPDX-License-Identifier: GPL-2.0-only
3 // Copyright(c) 2019 Intel Corporation
5 #include <linux/module.h>
8 #include <sound/hda_codec.h>
9 #include <sound/hda_i915.h>
10 #include "../../codecs/hdac_hda.h"
12 #include "hda_dsp_common.h"
14 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
17 * Search card topology and return PCM device number
18 * matching Nth HDMI device (zero-based index).
20 static struct snd_pcm
*hda_dsp_hdmi_pcm_handle(struct snd_soc_card
*card
,
23 struct snd_soc_pcm_runtime
*rtd
;
27 for_each_card_rtds(card
, rtd
) {
29 rtd
->pcm
->streams
[SNDRV_PCM_STREAM_PLAYBACK
].pcm
: NULL
;
30 if (spcm
&& strstr(spcm
->id
, "HDMI")) {
41 * Search card topology and register HDMI PCM related controls
44 int hda_dsp_hdmi_build_controls(struct snd_soc_card
*card
,
45 struct snd_soc_component
*comp
)
47 struct hdac_hda_priv
*hda_pvt
;
48 struct hda_codec
*hcodec
;
56 hda_pvt
= snd_soc_component_get_drvdata(comp
);
57 hcodec
= hda_pvt
->codec
;
59 list_for_each_entry(hpcm
, &hcodec
->pcm_list_head
, list
) {
60 spcm
= hda_dsp_hdmi_pcm_handle(card
, i
);
63 hpcm
->device
= spcm
->device
;
65 "mapping HDMI converter %d to PCM %d (%p)\n",
66 i
, hpcm
->device
, spcm
);
69 hpcm
->device
= SNDRV_PCM_INVALID_DEVICE
;
71 "%s: no PCM in topology for HDMI converter %d\n",
76 snd_hdac_display_power(hcodec
->core
.bus
,
77 HDA_CODEC_IDX_CONTROLLER
, true);
78 err
= snd_hda_codec_build_controls(hcodec
);
80 dev_err(card
->dev
, "unable to create controls %d\n", err
);
81 snd_hdac_display_power(hcodec
->core
.bus
,
82 HDA_CODEC_IDX_CONTROLLER
, false);
86 EXPORT_SYMBOL_NS(hda_dsp_hdmi_build_controls
, "SND_SOC_INTEL_HDA_DSP_COMMON");
90 MODULE_DESCRIPTION("ASoC Intel HDMI helpers");
91 MODULE_LICENSE("GPL");