Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patches for bcm2835ctl that make alsamixer useable #33

Merged
merged 2 commits into from
Jun 6, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions sound/arm/bcm2835-ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,27 @@

#include "bcm2835.h"


/* functions to convert alsa to chip volume and back. */
int alsa2chip(int vol)
{
return -((vol << 8) / 100);
}

int chip2alsa(int vol)
{
return -((vol * 100) >> 8);
}


static int snd_bcm2835_ctl_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
if (kcontrol->private_value == PCM_PLAYBACK_VOLUME) {
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = 1;
uinfo->value.integer.min = -10240;
uinfo->value.integer.max = 2303;
uinfo->value.integer.max = 400; /* 2303 */
} else if (kcontrol->private_value == PCM_PLAYBACK_MUTE) {
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = 1;
Expand All @@ -64,7 +77,7 @@ static int snd_bcm2835_ctl_get(struct snd_kcontrol *kcontrol,
BUG_ON(!chip && !(chip->avail_substreams & AVAIL_SUBSTREAMS_MASK));

if (kcontrol->private_value == PCM_PLAYBACK_VOLUME)
ucontrol->value.integer.value[0] = chip->volume;
ucontrol->value.integer.value[0] = chip2alsa(chip->volume);
else if (kcontrol->private_value == PCM_PLAYBACK_MUTE)
ucontrol->value.integer.value[0] = chip->mute;
else if (kcontrol->private_value == PCM_PLAYBACK_DEVICE)
Expand All @@ -85,13 +98,10 @@ static int snd_bcm2835_ctl_put(struct snd_kcontrol *kcontrol,
changed = 1;
}
if (changed
|| (ucontrol->value.integer.value[0] != chip->volume)) {
int atten;
|| (ucontrol->value.integer.value[0] != chip2alsa(chip->volume))) {

chip->volume = ucontrol->value.integer.value[0];
chip->volume = alsa2chip(ucontrol->value.integer.value[0]);
changed = 1;
atten = -((chip->volume << 8) / 100);
chip->volume = atten;
}

} else if (kcontrol->private_value == PCM_PLAYBACK_MUTE) {
Expand Down