All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: usb-audio: add implicit feedback quirk for Yamaha P-125
@ 2020-01-02 17:16 Arseniy Lartsev
  0 siblings, 0 replies; only message in thread
From: Arseniy Lartsev @ 2020-01-02 17:16 UTC (permalink / raw)
  To: linux-kernel

This digital piano has audio playback function with implicit feedback
endpoint.

On this device in particular, if USB host sends samples slightly too fast due
to lack of synchronization (50% chance of that happening), playback will fail
after a few minutes. This patch fixes the problem.

The feedback endpoint is, in fact, very nearly standard-compliant, but
set_sync_endpoint function currently uses different logic for feedback
endpoint discovery - the patch also adds a comment to clarify this behaviour.

Signed-off-by: Arseniy Lartsev <arseniy@alumni.chalmers.se>
---
 sound/usb/pcm.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 9c8930b..47ccea6 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -351,6 +351,10 @@ static int set_sync_ep_implicit_fb_quirk(struct 
snd_usb_substream *subs,
 	case USB_ID(0x0582, 0x01d8): /* BOSS Katana */
 		/* BOSS Katana amplifiers do not need quirks */
 		return 0;
+	case USB_ID(0x0499, 0x1718): /* Yamaha P-125 digital piano */
+		ep = 0x86;
+		ifnum = 2;
+		goto add_sync_ep_from_ifnum;
 	}
 
 	if (attr == USB_ENDPOINT_SYNC_ASYNC &&
@@ -427,6 +431,21 @@ static int set_sync_endpoint(struct snd_usb_substream 
*subs,
 	if (err > 0)
 		return 0;
 
+	/*
+	 * Actually, what USB 2.0 standard says is this:
+	 *
+	 * A feedback endpoint (explicit or implicit) needs to be associated with
+	 * one (or more) isochronous data endpoints to which it provides feedback
+	 * service. <...> The first data endpoint and the feedback endpoint must
+	 * have the same endpoint number (and opposite direction). This ensures
+	 * that a data endpoint can uniquely identify its feedback endpoint by
+	 * searching for the first feedback endpoint that has an endpoint number
+	 * equal or less than its own endpoint number.
+	 *
+	 * However, it looks like hardware vendors never follow this except by
+	 * accident, so we may as well give up on it too. Look for a feedback
+	 * endpoint as a second endpoint on the same interface.
+	 */
 	if (altsd->bNumEndpoints < 2)
 		return 0;
 
-- 
2.10.0



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-01-02 17:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-02 17:16 [PATCH] ALSA: usb-audio: add implicit feedback quirk for Yamaha P-125 Arseniy Lartsev

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.