Skip to content

Commit

Permalink
Merge pull request #33 from Arne-F/rpi-patches
Browse files Browse the repository at this point in the history
Patches for bcm2835ctl that make alsamixer useable
  • Loading branch information
popcornmix committed Jun 6, 2012
2 parents 94fbbc4 + 829da61 commit b683e89
Showing 1 changed file with 17 additions and 7 deletions.
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

0 comments on commit b683e89

Please sign in to comment.