From 4a484e116b1d351f732ea172dcd9cf00e29edf20 Mon Sep 17 00:00:00 2001 From: Baptiste Robert Date: Thu, 12 Sep 2013 15:37:53 +0200 Subject: Tinyalsa: standardize error message for wrong input value Currently, if a user sets a mixer with a percentage value greater than the maximum, tinyalsa does not inform the user about this "error" and silently replaces the user's value by the maximum. However, if a user sets a mixer with an integer value greater than the maximum, tinyalsa informs the user with an error. This patch purpose is to define the same behaviour in both quoted cases: user is informed through an error. Change-Id: I79547758266d1eb08a65d7b1355ec9859f3b27bb Signed-off-by: Baptiste Robert Signed-off-by: Vinod Koul --- mixer.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mixer.c b/mixer.c index b6c854f..057a271 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; } -- cgit v1.2.3 From ce2b63440f66bb77dc065768272079d0fcf26c18 Mon Sep 17 00:00:00 2001 From: "David.Coutherut" Date: Tue, 11 Jun 2013 16:22:57 +0200 Subject: tinyalsa: unable to set BYTE mixer tinyalsa set mixer function didn't support BYTE element type Add BYTE element type support Change-Id: I95d1d82150805f16cc5103bac9c9c9500210bbbf Signed-off-by: David Coutherut Signed-off-by: Vinod Koul --- mixer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mixer.c b/mixer.c index 057a271..9be8623 100644 --- a/mixer.c +++ b/mixer.c @@ -401,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; } -- cgit v1.2.3