Commit 99b04f4c authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: add Component level pcm_new/pcm_free

In current ALSA SoC, Platform only has pcm_new/pcm_free feature,
but it should be supported on Component level. This patch adds it.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent a5de5b74
...@@ -785,6 +785,10 @@ struct snd_soc_component_driver { ...@@ -785,6 +785,10 @@ struct snd_soc_component_driver {
int (*suspend)(struct snd_soc_component *); int (*suspend)(struct snd_soc_component *);
int (*resume)(struct snd_soc_component *); int (*resume)(struct snd_soc_component *);
/* pcm creation and destruction */
int (*pcm_new)(struct snd_soc_pcm_runtime *);
void (*pcm_free)(struct snd_pcm *);
/* DT */ /* DT */
int (*of_xlate_dai_name)(struct snd_soc_component *component, int (*of_xlate_dai_name)(struct snd_soc_component *component,
struct of_phandle_args *args, struct of_phandle_args *args,
...@@ -858,6 +862,8 @@ struct snd_soc_component { ...@@ -858,6 +862,8 @@ struct snd_soc_component {
void (*remove)(struct snd_soc_component *); void (*remove)(struct snd_soc_component *);
int (*suspend)(struct snd_soc_component *); int (*suspend)(struct snd_soc_component *);
int (*resume)(struct snd_soc_component *); int (*resume)(struct snd_soc_component *);
int (*pcm_new)(struct snd_soc_pcm_runtime *);
void (*pcm_free)(struct snd_pcm *);
/* machine specific init */ /* machine specific init */
int (*init)(struct snd_soc_component *component); int (*init)(struct snd_soc_component *component);
......
...@@ -2976,6 +2976,8 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, ...@@ -2976,6 +2976,8 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
component->remove = component->driver->remove; component->remove = component->driver->remove;
component->suspend = component->driver->suspend; component->suspend = component->driver->suspend;
component->resume = component->driver->resume; component->resume = component->driver->resume;
component->pcm_new = component->driver->pcm_new;
component->pcm_free= component->driver->pcm_free;
dapm = &component->dapm; dapm = &component->dapm;
dapm->dev = dev; dapm->dev = dev;
...@@ -3158,6 +3160,21 @@ static void snd_soc_platform_drv_remove(struct snd_soc_component *component) ...@@ -3158,6 +3160,21 @@ static void snd_soc_platform_drv_remove(struct snd_soc_component *component)
platform->driver->remove(platform); platform->driver->remove(platform);
} }
static int snd_soc_platform_drv_pcm_new(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_platform *platform = rtd->platform;
return platform->driver->pcm_new(rtd);
}
static void snd_soc_platform_drv_pcm_free(struct snd_pcm *pcm)
{
struct snd_soc_pcm_runtime *rtd = pcm->private_data;
struct snd_soc_platform *platform = rtd->platform;
platform->driver->pcm_free(pcm);
}
/** /**
* snd_soc_add_platform - Add a platform to the ASoC core * snd_soc_add_platform - Add a platform to the ASoC core
* @dev: The parent device for the platform * @dev: The parent device for the platform
...@@ -3181,6 +3198,10 @@ int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, ...@@ -3181,6 +3198,10 @@ int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform,
platform->component.probe = snd_soc_platform_drv_probe; platform->component.probe = snd_soc_platform_drv_probe;
if (platform_drv->remove) if (platform_drv->remove)
platform->component.remove = snd_soc_platform_drv_remove; platform->component.remove = snd_soc_platform_drv_remove;
if (platform_drv->pcm_new)
platform->component.pcm_new = snd_soc_platform_drv_pcm_new;
if (platform_drv->pcm_free)
platform->component.pcm_free = snd_soc_platform_drv_pcm_free;
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
platform->component.debugfs_prefix = "platform"; platform->component.debugfs_prefix = "platform";
......
...@@ -2640,12 +2640,25 @@ static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream) ...@@ -2640,12 +2640,25 @@ static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream)
return ret; return ret;
} }
static void soc_pcm_free(struct snd_pcm *pcm)
{
struct snd_soc_pcm_runtime *rtd = pcm->private_data;
struct snd_soc_component *component;
list_for_each_entry(component, &rtd->card->component_dev_list,
card_list) {
if (component->pcm_free)
component->pcm_free(pcm);
}
}
/* create a new pcm */ /* create a new pcm */
int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
{ {
struct snd_soc_platform *platform = rtd->platform; struct snd_soc_platform *platform = rtd->platform;
struct snd_soc_dai *codec_dai; struct snd_soc_dai *codec_dai;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
struct snd_soc_component *component;
struct snd_pcm *pcm; struct snd_pcm *pcm;
char new_name[64]; char new_name[64];
int ret = 0, playback = 0, capture = 0; int ret = 0, playback = 0, capture = 0;
...@@ -2754,17 +2767,18 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) ...@@ -2754,17 +2767,18 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
if (capture) if (capture)
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops);
if (platform->driver->pcm_new) { list_for_each_entry(component, &rtd->card->component_dev_list, card_list) {
ret = platform->driver->pcm_new(rtd); if (component->pcm_new) {
if (ret < 0) { ret = component->pcm_new(rtd);
dev_err(platform->dev, if (ret < 0) {
"ASoC: pcm constructor failed: %d\n", dev_err(component->dev,
ret); "ASoC: pcm constructor failed: %d\n",
return ret; ret);
return ret;
}
} }
} }
pcm->private_free = soc_pcm_free;
pcm->private_free = platform->driver->pcm_free;
out: out:
dev_info(rtd->card->dev, "%s <-> %s mapping ok\n", dev_info(rtd->card->dev, "%s <-> %s mapping ok\n",
(rtd->num_codecs > 1) ? "multicodec" : rtd->codec_dai->name, (rtd->num_codecs > 1) ? "multicodec" : rtd->codec_dai->name,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment