aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/brcm2708/patches-4.4/0367-Add-dt-param-to-force-HiFiBerry-DAC-Pro-into-slave-m.patch
blob: d413faea5591ae7859ccb05ae26cf53c1d6868d6 (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 8f9baa887c3328ee17a78b05eba51af6c8ffc83e Mon Sep 17 00:00:00 2001
From: DigitalDreamtime <clive.messer@digitaldreamtime.co.uk>
Date: Sun, 29 May 2016 05:22:29 +0100
Subject: [PATCH] Add dt param to force HiFiBerry DAC+ Pro into slave mode

"dtoverlay=hifiberry-dacplus,slave"

Add 'slave' param to use HiFiBerry DAC+ Pro in slave mode,
with Pi as master for bit and frame clock.

Signed-off-by: DigitalDreamtime <clive.messer@digitaldreamtime.co.uk>
---
 arch/arm/boot/dts/overlays/README                        |  2 ++
 arch/arm/boot/dts/overlays/hifiberry-dacplus-overlay.dts |  6 ++++--
 sound/soc/bcm/hifiberry_dacplus.c                        | 10 ++++++++--
 3 files changed, 14 insertions(+), 4 deletions(-)

--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -344,6 +344,8 @@ Params: 24db_digital_gain       Allow ga
                                 responsibility of the user to ensure that
                                 the Digital volume control is set to a value
                                 that does not result in clipping/distortion!)
+        slave                   Force DAC+ Pro into slave mode, using Pi as
+                                master for bit clock and frame clock.
 
 
 Name:   hifiberry-digi
--- a/arch/arm/boot/dts/overlays/hifiberry-dacplus-overlay.dts
+++ b/arch/arm/boot/dts/overlays/hifiberry-dacplus-overlay.dts
@@ -41,7 +41,7 @@
 
 	fragment@3 {
 		target = <&sound>;
-		frag3: __overlay__ {
+		hifiberry_dacplus: __overlay__ {
 			compatible = "hifiberry,hifiberry-dacplus";
 			i2s-controller = <&i2s>;
 			status = "okay";
@@ -49,6 +49,8 @@
 	};
 
 	__overrides__ {
-		24db_digital_gain = <&frag3>,"hifiberry,24db_digital_gain?";
+		24db_digital_gain =
+			<&hifiberry_dacplus>,"hifiberry,24db_digital_gain?";
+		slave = <&hifiberry_dacplus>,"hifiberry-dacplus,slave?";
 	};
 };
--- a/sound/soc/bcm/hifiberry_dacplus.c
+++ b/sound/soc/bcm/hifiberry_dacplus.c
@@ -47,6 +47,7 @@ struct pcm512x_priv {
 /* Clock rate of CLK48EN attached to GPIO3 pin */
 #define CLK_48EN_RATE 24576000UL
 
+static bool slave;
 static bool snd_rpi_hifiberry_is_dacpro;
 static bool digital_gain_0db_limit = true;
 
@@ -145,8 +146,11 @@ static int snd_rpi_hifiberry_dacplus_ini
 	struct snd_soc_codec *codec = rtd->codec;
 	struct pcm512x_priv *priv;
 
-	snd_rpi_hifiberry_is_dacpro
-		= snd_rpi_hifiberry_dacplus_is_pro_card(codec);
+	if (slave)
+		snd_rpi_hifiberry_is_dacpro = false;
+	else
+		snd_rpi_hifiberry_is_dacpro =
+				snd_rpi_hifiberry_dacplus_is_pro_card(codec);
 
 	if (snd_rpi_hifiberry_is_dacpro) {
 		struct snd_soc_dai_link *dai = rtd->dai_link;
@@ -314,6 +318,8 @@ static int snd_rpi_hifiberry_dacplus_pro
 
 		digital_gain_0db_limit = !of_property_read_bool(
 			pdev->dev.of_node, "hifiberry,24db_digital_gain");
+		slave = of_property_read_bool(pdev->dev.of_node,
+						"hifiberry-dacplus,slave");
 	}
 
 	ret = snd_soc_register_card(&snd_rpi_hifiberry_dacplus);