From a03624a0cef3a85b145cc4820c7a7171855e052f Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Fri, 16 Jun 2023 23:49:29 +0100 Subject: [PATCH] v6.3: cleanup Playback/Capture data for snd_soc_dai commit 3653480c68120dc16ebfeb80e529200dbbd98f92 Author: Kuninori Morimoto Date: Tue Jan 31 02:02:04 2023 +0000 ASoC: soc-dai.h: cleanup Playback/Capture data for snd_soc_dai Current snd_soc_dai has data for Playback/Capture, but it is very random. Someone is array (A), someone is playback/capture (B), and someone is tx/rx (C); struct snd_soc_dai { ... (A) unsigned int stream_active[SNDRV_PCM_STREAM_LAST + 1]; (B) struct snd_soc_dapm_widget *playback_widget; (B) struct snd_soc_dapm_widget *capture_widget; (B) void *playback_dma_data; (B) void *capture_dma_data; ... (C) unsigned int tx_mask; (C) unsigned int rx_mask; }; Because of it, the code was very complicated. This patch creates new data structure to merge these into one, and tidyup the code. Signed-off-by: Kuninori Morimoto Reviewed-by: Charles Keepax Link: https://lore.kernel.org/r/87cz6vea1v.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- ac101.c | 4 ++-- ac108.c | 6 +++--- seeed-voicecard.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ac101.c b/ac101.c index 23837a7..323876c 100644 --- a/ac101.c +++ b/ac101.c @@ -955,7 +955,7 @@ void ac101_aif_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai AC101_DBG("stream = %s, play: %d, capt: %d, active: %d\n", snd_pcm_stream_str(substream), - codec_dai->stream_active[SNDRV_PCM_STREAM_PLAYBACK], codec_dai->stream_active[SNDRV_PCM_STREAM_CAPTURE], + codec_dai->stream[SNDRV_PCM_STREAM_PLAYBACK].active, codec_dai->stream[SNDRV_PCM_STREAM_CAPTURE].active, snd_soc_dai_active(codec_dai)); if (!snd_soc_dai_active(codec_dai)) { @@ -1080,7 +1080,7 @@ int ac101_hw_params(struct snd_pcm_substream *substream, freq_out = _FREQ_24_576K; for (i = 0; i < ARRAY_SIZE(codec_aif1_fs); i++) { if (codec_aif1_fs[i].samp_rate == params_rate(params)) { - if (codec_dai->stream_active[SNDRV_PCM_STREAM_CAPTURE] && dmic_used && codec_aif1_fs[i].samp_rate == 44100) { + if (codec_dai->stream[SNDRV_PCM_STREAM_CAPTURE].active && dmic_used && codec_aif1_fs[i].samp_rate == 44100) { ac101_update_bits(codec, AIF_SR_CTRL, (0xf<dev, "%s() stream=%s play:%d capt:%d +++\n", __func__, snd_pcm_stream_str(substream), - dai->stream_active[SNDRV_PCM_STREAM_PLAYBACK], dai->stream_active[SNDRV_PCM_STREAM_CAPTURE]); + dai->stream[SNDRV_PCM_STREAM_PLAYBACK].active, dai->stream[SNDRV_PCM_STREAM_CAPTURE].active); if (ac10x->i2c101) { ret = ac101_hw_params(substream, params, dai); @@ -664,8 +664,8 @@ static int ac108_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_h } } - if ((substream->stream == SNDRV_PCM_STREAM_CAPTURE && dai->stream_active[SNDRV_PCM_STREAM_PLAYBACK]) - || (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && dai->stream_active[SNDRV_PCM_STREAM_CAPTURE])) { + if ((substream->stream == SNDRV_PCM_STREAM_CAPTURE && dai->stream[SNDRV_PCM_STREAM_PLAYBACK].active) + || (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && dai->stream[SNDRV_PCM_STREAM_CAPTURE].active)) { /* not configure hw_param twice */ /* return 0; */ } diff --git a/seeed-voicecard.c b/seeed-voicecard.c index 886eb0e..935f997 100644 --- a/seeed-voicecard.c +++ b/seeed-voicecard.c @@ -220,7 +220,7 @@ static int seeed_voice_card_trigger(struct snd_pcm_substream *substream, int cmd dev_dbg(rtd->card->dev, "%s() stream=%s cmd=%d play:%d, capt:%d\n", __FUNCTION__, snd_pcm_stream_str(substream), cmd, - dai->stream_active[SNDRV_PCM_STREAM_PLAYBACK], dai->stream_active[SNDRV_PCM_STREAM_CAPTURE]); + dai->stream[SNDRV_PCM_STREAM_PLAYBACK].active, dai->stream[SNDRV_PCM_STREAM_CAPTURE].active); switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -242,7 +242,7 @@ static int seeed_voice_card_trigger(struct snd_pcm_substream *substream, int cmd case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: /* capture channel resync, if overrun */ - if (dai->stream_active[SNDRV_PCM_STREAM_CAPTURE] && substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + if (dai->stream[SNDRV_PCM_STREAM_CAPTURE].active && substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { break; } @@ -262,7 +262,7 @@ static int seeed_voice_card_trigger(struct snd_pcm_substream *substream, int cmd dev_dbg(rtd->card->dev, "%s() stream=%s cmd=%d play:%d, capt:%d;finished %d\n", __FUNCTION__, snd_pcm_stream_str(substream), cmd, - dai->stream_active[SNDRV_PCM_STREAM_PLAYBACK], dai->stream_active[SNDRV_PCM_STREAM_CAPTURE], ret); + dai->stream[SNDRV_PCM_STREAM_PLAYBACK].active, dai->stream[SNDRV_PCM_STREAM_CAPTURE].active, ret); return ret; }