summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Elwell <pelwell@users.noreply.github.com>2016-02-09 08:38:30 +0000
committerPhil Elwell <pelwell@users.noreply.github.com>2016-02-09 08:38:30 +0000
commit4b56db768587edc106eee2ec4a406fc66030e4b7 (patch)
tree85eb7a4d3725c3d3468b15e2ddec9ac86f1d436c
parente703af81a51cb207e32b63f900db3897d5c21ab6 (diff)
parent6efcd65886903c2ece1f819c3e95405a549fa789 (diff)
Merge pull request #1284 from DigitalDreamtimeLtd/rpi-4.1.y
rpi-4.1.y: Allow up to 24dB digital gain to be applied when using IQAudIO DAC+
-rw-r--r--arch/arm/boot/dts/overlays/README34
-rw-r--r--arch/arm/boot/dts/overlays/hifiberry-dacplus-overlay.dts6
-rw-r--r--arch/arm/boot/dts/overlays/iqaudio-dacplus-overlay.dts6
-rw-r--r--sound/soc/bcm/hifiberry_dacplus.c15
-rw-r--r--sound/soc/bcm/iqaudio-dac.c22
5 files changed, 70 insertions, 13 deletions
diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README
index b657512ecdc9..3f7a25d3edcb 100644
--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -252,8 +252,21 @@ Params: <None>
Name: hifiberry-dacplus
Info: Configures the HifiBerry DAC+ audio card
-Load: dtoverlay=hifiberry-dacplus
-Params: <None>
+Load: dtoverlay=hifiberry-dacplus,<param>=<val>
+Params: 24db_digital_gain Allow gain to be applied via the PCM512x codec
+ Digital volume control. Enable with
+ "dtoverlay=hifiberry-dacplus,24db_digital_gain"
+ (The default behaviour is that the Digital
+ volume control is limited to a maximum of
+ 0dB. ie. it can attenuate but not provide
+ gain. For most users, this will be desired
+ as it will prevent clipping. By appending
+ the 24dB_digital_gain parameter, the Digital
+ volume control will allow up to 24dB of
+ gain. If this parameter is enabled, it is the
+ responsibility of the user to ensure that
+ the Digital volume control is set to a value
+ that does not result in clipping/distortion!)
Name: hifiberry-digi
@@ -341,8 +354,21 @@ Params: <None>
Name: iqaudio-dacplus
Info: Configures the IQaudio DAC+ audio card
-Load: dtoverlay=iqaudio-dacplus
-Params: <None>
+Load: dtoverlay=iqaudio-dacplus,<param>=<val>
+Params: 24db_digital_gain Allow gain to be applied via the PCM512x codec
+ Digital volume control. Enable with
+ "dtoverlay=iqaudio-dacplus,24db_digital_gain"
+ (The default behaviour is that the Digital
+ volume control is limited to a maximum of
+ 0dB. ie. it can attenuate but not provide
+ gain. For most users, this will be desired
+ as it will prevent clipping. By appending
+ the 24db_digital_gain parameter, the Digital
+ volume control will allow up to 24dB of
+ gain. If this parameter is enabled, it is the
+ responsibility of the user to ensure that
+ the Digital volume control is set to a value
+ that does not result in clipping/distortion!)
Name: lirc-rpi
diff --git a/arch/arm/boot/dts/overlays/hifiberry-dacplus-overlay.dts b/arch/arm/boot/dts/overlays/hifiberry-dacplus-overlay.dts
index f923a48628d7..42a0194e97c0 100644
--- a/arch/arm/boot/dts/overlays/hifiberry-dacplus-overlay.dts
+++ b/arch/arm/boot/dts/overlays/hifiberry-dacplus-overlay.dts
@@ -17,7 +17,7 @@
fragment@1 {
target = <&sound>;
- __overlay__ {
+ frag1: __overlay__ {
compatible = "hifiberry,hifiberry-dacplus";
i2s-controller = <&i2s>;
status = "okay";
@@ -47,4 +47,8 @@
};
};
};
+
+ __overrides__ {
+ 24db_digital_gain = <&frag1>,"hifiberry,24db_digital_gain?";
+ };
};
diff --git a/arch/arm/boot/dts/overlays/iqaudio-dacplus-overlay.dts b/arch/arm/boot/dts/overlays/iqaudio-dacplus-overlay.dts
index 735d8abfccb2..e0aaf8f03349 100644
--- a/arch/arm/boot/dts/overlays/iqaudio-dacplus-overlay.dts
+++ b/arch/arm/boot/dts/overlays/iqaudio-dacplus-overlay.dts
@@ -7,7 +7,7 @@
fragment@0 {
target = <&sound>;
- __overlay__ {
+ frag0: __overlay__ {
compatible = "iqaudio,iqaudio-dac";
i2s-controller = <&i2s>;
status = "okay";
@@ -36,4 +36,8 @@
};
};
};
+
+ __overrides__ {
+ 24db_digital_gain = <&frag0>,"iqaudio,24db_digital_gain?";
+ };
};
diff --git a/sound/soc/bcm/hifiberry_dacplus.c b/sound/soc/bcm/hifiberry_dacplus.c
index a6b651cb608a..50b66a1d355e 100644
--- a/sound/soc/bcm/hifiberry_dacplus.c
+++ b/sound/soc/bcm/hifiberry_dacplus.c
@@ -48,6 +48,7 @@ struct pcm512x_priv {
#define CLK_48EN_RATE 24576000UL
static bool snd_rpi_hifiberry_is_dacpro;
+static bool digital_gain_0db_limit = true;
static void snd_rpi_hifiberry_dacplus_select_clk(struct snd_soc_codec *codec,
int clk_id)
@@ -167,6 +168,17 @@ static int snd_rpi_hifiberry_dacplus_init(struct snd_soc_pcm_runtime *rtd)
snd_soc_update_bits(codec, PCM512x_GPIO_OUTPUT_4, 0x0f, 0x02);
snd_soc_update_bits(codec, PCM512x_GPIO_CONTROL_1, 0x08, 0x08);
+ if (digital_gain_0db_limit)
+ {
+ int ret;
+ struct snd_soc_card *card = rtd->card;
+ struct snd_soc_codec *codec = rtd->codec;
+
+ ret = snd_soc_limit_volume(codec, "Digital Playback Volume", 207);
+ if (ret < 0)
+ dev_warn(card->dev, "Failed to set volume limit: %d\n", ret);
+ }
+
return 0;
}
@@ -299,6 +311,9 @@ static int snd_rpi_hifiberry_dacplus_probe(struct platform_device *pdev)
dai->platform_name = NULL;
dai->platform_of_node = i2s_node;
}
+
+ digital_gain_0db_limit = !of_property_read_bool(
+ pdev->dev.of_node, "hifiberry,24db_digital_gain");
}
ret = snd_soc_register_card(&snd_rpi_hifiberry_dacplus);
diff --git a/sound/soc/bcm/iqaudio-dac.c b/sound/soc/bcm/iqaudio-dac.c
index a38e8741f263..5ade0061ceb0 100644
--- a/sound/soc/bcm/iqaudio-dac.c
+++ b/sound/soc/bcm/iqaudio-dac.c
@@ -23,15 +23,20 @@
#include <sound/soc.h>
#include <sound/jack.h>
+static bool digital_gain_0db_limit = true;
+
static int snd_rpi_iqaudio_dac_init(struct snd_soc_pcm_runtime *rtd)
{
- int ret;
- struct snd_soc_card *card = rtd->card;
- struct snd_soc_codec *codec = rtd->codec;
-
- ret = snd_soc_limit_volume(codec, "Digital Playback Volume", 207);
- if (ret < 0)
- dev_warn(card->dev, "Failed to set volume limit: %d\n", ret);
+ if (digital_gain_0db_limit)
+ {
+ int ret;
+ struct snd_soc_card *card = rtd->card;
+ struct snd_soc_codec *codec = rtd->codec;
+
+ ret = snd_soc_limit_volume(codec, "Digital Playback Volume", 207);
+ if (ret < 0)
+ dev_warn(card->dev, "Failed to set volume limit: %d\n", ret);
+ }
return 0;
}
@@ -95,6 +100,9 @@ static int snd_rpi_iqaudio_dac_probe(struct platform_device *pdev)
dai->platform_name = NULL;
dai->platform_of_node = i2s_node;
}
+
+ digital_gain_0db_limit = !of_property_read_bool(pdev->dev.of_node,
+ "iqaudio,24db_digital_gain");
}
ret = snd_soc_register_card(&snd_rpi_iqaudio_dac);