Skip to content

Commit

Permalink
Merge series "ASoC: dapm/pins: handle component prefix" from Pierre-L…
Browse files Browse the repository at this point in the history
…ouis Bossart <pierre-louis.bossart@linux.intel.com>:

SoundWire machine drivers make a heavy use of component prefixes to
uniquify control names. This however results in errors when looking
for widgets or pins. This patchset suggests two solutions but feedback
or suggestions on how to take the prefix into account would be
welcome.

Bard Liao (1):
  ASoC: Intel: boards: max98373: get dapm from cpu_dai

Shuming Fan (1):
  ASoC: dapm: use component prefix when checking widget names

 sound/soc/intel/boards/sof_maxim_common.c |  5 +++--
 sound/soc/soc-dapm.c                      | 13 ++++++++++++-
 2 files changed, 15 insertions(+), 3 deletions(-)

--
2.25.1
  • Loading branch information
Mark Brown committed Feb 10, 2021
2 parents 4fc320d + 1183c35 commit b165457
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions sound/soc/intel/boards/sof_maxim_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,18 @@ int max98373_trigger(struct snd_pcm_substream *substream, int cmd)
{
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
struct snd_soc_dai *codec_dai;
struct snd_soc_dai *cpu_dai;
int j;
int ret = 0;

/* set spk pin by playback only */
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
return 0;

cpu_dai = asoc_rtd_to_cpu(rtd, 0);
for_each_rtd_codec_dais(rtd, j, codec_dai) {
struct snd_soc_component *component = codec_dai->component;
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
snd_soc_component_get_dapm(cpu_dai->component);
char pin_name[MAX_98373_PIN_NAME];

snprintf(pin_name, ARRAY_SIZE(pin_name), "%s Spk",
Expand Down
13 changes: 12 additions & 1 deletion sound/soc/soc-dapm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2528,9 +2528,20 @@ static struct snd_soc_dapm_widget *dapm_find_widget(
{
struct snd_soc_dapm_widget *w;
struct snd_soc_dapm_widget *fallback = NULL;
char prefixed_pin[80];
const char *pin_name;
const char *prefix = soc_dapm_prefix(dapm);

if (prefix) {
snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
prefix, pin);
pin_name = prefixed_pin;
} else {
pin_name = pin;
}

for_each_card_widgets(dapm->card, w) {
if (!strcmp(w->name, pin)) {
if (!strcmp(w->name, pin_name)) {
if (w->dapm == dapm)
return w;
else
Expand Down

0 comments on commit b165457

Please sign in to comment.