blob: d38afb1c61ae20733578d471643f0cdc2c7945cf [file] [log] [blame]
Peter Ujfalusi58726f52014-03-14 16:42:45 +02001/*
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
28static const struct snd_pcm_hardware edma_pcm_hardware = {
29 .info = SNDRV_PCM_INFO_MMAP |
30 SNDRV_PCM_INFO_MMAP_VALID |
31 SNDRV_PCM_INFO_BATCH |
32 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME |
33 SNDRV_PCM_INFO_INTERLEAVED,
34 .buffer_bytes_max = 128 * 1024,
35 .period_bytes_min = 32,
36 .period_bytes_max = 64 * 1024,
37 .periods_min = 2,
38 .periods_max = 19, /* Limit by edma dmaengine driver */
39};
40
41static const struct snd_dmaengine_pcm_config edma_dmaengine_pcm_config = {
42 .pcm_hardware = &edma_pcm_hardware,
43 .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
44 .compat_filter_fn = edma_filter_fn,
45 .prealloc_buffer_size = 128 * 1024,
46};
47
48int edma_pcm_platform_register(struct device *dev)
49{
50 return devm_snd_dmaengine_pcm_register(dev, &edma_dmaengine_pcm_config,
51 SND_DMAENGINE_PCM_FLAG_COMPAT);
52}
53EXPORT_SYMBOL_GPL(edma_pcm_platform_register);
54
55MODULE_AUTHOR("Peter Ujfalusi <peter.ujfalusi@ti.com>");
56MODULE_DESCRIPTION("eDMA PCM ASoC platform driver");
57MODULE_LICENSE("GPL");