Skip to contentSkip to conversation

ALSA: usb-audio: Ignore clock selector errors for single connection

PATCH In review Alexander Tsoy 2 participants 4 messages Feb 1, 2024 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: usb-audio: Ignore clock selector errors for single connection

For devices with multiple clock sources connected to a selector, we need to check what a clock selector control request has returned. This is needed to ensure that a requested clock source is indeed selected and for autoclock feature to work.

For devices with single clock source connected, if we get an error there is nothing else we can do about it. We can't skip clock selector setup as it is required by some devices. So lets just ignore error in this case.

This should fix various buggy Mackie devices:

[  649.109785] usb 1-1.3: parse_audio_format_rates_v2v3(): unable to find clock source (clock -32)
[  649.111946] usb 1-1.3: parse_audio_format_rates_v2v3(): unable to find clock source (clock -32)
[  649.113822] usb 1-1.3: parse_audio_format_rates_v2v3(): unable to find clock source (clock -32)

There is also interesting info from the Windows documentation [1] (this is probably why manufacturers dont't even test this feature):

"The USB Audio 2.0 driver doesn't support clock selection. The driver uses the Clock Source Entity, which is selected by default and never issues a Clock Selector Control SET CUR request."

---
 sound/usb/clock.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
sound/usb/clock.c +9 -1
index a8204c6d6fac..60fcb872a80b 100644
@@ -347,8 +347,16 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
 			    !writeable)
 				return ret;
 			err = uac_clock_selector_set_val(chip, entity_id, cur);
-			if (err < 0)
+			if (err < 0) {
+				if (pins == 1) {
+					usb_audio_dbg(chip,
+						      "%s(): selector returned an error, "
+						      "assuming a firmware bug, id %d, ret %d\n",
+						      __func__, clock_id, err);
+					return ret;
+				}
 				return err;
+			}
 		}
 
 		if (!validate || ret > 0 || !chip->autoclock)
Signature · 1 line
2.43.0
#1 lore raw
Quoted 41 lines · Alexander Tsoy

For devices with multiple clock sources connected to a selector, we need to check what a clock selector control request has returned. This is needed to ensure that a requested clock source is indeed selected and for autoclock feature to work.

For devices with single clock source connected, if we get an error there is nothing else we can do about it. We can't skip clock selector setup as it is required by some devices. So lets just ignore error in this case.

This should fix various buggy Mackie devices:

[  649.109785] usb 1-1.3: parse_audio_format_rates_v2v3(): unable to find clock source (clock -32)
[  649.111946] usb 1-1.3: parse_audio_format_rates_v2v3(): unable to find clock source (clock -32)
[  649.113822] usb 1-1.3: parse_audio_format_rates_v2v3(): unable to find clock source (clock -32)

There is also interesting info from the Windows documentation [1] (this is probably why manufacturers dont't even test this feature):

"The USB Audio 2.0 driver doesn't support clock selection. The driver uses the Clock Source Entity, which is selected by default and never issues a Clock Selector Control SET CUR request."

---
 sound/usb/clock.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
sound/usb/clock.c +0 -1
index a8204c6d6fac..60fcb872a80b 100644
@@ -347,8 +347,16 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
 			    !writeable)
 				return ret;
 			err = uac_clock_selector_set_val(chip, entity_id, cur);
-			if (err < 0)

