aboutsummaryrefslogtreecommitdiff
path: root/src/mixer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mixer.c')
-rw-r--r--src/mixer.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/mixer.c b/src/mixer.c
index daa04f7..b7239fd 100644
--- a/src/mixer.c
+++ b/src/mixer.c
@@ -590,8 +590,20 @@ int mixer_ctl_get_array(const struct mixer_ctl *ctl, void *array, size_t count)
int ret = 0;
size_t size;
void *source;
+ size_t total_count;
- if (!ctl || (count > ctl->info.count) || !count || !array)
+ if ((!ctl) || !count || !array)
+ return -EINVAL;
+
+ total_count = ctl->info.count;
+
+ if ((ctl->info.type == SNDRV_CTL_ELEM_TYPE_BYTES) &&
+ (mixer_ctl_is_access_tlv_rw(ctl))) {
+ /* Additional two words is for the TLV header */
+ total_count += TLV_HEADER_SIZE;
+ }
+
+ if (count > total_count)
return -EINVAL;
memset(&ev, 0, sizeof(ev));
@@ -714,8 +726,20 @@ int mixer_ctl_set_array(struct mixer_ctl *ctl, const void *array, size_t count)
struct snd_ctl_elem_value ev;
size_t size;
void *dest;
+ size_t total_count;
+
+ if ((!ctl) || !count || !array)
+ return -EINVAL;
+
+ total_count = ctl->info.count;
+
+ if ((ctl->info.type == SNDRV_CTL_ELEM_TYPE_BYTES) &&
+ (mixer_ctl_is_access_tlv_rw(ctl))) {
+ /* Additional TLV header */
+ total_count += TLV_HEADER_SIZE;
+ }
- if (!ctl || (count > ctl->info.count) || !count || !array)
+ if (count > total_count)
return -EINVAL;
memset(&ev, 0, sizeof(ev));