* [PATCH] cx88-alsa: prevent out-of-range volume setting
@ 2010-02-22 9:45 Clemens Ladisch
0 siblings, 0 replies; only message in thread
From: Clemens Ladisch @ 2010-02-22 9:45 UTC (permalink / raw)
To: Mauro Carvalho Chehab, linux-media, linux-kernel
Ensure that volume values are always in the allowed range. Otherwise,
it would be possible to set other bits in the AUD_VOL_CTL register or to
get a wrong sign in the AUD_BAL_CTL register.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
--- linux/drivers/media/video/cx88/cx88-alsa.c
+++ linux/drivers/media/video/cx88/cx88-alsa.c
@@ -583,16 +583,18 @@ static int snd_cx88_volume_put(struct sn
{
snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol);
struct cx88_core *core=chip->core;
- int v, b;
+ int left, right, v, b;
int changed = 0;
u32 old;
- b = value->value.integer.value[1] - value->value.integer.value[0];
+ left = value->value.integer.value[0] & 0x3f;
+ right = value->value.integer.value[1] & 0x3f;
+ b = right - left;
if (b < 0) {
- v = 0x3f - value->value.integer.value[0];
+ v = 0x3f - left;
b = (-b) | 0x40;
} else {
- v = 0x3f - value->value.integer.value[1];
+ v = 0x3f - right;
}
/* Do we really know this will always be called with IRQs on? */
spin_lock_irq(&chip->reg_lock);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-02-22 9:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-22 9:45 [PATCH] cx88-alsa: prevent out-of-range volume setting Clemens Ladisch
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.