-
Notifications
You must be signed in to change notification settings - Fork 11
/
hifimems-codec.c
108 lines (95 loc) · 3.2 KB
/
hifimems-codec.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
* Simple driver for Hifiberry and ICS43432 MEMS microphone compatible hardware
*
* Author: Greg Miell <[email protected]>
* Copyright 2017
* Based on googlevoicehat-codec.c by Peter Malkin
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include <linux/device.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/version.h>
#include <sound/pcm.h>
#include <sound/soc.h>
#include <sound/soc-dai.h>
#include <sound/soc-dapm.h>
static int hifimems_codec_probe(struct snd_soc_codec *codec) {
return 0;
}
static int hifimems_codec_remove(struct snd_soc_codec *codec) {
return 0;
}
static const struct snd_soc_dapm_widget hifimems_dapm_widgets[] = {
SND_SOC_DAPM_OUTPUT("Speaker"),
};
static const struct snd_soc_dapm_route hifimems_dapm_routes[] = {
{"Speaker", NULL, "Playback"},
};
static struct snd_soc_codec_driver hifimems_codec_driver = {
.probe = hifimems_codec_probe,
.remove = hifimems_codec_remove,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
.component_driver = {
#endif
.dapm_widgets = hifimems_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(hifimems_dapm_widgets),
.dapm_routes = hifimems_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(hifimems_dapm_routes),
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
},
#endif
};
static struct snd_soc_dai_driver hifimems_dai = {
.name = "hifimems-hifi",
.capture = {.stream_name = "Capture",
.channels_min = 2,
.channels_max = 2,
.rates = SNDRV_PCM_RATE_48000,
.formats = SNDRV_PCM_FMTBIT_S32_LE},
.playback = {.stream_name = "Playback",
.channels_min = 2,
.channels_max = 2,
.rates = SNDRV_PCM_RATE_48000,
.formats = SNDRV_PCM_FMTBIT_S32_LE},
.symmetric_rates = 1};
#ifdef CONFIG_OF
static const struct of_device_id hifimems_ids[] = {
{
.compatible = "hifimems,hifimems",
},
{}};
MODULE_DEVICE_TABLE(of, hifimems_ids);
#endif
static int hifimems_platform_probe(struct platform_device *pdev) {
return snd_soc_register_codec(&pdev->dev, &hifimems_codec_driver, &hifimems_dai, 1);
}
static int hifimems_platform_remove(struct platform_device *pdev) {
snd_soc_unregister_codec(&pdev->dev);
return 0;
}
static struct platform_driver hifimems_driver = {
.driver =
{
.name = "hifimems-codec", .of_match_table = of_match_ptr(hifimems_ids),
},
.probe = hifimems_platform_probe,
.remove = hifimems_platform_remove,
};
module_platform_driver(hifimems_driver);
MODULE_DESCRIPTION("Simple I2S Hifiberry & ICS43432 MEMS Codec");
MODULE_AUTHOR("Greg Miell <[email protected]>");
MODULE_LICENSE("GPL v2");