blob: 93caed500565662450da8379dd640f268315860d [file] [log] [blame]
Stephen Warren7605eb52011-01-07 22:36:13 -07001/*
2 * tegra_pcm.c - Tegra PCM driver
3 *
4 * Author: Stephen Warren <swarren@nvidia.com>
Stephen Warren518de862012-03-20 14:55:49 -06005 * Copyright (C) 2010,2012 - NVIDIA, Inc.
Stephen Warren7605eb52011-01-07 22:36:13 -07006 *
7 * Based on code copyright/by:
8 *
9 * Copyright (c) 2009-2010, NVIDIA Corporation.
10 * Scott Peterson <speterson@nvidia.com>
11 * Vijay Mali <vmali@nvidia.com>
12 *
13 * Copyright (C) 2010 Google, Inc.
14 * Iliyan Malchev <malchev@google.com>
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * version 2 as published by the Free Software Foundation.
19 *
20 * This program is distributed in the hope that it will be useful, but
21 * WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
28 * 02110-1301 USA
29 *
30 */
31
Stephen Warren7613c502012-04-06 11:12:25 -060032#include <linux/module.h>
Stephen Warren7605eb52011-01-07 22:36:13 -070033#include <sound/core.h>
34#include <sound/pcm.h>
35#include <sound/pcm_params.h>
36#include <sound/soc.h>
Laxman Dewangandf79f552012-06-29 17:04:33 +053037#include <sound/dmaengine_pcm.h>
Stephen Warren7605eb52011-01-07 22:36:13 -070038
39#include "tegra_pcm.h"
40
41static const struct snd_pcm_hardware tegra_pcm_hardware = {
42 .info = SNDRV_PCM_INFO_MMAP |
43 SNDRV_PCM_INFO_MMAP_VALID |
Stephen Warren7605eb52011-01-07 22:36:13 -070044 SNDRV_PCM_INFO_INTERLEAVED,
Stephen Warren7605eb52011-01-07 22:36:13 -070045 .period_bytes_min = 1024,
46 .period_bytes_max = PAGE_SIZE,
47 .periods_min = 2,
48 .periods_max = 8,
49 .buffer_bytes_max = PAGE_SIZE * 8,
50 .fifo_size = 4,
51};
52
Lars-Peter Clausen11a85762013-04-15 19:19:52 +020053static const struct snd_dmaengine_pcm_config tegra_dmaengine_pcm_config = {
54 .pcm_hardware = &tegra_pcm_hardware,
55 .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
Lars-Peter Clausen11a85762013-04-15 19:19:52 +020056 .prealloc_buffer_size = PAGE_SIZE * 8,
Stephen Warren7605eb52011-01-07 22:36:13 -070057};
58
Bill Pemberton4652a0d2012-12-07 09:26:33 -050059int tegra_pcm_platform_register(struct device *dev)
Stephen Warren7605eb52011-01-07 22:36:13 -070060{
Stephen Warren5608bd32013-11-11 15:21:01 -070061 return snd_dmaengine_pcm_register(dev, &tegra_dmaengine_pcm_config, 0);
Stephen Warren7605eb52011-01-07 22:36:13 -070062}
Stephen Warren518de862012-03-20 14:55:49 -060063EXPORT_SYMBOL_GPL(tegra_pcm_platform_register);
Stephen Warren7605eb52011-01-07 22:36:13 -070064
Stephen Warren5608bd32013-11-11 15:21:01 -070065int tegra_pcm_platform_register_with_chan_names(struct device *dev,
66 struct snd_dmaengine_pcm_config *config,
67 char *txdmachan, char *rxdmachan)
68{
69 *config = tegra_dmaengine_pcm_config;
70 config->dma_dev = dev->parent;
71 config->chan_names[0] = txdmachan;
72 config->chan_names[1] = rxdmachan;
73
74 return snd_dmaengine_pcm_register(dev, config, 0);
75}
76EXPORT_SYMBOL_GPL(tegra_pcm_platform_register_with_chan_names);
77
Bill Pemberton4652a0d2012-12-07 09:26:33 -050078void tegra_pcm_platform_unregister(struct device *dev)
Stephen Warren7605eb52011-01-07 22:36:13 -070079{
Lars-Peter Clausen11a85762013-04-15 19:19:52 +020080 return snd_dmaengine_pcm_unregister(dev);
Stephen Warren7605eb52011-01-07 22:36:13 -070081}
Stephen Warren518de862012-03-20 14:55:49 -060082EXPORT_SYMBOL_GPL(tegra_pcm_platform_unregister);
Stephen Warren7605eb52011-01-07 22:36:13 -070083
84MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>");
85MODULE_DESCRIPTION("Tegra PCM ASoC driver");
86MODULE_LICENSE("GPL");