Re: [PATCH] ASoC: codecs: wcd938x: fix dB range for HPHL and HPHR

From: Takashi Iwai
Date: Mon Jul 10 2023 - 04:20:29 EST


On Fri, 07 Jul 2023 17:06:24 +0200,
Mark Brown wrote:
>
> On Fri, Jul 07, 2023 at 03:47:47PM +0200, Takashi Iwai wrote:
> > Mark Brown wrote:
>
> > > The ASoC generic control stuff supports inverting the value prior to
> > > presentation to userspace so it's masked there (instead of writing the
> > > number userspace sees to the register we subtract the number from the
> > > maximum value and write that to the register), pulling that up further
> > > to the ALSA core might be nice I guess?
>
> > I believe yes. Though, I'm still not sure how we can improve the
> > mismatch of dB min/max. The dB values of those inverted controls
> > reflect the result of subtraction, no?
>
> Yes, the dB scale presented to userspace is reversed relative to the
> ordering in the registers.

Right, the TLV min/max corresponds to the control values, and they
don't mean the raw register values.

BTW, this thread made me wonder whether it makes sense to give some
sanity checks (maybe with CONFIG_SND_DEBUG) in ALSA core.
e.g. read_tlv_buf() in sound/core/control.c can perform some tests
before actually passing to user-space.


Takashi