Skip to contentSkip to conversation

ALSA: usb: Add support for Reloop Jockey 3 DJ controllers

PATCH Superseded Frank van de Pol 3 participants 6 messages Jun 17 – Jun 19 Sound

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover ALSA: usb: Add support for Reloop Jockey 3 DJ controllers

Hi Takashi, Jaroslav, and the ALSA community,

After being away from active ALSA development for some 25 years or so, I am happy to submit this patch to introduce a dedicated driver supporting the Jockey 3 series of DJ Controllers made by Reloop (specifically covering the Master Edition and the Remix variants).

I initially evaluated the feasibility of integrating the required logic to handle the non-standard proprietary Ploytec framing protocol into the standard USB-audio driver via quirks. However, doing so would require introducing numerous hardware-specific exceptions throughout the core layout, adding significant complexity. A clean, isolated driver subdirectory provides much better long-term maintainability without cluttering the existing class-compliant architecture.

Following up on the feedback received from the v1 submission last week, I have revised the architecture to address locking consistency, lifecycle safety, and stream verification flags highlighted during review.

Changes v1 -> v2:
- Migrated URB lifecycle management to use standard usb_anchors.
- Revised and hardened URB buffer memory allocation constraints.
- Addressed locking consistency, scoping issues, and static analysis warnings raised by Takashi and the Sashiko automated review.
- Implemented dynamic PCM rate constraints when a stream is active.
- Implemented full MIDI Running Status support for the control surface.
- Refactored several large code blocks to improve overall readability.
- Added clarifications on hardware specific quirks and codec format.
- Optimized struct jockey3_chip layout for padding and locality.

I have successfully validated and stress-tested this driver across three distinct hardware architectures to ensure robustness regarding DMA, timing, and memory alignment:
- x86_64 (Standard PC desktop environment)
- armhf (32-bit on a Raspberry Pi 1B -- functional, though tight at 96 kHz)
- arm64 (64-bit modern SoC environment on a Raspberry Pi 4)

I look forward to your review and feedback, and I am more than happy to make further architectural adjustments as required.

Best regards,
Frank van de Pol

Frank van de Pol (1):
ALSA: usb: Add support for Reloop Jockey 3 DJ controllers

 MAINTAINERS                       |    7 +
 sound/usb/Kconfig                 |    1 +
 sound/usb/Makefile                |    1 +
 sound/usb/jockey3/Kconfig         |   19 +
 sound/usb/jockey3/Makefile        |    3 +
 sound/usb/jockey3/jockey3.c       | 1025 +++++++++++++++++++++++++++++
 sound/usb/jockey3/ploytec_proto.c |  240 +++++++
 sound/usb/jockey3/ploytec_proto.h |   53 ++
 8 files changed, 1349 insertions(+)
 create mode 100644 sound/usb/jockey3/Kconfig
 create mode 100644 sound/usb/jockey3/Makefile
 create mode 100644 sound/usb/jockey3/jockey3.c
 create mode 100644 sound/usb/jockey3/ploytec_proto.c
 create mode 100644 sound/usb/jockey3/ploytec_proto.h
Signature · 1 line
2.47.3
#1 lore raw

PATCH v2 1/1 ALSA: usb: Add support for Reloop Jockey 3 DJ controllers

Introduce a dedicated repository subdirectory and driver for the Reloop Jockey 3 Master Edition and Reloop Jockey 3 Remix USB DJ controllers.

Because these devices utilize a non-standard, proprietary Ploytec USB framing protocol instead of standard USB Audio Class (UAC) mechanisms, they require specialized handling outside of standard quirks.

This driver provides:
- 24-bit multi-channel (6x4) audio capture and playback.
- Support for 44.1, 48, 88.2, and 96 kHz sample rates.
- ALSA RawMIDI input and output mapping for the integrated control surface.

The custom Ploytec encapsulation and streaming format was successfully reverse-engineered via USB protocol analysis and is isolated cleanly into a local hardware-independent codec abstraction.

Updates based on the feedback from code review

address issues from code review, further optimization

---
 MAINTAINERS                       |    7 +
 sound/usb/Kconfig                 |    1 +
 sound/usb/Makefile                |    1 +
 sound/usb/jockey3/Kconfig         |   19 +
 sound/usb/jockey3/Makefile        |    3 +
 sound/usb/jockey3/jockey3.c       | 1025 +++++++++++++++++++++++++++++
 sound/usb/jockey3/ploytec_proto.c |  240 +++++++
 sound/usb/jockey3/ploytec_proto.h |   53 ++
 8 files changed, 1349 insertions(+)
 create mode 100644 sound/usb/jockey3/Kconfig
 create mode 100644 sound/usb/jockey3/Makefile
 create mode 100644 sound/usb/jockey3/jockey3.c
 create mode 100644 sound/usb/jockey3/ploytec_proto.c
 create mode 100644 sound/usb/jockey3/ploytec_proto.h
