ASoC: omap: sdma-pcm: Fix modpost warning
[linux-block.git] / sound / soc / omap / sdma-pcm.c
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 <linux/module.h>
8 #include <sound/core.h>
9 #include <sound/pcm.h>
10 #include <sound/pcm_params.h>
11 #include <sound/soc.h>
12 #include <sound/dmaengine_pcm.h>
13 #include <linux/omap-dma.h>
14
15 #include "sdma-pcm.h"
16
17 static const struct snd_pcm_hardware sdma_pcm_hardware = {
18         .info                   = SNDRV_PCM_INFO_MMAP |
19                                   SNDRV_PCM_INFO_MMAP_VALID |
20                                   SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME |
21                                   SNDRV_PCM_INFO_NO_PERIOD_WAKEUP |
22                                   SNDRV_PCM_INFO_INTERLEAVED,
23         .period_bytes_min       = 32,
24         .period_bytes_max       = 64 * 1024,
25         .buffer_bytes_max       = 128 * 1024,
26         .periods_min            = 2,
27         .periods_max            = 255,
28 };
29
30 static const struct snd_dmaengine_pcm_config sdma_dmaengine_pcm_config = {
31         .pcm_hardware = &sdma_pcm_hardware,
32         .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
33         .compat_filter_fn = omap_dma_filter_fn,
34         .prealloc_buffer_size = 128 * 1024,
35 };
36
37 int sdma_pcm_platform_register(struct device *dev,
38                                char *txdmachan, char *rxdmachan)
39 {
40         struct snd_dmaengine_pcm_config *config;
41         unsigned int flags = SND_DMAENGINE_PCM_FLAG_COMPAT;
42
43         /* Standard names for the directions: 'tx' and 'rx' */
44         if (!txdmachan && !rxdmachan)
45                 return devm_snd_dmaengine_pcm_register(dev,
46                                                 &sdma_dmaengine_pcm_config,
47                                                 flags);
48
49         config = devm_kzalloc(dev, sizeof(*config), GFP_KERNEL);
50         if (!config)
51                 return -ENOMEM;
52
53         *config = sdma_dmaengine_pcm_config;
54
55         if (!txdmachan || !rxdmachan) {
56                 /* One direction only PCM */
57                 flags |= SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX;
58                 if (!txdmachan) {
59                         txdmachan = rxdmachan;
60                         rxdmachan = NULL;
61                 }
62         }
63
64         config->chan_names[0] = txdmachan;
65         config->chan_names[1] = rxdmachan;
66
67         return devm_snd_dmaengine_pcm_register(dev, config, flags);
68 }
69 EXPORT_SYMBOL_GPL(sdma_pcm_platform_register);
70
71 MODULE_AUTHOR("Peter Ujfalusi <peter.ujfalusi@ti.com>");
72 MODULE_DESCRIPTION("sDMA PCM ASoC platform driver");
73 MODULE_LICENSE("GPL v2");