Lines Matching refs:ctl
134 if (mixer->ctl) { in mixer_close()
136 if (mixer->ctl[n].ename) { in mixer_close()
137 unsigned max = mixer->ctl[n].info->value.enumerated.items; in mixer_close()
139 free(mixer->ctl[n].ename[m]); in mixer_close()
140 free(mixer->ctl[n].ename); in mixer_close()
143 free(mixer->ctl); in mixer_close()
177 mixer->ctl = calloc(elist.count, sizeof(struct mixer_ctl)); in mixer_open()
179 if (!mixer->ctl || !mixer->info) in mixer_open()
198 mixer->ctl[n].info = ei; in mixer_open()
199 mixer->ctl[n].mixer = mixer; in mixer_open()
204 mixer->ctl[n].ename = enames; in mixer_open()
273 ALOGV(" { %s=0", mixer->ctl[n].ename[0]); in mixer_dump()
275 ALOGV(", %s=%d", mixer->ctl[n].ename[m],m); in mixer_dump()
292 return mixer->ctl + n; in mixer_get_control()
302 return mixer->ctl + n; in mixer_get_nth_control()
311 int mixer_ctl_read_tlv(struct mixer_ctl *ctl, in mixer_ctl_read_tlv() argument
319 if(!!(ctl->info->access & SNDRV_CTL_ELEM_ACCESS_TLV_READ)) { in mixer_ctl_read_tlv()
326 xtlv->numid = ctl->info->id.numid; in mixer_ctl_read_tlv()
329 if (ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_TLV_READ, xtlv) < 0) { in mixer_ctl_read_tlv()
362 *max = (ctl->info->value.integer.max); in mixer_ctl_read_tlv()
363 print_dB((long)ctl->info->value.integer.max); in mixer_ctl_read_tlv()
394 void mixer_ctl_get(struct mixer_ctl *ctl, unsigned *value) in mixer_ctl_get() argument
403 if (is_volume(ctl->info->id.name, &type)) { in mixer_ctl_get()
409 mixer_ctl_read_tlv(ctl, tlv, &min, &max, &tlv_type); in mixer_ctl_get()
415 ev.id.numid = ctl->info->id.numid; in mixer_ctl_get()
416 if (ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_READ, &ev)) in mixer_ctl_get()
418 ALOGV("%s:", ctl->info->id.name); in mixer_ctl_get()
420 switch (ctl->info->type) { in mixer_ctl_get()
422 for (n = 0; n < ctl->info->count; n++) in mixer_ctl_get()
427 for (n = 0; n < ctl->info->count; n++) in mixer_ctl_get()
433 for (n = 0; n < ctl->info->count; n++) in mixer_ctl_get()
438 for (n = 0; n < ctl->info->count; n++) { in mixer_ctl_get()
441 (v < ctl->info->value.enumerated.items) ? ctl->ename[v] : "???"); in mixer_ctl_get()
479 int mixer_ctl_mulvalues(struct mixer_ctl *ctl, int count, char ** argv) in mixer_ctl_mulvalues() argument
484 if (!ctl) { in mixer_ctl_mulvalues()
488 if (count < ctl->info->count || count > ctl->info->count) in mixer_ctl_mulvalues()
493 ev.id.numid = ctl->info->id.numid; in mixer_ctl_mulvalues()
494 switch (ctl->info->type) { in mixer_ctl_mulvalues()
496 for (n = 0; n < ctl->info->count; n++) in mixer_ctl_mulvalues()
500 for (n = 0; n < ctl->info->count; n++) { in mixer_ctl_mulvalues()
507 for (n = 0; n < ctl->info->count; n++) { in mixer_ctl_mulvalues()
508 long long value_ll = scale_int64(ctl->info, atoi(argv[n])); in mixer_ctl_mulvalues()
519 return ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, &ev); in mixer_ctl_mulvalues()
522 int mixer_ctl_set(struct mixer_ctl *ctl, unsigned percent) in mixer_ctl_set() argument
532 if (!ctl) { in mixer_ctl_set()
537 if (is_volume(ctl->info->id.name, &type)) { in mixer_ctl_set()
542 } else if (!mixer_ctl_read_tlv(ctl, tlv, &min, &max, &tlv_type)) { in mixer_ctl_set()
566 ev.id.numid = ctl->info->id.numid; in mixer_ctl_set()
567 switch (ctl->info->type) { in mixer_ctl_set()
569 for (n = 0; n < ctl->info->count; n++) in mixer_ctl_set()
575 value = scale_int(ctl->info, percent); in mixer_ctl_set()
578 for (n = 0; n < ctl->info->count; n++) in mixer_ctl_set()
585 value = scale_int64(ctl->info, percent); in mixer_ctl_set()
588 for (n = 0; n < ctl->info->count; n++) in mixer_ctl_set()
603 return ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, &ev); in mixer_ctl_set()
613 static int set_volume_simple(struct mixer_ctl *ctl, in set_volume_simple() argument
647 if (!ctl) { in set_volume_simple()
651 if (count < ctl->info->count || count > ctl->info->count) in set_volume_simple()
657 ev.id.numid = ctl->info->id.numid; in set_volume_simple()
658 switch (ctl->info->type) { in set_volume_simple()
660 for (n = 0; n < ctl->info->count; n++) in set_volume_simple()
665 for (n = 0; n < ctl->info->count; n++) in set_volume_simple()
671 for (n = 0; n < ctl->info->count; n++) { in set_volume_simple()
672 long long value_ll = scale_int64(ctl->info, val); in set_volume_simple()
684 return ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, &ev); in set_volume_simple()
693 int mixer_ctl_set_value(struct mixer_ctl *ctl, int count, char ** argv) in mixer_ctl_set_value() argument
701 if (is_volume(ctl->info->id.name, &type)) { in mixer_ctl_set_value()
706 } else if (!mixer_ctl_read_tlv(ctl, tlv, &min, &max, &tlv_type)) { in mixer_ctl_set_value()
708 if (set_volume_simple(ctl, argv, min, max, count)) in mixer_ctl_set_value()
709 mixer_ctl_mulvalues(ctl, count, argv); in mixer_ctl_set_value()
714 mixer_ctl_mulvalues(ctl, count, argv); in mixer_ctl_set_value()
720 int mixer_ctl_select(struct mixer_ctl *ctl, const char *value) in mixer_ctl_select() argument
726 if (ctl->info->type != SNDRV_CTL_ELEM_TYPE_ENUMERATED) { in mixer_ctl_select()
733 max = ctl->info->value.enumerated.items; in mixer_ctl_select()
736 str_len = strnlen(ctl->ename[n], 64); in mixer_ctl_select()
740 if (!strncmp(value, ctl->ename[n], str_len)) { in mixer_ctl_select()
743 ev.id.numid = ctl->info->id.numid; in mixer_ctl_select()
744 if (ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, &ev) < 0) in mixer_ctl_select()