xref: /linux/sound/soc/codecs/dmic.c (revision a85f9da707366e856c0aad9e329db0cc59475290)
1a710770eSDavid Lambert /*
2a710770eSDavid Lambert  * dmic.c  --  SoC audio for Generic Digital MICs
3a710770eSDavid Lambert  *
4a710770eSDavid Lambert  * Author: Liam Girdwood <lrg@slimlogic.co.uk>
5a710770eSDavid Lambert  *
6a710770eSDavid Lambert  * This program is free software; you can redistribute it and/or
7a710770eSDavid Lambert  * modify it under the terms of the GNU General Public License
8a710770eSDavid Lambert  * version 2 as published by the Free Software Foundation.
9a710770eSDavid Lambert  *
10a710770eSDavid Lambert  * This program is distributed in the hope that it will be useful, but
11a710770eSDavid Lambert  * WITHOUT ANY WARRANTY; without even the implied warranty of
12a710770eSDavid Lambert  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13a710770eSDavid Lambert  * General Public License for more details.
14a710770eSDavid Lambert  *
15a710770eSDavid Lambert  * You should have received a copy of the GNU General Public License
16a710770eSDavid Lambert  * along with this program; if not, write to the Free Software
17a710770eSDavid Lambert  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18a710770eSDavid Lambert  * 02110-1301 USA
19a710770eSDavid Lambert  *
20a710770eSDavid Lambert  */
21a710770eSDavid Lambert 
22a710770eSDavid Lambert #include <linux/platform_device.h>
23a710770eSDavid Lambert #include <linux/slab.h>
24da155d5bSPaul Gortmaker #include <linux/module.h>
25a710770eSDavid Lambert #include <sound/core.h>
26a710770eSDavid Lambert #include <sound/pcm.h>
27a710770eSDavid Lambert #include <sound/soc.h>
28a710770eSDavid Lambert #include <sound/soc-dapm.h>
29a710770eSDavid Lambert 
30a710770eSDavid Lambert static struct snd_soc_dai_driver dmic_dai = {
31a710770eSDavid Lambert 	.name = "dmic-hifi",
32a710770eSDavid Lambert 	.capture = {
33a710770eSDavid Lambert 		.stream_name = "Capture",
34a710770eSDavid Lambert 		.channels_min = 1,
35a710770eSDavid Lambert 		.channels_max = 8,
36a710770eSDavid Lambert 		.rates = SNDRV_PCM_RATE_CONTINUOUS,
37a710770eSDavid Lambert 		.formats = SNDRV_PCM_FMTBIT_S32_LE
38a710770eSDavid Lambert 			| SNDRV_PCM_FMTBIT_S24_LE
39a710770eSDavid Lambert 			| SNDRV_PCM_FMTBIT_S16_LE,
40a710770eSDavid Lambert 	},
41a710770eSDavid Lambert };
42a710770eSDavid Lambert 
43d5e4b0adSMisael Lopez Cruz static const struct snd_soc_dapm_widget dmic_dapm_widgets[] = {
44d5e4b0adSMisael Lopez Cruz 	SND_SOC_DAPM_AIF_OUT("DMIC AIF", "Capture", 0,
45d5e4b0adSMisael Lopez Cruz 			     SND_SOC_NOPM, 0, 0),
46d5e4b0adSMisael Lopez Cruz 	SND_SOC_DAPM_INPUT("DMic"),
47d5e4b0adSMisael Lopez Cruz };
48d5e4b0adSMisael Lopez Cruz 
49d5e4b0adSMisael Lopez Cruz static const struct snd_soc_dapm_route intercon[] = {
50d5e4b0adSMisael Lopez Cruz 	{"DMIC AIF", NULL, "DMic"},
51d5e4b0adSMisael Lopez Cruz };
52d5e4b0adSMisael Lopez Cruz 
53d5e4b0adSMisael Lopez Cruz static struct snd_soc_codec_driver soc_dmic = {
54*a85f9da7SLars-Peter Clausen 	.dapm_widgets = dmic_dapm_widgets,
55*a85f9da7SLars-Peter Clausen 	.num_dapm_widgets = ARRAY_SIZE(dmic_dapm_widgets),
56*a85f9da7SLars-Peter Clausen 	.dapm_routes = intercon,
57*a85f9da7SLars-Peter Clausen 	.num_dapm_routes = ARRAY_SIZE(intercon),
58d5e4b0adSMisael Lopez Cruz };
59a710770eSDavid Lambert 
607a79e94eSBill Pemberton static int dmic_dev_probe(struct platform_device *pdev)
61a710770eSDavid Lambert {
62a710770eSDavid Lambert 	return snd_soc_register_codec(&pdev->dev,
63a710770eSDavid Lambert 			&soc_dmic, &dmic_dai, 1);
64a710770eSDavid Lambert }
65a710770eSDavid Lambert 
667a79e94eSBill Pemberton static int dmic_dev_remove(struct platform_device *pdev)
67a710770eSDavid Lambert {
68a710770eSDavid Lambert 	snd_soc_unregister_codec(&pdev->dev);
69a710770eSDavid Lambert 	return 0;
70a710770eSDavid Lambert }
71a710770eSDavid Lambert 
72a710770eSDavid Lambert MODULE_ALIAS("platform:dmic-codec");
73a710770eSDavid Lambert 
74a710770eSDavid Lambert static struct platform_driver dmic_driver = {
75a710770eSDavid Lambert 	.driver = {
76a710770eSDavid Lambert 		.name = "dmic-codec",
77a710770eSDavid Lambert 		.owner = THIS_MODULE,
78a710770eSDavid Lambert 	},
79a710770eSDavid Lambert 	.probe = dmic_dev_probe,
807a79e94eSBill Pemberton 	.remove = dmic_dev_remove,
81a710770eSDavid Lambert };
82a710770eSDavid Lambert 
835bbcc3c0SMark Brown module_platform_driver(dmic_driver);
84a710770eSDavid Lambert 
85a710770eSDavid Lambert MODULE_DESCRIPTION("Generic DMIC driver");
86a710770eSDavid Lambert MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>");
87a710770eSDavid Lambert MODULE_LICENSE("GPL");
88