All of lore.kernel.org
 help / color / mirror / Atom feed
* Support for NUX MG-300 USB interface
@ 2021-01-17 18:56 Mike Oliphant
  2021-01-18  7:43 ` Takashi Iwai
  0 siblings, 1 reply; 16+ messages in thread
From: Mike Oliphant @ 2021-01-17 18:56 UTC (permalink / raw)
  To: alsa-devel

I recently got a NUX MG-300 USB guitar fx interface with high hopes that it
would work in Linux. It is supposed to be class-compliant, and works in iOS
and macOS without a driver.

Unfortunately, while it is recognized as a USB audio device by Linux, it is
not working.

The core issue seems to be that "stream0" reports no playback rates. dmesg
also shows errors, including "__uac_clock_find_source(): selector reported
illegal value".

Any help identifying the issue would be much appreciated. I have some
experience troubleshooting the USB audio kernel code and am happy to try
doing so if I can get a nudge in the right direction.

Output from "stream0", dmesg, and lsusb follows.

Thanks!

Mike

"stream0"
---
NUX NUX MG-300 AUDIO at usb-0000:00:1a.7-1.3, high speed : USB Audio

Playback:
  Status: Stop
  Interface 1
    Altset 1
    Format: S32_LE
    Channels: 2
    Endpoint: 0x01 (1 OUT) (ASYNC)
    Rates:
    Data packet interval: 1000 us
    Bits: 24
    Channel map: FL FR
    Sync Endpoint: 0x81 (1 IN)
    Sync EP Interface: 1
    Sync EP Altset: 1
    Implicit Feedback Mode: No

Capture:
  Status: Stop
  Interface 2
    Altset 1
    Format: S32_LE
    Channels: 2
    Endpoint: 0x82 (2 IN) (ASYNC)
    Rates:
    Data packet interval: 1000 us
    Bits: 24
    Channel map: FL FR
---

dmesg log:
---
[  141.265806] usb 3-1.3: new high-speed USB device number 9 using ehci-pci
[  141.374351] usb 3-1.3: config 1 interface 3 altsetting 0 bulk endpoint
0x4 has invalid maxpacket 256
[  141.374370] usb 3-1.3: config 1 interface 3 altsetting 0 bulk endpoint
0x83 has invalid maxpacket 256
[  141.375373] usb 3-1.3: New USB device found, idVendor=1fc9,
idProduct=8260, bcdDevice= 1.00
[  141.375389] usb 3-1.3: New USB device strings: Mfr=1, Product=2,
SerialNumber=3
[  141.375396] usb 3-1.3: Product: NUX MG-300 AUDIO
[  141.375401] usb 3-1.3: Manufacturer: NUX
[  141.375405] usb 3-1.3: SerialNumber: 2008101346
[  141.468523] usb 3-1.3: __uac_clock_find_source(): selector reported
illegal value, id 40, ret 0
[  141.468531] usb 3-1.3: parse_audio_format_rates_v2v3(): unable to find
clock source (clock -22)
[  141.468771] usb 3-1.3: __uac_clock_find_source(): selector reported
illegal value, id 40, ret 0
[  141.468897] usb 3-1.3: __uac_clock_find_source(): selector reported
illegal value, id 40, ret 0
[  141.469274] usb 3-1.3: __uac_clock_find_source(): selector reported
illegal value, id 40, ret 0
[  141.469279] usb 3-1.3: parse_audio_format_rates_v2v3(): unable to find
clock source (clock -22)
[  141.469521] usb 3-1.3: __uac_clock_find_source(): selector reported
illegal value, id 40, ret 0
[  141.469646] usb 3-1.3: __uac_clock_find_source(): selector reported
illegal value, id 40, ret 0
[  141.472645] usbcore: registered new interface driver snd-usb-audio
---

lsusb output:
---
Bus 003 Device 009: ID 1fc9:8260 NXP Semiconductors
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x1fc9 NXP Semiconductors
  idProduct          0x8260
  bcdDevice            1.00
  iManufacturer           1
  iProduct                2
  iSerial                 3
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x013e
    bNumInterfaces          4
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xc0
      Self Powered
    MaxPower                2mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         3
      bFunctionClass          1 Audio
      bFunctionSubClass       0
      bFunctionProtocol      32
      iFunction               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      1 Control Device
      bInterfaceProtocol     32
      iInterface              0
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdADC               2.00
        bCategory               8
        wTotalLength       0x0065
        bmControls           0x00
      AudioControl Interface Descriptor:
        bLength                 8
        bDescriptorType        36
        bDescriptorSubtype     10 (CLOCK_SOURCE)
        bClockID               41
        bmAttributes            3 Internal programmable clock
        bmControls           0x07
          Clock Frequency Control (read/write)
          Clock Validity Control (read-only)
        bAssocTerminal          0
        iClockSource            0
      AudioControl Interface Descriptor:
        bLength                 8
        bDescriptorType        36
        bDescriptorSubtype     11 (CLOCK_SELECTOR)
        bClockID               40
        bNrInPins               1
        baCSourceID(0)         41
        bmControls           0x03
          Clock Selector Control (read/write)
        iClockSelector          0
      AudioControl Interface Descriptor:
        bLength                17
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             2
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bCSourceID             40
        bNrChannels             2
        bmChannelConfig    0x00000000
        iChannelNames           0
        bmControls         0x0000
        iTerminal               0
      AudioControl Interface Descriptor:
        bLength                18
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                10
        bSourceID               2
        bmaControls(0)     0x0000000f
          Mute Control (read/write)
          Volume Control (read/write)
        bmaControls(1)     0x0000000f
          Mute Control (read/write)
          Volume Control (read/write)
        bmaControls(2)     0x0000000f
          Mute Control (read/write)
          Volume Control (read/write)
        iFeature                0
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID            20
        wTerminalType      0x0301 Speaker
        bAssocTerminal          0
        bSourceID              10
        bCSourceID             40
        bmControls         0x0000
        iTerminal               0
      AudioControl Interface Descriptor:
        bLength                17
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             1
        wTerminalType      0x0201 Microphone
        bAssocTerminal          0
        bCSourceID             40
        bNrChannels             2
        bmChannelConfig    0x00000000
        iChannelNames           0
        bmControls         0x0000
        iTerminal               0
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID            22
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bSourceID               2
        bCSourceID             40
        bmControls         0x0000
        iTerminal               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32
      iInterface              0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           2
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32
      iInterface              0
      AudioStreaming Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           2
        bmControls           0x00
        bFormatType             1
        bmFormats          0x00000001
          PCM
        bNrChannels             2
        bmChannelConfig    0x00000000
        iChannelNames           0
      AudioStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bSubslotSize            4
        bBitResolution         24
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x0258  1x 600 bytes
        bInterval               4
        AudioStreaming Endpoint Descriptor:
          bLength                 8
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bmControls           0x00
          bLockDelayUnits         0 Undefined
          wLockDelay         0x0000
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes           17
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Feedback
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval               4
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32
      iInterface              0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       1
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32
      iInterface              0
      AudioStreaming Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink          22
        bmControls           0x00
        bFormatType             1
        bmFormats          0x00000001
          PCM
        bNrChannels             2
        bmChannelConfig    0x00000000
        iChannelNames           0
      AudioStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bSubslotSize            4
        bBitResolution         24
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x0258  1x 600 bytes
        bInterval               4
        AudioStreaming Endpoint Descriptor:
          bLength                 8
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bmControls           0x00
          bLockDelayUnits         0 Undefined
          wLockDelay         0x0000
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         1 Audio
      bInterfaceSubClass      3 MIDI Streaming
      bInterfaceProtocol      0
      iInterface              4
      MIDIStreaming Interface Descriptor:
        bLength                 7
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdADC               1.00
        wTotalLength       0x0041
      MIDIStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (MIDI_IN_JACK)
        bJackType               1 Embedded
        bJackID                 1
        iJack                   0
      MIDIStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (MIDI_IN_JACK)
        bJackType               2 External
        bJackID                 2
        iJack                   0
      MIDIStreaming Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      3 (MIDI_OUT_JACK)
        bJackType               1 Embedded
        bJackID                 3
        bNrInputPins            1
        baSourceID( 0)          2
        BaSourcePin( 0)         1
        iJack                   0
      MIDIStreaming Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      3 (MIDI_OUT_JACK)
        bJackType               2 External
        bJackID                 4
        bNrInputPins            1
        baSourceID( 0)          1
        BaSourcePin( 0)         1
        iJack                   0
      Endpoint Descriptor:
        bLength                 9
        bDescriptorType         5
        bEndpointAddress     0x04  EP 4 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0100  1x 256 bytes
        bInterval               0
        bRefresh                0
        bSynchAddress           0
        MIDIStreaming Endpoint Descriptor:
          bLength                 5
          bDescriptorType        37
          bDescriptorSubtype      1 (GENERAL)
          bNumEmbMIDIJack         1
          baAssocJackID( 0)       1
      Endpoint Descriptor:
        bLength                 9
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0100  1x 256 bytes
        bInterval               0
        bRefresh                0
        bSynchAddress           0
        MIDIStreaming Endpoint Descriptor:
          bLength                 5
          bDescriptorType        37
          bDescriptorSubtype      1 (GENERAL)
          bNumEmbMIDIJack         1
          baAssocJackID( 0)       3
---

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Support for NUX MG-300 USB interface
  2021-01-17 18:56 Support for NUX MG-300 USB interface Mike Oliphant
@ 2021-01-18  7:43 ` Takashi Iwai
  2021-01-18 16:33   ` Mike Oliphant
  0 siblings, 1 reply; 16+ messages in thread
From: Takashi Iwai @ 2021-01-18  7:43 UTC (permalink / raw)
  To: Mike Oliphant; +Cc: alsa-devel

On Sun, 17 Jan 2021 19:56:01 +0100,
Mike Oliphant wrote:
> 
> I recently got a NUX MG-300 USB guitar fx interface with high hopes that it
> would work in Linux. It is supposed to be class-compliant, and works in iOS
> and macOS without a driver.
> 
> Unfortunately, while it is recognized as a USB audio device by Linux, it is
> not working.
> 
> The core issue seems to be that "stream0" reports no playback rates. dmesg
> also shows errors, including "__uac_clock_find_source(): selector reported
> illegal value".
> 
> Any help identifying the issue would be much appreciated. I have some
> experience troubleshooting the USB audio kernel code and am happy to try
> doing so if I can get a nudge in the right direction.
> 
> Output from "stream0", dmesg, and lsusb follows.

Did you try the latest 5.11-rc kernel?  There have been lots of
changes in USB-audio and this might work better there.

If it still doesn't work with 5.11-rc, please try to enable the debug
option, e.g. boot with snd_usb_audio.dyndbg=+p boot option, plug the
device, and get the kernel logs (at plugging and during the audio
operations).


thanks,

Takashi

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Support for NUX MG-300 USB interface
  2021-01-18  7:43 ` Takashi Iwai
