Merge branch 'for-linus' of git://git.open-osd.org/linux-open-osd
[sfrench/cifs-2.6.git] / sound / soc / davinci / edma-pcm.c
1 /*
2  * edma-pcm.c - eDMA PCM driver using dmaengine for AM3xxx, AM4xxx
3  *
4  * Copyright (C) 2014 Texas Instruments, Inc.
5  *
6  * Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
7  *
8  * Based on: sound/soc/tegra/tegra_pcm.c
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * version 2 as published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * General Public License for more details.
18  */
19
20 #include <linux/module.h>
21 #include <sound/core.h>
22 #include <sound/pcm.h>
23 #include <sound/pcm_params.h>
24 #include <sound/soc.h>
25 #include <sound/dmaengine_pcm.h>
26 #include <linux/edma.h>
27
28 #include "edma-pcm.h"
29
30 static const struct snd_pcm_hardware edma_pcm_hardware = {
31         .info                   = SNDRV_PCM_INFO_MMAP |
32                                   SNDRV_PCM_INFO_MMAP_VALID |
33                                   SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME |
34                                   SNDRV_PCM_INFO_NO_PERIOD_WAKEUP |
35                                   SNDRV_PCM_INFO_INTERLEAVED,
36         .buffer_bytes_max       = 128 * 1024,
37         .period_bytes_min       = 32,
38         .period_bytes_max       = 64 * 1024,
39         .periods_min            = 2,
40         .periods_max            = 19, /* Limit by edma dmaengine driver */
41 };
42
43 static const struct snd_dmaengine_pcm_config edma_dmaengine_pcm_config = {
44         .pcm_hardware = &edma_pcm_hardware,
45         .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
46         .compat_filter_fn = edma_filter_fn,
47         .prealloc_buffer_size = 128 * 1024,
48 };
49
50 int edma_pcm_platform_register(struct device *dev)
51 {
52         return devm_snd_dmaengine_pcm_register(dev, &edma_dmaengine_pcm_config,
53                                         SND_DMAENGINE_PCM_FLAG_COMPAT);
54 }
55 EXPORT_SYMBOL_GPL(edma_pcm_platform_register);
56
57 MODULE_AUTHOR("Peter Ujfalusi <peter.ujfalusi@ti.com>");
58 MODULE_DESCRIPTION("eDMA PCM ASoC platform driver");
59 MODULE_LICENSE("GPL");