Re: GPIO connections for the M-Audio Revolution 5.1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux