]> rtime.felk.cvut.cz Git - zynq/linux.git/blob - sound/soc/xilinx/xilinx-dp-pcm.c
4c2cdfb9d6135fdbd180346540776ebd98df6426
[zynq/linux.git] / sound / soc / xilinx / xilinx-dp-pcm.c
1 /*
2  * Xilinx DisplayPort Sound PCM support
3  *
4  *  Copyright (C) 2015 Xilinx, Inc.
5  *
6  *  Author: Hyun Woo Kwon <hyunk@xilinx.com>
7  *
8  * This software is licensed under the terms of the GNU General Public
9  * License version 2, as published by the Free Software Foundation, and
10  * may be copied, distributed, and modified under those terms.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  */
17
18 #include <linux/device.h>
19 #include <linux/module.h>
20 #include <linux/platform_device.h>
21
22 #include <sound/dmaengine_pcm.h>
23 #include <sound/pcm.h>
24 #include <sound/soc.h>
25
26 static const struct snd_pcm_hardware xilinx_pcm_hw = {
27         .info                   = SNDRV_PCM_INFO_MMAP |
28                                   SNDRV_PCM_INFO_MMAP_VALID |
29                                   SNDRV_PCM_INFO_INTERLEAVED |
30                                   SNDRV_PCM_INFO_PAUSE |
31                                   SNDRV_PCM_INFO_RESUME |
32                                   SNDRV_PCM_INFO_NO_PERIOD_WAKEUP,
33         .buffer_bytes_max       = 128 * 1024,
34         .period_bytes_min       = 256,
35         .period_bytes_max       = 1024 * 1024,
36         .periods_min            = 2,
37         .periods_max            = 256,
38 };
39
40 static const struct snd_dmaengine_pcm_config xilinx_dmaengine_pcm_config = {
41         .pcm_hardware = &xilinx_pcm_hw,
42         .prealloc_buffer_size = 64 * 1024,
43 };
44
45 static int xilinx_dp_pcm_probe(struct platform_device *pdev)
46 {
47         int ret;
48
49         ret = devm_snd_dmaengine_pcm_register(&pdev->dev,
50                                               &xilinx_dmaengine_pcm_config, 0);
51         if (ret)
52                 return ret;
53
54         dev_info(&pdev->dev, "Xilinx DisplayPort Sound PCM probed\n");
55
56         return 0;
57 }
58
59 static int xilinx_dp_pcm_dev_remove(struct platform_device *pdev)
60 {
61         return 0;
62 }
63
64 static const struct of_device_id xilinx_dp_pcm_of_match[] = {
65         { .compatible = "xlnx,dp-snd-pcm", },
66         { /* end of table */ },
67 };
68 MODULE_DEVICE_TABLE(of, xilinx_dp_pcm_of_match);
69
70 static struct platform_driver xilinx_dp_pcm_driver = {
71         .driver = {
72                 .name           = "xilinx-dp-snd-pcm",
73                 .of_match_table = xilinx_dp_pcm_of_match,
74         },
75         .probe  = xilinx_dp_pcm_probe,
76         .remove = xilinx_dp_pcm_dev_remove,
77 };
78 module_platform_driver(xilinx_dp_pcm_driver);
79
80 MODULE_DESCRIPTION("Xilinx DisplayPort Sound PCM module");
81 MODULE_LICENSE("GPL v2");