Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * linux/sound/arm/ep93xx-pcm.c - EP93xx ALSA PCM interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Copyright (C) 2006 Applied Data Systems
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  * Rewritten for the SoC audio subsystem (Based on PXA2xx code):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  *   Copyright (c) 2008 Ryan Mallon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/dmaengine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <sound/pcm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <sound/soc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <sound/dmaengine_pcm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/platform_data/dma-ep93xx.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include "ep93xx-pcm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static const struct snd_pcm_hardware ep93xx_pcm_hardware = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	.info			= (SNDRV_PCM_INFO_MMAP		|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 				   SNDRV_PCM_INFO_MMAP_VALID	|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 				   SNDRV_PCM_INFO_INTERLEAVED	|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 				   SNDRV_PCM_INFO_BLOCK_TRANSFER),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	.buffer_bytes_max	= 131072,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	.period_bytes_min	= 32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	.period_bytes_max	= 32768,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	.periods_min		= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	.periods_max		= 32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	.fifo_size		= 32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static bool ep93xx_pcm_dma_filter(struct dma_chan *chan, void *filter_param)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	struct ep93xx_dma_data *data = filter_param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	if (data->direction == ep93xx_dma_chan_direction(chan)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 		chan->private = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	.pcm_hardware = &ep93xx_pcm_hardware,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	.compat_filter_fn = ep93xx_pcm_dma_filter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	.prealloc_buffer_size = 131072,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) int devm_ep93xx_pcm_platform_register(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	return devm_snd_dmaengine_pcm_register(dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 		&ep93xx_dmaengine_pcm_config,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 		SND_DMAENGINE_PCM_FLAG_NO_DT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 		SND_DMAENGINE_PCM_FLAG_COMPAT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) EXPORT_SYMBOL_GPL(devm_ep93xx_pcm_platform_register);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) MODULE_AUTHOR("Ryan Mallon");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) MODULE_DESCRIPTION("EP93xx ALSA PCM interface");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) MODULE_LICENSE("GPL");