Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
awilliam
GitHub Repository: awilliam/linux-vfio
Path: blob/master/sound/soc/codecs/dmic.c
10817 views
1
/*
2
* dmic.c -- SoC audio for Generic Digital MICs
3
*
4
* Author: Liam Girdwood <[email protected]>
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* version 2 as published by the Free Software Foundation.
9
*
10
* This program is distributed in the hope that it will be useful, but
11
* WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18
* 02110-1301 USA
19
*
20
*/
21
22
#include <linux/platform_device.h>
23
#include <linux/slab.h>
24
#include <sound/core.h>
25
#include <sound/pcm.h>
26
#include <sound/soc.h>
27
#include <sound/soc-dapm.h>
28
29
static struct snd_soc_dai_driver dmic_dai = {
30
.name = "dmic-hifi",
31
.capture = {
32
.stream_name = "Capture",
33
.channels_min = 1,
34
.channels_max = 8,
35
.rates = SNDRV_PCM_RATE_CONTINUOUS,
36
.formats = SNDRV_PCM_FMTBIT_S32_LE
37
| SNDRV_PCM_FMTBIT_S24_LE
38
| SNDRV_PCM_FMTBIT_S16_LE,
39
},
40
};
41
42
static const struct snd_soc_dapm_widget dmic_dapm_widgets[] = {
43
SND_SOC_DAPM_AIF_OUT("DMIC AIF", "Capture", 0,
44
SND_SOC_NOPM, 0, 0),
45
SND_SOC_DAPM_INPUT("DMic"),
46
};
47
48
static const struct snd_soc_dapm_route intercon[] = {
49
{"DMIC AIF", NULL, "DMic"},
50
};
51
52
static int dmic_probe(struct snd_soc_codec *codec)
53
{
54
struct snd_soc_dapm_context *dapm = &codec->dapm;
55
56
snd_soc_dapm_new_controls(dapm, dmic_dapm_widgets,
57
ARRAY_SIZE(dmic_dapm_widgets));
58
snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon));
59
snd_soc_dapm_new_widgets(dapm);
60
61
return 0;
62
}
63
64
static struct snd_soc_codec_driver soc_dmic = {
65
.probe = dmic_probe,
66
};
67
68
static int __devinit dmic_dev_probe(struct platform_device *pdev)
69
{
70
return snd_soc_register_codec(&pdev->dev,
71
&soc_dmic, &dmic_dai, 1);
72
}
73
74
static int __devexit dmic_dev_remove(struct platform_device *pdev)
75
{
76
snd_soc_unregister_codec(&pdev->dev);
77
return 0;
78
}
79
80
MODULE_ALIAS("platform:dmic-codec");
81
82
static struct platform_driver dmic_driver = {
83
.driver = {
84
.name = "dmic-codec",
85
.owner = THIS_MODULE,
86
},
87
.probe = dmic_dev_probe,
88
.remove = __devexit_p(dmic_dev_remove),
89
};
90
91
static int __init dmic_init(void)
92
{
93
return platform_driver_register(&dmic_driver);
94
}
95
module_init(dmic_init);
96
97
static void __exit dmic_exit(void)
98
{
99
platform_driver_unregister(&dmic_driver);
100
}
101
module_exit(dmic_exit);
102
103
MODULE_DESCRIPTION("Generic DMIC driver");
104
MODULE_AUTHOR("Liam Girdwood <[email protected]>");
105
MODULE_LICENSE("GPL");
106
107