Skip to content

Commit

Permalink
Merge series "ASoC: soc-pcm cleanup step6" from Kuninori Morimoto <ku…
Browse files Browse the repository at this point in the history
…ninori.morimoto.gx@renesas.com>:

Hi Mark

We are using plural form for for_each_xxx() macro.
But, for_each_rtd_codec/cpu_dai() are out of this rule.
1) - 7) are for it.
8) - 9) add new for_each_card_xxx() macros.

Kuninori Morimoto (9):
   1) ASoC: soc.h: add for_each_rtd_codecs/cpus_dai() macro
   2) ASoC: Intel: use for_each_rtd_codecs/cpus_dai() macro
   3) ASoC: mediatek: use for_each_rtd_codecs/cpus_dai() macro
   4) ASoC: meson: use for_each_rtd_codecs/cpus_dai() macro
   5) ASoC: qcom: use for_each_rtd_codecs/cpus_dai() macro
   6) ASoC: soc: use for_each_rtd_codecs/cpus_dai() macro
   7) ASoC: soc.h: remove non plural form for_each_xxx macro
   8) ASoC: soc-dapm: add for_each_card_dapms() macro
   9) ASoC: soc-dapm: add for_each_card_widgets() macro

 drivers/soundwire/qcom.c                      |   2 +-
 include/sound/soc.h                           |  28 ++--
 sound/soc/intel/boards/cml_rt1011_rt5682.c    |   2 +-
 sound/soc/intel/boards/kbl_da7219_max98927.c  |   4 +-
 sound/soc/intel/boards/kbl_rt5663_max98927.c  |   2 +-
 .../intel/boards/kbl_rt5663_rt5514_max98927.c |   2 +-
 .../mediatek/mt8173/mt8173-rt5650-rt5514.c    |   2 +-
 .../mediatek/mt8173/mt8173-rt5650-rt5676.c    |   2 +-
 sound/soc/mediatek/mt8173/mt8173-rt5650.c     |   2 +-
 .../mediatek/mt8183/mt8183-da7219-max98357.c  |   4 +-
 sound/soc/meson/axg-card.c                    |   2 +-
 sound/soc/meson/meson-card-utils.c            |   2 +-
 sound/soc/qcom/apq8016_sbc.c                  |   2 +-
 sound/soc/qcom/sdm845.c                       |   8 +-
 sound/soc/soc-core.c                          |  16 +--
 sound/soc/soc-dapm.c                          |  53 ++++----
 sound/soc/soc-pcm.c                           | 124 +++++++++---------
 sound/soc/soc-topology.c                      |   2 +-
 18 files changed, 134 insertions(+), 125 deletions(-)

--
2.17.1
  • Loading branch information
