mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ASoC: qcom: sm8250: Limit RX digital gain to 0 dB
@ 2026-10-27  1:33 Filippo Falezza
  2026-10-27 10:12 ` Prasad Kumpatla
  2026-10-27 12:49 ` Srinivas Kandagatla
  0 siblings, 2 replies; 3+ messages in thread
From: Filippo Falezza @ 2026-10-27  1:33 UTC (permalink / raw)
  To: Srinivas Kandagatla, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai
  Cc: linux-sound, linux-arm-msm, linux-kernel, Filippo Falezza

The RX macro interpolator gains ("RX_RXn Digital Volume") run from
-84 dB to +40 dB. PipeWire and PulseAudio map full volume to the top of
a hardware control's range, so a UCM device that uses one of them as
its volume control plays 40 dB hot at 100% and clips.

Set a platform limit of 84 (0 dB) on the RX0, RX1 and RX2 interpolator
gains when the RX codec DMA link is initialised, the way the sc8280xp
and x1e80100 machine drivers limit their WSA gains. 0 dB is the default
of these controls and the value alsa-ucm-conf's rx-macro init sets, so
existing configurations are unaffected. A control that does not exist
on a board is skipped.

Signed-off-by: Filippo Falezza <effeffe99@gmail.com>
---
Hello there,

this caps the RX macro's digital gains at 0 dB in the sm8250 machine
driver. I need it on a Motorola Moto G 5G Plus (SM7250), which I'm
bringing up on mainline: its UCM profile uses "RX_RX0 Digital Volume"
as the earpiece volume, so that the volume keys change a hardware gain
that also applies to the voice downlink, and without the cap 100% in
PipeWire was +40 dB and clipped badly.

This touches every board that uses this machine driver. As far as I can
see in alsa-ucm-conf, nothing sets these gains above 0 dB (rx-macro's
init.conf sets RX0 and RX1 to 84), so the only change for them is that
the controls no longer offer positive gain. If anyone relies on boosting
the headphone path digitally, a per-board limit would be the
alternative, and I'm happy to rework it that way.

Tested on the phone on top of next-20261021: the earpiece volume follows
the volume keys from silent to a clean 100%, in media playback and in
calls. The patch is on top of broonie/for-next (f3c7bee984aa) and builds
with W=1 for arm64.

I wrote this patch and drafted this note with the help of an AI coding
assistant (Claude Code). The testing above is on the phone.

Thanks,
Filippo
---
 sound/soc/qcom/sm8250.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/sound/soc/qcom/sm8250.c b/sound/soc/qcom/sm8250.c
index 5866f1f34b3d..d776a17f1fd3 100644
--- a/sound/soc/qcom/sm8250.c
+++ b/sound/soc/qcom/sm8250.c
@@ -39,6 +39,16 @@ static int sm8250_snd_init(struct snd_soc_pcm_runtime *rtd)
 	case USB_RX:
 		return qcom_snd_usb_offload_jack_setup(rtd, &data->usb_offload_jack,
 						       &data->usb_offload_jack_setup);
+	case RX_CODEC_DMA_RX_0:
+		/*
+		 * The RX macro digital gain goes up to +40 dB. Userspace that
+		 * maps full volume to the top of the range (PipeWire, PulseAudio)
+		 * would clip there, so stop the interpolator gains at 0 dB.
+		 */
+		snd_soc_limit_volume(rtd->card, "RX_RX0 Digital Volume", 84);
+		snd_soc_limit_volume(rtd->card, "RX_RX1 Digital Volume", 84);
+		snd_soc_limit_volume(rtd->card, "RX_RX2 Digital Volume", 84);
+		fallthrough;
 	default:
 		return qcom_snd_wcd_jack_setup(rtd, &data->jack, &data->jack_setup);
 	}

---
base-commit: f3c7bee984aa0ba2b48a44e16a6f3ec2c27f851e
change-id: 20261027-sm8250-rx-gain-70cba15f0c1e

Best regards,
--  
Filippo Falezza <effeffe99@gmail.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: qcom: sm8250: Limit RX digital gain to 0 dB
  2026-10-27  1:33 [PATCH] ASoC: qcom: sm8250: Limit RX digital gain to 0 dB Filippo Falezza
@ 2026-10-27 10:12 ` Prasad Kumpatla
  2026-10-27 12:49 ` Srinivas Kandagatla
  1 sibling, 0 replies; 3+ messages in thread
From: Prasad Kumpatla @ 2026-10-27 10:12 UTC (permalink / raw)
  To: Filippo Falezza, Srinivas Kandagatla, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai
  Cc: linux-sound, linux-arm-msm, linux-kernel


On 10/27/2026 7:03 AM, Filippo Falezza wrote:
> The RX macro interpolator gains ("RX_RXn Digital Volume") run from
> -84 dB to +40 dB. PipeWire and PulseAudio map full volume to the top of
> a hardware control's range, so a UCM device that uses one of them as
> its volume control plays 40 dB hot at 100% and clips.
>
> Set a platform limit of 84 (0 dB) on the RX0, RX1 and RX2 interpolator
> gains when the RX codec DMA link is initialised, the way the sc8280xp
> and x1e80100 machine drivers limit their WSA gains. 0 dB is the default
> of these controls and the value alsa-ucm-conf's rx-macro init sets, so
> existing configurations are unaffected. A control that does not exist
> on a board is skipped.
>
> Signed-off-by: Filippo Falezza <effeffe99@gmail.com>
> ---