@ 2021-01-18 16:33   ` Mike Oliphant
  2021-01-18 17:54     ` Mike Oliphant
  0 siblings, 1 reply; 16+ messages in thread
From: Mike Oliphant @ 2021-01-18 16:33 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

Thanks for the response. I'm running a very recent build of the master
kernel tree (~ 5.11-rc2).

I'll give dyndbg a try.

Mike

On Sun, Jan 17, 2021 at 11:43 PM Takashi Iwai <tiwai@suse.de> wrote:

> On Sun, 17 Jan 2021 19:56:01 +0100,
> Mike Oliphant wrote:
> >
> > I recently got a NUX MG-300 USB guitar fx interface with high hopes that
> it
> > would work in Linux. It is supposed to be class-compliant, and works in
> iOS
> > and macOS without a driver.
> >
> > Unfortunately, while it is recognized as a USB audio device by Linux, it
> is
> > not working.
> >
> > The core issue seems to be that "stream0" reports no playback rates.
> dmesg
> > also shows errors, including "__uac_clock_find_source(): selector
> reported
> > illegal value".
> >
> > Any help identifying the issue would be much appreciated. I have some
> > experience troubleshooting the USB audio kernel code and am happy to try
> > doing so if I can get a nudge in the right direction.
> >
> > Output from "stream0", dmesg, and lsusb follows.
>
> Did you try the latest 5.11-rc kernel?  There have been lots of
> changes in USB-audio and this might work better there.
>
> If it still doesn't work with 5.11-rc, please try to enable the debug
> option, e.g. boot with snd_usb_audio.dyndbg=+p boot option, plug the
> device, and get the kernel logs (at plugging and during the audio
> operations).
>
>
> thanks,
>
> Takashi
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Support for NUX MG-300 USB interface
  2021-01-18 16:33   ` Mike Oliphant
@ 2021-01-18 17:54     ` Mike Oliphant
  2021-01-18 19:19       ` Takashi Iwai
  0 siblings, 1 reply; 16+ messages in thread
From: Mike Oliphant @ 2021-01-18 17:54 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

Here is the dmesg output with dyndbg enabled. It looks like it is failing
to find the clock source, and hence cannot obtain the valid sample rates.

It looks like it is finding the clock selector (id: 40), but
"uac_clock_selector_get_val()" is returning zero, and it never gets the
clock source (id: 41).

[  229.641481] usb 2-1.3: new high-speed USB device number 9 using ehci-pci
[  229.750316] usb 2-1.3: config 1 interface 3 altsetting 0 bulk endpoint
0x4 has invalid maxpacket 256
[  229.750335] usb 2-1.3: config 1 interface 3 altsetting 0 bulk endpoint
0x83 has invalid maxpacket 256
[  229.751432] usb 2-1.3: New USB device found, idVendor=1fc9,
idProduct=8260, bcdDevice= 1.00
[  229.751452] usb 2-1.3: New USB device strings: Mfr=1, Product=2,
SerialNumber=3
[  229.751459] usb 2-1.3: Product: NUX MG-300 AUDIO
[  229.751464] usb 2-1.3: Manufacturer: NUX
[  229.751468] usb 2-1.3: SerialNumber: 2008101346
[  230.170840] usb 2-1.3: __uac_clock_find_source(): selector reported
illegal value, id 40, ret 0
[  230.170860] usb 2-1.3: parse_audio_format_rates_v2v3(): unable to find
clock source (clock -22)
[  230.170871] usb 2-1.3: 1:1: found sync_ep=0x81, iface=1, alt=1,
implicit_fb=0
[  230.170879] usb 2-1.3: 1:1: add audio endpoint 0x1
[  230.170907] usb 2-1.3: Creating new data endpoint #1
[  230.170915] usb 2-1.3: Creating new sync endpoint #81
[  230.171181] usb 2-1.3: 1:1 Set sample rate 0, clock 40
[  230.171408] usb 2-1.3: __uac_clock_find_source(): selector reported
illegal value, id 40, ret 0
[  230.171657] usb 2-1.3: __uac_clock_find_source(): selector reported
illegal value, id 40, ret 0
[  230.172463] usb 2-1.3: __uac_clock_find_source(): selector reported
illegal value, id 40, ret 0
[  230.172480] usb 2-1.3: parse_audio_format_rates_v2v3(): unable to find
clock source (clock -22)
[  230.172490] usb 2-1.3: 2:1: add audio endpoint 0x82
[  230.172512] usb 2-1.3: Creating new data endpoint #82
[  230.172707] usb 2-1.3: 2:1 Set sample rate 0, clock 40
[  230.172832] usb 2-1.3: __uac_clock_find_source(): selector reported
illegal value, id 40, ret 0
[  230.173079] usb 2-1.3: __uac_clock_find_source(): selector reported
illegal value, id 40, ret 0
[  230.173442] usb 2-1.3: [10] FU [PCM Playback Switch] ch = 2, val = 0/1/1
[  230.173450] usb 2-1.3: [10] FU [PCM Playback Switch] ch = 1, val = 0/1/1
[  230.173949] usb 2-1.3: RANGE setting not yet supported
[  230.174700] usb 2-1.3: [10] FU [PCM Playback Volume] ch = 2, val =
-16384/0/256
[  230.175074] usb 2-1.3: RANGE setting not yet supported
[  230.175823] usb 2-1.3: [10] FU [PCM Playback Volume] ch = 1, val =
-16384/0/256
[  230.176631] usbcore: registered new interface driver snd-usb-audio

On Mon, Jan 18, 2021 at 8:33 AM Mike Oliphant <oliphant@nostatic.org> wrote:

> Thanks for the response. I'm running a very recent build of the master
> kernel tree (~ 5.11-rc2).
>
> I'll give dyndbg a try.
>
> Mike
>
> On Sun, Jan 17, 2021 at 11:43 PM Takashi Iwai <tiwai@suse.de> wrote:
>
>> On Sun, 17 Jan 2021 19:56:01 +0100,
>> Mike Oliphant wrote:
>> >
>> > I recently got a NUX MG-300 USB guitar fx interface with high hopes
>> that it
>> > would work in Linux. It is supposed to be class-compliant, and works in
>> iOS
>> > and macOS without a driver.
>> >
>> > Unfortunately, while it is recognized as a USB audio device by Linux,
>> it is
>> > not working.
>> >
>> > The core issue seems to be that "stream0" reports no playback rates.
>> dmesg
>> > also shows errors, including "__uac_clock_find_source(): selector
>> reported
>> > illegal value".
>> >
>> > Any help identifying the issue would be much appreciated. I have some
>> > experience troubleshooting the USB audio kernel code and am happy to try
>> > doing so if I can get a nudge in the right direction.
>> >
>> > Output from "stream0", dmesg, and lsusb follows.
>>
>> Did you try the latest 5.11-rc kernel?  There have been lots of
>> changes in USB-audio and this might work better there.
>>
>> If it still doesn't work with 5.11-rc, please try to enable the debug
>> option, e.g. boot with snd_usb_audio.dyndbg=+p boot option, plug the
>> device, and get the kernel logs (at plugging and during the audio
>> operations).
>>
>>
>> thanks,
>>
>> Takashi
>>
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Support for NUX MG-300 USB interface
  2021-01-18 17:54     ` Mike Oliphant
