mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
To: Filippo Falezza <effeffe99@gmail.com>,
	Srinivas Kandagatla <srini@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>
Cc: linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ASoC: qcom: sm8250: Limit RX digital gain to 0 dB
Date: Tue, 27 Oct 2026 12:49:04 +0000	[thread overview]
Message-ID: <8742f177-07c7-4090-a94e-61c7b7140110@oss.qualcomm.com> (raw)
In-Reply-To: <20261027-sm8250-rx-gain-v1-1-386ee6d971db@gmail.com>

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>
> 
> 


      parent reply	other threads:[~2026-10-27 12:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27  1:33 Filippo Falezza
2026-10-27 10:12 ` Prasad Kumpatla
2026-10-27 12:49 ` Srinivas Kandagatla [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8742f177-07c7-4090-a94e-61c7b7140110@oss.qualcomm.com \
    --to=srinivas.kandagatla@oss.qualcomm.com \
    --cc=broonie@kernel.org \
    --cc=effeffe99@gmail.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=srini@kernel.org \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®