Skip to content

Commit 0c0ac6d

Browse files
committed
Add support for Audio Injector Octo audio HAT
1 parent 5d30e4f commit 0c0ac6d

File tree

8 files changed

+68
-32
lines changed

8 files changed

+68
-32
lines changed

arch/arm/boot/dts/overlays/audioinjector-addons-overlay.dts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
/dts-v1/;
33
/plugin/;
44

5+
#include <dt-bindings/pinctrl/rockchip.h>
6+
57
/ {
6-
compatible = "brcm,bcm2708";
8+
compatible = "rockchip,rk3288-miniarm", "rockchip,rk3288";
79

810
fragment@0 {
911
target = <&i2s>;
1012
__overlay__ {
1113
status = "okay";
14+
rockchip,bcm2835_compatibility_mode = <1>;
1215
};
1316
};
1417

@@ -37,18 +40,32 @@
3740
};
3841

3942
fragment@2 {
40-
target = <&sound>;
43+
target-path = "/sound-ext-card";
4144
snd: __overlay__ {
4245
compatible = "ai,audioinjector-octo-soundcard";
43-
mult-gpios = <&gpio 27 0>, <&gpio 22 0>, <&gpio 23 0>,
44-
<&gpio 24 0>;
45-
reset-gpios = <&gpio 5 0>;
46+
mult-gpios = <&gpio5 RK_PB6 0>, <&gpio5 RK_PB7 0>, <&gpio5 RK_PB2 0>,
47+
<&gpio5 RK_PB3 0>;
48+
reset-gpios = <&gpio5 RK_PB5 0>;
4649
i2s-controller = <&i2s>;
4750
codec = <&cs42448>;
4851
status = "okay";
4952
};
5053
};
5154

55+
fragment@3 {
56+
target-path = "/sound-simple-card";
57+
__overlay__ {
58+
status = "disabled";
59+
};
60+
};
61+
62+
fragment@4 {
63+
target = <&hdmi>;
64+
__overlay__ {
65+
hdmi-i2s-audio-disable;
66+
};
67+
};
68+
5269
__overrides__ {
5370
non-stop-clocks = <&snd>, "non-stop-clocks?";
5471
};

arch/arm/configs/miniarm-rk3288_defconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,8 @@ CONFIG_SND_SOC_ROCKCHIP_MAX98090=y
615615
CONFIG_SND_SOC_ROCKCHIP_RT5645=y
616616
CONFIG_SND_SOC_CX20810=y
617617
CONFIG_SND_SOC_RT5616=y
618+
CONFIG_SND_SOC_CS42XX8=m
619+
CONFIG_SND_SOC_CS42XX8_I2C=m
618620
CONFIG_SND_SOC_RT5640=y
619621
CONFIG_SND_SOC_SEEEDVOICEHAT_CARD=y
620622
CONFIG_SND_SOC_SPDIF=y
@@ -895,3 +897,4 @@ CONFIG_CAN_DEV=y
895897
CONFIG_CAN_MCP251X=y
896898
CONFIG_SND_SOC_GOOGLEVOICEHAT_CARD=y
897899
CONFIG_OVERLAY_FS=y
900+
CONFIG_SND_AUDIOINJECTOR_OCTO_SOUNDCARD=m

sound/soc/bcm/Kconfig

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,3 @@ config SND_BCM2835_SOC_I2S
77
Say Y or M if you want to add support for codecs attached to
88
the BCM2835 I2S interface. You will also need
99
to select the audio interfaces to support below.
10-
11-
config SND_AUDIOINJECTOR_OCTO_SOUNDCARD
12-
tristate "Support for audioinjector.net Octo channel (Hat) soundcard"
13-
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
14-
select SND_SOC_CS42XX8_I2C
15-
help
16-
Say Y or M if you want to add support for audioinjector.net octo add on

sound/soc/bcm/Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,3 @@
22
snd-soc-bcm2835-i2s-objs := bcm2835-i2s.o
33

44
obj-$(CONFIG_SND_BCM2835_SOC_I2S) += snd-soc-bcm2835-i2s.o
5-
6-
snd-soc-audioinjector-octo-soundcard-objs := audioinjector-octo-soundcard.o
7-
8-
obj-$(CONFIG_SND_AUDIOINJECTOR_OCTO_SOUNDCARD) += snd-soc-audioinjector-octo-soundcard.o

sound/soc/rockchip/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,10 @@ config SND_SOC_SEEEDVOICEHAT_CARD
201201
tristate "Support for Seeed voice HAT sound card"
202202
help
203203
Say Y or M if you want to add support for Seeed voice sound card.
204+
205+
config SND_AUDIOINJECTOR_OCTO_SOUNDCARD
206+
tristate "Support for audioinjector.net Octo channel (Hat) soundcard"
207+
depends on SND_SOC_ROCKCHIP
208+
select SND_SOC_CS42XX8_I2C
209+
help
210+
Say Y or M if you want to add support for audioinjector.net octo sound card.

