Skip to content

Commit

Permalink
Allow up to 24dB digital gain to be applied when using IQAudIO DAC+
Browse files Browse the repository at this point in the history
24db_digital_gain DT param can be used to specify that PCM512x
codec "Digital" volume control should not be limited to 0dB gain,
and if specified will allow the full 24dB gain.
  • Loading branch information
DigitalDreamtime committed Feb 7, 2016
1 parent 9c1adcc commit e596bba
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
17 changes: 15 additions & 2 deletions arch/arm/boot/dts/overlays/README
Expand Up @@ -362,8 +362,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
Expand Down
6 changes: 5 additions & 1 deletion arch/arm/boot/dts/overlays/iqaudio-dacplus-overlay.dts
Expand Up @@ -7,7 +7,7 @@

fragment@0 {
target = <&sound>;
__overlay__ {
frag0: __overlay__ {
compatible = "iqaudio,iqaudio-dac";
i2s-controller = <&i2s>;
status = "okay";
Expand Down Expand Up @@ -36,4 +36,8 @@
};
};
};

__overrides__ {
24db_digital_gain = <&frag0>,"iqaudio,24db_digital_gain?";
};
};
20 changes: 14 additions & 6 deletions sound/soc/bcm/iqaudio-dac.c
Expand Up @@ -23,14 +23,19 @@
#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;

ret = snd_soc_limit_volume(card, "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;

ret = snd_soc_limit_volume(card, "Digital Playback Volume", 207);
if (ret < 0)
dev_warn(card->dev, "Failed to set volume limit: %d\n", ret);
}

return 0;
}
Expand Down Expand Up @@ -94,6 +99,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);
Expand Down

0 comments on commit e596bba

Please sign in to comment.