Skip to content

Commit 1651828

Browse files
committed
ASoC: SOF: pcm: Set the PCM device name for HDMI
User space (alsa-lib) uses the PCM device name to detect HDMI devices, the name is expected to be in form of 'HDMI'+<space>+number. The PCM device name is not configured in ASoC, only the PCM id is set based on the loaded topology. Detect the HDMI PCM playback devices and configure the name to help user space to handle HDMI PCMs correctly. aplay -l | grep HDMI (Audio capable monitor connected) Before the change: card 0: sofhdadsp [sof-hda-dsp], device 3: HDMI1 (*) [] card 0: sofhdadsp [sof-hda-dsp], device 4: HDMI2 (*) [] card 0: sofhdadsp [sof-hda-dsp], device 5: HDMI3 (*) [] after the change: card 0: sofhdadsp [sof-hda-dsp], device 3: HDMI1 (*) [DELL P1917S] card 0: sofhdadsp [sof-hda-dsp], device 4: HDMI2 (*) [HDMI 2] card 0: sofhdadsp [sof-hda-dsp], device 5: HDMI3 (*) [HDMI 3] Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent c13f44b commit 1651828

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

sound/soc/sof/pcm.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,24 @@ static int sof_pcm_new(struct snd_soc_component *component,
672672
snd_pcm_set_managed_buffer(pcm->streams[stream].substream,
673673
SNDRV_DMA_TYPE_DEV_SG, sdev->dev,
674674
0, le32_to_cpu(caps->buffer_size_max));
675+
676+
/* Set the PCM device name for HDMI playback */
677+
if (!strncmp(pcm->id, "HDMI", 4)) {
678+
int hdmi_idx;
679+
680+
/*
681+
* Make sure that the name is in"HDMI<SPACE>x" format as this is
682+
* expected by user space.
683+
* See alsa-lib's __snd_pcm_info_eld_fixup_check() which is
684+
* guarding the __snd_pcm_info_eld_fixup() in
685+
* snd_ctl_hw_pcm_info() and snd_pcm_hw_info() library functions
686+
*/
687+
if (sscanf(pcm->id, "HDMI%d", &hdmi_idx) == 1)
688+
snprintf(pcm->name, sizeof(pcm->name), "HDMI %d",
689+
hdmi_idx);
690+
else
691+
strscpy(pcm->name, pcm->id, sizeof(pcm->name));
692+
}
675693
capture:
676694
stream = SNDRV_PCM_STREAM_CAPTURE;
677695

0 commit comments

Comments
 (0)