]> rtime.felk.cvut.cz Git - zynq/linux.git/blob - sound/soc/xilinx/xilinx-dp-pcm.c
sound: xilinx: pcm: Set the shorter device name
[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         dev_set_name(&pdev->dev, pdev->dev.of_node->name);
50         ret = devm_snd_dmaengine_pcm_register(&pdev->dev,
51                                               &xilinx_dmaengine_pcm_config, 0);
52         if (ret)
53                 return ret;
54
55         dev_info(&pdev->dev, "Xilinx DisplayPort Sound PCM probed\n");
56
57         return 0;
58 }
59
60 static int xilinx_dp_pcm_dev_remove(struct platform_device *pdev)
61 {
62         return 0;
63 }
64
65 static const struct of_device_id xilinx_dp_pcm_of_match[] = {
66         { .compatible = "xlnx,dp-snd-pcm", },
67         { /* end of table */ },
68 };
69 MODULE_DEVICE_TABLE(of, xilinx_dp_pcm_of_match);
70
71 static struct platform_driver xilinx_dp_pcm_driver = {
72         .driver = {
73                 .name           = "xilinx-dp-snd-pcm",
74                 .of_match_table = xilinx_dp_pcm_of_match,
75         },
76         .probe  = xilinx_dp_pcm_probe,
77         .remove = xilinx_dp_pcm_dev_remove,
78 };
79 module_platform_driver(xilinx_dp_pcm_driver);
80
81 MODULE_DESCRIPTION("Xilinx DisplayPort Sound PCM module");
82 MODULE_LICENSE("GPL v2");