ar71xx/image: introduce LOADER_TYPE to support elf loaders
[openwrt.git] / target / linux / brcm2708 / patches-4.4 / 0144-Limit-PCM512x-Digital-gain-to-0dB-by-default-with-Hi.patch
1 From 8a189f18de820c6facd00ba2db97ba7c4a75156f Mon Sep 17 00:00:00 2001
2 From: Digital Dreamtime <clive.messer@digitaldreamtime.co.uk>
3 Date: Thu, 4 Feb 2016 20:04:00 +0000
4 Subject: [PATCH 144/170] Limit PCM512x "Digital" gain to 0dB by default with
5  HiFiBerry 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  .../arm/boot/dts/overlays/hifiberry-dacplus-overlay.dts |  6 +++++-
13  sound/soc/bcm/hifiberry_dacplus.c                       | 14 ++++++++++++++
14  3 files changed, 34 insertions(+), 3 deletions(-)
15
16 --- a/arch/arm/boot/dts/overlays/README
17 +++ b/arch/arm/boot/dts/overlays/README
18 @@ -273,8 +273,21 @@ Params: <None>
19  
20  Name:   hifiberry-dacplus
21  Info:   Configures the HifiBerry DAC+ audio card
22 -Load:   dtoverlay=hifiberry-dacplus
23 -Params: <None>
24 +Load:   dtoverlay=hifiberry-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=hifiberry-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:   hifiberry-digi
42 --- a/arch/arm/boot/dts/overlays/hifiberry-dacplus-overlay.dts
43 +++ b/arch/arm/boot/dts/overlays/hifiberry-dacplus-overlay.dts
44 @@ -17,7 +17,7 @@
45  
46         fragment@1 {
47                 target = <&sound>;
48 -               __overlay__ {
49 +               frag1: __overlay__ {
50                         compatible = "hifiberry,hifiberry-dacplus";
51                         i2s-controller = <&i2s>;
52                         status = "okay";
53 @@ -47,4 +47,8 @@
54                         };
55                 };
56         };
57 +
58 +       __overrides__ {
59 +               24db_digital_gain = <&frag1>,"hifiberry,24db_digital_gain?";
60 +       };
61  };
62 --- a/sound/soc/bcm/hifiberry_dacplus.c
63 +++ b/sound/soc/bcm/hifiberry_dacplus.c
64 @@ -48,6 +48,7 @@ struct pcm512x_priv {
65  #define CLK_48EN_RATE 24576000UL
66  
67  static bool snd_rpi_hifiberry_is_dacpro;
68 +static bool digital_gain_0db_limit = true;
69  
70  static void snd_rpi_hifiberry_dacplus_select_clk(struct snd_soc_codec *codec,
71         int clk_id)
72 @@ -167,6 +168,16 @@ static int snd_rpi_hifiberry_dacplus_ini
73         snd_soc_update_bits(codec, PCM512x_GPIO_OUTPUT_4, 0x0f, 0x02);
74         snd_soc_update_bits(codec, PCM512x_GPIO_CONTROL_1, 0x08, 0x08);
75  
76 +       if (digital_gain_0db_limit)
77 +       {
78 +               int ret;
79 +               struct snd_soc_card *card = rtd->card;
80 +
81 +               ret = snd_soc_limit_volume(card, "Digital Playback Volume", 207);
82 +               if (ret < 0)
83 +                       dev_warn(card->dev, "Failed to set volume limit: %d\n", ret);
84 +       }
85 +
86         return 0;
87  }
88  
89 @@ -299,6 +310,9 @@ static int snd_rpi_hifiberry_dacplus_pro
90                         dai->platform_name = NULL;
91                         dai->platform_of_node = i2s_node;
92                 }
93 +
94 +               digital_gain_0db_limit = !of_property_read_bool(
95 +                       pdev->dev.of_node, "hifiberry,24db_digital_gain");
96         }
97  
98         ret = snd_soc_register_card(&snd_rpi_hifiberry_dacplus);