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