Commit e041a2a5 authored by Emil Abildgaard Svendsen's avatar Emil Abildgaard Svendsen Committed by Mark Brown

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: default avatarEmil Svendsen <emas@bang-olufsen.dk>
Link: https://lore.kernel.org/r/20230309065432.4150700-2-emas@bang-olufsen.dkSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent af0f46e5
...@@ -428,8 +428,13 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream, ...@@ -428,8 +428,13 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream,
{ {
struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
bool has_capture = !hcp->hcd.no_i2s_capture;
bool has_playback = !hcp->hcd.no_i2s_playback;
int ret = 0; int ret = 0;
if (!((has_playback && tx) || (has_capture && !tx)))
return 0;
mutex_lock(&hcp->lock); mutex_lock(&hcp->lock);
if (hcp->busy) { if (hcp->busy) {
dev_err(dai->dev, "Only one simultaneous stream supported!\n"); dev_err(dai->dev, "Only one simultaneous stream supported!\n");
...@@ -468,6 +473,12 @@ static void hdmi_codec_shutdown(struct snd_pcm_substream *substream, ...@@ -468,6 +473,12 @@ static void hdmi_codec_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
bool has_capture = !hcp->hcd.no_i2s_capture;
bool has_playback = !hcp->hcd.no_i2s_playback;
if (!((has_playback && tx) || (has_capture && !tx)))
return;
hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN; hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN;
hcp->hcd.ops->audio_shutdown(dai->dev->parent, hcp->hcd.data); hcp->hcd.ops->audio_shutdown(dai->dev->parent, hcp->hcd.data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment