bd8f405ef89226797c4664618b2865daf666cc0e
[openwrt/openwrt.git] /
1 From 36949b2ea78d5782faed2fb00a037f37789fa85d Mon Sep 17 00:00:00 2001
2 From: j-schambacher <joerg@i2audio.com>
3 Date: Mon, 27 Jan 2020 20:37:34 +0100
4 Subject: [PATCH] adds LED OFF feature to HiFiBerry DAC+ADC sound card
5
6 This adds a DT overlay parameter 'leds_off' which allows
7 to switch off the onboard activity LEDs at all times
8 which has been requested by some users.
9
10 Signed-off-by: Joerg Schambacher <joerg@i2audio.com>
11 ---
12 arch/arm/boot/dts/overlays/README | 2 ++
13 .../boot/dts/overlays/hifiberry-dacplusadc-overlay.dts | 1 +
14 sound/soc/bcm/hifiberry_dacplusadc.c | 10 +++++++++-
15 3 files changed, 12 insertions(+), 1 deletion(-)
16
17 --- a/arch/arm/boot/dts/overlays/README
18 +++ b/arch/arm/boot/dts/overlays/README
19 @@ -927,6 +927,8 @@ Params: 24db_digital_gain Allow ga
20 that does not result in clipping/distortion!)
21 slave Force DAC+ Pro into slave mode, using Pi as
22 master for bit clock and frame clock.
23 + leds_off If set to 'true' the onboard indicator LEDs
24 + are switched off at all times.
25
26
27 Name: hifiberry-dacplusadcpro
28 --- a/arch/arm/boot/dts/overlays/hifiberry-dacplusadc-overlay.dts
29 +++ b/arch/arm/boot/dts/overlays/hifiberry-dacplusadc-overlay.dts
30 @@ -67,5 +67,6 @@
31 24db_digital_gain =
32 <&hifiberry_dacplusadc>,"hifiberry,24db_digital_gain?";
33 slave = <&hifiberry_dacplusadc>,"hifiberry-dacplusadc,slave?";
34 + leds_off = <&hifiberry_dacplusadc>,"hifiberry-dacplusadc,leds_off?";
35 };
36 };
37 --- a/sound/soc/bcm/hifiberry_dacplusadc.c
38 +++ b/sound/soc/bcm/hifiberry_dacplusadc.c
39 @@ -54,6 +54,7 @@ struct pcm512x_priv {
40 static bool slave;
41 static bool snd_rpi_hifiberry_is_dacpro;
42 static bool digital_gain_0db_limit = true;
43 +static bool leds_off;
44
45 static void snd_rpi_hifiberry_dacplusadc_select_clk(struct snd_soc_component *component,
46 int clk_id)
47 @@ -175,7 +176,10 @@ static int snd_rpi_hifiberry_dacplusadc_
48
49 snd_soc_component_update_bits(component, PCM512x_GPIO_EN, 0x08, 0x08);
50 snd_soc_component_update_bits(component, PCM512x_GPIO_OUTPUT_4, 0x0f, 0x02);
51 - snd_soc_component_update_bits(component, PCM512x_GPIO_CONTROL_1, 0x08, 0x08);
52 + if (leds_off)
53 + snd_soc_component_update_bits(component, PCM512x_GPIO_CONTROL_1, 0x08, 0x00);
54 + else
55 + snd_soc_component_update_bits(component, PCM512x_GPIO_CONTROL_1, 0x08, 0x08);
56
57 if (digital_gain_0db_limit) {
58 int ret;
59 @@ -254,6 +258,8 @@ static int snd_rpi_hifiberry_dacplusadc_
60 struct snd_soc_pcm_runtime *rtd = substream->private_data;
61 struct snd_soc_component *component = rtd->codec_dai->component;
62
63 + if (leds_off)
64 + return 0;
65 snd_soc_component_update_bits(component, PCM512x_GPIO_CONTROL_1,
66 0x08, 0x08);
67 hifiberry_dacplusadc_LED_cnt++;
68 @@ -330,6 +336,8 @@ static int snd_rpi_hifiberry_dacplusadc_
69 pdev->dev.of_node, "hifiberry,24db_digital_gain");
70 slave = of_property_read_bool(pdev->dev.of_node,
71 "hifiberry-dacplusadc,slave");
72 + leds_off = of_property_read_bool(pdev->dev.of_node,
73 + "hifiberry-dacplusadc,leds_off");
74
75 ret = devm_snd_soc_register_card(&pdev->dev,
76 &snd_rpi_hifiberry_dacplusadc);