[alsa-devel] Mixer volume/decibel mapping

Peter Ujfalusi peter.ujfalusi at nokia.com
Fri May 21 08:51:36 CEST 2010


Hi,

On Friday 21 May 2010 09:35:31 ext Clemens Ladisch wrote:
> James Courtier-Dutton wrote:
> > I believe it could be extended to support a continuous range.
> > For example, some hardware uses a 32bit value to control the gain.
> > The mix operation is simply "the_sample" * "the_control_value".
> > So in this case the hardware has a linear control that can be
> > considered continuous for our purposes.
> 
> Such controls already exist:
> 
> $ grep -rl DB_LINEAR sound/
> sound/i2c/other/ak4xxx-adda.c
> sound/pci/oxygen/hifier.c
> sound/pci/oxygen/oxygen.c
> sound/pci/ymfpci/ymfpci_main.c
> sound/soc/codecs/stac9766.c
> sound/soc/codecs/wm8350.c
> sound/soc/codecs/wm8400.c
> sound/soc/codecs/wm8990.c

The DB_SCALE also provides linear mapping:
For example, if the HW volume control has a range 0 .. 100
In HW these means:
0 == -10dB, 1 == -9.8dB, 2 == -9.6dB .. 99 = 9.8dB, 100 = 10dB
So it is linear.

#define TLV_DB_LINEAR_ITEM(min_dB, max_dB)
#define TLV_DB_SCALE_ITEM(min, step, mute)

The
TLV_DB_LINEAR_ITEM(-1000, 1000); is essentially the same as
TLV_DB_SCALE_ITEM(-1000, 20, 0);
In this case

In linear, you specify the min, and max dB. The control provides the range 
(steps) in between the two ends.
In scale, you specify the minimum, and the steps for each control step.
At the end both are linear, and gives you exactly the same volume/dB pair.

> 
> > The conversion from the control value to a usable value would have to
> > include a user land log operation.
> > It was never implemented due to lack of demand.
> 
> It is implemented.
> 
> > For the cards that do have this 32bit linear value, a simple lookup
> > table is used in the kernel code to convert it to 256 step values.
> 
> Which driver is this?  It should be changed to use the full range.
> 
> 
> Regards,
> Clemens
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel at alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

-- 
Péter


More information about the Alsa-devel mailing list