LGTM.

Reviewed-by: Prasad Kumpatla<prasad.kumpatla@oss.qualcomm.com>

Thanks,
Prasad



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: qcom: sm8250: Limit RX digital gain to 0 dB
  2026-10-27  1:33 [PATCH] ASoC: qcom: sm8250: Limit RX digital gain to 0 dB Filippo Falezza
  2026-10-27 10:12 ` Prasad Kumpatla
@ 2026-10-27 12:49 ` Srinivas Kandagatla
  1 sibling, 0 replies; 3+ messages in thread
From: Srinivas Kandagatla @ 2026-10-27 12:49 UTC (permalink / raw)
  To: Filippo Falezza, Srinivas Kandagatla, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai
  Cc: linux-sound, linux-arm-msm, linux-kernel

On 10/27/26 1:33 AM, Filippo Falezza wrote:
> The RX macro interpolator gains ("RX_RXn Digital Volume") run from
> -84 dB to +40 dB. PipeWire and PulseAudio map full volume to the top of
> a hardware control's range, so a UCM device that uses one of them as
> its volume control plays 40 dB hot at 100% and clips.

The control range is 124 steps, its should map 124 as 100%, not zero.
> 
> Set a platform limit of 84 (0 dB) on the RX0, RX1 and RX2 interpolator
> gains when the RX codec DMA link is initialised, the way the sc8280xp
> and x1e80100 machine drivers limit their WSA gains. 0 dB is the default

The reason why we limit this in x1e80100 is due to missing speaker
protection. Is this the same reason why you want to limit this range?
If so please update that in the comment and commit log.

If not am still failing to understand why do you what to not want
1-124 steps mapped to 0-100% volume.

--srini

> of these controls and the value alsa-ucm-conf's rx-macro init sets, so
> existing configurations are unaffected. A control that does not exist
> on a board is skipped.
> 
> Signed-off-by: Filippo Falezza <effeffe99@gmail.com>
> ---
> Hello there,
> 
> this caps the RX macro's digital gains at 0 dB in the sm8250 machine
> driver. I need it on a Motorola Moto G 5G Plus (SM7250), which I'm
> bringing up on mainline: its UCM profile uses "RX_RX0 Digital Volume"
> as the earpiece volume, so that the volume keys change a hardware gain
> that also applies to the voice downlink, and without the cap 100% in
> PipeWire was +40 dB and clipped badly.
> 
> This touches every board that uses this machine driver. As far as I can
> see in alsa-ucm-conf, nothing sets these gains above 0 dB (rx-macro's
> init.conf sets RX0 and RX1 to 84), so the only change for them is that
> the controls no longer offer positive gain. If anyone relies on boosting
> the headphone path digitally, a per-board limit would be the
> alternative, and I'm happy to rework it that way.
> 
> Tested on the phone on top of next-20261021: the earpiece volume follows
> the volume keys from silent to a clean 100%, in media playback and in
> calls. The patch is on top of broonie/for-next (f3c7bee984aa) and builds
> with W=1 for arm64.
> 
> I wrote this patch and drafted this note with the help of an AI coding
> assistant (Claude Code). The testing above is on the phone.
> 
> Thanks,
> Filippo
> ---
>  sound/soc/qcom/sm8250.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/sound/soc/qcom/sm8250.c b/sound/soc/qcom/sm8250.c
> index 5866f1f34b3d..d776a17f1fd3 100644
> --- a/sound/soc/qcom/sm8250.c
> +++ b/sound/soc/qcom/sm8250.c
> @@ -39,6 +39,16 @@ static int sm8250_snd_init(struct snd_soc_pcm_runtime *rtd)
>  	case USB_RX:
>  		return qcom_snd_usb_offload_jack_setup(rtd, &data->usb_offload_jack,
>  						       &data->usb_offload_jack_setup);
> +	case RX_CODEC_DMA_RX_0:
> +		/*
> +		 * The RX macro digital gain goes up to +40 dB. Userspace that
> +		 * maps full volume to the top of the range (PipeWire, PulseAudio)
> +		 * would clip there, so stop the interpolator gains at 0 dB.
> +		 */
> +		snd_soc_limit_volume(rtd->card, "RX_RX0 Digital Volume", 84);
> +		snd_soc_limit_volume(rtd->card, "RX_RX1 Digital Volume", 84);
> +		snd_soc_limit_volume(rtd->card, "RX_RX2 Digital Volume", 84);
> +		fallthrough;
>  	default:
>  		return qcom_snd_wcd_jack_setup(rtd, &data->jack, &data->jack_setup);
>  	}
> 
> ---
> base-commit: f3c7bee984aa0ba2b48a44e16a6f3ec2c27f851e
> change-id: 20261027-sm8250-rx-gain-70cba15f0c1e
> 
> Best regards,
> --  
> Filippo Falezza <effeffe99@gmail.com>
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-27 12:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-27  1:33 [PATCH] ASoC: qcom: sm8250: Limit RX digital gain to 0 dB Filippo Falezza
2026-10-27 10:12 ` Prasad Kumpatla
2026-10-27 12:49 ` Srinivas Kandagatla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®