mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-30 10:52:50 +00:00
MFC r359321:
Factor out USB audio mixer value range check. Sponsored by: Mellanox Technologies
This commit is contained in:
parent
7d70098a7c
commit
a308210e1f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/stable/10/; revision=359872
@ -5380,25 +5380,19 @@ uaudio_mixer_bsd2value(struct uaudio_mixer_node *mc, int val)
|
|||||||
{
|
{
|
||||||
if (mc->type == MIX_ON_OFF) {
|
if (mc->type == MIX_ON_OFF) {
|
||||||
val = (val != 0);
|
val = (val != 0);
|
||||||
} else if (mc->type == MIX_SELECTOR) {
|
} else if (mc->type != MIX_SELECTOR) {
|
||||||
if ((val < mc->minval) ||
|
|
||||||
(val > mc->maxval)) {
|
|
||||||
val = mc->minval;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* compute actual volume */
|
/* compute actual volume */
|
||||||
val = (val * mc->mul) / 100;
|
val = (val * mc->mul) / 100;
|
||||||
|
|
||||||
/* add lower offset */
|
/* add lower offset */
|
||||||
val = val + mc->minval;
|
val = val + mc->minval;
|
||||||
|
}
|
||||||
/* make sure we don't write a value out of range */
|
/* make sure we don't write a value out of range */
|
||||||
if (val > mc->maxval)
|
if (val > mc->maxval)
|
||||||
val = mc->maxval;
|
val = mc->maxval;
|
||||||
else if (val < mc->minval)
|
else if (val < mc->minval)
|
||||||
val = mc->minval;
|
val = mc->minval;
|
||||||
}
|
|
||||||
|
|
||||||
DPRINTFN(6, "type=0x%03x val=%d min=%d max=%d val=%d\n",
|
DPRINTFN(6, "type=0x%03x val=%d min=%d max=%d val=%d\n",
|
||||||
mc->type, val, mc->minval, mc->maxval, val);
|
mc->type, val, mc->minval, mc->maxval, val);
|
||||||
|
Loading…
Reference in New Issue
Block a user