[alsa-devel] [PATCH] alsa-lib/tlv: fix handling of raw value ranges

James Courtier-Dutton james.dutton at gmail.com
Sat Jun 2 10:09:56 CEST 2012

On 30 March 2012 11:41, Benoît Thébaudeau
<benoit.thebaudeau at advansee.com> wrote:
> Clemens Ladisch wrote:
>> Benoît Thébaudeau wrote:
>> > In case of a TLV dB range with all items having raw value ranges
>> > strictly within
>> > the main raw value range reported by the driver,
>> > snd_tlv_convert_from_dB()
>> > returned one of the main raw range boundaries, which was outside
>> > all dB range
>> > items.
>> But the main raw range boundaries _are_ valid values.
> Not always. For instance, if a codec register has the following volume values:
> 0x00 to 0x20: prohibited
> 0x21 to 0x40: some dB values
> 0x41 to 0x60: prohibited
> 0x61 to 0xff: some dB values

In the userspace to kernel interface. A mixer control must have min/max values.
When writing the value, all values within the range of min to max must
be valid values.
There are just too many user land tools that rely on this fact.
Think of the use case or "Next step louder please". If the currently
written value is 0x40, the current user land mixer apps would try to
write 0x41, without even bothering to look at the dB tables.
If you instead change the driver to map:
0x21 to 0x40 -> 0x00 to 0x1f
0x61 to 0xff -> 0x20 to 0xBE
and set min to 0, and max to 0xbe
The user space tools will then work fine.

The dB conversion tables are just a friendly way of displaying a
slightly more useful figure to the user than a percentage.
If you have hardware with gaps like the above, the kernel driver will
have to be fixed to remove the prohibited ranges in the kernel to
userspace API.
This sort of conversion is done in many other alsa kernel drivers.

Kind Regards


More information about the Alsa-devel mailing list