aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-5.4/950-0400-adds-LED-OFF-feature-to-HiFiBerry-DAC-ADC-PRO-sound-.patch
blob: 397a2c3331ccc4d9ba21984986a601f086c3f891 (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
83
84
85
86
87
88
89
From 4a773d6535c3386044490156264ebd2a3b1bc38b Mon Sep 17 00:00:00 2001
From: j-schambacher <joerg@i2audio.com>
Date: Mon, 27 Jan 2020 17:45:51 +0100
Subject: [PATCH] adds LED OFF feature to HiFiBerry DAC+ADC PRO sound
 card

This adds a DT overlay parameter 'leds_off' which allows
to switch off the onboard activity LEDs at all times
which has been requested by some users.

Signed-off-by: Joerg Schambacher <joerg@i2audio.com>
---
 arch/arm/boot/dts/overlays/README                 |  2 ++
 .../overlays/hifiberry-dacplusadcpro-overlay.dts  |  1 +
 sound/soc/bcm/hifiberry_dacplusadcpro.c           | 15 +++++++++++++--
 3 files changed, 16 insertions(+), 2 deletions(-)

--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -948,6 +948,8 @@ Params: 24db_digital_gain       Allow ga
                                 that does not result in clipping/distortion!)
         slave                   Force DAC+ADC Pro into slave mode, using Pi as
                                 master for bit clock and frame clock.
+        leds_off                If set to 'true' the onboard indicator LEDs
+                                are switched off at all times.
 
 
 Name:   hifiberry-dacplusdsp
--- a/arch/arm/boot/dts/overlays/hifiberry-dacplusadcpro-overlay.dts
+++ b/arch/arm/boot/dts/overlays/hifiberry-dacplusadcpro-overlay.dts
@@ -60,5 +60,6 @@
 		24db_digital_gain =
 			<&hifiberry_dacplusadcpro>,"hifiberry-dacplusadcpro,24db_digital_gain?";
 		slave = <&hifiberry_dacplusadcpro>,"hifiberry-dacplusadcpro,slave?";
+		leds_off = <&hifiberry_dacplusadcpro>,"hifiberry-dacplusadcpro,leds_off?";
 	};
 };
--- a/sound/soc/bcm/hifiberry_dacplusadcpro.c
+++ b/sound/soc/bcm/hifiberry_dacplusadcpro.c
@@ -54,6 +54,7 @@ struct pcm512x_priv {
 static bool slave;
 static bool snd_rpi_hifiberry_is_dacpro;
 static bool digital_gain_0db_limit = true;
+static bool leds_off;
 
 static const unsigned int pcm186x_adc_input_channel_sel_value[] = {
 	0x00, 0x01, 0x02, 0x03, 0x10
@@ -321,7 +322,10 @@ static int snd_rpi_hifiberry_dacplusadcp
 
 	snd_soc_component_update_bits(dac, PCM512x_GPIO_EN, 0x08, 0x08);
 	snd_soc_component_update_bits(dac, PCM512x_GPIO_OUTPUT_4, 0x0f, 0x02);
-	snd_soc_component_update_bits(dac, PCM512x_GPIO_CONTROL_1, 0x08, 0x08);
+	if (leds_off)
+		snd_soc_component_update_bits(dac, PCM512x_GPIO_CONTROL_1, 0x08, 0x00);
+	else
+		snd_soc_component_update_bits(dac, PCM512x_GPIO_CONTROL_1, 0x08, 0x08);
 
 	ret = pcm1863_add_controls(adc);
 	if (ret < 0)
@@ -331,7 +335,10 @@ static int snd_rpi_hifiberry_dacplusadcp
 	/* set GPIO2 to output, GPIO3 input */
 	snd_soc_component_write(adc, PCM186X_GPIO3_2_CTRL, 0x00);
 	snd_soc_component_write(adc, PCM186X_GPIO3_2_DIR_CTRL, 0x04);
-	snd_soc_component_update_bits(adc, PCM186X_GPIO_IN_OUT, 0x40, 0x40);
+	if (leds_off)
+		snd_soc_component_update_bits(adc, PCM186X_GPIO_IN_OUT, 0x40, 0x00);
+	else
+		snd_soc_component_update_bits(adc, PCM186X_GPIO_IN_OUT, 0x40, 0x40);
 
 	if (digital_gain_0db_limit) {
 		int ret;
@@ -417,6 +424,8 @@ static int snd_rpi_hifiberry_dacplusadcp
 	struct snd_soc_component *dac = rtd->codec_dais[0]->component;
 	struct snd_soc_component *adc = rtd->codec_dais[1]->component;
 
+	if (leds_off)
+		return 0;
 	/* switch on respective LED */
 	if (!substream->stream)
 		snd_soc_component_update_bits(dac, PCM512x_GPIO_CONTROL_1, 0x08, 0x08);
@@ -500,6 +509,8 @@ static int snd_rpi_hifiberry_dacplusadcp
 		pdev->dev.of_node, "hifiberry-dacplusadcpro,24db_digital_gain");
 	slave = of_property_read_bool(pdev->dev.of_node,
 					"hifiberry-dacplusadcpro,slave");
+	leds_off = of_property_read_bool(pdev->dev.of_node,
+					"hifiberry-dacplusadcpro,leds_off");
 	ret = snd_soc_register_card(&snd_rpi_hifiberry_dacplusadcpro);
 	if (ret && ret != -EPROBE_DEFER)
 		dev_err(&pdev->dev,