On Wed, Jan 29, 2025 at 05:40:04PM +0100, Takashi Iwai wrote: > On Wed, 29 Jan 2025 17:05:19 +0100, > John Keeping wrote: > > > > In the two loops before setting the MIDIStreaming descriptors, > > ms_in_desc.baAssocJackID[] has entries written for "in_ports" values and > > ms_out_desc.baAssocJackID[] has entries written for "out_ports" values. > > But the counts and lengths are set the other way round in the > > descriptors. > > > > Fix the descriptors so that the bNumEmbMIDIJack values and the > > descriptor lengths match the number of entries populated in the trailing > > arrays. > > Are you sure that it's a correct change? > > IIUC, the in_ports and out_ports parameters are for external IN and > OUT jacks, where an external OUT jack is connected to an embedded IN > jack, and an external IN jack is connected to an embedded OUT jack. I think it depends how the in_ports and out_ports values in configfs are interpreted. However, the case where in_ports != out_ports has been broken since these files were added! Without this change, setting in_ports=4 out_ports=2 we end up with: Endpoint Descriptor: [...] bEndpointAddress 0x01 EP 1 OUT [...] MIDIStreaming Endpoint Descriptor: bLength 8 bDescriptorType 37 bDescriptorSubtype 1 (Invalid) bNumEmbMIDIJack 4 baAssocJackID( 0) 9 baAssocJackID( 1) 11 baAssocJackID( 2) 9 baAssocJackID( 3) 0 Endpoint Descriptor: [...] bEndpointAddress 0x81 EP 1 IN [...] MIDIStreaming Endpoint Descriptor: bLength 6 bDescriptorType 37 bDescriptorSubtype 1 (Invalid) bNumEmbMIDIJack 2 baAssocJackID( 0) 2 baAssocJackID( 1) 4 Note that baAssocJackID values 2 and 3 on the OUT endpoint are wrong.