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