All of lore.kernel.org
 help / color / mirror / Atom feed
* More mixer questions
@ 2006-04-01 23:18 Adrian McMenamin
  2006-04-02  3:09 ` Lee Revell
  0 siblings, 1 reply; 3+ messages in thread
From: Adrian McMenamin @ 2006-04-01 23:18 UTC (permalink / raw)
  To: alsa-devel

Sorry to hit the list with another question about the mixer/control
stuff, but I'm pretty puzzled as to what I am getting wrong.

I am using mpg123 compiled to only hack oss, so I am reliant on oss
emulation.

I have the control code attached below, which defines both master and
pcm functions (mapped together as the device only plays PCM).

By default I get this:

/ # cat /proc/asound/card0/oss_mixer
VOLUME "" 0
BASS "" 0
TREBLE "" 0
SYNTH "" 0
PCM "" 0
SPEAKER "" 0
LINE "" 0
MIC "" 0
CD "" 0
IMIX "" 0
ALTPCM "" 0
RECLEV "" 0
IGAIN "" 0
OGAIN "" 0
LINE1 "" 0
LINE2 "" 0
LINE3 "" 0
DIGITAL1 "" 0
DIGITAL2 "" 0
DIGITAL3 "" 0
PHONEIN "" 0
PHONEOUT "" 0
VIDEO "" 0
RADIO "" 0
MONITOR "" 0

ie nothing mapped against oss. But if I do this:
echo 'VOLUME "PCM" 0' > /proc/asound/card0/oss_mixer
or
echo 'VOLUME "Master" 0' > /proc/asound/card0/oss_mixer

Then I get control of gain... so why doesn't the mapping work by
default?


/* Mixer controls */
static int aica_pcmswitch_info(snd_kcontrol_t * kcontrol,
			       snd_ctl_elem_info_t * uinfo)
{
	uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
	uinfo->count = 1;
	uinfo->value.integer.min = 0;
	uinfo->value.integer.max = 1;
	return 0;
}

static int aica_pcmswitch_get(snd_kcontrol_t * kcontrol,
			      snd_ctl_elem_value_t * ucontrol)
{
	ucontrol->value.integer.value[0] = 1;	/* TO DO: Fix me */
	return 0;
}

static int aica_pcmswitch_put(snd_kcontrol_t * kcontrol,
			      snd_ctl_elem_value_t * ucontrol)
{
	if (ucontrol->value.integer.value[0] == 1)
		return 0;	/* TO DO: Fix me */
	else
		aica_chn_halt();
	return 0;
}

static snd_kcontrol_new_t snd_aica_masterswitch_control __devinitdata =
{
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Master Playback Switch",
	.info = aica_pcmswitch_info,
	.get = aica_pcmswitch_get,
	.put = aica_pcmswitch_put
};

static snd_kcontrol_new_t snd_aica_pcmswitch_control __devinitdata = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "PCM Playback Switch",
	.index = 0,
	.info = aica_pcmswitch_info,
	.get = aica_pcmswitch_get,
	.put = aica_pcmswitch_put
};




static int aica_pcmvolume_info(snd_kcontrol_t * kcontrol,
			       snd_ctl_elem_info_t * uinfo)
{

	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
	uinfo->count = 1;
	uinfo->value.integer.min = 0;
	uinfo->value.integer.max = 0xFF;

	return 0;
}

static int aica_pcmvolume_get(snd_kcontrol_t * kcontrol,
			      snd_ctl_elem_value_t * ucontrol)
{
	if (!channel)
		return -ETXTBSY;	/* we've not yet been set up */
	ucontrol->value.integer.value[0] = channel->vol;
	return 0;
}

static int aica_pcmvolume_put(snd_kcontrol_t * kcontrol,
			      snd_ctl_elem_value_t * ucontrol)
{
	if (!channel) {
		snd_printk("No channel yet\n");
		return -ETXTBSY;	/* too soon */
	}

	else if (channel->vol == ucontrol->value.integer.value[0])
		return 0;

	else {
		channel->vol = ucontrol->value.integer.value[0];
		dreamcastcard->master_volume = ucontrol->value.integer.value[0];
		spu_memload(AICA_CHANNEL0_CONTROL_OFFSET,
			    (uint8_t *) channel, sizeof(aica_channel_t));
	}
	return 1;
}

static snd_kcontrol_new_t snd_aica_mastervolume_control __devinitdata =
{
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Master Playback Volume",
	.info = aica_pcmvolume_info,
	.get = aica_pcmvolume_get,
	.put = aica_pcmvolume_put
};

static snd_kcontrol_new_t snd_aica_pcmvolume_control __devinitdata = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "PCM Playback Volume",
	.index = 0,
	.info = aica_pcmvolume_info,
	.get = aica_pcmvolume_get,
	.put = aica_pcmvolume_put
};






-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-04-02  9:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-01 23:18 More mixer questions Adrian McMenamin
2006-04-02  3:09 ` Lee Revell
2006-04-02  9:39   ` Adrian McMenamin

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.