diff options
author | Takashi Iwai <tiwai@suse.de> | 2007-11-15 09:56:07 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-01-31 11:29:24 -0500 |
commit | 9cd17cd2409ddbe9853575569cfd97561fa86b14 (patch) | |
tree | e41f734ccf669f6360fe1155be42e262e44a9552 /sound/pci/ice1712/phase.c | |
parent | 68ea7b2f2d8c1effd662fded04e9a589cb640da6 (diff) |
[ALSA] ice1724 - Check value ranges in ctl callbacks
Check the value ranges in ctl put callbacks properly.
Also fixed the wrong access type to enum elements in aureon.c.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/ice1712/phase.c')
-rw-r--r-- | sound/pci/ice1712/phase.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/sound/pci/ice1712/phase.c b/sound/pci/ice1712/phase.c index 3ac25058bb58..c81efc2f8c95 100644 --- a/sound/pci/ice1712/phase.c +++ b/sound/pci/ice1712/phase.c | |||
@@ -326,10 +326,13 @@ static int wm_master_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_ | |||
326 | 326 | ||
327 | snd_ice1712_save_gpio_status(ice); | 327 | snd_ice1712_save_gpio_status(ice); |
328 | for (ch = 0; ch < 2; ch++) { | 328 | for (ch = 0; ch < 2; ch++) { |
329 | if (ucontrol->value.integer.value[ch] != ice->spec.phase28.master[ch]) { | 329 | unsigned int vol = ucontrol->value.integer.value[ch]; |
330 | if (vol > WM_VOL_MAX) | ||
331 | continue; | ||
332 | vol |= ice->spec.phase28.master[ch] & WM_VOL_MUTE; | ||
333 | if (vol != ice->spec.phase28.master[ch]) { | ||
330 | int dac; | 334 | int dac; |
331 | ice->spec.phase28.master[ch] &= WM_VOL_MUTE; | 335 | ice->spec.phase28.master[ch] = vol; |
332 | ice->spec.phase28.master[ch] |= ucontrol->value.integer.value[ch]; | ||
333 | for (dac = 0; dac < ice->num_total_dacs; dac += 2) | 336 | for (dac = 0; dac < ice->num_total_dacs; dac += 2) |
334 | wm_set_vol(ice, WM_DAC_ATTEN + dac + ch, | 337 | wm_set_vol(ice, WM_DAC_ATTEN + dac + ch, |
335 | ice->spec.phase28.vol[dac + ch], | 338 | ice->spec.phase28.vol[dac + ch], |
@@ -462,10 +465,14 @@ static int wm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value * | |||
462 | ofs = kcontrol->private_value & 0xff; | 465 | ofs = kcontrol->private_value & 0xff; |
463 | snd_ice1712_save_gpio_status(ice); | 466 | snd_ice1712_save_gpio_status(ice); |
464 | for (i = 0; i < voices; i++) { | 467 | for (i = 0; i < voices; i++) { |
465 | idx = WM_DAC_ATTEN + ofs + i; | 468 | unsigned int vol; |
466 | if (ucontrol->value.integer.value[i] != ice->spec.phase28.vol[ofs+i]) { | 469 | vol = ucontrol->value.integer.value[i]; |
467 | ice->spec.phase28.vol[ofs+i] &= WM_VOL_MUTE; | 470 | if (vol > 0x7f) |
468 | ice->spec.phase28.vol[ofs+i] |= ucontrol->value.integer.value[i]; | 471 | continue; |
472 | vol |= ice->spec.phase28.vol[ofs+i] & WM_VOL_MUTE; | ||
473 | if (vol != ice->spec.phase28.vol[ofs+i]) { | ||
474 | ice->spec.phase28.vol[ofs+i] = vol; | ||
475 | idx = WM_DAC_ATTEN + ofs + i; | ||
469 | wm_set_vol(ice, idx, ice->spec.phase28.vol[ofs+i], | 476 | wm_set_vol(ice, idx, ice->spec.phase28.vol[ofs+i], |
470 | ice->spec.phase28.master[i]); | 477 | ice->spec.phase28.master[i]); |
471 | change = 1; | 478 | change = 1; |
@@ -595,8 +602,10 @@ static int wm_pcm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val | |||
595 | unsigned short ovol, nvol; | 602 | unsigned short ovol, nvol; |
596 | int change = 0; | 603 | int change = 0; |
597 | 604 | ||
598 | snd_ice1712_save_gpio_status(ice); | ||
599 | nvol = ucontrol->value.integer.value[0]; | 605 | nvol = ucontrol->value.integer.value[0]; |
606 | if (nvol > PCM_RES) | ||
607 | return -EINVAL; | ||
608 | snd_ice1712_save_gpio_status(ice); | ||
600 | nvol = (nvol ? (nvol + PCM_MIN) : 0) & 0xff; | 609 | nvol = (nvol ? (nvol + PCM_MIN) : 0) & 0xff; |
601 | ovol = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff; | 610 | ovol = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff; |
602 | if (ovol != nvol) { | 611 | if (ovol != nvol) { |