Add basic capture support for Pioneer DJ DJM-250MK2
PATCH 1/1 Add basic capture support for Pioneer DJ DJM-250MK2
From: František Kučera <[email protected]>
This patch extends support for DJM-250MK2 and allows recording. However, DVS is not possible yet (see the comment in code).
--- sound/usb/pcm.c | 1 + sound/usb/quirks-table.h | 62 ++++++++++++++++++++++++++++++++++------ sound/usb/quirks.c | 1 + 3 files changed, 56 insertions(+), 8 deletions(-)
sound/usb/pcm.c +1 -0
@@ -374,6 +374,7 @@ static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs, ifnum =2 ; goto add_sync_ep_from_ifnum;case USB_ID (0x2b73 ,0x000a ):/* Pioneer DJ DJM-900NXS2 */ +case USB_ID (0x2b73 ,0x0017 ):/* Pioneer DJ DJM-250MK2 */ ep =0x82 ; ifnum =0 ; goto add_sync_ep_from_ifnum;
sound/usb/quirks-table.h +54 -8
74 lines not on this page · raw message
sound/usb/quirks.c +1 -0
@@ -1493,6 +1493,7 @@ void snd_usb_set_format_quirk(struct snd_usb_substream *subs,set_format_emu_quirk (subs, fmt);break ;case USB_ID (0x2b73 ,0x000a ):/* Pioneer DJ DJM-900NXS2 */ +case USB_ID (0x2b73 ,0x0017 ):/* Pioneer DJ DJM-250MK2 */ pioneer_djm_set_format_quirk (subs);break ;case USB_ID (0x534d ,0x2109 ):/* MacroSilicon MS2109 */
Signature · 1 line
2.20.1
Hello,
in February I added playback support for Pioneer DJ DJM-250MK2 (commit 73d8c94084341e2895169a0462dbc18167f01683). Then I gave up being disgusted by Pioneer's quality and support...
Now I returned back to the unfinished work and added basic support for recording. It is now possible to record from MIC, AUX and PHONO/LINE (but just post fader). Thanks Dmitry Panchenko and Fabian Lesniak for inspiration.
There are two remaining open questions/issues:
1) The direct (before fader) PHONO/LINE recording channels are silent until some (yet unknown) special command is send to the mixer. There is quite a lot communication over USB in both directions and I have to dig through the dumps. This would be a separate commit and I do not know, how long it could take.
2) The channels 1-2, 2-3 and 3-5, both recording and playback, can be configured/mapped (by an USB URB command) to various sources. I wrote some userspace C code for testing purposes that uses libusb-1.0/libusb.h, so I can switch the channels. How this feature should be provided to the user? Should the USB commands be issued from the kernel driver or from userspace? Is there any existing similar example?
Franta
Quoted 10 lines · František Kučera
Hello,
in February I added playback support for Pioneer DJ DJM-250MK2 (commit
73d8c94084341e2895169a0462dbc18167f01683). Then I gave up being disgusted by Pioneer's quality and support...Now I returned back to the unfinished work and added basic support for recording. It is now possible to record from MIC, AUX and PHONO/LINE (but just post fader). Thanks Dmitry Panchenko and Fabian Lesniak for inspiration.
Quoted 5 lines
There are two remaining open questions/issues:
1) The direct (before fader) PHONO/LINE recording channels are silent until some (yet unknown) special command is send to the mixer. There is quite a lot communication over USB in both directions and I have to dig through the dumps. This would be a separate commit and I do not know, how long it could take.
2) The channels 1-2, 2-3 and 3-5, both recording and playback, can be configured/mapped (by an USB URB command) to various sources. I wrote some userspace C code for testing purposes that uses
libusb-1.0/libusb.h, so I can switch the channels. How this feature should be provided to the user? Should the USB commands be issued from the kernel driver or from userspace? Is there any existing similar example?
At best implement a mixer element (probably with enumerated type) to perform the switching. You can find quite a lot of examples in mixer_quirks.c.
Takashi
Hello Franta,
Quoted 1 line
2) The channels 1-2, 2-3 and 3-5, both recording and playback, can be configured/mapped (by an USB URB command) to various sources. I wrote some userspace C code for testing purposes that uses
libusb-1.0/libusb.h, so I can switch the channels. How this feature should be provided to the user? Should the USB commands be issued from the kernel driver or from userspace? Is there any existing similar example?
I have implemented these controls in mixer_quirks.c back when I fought with these mixers. As I have not tested them against the current master and your changes yet, I'll just drop a gist with the old patches from last September if you want to have a look (patch 0003 is the one with the mixer controls):
https://gist.github.com/flesniak/074ab23bbc833663b782f44174eae6a4
I will try to test that single patch together with your patches and submit them if it works. I remember faintly that alsamixer did not show the TLV dB range correctly, probably I was using DECLARE_TLV_DB_RANGE incorrectly.
Cheers
Fabian
MIDI handshake for Pioneer DJ DJM-250MK2 to enable recording LINE/PHONO channels
In reply to František KučeraDne 25. 08. 20 v 17:36 František Kučera napsal(a):
Quoted 1 line
1) The direct (before fader) PHONO/LINE recording channels are silent until some (yet unknown) special command is send to the mixer. There is quite a lot communication over USB in both directions and I have to dig through the dumps. This would be a separate commit and I do not know, how long it could take.
As mentioned earlier, the Pioneer DJM devices are somehow broken and by default they produce only silence on LINE/PHONO recording channels.
It was really challenging but it is no more hopeless – in the meantime, someone described, how it works inside, and I wrote a standalone program called djm-fix that fixes the device and enables the LINE/PHONO channels (so the mixer is usable e.g. for DVS). Details are described here: <https://blog.frantovo.cz/c/387/>. The djm-fix tool is still a bit raw, but it works for me and at least one more DJM-250MK2 owner confirmed, that it works.
Is it possible to move this fix to the kernel level? Or should it stay rather as a standalone tool? I think that it would be nice to have Pioneer DJM devices fully working out of the box without additional tools.
The fix consists of a MIDI handshake – we need to send and receive some messages, compute some hash and then periodically send a keep-alive message (when we stop, the LINE/PHONO channels become silent again).
Franta
Re: MIDI handshake for Pioneer DJ DJM-250MK2 to enable recording LINE/PHONO channels
Quoted 11 lines · František Kučera
Dne 25. 08. 20 v 17:36 František Kučera napsal(a):
Quoted 1 line
1) The direct (before fader) PHONO/LINE recording channels are silent until some (yet unknown) special command is send to the mixer. There is quite a lot communication over USB in both directions and I have to dig through the dumps. This would be a separate commit and I do not know, how long it could take.
As mentioned earlier, the Pioneer DJM devices are somehow broken and by default they produce only silence on LINE/PHONO recording channels.
It was really challenging but it is no more hopeless – in the meantime, someone described, how it works inside, and I wrote a standalone program called djm-fix that fixes the device and enables the LINE/PHONO channels (so the mixer is usable e.g. for DVS). Details are described here: <https://blog.frantovo.cz/c/387/>. The djm-fix tool is still a bit raw, but it works for me and at least one more DJM-250MK2 owner confirmed, that it works.
Is it possible to move this fix to the kernel level? Or should it stay rather as a standalone tool? I think that it would be nice to have Pioneer DJM devices fully working out of the box without additional tools.
The fix consists of a MIDI handshake – we need to send and receive some messages, compute some hash and then periodically send a keep-alive message (when we stop, the LINE/PHONO channels become silent again).
I haven't looked closely, but if it's about MIDI messaging, it can be implemented in the kernel, too (only if it fits better than user-space), yes. If it's over HID, it's a different story, though.
Takashi
Re: MIDI handshake for Pioneer DJ DJM-250MK2 to enable recording LINE/PHONO channels
Dne 19. 01. 21 v 9:54 Takashi Iwai napsal(a):
Quoted 3 lines
I haven't looked closely, but if it's about MIDI messaging, it can be implemented in the kernel, too (only if it fits better than user-space), yes. If it's over HID, it's a different story, though.
Yes, it is only MIDI. The scenario is:
1) send a greeting message to the mixer
2) receive a greeting message
3) send another constant message
4) receive the response
5) compute something and send it back
6) receive the confirmation message
7) start sending a keep-alive message each 200 ms
Specific received messages might be consumed by kernel (invisible for user-space), but others should flow undisturbed to the user-space. The sent messages should be injected and intermixed with normal messages coming from user-space. The kernel should not claim exclusive access to the MIDI device, because user-space tools might want to use it too.
Is there already anything similar, for inspiration?
Franta
Re: MIDI handshake for Pioneer DJ DJM-250MK2 to enable recording LINE/PHONO channels
I discourage doing this in the kernel. If Pioneer did this in their drivers on Windows and macOS, I would recommend doing it in the kernel. But they do not; Rekordbox does it at the application level. Mixxx users are currently unable to use the phono inputs of these devices regardless of OS (see https://mixxx.discourse.group/t/pioneer-djm-250-mk2/17001/29 ). The best way to implement this would be through Mixxx's MIDI controller mapping system so that it works across Linux, Windows, and macOS.
I am CCing Olivia Mackintosh because the Pioneer DJM 750 likely uses the same or very similar MIDI signals. They could probably share one MIDI script in Mixxx. The Pioneer DJM 900 NXS2 probably uses the same or very similar signals too.
If you're interested in implementing this in Mixxx, let's continue the discussion in Mixxx's Zulip chat: https://mixxx.zulipchat.com/
Quoted 16 lines
Dne 19. 01. 21 v 9:54 Takashi Iwai napsal(a):
Quoted 1 line
/I haven't looked closely, but if it's about MIDI messaging, it can be /> >/implemented in the kernel, too (only if it fits better than /> >/user-space), yes. If it's over HID, it's a different story, though. />
Yes, it is only MIDI. The scenario is:
1) send a greeting message to the mixer
2) receive a greeting message
3) send another constant message
4) receive the response
5) compute something and send it back
6) receive the confirmation message
Quoted 7 lines
7) start sending a keep-alive message each 200 ms
Specific received messages might be consumed by kernel (invisible for user-space), but others should flow undisturbed to the user-space. The sent messages should be injected and intermixed with normal messages coming from user-space. The kernel should not claim exclusive access to the MIDI device, because user-space tools might want to use it too.
Is there already anything similar, for inspiration?
Franta
------------------------------------------------------------------------
Re: MIDI handshake for Pioneer DJ DJM-250MK2 to enable recording LINE/PHONO channels
Thank you for copying me in.
I would love to support Pioneer devices under Linux ("fully"). I.e:
for DJM mixers: the ability to use audio and midi IO with ALSA and by extension pulse/pipewire/JACK and so on. This is my bias.
I'm partial to things just working™ so would prefer it to be a kernel module but the inclusion in-tree is not for me to say.
Lets continue this discussion on the Mixxx chat for now.
Kind regards,
Olivia
Quoted 32 lines · Be
I discourage doing this in the kernel. If Pioneer did this in their drivers on Windows and macOS, I would recommend doing it in the kernel. But they do not; Rekordbox does it at the application level. Mixxx users are currently unable to use the phono inputs of these devices regardless of OS (see https://mixxx.discourse.group/t/pioneer-djm-250-mk2/17001/29 ). The best way to implement this would be through Mixxx's MIDI controller mapping system so that it works across Linux, Windows, and macOS.
I am CCing Olivia Mackintosh because the Pioneer DJM 750 likely uses the same or very similar MIDI signals. They could probably share one MIDI script in Mixxx. The Pioneer DJM 900 NXS2 probably uses the same or very similar signals too.
If you're interested in implementing this in Mixxx, let's continue the discussion in Mixxx's Zulip chat: https://mixxx.zulipchat.com/
Quoted 16 lines
Dne 19. 01. 21 v 9:54 Takashi Iwai napsal(a):
Quoted 1 line
/I haven't looked closely, but if it's about MIDI messaging, it can be /> >/implemented in the kernel, too (only if it fits better than /> >/user-space), yes. If it's over HID, it's a different story, though. />
Yes, it is only MIDI. The scenario is:
1) send a greeting message to the mixer
2) receive a greeting message
3) send another constant message
4) receive the response
5) compute something and send it back
6) receive the confirmation message
Quoted 7 lines
7) start sending a keep-alive message each 200 ms
Specific received messages might be consumed by kernel (invisible for user-space), but others should flow undisturbed to the user-space. The sent messages should be injected and intermixed with normal messages coming from user-space. The kernel should not claim exclusive access to the MIDI device, because user-space tools might want to use it too.
Is there already anything similar, for inspiration?
Franta
------------------------------------------------------------------------
Quoted 7 lines · František Kučera
From: František Kučera <[email protected]>
This patch extends support for DJM-250MK2 and allows recording. However, DVS is not possible yet (see the comment in code).
Signed-off-by František Kučera <[email protected]>
Applied now. Thanks.
Takashi