1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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>
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
43static 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 struct snd_soc_codec_driver soc_dmic = {
54 .component_driver = {
55 .dapm_widgets = dmic_dapm_widgets,
56 .num_dapm_widgets = ARRAY_SIZE(dmic_dapm_widgets),
57 .dapm_routes = intercon,
58 .num_dapm_routes = ARRAY_SIZE(intercon),
59 },
60};
61
62static int dmic_dev_probe(struct platform_device *pdev)
63{
64 return snd_soc_register_codec(&pdev->dev,
65 &soc_dmic, &dmic_dai, 1);
66}
67
68static int dmic_dev_remove(struct platform_device *pdev)
69{
70 snd_soc_unregister_codec(&pdev->dev);
71 return 0;
72}
73
74MODULE_ALIAS("platform:dmic-codec");
75
76static struct platform_driver dmic_driver = {
77 .driver = {
78 .name = "dmic-codec",
79 },
80 .probe = dmic_dev_probe,
81 .remove = dmic_dev_remove,
82};
83
84module_platform_driver(dmic_driver);
85
86MODULE_DESCRIPTION("Generic DMIC driver");
87MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>");
88MODULE_LICENSE("GPL");
89