Skip to content

Commit 7afd1b0

Browse files
zonquebroonie
authored andcommitted
ASoC: pxa: move some functions to pxa2xx-lib
To get rid of some intermediate platform layers, move pxa2xx_soc_pcm_new() and pxa2xx_pcm_ops in pxa2xx-lib. Signed-off-by: Daniel Mack <daniel@zonque.org> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent a716067 commit 7afd1b0

4 files changed

Lines changed: 47 additions & 58 deletions

File tree

‎include/sound/pxa2xx-lib.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/* PCM */
99
struct snd_pcm_substream;
1010
struct snd_pcm_hw_params;
11+
struct snd_soc_pcm_runtime;
1112
struct snd_pcm;
1213

1314
extern int pxa2xx_pcm_hw_params(struct snd_pcm_substream *substream,
@@ -22,6 +23,8 @@ extern int pxa2xx_pcm_mmap(struct snd_pcm_substream *substream,
2223
struct vm_area_struct *vma);
2324
extern int pxa2xx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream);
2425
extern void pxa2xx_pcm_free_dma_buffers(struct snd_pcm *pcm);
26+
extern int pxa2xx_soc_pcm_new(struct snd_soc_pcm_runtime *rtd);
27+
extern const struct snd_pcm_ops pxa2xx_pcm_ops;
2528

2629
/* AC97 */
2730

‎sound/arm/pxa2xx-ac97.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static int pxa2xx_ac97_resume(struct device *dev)
174174
static SIMPLE_DEV_PM_OPS(pxa2xx_ac97_pm_ops, pxa2xx_ac97_suspend, pxa2xx_ac97_resume);
175175
#endif
176176

177-
static const struct snd_pcm_ops pxa2xx_pcm_ops = {
177+
static const struct snd_pcm_ops pxa2xx_ac97_pcm_ops = {
178178
.open = pxa2xx_ac97_pcm_open,
179179
.close = pxa2xx_ac97_pcm_close,
180180
.ioctl = snd_pcm_lib_ioctl,
@@ -203,13 +203,13 @@ static int pxa2xx_ac97_pcm_new(struct snd_card *card)
203203
goto out;
204204

205205
stream = SNDRV_PCM_STREAM_PLAYBACK;
206-
snd_pcm_set_ops(pcm, stream, &pxa2xx_pcm_ops);
206+
snd_pcm_set_ops(pcm, stream, &pxa2xx_ac97_pcm_ops);
207207
ret = pxa2xx_pcm_preallocate_dma_buffer(pcm, stream);
208208
if (ret)
209209
goto out;
210210

211211
stream = SNDRV_PCM_STREAM_CAPTURE;
212-
snd_pcm_set_ops(pcm, stream, &pxa2xx_pcm_ops);
212+
snd_pcm_set_ops(pcm, stream, &pxa2xx_ac97_pcm_ops);
213213
ret = pxa2xx_pcm_preallocate_dma_buffer(pcm, stream);
214214
if (ret)
215215
goto out;

‎sound/arm/pxa2xx-pcm-lib.c‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,47 @@ void pxa2xx_pcm_free_dma_buffers(struct snd_pcm *pcm)
179179
}
180180
EXPORT_SYMBOL(pxa2xx_pcm_free_dma_buffers);
181181

182+
int pxa2xx_soc_pcm_new(struct snd_soc_pcm_runtime *rtd)
183+
{
184+
struct snd_card *card = rtd->card->snd_card;
185+
struct snd_pcm *pcm = rtd->pcm;
186+
int ret;
187+
188+
ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
189+
if (ret)
190+
return ret;
191+
192+
if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
193+
ret = pxa2xx_pcm_preallocate_dma_buffer(pcm,
194+
SNDRV_PCM_STREAM_PLAYBACK);
195+
if (ret)
196+
goto out;
197+
}
198+
199+
if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
200+
ret = pxa2xx_pcm_preallocate_dma_buffer(pcm,
201+
SNDRV_PCM_STREAM_CAPTURE);
202+
if (ret)
203+
goto out;
204+
}
205+
out:
206+
return ret;
207+
}
208+
EXPORT_SYMBOL(pxa2xx_soc_pcm_new);
209+
210+
const struct snd_pcm_ops pxa2xx_pcm_ops = {
211+
.open = pxa2xx_pcm_open,
212+
.close = pxa2xx_pcm_close,
213+
.ioctl = snd_pcm_lib_ioctl,
214+
.hw_params = pxa2xx_pcm_hw_params,
215+
.hw_free = pxa2xx_pcm_hw_free,
216+
.prepare = pxa2xx_pcm_prepare,
217+
.trigger = pxa2xx_pcm_trigger,
218+
.pointer = pxa2xx_pcm_pointer,
219+
.mmap = pxa2xx_pcm_mmap,
220+
};
221+
EXPORT_SYMBOL(pxa2xx_pcm_ops);
222+
182223
MODULE_AUTHOR("Nicolas Pitre");
183224
MODULE_DESCRIPTION("Intel PXA2xx sound library");
184225
MODULE_LICENSE("GPL");

‎sound/soc/pxa/pxa2xx-pcm.c‎

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -20,61 +20,6 @@
2020
#include <sound/pxa2xx-lib.h>
2121
#include <sound/dmaengine_pcm.h>
2222

23-
static int __pxa2xx_pcm_hw_params(struct snd_pcm_substream *substream,
24-
struct snd_pcm_hw_params *params)
25-
{
26-
struct snd_soc_pcm_runtime *rtd = substream->private_data;
27-
struct snd_dmaengine_dai_dma_data *dma;
28-
29-
dma = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
30-
31-
/* return if this is a bufferless transfer e.g.
32-
* codec <--> BT codec or GSM modem -- lg FIXME */
33-
if (!dma)
34-
return 0;
35-
36-
return pxa2xx_pcm_hw_params(substream, params);
37-
}
38-
39-
static const struct snd_pcm_ops pxa2xx_pcm_ops = {
40-
.open = pxa2xx_pcm_open,
41-
.close = pxa2xx_pcm_close,
42-
.ioctl = snd_pcm_lib_ioctl,
43-
.hw_params = __pxa2xx_pcm_hw_params,
44-
.hw_free = pxa2xx_pcm_hw_free,
45-
.prepare = pxa2xx_pcm_prepare,
46-
.trigger = pxa2xx_pcm_trigger,
47-
.pointer = pxa2xx_pcm_pointer,
48-
.mmap = pxa2xx_pcm_mmap,
49-
};
50-
51-
static int pxa2xx_soc_pcm_new(struct snd_soc_pcm_runtime *rtd)
52-
{
53-
struct snd_card *card = rtd->card->snd_card;
54-
struct snd_pcm *pcm = rtd->pcm;
55-
int ret;
56-
57-
ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
58-
if (ret)
59-
return ret;
60-
61-
if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
62-
ret = pxa2xx_pcm_preallocate_dma_buffer(pcm,
63-
SNDRV_PCM_STREAM_PLAYBACK);
64-
if (ret)
65-
goto out;
66-
}
67-
68-
if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
69-
ret = pxa2xx_pcm_preallocate_dma_buffer(pcm,
70-
SNDRV_PCM_STREAM_CAPTURE);
71-
if (ret)
72-
goto out;
73-
}
74-
out:
75-
return ret;
76-
}
77-
7823
static const struct snd_soc_component_driver pxa2xx_soc_platform = {
7924
.ops = &pxa2xx_pcm_ops,
8025
.pcm_new = pxa2xx_soc_pcm_new,

0 commit comments

Comments
 (0)