@ 2021-01-18 19:19       ` Takashi Iwai
  2021-01-18 21:15         ` Mike Oliphant
  0 siblings, 1 reply; 16+ messages in thread
From: Takashi Iwai @ 2021-01-18 19:19 UTC (permalink / raw)
  To: Mike Oliphant; +Cc: alsa-devel

On Mon, 18 Jan 2021 18:54:57 +0100,
Mike Oliphant wrote:
> 
> Here is the dmesg output with dyndbg enabled. It looks like it is failing
> to find the clock source, and hence cannot obtain the valid sample rates.
> 
> It looks like it is finding the clock selector (id: 40), but
> "uac_clock_selector_get_val()" is returning zero, and it never gets the
> clock source (id: 41).

Aha.  Maybe the firmware doesn't expect it being asked as it's the
single connection.

Does the patch below help anything?


Takashi

--- a/sound/usb/clock.c
+++ b/sound/usb/clock.c
@@ -298,6 +298,11 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
 	if (selector) {
 		int ret, i, cur;
 
+		if (selector->bNrInPins == 1) {
+			ret = 1;
+			goto find_source;
+		}
+
 		/* the entity ID we are looking for is a selector.
 		 * find out what it currently selects */
 		ret = uac_clock_selector_get_val(chip, selector->bClockID);
@@ -314,6 +319,7 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
 			return -EINVAL;
 		}
 
