Merge tag 'v5.15.57' into rpi-5.15.y
[platform/kernel/linux-rpi.git] / sound / soc / bcm / hifiberry_dacplusdsp.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * ASoC Driver for HiFiBerry DAC + DSP
4  *
5  * Author:      Joerg Schambacher <joscha@schambacher.com>
6  *              Copyright 2018
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * version 2 as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  */
17
18 #include <linux/init.h>
19 #include <linux/module.h>
20 #include <linux/of.h>
21 #include <linux/platform_device.h>
22 #include <sound/soc.h>
23
24 static struct snd_soc_component_driver dacplusdsp_component_driver;
25
26 static struct snd_soc_dai_driver dacplusdsp_dai = {
27         .name = "dacplusdsp-hifi",
28         .capture = {
29                 .stream_name = "DAC+DSP Capture",
30                 .channels_min = 2,
31                 .channels_max = 2,
32                 .rates = SNDRV_PCM_RATE_CONTINUOUS,
33                 .formats = SNDRV_PCM_FMTBIT_S16_LE |
34                            SNDRV_PCM_FMTBIT_S24_LE |
35                            SNDRV_PCM_FMTBIT_S32_LE,
36         },
37         .playback = {
38                 .stream_name = "DACP+DSP Playback",
39                 .channels_min = 2,
40                 .channels_max = 2,
41                 .rates = SNDRV_PCM_RATE_CONTINUOUS,
42                 .formats = SNDRV_PCM_FMTBIT_S16_LE |
43                            SNDRV_PCM_FMTBIT_S24_LE |
44                            SNDRV_PCM_FMTBIT_S32_LE,
45         },
46         .symmetric_rate = 1};
47
48 #ifdef CONFIG_OF
49 static const struct of_device_id dacplusdsp_ids[] = {
50         {
51                 .compatible = "hifiberry,dacplusdsp",
52         },
53         {} };
54 MODULE_DEVICE_TABLE(of, dacplusdsp_ids);
55 #endif
56
57 static int dacplusdsp_platform_probe(struct platform_device *pdev)
58 {
59         int ret;
60
61         ret = snd_soc_register_component(&pdev->dev,
62                         &dacplusdsp_component_driver, &dacplusdsp_dai, 1);
63         if (ret) {
64                 pr_alert("snd_soc_register_component failed\n");
65                 return ret;
66         }
67
68         return 0;
69 }
70
71 static int dacplusdsp_platform_remove(struct platform_device *pdev)
72 {
73         snd_soc_unregister_component(&pdev->dev);
74         return 0;
75 }
76
77 static struct platform_driver dacplusdsp_driver = {
78         .driver = {
79                 .name = "hifiberry-dacplusdsp-codec",
80                 .of_match_table = of_match_ptr(dacplusdsp_ids),
81                 },
82                 .probe = dacplusdsp_platform_probe,
83                 .remove = dacplusdsp_platform_remove,
84 };
85
86 module_platform_driver(dacplusdsp_driver);
87
88 MODULE_AUTHOR("Joerg Schambacher <joerg@i2audio.com>");
89 MODULE_DESCRIPTION("ASoC Driver for HiFiBerry DAC+DSP");
90 MODULE_LICENSE("GPL v2");