ASoC: dmaengine_pcm: Allow passing component name via config
authorTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Tue, 19 Mar 2024 08:22:36 +0000 (10:22 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 25 Mar 2024 00:49:47 +0000 (00:49 +0000)
At the moment we cannot instantiate two dmaengine_pcms with the same
parent device, as the components will be named the same, leading to
conflicts.

Add 'name' field to the snd_dmaengine_pcm_config, and use that (if
defined) as the component name instead of deriving the component name
from the device.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Link: https://msgid.link/r/20240319-xilinx-dp-audio-v2-1-92d6d3a7ca7e@ideasonboard.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/dmaengine_pcm.h
sound/soc/soc-core.c
sound/soc/soc-generic-dmaengine-pcm.c

index d70c55f17df7ca8f9e68f91beb86a93b5f4711d4..c11aaf8079fbbec62c7de6ea36e68d9a25ba12ed 100644 (file)
@@ -118,6 +118,7 @@ int snd_dmaengine_pcm_refine_runtime_hwparams(
  *   which do not use devicetree.
  * @process: Callback used to apply processing on samples transferred from/to
  *   user space.
+ * @name: Component name. If null, dev_name will be used.
  * @compat_filter_fn: Will be used as the filter function when requesting a
  *  channel for platforms which do not use devicetree. The filter parameter
  *  will be the DAI's DMA data.
@@ -143,6 +144,7 @@ struct snd_dmaengine_pcm_config {
        int (*process)(struct snd_pcm_substream *substream,
                       int channel, unsigned long hwoff,
                       unsigned long bytes);
+       const char *name;
        dma_filter_fn compat_filter_fn;
        struct device *dma_dev;
        const char *chan_names[SNDRV_PCM_STREAM_LAST + 1];
index 2ec13d1634b636455f51ab541773e5587003e14b..3ab6626ad68024d7cb8edea5bbd574c72b080015 100644 (file)
@@ -2796,10 +2796,12 @@ int snd_soc_component_initialize(struct snd_soc_component *component,
        INIT_LIST_HEAD(&component->list);
        mutex_init(&component->io_mutex);
 
-       component->name = fmt_single_name(dev, &component->id);
        if (!component->name) {
-               dev_err(dev, "ASoC: Failed to allocate name\n");
-               return -ENOMEM;
+               component->name = fmt_single_name(dev, &component->id);
+               if (!component->name) {
+                       dev_err(dev, "ASoC: Failed to allocate name\n");
+                       return -ENOMEM;
+               }
        }
 
        component->dev          = dev;
index 092ca09f36319d457124f00e027ea87f835552bc..83db1a83d8ba88873858445f836ab45195070043 100644 (file)
@@ -441,6 +441,9 @@ int snd_dmaengine_pcm_register(struct device *dev,
        pcm->config = config;
        pcm->flags = flags;
 
+       if (config->name)
+               pcm->component.name = config->name;
+
        ret = dmaengine_pcm_request_chan_of(pcm, dev, config);
        if (ret)
                goto err_free_dma;