18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * ALSA PCM interface for ST SPEAr Processors
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * sound/soc/spear/spear_pcm.c
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Copyright (C) 2012 ST Microelectronics
78c2ecf20Sopenharmony_ci * Rajeev Kumar<rajeevkumar.linux@gmail.com>
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * This file is licensed under the terms of the GNU General Public
108c2ecf20Sopenharmony_ci * License version 2. This program is licensed "as is" without any
118c2ecf20Sopenharmony_ci * warranty of any kind, whether express or implied.
128c2ecf20Sopenharmony_ci */
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include <linux/module.h>
158c2ecf20Sopenharmony_ci#include <linux/dmaengine.h>
168c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
178c2ecf20Sopenharmony_ci#include <sound/dmaengine_pcm.h>
188c2ecf20Sopenharmony_ci#include <sound/pcm.h>
198c2ecf20Sopenharmony_ci#include <sound/soc.h>
208c2ecf20Sopenharmony_ci#include <sound/spear_dma.h>
218c2ecf20Sopenharmony_ci#include "spear_pcm.h"
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_cistatic const struct snd_pcm_hardware spear_pcm_hardware = {
248c2ecf20Sopenharmony_ci	.info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
258c2ecf20Sopenharmony_ci		 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
268c2ecf20Sopenharmony_ci		 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
278c2ecf20Sopenharmony_ci	.buffer_bytes_max = 16 * 1024, /* max buffer size */
288c2ecf20Sopenharmony_ci	.period_bytes_min = 2 * 1024, /* 1 msec data minimum period size */
298c2ecf20Sopenharmony_ci	.period_bytes_max = 2 * 1024, /* maximum period size */
308c2ecf20Sopenharmony_ci	.periods_min = 1, /* min # periods */
318c2ecf20Sopenharmony_ci	.periods_max = 8, /* max # of periods */
328c2ecf20Sopenharmony_ci	.fifo_size = 0, /* fifo size in bytes */
338c2ecf20Sopenharmony_ci};
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cistatic const struct snd_dmaengine_pcm_config spear_dmaengine_pcm_config = {
368c2ecf20Sopenharmony_ci	.pcm_hardware = &spear_pcm_hardware,
378c2ecf20Sopenharmony_ci	.prealloc_buffer_size = 16 * 1024,
388c2ecf20Sopenharmony_ci};
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ciint devm_spear_pcm_platform_register(struct device *dev,
418c2ecf20Sopenharmony_ci			struct snd_dmaengine_pcm_config *config,
428c2ecf20Sopenharmony_ci			bool (*filter)(struct dma_chan *chan, void *slave))
438c2ecf20Sopenharmony_ci{
448c2ecf20Sopenharmony_ci	*config = spear_dmaengine_pcm_config;
458c2ecf20Sopenharmony_ci	config->compat_filter_fn = filter;
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci	return devm_snd_dmaengine_pcm_register(dev, config,
488c2ecf20Sopenharmony_ci		SND_DMAENGINE_PCM_FLAG_NO_DT |
498c2ecf20Sopenharmony_ci		SND_DMAENGINE_PCM_FLAG_COMPAT);
508c2ecf20Sopenharmony_ci}
518c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(devm_spear_pcm_platform_register);
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ciMODULE_AUTHOR("Rajeev Kumar <rajeevkumar.linux@gmail.com>");
548c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("SPEAr PCM DMA module");
558c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
56