Lines Matching +full:cs +full:- +full:dev +full:- +full:assoc

1 // SPDX-License-Identifier: GPL-2.0-or-later
17 * - support for UAC2 effect units
18 * - support for graphical equalizers
19 * - RANGE and MEM set commands (UAC2)
20 * - RANGE and MEM interrupt dispatchers (UAC2)
21 * - audio channel clustering (UAC2)
22 * - audio sample rate converter units (UAC2)
23 * - proper handling of clock multipliers (UAC2)
24 * - dispatch clock change notifications (UAC2)
25 * - stop PCM streams which use a clock that became invalid
26 * - stop PCM streams which use a clock selector that has changed
27 * - parse available sample rates again when clock sources changed
38 #include <linux/usb/audio-v2.h>
39 #include <linux/usb/audio-v3.h>
77 /*E-mu 0202/0404/0204 eXtension Unit(XU) control*/
106 for (; p->id; p++) { in find_map()
107 if (p->id == unitid && in find_map()
108 (!control || !p->control || control == p->control)) in find_map()
120 if (!p || !p->name) in check_mapped_name()
123 buflen--; in check_mapped_name()
124 len = strscpy(buf, p->name, buflen); in check_mapped_name()
130 ((cval)->head.mixer->ignore_ctl_error ? 0 : (err))
136 if (!p || p->name || p->dB) in check_ignored_ctl()
145 if (p && p->dB) { in check_mapped_dB()
146 cval->dBmin = p->dB->min; in check_mapped_dB()
147 cval->dBmax = p->dB->max; in check_mapped_dB()
148 cval->min_mute = p->dB->min_mute; in check_mapped_dB()
149 cval->initialized = 1; in check_mapped_dB()
160 if (!state->selector_map) in check_mapped_selector_name()
162 for (p = state->selector_map; p->id; p++) { in check_mapped_selector_name()
163 if (p->id == unitid && index < p->count) { in check_mapped_selector_name()
164 len = strscpy(buf, p->names[index], buflen); in check_mapped_selector_name()
180 while ((hdr = snd_usb_find_desc(state->buffer, state->buflen, hdr, in find_audio_control_unit()
182 if (hdr->bLength >= 4 && in find_audio_control_unit()
183 hdr->bDescriptorSubtype >= UAC_INPUT_TERMINAL && in find_audio_control_unit()
184 hdr->bDescriptorSubtype <= UAC3_SAMPLE_RATE_CONVERTER && in find_audio_control_unit()
185 hdr->bUnitID == unit) in find_audio_control_unit()
198 int len = usb_string(chip->dev, index, buf, maxlen - 1); in snd_usb_copy_string_desc()
208 * convert from the byte/word on usb descriptor to the zero-based integer
212 switch (cval->val_type) { in convert_signed_value()
223 val -= 0x100; in convert_signed_value()
231 val -= 0x10000; in convert_signed_value()
238 * convert from the zero-based int to the byte/word for usb descriptor
242 switch (cval->val_type) { in convert_bytes_value()
259 if (!cval->res) in get_relative_value()
260 cval->res = 1; in get_relative_value()
261 if (val < cval->min) in get_relative_value()
263 else if (val >= cval->max) in get_relative_value()
264 return DIV_ROUND_UP(cval->max - cval->min, cval->res); in get_relative_value()
266 return (val - cval->min) / cval->res; in get_relative_value()
272 return cval->min; in get_abs_value()
273 if (!cval->res) in get_abs_value()
274 cval->res = 1; in get_abs_value()
275 val *= cval->res; in get_abs_value()
276 val += cval->min; in get_abs_value()
277 if (val > cval->max) in get_abs_value()
278 return cval->max; in get_abs_value()
304 return get_iface_desc(mixer->hostif)->bInterfaceNumber; in mixer_ctrl_intf()
310 struct snd_usb_audio *chip = cval->head.mixer->chip; in get_ctl_value_v1()
312 int val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1; in get_ctl_value_v1()
318 return -EIO; in get_ctl_value_v1()
320 while (timeout-- > 0) { in get_ctl_value_v1()
321 idx = mixer_ctrl_intf(cval->head.mixer) | (cval->head.id << 8); in get_ctl_value_v1()
322 err = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), request, in get_ctl_value_v1()
329 } else if (err == -ETIMEDOUT) { in get_ctl_value_v1()
335 request, validx, idx, cval->val_type); in get_ctl_value_v1()
336 err = -EINVAL; in get_ctl_value_v1()
346 struct snd_usb_audio *chip = cval->head.mixer->chip; in get_ctl_value_v2()
353 val_size = uac2_ctl_value_size(cval->val_type); in get_ctl_value_v2()
366 return -EIO; in get_ctl_value_v2()
368 idx = mixer_ctrl_intf(cval->head.mixer) | (cval->head.id << 8); in get_ctl_value_v2()
369 ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), bRequest, in get_ctl_value_v2()
377 request, validx, idx, cval->val_type); in get_ctl_value_v2()
397 return -EINVAL; in get_ctl_value_v2()
409 validx += cval->idx_off; in get_ctl_value()
411 return (cval->head.mixer->protocol == UAC_VERSION_1) ? in get_ctl_value()
427 (cval->control << 8) | channel, in get_cur_mix_raw()
436 if (cval->cached & BIT(channel)) { in snd_usb_get_cur_mix_value()
437 *value = cval->cache_val[index]; in snd_usb_get_cur_mix_value()
442 if (!cval->head.mixer->ignore_ctl_error) in snd_usb_get_cur_mix_value()
443 usb_audio_dbg(cval->head.mixer->chip, in snd_usb_get_cur_mix_value()
445 cval->control, channel, err); in snd_usb_get_cur_mix_value()
448 cval->cached |= BIT(channel); in snd_usb_get_cur_mix_value()
449 cval->cache_val[index] = *value; in snd_usb_get_cur_mix_value()
460 struct snd_usb_audio *chip = cval->head.mixer->chip; in snd_usb_mixer_set_ctl_value()
464 validx += cval->idx_off; in snd_usb_mixer_set_ctl_value()
467 if (cval->head.mixer->protocol == UAC_VERSION_1) { in snd_usb_mixer_set_ctl_value()
468 val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1; in snd_usb_mixer_set_ctl_value()
470 val_len = uac2_ctl_value_size(cval->val_type); in snd_usb_mixer_set_ctl_value()
475 return -EINVAL; in snd_usb_mixer_set_ctl_value()
489 return -EIO; in snd_usb_mixer_set_ctl_value()
491 while (timeout-- > 0) { in snd_usb_mixer_set_ctl_value()
492 idx = mixer_ctrl_intf(cval->head.mixer) | (cval->head.id << 8); in snd_usb_mixer_set_ctl_value()
493 err = snd_usb_ctl_msg(chip->dev, in snd_usb_mixer_set_ctl_value()
494 usb_sndctrlpipe(chip->dev, 0), request, in snd_usb_mixer_set_ctl_value()
500 } else if (err == -ETIMEDOUT) { in snd_usb_mixer_set_ctl_value()
505 request, validx, idx, cval->val_type, buf[0], buf[1]); in snd_usb_mixer_set_ctl_value()
506 err = -EINVAL; in snd_usb_mixer_set_ctl_value()
524 cval->master_readonly : in snd_usb_set_cur_mix_value()
525 cval->ch_readonly & BIT(channel - 1); in snd_usb_set_cur_mix_value()
528 usb_audio_dbg(cval->head.mixer->chip, in snd_usb_set_cur_mix_value()
530 __func__, channel, cval->control); in snd_usb_set_cur_mix_value()
535 UAC_SET_CUR, (cval->control << 8) | channel, in snd_usb_set_cur_mix_value()
539 cval->cached |= BIT(channel); in snd_usb_set_cur_mix_value()
540 cval->cache_val[index] = value; in snd_usb_set_cur_mix_value()
550 struct usb_mixer_elem_info *cval = kcontrol->private_data; in snd_usb_mixer_vol_tlv()
554 return -ENOMEM; in snd_usb_mixer_vol_tlv()
555 if (cval->min_mute) in snd_usb_mixer_vol_tlv()
557 scale[2] = cval->dBmin; in snd_usb_mixer_vol_tlv()
558 scale[3] = cval->dBmax; in snd_usb_mixer_vol_tlv()
560 return -EFAULT; in snd_usb_mixer_vol_tlv()
593 struct usb_mixer_interface *mixer = list->mixer; in snd_usb_mixer_add_list()
596 while (snd_ctl_find_id(mixer->chip->card, &kctl->id)) in snd_usb_mixer_add_list()
597 kctl->id.index++; in snd_usb_mixer_add_list()
598 err = snd_ctl_add(mixer->chip->card, kctl); in snd_usb_mixer_add_list()
600 usb_audio_dbg(mixer->chip, "cannot add control (err = %d)\n", in snd_usb_mixer_add_list()
604 list->kctl = kctl; in snd_usb_mixer_add_list()
605 list->is_std_info = is_std_info; in snd_usb_mixer_add_list()
606 list->next_id_elem = mixer->id_elems[list->id]; in snd_usb_mixer_add_list()
607 mixer->id_elems[list->id] = list; in snd_usb_mixer_add_list()
653 { 0x0712, "Multi-Track Recorder" },
664 if (iterm->name) { in get_term_name()
665 len = snd_usb_copy_string_desc(chip, iterm->name, in get_term_name()
671 /* virtual type - not a real terminal */ in get_term_name()
672 if (iterm->type >> 16) { in get_term_name()
675 switch (iterm->type >> 16) { in get_term_name()
689 return sprintf(name, "Unit %d", iterm->id); in get_term_name()
693 switch (iterm->type & 0xff00) { in get_term_name()
708 for (names = iterm_names; names->type; names++) { in get_term_name()
709 if (names->type == iterm->type) { in get_term_name()
710 strcpy(name, names->name); in get_term_name()
711 return strlen(names->name); in get_term_name()
726 err = snd_usb_ctl_msg(state->chip->dev, in get_cluster_channels_v3()
727 usb_rcvctrlpipe(state->chip->dev, 0), in get_cluster_channels_v3()
731 snd_usb_ctrl_intf(state->mixer->hostif), in get_cluster_channels_v3()
736 err = -EIO; in get_cluster_channels_v3()
743 usb_audio_err(state->chip, "cannot request logical cluster ID: %d (err: %d)\n", cluster_id, err); in get_cluster_channels_v3()
755 switch (state->mixer->protocol) { in uac_mixer_unit_get_channels()
759 if (desc->bLength < sizeof(*desc) + desc->bNrInPins + 1) in uac_mixer_unit_get_channels()
760 return 0; /* no bmControls -> skip */ in uac_mixer_unit_get_channels()
784 term->type = le16_to_cpu(d->wTerminalType); in parse_term_uac1_iterm_unit()
785 term->channels = d->bNrChannels; in parse_term_uac1_iterm_unit()
786 term->chconfig = le16_to_cpu(d->wChannelConfig); in parse_term_uac1_iterm_unit()
787 term->name = d->iTerminal; in parse_term_uac1_iterm_unit()
799 err = __check_input_term(state, d->bCSourceID, term); in parse_term_uac2_iterm_unit()
806 term->id = id; in parse_term_uac2_iterm_unit()
807 term->type = le16_to_cpu(d->wTerminalType); in parse_term_uac2_iterm_unit()
808 term->channels = d->bNrChannels; in parse_term_uac2_iterm_unit()
809 term->chconfig = le32_to_cpu(d->bmChannelConfig); in parse_term_uac2_iterm_unit()
810 term->name = d->iTerminal; in parse_term_uac2_iterm_unit()
822 err = __check_input_term(state, d->bCSourceID, term); in parse_term_uac3_iterm_unit()
829 term->id = id; in parse_term_uac3_iterm_unit()
830 term->type = le16_to_cpu(d->wTerminalType); in parse_term_uac3_iterm_unit()
832 err = get_cluster_channels_v3(state, le16_to_cpu(d->wClusterDescrID)); in parse_term_uac3_iterm_unit()
835 term->channels = err; in parse_term_uac3_iterm_unit()
838 term->chconfig = 0; in parse_term_uac3_iterm_unit()
840 term->name = le16_to_cpu(d->wTerminalDescrStr); in parse_term_uac3_iterm_unit()
849 int protocol = state->mixer->protocol; in parse_term_mixer_unit()
856 term->type = UAC3_MIXER_UNIT << 16; /* virtual type */ in parse_term_mixer_unit()
857 term->channels = err; in parse_term_mixer_unit()
859 term->chconfig = uac_mixer_unit_wChannelConfig(d, protocol); in parse_term_mixer_unit()
860 term->name = uac_mixer_unit_iMixer(d); in parse_term_mixer_unit()
873 err = __check_input_term(state, d->baSourceID[0], term); in parse_term_selector_unit()
876 term->type = UAC3_SELECTOR_UNIT << 16; /* virtual type */ in parse_term_selector_unit()
877 term->id = id; in parse_term_selector_unit()
878 if (state->mixer->protocol != UAC_VERSION_3) in parse_term_selector_unit()
879 term->name = uac_selector_unit_iSelector(d); in parse_term_selector_unit()
888 int protocol = state->mixer->protocol; in parse_term_proc_unit()
891 if (d->bNrInPins) { in parse_term_proc_unit()
893 err = __check_input_term(state, d->baSourceID[0], term); in parse_term_proc_unit()
898 term->type = vtype << 16; /* virtual type */ in parse_term_proc_unit()
899 term->id = id; in parse_term_proc_unit()
904 if (!term->channels) { in parse_term_proc_unit()
905 term->channels = uac_processing_unit_bNrChannels(d); in parse_term_proc_unit()
906 term->chconfig = uac_processing_unit_wChannelConfig(d, protocol); in parse_term_proc_unit()
908 term->name = uac_processing_unit_iProcessing(d, protocol); in parse_term_proc_unit()
919 err = __check_input_term(state, d->bSourceID, term); in parse_term_effect_unit()
922 term->type = UAC3_EFFECT_UNIT << 16; /* virtual type */ in parse_term_effect_unit()
923 term->id = id; in parse_term_effect_unit()
933 term->type = UAC3_CLOCK_SOURCE << 16; /* virtual type */ in parse_term_uac2_clock_source()
934 term->id = id; in parse_term_uac2_clock_source()
935 term->name = d->iClockSource; in parse_term_uac2_clock_source()
945 term->type = UAC3_CLOCK_SOURCE << 16; /* virtual type */ in parse_term_uac3_clock_source()
946 term->id = id; in parse_term_uac3_clock_source()
947 term->name = le16_to_cpu(d->wClockSourceStr); in parse_term_uac3_clock_source()
960 int protocol = state->mixer->protocol; in __check_input_term()
966 if (test_and_set_bit(id, state->termbitmap)) in __check_input_term()
967 return -EINVAL; in __check_input_term()
976 term->id = id; in __check_input_term()
985 id = d->bSourceID; in __check_input_term()
1022 return -ENODEV; in __check_input_term()
1025 return -ENODEV; in __check_input_term()
1033 memset(state->termbitmap, 0, sizeof(state->termbitmap)); in check_input_term()
1046 int type_uac2; /* data type for uac2 if different from uac1, else -1 */
1050 { UAC_FU_MUTE, "Mute", USB_MIXER_INV_BOOLEAN, -1 },
1051 { UAC_FU_VOLUME, "Volume", USB_MIXER_S16, -1 },
1052 { UAC_FU_BASS, "Tone Control - Bass", USB_MIXER_S8, -1 },
1053 { UAC_FU_MID, "Tone Control - Mid", USB_MIXER_S8, -1 },
1054 { UAC_FU_TREBLE, "Tone Control - Treble", USB_MIXER_S8, -1 },
1055 …{ UAC_FU_GRAPHIC_EQUALIZER, "Graphic Equalizer", USB_MIXER_S8, -1 }, /* FIXME: not implemented yet…
1056 { UAC_FU_AUTOMATIC_GAIN, "Auto Gain Control", USB_MIXER_BOOLEAN, -1 },
1058 { UAC_FU_BASS_BOOST, "Bass Boost", USB_MIXER_BOOLEAN, -1 },
1059 { UAC_FU_LOUDNESS, "Loudness", USB_MIXER_BOOLEAN, -1 },
1061 { UAC2_FU_INPUT_GAIN, "Input Gain Control", USB_MIXER_S16, -1 },
1062 { UAC2_FU_INPUT_GAIN_PAD, "Input Gain Pad Control", USB_MIXER_S16, -1 },
1063 { UAC2_FU_PHASE_INVERTER, "Phase Inverter Control", USB_MIXER_BOOLEAN, -1 },
1074 usb_mixer_elem_info_free(kctl->private_data); in snd_usb_mixer_elem_free()
1075 kctl->private_data = NULL; in snd_usb_mixer_elem_free()
1086 struct snd_usb_audio *chip = cval->head.mixer->chip; in volume_control_quirks()
1087 switch (chip->usb_id) { in volume_control_quirks()
1088 case USB_ID(0x0763, 0x2030): /* M-Audio Fast Track C400 */ in volume_control_quirks()
1089 case USB_ID(0x0763, 0x2031): /* M-Audio Fast Track C600 */ in volume_control_quirks()
1090 if (strcmp(kctl->id.name, "Effect Duration") == 0) { in volume_control_quirks()
1091 cval->min = 0x0000; in volume_control_quirks()
1092 cval->max = 0xffff; in volume_control_quirks()
1093 cval->res = 0x00e6; in volume_control_quirks()
1096 if (strcmp(kctl->id.name, "Effect Volume") == 0 || in volume_control_quirks()
1097 strcmp(kctl->id.name, "Effect Feedback Volume") == 0) { in volume_control_quirks()
1098 cval->min = 0x00; in volume_control_quirks()
1099 cval->max = 0xff; in volume_control_quirks()
1102 if (strstr(kctl->id.name, "Effect Return") != NULL) { in volume_control_quirks()
1103 cval->min = 0xb706; in volume_control_quirks()
1104 cval->max = 0xff7b; in volume_control_quirks()
1105 cval->res = 0x0073; in volume_control_quirks()
1108 if ((strstr(kctl->id.name, "Playback Volume") != NULL) || in volume_control_quirks()
1109 (strstr(kctl->id.name, "Effect Send") != NULL)) { in volume_control_quirks()
1110 cval->min = 0xb5fb; /* -73 dB = 0xb6ff */ in volume_control_quirks()
1111 cval->max = 0xfcfe; in volume_control_quirks()
1112 cval->res = 0x0073; in volume_control_quirks()
1116 case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */ in volume_control_quirks()
1117 case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra */ in volume_control_quirks()
1118 if (strcmp(kctl->id.name, "Effect Duration") == 0) { in volume_control_quirks()
1121 cval->min = 0x0000; in volume_control_quirks()
1122 cval->max = 0x7f00; in volume_control_quirks()
1123 cval->res = 0x0100; in volume_control_quirks()
1126 if (strcmp(kctl->id.name, "Effect Volume") == 0 || in volume_control_quirks()
1127 strcmp(kctl->id.name, "Effect Feedback Volume") == 0) { in volume_control_quirks()
1130 cval->min = 0x00; in volume_control_quirks()
1131 cval->max = 0x7f; in volume_control_quirks()
1137 if (!strcmp(kctl->id.name, "PCM Playback Volume")) { in volume_control_quirks()
1139 "set volume quirk for CM102-A+/102S+\n"); in volume_control_quirks()
1140 cval->min = -256; in volume_control_quirks()
1151 * I hope that the min value is -15360 for newer firmware --jk in volume_control_quirks()
1153 if (!strcmp(kctl->id.name, "PCM Playback Volume") && in volume_control_quirks()
1154 cval->min == -15616) { in volume_control_quirks()
1157 cval->max = -256; in volume_control_quirks()
1162 if (!strcmp(kctl->id.name, "Mic Capture Volume")) { in volume_control_quirks()
1165 cval->min = 6080; in volume_control_quirks()
1166 cval->max = 8768; in volume_control_quirks()
1167 cval->res = 192; in volume_control_quirks()
1184 * Probably there is some logitech magic behind this number --fishor in volume_control_quirks()
1186 if (!strcmp(kctl->id.name, "Mic Capture Volume")) { in volume_control_quirks()
1188 "set resolution quirk: cval->res = 384\n"); in volume_control_quirks()
1189 cval->res = 384; in volume_control_quirks()
1193 if ((strstr(kctl->id.name, "Playback Volume") != NULL) || in volume_control_quirks()
1194 strstr(kctl->id.name, "Capture Volume") != NULL) { in volume_control_quirks()
1195 cval->min >>= 8; in volume_control_quirks()
1196 cval->max = 0; in volume_control_quirks()
1197 cval->res = 1; in volume_control_quirks()
1201 if (!strcmp(kctl->id.name, "Mic Capture Volume")) { in volume_control_quirks()
1203 "set resolution quirk: cval->res = 16\n"); in volume_control_quirks()
1204 cval->res = 16; in volume_control_quirks()
1209 if (!strcmp(kctl->id.name, "Mic Capture Volume")) { in volume_control_quirks()
1211 "set resolution quirk: cval->res = 16\n"); in volume_control_quirks()
1212 cval->res = 16; in volume_control_quirks()
1216 if (!strcmp(kctl->id.name, "Mic Capture Volume")) { in volume_control_quirks()
1218 "set resolution quirk: cval->res = 16\n"); in volume_control_quirks()
1219 cval->res = 16; in volume_control_quirks()
1235 if (!cval->head.mixer->ignore_ctl_error) in init_cur_mix_raw()
1236 usb_audio_warn(cval->head.mixer->chip, in init_cur_mix_raw()
1238 cval->head.id, mixer_ctrl_intf(cval->head.mixer), in init_cur_mix_raw()
1240 snd_usb_set_cur_mix_value(cval, ch, idx, cval->min); in init_cur_mix_raw()
1252 cval->min = default_min; in get_min_max_with_quirks()
1253 cval->max = cval->min + 1; in get_min_max_with_quirks()
1254 cval->res = 1; in get_min_max_with_quirks()
1255 cval->dBmin = cval->dBmax = 0; in get_min_max_with_quirks()
1257 if (cval->val_type == USB_MIXER_BOOLEAN || in get_min_max_with_quirks()
1258 cval->val_type == USB_MIXER_INV_BOOLEAN) { in get_min_max_with_quirks()
1259 cval->initialized = 1; in get_min_max_with_quirks()
1262 if (cval->cmask) { in get_min_max_with_quirks()
1264 if (cval->cmask & BIT(i)) { in get_min_max_with_quirks()
1269 if (get_ctl_value(cval, UAC_GET_MAX, (cval->control << 8) | minchn, &cval->max) < 0 || in get_min_max_with_quirks()
1270 get_ctl_value(cval, UAC_GET_MIN, (cval->control << 8) | minchn, &cval->min) < 0) { in get_min_max_with_quirks()
1271 usb_audio_err(cval->head.mixer->chip, in get_min_max_with_quirks()
1273 cval->head.id, mixer_ctrl_intf(cval->head.mixer), in get_min_max_with_quirks()
1274 cval->control, cval->head.id); in get_min_max_with_quirks()
1275 return -EINVAL; in get_min_max_with_quirks()
1278 (cval->control << 8) | minchn, in get_min_max_with_quirks()
1279 &cval->res) < 0) { in get_min_max_with_quirks()
1280 cval->res = 1; in get_min_max_with_quirks()
1281 } else if (cval->head.mixer->protocol == UAC_VERSION_1) { in get_min_max_with_quirks()
1282 int last_valid_res = cval->res; in get_min_max_with_quirks()
1284 while (cval->res > 1) { in get_min_max_with_quirks()
1286 (cval->control << 8) | minchn, in get_min_max_with_quirks()
1287 cval->res / 2) < 0) in get_min_max_with_quirks()
1289 cval->res /= 2; in get_min_max_with_quirks()
1292 (cval->control << 8) | minchn, &cval->res) < 0) in get_min_max_with_quirks()
1293 cval->res = last_valid_res; in get_min_max_with_quirks()
1295 if (cval->res == 0) in get_min_max_with_quirks()
1296 cval->res = 1; in get_min_max_with_quirks()
1304 if (cval->min + cval->res < cval->max) { in get_min_max_with_quirks()
1305 int last_valid_res = cval->res; in get_min_max_with_quirks()
1311 if (test < cval->max) in get_min_max_with_quirks()
1312 test += cval->res; in get_min_max_with_quirks()
1314 test -= cval->res; in get_min_max_with_quirks()
1315 if (test < cval->min || test > cval->max || in get_min_max_with_quirks()
1318 cval->res = last_valid_res; in get_min_max_with_quirks()
1323 cval->res *= 2; in get_min_max_with_quirks()
1329 cval->initialized = 1; in get_min_max_with_quirks()
1338 cval->dBmin = (convert_signed_value(cval, cval->min) * 100) / 256; in get_min_max_with_quirks()
1339 cval->dBmax = (convert_signed_value(cval, cval->max) * 100) / 256; in get_min_max_with_quirks()
1340 if (cval->dBmin > cval->dBmax) { in get_min_max_with_quirks()
1342 if (cval->dBmin < 0) in get_min_max_with_quirks()
1343 cval->dBmax = 0; in get_min_max_with_quirks()
1344 else if (cval->dBmin > 0) in get_min_max_with_quirks()
1345 cval->dBmin = 0; in get_min_max_with_quirks()
1346 if (cval->dBmin > cval->dBmax) { in get_min_max_with_quirks()
1348 return -EINVAL; in get_min_max_with_quirks()
1352 * here we use -96dB as the threshold in get_min_max_with_quirks()
1354 if (cval->dBmax <= -9600) { in get_min_max_with_quirks()
1355 usb_audio_info(cval->head.mixer->chip, in get_min_max_with_quirks()
1357 cval->head.id, mixer_ctrl_intf(cval->head.mixer), in get_min_max_with_quirks()
1358 cval->dBmin, cval->dBmax); in get_min_max_with_quirks()
1359 cval->dBmin = cval->dBmax = 0; in get_min_max_with_quirks()
1364 if (!cval->cmask) { in get_min_max_with_quirks()
1369 if (cval->cmask & BIT(i)) { in get_min_max_with_quirks()
1384 if (!cval->max_exposed) { in get_max_exposed()
1385 if (cval->res) in get_max_exposed()
1386 cval->max_exposed = in get_max_exposed()
1387 DIV_ROUND_UP(cval->max - cval->min, cval->res); in get_max_exposed()
1389 cval->max_exposed = cval->max - cval->min; in get_max_exposed()
1391 return cval->max_exposed; in get_max_exposed()
1398 struct usb_mixer_elem_info *cval = kcontrol->private_data; in mixer_ctl_feature_info()
1400 if (cval->val_type == USB_MIXER_BOOLEAN || in mixer_ctl_feature_info()
1401 cval->val_type == USB_MIXER_INV_BOOLEAN) in mixer_ctl_feature_info()
1402 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; in mixer_ctl_feature_info()
1404 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in mixer_ctl_feature_info()
1405 uinfo->count = cval->channels; in mixer_ctl_feature_info()
1406 if (cval->val_type != USB_MIXER_BOOLEAN && in mixer_ctl_feature_info()
1407 cval->val_type != USB_MIXER_INV_BOOLEAN) { in mixer_ctl_feature_info()
1408 if (!cval->initialized) { in mixer_ctl_feature_info()
1410 if (cval->initialized && cval->dBmin >= cval->dBmax) { in mixer_ctl_feature_info()
1411 kcontrol->vd[0].access &= in mixer_ctl_feature_info()
1414 snd_ctl_notify(cval->head.mixer->chip->card, in mixer_ctl_feature_info()
1416 &kcontrol->id); in mixer_ctl_feature_info()
1421 uinfo->value.integer.min = 0; in mixer_ctl_feature_info()
1422 uinfo->value.integer.max = get_max_exposed(cval); in mixer_ctl_feature_info()
1430 struct usb_mixer_elem_info *cval = kcontrol->private_data; in mixer_ctl_feature_get()
1433 ucontrol->value.integer.value[0] = cval->min; in mixer_ctl_feature_get()
1434 if (cval->cmask) { in mixer_ctl_feature_get()
1437 if (!(cval->cmask & BIT(c))) in mixer_ctl_feature_get()
1443 ucontrol->value.integer.value[cnt] = val; in mixer_ctl_feature_get()
1453 ucontrol->value.integer.value[0] = val; in mixer_ctl_feature_get()
1462 struct usb_mixer_elem_info *cval = kcontrol->private_data; in mixer_ctl_feature_put()
1467 if (cval->cmask) { in mixer_ctl_feature_put()
1470 if (!(cval->cmask & BIT(c))) in mixer_ctl_feature_put()
1475 val = ucontrol->value.integer.value[cnt]; in mixer_ctl_feature_put()
1477 return -EINVAL; in mixer_ctl_feature_put()
1490 val = ucontrol->value.integer.value[0]; in mixer_ctl_feature_put()
1492 return -EINVAL; in mixer_ctl_feature_put()
1506 struct usb_mixer_elem_info *cval = kcontrol->private_data; in mixer_ctl_master_bool_get()
1513 ucontrol->value.integer.value[0] = val; in mixer_ctl_master_bool_get()
1520 struct snd_usb_audio *chip = cval->head.mixer->chip; in get_connector_value()
1523 validx = cval->control << 8 | 0; in get_connector_value()
1525 ret = snd_usb_lock_shutdown(chip) ? -EIO : 0; in get_connector_value()
1529 idx = mixer_ctrl_intf(cval->head.mixer) | (cval->head.id << 8); in get_connector_value()
1530 if (cval->head.mixer->protocol == UAC_VERSION_2) { in get_connector_value()
1533 ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), UAC2_CS_CUR, in get_connector_value()
1541 ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), UAC2_CS_CUR, in get_connector_value()
1559 UAC_GET_CUR, validx, idx, cval->val_type); in get_connector_value()
1574 struct usb_mixer_elem_info *cval = kcontrol->private_data; in mixer_ctl_connector_get()
1577 ret = get_connector_value(cval, kcontrol->id.name, &val); in mixer_ctl_connector_get()
1582 ucontrol->value.integer.value[0] = val; in mixer_ctl_connector_get()
1594 /* the read-only variant */
1636 return strlcat(kctl->id.name, str, sizeof(kctl->id.name)); in append_ctl_name()
1652 if (strcmp("Speaker", kctl->id.name)) in check_no_speaker_on_headset()
1656 if (strstr(card->shortname, *s)) { in check_no_speaker_on_headset()
1705 snd_usb_mixer_elem_init_std(&cval->head, mixer, unitid); in __build_feature_ctl()
1706 cval->control = control; in __build_feature_ctl()
1707 cval->cmask = ctl_mask; in __build_feature_ctl()
1714 if (mixer->protocol == UAC_VERSION_1) in __build_feature_ctl()
1715 cval->val_type = ctl_info->type; in __build_feature_ctl()
1717 cval->val_type = ctl_info->type_uac2 >= 0 ? in __build_feature_ctl()
1718 ctl_info->type_uac2 : ctl_info->type; in __build_feature_ctl()
1721 cval->channels = 1; /* master channel */ in __build_feature_ctl()
1722 cval->master_readonly = readonly_mask; in __build_feature_ctl()
1728 cval->channels = c; in __build_feature_ctl()
1729 cval->ch_readonly = readonly_mask; in __build_feature_ctl()
1733 * If all channels in the mask are marked read-only, make the control in __build_feature_ctl()
1734 * read-only. snd_usb_set_cur_mix_value() will check the mask again and won't in __build_feature_ctl()
1735 * issue write commands to read-only channels. in __build_feature_ctl()
1737 if (cval->channels == readonly_mask) in __build_feature_ctl()
1743 usb_audio_err(mixer->chip, "cannot malloc kcontrol\n"); in __build_feature_ctl()
1747 kctl->private_free = snd_usb_mixer_elem_free; in __build_feature_ctl()
1749 len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)); in __build_feature_ctl()
1752 len = snd_usb_copy_string_desc(mixer->chip, nameid, in __build_feature_ctl()
1753 kctl->id.name, sizeof(kctl->id.name)); in __build_feature_ctl()
1760 * - if a name id is given in descriptor, use it. in __build_feature_ctl()
1761 * - if the connected input can be determined, then use the name in __build_feature_ctl()
1763 * - if the connected output can be determined, use it. in __build_feature_ctl()
1764 * - otherwise, anonymous name. in __build_feature_ctl()
1768 len = get_term_name(mixer->chip, iterm, in __build_feature_ctl()
1769 kctl->id.name, in __build_feature_ctl()
1770 sizeof(kctl->id.name), 1); in __build_feature_ctl()
1772 len = get_term_name(mixer->chip, oterm, in __build_feature_ctl()
1773 kctl->id.name, in __build_feature_ctl()
1774 sizeof(kctl->id.name), 1); in __build_feature_ctl()
1776 snprintf(kctl->id.name, sizeof(kctl->id.name), in __build_feature_ctl()
1781 check_no_speaker_on_headset(kctl, mixer->chip->card); in __build_feature_ctl()
1788 if (!mapped_name && oterm && !(oterm->type >> 16)) { in __build_feature_ctl()
1789 if ((oterm->type & 0xff00) == 0x0100) in __build_feature_ctl()
1799 strscpy(kctl->id.name, audio_feature_info[control-1].name, in __build_feature_ctl()
1800 sizeof(kctl->id.name)); in __build_feature_ctl()
1808 if (cval->max <= cval->min) { in __build_feature_ctl()
1809 usb_audio_dbg(mixer->chip, in __build_feature_ctl()
1811 cval->head.id, kctl->id.name); in __build_feature_ctl()
1819 if (cval->dBmin < cval->dBmax || !cval->initialized) { in __build_feature_ctl()
1820 kctl->tlv.c = snd_usb_mixer_vol_tlv; in __build_feature_ctl()
1821 kctl->vd[0].access |= in __build_feature_ctl()
1829 range = (cval->max - cval->min) / cval->res; in __build_feature_ctl()
1836 usb_audio_warn(mixer->chip, in __build_feature_ctl()
1837 "Warning! Unlikely big volume range (=%u), cval->res is probably wrong.", in __build_feature_ctl()
1839 usb_audio_warn(mixer->chip, in __build_feature_ctl()
1841 cval->head.id, kctl->id.name, cval->channels, in __build_feature_ctl()
1842 cval->min, cval->max, cval->res); in __build_feature_ctl()
1845 usb_audio_dbg(mixer->chip, "[%d] FU [%s] ch = %d, val = %d/%d/%d\n", in __build_feature_ctl()
1846 cval->head.id, kctl->id.name, cval->channels, in __build_feature_ctl()
1847 cval->min, cval->max, cval->res); in __build_feature_ctl()
1848 snd_usb_mixer_add_control(&cval->head, kctl); in __build_feature_ctl()
1859 __build_feature_ctl(state->mixer, state->map, ctl_mask, control, in build_feature_ctl()
1860 iterm, &state->oterm, unitid, nameid, readonly_mask); in build_feature_ctl()
1875 int name_len = get_term_name(mixer->chip, term, name, name_size, 0); in get_connector_control_name()
1886 strlcat(name, " - Input Jack", name_size); in get_connector_control_name()
1888 strlcat(name, " - Output Jack", name_size); in get_connector_control_name()
1900 /* Build a mixer control for a UAC connector control (jack-detect) */
1909 map = find_map(imap, term->id, 0); in build_connector_control()
1916 snd_usb_mixer_elem_init_std(&cval->head, mixer, term->id); in build_connector_control()
1919 cval->head.resume = connector_mixer_resume; in build_connector_control()
1931 if (mixer->protocol == UAC_VERSION_2) in build_connector_control()
1932 cval->control = UAC2_TE_CONNECTOR; in build_connector_control()
1934 cval->control = UAC3_TE_INSERTION; in build_connector_control()
1936 cval->val_type = USB_MIXER_BOOLEAN; in build_connector_control()
1937 cval->channels = 1; /* report true if any channel is connected */ in build_connector_control()
1938 cval->min = 0; in build_connector_control()
1939 cval->max = 1; in build_connector_control()
1942 usb_audio_err(mixer->chip, "cannot malloc kcontrol\n"); in build_connector_control()
1947 if (check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name))) in build_connector_control()
1948 strlcat(kctl->id.name, " Jack", sizeof(kctl->id.name)); in build_connector_control()
1950 get_connector_control_name(mixer, term, is_input, kctl->id.name, in build_connector_control()
1951 sizeof(kctl->id.name)); in build_connector_control()
1952 kctl->private_free = snd_usb_mixer_elem_free; in build_connector_control()
1953 snd_usb_mixer_add_control(&cval->head, kctl); in build_connector_control()
1964 if (state->mixer->protocol != UAC_VERSION_2) in parse_clock_source_unit()
1965 return -EINVAL; in parse_clock_source_unit()
1971 if (!uac_v2v3_control_is_readable(hdr->bmControls, in parse_clock_source_unit()
1977 return -ENOMEM; in parse_clock_source_unit()
1979 snd_usb_mixer_elem_init_std(&cval->head, state->mixer, hdr->bClockID); in parse_clock_source_unit()
1981 cval->min = 0; in parse_clock_source_unit()
1982 cval->max = 1; in parse_clock_source_unit()
1983 cval->channels = 1; in parse_clock_source_unit()
1984 cval->val_type = USB_MIXER_BOOLEAN; in parse_clock_source_unit()
1985 cval->control = UAC2_CS_CONTROL_CLOCK_VALID; in parse_clock_source_unit()
1987 cval->master_readonly = 1; in parse_clock_source_unit()
1993 return -ENOMEM; in parse_clock_source_unit()
1996 kctl->private_free = snd_usb_mixer_elem_free; in parse_clock_source_unit()
1997 ret = snd_usb_copy_string_desc(state->chip, hdr->iClockSource, in parse_clock_source_unit()
1998 kctl->id.name, sizeof(kctl->id.name)); in parse_clock_source_unit()
2002 snprintf(kctl->id.name, sizeof(kctl->id.name), in parse_clock_source_unit()
2003 "Clock Source %d Validity", hdr->bClockID); in parse_clock_source_unit()
2005 return snd_usb_mixer_add_control(&cval->head, kctl); in parse_clock_source_unit()
2023 if (state->mixer->protocol == UAC_VERSION_1) { in parse_audio_feature_unit()
2024 csize = hdr->bControlSize; in parse_audio_feature_unit()
2025 channels = (hdr->bLength - 7) / csize - 1; in parse_audio_feature_unit()
2026 bmaControls = hdr->bmaControls; in parse_audio_feature_unit()
2027 } else if (state->mixer->protocol == UAC_VERSION_2) { in parse_audio_feature_unit()
2030 channels = (hdr->bLength - 6) / 4 - 1; in parse_audio_feature_unit()
2031 bmaControls = ftr->bmaControls; in parse_audio_feature_unit()
2036 channels = (ftr->bLength - 7) / 4 - 1; in parse_audio_feature_unit()
2037 bmaControls = ftr->bmaControls; in parse_audio_feature_unit()
2041 usb_audio_info(state->chip, in parse_audio_feature_unit()
2044 return -EINVAL; in parse_audio_feature_unit()
2048 err = parse_audio_unit(state, hdr->bSourceID); in parse_audio_feature_unit()
2053 err = check_input_term(state, hdr->bSourceID, &iterm); in parse_audio_feature_unit()
2059 switch (state->chip->usb_id) { in parse_audio_feature_unit()
2061 usb_audio_info(state->chip, in parse_audio_feature_unit()
2063 /* disable non-functional volume control */ in parse_audio_feature_unit()
2067 usb_audio_info(state->chip, in parse_audio_feature_unit()
2069 /* disable non-functional volume control */ in parse_audio_feature_unit()
2075 if (state->mixer->protocol == UAC_VERSION_1) { in parse_audio_feature_unit()
2089 /* audio class v1 controls are never read-only */ in parse_audio_feature_unit()
2122 * read-only if all channels are marked read-only in in parse_audio_feature_unit()
2125 * actually issue a write command for read-only in parse_audio_feature_unit()
2192 map = find_map(state->map, unitid, 0); in build_mixer_unit_ctl()
2200 snd_usb_mixer_elem_init_std(&cval->head, state->mixer, unitid); in build_mixer_unit_ctl()
2201 cval->control = in_ch + 1; /* based on 1 */ in build_mixer_unit_ctl()
2202 cval->val_type = USB_MIXER_S16; in build_mixer_unit_ctl()
2204 __u8 *c = uac_mixer_unit_bmControls(desc, state->mixer->protocol); in build_mixer_unit_ctl()
2207 cval->cmask |= BIT(i); in build_mixer_unit_ctl()
2208 cval->channels++; in build_mixer_unit_ctl()
2217 usb_audio_err(state->chip, "cannot malloc kcontrol\n"); in build_mixer_unit_ctl()
2221 kctl->private_free = snd_usb_mixer_elem_free; in build_mixer_unit_ctl()
2223 len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)); in build_mixer_unit_ctl()
2225 len = get_term_name(state->chip, iterm, kctl->id.name, in build_mixer_unit_ctl()
2226 sizeof(kctl->id.name), 0); in build_mixer_unit_ctl()
2228 len = sprintf(kctl->id.name, "Mixer Source %d", in_ch + 1); in build_mixer_unit_ctl()
2231 usb_audio_dbg(state->chip, "[%d] MU [%s] ch = %d, val = %d/%d\n", in build_mixer_unit_ctl()
2232 cval->head.id, kctl->id.name, cval->channels, cval->min, cval->max); in build_mixer_unit_ctl()
2233 snd_usb_mixer_add_control(&cval->head, kctl); in build_mixer_unit_ctl()
2242 if (state->mixer->protocol == UAC_VERSION_2) { in parse_audio_input_terminal()
2245 term_id = d_v2->bTerminalID; in parse_audio_input_terminal()
2246 bmctls = le16_to_cpu(d_v2->bmControls); in parse_audio_input_terminal()
2247 } else if (state->mixer->protocol == UAC_VERSION_3) { in parse_audio_input_terminal()
2250 term_id = d_v3->bTerminalID; in parse_audio_input_terminal()
2251 bmctls = le32_to_cpu(d_v3->bmControls); in parse_audio_input_terminal()
2261 build_connector_control(state->mixer, state->map, &iterm, true); in parse_audio_input_terminal()
2279 usb_audio_err(state->chip, in parse_audio_mixer_unit()
2286 input_pins = desc->bNrInPins; in parse_audio_mixer_unit()
2291 err = parse_audio_unit(state, desc->baSourceID[pin]); in parse_audio_mixer_unit()
2294 /* no bmControls field (e.g. Maya44) -> ignore */ in parse_audio_mixer_unit()
2297 err = check_input_term(state, desc->baSourceID[pin], &iterm); in parse_audio_mixer_unit()
2301 if (mixer_bitmap_overflow(desc, state->mixer->protocol, in parse_audio_mixer_unit()
2309 state->mixer->protocol); in parse_audio_mixer_unit()
2332 struct usb_mixer_elem_info *cval = kcontrol->private_data; in mixer_ctl_procunit_get()
2335 err = get_cur_ctl_value(cval, cval->control << 8, &val); in mixer_ctl_procunit_get()
2337 ucontrol->value.integer.value[0] = cval->min; in mixer_ctl_procunit_get()
2341 ucontrol->value.integer.value[0] = val; in mixer_ctl_procunit_get()
2349 struct usb_mixer_elem_info *cval = kcontrol->private_data; in mixer_ctl_procunit_put()
2352 err = get_cur_ctl_value(cval, cval->control << 8, &oval); in mixer_ctl_procunit_put()
2355 val = ucontrol->value.integer.value[0]; in mixer_ctl_procunit_put()
2357 return -EINVAL; in mixer_ctl_procunit_put()
2360 set_cur_ctl_value(cval, cval->control << 8, val); in mixer_ctl_procunit_put()
2457 { UAC3_PROCESS_MULTI_FUNCTION, "Multi-Function", undefined_proc_info },
2513 num_ins = desc->bNrInPins; in build_audio_procunit()
2515 err = parse_audio_unit(state, desc->baSourceID[i]); in build_audio_procunit()
2520 type = le16_to_cpu(desc->wProcessType); in build_audio_procunit()
2521 for (info = list; info && info->type; info++) in build_audio_procunit()
2522 if (info->type == type) in build_audio_procunit()
2524 if (!info || !info->type) in build_audio_procunit()
2527 for (valinfo = info->values; valinfo->control; valinfo++) { in build_audio_procunit()
2528 __u8 *controls = uac_processing_unit_bmControls(desc, state->mixer->protocol); in build_audio_procunit()
2530 if (state->mixer->protocol == UAC_VERSION_1) { in build_audio_procunit()
2531 if (!(controls[valinfo->control / 8] & in build_audio_procunit()
2532 BIT((valinfo->control % 8) - 1))) in build_audio_procunit()
2535 if (!uac_v2v3_control_is_readable(controls[valinfo->control / 8], in build_audio_procunit()
2536 valinfo->control)) in build_audio_procunit()
2540 map = find_map(state->map, unitid, valinfo->control); in build_audio_procunit()
2545 return -ENOMEM; in build_audio_procunit()
2546 snd_usb_mixer_elem_init_std(&cval->head, state->mixer, unitid); in build_audio_procunit()
2547 cval->control = valinfo->control; in build_audio_procunit()
2548 cval->val_type = valinfo->val_type; in build_audio_procunit()
2549 cval->channels = 1; in build_audio_procunit()
2551 if (state->mixer->protocol > UAC_VERSION_1 && in build_audio_procunit()
2552 !uac_v2v3_control_is_writeable(controls[valinfo->control / 8], in build_audio_procunit()
2553 valinfo->control)) in build_audio_procunit()
2554 cval->master_readonly = 1; in build_audio_procunit()
2561 switch (state->mixer->protocol) { in build_audio_procunit()
2565 if (cval->control == UAC_UD_MODE_SELECT) in build_audio_procunit()
2569 if (cval->control == UAC3_UD_MODE_SELECT) in build_audio_procunit()
2576 state->mixer->protocol); in build_audio_procunit()
2577 cval->min = 1; in build_audio_procunit()
2578 cval->max = control_spec[0]; in build_audio_procunit()
2579 cval->res = 1; in build_audio_procunit()
2580 cval->initialized = 1; in build_audio_procunit()
2584 get_min_max(cval, valinfo->min_value); in build_audio_procunit()
2589 * E-Mu USB 0404/0202/TrackerPre/0204 in build_audio_procunit()
2592 cval->min = 0; in build_audio_procunit()
2593 cval->max = 5; in build_audio_procunit()
2594 cval->res = 1; in build_audio_procunit()
2595 cval->initialized = 1; in build_audio_procunit()
2598 get_min_max(cval, valinfo->min_value); in build_audio_procunit()
2602 err = get_cur_ctl_value(cval, cval->control << 8, &val); in build_audio_procunit()
2605 return -EINVAL; in build_audio_procunit()
2611 return -ENOMEM; in build_audio_procunit()
2613 kctl->private_free = snd_usb_mixer_elem_free; in build_audio_procunit()
2615 if (check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name))) { in build_audio_procunit()
2617 } else if (info->name) { in build_audio_procunit()
2618 strscpy(kctl->id.name, info->name, sizeof(kctl->id.name)); in build_audio_procunit()
2621 nameid = uac_extension_unit_iExtension(desc, state->mixer->protocol); in build_audio_procunit()
2623 nameid = uac_processing_unit_iProcessing(desc, state->mixer->protocol); in build_audio_procunit()
2626 len = snd_usb_copy_string_desc(state->chip, in build_audio_procunit()
2628 kctl->id.name, in build_audio_procunit()
2629 sizeof(kctl->id.name)); in build_audio_procunit()
2631 strscpy(kctl->id.name, name, sizeof(kctl->id.name)); in build_audio_procunit()
2634 append_ctl_name(kctl, valinfo->suffix); in build_audio_procunit()
2636 usb_audio_dbg(state->chip, in build_audio_procunit()
2638 cval->head.id, kctl->id.name, cval->channels, in build_audio_procunit()
2639 cval->min, cval->max); in build_audio_procunit()
2641 err = snd_usb_mixer_add_control(&cval->head, kctl); in build_audio_procunit()
2651 switch (state->mixer->protocol) { in parse_audio_processing_unit()
2684 struct usb_mixer_elem_info *cval = kcontrol->private_data; in mixer_ctl_selector_info()
2685 const char **itemlist = (const char **)kcontrol->private_value; in mixer_ctl_selector_info()
2688 return -EINVAL; in mixer_ctl_selector_info()
2689 return snd_ctl_enum_info(uinfo, 1, cval->max, itemlist); in mixer_ctl_selector_info()
2696 struct usb_mixer_elem_info *cval = kcontrol->private_data; in mixer_ctl_selector_get()
2699 err = get_cur_ctl_value(cval, cval->control << 8, &val); in mixer_ctl_selector_get()
2701 ucontrol->value.enumerated.item[0] = 0; in mixer_ctl_selector_get()
2705 ucontrol->value.enumerated.item[0] = val; in mixer_ctl_selector_get()
2713 struct usb_mixer_elem_info *cval = kcontrol->private_data; in mixer_ctl_selector_put()
2716 err = get_cur_ctl_value(cval, cval->control << 8, &oval); in mixer_ctl_selector_put()
2719 val = ucontrol->value.enumerated.item[0]; in mixer_ctl_selector_put()
2720 if (val < 0 || val >= cval->max) /* here cval->max = # elements */ in mixer_ctl_selector_put()
2721 return -EINVAL; in mixer_ctl_selector_put()
2724 set_cur_ctl_value(cval, cval->control << 8, val); in mixer_ctl_selector_put()
2747 if (kctl->private_data) { in usb_mixer_selector_elem_free()
2748 struct usb_mixer_elem_info *cval = kctl->private_data; in usb_mixer_selector_elem_free()
2749 num_ins = cval->max; in usb_mixer_selector_elem_free()
2751 kctl->private_data = NULL; in usb_mixer_selector_elem_free()
2753 if (kctl->private_value) { in usb_mixer_selector_elem_free()
2754 char **itemlist = (char **)kctl->private_value; in usb_mixer_selector_elem_free()
2758 kctl->private_value = 0; in usb_mixer_selector_elem_free()
2776 for (i = 0; i < desc->bNrInPins; i++) { in parse_audio_selector_unit()
2777 err = parse_audio_unit(state, desc->baSourceID[i]); in parse_audio_selector_unit()
2782 if (desc->bNrInPins == 1) /* only one ? nonsense! */ in parse_audio_selector_unit()
2785 map = find_map(state->map, unitid, 0); in parse_audio_selector_unit()
2791 return -ENOMEM; in parse_audio_selector_unit()
2792 snd_usb_mixer_elem_init_std(&cval->head, state->mixer, unitid); in parse_audio_selector_unit()
2793 cval->val_type = USB_MIXER_U8; in parse_audio_selector_unit()
2794 cval->channels = 1; in parse_audio_selector_unit()
2795 cval->min = 1; in parse_audio_selector_unit()
2796 cval->max = desc->bNrInPins; in parse_audio_selector_unit()
2797 cval->res = 1; in parse_audio_selector_unit()
2798 cval->initialized = 1; in parse_audio_selector_unit()
2800 switch (state->mixer->protocol) { in parse_audio_selector_unit()
2803 cval->control = 0; in parse_audio_selector_unit()
2807 if (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR || in parse_audio_selector_unit()
2808 desc->bDescriptorSubtype == UAC3_CLOCK_SELECTOR) in parse_audio_selector_unit()
2809 cval->control = UAC2_CX_CLOCK_SELECTOR; in parse_audio_selector_unit()
2811 cval->control = UAC2_SU_SELECTOR; in parse_audio_selector_unit()
2815 namelist = kcalloc(desc->bNrInPins, sizeof(char *), GFP_KERNEL); in parse_audio_selector_unit()
2817 err = -ENOMEM; in parse_audio_selector_unit()
2821 for (i = 0; i < desc->bNrInPins; i++) { in parse_audio_selector_unit()
2825 err = -ENOMEM; in parse_audio_selector_unit()
2830 if (! len && check_input_term(state, desc->baSourceID[i], &iterm) >= 0) in parse_audio_selector_unit()
2831 len = get_term_name(state->chip, &iterm, namelist[i], in parse_audio_selector_unit()
2839 usb_audio_err(state->chip, "cannot malloc kcontrol\n"); in parse_audio_selector_unit()
2840 err = -ENOMEM; in parse_audio_selector_unit()
2843 kctl->private_value = (unsigned long)namelist; in parse_audio_selector_unit()
2844 kctl->private_free = usb_mixer_selector_elem_free; in parse_audio_selector_unit()
2847 len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)); in parse_audio_selector_unit()
2850 switch (state->mixer->protocol) { in parse_audio_selector_unit()
2857 len = snd_usb_copy_string_desc(state->chip, in parse_audio_selector_unit()
2858 nameid, kctl->id.name, in parse_audio_selector_unit()
2859 sizeof(kctl->id.name)); in parse_audio_selector_unit()
2862 /* TODO: Class-Specific strings not yet supported */ in parse_audio_selector_unit()
2868 len = get_term_name(state->chip, &state->oterm, in parse_audio_selector_unit()
2869 kctl->id.name, sizeof(kctl->id.name), 0); in parse_audio_selector_unit()
2872 strscpy(kctl->id.name, "USB", sizeof(kctl->id.name)); in parse_audio_selector_unit()
2875 if (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR || in parse_audio_selector_unit()
2876 desc->bDescriptorSubtype == UAC3_CLOCK_SELECTOR) in parse_audio_selector_unit()
2878 else if ((state->oterm.type & 0xff00) == 0x0100) in parse_audio_selector_unit()
2884 usb_audio_dbg(state->chip, "[%d] SU [%s] items = %d\n", in parse_audio_selector_unit()
2885 cval->head.id, kctl->id.name, desc->bNrInPins); in parse_audio_selector_unit()
2886 return snd_usb_mixer_add_control(&cval->head, kctl); in parse_audio_selector_unit()
2889 for (i = 0; i < desc->bNrInPins; i++) in parse_audio_selector_unit()
2904 int protocol = state->mixer->protocol; in parse_audio_unit()
2906 if (test_and_set_bit(unitid, state->unitbitmap)) in parse_audio_unit()
2911 usb_audio_err(state->chip, "unit %d not found!\n", unitid); in parse_audio_unit()
2912 return -EINVAL; in parse_audio_unit()
2916 usb_audio_dbg(state->chip, "invalid unit %d\n", unitid); in parse_audio_unit()
2952 return 0; /* FIXME - effect units not implemented yet */ in parse_audio_unit()
2954 usb_audio_err(state->chip, in parse_audio_unit()
2957 return -EINVAL; in parse_audio_unit()
2966 kfree(mixer->id_elems); in snd_usb_mixer_free()
2967 if (mixer->urb) { in snd_usb_mixer_free()
2968 kfree(mixer->urb->transfer_buffer); in snd_usb_mixer_free()
2969 usb_free_urb(mixer->urb); in snd_usb_mixer_free()
2971 usb_free_urb(mixer->rc_urb); in snd_usb_mixer_free()
2972 kfree(mixer->rc_setup_packet); in snd_usb_mixer_free()
2978 struct usb_mixer_interface *mixer = device->device_data; in snd_usb_mixer_dev_free()
3001 .c_chmask = -1, /* dynamic channels */
3002 .p_chmask = -1, /* dynamic channels */
3014 .p_chmask = -1, /* dynamic channels */
3020 .c_chmask = -1, /* dynamic channels */
3031 .p_chmask = -1, /* dynamic channels */
3060 if (f->c_chmask < 0 && f->p_chmask < 0) { in uac3_badd_func_has_valid_channels()
3062 usb_audio_warn(mixer->chip, "BAAD %s: no channels?", in uac3_badd_func_has_valid_channels()
3063 f->name); in uac3_badd_func_has_valid_channels()
3069 if ((f->c_chmask < 0 && !c_chmask) || in uac3_badd_func_has_valid_channels()
3070 (f->c_chmask >= 0 && f->c_chmask != c_chmask)) { in uac3_badd_func_has_valid_channels()
3071 usb_audio_warn(mixer->chip, "BAAD %s c_chmask mismatch", in uac3_badd_func_has_valid_channels()
3072 f->name); in uac3_badd_func_has_valid_channels()
3075 if ((f->p_chmask < 0 && !p_chmask) || in uac3_badd_func_has_valid_channels()
3076 (f->p_chmask >= 0 && f->p_chmask != p_chmask)) { in uac3_badd_func_has_valid_channels()
3077 usb_audio_warn(mixer->chip, "BAAD %s p_chmask mismatch", in uac3_badd_func_has_valid_channels()
3078 f->name); in uac3_badd_func_has_valid_channels()
3087 * UAC3 BADD device doesn't contain CS descriptors thus we will guess everything
3094 struct usb_device *dev = mixer->chip->dev; in snd_usb_mixer_controls_badd() local
3095 struct usb_interface_assoc_descriptor *assoc; in snd_usb_mixer_controls_badd() local
3096 int badd_profile = mixer->chip->badd_profile; in snd_usb_mixer_controls_badd()
3102 assoc = usb_ifnum_to_if(dev, ctrlif)->intf_assoc; in snd_usb_mixer_controls_badd()
3105 for (i = 0; i < assoc->bInterfaceCount; i++) { in snd_usb_mixer_controls_badd()
3106 int intf = assoc->bFirstInterface + i; in snd_usb_mixer_controls_badd()
3118 iface = usb_ifnum_to_if(dev, intf); in snd_usb_mixer_controls_badd()
3122 num = iface->num_altsetting; in snd_usb_mixer_controls_badd()
3125 return -EINVAL; in snd_usb_mixer_controls_badd()
3134 alts = &iface->altsetting[1]; in snd_usb_mixer_controls_badd()
3137 if (altsd->bNumEndpoints < 1) in snd_usb_mixer_controls_badd()
3138 return -EINVAL; in snd_usb_mixer_controls_badd()
3141 dir_in = (get_endpoint(alts, 0)->bEndpointAddress & USB_DIR_IN); in snd_usb_mixer_controls_badd()
3142 maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); in snd_usb_mixer_controls_badd()
3146 usb_audio_err(mixer->chip, in snd_usb_mixer_controls_badd()
3149 return -EINVAL; in snd_usb_mixer_controls_badd()
3170 usb_audio_dbg(mixer->chip, in snd_usb_mixer_controls_badd()
3175 for (map = uac3_badd_usbmix_ctl_maps; map->id; map++) { in snd_usb_mixer_controls_badd()
3176 if (map->id == badd_profile) in snd_usb_mixer_controls_badd()
3180 if (!map->id) in snd_usb_mixer_controls_badd()
3181 return -EINVAL; in snd_usb_mixer_controls_badd()
3183 for (f = uac3_badd_profiles; f->name; f++) { in snd_usb_mixer_controls_badd()
3184 if (badd_profile == f->subclass) in snd_usb_mixer_controls_badd()
3187 if (!f->name) in snd_usb_mixer_controls_badd()
3188 return -EINVAL; in snd_usb_mixer_controls_badd()
3190 return -EINVAL; in snd_usb_mixer_controls_badd()
3191 st_chmask = f->st_chmask; in snd_usb_mixer_controls_badd()
3197 UAC3_BADD_FU_ID2, map->map); in snd_usb_mixer_controls_badd()
3200 UAC3_BADD_FU_ID2, map->map); in snd_usb_mixer_controls_badd()
3207 UAC3_BADD_FU_ID5, map->map); in snd_usb_mixer_controls_badd()
3210 UAC3_BADD_FU_ID5, map->map); in snd_usb_mixer_controls_badd()
3213 /* Side tone-mixing */ in snd_usb_mixer_controls_badd()
3217 UAC3_BADD_FU_ID7, map->map); in snd_usb_mixer_controls_badd()
3220 UAC3_BADD_FU_ID7, map->map); in snd_usb_mixer_controls_badd()
3224 if (f->subclass == UAC3_FUNCTION_SUBCLASS_HEADSET_ADAPTER) { in snd_usb_mixer_controls_badd()
3227 /* Input Term - Insertion control */ in snd_usb_mixer_controls_badd()
3231 build_connector_control(mixer, map->map, &iterm, true); in snd_usb_mixer_controls_badd()
3233 /* Output Term - Insertion control */ in snd_usb_mixer_controls_badd()
3237 build_connector_control(mixer, map->map, &oterm, false); in snd_usb_mixer_controls_badd()
3256 state.chip = mixer->chip; in snd_usb_mixer_controls()
3258 state.buffer = mixer->hostif->extra; in snd_usb_mixer_controls()
3259 state.buflen = mixer->hostif->extralen; in snd_usb_mixer_controls()
3262 for (map = usbmix_ctl_maps; map->id; map++) { in snd_usb_mixer_controls()
3263 if (map->id == state.chip->usb_id) { in snd_usb_mixer_controls()
3264 state.map = map->map; in snd_usb_mixer_controls()
3265 state.selector_map = map->selector_map; in snd_usb_mixer_controls()
3266 mixer->connector_map = map->connector_map; in snd_usb_mixer_controls()
3272 while ((p = snd_usb_find_csint_desc(mixer->hostif->extra, in snd_usb_mixer_controls()
3273 mixer->hostif->extralen, in snd_usb_mixer_controls()
3275 if (!snd_usb_validate_audio_desc(p, mixer->protocol)) in snd_usb_mixer_controls()
3278 if (mixer->protocol == UAC_VERSION_1) { in snd_usb_mixer_controls()
3282 set_bit(desc->bTerminalID, state.unitbitmap); in snd_usb_mixer_controls()
3283 state.oterm.id = desc->bTerminalID; in snd_usb_mixer_controls()
3284 state.oterm.type = le16_to_cpu(desc->wTerminalType); in snd_usb_mixer_controls()
3285 state.oterm.name = desc->iTerminal; in snd_usb_mixer_controls()
3286 err = parse_audio_unit(&state, desc->bSourceID); in snd_usb_mixer_controls()
3287 if (err < 0 && err != -EINVAL) in snd_usb_mixer_controls()
3289 } else if (mixer->protocol == UAC_VERSION_2) { in snd_usb_mixer_controls()
3293 set_bit(desc->bTerminalID, state.unitbitmap); in snd_usb_mixer_controls()
3294 state.oterm.id = desc->bTerminalID; in snd_usb_mixer_controls()
3295 state.oterm.type = le16_to_cpu(desc->wTerminalType); in snd_usb_mixer_controls()
3296 state.oterm.name = desc->iTerminal; in snd_usb_mixer_controls()
3297 err = parse_audio_unit(&state, desc->bSourceID); in snd_usb_mixer_controls()
3298 if (err < 0 && err != -EINVAL) in snd_usb_mixer_controls()
3305 err = parse_audio_unit(&state, desc->bCSourceID); in snd_usb_mixer_controls()
3306 if (err < 0 && err != -EINVAL) in snd_usb_mixer_controls()
3310 uac_v2v3_control_is_readable(le16_to_cpu(desc->bmControls), in snd_usb_mixer_controls()
3319 set_bit(desc->bTerminalID, state.unitbitmap); in snd_usb_mixer_controls()
3320 state.oterm.id = desc->bTerminalID; in snd_usb_mixer_controls()
3321 state.oterm.type = le16_to_cpu(desc->wTerminalType); in snd_usb_mixer_controls()
3322 state.oterm.name = le16_to_cpu(desc->wTerminalDescrStr); in snd_usb_mixer_controls()
3323 err = parse_audio_unit(&state, desc->bSourceID); in snd_usb_mixer_controls()
3324 if (err < 0 && err != -EINVAL) in snd_usb_mixer_controls()
3331 err = parse_audio_unit(&state, desc->bCSourceID); in snd_usb_mixer_controls()
3332 if (err < 0 && err != -EINVAL) in snd_usb_mixer_controls()
3336 uac_v2v3_control_is_readable(le32_to_cpu(desc->bmControls), in snd_usb_mixer_controls()
3350 const struct usbmix_connector_map *map = mixer->connector_map; in delegate_notify()
3355 for (; map->id; map++) { in delegate_notify()
3356 if (map->id == unitid) { in delegate_notify()
3357 if (control && map->control) in delegate_notify()
3358 *control = map->control; in delegate_notify()
3359 if (channel && map->channel) in delegate_notify()
3360 *channel = map->channel; in delegate_notify()
3361 return map->delegated_id; in delegate_notify()
3376 if (!list->is_std_info) in snd_usb_mixer_notify_id()
3380 info->cached = 0; in snd_usb_mixer_notify_id()
3381 snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in snd_usb_mixer_notify_id()
3382 &list->kctl->id); in snd_usb_mixer_notify_id()
3402 "channels=%i, type=\"%s\"\n", cval->head.id, in snd_usb_mixer_dump_cval()
3403 cval->control, cval->cmask, cval->channels, in snd_usb_mixer_dump_cval()
3404 val_types[cval->val_type]); in snd_usb_mixer_dump_cval()
3406 cval->min, cval->max, cval->dBmin, cval->dBmax); in snd_usb_mixer_dump_cval()
3412 struct snd_usb_audio *chip = entry->private_data; in snd_usb_mixer_proc_read()
3417 list_for_each_entry(mixer, &chip->mixer_list, list) { in snd_usb_mixer_proc_read()
3420 chip->usb_id, mixer_ctrl_intf(mixer), in snd_usb_mixer_proc_read()
3421 mixer->ignore_ctl_error); in snd_usb_mixer_proc_read()
3422 snd_iprintf(buffer, "Card: %s\n", chip->card->longname); in snd_usb_mixer_proc_read()
3425 snd_iprintf(buffer, " Unit: %i\n", list->id); in snd_usb_mixer_proc_read()
3426 if (list->kctl) in snd_usb_mixer_proc_read()
3429 list->kctl->id.name, in snd_usb_mixer_proc_read()
3430 list->kctl->id.index); in snd_usb_mixer_proc_read()
3431 if (list->dump) in snd_usb_mixer_proc_read()
3432 list->dump(buffer, list); in snd_usb_mixer_proc_read()
3448 usb_audio_dbg(mixer->chip, in snd_usb_mixer_interrupt_v2()
3465 if (!list->kctl) in snd_usb_mixer_interrupt_v2()
3467 if (!list->is_std_info) in snd_usb_mixer_interrupt_v2()
3471 if (count > 1 && info->control != control) in snd_usb_mixer_interrupt_v2()
3478 info->cached &= ~BIT(channel); in snd_usb_mixer_interrupt_v2()
3480 info->cached = 0; in snd_usb_mixer_interrupt_v2()
3482 snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in snd_usb_mixer_interrupt_v2()
3483 &info->head.kctl->id); in snd_usb_mixer_interrupt_v2()
3495 usb_audio_dbg(mixer->chip, in snd_usb_mixer_interrupt_v2()
3505 struct usb_mixer_interface *mixer = urb->context; in snd_usb_mixer_interrupt()
3506 int len = urb->actual_length; in snd_usb_mixer_interrupt()
3507 int ustatus = urb->status; in snd_usb_mixer_interrupt()
3512 if (mixer->protocol == UAC_VERSION_1) { in snd_usb_mixer_interrupt()
3515 for (status = urb->transfer_buffer; in snd_usb_mixer_interrupt()
3517 len -= sizeof(*status), status++) { in snd_usb_mixer_interrupt()
3518 dev_dbg(&urb->dev->dev, "status interrupt: %02x %02x\n", in snd_usb_mixer_interrupt()
3519 status->bStatusType, in snd_usb_mixer_interrupt()
3520 status->bOriginator); in snd_usb_mixer_interrupt()
3523 if ((status->bStatusType & UAC1_STATUS_TYPE_ORIG_MASK) != in snd_usb_mixer_interrupt()
3527 if (status->bStatusType & UAC1_STATUS_TYPE_MEM_CHANGED) in snd_usb_mixer_interrupt()
3528 snd_usb_mixer_rc_memory_change(mixer, status->bOriginator); in snd_usb_mixer_interrupt()
3530 snd_usb_mixer_notify_id(mixer, status->bOriginator); in snd_usb_mixer_interrupt()
3535 for (msg = urb->transfer_buffer; in snd_usb_mixer_interrupt()
3537 len -= sizeof(*msg), msg++) { in snd_usb_mixer_interrupt()
3539 if ((msg->bInfo & UAC2_INTERRUPT_DATA_MSG_VENDOR) || in snd_usb_mixer_interrupt()
3540 (msg->bInfo & UAC2_INTERRUPT_DATA_MSG_EP)) in snd_usb_mixer_interrupt()
3543 snd_usb_mixer_interrupt_v2(mixer, msg->bAttribute, in snd_usb_mixer_interrupt()
3544 le16_to_cpu(msg->wValue), in snd_usb_mixer_interrupt()
3545 le16_to_cpu(msg->wIndex)); in snd_usb_mixer_interrupt()
3550 if (ustatus != -ENOENT && in snd_usb_mixer_interrupt()
3551 ustatus != -ECONNRESET && in snd_usb_mixer_interrupt()
3552 ustatus != -ESHUTDOWN) { in snd_usb_mixer_interrupt()
3553 urb->dev = mixer->chip->dev; in snd_usb_mixer_interrupt()
3567 if (get_iface_desc(mixer->hostif)->bNumEndpoints < 1) in snd_usb_mixer_status_create()
3569 ep = get_endpoint(mixer->hostif, 0); in snd_usb_mixer_status_create()
3574 buffer_length = le16_to_cpu(ep->wMaxPacketSize); in snd_usb_mixer_status_create()
3577 return -ENOMEM; in snd_usb_mixer_status_create()
3578 mixer->urb = usb_alloc_urb(0, GFP_KERNEL); in snd_usb_mixer_status_create()
3579 if (!mixer->urb) { in snd_usb_mixer_status_create()
3581 return -ENOMEM; in snd_usb_mixer_status_create()
3583 usb_fill_int_urb(mixer->urb, mixer->chip->dev, in snd_usb_mixer_status_create()
3584 usb_rcvintpipe(mixer->chip->dev, epnum), in snd_usb_mixer_status_create()
3586 snd_usb_mixer_interrupt, mixer, ep->bInterval); in snd_usb_mixer_status_create()
3587 usb_submit_urb(mixer->urb, GFP_KERNEL); in snd_usb_mixer_status_create()
3599 strcpy(chip->card->mixername, "USB Mixer"); in snd_usb_create_mixer()
3603 return -ENOMEM; in snd_usb_create_mixer()
3604 mixer->chip = chip; in snd_usb_create_mixer()
3605 mixer->ignore_ctl_error = !!(chip->quirk_flags & QUIRK_FLAG_IGNORE_CTL_ERROR); in snd_usb_create_mixer()
3606 mixer->id_elems = kcalloc(MAX_ID_ELEMS, sizeof(*mixer->id_elems), in snd_usb_create_mixer()
3608 if (!mixer->id_elems) { in snd_usb_create_mixer()
3610 return -ENOMEM; in snd_usb_create_mixer()
3613 mixer->hostif = &usb_ifnum_to_if(chip->dev, ctrlif)->altsetting[0]; in snd_usb_create_mixer()
3614 switch (get_iface_desc(mixer->hostif)->bInterfaceProtocol) { in snd_usb_create_mixer()
3617 mixer->protocol = UAC_VERSION_1; in snd_usb_create_mixer()
3620 mixer->protocol = UAC_VERSION_2; in snd_usb_create_mixer()
3623 mixer->protocol = UAC_VERSION_3; in snd_usb_create_mixer()
3627 if (mixer->protocol == UAC_VERSION_3 && in snd_usb_create_mixer()
3628 chip->badd_profile >= UAC3_FUNCTION_SUBCLASS_GENERIC_IO) { in snd_usb_create_mixer()
3646 err = snd_device_new(chip->card, SNDRV_DEV_CODEC, mixer, &dev_ops); in snd_usb_create_mixer()
3650 if (list_empty(&chip->mixer_list)) in snd_usb_create_mixer()
3651 snd_card_ro_proc_new(chip->card, "usbmixer", chip, in snd_usb_create_mixer()
3654 list_add(&mixer->list, &chip->mixer_list); in snd_usb_create_mixer()
3664 if (mixer->disconnected) in snd_usb_mixer_disconnect()
3666 if (mixer->urb) in snd_usb_mixer_disconnect()
3667 usb_kill_urb(mixer->urb); in snd_usb_mixer_disconnect()
3668 if (mixer->rc_urb) in snd_usb_mixer_disconnect()
3669 usb_kill_urb(mixer->rc_urb); in snd_usb_mixer_disconnect()
3670 if (mixer->private_free) in snd_usb_mixer_disconnect()
3671 mixer->private_free(mixer); in snd_usb_mixer_disconnect()
3672 mixer->disconnected = true; in snd_usb_mixer_disconnect()
3678 usb_kill_urb(mixer->urb); in snd_usb_mixer_inactivate()
3679 usb_kill_urb(mixer->rc_urb); in snd_usb_mixer_inactivate()
3686 if (mixer->urb) { in snd_usb_mixer_activate()
3687 err = usb_submit_urb(mixer->urb, GFP_NOIO); in snd_usb_mixer_activate()
3698 if (mixer->private_suspend) in snd_usb_mixer_suspend()
3699 mixer->private_suspend(mixer); in snd_usb_mixer_suspend()
3708 if (cval->val_type == USB_MIXER_BESPOKEN) in restore_mixer_value()
3711 if (cval->cmask) { in restore_mixer_value()
3714 if (!(cval->cmask & BIT(c))) in restore_mixer_value()
3716 if (cval->cached & BIT(c + 1)) { in restore_mixer_value()
3718 cval->cache_val[idx]); in restore_mixer_value()
3726 if (cval->cached) in restore_mixer_value()
3727 snd_usb_set_cur_mix_value(cval, 0, 0, *cval->cache_val); in restore_mixer_value()
3741 if (list->resume) { in snd_usb_mixer_resume()
3742 err = list->resume(list); in snd_usb_mixer_resume()
3758 list->mixer = mixer; in snd_usb_mixer_elem_init_std()
3759 list->id = unitid; in snd_usb_mixer_elem_init_std()
3760 list->dump = snd_usb_mixer_dump_cval; in snd_usb_mixer_elem_init_std()
3761 list->resume = restore_mixer_value; in snd_usb_mixer_elem_init_std()