summaryrefslogtreecommitdiffstats
path: root/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2018-09-04 17:58:34 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-10 11:14:58 +0200
commita97962111e6710adb127bff28092236687b742c3 (patch)
treeb8c368603c8beabd8982624461438aab83b374b5 /drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
parent51002248a68f2d7e4fcd254c9ae726ab6f40c71e (diff)
downloadlinux-stable-a97962111e6710adb127bff28092236687b742c3.tar.gz
linux-stable-a97962111e6710adb127bff28092236687b742c3.tar.bz2
linux-stable-a97962111e6710adb127bff28092236687b742c3.zip
staging: bcm2835-audio: Fix mute controls, volume handling cleanup
In the current code, the mute control is dealt in a special manner, modifying the current volume and saving the old volume, etc. This is inconsistent (e.g. change the volume while muted, then unmute), and way too complex. Also, the whole volume handling code has conversion between ALSA volume and raw volume values, which can lead to another inconsistency and complexity. This patch simplifies these points: - The ALSA volume value is saved in chip->volume - volume->mute saves the mute state - The mute state is evaluated only when the actual volume is passed to the hardware, bcm2835_audio_set_ctls() Signed-off-by: Takashi Iwai <tiwai@suse.de> Tested-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c')
-rw-r--r--drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c32
1 files changed, 7 insertions, 25 deletions
diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
index 942a38942c29..8684dc1d0b41 100644
--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
@@ -460,11 +460,11 @@ free_wq:
return ret;
}
-static int bcm2835_audio_set_ctls_chan(struct bcm2835_alsa_stream *alsa_stream,
- struct bcm2835_chip *chip)
+int bcm2835_audio_set_ctls(struct bcm2835_alsa_stream *alsa_stream)
{
struct vc_audio_msg m;
struct bcm2835_audio_instance *instance = alsa_stream->instance;
+ struct bcm2835_chip *chip = alsa_stream->chip;
int status;
int ret;
@@ -478,7 +478,10 @@ static int bcm2835_audio_set_ctls_chan(struct bcm2835_alsa_stream *alsa_stream,
m.type = VC_AUDIO_MSG_TYPE_CONTROL;
m.u.control.dest = chip->dest;
- m.u.control.volume = chip->volume;
+ if (!chip->mute)
+ m.u.control.volume = CHIP_MIN_VOLUME;
+ else
+ m.u.control.volume = alsa2chip(chip->volume);
/* Create the message available completion */
init_completion(&instance->msg_avail_comp);
@@ -514,27 +517,6 @@ unlock:
return ret;
}
-int bcm2835_audio_set_ctls(struct bcm2835_chip *chip)
-{
- int i;
- int ret = 0;
-
- LOG_DBG(" Setting ALSA dest(%d), volume(%d)\n", chip->dest, chip->volume);
-
- /* change ctls for all substreams */
- for (i = 0; i < MAX_SUBSTREAMS; i++) {
- if (!chip->alsa_stream[i])
- continue;
- if (bcm2835_audio_set_ctls_chan(chip->alsa_stream[i], chip) != 0) {
- LOG_ERR("Couldn't set the controls for stream %d\n", i);
- ret = -1;
- } else {
- LOG_DBG(" Controls set for stream %d\n", i);
- }
- }
- return ret;
-}
-
int bcm2835_audio_set_params(struct bcm2835_alsa_stream *alsa_stream,
unsigned int channels, unsigned int samplerate,
unsigned int bps)
@@ -548,7 +530,7 @@ int bcm2835_audio_set_params(struct bcm2835_alsa_stream *alsa_stream,
channels, samplerate, bps);
/* resend ctls - alsa_stream may not have been open when first send */
- ret = bcm2835_audio_set_ctls_chan(alsa_stream, alsa_stream->chip);
+ ret = bcm2835_audio_set_ctls(alsa_stream);
if (ret) {
LOG_ERR(" Alsa controls not supported\n");
return -EINVAL;