Skip to content

Commit e041a2a

Browse files
Svendsen991broonie
authored andcommitted
ASoC: hdmi-codec: only startup/shutdown on supported streams
Currently only one stream is supported. This isn't usally a problem until you have a multi codec audio card. Because the audio card will run startup and shutdown on both capture and playback streams. So if your hdmi-codec only support either playback or capture. Then ALSA can't open for playback and capture. This patch will ignore if startup and shutdown are called with a non supported stream. Thus, allowing an audio card like this: +-+ cpu1 <--@-| |-> codec1 (HDMI-CODEC) | |<- codec2 (NOT HDMI-CODEC) +-+ Signed-off-by: Emil Svendsen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent af0f46e commit e041a2a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

sound/soc/codecs/hdmi-codec.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,13 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream,
428428
{
429429
struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
430430
bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
431+
bool has_capture = !hcp->hcd.no_i2s_capture;
432+
bool has_playback = !hcp->hcd.no_i2s_playback;
431433
int ret = 0;
432434

435+
if (!((has_playback && tx) || (has_capture && !tx)))
436+
return 0;
437+
433438
mutex_lock(&hcp->lock);
434439
if (hcp->busy) {
435440
dev_err(dai->dev, "Only one simultaneous stream supported!\n");
@@ -468,6 +473,12 @@ static void hdmi_codec_shutdown(struct snd_pcm_substream *substream,
468473
struct snd_soc_dai *dai)
469474
{
470475
struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
476+
bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
477+
bool has_capture = !hcp->hcd.no_i2s_capture;
478+
bool has_playback = !hcp->hcd.no_i2s_playback;
479+
480+
if (!((has_playback && tx) || (has_capture && !tx)))
481+
return;
471482

472483
hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN;
473484
hcp->hcd.ops->audio_shutdown(dai->dev->parent, hcp->hcd.data);

0 commit comments

Comments
 (0)