diff options
author | Peter Ujfalusi <peter.ujfalusi@ti.com> | 2018-05-07 04:49:54 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-05-09 05:22:00 -0400 |
commit | dde637f2daf19daf7e0d551ef47bec6819504910 (patch) | |
tree | fdacb451264a11f16ef83b359c35bd7ea1a4b01b | |
parent | e5ba319882d78030b054dee4eeaf758340b2756f (diff) |
ASoC: omap: Introduce the generic_dmaengine_pcm based sdma-pcm
With the generic dmaengine_pcm support the omap-cpm can be replaced with a
much smaller wrapper.
CPU DAI drivers can use the:
int sdma_pcm_platform_register(struct device *dev,
char *txdmachan, char *rxdmachan);
To register the platform driver, txdmachan/rxdmachan is only needed to be
provided if the DMA channel names are not standard tx/rx, like in case of
McPDM, or the DAI is only capable of one audio direction (DMIC, HDMI).
This patch only introduces the source file and changes to the
Kconfig/Makefile, but does not change any of the DAI drivers to use it.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Acked-by: Jarkko Nikula <jarkko.nikula@bitmer.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/omap/Kconfig | 6 | ||||
-rw-r--r-- | sound/soc/omap/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/omap/sdma-pcm.c | 68 | ||||
-rw-r--r-- | sound/soc/omap/sdma-pcm.h | 21 |
4 files changed, 97 insertions, 0 deletions
diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index 9d20c9b94477..2576fc92bff7 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig | |||
@@ -2,6 +2,12 @@ config SND_OMAP_SOC | |||
2 | tristate "SoC Audio for the Texas Instruments OMAP chips" | 2 | tristate "SoC Audio for the Texas Instruments OMAP chips" |
3 | depends on (ARCH_OMAP && DMA_OMAP) || (ARM && COMPILE_TEST) | 3 | depends on (ARCH_OMAP && DMA_OMAP) || (ARM && COMPILE_TEST) |
4 | select SND_DMAENGINE_PCM | 4 | select SND_DMAENGINE_PCM |
5 | select SND_SDMA_SOC | ||
6 | |||
7 | config SND_SDMA_SOC | ||
8 | tristate "SoC Audio for Texas Instruments chips using sDMA" | ||
9 | depends on DMA_OMAP | ||
10 | select SND_SOC_GENERIC_DMAENGINE_PCM | ||
5 | 11 | ||
6 | config SND_OMAP_SOC_DMIC | 12 | config SND_OMAP_SOC_DMIC |
7 | tristate | 13 | tristate |
diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile index a6785dc4fc90..0619a5b3bd9f 100644 --- a/sound/soc/omap/Makefile +++ b/sound/soc/omap/Makefile | |||
@@ -1,12 +1,14 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
2 | # OMAP Platform Support | 2 | # OMAP Platform Support |
3 | snd-soc-omap-objs := omap-pcm.o | 3 | snd-soc-omap-objs := omap-pcm.o |
4 | snd-soc-sdma-objs := sdma-pcm.o | ||
4 | snd-soc-omap-dmic-objs := omap-dmic.o | 5 | snd-soc-omap-dmic-objs := omap-dmic.o |
5 | snd-soc-omap-mcbsp-objs := omap-mcbsp.o mcbsp.o | 6 | snd-soc-omap-mcbsp-objs := omap-mcbsp.o mcbsp.o |
6 | snd-soc-omap-mcpdm-objs := omap-mcpdm.o | 7 | snd-soc-omap-mcpdm-objs := omap-mcpdm.o |
7 | snd-soc-omap-hdmi-audio-objs := omap-hdmi-audio.o | 8 | snd-soc-omap-hdmi-audio-objs := omap-hdmi-audio.o |
8 | 9 | ||
9 | obj-$(CONFIG_SND_OMAP_SOC) += snd-soc-omap.o | 10 | obj-$(CONFIG_SND_OMAP_SOC) += snd-soc-omap.o |
11 | obj-$(CONFIG_SND_SDMA_SOC) += snd-soc-sdma.o | ||
10 | obj-$(CONFIG_SND_OMAP_SOC_DMIC) += snd-soc-omap-dmic.o | 12 | obj-$(CONFIG_SND_OMAP_SOC_DMIC) += snd-soc-omap-dmic.o |
11 | obj-$(CONFIG_SND_OMAP_SOC_MCBSP) += snd-soc-omap-mcbsp.o | 13 | obj-$(CONFIG_SND_OMAP_SOC_MCBSP) += snd-soc-omap-mcbsp.o |
12 | obj-$(CONFIG_SND_OMAP_SOC_MCPDM) += snd-soc-omap-mcpdm.o | 14 | obj-$(CONFIG_SND_OMAP_SOC_MCPDM) += snd-soc-omap-mcpdm.o |
diff --git a/sound/soc/omap/sdma-pcm.c b/sound/soc/omap/sdma-pcm.c new file mode 100644 index 000000000000..f7b2b5b69d27 --- /dev/null +++ b/sound/soc/omap/sdma-pcm.c | |||
@@ -0,0 +1,68 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
2 | /* | ||
3 | * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com | ||
4 | * Author: Peter Ujfalusi <peter.ujfalusi@ti.com> | ||
5 | */ | ||
6 | |||
7 | #include <sound/core.h> | ||
8 | #include <sound/pcm.h> | ||
9 | #include <sound/pcm_params.h> | ||
10 | #include <sound/soc.h> | ||
11 | #include <sound/dmaengine_pcm.h> | ||
12 | #include <linux/omap-dma.h> | ||
13 | |||
14 | #include "sdma-pcm.h" | ||
15 | |||
16 | static const struct snd_pcm_hardware sdma_pcm_hardware = { | ||
17 | .info = SNDRV_PCM_INFO_MMAP | | ||
18 | SNDRV_PCM_INFO_MMAP_VALID | | ||
19 | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME | | ||
20 | SNDRV_PCM_INFO_NO_PERIOD_WAKEUP | | ||
21 | SNDRV_PCM_INFO_INTERLEAVED, | ||
22 | .period_bytes_min = 32, | ||
23 | .period_bytes_max = 64 * 1024, | ||
24 | .buffer_bytes_max = 128 * 1024, | ||
25 | .periods_min = 2, | ||
26 | .periods_max = 255, | ||
27 | }; | ||
28 | |||
29 | static const struct snd_dmaengine_pcm_config sdma_dmaengine_pcm_config = { | ||
30 | .pcm_hardware = &sdma_pcm_hardware, | ||
31 | .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, | ||
32 | .compat_filter_fn = omap_dma_filter_fn, | ||
33 | .prealloc_buffer_size = 128 * 1024, | ||
34 | }; | ||
35 | |||
36 | int sdma_pcm_platform_register(struct device *dev, | ||
37 | char *txdmachan, char *rxdmachan) | ||
38 | { | ||
39 | struct snd_dmaengine_pcm_config *config; | ||
40 | unsigned int flags = SND_DMAENGINE_PCM_FLAG_COMPAT; | ||
41 | |||
42 | /* Standard names for the directions: 'tx' and 'rx' */ | ||
43 | if (!txdmachan && !rxdmachan) | ||
44 | return devm_snd_dmaengine_pcm_register(dev, | ||
45 | &sdma_dmaengine_pcm_config, | ||
46 | flags); | ||
47 | |||
48 | config = devm_kzalloc(dev, sizeof(*config), GFP_KERNEL); | ||
49 | if (!config) | ||
50 | return -ENOMEM; | ||
51 | |||
52 | *config = sdma_dmaengine_pcm_config; | ||
53 | |||
54 | if (!txdmachan || !rxdmachan) { | ||
55 | /* One direction only PCM */ | ||
56 | flags |= SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX; | ||
57 | if (!txdmachan) { | ||
58 | txdmachan = rxdmachan; | ||
59 | rxdmachan = NULL; | ||
60 | } | ||
61 | } | ||
62 | |||
63 | config->chan_names[0] = txdmachan; | ||
64 | config->chan_names[1] = rxdmachan; | ||
65 | |||
66 | return devm_snd_dmaengine_pcm_register(dev, config, flags); | ||
67 | } | ||
68 | EXPORT_SYMBOL_GPL(sdma_pcm_platform_register); | ||
diff --git a/sound/soc/omap/sdma-pcm.h b/sound/soc/omap/sdma-pcm.h new file mode 100644 index 000000000000..34a7f90b2587 --- /dev/null +++ b/sound/soc/omap/sdma-pcm.h | |||
@@ -0,0 +1,21 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
2 | /* | ||
3 | * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com | ||
4 | * Author: Peter Ujfalusi <peter.ujfalusi@ti.com> | ||
5 | */ | ||
6 | |||
7 | #ifndef __SDMA_PCM_H__ | ||
8 | #define __SDMA_PCM_H__ | ||
9 | |||
10 | #if IS_ENABLED(CONFIG_SND_SDMA_SOC) | ||
11 | int sdma_pcm_platform_register(struct device *dev, | ||
12 | char *txdmachan, char *rxdmachan); | ||
13 | #else | ||
14 | static inline int sdma_pcm_platform_register(struct device *dev, | ||
15 | char *txdmachan, char *rxdmachan) | ||
16 | { | ||
17 | return -ENODEV; | ||
18 | } | ||
19 | #endif /* CONFIG_SND_SDMA_SOC */ | ||
20 | |||
21 | #endif /* __SDMA_PCM_H__ */ | ||