Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * linux/sound/arm/ep93xx-pcm.c - EP93xx ALSA PCM interface
0004  *
0005  * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
0006  * Copyright (C) 2006 Applied Data Systems
0007  *
0008  * Rewritten for the SoC audio subsystem (Based on PXA2xx code):
0009  *   Copyright (c) 2008 Ryan Mallon
0010  */
0011 
0012 #include <linux/module.h>
0013 #include <linux/init.h>
0014 #include <linux/platform_device.h>
0015 #include <linux/dmaengine.h>
0016 
0017 #include <sound/pcm.h>
0018 #include <sound/soc.h>
0019 #include <sound/dmaengine_pcm.h>
0020 
0021 #include <linux/platform_data/dma-ep93xx.h>
0022 
0023 #include "ep93xx-pcm.h"
0024 
0025 static const struct snd_pcm_hardware ep93xx_pcm_hardware = {
0026     .info           = (SNDRV_PCM_INFO_MMAP      |
0027                    SNDRV_PCM_INFO_MMAP_VALID    |
0028                    SNDRV_PCM_INFO_INTERLEAVED   |
0029                    SNDRV_PCM_INFO_BLOCK_TRANSFER),
0030     .buffer_bytes_max   = 131072,
0031     .period_bytes_min   = 32,
0032     .period_bytes_max   = 32768,
0033     .periods_min        = 1,
0034     .periods_max        = 32,
0035     .fifo_size      = 32,
0036 };
0037 
0038 static bool ep93xx_pcm_dma_filter(struct dma_chan *chan, void *filter_param)
0039 {
0040     struct ep93xx_dma_data *data = filter_param;
0041 
0042     if (data->direction == ep93xx_dma_chan_direction(chan)) {
0043         chan->private = data;
0044         return true;
0045     }
0046 
0047     return false;
0048 }
0049 
0050 static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = {
0051     .pcm_hardware = &ep93xx_pcm_hardware,
0052     .compat_filter_fn = ep93xx_pcm_dma_filter,
0053     .prealloc_buffer_size = 131072,
0054 };
0055 
0056 int devm_ep93xx_pcm_platform_register(struct device *dev)
0057 {
0058     return devm_snd_dmaengine_pcm_register(dev,
0059         &ep93xx_dmaengine_pcm_config,
0060         SND_DMAENGINE_PCM_FLAG_NO_DT |
0061         SND_DMAENGINE_PCM_FLAG_COMPAT);
0062 }
0063 EXPORT_SYMBOL_GPL(devm_ep93xx_pcm_platform_register);
0064 
0065 MODULE_AUTHOR("Ryan Mallon");
0066 MODULE_DESCRIPTION("EP93xx ALSA PCM interface");
0067 MODULE_LICENSE("GPL");