ALSA: usb-audio: Yet more fixes for Pioneer devices
cover ALSA: usb-audio: Yet more fixes for Pioneer devices
Hi,
the Pioneer UAC1 devices still didn't work with the recent changes, and after debugging sessions, a few issues were discovered. Below are the patches to cover those errors.
Takashi
===
Takashi Iwai (3):
ALSA: usb-audio: Fix UAC1 rate setup for secondary endpoints
ALSA: usb-audio: Set sample rate for all sharing EPs on UAC1
ALSA: usb-audio: Avoid implicit feedback on Pioneer devices
sound/usb/clock.c | 21 ++++++--------------- sound/usb/endpoint.c | 9 +++++++++ sound/usb/implicit.c | 17 +++++++++-------- sound/usb/quirks.c | 28 ---------------------------- 4 files changed, 24 insertions(+), 51 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/3 ALSA: usb-audio: Fix UAC1 rate setup for secondary endpoints
The current sample rate setup function for UAC1 assumes only the first endpoint retrieved from the interface:altset pair, but the rate set up may be needed also for the secondary endpoint. Also, retrieving the endpoint number from the interface descriptor is redundant; we have already the target endpoint in the given audioformat object.
This patch simplifies the code and corrects the target endpoint as described in the above. It simply refers to fmt->endpoint directly.
Also, this patch drops the pioneer_djm_set_format_quirk() that is caleld from snd_usb_set_format_quirk(); this function does the sample rate setup but for the capture endpoint (0x82), and that's exactly what the change above fixes.
--- sound/usb/clock.c | 21 ++++++--------------- sound/usb/quirks.c | 28 ---------------------------- 2 files changed, 6 insertions(+), 43 deletions(-)
sound/usb/clock.c +6 -15
@@ -485,18 +485,9 @@ static int set_sample_rate_v1(struct snd_usb_audio *chip, const struct audioformat *fmt, int rate) {struct usb_device *dev = chip->dev; -struct usb_host_interface *alts; -unsigned int ep;unsigned char data[3 ];int err, crate; - alts =snd_usb_get_host_interface (chip, fmt->iface, fmt->altsetting); -if (!alts) -return -EINVAL ; -if (get_iface_desc (alts)->bNumEndpoints <1 ) -return -EINVAL ; - ep =get_endpoint (alts,0 )->bEndpointAddress; -/* if endpoint doesn't have sampling rate control, bail out */ if (!(fmt->attributes &UAC_EP_CS_ATTR_SAMPLE_RATE ))return 0 ;
@@ -506,11 +497,11 @@ static int set_sample_rate_v1(struct snd_usb_audio *chip, data[2 ] = rate >>16 ; err =snd_usb_ctl_msg (dev,usb_sndctrlpipe (dev,0 ),UAC_SET_CUR ,USB_TYPE_CLASS |USB_RECIP_ENDPOINT |USB_DIR_OUT , -UAC_EP_CS_ATTR_SAMPLE_RATE <<8 , ep, - data,sizeof (data)); +UAC_EP_CS_ATTR_SAMPLE_RATE <<8 , + fmt->endpoint, data,sizeof (data));if (err <0 ) {dev_err (&dev->dev,"%d:%d: cannot set freq %d to ep %#x\n" , - fmt->iface, fmt->altsetting, rate, ep); + fmt->iface, fmt->altsetting, rate, fmt->endpoint);return err; }
@@ -524,11 +515,11 @@ static int set_sample_rate_v1(struct snd_usb_audio *chip, err =snd_usb_ctl_msg (dev,usb_rcvctrlpipe (dev,0 ),UAC_GET_CUR ,USB_TYPE_CLASS |USB_RECIP_ENDPOINT |USB_DIR_IN , -UAC_EP_CS_ATTR_SAMPLE_RATE <<8 , ep, - data,sizeof (data)); +UAC_EP_CS_ATTR_SAMPLE_RATE <<8 , + fmt->endpoint, data,sizeof (data));if (err <0 ) {dev_err (&dev->dev,"%d:%d: cannot get freq at ep %#x\n" , - fmt->iface, fmt->altsetting, ep); + fmt->iface, fmt->altsetting, fmt->endpoint); chip->sample_rate_read_error++;return 0 ;/* some devices don't support reading */ }
sound/usb/quirks.c +0 -28
@@ -1470,30 +1470,6 @@ static void set_format_emu_quirk(struct snd_usb_substream *subs, subs->pkt_offset_adj = (emu_samplerate_id >=EMU_QUIRK_SR_176400HZ ) ?4 :0 ; } - -/* -* Pioneer DJ DJM-900NXS2 -* Device needs to know the sample rate each time substream is started -*/ -static int pioneer_djm_set_format_quirk (struct snd_usb_substream *subs) -{ -unsigned int cur_rate = subs->data_endpoint->cur_rate; -/* Convert sample rate value to little endian */ -u8 sr[3 ]; - - sr[0 ] = cur_rate &0xff ; - sr[1 ] = (cur_rate >>8 ) &0xff ; - sr[2 ] = (cur_rate >>16 ) &0xff ; - -/* Configure device */ -usb_set_interface (subs->dev,0 ,1 ); -snd_usb_ctl_msg (subs->stream->chip->dev, -usb_rcvctrlpipe (subs->stream->chip->dev,0 ), -0x01 ,0x22 ,0x0100 ,0x0082 , &sr,0x0003 ); - -return 0 ; -} -void snd_usb_set_format_quirk (struct snd_usb_substream *subs,const struct audioformat *fmt) {
@@ -1504,10 +1480,6 @@ void snd_usb_set_format_quirk(struct snd_usb_substream *subs,case USB_ID (0x041e ,0x3f19 ):/* E-Mu 0204 USB */ set_format_emu_quirk (subs, fmt);break ; -case USB_ID (0x2b73 ,0x000a ):/* Pioneer DJ DJM-900NXS2 */ -case USB_ID (0x2b73 ,0x0017 ):/* Pioneer DJ DJM-250MK2 */ -pioneer_djm_set_format_quirk (subs); -break ;case USB_ID (0x534d ,0x2109 ):/* MacroSilicon MS2109 */ subs->stream_offset_adj =2 ;break ;
Signature · 1 line
2.26.2
PATCH 2/3 ALSA: usb-audio: Set sample rate for all sharing EPs on UAC1
In reply to Takashi IwaiThe UAC2/3 sample rate setup is based on the clock node, which is usually shared in the interface, and can't be re-setup without deselecting the interface once, and that's how the current code behaves. OTOH, the sample rate setup of UAC1 is per endpoint, hence we basically need to call for each endpoint usage even if those share the same interface.
This patch fixes the behavior of UAC1 to call always snd_usb_init_sample_rate() in snd_usb_endpoint_configure().
--- sound/usb/endpoint.c | 9 +++++++++ 1 file changed, 9 insertions(+)
sound/usb/endpoint.c +9 -0
@@ -1252,6 +1252,15 @@ int snd_usb_endpoint_configure(struct snd_usb_audio *chip,/* If the interface has been already set up, just set EP parameters */ if (!ep->iface_ref->need_setup) { +/* sample rate setup of UAC1 is per endpoint, and we need +* to update at each EP configuration +*/ +if (ep->cur_audiofmt->protocol ==UAC_VERSION_1 ) { + err =snd_usb_init_sample_rate (chip, ep->cur_audiofmt, + ep->cur_rate); +if (err <0 ) + goto unlock; + } err =snd_usb_endpoint_set_params (chip, ep);if (err <0 ) goto unlock;
Signature · 1 line
2.26.2
PATCH 3/3 ALSA: usb-audio: Avoid implicit feedback on Pioneer devices
In reply to Takashi IwaiFor addressing the regression on Pioneer devices, we recently corrected the quirk code to enable the implicit feedback mode on those devices properly. However, the devices still showed problems with the full duplex operations with JACK, and after debug sessions, we figured out that the older kernels that had worked with JACK also didn't use the implicit feedback mode at all although they had the quirk code to enable it; instead, the old code worked just to skip the normal sync endpoint setup that would have been detected without it. IOW, what broke without the implicit-fb quirk in the past was the application of the normal sync endpoint that is actually the capture data endpoint on these devices.
This patch covers the overseen piece: it modifies the quirk code again not to enable the implicit feedback mode but just to make the driver skipping the sync endpoint detection. This made the driver working with JACK full-duplex mode again.
Still it's not quite clear why the implicit feedback doesn't work on those devices yet; maybe it's about some issues in the URB setup. But at least, with this patch, the driver should work in the level of the older kernels again.
--- sound/usb/implicit.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
sound/usb/implicit.c +9 -8
@@ -175,11 +175,13 @@ static int add_roland_implicit_fb(struct snd_usb_audio *chip, ifnum, alts); } -/* Pioneer devices: playback and capture streams sharing the same iface/altset +/* 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. */ -static int add_pioneer_implicit_fb (struct snd_usb_audio *chip, -struct audioformat *fmt, -struct usb_host_interface *alts) +static int skip_pioneer_sync_ep (struct snd_usb_audio *chip, +struct audioformat *fmt, +struct usb_host_interface *alts) {struct usb_endpoint_descriptor *epd;
@@ -194,8 +196,7 @@ static int add_pioneer_implicit_fb(struct snd_usb_audio *chip, (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); +return 1 ;/* don't handle with the implicit fb, just skip sync EP */ } static int __add_generic_implicit_fb(struct snd_usb_audio *chip,
@@ -298,11 +299,11 @@ static int audioformat_implicit_fb_quirk(struct snd_usb_audio *chip,return 1 ; } -/* Pioneer devices implicit feedback with vendor spec class */ +/* Pioneer devices with vendor spec class */ if (attr ==USB_ENDPOINT_SYNC_ASYNC && alts->desc.bInterfaceClass ==USB_CLASS_VENDOR_SPEC &&USB_ID_VENDOR (chip->usb_id) ==0x2b73 /* Pioneer */ ) { -if (add_pioneer_implicit_fb (chip, fmt, alts)) +if (skip_pioneer_sync_ep (chip, fmt, alts))return 1 ; }
Signature · 1 line
2.26.2
Dne 18. 01. 21 v 8:58 Takashi Iwai napsal(a):
Quoted 3 lines
the Pioneer UAC1 devices still didn't work with the recent changes, and after debugging sessions, a few issues were discovered. Below are the patches to cover those errors.
I have compiled and tested version 532a208ad610 (Avoid implicit feedback on Pioneer devices)
and can confirm that Pioneer DJ DJM-250MK2 works again (playback, recording – tested through JACK in duplex mode).
Thanks,
Franta
Jan 18 14:11:49 antracit kernel: [ 3168.116208] usb 1-3: new high-speed USB device number 2 using ehci-pci Jan 18 14:11:49 antracit kernel: [ 3168.272980] usb 1-3: New USB device found, idVendor=2b73, idProduct=0017, bcdDevice= 1.06 Jan 18 14:11:49 antracit kernel: [ 3168.272991] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0 Jan 18 14:11:49 antracit kernel: [ 3168.272997] usb 1-3: Product: DJM-250MK2 Jan 18 14:11:49 antracit kernel: [ 3168.273001] usb 1-3: Manufacturer: Pioneer DJ Corporation Jan 18 14:11:49 antracit kernel: [ 3168.276464] hid-generic 0003:2B73:0017.0004: hiddev0,hidraw3: USB HID v1.11 Device [Pioneer DJ Corporation DJM-250MK2] on usb-0000:00:12.2-3/input3 Jan 18 14:11:49 antracit kernel: [ 3168.296965] mc: Linux media interface: v0.10 Jan 18 14:11:49 antracit kernel: [ 3168.305100] usb 1-3: Creating new data endpoint #1 Jan 18 14:11:49 antracit kernel: [ 3168.305216] usb 1-3: 0:1 Set sample rate 48000, clock 0 Jan 18 14:11:49 antracit kernel: [ 3168.305219] usb 1-3: 0:1: found sync_ep=0x82, iface=0, alt=1, implicit_fb=0 Jan 18 14:11:49 antracit kernel: [ 3168.305224] usb 1-3: Creating new data endpoint #82 Jan 18 14:11:49 antracit kernel: [ 3168.305340] usb 1-3: 0:1 Set sample rate 48000, clock 0 Jan 18 14:11:49 antracit kernel: [ 3168.306796] usbcore: registered new interface driver snd-usb-audio Jan 18 14:11:49 antracit kernel: [ 3168.358262] usb 1-3: Open EP 0x1, iface=0:1, idx=0 Jan 18 14:11:49 antracit kernel: [ 3168.358268] usb 1-3: channels=8, rate=48000, format=S24_3LE, period_bytes=28776, periods=4, implicit_fb=0 Jan 18 14:11:49 antracit kernel: [ 3168.358272] usb 1-3: Setting usb interface 0:0 for EP 0x1 Jan 18 14:11:49 antracit kernel: [ 3168.358660] usb 1-3: Setting usb interface 0:1 for EP 0x1 Jan 18 14:11:49 antracit kernel: [ 3168.358872] usb 1-3: 0:1 Set sample rate 48000, clock 0 Jan 18 14:11:49 antracit kernel: [ 3168.358876] usb 1-3: Setting params for data EP 0x1, pipe 0x8200 Jan 18 14:11:49 antracit kernel: [ 3168.358886] usb 1-3: Set up 3 URBS, ret=0 Jan 18 14:11:49 antracit kernel: [ 3168.358939] usb 1-3: Starting data EP 0x1 (running 0) Jan 18 14:11:49 antracit kernel: [ 3168.358973] usb 1-3: 3 URBs submitted for EP 0x1 Jan 18 14:11:49 antracit kernel: [ 3168.359576] usb 1-3: Stopping data EP 0x1 (running 1) Jan 18 14:11:49 antracit kernel: [ 3168.362140] usb 1-3: Open EP 0x82, iface=0:1, idx=1 Jan 18 14:11:49 antracit kernel: [ 3168.362144] usb 1-3: channels=8, rate=48000, format=S24_3LE, period_bytes=28776, periods=4, implicit_fb=0 Jan 18 14:11:49 antracit kernel: [ 3168.362147] usb 1-3: Reopened EP 0x82 (count 1) Jan 18 14:11:49 antracit kernel: [ 3168.362149] usb 1-3: 0:1 Set sample rate 48000, clock 0 Jan 18 14:11:49 antracit kernel: [ 3168.362152] usb 1-3: Setting params for data EP 0x82, pipe 0x10280 Jan 18 14:11:49 antracit kernel: [ 3168.362171] usb 1-3: Set up 12 URBS, ret=0 Jan 18 14:11:49 antracit kernel: [ 3168.362292] usb 1-3: Closing EP 0x82 (count 2) Jan 18 14:11:49 antracit kernel: [ 3168.362295] usb 1-3: Closing EP 0x82 (count 1) Jan 18 14:11:49 antracit kernel: [ 3168.362296] usb 1-3: EP 0x82 closed Jan 18 14:11:49 antracit kernel: [ 3168.363756] usb 1-3: Open EP 0x82, iface=0:1, idx=1 Jan 18 14:11:49 antracit kernel: [ 3168.363760] usb 1-3: channels=8, rate=48000, format=S24_3LE, period_bytes=524280, periods=2, implicit_fb=0 Jan 18 14:11:49 antracit kernel: [ 3168.363763] usb 1-3: Reopened EP 0x82 (count 1) Jan 18 14:11:49 antracit kernel: [ 3168.363765] usb 1-3: 0:1 Set sample rate 48000, clock 0 Jan 18 14:11:49 antracit kernel: [ 3168.363769] usb 1-3: Setting params for data EP 0x82, pipe 0x10280 Jan 18 14:11:49 antracit kernel: [ 3168.363773] usb 1-3: Set up 12 URBS, ret=0 Jan 18 14:11:49 antracit kernel: [ 3168.369529] usb 1-3: Starting data EP 0x82 (running 0) Jan 18 14:11:49 antracit kernel: [ 3168.369585] usb 1-3: 12 URBs submitted for EP 0x82 Jan 18 14:11:49 antracit kernel: [ 3168.369591] usb 1-3: Starting data EP 0x82 (running 1) Jan 18 14:11:49 antracit kernel: [ 3168.369597] usb 1-3: 0:1 Start Capture PCM Jan 18 14:11:49 antracit kernel: [ 3168.380281] usb 1-3: Closing EP 0x1 (count 1) Jan 18 14:11:49 antracit kernel: [ 3168.380297] usb 1-3: EP 0x1 closed Jan 18 14:11:54 antracit kernel: [ 3173.375555] usb 1-3: Stopping data EP 0x82 (running 2) Jan 18 14:11:54 antracit kernel: [ 3173.375567] usb 1-3: Stopping data EP 0x82 (running 1) Jan 18 14:11:54 antracit kernel: [ 3173.375582] usb 1-3: 0:1 Stop Capture PCM Jan 18 14:11:54 antracit kernel: [ 3173.388009] usb 1-3: Closing EP 0x82 (count 2) Jan 18 14:11:54 antracit kernel: [ 3173.388019] usb 1-3: Closing EP 0x82 (count 1) Jan 18 14:11:54 antracit kernel: [ 3173.388025] usb 1-3: Setting usb interface 0:0 for EP 0x82 Jan 18 14:11:54 antracit kernel: [ 3173.388273] usb 1-3: EP 0x82 closed Jan 18 14:12:03 antracit kernel: [ 3181.925328] usb 1-3: Open EP 0x82, iface=0:1, idx=1 Jan 18 14:12:03 antracit kernel: [ 3181.925335] usb 1-3: channels=8, rate=48000, format=S24_3LE, period_bytes=24576, periods=2, implicit_fb=0 Jan 18 14:12:03 antracit kernel: [ 3181.925339] usb 1-3: Reopened EP 0x82 (count 1) Jan 18 14:12:03 antracit kernel: [ 3181.925341] usb 1-3: Setting usb interface 0:0 for EP 0x82 Jan 18 14:12:03 antracit kernel: [ 3181.925435] usb 1-3: Setting usb interface 0:1 for EP 0x82 Jan 18 14:12:03 antracit kernel: [ 3181.925578] usb 1-3: 0:1 Set sample rate 48000, clock 0 Jan 18 14:12:03 antracit kernel: [ 3181.925587] usb 1-3: Setting params for data EP 0x82, pipe 0x10280 Jan 18 14:12:03 antracit kernel: [ 3181.925592] usb 1-3: Set up 12 URBS, ret=0 Jan 18 14:12:03 antracit kernel: [ 3181.925665] usb 1-3: Open EP 0x1, iface=0:1, idx=0 Jan 18 14:12:03 antracit kernel: [ 3181.925668] usb 1-3: channels=8, rate=48000, format=S24_3LE, period_bytes=24576, periods=2, implicit_fb=0 Jan 18 14:12:03 antracit kernel: [ 3181.925670] usb 1-3: 0:1 Set sample rate 48000, clock 0 Jan 18 14:12:03 antracit kernel: [ 3181.925676] usb 1-3: Setting params for data EP 0x1, pipe 0x8200 Jan 18 14:12:03 antracit kernel: [ 3181.925686] usb 1-3: Set up 3 URBS, ret=0 Jan 18 14:12:03 antracit kernel: [ 3181.925706] usb 1-3: Starting data EP 0x1 (running 0) Jan 18 14:12:03 antracit kernel: [ 3181.925740] usb 1-3: 3 URBs submitted for EP 0x1 Jan 18 14:12:03 antracit kernel: [ 3181.926306] usb 1-3: Starting data EP 0x82 (running 0) Jan 18 14:12:03 antracit kernel: [ 3181.926326] usb 1-3: 12 URBs submitted for EP 0x82 Jan 18 14:12:03 antracit kernel: [ 3181.926328] usb 1-3: Starting data EP 0x82 (running 1) Jan 18 14:12:03 antracit kernel: [ 3181.926331] usb 1-3: 0:1 Start Capture PCM Jan 18 14:12:03 antracit kernel: [ 3181.926333] usb 1-3: 0:1 Start Playback PCM Jan 18 14:15:02 antracit kernel: [ 3361.231486] usb 1-3: Stopping data EP 0x82 (running 2) Jan 18 14:15:02 antracit kernel: [ 3361.231495] usb 1-3: Stopping data EP 0x82 (running 1) Jan 18 14:15:02 antracit kernel: [ 3361.231502] usb 1-3: 0:1 Stop Capture PCM Jan 18 14:15:02 antracit kernel: [ 3361.231505] usb 1-3: Stopping data EP 0x1 (running 1) Jan 18 14:15:02 antracit kernel: [ 3361.231509] usb 1-3: 0:1 Stop Playback PCM Jan 18 14:15:02 antracit kernel: [ 3361.244756] usb 1-3: Starting data EP 0x1 (running 0) Jan 18 14:15:02 antracit kernel: [ 3361.244819] usb 1-3: 3 URBs submitted for EP 0x1 Jan 18 14:15:02 antracit kernel: [ 3361.245080] usb 1-3: Starting data EP 0x82 (running 0) Jan 18 14:15:02 antracit kernel: [ 3361.245118] usb 1-3: 12 URBs submitted for EP 0x82 Jan 18 14:15:02 antracit kernel: [ 3361.245123] usb 1-3: Starting data EP 0x82 (running 1) Jan 18 14:15:02 antracit kernel: [ 3361.245128] usb 1-3: 0:1 Start Capture PCM Jan 18 14:15:02 antracit kernel: [ 3361.245133] usb 1-3: 0:1 Start Playback PCM Jan 18 14:16:38 antracit kernel: [ 3457.437255] radeon_dp_aux_transfer_native: 74 callbacks suppressed Jan 18 14:17:03 antracit kernel: [ 3481.969901] usb 1-3: Stopping data EP 0x82 (running 2) Jan 18 14:17:03 antracit kernel: [ 3481.969913] usb 1-3: Stopping data EP 0x82 (running 1) Jan 18 14:17:03 antracit kernel: [ 3481.969925] usb 1-3: 0:1 Stop Capture PCM Jan 18 14:17:03 antracit kernel: [ 3481.969930] usb 1-3: Stopping data EP 0x1 (running 1) Jan 18 14:17:03 antracit kernel: [ 3481.969937] usb 1-3: 0:1 Stop Playback PCM Jan 18 14:17:03 antracit kernel: [ 3481.980063] usb 1-3: Closing EP 0x82 (count 2) Jan 18 14:17:03 antracit kernel: [ 3481.980075] usb 1-3: Closing EP 0x82 (count 1) Jan 18 14:17:03 antracit kernel: [ 3481.980080] usb 1-3: EP 0x82 closed Jan 18 14:17:03 antracit kernel: [ 3481.988076] usb 1-3: Closing EP 0x1 (count 1) Jan 18 14:17:03 antracit kernel: [ 3481.988087] usb 1-3: Setting usb interface 0:0 for EP 0x1 Jan 18 14:17:03 antracit kernel: [ 3481.988295] usb 1-3: EP 0x1 closed