xref: /linux/sound/soc/cirrus/ep93xx-pcm.c (revision d2912cb15bdda8ba4a5dd73396ad62641af2f520)
1*d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
20ed275efSAlexander Shiyan /*
30ed275efSAlexander Shiyan  * linux/sound/arm/ep93xx-pcm.c - EP93xx ALSA PCM interface
40ed275efSAlexander Shiyan  *
50ed275efSAlexander Shiyan  * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
60ed275efSAlexander Shiyan  * Copyright (C) 2006 Applied Data Systems
70ed275efSAlexander Shiyan  *
80ed275efSAlexander Shiyan  * Rewritten for the SoC audio subsystem (Based on PXA2xx code):
90ed275efSAlexander Shiyan  *   Copyright (c) 2008 Ryan Mallon
100ed275efSAlexander Shiyan  */
110ed275efSAlexander Shiyan 
120ed275efSAlexander Shiyan #include <linux/module.h>
130ed275efSAlexander Shiyan #include <linux/init.h>
14e27e8a60SLars-Peter Clausen #include <linux/platform_device.h>
150ed275efSAlexander Shiyan #include <linux/dmaengine.h>
160ed275efSAlexander Shiyan 
170ed275efSAlexander Shiyan #include <sound/pcm.h>
180ed275efSAlexander Shiyan #include <sound/soc.h>
190ed275efSAlexander Shiyan #include <sound/dmaengine_pcm.h>
200ed275efSAlexander Shiyan 
21f5a246eaSLinus Torvalds #include <linux/platform_data/dma-ep93xx.h>
220ed275efSAlexander Shiyan 
236f2032a1SStephen Warren #include "ep93xx-pcm.h"
246f2032a1SStephen Warren 
250ed275efSAlexander Shiyan static const struct snd_pcm_hardware ep93xx_pcm_hardware = {
260ed275efSAlexander Shiyan 	.info			= (SNDRV_PCM_INFO_MMAP		|
270ed275efSAlexander Shiyan 				   SNDRV_PCM_INFO_MMAP_VALID	|
280ed275efSAlexander Shiyan 				   SNDRV_PCM_INFO_INTERLEAVED	|
290ed275efSAlexander Shiyan 				   SNDRV_PCM_INFO_BLOCK_TRANSFER),
300ed275efSAlexander Shiyan 	.buffer_bytes_max	= 131072,
310ed275efSAlexander Shiyan 	.period_bytes_min	= 32,
320ed275efSAlexander Shiyan 	.period_bytes_max	= 32768,
330ed275efSAlexander Shiyan 	.periods_min		= 1,
340ed275efSAlexander Shiyan 	.periods_max		= 32,
350ed275efSAlexander Shiyan 	.fifo_size		= 32,
360ed275efSAlexander Shiyan };
370ed275efSAlexander Shiyan 
380ed275efSAlexander Shiyan static bool ep93xx_pcm_dma_filter(struct dma_chan *chan, void *filter_param)
390ed275efSAlexander Shiyan {
400ed275efSAlexander Shiyan 	struct ep93xx_dma_data *data = filter_param;
410ed275efSAlexander Shiyan 
420ed275efSAlexander Shiyan 	if (data->direction == ep93xx_dma_chan_direction(chan)) {
430ed275efSAlexander Shiyan 		chan->private = data;
440ed275efSAlexander Shiyan 		return true;
450ed275efSAlexander Shiyan 	}
460ed275efSAlexander Shiyan 
470ed275efSAlexander Shiyan 	return false;
480ed275efSAlexander Shiyan }
490ed275efSAlexander Shiyan 
50e27e8a60SLars-Peter Clausen static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = {
51e27e8a60SLars-Peter Clausen 	.pcm_hardware = &ep93xx_pcm_hardware,
52e27e8a60SLars-Peter Clausen 	.compat_filter_fn = ep93xx_pcm_dma_filter,
53e27e8a60SLars-Peter Clausen 	.prealloc_buffer_size = 131072,
540ed275efSAlexander Shiyan };
550ed275efSAlexander Shiyan 
566f2032a1SStephen Warren int devm_ep93xx_pcm_platform_register(struct device *dev)
570ed275efSAlexander Shiyan {
586f2032a1SStephen Warren 	return devm_snd_dmaengine_pcm_register(dev,
59e27e8a60SLars-Peter Clausen 		&ep93xx_dmaengine_pcm_config,
60e27e8a60SLars-Peter Clausen 		SND_DMAENGINE_PCM_FLAG_NO_DT |
61e27e8a60SLars-Peter Clausen 		SND_DMAENGINE_PCM_FLAG_COMPAT);
620ed275efSAlexander Shiyan }
636f2032a1SStephen Warren EXPORT_SYMBOL_GPL(devm_ep93xx_pcm_platform_register);
640ed275efSAlexander Shiyan 
650ed275efSAlexander Shiyan MODULE_AUTHOR("Ryan Mallon");
660ed275efSAlexander Shiyan MODULE_DESCRIPTION("EP93xx ALSA PCM interface");
670ed275efSAlexander Shiyan MODULE_LICENSE("GPL");
68