From: James Courtier-Dutton <James@superbug.co.uk>
To: Takashi Iwai <tiwai@suse.de>
Cc: ALSA development <alsa-devel@alsa-project.org>
Subject: Re: dB gain
Date: Mon, 29 May 2006 15:50:01 +0100 [thread overview]
Message-ID: <447B0A19.2050408@superbug.co.uk> (raw)
In-Reply-To: <s5hverp7zcr.wl%tiwai@suse.de>
Takashi Iwai wrote:
> At Sat, 27 May 2006 20:03:44 +0100,
> James Courtier-Dutton wrote:
>> Hi,
>>
>> I have made a new attempt at adding support for dB gain reports in
>> alsamixer.
>>
>> See the attached diffs against the current alsa hg repository. 27-5-2006
>>
>> It shows an example of support for the snd-ca0106 driver.
>> As one can see, this adds minimal amounts of code to each sound card
>> driver. 22 new lines + 1 per volume control making 33 lines total.
>>
>> Any comments?
>
> Apart from some small implementation details, it looks almost fine.
> One remaining thing is the definition of protocol. Shouldn't be numid
> regardless of container type? Now the numid is checked inside the
> block of db container type. I think this can be outside.
>
> Also, a bit more sensible names are preferred for new stuff.
> "misc" sounds too ambiguous to me, and "info2" is...
>
> I'm not a native speaker, so I expect someone elese has better
> proposal.
>
>
> Takashi
As for the naming, I called it misc because it can be used for anything
we want, depending on the TLVs requested. "misc" is short for
miscellaneous. So I thing that "misc" is appropriate, given it's
potential to be used for other stuff in future.
An explanation of the protocol:
The protocol is a request/response protocol
Request:
uint32_t version; // Protocol version
uint32_t length; // Length of the user land data buffer. This is filled
with the response.
uint8_t data[]; // A block of data bytes malloc by user land,
containing the actual "request".
Inside the data one has TLVs (Type, Length, Values)
For requesting db gain scales:
Request:
uint32_t type = SND_MISC_DB_SCALE;
uint32_t length = 4; /* sizeof(following uint32_t)
uint32_t value = numid; /* Used by snd_ctl_find_numid() */
Note: numid is used because it is present in both userland and kernel
land as a unique identifier of the mixer control in question.
Of course, if we wished to get some different information, the type
would be a different value, and the resulting value could relate to
something else. How the value is interpreted is dependent on the type field.
Response:
This depends on the function used to do the conversion.
uint32_t type = SND_MISC_DB_SCALE;
uint32_t length = length of following data; /* In this example it will
be 20 */
uint8_t data[] /* data returned from sound card driver info2() */
Note: the info2(kctl, 1, &info2). The "1" tells the driver to return
info2 info about the db_gain function.
For example, if it was "2", we could(not implemented yet) get the driver
to return all the info returned in the current info() function, but in
TLV form.
In a simple example the data[] contains:
uint32_t type = 1 /* For simple dB = (X * db_per_devision) - db_offset */
uint32_t length = 12 /* 3 following uint32_t */
int32_t db_per_devision; /* Use db per devision * 100 */
int32_t db_offset; /* Use dB offset * 100. This identifies the 0dB point */
int32_t db_mute; /* The value, before conversion, that is equivalent to
MUTE */
There is the potential to request multiple parameters by encapsulating
more different TLVs in the same request, but this example only used one
for simplicity.
If the conversion, % to dB, function is more complex, on would add a new
type, e.g. 2, and then as much data as needed to describe the function.
One would then implement the type 2 processing in alsa-lib.
If there is a mismatch, and the user lib is of a different version from
the kernel, and the required type is not implemented, the GUI mixer app
would simply not display dB gain levels, as is the case with the current
alsamixer.
James
next prev parent reply other threads:[~2006-05-29 14:50 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-27 19:03 dB gain James Courtier-Dutton
2006-05-29 13:08 ` Takashi Iwai
2006-05-29 13:47 ` Jaroslav Kysela
2006-05-29 14:17 ` Jaroslav Kysela
2006-05-29 14:28 ` Takashi Iwai
2006-05-29 14:55 ` Jaroslav Kysela
2006-05-29 15:12 ` James Courtier-Dutton
2006-05-29 15:41 ` Takashi Iwai
2006-05-29 18:34 ` Jaroslav Kysela
2006-05-29 19:21 ` James Courtier-Dutton
2006-05-29 14:50 ` James Courtier-Dutton [this message]
2006-05-29 15:54 ` Takashi Iwai
2006-05-29 17:34 ` James Courtier-Dutton
2006-05-29 18:11 ` Takashi Iwai
2006-05-29 18:27 ` Jaroslav Kysela
2006-05-30 18:59 ` James Courtier-Dutton
2006-05-30 19:49 ` Jaroslav Kysela
2006-05-31 10:47 ` Takashi Iwai
2006-05-31 11:04 ` James Courtier-Dutton
2006-05-31 11:31 ` Takashi Iwai
2006-05-31 11:18 ` 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=447B0A19.2050408@superbug.co.uk \
--to=james@superbug.co.uk \
--cc=alsa-devel@alsa-project.org \
--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.