Mark Brown committed Mar 10, 2020
2 parents a3b7343 + 1459669 commit c23f044
Show file tree
Hide file tree
Showing 18 changed files with 134 additions and 125 deletions.
2 changes: 1 addition & 1 deletion drivers/soundwire/qcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ static int qcom_swrm_startup(struct snd_pcm_substream *substream,

ctrl->sruntime[dai->id] = sruntime;

for_each_rtd_codec_dai(rtd, i, codec_dai) {
for_each_rtd_codec_dais(rtd, i, codec_dai) {
ret = snd_soc_dai_set_sdw_stream(codec_dai, sruntime,
substream->stream);
if (ret < 0 && ret != -ENOTSUPP) {
Expand Down
28 changes: 18 additions & 10 deletions include/sound/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,14 @@ struct snd_soc_card {
#define for_each_card_components(card, component) \
list_for_each_entry(component, &(card)->component_dev_list, card_list)

#define for_each_card_dapms(card, dapm) \
list_for_each_entry(dapm, &card->dapm_list, list)

#define for_each_card_widgets(card, w)\
list_for_each_entry(w, &card->widgets, list)
#define for_each_card_widgets_safe(card, w, _w) \
list_for_each_entry_safe(w, _w, &card->widgets, list)

/* SoC machine DAI configuration, glues a codec and cpu DAI together */
struct snd_soc_pcm_runtime {
struct device *dev;
Expand Down Expand Up @@ -1163,19 +1171,19 @@ struct snd_soc_pcm_runtime {
for ((i) = 0; \
((i) < rtd->num_components) && ((component) = rtd->components[i]);\
(i)++)
#define for_each_rtd_codec_dai(rtd, i, dai)\
for ((i) = 0; \
((i) < rtd->num_codecs) && ((dai) = rtd->codec_dais[i]); \
#define for_each_rtd_cpu_dais(rtd, i, dai) \
for ((i) = 0; \
((i) < rtd->num_cpus) && ((dai) = rtd->cpu_dais[i]); \
(i)++)
#define for_each_rtd_cpu_dais_rollback(rtd, i, dai) \
for (; (--(i) >= 0) && ((dai) = rtd->cpu_dais[i]);)
#define for_each_rtd_codec_dais(rtd, i, dai) \
for ((i) = 0; \
((i) < rtd->num_codecs) && ((dai) = rtd->codec_dais[i]); \
(i)++)
#define for_each_rtd_codec_dai_rollback(rtd, i, dai) \
#define for_each_rtd_codec_dais_rollback(rtd, i, dai) \
for (; (--(i) >= 0) && ((dai) = rtd->codec_dais[i]);)

#define for_each_rtd_cpu_dai(rtd, i, dai)\
for ((i) = 0; \
((i) < rtd->num_cpus) && ((dai) = rtd->cpu_dais[i]); \
(i)++)
#define for_each_rtd_cpu_dai_rollback(rtd, i, dai) \
for (; (--(i) >= 0) && ((dai) = rtd->cpu_dais[i]);)

void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd);

Expand Down
2 changes: 1 addition & 1 deletion sound/soc/intel/boards/cml_rt1011_rt5682.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static int cml_rt1011_hw_params(struct snd_pcm_substream *substream,

srate = params_rate(params);

for_each_rtd_codec_dai(rtd, i, codec_dai) {
for_each_rtd_codec_dais(rtd, i, codec_dai) {

/* 100 Fs to drive 24 bit data */
ret = snd_soc_dai_set_pll(codec_dai, 0, RT1011_PLL1_S_BCLK,
Expand Down
4 changes: 2 additions & 2 deletions sound/soc/intel/boards/kbl_da7219_max98927.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *codec_dai;
int ret, j;

for_each_rtd_codec_dai(runtime, j, codec_dai) {
for_each_rtd_codec_dais(runtime, j, codec_dai) {

if (!strcmp(codec_dai->component->name, MAX98927_DEV0_NAME)) {
ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x30, 3, 8, 16);
Expand Down Expand Up @@ -224,7 +224,7 @@ static int kabylake_ssp0_trigger(struct snd_pcm_substream *substream, int cmd)
struct snd_soc_dai *codec_dai;
int j, ret;

for_each_rtd_codec_dai(rtd, j, codec_dai) {
for_each_rtd_codec_dais(rtd, j, codec_dai) {
const char *name = codec_dai->component->name;
struct snd_soc_component *component = codec_dai->component;
struct snd_soc_dapm_context *dapm =
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/intel/boards/kbl_rt5663_max98927.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *codec_dai;
int ret = 0, j;

for_each_rtd_codec_dai(rtd, j, codec_dai) {
for_each_rtd_codec_dais(rtd, j, codec_dai) {
if (!strcmp(codec_dai->component->name, MAXIM_DEV0_NAME)) {
/*
* Use channel 4 and 5 for the first amp
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *codec_dai;
int ret = 0, j;

for_each_rtd_codec_dai(rtd, j, codec_dai) {
for_each_rtd_codec_dais(rtd, j, codec_dai) {
if (!strcmp(codec_dai->component->name, RT5514_DEV_NAME)) {
ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xF, 0, 8, 16);
if (ret < 0) {
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static int mt8173_rt5650_rt5514_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *codec_dai;
int i, ret;

for_each_rtd_codec_dai(rtd, i, codec_dai) {
for_each_rtd_codec_dais(rtd, i, codec_dai) {
/* pll from mclk 12.288M */
ret = snd_soc_dai_set_pll(codec_dai, 0, 0, MCLK_FOR_CODECS,
params_rate(params) * 512);
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static int mt8173_rt5650_rt5676_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *codec_dai;
int i, ret;

for_each_rtd_codec_dai(rtd, i, codec_dai) {
for_each_rtd_codec_dais(rtd, i, codec_dai) {
/* pll from mclk 12.288M */
ret = snd_soc_dai_set_pll(codec_dai, 0, 0, MCLK_FOR_CODECS,
params_rate(params) * 512);
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/mediatek/mt8173/mt8173-rt5650.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static int mt8173_rt5650_hw_params(struct snd_pcm_substream *substream,
break;
}

for_each_rtd_codec_dai(rtd, i, codec_dai) {
for_each_rtd_codec_dais(rtd, i, codec_dai) {
/* pll from mclk */
ret = snd_soc_dai_set_pll(codec_dai, 0, 0, mclk_clock,
params_rate(params) * 512);
Expand Down
4 changes: 2 additions & 2 deletions sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static int mt8183_da7219_i2s_hw_params(struct snd_pcm_substream *substream,
if (ret < 0)
dev_err(rtd->dev, "failed to set cpu dai sysclk\n");

for_each_rtd_codec_dai(rtd, j, codec_dai) {
for_each_rtd_codec_dais(rtd, j, codec_dai) {

if (!strcmp(codec_dai->component->name, "da7219.5-001a")) {
ret = snd_soc_dai_set_sysclk(codec_dai,
Expand Down Expand Up @@ -85,7 +85,7 @@ static int mt8183_da7219_hw_free(struct snd_pcm_substream *substream)
struct snd_soc_dai *codec_dai;
int ret = 0, j;

for_each_rtd_codec_dai(rtd, j, codec_dai) {
for_each_rtd_codec_dais(rtd, j, codec_dai) {

if (!strcmp(codec_dai->component->name, "da7219.5-001a")) {
ret = snd_soc_dai_set_pll(codec_dai,
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/meson/axg-card.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static int axg_card_tdm_dai_init(struct snd_soc_pcm_runtime *rtd)
struct snd_soc_dai *codec_dai;
int ret, i;

for_each_rtd_codec_dai(rtd, i, codec_dai) {
for_each_rtd_codec_dais(rtd, i, codec_dai) {
ret = snd_soc_dai_set_tdm_slot(codec_dai,
be->codec_masks[i].tx,
be->codec_masks[i].rx,
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/meson/meson-card-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int meson_card_i2s_set_sysclk(struct snd_pcm_substream *substream,

mclk = params_rate(params) * mclk_fs;

for_each_rtd_codec_dai(rtd, i, codec_dai) {
for_each_rtd_codec_dais(rtd, i, codec_dai) {
ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
SND_SOC_CLOCK_IN);
if (ret && ret != -ENOTSUPP)
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/qcom/apq8016_sbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static int apq8016_sbc_dai_init(struct snd_soc_pcm_runtime *rtd)
pdata->jack_setup = true;
}

for_each_rtd_codec_dai(rtd, i, codec_dai) {
for_each_rtd_codec_dais(rtd, i, codec_dai) {

component = codec_dai->component;
/* Set default mclk for internal codec */
Expand Down
8 changes: 4 additions & 4 deletions sound/soc/qcom/sdm845.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static int sdm845_slim_snd_hw_params(struct snd_pcm_substream *substream,
u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
int ret = 0, i;

for_each_rtd_codec_dai(rtd, i, codec_dai) {
for_each_rtd_codec_dais(rtd, i, codec_dai) {
ret = snd_soc_dai_get_channel_map(codec_dai,
&tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);

Expand Down Expand Up @@ -126,7 +126,7 @@ static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream,
}
}

for_each_rtd_codec_dai(rtd, j, codec_dai) {
for_each_rtd_codec_dais(rtd, j, codec_dai) {

if (!strcmp(codec_dai->component->name_prefix, "Left")) {
ret = snd_soc_dai_set_tdm_slot(
Expand Down Expand Up @@ -265,7 +265,7 @@ static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd)
}
break;
case SLIMBUS_0_RX...SLIMBUS_6_TX:
for_each_rtd_codec_dai(rtd, i, codec_dai) {
for_each_rtd_codec_dais(rtd, i, codec_dai) {
rval = snd_soc_dai_set_channel_map(codec_dai,
ARRAY_SIZE(tx_ch),
tx_ch,
Expand Down Expand Up @@ -344,7 +344,7 @@ static int sdm845_snd_startup(struct snd_pcm_substream *substream)

codec_dai_fmt |= SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_DSP_B;

for_each_rtd_codec_dai(rtd, j, codec_dai) {
for_each_rtd_codec_dais(rtd, j, codec_dai) {

if (!strcmp(codec_dai->component->name_prefix,
"Left")) {
Expand Down
16 changes: 8 additions & 8 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ int snd_soc_suspend(struct device *dev)
if (rtd->dai_link->ignore_suspend)
continue;

for_each_rtd_codec_dai(rtd, i, dai) {
for_each_rtd_codec_dais(rtd, i, dai) {
if (dai->stream_active[playback])
snd_soc_dai_digital_mute(dai, 1, playback);
}
Expand Down Expand Up @@ -689,7 +689,7 @@ static void soc_resume_deferred(struct work_struct *work)
if (rtd->dai_link->ignore_suspend)
continue;

for_each_rtd_codec_dai(rtd, i, dai) {
for_each_rtd_codec_dais(rtd, i, dai) {
if (dai->stream_active[playback])
snd_soc_dai_digital_mute(dai, 0, playback);
}
Expand Down Expand Up @@ -1321,10 +1321,10 @@ static void soc_remove_link_dais(struct snd_soc_card *card)
for_each_comp_order(order) {
for_each_card_rtds(card, rtd) {
/* remove the CODEC DAI */
for_each_rtd_codec_dai(rtd, i, codec_dai)
for_each_rtd_codec_dais(rtd, i, codec_dai)
soc_remove_dai(codec_dai, order);

for_each_rtd_cpu_dai(rtd, i, cpu_dai)
for_each_rtd_cpu_dais(rtd, i, cpu_dai)
soc_remove_dai(cpu_dai, order);
}
}
Expand All @@ -1344,14 +1344,14 @@ static int soc_probe_link_dais(struct snd_soc_card *card)
card->name, rtd->num, order);

/* probe the CPU DAI */
for_each_rtd_cpu_dai(rtd, i, cpu_dai) {
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
ret = soc_probe_dai(cpu_dai, order);
if (ret)
return ret;
}

/* probe the CODEC DAI */
for_each_rtd_codec_dai(rtd, i, codec_dai) {
for_each_rtd_codec_dais(rtd, i, codec_dai) {
ret = soc_probe_dai(codec_dai, order);
if (ret)
return ret;
Expand Down Expand Up @@ -1486,7 +1486,7 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
unsigned int i;
int ret;

for_each_rtd_codec_dai(rtd, i, codec_dai) {
for_each_rtd_codec_dais(rtd, i, codec_dai) {
ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt);
if (ret != 0 && ret != -ENOTSUPP) {
dev_warn(codec_dai->dev,
Expand Down Expand Up @@ -1514,7 +1514,7 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
inv_dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
break;
}
for_each_rtd_cpu_dai(rtd, i, cpu_dai) {
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
unsigned int fmt = dai_fmt;

if (cpu_dai->component->driver->non_legacy_dai_naming)
Expand Down
Loading

0 comments on commit c23f044

Please sign in to comment.