Skip to content

Commit

Permalink
ASoC: allo-piano-dac-plus: Fix volume limiting
Browse files Browse the repository at this point in the history
Controls which only exist when snd_soc_register_card returns can't be
modified before then. Move the setting of volume limits to just before
the end of the probe function.

Link: #6527

Signed-off-by: Phil Elwell <[email protected]>
  • Loading branch information
pelwell committed Jan 9, 2025
1 parent cd47d5c commit 9147c0b
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions sound/soc/bcm/allo-piano-dac-plus.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,18 +734,6 @@ static int snd_allo_piano_dac_init(struct snd_soc_pcm_runtime *rtd)
if (digital_gain_0db_limit) {
int ret;

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

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

//Set volume limit on both dacs
for (i = 0; i < ARRAY_SIZE(codec_ctl_pfx); i++) {
char cname[256];
Expand Down Expand Up @@ -1000,6 +988,20 @@ static int snd_allo_piano_dac_probe(struct platform_device *pdev)
if (ret < 0)
return dev_err_probe(&pdev->dev, ret, "snd_soc_register_card() failed\n");

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

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

if ((mute_gpio[0]) && (mute_gpio[1]))
snd_allo_piano_gpio_mute(&snd_allo_piano_dac);

Expand Down

0 comments on commit 9147c0b

Please sign in to comment.