diff options
| author | Shawn Guo <shawn.guo@linaro.org> | 2013-04-24 23:18:50 -0400 |
|---|---|---|
| committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-05-15 01:27:27 -0400 |
| commit | dbdf6b54340e1671439a4a5efbd15b7a0b14eacb (patch) | |
| tree | 8eb6872e76e507173700f07df866b49e892bf7dd | |
| parent | 2bf9d4bbd0fa97ff6f214484f62fc8aca64d1d00 (diff) | |
ASoC: fsl: remove imx-pcm driver
With imx-pcm-dma moving to generic dmaengine pcm driver and the removal
of imx-pcm-audio/imx-fiq-pcm-audio platform device use, now imx-pcm
driver contains a few functions that are only used by imx-pcm-fiq.c.
Move these functions into imx-pcm-fiq.c and remove imx-pcm.c completely.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| -rw-r--r-- | sound/soc/fsl/Kconfig | 5 | ||||
| -rw-r--r-- | sound/soc/fsl/Makefile | 11 | ||||
| -rw-r--r-- | sound/soc/fsl/imx-pcm-dma.c | 2 | ||||
| -rw-r--r-- | sound/soc/fsl/imx-pcm-fiq.c | 87 | ||||
| -rw-r--r-- | sound/soc/fsl/imx-pcm.c | 145 | ||||
| -rw-r--r-- | sound/soc/fsl/imx-pcm.h | 5 |
6 files changed, 91 insertions, 164 deletions
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 3843a18d4e56..7860cc27e5b2 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig | |||
| @@ -108,18 +108,13 @@ if SND_IMX_SOC | |||
| 108 | config SND_SOC_IMX_SSI | 108 | config SND_SOC_IMX_SSI |
| 109 | tristate | 109 | tristate |
| 110 | 110 | ||
| 111 | config SND_SOC_IMX_PCM | ||
| 112 | tristate | ||
| 113 | |||
| 114 | config SND_SOC_IMX_PCM_FIQ | 111 | config SND_SOC_IMX_PCM_FIQ |
| 115 | bool | 112 | bool |
| 116 | select FIQ | 113 | select FIQ |
| 117 | select SND_SOC_IMX_PCM | ||
| 118 | 114 | ||
| 119 | config SND_SOC_IMX_PCM_DMA | 115 | config SND_SOC_IMX_PCM_DMA |
| 120 | bool | 116 | bool |
| 121 | select SND_SOC_GENERIC_DMAENGINE_PCM | 117 | select SND_SOC_GENERIC_DMAENGINE_PCM |
| 122 | select SND_SOC_IMX_PCM | ||
| 123 | 118 | ||
| 124 | config SND_SOC_IMX_AUDMUX | 119 | config SND_SOC_IMX_AUDMUX |
| 125 | tristate | 120 | tristate |
diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index afd34794db53..91883f8a2321 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile | |||
| @@ -30,18 +30,11 @@ obj-$(CONFIG_SND_MPC52xx_SOC_EFIKA) += efika-audio-fabric.o | |||
| 30 | # i.MX Platform Support | 30 | # i.MX Platform Support |
| 31 | snd-soc-imx-ssi-objs := imx-ssi.o | 31 | snd-soc-imx-ssi-objs := imx-ssi.o |
| 32 | snd-soc-imx-audmux-objs := imx-audmux.o | 32 | snd-soc-imx-audmux-objs := imx-audmux.o |
| 33 | snd-soc-imx-pcm-objs := imx-pcm.o | ||
| 34 | ifneq ($(CONFIG_SND_SOC_IMX_PCM_FIQ),) | ||
| 35 | snd-soc-imx-pcm-objs += imx-pcm-fiq.o | ||
| 36 | endif | ||
| 37 | ifneq ($(CONFIG_SND_SOC_IMX_PCM_DMA),) | ||
| 38 | snd-soc-imx-pcm-objs += imx-pcm-dma.o | ||
| 39 | endif | ||
| 40 | |||
| 41 | obj-$(CONFIG_SND_SOC_IMX_SSI) += snd-soc-imx-ssi.o | 33 | obj-$(CONFIG_SND_SOC_IMX_SSI) += snd-soc-imx-ssi.o |
| 42 | obj-$(CONFIG_SND_SOC_IMX_AUDMUX) += snd-soc-imx-audmux.o | 34 | obj-$(CONFIG_SND_SOC_IMX_AUDMUX) += snd-soc-imx-audmux.o |
| 43 | 35 | ||
| 44 | obj-$(CONFIG_SND_SOC_IMX_PCM) += snd-soc-imx-pcm.o | 36 | obj-$(CONFIG_SND_SOC_IMX_PCM_FIQ) += imx-pcm-fiq.o |
| 37 | obj-$(CONFIG_SND_SOC_IMX_PCM_DMA) += imx-pcm-dma.o | ||
| 45 | 38 | ||
| 46 | # i.MX Machine Support | 39 | # i.MX Machine Support |
| 47 | snd-soc-eukrea-tlv320-objs := eukrea-tlv320.o | 40 | snd-soc-eukrea-tlv320-objs := eukrea-tlv320.o |
diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c index c246fb514930..fde4d2ea68c8 100644 --- a/sound/soc/fsl/imx-pcm-dma.c +++ b/sound/soc/fsl/imx-pcm-dma.c | |||
| @@ -67,8 +67,10 @@ int imx_pcm_dma_init(struct platform_device *pdev) | |||
| 67 | SND_DMAENGINE_PCM_FLAG_NO_DT | | 67 | SND_DMAENGINE_PCM_FLAG_NO_DT | |
| 68 | SND_DMAENGINE_PCM_FLAG_COMPAT); | 68 | SND_DMAENGINE_PCM_FLAG_COMPAT); |
| 69 | } | 69 | } |
| 70 | EXPORT_SYMBOL_GPL(imx_pcm_dma_init); | ||
| 70 | 71 | ||
| 71 | void imx_pcm_dma_exit(struct platform_device *pdev) | 72 | void imx_pcm_dma_exit(struct platform_device *pdev) |
| 72 | { | 73 | { |
| 73 | snd_dmaengine_pcm_unregister(&pdev->dev); | 74 | snd_dmaengine_pcm_unregister(&pdev->dev); |
| 74 | } | 75 | } |
| 76 | EXPORT_SYMBOL_GPL(imx_pcm_dma_exit); | ||
diff --git a/sound/soc/fsl/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c index 710c06990450..310d90290320 100644 --- a/sound/soc/fsl/imx-pcm-fiq.c +++ b/sound/soc/fsl/imx-pcm-fiq.c | |||
| @@ -225,6 +225,22 @@ static int snd_imx_close(struct snd_pcm_substream *substream) | |||
| 225 | return 0; | 225 | return 0; |
| 226 | } | 226 | } |
| 227 | 227 | ||
| 228 | static int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, | ||
| 229 | struct vm_area_struct *vma) | ||
| 230 | { | ||
| 231 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 232 | int ret; | ||
| 233 | |||
| 234 | ret = dma_mmap_writecombine(substream->pcm->card->dev, vma, | ||
| 235 | runtime->dma_area, runtime->dma_addr, runtime->dma_bytes); | ||
| 236 | |||
| 237 | pr_debug("%s: ret: %d %p 0x%08x 0x%08x\n", __func__, ret, | ||
| 238 | runtime->dma_area, | ||
| 239 | runtime->dma_addr, | ||
| 240 | runtime->dma_bytes); | ||
| 241 | return ret; | ||
| 242 | } | ||
| 243 | |||
| 228 | static struct snd_pcm_ops imx_pcm_ops = { | 244 | static struct snd_pcm_ops imx_pcm_ops = { |
| 229 | .open = snd_imx_open, | 245 | .open = snd_imx_open, |
| 230 | .close = snd_imx_close, | 246 | .close = snd_imx_close, |
| @@ -236,6 +252,54 @@ static struct snd_pcm_ops imx_pcm_ops = { | |||
| 236 | .mmap = snd_imx_pcm_mmap, | 252 | .mmap = snd_imx_pcm_mmap, |
| 237 | }; | 253 | }; |
| 238 | 254 | ||
| 255 | static int imx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) | ||
| 256 | { | ||
| 257 | struct snd_pcm_substream *substream = pcm->streams[stream].substream; | ||
| 258 | struct snd_dma_buffer *buf = &substream->dma_buffer; | ||
| 259 | size_t size = IMX_SSI_DMABUF_SIZE; | ||
| 260 | |||
| 261 | buf->dev.type = SNDRV_DMA_TYPE_DEV; | ||
| 262 | buf->dev.dev = pcm->card->dev; | ||
| 263 | buf->private_data = NULL; | ||
| 264 | buf->area = dma_alloc_writecombine(pcm->card->dev, size, | ||
| 265 | &buf->addr, GFP_KERNEL); | ||
| 266 | if (!buf->area) | ||
| 267 | return -ENOMEM; | ||
| 268 | buf->bytes = size; | ||
| 269 | |||
| 270 | return 0; | ||
| 271 | } | ||
| 272 | |||
| 273 | static u64 imx_pcm_dmamask = DMA_BIT_MASK(32); | ||
| 274 | |||
| 275 | static int imx_pcm_new(struct snd_soc_pcm_runtime *rtd) | ||
| 276 | { | ||
| 277 | struct snd_card *card = rtd->card->snd_card; | ||
| 278 | struct snd_pcm *pcm = rtd->pcm; | ||
| 279 | int ret = 0; | ||
| 280 | |||
| 281 | if (!card->dev->dma_mask) | ||
| 282 | card->dev->dma_mask = &imx_pcm_dmamask; | ||
| 283 | if (!card->dev->coherent_dma_mask) | ||
| 284 | card->dev->coherent_dma_mask = DMA_BIT_MASK(32); | ||
| 285 | if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { | ||
| 286 | ret = imx_pcm_preallocate_dma_buffer(pcm, | ||
| 287 | SNDRV_PCM_STREAM_PLAYBACK); | ||
| 288 | if (ret) | ||
| 289 | goto out; | ||
| 290 | } | ||
| 291 | |||
| 292 | if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { | ||
| 293 | ret = imx_pcm_preallocate_dma_buffer(pcm, | ||
| 294 | SNDRV_PCM_STREAM_CAPTURE); | ||
| 295 | if (ret) | ||
| 296 | goto out; | ||
| 297 | } | ||
| 298 | |||
| 299 | out: | ||
| 300 | return ret; | ||
| 301 | } | ||
| 302 | |||
| 239 | static int ssi_irq = 0; | 303 | static int ssi_irq = 0; |
| 240 | 304 | ||
| 241 | static int imx_pcm_fiq_new(struct snd_soc_pcm_runtime *rtd) | 305 | static int imx_pcm_fiq_new(struct snd_soc_pcm_runtime *rtd) |
| @@ -268,6 +332,27 @@ static int imx_pcm_fiq_new(struct snd_soc_pcm_runtime *rtd) | |||
| 268 | return 0; | 332 | return 0; |
| 269 | } | 333 | } |
| 270 | 334 | ||
| 335 | static void imx_pcm_free(struct snd_pcm *pcm) | ||
| 336 | { | ||
| 337 | struct snd_pcm_substream *substream; | ||
| 338 | struct snd_dma_buffer *buf; | ||
| 339 | int stream; | ||
| 340 | |||
| 341 | for (stream = 0; stream < 2; stream++) { | ||
| 342 | substream = pcm->streams[stream].substream; | ||
| 343 | if (!substream) | ||
| 344 | continue; | ||
| 345 | |||
| 346 | buf = &substream->dma_buffer; | ||
| 347 | if (!buf->area) | ||
| 348 | continue; | ||
| 349 | |||
| 350 | dma_free_writecombine(pcm->card->dev, buf->bytes, | ||
| 351 | buf->area, buf->addr); | ||
| 352 | buf->area = NULL; | ||
| 353 | } | ||
| 354 | } | ||
| 355 | |||
| 271 | static void imx_pcm_fiq_free(struct snd_pcm *pcm) | 356 | static void imx_pcm_fiq_free(struct snd_pcm *pcm) |
| 272 | { | 357 | { |
| 273 | mxc_set_irq_fiq(ssi_irq, 0); | 358 | mxc_set_irq_fiq(ssi_irq, 0); |
| @@ -314,8 +399,10 @@ failed_register: | |||
| 314 | 399 | ||
| 315 | return ret; | 400 | return ret; |
| 316 | } | 401 | } |
| 402 | EXPORT_SYMBOL_GPL(imx_pcm_fiq_init); | ||
| 317 | 403 | ||
| 318 | void imx_pcm_fiq_exit(struct platform_device *pdev) | 404 | void imx_pcm_fiq_exit(struct platform_device *pdev) |
| 319 | { | 405 | { |
| 320 | snd_soc_unregister_platform(&pdev->dev); | 406 | snd_soc_unregister_platform(&pdev->dev); |
| 321 | } | 407 | } |
| 408 | EXPORT_SYMBOL_GPL(imx_pcm_fiq_exit); | ||
diff --git a/sound/soc/fsl/imx-pcm.c b/sound/soc/fsl/imx-pcm.c deleted file mode 100644 index 16a956bcc52b..000000000000 --- a/sound/soc/fsl/imx-pcm.c +++ /dev/null | |||
| @@ -1,145 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2009 Sascha Hauer <s.hauer@pengutronix.de> | ||
| 3 | * | ||
| 4 | * This code is based on code copyrighted by Freescale, | ||
| 5 | * Liam Girdwood, Javier Martin and probably others. | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify it | ||
| 8 | * under the terms of the GNU General Public License as published by the | ||
| 9 | * Free Software Foundation; either version 2 of the License, or (at your | ||
| 10 | * option) any later version. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/dma-mapping.h> | ||
| 14 | #include <linux/module.h> | ||
| 15 | #include <sound/pcm.h> | ||
| 16 | #include <sound/soc.h> | ||
| 17 | #include "imx-pcm.h" | ||
| 18 | |||
| 19 | int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, | ||
| 20 | struct vm_area_struct *vma) | ||
| 21 | { | ||
| 22 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 23 | int ret; | ||
| 24 | |||
| 25 | ret = dma_mmap_writecombine(substream->pcm->card->dev, vma, | ||
| 26 | runtime->dma_area, runtime->dma_addr, runtime->dma_bytes); | ||
| 27 | |||
| 28 | pr_debug("%s: ret: %d %p 0x%08x 0x%08x\n", __func__, ret, | ||
| 29 | runtime->dma_area, | ||
| 30 | runtime->dma_addr, | ||
| 31 | runtime->dma_bytes); | ||
| 32 | return ret; | ||
| 33 | } | ||
| 34 | EXPORT_SYMBOL_GPL(snd_imx_pcm_mmap); | ||
| 35 | |||
| 36 | static int imx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) | ||
| 37 | { | ||
| 38 | struct snd_pcm_substream *substream = pcm->streams[stream].substream; | ||
| 39 | struct snd_dma_buffer *buf = &substream->dma_buffer; | ||
| 40 | size_t size = IMX_SSI_DMABUF_SIZE; | ||
| 41 | |||
| 42 | buf->dev.type = SNDRV_DMA_TYPE_DEV; | ||
| 43 | buf->dev.dev = pcm->card->dev; | ||
| 44 | buf->private_data = NULL; | ||
| 45 | buf->area = dma_alloc_writecombine(pcm->card->dev, size, | ||
| 46 | &buf->addr, GFP_KERNEL); | ||
| 47 | if (!buf->area) | ||
| 48 | return -ENOMEM; | ||
| 49 | buf->bytes = size; | ||
| 50 | |||
| 51 | return 0; | ||
| 52 | } | ||
| 53 | |||
| 54 | static u64 imx_pcm_dmamask = DMA_BIT_MASK(32); | ||
| 55 | |||
| 56 | int imx_pcm_new(struct snd_soc_pcm_runtime *rtd) | ||
| 57 | { | ||
| 58 | struct snd_card *card = rtd->card->snd_card; | ||
| 59 | struct snd_pcm *pcm = rtd->pcm; | ||
| 60 | int ret = 0; | ||
| 61 | |||
| 62 | if (!card->dev->dma_mask) | ||
| 63 | card->dev->dma_mask = &imx_pcm_dmamask; | ||
| 64 | if (!card->dev->coherent_dma_mask) | ||
| 65 | card->dev->coherent_dma_mask = DMA_BIT_MASK(32); | ||
| 66 | if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { | ||
| 67 | ret = imx_pcm_preallocate_dma_buffer(pcm, | ||
| 68 | SNDRV_PCM_STREAM_PLAYBACK); | ||
| 69 | if (ret) | ||
| 70 | goto out; | ||
| 71 | } | ||
| 72 | |||
| 73 | if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { | ||
| 74 | ret = imx_pcm_preallocate_dma_buffer(pcm, | ||
| 75 | SNDRV_PCM_STREAM_CAPTURE); | ||
| 76 | if (ret) | ||
| 77 | goto out; | ||
| 78 | } | ||
| 79 | |||
| 80 | out: | ||
| 81 | return ret; | ||
| 82 | } | ||
| 83 | EXPORT_SYMBOL_GPL(imx_pcm_new); | ||
| 84 | |||
| 85 | void imx_pcm_free(struct snd_pcm *pcm) | ||
| 86 | { | ||
| 87 | struct snd_pcm_substream *substream; | ||
| 88 | struct snd_dma_buffer *buf; | ||
| 89 | int stream; | ||
| 90 | |||
| 91 | for (stream = 0; stream < 2; stream++) { | ||
| 92 | substream = pcm->streams[stream].substream; | ||
| 93 | if (!substream) | ||
| 94 | continue; | ||
| 95 | |||
| 96 | buf = &substream->dma_buffer; | ||
| 97 | if (!buf->area) | ||
| 98 | continue; | ||
| 99 | |||
| 100 | dma_free_writecombine(pcm->card->dev, buf->bytes, | ||
| 101 | buf->area, buf->addr); | ||
| 102 | buf->area = NULL; | ||
| 103 | } | ||
| 104 | } | ||
| 105 | EXPORT_SYMBOL_GPL(imx_pcm_free); | ||
| 106 | |||
| 107 | static int imx_pcm_probe(struct platform_device *pdev) | ||
| 108 | { | ||
| 109 | if (strcmp(pdev->id_entry->name, "imx-fiq-pcm-audio") == 0) | ||
| 110 | return imx_pcm_fiq_init(pdev); | ||
| 111 | |||
| 112 | return imx_pcm_dma_init(pdev); | ||
| 113 | } | ||
| 114 | |||
| 115 | static int imx_pcm_remove(struct platform_device *pdev) | ||
| 116 | { | ||
| 117 | if (strcmp(pdev->id_entry->name, "imx-fiq-pcm-audio") == 0) | ||
| 118 | imx_pcm_fiq_exit(pdev); | ||
| 119 | else | ||
| 120 | imx_pcm_dma_exit(pdev); | ||
| 121 | |||
| 122 | return 0; | ||
| 123 | } | ||
| 124 | |||
| 125 | static struct platform_device_id imx_pcm_devtype[] = { | ||
| 126 | { .name = "imx-pcm-audio", }, | ||
| 127 | { .name = "imx-fiq-pcm-audio", }, | ||
| 128 | { /* sentinel */ } | ||
| 129 | }; | ||
| 130 | MODULE_DEVICE_TABLE(platform, imx_pcm_devtype); | ||
| 131 | |||
| 132 | static struct platform_driver imx_pcm_driver = { | ||
| 133 | .driver = { | ||
| 134 | .name = "imx-pcm", | ||
| 135 | .owner = THIS_MODULE, | ||
| 136 | }, | ||
| 137 | .id_table = imx_pcm_devtype, | ||
| 138 | .probe = imx_pcm_probe, | ||
| 139 | .remove = imx_pcm_remove, | ||
| 140 | }; | ||
| 141 | module_platform_driver(imx_pcm_driver); | ||
| 142 | |||
| 143 | MODULE_DESCRIPTION("Freescale i.MX PCM driver"); | ||
| 144 | MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>"); | ||
| 145 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/fsl/imx-pcm.h b/sound/soc/fsl/imx-pcm.h index 073bf389c02e..67f656c7c320 100644 --- a/sound/soc/fsl/imx-pcm.h +++ b/sound/soc/fsl/imx-pcm.h | |||
| @@ -32,11 +32,6 @@ imx_pcm_dma_params_init_data(struct imx_dma_data *dma_data, | |||
| 32 | dma_data->peripheral_type = IMX_DMATYPE_SSI; | 32 | dma_data->peripheral_type = IMX_DMATYPE_SSI; |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, | ||
| 36 | struct vm_area_struct *vma); | ||
| 37 | int imx_pcm_new(struct snd_soc_pcm_runtime *rtd); | ||
| 38 | void imx_pcm_free(struct snd_pcm *pcm); | ||
| 39 | |||
| 40 | #ifdef CONFIG_SND_SOC_IMX_PCM_DMA | 35 | #ifdef CONFIG_SND_SOC_IMX_PCM_DMA |
| 41 | int imx_pcm_dma_init(struct platform_device *pdev); | 36 | int imx_pcm_dma_init(struct platform_device *pdev); |
| 42 | void imx_pcm_dma_exit(struct platform_device *pdev); | 37 | void imx_pcm_dma_exit(struct platform_device *pdev); |
