From: Clemens Ladisch <clemens@ladisch.de>
To: "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
Cc: alsa-devel@alsa-project.org
Subject: Re: [PATCH] alsa-lib/tlv: fix handling of raw value ranges
Date: Fri, 30 Mar 2012 15:51:15 +0200 [thread overview]
Message-ID: <4F75BA53.9030709@ladisch.de> (raw)
In-Reply-To: <823a8c22-89ad-4301-bacc-191d1277dd78@zose-store-12>
Benoît Thébaudeau wrote:
> Clemens Ladisch wrote:
>> Benoît Thébaudeau wrote:
>>> Clemens Ladisch wrote:
>> All raw values described by the .info callback, returned by the .get
>> callback, and especially accepted by the .put callback, are valid.
>>
>> The TLV information just _describes_ values, it cannot _restrict_
>> them.
>>
>> If a register has invalid values, the driver must somehow map between
>> raw control values and valid register values.
>
> Now I understand how you see things. But is it an official and absolute ALSA
> rule,
Yes.
> known by everybody,
No.
> that may cause issues if not applied?
Yes.
> The hardware values are:
> 0x00 to 0x70: prohibited
> 0x71 to 0xcf: +15 dB to -79 dB by -1 dB steps
> 0xd0 to 0xfe: prohibited
> 0xff: mute
>
> To respect your rule, the driver would have to implement its own .info/.get/.put
> callbacks, giving the following mapping:
> SW 0x00: HW 0xff: mute
> SW 0x01 to 0x5f: HW 0x71 to 0xcf: +15 dB to -79 dB by -1 dB steps
>
> But why compel the driver to complicate things this way if it can work with
> standard macros and holes in the TLV ranges?
Because it _cannot_ work with standard macros and holes.
> It is also probably the case for many other existing hardware.
>
> Do you think that the solution would be rather to add common kernel ALSA stuff
> to handle such mappings?
Yes.
I'll see if I can cobble together some TLV checking code ...
>>>> As for the patch, while I'm not sure whether it is needed at all,
>>>> I also
>>>> don't quite understand the reason for all the changes.
>>>>
>>>>> --- alsa-lib/src/control/tlv.c
>>>>> +++ alsa-lib/src/control/tlv.c
>>>>> @@ -291,41 +291,37 @@ int snd_tlv_convert_from_dB(unsigned int
>>>>> {
>>>>> switch (tlv[0]) {
>>>>> case SND_CTL_TLVT_DB_RANGE: {
>>>>> + long dbmin, dbmax, prev_submax;
>>>>> unsigned int pos, len;
>>>>> len = int_index(tlv[1]);
>>>>> + if (len < 6 || len > MAX_TLV_RANGE_SIZE)
>>>>> return -EINVAL;
>>>>> pos = 2;
>>>>> + prev_submax = 0;
>>>>> + do {
>>>>
>>>> Why is this not a while loop?
>>>
>>> Because the added "if (len < 6" makes it pointless.
>>
>> Then why did you add the len<6 check? This is, in effect, just the same
>> as the old while condition.
>
> Because it's useless to wait until the end of the loop to return -EINVAL,
It is not necessary to optimize for error cases.
> and with my patch, the after-loop code becomes the fallback case for beyond-
> final-range values, so it avoids adding a weird extra check there.
But why does this force you to use do instead of while?
Regards,
Clemens
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
next prev parent reply other threads:[~2012-03-30 13:48 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <a995c693-9d0b-4572-af9c-85e3deebf37c@zose-store-12>
2012-03-29 23:05 ` [PATCH] alsa-lib/tlv: fix handling of raw value ranges Benoît Thébaudeau
2012-03-30 8:37 ` Clemens Ladisch
2012-03-30 10:41 ` Benoît Thébaudeau
2012-03-30 11:44 ` Takashi Iwai
2012-03-30 11:51 ` Takashi Iwai
2012-03-30 13:07 ` Benoît Thébaudeau
2012-03-30 13:23 ` Takashi Iwai
2012-03-30 12:38 ` Clemens Ladisch
2012-03-30 13:07 ` Benoît Thébaudeau
2012-03-30 13:10 ` Benoît Thébaudeau
2012-03-30 13:51 ` Clemens Ladisch [this message]
2012-03-30 13:58 ` Benoît Thébaudeau
2012-03-30 15:20 ` Benoît Thébaudeau
2012-03-30 15:45 ` Takashi Iwai
2012-03-30 15:59 ` Benoît Thébaudeau
2012-03-30 15:44 ` Takashi Iwai
2012-03-30 16:15 ` Benoît Thébaudeau
2012-05-21 19:38 ` Benoît Thébaudeau
2012-05-22 0:57 ` Takashi Iwai
2012-05-22 2:19 ` Benoît Thébaudeau
2012-05-22 8:45 ` Takashi Iwai
2012-05-22 16:06 ` Benoît Thébaudeau
2012-05-22 23:54 ` Takashi Iwai
2012-06-02 8:09 ` James Courtier-Dutton
2012-06-02 12:26 ` Benoît Thébaudeau
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=4F75BA53.9030709@ladisch.de \
--to=clemens@ladisch.de \
--cc=alsa-devel@alsa-project.org \
--cc=benoit.thebaudeau@advansee.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.