]> Pileus Git - ~andy/linux/blob - sound/soc/cirrus/ep93xx-pcm.c
ASoC: wm8962: Use IS_ENABLED() macro
[~andy/linux] / sound / soc / cirrus / ep93xx-pcm.c
1 /*
2  * linux/sound/arm/ep93xx-pcm.c - EP93xx ALSA PCM interface
3  *
4  * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
5  * Copyright (C) 2006 Applied Data Systems
6  *
7  * Rewritten for the SoC audio subsystem (Based on PXA2xx code):
8  *   Copyright (c) 2008 Ryan Mallon
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  */
14
15 #include <linux/module.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/dmaengine.h>
19
20 #include <sound/pcm.h>
21 #include <sound/soc.h>
22 #include <sound/dmaengine_pcm.h>
23
24 #include <linux/platform_data/dma-ep93xx.h>
25
26 static const struct snd_pcm_hardware ep93xx_pcm_hardware = {
27         .info                   = (SNDRV_PCM_INFO_MMAP          |
28                                    SNDRV_PCM_INFO_MMAP_VALID    |
29                                    SNDRV_PCM_INFO_INTERLEAVED   |
30                                    SNDRV_PCM_INFO_BLOCK_TRANSFER),
31                                    
32         .rates                  = SNDRV_PCM_RATE_8000_192000,
33         .rate_min               = SNDRV_PCM_RATE_8000,
34         .rate_max               = SNDRV_PCM_RATE_192000,
35         
36         .formats                = (SNDRV_PCM_FMTBIT_S16_LE |
37                                    SNDRV_PCM_FMTBIT_S24_LE |
38                                    SNDRV_PCM_FMTBIT_S32_LE),
39         
40         .buffer_bytes_max       = 131072,
41         .period_bytes_min       = 32,
42         .period_bytes_max       = 32768,
43         .periods_min            = 1,
44         .periods_max            = 32,
45         .fifo_size              = 32,
46 };
47
48 static bool ep93xx_pcm_dma_filter(struct dma_chan *chan, void *filter_param)
49 {
50         struct ep93xx_dma_data *data = filter_param;
51
52         if (data->direction == ep93xx_dma_chan_direction(chan)) {
53                 chan->private = data;
54                 return true;
55         }
56
57         return false;
58 }
59
60 static struct dma_chan *ep93xx_compat_request_channel(
61         struct snd_soc_pcm_runtime *rtd,
62         struct snd_pcm_substream *substream)
63 {
64         struct snd_dmaengine_dai_dma_data *dma_data;
65
66         dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
67
68         return snd_dmaengine_pcm_request_channel(ep93xx_pcm_dma_filter,
69                                                  dma_data);
70 }
71
72 static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = {
73         .pcm_hardware = &ep93xx_pcm_hardware,
74         .compat_filter_fn = ep93xx_pcm_dma_filter,
75         .compat_request_channel = ep93xx_compat_request_channel,
76         .prealloc_buffer_size = 131072,
77 };
78
79 static int ep93xx_soc_platform_probe(struct platform_device *pdev)
80 {
81         return snd_dmaengine_pcm_register(&pdev->dev,
82                 &ep93xx_dmaengine_pcm_config,
83                 SND_DMAENGINE_PCM_FLAG_NO_RESIDUE |
84                 SND_DMAENGINE_PCM_FLAG_NO_DT |
85                 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         return 0;
92 }
93
94 static struct platform_driver ep93xx_pcm_driver = {
95         .driver = {
96                         .name = "ep93xx-pcm-audio",
97                         .owner = THIS_MODULE,
98         },
99
100         .probe = ep93xx_soc_platform_probe,
101         .remove = ep93xx_soc_platform_remove,
102 };
103
104 module_platform_driver(ep93xx_pcm_driver);
105
106 MODULE_AUTHOR("Ryan Mallon");
107 MODULE_DESCRIPTION("EP93xx ALSA PCM interface");
108 MODULE_LICENSE("GPL");
109 MODULE_ALIAS("platform:ep93xx-pcm-audio");