brcm2708: switch to linux 4.4 and update patches
[openwrt.git] / target / linux / brcm2708 / patches-4.4 / 0143-Allow-up-to-24dB-digital-gain-to-be-applied-when-usi.patch
1 From e7fc348fed61518907205603a7d0d6038cecfa1f Mon Sep 17 00:00:00 2001
2 From: Digital Dreamtime <clive.messer@digitaldreamtime.co.uk>
3 Date: Thu, 4 Feb 2016 14:14:44 +0000
4 Subject: [PATCH 143/156] Allow up to 24dB digital gain to be applied when
5  using IQAudIO DAC+
6
7 24db_digital_gain DT param can be used to specify that PCM512x
8 codec "Digital" volume control should not be limited to 0dB gain,
9 and if specified will allow the full 24dB gain.
10 ---
11  arch/arm/boot/dts/overlays/README                    | 17 +++++++++++++++--
12  .../boot/dts/overlays/iqaudio-dacplus-overlay.dts    |  6 +++++-
13  sound/soc/bcm/iqaudio-dac.c                          | 20 ++++++++++++++------
14  3 files changed, 34 insertions(+), 9 deletions(-)
15
16 --- a/arch/arm/boot/dts/overlays/README
17 +++ b/arch/arm/boot/dts/overlays/README
18 @@ -362,8 +362,21 @@ Params: <None>
19  
20  Name:   iqaudio-dacplus
21  Info:   Configures the IQaudio DAC+ audio card
22 -Load:   dtoverlay=iqaudio-dacplus
23 -Params: <None>
24 +Load:   dtoverlay=iqaudio-dacplus,<param>=<val>
25 +Params: 24db_digital_gain       Allow gain to be applied via the PCM512x codec
26 +                                Digital volume control. Enable with
27 +                                "dtoverlay=iqaudio-dacplus,24db_digital_gain"
28 +                                (The default behaviour is that the Digital
29 +                                volume control is limited to a maximum of
30 +                                0dB. ie. it can attenuate but not provide
31 +                                gain. For most users, this will be desired
32 +                                as it will prevent clipping. By appending
33 +                                the 24db_digital_gain parameter, the Digital
34 +                                volume control will allow up to 24dB of
35 +                                gain. If this parameter is enabled, it is the
36 +                                responsibility of the user to ensure that
37 +                                the Digital volume control is set to a value
38 +                                that does not result in clipping/distortion!)
39  
40  
41  Name:   lirc-rpi
42 --- a/arch/arm/boot/dts/overlays/iqaudio-dacplus-overlay.dts
43 +++ b/arch/arm/boot/dts/overlays/iqaudio-dacplus-overlay.dts
44 @@ -7,7 +7,7 @@
45  
46         fragment@0 {
47                 target = <&sound>;
48 -               __overlay__ {
49 +               frag0: __overlay__ {
50                         compatible = "iqaudio,iqaudio-dac";
51                         i2s-controller = <&i2s>;
52                         status = "okay";
53 @@ -36,4 +36,8 @@
54                         };
55                 };
56         };
57 +
58 +       __overrides__ {
59 +               24db_digital_gain = <&frag0>,"iqaudio,24db_digital_gain?";
60 +       };
61  };
62 --- a/sound/soc/bcm/iqaudio-dac.c
63 +++ b/sound/soc/bcm/iqaudio-dac.c
64 @@ -23,14 +23,19 @@
65  #include <sound/soc.h>
66  #include <sound/jack.h>
67  
68 +static bool digital_gain_0db_limit = true;
69 +
70  static int snd_rpi_iqaudio_dac_init(struct snd_soc_pcm_runtime *rtd)
71  {
72 -       int ret;
73 -       struct snd_soc_card *card = rtd->card;
74 -
75 -       ret = snd_soc_limit_volume(card, "Digital Playback Volume", 207);
76 -       if (ret < 0)
77 -               dev_warn(card->dev, "Failed to set volume limit: %d\n", ret);
78 +       if (digital_gain_0db_limit)
79 +       {
80 +               int ret;
81 +               struct snd_soc_card *card = rtd->card;
82 +
83 +               ret = snd_soc_limit_volume(card, "Digital Playback Volume", 207);
84 +               if (ret < 0)
85 +                       dev_warn(card->dev, "Failed to set volume limit: %d\n", ret);
86 +       }
87  
88         return 0;
89  }
90 @@ -94,6 +99,9 @@ static int snd_rpi_iqaudio_dac_probe(str
91                 dai->platform_name = NULL;
92                 dai->platform_of_node = i2s_node;
93             }
94 +
95 +           digital_gain_0db_limit = !of_property_read_bool(pdev->dev.of_node,
96 +                                       "iqaudio,24db_digital_gain");
97         }
98  
99         ret = snd_soc_register_card(&snd_rpi_iqaudio_dac);