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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
From fb21611efd7cd916646d9ab2988c3af08f139761 Mon Sep 17 00:00:00 2001
From: Ben Payne <ben@bluerocksoft.com>
Date: Tue, 13 Feb 2024 14:55:14 -0800
Subject: [PATCH 1276/1295] Impliment driver support for Interlude Audio
Digital Hat
Implementing driver support for
Interlude audio's WM8805 based digital hat
by leveraging existing drivers
---
sound/soc/bcm/rpi-wm8804-soundcard.c | 139 +++++++++++++++++++++++++++
1 file changed, 139 insertions(+)
--- a/sound/soc/bcm/rpi-wm8804-soundcard.c
+++ b/sound/soc/bcm/rpi-wm8804-soundcard.c
@@ -34,6 +34,7 @@
#include <linux/gpio/consumer.h>
#include <linux/platform_device.h>
#include <linux/module.h>
+#include <linux/delay.h>
#include <sound/core.h>
#include <sound/pcm.h>
@@ -65,6 +66,10 @@ struct snd_rpi_wm8804_drvdata {
static struct gpio_desc *snd_clk44gpio;
static struct gpio_desc *snd_clk48gpio;
static int wm8804_samplerate = 0;
+static struct gpio_desc *led_gpio_1;
+static struct gpio_desc *led_gpio_2;
+static struct gpio_desc *led_gpio_3;
+static struct gpio_desc *custom_reset;
/* Forward declarations */
static struct snd_soc_dai_link snd_allo_digione_dai[];
@@ -74,6 +79,37 @@ static struct snd_soc_card snd_rpi_wm880
#define CLK_44EN_RATE 22579200UL
#define CLK_48EN_RATE 24576000UL
+static const char * const wm8805_input_select_text[] = {
+ "Rx 0",
+ "Rx 1",
+ "Rx 2",
+ "Rx 3",
+ "Rx 4",
+ "Rx 5",
+ "Rx 6",
+ "Rx 7"
+};
+
+static const unsigned int wm8805_input_channel_select_value[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7
+};
+
+static const struct soc_enum wm8805_input_channel_sel[] = {
+ SOC_VALUE_ENUM_SINGLE(WM8804_PLL6, 0, 7, ARRAY_SIZE(wm8805_input_select_text),
+ wm8805_input_select_text, wm8805_input_channel_select_value),
+};
+
+static const struct snd_kcontrol_new wm8805_input_controls_card[] = {
+ SOC_ENUM("Select Input Channel", wm8805_input_channel_sel[0]),
+};
+
+static int wm8805_add_input_controls(struct snd_soc_component *component)
+{
+ snd_soc_add_component_controls(component, wm8805_input_controls_card,
+ ARRAY_SIZE(wm8805_input_controls_card));
+ return 0;
+}
+
static unsigned int snd_rpi_wm8804_enable_clock(unsigned int samplerate)
{
switch (samplerate) {
@@ -187,6 +223,53 @@ static struct snd_soc_ops snd_rpi_wm8804
.hw_params = snd_rpi_wm8804_hw_params,
};
+static int snd_interlude_audio_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params)
+{
+ int ret = snd_rpi_wm8804_hw_params(substream, params);
+ int samplerate = params_rate(params);
+
+ switch (samplerate) {
+ case 44100:
+ gpiod_set_value_cansleep(led_gpio_1, 1);
+ gpiod_set_value_cansleep(led_gpio_2, 0);
+ gpiod_set_value_cansleep(led_gpio_3, 0);
+ break;
+ case 48000:
+ gpiod_set_value_cansleep(led_gpio_1, 1);
+ gpiod_set_value_cansleep(led_gpio_2, 0);
+ gpiod_set_value_cansleep(led_gpio_3, 0);
+ break;
+ case 88200:
+ gpiod_set_value_cansleep(led_gpio_1, 0);
+ gpiod_set_value_cansleep(led_gpio_2, 1);
+ gpiod_set_value_cansleep(led_gpio_3, 0);
+ break;
+ case 96000:
+ gpiod_set_value_cansleep(led_gpio_1, 0);
+ gpiod_set_value_cansleep(led_gpio_2, 1);
+ gpiod_set_value_cansleep(led_gpio_3, 0);
+ break;
+ case 176400:
+ gpiod_set_value_cansleep(led_gpio_1, 0);
+ gpiod_set_value_cansleep(led_gpio_2, 0);
+ gpiod_set_value_cansleep(led_gpio_3, 1);
+ break;
+ case 192000:
+ gpiod_set_value_cansleep(led_gpio_1, 0);
+ gpiod_set_value_cansleep(led_gpio_2, 0);
+ gpiod_set_value_cansleep(led_gpio_3, 1);
+ break;
+ default:
+ break;
+ }
+ return ret;
+}
+
+const struct snd_soc_ops interlude_audio_digital_dai_ops = {
+ .hw_params = snd_interlude_audio_hw_params,
+};
+
SND_SOC_DAILINK_DEFS(justboom_digi,
DAILINK_COMP_ARRAY(COMP_EMPTY()),
DAILINK_COMP_ARRAY(COMP_EMPTY()),
@@ -287,6 +370,60 @@ static struct snd_rpi_wm8804_drvdata drv
.probe = snd_hifiberry_digi_probe,
};
+SND_SOC_DAILINK_DEFS(interlude_audio_digital,
+ DAILINK_COMP_ARRAY(COMP_EMPTY()),
+ DAILINK_COMP_ARRAY(COMP_EMPTY()),
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
+
+static int snd_interlude_audio_init(struct snd_soc_pcm_runtime *rtd)
+{
+ struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
+ int ret;
+
+ ret = wm8805_add_input_controls(component);
+ if (ret != 0)
+ pr_err("failed to add input controls");
+
+ return 0;
+}
+
+
+static struct snd_soc_dai_link snd_interlude_audio_digital_dai[] = {
+{
+ .name = "Interlude Audio Digital",
+ .stream_name = "Interlude Audio Digital HiFi",
+ .init = snd_interlude_audio_init,
+ .ops = &interlude_audio_digital_dai_ops,
+ SND_SOC_DAILINK_REG(interlude_audio_digital),
+},
+};
+
+
+static int snd_interlude_audio_digital_probe(struct platform_device *pdev)
+{
+ if (IS_ERR(snd_clk44gpio) || IS_ERR(snd_clk48gpio))
+ return 0;
+
+ custom_reset = devm_gpiod_get(&pdev->dev, "reset", GPIOD_OUT_LOW);
+ gpiod_set_value_cansleep(custom_reset, 0);
+ mdelay(10);
+ gpiod_set_value_cansleep(custom_reset, 1);
+
+ snd_interlude_audio_digital_dai->name = "Interlude Audio Digital";
+ snd_interlude_audio_digital_dai->stream_name = "Interlude Audio Digital HiFi";
+ led_gpio_1 = devm_gpiod_get(&pdev->dev, "led1", GPIOD_OUT_LOW);
+ led_gpio_2 = devm_gpiod_get(&pdev->dev, "led2", GPIOD_OUT_LOW);
+ led_gpio_3 = devm_gpiod_get(&pdev->dev, "led3", GPIOD_OUT_LOW);
+ return 0;
+}
+
+
+static struct snd_rpi_wm8804_drvdata drvdata_interlude_audio_digital = {
+ .card_name = "snd_IA_Digital_Hat",
+ .dai = snd_interlude_audio_digital_dai,
+ .probe = snd_interlude_audio_digital_probe,
+};
+
static const struct of_device_id snd_rpi_wm8804_of_match[] = {
{ .compatible = "justboom,justboom-digi",
.data = (void *) &drvdata_justboom_digi },
@@ -296,6 +433,8 @@ static const struct of_device_id snd_rpi
.data = (void *) &drvdata_allo_digione },
{ .compatible = "hifiberry,hifiberry-digi",
.data = (void *) &drvdata_hifiberry_digi },
+ { .compatible = "interludeaudio,interludeaudio-digital",
+ .data = (void *) &drvdata_interlude_audio_digital },
{},
};
|