From: Liam Girdwood <Liam.Girdwood@wolfsonmicro.com>
To: alsa-devel@lists.sourceforge.net
Subject: [RFC] New method for adding AC97 SNDRV_CTL_ELEM_TYPE_ENUMERATED controls
Date: Thu, 10 Feb 2005 16:33:10 +0000 [thread overview]
Message-ID: <1108053190.4533.140.camel@cearnarfon> (raw)
I'm interested to know what people think of the following change to the
way that custom controls of type SNDRV_CTL_ELEM_TYPE_ENUMERATED are
added in ac97_codec.c and ac97_patch.c.
Currently, we have to do something like this for every custom
SNDRV_CTL_ELEM_TYPE_ENUMERATED control we want to add:-
int snd_add_ctl(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
{
static char *texts[6] = {
"Mic1", "Mic2", "Mono", "Stereo", "Line L", Line R"
};
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
uinfo->count = 1;
uinfo->value.enumerated.items = 6;
if (uinfo->value.enumerated.item > 5)
uinfo->value.enumerated.item = 5;
strcpy(uinfo->value.enumerated.name,
texts[uinfo->value.enumerated.item]);
return 0;
}
I would like to make it easier to add a lot of larger and more complex
controls without the need of adding a lot of new code (and re inveting
the wheel). I'm proposing adding an AC97_ENUM_SINGLE macro i.e.
#define AC97_ENUM_SINGLE(xname, reg, shift, item, invert) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info =
snd_ac97_info_enum_single, \
.get = snd_ac97_get_enum_single, .put = snd_ac97_put_enum_single, \
.private_value = reg | (shift << 8) | (item << 16) | (invert << 24) }
and also changing AC97_ENUM_DOUBLE:-
#define AC97_ENUM_DOUBLE(xname, reg, shift_l, shift_r, item, invert) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info =
snd_ac97_info_enum_double, \
.get = snd_ac97_get_enum_double, .put = snd_ac97_put_enum_double, \
.private_value = reg | (shift_l << 8) | (shift_r << 12) | (item << 16)
| (invert << 24) }
This now makes it possible to add the new controls to a regular array of
type snd_kcontrol_new_t. i.e.
static const snd_kcontrol_new_t wm13_snd_ac97_controls_recsel[7] = {
AC97_ENUM_SINGLE("Record to Headphone Path", AC97_VIDEO, 14, 5, 0),
AC97_SINGLE("Record to Headphone Volume", AC97_VIDEO, 11, 7, 0),
AC97_ENUM_SINGLE("Record to Mono Path", AC97_VIDEO, 9, 5, 0),
AC97_SINGLE("Record to Mono Boost (+20dB)", AC97_VIDEO, 8, 1, 0),
AC97_SINGLE("Record ADC Boost (+20dB)", AC97_VIDEO, 6, 1, 0),
AC97_ENUM_SINGLE("Record Select Left", AC97_VIDEO, 3, 6, 0),
AC97_ENUM_SINGLE("Record Select Right", AC97_VIDEO, 0, 7, 0),
};
The text and mask for the control exists in a table of type
struct ac97_enum_info {
int mask; /* number of bits in selector */
char* text[8]; /* selector description */
};
e.g.
static struct ac97_enum_info enum_info[] = {
{ 2, {"pre 3D", "post 3D", NULL, NULL, NULL, NULL, NULL, NULL}}, /* std
GP */
{ 2, {"Mix", "Mic", NULL, NULL, NULL, NULL, NULL, NULL}}, /* std GP */
{ 2, {"Mic1", "Mic2", NULL, NULL, NULL, NULL, NULL, NULL}}, /* std PG
*/
{ 8, {"Mic", "CD", "Video", "Aux", "Line", "Mix", "Mix Mono",
"Phone"}}, /* std REC select */
{ 4, {"Stereo", "Mic1", "Mic2", "Mute", NULL, NULL, NULL, NULL}},
{ 4, {"Stereo", "Left", "Right", "Mute", NULL, NULL, NULL, NULL}},
{ 8, {"Mic1", "Mic2", "Line L", "Mono In", "HP Mix L", "Spk Mix", "Mono
Mix", "Zh"}},
{ 8, {"Mic1", "Mic2", "Line R", "Mono In", "HP Mix R", "Spk Mix", "Mono
Mix", "Zh"}},
};
I've already implemented this for the wm9713 codec and it works well. I
can now add new routing and mixer enum controls very quickly without too
much new driver bloat.
If this is acceptable, I'll submit a patch.
Liam
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
next reply other threads:[~2005-02-10 16:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-10 16:33 Liam Girdwood [this message]
2005-02-10 17:10 ` [RFC] New method for adding AC97 SNDRV_CTL_ELEM_TYPE_ENUMERATED controls Takashi Iwai
2005-02-10 17:22 ` Liam Girdwood
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=1108053190.4533.140.camel@cearnarfon \
--to=liam.girdwood@wolfsonmicro.com \
--cc=alsa-devel@lists.sourceforge.net \
/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.