aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/usbmixer.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-04-02 13:08:49 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2006-04-02 13:08:49 -0700
commitf27f0a045b79de5729d064497e21a70871f1d6fe (patch)
tree078416852de43b76e297224b57a9c5b9f67dfb56 /sound/usb/usbmixer.c
parent[PATCH] sysfs: zero terminate sysfs write buffers (diff)
parent[ALSA] Kconfig SND_SEQUENCER_OSS help text fix (diff)
downloadlinux-dev-f27f0a045b79de5729d064497e21a70871f1d6fe.tar.xz
linux-dev-f27f0a045b79de5729d064497e21a70871f1d6fe.zip
Merge master.kernel.org:/pub/scm/linux/kernel/git/perex/alsa
* master.kernel.org:/pub/scm/linux/kernel/git/perex/alsa: (28 commits) [ALSA] Kconfig SND_SEQUENCER_OSS help text fix [ALSA] Add Aux input switch control for Aureon Universe [ALSA] pcxhr - Fix the crash with REV01 board [ALSA] sound/pci/hda: use create_singlethread_workqueue() [ALSA] hda-intel - Add support of ATI SB600 [ALSA] cs4281 - Fix the check of timeout in probe [ALSA] cs4281 - Fix the check of right channel [ALSA] Test volume resolution of usb audio at initialization [ALSA] maestro3.c: fix BUG, optimization [ALSA] HDA/Realtek: multiple input mux definitions and pin mode additions [ALSA] AdLib FM card driver [ALSA] Fix / clean up PCM-OSS setup hooks [ALSA] Clean up PCM codes (take 2) [ALSA] Tiny clean up of PCM codes [ALSA] ISA drivers bailing on first !enable[i] [ALSA] Remove obsolete kfree_nocheck call [ALSA] Remove obsolete kfree_nocheck call [ALSA] Add snd-als300 driver for Avance Logic ALS300/ALS300+ soundcards [ALSA] Add snd-riptide driver for Conexant Riptide chip [ALSA] hda-codec - Fix noisy output wtih AD1986A 3stack model ...
Diffstat (limited to 'sound/usb/usbmixer.c')
-rw-r--r--sound/usb/usbmixer.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c
index 8d08b34a1cb5..ce86283ee0fa 100644
--- a/sound/usb/usbmixer.c
+++ b/sound/usb/usbmixer.c
@@ -306,8 +306,8 @@ static int get_relative_value(struct usb_mixer_elem_info *cval, int val)
cval->res = 1;
if (val < cval->min)
return 0;
- else if (val > cval->max)
- return (cval->max - cval->min) / cval->res;
+ else if (val >= cval->max)
+ return (cval->max - cval->min + cval->res - 1) / cval->res;
else
return (val - cval->min) / cval->res;
}
@@ -670,6 +670,36 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min)
}
if (cval->res == 0)
cval->res = 1;
+
+ /* Additional checks for the proper resolution
+ *
+ * Some devices report smaller resolutions than actually
+ * reacting. They don't return errors but simply clip
+ * to the lower aligned value.
+ */
+ if (cval->min + cval->res < cval->max) {
+ int last_valid_res = cval->res;
+ int saved, test, check;
+ get_cur_mix_value(cval, minchn, &saved);
+ for (;;) {
+ test = saved;
+ if (test < cval->max)
+ test += cval->res;
+ else
+ test -= cval->res;
+ if (test < cval->min || test > cval->max ||
+ set_cur_mix_value(cval, minchn, test) ||
+ get_cur_mix_value(cval, minchn, &check)) {
+ cval->res = last_valid_res;
+ break;
+ }
+ if (test == check)
+ break;
+ cval->res *= 2;
+ }
+ set_cur_mix_value(cval, minchn, saved);
+ }
+
cval->initialized = 1;
}
return 0;
@@ -695,7 +725,8 @@ static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
if (! cval->initialized)
get_min_max(cval, 0);
uinfo->value.integer.min = 0;
- uinfo->value.integer.max = (cval->max - cval->min) / cval->res;
+ uinfo->value.integer.max =
+ (cval->max - cval->min + cval->res - 1) / cval->res;
}
return 0;
}