233e368737a71abc8892607d79abfa495ba5bf0b
[openwrt/staging/aparcar.git] /
1 From c23190019110e3314041f2184552a8343de55117 Mon Sep 17 00:00:00 2001
2 From: j-schambacher <joerg@i2audio.com>
3 Date: Mon, 27 Jan 2020 17:45:51 +0100
4 Subject: [PATCH] adds LED OFF feature to HiFiBerry DAC+ADC PRO sound
5 card
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 .../overlays/hifiberry-dacplusadcpro-overlay.dts | 1 +
15 sound/soc/bcm/hifiberry_dacplusadcpro.c | 15 +++++++++++++--
16 3 files changed, 16 insertions(+), 2 deletions(-)
17
18 --- a/arch/arm/boot/dts/overlays/README
19 +++ b/arch/arm/boot/dts/overlays/README
20 @@ -948,6 +948,8 @@ Params: 24db_digital_gain Allow ga
21 that does not result in clipping/distortion!)
22 slave Force DAC+ADC 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-dacplusdsp
29 --- a/arch/arm/boot/dts/overlays/hifiberry-dacplusadcpro-overlay.dts
30 +++ b/arch/arm/boot/dts/overlays/hifiberry-dacplusadcpro-overlay.dts
31 @@ -60,5 +60,6 @@
32 24db_digital_gain =
33 <&hifiberry_dacplusadcpro>,"hifiberry-dacplusadcpro,24db_digital_gain?";
34 slave = <&hifiberry_dacplusadcpro>,"hifiberry-dacplusadcpro,slave?";
35 + leds_off = <&hifiberry_dacplusadcpro>,"hifiberry-dacplusadcpro,leds_off?";
36 };
37 };
38 --- a/sound/soc/bcm/hifiberry_dacplusadcpro.c
39 +++ b/sound/soc/bcm/hifiberry_dacplusadcpro.c
40 @@ -54,6 +54,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 const unsigned int pcm186x_adc_input_channel_sel_value[] = {
47 0x00, 0x01, 0x02, 0x03, 0x10
48 @@ -321,7 +322,10 @@ static int snd_rpi_hifiberry_dacplusadcp
49
50 snd_soc_component_update_bits(dac, PCM512x_GPIO_EN, 0x08, 0x08);
51 snd_soc_component_update_bits(dac, PCM512x_GPIO_OUTPUT_4, 0x0f, 0x02);
52 - snd_soc_component_update_bits(dac, PCM512x_GPIO_CONTROL_1, 0x08, 0x08);
53 + if (leds_off)
54 + snd_soc_component_update_bits(dac, PCM512x_GPIO_CONTROL_1, 0x08, 0x00);
55 + else
56 + snd_soc_component_update_bits(dac, PCM512x_GPIO_CONTROL_1, 0x08, 0x08);
57
58 ret = pcm1863_add_controls(adc);
59 if (ret < 0)
60 @@ -331,7 +335,10 @@ static int snd_rpi_hifiberry_dacplusadcp
61 /* set GPIO2 to output, GPIO3 input */
62 snd_soc_component_write(adc, PCM186X_GPIO3_2_CTRL, 0x00);
63 snd_soc_component_write(adc, PCM186X_GPIO3_2_DIR_CTRL, 0x04);
64 - snd_soc_component_update_bits(adc, PCM186X_GPIO_IN_OUT, 0x40, 0x40);
65 + if (leds_off)
66 + snd_soc_component_update_bits(adc, PCM186X_GPIO_IN_OUT, 0x40, 0x00);
67 + else
68 + snd_soc_component_update_bits(adc, PCM186X_GPIO_IN_OUT, 0x40, 0x40);
69
70 if (digital_gain_0db_limit) {
71 int ret;
72 @@ -417,6 +424,8 @@ static int snd_rpi_hifiberry_dacplusadcp
73 struct snd_soc_component *dac = rtd->codec_dais[0]->component;
74 struct snd_soc_component *adc = rtd->codec_dais[1]->component;
75
76 + if (leds_off)
77 + return 0;
78 /* switch on respective LED */
79 if (!substream->stream)
80 snd_soc_component_update_bits(dac, PCM512x_GPIO_CONTROL_1, 0x08, 0x08);
81 @@ -508,6 +517,8 @@ static int snd_rpi_hifiberry_dacplusadcp
82 pdev->dev.of_node, "hifiberry-dacplusadcpro,24db_digital_gain");
83 slave = of_property_read_bool(pdev->dev.of_node,
84 "hifiberry-dacplusadcpro,slave");
85 + leds_off = of_property_read_bool(pdev->dev.of_node,
86 + "hifiberry-dacplusadcpro,leds_off");
87 ret = snd_soc_register_card(&snd_rpi_hifiberry_dacplusadcpro);
88 if (ret && ret != -EPROBE_DEFER)
89 dev_err(&pdev->dev,