Lines Matching full:mixer
5 * Mixer control part
15 * TODOs, for both the mixer and the streaming interfaces:
48 #include "mixer.h"
67 struct usb_mixer_interface *mixer; member
94 * manual mapping of mixer names
95 * if the mixer topology is too complicated and the parsed names are
127 ((cval)->head.mixer->ignore_ctl_error ? 0 : (err))
292 * retrieve a mixer value
295 static inline int mixer_ctrl_intf(struct usb_mixer_interface *mixer) in mixer_ctrl_intf() argument
297 return get_iface_desc(mixer->hostif)->bInterfaceNumber; in mixer_ctrl_intf()
303 struct snd_usb_audio *chip = cval->head.mixer->chip; in get_ctl_value_v1()
314 idx = mixer_ctrl_intf(cval->head.mixer) | (cval->head.id << 8); in get_ctl_value_v1()
339 struct snd_usb_audio *chip = cval->head.mixer->chip; in get_ctl_value_v2()
362 idx = mixer_ctrl_intf(cval->head.mixer) | (cval->head.id << 8); in get_ctl_value_v2()
406 return (cval->head.mixer->protocol == UAC_VERSION_1) ? in get_ctl_value()
437 if (!cval->head.mixer->ignore_ctl_error) in snd_usb_get_cur_mix_value()
438 usb_audio_dbg(cval->head.mixer->chip, in snd_usb_get_cur_mix_value()
449 * set a mixer value
455 struct snd_usb_audio *chip = cval->head.mixer->chip; in snd_usb_mixer_set_ctl_value()
462 if (cval->head.mixer->protocol == UAC_VERSION_1) { in snd_usb_mixer_set_ctl_value()
487 idx = mixer_ctrl_intf(cval->head.mixer) | (cval->head.id << 8); in snd_usb_mixer_set_ctl_value()
523 usb_audio_dbg(cval->head.mixer->chip, in snd_usb_set_cur_mix_value()
540 * TLV callback for mixer volume controls
568 * used for mixer unit parser
588 struct usb_mixer_interface *mixer = list->mixer; in snd_usb_mixer_add_list() local
591 while (snd_ctl_find_id(mixer->chip->card, &kctl->id)) in snd_usb_mixer_add_list()
593 err = snd_ctl_add(mixer->chip->card, kctl); in snd_usb_mixer_add_list()
595 usb_audio_dbg(mixer->chip, "cannot add control (err = %d)\n", in snd_usb_mixer_add_list()
601 list->next_id_elem = mixer->id_elems[list->id]; in snd_usb_mixer_add_list()
602 mixer->id_elems[list->id] = list; in snd_usb_mixer_add_list()
681 strcpy(name, "Mixer"); in get_term_name()
743 * Get number of channels for a Mixer Unit.
750 switch (state->mixer->protocol) { in uac_mixer_unit_get_channels()
844 int protocol = state->mixer->protocol; in parse_term_mixer_unit()
873 if (state->mixer->protocol != UAC_VERSION_3) in parse_term_selector_unit()
883 int protocol = state->mixer->protocol; in parse_term_proc_unit()
955 int protocol = state->mixer->protocol; in __check_input_term()
1074 * interface to ALSA control for feature/mixer units
1081 struct snd_usb_audio *chip = cval->head.mixer->chip; in volume_control_quirks()
1225 usb_audio_err(cval->head.mixer->chip, in get_min_max_with_quirks()
1227 cval->head.id, mixer_ctrl_intf(cval->head.mixer), in get_min_max_with_quirks()
1311 /* get a feature/mixer unit info */
1334 snd_ctl_notify(cval->head.mixer->chip->card, in mixer_ctl_feature_info()
1346 /* get the current value from feature/mixer unit */
1378 /* put the current value to feature/mixer unit */
1437 struct snd_usb_audio *chip = cval->head.mixer->chip; in mixer_ctl_connector_get()
1446 idx = mixer_ctrl_intf(cval->head.mixer) | (cval->head.id << 8); in mixer_ctl_connector_get()
1447 if (cval->head.mixer->protocol == UAC_VERSION_2) { in mixer_ctl_connector_get()
1521 * This symbol is exported in order to allow the mixer quirks to
1535 * A lot of headsets/headphones have a "Speaker" mixer. Make sure we
1573 static void __build_feature_ctl(struct usb_mixer_interface *mixer, in __build_feature_ctl() argument
1600 snd_usb_mixer_elem_init_std(&cval->head, mixer, unitid); in __build_feature_ctl()
1609 if (mixer->protocol == UAC_VERSION_1) in __build_feature_ctl()
1638 usb_audio_err(mixer->chip, "cannot malloc kcontrol\n"); in __build_feature_ctl()
1647 len = snd_usb_copy_string_desc(mixer->chip, nameid, in __build_feature_ctl()
1663 len = get_term_name(mixer->chip, iterm, in __build_feature_ctl()
1667 len = get_term_name(mixer->chip, oterm, in __build_feature_ctl()
1676 check_no_speaker_on_headset(kctl, mixer->chip->card); in __build_feature_ctl()
1704 usb_audio_dbg(mixer->chip, in __build_feature_ctl()
1722 snd_usb_mixer_fu_apply_quirk(mixer, cval, unitid, kctl); in __build_feature_ctl()
1731 usb_audio_warn(mixer->chip, in __build_feature_ctl()
1734 usb_audio_warn(mixer->chip, in __build_feature_ctl()
1740 usb_audio_dbg(mixer->chip, "[%d] FU [%s] ch = %d, val = %d/%d/%d\n", in __build_feature_ctl()
1754 __build_feature_ctl(state->mixer, state->map, ctl_mask, control, in build_feature_ctl()
1758 static void build_feature_ctl_badd(struct usb_mixer_interface *mixer, in build_feature_ctl_badd() argument
1762 __build_feature_ctl(mixer, badd_map, ctl_mask, control, in build_feature_ctl_badd()
1766 static void get_connector_control_name(struct usb_mixer_interface *mixer, in get_connector_control_name() argument
1770 int name_len = get_term_name(mixer->chip, term, name, name_size, 0); in get_connector_control_name()
1786 /* Build a mixer control for a UAC connector control (jack-detect) */
1787 static void build_connector_control(struct usb_mixer_interface *mixer, in build_connector_control() argument
1802 snd_usb_mixer_elem_init_std(&cval->head, mixer, term->id); in build_connector_control()
1813 if (mixer->protocol == UAC_VERSION_2) in build_connector_control()
1824 usb_audio_err(mixer->chip, "cannot malloc kcontrol\n"); in build_connector_control()
1832 get_connector_control_name(mixer, term, is_input, kctl->id.name, in build_connector_control()
1847 if (state->mixer->protocol != UAC_VERSION_2) in parse_clock_source_unit()
1862 snd_usb_mixer_elem_init_std(&cval->head, state->mixer, hdr->bClockID); in parse_clock_source_unit()
1907 if (state->mixer->protocol == UAC_VERSION_1) { in parse_audio_feature_unit()
1911 } else if (state->mixer->protocol == UAC_VERSION_2) { in parse_audio_feature_unit()
1952 if (state->mixer->protocol == UAC_VERSION_1) { in parse_audio_feature_unit()
2025 * Mixer Unit
2054 * build a mixer unit control
2077 snd_usb_mixer_elem_init_std(&cval->head, state->mixer, unitid); in build_mixer_unit_ctl()
2081 __u8 *c = uac_mixer_unit_bmControls(desc, state->mixer->protocol); in build_mixer_unit_ctl()
2105 len = sprintf(kctl->id.name, "Mixer Source %d", in_ch + 1); in build_mixer_unit_ctl()
2119 if (state->mixer->protocol == UAC_VERSION_2) { in parse_audio_input_terminal()
2124 } else if (state->mixer->protocol == UAC_VERSION_3) { in parse_audio_input_terminal()
2138 build_connector_control(state->mixer, state->map, &iterm, true); in parse_audio_input_terminal()
2144 * parse a mixer unit
2157 "invalid MIXER UNIT descriptor %d\n", in parse_audio_mixer_unit()
2178 if (mixer_bitmap_overflow(desc, state->mixer->protocol, in parse_audio_mixer_unit()
2186 state->mixer->protocol); in parse_audio_mixer_unit()
2403 __u8 *controls = uac_processing_unit_bmControls(desc, state->mixer->protocol); in build_audio_procunit()
2405 if (state->mixer->protocol == UAC_VERSION_1) { in build_audio_procunit()
2421 snd_usb_mixer_elem_init_std(&cval->head, state->mixer, unitid); in build_audio_procunit()
2426 if (state->mixer->protocol > UAC_VERSION_1 && in build_audio_procunit()
2436 switch (state->mixer->protocol) { in build_audio_procunit()
2451 state->mixer->protocol); in build_audio_procunit()
2496 nameid = uac_extension_unit_iExtension(desc, state->mixer->protocol); in build_audio_procunit()
2498 nameid = uac_processing_unit_iProcessing(desc, state->mixer->protocol); in build_audio_procunit()
2526 switch (state->mixer->protocol) { in parse_audio_processing_unit()
2665 snd_usb_mixer_elem_init_std(&cval->head, state->mixer, unitid); in parse_audio_selector_unit()
2673 switch (state->mixer->protocol) { in parse_audio_selector_unit()
2724 switch (state->mixer->protocol) { in parse_audio_selector_unit()
2778 int protocol = state->mixer->protocol; in parse_audio_unit()
2835 static void snd_usb_mixer_free(struct usb_mixer_interface *mixer) in snd_usb_mixer_free() argument
2838 snd_usb_mixer_disconnect(mixer); in snd_usb_mixer_free()
2840 kfree(mixer->id_elems); in snd_usb_mixer_free()
2841 if (mixer->urb) { in snd_usb_mixer_free()
2842 kfree(mixer->urb->transfer_buffer); in snd_usb_mixer_free()
2843 usb_free_urb(mixer->urb); in snd_usb_mixer_free()
2845 usb_free_urb(mixer->rc_urb); in snd_usb_mixer_free()
2846 kfree(mixer->rc_setup_packet); in snd_usb_mixer_free()
2847 kfree(mixer); in snd_usb_mixer_free()
2852 struct usb_mixer_interface *mixer = device->device_data; in snd_usb_mixer_dev_free() local
2853 snd_usb_mixer_free(mixer); in snd_usb_mixer_dev_free()
2926 static bool uac3_badd_func_has_valid_channels(struct usb_mixer_interface *mixer, in uac3_badd_func_has_valid_channels() argument
2936 usb_audio_warn(mixer->chip, "BAAD %s: no channels?", in uac3_badd_func_has_valid_channels()
2945 usb_audio_warn(mixer->chip, "BAAD %s c_chmask mismatch", in uac3_badd_func_has_valid_channels()
2951 usb_audio_warn(mixer->chip, "BAAD %s p_chmask mismatch", in uac3_badd_func_has_valid_channels()
2959 * create mixer controls for UAC3 BADD profiles
2963 * BADD device may contain Mixer Unit, which doesn't have any controls, skip it
2965 static int snd_usb_mixer_controls_badd(struct usb_mixer_interface *mixer, in snd_usb_mixer_controls_badd() argument
2968 struct usb_device *dev = mixer->chip->dev; in snd_usb_mixer_controls_badd()
2970 int badd_profile = mixer->chip->badd_profile; in snd_usb_mixer_controls_badd()
3020 usb_audio_err(mixer->chip, in snd_usb_mixer_controls_badd()
3044 usb_audio_dbg(mixer->chip, in snd_usb_mixer_controls_badd()
3063 if (!uac3_badd_func_has_valid_channels(mixer, f, c_chmask, p_chmask)) in snd_usb_mixer_controls_badd()
3070 build_feature_ctl_badd(mixer, 0, UAC_FU_MUTE, in snd_usb_mixer_controls_badd()
3073 build_feature_ctl_badd(mixer, p_chmask, UAC_FU_VOLUME, in snd_usb_mixer_controls_badd()
3080 build_feature_ctl_badd(mixer, 0, UAC_FU_MUTE, in snd_usb_mixer_controls_badd()
3083 build_feature_ctl_badd(mixer, c_chmask, UAC_FU_VOLUME, in snd_usb_mixer_controls_badd()
3090 build_feature_ctl_badd(mixer, 0, UAC_FU_MUTE, in snd_usb_mixer_controls_badd()
3093 build_feature_ctl_badd(mixer, 1, UAC_FU_VOLUME, in snd_usb_mixer_controls_badd()
3105 build_connector_control(mixer, map->map, &iterm, true); in snd_usb_mixer_controls_badd()
3111 build_connector_control(mixer, map->map, &oterm, false); in snd_usb_mixer_controls_badd()
3118 * create mixer controls
3122 static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) in snd_usb_mixer_controls() argument
3130 state.chip = mixer->chip; in snd_usb_mixer_controls()
3131 state.mixer = mixer; in snd_usb_mixer_controls()
3132 state.buffer = mixer->hostif->extra; in snd_usb_mixer_controls()
3133 state.buflen = mixer->hostif->extralen; in snd_usb_mixer_controls()
3140 mixer->connector_map = map->connector_map; in snd_usb_mixer_controls()
3141 mixer->ignore_ctl_error |= map->ignore_ctl_error; in snd_usb_mixer_controls()
3147 while ((p = snd_usb_find_csint_desc(mixer->hostif->extra, in snd_usb_mixer_controls()
3148 mixer->hostif->extralen, in snd_usb_mixer_controls()
3150 if (!snd_usb_validate_audio_desc(p, mixer->protocol)) in snd_usb_mixer_controls()
3153 if (mixer->protocol == UAC_VERSION_1) { in snd_usb_mixer_controls()
3164 } else if (mixer->protocol == UAC_VERSION_2) { in snd_usb_mixer_controls()
3187 build_connector_control(state.mixer, state.map, in snd_usb_mixer_controls()
3213 build_connector_control(state.mixer, state.map, in snd_usb_mixer_controls()
3222 static int delegate_notify(struct usb_mixer_interface *mixer, int unitid, in delegate_notify() argument
3225 const struct usbmix_connector_map *map = mixer->connector_map; in delegate_notify()
3242 void snd_usb_mixer_notify_id(struct usb_mixer_interface *mixer, int unitid) in snd_usb_mixer_notify_id() argument
3246 unitid = delegate_notify(mixer, unitid, NULL, NULL); in snd_usb_mixer_notify_id()
3248 for_each_mixer_elem(list, mixer, unitid) { in snd_usb_mixer_notify_id()
3256 snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in snd_usb_mixer_notify_id()
3279 struct usb_mixer_interface *mixer; in snd_usb_mixer_proc_read() local
3283 list_for_each_entry(mixer, &chip->mixer_list, list) { in snd_usb_mixer_proc_read()
3285 "USB Mixer: usb_id=0x%08x, ctrlif=%i, ctlerr=%i\n", in snd_usb_mixer_proc_read()
3286 chip->usb_id, mixer_ctrl_intf(mixer), in snd_usb_mixer_proc_read()
3287 mixer->ignore_ctl_error); in snd_usb_mixer_proc_read()
3290 for_each_mixer_elem(list, mixer, unitid) { in snd_usb_mixer_proc_read()
3304 static void snd_usb_mixer_interrupt_v2(struct usb_mixer_interface *mixer, in snd_usb_mixer_interrupt_v2() argument
3314 usb_audio_dbg(mixer->chip, in snd_usb_mixer_interrupt_v2()
3320 unitid = delegate_notify(mixer, unitid, &control, &channel); in snd_usb_mixer_interrupt_v2()
3322 for_each_mixer_elem(list, mixer, unitid) in snd_usb_mixer_interrupt_v2()
3328 for_each_mixer_elem(list, mixer, unitid) { in snd_usb_mixer_interrupt_v2()
3348 snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in snd_usb_mixer_interrupt_v2()
3361 usb_audio_dbg(mixer->chip, in snd_usb_mixer_interrupt_v2()
3371 struct usb_mixer_interface *mixer = urb->context; in snd_usb_mixer_interrupt() local
3378 if (mixer->protocol == UAC_VERSION_1) { in snd_usb_mixer_interrupt()
3394 snd_usb_mixer_rc_memory_change(mixer, status->bOriginator); in snd_usb_mixer_interrupt()
3396 snd_usb_mixer_notify_id(mixer, status->bOriginator); in snd_usb_mixer_interrupt()
3409 snd_usb_mixer_interrupt_v2(mixer, msg->bAttribute, in snd_usb_mixer_interrupt()
3419 urb->dev = mixer->chip->dev; in snd_usb_mixer_interrupt()
3425 static int snd_usb_mixer_status_create(struct usb_mixer_interface *mixer) in snd_usb_mixer_status_create() argument
3433 if (get_iface_desc(mixer->hostif)->bNumEndpoints < 1) in snd_usb_mixer_status_create()
3435 ep = get_endpoint(mixer->hostif, 0); in snd_usb_mixer_status_create()
3444 mixer->urb = usb_alloc_urb(0, GFP_KERNEL); in snd_usb_mixer_status_create()
3445 if (!mixer->urb) { in snd_usb_mixer_status_create()
3449 usb_fill_int_urb(mixer->urb, mixer->chip->dev, in snd_usb_mixer_status_create()
3450 usb_rcvintpipe(mixer->chip->dev, epnum), in snd_usb_mixer_status_create()
3452 snd_usb_mixer_interrupt, mixer, ep->bInterval); in snd_usb_mixer_status_create()
3453 usb_submit_urb(mixer->urb, GFP_KERNEL); in snd_usb_mixer_status_create()
3460 struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); in keep_iface_ctl_get() local
3462 ucontrol->value.integer.value[0] = mixer->chip->keep_iface; in keep_iface_ctl_get()
3469 struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); in keep_iface_ctl_put() local
3472 if (mixer->chip->keep_iface == keep_iface) in keep_iface_ctl_put()
3474 mixer->chip->keep_iface = keep_iface; in keep_iface_ctl_put()
3486 static int create_keep_iface_ctl(struct usb_mixer_interface *mixer) in create_keep_iface_ctl() argument
3488 struct snd_kcontrol *kctl = snd_ctl_new1(&keep_iface_ctl, mixer); in create_keep_iface_ctl()
3491 if (snd_ctl_find_id(mixer->chip->card, &kctl->id)) { in create_keep_iface_ctl()
3496 return snd_ctl_add(mixer->chip->card, kctl); in create_keep_iface_ctl()
3505 struct usb_mixer_interface *mixer; in snd_usb_create_mixer() local
3508 strcpy(chip->card->mixername, "USB Mixer"); in snd_usb_create_mixer()
3510 mixer = kzalloc(sizeof(*mixer), GFP_KERNEL); in snd_usb_create_mixer()
3511 if (!mixer) in snd_usb_create_mixer()
3513 mixer->chip = chip; in snd_usb_create_mixer()
3514 mixer->ignore_ctl_error = ignore_error; in snd_usb_create_mixer()
3515 mixer->id_elems = kcalloc(MAX_ID_ELEMS, sizeof(*mixer->id_elems), in snd_usb_create_mixer()
3517 if (!mixer->id_elems) { in snd_usb_create_mixer()
3518 kfree(mixer); in snd_usb_create_mixer()
3522 mixer->hostif = &usb_ifnum_to_if(chip->dev, ctrlif)->altsetting[0]; in snd_usb_create_mixer()
3523 switch (get_iface_desc(mixer->hostif)->bInterfaceProtocol) { in snd_usb_create_mixer()
3526 mixer->protocol = UAC_VERSION_1; in snd_usb_create_mixer()
3529 mixer->protocol = UAC_VERSION_2; in snd_usb_create_mixer()
3532 mixer->protocol = UAC_VERSION_3; in snd_usb_create_mixer()
3536 if (mixer->protocol == UAC_VERSION_3 && in snd_usb_create_mixer()
3538 err = snd_usb_mixer_controls_badd(mixer, ctrlif); in snd_usb_create_mixer()
3542 err = snd_usb_mixer_controls(mixer); in snd_usb_create_mixer()
3547 err = snd_usb_mixer_status_create(mixer); in snd_usb_create_mixer()
3551 err = create_keep_iface_ctl(mixer); in snd_usb_create_mixer()
3555 err = snd_usb_mixer_apply_create_quirk(mixer); in snd_usb_create_mixer()
3559 err = snd_device_new(chip->card, SNDRV_DEV_CODEC, mixer, &dev_ops); in snd_usb_create_mixer()
3567 list_add(&mixer->list, &chip->mixer_list); in snd_usb_create_mixer()
3571 snd_usb_mixer_free(mixer); in snd_usb_create_mixer()
3575 void snd_usb_mixer_disconnect(struct usb_mixer_interface *mixer) in snd_usb_mixer_disconnect() argument
3577 if (mixer->disconnected) in snd_usb_mixer_disconnect()
3579 if (mixer->urb) in snd_usb_mixer_disconnect()
3580 usb_kill_urb(mixer->urb); in snd_usb_mixer_disconnect()
3581 if (mixer->rc_urb) in snd_usb_mixer_disconnect()
3582 usb_kill_urb(mixer->rc_urb); in snd_usb_mixer_disconnect()
3583 if (mixer->private_free) in snd_usb_mixer_disconnect()
3584 mixer->private_free(mixer); in snd_usb_mixer_disconnect()
3585 mixer->disconnected = true; in snd_usb_mixer_disconnect()
3589 /* stop any bus activity of a mixer */
3590 static void snd_usb_mixer_inactivate(struct usb_mixer_interface *mixer) in snd_usb_mixer_inactivate() argument
3592 usb_kill_urb(mixer->urb); in snd_usb_mixer_inactivate()
3593 usb_kill_urb(mixer->rc_urb); in snd_usb_mixer_inactivate()
3596 static int snd_usb_mixer_activate(struct usb_mixer_interface *mixer) in snd_usb_mixer_activate() argument
3600 if (mixer->urb) { in snd_usb_mixer_activate()
3601 err = usb_submit_urb(mixer->urb, GFP_NOIO); in snd_usb_mixer_activate()
3609 int snd_usb_mixer_suspend(struct usb_mixer_interface *mixer) in snd_usb_mixer_suspend() argument
3611 snd_usb_mixer_inactivate(mixer); in snd_usb_mixer_suspend()
3612 if (mixer->private_suspend) in snd_usb_mixer_suspend()
3613 mixer->private_suspend(mixer); in snd_usb_mixer_suspend()
3647 int snd_usb_mixer_resume(struct usb_mixer_interface *mixer, bool reset_resume) in snd_usb_mixer_resume() argument
3653 /* restore cached mixer values */ in snd_usb_mixer_resume()
3655 for_each_mixer_elem(list, mixer, id) { in snd_usb_mixer_resume()
3665 snd_usb_mixer_resume_quirk(mixer); in snd_usb_mixer_resume()
3667 return snd_usb_mixer_activate(mixer); in snd_usb_mixer_resume()
3672 struct usb_mixer_interface *mixer, in snd_usb_mixer_elem_init_std() argument
3675 list->mixer = mixer; in snd_usb_mixer_elem_init_std()