diff options
Diffstat (limited to 'sound/usb/mixer.c')
-rw-r--r-- | sound/usb/mixer.c | 411 |
1 files changed, 247 insertions, 164 deletions
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index d40a2850e270..0b728d886f0d 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c | |||
@@ -162,7 +162,7 @@ static int check_mapped_selector_name(struct mixer_build *state, int unitid, | |||
162 | { | 162 | { |
163 | const struct usbmix_selector_map *p; | 163 | const struct usbmix_selector_map *p; |
164 | 164 | ||
165 | if (! state->selector_map) | 165 | if (!state->selector_map) |
166 | return 0; | 166 | return 0; |
167 | for (p = state->selector_map; p->id; p++) { | 167 | for (p = state->selector_map; p->id; p++) { |
168 | if (p->id == unitid && index < p->count) | 168 | if (p->id == unitid && index < p->count) |
@@ -174,7 +174,8 @@ static int check_mapped_selector_name(struct mixer_build *state, int unitid, | |||
174 | /* | 174 | /* |
175 | * find an audio control unit with the given unit id | 175 | * find an audio control unit with the given unit id |
176 | */ | 176 | */ |
177 | static void *find_audio_control_unit(struct mixer_build *state, unsigned char unit) | 177 | static void *find_audio_control_unit(struct mixer_build *state, |
178 | unsigned char unit) | ||
178 | { | 179 | { |
179 | /* we just parse the header */ | 180 | /* we just parse the header */ |
180 | struct uac_feature_unit_descriptor *hdr = NULL; | 181 | struct uac_feature_unit_descriptor *hdr = NULL; |
@@ -194,7 +195,8 @@ static void *find_audio_control_unit(struct mixer_build *state, unsigned char un | |||
194 | /* | 195 | /* |
195 | * copy a string with the given id | 196 | * copy a string with the given id |
196 | */ | 197 | */ |
197 | static int snd_usb_copy_string_desc(struct mixer_build *state, int index, char *buf, int maxlen) | 198 | static int snd_usb_copy_string_desc(struct mixer_build *state, |
199 | int index, char *buf, int maxlen) | ||
198 | { | 200 | { |
199 | int len = usb_string(state->chip->dev, index, buf, maxlen - 1); | 201 | int len = usb_string(state->chip->dev, index, buf, maxlen - 1); |
200 | buf[len] = 0; | 202 | buf[len] = 0; |
@@ -253,7 +255,7 @@ static int convert_bytes_value(struct usb_mixer_elem_info *cval, int val) | |||
253 | 255 | ||
254 | static int get_relative_value(struct usb_mixer_elem_info *cval, int val) | 256 | static int get_relative_value(struct usb_mixer_elem_info *cval, int val) |
255 | { | 257 | { |
256 | if (! cval->res) | 258 | if (!cval->res) |
257 | cval->res = 1; | 259 | cval->res = 1; |
258 | if (val < cval->min) | 260 | if (val < cval->min) |
259 | return 0; | 261 | return 0; |
@@ -267,7 +269,7 @@ static int get_abs_value(struct usb_mixer_elem_info *cval, int val) | |||
267 | { | 269 | { |
268 | if (val < 0) | 270 | if (val < 0) |
269 | return cval->min; | 271 | return cval->min; |
270 | if (! cval->res) | 272 | if (!cval->res) |
271 | cval->res = 1; | 273 | cval->res = 1; |
272 | val *= cval->res; | 274 | val *= cval->res; |
273 | val += cval->min; | 275 | val += cval->min; |
@@ -281,7 +283,8 @@ static int get_abs_value(struct usb_mixer_elem_info *cval, int val) | |||
281 | * retrieve a mixer value | 283 | * retrieve a mixer value |
282 | */ | 284 | */ |
283 | 285 | ||
284 | static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret) | 286 | static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, |
287 | int validx, int *value_ret) | ||
285 | { | 288 | { |
286 | struct snd_usb_audio *chip = cval->mixer->chip; | 289 | struct snd_usb_audio *chip = cval->mixer->chip; |
287 | unsigned char buf[2]; | 290 | unsigned char buf[2]; |
@@ -292,6 +295,7 @@ static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, int v | |||
292 | err = snd_usb_autoresume(cval->mixer->chip); | 295 | err = snd_usb_autoresume(cval->mixer->chip); |
293 | if (err < 0) | 296 | if (err < 0) |
294 | return -EIO; | 297 | return -EIO; |
298 | |||
295 | down_read(&chip->shutdown_rwsem); | 299 | down_read(&chip->shutdown_rwsem); |
296 | while (timeout-- > 0) { | 300 | while (timeout-- > 0) { |
297 | if (chip->shutdown) | 301 | if (chip->shutdown) |
@@ -316,10 +320,11 @@ static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, int v | |||
316 | return err; | 320 | return err; |
317 | } | 321 | } |
318 | 322 | ||
319 | static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret) | 323 | static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, |
324 | int validx, int *value_ret) | ||
320 | { | 325 | { |
321 | struct snd_usb_audio *chip = cval->mixer->chip; | 326 | struct snd_usb_audio *chip = cval->mixer->chip; |
322 | unsigned char buf[2 + 3*sizeof(__u16)]; /* enough space for one range */ | 327 | unsigned char buf[2 + 3 * sizeof(__u16)]; /* enough space for one range */ |
323 | unsigned char *val; | 328 | unsigned char *val; |
324 | int idx = 0, ret, size; | 329 | int idx = 0, ret, size; |
325 | __u8 bRequest; | 330 | __u8 bRequest; |
@@ -339,9 +344,9 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int v | |||
339 | goto error; | 344 | goto error; |
340 | 345 | ||
341 | down_read(&chip->shutdown_rwsem); | 346 | down_read(&chip->shutdown_rwsem); |
342 | if (chip->shutdown) | 347 | if (chip->shutdown) { |
343 | ret = -ENODEV; | 348 | ret = -ENODEV; |
344 | else { | 349 | } else { |
345 | idx = snd_usb_ctrl_intf(chip) | (cval->id << 8); | 350 | idx = snd_usb_ctrl_intf(chip) | (cval->id << 8); |
346 | ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), bRequest, | 351 | ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), bRequest, |
347 | USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, | 352 | USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, |
@@ -382,7 +387,8 @@ error: | |||
382 | return 0; | 387 | return 0; |
383 | } | 388 | } |
384 | 389 | ||
385 | static int get_ctl_value(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret) | 390 | static int get_ctl_value(struct usb_mixer_elem_info *cval, int request, |
391 | int validx, int *value_ret) | ||
386 | { | 392 | { |
387 | validx += cval->idx_off; | 393 | validx += cval->idx_off; |
388 | 394 | ||
@@ -391,7 +397,8 @@ static int get_ctl_value(struct usb_mixer_elem_info *cval, int request, int vali | |||
391 | get_ctl_value_v2(cval, request, validx, value_ret); | 397 | get_ctl_value_v2(cval, request, validx, value_ret); |
392 | } | 398 | } |
393 | 399 | ||
394 | static int get_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int *value) | 400 | static int get_cur_ctl_value(struct usb_mixer_elem_info *cval, |
401 | int validx, int *value) | ||
395 | { | 402 | { |
396 | return get_ctl_value(cval, UAC_GET_CUR, validx, value); | 403 | return get_ctl_value(cval, UAC_GET_CUR, validx, value); |
397 | } | 404 | } |
@@ -400,7 +407,9 @@ static int get_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int * | |||
400 | static inline int get_cur_mix_raw(struct usb_mixer_elem_info *cval, | 407 | static inline int get_cur_mix_raw(struct usb_mixer_elem_info *cval, |
401 | int channel, int *value) | 408 | int channel, int *value) |
402 | { | 409 | { |
403 | return get_ctl_value(cval, UAC_GET_CUR, (cval->control << 8) | channel, value); | 410 | return get_ctl_value(cval, UAC_GET_CUR, |
411 | (cval->control << 8) | channel, | ||
412 | value); | ||
404 | } | 413 | } |
405 | 414 | ||
406 | static int get_cur_mix_value(struct usb_mixer_elem_info *cval, | 415 | static int get_cur_mix_value(struct usb_mixer_elem_info *cval, |
@@ -417,7 +426,7 @@ static int get_cur_mix_value(struct usb_mixer_elem_info *cval, | |||
417 | if (!cval->mixer->ignore_ctl_error) | 426 | if (!cval->mixer->ignore_ctl_error) |
418 | usb_audio_dbg(cval->mixer->chip, | 427 | usb_audio_dbg(cval->mixer->chip, |
419 | "cannot get current value for control %d ch %d: err = %d\n", | 428 | "cannot get current value for control %d ch %d: err = %d\n", |
420 | cval->control, channel, err); | 429 | cval->control, channel, err); |
421 | return err; | 430 | return err; |
422 | } | 431 | } |
423 | cval->cached |= 1 << channel; | 432 | cval->cached |= 1 << channel; |
@@ -425,7 +434,6 @@ static int get_cur_mix_value(struct usb_mixer_elem_info *cval, | |||
425 | return 0; | 434 | return 0; |
426 | } | 435 | } |
427 | 436 | ||
428 | |||
429 | /* | 437 | /* |
430 | * set a mixer value | 438 | * set a mixer value |
431 | */ | 439 | */ |
@@ -474,7 +482,7 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval, | |||
474 | } | 482 | } |
475 | } | 483 | } |
476 | usb_audio_dbg(chip, "cannot set ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d, data = %#x/%#x\n", | 484 | usb_audio_dbg(chip, "cannot set ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d, data = %#x/%#x\n", |
477 | request, validx, idx, cval->val_type, buf[0], buf[1]); | 485 | request, validx, idx, cval->val_type, buf[0], buf[1]); |
478 | err = -EINVAL; | 486 | err = -EINVAL; |
479 | 487 | ||
480 | out: | 488 | out: |
@@ -483,7 +491,8 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval, | |||
483 | return err; | 491 | return err; |
484 | } | 492 | } |
485 | 493 | ||
486 | static int set_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int value) | 494 | static int set_cur_ctl_value(struct usb_mixer_elem_info *cval, |
495 | int validx, int value) | ||
487 | { | 496 | { |
488 | return snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR, validx, value); | 497 | return snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR, validx, value); |
489 | } | 498 | } |
@@ -503,8 +512,9 @@ static int set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel, | |||
503 | return 0; | 512 | return 0; |
504 | } | 513 | } |
505 | 514 | ||
506 | err = snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR, (cval->control << 8) | channel, | 515 | err = snd_usb_mixer_set_ctl_value(cval, |
507 | value); | 516 | UAC_SET_CUR, (cval->control << 8) | channel, |
517 | value); | ||
508 | if (err < 0) | 518 | if (err < 0) |
509 | return err; | 519 | return err; |
510 | cval->cached |= 1 << channel; | 520 | cval->cached |= 1 << channel; |
@@ -541,13 +551,13 @@ static int parse_audio_unit(struct mixer_build *state, int unitid); | |||
541 | * check if the input/output channel routing is enabled on the given bitmap. | 551 | * check if the input/output channel routing is enabled on the given bitmap. |
542 | * used for mixer unit parser | 552 | * used for mixer unit parser |
543 | */ | 553 | */ |
544 | static int check_matrix_bitmap(unsigned char *bmap, int ich, int och, int num_outs) | 554 | static int check_matrix_bitmap(unsigned char *bmap, |
555 | int ich, int och, int num_outs) | ||
545 | { | 556 | { |
546 | int idx = ich * num_outs + och; | 557 | int idx = ich * num_outs + och; |
547 | return bmap[idx >> 3] & (0x80 >> (idx & 7)); | 558 | return bmap[idx >> 3] & (0x80 >> (idx & 7)); |
548 | } | 559 | } |
549 | 560 | ||
550 | |||
551 | /* | 561 | /* |
552 | * add an alsa control element | 562 | * add an alsa control element |
553 | * search and increment the index until an empty slot is found. | 563 | * search and increment the index until an empty slot is found. |
@@ -564,7 +574,8 @@ int snd_usb_mixer_add_control(struct usb_mixer_interface *mixer, | |||
564 | while (snd_ctl_find_id(mixer->chip->card, &kctl->id)) | 574 | while (snd_ctl_find_id(mixer->chip->card, &kctl->id)) |
565 | kctl->id.index++; | 575 | kctl->id.index++; |
566 | if ((err = snd_ctl_add(mixer->chip->card, kctl)) < 0) { | 576 | if ((err = snd_ctl_add(mixer->chip->card, kctl)) < 0) { |
567 | usb_audio_dbg(mixer->chip, "cannot add control (err = %d)\n", err); | 577 | usb_audio_dbg(mixer->chip, "cannot add control (err = %d)\n", |
578 | err); | ||
568 | return err; | 579 | return err; |
569 | } | 580 | } |
570 | cval->elem_id = &kctl->id; | 581 | cval->elem_id = &kctl->id; |
@@ -573,7 +584,6 @@ int snd_usb_mixer_add_control(struct usb_mixer_interface *mixer, | |||
573 | return 0; | 584 | return 0; |
574 | } | 585 | } |
575 | 586 | ||
576 | |||
577 | /* | 587 | /* |
578 | * get a terminal name string | 588 | * get a terminal name string |
579 | */ | 589 | */ |
@@ -627,7 +637,8 @@ static int get_term_name(struct mixer_build *state, struct usb_audio_term *iterm | |||
627 | struct iterm_name_combo *names; | 637 | struct iterm_name_combo *names; |
628 | 638 | ||
629 | if (iterm->name) | 639 | if (iterm->name) |
630 | return snd_usb_copy_string_desc(state, iterm->name, name, maxlen); | 640 | return snd_usb_copy_string_desc(state, iterm->name, |
641 | name, maxlen); | ||
631 | 642 | ||
632 | /* virtual type - not a real terminal */ | 643 | /* virtual type - not a real terminal */ |
633 | if (iterm->type >> 16) { | 644 | if (iterm->type >> 16) { |
@@ -635,13 +646,17 @@ static int get_term_name(struct mixer_build *state, struct usb_audio_term *iterm | |||
635 | return 0; | 646 | return 0; |
636 | switch (iterm->type >> 16) { | 647 | switch (iterm->type >> 16) { |
637 | case UAC_SELECTOR_UNIT: | 648 | case UAC_SELECTOR_UNIT: |
638 | strcpy(name, "Selector"); return 8; | 649 | strcpy(name, "Selector"); |
650 | return 8; | ||
639 | case UAC1_PROCESSING_UNIT: | 651 | case UAC1_PROCESSING_UNIT: |
640 | strcpy(name, "Process Unit"); return 12; | 652 | strcpy(name, "Process Unit"); |
653 | return 12; | ||
641 | case UAC1_EXTENSION_UNIT: | 654 | case UAC1_EXTENSION_UNIT: |
642 | strcpy(name, "Ext Unit"); return 8; | 655 | strcpy(name, "Ext Unit"); |
656 | return 8; | ||
643 | case UAC_MIXER_UNIT: | 657 | case UAC_MIXER_UNIT: |
644 | strcpy(name, "Mixer"); return 5; | 658 | strcpy(name, "Mixer"); |
659 | return 5; | ||
645 | default: | 660 | default: |
646 | return sprintf(name, "Unit %d", iterm->id); | 661 | return sprintf(name, "Unit %d", iterm->id); |
647 | } | 662 | } |
@@ -649,29 +664,35 @@ static int get_term_name(struct mixer_build *state, struct usb_audio_term *iterm | |||
649 | 664 | ||
650 | switch (iterm->type & 0xff00) { | 665 | switch (iterm->type & 0xff00) { |
651 | case 0x0100: | 666 | case 0x0100: |
652 | strcpy(name, "PCM"); return 3; | 667 | strcpy(name, "PCM"); |
668 | return 3; | ||
653 | case 0x0200: | 669 | case 0x0200: |
654 | strcpy(name, "Mic"); return 3; | 670 | strcpy(name, "Mic"); |
671 | return 3; | ||
655 | case 0x0400: | 672 | case 0x0400: |
656 | strcpy(name, "Headset"); return 7; | 673 | strcpy(name, "Headset"); |
674 | return 7; | ||
657 | case 0x0500: | 675 | case 0x0500: |
658 | strcpy(name, "Phone"); return 5; | 676 | strcpy(name, "Phone"); |
677 | return 5; | ||
659 | } | 678 | } |
660 | 679 | ||
661 | for (names = iterm_names; names->type; names++) | 680 | for (names = iterm_names; names->type; names++) { |
662 | if (names->type == iterm->type) { | 681 | if (names->type == iterm->type) { |
663 | strcpy(name, names->name); | 682 | strcpy(name, names->name); |
664 | return strlen(names->name); | 683 | return strlen(names->name); |
665 | } | 684 | } |
685 | } | ||
686 | |||
666 | return 0; | 687 | return 0; |
667 | } | 688 | } |
668 | 689 | ||
669 | |||
670 | /* | 690 | /* |
671 | * parse the source unit recursively until it reaches to a terminal | 691 | * parse the source unit recursively until it reaches to a terminal |
672 | * or a branched unit. | 692 | * or a branched unit. |
673 | */ | 693 | */ |
674 | static int check_input_term(struct mixer_build *state, int id, struct usb_audio_term *term) | 694 | static int check_input_term(struct mixer_build *state, int id, |
695 | struct usb_audio_term *term) | ||
675 | { | 696 | { |
676 | int err; | 697 | int err; |
677 | void *p1; | 698 | void *p1; |
@@ -766,7 +787,6 @@ static int check_input_term(struct mixer_build *state, int id, struct usb_audio_ | |||
766 | return -ENODEV; | 787 | return -ENODEV; |
767 | } | 788 | } |
768 | 789 | ||
769 | |||
770 | /* | 790 | /* |
771 | * Feature Unit | 791 | * Feature Unit |
772 | */ | 792 | */ |
@@ -794,7 +814,6 @@ static struct usb_feature_control_info audio_feature_info[] = { | |||
794 | { "Phase Inverter Control", USB_MIXER_BOOLEAN }, | 814 | { "Phase Inverter Control", USB_MIXER_BOOLEAN }, |
795 | }; | 815 | }; |
796 | 816 | ||
797 | |||
798 | /* private_free callback */ | 817 | /* private_free callback */ |
799 | static void usb_mixer_elem_free(struct snd_kcontrol *kctl) | 818 | static void usb_mixer_elem_free(struct snd_kcontrol *kctl) |
800 | { | 819 | { |
@@ -802,7 +821,6 @@ static void usb_mixer_elem_free(struct snd_kcontrol *kctl) | |||
802 | kctl->private_data = NULL; | 821 | kctl->private_data = NULL; |
803 | } | 822 | } |
804 | 823 | ||
805 | |||
806 | /* | 824 | /* |
807 | * interface to ALSA control for feature/mixer units | 825 | * interface to ALSA control for feature/mixer units |
808 | */ | 826 | */ |
@@ -906,7 +924,6 @@ static void volume_control_quirks(struct usb_mixer_elem_info *cval, | |||
906 | cval->res = 384; | 924 | cval->res = 384; |
907 | } | 925 | } |
908 | break; | 926 | break; |
909 | |||
910 | } | 927 | } |
911 | } | 928 | } |
912 | 929 | ||
@@ -939,21 +956,26 @@ static int get_min_max_with_quirks(struct usb_mixer_elem_info *cval, | |||
939 | get_ctl_value(cval, UAC_GET_MIN, (cval->control << 8) | minchn, &cval->min) < 0) { | 956 | get_ctl_value(cval, UAC_GET_MIN, (cval->control << 8) | minchn, &cval->min) < 0) { |
940 | usb_audio_err(cval->mixer->chip, | 957 | usb_audio_err(cval->mixer->chip, |
941 | "%d:%d: cannot get min/max values for control %d (id %d)\n", | 958 | "%d:%d: cannot get min/max values for control %d (id %d)\n", |
942 | cval->id, snd_usb_ctrl_intf(cval->mixer->chip), cval->control, cval->id); | 959 | cval->id, snd_usb_ctrl_intf(cval->mixer->chip), |
960 | cval->control, cval->id); | ||
943 | return -EINVAL; | 961 | return -EINVAL; |
944 | } | 962 | } |
945 | if (get_ctl_value(cval, UAC_GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) { | 963 | if (get_ctl_value(cval, UAC_GET_RES, |
964 | (cval->control << 8) | minchn, | ||
965 | &cval->res) < 0) { | ||
946 | cval->res = 1; | 966 | cval->res = 1; |
947 | } else { | 967 | } else { |
948 | int last_valid_res = cval->res; | 968 | int last_valid_res = cval->res; |
949 | 969 | ||
950 | while (cval->res > 1) { | 970 | while (cval->res > 1) { |
951 | if (snd_usb_mixer_set_ctl_value(cval, UAC_SET_RES, | 971 | if (snd_usb_mixer_set_ctl_value(cval, UAC_SET_RES, |
952 | (cval->control << 8) | minchn, cval->res / 2) < 0) | 972 | (cval->control << 8) | minchn, |
973 | cval->res / 2) < 0) | ||
953 | break; | 974 | break; |
954 | cval->res /= 2; | 975 | cval->res /= 2; |
955 | } | 976 | } |
956 | if (get_ctl_value(cval, UAC_GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) | 977 | if (get_ctl_value(cval, UAC_GET_RES, |
978 | (cval->control << 8) | minchn, &cval->res) < 0) | ||
957 | cval->res = last_valid_res; | 979 | cval->res = last_valid_res; |
958 | } | 980 | } |
959 | if (cval->res == 0) | 981 | if (cval->res == 0) |
@@ -1017,7 +1039,8 @@ static int get_min_max_with_quirks(struct usb_mixer_elem_info *cval, | |||
1017 | #define get_min_max(cval, def) get_min_max_with_quirks(cval, def, NULL) | 1039 | #define get_min_max(cval, def) get_min_max_with_quirks(cval, def, NULL) |
1018 | 1040 | ||
1019 | /* get a feature/mixer unit info */ | 1041 | /* get a feature/mixer unit info */ |
1020 | static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 1042 | static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol, |
1043 | struct snd_ctl_elem_info *uinfo) | ||
1021 | { | 1044 | { |
1022 | struct usb_mixer_elem_info *cval = kcontrol->private_data; | 1045 | struct usb_mixer_elem_info *cval = kcontrol->private_data; |
1023 | 1046 | ||
@@ -1051,7 +1074,8 @@ static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol, struct snd_ctl_ | |||
1051 | } | 1074 | } |
1052 | 1075 | ||
1053 | /* get the current value from feature/mixer unit */ | 1076 | /* get the current value from feature/mixer unit */ |
1054 | static int mixer_ctl_feature_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 1077 | static int mixer_ctl_feature_get(struct snd_kcontrol *kcontrol, |
1078 | struct snd_ctl_elem_value *ucontrol) | ||
1055 | { | 1079 | { |
1056 | struct usb_mixer_elem_info *cval = kcontrol->private_data; | 1080 | struct usb_mixer_elem_info *cval = kcontrol->private_data; |
1057 | int c, cnt, val, err; | 1081 | int c, cnt, val, err; |
@@ -1082,7 +1106,8 @@ static int mixer_ctl_feature_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e | |||
1082 | } | 1106 | } |
1083 | 1107 | ||
1084 | /* put the current value to feature/mixer unit */ | 1108 | /* put the current value to feature/mixer unit */ |
1085 | static int mixer_ctl_feature_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 1109 | static int mixer_ctl_feature_put(struct snd_kcontrol *kcontrol, |
1110 | struct snd_ctl_elem_value *ucontrol) | ||
1086 | { | 1111 | { |
1087 | struct usb_mixer_elem_info *cval = kcontrol->private_data; | 1112 | struct usb_mixer_elem_info *cval = kcontrol->private_data; |
1088 | int c, cnt, val, oval, err; | 1113 | int c, cnt, val, oval, err; |
@@ -1136,22 +1161,25 @@ static struct snd_kcontrol_new usb_feature_unit_ctl_ro = { | |||
1136 | .put = NULL, | 1161 | .put = NULL, |
1137 | }; | 1162 | }; |
1138 | 1163 | ||
1139 | /* This symbol is exported in order to allow the mixer quirks to | 1164 | /* |
1140 | * hook up to the standard feature unit control mechanism */ | 1165 | * This symbol is exported in order to allow the mixer quirks to |
1166 | * hook up to the standard feature unit control mechanism | ||
1167 | */ | ||
1141 | struct snd_kcontrol_new *snd_usb_feature_unit_ctl = &usb_feature_unit_ctl; | 1168 | struct snd_kcontrol_new *snd_usb_feature_unit_ctl = &usb_feature_unit_ctl; |
1142 | 1169 | ||
1143 | /* | 1170 | /* |
1144 | * build a feature control | 1171 | * build a feature control |
1145 | */ | 1172 | */ |
1146 | |||
1147 | static size_t append_ctl_name(struct snd_kcontrol *kctl, const char *str) | 1173 | static size_t append_ctl_name(struct snd_kcontrol *kctl, const char *str) |
1148 | { | 1174 | { |
1149 | return strlcat(kctl->id.name, str, sizeof(kctl->id.name)); | 1175 | return strlcat(kctl->id.name, str, sizeof(kctl->id.name)); |
1150 | } | 1176 | } |
1151 | 1177 | ||
1152 | /* A lot of headsets/headphones have a "Speaker" mixer. Make sure we | 1178 | /* |
1153 | rename it to "Headphone". We determine if something is a headphone | 1179 | * A lot of headsets/headphones have a "Speaker" mixer. Make sure we |
1154 | similar to how udev determines form factor. */ | 1180 | * rename it to "Headphone". We determine if something is a headphone |
1181 | * similar to how udev determines form factor. | ||
1182 | */ | ||
1155 | static void check_no_speaker_on_headset(struct snd_kcontrol *kctl, | 1183 | static void check_no_speaker_on_headset(struct snd_kcontrol *kctl, |
1156 | struct snd_card *card) | 1184 | struct snd_card *card) |
1157 | { | 1185 | { |
@@ -1201,10 +1229,8 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc, | |||
1201 | return; | 1229 | return; |
1202 | 1230 | ||
1203 | cval = kzalloc(sizeof(*cval), GFP_KERNEL); | 1231 | cval = kzalloc(sizeof(*cval), GFP_KERNEL); |
1204 | if (! cval) { | 1232 | if (!cval) |
1205 | usb_audio_err(state->chip, "cannot malloc kcontrol\n"); | ||
1206 | return; | 1233 | return; |
1207 | } | ||
1208 | cval->mixer = state->mixer; | 1234 | cval->mixer = state->mixer; |
1209 | cval->id = unitid; | 1235 | cval->id = unitid; |
1210 | cval->control = control; | 1236 | cval->control = control; |
@@ -1222,15 +1248,17 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc, | |||
1222 | cval->ch_readonly = readonly_mask; | 1248 | cval->ch_readonly = readonly_mask; |
1223 | } | 1249 | } |
1224 | 1250 | ||
1225 | /* if all channels in the mask are marked read-only, make the control | 1251 | /* |
1252 | * If all channels in the mask are marked read-only, make the control | ||
1226 | * read-only. set_cur_mix_value() will check the mask again and won't | 1253 | * read-only. set_cur_mix_value() will check the mask again and won't |
1227 | * issue write commands to read-only channels. */ | 1254 | * issue write commands to read-only channels. |
1255 | */ | ||
1228 | if (cval->channels == readonly_mask) | 1256 | if (cval->channels == readonly_mask) |
1229 | kctl = snd_ctl_new1(&usb_feature_unit_ctl_ro, cval); | 1257 | kctl = snd_ctl_new1(&usb_feature_unit_ctl_ro, cval); |
1230 | else | 1258 | else |
1231 | kctl = snd_ctl_new1(&usb_feature_unit_ctl, cval); | 1259 | kctl = snd_ctl_new1(&usb_feature_unit_ctl, cval); |
1232 | 1260 | ||
1233 | if (! kctl) { | 1261 | if (!kctl) { |
1234 | usb_audio_err(state->chip, "cannot malloc kcontrol\n"); | 1262 | usb_audio_err(state->chip, "cannot malloc kcontrol\n"); |
1235 | kfree(cval); | 1263 | kfree(cval); |
1236 | return; | 1264 | return; |
@@ -1239,48 +1267,53 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc, | |||
1239 | 1267 | ||
1240 | len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)); | 1268 | len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)); |
1241 | mapped_name = len != 0; | 1269 | mapped_name = len != 0; |
1242 | if (! len && nameid) | 1270 | if (!len && nameid) |
1243 | len = snd_usb_copy_string_desc(state, nameid, | 1271 | len = snd_usb_copy_string_desc(state, nameid, |
1244 | kctl->id.name, sizeof(kctl->id.name)); | 1272 | kctl->id.name, sizeof(kctl->id.name)); |
1245 | 1273 | ||
1246 | switch (control) { | 1274 | switch (control) { |
1247 | case UAC_FU_MUTE: | 1275 | case UAC_FU_MUTE: |
1248 | case UAC_FU_VOLUME: | 1276 | case UAC_FU_VOLUME: |
1249 | /* determine the control name. the rule is: | 1277 | /* |
1278 | * determine the control name. the rule is: | ||
1250 | * - if a name id is given in descriptor, use it. | 1279 | * - if a name id is given in descriptor, use it. |
1251 | * - if the connected input can be determined, then use the name | 1280 | * - if the connected input can be determined, then use the name |
1252 | * of terminal type. | 1281 | * of terminal type. |
1253 | * - if the connected output can be determined, use it. | 1282 | * - if the connected output can be determined, use it. |
1254 | * - otherwise, anonymous name. | 1283 | * - otherwise, anonymous name. |
1255 | */ | 1284 | */ |
1256 | if (! len) { | 1285 | if (!len) { |
1257 | len = get_term_name(state, iterm, kctl->id.name, sizeof(kctl->id.name), 1); | 1286 | len = get_term_name(state, iterm, kctl->id.name, |
1258 | if (! len) | 1287 | sizeof(kctl->id.name), 1); |
1259 | len = get_term_name(state, &state->oterm, kctl->id.name, sizeof(kctl->id.name), 1); | 1288 | if (!len) |
1260 | if (! len) | 1289 | len = get_term_name(state, &state->oterm, |
1261 | len = snprintf(kctl->id.name, sizeof(kctl->id.name), | 1290 | kctl->id.name, |
1291 | sizeof(kctl->id.name), 1); | ||
1292 | if (!len) | ||
1293 | len = snprintf(kctl->id.name, | ||
1294 | sizeof(kctl->id.name), | ||
1262 | "Feature %d", unitid); | 1295 | "Feature %d", unitid); |
1263 | } | 1296 | } |
1264 | 1297 | ||
1265 | if (!mapped_name) | 1298 | if (!mapped_name) |
1266 | check_no_speaker_on_headset(kctl, state->mixer->chip->card); | 1299 | check_no_speaker_on_headset(kctl, state->mixer->chip->card); |
1267 | 1300 | ||
1268 | /* determine the stream direction: | 1301 | /* |
1302 | * determine the stream direction: | ||
1269 | * if the connected output is USB stream, then it's likely a | 1303 | * if the connected output is USB stream, then it's likely a |
1270 | * capture stream. otherwise it should be playback (hopefully :) | 1304 | * capture stream. otherwise it should be playback (hopefully :) |
1271 | */ | 1305 | */ |
1272 | if (! mapped_name && ! (state->oterm.type >> 16)) { | 1306 | if (!mapped_name && !(state->oterm.type >> 16)) { |
1273 | if ((state->oterm.type & 0xff00) == 0x0100) { | 1307 | if ((state->oterm.type & 0xff00) == 0x0100) |
1274 | len = append_ctl_name(kctl, " Capture"); | 1308 | len = append_ctl_name(kctl, " Capture"); |
1275 | } else { | 1309 | else |
1276 | len = append_ctl_name(kctl, " Playback"); | 1310 | len = append_ctl_name(kctl, " Playback"); |
1277 | } | ||
1278 | } | 1311 | } |
1279 | append_ctl_name(kctl, control == UAC_FU_MUTE ? | 1312 | append_ctl_name(kctl, control == UAC_FU_MUTE ? |
1280 | " Switch" : " Volume"); | 1313 | " Switch" : " Volume"); |
1281 | break; | 1314 | break; |
1282 | default: | 1315 | default: |
1283 | if (! len) | 1316 | if (!len) |
1284 | strlcpy(kctl->id.name, audio_feature_info[control-1].name, | 1317 | strlcpy(kctl->id.name, audio_feature_info[control-1].name, |
1285 | sizeof(kctl->id.name)); | 1318 | sizeof(kctl->id.name)); |
1286 | break; | 1319 | break; |
@@ -1300,33 +1333,35 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc, | |||
1300 | } | 1333 | } |
1301 | 1334 | ||
1302 | range = (cval->max - cval->min) / cval->res; | 1335 | range = (cval->max - cval->min) / cval->res; |
1303 | /* Are there devices with volume range more than 255? I use a bit more | 1336 | /* |
1337 | * Are there devices with volume range more than 255? I use a bit more | ||
1304 | * to be sure. 384 is a resolution magic number found on Logitech | 1338 | * to be sure. 384 is a resolution magic number found on Logitech |
1305 | * devices. It will definitively catch all buggy Logitech devices. | 1339 | * devices. It will definitively catch all buggy Logitech devices. |
1306 | */ | 1340 | */ |
1307 | if (range > 384) { | 1341 | if (range > 384) { |
1308 | usb_audio_warn(state->chip, "Warning! Unlikely big " | 1342 | usb_audio_warn(state->chip, |
1309 | "volume range (=%u), cval->res is probably wrong.", | 1343 | "Warning! Unlikely big volume range (=%u), " |
1310 | range); | 1344 | "cval->res is probably wrong.", |
1345 | range); | ||
1311 | usb_audio_warn(state->chip, "[%d] FU [%s] ch = %d, " | 1346 | usb_audio_warn(state->chip, "[%d] FU [%s] ch = %d, " |
1312 | "val = %d/%d/%d", cval->id, | 1347 | "val = %d/%d/%d", cval->id, |
1313 | kctl->id.name, cval->channels, | 1348 | kctl->id.name, cval->channels, |
1314 | cval->min, cval->max, cval->res); | 1349 | cval->min, cval->max, cval->res); |
1315 | } | 1350 | } |
1316 | 1351 | ||
1317 | usb_audio_dbg(state->chip, "[%d] FU [%s] ch = %d, val = %d/%d/%d\n", | 1352 | usb_audio_dbg(state->chip, "[%d] FU [%s] ch = %d, val = %d/%d/%d\n", |
1318 | cval->id, kctl->id.name, cval->channels, cval->min, cval->max, cval->res); | 1353 | cval->id, kctl->id.name, cval->channels, |
1354 | cval->min, cval->max, cval->res); | ||
1319 | snd_usb_mixer_add_control(state->mixer, kctl); | 1355 | snd_usb_mixer_add_control(state->mixer, kctl); |
1320 | } | 1356 | } |
1321 | 1357 | ||
1322 | |||
1323 | |||
1324 | /* | 1358 | /* |
1325 | * parse a feature unit | 1359 | * parse a feature unit |
1326 | * | 1360 | * |
1327 | * most of controls are defined here. | 1361 | * most of controls are defined here. |
1328 | */ | 1362 | */ |
1329 | static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void *_ftr) | 1363 | static int parse_audio_feature_unit(struct mixer_build *state, int unitid, |
1364 | void *_ftr) | ||
1330 | { | 1365 | { |
1331 | int channels, i, j; | 1366 | int channels, i, j; |
1332 | struct usb_audio_term iterm; | 1367 | struct usb_audio_term iterm; |
@@ -1400,15 +1435,25 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void | |||
1400 | for (i = 0; i < 10; i++) { | 1435 | for (i = 0; i < 10; i++) { |
1401 | unsigned int ch_bits = 0; | 1436 | unsigned int ch_bits = 0; |
1402 | for (j = 0; j < channels; j++) { | 1437 | for (j = 0; j < channels; j++) { |
1403 | unsigned int mask = snd_usb_combine_bytes(bmaControls + csize * (j+1), csize); | 1438 | unsigned int mask; |
1439 | |||
1440 | mask = snd_usb_combine_bytes(bmaControls + | ||
1441 | csize * (j+1), csize); | ||
1404 | if (mask & (1 << i)) | 1442 | if (mask & (1 << i)) |
1405 | ch_bits |= (1 << j); | 1443 | ch_bits |= (1 << j); |
1406 | } | 1444 | } |
1407 | /* audio class v1 controls are never read-only */ | 1445 | /* audio class v1 controls are never read-only */ |
1408 | if (ch_bits & 1) /* the first channel must be set (for ease of programming) */ | 1446 | |
1409 | build_feature_ctl(state, _ftr, ch_bits, i, &iterm, unitid, 0); | 1447 | /* |
1448 | * The first channel must be set | ||
1449 | * (for ease of programming). | ||
1450 | */ | ||
1451 | if (ch_bits & 1) | ||
1452 | build_feature_ctl(state, _ftr, ch_bits, i, | ||
1453 | &iterm, unitid, 0); | ||
1410 | if (master_bits & (1 << i)) | 1454 | if (master_bits & (1 << i)) |
1411 | build_feature_ctl(state, _ftr, 0, i, &iterm, unitid, 0); | 1455 | build_feature_ctl(state, _ftr, 0, i, &iterm, |
1456 | unitid, 0); | ||
1412 | } | 1457 | } |
1413 | } else { /* UAC_VERSION_2 */ | 1458 | } else { /* UAC_VERSION_2 */ |
1414 | for (i = 0; i < ARRAY_SIZE(audio_feature_info); i++) { | 1459 | for (i = 0; i < ARRAY_SIZE(audio_feature_info); i++) { |
@@ -1416,7 +1461,10 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void | |||
1416 | unsigned int ch_read_only = 0; | 1461 | unsigned int ch_read_only = 0; |
1417 | 1462 | ||
1418 | for (j = 0; j < channels; j++) { | 1463 | for (j = 0; j < channels; j++) { |
1419 | unsigned int mask = snd_usb_combine_bytes(bmaControls + csize * (j+1), csize); | 1464 | unsigned int mask; |
1465 | |||
1466 | mask = snd_usb_combine_bytes(bmaControls + | ||
1467 | csize * (j+1), csize); | ||
1420 | if (uac2_control_is_readable(mask, i)) { | 1468 | if (uac2_control_is_readable(mask, i)) { |
1421 | ch_bits |= (1 << j); | 1469 | ch_bits |= (1 << j); |
1422 | if (!uac2_control_is_writeable(mask, i)) | 1470 | if (!uac2_control_is_writeable(mask, i)) |
@@ -1424,12 +1472,22 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void | |||
1424 | } | 1472 | } |
1425 | } | 1473 | } |
1426 | 1474 | ||
1427 | /* NOTE: build_feature_ctl() will mark the control read-only if all channels | 1475 | /* |
1428 | * are marked read-only in the descriptors. Otherwise, the control will be | 1476 | * NOTE: build_feature_ctl() will mark the control |
1429 | * reported as writeable, but the driver will not actually issue a write | 1477 | * read-only if all channels are marked read-only in |
1430 | * command for read-only channels */ | 1478 | * the descriptors. Otherwise, the control will be |
1431 | if (ch_bits & 1) /* the first channel must be set (for ease of programming) */ | 1479 | * reported as writeable, but the driver will not |
1432 | build_feature_ctl(state, _ftr, ch_bits, i, &iterm, unitid, ch_read_only); | 1480 | * actually issue a write command for read-only |
1481 | * channels. | ||
1482 | */ | ||
1483 | |||
1484 | /* | ||
1485 | * The first channel must be set | ||
1486 | * (for ease of programming). | ||
1487 | */ | ||
1488 | if (ch_bits & 1) | ||
1489 | build_feature_ctl(state, _ftr, ch_bits, i, | ||
1490 | &iterm, unitid, ch_read_only); | ||
1433 | if (uac2_control_is_readable(master_bits, i)) | 1491 | if (uac2_control_is_readable(master_bits, i)) |
1434 | build_feature_ctl(state, _ftr, 0, i, &iterm, unitid, | 1492 | build_feature_ctl(state, _ftr, 0, i, &iterm, unitid, |
1435 | !uac2_control_is_writeable(master_bits, i)); | 1493 | !uac2_control_is_writeable(master_bits, i)); |
@@ -1439,7 +1497,6 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void | |||
1439 | return 0; | 1497 | return 0; |
1440 | } | 1498 | } |
1441 | 1499 | ||
1442 | |||
1443 | /* | 1500 | /* |
1444 | * Mixer Unit | 1501 | * Mixer Unit |
1445 | */ | 1502 | */ |
@@ -1450,7 +1507,6 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void | |||
1450 | * the callbacks are identical with feature unit. | 1507 | * the callbacks are identical with feature unit. |
1451 | * input channel number (zero based) is given in control field instead. | 1508 | * input channel number (zero based) is given in control field instead. |
1452 | */ | 1509 | */ |
1453 | |||
1454 | static void build_mixer_unit_ctl(struct mixer_build *state, | 1510 | static void build_mixer_unit_ctl(struct mixer_build *state, |
1455 | struct uac_mixer_unit_descriptor *desc, | 1511 | struct uac_mixer_unit_descriptor *desc, |
1456 | int in_pin, int in_ch, int unitid, | 1512 | int in_pin, int in_ch, int unitid, |
@@ -1467,7 +1523,7 @@ static void build_mixer_unit_ctl(struct mixer_build *state, | |||
1467 | return; | 1523 | return; |
1468 | 1524 | ||
1469 | cval = kzalloc(sizeof(*cval), GFP_KERNEL); | 1525 | cval = kzalloc(sizeof(*cval), GFP_KERNEL); |
1470 | if (! cval) | 1526 | if (!cval) |
1471 | return; | 1527 | return; |
1472 | 1528 | ||
1473 | cval->mixer = state->mixer; | 1529 | cval->mixer = state->mixer; |
@@ -1475,7 +1531,9 @@ static void build_mixer_unit_ctl(struct mixer_build *state, | |||
1475 | cval->control = in_ch + 1; /* based on 1 */ | 1531 | cval->control = in_ch + 1; /* based on 1 */ |
1476 | cval->val_type = USB_MIXER_S16; | 1532 | cval->val_type = USB_MIXER_S16; |
1477 | for (i = 0; i < num_outs; i++) { | 1533 | for (i = 0; i < num_outs; i++) { |
1478 | if (check_matrix_bitmap(uac_mixer_unit_bmControls(desc, state->mixer->protocol), in_ch, i, num_outs)) { | 1534 | __u8 *c = uac_mixer_unit_bmControls(desc, state->mixer->protocol); |
1535 | |||
1536 | if (check_matrix_bitmap(c, in_ch, i, num_outs)) { | ||
1479 | cval->cmask |= (1 << i); | 1537 | cval->cmask |= (1 << i); |
1480 | cval->channels++; | 1538 | cval->channels++; |
1481 | } | 1539 | } |
@@ -1485,7 +1543,7 @@ static void build_mixer_unit_ctl(struct mixer_build *state, | |||
1485 | get_min_max(cval, 0); | 1543 | get_min_max(cval, 0); |
1486 | 1544 | ||
1487 | kctl = snd_ctl_new1(&usb_feature_unit_ctl, cval); | 1545 | kctl = snd_ctl_new1(&usb_feature_unit_ctl, cval); |
1488 | if (! kctl) { | 1546 | if (!kctl) { |
1489 | usb_audio_err(state->chip, "cannot malloc kcontrol\n"); | 1547 | usb_audio_err(state->chip, "cannot malloc kcontrol\n"); |
1490 | kfree(cval); | 1548 | kfree(cval); |
1491 | return; | 1549 | return; |
@@ -1493,9 +1551,10 @@ static void build_mixer_unit_ctl(struct mixer_build *state, | |||
1493 | kctl->private_free = usb_mixer_elem_free; | 1551 | kctl->private_free = usb_mixer_elem_free; |
1494 | 1552 | ||
1495 | len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)); | 1553 | len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)); |
1496 | if (! len) | 1554 | if (!len) |
1497 | len = get_term_name(state, iterm, kctl->id.name, sizeof(kctl->id.name), 0); | 1555 | len = get_term_name(state, iterm, kctl->id.name, |
1498 | if (! len) | 1556 | sizeof(kctl->id.name), 0); |
1557 | if (!len) | ||
1499 | len = sprintf(kctl->id.name, "Mixer Source %d", in_ch + 1); | 1558 | len = sprintf(kctl->id.name, "Mixer Source %d", in_ch + 1); |
1500 | append_ctl_name(kctl, " Volume"); | 1559 | append_ctl_name(kctl, " Volume"); |
1501 | 1560 | ||
@@ -1504,24 +1563,28 @@ static void build_mixer_unit_ctl(struct mixer_build *state, | |||
1504 | snd_usb_mixer_add_control(state->mixer, kctl); | 1563 | snd_usb_mixer_add_control(state->mixer, kctl); |
1505 | } | 1564 | } |
1506 | 1565 | ||
1507 | |||
1508 | /* | 1566 | /* |
1509 | * parse a mixer unit | 1567 | * parse a mixer unit |
1510 | */ | 1568 | */ |
1511 | static int parse_audio_mixer_unit(struct mixer_build *state, int unitid, void *raw_desc) | 1569 | static int parse_audio_mixer_unit(struct mixer_build *state, int unitid, |
1570 | void *raw_desc) | ||
1512 | { | 1571 | { |
1513 | struct uac_mixer_unit_descriptor *desc = raw_desc; | 1572 | struct uac_mixer_unit_descriptor *desc = raw_desc; |
1514 | struct usb_audio_term iterm; | 1573 | struct usb_audio_term iterm; |
1515 | int input_pins, num_ins, num_outs; | 1574 | int input_pins, num_ins, num_outs; |
1516 | int pin, ich, err; | 1575 | int pin, ich, err; |
1517 | 1576 | ||
1518 | if (desc->bLength < 11 || ! (input_pins = desc->bNrInPins) || ! (num_outs = uac_mixer_unit_bNrChannels(desc))) { | 1577 | if (desc->bLength < 11 || !(input_pins = desc->bNrInPins) || |
1519 | usb_audio_err(state->chip, "invalid MIXER UNIT descriptor %d\n", unitid); | 1578 | !(num_outs = uac_mixer_unit_bNrChannels(desc))) { |
1579 | usb_audio_err(state->chip, | ||
1580 | "invalid MIXER UNIT descriptor %d\n", | ||
1581 | unitid); | ||
1520 | return -EINVAL; | 1582 | return -EINVAL; |
1521 | } | 1583 | } |
1522 | /* no bmControls field (e.g. Maya44) -> ignore */ | 1584 | /* no bmControls field (e.g. Maya44) -> ignore */ |
1523 | if (desc->bLength <= 10 + input_pins) { | 1585 | if (desc->bLength <= 10 + input_pins) { |
1524 | usb_audio_dbg(state->chip, "MU %d has no bmControls field\n", unitid); | 1586 | usb_audio_dbg(state->chip, "MU %d has no bmControls field\n", |
1587 | unitid); | ||
1525 | return 0; | 1588 | return 0; |
1526 | } | 1589 | } |
1527 | 1590 | ||
@@ -1535,12 +1598,14 @@ static int parse_audio_mixer_unit(struct mixer_build *state, int unitid, void *r | |||
1535 | if (err < 0) | 1598 | if (err < 0) |
1536 | return err; | 1599 | return err; |
1537 | num_ins += iterm.channels; | 1600 | num_ins += iterm.channels; |
1538 | for (; ich < num_ins; ++ich) { | 1601 | for (; ich < num_ins; ich++) { |
1539 | int och, ich_has_controls = 0; | 1602 | int och, ich_has_controls = 0; |
1540 | 1603 | ||
1541 | for (och = 0; och < num_outs; ++och) { | 1604 | for (och = 0; och < num_outs; och++) { |
1542 | if (check_matrix_bitmap(uac_mixer_unit_bmControls(desc, state->mixer->protocol), | 1605 | __u8 *c = uac_mixer_unit_bmControls(desc, |
1543 | ich, och, num_outs)) { | 1606 | state->mixer->protocol); |
1607 | |||
1608 | if (check_matrix_bitmap(c, ich, och, num_outs)) { | ||
1544 | ich_has_controls = 1; | 1609 | ich_has_controls = 1; |
1545 | break; | 1610 | break; |
1546 | } | 1611 | } |
@@ -1553,13 +1618,13 @@ static int parse_audio_mixer_unit(struct mixer_build *state, int unitid, void *r | |||
1553 | return 0; | 1618 | return 0; |
1554 | } | 1619 | } |
1555 | 1620 | ||
1556 | |||
1557 | /* | 1621 | /* |
1558 | * Processing Unit / Extension Unit | 1622 | * Processing Unit / Extension Unit |
1559 | */ | 1623 | */ |
1560 | 1624 | ||
1561 | /* get callback for processing/extension unit */ | 1625 | /* get callback for processing/extension unit */ |
1562 | static int mixer_ctl_procunit_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 1626 | static int mixer_ctl_procunit_get(struct snd_kcontrol *kcontrol, |
1627 | struct snd_ctl_elem_value *ucontrol) | ||
1563 | { | 1628 | { |
1564 | struct usb_mixer_elem_info *cval = kcontrol->private_data; | 1629 | struct usb_mixer_elem_info *cval = kcontrol->private_data; |
1565 | int err, val; | 1630 | int err, val; |
@@ -1577,7 +1642,8 @@ static int mixer_ctl_procunit_get(struct snd_kcontrol *kcontrol, struct snd_ctl_ | |||
1577 | } | 1642 | } |
1578 | 1643 | ||
1579 | /* put callback for processing/extension unit */ | 1644 | /* put callback for processing/extension unit */ |
1580 | static int mixer_ctl_procunit_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 1645 | static int mixer_ctl_procunit_put(struct snd_kcontrol *kcontrol, |
1646 | struct snd_ctl_elem_value *ucontrol) | ||
1581 | { | 1647 | { |
1582 | struct usb_mixer_elem_info *cval = kcontrol->private_data; | 1648 | struct usb_mixer_elem_info *cval = kcontrol->private_data; |
1583 | int val, oval, err; | 1649 | int val, oval, err; |
@@ -1606,7 +1672,6 @@ static struct snd_kcontrol_new mixer_procunit_ctl = { | |||
1606 | .put = mixer_ctl_procunit_put, | 1672 | .put = mixer_ctl_procunit_put, |
1607 | }; | 1673 | }; |
1608 | 1674 | ||
1609 | |||
1610 | /* | 1675 | /* |
1611 | * predefined data for processing units | 1676 | * predefined data for processing units |
1612 | */ | 1677 | */ |
@@ -1697,10 +1762,13 @@ static struct procunit_info extunits[] = { | |||
1697 | { USB_XU_DEVICE_OPTIONS, "AnalogueIn Soft Limit", soft_limit_xu_info }, | 1762 | { USB_XU_DEVICE_OPTIONS, "AnalogueIn Soft Limit", soft_limit_xu_info }, |
1698 | { 0 } | 1763 | { 0 } |
1699 | }; | 1764 | }; |
1765 | |||
1700 | /* | 1766 | /* |
1701 | * build a processing/extension unit | 1767 | * build a processing/extension unit |
1702 | */ | 1768 | */ |
1703 | static int build_audio_procunit(struct mixer_build *state, int unitid, void *raw_desc, struct procunit_info *list, char *name) | 1769 | static int build_audio_procunit(struct mixer_build *state, int unitid, |
1770 | void *raw_desc, struct procunit_info *list, | ||
1771 | char *name) | ||
1704 | { | 1772 | { |
1705 | struct uac_processing_unit_descriptor *desc = raw_desc; | 1773 | struct uac_processing_unit_descriptor *desc = raw_desc; |
1706 | int num_ins = desc->bNrInPins; | 1774 | int num_ins = desc->bNrInPins; |
@@ -1733,22 +1801,20 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, void *raw | |||
1733 | for (info = list; info && info->type; info++) | 1801 | for (info = list; info && info->type; info++) |
1734 | if (info->type == type) | 1802 | if (info->type == type) |
1735 | break; | 1803 | break; |
1736 | if (! info || ! info->type) | 1804 | if (!info || !info->type) |
1737 | info = &default_info; | 1805 | info = &default_info; |
1738 | 1806 | ||
1739 | for (valinfo = info->values; valinfo->control; valinfo++) { | 1807 | for (valinfo = info->values; valinfo->control; valinfo++) { |
1740 | __u8 *controls = uac_processing_unit_bmControls(desc, state->mixer->protocol); | 1808 | __u8 *controls = uac_processing_unit_bmControls(desc, state->mixer->protocol); |
1741 | 1809 | ||
1742 | if (! (controls[valinfo->control / 8] & (1 << ((valinfo->control % 8) - 1)))) | 1810 | if (!(controls[valinfo->control / 8] & (1 << ((valinfo->control % 8) - 1)))) |
1743 | continue; | 1811 | continue; |
1744 | map = find_map(state, unitid, valinfo->control); | 1812 | map = find_map(state, unitid, valinfo->control); |
1745 | if (check_ignored_ctl(map)) | 1813 | if (check_ignored_ctl(map)) |
1746 | continue; | 1814 | continue; |
1747 | cval = kzalloc(sizeof(*cval), GFP_KERNEL); | 1815 | cval = kzalloc(sizeof(*cval), GFP_KERNEL); |
1748 | if (! cval) { | 1816 | if (!cval) |
1749 | usb_audio_err(state->chip, "cannot malloc kcontrol\n"); | ||
1750 | return -ENOMEM; | 1817 | return -ENOMEM; |
1751 | } | ||
1752 | cval->mixer = state->mixer; | 1818 | cval->mixer = state->mixer; |
1753 | cval->id = unitid; | 1819 | cval->id = unitid; |
1754 | cval->control = valinfo->control; | 1820 | cval->control = valinfo->control; |
@@ -1765,7 +1831,8 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, void *raw | |||
1765 | cval->initialized = 1; | 1831 | cval->initialized = 1; |
1766 | } else { | 1832 | } else { |
1767 | if (type == USB_XU_CLOCK_RATE) { | 1833 | if (type == USB_XU_CLOCK_RATE) { |
1768 | /* E-Mu USB 0404/0202/TrackerPre/0204 | 1834 | /* |
1835 | * E-Mu USB 0404/0202/TrackerPre/0204 | ||
1769 | * samplerate control quirk | 1836 | * samplerate control quirk |
1770 | */ | 1837 | */ |
1771 | cval->min = 0; | 1838 | cval->min = 0; |
@@ -1777,60 +1844,69 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, void *raw | |||
1777 | } | 1844 | } |
1778 | 1845 | ||
1779 | kctl = snd_ctl_new1(&mixer_procunit_ctl, cval); | 1846 | kctl = snd_ctl_new1(&mixer_procunit_ctl, cval); |
1780 | if (! kctl) { | 1847 | if (!kctl) { |
1781 | usb_audio_err(state->chip, "cannot malloc kcontrol\n"); | ||
1782 | kfree(cval); | 1848 | kfree(cval); |
1783 | return -ENOMEM; | 1849 | return -ENOMEM; |
1784 | } | 1850 | } |
1785 | kctl->private_free = usb_mixer_elem_free; | 1851 | kctl->private_free = usb_mixer_elem_free; |
1786 | 1852 | ||
1787 | if (check_mapped_name(map, kctl->id.name, | 1853 | if (check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name))) { |
1788 | sizeof(kctl->id.name))) | ||
1789 | /* nothing */ ; | 1854 | /* nothing */ ; |
1790 | else if (info->name) | 1855 | } else if (info->name) { |
1791 | strlcpy(kctl->id.name, info->name, sizeof(kctl->id.name)); | 1856 | strlcpy(kctl->id.name, info->name, sizeof(kctl->id.name)); |
1792 | else { | 1857 | } else { |
1793 | nameid = uac_processing_unit_iProcessing(desc, state->mixer->protocol); | 1858 | nameid = uac_processing_unit_iProcessing(desc, state->mixer->protocol); |
1794 | len = 0; | 1859 | len = 0; |
1795 | if (nameid) | 1860 | if (nameid) |
1796 | len = snd_usb_copy_string_desc(state, nameid, kctl->id.name, sizeof(kctl->id.name)); | 1861 | len = snd_usb_copy_string_desc(state, nameid, |
1797 | if (! len) | 1862 | kctl->id.name, |
1863 | sizeof(kctl->id.name)); | ||
1864 | if (!len) | ||
1798 | strlcpy(kctl->id.name, name, sizeof(kctl->id.name)); | 1865 | strlcpy(kctl->id.name, name, sizeof(kctl->id.name)); |
1799 | } | 1866 | } |
1800 | append_ctl_name(kctl, " "); | 1867 | append_ctl_name(kctl, " "); |
1801 | append_ctl_name(kctl, valinfo->suffix); | 1868 | append_ctl_name(kctl, valinfo->suffix); |
1802 | 1869 | ||
1803 | usb_audio_dbg(state->chip, | 1870 | usb_audio_dbg(state->chip, |
1804 | "[%d] PU [%s] ch = %d, val = %d/%d\n", | 1871 | "[%d] PU [%s] ch = %d, val = %d/%d\n", |
1805 | cval->id, kctl->id.name, cval->channels, cval->min, cval->max); | 1872 | cval->id, kctl->id.name, cval->channels, |
1806 | if ((err = snd_usb_mixer_add_control(state->mixer, kctl)) < 0) | 1873 | cval->min, cval->max); |
1874 | |||
1875 | err = snd_usb_mixer_add_control(state->mixer, kctl); | ||
1876 | if (err < 0) | ||
1807 | return err; | 1877 | return err; |
1808 | } | 1878 | } |
1809 | return 0; | 1879 | return 0; |
1810 | } | 1880 | } |
1811 | 1881 | ||
1812 | 1882 | static int parse_audio_processing_unit(struct mixer_build *state, int unitid, | |
1813 | static int parse_audio_processing_unit(struct mixer_build *state, int unitid, void *raw_desc) | 1883 | void *raw_desc) |
1814 | { | 1884 | { |
1815 | return build_audio_procunit(state, unitid, raw_desc, procunits, "Processing Unit"); | 1885 | return build_audio_procunit(state, unitid, raw_desc, |
1886 | procunits, "Processing Unit"); | ||
1816 | } | 1887 | } |
1817 | 1888 | ||
1818 | static int parse_audio_extension_unit(struct mixer_build *state, int unitid, void *raw_desc) | 1889 | static int parse_audio_extension_unit(struct mixer_build *state, int unitid, |
1890 | void *raw_desc) | ||
1819 | { | 1891 | { |
1820 | /* Note that we parse extension units with processing unit descriptors. | 1892 | /* |
1821 | * That's ok as the layout is the same */ | 1893 | * Note that we parse extension units with processing unit descriptors. |
1822 | return build_audio_procunit(state, unitid, raw_desc, extunits, "Extension Unit"); | 1894 | * That's ok as the layout is the same. |
1895 | */ | ||
1896 | return build_audio_procunit(state, unitid, raw_desc, | ||
1897 | extunits, "Extension Unit"); | ||
1823 | } | 1898 | } |
1824 | 1899 | ||
1825 | |||
1826 | /* | 1900 | /* |
1827 | * Selector Unit | 1901 | * Selector Unit |
1828 | */ | 1902 | */ |
1829 | 1903 | ||
1830 | /* info callback for selector unit | 1904 | /* |
1905 | * info callback for selector unit | ||
1831 | * use an enumerator type for routing | 1906 | * use an enumerator type for routing |
1832 | */ | 1907 | */ |
1833 | static int mixer_ctl_selector_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 1908 | static int mixer_ctl_selector_info(struct snd_kcontrol *kcontrol, |
1909 | struct snd_ctl_elem_info *uinfo) | ||
1834 | { | 1910 | { |
1835 | struct usb_mixer_elem_info *cval = kcontrol->private_data; | 1911 | struct usb_mixer_elem_info *cval = kcontrol->private_data; |
1836 | const char **itemlist = (const char **)kcontrol->private_value; | 1912 | const char **itemlist = (const char **)kcontrol->private_value; |
@@ -1841,7 +1917,8 @@ static int mixer_ctl_selector_info(struct snd_kcontrol *kcontrol, struct snd_ctl | |||
1841 | } | 1917 | } |
1842 | 1918 | ||
1843 | /* get callback for selector unit */ | 1919 | /* get callback for selector unit */ |
1844 | static int mixer_ctl_selector_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 1920 | static int mixer_ctl_selector_get(struct snd_kcontrol *kcontrol, |
1921 | struct snd_ctl_elem_value *ucontrol) | ||
1845 | { | 1922 | { |
1846 | struct usb_mixer_elem_info *cval = kcontrol->private_data; | 1923 | struct usb_mixer_elem_info *cval = kcontrol->private_data; |
1847 | int val, err; | 1924 | int val, err; |
@@ -1860,7 +1937,8 @@ static int mixer_ctl_selector_get(struct snd_kcontrol *kcontrol, struct snd_ctl_ | |||
1860 | } | 1937 | } |
1861 | 1938 | ||
1862 | /* put callback for selector unit */ | 1939 | /* put callback for selector unit */ |
1863 | static int mixer_ctl_selector_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 1940 | static int mixer_ctl_selector_put(struct snd_kcontrol *kcontrol, |
1941 | struct snd_ctl_elem_value *ucontrol) | ||
1864 | { | 1942 | { |
1865 | struct usb_mixer_elem_info *cval = kcontrol->private_data; | 1943 | struct usb_mixer_elem_info *cval = kcontrol->private_data; |
1866 | int val, oval, err; | 1944 | int val, oval, err; |
@@ -1889,8 +1967,8 @@ static struct snd_kcontrol_new mixer_selectunit_ctl = { | |||
1889 | .put = mixer_ctl_selector_put, | 1967 | .put = mixer_ctl_selector_put, |
1890 | }; | 1968 | }; |
1891 | 1969 | ||
1892 | 1970 | /* | |
1893 | /* private free callback. | 1971 | * private free callback. |
1894 | * free both private_data and private_value | 1972 | * free both private_data and private_value |
1895 | */ | 1973 | */ |
1896 | static void usb_mixer_selector_elem_free(struct snd_kcontrol *kctl) | 1974 | static void usb_mixer_selector_elem_free(struct snd_kcontrol *kctl) |
@@ -1915,7 +1993,8 @@ static void usb_mixer_selector_elem_free(struct snd_kcontrol *kctl) | |||
1915 | /* | 1993 | /* |
1916 | * parse a selector unit | 1994 | * parse a selector unit |
1917 | */ | 1995 | */ |
1918 | static int parse_audio_selector_unit(struct mixer_build *state, int unitid, void *raw_desc) | 1996 | static int parse_audio_selector_unit(struct mixer_build *state, int unitid, |
1997 | void *raw_desc) | ||
1919 | { | 1998 | { |
1920 | struct uac_selector_unit_descriptor *desc = raw_desc; | 1999 | struct uac_selector_unit_descriptor *desc = raw_desc; |
1921 | unsigned int i, nameid, len; | 2000 | unsigned int i, nameid, len; |
@@ -1944,10 +2023,8 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, void | |||
1944 | return 0; | 2023 | return 0; |
1945 | 2024 | ||
1946 | cval = kzalloc(sizeof(*cval), GFP_KERNEL); | 2025 | cval = kzalloc(sizeof(*cval), GFP_KERNEL); |
1947 | if (! cval) { | 2026 | if (!cval) |
1948 | usb_audio_err(state->chip, "cannot malloc kcontrol\n"); | ||
1949 | return -ENOMEM; | 2027 | return -ENOMEM; |
1950 | } | ||
1951 | cval->mixer = state->mixer; | 2028 | cval->mixer = state->mixer; |
1952 | cval->id = unitid; | 2029 | cval->id = unitid; |
1953 | cval->val_type = USB_MIXER_U8; | 2030 | cval->val_type = USB_MIXER_U8; |
@@ -1963,8 +2040,7 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, void | |||
1963 | cval->control = 0; | 2040 | cval->control = 0; |
1964 | 2041 | ||
1965 | namelist = kmalloc(sizeof(char *) * desc->bNrInPins, GFP_KERNEL); | 2042 | namelist = kmalloc(sizeof(char *) * desc->bNrInPins, GFP_KERNEL); |
1966 | if (! namelist) { | 2043 | if (!namelist) { |
1967 | usb_audio_err(state->chip, "cannot malloc\n"); | ||
1968 | kfree(cval); | 2044 | kfree(cval); |
1969 | return -ENOMEM; | 2045 | return -ENOMEM; |
1970 | } | 2046 | } |
@@ -1973,8 +2049,7 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, void | |||
1973 | struct usb_audio_term iterm; | 2049 | struct usb_audio_term iterm; |
1974 | len = 0; | 2050 | len = 0; |
1975 | namelist[i] = kmalloc(MAX_ITEM_NAME_LEN, GFP_KERNEL); | 2051 | namelist[i] = kmalloc(MAX_ITEM_NAME_LEN, GFP_KERNEL); |
1976 | if (! namelist[i]) { | 2052 | if (!namelist[i]) { |
1977 | usb_audio_err(state->chip, "cannot malloc\n"); | ||
1978 | while (i--) | 2053 | while (i--) |
1979 | kfree(namelist[i]); | 2054 | kfree(namelist[i]); |
1980 | kfree(namelist); | 2055 | kfree(namelist); |
@@ -1986,7 +2061,7 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, void | |||
1986 | if (! len && check_input_term(state, desc->baSourceID[i], &iterm) >= 0) | 2061 | if (! len && check_input_term(state, desc->baSourceID[i], &iterm) >= 0) |
1987 | len = get_term_name(state, &iterm, namelist[i], MAX_ITEM_NAME_LEN, 0); | 2062 | len = get_term_name(state, &iterm, namelist[i], MAX_ITEM_NAME_LEN, 0); |
1988 | if (! len) | 2063 | if (! len) |
1989 | sprintf(namelist[i], "Input %d", i); | 2064 | sprintf(namelist[i], "Input %u", i); |
1990 | } | 2065 | } |
1991 | 2066 | ||
1992 | kctl = snd_ctl_new1(&mixer_selectunit_ctl, cval); | 2067 | kctl = snd_ctl_new1(&mixer_selectunit_ctl, cval); |
@@ -2004,11 +2079,12 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, void | |||
2004 | if (len) | 2079 | if (len) |
2005 | ; | 2080 | ; |
2006 | else if (nameid) | 2081 | else if (nameid) |
2007 | snd_usb_copy_string_desc(state, nameid, kctl->id.name, sizeof(kctl->id.name)); | 2082 | snd_usb_copy_string_desc(state, nameid, kctl->id.name, |
2083 | sizeof(kctl->id.name)); | ||
2008 | else { | 2084 | else { |
2009 | len = get_term_name(state, &state->oterm, | 2085 | len = get_term_name(state, &state->oterm, |
2010 | kctl->id.name, sizeof(kctl->id.name), 0); | 2086 | kctl->id.name, sizeof(kctl->id.name), 0); |
2011 | if (! len) | 2087 | if (!len) |
2012 | strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name)); | 2088 | strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name)); |
2013 | 2089 | ||
2014 | if (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR) | 2090 | if (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR) |
@@ -2027,7 +2103,6 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, void | |||
2027 | return 0; | 2103 | return 0; |
2028 | } | 2104 | } |
2029 | 2105 | ||
2030 | |||
2031 | /* | 2106 | /* |
2032 | * parse an audio unit recursively | 2107 | * parse an audio unit recursively |
2033 | */ | 2108 | */ |
@@ -2125,14 +2200,16 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) | |||
2125 | } | 2200 | } |
2126 | 2201 | ||
2127 | p = NULL; | 2202 | p = NULL; |
2128 | while ((p = snd_usb_find_csint_desc(mixer->hostif->extra, mixer->hostif->extralen, | 2203 | while ((p = snd_usb_find_csint_desc(mixer->hostif->extra, |
2204 | mixer->hostif->extralen, | ||
2129 | p, UAC_OUTPUT_TERMINAL)) != NULL) { | 2205 | p, UAC_OUTPUT_TERMINAL)) != NULL) { |
2130 | if (mixer->protocol == UAC_VERSION_1) { | 2206 | if (mixer->protocol == UAC_VERSION_1) { |
2131 | struct uac1_output_terminal_descriptor *desc = p; | 2207 | struct uac1_output_terminal_descriptor *desc = p; |
2132 | 2208 | ||
2133 | if (desc->bLength < sizeof(*desc)) | 2209 | if (desc->bLength < sizeof(*desc)) |
2134 | continue; /* invalid descriptor? */ | 2210 | continue; /* invalid descriptor? */ |
2135 | set_bit(desc->bTerminalID, state.unitbitmap); /* mark terminal ID as visited */ | 2211 | /* mark terminal ID as visited */ |
2212 | set_bit(desc->bTerminalID, state.unitbitmap); | ||
2136 | state.oterm.id = desc->bTerminalID; | 2213 | state.oterm.id = desc->bTerminalID; |
2137 | state.oterm.type = le16_to_cpu(desc->wTerminalType); | 2214 | state.oterm.type = le16_to_cpu(desc->wTerminalType); |
2138 | state.oterm.name = desc->iTerminal; | 2215 | state.oterm.name = desc->iTerminal; |
@@ -2144,7 +2221,8 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) | |||
2144 | 2221 | ||
2145 | if (desc->bLength < sizeof(*desc)) | 2222 | if (desc->bLength < sizeof(*desc)) |
2146 | continue; /* invalid descriptor? */ | 2223 | continue; /* invalid descriptor? */ |
2147 | set_bit(desc->bTerminalID, state.unitbitmap); /* mark terminal ID as visited */ | 2224 | /* mark terminal ID as visited */ |
2225 | set_bit(desc->bTerminalID, state.unitbitmap); | ||
2148 | state.oterm.id = desc->bTerminalID; | 2226 | state.oterm.id = desc->bTerminalID; |
2149 | state.oterm.type = le16_to_cpu(desc->wTerminalType); | 2227 | state.oterm.type = le16_to_cpu(desc->wTerminalType); |
2150 | state.oterm.name = desc->iTerminal; | 2228 | state.oterm.name = desc->iTerminal; |
@@ -2152,7 +2230,10 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) | |||
2152 | if (err < 0 && err != -EINVAL) | 2230 | if (err < 0 && err != -EINVAL) |
2153 | return err; | 2231 | return err; |
2154 | 2232 | ||
2155 | /* for UAC2, use the same approach to also add the clock selectors */ | 2233 | /* |
2234 | * For UAC2, use the same approach to also add the | ||
2235 | * clock selectors | ||
2236 | */ | ||
2156 | err = parse_audio_unit(&state, desc->bCSourceID); | 2237 | err = parse_audio_unit(&state, desc->bCSourceID); |
2157 | if (err < 0 && err != -EINVAL) | 2238 | if (err < 0 && err != -EINVAL) |
2158 | return err; | 2239 | return err; |
@@ -2306,7 +2387,9 @@ static void snd_usb_mixer_interrupt(struct urb *urb) | |||
2306 | } | 2387 | } |
2307 | 2388 | ||
2308 | requeue: | 2389 | requeue: |
2309 | if (ustatus != -ENOENT && ustatus != -ECONNRESET && ustatus != -ESHUTDOWN) { | 2390 | if (ustatus != -ENOENT && |
2391 | ustatus != -ECONNRESET && | ||
2392 | ustatus != -ESHUTDOWN) { | ||
2310 | urb->dev = mixer->chip->dev; | 2393 | urb->dev = mixer->chip->dev; |
2311 | usb_submit_urb(urb, GFP_ATOMIC); | 2394 | usb_submit_urb(urb, GFP_ATOMIC); |
2312 | } | 2395 | } |