MAINTAINERS +7 -0
index 42feedf526c3..531fa0bf23f6 100644
@@ -22539,6 +22539,13 @@ F:	Documentation/filesystems/relay.rst
 F:	include/linux/relay.h
 F:	kernel/relay.c
 
+RELOOP JOCKEY 3 DJ CONTROLLER DRIVER
+M:	Frank van de Pol <[email protected]>
+L:	[email protected]
+S:	Maintained
+T:	git git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
+F:	sound/usb/jockey3/
+
 REGISTER MAP ABSTRACTION
 M:	Mark Brown <[email protected]>
 L:	[email protected]
sound/usb/Kconfig +1 -0
index b4588915efa1..d7edfbaf099b 100644
@@ -205,6 +205,7 @@ config SND_USB_AUDIO_QMI
 	  will be called snd-usb-audio-qmi.
 
 source "sound/usb/line6/Kconfig"
+source "sound/usb/jockey3/Kconfig"
 
 endif	# SND_USB
 
sound/usb/Makefile +1 -0
index e62794a87e73..1f045c00dbc9 100644
@@ -37,3 +37,4 @@ obj-$(CONFIG_SND_USB_US122L) += snd-usbmidi-lib.o
 
 obj-$(CONFIG_SND) += misc/ usx2y/ caiaq/ 6fire/ hiface/ bcd2000/ qcom/
 obj-$(CONFIG_SND_USB_LINE6)	+= line6/
+obj-$(CONFIG_SND_USB_JOCKEY3) += jockey3/
sound/usb/jockey3/Kconfig new file +19 -0
new file mode 100644
index 000000000000..a1ac80f04450
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config SND_USB_JOCKEY3
+	tristate "Reloop Jockey 3 support"
+	default m
+	depends on SND_USB && USB
+	select SND_PCM
+	select SND_RAWMIDI
+	help
+	  Say Y here to include support for the Reloop Jockey 3 DJ controllers.
+          These devices utilize a non-standard, proprietary Ploytec USB
+          protocol.
+
+	  Supported devices:
+
+            * Reloop Jockey 3 Master Edition
+            * Reloop Jockey 3 Remix
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-reloop-jockey3.
sound/usb/jockey3/Makefile new file +3 -0
new file mode 100644
index 000000000000..85f9c6dcba14
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_SND_USB_JOCKEY3) += snd-reloop-jockey3.o
+snd-reloop-jockey3-objs := jockey3.o ploytec_proto.o
sound/usb/jockey3/jockey3.c new file +1025 -0

1,025 lines not on this page · raw message

sound/usb/jockey3/ploytec_proto.c new file +240 -0

240 lines not on this page · raw message

sound/usb/jockey3/ploytec_proto.h new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
2.47.3
#2 lore raw

Hi Frank,

Quoted 19 lines · Frank van de Pol
sound/usb/Kconfig +1 -0
+source "sound/usb/jockey3/Kconfig"
 
 endif	# SND_USB
sound/usb/Makefile +1 -0
index e62794a87e73..1f045c00dbc9 100644
@@ -37,3 +37,4 @@ obj-$(CONFIG_SND_USB_US122L) += snd-usbmidi-lib.o
 
 obj-$(CONFIG_SND) += misc/ usx2y/ caiaq/ 6fire/ hiface/ bcd2000/ qcom/
 obj-$(CONFIG_SND_USB_LINE6)	+= line6/
+obj-$(CONFIG_SND_USB_JOCKEY3) += jockey3/
sound/usb/jockey3/Kconfig new file +0 -0
new file mode 100644
index 000000000000..a1ac80f04450

sound/usb/jockey3/Kconfig line 7

Quoted 7 lines
sound/usb/jockey3/Kconfig new file +7 -0
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config SND_USB_JOCKEY3
+	tristate "Reloop Jockey 3 support"
+	default m
+	depends on SND_USB && USB
+	select SND_PCM
+	select SND_RAWMIDI

The dependency on SND_USB is unnecessary here, since the:
'source "sound/usb/jockey3/Kconfig"'
is already inside of an 'if SND_USB' so every config option in that file depends on SND_USB.

- Julian Braha

#3 lore raw
Quoted 36 lines · Julian Braha

Hi Frank,

Quoted 19 lines · Frank van de Pol
sound/usb/Kconfig +1 -0
+source "sound/usb/jockey3/Kconfig"
 
 endif	# SND_USB
