Lines Matching refs:ctl
58 struct mixer_ctl *ctl; member
72 if (mixer->ctl) { in mixer_close()
74 if (mixer->ctl[n].ename) { in mixer_close()
75 unsigned int max = mixer->ctl[n].info->value.enumerated.items; in mixer_close()
77 free(mixer->ctl[n].ename[m]); in mixer_close()
78 free(mixer->ctl[n].ename); in mixer_close()
81 free(mixer->ctl); in mixer_close()
115 mixer->ctl = calloc(elist.count, sizeof(struct mixer_ctl)); in mixer_open()
117 if (!mixer->ctl || !mixer->elem_info) in mixer_open()
139 mixer->ctl[n].info = ei; in mixer_open()
140 mixer->ctl[n].mixer = mixer; in mixer_open()
145 mixer->ctl[n].ename = enames; in mixer_open()
189 return mixer->ctl + id; in mixer_get_ctl()
203 return mixer->ctl + n; in mixer_get_ctl_by_name()
208 void mixer_ctl_update(struct mixer_ctl *ctl) in mixer_ctl_update() argument
210 ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_INFO, ctl->info); in mixer_ctl_update()
213 const char *mixer_ctl_get_name(struct mixer_ctl *ctl) in mixer_ctl_get_name() argument
215 if (!ctl) in mixer_ctl_get_name()
218 return (const char *)ctl->info->id.name; in mixer_ctl_get_name()
221 enum mixer_ctl_type mixer_ctl_get_type(struct mixer_ctl *ctl) in mixer_ctl_get_type() argument
223 if (!ctl) in mixer_ctl_get_type()
226 switch (ctl->info->type) { in mixer_ctl_get_type()
237 const char *mixer_ctl_get_type_string(struct mixer_ctl *ctl) in mixer_ctl_get_type_string() argument
239 if (!ctl) in mixer_ctl_get_type_string()
242 switch (ctl->info->type) { in mixer_ctl_get_type_string()
253 unsigned int mixer_ctl_get_num_values(struct mixer_ctl *ctl) in mixer_ctl_get_num_values() argument
255 if (!ctl) in mixer_ctl_get_num_values()
258 return ctl->info->count; in mixer_ctl_get_num_values()
285 int mixer_ctl_get_percent(struct mixer_ctl *ctl, unsigned int id) in mixer_ctl_get_percent() argument
287 if (!ctl || (ctl->info->type != SNDRV_CTL_ELEM_TYPE_INTEGER)) in mixer_ctl_get_percent()
290 return int_to_percent(ctl->info, mixer_ctl_get_value(ctl, id)); in mixer_ctl_get_percent()
293 int mixer_ctl_set_percent(struct mixer_ctl *ctl, unsigned int id, int percent) in mixer_ctl_set_percent() argument
295 if (!ctl || (ctl->info->type != SNDRV_CTL_ELEM_TYPE_INTEGER)) in mixer_ctl_set_percent()
298 return mixer_ctl_set_value(ctl, id, percent_to_int(ctl->info, percent)); in mixer_ctl_set_percent()
301 int mixer_ctl_get_value(struct mixer_ctl *ctl, unsigned int id) in mixer_ctl_get_value() argument
306 if (!ctl || (id >= ctl->info->count)) in mixer_ctl_get_value()
310 ev.id.numid = ctl->info->id.numid; in mixer_ctl_get_value()
311 ret = ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_READ, &ev); in mixer_ctl_get_value()
315 switch (ctl->info->type) { in mixer_ctl_get_value()
335 int mixer_ctl_get_array(struct mixer_ctl *ctl, void *array, size_t count) in mixer_ctl_get_array() argument
342 if (!ctl || (count > ctl->info->count) || !count || !array) in mixer_ctl_get_array()
346 ev.id.numid = ctl->info->id.numid; in mixer_ctl_get_array()
348 switch (ctl->info->type) { in mixer_ctl_get_array()
351 ret = ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_READ, &ev); in mixer_ctl_get_array()
360 if (ctl->info->access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE) { in mixer_ctl_get_array()
369 tlv->numid = ctl->info->id.numid; in mixer_ctl_get_array()
371 ret = ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_TLV_READ, tlv); in mixer_ctl_get_array()
380 ret = ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_READ, &ev); in mixer_ctl_get_array()
402 int mixer_ctl_set_value(struct mixer_ctl *ctl, unsigned int id, int value) in mixer_ctl_set_value() argument
407 if (!ctl || (id >= ctl->info->count)) in mixer_ctl_set_value()
411 ev.id.numid = ctl->info->id.numid; in mixer_ctl_set_value()
412 ret = ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_READ, &ev); in mixer_ctl_set_value()
416 switch (ctl->info->type) { in mixer_ctl_set_value()
437 return ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, &ev); in mixer_ctl_set_value()
440 int mixer_ctl_set_array(struct mixer_ctl *ctl, const void *array, size_t count) in mixer_ctl_set_array() argument
446 if (!ctl || (count > ctl->info->count) || !count || !array) in mixer_ctl_set_array()
450 ev.id.numid = ctl->info->id.numid; in mixer_ctl_set_array()
452 switch (ctl->info->type) { in mixer_ctl_set_array()
461 if (ctl->info->access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE) { in mixer_ctl_set_array()
469 tlv->numid = ctl->info->id.numid; in mixer_ctl_set_array()
473 ret = ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_TLV_WRITE, tlv); in mixer_ctl_set_array()
494 return ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, &ev); in mixer_ctl_set_array()
497 int mixer_ctl_get_range_min(struct mixer_ctl *ctl) in mixer_ctl_get_range_min() argument
499 if (!ctl || (ctl->info->type != SNDRV_CTL_ELEM_TYPE_INTEGER)) in mixer_ctl_get_range_min()
502 return ctl->info->value.integer.min; in mixer_ctl_get_range_min()
505 int mixer_ctl_get_range_max(struct mixer_ctl *ctl) in mixer_ctl_get_range_max() argument
507 if (!ctl || (ctl->info->type != SNDRV_CTL_ELEM_TYPE_INTEGER)) in mixer_ctl_get_range_max()
510 return ctl->info->value.integer.max; in mixer_ctl_get_range_max()
513 unsigned int mixer_ctl_get_num_enums(struct mixer_ctl *ctl) in mixer_ctl_get_num_enums() argument
515 if (!ctl) in mixer_ctl_get_num_enums()
518 return ctl->info->value.enumerated.items; in mixer_ctl_get_num_enums()
521 const char *mixer_ctl_get_enum_string(struct mixer_ctl *ctl, in mixer_ctl_get_enum_string() argument
524 if (!ctl || (ctl->info->type != SNDRV_CTL_ELEM_TYPE_ENUMERATED) || in mixer_ctl_get_enum_string()
525 (enum_id >= ctl->info->value.enumerated.items)) in mixer_ctl_get_enum_string()
528 return (const char *)ctl->ename[enum_id]; in mixer_ctl_get_enum_string()
531 int mixer_ctl_set_enum_by_string(struct mixer_ctl *ctl, const char *string) in mixer_ctl_set_enum_by_string() argument
537 if (!ctl || (ctl->info->type != SNDRV_CTL_ELEM_TYPE_ENUMERATED)) in mixer_ctl_set_enum_by_string()
540 num_enums = ctl->info->value.enumerated.items; in mixer_ctl_set_enum_by_string()
542 if (!strcmp(string, ctl->ename[i])) { in mixer_ctl_set_enum_by_string()
545 ev.id.numid = ctl->info->id.numid; in mixer_ctl_set_enum_by_string()
546 ret = ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, &ev); in mixer_ctl_set_enum_by_string()