1 // SPDX-License-Identifier: GPL-2.0-only
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"
13 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
16 * Search card topology and return PCM device number
17 * matching Nth HDMI device (zero-based index).
19 static struct snd_pcm
*hda_dsp_hdmi_pcm_handle(struct snd_soc_card
*card
,
22 struct snd_soc_pcm_runtime
*rtd
;
26 for_each_card_rtds(card
, rtd
) {
28 rtd
->pcm
->streams
[SNDRV_PCM_STREAM_PLAYBACK
].pcm
: NULL
;
29 if (spcm
&& strstr(spcm
->id
, "HDMI")) {
40 * Search card topology and register HDMI PCM related controls
43 int hda_dsp_hdmi_build_controls(struct snd_soc_card
*card
,
44 struct snd_soc_component
*comp
)
46 struct hdac_hda_priv
*hda_pvt
;
47 struct hda_codec
*hcodec
;
55 hda_pvt
= snd_soc_component_get_drvdata(comp
);
56 hcodec
= &hda_pvt
->codec
;
58 list_for_each_entry(hpcm
, &hcodec
->pcm_list_head
, list
) {
59 spcm
= hda_dsp_hdmi_pcm_handle(card
, i
);
62 hpcm
->device
= spcm
->device
;
64 "%s: mapping HDMI converter %d to PCM %d (%p)\n",
65 __func__
, i
, hpcm
->device
, spcm
);
68 hpcm
->device
= SNDRV_PCM_INVALID_DEVICE
;
70 "%s: no PCM in topology for HDMI converter %d\n\n",
75 snd_hdac_display_power(hcodec
->core
.bus
,
76 HDA_CODEC_IDX_CONTROLLER
, true);
77 err
= snd_hda_codec_build_controls(hcodec
);
79 dev_err(card
->dev
, "unable to create controls %d\n", err
);
80 snd_hdac_display_power(hcodec
->core
.bus
,
81 HDA_CODEC_IDX_CONTROLLER
, false);