sound/usb/Makefile +1 -0
index e62794a87e73..1f045c00dbc9 100644
@@ -37,3 +37,4 @@ obj-$(CONFIG_SND_USB_US122L) += snd-usbmidi-lib.o
 
 obj-$(CONFIG_SND) += misc/ usx2y/ caiaq/ 6fire/ hiface/ bcd2000/ qcom/
 obj-$(CONFIG_SND_USB_LINE6)	+= line6/
+obj-$(CONFIG_SND_USB_JOCKEY3) += jockey3/
sound/usb/jockey3/Kconfig new file +0 -0
new file mode 100644
index 000000000000..a1ac80f04450

sound/usb/jockey3/Kconfig line 7

Quoted 7 lines
sound/usb/jockey3/Kconfig new file +7 -0
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config SND_USB_JOCKEY3
+	tristate "Reloop Jockey 3 support"
+	default m
+	depends on SND_USB && USB
+	select SND_PCM
+	select SND_RAWMIDI

The dependency on SND_USB is unnecessary here, since the:
'source "sound/usb/jockey3/Kconfig"'
is already inside of an 'if SND_USB' so every config option in that file depends on SND_USB.

Quoted 1 line

- Julian Braha

Thank you Julian, good point. I'll update this when I'll prepare v3 of my patch for this driver.

I saw that the Sashiko review / code analysis found some more issues I introduced with my latest changes, including a potential AB-BA deadlock which I want to address.

https://sashiko.dev/#/patchset/20260617203937.1273852-2-fvdpol%40gmail.com

@Takashi, please do not yet merge this patch. I'd like to do more analysis on the Sashiko feedback and further improve the code quality for this driver.

Any further feedback and suggestions for improvement are more than welcome, best regards,
Frank.

#4 lore raw
In reply to Frank van de Pol
Quoted 17 lines · Frank van de Pol

Introduce a dedicated repository subdirectory and driver for the Reloop Jockey 3 Master Edition and Reloop Jockey 3 Remix USB DJ controllers.

Because these devices utilize a non-standard, proprietary Ploytec USB framing protocol instead of standard USB Audio Class (UAC) mechanisms, they require specialized handling outside of standard quirks.

This driver provides:
- 24-bit multi-channel (6x4) audio capture and playback.
- Support for 44.1, 48, 88.2, and 96 kHz sample rates.
- ALSA RawMIDI input and output mapping for the integrated control surface.

The custom Ploytec encapsulation and streaming format was successfully reverse-engineered via USB protocol analysis and is isolated cleanly into a local hardware-independent codec abstraction.

Quoted 5 lines

Updates based on the feedback from code review

address issues from code review, further optimization

Just a few nitpicking below, in addition to Sashiko reviews.

sound/usb/jockey3/Kconfig line 4

Quoted 7 lines
sound/usb/jockey3/Kconfig new file +4 -0
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config SND_USB_JOCKEY3
+	tristate "Reloop Jockey 3 support"
+	default m

Drop the "default m".