sound/usb/clock.c static int __uac_clock_find_source(struct snd_usb_audio *chip, · line 359

Quoted 10 lines
sound/usb/clock.c +9 -0
+			if (err < 0) {
+				if (pins == 1) {
+					usb_audio_dbg(chip,
+						      "%s(): selector returned an error, "
+						      "assuming a firmware bug, id %d, ret %d\n",
+						      __func__, clock_id, err);
+					return ret;
+				}
 				return err;
+			}

Hmm, what's the difference of the behavior except for the additional debug message? Both returns ret, so I don't see how it fixes.

thanks,

Takashi

#2 lore raw

В Чт, 01/02/2024 в 13:51 +0100, Takashi Iwai пишет:

Quoted 67 lines
Quoted 65 lines · Alexander Tsoy

For devices with multiple clock sources connected to a selector, we need
to check what a clock selector control request has returned. This is
needed to ensure that a requested clock source is indeed selected and for
autoclock feature to work.

For devices with single clock source connected, if we get an error there
is nothing else we can do about it. We can't skip clock selector setup as
it is required by some devices. So lets just ignore error in this case.

This should fix various buggy Mackie devices:

[  649.109785] usb 1-1.3: parse_audio_format_rates_v2v3(): unable to find clock source (clock -32)
[  649.111946] usb 1-1.3: parse_audio_format_rates_v2v3(): unable to find clock source (clock -32)
[  649.113822] usb 1-1.3: parse_audio_format_rates_v2v3(): unable to find clock source (clock -32)

There is also interesting info from the Windows documentation [1] (this
is probably why manufacturers dont't even test this feature):

"The USB Audio 2.0 driver doesn't support clock selection. The driver
uses the Clock Source Entity, which is selected by default and never
issues a Clock Selector Control SET CUR request."

Link:
https://learn.microsoft.com/en-us/windows-hardware/drivers/audio/usb-2-0-audio-drivers

---
 sound/usb/clock.c | 10 +++++++++-

 1 file changed, 9 insertions(+), 1 deletion(-)
sound/usb/clock.c +4 -1
index a8204c6d6fac..60fcb872a80b 100644
@@ -347,8 +347,16 @@ static int __uac_clock_find_source(struct
 snd_usb_audio *chip,
  			    !writeable)
  				return ret;
  			err = uac_clock_selector_set_val(chip,
 entity_id, cur);
-			if (err < 0)
+			if (err < 0) {
+				if (pins == 1) {
+					usb_audio_dbg(chip,
+						      "%s():

selector returned an error, "

sound/usb/clock.c +1 -0
+						      "assuming a

firmware bug, id %d, ret %d\n",

sound/usb/clock.c +1 -0
+						      __func__,
Quoted 8 lines

sound/usb/clock.c

Quoted 5 lines

clock_id, err);

sound/usb/clock.c +2 -0
+					return ret;
+				}

  return err;

sound/usb/clock.c +1 -0
+			}

Hmm, what's the difference of the behavior except for the additional debug message?  Both returns ret, so I don't see how it fixes.

If pins == 1, then ret is returned, otherwise err is returned. They are not equal here. But yes, the code is a bit confusing.

#3 lore raw
Quoted 78 lines · Alexander Tsoy

В Чт, 01/02/2024 в 13:51 +0100, Takashi Iwai пишет:

Quoted 67 lines
Quoted 65 lines · Alexander Tsoy

For devices with multiple clock sources connected to a selector, we need
to check what a clock selector control request has returned. This is
needed to ensure that a requested clock source is indeed selected and for
autoclock feature to work.

For devices with single clock source connected, if we get an error there
is nothing else we can do about it. We can't skip clock selector setup as
it is required by some devices. So lets just ignore error in this case.

This should fix various buggy Mackie devices:

[  649.109785] usb 1-1.3: parse_audio_format_rates_v2v3(): unable to find clock source (clock -32)
[  649.111946] usb 1-1.3: parse_audio_format_rates_v2v3(): unable to find clock source (clock -32)
[  649.113822] usb 1-1.3: parse_audio_format_rates_v2v3(): unable to find clock source (clock -32)

There is also interesting info from the Windows documentation [1] (this
is probably why manufacturers dont't even test this feature):

"The USB Audio 2.0 driver doesn't support clock selection. The driver
uses the Clock Source Entity, which is selected by default and never
issues a Clock Selector Control SET CUR request."

Link:
https://learn.microsoft.com/en-us/windows-hardware/drivers/audio/usb-2-0-audio-drivers

---
 sound/usb/clock.c | 10 +++++++++-

 1 file changed, 9 insertions(+), 1 deletion(-)
sound/usb/clock.c +4 -1
index a8204c6d6fac..60fcb872a80b 100644
@@ -347,8 +347,16 @@ static int __uac_clock_find_source(struct
 snd_usb_audio *chip,
  			    !writeable)
  				return ret;
  			err = uac_clock_selector_set_val(chip,
 entity_id, cur);
-			if (err < 0)
+			if (err < 0) {
+				if (pins == 1) {
+					usb_audio_dbg(chip,
+						      "%s():

selector returned an error, "

sound/usb/clock.c +1 -0
+						      "assuming a

firmware bug, id %d, ret %d\n",

sound/usb/clock.c +1 -0
+						      __func__,
Quoted 8 lines

sound/usb/clock.c

Quoted 5 lines

clock_id, err);

sound/usb/clock.c +2 -0
+					return ret;
+				}

  return err;

sound/usb/clock.c +1 -0
+			}

Hmm, what's the difference of the behavior except for the additional debug message?  Both returns ret, so I don't see how it fixes.

Quoted 2 lines

If pins == 1, then ret is returned, otherwise err is returned. They are not equal here. But yes, the code is a bit confusing.

Ah yeah, ret and err... OK, I'll take it.

thanks,

Takashi