Lines Matching +full:chan +full:- +full:name
3 /*-
4 * SPDX-License-Identifier: BSD-2-Clause
123 if (err != 0 || req->newptr == NULL || val == uaudio_buffer_ms) in uaudio_buffer_ms_sysctl()
149 #define UAUDIO_NFRAMES 64 /* must be factor of 8 due HS-USB */
157 #define BIT_TEST(bm,bno) (((bm)[(bno) / 8] >> (7 - ((bno) % 8))) & 1)
159 #define MIX(sc) ((sc)->sc_mixer_node)
177 const char *name; member
436 {UA_FMT_PCM8, 8, AFMT_U8, "8-bit U-LE PCM"},
437 {UA_FMT_PCM8, 16, AFMT_U16_LE, "16-bit U-LE PCM"},
438 {UA_FMT_PCM8, 24, AFMT_U24_LE, "24-bit U-LE PCM"},
439 {UA_FMT_PCM8, 32, AFMT_U32_LE, "32-bit U-LE PCM"},
441 {UA_FMT_PCM, 8, AFMT_S8, "8-bit S-LE PCM"},
442 {UA_FMT_PCM, 16, AFMT_S16_LE, "16-bit S-LE PCM"},
443 {UA_FMT_PCM, 24, AFMT_S24_LE, "24-bit S-LE PCM"},
444 {UA_FMT_PCM, 32, AFMT_S32_LE, "32-bit S-LE PCM"},
446 {UA_FMT_ALAW, 8, AFMT_A_LAW, "8-bit A-Law"},
447 {UA_FMT_MULAW, 8, AFMT_MU_LAW, "8-bit mu-Law"},
452 {UA20_FMT_PCM, 8, AFMT_S8, "8-bit S-LE PCM"},
453 {UA20_FMT_PCM, 16, AFMT_S16_LE, "16-bit S-LE PCM"},
454 {UA20_FMT_PCM, 24, AFMT_S24_LE, "24-bit S-LE PCM"},
455 {UA20_FMT_PCM, 32, AFMT_S32_LE, "32-bit S-LE PCM"},
457 {UA20_FMT_PCM8, 8, AFMT_U8, "8-bit U-LE PCM"},
458 {UA20_FMT_PCM8, 16, AFMT_U16_LE, "16-bit U-LE PCM"},
459 {UA20_FMT_PCM8, 24, AFMT_U24_LE, "24-bit U-LE PCM"},
460 {UA20_FMT_PCM8, 32, AFMT_U32_LE, "32-bit U-LE PCM"},
462 {UA20_FMT_ALAW, 8, AFMT_A_LAW, "8-bit A-Law"},
463 {UA20_FMT_MULAW, 8, AFMT_MU_LAW, "8-bit mu-Law"},
713 .name = "uaudio",
718 /* The following table is derived from Linux's quirks-table.h */
731 { USB_VPI(USB_VENDOR_YAMAHA, 0x100c, 0) }, /* UC-MX */
732 { USB_VPI(USB_VENDOR_YAMAHA, 0x100d, 0) }, /* UC-KX */
734 { USB_VPI(USB_VENDOR_YAMAHA, 0x100f, 0) }, /* CLP-150 */
735 { USB_VPI(USB_VENDOR_YAMAHA, 0x1010, 0) }, /* CLP-170 */
736 { USB_VPI(USB_VENDOR_YAMAHA, 0x1011, 0) }, /* P-250 */
738 { USB_VPI(USB_VENDOR_YAMAHA, 0x1013, 0) }, /* PF-500 */
740 { USB_VPI(USB_VENDOR_YAMAHA, 0x1015, 0) }, /* MOTIF-R */
741 { USB_VPI(USB_VENDOR_YAMAHA, 0x1016, 0) }, /* MDP-5 */
742 { USB_VPI(USB_VENDOR_YAMAHA, 0x1017, 0) }, /* CVP-204 */
743 { USB_VPI(USB_VENDOR_YAMAHA, 0x1018, 0) }, /* CVP-206 */
744 { USB_VPI(USB_VENDOR_YAMAHA, 0x1019, 0) }, /* CVP-208 */
745 { USB_VPI(USB_VENDOR_YAMAHA, 0x101a, 0) }, /* CVP-210 */
746 { USB_VPI(USB_VENDOR_YAMAHA, 0x101b, 0) }, /* PSR-1100 */
747 { USB_VPI(USB_VENDOR_YAMAHA, 0x101c, 0) }, /* PSR-2100 */
748 { USB_VPI(USB_VENDOR_YAMAHA, 0x101d, 0) }, /* CLP-175 */
749 { USB_VPI(USB_VENDOR_YAMAHA, 0x101e, 0) }, /* PSR-K1 */
750 { USB_VPI(USB_VENDOR_YAMAHA, 0x101f, 0) }, /* EZ-J24 */
751 { USB_VPI(USB_VENDOR_YAMAHA, 0x1020, 0) }, /* EZ-250i */
755 { USB_VPI(USB_VENDOR_YAMAHA, 0x1024, 0) }, /* CVP-301 */
756 { USB_VPI(USB_VENDOR_YAMAHA, 0x1025, 0) }, /* CVP-303 */
757 { USB_VPI(USB_VENDOR_YAMAHA, 0x1026, 0) }, /* CVP-305 */
758 { USB_VPI(USB_VENDOR_YAMAHA, 0x1027, 0) }, /* CVP-307 */
759 { USB_VPI(USB_VENDOR_YAMAHA, 0x1028, 0) }, /* CVP-309 */
760 { USB_VPI(USB_VENDOR_YAMAHA, 0x1029, 0) }, /* CVP-309GP */
761 { USB_VPI(USB_VENDOR_YAMAHA, 0x102a, 0) }, /* PSR-1500 */
762 { USB_VPI(USB_VENDOR_YAMAHA, 0x102b, 0) }, /* PSR-3000 */
763 { USB_VPI(USB_VENDOR_YAMAHA, 0x102e, 0) }, /* ELS-01/01C */
764 { USB_VPI(USB_VENDOR_YAMAHA, 0x1030, 0) }, /* PSR-295/293 */
765 { USB_VPI(USB_VENDOR_YAMAHA, 0x1031, 0) }, /* DGX-205/203 */
766 { USB_VPI(USB_VENDOR_YAMAHA, 0x1032, 0) }, /* DGX-305 */
767 { USB_VPI(USB_VENDOR_YAMAHA, 0x1033, 0) }, /* DGX-505 */
803 { USB_VPI(USB_VENDOR_YAMAHA, 0x2000, 0) }, /* DGP-7 */
804 { USB_VPI(USB_VENDOR_YAMAHA, 0x2001, 0) }, /* DGP-5 */
812 { USB_VPI(USB_VENDOR_YAMAHA, 0x5005, 0) }, /* ACU16-C */
813 { USB_VPI(USB_VENDOR_YAMAHA, 0x5006, 0) }, /* NHB32-C */
842 if (dev == sc->sc_child[i].pcm_device) in uaudio_get_child_index_by_dev()
855 if ((sc->sc_play_chan + i) == ch || in uaudio_get_child_index_by_chan()
856 (sc->sc_rec_chan + i) == ch) in uaudio_get_child_index_by_chan()
859 panic("uaudio_get_child_index_by_chan: Invalid chan: %p\n", ch); in uaudio_get_child_index_by_chan()
868 if (uaa->usb_mode != USB_MODE_HOST) in uaudio_probe()
871 /* lookup non-standard device(s) */ in uaudio_probe()
878 if (uaa->info.bInterfaceClass != UICLASS_AUDIO) { in uaudio_probe()
879 if (uaa->info.bInterfaceClass != UICLASS_VENDOR || in uaudio_probe()
886 if (uaa->info.bInterfaceSubClass == UISUBCLASS_AUDIOCONTROL) { in uaudio_probe()
895 if (uaa->info.bInterfaceSubClass == UISUBCLASS_MIDISTREAM) { in uaudio_probe()
929 if (usbd_req_set_report(sc->sc_udev, NULL, in uaudio_set_spdif_cm6206()
931 sc->sc_mixer_iface_index, UHID_OUTPUT_REPORT, 0) != 0) { in uaudio_set_spdif_cm6206()
950 iface = usbd_get_iface(sc->sc_udev, iface_index); in uaudio_force_power_save()
951 if (iface == NULL || iface->idesc == NULL) in uaudio_force_power_save()
955 if (iface->alt_index == 0) { in uaudio_force_power_save()
957 err = usbd_req_set_alt_interface_no(sc->sc_udev, NULL, iface_index, in uaudio_force_power_save()
958 iface->idesc->bAlternateSetting); in uaudio_force_power_save()
960 err = usbd_set_alt_interface_index(sc->sc_udev, iface_index, 0); in uaudio_force_power_save()
974 sc->sc_udev = uaa->device; in uaudio_attach()
975 sc->sc_mixer_iface_index = uaa->info.bIfaceIndex; in uaudio_attach()
976 sc->sc_mixer_iface_no = uaa->info.bIfaceNum; in uaudio_attach()
977 sc->sc_config_msg[0].hdr.pm_callback = &uaudio_configure_msg; in uaudio_attach()
978 sc->sc_config_msg[0].sc = sc; in uaudio_attach()
979 sc->sc_config_msg[1].hdr.pm_callback = &uaudio_configure_msg; in uaudio_attach()
980 sc->sc_config_msg[1].sc = sc; in uaudio_attach()
983 sc->sc_uq_audio_swap_lr = 1; in uaudio_attach()
986 sc->sc_uq_au_inp_async = 1; in uaudio_attach()
989 sc->sc_uq_au_no_xu = 1; in uaudio_attach()
992 sc->sc_uq_bad_adc = 1; in uaudio_attach()
995 sc->sc_uq_au_vendor_class = 1; in uaudio_attach()
999 sc->sc_set_spdif_fn = uaudio_set_spdif_cm6206; in uaudio_attach()
1001 sc->sc_set_spdif_fn = uaudio_set_spdif_dummy; in uaudio_attach()
1007 id = usbd_get_interface_descriptor(uaa->iface); in uaudio_attach()
1010 uaudio_mixer_fill_info(sc, uaa->device, id); in uaudio_attach()
1013 uaudio_chan_fill_info(sc, uaa->device); in uaudio_attach()
1016 sc->sc_audio_rev >> 8, in uaudio_attach()
1017 sc->sc_audio_rev & 0xff); in uaudio_attach()
1019 if (sc->sc_mixer_count == 0) { in uaudio_attach()
1020 if (uaa->info.idVendor == USB_VENDOR_MAUDIO && in uaudio_attach()
1021 (uaa->info.idProduct == USB_PRODUCT_MAUDIO_FASTTRACKULTRA || in uaudio_attach()
1022 uaa->info.idProduct == USB_PRODUCT_MAUDIO_FASTTRACKULTRA8R)) { in uaudio_attach()
1029 sc->sc_mixer_count); in uaudio_attach()
1034 if (sc->sc_play_chan[i].num_alt <= 0) in uaudio_attach()
1040 * re-enumeration loop: in uaudio_attach()
1043 sc->sc_play_chan[i].usb_alt[0].iface_index); in uaudio_attach()
1049 for (x = 0; x != sc->sc_play_chan[i].num_alt; x++) { in uaudio_attach()
1052 sc->sc_play_chan[i].usb_alt[x].sample_rate, in uaudio_attach()
1053 sc->sc_play_chan[i].usb_alt[x].channels, in uaudio_attach()
1054 sc->sc_play_chan[i].usb_alt[x].p_fmt->description, in uaudio_attach()
1065 if (sc->sc_rec_chan[i].num_alt <= 0) in uaudio_attach()
1071 * re-enumeration loop: in uaudio_attach()
1074 sc->sc_rec_chan[i].usb_alt[0].iface_index); in uaudio_attach()
1080 for (x = 0; x != sc->sc_rec_chan[i].num_alt; x++) { in uaudio_attach()
1083 sc->sc_rec_chan[i].usb_alt[x].sample_rate, in uaudio_attach()
1084 sc->sc_rec_chan[i].usb_alt[x].channels, in uaudio_attach()
1085 sc->sc_rec_chan[i].usb_alt[x].p_fmt->description, in uaudio_attach()
1093 if (sc->sc_midi_chan.valid == 0) { in uaudio_attach()
1096 sc->sc_midi_chan.iface_index = in uaudio_attach()
1097 (uint8_t)uaa->driver_info; in uaudio_attach()
1098 sc->sc_midi_chan.iface_alt_index = 0; in uaudio_attach()
1099 sc->sc_midi_chan.valid = 1; in uaudio_attach()
1103 if (sc->sc_midi_chan.valid) { in uaudio_attach()
1116 sc->sc_sndcard_func.func = SCF_PCM; in uaudio_attach()
1123 if (sc->sc_play_chan[i].num_alt <= 0 && in uaudio_attach()
1124 sc->sc_rec_chan[i].num_alt <= 0 && in uaudio_attach()
1125 sc->sc_child[i].mix_info == 0) in uaudio_attach()
1127 sc->sc_child[i].pcm_device = in uaudio_attach()
1130 if (sc->sc_child[i].pcm_device == NULL) { in uaudio_attach()
1134 device_set_ivars(sc->sc_child[i].pcm_device, in uaudio_attach()
1135 &sc->sc_sndcard_func); in uaudio_attach()
1152 if (sc->sc_set_spdif_fn(sc, in uaudio_attach()
1178 if (sc->sc_uq_audio_swap_lr) { in uaudio_attach_sub()
1182 if (sc->sc_play_chan[i].num_alt > 0 && in uaudio_attach_sub()
1183 (sc->sc_child[i].mix_info & SOUND_MASK_PCM) == 0) { in uaudio_attach_sub()
1192 if (sc->sc_pcm_bitperfect) { in uaudio_attach_sub()
1198 sc->sc_child[i].mixer_init = 1; in uaudio_attach_sub()
1203 usb_get_manufacturer(sc->sc_udev), in uaudio_attach_sub()
1204 usb_get_product(sc->sc_udev)); in uaudio_attach_sub()
1213 if (sc->sc_play_chan[i].num_alt > 0) { in uaudio_attach_sub()
1214 sc->sc_play_chan[i].priv_sc = sc; in uaudio_attach_sub()
1216 &sc->sc_play_chan[i]); in uaudio_attach_sub()
1219 if (sc->sc_rec_chan[i].num_alt > 0) { in uaudio_attach_sub()
1220 sc->sc_rec_chan[i].priv_sc = sc; in uaudio_attach_sub()
1222 &sc->sc_rec_chan[i]); in uaudio_attach_sub()
1226 sc->sc_child[i].pcm_registered = 1; in uaudio_attach_sub()
1232 "feedback_rate", CTLFLAG_RD, &sc->sc_play_chan[i].feedback_rate, in uaudio_attach_sub()
1249 if (sc->sc_child[i].pcm_registered) { in uaudio_detach_sub()
1251 } else if (sc->sc_child[i].mixer_init) { in uaudio_detach_sub()
1269 usb_proc_explore_lock(sc->sc_udev); in uaudio_detach()
1271 sc->sc_play_chan[i].operation = CHAN_OP_DRAIN; in uaudio_detach()
1272 sc->sc_rec_chan[i].operation = CHAN_OP_DRAIN; in uaudio_detach()
1274 usb_proc_explore_mwait(sc->sc_udev, in uaudio_detach()
1275 &sc->sc_config_msg[0], &sc->sc_config_msg[1]); in uaudio_detach()
1276 usb_proc_explore_unlock(sc->sc_udev); in uaudio_detach()
1279 usbd_transfer_unsetup(sc->sc_play_chan[i].xfer, UAUDIO_NCHANBUFS + 1); in uaudio_detach()
1280 usbd_transfer_unsetup(sc->sc_rec_chan[i].xfer, UAUDIO_NCHANBUFS + 1); in uaudio_detach()
1296 (void) sc->sc_set_spdif_fn(sc, 0); in uaudio_detach()
1305 /* Isochronous transfer interval is 2^(bInterval - 1) frames. */ in uaudio_get_interval_frames()
1306 if (ed->bInterval >= 1 && ed->bInterval <= 16) in uaudio_get_interval_frames()
1307 frames = (1 << (ed->bInterval - 1)); in uaudio_get_interval_frames()
1318 uint32_t fps = usbd_get_isoc_fps(sc->sc_udev); in uaudio_get_buffer_ms()
1336 struct uaudio_chan_alt *chan_alt = &ch->usb_alt[alt]; in uaudio_get_buffer_size()
1339 int_frames = uaudio_get_interval_frames(chan_alt->p_ed1); in uaudio_get_buffer_size()
1341 ms = uaudio_get_buffer_ms(ch->priv_sc, int_frames); in uaudio_get_buffer_size()
1342 buf_size = chan_alt->sample_size * in uaudio_get_buffer_size()
1343 howmany(chan_alt->sample_rate * ms, 1000); in uaudio_get_buffer_size()
1350 struct uaudio_chan_alt *chan_alt = &ch->usb_alt[alt]; in uaudio_max_buffer_size()
1353 buf_size = chan_alt->sample_size * in uaudio_max_buffer_size()
1354 howmany(chan_alt->sample_rate * UAUDIO_BUFFER_MS_MAX, 1000); in uaudio_max_buffer_size()
1360 struct uaudio_chan *chan, int dir) in uaudio_configure_msg_sub() argument
1371 if (chan->num_alt <= 0) in uaudio_configure_msg_sub()
1376 usb_proc_explore_lock(sc->sc_udev); in uaudio_configure_msg_sub()
1377 operation = chan->operation; in uaudio_configure_msg_sub()
1381 chan->operation = CHAN_OP_NONE; in uaudio_configure_msg_sub()
1386 usb_proc_explore_unlock(sc->sc_udev); in uaudio_configure_msg_sub()
1391 usbd_transfer_unsetup(chan->xfer, UAUDIO_NCHANBUFS + 1); in uaudio_configure_msg_sub()
1393 mtx_lock(chan->pcm_mtx); in uaudio_configure_msg_sub()
1394 chan->cur_alt = CHAN_MAX_ALT; in uaudio_configure_msg_sub()
1395 mtx_unlock(chan->pcm_mtx); in uaudio_configure_msg_sub()
1402 err = usbd_set_alt_interface_index(sc->sc_udev, chan->iface_index, 0); in uaudio_configure_msg_sub()
1411 usbd_transfer_unsetup(chan->xfer, UAUDIO_NCHANBUFS + 1); in uaudio_configure_msg_sub()
1418 mtx_lock(chan->pcm_mtx); in uaudio_configure_msg_sub()
1419 next_alt = chan->set_alt; in uaudio_configure_msg_sub()
1420 mtx_unlock(chan->pcm_mtx); in uaudio_configure_msg_sub()
1422 chan_alt = chan->usb_alt + next_alt; in uaudio_configure_msg_sub()
1424 err = usbd_set_alt_interface_index(sc->sc_udev, in uaudio_configure_msg_sub()
1425 chan_alt->iface_index, chan_alt->iface_alt_index); in uaudio_configure_msg_sub()
1437 if (sc->sc_audio_rev >= UAUDIO_VERSION_30) { in uaudio_configure_msg_sub()
1439 } else if (sc->sc_audio_rev >= UAUDIO_VERSION_20) { in uaudio_configure_msg_sub()
1444 if (!(sc->sc_mixer_clocks.bit_output[x / 8] & in uaudio_configure_msg_sub()
1449 if (!(sc->sc_mixer_clocks.bit_input[x / 8] & in uaudio_configure_msg_sub()
1455 if (uaudio20_set_speed(sc->sc_udev, in uaudio_configure_msg_sub()
1456 sc->sc_mixer_iface_no, x, chan_alt->sample_rate)) { in uaudio_configure_msg_sub()
1465 } else if (chan_alt->p_sed.v1->bmAttributes & UA_SED_FREQ_CONTROL) { in uaudio_configure_msg_sub()
1466 if (uaudio_set_speed(sc->sc_udev, in uaudio_configure_msg_sub()
1467 chan_alt->p_ed1->bEndpointAddress, chan_alt->sample_rate)) { in uaudio_configure_msg_sub()
1476 if (usbd_transfer_setup(sc->sc_udev, &chan_alt->iface_index, chan->xfer, in uaudio_configure_msg_sub()
1477 chan_alt->usb_cfg, UAUDIO_NCHANBUFS + 1, chan, chan->pcm_mtx)) { in uaudio_configure_msg_sub()
1482 fps = usbd_get_isoc_fps(sc->sc_udev); in uaudio_configure_msg_sub()
1492 fps_shift = usbd_xfer_get_fps_shift(chan->xfer[0]); in uaudio_configure_msg_sub()
1499 chan->bytes_per_frame[0] = in uaudio_configure_msg_sub()
1500 ((chan_alt->sample_rate / fps) * chan_alt->sample_size); in uaudio_configure_msg_sub()
1501 chan->bytes_per_frame[1] = howmany(chan_alt->sample_rate, fps) * in uaudio_configure_msg_sub()
1502 chan_alt->sample_size; in uaudio_configure_msg_sub()
1505 chan->frames_per_second = fps; in uaudio_configure_msg_sub()
1506 chan->sample_rem = chan_alt->sample_rate % fps; in uaudio_configure_msg_sub()
1507 chan->sample_curr = 0; in uaudio_configure_msg_sub()
1510 buf_size = (chan->bytes_per_frame[1] * frames); in uaudio_configure_msg_sub()
1512 if (buf_size > (chan->end - chan->start)) { in uaudio_configure_msg_sub()
1517 chan->intr_frames = frames; in uaudio_configure_msg_sub()
1519 DPRINTF("fps=%d sample_rem=%d\n", (int)fps, (int)chan->sample_rem); in uaudio_configure_msg_sub()
1521 if (chan->intr_frames == 0) { in uaudio_configure_msg_sub()
1530 mtx_lock(chan->pcm_mtx); in uaudio_configure_msg_sub()
1531 chan->cur_alt = next_alt; in uaudio_configure_msg_sub()
1532 usbd_transfer_start(chan->xfer[0]); in uaudio_configure_msg_sub()
1533 usbd_transfer_start(chan->xfer[1]); in uaudio_configure_msg_sub()
1534 mtx_unlock(chan->pcm_mtx); in uaudio_configure_msg_sub()
1537 usbd_transfer_unsetup(chan->xfer, UAUDIO_NCHANBUFS + 1); in uaudio_configure_msg_sub()
1539 mtx_lock(chan->pcm_mtx); in uaudio_configure_msg_sub()
1540 chan->cur_alt = CHAN_MAX_ALT; in uaudio_configure_msg_sub()
1541 mtx_unlock(chan->pcm_mtx); in uaudio_configure_msg_sub()
1547 struct uaudio_softc *sc = ((struct uaudio_configure_msg *)pm)->sc; in uaudio_configure_msg()
1550 usb_proc_explore_unlock(sc->sc_udev); in uaudio_configure_msg()
1552 uaudio_configure_msg_sub(sc, &sc->sc_play_chan[i], PCMDIR_PLAY); in uaudio_configure_msg()
1553 uaudio_configure_msg_sub(sc, &sc->sc_rec_chan[i], PCMDIR_REC); in uaudio_configure_msg()
1555 usb_proc_explore_lock(sc->sc_udev); in uaudio_configure_msg()
1559 * AS - Audio Stream - routines
1571 ed, ed->bLength, ed->bDescriptorType, in uaudio_chan_dump_ep_desc()
1572 ed->bEndpointAddress, ed->bmAttributes, in uaudio_chan_dump_ep_desc()
1573 UGETW(ed->wMaxPacketSize), ed->bInterval, in uaudio_chan_dump_ep_desc()
1574 UEP_HAS_REFRESH(ed) ? ed->bRefresh : 0, in uaudio_chan_dump_ep_desc()
1575 UEP_HAS_SYNCADDR(ed) ? ed->bSynchAddress : 0); in uaudio_chan_dump_ep_desc()
1582 * The following is a workaround for broken no-name USB audio devices
1595 mps = UGETW(ep->wMaxPacketSize); in uaudio_record_fix_fs()
1612 USETW(ep->wMaxPacketSize, xps); in uaudio_record_fix_fs()
1654 rates = MIN(UAUDIO20_MAX_RATES, (255 - 2) / 12); in uaudio20_check_rate()
1686 actlen = (actlen - 2) / 12; in uaudio20_check_rate()
1712 (((rate - min) % res) == 0)) { in uaudio20_check_rate()
1720 uaudio_get_chan(struct uaudio_softc *sc, struct uaudio_chan *chan, in uaudio_get_chan() argument
1725 for (i = 0; i != UAUDIO_MAX_CHILD; i++, chan++) { in uaudio_get_chan()
1726 if (chan->num_alt == 0) { in uaudio_get_chan()
1727 chan->iface_index = iface_index; in uaudio_get_chan()
1728 return (chan); in uaudio_get_chan()
1729 } else if (chan->iface_index == iface_index) in uaudio_get_chan()
1730 return (chan); in uaudio_get_chan()
1749 struct uaudio_chan *chan; in uaudio_chan_fill_info_sub() local
1765 if ((desc->bDescriptorType == UDESC_INTERFACE) && in uaudio_chan_fill_info_sub()
1766 (desc->bLength >= sizeof(*id))) { in uaudio_chan_fill_info_sub()
1769 if (id->bInterfaceNumber != lastidx) { in uaudio_chan_fill_info_sub()
1770 lastidx = id->bInterfaceNumber; in uaudio_chan_fill_info_sub()
1778 if ((!(sc->sc_hid.flags & UAUDIO_HID_VALID)) && in uaudio_chan_fill_info_sub()
1779 (id->bInterfaceClass == UICLASS_HID) && in uaudio_chan_fill_info_sub()
1780 (id->bInterfaceSubClass == 0) && in uaudio_chan_fill_info_sub()
1781 (id->bInterfaceProtocol == 0) && in uaudio_chan_fill_info_sub()
1786 sc->sc_hid.flags |= UAUDIO_HID_VALID; in uaudio_chan_fill_info_sub()
1787 sc->sc_hid.iface_index = curidx; in uaudio_chan_fill_info_sub()
1791 ((id->bInterfaceClass == UICLASS_AUDIO) || in uaudio_chan_fill_info_sub()
1792 ((id->bInterfaceClass == UICLASS_VENDOR) && in uaudio_chan_fill_info_sub()
1793 (sc->sc_uq_au_vendor_class != 0))); in uaudio_chan_fill_info_sub()
1796 (id->bInterfaceSubClass == UISUBCLASS_AUDIOSTREAM)) { in uaudio_chan_fill_info_sub()
1803 (id->bInterfaceSubClass == UISUBCLASS_MIDISTREAM)) { in uaudio_chan_fill_info_sub()
1809 if ((sc->sc_midi_chan.valid == 0) && in uaudio_chan_fill_info_sub()
1811 sc->sc_midi_chan.iface_index = curidx; in uaudio_chan_fill_info_sub()
1812 sc->sc_midi_chan.iface_alt_index = alt_index; in uaudio_chan_fill_info_sub()
1813 sc->sc_midi_chan.valid = 1; in uaudio_chan_fill_info_sub()
1829 if (alt_index == 0 && curidx != sc->sc_mixer_iface_index && in uaudio_chan_fill_info_sub()
1830 (id->bInterfaceClass == UICLASS_AUDIO || audio_if != 0 || in uaudio_chan_fill_info_sub()
1832 usbd_set_parent_iface(sc->sc_udev, curidx, in uaudio_chan_fill_info_sub()
1833 sc->sc_mixer_iface_index); in uaudio_chan_fill_info_sub()
1840 (desc->bDescriptorType == UDESC_CS_INTERFACE) && in uaudio_chan_fill_info_sub()
1841 (desc->bDescriptorSubtype == UDESCSUB_AC_HEADER) && in uaudio_chan_fill_info_sub()
1842 (desc->bLength >= sizeof(*acdp))) { in uaudio_chan_fill_info_sub()
1844 audio_rev = UGETW(acdp->bcdADC); in uaudio_chan_fill_info_sub()
1850 if (msid->bLength >= sizeof(*msid) && in uaudio_chan_fill_info_sub()
1851 msid->bDescriptorType == UDESC_CS_ENDPOINT && in uaudio_chan_fill_info_sub()
1852 msid->bDescriptorSubtype == MS_GENERAL && in uaudio_chan_fill_info_sub()
1853 msid->bNumEmbMIDIJack > sc->sc_midi_chan.max_emb_jack) { in uaudio_chan_fill_info_sub()
1854 sc->sc_midi_chan.max_emb_jack = msid->bNumEmbMIDIJack; in uaudio_chan_fill_info_sub()
1864 if ((acdp != NULL || sc->sc_uq_au_vendor_class != 0) && in uaudio_chan_fill_info_sub()
1865 (desc->bDescriptorType == UDESC_CS_INTERFACE) && in uaudio_chan_fill_info_sub()
1866 (desc->bDescriptorSubtype == AS_GENERAL) && in uaudio_chan_fill_info_sub()
1871 if (desc->bLength >= sizeof(*asid.v2)) { in uaudio_chan_fill_info_sub()
1875 if (desc->bLength >= sizeof(*asid.v1)) { in uaudio_chan_fill_info_sub()
1880 if ((acdp != NULL || sc->sc_uq_au_vendor_class != 0) && in uaudio_chan_fill_info_sub()
1881 (desc->bDescriptorType == UDESC_CS_INTERFACE) && in uaudio_chan_fill_info_sub()
1882 (desc->bDescriptorSubtype == FORMAT_TYPE) && in uaudio_chan_fill_info_sub()
1887 if (desc->bLength >= sizeof(*asf1d.v2)) in uaudio_chan_fill_info_sub()
1890 if (desc->bLength >= sizeof(*asf1d.v1)) { in uaudio_chan_fill_info_sub()
1893 if (asf1d.v1->bFormatType != FORMAT_TYPE_I) { in uaudio_chan_fill_info_sub()
1895 asf1d.v1->bFormatType); in uaudio_chan_fill_info_sub()
1899 if (desc->bLength < (sizeof(*asf1d.v1) + in uaudio_chan_fill_info_sub()
1900 ((asf1d.v1->bSamFreqType == 0) ? 6 : in uaudio_chan_fill_info_sub()
1901 (asf1d.v1->bSamFreqType * 3)))) { in uaudio_chan_fill_info_sub()
1910 if ((desc->bDescriptorType == UDESC_ENDPOINT) && in uaudio_chan_fill_info_sub()
1911 (desc->bLength >= UEP_MINSIZE) && in uaudio_chan_fill_info_sub()
1914 if (UE_GET_XFERTYPE(ed1->bmAttributes) != UE_ISOCHRONOUS) { in uaudio_chan_fill_info_sub()
1919 if ((acdp != NULL || sc->sc_uq_au_vendor_class != 0) && in uaudio_chan_fill_info_sub()
1920 (desc->bDescriptorType == UDESC_CS_ENDPOINT) && in uaudio_chan_fill_info_sub()
1921 (desc->bDescriptorSubtype == AS_GENERAL) && in uaudio_chan_fill_info_sub()
1926 if (desc->bLength >= sizeof(*sed.v2)) in uaudio_chan_fill_info_sub()
1929 if (desc->bLength >= sizeof(*sed.v1)) in uaudio_chan_fill_info_sub()
1939 ep_dir = UE_GET_DIR(ed1->bEndpointAddress); in uaudio_chan_fill_info_sub()
1948 dwFormat = UGETDW(asid.v2->bmFormats); in uaudio_chan_fill_info_sub()
1949 bChannels = asid.v2->bNrChannels; in uaudio_chan_fill_info_sub()
1950 bBitResolution = asf1d.v2->bSubslotSize * 8; in uaudio_chan_fill_info_sub()
1959 p_fmt->wFormat != 0; p_fmt++) { in uaudio_chan_fill_info_sub()
1960 if ((p_fmt->wFormat & dwFormat) && in uaudio_chan_fill_info_sub()
1961 (p_fmt->bPrecision == bBitResolution)) in uaudio_chan_fill_info_sub()
1965 if (p_fmt->wFormat == 0) { in uaudio_chan_fill_info_sub()
1972 if (!(sc->sc_mixer_clocks.bit_output[x / 8] & in uaudio_chan_fill_info_sub()
1977 if (!(sc->sc_mixer_clocks.bit_input[x / 8] & in uaudio_chan_fill_info_sub()
1986 sc->sc_mixer_iface_no, x, rate)) { in uaudio_chan_fill_info_sub()
1995 wFormat = UGETW(asid.v1->wFormatTag); in uaudio_chan_fill_info_sub()
1996 bChannels = UAUDIO_MAX_CHAN(asf1d.v1->bNrChannels); in uaudio_chan_fill_info_sub()
1997 bBitResolution = asf1d.v1->bSubFrameSize * 8; in uaudio_chan_fill_info_sub()
1999 if (asf1d.v1->bSamFreqType == 0) { in uaudio_chan_fill_info_sub()
2000 DPRINTFN(16, "Sample rate: %d-%dHz\n", in uaudio_chan_fill_info_sub()
2008 for (x = 0; x < asf1d.v1->bSamFreqType; x++) { in uaudio_chan_fill_info_sub()
2020 p_fmt->wFormat != 0; p_fmt++) { in uaudio_chan_fill_info_sub()
2021 if ((p_fmt->wFormat == wFormat) && in uaudio_chan_fill_info_sub()
2022 (p_fmt->bPrecision == bBitResolution)) in uaudio_chan_fill_info_sub()
2025 if (p_fmt->wFormat == 0) { in uaudio_chan_fill_info_sub()
2037 chan = uaudio_get_chan(sc, (ep_dir == UE_DIR_OUT) ? &sc->sc_play_chan[0] : in uaudio_chan_fill_info_sub()
2038 &sc->sc_rec_chan[0], curidx); in uaudio_chan_fill_info_sub()
2039 if (chan == NULL) { in uaudio_chan_fill_info_sub()
2048 if (chan->num_alt == CHAN_MAX_ALT) { in uaudio_chan_fill_info_sub()
2052 chan->set_alt = 0; in uaudio_chan_fill_info_sub()
2053 chan->cur_alt = CHAN_MAX_ALT; in uaudio_chan_fill_info_sub()
2055 chan_alt = &chan->usb_alt[chan->num_alt++]; in uaudio_chan_fill_info_sub()
2061 "bits = %d, format = %s, ep 0x%02x, chan %p\n", rate, channels, in uaudio_chan_fill_info_sub()
2062 bit_resolution, p_fmt->description, ed1->bEndpointAddress, chan); in uaudio_chan_fill_info_sub()
2064 chan_alt->sample_rate = rate; in uaudio_chan_fill_info_sub()
2065 chan_alt->p_asf1d = asf1d; in uaudio_chan_fill_info_sub()
2066 chan_alt->p_ed1 = ed1; in uaudio_chan_fill_info_sub()
2067 chan_alt->p_fmt = p_fmt; in uaudio_chan_fill_info_sub()
2068 chan_alt->p_sed = sed; in uaudio_chan_fill_info_sub()
2069 chan_alt->iface_index = curidx; in uaudio_chan_fill_info_sub()
2070 chan_alt->iface_alt_index = alt_index; in uaudio_chan_fill_info_sub()
2073 chan_alt->usb_cfg = uaudio_cfg_record; in uaudio_chan_fill_info_sub()
2075 chan_alt->usb_cfg = uaudio_cfg_play; in uaudio_chan_fill_info_sub()
2077 chan_alt->sample_size = (UAUDIO_MAX_CHAN(channels) * in uaudio_chan_fill_info_sub()
2078 p_fmt->bPrecision) / 8; in uaudio_chan_fill_info_sub()
2079 chan_alt->channels = channels; in uaudio_chan_fill_info_sub()
2084 chan_alt->sample_size * (rate / 1000), in uaudio_chan_fill_info_sub()
2085 chan_alt->sample_size * (rate / 4000)); in uaudio_chan_fill_info_sub()
2090 format = chan_alt->p_fmt->freebsd_fmt; in uaudio_chan_fill_info_sub()
2093 format = SND_FORMAT(format, chan_alt->channels, 0); in uaudio_chan_fill_info_sub()
2095 switch (chan_alt->channels) { in uaudio_chan_fill_info_sub()
2113 chan->num_alt--; in uaudio_chan_fill_info_sub()
2116 if (chan->num_alt > 1) { in uaudio_chan_fill_info_sub()
2118 if (chan->pcm_format[0] != format) { in uaudio_chan_fill_info_sub()
2120 chan->num_alt--; in uaudio_chan_fill_info_sub()
2124 if (rate == chan->usb_alt[chan->num_alt - 2].sample_rate) { in uaudio_chan_fill_info_sub()
2126 chan->num_alt--; in uaudio_chan_fill_info_sub()
2130 chan->pcm_cap.fmtlist = chan->pcm_format; in uaudio_chan_fill_info_sub()
2131 chan->pcm_cap.fmtlist[0] = format; in uaudio_chan_fill_info_sub()
2134 if (chan_alt->channels > UAUDIO_MATRIX_MAX) in uaudio_chan_fill_info_sub()
2135 sc->sc_pcm_bitperfect = 1; in uaudio_chan_fill_info_sub()
2137 if (rate < chan->pcm_cap.minspeed || chan->pcm_cap.minspeed == 0) in uaudio_chan_fill_info_sub()
2138 chan->pcm_cap.minspeed = rate; in uaudio_chan_fill_info_sub()
2139 if (rate > chan->pcm_cap.maxspeed || chan->pcm_cap.maxspeed == 0) in uaudio_chan_fill_info_sub()
2140 chan->pcm_cap.maxspeed = rate; in uaudio_chan_fill_info_sub()
2185 bits -= (bits % 8); in uaudio_chan_fill_info()
2198 * with HIGH-speed split transactions we in uaudio_chan_fill_info()
2199 * disable surround setups on FULL-speed USB in uaudio_chan_fill_info()
2216 for (x = channels; x; x--) { in uaudio_chan_fill_info()
2217 for (y = bits; y; y -= 8) { in uaudio_chan_fill_info()
2234 y -= 8; in uaudio_chan_fill_info()
2242 x--; in uaudio_chan_fill_info()
2261 i = uaudio_get_child_index_by_chan(ch->priv_sc, ch); in uaudio_chan_play_sync_callback()
2285 /* auto-detect SYNC format */ in uaudio_chan_play_sync_callback()
2297 sample_rate = ch->usb_alt[ch->cur_alt].sample_rate; in uaudio_chan_play_sync_callback()
2300 while (temp < (sample_rate - (sample_rate / 4))) in uaudio_chan_play_sync_callback()
2313 if (ch->priv_sc->sc_rec_chan[i].num_alt == 0) { in uaudio_chan_play_sync_callback()
2324 ch->jitter_curr = temp - sample_rate; in uaudio_chan_play_sync_callback()
2325 if (ch->jitter_curr > jitter_max) in uaudio_chan_play_sync_callback()
2326 ch->jitter_curr = jitter_max; in uaudio_chan_play_sync_callback()
2327 else if (ch->jitter_curr < -jitter_max) in uaudio_chan_play_sync_callback()
2328 ch->jitter_curr = -jitter_max; in uaudio_chan_play_sync_callback()
2330 ch->feedback_rate = temp; in uaudio_chan_play_sync_callback()
2339 if (ch->priv_sc->sc_rec_chan[i].num_alt != 0 && in uaudio_chan_play_sync_callback()
2355 uint8_t attr = ch->usb_alt[alt].p_ed1->bmAttributes; in uaudio_chan_is_async()
2375 if (ch->running == 0 || ch->start == ch->end) { in uaudio_chan_play_callback()
2380 i = uaudio_get_child_index_by_chan(ch->priv_sc, ch); in uaudio_chan_play_callback()
2383 ch_rec = ch->priv_sc->sc_rec_chan + i; in uaudio_chan_play_callback()
2385 if (ch_rec->num_alt == 0) in uaudio_chan_play_callback()
2402 ch_rec->jitter_curr = 0; in uaudio_chan_play_callback()
2403 ch_rec->jitter_rem = 0; in uaudio_chan_play_callback()
2407 ch->jitter_curr = 0; in uaudio_chan_play_callback()
2408 ch->jitter_rem = 0; in uaudio_chan_play_callback()
2416 chn_intr(ch->pcm_ch); in uaudio_chan_play_callback()
2423 uaudio_chan_is_async(ch, ch->cur_alt) != 0) { in uaudio_chan_play_callback()
2424 uint32_t rec_alt = ch_rec->cur_alt; in uaudio_chan_play_callback()
2425 if (rec_alt < ch_rec->num_alt) { in uaudio_chan_play_callback()
2437 tx_jitter = ch->usb_alt[ch->cur_alt].sample_rate; in uaudio_chan_play_callback()
2438 tx_jitter = (tx_jitter * ch_rec->jitter_curr) + in uaudio_chan_play_callback()
2439 ch->jitter_rem; in uaudio_chan_play_callback()
2442 ch_rec->jitter_curr = 0; in uaudio_chan_play_callback()
2443 ch_rec->jitter_rem = 0; in uaudio_chan_play_callback()
2446 rx_rate = ch_rec->usb_alt[rec_alt].sample_rate; in uaudio_chan_play_callback()
2447 ch->jitter_curr += tx_jitter / rx_rate; in uaudio_chan_play_callback()
2448 ch->jitter_rem = tx_jitter % rx_rate; in uaudio_chan_play_callback()
2453 ch->intr_counter += ch->intr_frames; in uaudio_chan_play_callback()
2454 if (ch->intr_counter >= ch->frames_per_second) { in uaudio_chan_play_callback()
2455 ch->intr_counter -= ch->frames_per_second; in uaudio_chan_play_callback()
2456 usbd_transfer_start(ch->xfer[UAUDIO_NCHANBUFS]); in uaudio_chan_play_callback()
2461 if (ch->bytes_per_frame[1] > mfl) { in uaudio_chan_play_callback()
2464 ch->bytes_per_frame[1], in uaudio_chan_play_callback()
2469 blockcount = ch->intr_frames; in uaudio_chan_play_callback()
2475 sample_size = ch->usb_alt[ch->cur_alt].sample_size; in uaudio_chan_play_callback()
2484 ch->sample_curr += ch->sample_rem; in uaudio_chan_play_callback()
2485 if (ch->sample_curr >= ch->frames_per_second) { in uaudio_chan_play_callback()
2486 ch->sample_curr -= ch->frames_per_second; in uaudio_chan_play_callback()
2487 frame_len = ch->bytes_per_frame[1]; in uaudio_chan_play_callback()
2489 frame_len = ch->bytes_per_frame[0]; in uaudio_chan_play_callback()
2493 if (ch->jitter_curr > 0 && in uaudio_chan_play_callback()
2496 ch->jitter_curr--; in uaudio_chan_play_callback()
2498 } else if (ch->jitter_curr < 0 && in uaudio_chan_play_callback()
2501 ch->jitter_curr++; in uaudio_chan_play_callback()
2502 frame_len -= sample_size; in uaudio_chan_play_callback()
2514 n = (ch->end - ch->cur); in uaudio_chan_play_callback()
2518 usbd_copy_in(pc, offset, ch->cur, n); in uaudio_chan_play_callback()
2520 total -= n; in uaudio_chan_play_callback()
2521 ch->cur += n; in uaudio_chan_play_callback()
2524 if (ch->cur >= ch->end) in uaudio_chan_play_callback()
2525 ch->cur = ch->start; in uaudio_chan_play_callback()
2558 if (ch->start == ch->end) { in uaudio_chan_record_callback()
2573 ch->sample_curr += (ch->sample_rem * ch->intr_frames); in uaudio_chan_record_callback()
2576 expected_bytes = (ch->intr_frames * ch->bytes_per_frame[0]) + in uaudio_chan_record_callback()
2577 ((ch->sample_curr / ch->frames_per_second) * in uaudio_chan_record_callback()
2578 (ch->bytes_per_frame[1] - ch->bytes_per_frame[0])); in uaudio_chan_record_callback()
2581 ch->sample_curr %= ch->frames_per_second; in uaudio_chan_record_callback()
2584 sample_size = ch->usb_alt[ch->cur_alt].sample_size; in uaudio_chan_record_callback()
2592 len = len - (len % sample_size); in uaudio_chan_record_callback()
2595 expected_bytes -= len; in uaudio_chan_record_callback()
2598 if (ch->running == 0 || ch->cur_alt != ch->set_alt) in uaudio_chan_record_callback()
2603 m = (ch->end - ch->cur); in uaudio_chan_record_callback()
2608 usbd_copy_out(pc, offset1, ch->cur, m); in uaudio_chan_record_callback()
2610 len -= m; in uaudio_chan_record_callback()
2612 ch->cur += m; in uaudio_chan_record_callback()
2614 if (ch->cur >= ch->end) in uaudio_chan_record_callback()
2615 ch->cur = ch->start; in uaudio_chan_record_callback()
2622 ch->jitter_curr -= (expected_bytes / sample_size); in uaudio_chan_record_callback()
2625 nframes = 2 * ch->intr_frames; in uaudio_chan_record_callback()
2628 if (ch->jitter_curr < -nframes) in uaudio_chan_record_callback()
2629 ch->jitter_curr = -nframes; in uaudio_chan_record_callback()
2630 else if (ch->jitter_curr > nframes) in uaudio_chan_record_callback()
2631 ch->jitter_curr = nframes; in uaudio_chan_record_callback()
2634 actlen, ch->jitter_curr); in uaudio_chan_record_callback()
2636 if (ch->running != 0) in uaudio_chan_record_callback()
2637 chn_intr(ch->pcm_ch); in uaudio_chan_record_callback()
2641 nframes = ch->intr_frames; in uaudio_chan_record_callback()
2666 ch->pcm_ch = c; in uaudio_chan_init()
2667 ch->pcm_mtx = c->lock; in uaudio_chan_init()
2672 for (x = 0; x != ch->num_alt; x++) { in uaudio_chan_init()
2683 ch->buf = malloc(buf_size, M_DEVBUF, M_WAITOK | M_ZERO); in uaudio_chan_init()
2684 if (sndbuf_setup(b, ch->buf, buf_size) != 0) in uaudio_chan_init()
2687 ch->start = ch->buf; in uaudio_chan_init()
2688 ch->end = ch->buf + buf_size; in uaudio_chan_init()
2689 ch->cur = ch->buf; in uaudio_chan_init()
2690 ch->pcm_buf = b; in uaudio_chan_init()
2691 ch->max_buf = buf_size; in uaudio_chan_init()
2693 if (ch->pcm_mtx == NULL) { in uaudio_chan_init()
2707 if (ch->buf != NULL) { in uaudio_chan_free()
2708 free(ch->buf, M_DEVBUF); in uaudio_chan_free()
2709 ch->buf = NULL; in uaudio_chan_free()
2711 usbd_transfer_unsetup(ch->xfer, UAUDIO_NCHANBUFS + 1); in uaudio_chan_free()
2713 ch->num_alt = 0; in uaudio_chan_free()
2721 uint32_t temp = 2 * uaudio_get_buffer_size(ch, ch->set_alt); in uaudio_chan_set_param_blocksize()
2722 sndbuf_setup(ch->pcm_buf, ch->buf, temp); in uaudio_chan_set_param_blocksize()
2739 sc = ch->priv_sc; in uaudio_chan_set_param_speed()
2741 for (x = 0, y = 1; y < ch->num_alt; y++) { in uaudio_chan_set_param_speed()
2743 if ((ch->usb_alt[x].sample_rate < speed && in uaudio_chan_set_param_speed()
2744 ch->usb_alt[x].sample_rate < ch->usb_alt[y].sample_rate) || in uaudio_chan_set_param_speed()
2745 (speed <= ch->usb_alt[y].sample_rate && in uaudio_chan_set_param_speed()
2746 ch->usb_alt[y].sample_rate < ch->usb_alt[x].sample_rate)) in uaudio_chan_set_param_speed()
2750 usb_proc_explore_lock(sc->sc_udev); in uaudio_chan_set_param_speed()
2751 ch->set_alt = x; in uaudio_chan_set_param_speed()
2752 usb_proc_explore_unlock(sc->sc_udev); in uaudio_chan_set_param_speed()
2756 return (ch->usb_alt[x].sample_rate); in uaudio_chan_set_param_speed()
2762 return (ch->cur - ch->start); in uaudio_chan_getptr()
2768 return (&ch->pcm_cap); in uaudio_chan_getcaps()
2798 .offset = { 1, 0, -1, -1, -1, -1, -1, -1, -1,
2799 -1, -1, -1, -1, -1, -1, -1, -1, -1 }
2807 sc = ch->priv_sc; in uaudio_chan_getmatrix()
2809 if (sc != NULL && sc->sc_uq_audio_swap_lr != 0 && in uaudio_chan_getmatrix()
2826 struct uaudio_softc *sc = ch->priv_sc; in uaudio_chan_reconfigure()
2829 if (ch->operation == CHAN_OP_DRAIN) in uaudio_chan_reconfigure()
2833 ch->operation = operation; in uaudio_chan_reconfigure()
2840 (void)usb_proc_explore_msignal(sc->sc_udev, in uaudio_chan_reconfigure()
2841 &sc->sc_config_msg[0], &sc->sc_config_msg[1]); in uaudio_chan_reconfigure()
2847 return (pchan->num_alt > 0 && in uaudio_chan_need_both()
2848 pchan->running != 0 && in uaudio_chan_need_both()
2849 uaudio_chan_is_async(pchan, pchan->set_alt) != 0 && in uaudio_chan_need_both()
2850 rchan->num_alt > 0 && in uaudio_chan_need_both()
2851 rchan->running == 0); in uaudio_chan_need_both()
2857 return (pchan->num_alt > 0 && in uaudio_chan_need_none()
2858 pchan->running == 0 && in uaudio_chan_need_none()
2859 rchan->num_alt > 0 && in uaudio_chan_need_none()
2860 rchan->running == 0); in uaudio_chan_need_none()
2866 struct uaudio_softc *sc = ch->priv_sc; in uaudio_chan_start()
2870 usb_proc_explore_lock(sc->sc_udev); in uaudio_chan_start()
2873 if (ch->running == 0) { in uaudio_chan_start()
2877 temp = 2 * uaudio_get_buffer_size(ch, ch->set_alt); in uaudio_chan_start()
2880 ch->running = 1; in uaudio_chan_start()
2883 ch->start = ch->buf; in uaudio_chan_start()
2884 ch->end = ch->buf + temp; in uaudio_chan_start()
2885 ch->cur = ch->buf; in uaudio_chan_start()
2888 &sc->sc_play_chan[i], in uaudio_chan_start()
2889 &sc->sc_rec_chan[i])) { in uaudio_chan_start()
2894 uaudio_chan_reconfigure(&sc->sc_rec_chan[i], CHAN_OP_START); in uaudio_chan_start()
2895 uaudio_chan_reconfigure(&sc->sc_play_chan[i], CHAN_OP_START); in uaudio_chan_start()
2902 usb_proc_explore_unlock(sc->sc_udev); in uaudio_chan_start()
2908 struct uaudio_softc *sc = ch->priv_sc; in uaudio_chan_stop()
2912 usb_proc_explore_lock(sc->sc_udev); in uaudio_chan_stop()
2915 if (ch->running != 0) { in uaudio_chan_stop()
2917 ch->running = 0; in uaudio_chan_stop()
2920 &sc->sc_play_chan[i], in uaudio_chan_stop()
2921 &sc->sc_rec_chan[i])) { in uaudio_chan_stop()
2927 &sc->sc_play_chan[i], in uaudio_chan_stop()
2928 &sc->sc_rec_chan[i])) { in uaudio_chan_stop()
2933 uaudio_chan_reconfigure(&sc->sc_rec_chan[i], CHAN_OP_STOP); in uaudio_chan_stop()
2934 uaudio_chan_reconfigure(&sc->sc_play_chan[i], CHAN_OP_STOP); in uaudio_chan_stop()
2941 usb_proc_explore_unlock(sc->sc_udev); in uaudio_chan_stop()
2945 * AC - Audio Controller - routines
2956 int chan = 0; in uaudio_mixer_sysctl_handler() local
2958 sc = (struct uaudio_softc *)oidp->oid_arg1; in uaudio_mixer_sysctl_handler()
2959 hint = oidp->oid_arg2; in uaudio_mixer_sysctl_handler()
2961 if (sc->sc_child[0].mixer_lock == NULL) in uaudio_mixer_sysctl_handler()
2966 mtx_lock(sc->sc_child[0].mixer_lock); in uaudio_mixer_sysctl_handler()
2967 for (pmc = sc->sc_mixer_root; pmc != NULL; pmc = pmc->next) { in uaudio_mixer_sysctl_handler()
2968 for (chan = 0; chan != (int)pmc->nchan; chan++) { in uaudio_mixer_sysctl_handler()
2969 if (pmc->wValue[chan] != -1 && in uaudio_mixer_sysctl_handler()
2970 pmc->wValue[chan] == hint) { in uaudio_mixer_sysctl_handler()
2971 temp = pmc->wData[chan]; in uaudio_mixer_sysctl_handler()
2977 mtx_unlock(sc->sc_child[0].mixer_lock); in uaudio_mixer_sysctl_handler()
2980 if (error != 0 || req->newptr == NULL) in uaudio_mixer_sysctl_handler()
2985 mtx_lock(sc->sc_child[0].mixer_lock); in uaudio_mixer_sysctl_handler()
2987 temp >= pmc->minval && in uaudio_mixer_sysctl_handler()
2988 temp <= pmc->maxval) { in uaudio_mixer_sysctl_handler()
2989 pmc->wData[chan] = temp; in uaudio_mixer_sysctl_handler()
2990 pmc->update[(chan / 8)] |= (1 << (chan % 8)); in uaudio_mixer_sysctl_handler()
2993 usbd_transfer_start(sc->sc_mixer_xfer[0]); in uaudio_mixer_sysctl_handler()
2995 mtx_unlock(sc->sc_child[0].mixer_lock); in uaudio_mixer_sysctl_handler()
3005 while ((p_mc = sc->sc_mixer_root) != NULL) { in uaudio_mixer_ctl_free()
3006 sc->sc_mixer_root = p_mc->next; in uaudio_mixer_ctl_free()
3019 int chan; in uaudio_mixer_register_sysctl() local
3032 for (n = 0, pmc = sc->sc_mixer_root; pmc != NULL; in uaudio_mixer_register_sysctl()
3033 pmc = pmc->next, n++) { in uaudio_mixer_register_sysctl()
3034 for (chan = 0; chan < pmc->nchan; chan++) { in uaudio_mixer_register_sysctl()
3035 if (pmc->nchan > 1) { in uaudio_mixer_register_sysctl()
3037 pmc->name, n, chan); in uaudio_mixer_register_sysctl()
3040 pmc->name, n); in uaudio_mixer_register_sysctl()
3055 sc, pmc->wValue[chan], in uaudio_mixer_register_sysctl()
3060 OID_AUTO, "min", CTLFLAG_RD, 0, pmc->minval, in uaudio_mixer_register_sysctl()
3065 OID_AUTO, "max", CTLFLAG_RD, 0, pmc->maxval, in uaudio_mixer_register_sysctl()
3070 OID_AUTO, "desc", CTLFLAG_RD, pmc->desc, 0, in uaudio_mixer_register_sysctl()
3076 /* M-Audio FastTrack Ultra Mixer Description */
3085 MIX(sc).wIndex = MAKE_WORD(6, sc->sc_mixer_iface_no); in uaudio_mixer_controls_create_ftu()
3089 MIX(sc).name = "effect"; in uaudio_mixer_controls_create_ftu()
3099 MIX(sc).wIndex = MAKE_WORD(5, sc->sc_mixer_iface_no); in uaudio_mixer_controls_create_ftu()
3106 MIX(sc).name = "mix_rec"; in uaudio_mixer_controls_create_ftu()
3111 "AIn%d - Out%d Record Volume", chy + 1, chx + 1); in uaudio_mixer_controls_create_ftu()
3118 MIX(sc).name = "mix_play"; in uaudio_mixer_controls_create_ftu()
3123 "DIn%d - Out%d Playback Volume", chy + 1, chx + 1); in uaudio_mixer_controls_create_ftu()
3130 MIX(sc).wIndex = MAKE_WORD(6, sc->sc_mixer_iface_no); in uaudio_mixer_controls_create_ftu()
3134 MIX(sc).name = "effect_vol"; in uaudio_mixer_controls_create_ftu()
3146 MIX(sc).wIndex = MAKE_WORD(6, sc->sc_mixer_iface_no); in uaudio_mixer_controls_create_ftu()
3150 MIX(sc).name = "effect_dur"; in uaudio_mixer_controls_create_ftu()
3162 MIX(sc).wIndex = MAKE_WORD(6, sc->sc_mixer_iface_no); in uaudio_mixer_controls_create_ftu()
3166 MIX(sc).name = "effect_fb"; in uaudio_mixer_controls_create_ftu()
3178 MIX(sc).wIndex = MAKE_WORD(7, sc->sc_mixer_iface_no); in uaudio_mixer_controls_create_ftu()
3183 MIX(sc).name = "effect_ret"; in uaudio_mixer_controls_create_ftu()
3193 MIX(sc).wIndex = MAKE_WORD(5, sc->sc_mixer_iface_no); in uaudio_mixer_controls_create_ftu()
3199 MIX(sc).name = "effect_send"; in uaudio_mixer_controls_create_ftu()
3210 MIX(sc).name = "effect_send"; in uaudio_mixer_controls_create_ftu()
3224 int chan; in uaudio_mixer_reload_all() local
3226 if (sc->sc_child[0].mixer_lock == NULL) in uaudio_mixer_reload_all()
3229 mtx_lock(sc->sc_child[0].mixer_lock); in uaudio_mixer_reload_all()
3230 for (pmc = sc->sc_mixer_root; pmc != NULL; pmc = pmc->next) { in uaudio_mixer_reload_all()
3231 /* use reset defaults for non-oss controlled settings */ in uaudio_mixer_reload_all()
3232 if (pmc->ctl == SOUND_MIXER_NRDEVICES) in uaudio_mixer_reload_all()
3234 for (chan = 0; chan < pmc->nchan; chan++) in uaudio_mixer_reload_all()
3235 pmc->update[chan / 8] |= (1 << (chan % 8)); in uaudio_mixer_reload_all()
3237 usbd_transfer_start(sc->sc_mixer_xfer[0]); in uaudio_mixer_reload_all()
3240 usbd_transfer_start(sc->sc_hid.xfer[0]); in uaudio_mixer_reload_all()
3241 mtx_unlock(sc->sc_child[0].mixer_lock); in uaudio_mixer_reload_all()
3252 p_mc_new->next = sc->sc_mixer_root; in uaudio_mixer_add_ctl_sub()
3253 sc->sc_mixer_root = p_mc_new; in uaudio_mixer_add_ctl_sub()
3254 sc->sc_mixer_count++; in uaudio_mixer_add_ctl_sub()
3257 for (ch = 0; ch < p_mc_new->nchan; ch++) { in uaudio_mixer_add_ctl_sub()
3258 switch (p_mc_new->val_default) { in uaudio_mixer_add_ctl_sub()
3261 p_mc_new->wData[ch] = (p_mc_new->maxval + p_mc_new->minval) / 2; in uaudio_mixer_add_ctl_sub()
3265 p_mc_new->wData[ch] = p_mc_new->maxval; in uaudio_mixer_add_ctl_sub()
3269 p_mc_new->wData[ch] = p_mc_new->minval; in uaudio_mixer_add_ctl_sub()
3280 DPRINTF("adding %d\n", mc->ctl); in uaudio_mixer_add_ctl()
3282 if (mc->type == MIX_ON_OFF) { in uaudio_mixer_add_ctl()
3283 mc->minval = 0; in uaudio_mixer_add_ctl()
3284 mc->maxval = 1; in uaudio_mixer_add_ctl()
3285 } else if (mc->type == MIX_SELECTOR) { in uaudio_mixer_add_ctl()
3289 mc->minval = uaudio_mixer_get(sc->sc_udev, in uaudio_mixer_add_ctl()
3290 sc->sc_audio_rev, GET_MIN, mc); in uaudio_mixer_add_ctl()
3291 mc->maxval = uaudio_mixer_get(sc->sc_udev, in uaudio_mixer_add_ctl()
3292 sc->sc_audio_rev, GET_MAX, mc); in uaudio_mixer_add_ctl()
3296 if (mc->maxval < mc->minval) { in uaudio_mixer_add_ctl()
3297 res = mc->maxval; in uaudio_mixer_add_ctl()
3298 mc->maxval = mc->minval; in uaudio_mixer_add_ctl()
3299 mc->minval = res; in uaudio_mixer_add_ctl()
3303 mc->mul = mc->maxval - mc->minval; in uaudio_mixer_add_ctl()
3304 if (mc->mul == 0) in uaudio_mixer_add_ctl()
3305 mc->mul = 1; in uaudio_mixer_add_ctl()
3308 res = uaudio_mixer_get(sc->sc_udev, in uaudio_mixer_add_ctl()
3309 sc->sc_audio_rev, GET_RES, mc); in uaudio_mixer_add_ctl()
3320 for (i = 0; i < mc->nchan; i++) { in uaudio_mixer_add_ctl()
3321 DPRINTF("[mix] wValue=%04x\n", mc->wValue[0]); in uaudio_mixer_add_ctl()
3325 mc->wIndex, mc->type, mc->ctl, in uaudio_mixer_add_ctl()
3326 mc->minval, mc->maxval); in uaudio_mixer_add_ctl()
3350 d0->bUnitId, d0->bNrInPins); in uaudio_mixer_add_mixer()
3355 for (i = 0; i < d0->bNrInPins; i++) { in uaudio_mixer_add_mixer()
3357 d0->baSourceId[i], iot).bNrChannels; in uaudio_mixer_add_mixer()
3360 d1 = (const void *)(d0->baSourceId + d0->bNrInPins); in uaudio_mixer_add_mixer()
3364 ochs = d1->bNrChannels; in uaudio_mixer_add_mixer()
3370 MIX(sc).wIndex = MAKE_WORD(d0->bUnitId, sc->sc_mixer_iface_no); in uaudio_mixer_add_mixer()
3376 for (p = i = 0; i < d0->bNrInPins; i++) { in uaudio_mixer_add_mixer()
3378 d0->baSourceId[i], iot).bNrChannels; in uaudio_mixer_add_mixer()
3384 if (BIT_TEST(d1->bmControls, bno)) in uaudio_mixer_add_mixer()
3391 /* repeat bit-scan */ in uaudio_mixer_add_mixer()
3397 if (BIT_TEST(d1->bmControls, bno)) in uaudio_mixer_add_mixer()
3427 d0->bUnitId, d0->bNrInPins); in uaudio20_mixer_add_mixer()
3432 for (i = 0; i < d0->bNrInPins; i++) { in uaudio20_mixer_add_mixer()
3434 d0->baSourceId[i], iot).bNrChannels; in uaudio20_mixer_add_mixer()
3437 d1 = (const void *)(d0->baSourceId + d0->bNrInPins); in uaudio20_mixer_add_mixer()
3441 ochs = d1->bNrChannels; in uaudio20_mixer_add_mixer()
3447 MIX(sc).wIndex = MAKE_WORD(d0->bUnitId, sc->sc_mixer_iface_no); in uaudio20_mixer_add_mixer()
3453 for (p = i = 0; i < d0->bNrInPins; i++) { in uaudio20_mixer_add_mixer()
3455 d0->baSourceId[i], iot).bNrChannels; in uaudio20_mixer_add_mixer()
3461 if (BIT_TEST(d1->bmControls, bno)) in uaudio20_mixer_add_mixer()
3468 /* repeat bit-scan */ in uaudio20_mixer_add_mixer()
3474 if (BIT_TEST(d1->bmControls, bno)) in uaudio20_mixer_add_mixer()
3545 d->bUnitId, d->bNrInPins); in uaudio_mixer_add_selector()
3547 if (d->bNrInPins == 0) in uaudio_mixer_add_selector()
3552 MIX(sc).wIndex = MAKE_WORD(d->bUnitId, sc->sc_mixer_iface_no); in uaudio_mixer_add_selector()
3558 MIX(sc).maxval = d->bNrInPins; in uaudio_mixer_add_selector()
3559 MIX(sc).name = "selector"; in uaudio_mixer_add_selector()
3561 i = d->baSourceId[d->bNrInPins]; in uaudio_mixer_add_selector()
3563 usbd_req_get_string_any(sc->sc_udev, NULL, in uaudio_mixer_add_selector()
3571 MIX(sc).mul = MIX(sc).maxval - MIX(sc).minval; in uaudio_mixer_add_selector()
3575 uaudio_mixer_determine_class(&iot[d->baSourceId[i]]); in uaudio_mixer_add_selector()
3592 d->bUnitId, d->bNrInPins); in uaudio20_mixer_add_selector()
3594 if (d->bNrInPins == 0) in uaudio20_mixer_add_selector()
3599 MIX(sc).wIndex = MAKE_WORD(d->bUnitId, sc->sc_mixer_iface_no); in uaudio20_mixer_add_selector()
3605 MIX(sc).maxval = d->bNrInPins; in uaudio20_mixer_add_selector()
3606 MIX(sc).name = "selector"; in uaudio20_mixer_add_selector()
3608 i = d->baSourceId[d->bNrInPins]; in uaudio20_mixer_add_selector()
3610 usbd_req_get_string_any(sc->sc_udev, NULL, in uaudio20_mixer_add_selector()
3618 MIX(sc).mul = MIX(sc).maxval - MIX(sc).minval; in uaudio20_mixer_add_selector()
3622 uaudio20_mixer_determine_class(&iot[d->baSourceId[i]]); in uaudio20_mixer_add_selector()
3636 uint32_t offset = (i * d->bControlSize); in uaudio_mixer_feature_get_bmaControls()
3638 if (d->bControlSize > 0) { in uaudio_mixer_feature_get_bmaControls()
3639 temp |= d->bmaControls[offset]; in uaudio_mixer_feature_get_bmaControls()
3640 if (d->bControlSize > 1) { in uaudio_mixer_feature_get_bmaControls()
3641 temp |= d->bmaControls[offset + 1] << 8; in uaudio_mixer_feature_get_bmaControls()
3642 if (d->bControlSize > 2) { in uaudio_mixer_feature_get_bmaControls()
3643 temp |= d->bmaControls[offset + 2] << 16; in uaudio_mixer_feature_get_bmaControls()
3644 if (d->bControlSize > 3) { in uaudio_mixer_feature_get_bmaControls()
3645 temp |= d->bmaControls[offset + 3] << 24; in uaudio_mixer_feature_get_bmaControls()
3663 uint8_t chan; in uaudio_mixer_add_feature() local
3667 if (d->bControlSize == 0) in uaudio_mixer_add_feature()
3672 nchan = (d->bLength - 7) / d->bControlSize; in uaudio_mixer_add_feature()
3681 for (chan = 1; chan < nchan; chan++) { in uaudio_mixer_add_feature()
3682 DPRINTFN(10, "chan=%d mask=%x\n", in uaudio_mixer_add_feature()
3683 chan, uaudio_mixer_feature_get_bmaControls(d, chan)); in uaudio_mixer_add_feature()
3685 cmask |= uaudio_mixer_feature_get_bmaControls(d, chan); in uaudio_mixer_add_feature()
3688 MIX(sc).wIndex = MAKE_WORD(d->bUnitId, sc->sc_mixer_iface_no); in uaudio_mixer_add_feature()
3690 i = d->bmaControls[nchan * d->bControlSize]; in uaudio_mixer_add_feature()
3692 usbd_req_get_string_any(sc->sc_udev, NULL, in uaudio_mixer_add_feature()
3710 MIX(sc).nchan = nchan - 1; in uaudio_mixer_add_feature()
3713 MIX(sc).wValue[i - 1] = MAKE_WORD(ctl, i); in uaudio_mixer_add_feature()
3715 MIX(sc).wValue[i - 1] = -1; in uaudio_mixer_add_feature()
3727 MIX(sc).name = "mute"; in uaudio_mixer_add_feature()
3733 MIX(sc).name = "vol"; in uaudio_mixer_add_feature()
3739 MIX(sc).name = "bass"; in uaudio_mixer_add_feature()
3745 MIX(sc).name = "mid"; in uaudio_mixer_add_feature()
3751 MIX(sc).name = "treble"; in uaudio_mixer_add_feature()
3760 MIX(sc).name = "agc"; in uaudio_mixer_add_feature()
3766 MIX(sc).name = "delay"; in uaudio_mixer_add_feature()
3772 MIX(sc).name = "boost"; in uaudio_mixer_add_feature()
3778 MIX(sc).name = "loudness"; in uaudio_mixer_add_feature()
3801 uint8_t chan; in uaudio20_mixer_add_feature() local
3805 if (UGETDW(d->bmaControls[0]) == 0) in uaudio20_mixer_add_feature()
3810 nchan = (d->bLength - 6) / 4; in uaudio20_mixer_add_feature()
3811 mmask = UGETDW(d->bmaControls[0]); in uaudio20_mixer_add_feature()
3819 for (chan = 1; chan < nchan; chan++) in uaudio20_mixer_add_feature()
3820 cmask |= UGETDW(d->bmaControls[chan]); in uaudio20_mixer_add_feature()
3822 MIX(sc).wIndex = MAKE_WORD(d->bUnitId, sc->sc_mixer_iface_no); in uaudio20_mixer_add_feature()
3824 i = d->bmaControls[nchan][0]; in uaudio20_mixer_add_feature()
3826 usbd_req_get_string_any(sc->sc_udev, NULL, in uaudio20_mixer_add_feature()
3841 MIX(sc).name = "mute"; in uaudio20_mixer_add_feature()
3847 MIX(sc).name = "vol"; in uaudio20_mixer_add_feature()
3853 MIX(sc).name = "bass"; in uaudio20_mixer_add_feature()
3859 MIX(sc).name = "mid"; in uaudio20_mixer_add_feature()
3865 MIX(sc).name = "treble"; in uaudio20_mixer_add_feature()
3871 MIX(sc).name = "agc"; in uaudio20_mixer_add_feature()
3877 MIX(sc).name = "delay"; in uaudio20_mixer_add_feature()
3883 MIX(sc).name = "boost"; in uaudio20_mixer_add_feature()
3889 MIX(sc).name = "loudness"; in uaudio20_mixer_add_feature()
3895 MIX(sc).name = "igain"; in uaudio20_mixer_add_feature()
3901 MIX(sc).name = "igainpad"; in uaudio20_mixer_add_feature()
3912 MIX(sc).nchan = nchan - 1; in uaudio20_mixer_add_feature()
3914 if ((UGETDW(d->bmaControls[i]) & ctl) == ctl) in uaudio20_mixer_add_feature()
3915 MIX(sc).wValue[i - 1] = MAKE_WORD(what, i); in uaudio20_mixer_add_feature()
3917 MIX(sc).wValue[i - 1] = -1; in uaudio20_mixer_add_feature()
3934 (const void *)(d0->baSourceId + d0->bNrInPins); in uaudio_mixer_add_processing_updown()
3936 (const void *)(d1->bmControls + d1->bControlSize); in uaudio_mixer_add_processing_updown()
3942 if (uaudio_mixer_verify_desc(d0, sizeof(*ud) + (2 * ud->bNrModes)) in uaudio_mixer_add_processing_updown()
3947 d0->bUnitId, ud->bNrModes); in uaudio_mixer_add_processing_updown()
3949 if (!(d1->bmControls[0] & UA_PROC_MASK(UD_MODE_SELECT_CONTROL))) { in uaudio_mixer_add_processing_updown()
3955 MIX(sc).wIndex = MAKE_WORD(d0->bUnitId, sc->sc_mixer_iface_no); in uaudio_mixer_add_processing_updown()
3960 for (i = 0; i < ud->bNrModes; i++) { in uaudio_mixer_add_processing_updown()
3961 DPRINTFN(3, "i=%d bm=0x%x\n", i, UGETW(ud->waModes[i])); in uaudio_mixer_add_processing_updown()
3974 (const void *)(d0->baSourceId + d0->bNrInPins); in uaudio_mixer_add_processing()
3979 ptype = UGETW(d0->wProcessType); in uaudio_mixer_add_processing()
3982 "bNrInPins=%d\n", ptype, d0->bUnitId, d0->bNrInPins); in uaudio_mixer_add_processing()
3984 if (d1->bControlSize == 0) { in uaudio_mixer_add_processing()
3987 if (d1->bmControls[0] & UA_PROC_ENABLE_MASK) { in uaudio_mixer_add_processing()
3988 MIX(sc).wIndex = MAKE_WORD(d0->bUnitId, sc->sc_mixer_iface_no); in uaudio_mixer_add_processing()
4006 d0->bUnitId, ptype); in uaudio_mixer_add_processing()
4017 (const void *)(d0->baSourceId + d0->bNrInPins); in uaudio_mixer_add_extension()
4020 d0->bUnitId, d0->bNrInPins); in uaudio_mixer_add_extension()
4022 if (sc->sc_uq_au_no_xu) { in uaudio_mixer_add_extension()
4025 if (d1->bControlSize == 0) { in uaudio_mixer_add_extension()
4028 if (d1->bmControls[0] & UA_EXT_ENABLE_MASK) { in uaudio_mixer_add_extension()
4031 MIX(sc).wIndex = MAKE_WORD(d0->bUnitId, sc->sc_mixer_iface_no); in uaudio_mixer_add_extension()
4063 if (u.desc->bDescriptorType != UDESC_CS_INTERFACE) { in uaudio_mixer_verify_desc()
4066 switch (u.desc->bDescriptorSubtype) { in uaudio_mixer_verify_desc()
4078 if (u.desc->bLength < len) { in uaudio_mixer_verify_desc()
4081 len += u.mu->bNrInPins; in uaudio_mixer_verify_desc()
4083 if (u.desc->bLength < len) { in uaudio_mixer_verify_desc()
4086 d1 = (const void *)(u.mu->baSourceId + u.mu->bNrInPins); in uaudio_mixer_verify_desc()
4094 if (u.desc->bLength < len) { in uaudio_mixer_verify_desc()
4097 len += u.su->bNrInPins + 1; in uaudio_mixer_verify_desc()
4103 if (u.desc->bLength < len) in uaudio_mixer_verify_desc()
4106 len += u.fu->bControlSize; in uaudio_mixer_verify_desc()
4112 if (u.desc->bLength < len) { in uaudio_mixer_verify_desc()
4115 len += u.pu->bNrInPins; in uaudio_mixer_verify_desc()
4117 if (u.desc->bLength < len) { in uaudio_mixer_verify_desc()
4120 u1 = (const void *)(u.pu->baSourceId + u.pu->bNrInPins); in uaudio_mixer_verify_desc()
4124 if (u.desc->bLength < len) { in uaudio_mixer_verify_desc()
4127 len += u1->bControlSize; in uaudio_mixer_verify_desc()
4134 if (u.desc->bLength < len) { in uaudio_mixer_verify_desc()
4137 len += u.eu->bNrInPins; in uaudio_mixer_verify_desc()
4139 if (u.desc->bLength < len) { in uaudio_mixer_verify_desc()
4142 e1 = (const void *)(u.eu->baSourceId + u.eu->bNrInPins); in uaudio_mixer_verify_desc()
4146 if (u.desc->bLength < len) { in uaudio_mixer_verify_desc()
4149 len += e1->bControlSize; in uaudio_mixer_verify_desc()
4156 if (u.desc->bLength < len) { in uaudio_mixer_verify_desc()
4165 u.desc->bDescriptorType, in uaudio_mixer_verify_desc()
4166 u.desc->bDescriptorSubtype, in uaudio_mixer_verify_desc()
4167 u.desc->bLength, len); in uaudio_mixer_verify_desc()
4201 if (u.desc->bDescriptorType != UDESC_CS_INTERFACE) in uaudio20_mixer_verify_desc()
4204 switch (u.desc->bDescriptorSubtype) { in uaudio20_mixer_verify_desc()
4216 if (u.desc->bLength < len) in uaudio20_mixer_verify_desc()
4218 len += u.mu->bNrInPins; in uaudio20_mixer_verify_desc()
4220 if (u.desc->bLength < len) in uaudio20_mixer_verify_desc()
4223 d1 = (const void *)(u.mu->baSourceId + u.mu->bNrInPins); in uaudio20_mixer_verify_desc()
4225 len += sizeof(*d1) + d1->bNrChannels; in uaudio20_mixer_verify_desc()
4231 if (u.desc->bLength < len) in uaudio20_mixer_verify_desc()
4234 len += u.su->bNrInPins + 1; in uaudio20_mixer_verify_desc()
4248 if (u.desc->bLength < len) in uaudio20_mixer_verify_desc()
4251 len += u.pu->bNrInPins; in uaudio20_mixer_verify_desc()
4253 if (u.desc->bLength < len) in uaudio20_mixer_verify_desc()
4256 u1 = (const void *)(u.pu->baSourceId + u.pu->bNrInPins); in uaudio20_mixer_verify_desc()
4264 if (u.desc->bLength < len) in uaudio20_mixer_verify_desc()
4267 len += u.eu->bNrInPins; in uaudio20_mixer_verify_desc()
4269 if (u.desc->bLength < len) in uaudio20_mixer_verify_desc()
4272 e1 = (const void *)(u.eu->baSourceId + u.eu->bNrInPins); in uaudio20_mixer_verify_desc()
4284 if (u.desc->bLength < len) in uaudio20_mixer_verify_desc()
4287 len += u.csel->bNrInPins; in uaudio20_mixer_verify_desc()
4289 if (u.desc->bLength < len) in uaudio20_mixer_verify_desc()
4292 c1 = (const void *)(u.csel->baCSourceId + u.csel->bNrInPins); in uaudio20_mixer_verify_desc()
4309 if (u.desc->bLength < len) in uaudio20_mixer_verify_desc()
4318 u.desc->bDescriptorType, in uaudio20_mixer_verify_desc()
4319 u.desc->bDescriptorSubtype, in uaudio20_mixer_verify_desc()
4320 u.desc->bLength, len); in uaudio20_mixer_verify_desc()
4337 switch (dp->bDescriptorSubtype) { in uaudio_mixer_get_cluster()
4339 r.bNrChannels = iot[id].u.it_v1->bNrChannels; in uaudio_mixer_get_cluster()
4340 r.wChannelConfig[0] = iot[id].u.it_v1->wChannelConfig[0]; in uaudio_mixer_get_cluster()
4341 r.wChannelConfig[1] = iot[id].u.it_v1->wChannelConfig[1]; in uaudio_mixer_get_cluster()
4342 r.iChannelNames = iot[id].u.it_v1->iChannelNames; in uaudio_mixer_get_cluster()
4346 id = iot[id].u.ot_v1->bSourceId; in uaudio_mixer_get_cluster()
4351 &iot[id].u.mu_v1->baSourceId[ in uaudio_mixer_get_cluster()
4352 iot[id].u.mu_v1->bNrInPins]; in uaudio_mixer_get_cluster()
4356 if (iot[id].u.su_v1->bNrInPins > 0) { in uaudio_mixer_get_cluster()
4358 id = iot[id].u.su_v1->baSourceId[0]; in uaudio_mixer_get_cluster()
4363 id = iot[id].u.fu_v1->bSourceId; in uaudio_mixer_get_cluster()
4368 &iot[id].u.pu_v1->baSourceId[ in uaudio_mixer_get_cluster()
4369 iot[id].u.pu_v1->bNrInPins]); in uaudio_mixer_get_cluster()
4374 &iot[id].u.eu_v1->baSourceId[ in uaudio_mixer_get_cluster()
4375 iot[id].u.eu_v1->bNrInPins]); in uaudio_mixer_get_cluster()
4401 switch (dp->bDescriptorSubtype) { in uaudio20_mixer_get_cluster()
4403 r.bNrChannels = iot[id].u.it_v2->bNrChannels; in uaudio20_mixer_get_cluster()
4404 r.bmChannelConfig[0] = iot[id].u.it_v2->bmChannelConfig[0]; in uaudio20_mixer_get_cluster()
4405 r.bmChannelConfig[1] = iot[id].u.it_v2->bmChannelConfig[1]; in uaudio20_mixer_get_cluster()
4406 r.bmChannelConfig[2] = iot[id].u.it_v2->bmChannelConfig[2]; in uaudio20_mixer_get_cluster()
4407 r.bmChannelConfig[3] = iot[id].u.it_v2->bmChannelConfig[3]; in uaudio20_mixer_get_cluster()
4408 r.iChannelNames = iot[id].u.it_v2->iTerminal; in uaudio20_mixer_get_cluster()
4412 id = iot[id].u.ot_v2->bSourceId; in uaudio20_mixer_get_cluster()
4417 &iot[id].u.mu_v2->baSourceId[ in uaudio20_mixer_get_cluster()
4418 iot[id].u.mu_v2->bNrInPins]; in uaudio20_mixer_get_cluster()
4422 if (iot[id].u.su_v2->bNrInPins > 0) { in uaudio20_mixer_get_cluster()
4424 id = iot[id].u.su_v2->baSourceId[0]; in uaudio20_mixer_get_cluster()
4429 id = iot[id].u.ru_v2->bSourceId; in uaudio20_mixer_get_cluster()
4433 id = iot[id].u.ef_v2->bSourceId; in uaudio20_mixer_get_cluster()
4437 id = iot[id].u.fu_v2->bSourceId; in uaudio20_mixer_get_cluster()
4442 &iot[id].u.pu_v2->baSourceId[ in uaudio20_mixer_get_cluster()
4443 iot[id].u.pu_v2->bNrInPins]); in uaudio20_mixer_get_cluster()
4448 &iot[id].u.eu_v2->baSourceId[ in uaudio20_mixer_get_cluster()
4449 iot[id].u.eu_v2->bNrInPins]); in uaudio20_mixer_get_cluster()
4471 if (!n--) in uaudio_mixer_foreach_input()
4472 n = iot->usr.id_max; in uaudio_mixer_foreach_input()
4475 if (iot->usr.bit_input[n / 8] & (1 << (n % 8))) in uaudio_mixer_foreach_input()
4490 if (!n--) in uaudio_mixer_foreach_output()
4491 n = iot->usr.id_max; in uaudio_mixer_foreach_output()
4494 if (iot->usr.bit_output[n / 8] & (1 << (n % 8))) in uaudio_mixer_foreach_output()
4546 if (uat->terminal_type == 0) { in uaudio_mixer_get_feature_by_tt()
4561 } else if (uat->terminal_type == terminal_type) { in uaudio_mixer_get_feature_by_tt()
4562 retval = uat->feature; in uaudio_mixer_get_feature_by_tt()
4584 ptr = iot->root + i; in uaudio_mixer_determine_class()
4585 temp = UGETW(ptr->u.it_v1->wTerminalType); in uaudio_mixer_determine_class()
4596 ptr = iot->root + i; in uaudio_mixer_determine_class()
4597 temp = UGETW(ptr->u.ot_v1->wTerminalType); in uaudio_mixer_determine_class()
4643 ptr = iot->root + i; in uaudio20_mixer_determine_class()
4644 temp = UGETW(ptr->u.it_v2->wTerminalType); in uaudio20_mixer_determine_class()
4655 ptr = iot->root + i; in uaudio20_mixer_determine_class()
4656 temp = UGETW(ptr->u.ot_v2->wTerminalType); in uaudio20_mixer_determine_class()
4695 const uint8_t max = sizeof(src->bit_output) / sizeof(src->bit_output[0]); in uaudio_mixer_merge_outputs()
4699 dst->bit_output[x] |= src->bit_output[x]; in uaudio_mixer_merge_outputs()
4714 if (info->recurse_level == UAUDIO_RECURSE_LIMIT) { in uaudio_mixer_find_inputs_sub()
4719 info->recurse_level++; in uaudio_mixer_find_inputs_sub()
4723 if (iot->u.desc == NULL) in uaudio_mixer_find_inputs_sub()
4726 switch (iot->u.desc->bDescriptorSubtype) { in uaudio_mixer_find_inputs_sub()
4728 uaudio_mixer_merge_outputs(&iot->usr, info); in uaudio_mixer_find_inputs_sub()
4729 info->bit_input[i / 8] |= (1 << (i % 8)); in uaudio_mixer_find_inputs_sub()
4733 uaudio_mixer_merge_outputs(&iot->usr, info); in uaudio_mixer_find_inputs_sub()
4735 root, &iot->u.fu_v1->bSourceId, 1, info); in uaudio_mixer_find_inputs_sub()
4739 info->bit_output[i / 8] |= (1 << (i % 8)); in uaudio_mixer_find_inputs_sub()
4741 root, &iot->u.ot_v1->bSourceId, 1, info); in uaudio_mixer_find_inputs_sub()
4742 info->bit_output[i / 8] &= ~(1 << (i % 8)); in uaudio_mixer_find_inputs_sub()
4746 uaudio_mixer_merge_outputs(&iot->usr, info); in uaudio_mixer_find_inputs_sub()
4748 root, iot->u.mu_v1->baSourceId, in uaudio_mixer_find_inputs_sub()
4749 iot->u.mu_v1->bNrInPins, info); in uaudio_mixer_find_inputs_sub()
4753 uaudio_mixer_merge_outputs(&iot->usr, info); in uaudio_mixer_find_inputs_sub()
4755 root, iot->u.su_v1->baSourceId, in uaudio_mixer_find_inputs_sub()
4756 iot->u.su_v1->bNrInPins, info); in uaudio_mixer_find_inputs_sub()
4760 uaudio_mixer_merge_outputs(&iot->usr, info); in uaudio_mixer_find_inputs_sub()
4762 root, iot->u.pu_v1->baSourceId, in uaudio_mixer_find_inputs_sub()
4763 iot->u.pu_v1->bNrInPins, info); in uaudio_mixer_find_inputs_sub()
4767 uaudio_mixer_merge_outputs(&iot->usr, info); in uaudio_mixer_find_inputs_sub()
4769 root, iot->u.eu_v1->baSourceId, in uaudio_mixer_find_inputs_sub()
4770 iot->u.eu_v1->bNrInPins, info); in uaudio_mixer_find_inputs_sub()
4791 if (info->recurse_level == UAUDIO_RECURSE_LIMIT) { in uaudio20_mixer_find_inputs_sub()
4796 info->recurse_level++; in uaudio20_mixer_find_inputs_sub()
4800 if (iot->u.desc == NULL) in uaudio20_mixer_find_inputs_sub()
4803 switch (iot->u.desc->bDescriptorSubtype) { in uaudio20_mixer_find_inputs_sub()
4805 uaudio_mixer_merge_outputs(&iot->usr, info); in uaudio20_mixer_find_inputs_sub()
4806 info->bit_input[i / 8] |= (1 << (i % 8)); in uaudio20_mixer_find_inputs_sub()
4810 info->bit_output[i / 8] |= (1 << (i % 8)); in uaudio20_mixer_find_inputs_sub()
4812 root, &iot->u.ot_v2->bSourceId, 1, info); in uaudio20_mixer_find_inputs_sub()
4813 info->bit_output[i / 8] &= ~(1 << (i % 8)); in uaudio20_mixer_find_inputs_sub()
4817 uaudio_mixer_merge_outputs(&iot->usr, info); in uaudio20_mixer_find_inputs_sub()
4819 root, iot->u.mu_v2->baSourceId, in uaudio20_mixer_find_inputs_sub()
4820 iot->u.mu_v2->bNrInPins, info); in uaudio20_mixer_find_inputs_sub()
4824 uaudio_mixer_merge_outputs(&iot->usr, info); in uaudio20_mixer_find_inputs_sub()
4826 root, iot->u.su_v2->baSourceId, in uaudio20_mixer_find_inputs_sub()
4827 iot->u.su_v2->bNrInPins, info); in uaudio20_mixer_find_inputs_sub()
4831 uaudio_mixer_merge_outputs(&iot->usr, info); in uaudio20_mixer_find_inputs_sub()
4833 root, &iot->u.ru_v2->bSourceId, in uaudio20_mixer_find_inputs_sub()
4838 uaudio_mixer_merge_outputs(&iot->usr, info); in uaudio20_mixer_find_inputs_sub()
4840 root, &iot->u.ef_v2->bSourceId, in uaudio20_mixer_find_inputs_sub()
4845 uaudio_mixer_merge_outputs(&iot->usr, info); in uaudio20_mixer_find_inputs_sub()
4847 root, &iot->u.fu_v2->bSourceId, 1, info); in uaudio20_mixer_find_inputs_sub()
4851 uaudio_mixer_merge_outputs(&iot->usr, info); in uaudio20_mixer_find_inputs_sub()
4853 root, iot->u.pu_v2->baSourceId, in uaudio20_mixer_find_inputs_sub()
4854 iot->u.pu_v2->bNrInPins, info); in uaudio20_mixer_find_inputs_sub()
4858 uaudio_mixer_merge_outputs(&iot->usr, info); in uaudio20_mixer_find_inputs_sub()
4860 root, iot->u.eu_v2->baSourceId, in uaudio20_mixer_find_inputs_sub()
4861 iot->u.eu_v2->bNrInPins, info); in uaudio20_mixer_find_inputs_sub()
4884 if (info->recurse_level == UAUDIO_RECURSE_LIMIT) { in uaudio20_mixer_find_clocks_sub()
4889 info->recurse_level++; in uaudio20_mixer_find_clocks_sub()
4893 if (iot->u.desc == NULL) in uaudio20_mixer_find_clocks_sub()
4898 switch (iot->u.desc->bDescriptorSubtype) { in uaudio20_mixer_find_clocks_sub()
4900 info->is_input = 1; in uaudio20_mixer_find_clocks_sub()
4902 p_id = &iot->u.it_v2->bCSourceId; in uaudio20_mixer_find_clocks_sub()
4907 &iot->u.it_v2->bCSourceId, 1, info); in uaudio20_mixer_find_clocks_sub()
4911 info->is_input = 0; in uaudio20_mixer_find_clocks_sub()
4913 p_id = &iot->u.ot_v2->bCSourceId; in uaudio20_mixer_find_clocks_sub()
4918 &iot->u.ot_v2->bCSourceId, 1, info); in uaudio20_mixer_find_clocks_sub()
4923 p_id = iot->u.csel_v2->baCSourceId; in uaudio20_mixer_find_clocks_sub()
4924 n_id = iot->u.csel_v2->bNrInPins; in uaudio20_mixer_find_clocks_sub()
4928 iot->u.csel_v2->baCSourceId, in uaudio20_mixer_find_clocks_sub()
4929 iot->u.csel_v2->bNrInPins, info); in uaudio20_mixer_find_clocks_sub()
4934 p_id = &iot->u.cmul_v2->bCSourceId; in uaudio20_mixer_find_clocks_sub()
4939 &iot->u.cmul_v2->bCSourceId, in uaudio20_mixer_find_clocks_sub()
4945 id = iot->u.csrc_v2->bClockId; in uaudio20_mixer_find_clocks_sub()
4947 switch (info->is_input) { in uaudio20_mixer_find_clocks_sub()
4949 info->bit_output[id / 8] |= (1 << (id % 8)); in uaudio20_mixer_find_clocks_sub()
4952 info->bit_input[id / 8] |= (1 << (id % 8)); in uaudio20_mixer_find_clocks_sub()
4986 if ((acdp->bLength < sizeof(*acdp)) || in uaudio_mixer_fill_info()
4987 (acdp->bDescriptorType != UDESC_CS_INTERFACE) || in uaudio_mixer_fill_info()
4988 (acdp->bDescriptorSubtype != UDESCSUB_AC_HEADER)) { in uaudio_mixer_fill_info()
4993 wTotalLen = UGETW(acdp->wTotalLength) - acdp->bLength; in uaudio_mixer_fill_info()
4996 sc->sc_audio_rev = UGETW(acdp->bcdADC); in uaudio_mixer_fill_info()
4999 sc->sc_audio_rev, wTotalLen); in uaudio_mixer_fill_info()
5007 if (dp->bLength > wTotalLen) { in uaudio_mixer_fill_info()
5010 wTotalLen -= dp->bLength; in uaudio_mixer_fill_info()
5013 if (sc->sc_audio_rev >= UAUDIO_VERSION_30) in uaudio_mixer_fill_info()
5015 else if (sc->sc_audio_rev >= UAUDIO_VERSION_20) in uaudio_mixer_fill_info()
5021 iot[au->bUnitId].u.desc = (const void *)au; in uaudio_mixer_fill_info()
5022 if (au->bUnitId > ID_max) in uaudio_mixer_fill_info()
5023 ID_max = au->bUnitId; in uaudio_mixer_fill_info()
5035 if (sc->sc_audio_rev >= UAUDIO_VERSION_30) { in uaudio_mixer_fill_info()
5037 } else if (sc->sc_audio_rev >= UAUDIO_VERSION_20) { in uaudio_mixer_fill_info()
5039 &i, 1, &((iot + i)->usr)); in uaudio_mixer_fill_info()
5041 sc->sc_mixer_clocks.is_input = 255; in uaudio_mixer_fill_info()
5042 sc->sc_mixer_clocks.recurse_level = 0; in uaudio_mixer_fill_info()
5045 &i, 1, &sc->sc_mixer_clocks); in uaudio_mixer_fill_info()
5048 &i, 1, &((iot + i)->usr)); in uaudio_mixer_fill_info()
5050 } while (i--); in uaudio_mixer_fill_info()
5056 (iot + i)->usr.id_max = ID_max; in uaudio_mixer_fill_info()
5057 (iot + i)->root = iot; in uaudio_mixer_fill_info()
5058 } while (i--); in uaudio_mixer_fill_info()
5072 i, dp->bDescriptorSubtype); in uaudio_mixer_fill_info()
5074 if (sc->sc_audio_rev >= UAUDIO_VERSION_30) { in uaudio_mixer_fill_info()
5076 } else if (sc->sc_audio_rev >= UAUDIO_VERSION_20) { in uaudio_mixer_fill_info()
5077 switch (dp->bDescriptorSubtype) { in uaudio_mixer_fill_info()
5107 dp->bDescriptorSubtype); in uaudio_mixer_fill_info()
5113 switch (dp->bDescriptorSubtype) { in uaudio_mixer_fill_info()
5144 dp->bDescriptorSubtype); in uaudio_mixer_fill_info()
5148 } while (i--); in uaudio_mixer_fill_info()
5163 if (mc->wValue[0] == -1) in uaudio_mixer_get()
5177 uint16_t len = MIX_SIZE(mc->type); in uaudio_mixer_get()
5184 USETW(req.wValue, mc->wValue[0]); in uaudio_mixer_get()
5185 USETW(req.wIndex, mc->wIndex); in uaudio_mixer_get()
5220 val = uaudio_mixer_signext(mc->type, val); in uaudio_mixer_get()
5232 struct uaudio_mixer_node *mc = sc->sc_mixer_curr; in uaudio_mixer_write_cfg_callback()
5237 uint8_t chan; in uaudio_mixer_write_cfg_callback() local
5249 mc = sc->sc_mixer_root; in uaudio_mixer_write_cfg_callback()
5250 sc->sc_mixer_curr = mc; in uaudio_mixer_write_cfg_callback()
5251 sc->sc_mixer_chan = 0; in uaudio_mixer_write_cfg_callback()
5255 while (sc->sc_mixer_chan < mc->nchan) { in uaudio_mixer_write_cfg_callback()
5256 chan = sc->sc_mixer_chan; in uaudio_mixer_write_cfg_callback()
5258 sc->sc_mixer_chan++; in uaudio_mixer_write_cfg_callback()
5260 update = ((mc->update[chan / 8] & (1 << (chan % 8))) && in uaudio_mixer_write_cfg_callback()
5261 (mc->wValue[chan] != -1)); in uaudio_mixer_write_cfg_callback()
5263 mc->update[chan / 8] &= ~(1 << (chan % 8)); in uaudio_mixer_write_cfg_callback()
5267 USETW(req.wValue, mc->wValue[chan]); in uaudio_mixer_write_cfg_callback()
5268 USETW(req.wIndex, mc->wIndex); in uaudio_mixer_write_cfg_callback()
5270 if (sc->sc_audio_rev >= UAUDIO_VERSION_30) { in uaudio_mixer_write_cfg_callback()
5272 } else if (sc->sc_audio_rev >= UAUDIO_VERSION_20) { in uaudio_mixer_write_cfg_callback()
5277 len = MIX_SIZE(mc->type); in uaudio_mixer_write_cfg_callback()
5282 buf[0] = (mc->wData[chan] & 0xFF); in uaudio_mixer_write_cfg_callback()
5283 buf[1] = (mc->wData[chan] >> 8) & 0xFF; in uaudio_mixer_write_cfg_callback()
5298 mc = mc->next; in uaudio_mixer_write_cfg_callback()
5299 sc->sc_mixer_curr = mc; in uaudio_mixer_write_cfg_callback()
5300 sc->sc_mixer_chan = 0; in uaudio_mixer_write_cfg_callback()
5311 /* do nothing - we are detaching */ in uaudio_mixer_write_cfg_callback()
5377 if (mc->type == MIX_ON_OFF) { in uaudio_mixer_bsd2value()
5379 } else if (mc->type != MIX_SELECTOR) { in uaudio_mixer_bsd2value()
5381 val = (val * mc->mul) / 100; in uaudio_mixer_bsd2value()
5384 val = val + mc->minval; in uaudio_mixer_bsd2value()
5387 if (val > mc->maxval) in uaudio_mixer_bsd2value()
5388 val = mc->maxval; in uaudio_mixer_bsd2value()
5389 else if (val < mc->minval) in uaudio_mixer_bsd2value()
5390 val = mc->minval; in uaudio_mixer_bsd2value()
5393 mc->type, val, mc->minval, mc->maxval, val); in uaudio_mixer_bsd2value()
5399 uint8_t chan, int val) in uaudio_mixer_ctl_set() argument
5403 mc->update[chan / 8] |= (1 << (chan % 8)); in uaudio_mixer_ctl_set()
5404 mc->wData[chan] = val; in uaudio_mixer_ctl_set()
5408 usbd_transfer_start(sc->sc_mixer_xfer[0]); in uaudio_mixer_ctl_set()
5419 for (mc = sc->sc_mixer_root; mc; mc = mc->next) { in uaudio_mixer_init()
5420 if (mc->ctl != SOUND_MIXER_NRDEVICES) { in uaudio_mixer_init()
5425 sc->sc_child[index].mix_info |= 1U << mc->ctl; in uaudio_mixer_init()
5427 if ((mc->ctl == SOUND_MIXER_NRDEVICES) && in uaudio_mixer_init()
5428 (mc->type == MIX_SELECTOR)) { in uaudio_mixer_init()
5429 for (i = mc->minval; (i > 0) && (i <= mc->maxval); i++) { in uaudio_mixer_init()
5430 if (mc->slctrtype[i - 1] == SOUND_MIXER_NRDEVICES) in uaudio_mixer_init()
5432 sc->sc_child[index].recsrc_info |= 1U << mc->slctrtype[i - 1]; in uaudio_mixer_init()
5445 sc->sc_child[i].mixer_lock = mixer_get_lock(m); in uaudio_mixer_init_sub()
5446 sc->sc_child[i].mixer_dev = m; in uaudio_mixer_init_sub()
5449 usbd_transfer_setup(sc->sc_udev, &sc->sc_mixer_iface_index, in uaudio_mixer_init_sub()
5450 sc->sc_mixer_xfer, uaudio_mixer_config, 1, sc, in uaudio_mixer_init_sub()
5451 sc->sc_child[i].mixer_lock)) { in uaudio_mixer_init_sub()
5456 if (sc->sc_play_chan[i].num_alt > 0 && in uaudio_mixer_init_sub()
5457 (sc->sc_child[i].mix_info & SOUND_MASK_VOLUME) == 0) { in uaudio_mixer_init_sub()
5461 mix_setdevs(m, sc->sc_child[i].mix_info); in uaudio_mixer_init_sub()
5462 mix_setrecdevs(m, sc->sc_child[i].recsrc_info); in uaudio_mixer_init_sub()
5474 usbd_transfer_unsetup(sc->sc_mixer_xfer, 1); in uaudio_mixer_uninit_sub()
5476 sc->sc_child[index].mixer_lock = NULL; in uaudio_mixer_uninit_sub()
5487 int chan; in uaudio_mixer_set() local
5491 for (mc = sc->sc_mixer_root; mc != NULL; mc = mc->next) { in uaudio_mixer_set()
5492 if (mc->ctl == type) { in uaudio_mixer_set()
5493 for (chan = 0; chan < mc->nchan; chan++) { in uaudio_mixer_set()
5494 uaudio_mixer_ctl_set(sc, mc, chan, in uaudio_mixer_set()
5495 chan == 0 ? left : right); in uaudio_mixer_set()
5512 for (mc = sc->sc_mixer_root; mc; mc = mc->next) { in uaudio_mixer_setrecsrc()
5513 if ((mc->ctl == SOUND_MIXER_NRDEVICES) && in uaudio_mixer_setrecsrc()
5514 (mc->type == MIX_SELECTOR)) { in uaudio_mixer_setrecsrc()
5518 for (i = mc->minval; (i > 0) && (i <= mc->maxval); i++) in uaudio_mixer_setrecsrc()
5519 mask |= 1U << mc->slctrtype[i - 1]; in uaudio_mixer_setrecsrc()
5526 temp = (-temp) & temp; in uaudio_mixer_setrecsrc()
5532 for (i = mc->minval; (i > 0) && (i <= mc->maxval); i++) { in uaudio_mixer_setrecsrc()
5533 if (temp != (1U << mc->slctrtype[i - 1])) in uaudio_mixer_setrecsrc()
5550 struct umidi_chan *chan = usbd_xfer_softc(xfer); in umidi_bulk_read_callback() local
5577 * Lookup sub-channel. The index is range in umidi_bulk_read_callback()
5580 sub = &chan->sub[cn]; in umidi_bulk_read_callback()
5582 if ((cmd_len != 0) && (cn < chan->max_emb_jack) && in umidi_bulk_read_callback()
5583 (sub->read_open != 0)) { in umidi_bulk_read_callback()
5586 sub->fifo.fp[USB_FIFO_RX], in umidi_bulk_read_callback()
5589 actlen -= 4; in umidi_bulk_read_callback()
5627 sub->temp_0[0] = p0 | 0x0f; in umidi_convert_to_usb()
5628 sub->temp_0[1] = b; in umidi_convert_to_usb()
5629 sub->temp_0[2] = 0; in umidi_convert_to_usb()
5630 sub->temp_0[3] = 0; in umidi_convert_to_usb()
5631 sub->temp_cmd = sub->temp_0; in umidi_convert_to_usb()
5637 sub->temp_1[1] = b; in umidi_convert_to_usb()
5638 sub->state = UMIDI_ST_SYSEX_1; in umidi_convert_to_usb()
5642 sub->temp_1[1] = b; in umidi_convert_to_usb()
5643 sub->state = UMIDI_ST_1PARAM; in umidi_convert_to_usb()
5646 sub->temp_1[1] = b; in umidi_convert_to_usb()
5647 sub->state = UMIDI_ST_2PARAM_1; in umidi_convert_to_usb()
5651 sub->state = UMIDI_ST_UNKNOWN; in umidi_convert_to_usb()
5654 sub->temp_1[0] = p0 | 0x05; in umidi_convert_to_usb()
5655 sub->temp_1[1] = 0xf6; in umidi_convert_to_usb()
5656 sub->temp_1[2] = 0; in umidi_convert_to_usb()
5657 sub->temp_1[3] = 0; in umidi_convert_to_usb()
5658 sub->temp_cmd = sub->temp_1; in umidi_convert_to_usb()
5659 sub->state = UMIDI_ST_UNKNOWN; in umidi_convert_to_usb()
5663 switch (sub->state) { in umidi_convert_to_usb()
5665 sub->temp_1[0] = p0 | 0x05; in umidi_convert_to_usb()
5666 sub->temp_1[1] = 0xf7; in umidi_convert_to_usb()
5667 sub->temp_1[2] = 0; in umidi_convert_to_usb()
5668 sub->temp_1[3] = 0; in umidi_convert_to_usb()
5669 sub->temp_cmd = sub->temp_1; in umidi_convert_to_usb()
5670 sub->state = UMIDI_ST_UNKNOWN; in umidi_convert_to_usb()
5673 sub->temp_1[0] = p0 | 0x06; in umidi_convert_to_usb()
5674 sub->temp_1[2] = 0xf7; in umidi_convert_to_usb()
5675 sub->temp_1[3] = 0; in umidi_convert_to_usb()
5676 sub->temp_cmd = sub->temp_1; in umidi_convert_to_usb()
5677 sub->state = UMIDI_ST_UNKNOWN; in umidi_convert_to_usb()
5680 sub->temp_1[0] = p0 | 0x07; in umidi_convert_to_usb()
5681 sub->temp_1[3] = 0xf7; in umidi_convert_to_usb()
5682 sub->temp_cmd = sub->temp_1; in umidi_convert_to_usb()
5683 sub->state = UMIDI_ST_UNKNOWN; in umidi_convert_to_usb()
5686 sub->state = UMIDI_ST_UNKNOWN; in umidi_convert_to_usb()
5690 sub->temp_1[1] = b; in umidi_convert_to_usb()
5692 sub->state = UMIDI_ST_1PARAM; in umidi_convert_to_usb()
5694 sub->state = UMIDI_ST_2PARAM_1; in umidi_convert_to_usb()
5697 switch (sub->state) { in umidi_convert_to_usb()
5699 if (sub->temp_1[1] < 0xf0) { in umidi_convert_to_usb()
5700 p0 |= sub->temp_1[1] >> 4; in umidi_convert_to_usb()
5703 sub->state = UMIDI_ST_UNKNOWN; in umidi_convert_to_usb()
5705 sub->temp_1[0] = p0; in umidi_convert_to_usb()
5706 sub->temp_1[2] = b; in umidi_convert_to_usb()
5707 sub->temp_1[3] = 0; in umidi_convert_to_usb()
5708 sub->temp_cmd = sub->temp_1; in umidi_convert_to_usb()
5711 sub->temp_1[2] = b; in umidi_convert_to_usb()
5712 sub->state = UMIDI_ST_2PARAM_2; in umidi_convert_to_usb()
5715 if (sub->temp_1[1] < 0xf0) { in umidi_convert_to_usb()
5716 p0 |= sub->temp_1[1] >> 4; in umidi_convert_to_usb()
5717 sub->state = UMIDI_ST_2PARAM_1; in umidi_convert_to_usb()
5720 sub->state = UMIDI_ST_UNKNOWN; in umidi_convert_to_usb()
5722 sub->temp_1[0] = p0; in umidi_convert_to_usb()
5723 sub->temp_1[3] = b; in umidi_convert_to_usb()
5724 sub->temp_cmd = sub->temp_1; in umidi_convert_to_usb()
5727 sub->temp_1[1] = b; in umidi_convert_to_usb()
5728 sub->state = UMIDI_ST_SYSEX_1; in umidi_convert_to_usb()
5731 sub->temp_1[2] = b; in umidi_convert_to_usb()
5732 sub->state = UMIDI_ST_SYSEX_2; in umidi_convert_to_usb()
5735 sub->temp_1[0] = p0 | 0x04; in umidi_convert_to_usb()
5736 sub->temp_1[3] = b; in umidi_convert_to_usb()
5737 sub->temp_cmd = sub->temp_1; in umidi_convert_to_usb()
5738 sub->state = UMIDI_ST_SYSEX_0; in umidi_convert_to_usb()
5750 struct umidi_chan *chan = usbd_xfer_softc(xfer); in umidi_bulk_write_callback() local
5775 start_cable = chan->curr_cable; in umidi_bulk_write_callback()
5780 /* round robin de-queueing */ in umidi_bulk_write_callback()
5782 sub = &chan->sub[chan->curr_cable]; in umidi_bulk_write_callback()
5784 if (sub->write_open) { in umidi_bulk_write_callback()
5785 usb_fifo_get_data_linear(sub->fifo.fp[USB_FIFO_TX], in umidi_bulk_write_callback()
5795 (unsigned int)chan->curr_cable); in umidi_bulk_write_callback()
5797 if (umidi_convert_to_usb(sub, chan->curr_cable, buf)) { in umidi_bulk_write_callback()
5799 sub->temp_cmd[0], sub->temp_cmd[1], in umidi_bulk_write_callback()
5800 sub->temp_cmd[2], sub->temp_cmd[3]); in umidi_bulk_write_callback()
5802 usbd_copy_in(pc, nframes * 4, sub->temp_cmd, 4); in umidi_bulk_write_callback()
5806 if ((nframes >= UMIDI_TX_FRAMES) || (chan->single_command != 0)) in umidi_bulk_write_callback()
5813 chan->curr_cable++; in umidi_bulk_write_callback()
5814 if (chan->curr_cable >= chan->max_emb_jack) in umidi_bulk_write_callback()
5815 chan->curr_cable = 0; in umidi_bulk_write_callback()
5817 if (chan->curr_cable == start_cable) { in umidi_bulk_write_callback()
5847 struct umidi_chan *chan = usb_fifo_softc(fifo); in umidi_sub_by_fifo() local
5852 sub = &chan->sub[n]; in umidi_sub_by_fifo()
5853 if ((sub->fifo.fp[USB_FIFO_RX] == fifo) || in umidi_sub_by_fifo()
5854 (sub->fifo.fp[USB_FIFO_TX] == fifo)) { in umidi_sub_by_fifo()
5868 struct umidi_chan *chan = usb_fifo_softc(fifo); in umidi_start_read() local
5870 usbd_transfer_start(chan->xfer[UMIDI_RX_TRANSFER]); in umidi_start_read()
5876 struct umidi_chan *chan = usb_fifo_softc(fifo); in umidi_stop_read() local
5881 sub->read_open = 0; in umidi_stop_read()
5883 if (--(chan->read_open_refcount) == 0) { in umidi_stop_read()
5895 struct umidi_chan *chan = usb_fifo_softc(fifo); in umidi_start_write() local
5897 if (chan->xfer[UMIDI_TX_TRANSFER] == NULL) { in umidi_start_write()
5905 usbd_transfer_start(chan->xfer[UMIDI_TX_TRANSFER]); in umidi_start_write()
5912 struct umidi_chan *chan = usb_fifo_softc(fifo); in umidi_stop_write() local
5917 sub->write_open = 0; in umidi_stop_write()
5919 if (--(chan->write_open_refcount) == 0) { in umidi_stop_write()
5921 usbd_transfer_stop(chan->xfer[UMIDI_TX_TRANSFER]); in umidi_stop_write()
5928 struct umidi_chan *chan = usb_fifo_softc(fifo); in umidi_open() local
5935 mtx_lock(&chan->mtx); in umidi_open()
5936 chan->read_open_refcount++; in umidi_open()
5937 sub->read_open = 1; in umidi_open()
5938 mtx_unlock(&chan->mtx); in umidi_open()
5945 mtx_lock(&chan->mtx); in umidi_open()
5946 chan->write_open_refcount++; in umidi_open()
5947 sub->write_open = 1; in umidi_open()
5950 sub->state = UMIDI_ST_UNKNOWN; in umidi_open()
5951 mtx_unlock(&chan->mtx); in umidi_open()
5978 struct umidi_chan *chan = &sc->sc_midi_chan; in umidi_init() local
5980 mtx_init(&chan->mtx, "umidi lock", NULL, MTX_DEF | MTX_RECURSE); in umidi_init()
5999 struct umidi_chan *chan = &sc->sc_midi_chan; in umidi_probe() local
6006 chan->single_command = 1; in umidi_probe()
6008 error = usbd_set_alt_interface_index(sc->sc_udev, in umidi_probe()
6009 chan->iface_index, chan->iface_alt_index); in umidi_probe()
6015 usbd_set_parent_iface(sc->sc_udev, chan->iface_index, in umidi_probe()
6016 sc->sc_mixer_iface_index); in umidi_probe()
6018 error = usbd_transfer_setup(uaa->device, &chan->iface_index, in umidi_probe()
6019 chan->xfer, umidi_config, UMIDI_N_TRANSFER, in umidi_probe()
6020 chan, &chan->mtx); in umidi_probe()
6025 if (chan->xfer[UMIDI_TX_TRANSFER] == NULL && in umidi_probe()
6026 chan->xfer[UMIDI_RX_TRANSFER] == NULL) { in umidi_probe()
6039 * Controllers are required to have support for 8-, 16-, 32-, in umidi_probe()
6040 * and 64-byte maximum packet sizes for full-speed bulk in umidi_probe()
6041 * endpoints and 512 bytes for high-speed bulk endpoints." in umidi_probe()
6043 if (chan->xfer[UMIDI_TX_TRANSFER] != NULL && in umidi_probe()
6044 usbd_xfer_maxp_was_clamped(chan->xfer[UMIDI_TX_TRANSFER])) in umidi_probe()
6045 chan->single_command = 1; in umidi_probe()
6047 if (chan->single_command != 0) in umidi_probe()
6050 if ((chan->max_emb_jack == 0) || in umidi_probe()
6051 (chan->max_emb_jack > UMIDI_EMB_JACK_MAX)) { in umidi_probe()
6052 chan->max_emb_jack = UMIDI_EMB_JACK_MAX; in umidi_probe()
6055 for (n = 0; n < chan->max_emb_jack; n++) { in umidi_probe()
6056 sub = &chan->sub[n]; in umidi_probe()
6058 error = usb_fifo_attach(sc->sc_udev, chan, &chan->mtx, in umidi_probe()
6059 &umidi_fifo_methods, &sub->fifo, unit, n, in umidi_probe()
6060 chan->iface_index, in umidi_probe()
6067 mtx_lock(&chan->mtx); in umidi_probe()
6075 usbd_transfer_start(chan->xfer[UMIDI_RX_TRANSFER]); in umidi_probe()
6077 mtx_unlock(&chan->mtx); in umidi_probe()
6089 struct umidi_chan *chan = &sc->sc_midi_chan; in umidi_detach() local
6093 usb_fifo_detach(&chan->sub[n].fifo); in umidi_detach()
6095 mtx_lock(&chan->mtx); in umidi_detach()
6097 usbd_transfer_stop(chan->xfer[UMIDI_RX_TRANSFER]); in umidi_detach()
6099 mtx_unlock(&chan->mtx); in umidi_detach()
6101 usbd_transfer_unsetup(chan->xfer, UMIDI_N_TRANSFER); in umidi_detach()
6103 mtx_destroy(&chan->mtx); in umidi_detach()
6124 (sc->sc_hid.flags & UAUDIO_HID_HAS_ID)) { in uaudio_hid_rx_callback()
6127 actlen--; in uaudio_hid_rx_callback()
6132 m = sc->sc_child[0].mixer_dev; in uaudio_hid_rx_callback()
6134 if ((sc->sc_hid.flags & UAUDIO_HID_HAS_MUTE) && in uaudio_hid_rx_callback()
6135 (sc->sc_hid.mute_id == id) && in uaudio_hid_rx_callback()
6137 &sc->sc_hid.mute_loc)) { in uaudio_hid_rx_callback()
6143 if ((sc->sc_hid.flags & UAUDIO_HID_HAS_VOLUME_UP) && in uaudio_hid_rx_callback()
6144 (sc->sc_hid.volume_up_id == id) && in uaudio_hid_rx_callback()
6146 &sc->sc_hid.volume_up_loc)) { in uaudio_hid_rx_callback()
6152 if ((sc->sc_hid.flags & UAUDIO_HID_HAS_VOLUME_DOWN) && in uaudio_hid_rx_callback()
6153 (sc->sc_hid.volume_down_id == id) && in uaudio_hid_rx_callback()
6155 &sc->sc_hid.volume_down_loc)) { in uaudio_hid_rx_callback()
6158 mixer_hwvol_step_locked(m, -1, -1); in uaudio_hid_rx_callback()
6191 if (!(sc->sc_hid.flags & UAUDIO_HID_VALID)) in uaudio_hid_probe()
6192 return (-1); in uaudio_hid_probe()
6194 if (sc->sc_child[0].mixer_lock == NULL) in uaudio_hid_probe()
6195 return (-1); in uaudio_hid_probe()
6198 error = usbd_req_get_hid_desc(uaa->device, NULL, &d_ptr, in uaudio_hid_probe()
6199 &d_len, M_TEMP, sc->sc_hid.iface_index); in uaudio_hid_probe()
6203 return (-1); in uaudio_hid_probe()
6210 sc->sc_hid.flags |= UAUDIO_HID_HAS_ID; in uaudio_hid_probe()
6214 hid_input, 0, &sc->sc_hid.volume_up_loc, &flags, in uaudio_hid_probe()
6215 &sc->sc_hid.volume_up_id)) { in uaudio_hid_probe()
6217 sc->sc_hid.flags |= UAUDIO_HID_HAS_VOLUME_UP; in uaudio_hid_probe()
6223 hid_input, 0, &sc->sc_hid.volume_down_loc, &flags, in uaudio_hid_probe()
6224 &sc->sc_hid.volume_down_id)) { in uaudio_hid_probe()
6226 sc->sc_hid.flags |= UAUDIO_HID_HAS_VOLUME_DOWN; in uaudio_hid_probe()
6232 hid_input, 0, &sc->sc_hid.mute_loc, &flags, in uaudio_hid_probe()
6233 &sc->sc_hid.mute_id)) { in uaudio_hid_probe()
6235 sc->sc_hid.flags |= UAUDIO_HID_HAS_MUTE; in uaudio_hid_probe()
6241 if (!(sc->sc_hid.flags & (UAUDIO_HID_HAS_VOLUME_UP | in uaudio_hid_probe()
6245 return (-1); in uaudio_hid_probe()
6249 usbd_set_parent_iface(uaa->device, sc->sc_hid.iface_index, in uaudio_hid_probe()
6250 sc->sc_mixer_iface_index); in uaudio_hid_probe()
6253 error = usbd_transfer_setup(uaa->device, &sc->sc_hid.iface_index, in uaudio_hid_probe()
6254 sc->sc_hid.xfer, uaudio_hid_config, UAUDIO_HID_N_TRANSFER, in uaudio_hid_probe()
6255 sc, sc->sc_child[0].mixer_lock); in uaudio_hid_probe()
6258 return (-1); in uaudio_hid_probe()
6266 usbd_transfer_unsetup(sc->sc_hid.xfer, UAUDIO_HID_N_TRANSFER); in uaudio_hid_detach()