ASoC: soc-pcm: Merge for_each_rtd_cpu/codec_dais()
Now we can use for_each_rtd_dais(). Let's use it instead of for_each_rtd_cpu/codec_dais(). Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/87sgi8olet.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
e3c3cf7101
commit
c840f7698d
1 changed files with 75 additions and 236 deletions
|
@ -259,25 +259,15 @@ static int soc_rtd_trigger(struct snd_soc_pcm_runtime *rtd,
|
||||||
static void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
|
static void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
|
||||||
int stream, int action)
|
int stream, int action)
|
||||||
{
|
{
|
||||||
struct snd_soc_dai *cpu_dai;
|
struct snd_soc_dai *dai;
|
||||||
struct snd_soc_dai *codec_dai;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
lockdep_assert_held(&rtd->card->pcm_mutex);
|
lockdep_assert_held(&rtd->card->pcm_mutex);
|
||||||
|
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai)
|
for_each_rtd_dais(rtd, i, dai) {
|
||||||
cpu_dai->stream_active[stream] += action;
|
dai->stream_active[stream] += action;
|
||||||
|
dai->active += action;
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai)
|
dai->component->active += action;
|
||||||
codec_dai->stream_active[stream] += action;
|
|
||||||
|
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
|
||||||
cpu_dai->active += action;
|
|
||||||
cpu_dai->component->active += action;
|
|
||||||
}
|
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai) {
|
|
||||||
codec_dai->active += action;
|
|
||||||
codec_dai->component->active += action;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,8 +436,8 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream,
|
||||||
struct snd_pcm_hw_params *params)
|
struct snd_pcm_hw_params *params)
|
||||||
{
|
{
|
||||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||||
|
struct snd_soc_dai *dai;
|
||||||
struct snd_soc_dai *cpu_dai;
|
struct snd_soc_dai *cpu_dai;
|
||||||
struct snd_soc_dai *codec_dai;
|
|
||||||
unsigned int rate, channels, sample_bits, symmetry, i;
|
unsigned int rate, channels, sample_bits, symmetry, i;
|
||||||
|
|
||||||
rate = params_rate(params);
|
rate = params_rate(params);
|
||||||
|
@ -457,11 +447,8 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream,
|
||||||
/* reject unmatched parameters when applying symmetry */
|
/* reject unmatched parameters when applying symmetry */
|
||||||
symmetry = rtd->dai_link->symmetric_rates;
|
symmetry = rtd->dai_link->symmetric_rates;
|
||||||
|
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai)
|
for_each_rtd_cpu_dais(rtd, i, dai)
|
||||||
symmetry |= cpu_dai->driver->symmetric_rates;
|
symmetry |= dai->driver->symmetric_rates;
|
||||||
|
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai)
|
|
||||||
symmetry |= codec_dai->driver->symmetric_rates;
|
|
||||||
|
|
||||||
if (symmetry) {
|
if (symmetry) {
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
||||||
|
@ -475,11 +462,8 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream,
|
||||||
|
|
||||||
symmetry = rtd->dai_link->symmetric_channels;
|
symmetry = rtd->dai_link->symmetric_channels;
|
||||||
|
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai)
|
for_each_rtd_dais(rtd, i, dai)
|
||||||
symmetry |= cpu_dai->driver->symmetric_channels;
|
symmetry |= dai->driver->symmetric_channels;
|
||||||
|
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai)
|
|
||||||
symmetry |= codec_dai->driver->symmetric_channels;
|
|
||||||
|
|
||||||
if (symmetry) {
|
if (symmetry) {
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
||||||
|
@ -494,11 +478,8 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream,
|
||||||
|
|
||||||
symmetry = rtd->dai_link->symmetric_samplebits;
|
symmetry = rtd->dai_link->symmetric_samplebits;
|
||||||
|
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai)
|
for_each_rtd_dais(rtd, i, dai)
|
||||||
symmetry |= cpu_dai->driver->symmetric_samplebits;
|
symmetry |= dai->driver->symmetric_samplebits;
|
||||||
|
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai)
|
|
||||||
symmetry |= codec_dai->driver->symmetric_samplebits;
|
|
||||||
|
|
||||||
if (symmetry) {
|
if (symmetry) {
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
||||||
|
@ -518,25 +499,18 @@ static bool soc_pcm_has_symmetry(struct snd_pcm_substream *substream)
|
||||||
{
|
{
|
||||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||||
struct snd_soc_dai_link *link = rtd->dai_link;
|
struct snd_soc_dai_link *link = rtd->dai_link;
|
||||||
struct snd_soc_dai *codec_dai;
|
struct snd_soc_dai *dai;
|
||||||
struct snd_soc_dai *cpu_dai;
|
|
||||||
unsigned int symmetry, i;
|
unsigned int symmetry, i;
|
||||||
|
|
||||||
symmetry = link->symmetric_rates ||
|
symmetry = link->symmetric_rates ||
|
||||||
link->symmetric_channels ||
|
link->symmetric_channels ||
|
||||||
link->symmetric_samplebits;
|
link->symmetric_samplebits;
|
||||||
|
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai)
|
for_each_rtd_dais(rtd, i, dai)
|
||||||
symmetry = symmetry ||
|
symmetry = symmetry ||
|
||||||
cpu_dai->driver->symmetric_rates ||
|
dai->driver->symmetric_rates ||
|
||||||
cpu_dai->driver->symmetric_channels ||
|
dai->driver->symmetric_channels ||
|
||||||
cpu_dai->driver->symmetric_samplebits;
|
dai->driver->symmetric_samplebits;
|
||||||
|
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai)
|
|
||||||
symmetry = symmetry ||
|
|
||||||
codec_dai->driver->symmetric_rates ||
|
|
||||||
codec_dai->driver->symmetric_channels ||
|
|
||||||
codec_dai->driver->symmetric_samplebits;
|
|
||||||
|
|
||||||
return symmetry;
|
return symmetry;
|
||||||
}
|
}
|
||||||
|
@ -774,19 +748,15 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
|
||||||
{
|
{
|
||||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||||
struct snd_soc_component *component;
|
struct snd_soc_component *component;
|
||||||
struct snd_soc_dai *cpu_dai;
|
struct snd_soc_dai *dai;
|
||||||
struct snd_soc_dai *codec_dai;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
|
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
|
||||||
|
|
||||||
snd_soc_runtime_deactivate(rtd, substream->stream);
|
snd_soc_runtime_deactivate(rtd, substream->stream);
|
||||||
|
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai)
|
for_each_rtd_dais(rtd, i, dai)
|
||||||
snd_soc_dai_shutdown(cpu_dai, substream);
|
snd_soc_dai_shutdown(dai, substream);
|
||||||
|
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai)
|
|
||||||
snd_soc_dai_shutdown(codec_dai, substream);
|
|
||||||
|
|
||||||
soc_rtd_shutdown(rtd, substream);
|
soc_rtd_shutdown(rtd, substream);
|
||||||
|
|
||||||
|
@ -818,8 +788,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
|
||||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||||
struct snd_soc_component *component;
|
struct snd_soc_component *component;
|
||||||
struct snd_soc_dai *cpu_dai;
|
struct snd_soc_dai *dai;
|
||||||
struct snd_soc_dai *codec_dai;
|
|
||||||
const char *codec_dai_name = "multicodec";
|
const char *codec_dai_name = "multicodec";
|
||||||
const char *cpu_dai_name = "multicpu";
|
const char *cpu_dai_name = "multicpu";
|
||||||
int i, ret = 0;
|
int i, ret = 0;
|
||||||
|
@ -844,28 +813,19 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* startup the audio subsystem */
|
/* startup the audio subsystem */
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
for_each_rtd_dais(rtd, i, dai) {
|
||||||
ret = snd_soc_dai_startup(cpu_dai, substream);
|
ret = snd_soc_dai_startup(dai, substream);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(cpu_dai->dev, "ASoC: can't open interface %s: %d\n",
|
dev_err(dai->dev,
|
||||||
cpu_dai->name, ret);
|
"ASoC: can't open DAI %s: %d\n",
|
||||||
goto cpu_dai_err;
|
dai->name, ret);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai) {
|
|
||||||
ret = snd_soc_dai_startup(codec_dai, substream);
|
|
||||||
if (ret < 0) {
|
|
||||||
dev_err(codec_dai->dev,
|
|
||||||
"ASoC: can't open codec %s: %d\n",
|
|
||||||
codec_dai->name, ret);
|
|
||||||
goto config_err;
|
goto config_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
||||||
codec_dai->tx_mask = 0;
|
dai->tx_mask = 0;
|
||||||
else
|
else
|
||||||
codec_dai->rx_mask = 0;
|
dai->rx_mask = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dynamic PCM DAI links compat checks use dynamic capabilities */
|
/* Dynamic PCM DAI links compat checks use dynamic capabilities */
|
||||||
|
@ -905,17 +865,9 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
|
||||||
soc_pcm_apply_msb(substream);
|
soc_pcm_apply_msb(substream);
|
||||||
|
|
||||||
/* Symmetry only applies if we've already got an active stream. */
|
/* Symmetry only applies if we've already got an active stream. */
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
for_each_rtd_dais(rtd, i, dai) {
|
||||||
if (cpu_dai->active) {
|
if (dai->active) {
|
||||||
ret = soc_pcm_apply_symmetry(substream, cpu_dai);
|
ret = soc_pcm_apply_symmetry(substream, dai);
|
||||||
if (ret != 0)
|
|
||||||
goto config_err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai) {
|
|
||||||
if (codec_dai->active) {
|
|
||||||
ret = soc_pcm_apply_symmetry(substream, codec_dai);
|
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
goto config_err;
|
goto config_err;
|
||||||
}
|
}
|
||||||
|
@ -937,11 +889,8 @@ dynamic:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
config_err:
|
config_err:
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai)
|
for_each_rtd_dais(rtd, i, dai)
|
||||||
snd_soc_dai_shutdown(codec_dai, substream);
|
snd_soc_dai_shutdown(dai, substream);
|
||||||
cpu_dai_err:
|
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai)
|
|
||||||
snd_soc_dai_shutdown(cpu_dai, substream);
|
|
||||||
|
|
||||||
soc_rtd_shutdown(rtd, substream);
|
soc_rtd_shutdown(rtd, substream);
|
||||||
rtd_startup_err:
|
rtd_startup_err:
|
||||||
|
@ -980,8 +929,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
|
||||||
{
|
{
|
||||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||||
struct snd_soc_component *component;
|
struct snd_soc_component *component;
|
||||||
struct snd_soc_dai *cpu_dai;
|
struct snd_soc_dai *dai;
|
||||||
struct snd_soc_dai *codec_dai;
|
|
||||||
int i, ret = 0;
|
int i, ret = 0;
|
||||||
|
|
||||||
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
|
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
|
||||||
|
@ -1002,21 +950,11 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai) {
|
for_each_rtd_dais(rtd, i, dai) {
|
||||||
ret = snd_soc_dai_prepare(codec_dai, substream);
|
ret = snd_soc_dai_prepare(dai, substream);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(codec_dai->dev,
|
dev_err(dai->dev,
|
||||||
"ASoC: codec DAI prepare error: %d\n",
|
"ASoC: DAI prepare error: %d\n", ret);
|
||||||
ret);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
|
||||||
ret = snd_soc_dai_prepare(cpu_dai, substream);
|
|
||||||
if (ret < 0) {
|
|
||||||
dev_err(cpu_dai->dev,
|
|
||||||
"ASoC: cpu DAI prepare error: %d\n", ret);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1031,11 +969,8 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
|
||||||
snd_soc_dapm_stream_event(rtd, substream->stream,
|
snd_soc_dapm_stream_event(rtd, substream->stream,
|
||||||
SND_SOC_DAPM_STREAM_START);
|
SND_SOC_DAPM_STREAM_START);
|
||||||
|
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai)
|
for_each_rtd_dais(rtd, i, dai)
|
||||||
snd_soc_dai_digital_mute(codec_dai, 0,
|
snd_soc_dai_digital_mute(dai, 0, substream->stream);
|
||||||
substream->stream);
|
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai)
|
|
||||||
snd_soc_dai_digital_mute(cpu_dai, 0, substream->stream);
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
mutex_unlock(&rtd->card->pcm_mutex);
|
mutex_unlock(&rtd->card->pcm_mutex);
|
||||||
|
@ -1219,44 +1154,23 @@ codec_err:
|
||||||
static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
|
static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
|
||||||
{
|
{
|
||||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||||
struct snd_soc_dai *cpu_dai;
|
struct snd_soc_dai *dai;
|
||||||
struct snd_soc_dai *codec_dai;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
|
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
|
||||||
|
|
||||||
/* clear the corresponding DAIs parameters when going to be inactive */
|
/* clear the corresponding DAIs parameters when going to be inactive */
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
for_each_rtd_dais(rtd, i, dai) {
|
||||||
if (cpu_dai->active == 1) {
|
int active = dai->stream_active[substream->stream];
|
||||||
cpu_dai->rate = 0;
|
|
||||||
cpu_dai->channels = 0;
|
|
||||||
cpu_dai->sample_bits = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai) {
|
if (dai->active == 1) {
|
||||||
if (codec_dai->active == 1) {
|
dai->rate = 0;
|
||||||
codec_dai->rate = 0;
|
dai->channels = 0;
|
||||||
codec_dai->channels = 0;
|
dai->sample_bits = 0;
|
||||||
codec_dai->sample_bits = 0;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* apply codec digital mute */
|
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai) {
|
|
||||||
int active = codec_dai->stream_active[substream->stream];
|
|
||||||
|
|
||||||
if (active == 1)
|
if (active == 1)
|
||||||
snd_soc_dai_digital_mute(codec_dai, 1,
|
snd_soc_dai_digital_mute(dai, 1, substream->stream);
|
||||||
substream->stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
|
||||||
int active = cpu_dai->stream_active[substream->stream];
|
|
||||||
|
|
||||||
if (active == 1)
|
|
||||||
snd_soc_dai_digital_mute(cpu_dai, 1,
|
|
||||||
substream->stream);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free any machine hw params */
|
/* free any machine hw params */
|
||||||
|
@ -1266,18 +1180,11 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
|
||||||
soc_pcm_components_hw_free(substream, NULL);
|
soc_pcm_components_hw_free(substream, NULL);
|
||||||
|
|
||||||
/* now free hw params for the DAIs */
|
/* now free hw params for the DAIs */
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai) {
|
for_each_rtd_dais(rtd, i, dai) {
|
||||||
if (!snd_soc_dai_stream_valid(codec_dai, substream->stream))
|
if (!snd_soc_dai_stream_valid(dai, substream->stream))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
snd_soc_dai_hw_free(codec_dai, substream);
|
snd_soc_dai_hw_free(dai, substream);
|
||||||
}
|
|
||||||
|
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
|
||||||
if (!snd_soc_dai_stream_valid(cpu_dai, substream->stream))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
snd_soc_dai_hw_free(cpu_dai, substream);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&rtd->card->pcm_mutex);
|
mutex_unlock(&rtd->card->pcm_mutex);
|
||||||
|
@ -1288,8 +1195,7 @@ static int soc_pcm_trigger_start(struct snd_pcm_substream *substream, int cmd)
|
||||||
{
|
{
|
||||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||||
struct snd_soc_component *component;
|
struct snd_soc_component *component;
|
||||||
struct snd_soc_dai *cpu_dai;
|
struct snd_soc_dai *dai;
|
||||||
struct snd_soc_dai *codec_dai;
|
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
ret = soc_rtd_trigger(rtd, substream, cmd);
|
ret = soc_rtd_trigger(rtd, substream, cmd);
|
||||||
|
@ -1302,14 +1208,8 @@ static int soc_pcm_trigger_start(struct snd_pcm_substream *substream, int cmd)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
for_each_rtd_dais(rtd, i, dai) {
|
||||||
ret = snd_soc_dai_trigger(cpu_dai, substream, cmd);
|
ret = snd_soc_dai_trigger(dai, substream, cmd);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai) {
|
|
||||||
ret = snd_soc_dai_trigger(codec_dai, substream, cmd);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1321,18 +1221,11 @@ static int soc_pcm_trigger_stop(struct snd_pcm_substream *substream, int cmd)
|
||||||
{
|
{
|
||||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||||
struct snd_soc_component *component;
|
struct snd_soc_component *component;
|
||||||
struct snd_soc_dai *cpu_dai;
|
struct snd_soc_dai *dai;
|
||||||
struct snd_soc_dai *codec_dai;
|
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai) {
|
for_each_rtd_dais(rtd, i, dai) {
|
||||||
ret = snd_soc_dai_trigger(codec_dai, substream, cmd);
|
ret = snd_soc_dai_trigger(dai, substream, cmd);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
|
||||||
ret = snd_soc_dai_trigger(cpu_dai, substream, cmd);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1376,18 +1269,11 @@ static int soc_pcm_bespoke_trigger(struct snd_pcm_substream *substream,
|
||||||
int cmd)
|
int cmd)
|
||||||
{
|
{
|
||||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||||
struct snd_soc_dai *cpu_dai;
|
struct snd_soc_dai *dai;
|
||||||
struct snd_soc_dai *codec_dai;
|
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai) {
|
for_each_rtd_dais(rtd, i, dai) {
|
||||||
ret = snd_soc_dai_bespoke_trigger(codec_dai, substream, cmd);
|
ret = snd_soc_dai_bespoke_trigger(dai, substream, cmd);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
|
||||||
ret = snd_soc_dai_bespoke_trigger(cpu_dai, substream, cmd);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1546,7 +1432,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card,
|
||||||
if (!be->dai_link->no_pcm)
|
if (!be->dai_link->no_pcm)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for_each_rtd_cpu_dais(be, i, dai) {
|
for_each_rtd_dais(be, i, dai) {
|
||||||
w = snd_soc_dai_get_widget(dai, stream);
|
w = snd_soc_dai_get_widget(dai, stream);
|
||||||
|
|
||||||
dev_dbg(card->dev, "ASoC: try BE : %s\n",
|
dev_dbg(card->dev, "ASoC: try BE : %s\n",
|
||||||
|
@ -1555,13 +1441,6 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card,
|
||||||
if (w == widget)
|
if (w == widget)
|
||||||
return be;
|
return be;
|
||||||
}
|
}
|
||||||
|
|
||||||
for_each_rtd_codec_dais(be, i, dai) {
|
|
||||||
w = snd_soc_dai_get_widget(dai, stream);
|
|
||||||
|
|
||||||
if (w == widget)
|
|
||||||
return be;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Widget provided is not a BE */
|
/* Widget provided is not a BE */
|
||||||
|
@ -1635,27 +1514,18 @@ static bool dpcm_be_is_active(struct snd_soc_dpcm *dpcm, int stream,
|
||||||
struct snd_soc_dai *dai;
|
struct snd_soc_dai *dai;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
/* is there a valid CPU DAI widget for this BE */
|
/* is there a valid DAI widget for this BE */
|
||||||
for_each_rtd_cpu_dais(dpcm->be, i, dai) {
|
for_each_rtd_dais(dpcm->be, i, dai) {
|
||||||
widget = snd_soc_dai_get_widget(dai, stream);
|
widget = snd_soc_dai_get_widget(dai, stream);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The BE is pruned only if none of the cpu_dai
|
* The BE is pruned only if none of the dai
|
||||||
* widgets are in the active list.
|
* widgets are in the active list.
|
||||||
*/
|
*/
|
||||||
if (widget && widget_in_list(list, widget))
|
if (widget && widget_in_list(list, widget))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* is there a valid CODEC DAI widget for this BE */
|
|
||||||
for_each_rtd_codec_dais(dpcm->be, i, dai) {
|
|
||||||
widget = snd_soc_dai_get_widget(dai, stream);
|
|
||||||
|
|
||||||
/* prune the BE if it's no longer in our active list */
|
|
||||||
if (widget && widget_in_list(list, widget))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2001,43 +1871,23 @@ static void dpcm_runtime_merge_rate(struct snd_pcm_substream *substream,
|
||||||
|
|
||||||
for_each_dpcm_be(fe, stream, dpcm) {
|
for_each_dpcm_be(fe, stream, dpcm) {
|
||||||
struct snd_soc_pcm_runtime *be = dpcm->be;
|
struct snd_soc_pcm_runtime *be = dpcm->be;
|
||||||
struct snd_soc_pcm_stream *codec_stream;
|
struct snd_soc_pcm_stream *pcm;
|
||||||
struct snd_soc_pcm_stream *cpu_stream;
|
|
||||||
struct snd_soc_dai *dai;
|
struct snd_soc_dai *dai;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for_each_rtd_cpu_dais(be, i, dai) {
|
for_each_rtd_dais(be, i, dai) {
|
||||||
/*
|
/*
|
||||||
* Skip CPUs which don't support the current stream
|
* Skip DAIs which don't support the current stream
|
||||||
* type. See soc_pcm_init_runtime_hw() for more details
|
* type. See soc_pcm_init_runtime_hw() for more details
|
||||||
*/
|
*/
|
||||||
if (!snd_soc_dai_stream_valid(dai, stream))
|
if (!snd_soc_dai_stream_valid(dai, stream))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
cpu_stream = snd_soc_dai_get_pcm_stream(dai, stream);
|
pcm = snd_soc_dai_get_pcm_stream(dai, stream);
|
||||||
|
|
||||||
*rate_min = max(*rate_min, cpu_stream->rate_min);
|
*rate_min = max(*rate_min, pcm->rate_min);
|
||||||
*rate_max = min_not_zero(*rate_max,
|
*rate_max = min_not_zero(*rate_max, pcm->rate_max);
|
||||||
cpu_stream->rate_max);
|
*rates = snd_pcm_rate_mask_intersect(*rates, pcm->rates);
|
||||||
*rates = snd_pcm_rate_mask_intersect(*rates,
|
|
||||||
cpu_stream->rates);
|
|
||||||
}
|
|
||||||
|
|
||||||
for_each_rtd_codec_dais(be, i, dai) {
|
|
||||||
/*
|
|
||||||
* Skip CODECs which don't support the current stream
|
|
||||||
* type. See soc_pcm_init_runtime_hw() for more details
|
|
||||||
*/
|
|
||||||
if (!snd_soc_dai_stream_valid(dai, stream))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
codec_stream = snd_soc_dai_get_pcm_stream(dai, stream);
|
|
||||||
|
|
||||||
*rate_min = max(*rate_min, codec_stream->rate_min);
|
|
||||||
*rate_max = min_not_zero(*rate_max,
|
|
||||||
codec_stream->rate_max);
|
|
||||||
*rates = snd_pcm_rate_mask_intersect(*rates,
|
|
||||||
codec_stream->rates);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2120,8 +1970,7 @@ static int dpcm_apply_symmetry(struct snd_pcm_substream *fe_substream,
|
||||||
struct snd_pcm_substream *be_substream =
|
struct snd_pcm_substream *be_substream =
|
||||||
snd_soc_dpcm_get_substream(be, stream);
|
snd_soc_dpcm_get_substream(be, stream);
|
||||||
struct snd_soc_pcm_runtime *rtd;
|
struct snd_soc_pcm_runtime *rtd;
|
||||||
struct snd_soc_dai *codec_dai;
|
struct snd_soc_dai *dai;
|
||||||
struct snd_soc_dai *cpu_dai;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* A backend may not have the requested substream */
|
/* A backend may not have the requested substream */
|
||||||
|
@ -2136,19 +1985,9 @@ static int dpcm_apply_symmetry(struct snd_pcm_substream *fe_substream,
|
||||||
be_substream->runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX;
|
be_substream->runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX;
|
||||||
|
|
||||||
/* Symmetry only applies if we've got an active stream. */
|
/* Symmetry only applies if we've got an active stream. */
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
for_each_rtd_dais(rtd, i, dai) {
|
||||||
if (cpu_dai->active) {
|
if (dai->active) {
|
||||||
err = soc_pcm_apply_symmetry(fe_substream,
|
err = soc_pcm_apply_symmetry(fe_substream, dai);
|
||||||
cpu_dai);
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai) {
|
|
||||||
if (codec_dai->active) {
|
|
||||||
err = soc_pcm_apply_symmetry(fe_substream,
|
|
||||||
codec_dai);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue