aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2019-07-26 00:51:47 -0400
committerMark Brown <broonie@kernel.org>2019-08-05 11:24:42 -0400
commit0035e2565b93e0902a06320ba1716bc1ddd753b3 (patch)
treebe298a407bdb5a32951bf8e63591202b7f6d09b8 /sound
parent7951b14611851bdae18e9bca18015b1d84731d0d (diff)
ASoC: soc-component: add snd_soc_pcm_component_pointer()
Current ALSA SoC is directly using component->driver->ops->xxx, thus, the code nested deeply, and it makes code difficult to read, and is not good for encapsulation. We want to implement component related function at soc-component.c, but, some of them need to care whole snd_soc_pcm_runtime (= rtd) connected component. Let's call component related function which need to care with for_each_rtdcom() loop as snd_soc_pcm_component_xxx(). This patch adds new snd_soc_pcm_component_pointer() and use it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87sgqt4d0j.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/soc-component.c18
-rw-r--r--sound/soc/soc-pcm.c13
2 files changed, 19 insertions, 12 deletions
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index cb63df6e46eb..e2053c8bf1f0 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -424,3 +424,21 @@ int snd_soc_component_of_xlate_dai_name(struct snd_soc_component *component,
424 args, dai_name); 424 args, dai_name);
425 return -ENOTSUPP; 425 return -ENOTSUPP;
426} 426}
427
428int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream)
429{
430 struct snd_soc_pcm_runtime *rtd = substream->private_data;
431 struct snd_soc_component *component;
432 struct snd_soc_rtdcom_list *rtdcom;
433
434 for_each_rtdcom(rtd, rtdcom) {
435 component = rtdcom->component;
436
437 /* FIXME: use 1st pointer */
438 if (component->driver->ops &&
439 component->driver->ops->pointer)
440 return component->driver->ops->pointer(substream);
441 }
442
443 return 0;
444}
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index cd49c2d688c3..020e1d275076 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1111,8 +1111,6 @@ static int soc_pcm_bespoke_trigger(struct snd_pcm_substream *substream,
1111static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream) 1111static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
1112{ 1112{
1113 struct snd_soc_pcm_runtime *rtd = substream->private_data; 1113 struct snd_soc_pcm_runtime *rtd = substream->private_data;
1114 struct snd_soc_component *component;
1115 struct snd_soc_rtdcom_list *rtdcom;
1116 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 1114 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
1117 struct snd_soc_dai *codec_dai; 1115 struct snd_soc_dai *codec_dai;
1118 struct snd_pcm_runtime *runtime = substream->runtime; 1116 struct snd_pcm_runtime *runtime = substream->runtime;
@@ -1124,17 +1122,8 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
1124 /* clearing the previous total delay */ 1122 /* clearing the previous total delay */
1125 runtime->delay = 0; 1123 runtime->delay = 0;
1126 1124
1127 for_each_rtdcom(rtd, rtdcom) { 1125 offset = snd_soc_pcm_component_pointer(substream);
1128 component = rtdcom->component;
1129 1126
1130 if (!component->driver->ops ||
1131 !component->driver->ops->pointer)
1132 continue;
1133
1134 /* FIXME: use 1st pointer */
1135 offset = component->driver->ops->pointer(substream);
1136 break;
1137 }
1138 /* base delay if assigned in pointer callback */ 1127 /* base delay if assigned in pointer callback */
1139 delay = runtime->delay; 1128 delay = runtime->delay;
1140 1129