Skip to content

Commit d0735c7

Browse files
committed
bcm2835-ctl: fix alsamixer control.
alsamixer read the volume for the screen controller so we had to scale the chipvol back to db for reading.
1 parent 94fbbc4 commit d0735c7

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

sound/arm/bcm2835-ctl.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@
3333

3434
#include "bcm2835.h"
3535

36+
37+
/* functions to convert alsa to chip volume and back. */
38+
int alsa2chip(int vol)
39+
{
40+
return -((vol << 8) / 100);
41+
}
42+
43+
int chip2alsa(int vol)
44+
{
45+
return -((vol * 100) >> 8);
46+
}
47+
48+
3649
static int snd_bcm2835_ctl_info(struct snd_kcontrol *kcontrol,
3750
struct snd_ctl_elem_info *uinfo)
3851
{
@@ -64,7 +77,7 @@ static int snd_bcm2835_ctl_get(struct snd_kcontrol *kcontrol,
6477
BUG_ON(!chip && !(chip->avail_substreams & AVAIL_SUBSTREAMS_MASK));
6578

6679
if (kcontrol->private_value == PCM_PLAYBACK_VOLUME)
67-
ucontrol->value.integer.value[0] = chip->volume;
80+
ucontrol->value.integer.value[0] = chip2alsa(chip->volume);
6881
else if (kcontrol->private_value == PCM_PLAYBACK_MUTE)
6982
ucontrol->value.integer.value[0] = chip->mute;
7083
else if (kcontrol->private_value == PCM_PLAYBACK_DEVICE)
@@ -85,13 +98,10 @@ static int snd_bcm2835_ctl_put(struct snd_kcontrol *kcontrol,
8598
changed = 1;
8699
}
87100
if (changed
88-
|| (ucontrol->value.integer.value[0] != chip->volume)) {
89-
int atten;
101+
|| (ucontrol->value.integer.value[0] != chip2alsa(chip->volume))) {
90102

91-
chip->volume = ucontrol->value.integer.value[0];
103+
chip->volume = alsa2chip(ucontrol->value.integer.value[0]);
92104
changed = 1;
93-
atten = -((chip->volume << 8) / 100);
94-
chip->volume = atten;
95105
}
96106

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

0 commit comments

Comments
 (0)