1 // SPDX-License-Identifier: GPL-2.0
3 // Copyright(c) 2019 Intel Corporation. All rights reserved.
7 #include <sound/hda_codec.h>
8 #include <sound/hda_i915.h>
9 #include "../../codecs/hdac_hda.h"
11 #include "hda_dsp_common.h"
14 * Search card topology and return PCM device number
15 * matching Nth HDMI device (zero-based index).
17 struct snd_pcm
*hda_dsp_hdmi_pcm_handle(struct snd_soc_card
*card
,
20 struct snd_soc_pcm_runtime
*rtd
;
24 for_each_card_rtds(card
, rtd
) {
26 rtd
->pcm
->streams
[SNDRV_PCM_STREAM_PLAYBACK
].pcm
: NULL
;
27 if (spcm
&& strstr(spcm
->id
, "HDMI")) {
37 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
39 * Search card topology and register HDMI PCM related controls
42 int hda_dsp_hdmi_build_controls(struct snd_soc_card
*card
,
43 struct snd_soc_component
*comp
)
45 struct hdac_hda_priv
*hda_pvt
;
46 struct hda_codec
*hcodec
;
54 hda_pvt
= snd_soc_component_get_drvdata(comp
);
55 hcodec
= &hda_pvt
->codec
;
57 list_for_each_entry(hpcm
, &hcodec
->pcm_list_head
, list
) {
58 spcm
= hda_dsp_hdmi_pcm_handle(card
, i
);
61 hpcm
->device
= spcm
->device
;
63 "%s: mapping HDMI converter %d to PCM %d (%p)\n",
64 __func__
, i
, hpcm
->device
, spcm
);
67 hpcm
->device
= SNDRV_PCM_INVALID_DEVICE
;
69 "%s: no PCM in topology for HDMI converter %d\n\n",
74 snd_hdac_display_power(hcodec
->core
.bus
,
75 HDA_CODEC_IDX_CONTROLLER
, true);
76 err
= snd_hda_codec_build_controls(hcodec
);
78 dev_err(card
->dev
, "unable to create controls %d\n", err
);
79 snd_hdac_display_power(hcodec
->core
.bus
,
80 HDA_CODEC_IDX_CONTROLLER
, false);