diff options
author | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2015-03-30 13:54:54 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-04-01 16:24:27 -0400 |
commit | 488cb533911b96fe41af68a0206878aa46b799bc (patch) | |
tree | 85d6408a59f870a79df3dfa62aaf4d235a8b6787 /sound/soc/atmel | |
parent | b6d6c6e95ff0e78f9b8393e6b9f25d5a4341ae1a (diff) |
ASoC: atmel-pcm-pdc: merge atmel-pcm back in
atmel-pcm.c was split into two files to create a generic framework for both PDC
and DMA.
atmel-pcm-dma.c is using the generic dmaengine framework since 95e0e07e710e
(ASoC: atmel-pcm: use generic dmaengine framework).
Merge atmel-pcm.c in atmel-pcm-pdc.c as this is now the only user.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/atmel')
-rw-r--r-- | sound/soc/atmel/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/atmel/atmel-pcm-pdc.c | 79 | ||||
-rw-r--r-- | sound/soc/atmel/atmel-pcm.c | 121 | ||||
-rw-r--r-- | sound/soc/atmel/atmel-pcm.h | 5 |
4 files changed, 79 insertions, 128 deletions
diff --git a/sound/soc/atmel/Makefile b/sound/soc/atmel/Makefile index 466a821da98c..b327e5cc8de3 100644 --- a/sound/soc/atmel/Makefile +++ b/sound/soc/atmel/Makefile | |||
@@ -1,10 +1,8 @@ | |||
1 | # AT91 Platform Support | 1 | # AT91 Platform Support |
2 | snd-soc-atmel-pcm-objs := atmel-pcm.o | ||
3 | snd-soc-atmel-pcm-pdc-objs := atmel-pcm-pdc.o | 2 | snd-soc-atmel-pcm-pdc-objs := atmel-pcm-pdc.o |
4 | snd-soc-atmel-pcm-dma-objs := atmel-pcm-dma.o | 3 | snd-soc-atmel-pcm-dma-objs := atmel-pcm-dma.o |
5 | snd-soc-atmel_ssc_dai-objs := atmel_ssc_dai.o | 4 | snd-soc-atmel_ssc_dai-objs := atmel_ssc_dai.o |
6 | 5 | ||
7 | obj-$(CONFIG_SND_ATMEL_SOC) += snd-soc-atmel-pcm.o | ||
8 | obj-$(CONFIG_SND_ATMEL_SOC_PDC) += snd-soc-atmel-pcm-pdc.o | 6 | obj-$(CONFIG_SND_ATMEL_SOC_PDC) += snd-soc-atmel-pcm-pdc.o |
9 | obj-$(CONFIG_SND_ATMEL_SOC_DMA) += snd-soc-atmel-pcm-dma.o | 7 | obj-$(CONFIG_SND_ATMEL_SOC_DMA) += snd-soc-atmel-pcm-dma.o |
10 | obj-$(CONFIG_SND_ATMEL_SOC_SSC) += snd-soc-atmel_ssc_dai.o | 8 | obj-$(CONFIG_SND_ATMEL_SOC_SSC) += snd-soc-atmel_ssc_dai.o |
diff --git a/sound/soc/atmel/atmel-pcm-pdc.c b/sound/soc/atmel/atmel-pcm-pdc.c index a366b3503c28..da861b44413f 100644 --- a/sound/soc/atmel/atmel-pcm-pdc.c +++ b/sound/soc/atmel/atmel-pcm-pdc.c | |||
@@ -47,6 +47,85 @@ | |||
47 | #include "atmel-pcm.h" | 47 | #include "atmel-pcm.h" |
48 | 48 | ||
49 | 49 | ||
50 | static int atmel_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, | ||
51 | int stream) | ||
52 | { | ||
53 | struct snd_pcm_substream *substream = pcm->streams[stream].substream; | ||
54 | struct snd_dma_buffer *buf = &substream->dma_buffer; | ||
55 | size_t size = ATMEL_SSC_DMABUF_SIZE; | ||
56 | |||
57 | buf->dev.type = SNDRV_DMA_TYPE_DEV; | ||
58 | buf->dev.dev = pcm->card->dev; | ||
59 | buf->private_data = NULL; | ||
60 | buf->area = dma_alloc_coherent(pcm->card->dev, size, | ||
61 | &buf->addr, GFP_KERNEL); | ||
62 | pr_debug("atmel-pcm: alloc dma buffer: area=%p, addr=%p, size=%zu\n", | ||
63 | (void *)buf->area, (void *)(long)buf->addr, size); | ||
64 | |||
65 | if (!buf->area) | ||
66 | return -ENOMEM; | ||
67 | |||
68 | buf->bytes = size; | ||
69 | return 0; | ||
70 | } | ||
71 | |||
72 | static int atmel_pcm_mmap(struct snd_pcm_substream *substream, | ||
73 | struct vm_area_struct *vma) | ||
74 | { | ||
75 | return remap_pfn_range(vma, vma->vm_start, | ||
76 | substream->dma_buffer.addr >> PAGE_SHIFT, | ||
77 | vma->vm_end - vma->vm_start, vma->vm_page_prot); | ||
78 | } | ||
79 | |||
80 | static int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd) | ||
81 | { | ||
82 | struct snd_card *card = rtd->card->snd_card; | ||
83 | struct snd_pcm *pcm = rtd->pcm; | ||
84 | int ret; | ||
85 | |||
86 | ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); | ||
87 | if (ret) | ||
88 | return ret; | ||
89 | |||
90 | if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { | ||
91 | pr_debug("atmel-pcm: allocating PCM playback DMA buffer\n"); | ||
92 | ret = atmel_pcm_preallocate_dma_buffer(pcm, | ||
93 | SNDRV_PCM_STREAM_PLAYBACK); | ||
94 | if (ret) | ||
95 | goto out; | ||
96 | } | ||
97 | |||
98 | if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { | ||
99 | pr_debug("atmel-pcm: allocating PCM capture DMA buffer\n"); | ||
100 | ret = atmel_pcm_preallocate_dma_buffer(pcm, | ||
101 | SNDRV_PCM_STREAM_CAPTURE); | ||
102 | if (ret) | ||
103 | goto out; | ||
104 | } | ||
105 | out: | ||
106 | return ret; | ||
107 | } | ||
108 | |||
109 | static void atmel_pcm_free(struct snd_pcm *pcm) | ||
110 | { | ||
111 | struct snd_pcm_substream *substream; | ||
112 | struct snd_dma_buffer *buf; | ||
113 | int stream; | ||
114 | |||
115 | for (stream = 0; stream < 2; stream++) { | ||
116 | substream = pcm->streams[stream].substream; | ||
117 | if (!substream) | ||
118 | continue; | ||
119 | |||
120 | buf = &substream->dma_buffer; | ||
121 | if (!buf->area) | ||
122 | continue; | ||
123 | dma_free_coherent(pcm->card->dev, buf->bytes, | ||
124 | buf->area, buf->addr); | ||
125 | buf->area = NULL; | ||
126 | } | ||
127 | } | ||
128 | |||
50 | /*--------------------------------------------------------------------------*\ | 129 | /*--------------------------------------------------------------------------*\ |
51 | * Hardware definition | 130 | * Hardware definition |
52 | \*--------------------------------------------------------------------------*/ | 131 | \*--------------------------------------------------------------------------*/ |
diff --git a/sound/soc/atmel/atmel-pcm.c b/sound/soc/atmel/atmel-pcm.c deleted file mode 100644 index 8ae3fa5ac60a..000000000000 --- a/sound/soc/atmel/atmel-pcm.c +++ /dev/null | |||
@@ -1,121 +0,0 @@ | |||
1 | /* | ||
2 | * atmel-pcm.c -- ALSA PCM interface for the Atmel atmel SoC. | ||
3 | * | ||
4 | * Copyright (C) 2005 SAN People | ||
5 | * Copyright (C) 2008 Atmel | ||
6 | * | ||
7 | * Authors: Sedji Gaouaou <sedji.gaouaou@atmel.com> | ||
8 | * | ||
9 | * Based on at91-pcm. by: | ||
10 | * Frank Mandarino <fmandarino@endrelia.com> | ||
11 | * Copyright 2006 Endrelia Technologies Inc. | ||
12 | * | ||
13 | * Based on pxa2xx-pcm.c by: | ||
14 | * | ||
15 | * Author: Nicolas Pitre | ||
16 | * Created: Nov 30, 2004 | ||
17 | * Copyright: (C) 2004 MontaVista Software, Inc. | ||
18 | * | ||
19 | * This program is free software; you can redistribute it and/or modify | ||
20 | * it under the terms of the GNU General Public License as published by | ||
21 | * the Free Software Foundation; either version 2 of the License, or | ||
22 | * (at your option) any later version. | ||
23 | * | ||
24 | * This program is distributed in the hope that it will be useful, | ||
25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
27 | * GNU General Public License for more details. | ||
28 | * | ||
29 | * You should have received a copy of the GNU General Public License | ||
30 | * along with this program; if not, write to the Free Software | ||
31 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
32 | */ | ||
33 | |||
34 | #include <linux/module.h> | ||
35 | #include <linux/dma-mapping.h> | ||
36 | #include <sound/pcm.h> | ||
37 | #include <sound/soc.h> | ||
38 | #include "atmel-pcm.h" | ||
39 | |||
40 | static int atmel_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, | ||
41 | int stream) | ||
42 | { | ||
43 | struct snd_pcm_substream *substream = pcm->streams[stream].substream; | ||
44 | struct snd_dma_buffer *buf = &substream->dma_buffer; | ||
45 | size_t size = ATMEL_SSC_DMABUF_SIZE; | ||
46 | |||
47 | buf->dev.type = SNDRV_DMA_TYPE_DEV; | ||
48 | buf->dev.dev = pcm->card->dev; | ||
49 | buf->private_data = NULL; | ||
50 | buf->area = dma_alloc_coherent(pcm->card->dev, size, | ||
51 | &buf->addr, GFP_KERNEL); | ||
52 | pr_debug("atmel-pcm: alloc dma buffer: area=%p, addr=%p, size=%zu\n", | ||
53 | (void *)buf->area, (void *)(long)buf->addr, size); | ||
54 | |||
55 | if (!buf->area) | ||
56 | return -ENOMEM; | ||
57 | |||
58 | buf->bytes = size; | ||
59 | return 0; | ||
60 | } | ||
61 | |||
62 | int atmel_pcm_mmap(struct snd_pcm_substream *substream, | ||
63 | struct vm_area_struct *vma) | ||
64 | { | ||
65 | return remap_pfn_range(vma, vma->vm_start, | ||
66 | substream->dma_buffer.addr >> PAGE_SHIFT, | ||
67 | vma->vm_end - vma->vm_start, vma->vm_page_prot); | ||
68 | } | ||
69 | EXPORT_SYMBOL_GPL(atmel_pcm_mmap); | ||
70 | |||
71 | int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd) | ||
72 | { | ||
73 | struct snd_card *card = rtd->card->snd_card; | ||
74 | struct snd_pcm *pcm = rtd->pcm; | ||
75 | int ret; | ||
76 | |||
77 | ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); | ||
78 | if (ret) | ||
79 | return ret; | ||
80 | |||
81 | if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { | ||
82 | pr_debug("atmel-pcm: allocating PCM playback DMA buffer\n"); | ||
83 | ret = atmel_pcm_preallocate_dma_buffer(pcm, | ||
84 | SNDRV_PCM_STREAM_PLAYBACK); | ||
85 | if (ret) | ||
86 | goto out; | ||
87 | } | ||
88 | |||
89 | if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { | ||
90 | pr_debug("atmel-pcm: allocating PCM capture DMA buffer\n"); | ||
91 | ret = atmel_pcm_preallocate_dma_buffer(pcm, | ||
92 | SNDRV_PCM_STREAM_CAPTURE); | ||
93 | if (ret) | ||
94 | goto out; | ||
95 | } | ||
96 | out: | ||
97 | return ret; | ||
98 | } | ||
99 | EXPORT_SYMBOL_GPL(atmel_pcm_new); | ||
100 | |||
101 | void atmel_pcm_free(struct snd_pcm *pcm) | ||
102 | { | ||
103 | struct snd_pcm_substream *substream; | ||
104 | struct snd_dma_buffer *buf; | ||
105 | int stream; | ||
106 | |||
107 | for (stream = 0; stream < 2; stream++) { | ||
108 | substream = pcm->streams[stream].substream; | ||
109 | if (!substream) | ||
110 | continue; | ||
111 | |||
112 | buf = &substream->dma_buffer; | ||
113 | if (!buf->area) | ||
114 | continue; | ||
115 | dma_free_coherent(pcm->card->dev, buf->bytes, | ||
116 | buf->area, buf->addr); | ||
117 | buf->area = NULL; | ||
118 | } | ||
119 | } | ||
120 | EXPORT_SYMBOL_GPL(atmel_pcm_free); | ||
121 | |||
diff --git a/sound/soc/atmel/atmel-pcm.h b/sound/soc/atmel/atmel-pcm.h index 12ae814eff21..6eaf081cad50 100644 --- a/sound/soc/atmel/atmel-pcm.h +++ b/sound/soc/atmel/atmel-pcm.h | |||
@@ -83,11 +83,6 @@ struct atmel_pcm_dma_params { | |||
83 | #define ssc_readx(base, reg) (__raw_readl((base) + (reg))) | 83 | #define ssc_readx(base, reg) (__raw_readl((base) + (reg))) |
84 | #define ssc_writex(base, reg, value) __raw_writel((value), (base) + (reg)) | 84 | #define ssc_writex(base, reg, value) __raw_writel((value), (base) + (reg)) |
85 | 85 | ||
86 | int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd); | ||
87 | void atmel_pcm_free(struct snd_pcm *pcm); | ||
88 | int atmel_pcm_mmap(struct snd_pcm_substream *substream, | ||
89 | struct vm_area_struct *vma); | ||
90 | |||
91 | #if defined(CONFIG_SND_ATMEL_SOC_PDC) || \ | 86 | #if defined(CONFIG_SND_ATMEL_SOC_PDC) || \ |
92 | defined(CONFIG_SND_ATMEL_SOC_PDC_MODULE) | 87 | defined(CONFIG_SND_ATMEL_SOC_PDC_MODULE) |
93 | int atmel_pcm_pdc_platform_register(struct device *dev); | 88 | int atmel_pcm_pdc_platform_register(struct device *dev); |