ASoC: add for_each_rtd_codec_dai() macro
ALSA SoC snd_soc_pcm_runtime has snd_soc_dai array for codec_dai. To be more readable code, this patch adds new for_each_rtd_codec_dai() macro, and replace existing code to it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Родитель
3db769f177
Коммит
0b7990e389
|
@ -1158,6 +1158,13 @@ struct snd_soc_pcm_runtime {
|
||||||
unsigned int dev_registered:1;
|
unsigned int dev_registered:1;
|
||||||
unsigned int pop_wait:1;
|
unsigned int pop_wait:1;
|
||||||
};
|
};
|
||||||
|
#define for_each_rtd_codec_dai(rtd, i, dai)\
|
||||||
|
for ((i) = 0; \
|
||||||
|
((i) < rtd->num_codecs) && ((dai) = rtd->codec_dais[i]); \
|
||||||
|
(i)++)
|
||||||
|
#define for_each_rtd_codec_dai_reverse(rtd, i, dai) \
|
||||||
|
for (; ((i--) >= 0) && ((dai) = rtd->codec_dais[i]);)
|
||||||
|
|
||||||
|
|
||||||
/* mixer control */
|
/* mixer control */
|
||||||
struct soc_mixer_control {
|
struct soc_mixer_control {
|
||||||
|
|
|
@ -488,11 +488,10 @@ static int kabylake_ssp0_hw_params(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 *codec_dai;
|
||||||
int ret = 0, j;
|
int ret = 0, j;
|
||||||
|
|
||||||
for (j = 0; j < rtd->num_codecs; j++) {
|
for_each_rtd_codec_dai(rtd, j, codec_dai) {
|
||||||
struct snd_soc_dai *codec_dai = rtd->codec_dais[j];
|
|
||||||
|
|
||||||
if (!strcmp(codec_dai->component->name, MAXIM_DEV0_NAME)) {
|
if (!strcmp(codec_dai->component->name, MAXIM_DEV0_NAME)) {
|
||||||
/*
|
/*
|
||||||
* Use channel 4 and 5 for the first amp
|
* Use channel 4 and 5 for the first amp
|
||||||
|
|
|
@ -353,11 +353,10 @@ static int kabylake_ssp0_hw_params(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 *codec_dai;
|
||||||
int ret = 0, j;
|
int ret = 0, j;
|
||||||
|
|
||||||
for (j = 0; j < rtd->num_codecs; j++) {
|
for_each_rtd_codec_dai(rtd, j, codec_dai) {
|
||||||
struct snd_soc_dai *codec_dai = rtd->codec_dais[j];
|
|
||||||
|
|
||||||
if (!strcmp(codec_dai->component->name, RT5514_DEV_NAME)) {
|
if (!strcmp(codec_dai->component->name, RT5514_DEV_NAME)) {
|
||||||
ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xF, 0, 8, 16);
|
ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xF, 0, 8, 16);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
|
|
@ -44,11 +44,10 @@ static int mt8173_rt5650_rt5514_hw_params(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 *codec_dai;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
struct snd_soc_dai *codec_dai = rtd->codec_dais[i];
|
|
||||||
|
|
||||||
/* pll from mclk 12.288M */
|
/* pll from mclk 12.288M */
|
||||||
ret = snd_soc_dai_set_pll(codec_dai, 0, 0, MCLK_FOR_CODECS,
|
ret = snd_soc_dai_set_pll(codec_dai, 0, 0, MCLK_FOR_CODECS,
|
||||||
params_rate(params) * 512);
|
params_rate(params) * 512);
|
||||||
|
|
|
@ -48,11 +48,10 @@ static int mt8173_rt5650_rt5676_hw_params(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 *codec_dai;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
struct snd_soc_dai *codec_dai = rtd->codec_dais[i];
|
|
||||||
|
|
||||||
/* pll from mclk 12.288M */
|
/* pll from mclk 12.288M */
|
||||||
ret = snd_soc_dai_set_pll(codec_dai, 0, 0, MCLK_FOR_CODECS,
|
ret = snd_soc_dai_set_pll(codec_dai, 0, 0, MCLK_FOR_CODECS,
|
||||||
params_rate(params) * 512);
|
params_rate(params) * 512);
|
||||||
|
|
|
@ -59,6 +59,7 @@ static int mt8173_rt5650_hw_params(struct snd_pcm_substream *substream,
|
||||||
{
|
{
|
||||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||||
unsigned int mclk_clock;
|
unsigned int mclk_clock;
|
||||||
|
struct snd_soc_dai *codec_dai;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
switch (mt8173_rt5650_priv.pll_from) {
|
switch (mt8173_rt5650_priv.pll_from) {
|
||||||
|
@ -76,9 +77,7 @@ static int mt8173_rt5650_hw_params(struct snd_pcm_substream *substream,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
struct snd_soc_dai *codec_dai = rtd->codec_dais[i];
|
|
||||||
|
|
||||||
/* pll from mclk */
|
/* pll from mclk */
|
||||||
ret = snd_soc_dai_set_pll(codec_dai, 0, 0, mclk_clock,
|
ret = snd_soc_dai_set_pll(codec_dai, 0, 0, mclk_clock,
|
||||||
params_rate(params) * 512);
|
params_rate(params) * 512);
|
||||||
|
|
|
@ -168,8 +168,7 @@ static int axg_card_tdm_be_hw_params(struct snd_pcm_substream *substream,
|
||||||
if (be->mclk_fs) {
|
if (be->mclk_fs) {
|
||||||
mclk = params_rate(params) * be->mclk_fs;
|
mclk = params_rate(params) * be->mclk_fs;
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
codec_dai = rtd->codec_dais[i];
|
|
||||||
ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
|
ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
|
||||||
SND_SOC_CLOCK_IN);
|
SND_SOC_CLOCK_IN);
|
||||||
if (ret && ret != -ENOTSUPP)
|
if (ret && ret != -ENOTSUPP)
|
||||||
|
@ -197,8 +196,7 @@ static int axg_card_tdm_dai_init(struct snd_soc_pcm_runtime *rtd)
|
||||||
struct snd_soc_dai *codec_dai;
|
struct snd_soc_dai *codec_dai;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
codec_dai = rtd->codec_dais[i];
|
|
||||||
ret = snd_soc_dai_set_tdm_slot(codec_dai,
|
ret = snd_soc_dai_set_tdm_slot(codec_dai,
|
||||||
be->codec_masks[i].tx,
|
be->codec_masks[i].tx,
|
||||||
be->codec_masks[i].rx,
|
be->codec_masks[i].rx,
|
||||||
|
|
|
@ -452,12 +452,12 @@ int snd_soc_suspend(struct device *dev)
|
||||||
|
|
||||||
/* mute any active DACs */
|
/* mute any active DACs */
|
||||||
list_for_each_entry(rtd, &card->rtd_list, list) {
|
list_for_each_entry(rtd, &card->rtd_list, list) {
|
||||||
|
struct snd_soc_dai *dai;
|
||||||
|
|
||||||
if (rtd->dai_link->ignore_suspend)
|
if (rtd->dai_link->ignore_suspend)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, dai) {
|
||||||
struct snd_soc_dai *dai = rtd->codec_dais[i];
|
|
||||||
struct snd_soc_dai_driver *drv = dai->driver;
|
struct snd_soc_dai_driver *drv = dai->driver;
|
||||||
|
|
||||||
if (drv->ops->digital_mute && dai->playback_active)
|
if (drv->ops->digital_mute && dai->playback_active)
|
||||||
|
@ -625,12 +625,12 @@ static void soc_resume_deferred(struct work_struct *work)
|
||||||
|
|
||||||
/* unmute any active DACs */
|
/* unmute any active DACs */
|
||||||
list_for_each_entry(rtd, &card->rtd_list, list) {
|
list_for_each_entry(rtd, &card->rtd_list, list) {
|
||||||
|
struct snd_soc_dai *dai;
|
||||||
|
|
||||||
if (rtd->dai_link->ignore_suspend)
|
if (rtd->dai_link->ignore_suspend)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, dai) {
|
||||||
struct snd_soc_dai *dai = rtd->codec_dais[i];
|
|
||||||
struct snd_soc_dai_driver *drv = dai->driver;
|
struct snd_soc_dai_driver *drv = dai->driver;
|
||||||
|
|
||||||
if (drv->ops->digital_mute && dai->playback_active)
|
if (drv->ops->digital_mute && dai->playback_active)
|
||||||
|
@ -674,15 +674,14 @@ int snd_soc_resume(struct device *dev)
|
||||||
|
|
||||||
/* activate pins from sleep state */
|
/* activate pins from sleep state */
|
||||||
list_for_each_entry(rtd, &card->rtd_list, list) {
|
list_for_each_entry(rtd, &card->rtd_list, list) {
|
||||||
struct snd_soc_dai **codec_dais = rtd->codec_dais;
|
struct snd_soc_dai *codec_dai;
|
||||||
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
if (cpu_dai->active)
|
if (cpu_dai->active)
|
||||||
pinctrl_pm_select_default_state(cpu_dai->dev);
|
pinctrl_pm_select_default_state(cpu_dai->dev);
|
||||||
|
|
||||||
for (j = 0; j < rtd->num_codecs; j++) {
|
for_each_rtd_codec_dai(rtd, j, codec_dai) {
|
||||||
struct snd_soc_dai *codec_dai = codec_dais[j];
|
|
||||||
if (codec_dai->active)
|
if (codec_dai->active)
|
||||||
pinctrl_pm_select_default_state(codec_dai->dev);
|
pinctrl_pm_select_default_state(codec_dai->dev);
|
||||||
}
|
}
|
||||||
|
@ -877,6 +876,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
|
||||||
rtd->num_codecs = dai_link->num_codecs;
|
rtd->num_codecs = dai_link->num_codecs;
|
||||||
|
|
||||||
/* Find CODEC from registered CODECs */
|
/* Find CODEC from registered CODECs */
|
||||||
|
/* we can use for_each_rtd_codec_dai() after this */
|
||||||
codec_dais = rtd->codec_dais;
|
codec_dais = rtd->codec_dais;
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for (i = 0; i < rtd->num_codecs; i++) {
|
||||||
codec_dais[i] = snd_soc_find_dai(&codecs[i]);
|
codec_dais[i] = snd_soc_find_dai(&codecs[i]);
|
||||||
|
@ -959,6 +959,7 @@ static void soc_remove_link_dais(struct snd_soc_card *card,
|
||||||
struct snd_soc_pcm_runtime *rtd, int order)
|
struct snd_soc_pcm_runtime *rtd, int order)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
struct snd_soc_dai *codec_dai;
|
||||||
|
|
||||||
/* unregister the rtd device */
|
/* unregister the rtd device */
|
||||||
if (rtd->dev_registered) {
|
if (rtd->dev_registered) {
|
||||||
|
@ -967,8 +968,8 @@ static void soc_remove_link_dais(struct snd_soc_card *card,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove the CODEC DAI */
|
/* remove the CODEC DAI */
|
||||||
for (i = 0; i < rtd->num_codecs; i++)
|
for_each_rtd_codec_dai(rtd, i, codec_dai)
|
||||||
soc_remove_dai(rtd->codec_dais[i], order);
|
soc_remove_dai(codec_dai, order);
|
||||||
|
|
||||||
soc_remove_dai(rtd->cpu_dai, order);
|
soc_remove_dai(rtd->cpu_dai, order);
|
||||||
}
|
}
|
||||||
|
@ -1511,6 +1512,7 @@ static int soc_probe_link_dais(struct snd_soc_card *card,
|
||||||
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
||||||
struct snd_soc_rtdcom_list *rtdcom;
|
struct snd_soc_rtdcom_list *rtdcom;
|
||||||
struct snd_soc_component *component;
|
struct snd_soc_component *component;
|
||||||
|
struct snd_soc_dai *codec_dai;
|
||||||
int i, ret, num;
|
int i, ret, num;
|
||||||
|
|
||||||
dev_dbg(card->dev, "ASoC: probe %s dai link %d late %d\n",
|
dev_dbg(card->dev, "ASoC: probe %s dai link %d late %d\n",
|
||||||
|
@ -1524,8 +1526,8 @@ static int soc_probe_link_dais(struct snd_soc_card *card,
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* probe the CODEC DAI */
|
/* probe the CODEC DAI */
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
ret = soc_probe_dai(rtd->codec_dais[i], order);
|
ret = soc_probe_dai(codec_dai, order);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1712,14 +1714,12 @@ static void soc_remove_aux_devices(struct snd_soc_card *card)
|
||||||
int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
|
int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
|
||||||
unsigned int dai_fmt)
|
unsigned int dai_fmt)
|
||||||
{
|
{
|
||||||
struct snd_soc_dai **codec_dais = rtd->codec_dais;
|
|
||||||
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
||||||
|
struct snd_soc_dai *codec_dai;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
struct snd_soc_dai *codec_dai = codec_dais[i];
|
|
||||||
|
|
||||||
ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt);
|
ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt);
|
||||||
if (ret != 0 && ret != -ENOTSUPP) {
|
if (ret != 0 && ret != -ENOTSUPP) {
|
||||||
dev_warn(codec_dai->dev,
|
dev_warn(codec_dai->dev,
|
||||||
|
@ -2266,11 +2266,11 @@ int snd_soc_poweroff(struct device *dev)
|
||||||
/* deactivate pins to sleep state */
|
/* deactivate pins to sleep state */
|
||||||
list_for_each_entry(rtd, &card->rtd_list, list) {
|
list_for_each_entry(rtd, &card->rtd_list, list) {
|
||||||
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
||||||
|
struct snd_soc_dai *codec_dai;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
pinctrl_pm_select_sleep_state(cpu_dai->dev);
|
pinctrl_pm_select_sleep_state(cpu_dai->dev);
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
struct snd_soc_dai *codec_dai = rtd->codec_dais[i];
|
|
||||||
pinctrl_pm_select_sleep_state(codec_dai->dev);
|
pinctrl_pm_select_sleep_state(codec_dai->dev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2776,10 +2776,10 @@ int snd_soc_register_card(struct snd_soc_card *card)
|
||||||
/* deactivate pins to sleep state */
|
/* deactivate pins to sleep state */
|
||||||
list_for_each_entry(rtd, &card->rtd_list, list) {
|
list_for_each_entry(rtd, &card->rtd_list, list) {
|
||||||
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
||||||
|
struct snd_soc_dai *codec_dai;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
for (j = 0; j < rtd->num_codecs; j++) {
|
for_each_rtd_codec_dai(rtd, j, codec_dai) {
|
||||||
struct snd_soc_dai *codec_dai = rtd->codec_dais[j];
|
|
||||||
if (!codec_dai->active)
|
if (!codec_dai->active)
|
||||||
pinctrl_pm_select_sleep_state(codec_dai->dev);
|
pinctrl_pm_select_sleep_state(codec_dai->dev);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2370,12 +2370,13 @@ static ssize_t dapm_widget_show(struct device *dev,
|
||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev);
|
struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev);
|
||||||
|
struct snd_soc_dai *codec_dai;
|
||||||
int i, count = 0;
|
int i, count = 0;
|
||||||
|
|
||||||
mutex_lock(&rtd->card->dapm_mutex);
|
mutex_lock(&rtd->card->dapm_mutex);
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
struct snd_soc_component *cmpnt = rtd->codec_dais[i]->component;
|
struct snd_soc_component *cmpnt = codec_dai->component;
|
||||||
|
|
||||||
count += dapm_widget_show_component(cmpnt, buf + count);
|
count += dapm_widget_show_component(cmpnt, buf + count);
|
||||||
}
|
}
|
||||||
|
@ -4110,11 +4111,11 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
|
||||||
struct snd_soc_pcm_runtime *rtd)
|
struct snd_soc_pcm_runtime *rtd)
|
||||||
{
|
{
|
||||||
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
||||||
|
struct snd_soc_dai *codec_dai;
|
||||||
struct snd_soc_dapm_widget *sink, *source;
|
struct snd_soc_dapm_widget *sink, *source;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
struct snd_soc_dai *codec_dai = rtd->codec_dais[i];
|
|
||||||
|
|
||||||
/* connect BE DAI playback if widgets are valid */
|
/* connect BE DAI playback if widgets are valid */
|
||||||
if (codec_dai->playback_widget && cpu_dai->playback_widget) {
|
if (codec_dai->playback_widget && cpu_dai->playback_widget) {
|
||||||
|
@ -4202,11 +4203,12 @@ void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card)
|
||||||
static void soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
|
static void soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
|
||||||
int event)
|
int event)
|
||||||
{
|
{
|
||||||
|
struct snd_soc_dai *codec_dai;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
soc_dapm_dai_stream_event(rtd->cpu_dai, stream, event);
|
soc_dapm_dai_stream_event(rtd->cpu_dai, stream, event);
|
||||||
for (i = 0; i < rtd->num_codecs; i++)
|
for_each_rtd_codec_dai(rtd, i, codec_dai)
|
||||||
soc_dapm_dai_stream_event(rtd->codec_dais[i], stream, event);
|
soc_dapm_dai_stream_event(codec_dai, stream, event);
|
||||||
|
|
||||||
dapm_power_widgets(rtd->card, event);
|
dapm_power_widgets(rtd->card, event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,25 +59,26 @@ static bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int stream)
|
||||||
void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, int stream)
|
void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, int stream)
|
||||||
{
|
{
|
||||||
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
||||||
|
struct snd_soc_dai *codec_dai;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
lockdep_assert_held(&rtd->pcm_mutex);
|
lockdep_assert_held(&rtd->pcm_mutex);
|
||||||
|
|
||||||
if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
||||||
cpu_dai->playback_active++;
|
cpu_dai->playback_active++;
|
||||||
for (i = 0; i < rtd->num_codecs; i++)
|
for_each_rtd_codec_dai(rtd, i, codec_dai)
|
||||||
rtd->codec_dais[i]->playback_active++;
|
codec_dai->playback_active++;
|
||||||
} else {
|
} else {
|
||||||
cpu_dai->capture_active++;
|
cpu_dai->capture_active++;
|
||||||
for (i = 0; i < rtd->num_codecs; i++)
|
for_each_rtd_codec_dai(rtd, i, codec_dai)
|
||||||
rtd->codec_dais[i]->capture_active++;
|
codec_dai->capture_active++;
|
||||||
}
|
}
|
||||||
|
|
||||||
cpu_dai->active++;
|
cpu_dai->active++;
|
||||||
cpu_dai->component->active++;
|
cpu_dai->component->active++;
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
rtd->codec_dais[i]->active++;
|
codec_dai->active++;
|
||||||
rtd->codec_dais[i]->component->active++;
|
codec_dai->component->active++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,25 +95,26 @@ void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, int stream)
|
||||||
void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream)
|
void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream)
|
||||||
{
|
{
|
||||||
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
||||||
|
struct snd_soc_dai *codec_dai;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
lockdep_assert_held(&rtd->pcm_mutex);
|
lockdep_assert_held(&rtd->pcm_mutex);
|
||||||
|
|
||||||
if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
||||||
cpu_dai->playback_active--;
|
cpu_dai->playback_active--;
|
||||||
for (i = 0; i < rtd->num_codecs; i++)
|
for_each_rtd_codec_dai(rtd, i, codec_dai)
|
||||||
rtd->codec_dais[i]->playback_active--;
|
codec_dai->playback_active--;
|
||||||
} else {
|
} else {
|
||||||
cpu_dai->capture_active--;
|
cpu_dai->capture_active--;
|
||||||
for (i = 0; i < rtd->num_codecs; i++)
|
for_each_rtd_codec_dai(rtd, i, codec_dai)
|
||||||
rtd->codec_dais[i]->capture_active--;
|
codec_dai->capture_active--;
|
||||||
}
|
}
|
||||||
|
|
||||||
cpu_dai->active--;
|
cpu_dai->active--;
|
||||||
cpu_dai->component->active--;
|
cpu_dai->component->active--;
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
rtd->codec_dais[i]->component->active--;
|
codec_dai->component->active--;
|
||||||
rtd->codec_dais[i]->active--;
|
codec_dai->active--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,6 +255,7 @@ static int soc_pcm_params_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 *cpu_dai = rtd->cpu_dai;
|
struct snd_soc_dai *cpu_dai = rtd->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);
|
||||||
|
@ -263,8 +266,8 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream,
|
||||||
symmetry = cpu_dai->driver->symmetric_rates ||
|
symmetry = cpu_dai->driver->symmetric_rates ||
|
||||||
rtd->dai_link->symmetric_rates;
|
rtd->dai_link->symmetric_rates;
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++)
|
for_each_rtd_codec_dai(rtd, i, codec_dai)
|
||||||
symmetry |= rtd->codec_dais[i]->driver->symmetric_rates;
|
symmetry |= codec_dai->driver->symmetric_rates;
|
||||||
|
|
||||||
if (symmetry && cpu_dai->rate && cpu_dai->rate != rate) {
|
if (symmetry && cpu_dai->rate && cpu_dai->rate != rate) {
|
||||||
dev_err(rtd->dev, "ASoC: unmatched rate symmetry: %d - %d\n",
|
dev_err(rtd->dev, "ASoC: unmatched rate symmetry: %d - %d\n",
|
||||||
|
@ -275,8 +278,8 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream,
|
||||||
symmetry = cpu_dai->driver->symmetric_channels ||
|
symmetry = cpu_dai->driver->symmetric_channels ||
|
||||||
rtd->dai_link->symmetric_channels;
|
rtd->dai_link->symmetric_channels;
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++)
|
for_each_rtd_codec_dai(rtd, i, codec_dai)
|
||||||
symmetry |= rtd->codec_dais[i]->driver->symmetric_channels;
|
symmetry |= codec_dai->driver->symmetric_channels;
|
||||||
|
|
||||||
if (symmetry && cpu_dai->channels && cpu_dai->channels != channels) {
|
if (symmetry && cpu_dai->channels && cpu_dai->channels != channels) {
|
||||||
dev_err(rtd->dev, "ASoC: unmatched channel symmetry: %d - %d\n",
|
dev_err(rtd->dev, "ASoC: unmatched channel symmetry: %d - %d\n",
|
||||||
|
@ -287,8 +290,8 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream,
|
||||||
symmetry = cpu_dai->driver->symmetric_samplebits ||
|
symmetry = cpu_dai->driver->symmetric_samplebits ||
|
||||||
rtd->dai_link->symmetric_samplebits;
|
rtd->dai_link->symmetric_samplebits;
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++)
|
for_each_rtd_codec_dai(rtd, i, codec_dai)
|
||||||
symmetry |= rtd->codec_dais[i]->driver->symmetric_samplebits;
|
symmetry |= codec_dai->driver->symmetric_samplebits;
|
||||||
|
|
||||||
if (symmetry && cpu_dai->sample_bits && cpu_dai->sample_bits != sample_bits) {
|
if (symmetry && cpu_dai->sample_bits && cpu_dai->sample_bits != sample_bits) {
|
||||||
dev_err(rtd->dev, "ASoC: unmatched sample bits symmetry: %d - %d\n",
|
dev_err(rtd->dev, "ASoC: unmatched sample bits symmetry: %d - %d\n",
|
||||||
|
@ -304,17 +307,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_driver *cpu_driver = rtd->cpu_dai->driver;
|
struct snd_soc_dai_driver *cpu_driver = rtd->cpu_dai->driver;
|
||||||
struct snd_soc_dai_link *link = rtd->dai_link;
|
struct snd_soc_dai_link *link = rtd->dai_link;
|
||||||
|
struct snd_soc_dai *codec_dai;
|
||||||
unsigned int symmetry, i;
|
unsigned int symmetry, i;
|
||||||
|
|
||||||
symmetry = cpu_driver->symmetric_rates || link->symmetric_rates ||
|
symmetry = cpu_driver->symmetric_rates || link->symmetric_rates ||
|
||||||
cpu_driver->symmetric_channels || link->symmetric_channels ||
|
cpu_driver->symmetric_channels || link->symmetric_channels ||
|
||||||
cpu_driver->symmetric_samplebits || link->symmetric_samplebits;
|
cpu_driver->symmetric_samplebits || link->symmetric_samplebits;
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++)
|
for_each_rtd_codec_dai(rtd, i, codec_dai)
|
||||||
symmetry = symmetry ||
|
symmetry = symmetry ||
|
||||||
rtd->codec_dais[i]->driver->symmetric_rates ||
|
codec_dai->driver->symmetric_rates ||
|
||||||
rtd->codec_dais[i]->driver->symmetric_channels ||
|
codec_dai->driver->symmetric_channels ||
|
||||||
rtd->codec_dais[i]->driver->symmetric_samplebits;
|
codec_dai->driver->symmetric_samplebits;
|
||||||
|
|
||||||
return symmetry;
|
return symmetry;
|
||||||
}
|
}
|
||||||
|
@ -342,8 +346,7 @@ static void soc_pcm_apply_msb(struct snd_pcm_substream *substream)
|
||||||
unsigned int bits = 0, cpu_bits;
|
unsigned int bits = 0, cpu_bits;
|
||||||
|
|
||||||
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
codec_dai = rtd->codec_dais[i];
|
|
||||||
if (codec_dai->driver->playback.sig_bits == 0) {
|
if (codec_dai->driver->playback.sig_bits == 0) {
|
||||||
bits = 0;
|
bits = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -352,8 +355,7 @@ static void soc_pcm_apply_msb(struct snd_pcm_substream *substream)
|
||||||
}
|
}
|
||||||
cpu_bits = cpu_dai->driver->playback.sig_bits;
|
cpu_bits = cpu_dai->driver->playback.sig_bits;
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
codec_dai = rtd->codec_dais[i];
|
|
||||||
if (codec_dai->driver->capture.sig_bits == 0) {
|
if (codec_dai->driver->capture.sig_bits == 0) {
|
||||||
bits = 0;
|
bits = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -372,6 +374,7 @@ static void soc_pcm_init_runtime_hw(struct snd_pcm_substream *substream)
|
||||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||||
struct snd_pcm_hardware *hw = &runtime->hw;
|
struct snd_pcm_hardware *hw = &runtime->hw;
|
||||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||||
|
struct snd_soc_dai *codec_dai;
|
||||||
struct snd_soc_dai_driver *cpu_dai_drv = rtd->cpu_dai->driver;
|
struct snd_soc_dai_driver *cpu_dai_drv = rtd->cpu_dai->driver;
|
||||||
struct snd_soc_dai_driver *codec_dai_drv;
|
struct snd_soc_dai_driver *codec_dai_drv;
|
||||||
struct snd_soc_pcm_stream *codec_stream;
|
struct snd_soc_pcm_stream *codec_stream;
|
||||||
|
@ -388,7 +391,7 @@ static void soc_pcm_init_runtime_hw(struct snd_pcm_substream *substream)
|
||||||
cpu_stream = &cpu_dai_drv->capture;
|
cpu_stream = &cpu_dai_drv->capture;
|
||||||
|
|
||||||
/* first calculate min/max only for CODECs in the DAI link */
|
/* first calculate min/max only for CODECs in the DAI link */
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Skip CODECs which don't support the current stream type.
|
* Skip CODECs which don't support the current stream type.
|
||||||
|
@ -399,11 +402,11 @@ static void soc_pcm_init_runtime_hw(struct snd_pcm_substream *substream)
|
||||||
* bailed out on a higher level, since there would be no
|
* bailed out on a higher level, since there would be no
|
||||||
* CODEC to support the transfer direction in that case.
|
* CODEC to support the transfer direction in that case.
|
||||||
*/
|
*/
|
||||||
if (!snd_soc_dai_stream_valid(rtd->codec_dais[i],
|
if (!snd_soc_dai_stream_valid(codec_dai,
|
||||||
substream->stream))
|
substream->stream))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
codec_dai_drv = rtd->codec_dais[i]->driver;
|
codec_dai_drv = codec_dai->driver;
|
||||||
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
||||||
codec_stream = &codec_dai_drv->playback;
|
codec_stream = &codec_dai_drv->playback;
|
||||||
else
|
else
|
||||||
|
@ -482,8 +485,8 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
|
||||||
int i, ret = 0;
|
int i, ret = 0;
|
||||||
|
|
||||||
pinctrl_pm_select_default_state(cpu_dai->dev);
|
pinctrl_pm_select_default_state(cpu_dai->dev);
|
||||||
for (i = 0; i < rtd->num_codecs; i++)
|
for_each_rtd_codec_dai(rtd, i, codec_dai)
|
||||||
pinctrl_pm_select_default_state(rtd->codec_dais[i]->dev);
|
pinctrl_pm_select_default_state(codec_dai->dev);
|
||||||
|
|
||||||
for_each_rtdcom(rtd, rtdcom) {
|
for_each_rtdcom(rtd, rtdcom) {
|
||||||
component = rtdcom->component;
|
component = rtdcom->component;
|
||||||
|
@ -520,8 +523,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
|
||||||
}
|
}
|
||||||
component = NULL;
|
component = NULL;
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
codec_dai = rtd->codec_dais[i];
|
|
||||||
if (codec_dai->driver->ops->startup) {
|
if (codec_dai->driver->ops->startup) {
|
||||||
ret = codec_dai->driver->ops->startup(substream,
|
ret = codec_dai->driver->ops->startup(substream,
|
||||||
codec_dai);
|
codec_dai);
|
||||||
|
@ -588,10 +590,9 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
|
||||||
goto config_err;
|
goto config_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
if (rtd->codec_dais[i]->active) {
|
if (codec_dai->active) {
|
||||||
ret = soc_pcm_apply_symmetry(substream,
|
ret = soc_pcm_apply_symmetry(substream, codec_dai);
|
||||||
rtd->codec_dais[i]);
|
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
goto config_err;
|
goto config_err;
|
||||||
}
|
}
|
||||||
|
@ -620,8 +621,7 @@ machine_err:
|
||||||
i = rtd->num_codecs;
|
i = rtd->num_codecs;
|
||||||
|
|
||||||
codec_dai_err:
|
codec_dai_err:
|
||||||
while (--i >= 0) {
|
for_each_rtd_codec_dai_reverse(rtd, i, codec_dai) {
|
||||||
codec_dai = rtd->codec_dais[i];
|
|
||||||
if (codec_dai->driver->ops->shutdown)
|
if (codec_dai->driver->ops->shutdown)
|
||||||
codec_dai->driver->ops->shutdown(substream, codec_dai);
|
codec_dai->driver->ops->shutdown(substream, codec_dai);
|
||||||
}
|
}
|
||||||
|
@ -641,9 +641,9 @@ out:
|
||||||
pm_runtime_put_autosuspend(component->dev);
|
pm_runtime_put_autosuspend(component->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
if (!rtd->codec_dais[i]->active)
|
if (!codec_dai->active)
|
||||||
pinctrl_pm_select_sleep_state(rtd->codec_dais[i]->dev);
|
pinctrl_pm_select_sleep_state(codec_dai->dev);
|
||||||
}
|
}
|
||||||
if (!cpu_dai->active)
|
if (!cpu_dai->active)
|
||||||
pinctrl_pm_select_sleep_state(cpu_dai->dev);
|
pinctrl_pm_select_sleep_state(cpu_dai->dev);
|
||||||
|
@ -701,8 +701,7 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
|
||||||
if (!cpu_dai->active)
|
if (!cpu_dai->active)
|
||||||
cpu_dai->rate = 0;
|
cpu_dai->rate = 0;
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
codec_dai = rtd->codec_dais[i];
|
|
||||||
if (!codec_dai->active)
|
if (!codec_dai->active)
|
||||||
codec_dai->rate = 0;
|
codec_dai->rate = 0;
|
||||||
}
|
}
|
||||||
|
@ -712,8 +711,7 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
|
||||||
if (cpu_dai->driver->ops->shutdown)
|
if (cpu_dai->driver->ops->shutdown)
|
||||||
cpu_dai->driver->ops->shutdown(substream, cpu_dai);
|
cpu_dai->driver->ops->shutdown(substream, cpu_dai);
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
codec_dai = rtd->codec_dais[i];
|
|
||||||
if (codec_dai->driver->ops->shutdown)
|
if (codec_dai->driver->ops->shutdown)
|
||||||
codec_dai->driver->ops->shutdown(substream, codec_dai);
|
codec_dai->driver->ops->shutdown(substream, codec_dai);
|
||||||
}
|
}
|
||||||
|
@ -751,9 +749,9 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
|
||||||
pm_runtime_put_autosuspend(component->dev);
|
pm_runtime_put_autosuspend(component->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
if (!rtd->codec_dais[i]->active)
|
if (!codec_dai->active)
|
||||||
pinctrl_pm_select_sleep_state(rtd->codec_dais[i]->dev);
|
pinctrl_pm_select_sleep_state(codec_dai->dev);
|
||||||
}
|
}
|
||||||
if (!cpu_dai->active)
|
if (!cpu_dai->active)
|
||||||
pinctrl_pm_select_sleep_state(cpu_dai->dev);
|
pinctrl_pm_select_sleep_state(cpu_dai->dev);
|
||||||
|
@ -801,8 +799,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
codec_dai = rtd->codec_dais[i];
|
|
||||||
if (codec_dai->driver->ops->prepare) {
|
if (codec_dai->driver->ops->prepare) {
|
||||||
ret = codec_dai->driver->ops->prepare(substream,
|
ret = codec_dai->driver->ops->prepare(substream,
|
||||||
codec_dai);
|
codec_dai);
|
||||||
|
@ -834,8 +831,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 (i = 0; i < rtd->num_codecs; i++)
|
for_each_rtd_codec_dai(rtd, i, codec_dai)
|
||||||
snd_soc_dai_digital_mute(rtd->codec_dais[i], 0,
|
snd_soc_dai_digital_mute(codec_dai, 0,
|
||||||
substream->stream);
|
substream->stream);
|
||||||
snd_soc_dai_digital_mute(cpu_dai, 0, substream->stream);
|
snd_soc_dai_digital_mute(cpu_dai, 0, substream->stream);
|
||||||
|
|
||||||
|
@ -920,6 +917,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
|
||||||
struct snd_soc_component *component;
|
struct snd_soc_component *component;
|
||||||
struct snd_soc_rtdcom_list *rtdcom;
|
struct snd_soc_rtdcom_list *rtdcom;
|
||||||
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
||||||
|
struct snd_soc_dai *codec_dai;
|
||||||
int i, ret = 0;
|
int i, ret = 0;
|
||||||
|
|
||||||
mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
|
mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
|
||||||
|
@ -932,8 +930,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
struct snd_soc_dai *codec_dai = rtd->codec_dais[i];
|
|
||||||
struct snd_pcm_hw_params codec_params;
|
struct snd_pcm_hw_params codec_params;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1018,8 +1015,7 @@ interface_err:
|
||||||
i = rtd->num_codecs;
|
i = rtd->num_codecs;
|
||||||
|
|
||||||
codec_err:
|
codec_err:
|
||||||
while (--i >= 0) {
|
for_each_rtd_codec_dai_reverse(rtd, i, codec_dai) {
|
||||||
struct snd_soc_dai *codec_dai = rtd->codec_dais[i];
|
|
||||||
if (codec_dai->driver->ops->hw_free)
|
if (codec_dai->driver->ops->hw_free)
|
||||||
codec_dai->driver->ops->hw_free(substream, codec_dai);
|
codec_dai->driver->ops->hw_free(substream, codec_dai);
|
||||||
codec_dai->rate = 0;
|
codec_dai->rate = 0;
|
||||||
|
@ -1052,8 +1048,7 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
|
||||||
cpu_dai->sample_bits = 0;
|
cpu_dai->sample_bits = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
codec_dai = rtd->codec_dais[i];
|
|
||||||
if (codec_dai->active == 1) {
|
if (codec_dai->active == 1) {
|
||||||
codec_dai->rate = 0;
|
codec_dai->rate = 0;
|
||||||
codec_dai->channels = 0;
|
codec_dai->channels = 0;
|
||||||
|
@ -1062,10 +1057,10 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* apply codec digital mute */
|
/* apply codec digital mute */
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
if ((playback && rtd->codec_dais[i]->playback_active == 1) ||
|
if ((playback && codec_dai->playback_active == 1) ||
|
||||||
(!playback && rtd->codec_dais[i]->capture_active == 1))
|
(!playback && codec_dai->capture_active == 1))
|
||||||
snd_soc_dai_digital_mute(rtd->codec_dais[i], 1,
|
snd_soc_dai_digital_mute(codec_dai, 1,
|
||||||
substream->stream);
|
substream->stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1077,8 +1072,7 @@ 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 (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
codec_dai = rtd->codec_dais[i];
|
|
||||||
if (codec_dai->driver->ops->hw_free)
|
if (codec_dai->driver->ops->hw_free)
|
||||||
codec_dai->driver->ops->hw_free(substream, codec_dai);
|
codec_dai->driver->ops->hw_free(substream, codec_dai);
|
||||||
}
|
}
|
||||||
|
@ -1099,8 +1093,7 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
|
||||||
struct snd_soc_dai *codec_dai;
|
struct snd_soc_dai *codec_dai;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
codec_dai = rtd->codec_dais[i];
|
|
||||||
if (codec_dai->driver->ops->trigger) {
|
if (codec_dai->driver->ops->trigger) {
|
||||||
ret = codec_dai->driver->ops->trigger(substream,
|
ret = codec_dai->driver->ops->trigger(substream,
|
||||||
cmd, codec_dai);
|
cmd, codec_dai);
|
||||||
|
@ -1144,8 +1137,7 @@ static int soc_pcm_bespoke_trigger(struct snd_pcm_substream *substream,
|
||||||
struct snd_soc_dai *codec_dai;
|
struct snd_soc_dai *codec_dai;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
codec_dai = rtd->codec_dais[i];
|
|
||||||
if (codec_dai->driver->ops->bespoke_trigger) {
|
if (codec_dai->driver->ops->bespoke_trigger) {
|
||||||
ret = codec_dai->driver->ops->bespoke_trigger(substream,
|
ret = codec_dai->driver->ops->bespoke_trigger(substream,
|
||||||
cmd, codec_dai);
|
cmd, codec_dai);
|
||||||
|
@ -1199,8 +1191,7 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
|
||||||
if (cpu_dai->driver->ops->delay)
|
if (cpu_dai->driver->ops->delay)
|
||||||
delay += cpu_dai->driver->ops->delay(substream, cpu_dai);
|
delay += cpu_dai->driver->ops->delay(substream, cpu_dai);
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
codec_dai = rtd->codec_dais[i];
|
|
||||||
if (codec_dai->driver->ops->delay)
|
if (codec_dai->driver->ops->delay)
|
||||||
codec_delay = max(codec_delay,
|
codec_delay = max(codec_delay,
|
||||||
codec_dai->driver->ops->delay(substream,
|
codec_dai->driver->ops->delay(substream,
|
||||||
|
@ -1388,6 +1379,7 @@ static bool dpcm_end_walk_at_be(struct snd_soc_dapm_widget *widget,
|
||||||
{
|
{
|
||||||
struct snd_soc_card *card = widget->dapm->card;
|
struct snd_soc_card *card = widget->dapm->card;
|
||||||
struct snd_soc_pcm_runtime *rtd;
|
struct snd_soc_pcm_runtime *rtd;
|
||||||
|
struct snd_soc_dai *dai;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (dir == SND_SOC_DAPM_DIR_OUT) {
|
if (dir == SND_SOC_DAPM_DIR_OUT) {
|
||||||
|
@ -1398,8 +1390,7 @@ static bool dpcm_end_walk_at_be(struct snd_soc_dapm_widget *widget,
|
||||||
if (rtd->cpu_dai->playback_widget == widget)
|
if (rtd->cpu_dai->playback_widget == widget)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; ++i) {
|
for_each_rtd_codec_dai(rtd, i, dai) {
|
||||||
struct snd_soc_dai *dai = rtd->codec_dais[i];
|
|
||||||
if (dai->playback_widget == widget)
|
if (dai->playback_widget == widget)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1412,8 +1403,7 @@ static bool dpcm_end_walk_at_be(struct snd_soc_dapm_widget *widget,
|
||||||
if (rtd->cpu_dai->capture_widget == widget)
|
if (rtd->cpu_dai->capture_widget == widget)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; ++i) {
|
for_each_rtd_codec_dai(rtd, i, dai) {
|
||||||
struct snd_soc_dai *dai = rtd->codec_dais[i];
|
|
||||||
if (dai->capture_widget == widget)
|
if (dai->capture_widget == widget)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1907,6 +1897,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 = be_substream->private_data;
|
struct snd_soc_pcm_runtime *rtd = be_substream->private_data;
|
||||||
|
struct snd_soc_dai *codec_dai;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (rtd->dai_link->be_hw_params_fixup)
|
if (rtd->dai_link->be_hw_params_fixup)
|
||||||
|
@ -1923,10 +1914,10 @@ static int dpcm_apply_symmetry(struct snd_pcm_substream *fe_substream,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
if (rtd->codec_dais[i]->active) {
|
if (codec_dai->active) {
|
||||||
err = soc_pcm_apply_symmetry(fe_substream,
|
err = soc_pcm_apply_symmetry(fe_substream,
|
||||||
rtd->codec_dais[i]);
|
codec_dai);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -3041,8 +3032,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
|
||||||
playback = rtd->dai_link->dpcm_playback;
|
playback = rtd->dai_link->dpcm_playback;
|
||||||
capture = rtd->dai_link->dpcm_capture;
|
capture = rtd->dai_link->dpcm_capture;
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < rtd->num_codecs; i++) {
|
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
||||||
codec_dai = rtd->codec_dais[i];
|
|
||||||
if (codec_dai->driver->playback.channels_min)
|
if (codec_dai->driver->playback.channels_min)
|
||||||
playback = 1;
|
playback = 1;
|
||||||
if (codec_dai->driver->capture.channels_min)
|
if (codec_dai->driver->capture.channels_min)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче