diff mbox series

[v3,2/5] ASoC: codecs: wsa883x: lower default PA gain

Message ID 20240118165811.13672-3-johan+linaro@kernel.org (mailing list archive)
State Superseded
Headers show
Series ASoC: qcom: volume fixes and codec cleanups | expand

Commit Message

Johan Hovold Jan. 18, 2024, 4:58 p.m. UTC
The default PA gain is set to a pretty high level of 15 dB. Initialise
the register to the minimum -3 dB level instead.

This is specifically needed to allow machine drivers to use the lowest
level as a volume limit.

Cc: stable@vger.kernel.org      # 6.5
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 sound/soc/codecs/wsa883x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mark Brown Jan. 18, 2024, 5:21 p.m. UTC | #1
On Thu, Jan 18, 2024 at 05:58:08PM +0100, Johan Hovold wrote:
> The default PA gain is set to a pretty high level of 15 dB. Initialise
> the register to the minimum -3 dB level instead.
> 
> This is specifically needed to allow machine drivers to use the lowest
> level as a volume limit.

> @@ -722,7 +722,7 @@ static struct reg_default wsa883x_defaults[] = {
>  	{ WSA883X_WAVG_PER_6_7, 0x88 },
>  	{ WSA883X_WAVG_STA, 0x00 },
>  	{ WSA883X_DRE_CTL_0, 0x70 },
> -	{ WSA883X_DRE_CTL_1, 0x08 },
> +	{ WSA883X_DRE_CTL_1, 0x1e },

This is broken, the register defaults provided to regmap need to
correspond to whatever the hardware default is since for example a
register cache sync will not write back any default values (as they
should already be there in the hardware).  Anything like this would need
to be done by writes during init.
Srinivas Kandagatla Jan. 19, 2024, 7:15 a.m. UTC | #2
On 18/01/2024 16:58, Johan Hovold wrote:
> The default PA gain is set to a pretty high level of 15 dB. Initialise
> the register to the minimum -3 dB level instead.
> 
> This is specifically needed to allow machine drivers to use the lowest
> level as a volume limit.
> 
> Cc: stable@vger.kernel.org      # 6.5
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> ---
>   sound/soc/codecs/wsa883x.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/soc/codecs/wsa883x.c b/sound/soc/codecs/wsa883x.c
> index 32983ca9afba..8942c88dee09 100644
> --- a/sound/soc/codecs/wsa883x.c
> +++ b/sound/soc/codecs/wsa883x.c
> @@ -722,7 +722,7 @@ static struct reg_default wsa883x_defaults[] = {
>   	{ WSA883X_WAVG_PER_6_7, 0x88 },
>   	{ WSA883X_WAVG_STA, 0x00 },
>   	{ WSA883X_DRE_CTL_0, 0x70 },
> -	{ WSA883X_DRE_CTL_1, 0x08 },

this is hw default value.

> +	{ WSA883X_DRE_CTL_1, 0x1e },
>   	{ WSA883X_DRE_IDLE_DET_CTL, 0x1F },
>   	{ WSA883X_CLSH_CTL_0, 0x37 },
>   	{ WSA883X_CLSH_CTL_1, 0x81 },
Johan Hovold Jan. 19, 2024, 7:57 a.m. UTC | #3
On Thu, Jan 18, 2024 at 05:21:48PM +0000, Mark Brown wrote:
> On Thu, Jan 18, 2024 at 05:58:08PM +0100, Johan Hovold wrote:
> > The default PA gain is set to a pretty high level of 15 dB. Initialise
> > the register to the minimum -3 dB level instead.
> > 
> > This is specifically needed to allow machine drivers to use the lowest
> > level as a volume limit.
> 
> > @@ -722,7 +722,7 @@ static struct reg_default wsa883x_defaults[] = {
> >  	{ WSA883X_WAVG_PER_6_7, 0x88 },
> >  	{ WSA883X_WAVG_STA, 0x00 },
> >  	{ WSA883X_DRE_CTL_0, 0x70 },
> > -	{ WSA883X_DRE_CTL_1, 0x08 },
> > +	{ WSA883X_DRE_CTL_1, 0x1e },
> 
> This is broken, the register defaults provided to regmap need to
> correspond to whatever the hardware default is since for example a
> register cache sync will not write back any default values (as they
> should already be there in the hardware).  Anything like this would need
> to be done by writes during init.

Bah, thanks for catching that. For some reason this was enough to have
the driver initialise the register at boot at least. I'll set it
explicitly at probe instead.

Johan
Johan Hovold Jan. 19, 2024, 8 a.m. UTC | #4
On Fri, Jan 19, 2024 at 07:15:33AM +0000, Srinivas Kandagatla wrote:
> 
> 
> On 18/01/2024 16:58, Johan Hovold wrote:
> > The default PA gain is set to a pretty high level of 15 dB. Initialise
> > the register to the minimum -3 dB level instead.
> > 
> > This is specifically needed to allow machine drivers to use the lowest
> > level as a volume limit.
> > 
> > Cc: stable@vger.kernel.org      # 6.5
> > Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> > ---
> >   sound/soc/codecs/wsa883x.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/sound/soc/codecs/wsa883x.c b/sound/soc/codecs/wsa883x.c
> > index 32983ca9afba..8942c88dee09 100644
> > --- a/sound/soc/codecs/wsa883x.c
> > +++ b/sound/soc/codecs/wsa883x.c
> > @@ -722,7 +722,7 @@ static struct reg_default wsa883x_defaults[] = {
> >   	{ WSA883X_WAVG_PER_6_7, 0x88 },
> >   	{ WSA883X_WAVG_STA, 0x00 },
> >   	{ WSA883X_DRE_CTL_0, 0x70 },
> > -	{ WSA883X_DRE_CTL_1, 0x08 },
> 
> this is hw default value.

Indeed. This was a last minute change when I noticed I could actually
set the lowest limit in the machine driver after I offset it, but then
the reset value was never updated. Didn't think this through.

> > +	{ WSA883X_DRE_CTL_1, 0x1e },
> >   	{ WSA883X_DRE_IDLE_DET_CTL, 0x1F },
> >   	{ WSA883X_CLSH_CTL_0, 0x37 },
> >   	{ WSA883X_CLSH_CTL_1, 0x81 },

Johan
diff mbox series

Patch

diff --git a/sound/soc/codecs/wsa883x.c b/sound/soc/codecs/wsa883x.c
index 32983ca9afba..8942c88dee09 100644
--- a/sound/soc/codecs/wsa883x.c
+++ b/sound/soc/codecs/wsa883x.c
@@ -722,7 +722,7 @@  static struct reg_default wsa883x_defaults[] = {
 	{ WSA883X_WAVG_PER_6_7, 0x88 },
 	{ WSA883X_WAVG_STA, 0x00 },
 	{ WSA883X_DRE_CTL_0, 0x70 },
-	{ WSA883X_DRE_CTL_1, 0x08 },
+	{ WSA883X_DRE_CTL_1, 0x1e },
 	{ WSA883X_DRE_IDLE_DET_CTL, 0x1F },
 	{ WSA883X_CLSH_CTL_0, 0x37 },
 	{ WSA883X_CLSH_CTL_1, 0x81 },