Hello everybody, This is a highly experimental patch on top of 5.12-rc4 that's supposed to engage implicit feedback sync on the playback for Pioneer devices. Without implicit feedback sync the inputs started glitching due to clock drift in about an hour in my Pioneer DJ DDJ-SR2. If you own a Pioneer device please test this patch and verify in the dyndbg logs if your capture(input) EP is being opened twice and if implicit_fb = 1 for the playback EP. I can't ask of you all to test this for hours and hours but if you wanted to have an excuse to digitize vinyl or spin up DVS this is your perfect one. Help open source! I'd like to thank Takashi Iwai for his tireless support in the Pioneer regression and beyond. Hopefully this highly experimental feature's code can be polished and mainlined eventually. --- implicit.c.git 2021-03-21 22:40:48.363417245 -0300 +++ implicit.c 2021-03-22 01:03:05.726729481 -0300 @@ -177,30 +177,31 @@ ifnum, alts); } -/* Playback and capture EPs on Pioneer devices share the same iface/altset, - * but they don't seem working with the implicit fb mode well, hence we - * just return as if the sync were already set up. +/* Pioneer devices: playback and capture streams sharing the same iface/altset */ -static int skip_pioneer_sync_ep(struct snd_usb_audio *chip, - struct audioformat *fmt, - struct usb_host_interface *alts) -{ - struct usb_endpoint_descriptor *epd; - - if (alts->desc.bNumEndpoints != 2) - return 0; - - epd = get_endpoint(alts, 1); - if (!usb_endpoint_is_isoc_in(epd) || - (epd->bmAttributes & USB_ENDPOINT_SYNCTYPE) != USB_ENDPOINT_SYNC_ASYNC || - ((epd->bmAttributes & USB_ENDPOINT_USAGE_MASK) != - USB_ENDPOINT_USAGE_DATA && - (epd->bmAttributes & USB_ENDPOINT_USAGE_MASK) != - USB_ENDPOINT_USAGE_IMPLICIT_FB)) - return 0; - return 1; /* don't handle with the implicit fb, just skip sync EP */ +static int add_pioneer_implicit_fb(struct snd_usb_audio *chip, + struct audioformat *fmt, + struct usb_host_interface *alts) +{ + struct usb_endpoint_descriptor *epd; + + if (alts->desc.bNumEndpoints != 2) + return 0; + + epd = get_endpoint(alts, 1); + + if (!usb_endpoint_is_isoc_in(epd) || + (epd->bmAttributes & USB_ENDPOINT_SYNCTYPE) != USB_ENDPOINT_SYNC_ASYNC || + ((epd->bmAttributes & USB_ENDPOINT_USAGE_MASK) != + USB_ENDPOINT_USAGE_DATA && + (epd->bmAttributes & USB_ENDPOINT_USAGE_MASK) != + USB_ENDPOINT_USAGE_IMPLICIT_FB)) + return 0; + return add_implicit_fb_sync_ep(chip, fmt, epd->bEndpointAddress, 1, + alts->desc.bInterfaceNumber, alts); } + static int __add_generic_implicit_fb(struct snd_usb_audio *chip, struct audioformat *fmt, int iface, int altset) @@ -306,7 +307,7 @@ alts->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC && (USB_ID_VENDOR(chip->usb_id) == 0x2b73 || /* Pioneer */ USB_ID_VENDOR(chip->usb_id) == 0x08e4 /* Pioneer */)) { - if (skip_pioneer_sync_ep(chip, fmt, alts)) + if (add_pioneer_implicit_fb(chip, fmt, alts)) return 1; } @@ -339,8 +340,20 @@ struct audioformat *fmt, struct usb_host_interface *alts) { - if (fmt->endpoint & USB_DIR_IN) - return audioformat_capture_quirk(chip, fmt, alts); + bool isPioneer; + + if (alts->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC && + (USB_ID_VENDOR(chip->usb_id) == 0x2b73 || /* Pioneer */ + USB_ID_VENDOR(chip->usb_id) == 0x08e4 /* Pioneer */)) + isPioneer = true; + + if (fmt->endpoint & USB_DIR_IN) { + if (isPioneer == true) + return 1; + else + return audioformat_capture_quirk(chip, fmt, alts); + } + else return audioformat_implicit_fb_quirk(chip, fmt, alts); } --- endpoint.c.git 2021-03-21 22:40:54.800084101 -0300 +++ endpoint.c 2021-03-21 22:45:41.543425855 -0300 @@ -688,7 +688,7 @@ goto unlock; } - if (!ep->opened) { + if (ep->opened < 2) { if (is_sync_ep) { ep->iface = fp->sync_iface; ep->altsetting = fp->sync_altsetting;