1 From 3bb2e01fd397f375e54f6fe8a33af25aef1c981f 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 140/381] Allow up to 24dB digital gain to be applied when
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.
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(-)
16 --- a/arch/arm/boot/dts/overlays/README
17 +++ b/arch/arm/boot/dts/overlays/README
18 @@ -362,8 +362,21 @@ Params: <None>
21 Info: Configures the IQaudio DAC+ audio card
22 -Load: dtoverlay=iqaudio-dacplus
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!)
42 --- a/arch/arm/boot/dts/overlays/iqaudio-dacplus-overlay.dts
43 +++ b/arch/arm/boot/dts/overlays/iqaudio-dacplus-overlay.dts
49 + frag0: __overlay__ {
50 compatible = "iqaudio,iqaudio-dac";
51 i2s-controller = <&i2s>;
59 + 24db_digital_gain = <&frag0>,"iqaudio,24db_digital_gain?";
62 --- a/sound/soc/bcm/iqaudio-dac.c
63 +++ b/sound/soc/bcm/iqaudio-dac.c
65 #include <sound/soc.h>
66 #include <sound/jack.h>
68 +static bool digital_gain_0db_limit = true;
70 static int snd_rpi_iqaudio_dac_init(struct snd_soc_pcm_runtime *rtd)
73 - struct snd_soc_card *card = rtd->card;
75 - ret = snd_soc_limit_volume(card, "Digital Playback Volume", 207);
77 - dev_warn(card->dev, "Failed to set volume limit: %d\n", ret);
78 + if (digital_gain_0db_limit)
81 + struct snd_soc_card *card = rtd->card;
83 + ret = snd_soc_limit_volume(card, "Digital Playback Volume", 207);
85 + dev_warn(card->dev, "Failed to set volume limit: %d\n", ret);
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;
95 + digital_gain_0db_limit = !of_property_read_bool(pdev->dev.of_node,
96 + "iqaudio,24db_digital_gain");
99 ret = snd_soc_register_card(&snd_rpi_iqaudio_dac);