2 * dmic.c -- SoC audio for Generic Digital MICs
4 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
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.
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.
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
22 #include <linux/platform_device.h>
23 #include <linux/slab.h>
24 #include <linux/module.h>
25 #include <sound/core.h>
26 #include <sound/pcm.h>
27 #include <sound/soc.h>
28 #include <sound/soc-dapm.h>
30 static struct snd_soc_dai_driver dmic_dai
= {
33 .stream_name
= "Capture",
36 .rates
= SNDRV_PCM_RATE_CONTINUOUS
,
37 .formats
= SNDRV_PCM_FMTBIT_S32_LE
38 | SNDRV_PCM_FMTBIT_S24_LE
39 | SNDRV_PCM_FMTBIT_S16_LE
,
43 static const struct snd_soc_dapm_widget dmic_dapm_widgets
[] = {
44 SND_SOC_DAPM_AIF_OUT("DMIC AIF", "Capture", 0,
46 SND_SOC_DAPM_INPUT("DMic"),
49 static const struct snd_soc_dapm_route intercon
[] = {
50 {"DMIC AIF", NULL
, "DMic"},
53 static int dmic_probe(struct snd_soc_codec
*codec
)
55 struct snd_soc_dapm_context
*dapm
= &codec
->dapm
;
57 snd_soc_dapm_new_controls(dapm
, dmic_dapm_widgets
,
58 ARRAY_SIZE(dmic_dapm_widgets
));
59 snd_soc_dapm_add_routes(dapm
, intercon
, ARRAY_SIZE(intercon
));
60 snd_soc_dapm_new_widgets(dapm
);
65 static struct snd_soc_codec_driver soc_dmic
= {
69 static int __devinit
dmic_dev_probe(struct platform_device
*pdev
)
71 return snd_soc_register_codec(&pdev
->dev
,
72 &soc_dmic
, &dmic_dai
, 1);
75 static int __devexit
dmic_dev_remove(struct platform_device
*pdev
)
77 snd_soc_unregister_codec(&pdev
->dev
);
81 MODULE_ALIAS("platform:dmic-codec");
83 static struct platform_driver dmic_driver
= {
88 .probe
= dmic_dev_probe
,
89 .remove
= __devexit_p(dmic_dev_remove
),
92 module_platform_driver(dmic_driver
);
94 MODULE_DESCRIPTION("Generic DMIC driver");
95 MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>");
96 MODULE_LICENSE("GPL");