ep93xx-pcm.c 2.8 KB
Newer Older
R
Ryan Mallon 已提交
1 2 3 4 5 6 7
/*
 * linux/sound/arm/ep93xx-pcm.c - EP93xx ALSA PCM interface
 *
 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
 * Copyright (C) 2006 Applied Data Systems
 *
 * Rewritten for the SoC audio subsystem (Based on PXA2xx code):
8
 *   Copyright (c) 2008 Ryan Mallon
R
Ryan Mallon 已提交
9 10 11 12 13 14 15 16
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/module.h>
#include <linux/init.h>
17
#include <linux/platform_device.h>
18
#include <linux/dmaengine.h>
R
Ryan Mallon 已提交
19 20 21

#include <sound/pcm.h>
#include <sound/soc.h>
22
#include <sound/dmaengine_pcm.h>
R
Ryan Mallon 已提交
23

24
#include <linux/platform_data/dma-ep93xx.h>
R
Ryan Mallon 已提交
25 26 27 28 29 30 31

static const struct snd_pcm_hardware ep93xx_pcm_hardware = {
	.info			= (SNDRV_PCM_INFO_MMAP		|
				   SNDRV_PCM_INFO_MMAP_VALID	|
				   SNDRV_PCM_INFO_INTERLEAVED	|
				   SNDRV_PCM_INFO_BLOCK_TRANSFER),
				   
32
	.rates			= SNDRV_PCM_RATE_8000_192000,
R
Ryan Mallon 已提交
33
	.rate_min		= SNDRV_PCM_RATE_8000,
34
	.rate_max		= SNDRV_PCM_RATE_192000,
R
Ryan Mallon 已提交
35 36 37 38 39 40 41 42 43 44 45 46 47
	
	.formats		= (SNDRV_PCM_FMTBIT_S16_LE |
				   SNDRV_PCM_FMTBIT_S24_LE |
				   SNDRV_PCM_FMTBIT_S32_LE),
	
	.buffer_bytes_max	= 131072,
	.period_bytes_min	= 32,
	.period_bytes_max	= 32768,
	.periods_min		= 1,
	.periods_max		= 32,
	.fifo_size		= 32,
};

48
static bool ep93xx_pcm_dma_filter(struct dma_chan *chan, void *filter_param)
R
Ryan Mallon 已提交
49
{
50
	struct ep93xx_dma_data *data = filter_param;
R
Ryan Mallon 已提交
51

52 53 54
	if (data->direction == ep93xx_dma_chan_direction(chan)) {
		chan->private = data;
		return true;
R
Ryan Mallon 已提交
55
	}
56 57

	return false;
R
Ryan Mallon 已提交
58 59
}

60 61 62 63 64 65 66 67 68 69 70 71
static struct dma_chan *ep93xx_compat_request_channel(
	struct snd_soc_pcm_runtime *rtd,
	struct snd_pcm_substream *substream)
{
	struct snd_dmaengine_dai_dma_data *dma_data;

	dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);

	return snd_dmaengine_pcm_request_channel(ep93xx_pcm_dma_filter,
						 dma_data);
}

72 73 74
static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = {
	.pcm_hardware = &ep93xx_pcm_hardware,
	.compat_filter_fn = ep93xx_pcm_dma_filter,
75
	.compat_request_channel = ep93xx_compat_request_channel,
76
	.prealloc_buffer_size = 131072,
R
Ryan Mallon 已提交
77
};
78

79
static int ep93xx_soc_platform_probe(struct platform_device *pdev)
80
{
81 82 83 84 85
	return snd_dmaengine_pcm_register(&pdev->dev,
		&ep93xx_dmaengine_pcm_config,
		SND_DMAENGINE_PCM_FLAG_NO_RESIDUE |
		SND_DMAENGINE_PCM_FLAG_NO_DT |
		SND_DMAENGINE_PCM_FLAG_COMPAT);
86 87
}

88
static int ep93xx_soc_platform_remove(struct platform_device *pdev)
89
{
90
	snd_dmaengine_pcm_unregister(&pdev->dev);
91 92 93 94 95 96 97 98 99 100
	return 0;
}

static struct platform_driver ep93xx_pcm_driver = {
	.driver = {
			.name = "ep93xx-pcm-audio",
			.owner = THIS_MODULE,
	},

	.probe = ep93xx_soc_platform_probe,
101
	.remove = ep93xx_soc_platform_remove,
102
};
R
Ryan Mallon 已提交
103

104
module_platform_driver(ep93xx_pcm_driver);
R
Ryan Mallon 已提交
105

106
MODULE_AUTHOR("Ryan Mallon");
R
Ryan Mallon 已提交
107 108
MODULE_DESCRIPTION("EP93xx ALSA PCM interface");
MODULE_LICENSE("GPL");
109
MODULE_ALIAS("platform:ep93xx-pcm-audio");