aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSangsu Park <sangsu4u.park@samsung.com>2012-01-02 03:15:10 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-01-03 15:28:51 -0500
commita500231da461cfe29541cb4b8422eb9bf59aa6ac (patch)
tree55936c39c91d67b760aec3b73eef654693647030
parent34be9244c7d8107ab9a46af53869f826648fccc8 (diff)
ASoC: soc-pcm: Allocate PCM operations dynamically to support multiple DAIs
The original code does not cover the case that two DAIs(CPU) have different ASoC core PCM operations(like mmap, pointer...). Currently we have only one global soc_pcm_ops for ASoC core PCM operation. When two DAIs have different pointer functions, second DAI's pointer function is set for both first DAI and second DAI in case of original code. This patch uses runtime's pcm_ops instead of global pcm_ops for each DAIs. So each DAIs can have different ASoC core PCM operations. This is needed to support multiple DAIs. Signed-off-by: Sangsu Park <sangsu4u.park@samsung.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--sound/soc/soc-pcm.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 8aa7cec6eab2..cdc860a5ff37 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -598,17 +598,6 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
598 return offset; 598 return offset;
599} 599}
600 600
601/* ASoC PCM operations */
602static struct snd_pcm_ops soc_pcm_ops = {
603 .open = soc_pcm_open,
604 .close = soc_pcm_close,
605 .hw_params = soc_pcm_hw_params,
606 .hw_free = soc_pcm_hw_free,
607 .prepare = soc_pcm_prepare,
608 .trigger = soc_pcm_trigger,
609 .pointer = soc_pcm_pointer,
610};
611
612/* create a new pcm */ 601/* create a new pcm */
613int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) 602int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
614{ 603{
@@ -616,10 +605,19 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
616 struct snd_soc_platform *platform = rtd->platform; 605 struct snd_soc_platform *platform = rtd->platform;
617 struct snd_soc_dai *codec_dai = rtd->codec_dai; 606 struct snd_soc_dai *codec_dai = rtd->codec_dai;
618 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 607 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
608 struct snd_pcm_ops *soc_pcm_ops = &rtd->ops;
619 struct snd_pcm *pcm; 609 struct snd_pcm *pcm;
620 char new_name[64]; 610 char new_name[64];
621 int ret = 0, playback = 0, capture = 0; 611 int ret = 0, playback = 0, capture = 0;
622 612
613 soc_pcm_ops->open = soc_pcm_open;
614 soc_pcm_ops->close = soc_pcm_close;
615 soc_pcm_ops->hw_params = soc_pcm_hw_params;
616 soc_pcm_ops->hw_free = soc_pcm_hw_free;
617 soc_pcm_ops->prepare = soc_pcm_prepare;
618 soc_pcm_ops->trigger = soc_pcm_trigger;
619 soc_pcm_ops->pointer = soc_pcm_pointer;
620
623 /* check client and interface hw capabilities */ 621 /* check client and interface hw capabilities */
624 snprintf(new_name, sizeof(new_name), "%s %s-%d", 622 snprintf(new_name, sizeof(new_name), "%s %s-%d",
625 rtd->dai_link->stream_name, codec_dai->name, num); 623 rtd->dai_link->stream_name, codec_dai->name, num);
@@ -643,20 +641,20 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
643 rtd->pcm = pcm; 641 rtd->pcm = pcm;
644 pcm->private_data = rtd; 642 pcm->private_data = rtd;
645 if (platform->driver->ops) { 643 if (platform->driver->ops) {
646 soc_pcm_ops.mmap = platform->driver->ops->mmap; 644 soc_pcm_ops->mmap = platform->driver->ops->mmap;
647 soc_pcm_ops.pointer = platform->driver->ops->pointer; 645 soc_pcm_ops->pointer = platform->driver->ops->pointer;
648 soc_pcm_ops.ioctl = platform->driver->ops->ioctl; 646 soc_pcm_ops->ioctl = platform->driver->ops->ioctl;
649 soc_pcm_ops.copy = platform->driver->ops->copy; 647 soc_pcm_ops->copy = platform->driver->ops->copy;
650 soc_pcm_ops.silence = platform->driver->ops->silence; 648 soc_pcm_ops->silence = platform->driver->ops->silence;
651 soc_pcm_ops.ack = platform->driver->ops->ack; 649 soc_pcm_ops->ack = platform->driver->ops->ack;
652 soc_pcm_ops.page = platform->driver->ops->page; 650 soc_pcm_ops->page = platform->driver->ops->page;
653 } 651 }
654 652
655 if (playback) 653 if (playback)
656 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &soc_pcm_ops); 654 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, soc_pcm_ops);
657 655
658 if (capture) 656 if (capture)
659 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &soc_pcm_ops); 657 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, soc_pcm_ops);
660 658
661 if (platform->driver->pcm_new) { 659 if (platform->driver->pcm_new) {
662 ret = platform->driver->pcm_new(rtd); 660 ret = platform->driver->pcm_new(rtd);