Skip to content

Commit

Permalink
Merge series "ASoC: cleanup / tidyup soc-pcm/core/component" from Kun…
Browse files Browse the repository at this point in the history
…inori Morimoto <kuninori.morimoto.gx@renesas.com>:

Hi Mark

These are not a big deal, but cleanup / tidyup patch for ALSA SoC.

Kuninori Morimoto (5):
  ASoC: soc-pcm: tidyup soc_pcm_hw_clean() - step1
  ASoC: soc-pcm: tidyup soc_pcm_hw_clean() - step2
  ASoC: soc-component: add snd_soc_component_is_codec()
  ASoC: soc-core: tidyup empty function
  ASoC: soc-core: accept zero format at snd_soc_runtime_set_dai_fmt()

 include/sound/soc-component.h         |  5 +++
 sound/soc/generic/simple-card-utils.c |  4 +--
 sound/soc/meson/meson-codec-glue.c    |  3 --
 sound/soc/soc-core.c                  | 51 ++++++++-------------------
 sound/soc/soc-pcm.c                   | 13 +++----
 5 files changed, 26 insertions(+), 50 deletions(-)

--
2.25.1
  • Loading branch information
Mark Brown committed Oct 18, 2021
2 parents a2b5c48 + 7db07e3 commit a79b02d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 50 deletions.
5 changes: 5 additions & 0 deletions include/sound/soc-component.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ static inline int snd_soc_component_cache_sync(
return regcache_sync(component->regmap);
}

static inline int snd_soc_component_is_codec(struct snd_soc_component *component)
{
return component->driver->non_legacy_dai_naming;
}

void snd_soc_component_set_aux(struct snd_soc_component *component,
struct snd_soc_aux_dev *aux);
int snd_soc_component_init(struct snd_soc_component *component);
Expand Down
4 changes: 2 additions & 2 deletions sound/soc/generic/simple-card-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ static int asoc_simple_init_dai_link_params(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_hardware hw;
int i, ret, stream;

/* Only codecs should have non_legacy_dai_naming set. */
/* Only Codecs */
for_each_rtd_components(rtd, i, component) {
if (!component->driver->non_legacy_dai_naming)
if (!snd_soc_component_is_codec(component))
return 0;
}

Expand Down
3 changes: 0 additions & 3 deletions sound/soc/meson/meson-codec-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ int meson_codec_glue_output_startup(struct snd_pcm_substream *substream,
/* Replace link params with the input params */
rtd->dai_link->params = &in_data->params;

if (!in_data->fmt)
return 0;

return snd_soc_runtime_set_dai_fmt(rtd, in_data->fmt);
}
EXPORT_SYMBOL_GPL(meson_codec_glue_output_startup);
Expand Down
51 changes: 15 additions & 36 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,31 +229,12 @@ static void snd_soc_debugfs_exit(void)

#else

static inline void soc_init_component_debugfs(
struct snd_soc_component *component)
{
}

static inline void soc_cleanup_component_debugfs(
struct snd_soc_component *component)
{
}

static inline void soc_init_card_debugfs(struct snd_soc_card *card)
{
}

static inline void soc_cleanup_card_debugfs(struct snd_soc_card *card)
{
}

static inline void snd_soc_debugfs_init(void)
{
}

static inline void snd_soc_debugfs_exit(void)
{
}
static inline void soc_init_component_debugfs(struct snd_soc_component *component) { }
static inline void soc_cleanup_component_debugfs(struct snd_soc_component *component) { }
static inline void soc_init_card_debugfs(struct snd_soc_card *card) { }
static inline void soc_cleanup_card_debugfs(struct snd_soc_card *card) { }
static inline void snd_soc_debugfs_init(void) { }
static inline void snd_soc_debugfs_exit(void) { }

#endif

Expand Down Expand Up @@ -739,9 +720,7 @@ static void soc_resume_init(struct snd_soc_card *card)
#else
#define snd_soc_suspend NULL
#define snd_soc_resume NULL
static inline void soc_resume_init(struct snd_soc_card *card)
{
}
static inline void soc_resume_init(struct snd_soc_card *card) { }
#endif

static struct device_node
Expand Down Expand Up @@ -1239,6 +1218,9 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
unsigned int i;
int ret;

if (!dai_fmt)
return 0;

for_each_rtd_codec_dais(rtd, i, codec_dai) {
ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt);
if (ret != 0 && ret != -ENOTSUPP)
Expand All @@ -1247,14 +1229,13 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,

/*
* Flip the polarity for the "CPU" end of a CODEC<->CODEC link
* the component which has non_legacy_dai_naming is Codec
*/
inv_dai_fmt = snd_soc_daifmt_clock_provider_fliped(dai_fmt);

for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
unsigned int fmt = dai_fmt;

if (cpu_dai->component->driver->non_legacy_dai_naming)
if (snd_soc_component_is_codec(cpu_dai->component))
fmt = inv_dai_fmt;

ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
Expand Down Expand Up @@ -1283,11 +1264,9 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,
return ret;

snd_soc_runtime_get_dai_fmt(rtd);
if (dai_link->dai_fmt) {
ret = snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt);
if (ret)
return ret;
}
ret = snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt);
if (ret)
return ret;

/* add DPCM sysfs entries */
soc_dpcm_debugfs_add(rtd);
Expand Down Expand Up @@ -2521,7 +2500,7 @@ static int snd_soc_register_dais(struct snd_soc_component *component,

for (i = 0; i < count; i++) {
dai = snd_soc_register_dai(component, dai_drv + i, count == 1 &&
!component->driver->non_legacy_dai_naming);
!snd_soc_component_is_codec(component));
if (dai == NULL) {
ret = -ENOMEM;
goto err;
Expand Down
13 changes: 4 additions & 9 deletions sound/soc/soc-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -879,12 +879,10 @@ static int soc_pcm_hw_clean(struct snd_pcm_substream *substream, int rollback)

/* clear the corresponding DAIs parameters when going to be inactive */
for_each_rtd_dais(rtd, i, dai) {
int active = snd_soc_dai_stream_active(dai, substream->stream);

if (snd_soc_dai_active(dai) == 1)
soc_pcm_set_dai_params(dai, NULL);

if (active == 1)
if (snd_soc_dai_stream_active(dai, substream->stream) == 1)
snd_soc_dai_digital_mute(dai, 1, substream->stream);
}

Expand All @@ -898,12 +896,9 @@ static int soc_pcm_hw_clean(struct snd_pcm_substream *substream, int rollback)
snd_soc_pcm_component_hw_free(substream, rollback);

/* now free hw params for the DAIs */
for_each_rtd_dais(rtd, i, dai) {
if (!snd_soc_dai_stream_valid(dai, substream->stream))
continue;

snd_soc_dai_hw_free(dai, substream, rollback);
}
for_each_rtd_dais(rtd, i, dai)
if (snd_soc_dai_stream_valid(dai, substream->stream))
snd_soc_dai_hw_free(dai, substream, rollback);

mutex_unlock(&rtd->card->pcm_mutex);
return 0;
Expand Down

0 comments on commit a79b02d

Please sign in to comment.