+	find_source:
 		cur = ret;
 		ret = __uac_clock_find_source(chip, fmt,
 					      selector->baCSourceID[ret - 1],

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Support for NUX MG-300 USB interface
  2021-01-18 19:19       ` Takashi Iwai
@ 2021-01-18 21:15         ` Mike Oliphant
  2021-01-18 21:59           ` Takashi Iwai
  0 siblings, 1 reply; 16+ messages in thread
From: Mike Oliphant @ 2021-01-18 21:15 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

Progress - thanks for the patch!

That got rid of the clock errors, and the the device now reports a 48000
sample rate, which is correct.

Unfortunately, it still isn't working properly. Playback doesn't seem to
work at all. Capture kind of works - it does record, but the audio is
extremely noisy.

Here is the current dmesg output when the device is connected.

Notable is the error "No valid sample rate available for 1:1, assuming a
firmware bug".

Also notable is "1:1 Set sample rate 48000, clock 40" - where "40" is the
id of the clock selector - "41" is the id of the actual clock source. So
maybe something is still getting wired up wrong?


[  418.366449] usb 3-1.2: new high-speed USB device number 6 using ehci-pci
[  418.479099] usb 3-1.2: config 1 interface 3 altsetting 0 bulk endpoint
0x4 has invalid maxpacket 256
[  418.479118] usb 3-1.2: config 1 interface 3 altsetting 0 bulk endpoint
0x83 has invalid maxpacket 256
[  418.480085] usb 3-1.2: New USB device found, idVendor=1fc9,
idProduct=8260, bcdDevice= 1.00
[  418.480100] usb 3-1.2: New USB device strings: Mfr=1, Product=2,
SerialNumber=3
[  418.480107] usb 3-1.2: Product: NUX MG-300 AUDIO
[  418.480112] usb 3-1.2: Manufacturer: NUX
[  418.480117] usb 3-1.2: SerialNumber: 2008101346
[  418.482025] usb 3-1.2: No valid sample rate available for 1:1, assuming
a firmware bug
[  418.482041] usb 3-1.2: 1:1: found sync_ep=0x81, iface=1, alt=1,
implicit_fb=0
[  418.482049] usb 3-1.2: 1:1: add audio endpoint 0x1
[  418.482078] usb 3-1.2: Creating new data endpoint #1
[  418.482086] usb 3-1.2: Creating new sync endpoint #81
[  418.482666] usb 3-1.2: 1:1 Set sample rate 48000, clock 40
[  418.484525] usb 3-1.2: No valid sample rate available for 2:1, assuming
a firmware bug
[  418.484545] usb 3-1.2: 2:1: add audio endpoint 0x82
[  418.484584] usb 3-1.2: Creating new data endpoint #82
[  418.484899] usb 3-1.2: 2:1 Set sample rate 48000, clock 40
[  418.485800] usb 3-1.2: [10] FU [PCM Playback Switch] ch = 2, val = 0/1/1
[  418.485822] usb 3-1.2: [10] FU [PCM Playback Switch] ch = 1, val = 0/1/1
[  418.486484] usb 3-1.2: RANGE setting not yet supported
[  418.487402] usb 3-1.2: [10] FU [PCM Playback Volume] ch = 2, val =
-16384/0/256
[  418.487899] usb 3-1.2: RANGE setting not yet supported
[  418.488774] usb 3-1.2: [10] FU [PCM Playback Volume] ch = 1, val =
-16384/0/256
[  418.541357] usb 3-1.2: Open EP 0x82, iface=2:1, idx=0
[  418.541363] usb 3-1.2:   channels=2, rate=48000, format=S32_LE,
period_bytes=9592, periods=4, implicit_fb=0
[  418.541367] usb 3-1.2: Setting usb interface 2:0 for EP 0x82
[  418.541524] usb 3-1.2: 2:1 Set sample rate 48000, clock 40
[  418.542000] usb 3-1.2: Setting params for data EP 0x82, pipe 0x10680
[  418.542007] usb 3-1.2: Set up 12 URBS, ret=0
[  418.542009] usb 3-1.2: Setting usb interface 2:1 for EP 0x82
[  418.545012] usb 3-1.2: Closing EP 0x82 (count 1)
[  418.545018] usb 3-1.2: Setting usb interface 2:0 for EP 0x82
[  418.545157] usb 3-1.2: EP 0x82 closed
[  418.545620] usb 3-1.2: Open EP 0x82, iface=2:1, idx=0
[  418.545624] usb 3-1.2:   channels=2, rate=48000, format=S32_LE,
period_bytes=9592, periods=4, implicit_fb=0
[  418.545627] usb 3-1.2: Setting usb interface 2:0 for EP 0x82
[  418.545893] usb 3-1.2: 2:1 Set sample rate 48000, clock 40
[  418.546257] usb 3-1.2: Setting params for data EP 0x82, pipe 0x10680
[  418.546263] usb 3-1.2: Set up 12 URBS, ret=0
[  418.546266] usb 3-1.2: Setting usb interface 2:1 for EP 0x82
[  418.546841] usb 3-1.2: Closing EP 0x82 (count 1)
[  418.546845] usb 3-1.2: Setting usb interface 2:0 for EP 0x82
[  418.547052] usb 3-1.2: EP 0x82 closed
[  418.547467] usb 3-1.2: Open EP 0x1, iface=1:1, idx=0
[  418.547470] usb 3-1.2:   channels=2, rate=48000, format=S32_LE,
period_bytes=9592, periods=4, implicit_fb=0
[  418.547473] usb 3-1.2: Open EP 0x81, iface=1:1, idx=1
[  418.547476] usb 3-1.2:   channels=2, rate=48000, format=S32_LE,
period_bytes=9592, periods=4, implicit_fb=0
[  418.547478] usb 3-1.2: Setting usb interface 1:0 for EP 0x1
[  418.547643] usb 3-1.2: 1:1 Set sample rate 48000, clock 40
[  418.548129] usb 3-1.2: Setting params for data EP 0x1, pipe 0x8600
[  418.548143] usb 3-1.2: Set up 12 URBS, ret=0
[  418.548146] usb 3-1.2: Setting usb interface 1:1 for EP 0x1
[  418.548420] usb 3-1.2: Setting params for sync EP 0x81, pipe 0x8680
[  418.548425] usb 3-1.2: Set up 4 URBS, ret=0
[  418.548443] usb 3-1.2: Starting data EP 0x1 (running 0)
[  418.548474] usb 3-1.2: 12 URBs submitted for EP 0x1
[  418.548477] usb 3-1.2: Starting sync EP 0x81 (running 0)
[  418.548487] usb 3-1.2: 4 URBs submitted for EP 0x81
[  418.549724] usb 3-1.2: Open EP 0x82, iface=2:1, idx=0
[  418.549729] usb 3-1.2:   channels=2, rate=48000, format=S32_LE,
period_bytes=9592, periods=4, implicit_fb=0
[  418.549732] usb 3-1.2: Setting usb interface 2:0 for EP 0x82
[  418.549888] usb 3-1.2: 2:1 Set sample rate 48000, clock 40
[  418.550256] usb 3-1.2: Setting params for data EP 0x82, pipe 0x10680
[  418.550259] usb 3-1.2: Set up 12 URBS, ret=0
[  418.550261] usb 3-1.2: Setting usb interface 2:1 for EP 0x82
[  418.550455] usb 3-1.2: Closing EP 0x82 (count 1)
[  418.550460] usb 3-1.2: Setting usb interface 2:0 for EP 0x82
[  418.550659] usb 3-1.2: EP 0x82 closed
[  418.551298] usb 3-1.2: Open EP 0x82, iface=2:1, idx=0
[  418.551303] usb 3-1.2:   channels=2, rate=48000, format=S32_LE,
period_bytes=9592, periods=4, implicit_fb=0
[  418.551307] usb 3-1.2: Setting usb interface 2:0 for EP 0x82
[  418.551528] usb 3-1.2: 2:1 Set sample rate 48000, clock 40
[  418.552021] usb 3-1.2: Setting params for data EP 0x82, pipe 0x10680
[  418.552028] usb 3-1.2: Set up 12 URBS, ret=0
[  418.552031] usb 3-1.2: Setting usb interface 2:1 for EP 0x82
[  418.552168] usb 3-1.2: Stopping sync EP 0x81 (running 1)
[  418.552174] usb 3-1.2: Stopping data EP 0x1 (running 1)
[  418.566466] usb 3-1.2: Closing EP 0x1 (count 1)
[  418.566472] usb 3-1.2: Setting usb interface 1:0 for EP 0x1
[  418.566772] usb 3-1.2: EP 0x1 closed
[  418.566775] usb 3-1.2: Closing EP 0x81 (count 1)
[  418.566777] usb 3-1.2: Setting usb interface 1:0 for EP 0x81
[  418.566954] usb 3-1.2: EP 0x81 closed
[  418.567038] usb 3-1.2: Closing EP 0x82 (count 1)
[  418.567040] usb 3-1.2: Setting usb interface 2:0 for EP 0x82
[  418.567257] usb 3-1.2: EP 0x82 closed
[  418.573720] usb 3-1.2: Open EP 0x1, iface=1:1, idx=0
[  418.573724] usb 3-1.2:   channels=2, rate=48000, format=S32_LE,
period_bytes=9592, periods=4, implicit_fb=0
[  418.573727] usb 3-1.2: Open EP 0x81, iface=1:1, idx=1
[  418.573729] usb 3-1.2:   channels=2, rate=48000, format=S32_LE,
period_bytes=9592, periods=4, implicit_fb=0
[  418.573732] usb 3-1.2: Setting usb interface 1:0 for EP 0x1
[  418.573927] usb 3-1.2: 1:1 Set sample rate 48000, clock 40
[  418.574564] usb 3-1.2: Setting params for data EP 0x1, pipe 0x8600
[  418.574570] usb 3-1.2: Set up 12 URBS, ret=0
[  418.574572] usb 3-1.2: Setting usb interface 1:1 for EP 0x1
[  418.574659] usb 3-1.2: Setting params for sync EP 0x81, pipe 0x8680
[  418.574662] usb 3-1.2: Set up 4 URBS, ret=0
[  418.574676] usb 3-1.2: Starting data EP 0x1 (running 0)
[  418.574700] usb 3-1.2: 12 URBs submitted for EP 0x1
[  418.574701] usb 3-1.2: Starting sync EP 0x81 (running 0)
[  418.574709] usb 3-1.2: 4 URBs submitted for EP 0x81
[  418.575117] usb 3-1.2: Open EP 0x82, iface=2:1, idx=0
[  418.575120] usb 3-1.2:   channels=2, rate=48000, format=S32_LE,
period_bytes=9592, periods=4, implicit_fb=0
[  418.575123] usb 3-1.2: Setting usb interface 2:0 for EP 0x82
[  418.575384] usb 3-1.2: 2:1 Set sample rate 48000, clock 40
[  418.575916] usb 3-1.2: Setting params for data EP 0x82, pipe 0x10680
[  418.575926] usb 3-1.2: Set up 12 URBS, ret=0
[  418.575928] usb 3-1.2: Setting usb interface 2:1 for EP 0x82
[  418.576065] usb 3-1.2: Closing EP 0x82 (count 1)
[  418.576069] usb 3-1.2: Setting usb interface 2:0 for EP 0x82
[  418.576171] usb 3-1.2: EP 0x82 closed
[  418.576574] usb 3-1.2: Open EP 0x82, iface=2:1, idx=0
[  418.576578] usb 3-1.2:   channels=2, rate=48000, format=S32_LE,
period_bytes=9592, periods=4, implicit_fb=0
[  418.576581] usb 3-1.2: Setting usb interface 2:0 for EP 0x82
[  418.576632] usb 3-1.2: 2:1 Set sample rate 48000, clock 40
[  418.577128] usb 3-1.2: Setting params for data EP 0x82, pipe 0x10680
[  418.577132] usb 3-1.2: Set up 12 URBS, ret=0
[  418.577134] usb 3-1.2: Setting usb interface 2:1 for EP 0x82
[  418.577404] usb 3-1.2: Stopping sync EP 0x81 (running 1)
[  418.577408] usb 3-1.2: Stopping data EP 0x1 (running 1)
[  418.594462] usb 3-1.2: Closing EP 0x1 (count 1)
[  418.594469] usb 3-1.2: Setting usb interface 1:0 for EP 0x1
[  418.594806] usb 3-1.2: EP 0x1 closed
[  418.594810] usb 3-1.2: Closing EP 0x81 (count 1)
[  418.594812] usb 3-1.2: Setting usb interface 1:0 for EP 0x81
[  418.595093] usb 3-1.2: EP 0x81 closed
[  418.595187] usb 3-1.2: Closing EP 0x82 (count 1)
[  418.595189] usb 3-1.2: Setting usb interface 2:0 for EP 0x82
[  418.595520] usb 3-1.2: EP 0x82 closed
[  418.610935] usb 3-1.2: Open EP 0x1, iface=1:1, idx=0
[  418.610943] usb 3-1.2:   channels=2, rate=48000, format=S32_LE,
period_bytes=384000, periods=2, implicit_fb=0
[  418.610946] usb 3-1.2: Open EP 0x81, iface=1:1, idx=1
[  418.610949] usb 3-1.2:   channels=2, rate=48000, format=S32_LE,
period_bytes=384000, periods=2, implicit_fb=0
[  418.610952] usb 3-1.2: Setting usb interface 1:0 for EP 0x1
[  418.611223] usb 3-1.2: 1:1 Set sample rate 48000, clock 40
[  418.611990] usb 3-1.2: Setting params for data EP 0x1, pipe 0x8600
[  418.612013] usb 3-1.2: Set up 12 URBS, ret=0
[  418.612020] usb 3-1.2: Setting usb interface 1:1 for EP 0x1
[  418.612281] usb 3-1.2: Setting params for sync EP 0x81, pipe 0x8680
[  418.612285] usb 3-1.2: Set up 4 URBS, ret=0
[  418.612363] usb 3-1.2: Starting data EP 0x1 (running 0)
[  418.612389] usb 3-1.2: 12 URBs submitted for EP 0x1
[  418.612390] usb 3-1.2: Starting sync EP 0x81 (running 0)
[  418.612397] usb 3-1.2: 4 URBs submitted for EP 0x81
[  418.613337] usb 3-1.2: 1:1 Start Playback PCM
[  418.613810] usb 3-1.2: Open EP 0x82, iface=2:1, idx=0
[  418.613813] usb 3-1.2:   channels=2, rate=48000, format=S32_LE,
period_bytes=384000, periods=2, implicit_fb=0
[  418.613815] usb 3-1.2: Setting usb interface 2:0 for EP 0x82
[  418.614078] usb 3-1.2: 2:1 Set sample rate 48000, clock 40
[  418.614639] usb 3-1.2: Setting params for data EP 0x82, pipe 0x10680
[  418.614648] usb 3-1.2: Set up 12 URBS, ret=0
[  418.614653] usb 3-1.2: Setting usb interface 2:1 for EP 0x82
[  418.615844] usb 3-1.2: Starting data EP 0x82 (running 0)
[  418.615879] usb 3-1.2: 12 URBs submitted for EP 0x82
[  418.615882] usb 3-1.2: 2:1 Start Capture PCM

On Mon, Jan 18, 2021 at 11:19 AM Takashi Iwai <tiwai@suse.de> wrote:

> On Mon, 18 Jan 2021 18:54:57 +0100,
> Mike Oliphant wrote:
> >
> > Here is the dmesg output with dyndbg enabled. It looks like it is failing
> > to find the clock source, and hence cannot obtain the valid sample rates.
> >
> > It looks like it is finding the clock selector (id: 40), but
> > "uac_clock_selector_get_val()" is returning zero, and it never gets the
> > clock source (id: 41).
>
> Aha.  Maybe the firmware doesn't expect it being asked as it's the
> single connection.
>
> Does the patch below help anything?
>
>
> Takashi
>
> --- a/sound/usb/clock.c
> +++ b/sound/usb/clock.c
> @@ -298,6 +298,11 @@ static int __uac_clock_find_source(struct
> snd_usb_audio *chip,
>         if (selector) {
>                 int ret, i, cur;
>
> +               if (selector->bNrInPins == 1) {
> +                       ret = 1;
> +                       goto find_source;
> +               }
> +
>                 /* the entity ID we are looking for is a selector.
>                  * find out what it currently selects */
>                 ret = uac_clock_selector_get_val(chip, selector->bClockID);
> @@ -314,6 +319,7 @@ static int __uac_clock_find_source(struct
> snd_usb_audio *chip,
>                         return -EINVAL;
>                 }
>
> +       find_source:
>                 cur = ret;
>                 ret = __uac_clock_find_source(chip, fmt,
>                                               selector->baCSourceID[ret -
> 1],
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Support for NUX MG-300 USB interface
  2021-01-18 21:15         ` Mike Oliphant
@ 2021-01-18 21:59           ` Takashi Iwai
  2021-01-19  0:26             ` Mike Oliphant
  0 siblings, 1 reply; 16+ messages in thread
From: Takashi Iwai @ 2021-01-18 21:59 UTC (permalink / raw)
  To: Mike Oliphant; +Cc: alsa-devel

On Mon, 18 Jan 2021 22:15:26 +0100,
Mike Oliphant wrote:
> 
> Progress - thanks for the patch!
> 
> That got rid of the clock errors, and the the device now reports a 48000
> sample rate, which is correct.
> 
> Unfortunately, it still isn't working properly. Playback doesn't seem to work
> at all. Capture kind of works - it does record, but the audio is extremely
> noisy.
> 
> Here is the current dmesg output when the device is connected.
> 
> Notable is the error "No valid sample rate available for 1:1, assuming a
> firmware bug".
> 
> Also notable is "1:1 Set sample rate 48000, clock 40" - where "40" is the id
> of the clock selector - "41" is the id of the actual clock source. So maybe
> something is still getting wired up wrong?

OK, how about the one below instead?


Takashi

--- a/sound/usb/clock.c
+++ b/sound/usb/clock.c
@@ -298,6 +298,12 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
 	if (selector) {
 		int ret, i, cur;
 
+		if (selector->bNrInPins == 1) {
+			uac_clock_selector_set_val(chip, selector->bClockID, 1);
+			ret = 1;
+			goto find_source;
+		}
+
 		/* the entity ID we are looking for is a selector.
 		 * find out what it currently selects */
 		ret = uac_clock_selector_get_val(chip, selector->bClockID);
@@ -314,6 +320,7 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
 			return -EINVAL;
 		}
 
+	find_source:
 		cur = ret;
 		ret = __uac_clock_find_source(chip, fmt,
 					      selector->baCSourceID[ret - 1],

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Support for NUX MG-300 USB interface
  2021-01-18 21:59           ` Takashi Iwai
@ 2021-01-19  0:26             ` Mike Oliphant
  2021-01-19  9:05               ` Takashi Iwai
  0 siblings, 1 reply; 16+ messages in thread
From: Mike Oliphant @ 2021-01-19  0:26 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

Unfortunately, the "uac_clock_selector_set_val()" call does not seem to
change anything.

From doing some more testing, I think that the references to clock id "40"
are ok - it has "40" stored in fmt->clock, but when it uses it,
"__uac_clock_find_source()" gets called and it resolved to the actual clock
source - "41".

Not sure about the "No valid sample rate available for 1:1, assuming a
firmware bug" error, but I suspect it is spurious.
"check_valid_altsetting_v2v3()" is failing for some reason, but it is
ignoring the error.

Playback is completely silent, but the system seems to think it is working.
No apparent errors, and a play operation seems to take the correct amount
of time. Just no audio.

Maybe it is a mixer issue? mixer.c is putting out "RANGE setting not yet
supported" errors on startup.

Here is a sample of dmesg output for a playback session:

[ 4748.260975] usb 1-1.3: Open EP 0x1, iface=1:1, idx=0
[ 4748.260983] usb 1-1.3:   channels=2, rate=48000, format=S32_LE,
period_bytes=48000, periods=4, implicit_fb=0
[ 4748.260988] usb 1-1.3: Open EP 0x81, iface=1:1, idx=1
[ 4748.260992] usb 1-1.3:   channels=2, rate=48000, format=S32_LE,
period_bytes=48000, periods=4, implicit_fb=0
[ 4748.260996] usb 1-1.3: Setting usb interface 1:0 for EP 0x1
[ 4748.261320] usb 1-1.3: 1:1 Set sample rate 48000, clock 40
[ 4748.261873] usb 1-1.3: Setting params for data EP 0x1, pipe 0x9d00
[ 4748.261890] usb 1-1.3: Set up 12 URBS, ret=0
[ 4748.261897] usb 1-1.3: Setting usb interface 1:1 for EP 0x1
[ 4748.262097] usb 1-1.3: Setting params for sync EP 0x81, pipe 0x9d80
[ 4748.262105] usb 1-1.3: Set up 4 URBS, ret=0
[ 4748.262147] usb 1-1.3: Starting data EP 0x1 (running 0)
[ 4748.262180] usb 1-1.3: 12 URBs submitted for EP 0x1
[ 4748.262183] usb 1-1.3: Starting sync EP 0x81 (running 0)
[ 4748.262193] usb 1-1.3: 4 URBs submitted for EP 0x81
[ 4748.262311] usb 1-1.3: 1:1 Start Playback PCM
[ 4762.887812] usb 1-1.3: Stopping sync EP 0x81 (running 1)
[ 4762.887836] usb 1-1.3: Stopping data EP 0x1 (running 1)
[ 4762.887849] usb 1-1.3: 1:1 Stop Playback PCM
[ 4762.902542] usb 1-1.3: Closing EP 0x1 (count 1)
[ 4762.902549] usb 1-1.3: Setting usb interface 1:0 for EP 0x1
[ 4762.902915] usb 1-1.3: EP 0x1 closed
[ 4762.902928] usb 1-1.3: Closing EP 0x81 (count 1)
[ 4762.902935] usb 1-1.3: Setting usb interface 1:0 for EP 0x81
[ 4762.903179] usb 1-1.3: EP 0x81 closed

On Mon, Jan 18, 2021 at 1:59 PM Takashi Iwai <tiwai@suse.de> wrote:

> On Mon, 18 Jan 2021 22:15:26 +0100,
> Mike Oliphant wrote:
> >
> > Progress - thanks for the patch!
> >
> > That got rid of the clock errors, and the the device now reports a 48000
> > sample rate, which is correct.
> >
> > Unfortunately, it still isn't working properly. Playback doesn't seem to
> work
> > at all. Capture kind of works - it does record, but the audio is
> extremely
> > noisy.
> >
> > Here is the current dmesg output when the device is connected.
> >
> > Notable is the error "No valid sample rate available for 1:1, assuming a
> > firmware bug".
> >
> > Also notable is "1:1 Set sample rate 48000, clock 40" - where "40" is
> the id
> > of the clock selector - "41" is the id of the actual clock source. So
> maybe
> > something is still getting wired up wrong?
>
> OK, how about the one below instead?
>
>
> Takashi
>
> --- a/sound/usb/clock.c
> +++ b/sound/usb/clock.c
> @@ -298,6 +298,12 @@ static int __uac_clock_find_source(struct
> snd_usb_audio *chip,
>         if (selector) {
>                 int ret, i, cur;
>
> +               if (selector->bNrInPins == 1) {
> +                       uac_clock_selector_set_val(chip,
> selector->bClockID, 1);
> +                       ret = 1;
> +                       goto find_source;
> +               }
> +
>                 /* the entity ID we are looking for is a selector.
>                  * find out what it currently selects */
>                 ret = uac_clock_selector_get_val(chip, selector->bClockID);
> @@ -314,6 +320,7 @@ static int __uac_clock_find_source(struct
> snd_usb_audio *chip,
>                         return -EINVAL;
>                 }
>
> +       find_source:
>                 cur = ret;
>                 ret = __uac_clock_find_source(chip, fmt,
>                                               selector->baCSourceID[ret -
> 1],
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Support for NUX MG-300 USB interface
  2021-01-19  0:26             ` Mike Oliphant
@ 2021-01-19  9:05               ` Takashi Iwai
  2021-01-19 17:40                 ` Mike Oliphant
  0 siblings, 1 reply; 16+ messages in thread
From: Takashi Iwai @ 2021-01-19  9:05 UTC (permalink / raw)
  To: Mike Oliphant; +Cc: alsa-devel

On Tue, 19 Jan 2021 01:26:51 +0100,
Mike Oliphant wrote:
> 
> Unfortunately, the "uac_clock_selector_set_val()" call does not seem to
> change anything.

OK,

> >From doing some more testing, I think that the references to clock id "40"
> are ok - it has "40" stored in fmt->clock, but when it uses it,
> "__uac_clock_find_source()" gets called and it resolved to the actual clock
> source - "41".
> 
> Not sure about the "No valid sample rate available for 1:1, assuming a
> firmware bug" error, but I suspect it is spurious.
> "check_valid_altsetting_v2v3()" is failing for some reason, but it is
> ignoring the error.

Yes, that's the part where verifying the altsetting for the given
rate.  The UAC2 device must return the valid altsetting bit mask for
the current rate in the request, but your device didn't seem returning
it.  The code is there for devices like MOTU that have multiple
altsets where each one has one sample rate exclusively.

> Playback is completely silent, but the system seems to think it is working.
> No apparent errors, and a play operation seems to take the correct amount
> of time. Just no audio.

Check the status in /proc/asound/card*/pcm*/sub*/status.  If the
pointer moves forward and the position is expected, at least the data
feed is done, and the problem must be something else.

What about the capture?  Do you get also only silence?

> Maybe it is a mixer issue? mixer.c is putting out "RANGE setting not yet
> supported" errors on startup.

That's probably no problem, I guess it comes from the code trying to
get the resolution.  The patch below may paper over it.

> Here is a sample of dmesg output for a playback session:
> 
> [ 4748.260975] usb 1-1.3: Open EP 0x1, iface=1:1, idx=0
> [ 4748.260983] usb 1-1.3:   channels=2, rate=48000, format=S32_LE,
> period_bytes=48000, periods=4, implicit_fb=0
> [ 4748.260988] usb 1-1.3: Open EP 0x81, iface=1:1, idx=1
> [ 4748.260992] usb 1-1.3:   channels=2, rate=48000, format=S32_LE,
> period_bytes=48000, periods=4, implicit_fb=0
> [ 4748.260996] usb 1-1.3: Setting usb interface 1:0 for EP 0x1
> [ 4748.261320] usb 1-1.3: 1:1 Set sample rate 48000, clock 40
> [ 4748.261873] usb 1-1.3: Setting params for data EP 0x1, pipe 0x9d00
> [ 4748.261890] usb 1-1.3: Set up 12 URBS, ret=0
> [ 4748.261897] usb 1-1.3: Setting usb interface 1:1 for EP 0x1
> [ 4748.262097] usb 1-1.3: Setting params for sync EP 0x81, pipe 0x9d80
> [ 4748.262105] usb 1-1.3: Set up 4 URBS, ret=0
> [ 4748.262147] usb 1-1.3: Starting data EP 0x1 (running 0)
> [ 4748.262180] usb 1-1.3: 12 URBs submitted for EP 0x1
> [ 4748.262183] usb 1-1.3: Starting sync EP 0x81 (running 0)
> [ 4748.262193] usb 1-1.3: 4 URBs submitted for EP 0x81
> [ 4748.262311] usb 1-1.3: 1:1 Start Playback PCM
> [ 4762.887812] usb 1-1.3: Stopping sync EP 0x81 (running 1)
> [ 4762.887836] usb 1-1.3: Stopping data EP 0x1 (running 1)
> [ 4762.887849] usb 1-1.3: 1:1 Stop Playback PCM
> [ 4762.902542] usb 1-1.3: Closing EP 0x1 (count 1)
> [ 4762.902549] usb 1-1.3: Setting usb interface 1:0 for EP 0x1
> [ 4762.902915] usb 1-1.3: EP 0x1 closed
> [ 4762.902928] usb 1-1.3: Closing EP 0x81 (count 1)
> [ 4762.902935] usb 1-1.3: Setting usb interface 1:0 for EP 0x81
> [ 4762.903179] usb 1-1.3: EP 0x81 closed

The flow looks good judging from this log, at least.

The device is configured with the dedicated sync endpoint, but it's
not with the implicit feedback mode.  It's interesting whether the
device behaves differently if you load snd-usb-audio module with
implicit_fb=1 boot option.  I don't expect it working better, but
anyway...


Takashi

--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -1238,7 +1238,7 @@ static int get_min_max_with_quirks(struct usb_mixer_elem_info *cval,
 				  (cval->control << 8) | minchn,
 				  &cval->res) < 0) {
 			cval->res = 1;
-		} else {
+		} else if (cval->head.mixer->protocol == UAC_VERSION_1) {
 			int last_valid_res = cval->res;
 
 			while (cval->res > 1) {


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Support for NUX MG-300 USB interface
  2021-01-19  9:05               ` Takashi Iwai
@ 2021-01-19 17:40                 ` Mike Oliphant
  2021-01-20 14:33                   ` Takashi Iwai
  0 siblings, 1 reply; 16+ messages in thread
From: Mike Oliphant @ 2021-01-19 17:40 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

Your mixer.c patch does get rid of the RANGE errors. No change to behavior,
though.

I'd already tried setting "implicit_fb=1" even though I didn't expect it to
work, since there is a separate feedback endpoint. I just tried it again -
it doesn't seem to hurt anything, but it doesn't help either.

Capture seems to be working perfectly with the clock patch - I'm not sure
why I was initially getting noisy input.

I checked "/proc/asound/card*/pcm*/sub*/status" during playback, and the
pointer seems to be moving forward as it should. All indications are that
the system thinks playback is working fine.

One interesting piece of information - alsamixer shows two stereo outputs
("pcm" and "pcm1"). Not sure why there are two - maybe output is going to
the wrong one?

Here is the output from "/proc/asound/AUDIO/usbmixer":

USB Mixer: usb_id=0x1fc98260, ctrlif=0, ctlerr=0
Card: NUX NUX MG-300 AUDIO at usb-0000:00:1a.7-1.3, high speed
  Unit: 10
    Control: name="PCM Playback Volume", index=1
    Info: id=10, control=2, cmask=0x0, channels=1, type="S16"
    Volume: min=-16384, max=0, dBmin=-6400, dBmax=0
  Unit: 10
    Control: name="PCM Playback Volume", index=0
    Info: id=10, control=2, cmask=0x3, channels=2, type="S16"
    Volume: min=-16384, max=0, dBmin=-6400, dBmax=0
  Unit: 10
    Control: name="PCM Playback Switch", index=1
    Info: id=10, control=1, cmask=0x0, channels=1, type="INV_BOOLEAN"
    Volume: min=0, max=1, dBmin=0, dBmax=0
  Unit: 10
    Control: name="PCM Playback Switch", index=0
    Info: id=10, control=1, cmask=0x3, channels=2, type="INV_BOOLEAN"
    Volume: min=0, max=1, dBmin=0, dBmax=0
  Unit: 41
    Control: name="Clock Source 41 Validity", index=0
    Info: id=41, control=2, cmask=0x0, channels=1, type="BOOLEAN"
    Volume: min=0, max=1, dBmin=0, dBmax=0

Mike

On Tue, Jan 19, 2021 at 1:05 AM Takashi Iwai <tiwai@suse.de> wrote:

> On Tue, 19 Jan 2021 01:26:51 +0100,
> Mike Oliphant wrote:
> >
> > Unfortunately, the "uac_clock_selector_set_val()" call does not seem to
> > change anything.
>
> OK,
>
> > >From doing some more testing, I think that the references to clock id
> "40"
> > are ok - it has "40" stored in fmt->clock, but when it uses it,
> > "__uac_clock_find_source()" gets called and it resolved to the actual
> clock
> > source - "41".
> >
> > Not sure about the "No valid sample rate available for 1:1, assuming a
> > firmware bug" error, but I suspect it is spurious.
> > "check_valid_altsetting_v2v3()" is failing for some reason, but it is
> > ignoring the error.
>
> Yes, that's the part where verifying the altsetting for the given
> rate.  The UAC2 device must return the valid altsetting bit mask for
> the current rate in the request, but your device didn't seem returning
> it.  The code is there for devices like MOTU that have multiple
> altsets where each one has one sample rate exclusively.
>
> > Playback is completely silent, but the system seems to think it is
> working.
> > No apparent errors, and a play operation seems to take the correct amount
> > of time. Just no audio.
>
> Check the status in /proc/asound/card*/pcm*/sub*/status.  If the
> pointer moves forward and the position is expected, at least the data
> feed is done, and the problem must be something else.
>
> What about the capture?  Do you get also only silence?
>
> > Maybe it is a mixer issue? mixer.c is putting out "RANGE setting not yet
> > supported" errors on startup.
>
> That's probably no problem, I guess it comes from the code trying to
> get the resolution.  The patch below may paper over it.
>
> > Here is a sample of dmesg output for a playback session:
> >
> > [ 4748.260975] usb 1-1.3: Open EP 0x1, iface=1:1, idx=0
> > [ 4748.260983] usb 1-1.3:   channels=2, rate=48000, format=S32_LE,
> > period_bytes=48000, periods=4, implicit_fb=0
> > [ 4748.260988] usb 1-1.3: Open EP 0x81, iface=1:1, idx=1
> > [ 4748.260992] usb 1-1.3:   channels=2, rate=48000, format=S32_LE,
> > period_bytes=48000, periods=4, implicit_fb=0
> > [ 4748.260996] usb 1-1.3: Setting usb interface 1:0 for EP 0x1
> > [ 4748.261320] usb 1-1.3: 1:1 Set sample rate 48000, clock 40
> > [ 4748.261873] usb 1-1.3: Setting params for data EP 0x1, pipe 0x9d00
> > [ 4748.261890] usb 1-1.3: Set up 12 URBS, ret=0
> > [ 4748.261897] usb 1-1.3: Setting usb interface 1:1 for EP 0x1
> > [ 4748.262097] usb 1-1.3: Setting params for sync EP 0x81, pipe 0x9d80
> > [ 4748.262105] usb 1-1.3: Set up 4 URBS, ret=0
> > [ 4748.262147] usb 1-1.3: Starting data EP 0x1 (running 0)
> > [ 4748.262180] usb 1-1.3: 12 URBs submitted for EP 0x1
> > [ 4748.262183] usb 1-1.3: Starting sync EP 0x81 (running 0)
> > [ 4748.262193] usb 1-1.3: 4 URBs submitted for EP 0x81
> > [ 4748.262311] usb 1-1.3: 1:1 Start Playback PCM
> > [ 4762.887812] usb 1-1.3: Stopping sync EP 0x81 (running 1)
> > [ 4762.887836] usb 1-1.3: Stopping data EP 0x1 (running 1)
> > [ 4762.887849] usb 1-1.3: 1:1 Stop Playback PCM
> > [ 4762.902542] usb 1-1.3: Closing EP 0x1 (count 1)
> > [ 4762.902549] usb 1-1.3: Setting usb interface 1:0 for EP 0x1
> > [ 4762.902915] usb 1-1.3: EP 0x1 closed
> > [ 4762.902928] usb 1-1.3: Closing EP 0x81 (count 1)
> > [ 4762.902935] usb 1-1.3: Setting usb interface 1:0 for EP 0x81
> > [ 4762.903179] usb 1-1.3: EP 0x81 closed
>
> The flow looks good judging from this log, at least.
>
> The device is configured with the dedicated sync endpoint, but it's
> not with the implicit feedback mode.  It's interesting whether the
> device behaves differently if you load snd-usb-audio module with
> implicit_fb=1 boot option.  I don't expect it working better, but
> anyway...
>
>
> Takashi
>
> --- a/sound/usb/mixer.c
> +++ b/sound/usb/mixer.c
> @@ -1238,7 +1238,7 @@ static int get_min_max_with_quirks(struct
> usb_mixer_elem_info *cval,
>                                   (cval->control << 8) | minchn,
>                                   &cval->res) < 0) {
>                         cval->res = 1;
> -               } else {
> +               } else if (cval->head.mixer->protocol == UAC_VERSION_1) {
>                         int last_valid_res = cval->res;
>
>                         while (cval->res > 1) {
>
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Support for NUX MG-300 USB interface
  2021-01-19 17:40                 ` Mike Oliphant
@ 2021-01-20 14:33                   ` Takashi Iwai
  2021-01-20 21:17                     ` Mike Oliphant
  0 siblings, 1 reply; 16+ messages in thread
From: Takashi Iwai @ 2021-01-20 14:33 UTC (permalink / raw)
  To: Mike Oliphant; +Cc: alsa-devel

On Tue, 19 Jan 2021 18:40:04 +0100,
Mike Oliphant wrote:
> 
> Your mixer.c patch does get rid of the RANGE errors. No change to behavior,
> though.
> 
> I'd already tried setting "implicit_fb=1" even though I didn't expect it to
> work, since there is a separate feedback endpoint. I just tried it again - it
> doesn't seem to hurt anything, but it doesn't help either.
> 
> Capture seems to be working perfectly with the clock patch - I'm not sure why
> I was initially getting noisy input.
> 
> I checked "/proc/asound/card*/pcm*/sub*/status" during playback, and the
> pointer seems to be moving forward as it should. All indications are that the
> system thinks playback is working fine.
> 
> One interesting piece of information - alsamixer shows two stereo outputs
> ("pcm" and "pcm1"). Not sure why there are two - maybe output is going to the
> wrong one?

You might need to unmute and increase both.  The first one should be a
master volume/switch while the second one is for the stereo channels.

Naming the mixer elements properly for USB-audio is a really tough
task.  Many firmware don't set the right strings and a guess work
doesn't fit to all.  But certainly there are some rooms for
improvements there.


Takashi

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Support for NUX MG-300 USB interface
  2021-01-20 14:33                   ` Takashi Iwai
@ 2021-01-20 21:17                     ` Mike Oliphant
  2021-01-20 21:38                       ` Takashi Iwai
  0 siblings, 1 reply; 16+ messages in thread
From: Mike Oliphant @ 2021-01-20 21:17 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

I spent a fair bit of time debugging the code setting/getting mixer control
values, and I can't see anything that seems to be operating incorrectly.

Unless you have any other suggestions, I'm going to admit defeat and return
the audio interface.

It is probably worth committing the clock selector patch - it at least made
capture work, and it may help with other audio interfaces.

Thanks for your help,

Mike



On Wed, Jan 20, 2021 at 6:33 AM Takashi Iwai <tiwai@suse.de> wrote:

> On Tue, 19 Jan 2021 18:40:04 +0100,
> Mike Oliphant wrote:
> >
> > Your mixer.c patch does get rid of the RANGE errors. No change to
> behavior,
> > though.
> >
> > I'd already tried setting "implicit_fb=1" even though I didn't expect it
> to
> > work, since there is a separate feedback endpoint. I just tried it again
> - it
> > doesn't seem to hurt anything, but it doesn't help either.
> >
> > Capture seems to be working perfectly with the clock patch - I'm not
> sure why
> > I was initially getting noisy input.
> >
> > I checked "/proc/asound/card*/pcm*/sub*/status" during playback, and the
> > pointer seems to be moving forward as it should. All indications are
> that the
> > system thinks playback is working fine.
> >
> > One interesting piece of information - alsamixer shows two stereo outputs
> > ("pcm" and "pcm1"). Not sure why there are two - maybe output is going
> to the
> > wrong one?
>
> You might need to unmute and increase both.  The first one should be a
> master volume/switch while the second one is for the stereo channels.
>
> Naming the mixer elements properly for USB-audio is a really tough
> task.  Many firmware don't set the right strings and a guess work
> doesn't fit to all.  But certainly there are some rooms for
> improvements there.
>
>
> Takashi
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Support for NUX MG-300 USB interface
  2021-01-20 21:17                     ` Mike Oliphant
@ 2021-01-20 21:38                       ` Takashi Iwai
  2021-01-20 21:47                         ` Mike Oliphant
  0 siblings, 1 reply; 16+ messages in thread
From: Takashi Iwai @ 2021-01-20 21:38 UTC (permalink / raw)
  To: Mike Oliphant; +Cc: alsa-devel

On Wed, 20 Jan 2021 22:17:35 +0100,
Mike Oliphant wrote:
> 
> I spent a fair bit of time debugging the code setting/getting mixer control
> values, and I can't see anything that seems to be operating incorrectly.

So, even if you unmute and raise both mixers, it didn't help, right?
I took a look at the lsusb output, but I couldn't find anything else
suspicious.

> Unless you have any other suggestions, I'm going to admit defeat and return
> the audio interface.
> 
> It is probably worth committing the clock selector patch - it at least made
> capture work, and it may help with other audio interfaces.

OK, I'll submit two fix patches.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Support for NUX MG-300 USB interface
  2021-01-20 21:38                       ` Takashi Iwai
@ 2021-01-20 21:47                         ` Mike Oliphant
  2021-01-21 19:04                           ` Mike Oliphant
  0 siblings, 1 reply; 16+ messages in thread
From: Mike Oliphant @ 2021-01-20 21:47 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

Yeah, I tried every possible permutation of mute/volumes on the mixer
controls.

Thanks for submitting the patches. Maybe someone else will have better luck
down the road.

Mike

On Wed, Jan 20, 2021 at 1:38 PM Takashi Iwai <tiwai@suse.de> wrote:

> On Wed, 20 Jan 2021 22:17:35 +0100,
> Mike Oliphant wrote:
> >
> > I spent a fair bit of time debugging the code setting/getting mixer
> control
> > values, and I can't see anything that seems to be operating incorrectly.
>
> So, even if you unmute and raise both mixers, it didn't help, right?
> I took a look at the lsusb output, but I couldn't find anything else
> suspicious.
>
> > Unless you have any other suggestions, I'm going to admit defeat and
> return
> > the audio interface.
> >
> > It is probably worth committing the clock selector patch - it at least
> made
> > capture work, and it may help with other audio interfaces.
>
> OK, I'll submit two fix patches.
>
>
> thanks,
>
> Takashi
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Support for NUX MG-300 USB interface
  2021-01-20 21:47                         ` Mike Oliphant
@ 2021-01-21 19:04                           ` Mike Oliphant
  2021-01-21 20:18                             ` Mike Oliphant
  0 siblings, 1 reply; 16+ messages in thread
From: Mike Oliphant @ 2021-01-21 19:04 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

As a last ditch effort before returning the device, I tried the clock patch
on a Raspberry Pi 4 running an older kernel, and... it works.

The kernel version is "Linux raspberrypi 4.19.89-v7l+" and is from late
February 2020.

Maybe a change between then and now broke something? I know there have been
a *lot* of changes since then, though...

Mike

On Wed, Jan 20, 2021 at 1:47 PM Mike Oliphant <oliphant@nostatic.org> wrote:

> Yeah, I tried every possible permutation of mute/volumes on the mixer
> controls.
>
> Thanks for submitting the patches. Maybe someone else will have better
> luck down the road.
>
> Mike
>
> On Wed, Jan 20, 2021 at 1:38 PM Takashi Iwai <tiwai@suse.de> wrote:
>
>> On Wed, 20 Jan 2021 22:17:35 +0100,
>> Mike Oliphant wrote:
>> >
>> > I spent a fair bit of time debugging the code setting/getting mixer
>> control
>> > values, and I can't see anything that seems to be operating incorrectly.
>>
>> So, even if you unmute and raise both mixers, it didn't help, right?
>> I took a look at the lsusb output, but I couldn't find anything else
>> suspicious.
>>
>> > Unless you have any other suggestions, I'm going to admit defeat and
>> return
>> > the audio interface.
>> >
>> > It is probably worth committing the clock selector patch - it at least
>> made
>> > capture work, and it may help with other audio interfaces.
>>
>> OK, I'll submit two fix patches.
>>
>>
>> thanks,
>>
>> Takashi
>>
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Support for NUX MG-300 USB interface
  2021-01-21 19:04                           ` Mike Oliphant
@ 2021-01-21 20:18                             ` Mike Oliphant
  0 siblings, 0 replies; 16+ messages in thread
From: Mike Oliphant @ 2021-01-21 20:18 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

After some more testing, it seems to be working inconsistently on my
Raspberry Pi. Sometimes it works perfectly, sometimes only capture works,
and sometimes only playback works.

The behavior seems reminiscent of some of the problems with implicit
feedback devices which have now been fixed.

Mike

On Thu, Jan 21, 2021 at 11:04 AM Mike Oliphant <oliphant@nostatic.org>
wrote:

> As a last ditch effort before returning the device, I tried the clock
> patch on a Raspberry Pi 4 running an older kernel, and... it works.
>
> The kernel version is "Linux raspberrypi 4.19.89-v7l+" and is from late
> February 2020.
>
> Maybe a change between then and now broke something? I know there have
> been a *lot* of changes since then, though...
>
> Mike
>
> On Wed, Jan 20, 2021 at 1:47 PM Mike Oliphant <oliphant@nostatic.org>
> wrote:
>
>> Yeah, I tried every possible permutation of mute/volumes on the mixer
>> controls.
>>
>> Thanks for submitting the patches. Maybe someone else will have better
>> luck down the road.
>>
>> Mike
>>
>> On Wed, Jan 20, 2021 at 1:38 PM Takashi Iwai <tiwai@suse.de> wrote:
>>
>>> On Wed, 20 Jan 2021 22:17:35 +0100,
>>> Mike Oliphant wrote:
>>> >
>>> > I spent a fair bit of time debugging the code setting/getting mixer
>>> control
>>> > values, and I can't see anything that seems to be operating
>>> incorrectly.
>>>
>>> So, even if you unmute and raise both mixers, it didn't help, right?
>>> I took a look at the lsusb output, but I couldn't find anything else
>>> suspicious.
>>>
>>> > Unless you have any other suggestions, I'm going to admit defeat and
>>> return
>>> > the audio interface.
>>> >
>>> > It is probably worth committing the clock selector patch - it at least
>>> made
>>> > capture work, and it may help with other audio interfaces.
>>>
>>> OK, I'll submit two fix patches.
>>>
>>>
>>> thanks,
>>>
>>> Takashi
>>>
>>

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-01-21 20:19 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-17 18:56 Support for NUX MG-300 USB interface Mike Oliphant
2021-01-18  7:43 ` Takashi Iwai
2021-01-18 16:33   ` Mike Oliphant
2021-01-18 17:54     ` Mike Oliphant
2021-01-18 19:19       ` Takashi Iwai
2021-01-18 21:15         ` Mike Oliphant
2021-01-18 21:59           ` Takashi Iwai
2021-01-19  0:26             ` Mike Oliphant
2021-01-19  9:05               ` Takashi Iwai
2021-01-19 17:40                 ` Mike Oliphant
2021-01-20 14:33                   ` Takashi Iwai
2021-01-20 21:17                     ` Mike Oliphant
2021-01-20 21:38                       ` Takashi Iwai
2021-01-20 21:47                         ` Mike Oliphant
2021-01-21 19:04                           ` Mike Oliphant
2021-01-21 20:18                             ` Mike Oliphant

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.