From 15b1ff559bb5e1f7155893054b286766d4fd6d04 Mon Sep 17 00:00:00 2001 From: alessandromrc <66976091+alessandromrc@users.noreply.github.com> Date: Tue, 26 Mar 2024 20:04:28 +0100 Subject: [PATCH 1/3] allo-boss-dac mute output when changing parameters Since I noticed that sometimes changing sample rates causes some digital quirks and noises, I've changed the function to mute the output before performing the changes and then unmute it when an error occurs or the parameters got set. Signed-off-by: Alessandro Marcon --- sound/soc/bcm/allo-boss-dac.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/sound/soc/bcm/allo-boss-dac.c b/sound/soc/bcm/allo-boss-dac.c index a9135badffd4c5..4e0604b2b8813a 100644 --- a/sound/soc/bcm/allo-boss-dac.c +++ b/sound/soc/bcm/allo-boss-dac.c @@ -275,23 +275,38 @@ static int snd_allo_boss_hw_params( struct snd_soc_pcm_runtime *rtd = substream->private_data; int channels = params_channels(params); int width = snd_pcm_format_width(params_format(params)); + struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; + struct snd_soc_card *card = rtd->card; - if (snd_soc_allo_boss_master) { - struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; + /* Mute before changing sample rate */ + snd_allo_boss_gpio_mute(card); - snd_allo_boss_set_sclk(component, - params_rate(params)); + if (snd_soc_allo_boss_master) { + snd_allo_boss_set_sclk(component, params_rate(params)); - ret = snd_allo_boss_update_rate_den( - substream, params); - if (ret) - return ret; + ret = snd_allo_boss_update_rate_den(substream, params); + + if (ret) { + goto error; + } } ret = snd_soc_dai_set_bclk_ratio(asoc_rtd_to_cpu(rtd, 0), channels * width); - if (ret) - return ret; + + if (ret) { + goto error; + } + ret = snd_soc_dai_set_bclk_ratio(asoc_rtd_to_codec(rtd, 0), channels * width); + + if (ret) { + goto error; + } + + /* Unmute after setting parameters or having an error */ +error: + snd_allo_boss_gpio_unmute(card); + return ret; } From 1b90a2e6d74f4a7268cfafe1617ef13cdf643076 Mon Sep 17 00:00:00 2001 From: alessandromrc <66976091+alessandromrc@users.noreply.github.com> Date: Tue, 26 Mar 2024 21:48:54 +0100 Subject: [PATCH 2/3] Correct if statement brackets and remove whitespace --- sound/soc/bcm/allo-boss-dac.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sound/soc/bcm/allo-boss-dac.c b/sound/soc/bcm/allo-boss-dac.c index 4e0604b2b8813a..42c0a57a1a1dde 100644 --- a/sound/soc/bcm/allo-boss-dac.c +++ b/sound/soc/bcm/allo-boss-dac.c @@ -285,23 +285,19 @@ static int snd_allo_boss_hw_params( snd_allo_boss_set_sclk(component, params_rate(params)); ret = snd_allo_boss_update_rate_den(substream, params); - - if (ret) { + if (ret) goto error; - } } ret = snd_soc_dai_set_bclk_ratio(asoc_rtd_to_cpu(rtd, 0), channels * width); - if (ret) { + if (ret) goto error; - } ret = snd_soc_dai_set_bclk_ratio(asoc_rtd_to_codec(rtd, 0), channels * width); - if (ret) { + if (ret) goto error; - } /* Unmute after setting parameters or having an error */ error: From 5221e4310f3a45dc108c3563d53884f98e71d91c Mon Sep 17 00:00:00 2001 From: alessandromrc <66976091+alessandromrc@users.noreply.github.com> Date: Tue, 26 Mar 2024 22:27:13 +0100 Subject: [PATCH 3/3] Remove whitespace Remove useless trailing whitespace on if statement. Signed-off-by: alessandromrc <66976091+alessandromrc@users.noreply.github.com>' --- sound/soc/bcm/allo-boss-dac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/bcm/allo-boss-dac.c b/sound/soc/bcm/allo-boss-dac.c index 42c0a57a1a1dde..cd817730ab404d 100644 --- a/sound/soc/bcm/allo-boss-dac.c +++ b/sound/soc/bcm/allo-boss-dac.c @@ -285,7 +285,7 @@ static int snd_allo_boss_hw_params( snd_allo_boss_set_sclk(component, params_rate(params)); ret = snd_allo_boss_update_rate_den(substream, params); - if (ret) + if (ret) goto error; }