From: Takashi Iwai <tiwai@suse.de>
To: Jochen Voss <voss@seehuhn.de>
Cc: ALSA development list <alsa-devel@lists.sourceforge.net>
Subject: Re: GPIO connections for the M-Audio Revolution 5.1
Date: Tue, 08 Aug 2006 20:02:20 +0200 [thread overview]
Message-ID: <s5hejvrf6mr.wl%tiwai@suse.de> (raw)
In-Reply-To: <20060808174741.GA29366@tarte.seehuhn.de>
At Tue, 8 Aug 2006 18:47:42 +0100,
Jochen Voss wrote:
>
> Hello Takashi,
>
> On Tue, Aug 08, 2006 at 07:30:44PM +0200, Takashi Iwai wrote:
> > > Is the last argument (mask) for AK_COMPOSE the maximum allowed mixer
> > > value? Is it ok if this is not a power of two?
> >
> > Yes and yes.
>
> Fine. Slowly I am getting there. Now I have something working,
> which uses the following addition to snd_akm4xxx_build_controls:
>
> if (ak->type == SND_AK5365) {
> memset(ctl, 0, sizeof(*ctl));
> if (ak->channel_names == NULL) {
> strcpy(ctl->id.name, "ADC Volume");
> } else {
> strcpy(ctl->id.name, ak->channel_names[0]);
> }
> ctl->id.index = ak->idx_offset * 2;
> ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
> ctl->count = 1;
> ctl->info = snd_akm4xxx_stereo_volume_info;
> ctl->get = snd_akm4xxx_stereo_volume_get;
> ctl->put = snd_akm4xxx_stereo_volume_put;
> /* register 4 & 5 */
> ctl->private_value =
> AK_COMPOSE(0, 4, 0, 0x98);
> ctl->private_data = ak;
> err = snd_ctl_add(ak->card,
> snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|
> SNDRV_CTL_ELEM_ACCESS_WRITE));
>
> if (err < 0)
> goto __error;
>
> idx += 2; /* always stereo */
> }
>
> (I will post a complete patch later today.)
>
> This gives me a beautiful (and working!) volume slider for the capture
> channel. Does this look ok to you? The magic constant 0x98 is from
> page 35 of the spec and I think is correct. I did not imitate the
> loop over idx which other parts of this function have. I hope that
> this is ok.
Great it looks almost fine. Just a cosmetic thing: remove superflous
parentheses around the single if () line (strcpy...). It's a
convention of kernel codes.
For a magic number 0x98, put a short comment there.
Maybe you should rename it to "Capture Volume" from "ADC Volume".
Or, pass "Capture Volume" from the caller side.
This is more common name. The "ADC" and "DAC" strings are used
there for the multi-channel boards. But Revo has only a stereo.
> The card seems to have a separate mute control. How do I create a
> mixer element for this? I would like alsamixer to place a little mute
> box just under the slider bar. I looked around, but could not find
> anything similar to copy within the ice1723 directory.
Then you need to create a boolean switch.
The code would be something like below:
static int ak4xxx_switch_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->count = 2;
uinfo->value.integer.min = 0;
uinfo->value.integer.max = 1;
return 0;
}
static int ak4xxx_switch_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
...
unsigned char val = snd_akm4xxx_get(ak, chip, addr);
/* 0 = off, 1 = on */
ucontrol->value.integer.value[0] = (val & left_bit) != 0;
ucontrol->value.integer.value[1] = (val & right_bit) != 0;
return 0;
}
static int ak4xxx_switch_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
...
unsigned char val, oval;
int change = 0;
val = 0;
if (ucontrol->value.integer.value[0])
val |= left_bit;
if (ucontrol->value.integer.value[1])
val |= right_bit;
oval = snd_akm4xxx_get(ak, chip, addr);
change = (oval != val);
if (change)
snd_akm4xxx_put(ak, chip, addr, val);
return change;
}
Takashi
-------------------------------------------------------------------------
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
prev parent reply other threads:[~2006-08-08 18:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-07 20:31 GPIO connections for the M-Audio Revolution 5.1 Jochen Voss
2006-08-08 10:21 ` Takashi Iwai
2006-08-08 10:40 ` Jochen Voss
2006-08-08 11:07 ` Takashi Iwai
2006-08-08 11:18 ` Jochen Voss
2006-08-08 11:23 ` Takashi Iwai
2006-08-08 11:40 ` Jochen Voss
2006-08-08 13:07 ` Takashi Iwai
2006-08-08 16:30 ` Jochen Voss
2006-08-08 16:48 ` Takashi Iwai
2006-08-08 16:52 ` Jochen Voss
2006-08-08 17:20 ` Jochen Voss
2006-08-08 17:30 ` Takashi Iwai
2006-08-08 17:47 ` Jochen Voss
2006-08-08 18:02 ` Takashi Iwai [this message]
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=s5hejvrf6mr.wl%tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@lists.sourceforge.net \
--cc=voss@seehuhn.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.