aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2017-02-19 11:35:41 -0500
committerMark Brown <broonie@kernel.org>2017-02-19 11:35:41 -0500
commit4ae8be8ea9f7b46f339b8481c265256ffd412567 (patch)
tree4c296a7ed3919a05e9a786945e5c62a336e4f95a
parent39bc30f25329ad16d67760581183ab7828f495cc (diff)
parent96241bae08f63e40dad8f3764e332858b27ba23c (diff)
Merge remote-tracking branch 'asoc/topic/component' into asoc-next
-rw-r--r--include/sound/soc.h18
-rw-r--r--sound/soc/soc-core.c21
-rw-r--r--sound/soc/soc-pcm.c55
3 files changed, 50 insertions, 44 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index b86168a21d56..5ab2e7e090c8 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -507,9 +507,6 @@ int snd_soc_params_to_bclk(struct snd_pcm_hw_params *parms);
507int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, 507int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
508 const struct snd_pcm_hardware *hw); 508 const struct snd_pcm_hardware *hw);
509 509
510int snd_soc_platform_trigger(struct snd_pcm_substream *substream,
511 int cmd, struct snd_soc_platform *platform);
512
513int soc_dai_hw_params(struct snd_pcm_substream *substream, 510int soc_dai_hw_params(struct snd_pcm_substream *substream,
514 struct snd_pcm_hw_params *params, 511 struct snd_pcm_hw_params *params,
515 struct snd_soc_dai *dai); 512 struct snd_soc_dai *dai);
@@ -785,6 +782,10 @@ struct snd_soc_component_driver {
785 int (*suspend)(struct snd_soc_component *); 782 int (*suspend)(struct snd_soc_component *);
786 int (*resume)(struct snd_soc_component *); 783 int (*resume)(struct snd_soc_component *);
787 784
785 /* pcm creation and destruction */
786 int (*pcm_new)(struct snd_soc_pcm_runtime *);
787 void (*pcm_free)(struct snd_pcm *);
788
788 /* DT */ 789 /* DT */
789 int (*of_xlate_dai_name)(struct snd_soc_component *component, 790 int (*of_xlate_dai_name)(struct snd_soc_component *component,
790 struct of_phandle_args *args, 791 struct of_phandle_args *args,
@@ -859,6 +860,8 @@ struct snd_soc_component {
859 void (*remove)(struct snd_soc_component *); 860 void (*remove)(struct snd_soc_component *);
860 int (*suspend)(struct snd_soc_component *); 861 int (*suspend)(struct snd_soc_component *);
861 int (*resume)(struct snd_soc_component *); 862 int (*resume)(struct snd_soc_component *);
863 int (*pcm_new)(struct snd_soc_pcm_runtime *);
864 void (*pcm_free)(struct snd_pcm *);
862 865
863 /* machine specific init */ 866 /* machine specific init */
864 int (*init)(struct snd_soc_component *component); 867 int (*init)(struct snd_soc_component *component);
@@ -941,20 +944,11 @@ struct snd_soc_platform_driver {
941 int (*pcm_new)(struct snd_soc_pcm_runtime *); 944 int (*pcm_new)(struct snd_soc_pcm_runtime *);
942 void (*pcm_free)(struct snd_pcm *); 945 void (*pcm_free)(struct snd_pcm *);
943 946
944 /*
945 * For platform caused delay reporting.
946 * Optional.
947 */
948 snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *,
949 struct snd_soc_dai *);
950
951 /* platform stream pcm ops */ 947 /* platform stream pcm ops */
952 const struct snd_pcm_ops *ops; 948 const struct snd_pcm_ops *ops;
953 949
954 /* platform stream compress ops */ 950 /* platform stream compress ops */
955 const struct snd_compr_ops *compr_ops; 951 const struct snd_compr_ops *compr_ops;
956
957 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
958}; 952};
959 953
960struct snd_soc_dai_link_component { 954struct snd_soc_dai_link_component {
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index baa1afa41e3d..4f6f682df046 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2976,6 +2976,8 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
2976 component->remove = component->driver->remove; 2976 component->remove = component->driver->remove;
2977 component->suspend = component->driver->suspend; 2977 component->suspend = component->driver->suspend;
2978 component->resume = component->driver->resume; 2978 component->resume = component->driver->resume;
2979 component->pcm_new = component->driver->pcm_new;
2980 component->pcm_free= component->driver->pcm_free;
2979 2981
2980 dapm = &component->dapm; 2982 dapm = &component->dapm;
2981 dapm->dev = dev; 2983 dapm->dev = dev;
@@ -3158,6 +3160,21 @@ static void snd_soc_platform_drv_remove(struct snd_soc_component *component)
3158 platform->driver->remove(platform); 3160 platform->driver->remove(platform);
3159} 3161}
3160 3162
3163static int snd_soc_platform_drv_pcm_new(struct snd_soc_pcm_runtime *rtd)
3164{
3165 struct snd_soc_platform *platform = rtd->platform;
3166
3167 return platform->driver->pcm_new(rtd);
3168}
3169
3170static void snd_soc_platform_drv_pcm_free(struct snd_pcm *pcm)
3171{
3172 struct snd_soc_pcm_runtime *rtd = pcm->private_data;
3173 struct snd_soc_platform *platform = rtd->platform;
3174
3175 platform->driver->pcm_free(pcm);
3176}
3177
3161/** 3178/**
3162 * snd_soc_add_platform - Add a platform to the ASoC core 3179 * snd_soc_add_platform - Add a platform to the ASoC core
3163 * @dev: The parent device for the platform 3180 * @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 platform->component.probe = snd_soc_platform_drv_probe; 3198 platform->component.probe = snd_soc_platform_drv_probe;
3182 if (platform_drv->remove) 3199 if (platform_drv->remove)
3183 platform->component.remove = snd_soc_platform_drv_remove; 3200 platform->component.remove = snd_soc_platform_drv_remove;
3201 if (platform_drv->pcm_new)
3202 platform->component.pcm_new = snd_soc_platform_drv_pcm_new;
3203 if (platform_drv->pcm_free)
3204 platform->component.pcm_free = snd_soc_platform_drv_pcm_free;
3184 3205
3185#ifdef CONFIG_DEBUG_FS 3206#ifdef CONFIG_DEBUG_FS
3186 platform->component.debugfs_prefix = "platform"; 3207 platform->component.debugfs_prefix = "platform";
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 6aba14009c92..efc5831f205d 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1055,7 +1055,6 @@ static int soc_pcm_bespoke_trigger(struct snd_pcm_substream *substream,
1055 int cmd) 1055 int cmd)
1056{ 1056{
1057 struct snd_soc_pcm_runtime *rtd = substream->private_data; 1057 struct snd_soc_pcm_runtime *rtd = substream->private_data;
1058 struct snd_soc_platform *platform = rtd->platform;
1059 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 1058 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
1060 struct snd_soc_dai *codec_dai; 1059 struct snd_soc_dai *codec_dai;
1061 int i, ret; 1060 int i, ret;
@@ -1071,12 +1070,6 @@ static int soc_pcm_bespoke_trigger(struct snd_pcm_substream *substream,
1071 } 1070 }
1072 } 1071 }
1073 1072
1074 if (platform->driver->bespoke_trigger) {
1075 ret = platform->driver->bespoke_trigger(substream, cmd);
1076 if (ret < 0)
1077 return ret;
1078 }
1079
1080 if (cpu_dai->driver->ops && cpu_dai->driver->ops->bespoke_trigger) { 1073 if (cpu_dai->driver->ops && cpu_dai->driver->ops->bespoke_trigger) {
1081 ret = cpu_dai->driver->ops->bespoke_trigger(substream, cmd, cpu_dai); 1074 ret = cpu_dai->driver->ops->bespoke_trigger(substream, cmd, cpu_dai);
1082 if (ret < 0) 1075 if (ret < 0)
@@ -1116,13 +1109,6 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
1116 } 1109 }
1117 delay += codec_delay; 1110 delay += codec_delay;
1118 1111
1119 /*
1120 * None of the existing platform drivers implement delay(), so
1121 * for now the codec_dai of first multicodec entry is used
1122 */
1123 if (platform->driver->delay)
1124 delay += platform->driver->delay(substream, rtd->codec_dais[0]);
1125
1126 runtime->delay = delay; 1112 runtime->delay = delay;
1127 1113
1128 return offset; 1114 return offset;
@@ -2642,12 +2628,25 @@ static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream)
2642 return ret; 2628 return ret;
2643} 2629}
2644 2630
2631static void soc_pcm_free(struct snd_pcm *pcm)
2632{
2633 struct snd_soc_pcm_runtime *rtd = pcm->private_data;
2634 struct snd_soc_component *component;
2635
2636 list_for_each_entry(component, &rtd->card->component_dev_list,
2637 card_list) {
2638 if (component->pcm_free)
2639 component->pcm_free(pcm);
2640 }
2641}
2642
2645/* create a new pcm */ 2643/* create a new pcm */
2646int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) 2644int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
2647{ 2645{
2648 struct snd_soc_platform *platform = rtd->platform; 2646 struct snd_soc_platform *platform = rtd->platform;
2649 struct snd_soc_dai *codec_dai; 2647 struct snd_soc_dai *codec_dai;
2650 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 2648 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
2649 struct snd_soc_component *component;
2651 struct snd_pcm *pcm; 2650 struct snd_pcm *pcm;
2652 char new_name[64]; 2651 char new_name[64];
2653 int ret = 0, playback = 0, capture = 0; 2652 int ret = 0, playback = 0, capture = 0;
@@ -2756,17 +2755,18 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
2756 if (capture) 2755 if (capture)
2757 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops); 2756 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops);
2758 2757
2759 if (platform->driver->pcm_new) { 2758 list_for_each_entry(component, &rtd->card->component_dev_list, card_list) {
2760 ret = platform->driver->pcm_new(rtd); 2759 if (component->pcm_new) {
2761 if (ret < 0) { 2760 ret = component->pcm_new(rtd);
2762 dev_err(platform->dev, 2761 if (ret < 0) {
2763 "ASoC: pcm constructor failed: %d\n", 2762 dev_err(component->dev,
2764 ret); 2763 "ASoC: pcm constructor failed: %d\n",
2765 return ret; 2764 ret);
2765 return ret;
2766 }
2766 } 2767 }
2767 } 2768 }
2768 2769 pcm->private_free = soc_pcm_free;
2769 pcm->private_free = platform->driver->pcm_free;
2770out: 2770out:
2771 dev_info(rtd->card->dev, "%s <-> %s mapping ok\n", 2771 dev_info(rtd->card->dev, "%s <-> %s mapping ok\n",
2772 (rtd->num_codecs > 1) ? "multicodec" : rtd->codec_dai->name, 2772 (rtd->num_codecs > 1) ? "multicodec" : rtd->codec_dai->name,
@@ -2874,15 +2874,6 @@ int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe,
2874} 2874}
2875EXPORT_SYMBOL_GPL(snd_soc_dpcm_can_be_params); 2875EXPORT_SYMBOL_GPL(snd_soc_dpcm_can_be_params);
2876 2876
2877int snd_soc_platform_trigger(struct snd_pcm_substream *substream,
2878 int cmd, struct snd_soc_platform *platform)
2879{
2880 if (platform->driver->ops && platform->driver->ops->trigger)
2881 return platform->driver->ops->trigger(substream, cmd);
2882 return 0;
2883}
2884EXPORT_SYMBOL_GPL(snd_soc_platform_trigger);
2885
2886#ifdef CONFIG_DEBUG_FS 2877#ifdef CONFIG_DEBUG_FS
2887static const char *dpcm_state_string(enum snd_soc_dpcm_state state) 2878static const char *dpcm_state_string(enum snd_soc_dpcm_state state)
2888{ 2879{