Quoted 2 lines
sound/usb/jockey3/Kconfig new file +2 -0
+static void jockey3_playback_callback(struct urb *urb)
+{

....

sound/usb/jockey3/Kconfig

Quoted 10 lines
sound/usb/jockey3/Kconfig new file +10 -0
+	if (urb->status) {
+		if (urb->status == -ENOENT || urb->status == -ECONNRESET ||
+		    urb->status == -ESHUTDOWN)
+			return;
+
+		/* Fatal error: stop resubmitting to prevent interrupt storm */
+		dev_err(&chip->intf0->dev, "Playback URB fatal error: %d\n", urb->status);
+		set_bit(JOCKEY3_FLAG_DISCONNECTED, &chip->flags);
+		return;
+	}

This code pattern appears repeatedly, so it can be factored out as a common helper.

sound/usb/jockey3/Kconfig

Quoted 2 lines
sound/usb/jockey3/Kconfig new file +2 -0
+	if (unlikely(test_bit(JOCKEY3_FLAG_DISCONNECTED, &chip->flags)))
+		return;

Also this check appears very frequently, and can be a form that is easier for readers, too.

Quoted 2 lines
sound/usb/jockey3/Kconfig new file +2 -0
+static int jockey3_pcm_open(struct snd_pcm_substream *substream)
+{

....

sound/usb/jockey3/Kconfig

Quoted 7 lines
sound/usb/jockey3/Kconfig new file +7 -0
+	runtime->hw.rate_min = 44100;
+	runtime->hw.rate_max = 96000;
+	runtime->hw.buffer_bytes_max = 1024 * 1024;
+	runtime->hw.period_bytes_min = 64;
+	runtime->hw.period_bytes_max = 512 * 1024;
+	runtime->hw.periods_min = 2;
+	runtime->hw.periods_max = 1024;

Maybe worth to mention that those are some sane software limitation you chose, not about the hardware limit.

sound/usb/jockey3/Kconfig

Quoted 10 lines
sound/usb/jockey3/Kconfig new file +10 -0
+
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		runtime->hw.channels_min = 4;
+		runtime->hw.channels_max = 4;
+		chip->playback_substream = substream;
+	} else {
+		runtime->hw.channels_min = 6;
+		runtime->hw.channels_max = 6;
+		chip->capture_substream = substream;
+	}

The substream assignment should be done better with the spinlock, and set at last, for avoiding the potential race? Otherwise...

sound/usb/jockey3/Kconfig

Quoted 8 lines
sound/usb/jockey3/Kconfig new file +8 -0
+	scoped_guard(mutex, &chip->rate_mutex) {
+		if (chip->active_streams > 0) {
+			/* Force the new stream to match the existing hardware rate */
+			ret = snd_pcm_hw_constraint_single(runtime,
+							   SNDRV_PCM_HW_PARAM_RATE,
+							   chip->current_rate);
+			if (ret < 0)
+				return ret;

... here the substream is still set and left. It might be no serious problem, but still better to be cleaned up.

Quoted 12 lines
sound/usb/jockey3/Kconfig new file +12 -0
+static int jockey3_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
+{
+	struct jockey3_chip *chip = snd_pcm_substream_chip(substream);
+
+	dev_dbg(&chip->intf0->dev, "PCM trigger stream %d, cmd %d\n", substream->stream, cmd);
+
+	if (test_bit(JOCKEY3_FLAG_DISCONNECTED, &chip->flags))
+		return -ENODEV;
+
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		guard(spinlock_irqsave)(&chip->playback_lock);
+		if (cmd == SNDRV_PCM_TRIGGER_START)

sound/usb/jockey3/Kconfig

Quoted 10 lines
sound/usb/jockey3/Kconfig new file +10 -0
+			chip->stream_running = true;
+		else if (cmd == SNDRV_PCM_TRIGGER_STOP)
+			chip->stream_running = false;
+	} else {
+		guard(spinlock_irqsave)(&chip->capture_lock);
+		if (cmd == SNDRV_PCM_TRIGGER_START)
+			chip->capture_running = true;
+		else if (cmd == SNDRV_PCM_TRIGGER_STOP)
+			chip->capture_running = false;
+	}

Better to implement SNDRV_PCM_TRIGGER_SUSPEND, too. It can be just as same as the stop operation. Then the suspend/resume would be supported, at least.

thanks,

Takashi

#5 lore raw
Quoted 19 lines · Takashi Iwai
Quoted 17 lines · Frank van de Pol

Introduce a dedicated repository subdirectory and driver for the Reloop Jockey 3 Master Edition and Reloop Jockey 3 Remix USB DJ controllers.

Because these devices utilize a non-standard, proprietary Ploytec USB framing protocol instead of standard USB Audio Class (UAC) mechanisms, they require specialized handling outside of standard quirks.

This driver provides:
- 24-bit multi-channel (6x4) audio capture and playback.
- Support for 44.1, 48, 88.2, and 96 kHz sample rates.
- ALSA RawMIDI input and output mapping for the integrated control surface.

The custom Ploytec encapsulation and streaming format was successfully reverse-engineered via USB protocol analysis and is isolated cleanly into a local hardware-independent codec abstraction.

Quoted 7 lines
Quoted 5 lines

Updates based on the feedback from code review

address issues from code review, further optimization

Just a few nitpicking below, in addition to Sashiko reviews.

:-) Thank you, it is these kind of nitpicking that help improve the code quality and maintainability, so more than happy to look into these.

Quoted 10 lines

sound/usb/jockey3/Kconfig line 4

Quoted 8 lines
sound/usb/jockey3/Kconfig new file +4 -0
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config SND_USB_JOCKEY3
+	tristate "Reloop Jockey 3 support"
+	default m

Drop the "default m".

Done

Quoted 16 lines
Quoted 2 lines
sound/usb/jockey3/Kconfig new file +2 -0
+static void jockey3_playback_callback(struct urb *urb)
+{

....

sound/usb/jockey3/Kconfig

Quoted 10 lines
sound/usb/jockey3/Kconfig new file +10 -0
+	if (urb->status) {
+		if (urb->status == -ENOENT || urb->status == -ECONNRESET ||
+		    urb->status == -ESHUTDOWN)
+			return;
+
+		/* Fatal error: stop resubmitting to prevent interrupt storm */
+		dev_err(&chip->intf0->dev, "Playback URB fatal error: %d\n", urb->status);
+		set_bit(JOCKEY3_FLAG_DISCONNECTED, &chip->flags);
+		return;
+	}

This code pattern appears repeatedly, so it can be factored out as a common helper.

Agreed, we have similar error handler logic for the playback, capture, and midi-in callbacks; good opportunity for a common helper function.

Quoted 7 lines

sound/usb/jockey3/Kconfig

Quoted 3 lines
sound/usb/jockey3/Kconfig new file +2 -0
+	if (unlikely(test_bit(JOCKEY3_FLAG_DISCONNECTED, &chip->flags)))
+		return;

Also this check appears very frequently, and can be a form that is easier for readers, too.

Good point; I moved the test_bit(.....) logic into a small helper functions jockey3_is_disconnected() and jockey3_is_stopping(). Resulting code is much easier on the eye:

	if (unlikely(jockey3_is_disconnected(chip)))
		return;
Quoted 28 lines
Quoted 2 lines
sound/usb/jockey3/Kconfig new file +2 -0
+static int jockey3_pcm_open(struct snd_pcm_substream *substream)
+{

....

sound/usb/jockey3/Kconfig

Quoted 7 lines
sound/usb/jockey3/Kconfig new file +7 -0
+	runtime->hw.rate_min = 44100;
+	runtime->hw.rate_max = 96000;
+	runtime->hw.buffer_bytes_max = 1024 * 1024;
+	runtime->hw.period_bytes_min = 64;
+	runtime->hw.period_bytes_max = 512 * 1024;
+	runtime->hw.periods_min = 2;
+	runtime->hw.periods_max = 1024;

Maybe worth to mention that those are some sane software limitation you chose, not about the hardware limit.

sound/usb/jockey3/Kconfig

Quoted 10 lines
sound/usb/jockey3/Kconfig new file +10 -0
+
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		runtime->hw.channels_min = 4;
+		runtime->hw.channels_max = 4;
+		chip->playback_substream = substream;
+	} else {
+		runtime->hw.channels_min = 6;
+		runtime->hw.channels_max = 6;
+		chip->capture_substream = substream;
+	}

The substream assignment should be done better with the spinlock, and set at last, for avoiding the potential race? Otherwise...

Quoted 11 lines

sound/usb/jockey3/Kconfig

Quoted 8 lines
sound/usb/jockey3/Kconfig new file +8 -0
+	scoped_guard(mutex, &chip->rate_mutex) {
+		if (chip->active_streams > 0) {
+			/* Force the new stream to match the existing hardware rate */
+			ret = snd_pcm_hw_constraint_single(runtime,
+							   SNDRV_PCM_HW_PARAM_RATE,
+							   chip->current_rate);
+			if (ret < 0)
+				return ret;

... here the substream is still set and left. It might be no serious problem, but still better to be cleaned up.

Ok, will look into these. Getting the concurrency handling correct is quite hard, since many subtile ways to mess it up. Thank you for the guidance.

Quoted 18 lines
Quoted 18 lines
sound/usb/jockey3/Kconfig new file +18 -0
+static int jockey3_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
+{
+	struct jockey3_chip *chip = snd_pcm_substream_chip(substream);
+
+	dev_dbg(&chip->intf0->dev, "PCM trigger stream %d, cmd %d\n", substream->stream, cmd);
+
+	if (test_bit(JOCKEY3_FLAG_DISCONNECTED, &chip->flags))
+		return -ENODEV;
+
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		guard(spinlock_irqsave)(&chip->playback_lock);
+		if (cmd == SNDRV_PCM_TRIGGER_START)
+			chip->stream_running = true;
+		else if (cmd == SNDRV_PCM_TRIGGER_STOP)
+			chip->stream_running = false;
+	} else {
+		guard(spinlock_irqsave)(&chip->capture_lock);
+		if (cmd == SNDRV_PCM_TRIGGER_START)
Quoted 8 lines

sound/usb/jockey3/Kconfig

Quoted 4 lines
sound/usb/jockey3/Kconfig new file +4 -0
+			chip->capture_running = true;
+		else if (cmd == SNDRV_PCM_TRIGGER_STOP)
+			chip->capture_running = false;
+	}

Better to implement SNDRV_PCM_TRIGGER_SUSPEND, too. It can be just as same as the stop operation. Then the suspend/resume would be supported, at least.

Hope to flesh out the v3 of this new driver this weekend.

Thanks,
Frank