summaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-6.6/950-0915-ASOc-Add-HiFiBerry-DAC8X-to-the-simple-card-driver.patch
blob: 22e0fc4ed8802abc36438bddf737ecf7300f29c7 (plain)
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
From 797e559bc4f5b66c9b2e324a8a612a9fd6805aa1 Mon Sep 17 00:00:00 2001
From: j-schambacher <joerg@hifiberry.com>
Date: Wed, 28 Feb 2024 11:25:14 +0100
Subject: [PATCH 0915/1085] ASOc: Add HiFiBerry DAC8X to the simple card driver

Defines the settings for the 8 channel version of the standard
DAC by overwriting the number of channels in the DAI defs.
It can run in 8ch mode only on PI5 using the 4 lane data output
of the designware I2S0 module.

Signed-off-by: j-schambacher <joerg@hifiberry.com>
---
 sound/soc/bcm/Kconfig                |  5 +++--
 sound/soc/bcm/rpi-simple-soundcard.c | 33 ++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 2 deletions(-)

--- a/sound/soc/bcm/Kconfig
+++ b/sound/soc/bcm/Kconfig
@@ -40,11 +40,12 @@ config SND_BCM2708_SOC_GOOGLEVOICEHAT_SO
           Say Y or M if you want to add support for voiceHAT soundcard.
 
 config SND_BCM2708_SOC_HIFIBERRY_DAC
-        tristate "Support for HifiBerry DAC"
+        tristate "Support for HifiBerry DAC and DAC8X"
         select SND_SOC_PCM5102A
         select SND_RPI_SIMPLE_SOUNDCARD
         help
-         Say Y or M if you want to add support for HifiBerry DAC.
+         Say Y or M if you want to add support for HifiBerry DAC and DAC8X.
+         Note: DAC8X only works on PI5
 
 config SND_BCM2708_SOC_HIFIBERRY_DACPLUS
         tristate "Support for HifiBerry DAC+"
--- a/sound/soc/bcm/rpi-simple-soundcard.c
+++ b/sound/soc/bcm/rpi-simple-soundcard.c
@@ -316,6 +316,37 @@ static struct snd_rpi_simple_drvdata drv
 	.dai       = snd_hifiberry_dac_dai,
 };
 
+static int hifiberry_dac8x_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
+
+	/* override the defaults to reflect 4 x PCM5102A on the card
+	 * and limit the sample rate to 192ksps
+	 */
+	codec_dai->driver->playback.channels_max = 8;
+	codec_dai->driver->playback.rates = SNDRV_PCM_RATE_8000_192000;
+
+	return 0;
+}
+
+static struct snd_soc_dai_link snd_hifiberry_dac8x_dai[] = {
+	{
+		.name           = "HifiBerry DAC8x",
+		.stream_name    = "HifiBerry DAC8x HiFi",
+		.dai_fmt        = SND_SOC_DAIFMT_I2S |
+					SND_SOC_DAIFMT_NB_NF |
+					SND_SOC_DAIFMT_CBS_CFS,
+		.init           = hifiberry_dac8x_init,
+		SND_SOC_DAILINK_REG(hifiberry_dac),
+	},
+};
+
+static struct snd_rpi_simple_drvdata drvdata_hifiberry_dac8x = {
+	.card_name = "snd_rpi_hifiberry_dac8x",
+	.dai       = snd_hifiberry_dac8x_dai,
+	.fixed_bclk_ratio = 64,
+};
+
 SND_SOC_DAILINK_DEFS(dionaudio_kiwi,
 	DAILINK_COMP_ARRAY(COMP_EMPTY()),
 	DAILINK_COMP_ARRAY(COMP_CODEC("pcm1794a-codec", "pcm1794a-hifi")),
@@ -417,6 +448,8 @@ static const struct of_device_id snd_rpi
 		.data = (void *) &drvdata_hifiberry_amp3 },
 	{ .compatible = "hifiberry,hifiberry-dac",
 		.data = (void *) &drvdata_hifiberry_dac },
+	{ .compatible = "hifiberry,hifiberry-dac8x",
+		.data = (void *) &drvdata_hifiberry_dac8x },
 	{ .compatible = "dionaudio,dionaudio-kiwi",
 		.data = (void *) &drvdata_dionaudio_kiwi },
 	{ .compatible = "rpi,rpi-dac", &drvdata_rpi_dac},