Lines Matching +full:mono +full:- +full:channel
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++) {
107 if (p->id == unitid &&
108 (!control || !p->control || control == p->control))
120 if (!p || !p->name)
123 buflen--;
124 len = strscpy(buf, p->name, buflen);
130 ((cval)->head.mixer->ignore_ctl_error ? 0 : (err))
136 if (!p || p->name || p->dB)
145 if (p && p->dB) {
146 cval->dBmin = p->dB->min;
147 cval->dBmax = p->dB->max;
148 cval->min_mute = p->dB->min_mute;
149 cval->initialized = 1;
160 if (!state->selector_map)
162 for (p = state->selector_map; p->id; p++) {
163 if (p->id == unitid && index < p->count) {
164 len = strscpy(buf, p->names[index], buflen);
180 while ((hdr = snd_usb_find_desc(state->buffer, state->buflen, hdr,
182 if (hdr->bLength >= 4 &&
183 hdr->bDescriptorSubtype >= UAC_INPUT_TERMINAL &&
184 hdr->bDescriptorSubtype <= UAC3_SAMPLE_RATE_CONVERTER &&
185 hdr->bUnitID == unit)
198 int len = usb_string(chip->dev, index, buf, maxlen - 1);
208 * convert from the byte/word on usb descriptor to the zero-based integer
212 switch (cval->val_type) {
223 val -= 0x100;
231 val -= 0x10000;
238 * convert from the zero-based int to the byte/word for usb descriptor
242 switch (cval->val_type) {
259 if (!cval->res)
260 cval->res = 1;
261 if (val < cval->min)
263 else if (val >= cval->max)
264 return DIV_ROUND_UP(cval->max - cval->min, cval->res);
266 return (val - cval->min) / cval->res;
272 return cval->min;
273 if (!cval->res)
274 cval->res = 1;
275 val *= cval->res;
276 val += cval->min;
277 if (val > cval->max)
278 return cval->max;
304 return get_iface_desc(mixer->hostif)->bInterfaceNumber;
310 struct snd_usb_audio *chip = cval->head.mixer->chip;
312 int val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1;
318 return -EIO;
320 while (timeout-- > 0) {
321 idx = mixer_ctrl_intf(cval->head.mixer) | (cval->head.id << 8);
322 err = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), request,
328 } else if (err == -ETIMEDOUT) {
334 request, validx, idx, cval->val_type);
335 return -EINVAL;
341 struct snd_usb_audio *chip = cval->head.mixer->chip;
348 val_size = uac2_ctl_value_size(cval->val_type);
363 return -EIO;
365 idx = mixer_ctrl_intf(cval->head.mixer) | (cval->head.id << 8);
366 ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), bRequest,
374 request, validx, idx, cval->val_type);
394 return -EINVAL;
406 validx += cval->idx_off;
408 return (cval->head.mixer->protocol == UAC_VERSION_1) ?
419 /* channel = 0: master, 1 = first channel */
421 int channel, int *value)
424 (cval->control << 8) | channel,
429 int channel, int index, int *value)
433 if (cval->cached & BIT(channel)) {
434 *value = cval->cache_val[index];
437 err = get_cur_mix_raw(cval, channel, value);
439 if (!cval->head.mixer->ignore_ctl_error)
440 usb_audio_dbg(cval->head.mixer->chip,
442 cval->control, channel, err);
445 cval->cached |= BIT(channel);
446 cval->cache_val[index] = *value;
457 struct snd_usb_audio *chip = cval->head.mixer->chip;
461 validx += cval->idx_off;
464 if (cval->head.mixer->protocol == UAC_VERSION_1) {
465 val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1;
467 val_len = uac2_ctl_value_size(cval->val_type);
472 return -EINVAL;
486 return -EIO;
488 while (timeout-- > 0) {
489 idx = mixer_ctrl_intf(cval->head.mixer) | (cval->head.id << 8);
490 err = snd_usb_ctl_msg(chip->dev,
491 usb_sndctrlpipe(chip->dev, 0), request,
496 else if (err == -ETIMEDOUT)
500 request, validx, idx, cval->val_type, buf[0], buf[1]);
501 return -EINVAL;
510 int snd_usb_set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel,
514 unsigned int read_only = (channel == 0) ?
515 cval->master_readonly :
516 cval->ch_readonly & BIT(channel - 1);
519 usb_audio_dbg(cval->head.mixer->chip,
520 "%s(): channel %d of control %d is read_only\n",
521 __func__, channel, cval->control);
526 UAC_SET_CUR, (cval->control << 8) | channel,
530 cval->cached |= BIT(channel);
531 cval->cache_val[index] = value;
545 return -ENOMEM;
546 if (cval->min_mute)
548 scale[2] = cval->dBmin;
549 scale[3] = cval->dBmax;
551 return -EFAULT;
563 * check if the input/output channel routing is enabled on the given bitmap.
584 struct usb_mixer_interface *mixer = list->mixer;
587 while (snd_ctl_find_id(mixer->chip->card, &kctl->id))
588 kctl->id.index++;
589 err = snd_ctl_add(mixer->chip->card, kctl);
591 usb_audio_dbg(mixer->chip, "cannot add control (err = %d)\n",
595 list->kctl = kctl;
596 list->is_std_info = is_std_info;
597 list->next_id_elem = mixer->id_elems[list->id];
598 mixer->id_elems[list->id] = list;
644 { 0x0712, "Multi-Track Recorder" },
655 if (iterm->name) {
656 len = snd_usb_copy_string_desc(chip, iterm->name,
662 /* virtual type - not a real terminal */
663 if (iterm->type >> 16) {
666 switch (iterm->type >> 16) {
680 return scnprintf(name, maxlen, "Unit %d", iterm->id);
684 switch (iterm->type & 0xff00) {
699 for (names = iterm_names; names->type; names++) {
700 if (names->type == iterm->type) {
701 strscpy(name, names->name, maxlen);
702 return strlen(names->name);
717 err = snd_usb_ctl_msg(state->chip->dev,
718 usb_rcvctrlpipe(state->chip->dev, 0),
722 snd_usb_ctrl_intf(state->mixer->hostif),
727 err = -EIO;
734 usb_audio_err(state->chip, "cannot request logical cluster ID: %d (err: %d)\n", cluster_id, err);
746 switch (state->mixer->protocol) {
750 if (desc->bLength < sizeof(*desc) + desc->bNrInPins + 1)
751 return 0; /* no bmControls -> skip */
775 term->type = le16_to_cpu(d->wTerminalType);
776 term->channels = d->bNrChannels;
777 term->chconfig = le16_to_cpu(d->wChannelConfig);
778 term->name = d->iTerminal;
790 err = __check_input_term(state, d->bCSourceID, term);
797 term->id = id;
798 term->type = le16_to_cpu(d->wTerminalType);
799 term->channels = d->bNrChannels;
800 term->chconfig = le32_to_cpu(d->bmChannelConfig);
801 term->name = d->iTerminal;
813 err = __check_input_term(state, d->bCSourceID, term);
820 term->id = id;
821 term->type = le16_to_cpu(d->wTerminalType);
823 err = get_cluster_channels_v3(state, le16_to_cpu(d->wClusterDescrID));
826 term->channels = err;
829 term->chconfig = 0;
831 term->name = le16_to_cpu(d->wTerminalDescrStr);
840 int protocol = state->mixer->protocol;
847 term->type = UAC3_MIXER_UNIT << 16; /* virtual type */
848 term->channels = err;
850 term->chconfig = uac_mixer_unit_wChannelConfig(d, protocol);
851 term->name = uac_mixer_unit_iMixer(d);
863 /* call recursively to retrieve the channel info */
864 err = __check_input_term(state, d->baSourceID[0], term);
867 term->type = UAC3_SELECTOR_UNIT << 16; /* virtual type */
868 term->id = id;
869 if (state->mixer->protocol != UAC_VERSION_3)
870 term->name = uac_selector_unit_iSelector(d);
879 int protocol = state->mixer->protocol;
882 if (d->bNrInPins) {
883 /* call recursively to retrieve the channel info */
884 err = __check_input_term(state, d->baSourceID[0], term);
889 term->type = vtype << 16; /* virtual type */
890 term->id = id;
895 if (!term->channels) {
896 term->channels = uac_processing_unit_bNrChannels(d);
897 term->chconfig = uac_processing_unit_wChannelConfig(d, protocol);
899 term->name = uac_processing_unit_iProcessing(d, protocol);
910 err = __check_input_term(state, d->bSourceID, term);
913 term->type = UAC3_EFFECT_UNIT << 16; /* virtual type */
914 term->id = id;
924 term->type = UAC3_CLOCK_SOURCE << 16; /* virtual type */
925 term->id = id;
926 term->name = d->iClockSource;
936 term->type = UAC3_CLOCK_SOURCE << 16; /* virtual type */
937 term->id = id;
938 term->name = le16_to_cpu(d->wClockSourceStr);
951 int protocol = state->mixer->protocol;
957 if (test_and_set_bit(id, state->termbitmap))
958 return -EINVAL;
967 term->id = id;
976 id = d->bSourceID;
1013 return -ENODEV;
1016 return -ENODEV;
1024 memset(state->termbitmap, 0, sizeof(state->termbitmap));
1037 int type_uac2; /* data type for uac2 if different from uac1, else -1 */
1041 { UAC_FU_MUTE, "Mute", USB_MIXER_INV_BOOLEAN, -1 },
1042 { UAC_FU_VOLUME, "Volume", USB_MIXER_S16, -1 },
1043 { UAC_FU_BASS, "Tone Control - Bass", USB_MIXER_S8, -1 },
1044 { UAC_FU_MID, "Tone Control - Mid", USB_MIXER_S8, -1 },
1045 { UAC_FU_TREBLE, "Tone Control - Treble", USB_MIXER_S8, -1 },
1046 { UAC_FU_GRAPHIC_EQUALIZER, "Graphic Equalizer", USB_MIXER_S8, -1 }, /* FIXME: not implemented yet */
1047 { UAC_FU_AUTOMATIC_GAIN, "Auto Gain Control", USB_MIXER_BOOLEAN, -1 },
1049 { UAC_FU_BASS_BOOST, "Bass Boost", USB_MIXER_BOOLEAN, -1 },
1050 { UAC_FU_LOUDNESS, "Loudness", USB_MIXER_BOOLEAN, -1 },
1052 { UAC2_FU_INPUT_GAIN, "Input Gain Control", USB_MIXER_S16, -1 },
1053 { UAC2_FU_INPUT_GAIN_PAD, "Input Gain Pad Control", USB_MIXER_S16, -1 },
1054 { UAC2_FU_PHASE_INVERTER, "Phase Inverter Control", USB_MIXER_BOOLEAN, -1 },
1065 usb_mixer_elem_info_free(kctl->private_data);
1066 kctl->private_data = NULL;
1077 struct snd_usb_audio *chip = cval->head.mixer->chip;
1079 if (chip->quirk_flags & QUIRK_FLAG_MIC_RES_384) {
1080 if (!strcmp(kctl->id.name, "Mic Capture Volume")) {
1082 "set resolution quirk: cval->res = 384\n");
1083 cval->res = 384;
1085 } else if (chip->quirk_flags & QUIRK_FLAG_MIC_RES_16) {
1086 if (!strcmp(kctl->id.name, "Mic Capture Volume")) {
1088 "set resolution quirk: cval->res = 16\n");
1089 cval->res = 16;
1093 switch (chip->usb_id) {
1094 case USB_ID(0x0763, 0x2030): /* M-Audio Fast Track C400 */
1095 case USB_ID(0x0763, 0x2031): /* M-Audio Fast Track C600 */
1096 if (strcmp(kctl->id.name, "Effect Duration") == 0) {
1097 cval->min = 0x0000;
1098 cval->max = 0xffff;
1099 cval->res = 0x00e6;
1102 if (strcmp(kctl->id.name, "Effect Volume") == 0 ||
1103 strcmp(kctl->id.name, "Effect Feedback Volume") == 0) {
1104 cval->min = 0x00;
1105 cval->max = 0xff;
1108 if (strstr(kctl->id.name, "Effect Return") != NULL) {
1109 cval->min = 0xb706;
1110 cval->max = 0xff7b;
1111 cval->res = 0x0073;
1114 if ((strstr(kctl->id.name, "Playback Volume") != NULL) ||
1115 (strstr(kctl->id.name, "Effect Send") != NULL)) {
1116 cval->min = 0xb5fb; /* -73 dB = 0xb6ff */
1117 cval->max = 0xfcfe;
1118 cval->res = 0x0073;
1122 case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */
1123 case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra */
1124 if (strcmp(kctl->id.name, "Effect Duration") == 0) {
1127 cval->min = 0x0000;
1128 cval->max = 0x7f00;
1129 cval->res = 0x0100;
1132 if (strcmp(kctl->id.name, "Effect Volume") == 0 ||
1133 strcmp(kctl->id.name, "Effect Feedback Volume") == 0) {
1136 cval->min = 0x00;
1137 cval->max = 0x7f;
1143 if (!strcmp(kctl->id.name, "PCM Playback Volume")) {
1145 "set volume quirk for CM102-A+/102S+\n");
1146 cval->min = -256;
1150 case USB_ID(0x045e, 0x070f): /* MS LifeChat LX-3000 Headset */
1151 if (!strcmp(kctl->id.name, "Speaker Playback Volume")) {
1153 "set volume quirk for MS LifeChat LX-3000\n");
1154 cval->res = 192;
1165 * I hope that the min value is -15360 for newer firmware --jk
1167 if (!strcmp(kctl->id.name, "PCM Playback Volume") &&
1168 cval->min == -15616) {
1171 cval->max = -256;
1176 if (!strcmp(kctl->id.name, "Mic Capture Volume")) {
1179 cval->min = 6080;
1180 cval->max = 8768;
1181 cval->res = 192;
1186 if ((strstr(kctl->id.name, "Playback Volume") != NULL) ||
1187 strstr(kctl->id.name, "Capture Volume") != NULL) {
1188 cval->min >>= 8;
1189 cval->max = 0;
1190 cval->res = 1;
1194 if (!strcmp(kctl->id.name, "PCM Playback Volume")) {
1197 cval->min = -14208; /* Mute under it */
1200 case USB_ID(0x12d1, 0x3a07): /* Huawei Technologies Co., Ltd. CM-Q3 */
1201 if (!strcmp(kctl->id.name, "PCM Playback Volume")) {
1203 "set volume quirk for Huawei Technologies Co., Ltd. CM-Q3\n");
1204 cval->min = -11264; /* Mute under it */
1220 if (!cval->head.mixer->ignore_ctl_error)
1221 usb_audio_warn(cval->head.mixer->chip,
1223 cval->head.id, mixer_ctrl_intf(cval->head.mixer),
1225 snd_usb_set_cur_mix_value(cval, ch, idx, cval->min);
1237 cval->min = default_min;
1238 cval->max = cval->min + 1;
1239 cval->res = 1;
1240 cval->dBmin = cval->dBmax = 0;
1242 if (cval->val_type == USB_MIXER_BOOLEAN ||
1243 cval->val_type == USB_MIXER_INV_BOOLEAN) {
1244 cval->initialized = 1;
1247 if (cval->cmask) {
1249 if (cval->cmask & BIT(i)) {
1254 if (get_ctl_value(cval, UAC_GET_MAX, (cval->control << 8) | minchn, &cval->max) < 0 ||
1255 get_ctl_value(cval, UAC_GET_MIN, (cval->control << 8) | minchn, &cval->min) < 0) {
1256 usb_audio_err(cval->head.mixer->chip,
1258 cval->head.id, mixer_ctrl_intf(cval->head.mixer),
1259 cval->control, cval->head.id);
1260 return -EINVAL;
1263 (cval->control << 8) | minchn,
1264 &cval->res) < 0) {
1265 cval->res = 1;
1266 } else if (cval->head.mixer->protocol == UAC_VERSION_1) {
1267 int last_valid_res = cval->res;
1269 while (cval->res > 1) {
1271 (cval->control << 8) | minchn,
1272 cval->res / 2) < 0)
1274 cval->res /= 2;
1277 (cval->control << 8) | minchn, &cval->res) < 0)
1278 cval->res = last_valid_res;
1280 if (cval->res == 0)
1281 cval->res = 1;
1289 if (cval->min + cval->res < cval->max) {
1290 int last_valid_res = cval->res;
1296 if (test < cval->max)
1297 test += cval->res;
1299 test -= cval->res;
1300 if (test < cval->min || test > cval->max ||
1303 cval->res = last_valid_res;
1308 cval->res *= 2;
1314 cval->initialized = 1;
1323 cval->dBmin = (convert_signed_value(cval, cval->min) * 100) / 256;
1324 cval->dBmax = (convert_signed_value(cval, cval->max) * 100) / 256;
1325 if (cval->dBmin > cval->dBmax) {
1327 if (cval->dBmin < 0)
1328 cval->dBmax = 0;
1329 else if (cval->dBmin > 0)
1330 cval->dBmin = 0;
1331 if (cval->dBmin > cval->dBmax) {
1333 return -EINVAL;
1337 * here we use -96dB as the threshold
1339 if (cval->dBmax <= -9600) {
1340 usb_audio_info(cval->head.mixer->chip,
1342 cval->head.id, mixer_ctrl_intf(cval->head.mixer),
1343 cval->dBmin, cval->dBmax);
1344 cval->dBmin = cval->dBmax = 0;
1349 if (!cval->cmask) {
1354 if (cval->cmask & BIT(i)) {
1369 if (!cval->max_exposed) {
1370 if (cval->res)
1371 cval->max_exposed =
1372 DIV_ROUND_UP(cval->max - cval->min, cval->res);
1374 cval->max_exposed = cval->max - cval->min;
1376 return cval->max_exposed;
1385 if (cval->val_type == USB_MIXER_BOOLEAN ||
1386 cval->val_type == USB_MIXER_INV_BOOLEAN)
1387 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1389 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1390 uinfo->count = cval->channels;
1391 if (cval->val_type != USB_MIXER_BOOLEAN &&
1392 cval->val_type != USB_MIXER_INV_BOOLEAN) {
1393 if (!cval->initialized) {
1395 if (cval->initialized && cval->dBmin >= cval->dBmax) {
1396 kcontrol->vd[0].access &=
1399 snd_ctl_notify(cval->head.mixer->chip->card,
1401 &kcontrol->id);
1406 uinfo->value.integer.min = 0;
1407 uinfo->value.integer.max = get_max_exposed(cval);
1418 ucontrol->value.integer.value[0] = cval->min;
1419 if (cval->cmask) {
1422 if (!(cval->cmask & BIT(c)))
1428 ucontrol->value.integer.value[cnt] = val;
1433 /* master channel */
1438 ucontrol->value.integer.value[0] = val;
1452 if (cval->cmask) {
1455 if (!(cval->cmask & BIT(c)))
1460 val = ucontrol->value.integer.value[cnt];
1462 return -EINVAL;
1471 /* master channel */
1475 val = ucontrol->value.integer.value[0];
1477 return -EINVAL;
1487 /* get the boolean value from the master channel of a UAC control */
1498 ucontrol->value.integer.value[0] = val;
1505 struct snd_usb_audio *chip = cval->head.mixer->chip;
1508 validx = cval->control << 8 | 0;
1512 ret = -EIO;
1516 idx = mixer_ctrl_intf(cval->head.mixer) | (cval->head.id << 8);
1517 if (cval->head.mixer->protocol == UAC_VERSION_2) {
1520 ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), UAC2_CS_CUR,
1528 ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), UAC2_CS_CUR,
1544 UAC_GET_CUR, validx, idx, cval->val_type);
1562 ret = get_connector_value(cval, kcontrol->id.name, &val);
1567 ucontrol->value.integer.value[0] = val;
1579 /* the read-only variant */
1590 * the master channel.
1621 return strlcat(kctl->id.name, str, sizeof(kctl->id.name));
1637 if (strcmp("Speaker", kctl->id.name))
1641 if (strstr(card->shortname, *s)) {
1690 snd_usb_mixer_elem_init_std(&cval->head, mixer, unitid);
1691 cval->control = control;
1692 cval->cmask = ctl_mask;
1699 if (mixer->protocol == UAC_VERSION_1)
1700 cval->val_type = ctl_info->type;
1702 cval->val_type = ctl_info->type_uac2 >= 0 ?
1703 ctl_info->type_uac2 : ctl_info->type;
1706 cval->channels = 1; /* master channel */
1707 cval->master_readonly = readonly_mask;
1713 cval->channels = c;
1714 cval->ch_readonly = readonly_mask;
1718 * If all channels in the mask are marked read-only, make the control
1719 * read-only. snd_usb_set_cur_mix_value() will check the mask again and won't
1720 * issue write commands to read-only channels.
1722 if (cval->channels == readonly_mask)
1728 usb_audio_err(mixer->chip, "cannot malloc kcontrol\n");
1732 kctl->private_free = snd_usb_mixer_elem_free;
1734 len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
1737 len = snd_usb_copy_string_desc(mixer->chip, nameid,
1738 kctl->id.name, sizeof(kctl->id.name));
1745 * - if a name id is given in descriptor, use it.
1746 * - if the connected input can be determined, then use the name
1748 * - if the connected output can be determined, use it.
1749 * - otherwise, anonymous name.
1753 len = get_term_name(mixer->chip, iterm,
1754 kctl->id.name,
1755 sizeof(kctl->id.name), 1);
1757 len = get_term_name(mixer->chip, oterm,
1758 kctl->id.name,
1759 sizeof(kctl->id.name), 1);
1761 snprintf(kctl->id.name, sizeof(kctl->id.name),
1766 check_no_speaker_on_headset(kctl, mixer->chip->card);
1773 if (!mapped_name && oterm && !(oterm->type >> 16)) {
1774 if ((oterm->type & 0xff00) == 0x0100)
1784 strscpy(kctl->id.name, audio_feature_info[control-1].name,
1785 sizeof(kctl->id.name));
1793 if (cval->max <= cval->min) {
1794 usb_audio_dbg(mixer->chip,
1796 cval->head.id, kctl->id.name);
1804 if (cval->dBmin < cval->dBmax || !cval->initialized) {
1805 kctl->tlv.c = snd_usb_mixer_vol_tlv;
1806 kctl->vd[0].access |=
1814 range = (cval->max - cval->min) / cval->res;
1821 usb_audio_warn(mixer->chip,
1822 "Warning! Unlikely big volume range (=%u), cval->res is probably wrong.",
1824 usb_audio_warn(mixer->chip,
1826 cval->head.id, kctl->id.name, cval->channels,
1827 cval->min, cval->max, cval->res);
1830 usb_audio_dbg(mixer->chip, "[%d] FU [%s] ch = %d, val = %d/%d/%d\n",
1831 cval->head.id, kctl->id.name, cval->channels,
1832 cval->min, cval->max, cval->res);
1833 snd_usb_mixer_add_control(&cval->head, kctl);
1844 __build_feature_ctl(state->mixer, state->map, ctl_mask, control,
1845 iterm, &state->oterm, unitid, nameid, readonly_mask);
1860 int name_len = get_term_name(mixer->chip, term, name, name_size, 0);
1871 strlcat(name, " - Input Jack", name_size);
1873 strlcat(name, " - Output Jack", name_size);
1885 /* Build a mixer control for a UAC connector control (jack-detect) */
1894 map = find_map(imap, term->id, 0);
1901 snd_usb_mixer_elem_init_std(&cval->head, mixer, term->id);
1904 cval->head.resume = connector_mixer_resume;
1916 if (mixer->protocol == UAC_VERSION_2)
1917 cval->control = UAC2_TE_CONNECTOR;
1919 cval->control = UAC3_TE_INSERTION;
1921 cval->val_type = USB_MIXER_BOOLEAN;
1922 cval->channels = 1; /* report true if any channel is connected */
1923 cval->min = 0;
1924 cval->max = 1;
1927 usb_audio_err(mixer->chip, "cannot malloc kcontrol\n");
1932 if (check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)))
1933 strlcat(kctl->id.name, " Jack", sizeof(kctl->id.name));
1935 get_connector_control_name(mixer, term, is_input, kctl->id.name,
1936 sizeof(kctl->id.name));
1937 kctl->private_free = snd_usb_mixer_elem_free;
1938 snd_usb_mixer_add_control(&cval->head, kctl);
1949 if (state->mixer->protocol != UAC_VERSION_2)
1950 return -EINVAL;
1956 if (!uac_v2v3_control_is_readable(hdr->bmControls,
1962 return -ENOMEM;
1964 snd_usb_mixer_elem_init_std(&cval->head, state->mixer, hdr->bClockID);
1966 cval->min = 0;
1967 cval->max = 1;
1968 cval->channels = 1;
1969 cval->val_type = USB_MIXER_BOOLEAN;
1970 cval->control = UAC2_CS_CONTROL_CLOCK_VALID;
1972 cval->master_readonly = 1;
1978 return -ENOMEM;
1981 kctl->private_free = snd_usb_mixer_elem_free;
1982 ret = snd_usb_copy_string_desc(state->chip, hdr->iClockSource,
1983 kctl->id.name, sizeof(kctl->id.name));
1987 snprintf(kctl->id.name, sizeof(kctl->id.name),
1988 "Clock Source %d Validity", hdr->bClockID);
1990 return snd_usb_mixer_add_control(&cval->head, kctl);
2008 if (state->mixer->protocol == UAC_VERSION_1) {
2009 csize = hdr->bControlSize;
2010 channels = (hdr->bLength - 7) / csize - 1;
2011 bmaControls = hdr->bmaControls;
2012 } else if (state->mixer->protocol == UAC_VERSION_2) {
2015 channels = (hdr->bLength - 6) / 4 - 1;
2016 bmaControls = ftr->bmaControls;
2021 channels = (ftr->bLength - 7) / 4 - 1;
2022 bmaControls = ftr->bmaControls;
2026 usb_audio_info(state->chip,
2029 return -EINVAL;
2033 err = parse_audio_unit(state, hdr->bSourceID);
2038 err = check_input_term(state, hdr->bSourceID, &iterm);
2044 switch (state->chip->usb_id) {
2046 usb_audio_info(state->chip,
2048 /* disable non-functional volume control */
2052 usb_audio_info(state->chip,
2054 /* disable non-functional volume control */
2060 if (state->mixer->protocol == UAC_VERSION_1) {
2074 /* audio class v1 controls are never read-only */
2077 * The first channel must be set
2107 * read-only if all channels are marked read-only in
2110 * actually issue a write command for read-only
2115 * The first channel must be set
2165 * input channel number (zero based) is given in control field instead.
2177 map = find_map(state->map, unitid, 0);
2185 snd_usb_mixer_elem_init_std(&cval->head, state->mixer, unitid);
2186 cval->control = in_ch + 1; /* based on 1 */
2187 cval->val_type = USB_MIXER_S16;
2189 __u8 *c = uac_mixer_unit_bmControls(desc, state->mixer->protocol);
2192 cval->cmask |= BIT(i);
2193 cval->channels++;
2202 usb_audio_err(state->chip, "cannot malloc kcontrol\n");
2206 kctl->private_free = snd_usb_mixer_elem_free;
2208 len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
2210 len = get_term_name(state->chip, iterm, kctl->id.name,
2211 sizeof(kctl->id.name), 0);
2213 snprintf(kctl->id.name, sizeof(kctl->id.name), "Mixer Source %d", in_ch + 1);
2217 usb_audio_dbg(state->chip, "[%d] MU [%s] ch = %d, val = %d/%d\n",
2218 cval->head.id, kctl->id.name, cval->channels, cval->min, cval->max);
2219 snd_usb_mixer_add_control(&cval->head, kctl);
2228 if (state->mixer->protocol == UAC_VERSION_2) {
2231 term_id = d_v2->bTerminalID;
2232 bmctls = le16_to_cpu(d_v2->bmControls);
2233 } else if (state->mixer->protocol == UAC_VERSION_3) {
2236 term_id = d_v3->bTerminalID;
2237 bmctls = le32_to_cpu(d_v3->bmControls);
2247 build_connector_control(state->mixer, state->map, &iterm, true);
2265 usb_audio_err(state->chip,
2272 input_pins = desc->bNrInPins;
2277 err = parse_audio_unit(state, desc->baSourceID[pin]);
2280 /* no bmControls field (e.g. Maya44) -> ignore */
2283 err = check_input_term(state, desc->baSourceID[pin], &iterm);
2287 if (mixer_bitmap_overflow(desc, state->mixer->protocol,
2295 state->mixer->protocol);
2321 err = get_cur_ctl_value(cval, cval->control << 8, &val);
2323 ucontrol->value.integer.value[0] = cval->min;
2327 ucontrol->value.integer.value[0] = val;
2338 err = get_cur_ctl_value(cval, cval->control << 8, &oval);
2341 val = ucontrol->value.integer.value[0];
2343 return -EINVAL;
2346 set_cur_ctl_value(cval, cval->control << 8, val);
2443 { UAC3_PROCESS_MULTI_FUNCTION, "Multi-Function", undefined_proc_info },
2499 num_ins = desc->bNrInPins;
2501 err = parse_audio_unit(state, desc->baSourceID[i]);
2506 type = le16_to_cpu(desc->wProcessType);
2507 for (info = list; info && info->type; info++)
2508 if (info->type == type)
2510 if (!info || !info->type)
2513 for (valinfo = info->values; valinfo->control; valinfo++) {
2514 __u8 *controls = uac_processing_unit_bmControls(desc, state->mixer->protocol);
2516 if (state->mixer->protocol == UAC_VERSION_1) {
2517 if (!(controls[valinfo->control / 8] &
2518 BIT((valinfo->control % 8) - 1)))
2521 if (!uac_v2v3_control_is_readable(controls[valinfo->control / 8],
2522 valinfo->control))
2526 map = find_map(state->map, unitid, valinfo->control);
2531 return -ENOMEM;
2532 snd_usb_mixer_elem_init_std(&cval->head, state->mixer, unitid);
2533 cval->control = valinfo->control;
2534 cval->val_type = valinfo->val_type;
2535 cval->channels = 1;
2537 if (state->mixer->protocol > UAC_VERSION_1 &&
2538 !uac_v2v3_control_is_writeable(controls[valinfo->control / 8],
2539 valinfo->control))
2540 cval->master_readonly = 1;
2547 switch (state->mixer->protocol) {
2551 if (cval->control == UAC_UD_MODE_SELECT)
2555 if (cval->control == UAC3_UD_MODE_SELECT)
2562 state->mixer->protocol);
2563 cval->min = 1;
2564 cval->max = control_spec[0];
2565 cval->res = 1;
2566 cval->initialized = 1;
2570 get_min_max(cval, valinfo->min_value);
2575 * E-Mu USB 0404/0202/TrackerPre/0204
2578 cval->min = 0;
2579 cval->max = 5;
2580 cval->res = 1;
2581 cval->initialized = 1;
2584 get_min_max(cval, valinfo->min_value);
2588 err = get_cur_ctl_value(cval, cval->control << 8, &val);
2591 return -EINVAL;
2597 return -ENOMEM;
2599 kctl->private_free = snd_usb_mixer_elem_free;
2601 if (check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name))) {
2603 } else if (info->name) {
2604 strscpy(kctl->id.name, info->name, sizeof(kctl->id.name));
2607 nameid = uac_extension_unit_iExtension(desc, state->mixer->protocol);
2609 nameid = uac_processing_unit_iProcessing(desc, state->mixer->protocol);
2612 len = snd_usb_copy_string_desc(state->chip,
2614 kctl->id.name,
2615 sizeof(kctl->id.name));
2617 strscpy(kctl->id.name, name, sizeof(kctl->id.name));
2620 append_ctl_name(kctl, valinfo->suffix);
2622 usb_audio_dbg(state->chip,
2624 cval->head.id, kctl->id.name, cval->channels,
2625 cval->min, cval->max);
2627 err = snd_usb_mixer_add_control(&cval->head, kctl);
2637 switch (state->mixer->protocol) {
2671 const char **itemlist = (const char **)kcontrol->private_value;
2674 return -EINVAL;
2675 return snd_ctl_enum_info(uinfo, 1, cval->max, itemlist);
2685 err = get_cur_ctl_value(cval, cval->control << 8, &val);
2687 ucontrol->value.enumerated.item[0] = 0;
2691 ucontrol->value.enumerated.item[0] = val;
2702 err = get_cur_ctl_value(cval, cval->control << 8, &oval);
2705 val = ucontrol->value.enumerated.item[0];
2706 if (val < 0 || val >= cval->max) /* here cval->max = # elements */
2707 return -EINVAL;
2710 set_cur_ctl_value(cval, cval->control << 8, val);
2733 if (kctl->private_data) {
2734 struct usb_mixer_elem_info *cval = kctl->private_data;
2735 num_ins = cval->max;
2737 kctl->private_data = NULL;
2739 if (kctl->private_value) {
2740 char **itemlist = (char **)kctl->private_value;
2744 kctl->private_value = 0;
2762 for (i = 0; i < desc->bNrInPins; i++) {
2763 err = parse_audio_unit(state, desc->baSourceID[i]);
2768 if (desc->bNrInPins == 1) /* only one ? nonsense! */
2771 map = find_map(state->map, unitid, 0);
2777 return -ENOMEM;
2778 snd_usb_mixer_elem_init_std(&cval->head, state->mixer, unitid);
2779 cval->val_type = USB_MIXER_U8;
2780 cval->channels = 1;
2781 cval->min = 1;
2782 cval->max = desc->bNrInPins;
2783 cval->res = 1;
2784 cval->initialized = 1;
2786 switch (state->mixer->protocol) {
2789 cval->control = 0;
2793 if (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR ||
2794 desc->bDescriptorSubtype == UAC3_CLOCK_SELECTOR)
2795 cval->control = UAC2_CX_CLOCK_SELECTOR;
2797 cval->control = UAC2_SU_SELECTOR;
2801 namelist = kcalloc(desc->bNrInPins, sizeof(char *), GFP_KERNEL);
2803 err = -ENOMEM;
2807 for (i = 0; i < desc->bNrInPins; i++) {
2811 err = -ENOMEM;
2816 if (! len && check_input_term(state, desc->baSourceID[i], &iterm) >= 0)
2817 len = get_term_name(state->chip, &iterm, namelist[i],
2825 usb_audio_err(state->chip, "cannot malloc kcontrol\n");
2826 err = -ENOMEM;
2829 kctl->private_value = (unsigned long)namelist;
2830 kctl->private_free = usb_mixer_selector_elem_free;
2833 len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
2836 switch (state->mixer->protocol) {
2843 len = snd_usb_copy_string_desc(state->chip,
2844 nameid, kctl->id.name,
2845 sizeof(kctl->id.name));
2848 /* TODO: Class-Specific strings not yet supported */
2854 len = get_term_name(state->chip, &state->oterm,
2855 kctl->id.name, sizeof(kctl->id.name), 0);
2858 strscpy(kctl->id.name, "USB", sizeof(kctl->id.name));
2861 if (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR ||
2862 desc->bDescriptorSubtype == UAC3_CLOCK_SELECTOR)
2864 else if ((state->oterm.type & 0xff00) == 0x0100)
2870 usb_audio_dbg(state->chip, "[%d] SU [%s] items = %d\n",
2871 cval->head.id, kctl->id.name, desc->bNrInPins);
2872 return snd_usb_mixer_add_control(&cval->head, kctl);
2875 for (i = 0; i < desc->bNrInPins; i++)
2890 int protocol = state->mixer->protocol;
2892 if (test_and_set_bit(unitid, state->unitbitmap))
2897 usb_audio_err(state->chip, "unit %d not found!\n", unitid);
2898 return -EINVAL;
2902 usb_audio_dbg(state->chip, "invalid unit %d\n", unitid);
2938 return 0; /* FIXME - effect units not implemented yet */
2940 usb_audio_err(state->chip,
2943 return -EINVAL;
2952 kfree(mixer->id_elems);
2953 if (mixer->urb) {
2954 kfree(mixer->urb->transfer_buffer);
2955 usb_free_urb(mixer->urb);
2957 usb_free_urb(mixer->rc_urb);
2958 kfree(mixer->rc_setup_packet);
2964 struct usb_mixer_interface *mixer = device->device_data;
2975 int st_chmask; /* side tone mixing channel mask */
2982 * IN: Mono or Stereo cfg, Mono alt possible
2983 * OUT: Mono or Stereo cfg, Mono alt possible
2987 .c_chmask = -1, /* dynamic channels */
2988 .p_chmask = -1, /* dynamic channels */
2991 /* BAOF; Stereo only cfg, Mono alt possible */
2997 /* BAOF; Mono or Stereo cfg, Mono alt possible */
3000 .p_chmask = -1, /* dynamic channels */
3003 /* BAIF; Mono or Stereo cfg, Mono alt possible */
3006 .c_chmask = -1, /* dynamic channels */
3011 * IN: Mono only
3012 * OUT: Mono or Stereo cfg, Mono alt possible
3017 .p_chmask = -1, /* dynamic channels */
3021 /* BAIOF; IN: Mono only; OUT: Stereo only, Mono alt possible */
3029 /* BAIF + BAOF; IN: Mono only; OUT: Mono only */
3044 * at least one channel is present
3046 if (f->c_chmask < 0 && f->p_chmask < 0) {
3048 usb_audio_warn(mixer->chip, "BAAD %s: no channels?",
3049 f->name);
3055 if ((f->c_chmask < 0 && !c_chmask) ||
3056 (f->c_chmask >= 0 && f->c_chmask != c_chmask)) {
3057 usb_audio_warn(mixer->chip, "BAAD %s c_chmask mismatch",
3058 f->name);
3061 if ((f->p_chmask < 0 && !p_chmask) ||
3062 (f->p_chmask >= 0 && f->p_chmask != p_chmask)) {
3063 usb_audio_warn(mixer->chip, "BAAD %s p_chmask mismatch",
3064 f->name);
3080 struct usb_device *dev = mixer->chip->dev;
3082 int badd_profile = mixer->chip->badd_profile;
3088 assoc = usb_ifnum_to_if(dev, ctrlif)->intf_assoc;
3091 for (i = 0; i < assoc->bInterfaceCount; i++) {
3092 int intf = assoc->bFirstInterface + i;
3108 num = iface->num_altsetting;
3111 return -EINVAL;
3120 alts = &iface->altsetting[1];
3123 if (altsd->bNumEndpoints < 1)
3124 return -EINVAL;
3127 dir_in = (get_endpoint(alts, 0)->bEndpointAddress & USB_DIR_IN);
3128 maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
3132 usb_audio_err(mixer->chip,
3135 return -EINVAL;
3156 usb_audio_dbg(mixer->chip,
3161 for (map = uac3_badd_usbmix_ctl_maps; map->id; map++) {
3162 if (map->id == badd_profile)
3166 if (!map->id)
3167 return -EINVAL;
3169 for (f = uac3_badd_profiles; f->name; f++) {
3170 if (badd_profile == f->subclass)
3173 if (!f->name)
3174 return -EINVAL;
3176 return -EINVAL;
3177 st_chmask = f->st_chmask;
3181 /* Master channel, always writable */
3183 UAC3_BADD_FU_ID2, map->map);
3184 /* Mono/Stereo volume channels, always writable */
3186 UAC3_BADD_FU_ID2, map->map);
3191 /* Master channel, always writable */
3193 UAC3_BADD_FU_ID5, map->map);
3194 /* Mono/Stereo volume channels, always writable */
3196 UAC3_BADD_FU_ID5, map->map);
3199 /* Side tone-mixing */
3201 /* Master channel, always writable */
3203 UAC3_BADD_FU_ID7, map->map);
3204 /* Mono volume channel, always writable */
3206 UAC3_BADD_FU_ID7, map->map);
3210 if (f->subclass == UAC3_FUNCTION_SUBCLASS_HEADSET_ADAPTER) {
3213 /* Input Term - Insertion control */
3217 build_connector_control(mixer, map->map, &iterm, true);
3219 /* Output Term - Insertion control */
3223 build_connector_control(mixer, map->map, &oterm, false);
3242 state.chip = mixer->chip;
3244 state.buffer = mixer->hostif->extra;
3245 state.buflen = mixer->hostif->extralen;
3248 for (map = usbmix_ctl_maps; map->id; map++) {
3249 if (map->id == state.chip->usb_id) {
3250 state.map = map->map;
3251 state.selector_map = map->selector_map;
3252 mixer->connector_map = map->connector_map;
3258 while ((p = snd_usb_find_csint_desc(mixer->hostif->extra,
3259 mixer->hostif->extralen,
3261 if (!snd_usb_validate_audio_desc(p, mixer->protocol))
3264 if (mixer->protocol == UAC_VERSION_1) {
3268 set_bit(desc->bTerminalID, state.unitbitmap);
3269 state.oterm.id = desc->bTerminalID;
3270 state.oterm.type = le16_to_cpu(desc->wTerminalType);
3271 state.oterm.name = desc->iTerminal;
3272 err = parse_audio_unit(&state, desc->bSourceID);
3273 if (err < 0 && err != -EINVAL)
3275 } else if (mixer->protocol == UAC_VERSION_2) {
3279 set_bit(desc->bTerminalID, state.unitbitmap);
3280 state.oterm.id = desc->bTerminalID;
3281 state.oterm.type = le16_to_cpu(desc->wTerminalType);
3282 state.oterm.name = desc->iTerminal;
3283 err = parse_audio_unit(&state, desc->bSourceID);
3284 if (err < 0 && err != -EINVAL)
3291 err = parse_audio_unit(&state, desc->bCSourceID);
3292 if (err < 0 && err != -EINVAL)
3296 uac_v2v3_control_is_readable(le16_to_cpu(desc->bmControls),
3305 set_bit(desc->bTerminalID, state.unitbitmap);
3306 state.oterm.id = desc->bTerminalID;
3307 state.oterm.type = le16_to_cpu(desc->wTerminalType);
3308 state.oterm.name = le16_to_cpu(desc->wTerminalDescrStr);
3309 err = parse_audio_unit(&state, desc->bSourceID);
3310 if (err < 0 && err != -EINVAL)
3317 err = parse_audio_unit(&state, desc->bCSourceID);
3318 if (err < 0 && err != -EINVAL)
3322 uac_v2v3_control_is_readable(le32_to_cpu(desc->bmControls),
3334 u8 *control, u8 *channel)
3336 const struct usbmix_connector_map *map = mixer->connector_map;
3341 for (; map->id; map++) {
3342 if (map->id == unitid) {
3343 if (control && map->control)
3344 *control = map->control;
3345 if (channel && map->channel)
3346 *channel = map->channel;
3347 return map->delegated_id;
3362 if (!list->is_std_info)
3366 info->cached = 0;
3367 snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
3368 &list->kctl->id);
3388 "channels=%i, type=\"%s\"\n", cval->head.id,
3389 cval->control, cval->cmask, cval->channels,
3390 val_types[cval->val_type]);
3392 cval->min, cval->max, cval->dBmin, cval->dBmax);
3398 struct snd_usb_audio *chip = entry->private_data;
3403 list_for_each_entry(mixer, &chip->mixer_list, list) {
3406 chip->usb_id, mixer_ctrl_intf(mixer),
3407 mixer->ignore_ctl_error);
3408 snd_iprintf(buffer, "Card: %s\n", chip->card->longname);
3411 snd_iprintf(buffer, " Unit: %i\n", list->id);
3412 if (list->kctl)
3415 list->kctl->id.name,
3416 list->kctl->id.index);
3417 if (list->dump)
3418 list->dump(buffer, list);
3430 __u8 channel = value & 0xff;
3433 if (channel >= MAX_CHANNELS) {
3434 usb_audio_dbg(mixer->chip,
3435 "%s(): bogus channel number %d\n",
3436 __func__, channel);
3440 unitid = delegate_notify(mixer, unitid, &control, &channel);
3451 if (!list->kctl)
3453 if (!list->is_std_info)
3457 if (count > 1 && info->control != control)
3463 if (channel)
3464 info->cached &= ~BIT(channel);
3465 else /* master channel */
3466 info->cached = 0;
3468 snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
3469 &info->head.kctl->id);
3481 usb_audio_dbg(mixer->chip,
3491 struct usb_mixer_interface *mixer = urb->context;
3492 int len = urb->actual_length;
3493 int ustatus = urb->status;
3498 if (mixer->protocol == UAC_VERSION_1) {
3501 for (status = urb->transfer_buffer;
3503 len -= sizeof(*status), status++) {
3504 dev_dbg(&urb->dev->dev, "status interrupt: %02x %02x\n",
3505 status->bStatusType,
3506 status->bOriginator);
3509 if ((status->bStatusType & UAC1_STATUS_TYPE_ORIG_MASK) !=
3513 if (status->bStatusType & UAC1_STATUS_TYPE_MEM_CHANGED)
3514 snd_usb_mixer_rc_memory_change(mixer, status->bOriginator);
3516 snd_usb_mixer_notify_id(mixer, status->bOriginator);
3521 for (msg = urb->transfer_buffer;
3523 len -= sizeof(*msg), msg++) {
3525 if ((msg->bInfo & UAC2_INTERRUPT_DATA_MSG_VENDOR) ||
3526 (msg->bInfo & UAC2_INTERRUPT_DATA_MSG_EP))
3529 snd_usb_mixer_interrupt_v2(mixer, msg->bAttribute,
3530 le16_to_cpu(msg->wValue),
3531 le16_to_cpu(msg->wIndex));
3536 if (ustatus != -ENOENT &&
3537 ustatus != -ECONNRESET &&
3538 ustatus != -ESHUTDOWN) {
3539 urb->dev = mixer->chip->dev;
3553 if (get_iface_desc(mixer->hostif)->bNumEndpoints < 1)
3555 ep = get_endpoint(mixer->hostif, 0);
3560 buffer_length = le16_to_cpu(ep->wMaxPacketSize);
3563 return -ENOMEM;
3564 mixer->urb = usb_alloc_urb(0, GFP_KERNEL);
3565 if (!mixer->urb) {
3567 return -ENOMEM;
3569 usb_fill_int_urb(mixer->urb, mixer->chip->dev,
3570 usb_rcvintpipe(mixer->chip->dev, epnum),
3572 snd_usb_mixer_interrupt, mixer, ep->bInterval);
3573 usb_submit_urb(mixer->urb, GFP_KERNEL);
3585 strscpy(chip->card->mixername, "USB Mixer");
3589 return -ENOMEM;
3590 mixer->chip = chip;
3591 mixer->ignore_ctl_error = !!(chip->quirk_flags & QUIRK_FLAG_IGNORE_CTL_ERROR);
3592 mixer->id_elems = kcalloc(MAX_ID_ELEMS, sizeof(*mixer->id_elems),
3594 if (!mixer->id_elems) {
3596 return -ENOMEM;
3599 mixer->hostif = &usb_ifnum_to_if(chip->dev, ctrlif)->altsetting[0];
3600 switch (get_iface_desc(mixer->hostif)->bInterfaceProtocol) {
3603 mixer->protocol = UAC_VERSION_1;
3606 mixer->protocol = UAC_VERSION_2;
3609 mixer->protocol = UAC_VERSION_3;
3613 if (mixer->protocol == UAC_VERSION_3 &&
3614 chip->badd_profile >= UAC3_FUNCTION_SUBCLASS_GENERIC_IO) {
3632 err = snd_device_new(chip->card, SNDRV_DEV_CODEC, mixer, &dev_ops);
3636 if (list_empty(&chip->mixer_list))
3637 snd_card_ro_proc_new(chip->card, "usbmixer", chip,
3640 list_add(&mixer->list, &chip->mixer_list);
3650 if (mixer->disconnected)
3652 if (mixer->urb)
3653 usb_kill_urb(mixer->urb);
3654 if (mixer->rc_urb)
3655 usb_kill_urb(mixer->rc_urb);
3656 if (mixer->private_free)
3657 mixer->private_free(mixer);
3658 mixer->disconnected = true;
3664 usb_kill_urb(mixer->urb);
3665 usb_kill_urb(mixer->rc_urb);
3672 if (mixer->urb) {
3673 err = usb_submit_urb(mixer->urb, GFP_NOIO);
3684 if (mixer->private_suspend)
3685 mixer->private_suspend(mixer);
3694 if (cval->val_type == USB_MIXER_BESPOKEN)
3697 if (cval->cmask) {
3700 if (!(cval->cmask & BIT(c)))
3702 if (cval->cached & BIT(c + 1)) {
3704 cval->cache_val[idx]);
3712 if (cval->cached)
3713 snd_usb_set_cur_mix_value(cval, 0, 0, *cval->cache_val);
3727 if (list->resume) {
3728 err = list->resume(list);
3744 list->mixer = mixer;
3745 list->id = unitid;
3746 list->dump = snd_usb_mixer_dump_cval;
3747 list->resume = restore_mixer_value;