blob: 3e929f079a1f0eb4b3fa472482d68503703da8c4 [file] [log] [blame]
David Lamberta7107702011-01-06 08:00:37 -06001/*
2 * dmic.c -- SoC audio for Generic Digital MICs
3 *
4 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
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>
Paul Gortmakerda155d52011-07-15 12:38:28 -040024#include <linux/module.h>
David Lamberta7107702011-01-06 08:00:37 -060025#include <sound/core.h>
26#include <sound/pcm.h>
27#include <sound/soc.h>
28#include <sound/soc-dapm.h>
29
30static struct snd_soc_dai_driver dmic_dai = {
31 .name = "dmic-hifi",
32 .capture = {
33 .stream_name = "Capture",
34 .channels_min = 1,
35 .channels_max = 8,
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,
40 },
41};
42
Misael Lopez Cruzd5e4b0a2011-05-12 16:26:20 +010043static const struct snd_soc_dapm_widget dmic_dapm_widgets[] = {
44 SND_SOC_DAPM_AIF_OUT("DMIC AIF", "Capture", 0,
45 SND_SOC_NOPM, 0, 0),
46 SND_SOC_DAPM_INPUT("DMic"),
47};
48
49static const struct snd_soc_dapm_route intercon[] = {
50 {"DMIC AIF", NULL, "DMic"},
51};
52
53static int dmic_probe(struct snd_soc_codec *codec)
54{
55 struct snd_soc_dapm_context *dapm = &codec->dapm;
56
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);
61
62 return 0;
63}
64
65static struct snd_soc_codec_driver soc_dmic = {
66 .probe = dmic_probe,
67};
David Lamberta7107702011-01-06 08:00:37 -060068
69static int __devinit dmic_dev_probe(struct platform_device *pdev)
70{
71 return snd_soc_register_codec(&pdev->dev,
72 &soc_dmic, &dmic_dai, 1);
73}
74
75static int __devexit dmic_dev_remove(struct platform_device *pdev)
76{
77 snd_soc_unregister_codec(&pdev->dev);
78 return 0;
79}
80
81MODULE_ALIAS("platform:dmic-codec");
82
83static struct platform_driver dmic_driver = {
84 .driver = {
85 .name = "dmic-codec",
86 .owner = THIS_MODULE,
87 },
88 .probe = dmic_dev_probe,
89 .remove = __devexit_p(dmic_dev_remove),
90};
91
Mark Brown5bbcc3c2011-11-23 22:52:08 +000092module_platform_driver(dmic_driver);
David Lamberta7107702011-01-06 08:00:37 -060093
94MODULE_DESCRIPTION("Generic DMIC driver");
95MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>");
96MODULE_LICENSE("GPL");