From: James Courtier-Dutton <James@superbug.co.uk>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: [RFC] dB range compound
Date: Mon, 04 Sep 2006 13:40:13 +0100 [thread overview]
Message-ID: <44FC1EAD.2010800@superbug.co.uk> (raw)
In-Reply-To: <s5hd5afmqdi.wl%tiwai@suse.de>
Takashi Iwai wrote:
> Hi,
>
> I found that some hardwares require the combination of dB scale
> ranges. For example, es1938 has volume controls with two curves,
> e.g. the volume step in the value 0-8 is 3 dB while it's 1.5 dB in the
> values 8-15.
>
> The patch below introduces a new TLV type, DB_RANGE, to implement
> the compound dB scales. It can contain one or more child TLVs,
> together with min and max values for each.
>
> The first patch is for the kernel and the second for alsa-lib.
>
> Any comments?
>
>
> Takashi
>
+static int do_convert_to_dB(unsigned int *tlv, long rangemin, long
rangemax,
+ long volume, long *db_gain)
+{
+ switch (tlv[0]) {
+ case SND_CTL_TLVT_DB_RANGE: {
+ unsigned int pos, len;
+ len = tlv[1] / sizeof(int);
+ pos = 2;
Be careful with this len limit in the while loop. I suggest adding a
further comparison to limit the loop to a constant size:
e.g.
while (pos + 4 <= len && (pos + 4 < MAX_BUFFER_SIZE) ) {
There are similar cases elsewhere in the patch.
+ while (pos + 4 <= len) {
+ rangemin = (int)tlv[pos];
+ rangemax = (int)tlv[pos + 1];
+ if (volume >= rangemin && volume <= rangemax)
+ return do_convert_to_dB(tlv + pos + 2,
+ rangemin, rangemax,
+ volume, db_gain);
+ pos += tlv[pos + 3] + 4;
+ }
return -EINVAL;
Apart from that, It looks OK to me.
With regard to this control actually being to separate register in the
chip, I think it might be nice to implement two separate controls
between kernel and alsa-lib, but add some TLV tag to link the two
controls together so that they appear as one. This will save code size
in the kernel.
For example, with the EMU DSPs one control can do 0 dB to -inf gain, and
another can to 0 dB to X gain. I was thinking of implementing these in
the emu10k1 module, with special code to link the two at the kernel
module level, but it might save code duplication if we let alsa-lib do
this task.
We might be able to do a similar link between mic gain and mic boost
switches.
James
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
next prev parent reply other threads:[~2006-09-04 12:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-01 17:46 [RFC] dB range compound Takashi Iwai
2006-09-04 12:40 ` James Courtier-Dutton [this message]
2006-09-04 13:31 ` Takashi Iwai
2006-09-04 18:40 ` Takashi Iwai
2006-09-05 14:36 ` Takashi Iwai
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=44FC1EAD.2010800@superbug.co.uk \
--to=james@superbug.co.uk \
--cc=alsa-devel@lists.sourceforge.net \
--cc=tiwai@suse.de \
/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.