diff options
author | Simon Wilson <ksattic@gmail.com> | 2014-09-04 09:52:32 -0700 |
---|---|---|
committer | Simon Wilson <ksattic@gmail.com> | 2014-09-04 09:52:32 -0700 |
commit | 40baeb10f5868885ec7c7ffedc47049c8e50c8a0 (patch) | |
tree | 6ab2f00b970ce5d4f8270a5deefe684354440fcf | |
parent | ad80762a3b75e39bb26faf091b203c1d7c49fc05 (diff) | |
parent | ce2b63440f66bb77dc065768272079d0fcf26c18 (diff) |
Merge pull request #49 from vinodkoul/fixes
Allow setting of single byte control and make error from percent_to_int more consistent.
-rw-r--r-- | mixer.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -259,14 +259,11 @@ unsigned int mixer_ctl_get_num_values(struct mixer_ctl *ctl) static int percent_to_int(struct snd_ctl_elem_info *ei, int percent) { - int range; - - if (percent > 100) - percent = 100; - else if (percent < 0) - percent = 0; + if ((percent > 100) || (percent < 0)) { + return -EINVAL; + } - range = (ei->value.integer.max - ei->value.integer.min); + int range = (ei->value.integer.max - ei->value.integer.min); return ei->value.integer.min + (range * percent) / 100; } @@ -404,6 +401,10 @@ int mixer_ctl_set_value(struct mixer_ctl *ctl, unsigned int id, int value) ev.value.enumerated.item[id] = value; break; + case SNDRV_CTL_ELEM_TYPE_BYTES: + ev.value.bytes.data[id] = value; + break; + default: return -EINVAL; } |