ALSA: usb-audio: Logitech P710e: Add quirk to fix setting sample rate.

Message ID 20230531125148.892100-1-joakim.tjernlund@infinera.com
State New
Headers
Series ALSA: usb-audio: Logitech P710e: Add quirk to fix setting sample rate. |

Commit Message

Joakim Tjernlund May 31, 2023, 12:51 p.m. UTC
  P710e, will throw an "cannot set freq 48000 to ep 0x3" error, no
matter adding mdelays around setting sample rate.

Only way to avoid it I can find is to avoid setting it at all.

Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
Cc: stable@vger.kernel.org
---

 I also tried QUIRK_FLAG_FIXED_RATE quirk but that didnt have any effect.
 sound/usb/quirks.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Joakim Tjernlund June 1, 2023, 10:39 a.m. UTC | #1
On Wed, 2023-05-31 at 14:51 +0200, Joakim Tjernlund wrote:
> P710e, will throw an "cannot set freq 48000 to ep 0x3" error, no
> matter adding mdelays around setting sample rate.

Please ignore this patch, the "cannot set freq 48000 to ep 0x3" only happens when
kernel(6.1.31) initially probes the device:

[  555.200166] usb 3-1: USB disconnect, device number 14
[  560.906553] usb 3-1: new full-speed USB device number 15 using xhci_hcd
[  561.104340] usb 3-1: 2:1: cannot set freq 48000 to ep 0x3
[  566.342420] usb 3-1: 2:1: cannot get freq at ep 0x3
[  566.497056] input: Logitech Speakerphone P710e Consumer Control as /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.3/0003:046D:0A4E.0008/input/input29
[  566.548828] input: Logitech Speakerphone P710e as /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.3/0003:046D:0A4E.0008/input/input30
[  566.549086] hid-generic 0003:046D:0A4E.0008: input,hiddev97,hidraw5: USB HID v1.11 Device [Logitech Speakerphone P710e] on usb-0000:00:14.0-1/input3

I have a Jabra SPEAK 510 which behaves the same.
Once attached setting sample rate works.
 
Seems like the devices are not ready to handle sample rate
this early when device is beeing attached. Does the kernel need to manage
sample rate before device is fully attached?

 Jocke
> 
> Only way to avoid it I can find is to avoid setting it at all.
> 
> Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
> Cc: stable@vger.kernel.org
> ---
> 
>  I also tried QUIRK_FLAG_FIXED_RATE quirk but that didnt have any effect.
>  sound/usb/quirks.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
> index 3ecd1ba7fd4b..8277bfd3deec 100644
> --- a/sound/usb/quirks.c
> +++ b/sound/usb/quirks.c
> @@ -1952,7 +1952,8 @@ void snd_usb_audioformat_attributes_quirk(struct snd_usb_audio *chip,
>  {
>  	switch (chip->usb_id) {
>  	case USB_ID(0x0a92, 0x0053): /* AudioTrak Optoplay */
> -		/* Optoplay sets the sample rate attribute although
> +	case USB_ID(0x046d, 0x0a4e): /* Logitech P710e */
> +		/* Optoplay/P710e sets the sample rate attribute although
>  		 * it seems not supporting it in fact.
>  		 */
>  		fp->attributes &= ~UAC_EP_CS_ATTR_SAMPLE_RATE;
  
Joakim Tjernlund June 1, 2023, 11:01 a.m. UTC | #2
On Thu, 2023-06-01 at 12:39 +0200, Joakim Tjernlund wrote:
> On Wed, 2023-05-31 at 14:51 +0200, Joakim Tjernlund wrote:
> > P710e, will throw an "cannot set freq 48000 to ep 0x3" error, no
> > matter adding mdelays around setting sample rate.
> 
> Please ignore this patch, the "cannot set freq 48000 to ep 0x3" only happens when
> kernel(6.1.31) initially probes the device:
> 
> [  555.200166] usb 3-1: USB disconnect, device number 14
> [  560.906553] usb 3-1: new full-speed USB device number 15 using xhci_hcd
> [  561.104340] usb 3-1: 2:1: cannot set freq 48000 to ep 0x3
> [  566.342420] usb 3-1: 2:1: cannot get freq at ep 0x3
> [  566.497056] input: Logitech Speakerphone P710e Consumer Control as /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.3/0003:046D:0A4E.0008/input/input29
> [  566.548828] input: Logitech Speakerphone P710e as /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.3/0003:046D:0A4E.0008/input/input30
> [  566.549086] hid-generic 0003:046D:0A4E.0008: input,hiddev97,hidraw5: USB HID v1.11 Device [Logitech Speakerphone P710e] on usb-0000:00:14.0-1/input3
> 
> I have a Jabra SPEAK 510 which behaves the same.
> Once attached setting sample rate works.
>  
> Seems like the devices are not ready to handle sample rate
> this early when device is beeing attached. Does the kernel need to manage
> sample rate before device is fully attached?

This swap appears to make the initial error go away:
diff -u stream.c.org stream.c
--- stream.c.org	2023-06-01 12:54:41.229145989 +0200
+++ stream.c	2023-06-01 12:57:46.427514638 +0200
@@ -1226,8 +1226,8 @@
 		/* try to set the interface... */
 		usb_set_interface(chip->dev, iface_no, 0);
 		snd_usb_init_pitch(chip, fp);
-		snd_usb_init_sample_rate(chip, fp, fp->rate_max);
 		usb_set_interface(chip->dev, iface_no, altno);
+		snd_usb_init_sample_rate(chip, fp, fp->rate_max);
 	}
 	return 0;
 }

But I don't really now what I am doing w.r.t USB/Audio 

 Jocke
  

Patch

diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 3ecd1ba7fd4b..8277bfd3deec 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1952,7 +1952,8 @@  void snd_usb_audioformat_attributes_quirk(struct snd_usb_audio *chip,
 {
 	switch (chip->usb_id) {
 	case USB_ID(0x0a92, 0x0053): /* AudioTrak Optoplay */
-		/* Optoplay sets the sample rate attribute although
+	case USB_ID(0x046d, 0x0a4e): /* Logitech P710e */
+		/* Optoplay/P710e sets the sample rate attribute although
 		 * it seems not supporting it in fact.
 		 */
 		fp->attributes &= ~UAC_EP_CS_ATTR_SAMPLE_RATE;