sound/soc/rockchip/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ snd-soc-justboom-dac-objs := justboom-dac.o
4141
snd-soc-justboom-digi-objs := justboom-digi.o
4242
snd-soc-googlevoicehat-soundcard-objs := googlevoicehat-soundcard.o
4343
snd-soc-googlevoicehat-codec-objs := googlevoicehat-codec.o
44+
snd-soc-audioinjector-octo-soundcard-objs := audioinjector-octo-soundcard.o
4445

4546
obj-$(CONFIG_SND_SOC_ROCKCHIP_DA7219) += snd-soc-rockchip-da7219.o
4647
obj-$(CONFIG_SND_SOC_ROCKCHIP_HDMI_ANALOG) += snd-soc-rockchip-hdmi-analog.o
@@ -63,3 +64,4 @@ obj-$(CONFIG_SND_SOC_JUSTBOOM_DIGI) += snd-soc-justboom-digi.o
6364
obj-$(CONFIG_SND_SOC_GOOGLEVOICEHAT_CARD) += snd-soc-googlevoicehat-soundcard.o
6465
obj-$(CONFIG_SND_SOC_GOOGLEVOICEHAT_CARD) += snd-soc-googlevoicehat-codec.o
6566
obj-$(CONFIG_SND_SOC_SEEEDVOICEHAT_CARD) += seeedvoicehat/
67+
obj-$(CONFIG_SND_AUDIOINJECTOR_OCTO_SOUNDCARD) += snd-soc-audioinjector-octo-soundcard.o

sound/soc/bcm/audioinjector-octo-soundcard.c renamed to sound/soc/rockchip/audioinjector-octo-soundcard.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* General Public License for more details.
1818
*/
1919

20+
#include <linux/delay.h>
2021
#include <linux/module.h>
2122
#include <linux/types.h>
2223
#include <linux/gpio/consumer.h>
@@ -42,7 +43,11 @@ static struct snd_pcm_hw_constraint_list audioinjector_octo_constraints = {
4243

4344
static int audioinjector_octo_dai_init(struct snd_soc_pcm_runtime *rtd)
4445
{
46+
#ifdef ROCKCHIP_AUDIO
47+
return 0;
48+
#else
4549
return snd_soc_dai_set_bclk_ratio(rtd->cpu_dai, 64);
50+
#endif
4651
}
4752

4853
static int audioinjector_octo_startup(struct snd_pcm_substream *substream)

sound/soc/rockchip/rockchip_i2s.c

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ struct rk_i2s_dev {
5757
int xfer_mode; /* 0: i2s, 1: pcm */
5858
const struct rk_i2s_pins *pins;
5959
unsigned int bclk_fs;
60+
bool bcm2835_compat_mode;
6061
};
6162

6263
/* txctrl/rxctrl lock */
@@ -339,23 +340,27 @@ static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream,
339340
return -EINVAL;
340341
}
341342

342-
switch (params_channels(params)) {
343-
case 8:
344-
val |= I2S_CHN_8;
345-
break;
346-
case 6:
347-
val |= I2S_CHN_6;
348-
break;
349-
case 4:
350-
val |= I2S_CHN_4;
351-
break;
352-
case 2:
343+
if (i2s->bcm2835_compat_mode) {
353344
val |= I2S_CHN_2;
354-
break;
355-
default:
356-
dev_err(i2s->dev, "invalid channel: %d\n",
357-
params_channels(params));
358-
return -EINVAL;
345+
} else {
346+
switch (params_channels(params)) {
347+
case 8:
348+
val |= I2S_CHN_8;
349+
break;
350+
case 6:
351+
val |= I2S_CHN_6;
352+
break;
353+
case 4:
354+
val |= I2S_CHN_4;
355+
break;
356+
case 2:
357+
val |= I2S_CHN_2;
358+
break;
359+
default:
360+
dev_err(i2s->dev, "invalid channel: %d\n",
361+
params_channels(params));
362+
return -EINVAL;
363+
}
359364
}
360365

361366
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
@@ -692,6 +697,14 @@ static int rockchip_i2s_probe(struct platform_device *pdev)
692697
i2s->bclk_fs = val;
693698
}
694699

700+
// If enabled, the behaviour of the rockchip I2S will more closely
701+
// resemble that of the BCM 2835 I2S controlller (as used in the
702+
// raspberry pi). This can be usuful to achieve compatibility with
703+
// Raspberry Pi Audio HATs.
704+
i2s->bcm2835_compat_mode =
705+
of_property_read_bool(node,
706+
"rockchip,bcm2835_compatibility_mode");
707+
695708
ret = devm_snd_soc_register_component(&pdev->dev,
696709
&rockchip_i2s_component,
697710
soc_dai, 1);

0 commit comments

Comments
 (0)