aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Wilson <ksattic@gmail.com>2014-09-04 09:52:32 -0700
committerSimon Wilson <ksattic@gmail.com>2014-09-04 09:52:32 -0700
commit40baeb10f5868885ec7c7ffedc47049c8e50c8a0 (patch)
tree6ab2f00b970ce5d4f8270a5deefe684354440fcf
parentad80762a3b75e39bb26faf091b203c1d7c49fc05 (diff)
parentce2b63440f66bb77dc065768272079d0fcf26c18 (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.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/mixer.c b/mixer.c
index b6c854f..9be8623 100644
--- a/mixer.c
+++ b/mixer.c
@@ -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;
}