All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4]: ALSA: usb-audio: Add Pioneer DJM-850 support
@ 2021-02-26 13:34 Nicolas MURE
  2021-02-26 13:34 ` [PATCH 1/4] ALSA: usb-audio: Add Pioneer DJM-850 to quirks-table Nicolas MURE
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Nicolas MURE @ 2021-02-26 13:34 UTC (permalink / raw)
  To: alsa-devel; +Cc: Nicolas MURE, livvy

Hello,

This patches serie adds support for the Pioneer DJM-850 mixer. The mixer
has a 24bits (little endian) sound card, which features 4 stereo
channels for capture and 4 stereo channels for playback.
The mixer also has controls to specify the capture source for each
channels, and also a control to set the sample rate (44.1kHz, 48kHz,
96kHz).

Thank you :)

Signed-off-by: Nicolas MURE <nicolas.mure2019@gmail.com>



^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/4] ALSA: usb-audio: Add Pioneer DJM-850 to quirks-table
  2021-02-26 13:34 [PATCH 0/4]: ALSA: usb-audio: Add Pioneer DJM-850 support Nicolas MURE
@ 2021-02-26 13:34 ` Nicolas MURE
  2021-02-26 13:34 ` [PATCH 2/4] ASLA: usb-audio: Declare Pioneer DJM-850 mixer controls Nicolas MURE
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 12+ messages in thread
From: Nicolas MURE @ 2021-02-26 13:34 UTC (permalink / raw)
  To: alsa-devel; +Cc: Nicolas MURE, livvy

Declare the Pioneer DJM-850 interfaces for capture and playback.

See https://github.com/nm2107/Pioneer-DJM-850-driver-reverse-engineering
    /blob/172fb9a61055960c88c67b7c416fe5bf3609807b
    /doc/usb-device-specifications.md

for the complete device spec.

Signed-off-by: Nicolas MURE <nicolas.mure2019@gmail.com>
---
 sound/usb/quirks-table.h | 63 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
index 1165a5ac60f2..9716a9f7c095 100644
--- a/sound/usb/quirks-table.h
+++ b/sound/usb/quirks-table.h
@@ -3817,6 +3817,69 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
 		}
 	}
 },
+{
+	/*
+	 * Pioneer DJ DJM-850
+	 * 8 channels playback and 8 channels capture @ 44.1/48/96kHz S24LE
+	 * Playback on EP 0x05
+	 * Capture on EP 0x86
+	 */
+	USB_DEVICE_VENDOR_SPEC(0x08e4, 0x0163),
+	.driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
+		.ifnum = QUIRK_ANY_INTERFACE,
+		.type = QUIRK_COMPOSITE,
+		.data = (const struct snd_usb_audio_quirk[]) {
+			{
+				.ifnum = 0,
+				.type = QUIRK_AUDIO_FIXED_ENDPOINT,
+				.data = &(const struct audioformat) {
+					.formats = SNDRV_PCM_FMTBIT_S24_3LE,
+					.channels = 8,
+					.iface = 0,
+					.altsetting = 1,
+					.altset_idx = 1,
+					.endpoint = 0x05,
+					.ep_attr = USB_ENDPOINT_XFER_ISOC|
+					    USB_ENDPOINT_SYNC_ASYNC|
+						USB_ENDPOINT_USAGE_DATA,
+					.rates = SNDRV_PCM_RATE_44100|
+						SNDRV_PCM_RATE_48000|
+						SNDRV_PCM_RATE_96000,
+					.rate_min = 44100,
+					.rate_max = 96000,
+					.nr_rates = 3,
+					.rate_table = (unsigned int[]) { 44100, 48000, 96000 }
+				}
+			},
+			{
+				.ifnum = 0,
+				.type = QUIRK_AUDIO_FIXED_ENDPOINT,
+				.data = &(const struct audioformat) {
+					.formats = SNDRV_PCM_FMTBIT_S24_3LE,
+					.channels = 8,
+					.iface = 0,
+					.altsetting = 1,
+					.altset_idx = 1,
+					.endpoint = 0x86,
+					.ep_idx = 1,
+					.ep_attr = USB_ENDPOINT_XFER_ISOC|
+						USB_ENDPOINT_SYNC_ASYNC|
+						USB_ENDPOINT_USAGE_DATA,
+					.rates = SNDRV_PCM_RATE_44100|
+						SNDRV_PCM_RATE_48000|
+						SNDRV_PCM_RATE_96000,
+					.rate_min = 44100,
+					.rate_max = 96000,
+					.nr_rates = 3,
+					.rate_table = (unsigned int[]) { 44100, 48000, 96000 }
+				}
+			},
+			{
+				.ifnum = -1
+			}
+		}
+	}
+},
 {
 	/*
 	 * Pioneer DJ DJM-450
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/4] ASLA: usb-audio: Declare Pioneer DJM-850 mixer controls
  2021-02-26 13:34 [PATCH 0/4]: ALSA: usb-audio: Add Pioneer DJM-850 support Nicolas MURE
  2021-02-26 13:34 ` [PATCH 1/4] ALSA: usb-audio: Add Pioneer DJM-850 to quirks-table Nicolas MURE
@ 2021-02-26 13:34 ` Nicolas MURE
  2021-02-26 13:34 ` [PATCH 3/4] ALSA: usb-audio: Configure Pioneer DJM-850 samplerate Nicolas MURE
  2021-02-26 13:34 ` [PATCH 4/4] ASLA: usb-audio: fix Pioneer DJM-850 control label info Nicolas MURE
  3 siblings, 0 replies; 12+ messages in thread
From: Nicolas MURE @ 2021-02-26 13:34 UTC (permalink / raw)
  To: alsa-devel; +Cc: Nicolas MURE, livvy

Declare audio capture controls to choose the audio source, and also to
set the capture level (in dB).

See https://github.com/nm2107/Pioneer-DJM-850-driver-reverse-engineering
    /blob/172fb9a61055960c88c67b7c416fe5bf3609807b
    /doc/windows-djm-850-setting-utility/mixer-output-tab/README.md

Signed-off-by: Nicolas MURE <nicolas.mure2019@gmail.com>
---
 sound/usb/mixer_quirks.c | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index 08873d2afe4d..b325b6597d91 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -2649,9 +2649,11 @@ static int snd_bbfpro_controls_create(struct usb_mixer_interface *mixer)
 #define SND_DJM_DEVICE_SHIFT	24
 
 // device table index
+// used for the snd_djm_devices table, so please update accordingly
 #define SND_DJM_250MK2_IDX	0x0
 #define SND_DJM_750_IDX		0x1
-#define SND_DJM_900NXS2_IDX	0x2
+#define SND_DJM_850_IDX		0x2
+#define SND_DJM_900NXS2_IDX	0x3
 
 
 #define SND_DJM_CTL(_name, suffix, _default_value, _windex) { \
@@ -2733,11 +2735,12 @@ static const char *snd_djm_get_label(u16 wvalue, u16 windex)
 	}
 };
 
-
-// DJM-250MK2
+// common DJM capture level option values
 static const u16 snd_djm_opts_cap_level[] = {
 	0x0000, 0x0100, 0x0200, 0x0300 };
 
+
+// DJM-250MK2
 static const u16 snd_djm_opts_250mk2_cap1[] = {
 	0x0103, 0x0100, 0x0106, 0x0107, 0x0108, 0x0109, 0x010d, 0x010a };
 
@@ -2781,6 +2784,25 @@ static const struct snd_djm_ctl snd_djm_ctls_750[] = {
 };
 
 
+// DJM-850
+static const u16 snd_djm_opts_850_cap1[] = {
+	0x0100, 0x0103, 0x0106, 0x0107, 0x0108, 0x0109, 0x010a, 0x010f };
+static const u16 snd_djm_opts_850_cap2[] = {
+	0x0200, 0x0201, 0x0206, 0x0207, 0x0208, 0x0209, 0x020a, 0x020f };
+static const u16 snd_djm_opts_850_cap3[] = {
+	0x0300, 0x0301, 0x0306, 0x0307, 0x0308, 0x0309, 0x030a, 0x030f };
+static const u16 snd_djm_opts_850_cap4[] = {
+	0x0400, 0x0403, 0x0406, 0x0407, 0x0408, 0x0409, 0x040a, 0x040f };
+
+static const struct snd_djm_ctl snd_djm_ctls_850[] = {
+	SND_DJM_CTL("Capture Level", cap_level, 0, SND_DJM_WINDEX_CAPLVL),
+	SND_DJM_CTL("Ch1 Input",   850_cap1, 1, SND_DJM_WINDEX_CAP),
+	SND_DJM_CTL("Ch2 Input",   850_cap2, 0, SND_DJM_WINDEX_CAP),
+	SND_DJM_CTL("Ch3 Input",   850_cap3, 0, SND_DJM_WINDEX_CAP),
+	SND_DJM_CTL("Ch4 Input",   850_cap4, 1, SND_DJM_WINDEX_CAP)
+};
+
+
 // DJM-900NXS2
 static const u16 snd_djm_opts_900nxs2_cap1[] = {
 	0x0100, 0x0102, 0x0103, 0x0106, 0x0107, 0x0108, 0x0109, 0x010a };
@@ -2806,6 +2828,7 @@ static const struct snd_djm_ctl snd_djm_ctls_900nxs2[] = {
 static const struct snd_djm_device snd_djm_devices[] = {
 	SND_DJM_DEVICE(250mk2),
 	SND_DJM_DEVICE(750),
+	SND_DJM_DEVICE(850),
 	SND_DJM_DEVICE(900nxs2)
 };
 
@@ -3045,6 +3068,9 @@ int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
 	case USB_ID(0x08e4, 0x017f): /* Pioneer DJ DJM-750 */
 		err = snd_djm_controls_create(mixer, SND_DJM_750_IDX);
 		break;
+	case USB_ID(0x08e4, 0x0163): /* Pioneer DJ DJM-850 */
+		err = snd_djm_controls_create(mixer, SND_DJM_850_IDX);
+		break;
 	case USB_ID(0x2b73, 0x000a): /* Pioneer DJ DJM-900NXS2 */
 		err = snd_djm_controls_create(mixer, SND_DJM_900NXS2_IDX);
 		break;
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/4] ALSA: usb-audio: Configure Pioneer DJM-850 samplerate
  2021-02-26 13:34 [PATCH 0/4]: ALSA: usb-audio: Add Pioneer DJM-850 support Nicolas MURE
  2021-02-26 13:34 ` [PATCH 1/4] ALSA: usb-audio: Add Pioneer DJM-850 to quirks-table Nicolas MURE
  2021-02-26 13:34 ` [PATCH 2/4] ASLA: usb-audio: Declare Pioneer DJM-850 mixer controls Nicolas MURE
@ 2021-02-26 13:34 ` Nicolas MURE
  2021-03-01 13:58   ` Takashi Iwai
  2021-02-26 13:34 ` [PATCH 4/4] ASLA: usb-audio: fix Pioneer DJM-850 control label info Nicolas MURE
  3 siblings, 1 reply; 12+ messages in thread
From: Nicolas MURE @ 2021-02-26 13:34 UTC (permalink / raw)
  To: alsa-devel; +Cc: Nicolas MURE, livvy

Send an `URB_CONTROL out` USB frame to the device to configure its
samplerate. This should be done before using the device for audio
streaming (capture or playback).

About the change of `usb_rcvctrlpipe` to `usb_sndctrlpipe`, I reached
the author of this line and she agrees about this change. Control frames
to set device options should have the `out` direction instead of the `in`
direction.

See https://github.com/nm2107/Pioneer-DJM-850-driver-reverse-engineering
    /blob/172fb9a61055960c88c67b7c416fe5bf3609807b
    /doc/windows-dvs/framerate-setting/README.md

Signed-off-by: Nicolas MURE <nicolas.mure2019@gmail.com>
---
 sound/usb/quirks.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 9ba4682ebc48..d02dac5fcd40 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1482,7 +1482,7 @@ static int pioneer_djm_set_format_quirk(struct snd_usb_substream *subs,
 	usb_set_interface(subs->dev, 0, 1);
 	// we should derive windex from fmt-sync_ep but it's not set
 	snd_usb_ctl_msg(subs->stream->chip->dev,
-		usb_rcvctrlpipe(subs->stream->chip->dev, 0),
+		usb_sndctrlpipe(subs->stream->chip->dev, 0),
 		0x01, 0x22, 0x0100, windex, &sr, 0x0003);
 	return 0;
 }
@@ -1503,6 +1503,9 @@ void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
 	case USB_ID(0x2b73, 0x0013): /* Pioneer DJM-450 */
 		pioneer_djm_set_format_quirk(subs, 0x0082);
 		break;
+	case USB_ID(0x08e4, 0x0163): /* Pioneer DJM-850 */
+		pioneer_djm_set_format_quirk(subs, 0x0086);
+		break;
 	}
 }
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/4] ASLA: usb-audio: fix Pioneer DJM-850 control label info
  2021-02-26 13:34 [PATCH 0/4]: ALSA: usb-audio: Add Pioneer DJM-850 support Nicolas MURE
                   ` (2 preceding siblings ...)
  2021-02-26 13:34 ` [PATCH 3/4] ALSA: usb-audio: Configure Pioneer DJM-850 samplerate Nicolas MURE
@ 2021-02-26 13:34 ` Nicolas MURE
  3 siblings, 0 replies; 12+ messages in thread
From: Nicolas MURE @ 2021-02-26 13:34 UTC (permalink / raw)
  To: alsa-devel; +Cc: Nicolas MURE, livvy

Unlike the other DJM, the value to set the "CD/LINE" and "LINE" capture
control options are inverted. This fix makes sure that the displayed
info label while using `alsamixer` matches the input switches label
on the DJM-850 mixer.

Signed-off-by: Nicolas MURE <nicolas.mure2019@gmail.com>
---
 sound/usb/mixer_quirks.c | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index b325b6597d91..5b77e8140ba6 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -2693,7 +2693,7 @@ static const char *snd_djm_get_label_caplevel(u16 wvalue)
 	}
 };
 
-static const char *snd_djm_get_label_cap(u16 wvalue)
+static const char *snd_djm_get_label_cap_common(u16 wvalue)
 {
 	switch (wvalue & 0x00ff) {
 	case SND_DJM_CAP_LINE:		return "Control Tone LINE";
@@ -2715,6 +2715,25 @@ static const char *snd_djm_get_label_cap(u16 wvalue)
 	}
 };
 
+// The DJM-850 has different values for CD/LINE and LINE capture
+// control options than the other DJM declared in this file.
+static const char *snd_djm_get_label_cap_850(u16 wvalue)
+{
+	switch (wvalue & 0x00ff) {
+	case 0x00:		return "Control Tone CD/LINE";
+	case 0x01:		return "Control Tone LINE";
+	default:		return snd_djm_get_label_cap_common(wvalue);
+	}
+};
+
+static const char *snd_djm_get_label_cap(u8 device_idx, u16 wvalue)
+{
+	switch (device_idx) {
+	case SND_DJM_850_IDX:		return snd_djm_get_label_cap_850(wvalue);
+	default:			return snd_djm_get_label_cap_common(wvalue);
+	}
+};
+
 static const char *snd_djm_get_label_pb(u16 wvalue)
 {
 	switch (wvalue & 0x00ff) {
@@ -2725,11 +2744,11 @@ static const char *snd_djm_get_label_pb(u16 wvalue)
 	}
 };
 
-static const char *snd_djm_get_label(u16 wvalue, u16 windex)
+static const char *snd_djm_get_label(u8 device_idx, u16 wvalue, u16 windex)
 {
 	switch (windex) {
 	case SND_DJM_WINDEX_CAPLVL:	return snd_djm_get_label_caplevel(wvalue);
-	case SND_DJM_WINDEX_CAP:	return snd_djm_get_label_cap(wvalue);
+	case SND_DJM_WINDEX_CAP:	return snd_djm_get_label_cap(device_idx, wvalue);
 	case SND_DJM_WINDEX_PB:		return snd_djm_get_label_pb(wvalue);
 	default:			return NULL;
 	}
@@ -2852,7 +2871,8 @@ static int snd_djm_controls_info(struct snd_kcontrol *kctl,
 	if (info->value.enumerated.item >= noptions)
 		info->value.enumerated.item = noptions - 1;
 
-	name = snd_djm_get_label(ctl->options[info->value.enumerated.item],
+	name = snd_djm_get_label(device_idx,
+				ctl->options[info->value.enumerated.item],
 				ctl->wIndex);
 	if (!name)
 		return -EINVAL;
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/4] ALSA: usb-audio: Configure Pioneer DJM-850 samplerate
  2021-02-26 13:34 ` [PATCH 3/4] ALSA: usb-audio: Configure Pioneer DJM-850 samplerate Nicolas MURE
@ 2021-03-01 13:58   ` Takashi Iwai
  2021-03-01 15:27     ` [PATCH v2 0/4] ALSA: usb-audio: Add Pioneer DJM-850 support Nicolas MURE
  0 siblings, 1 reply; 12+ messages in thread
From: Takashi Iwai @ 2021-03-01 13:58 UTC (permalink / raw)
  To: Nicolas MURE; +Cc: alsa-devel, livvy

On Fri, 26 Feb 2021 14:34:28 +0100,
Nicolas MURE wrote:
> 
> Send an `URB_CONTROL out` USB frame to the device to configure its
> samplerate. This should be done before using the device for audio
> streaming (capture or playback).
> 
> About the change of `usb_rcvctrlpipe` to `usb_sndctrlpipe`, I reached
> the author of this line and she agrees about this change. Control frames
> to set device options should have the `out` direction instead of the `in`
> direction.

This specific fix should be applied separately for 5.12.
Could you split this one and submit as an individual fix?

I'm currently thinking of merging the rest for 5.13, as 5.12 merge
window was already closed.


thanks,

Takashi

> 
> See https://github.com/nm2107/Pioneer-DJM-850-driver-reverse-engineering
>     /blob/172fb9a61055960c88c67b7c416fe5bf3609807b
>     /doc/windows-dvs/framerate-setting/README.md
> 
> Signed-off-by: Nicolas MURE <nicolas.mure2019@gmail.com>
> ---
>  sound/usb/quirks.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
> index 9ba4682ebc48..d02dac5fcd40 100644
> --- a/sound/usb/quirks.c
> +++ b/sound/usb/quirks.c
> @@ -1482,7 +1482,7 @@ static int pioneer_djm_set_format_quirk(struct snd_usb_substream *subs,
>  	usb_set_interface(subs->dev, 0, 1);
>  	// we should derive windex from fmt-sync_ep but it's not set
>  	snd_usb_ctl_msg(subs->stream->chip->dev,
> -		usb_rcvctrlpipe(subs->stream->chip->dev, 0),
> +		usb_sndctrlpipe(subs->stream->chip->dev, 0),
>  		0x01, 0x22, 0x0100, windex, &sr, 0x0003);
>  	return 0;
>  }
> @@ -1503,6 +1503,9 @@ void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
>  	case USB_ID(0x2b73, 0x0013): /* Pioneer DJM-450 */
>  		pioneer_djm_set_format_quirk(subs, 0x0082);
>  		break;
> +	case USB_ID(0x08e4, 0x0163): /* Pioneer DJM-850 */
> +		pioneer_djm_set_format_quirk(subs, 0x0086);
> +		break;
>  	}
>  }
>  
> -- 
> 2.29.2
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 0/4] ALSA: usb-audio: Add Pioneer DJM-850 support
  2021-03-01 13:58   ` Takashi Iwai
@ 2021-03-01 15:27     ` Nicolas MURE
  2021-03-01 15:27       ` [PATCH v2 1/4] ALSA: usb-audio: Add Pioneer DJM-850 to quirks-table Nicolas MURE
                         ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Nicolas MURE @ 2021-03-01 15:27 UTC (permalink / raw)
  To: tiwai; +Cc: alsa-devel, livvy

Hello,

I updated the patches to consider the request to split patch #3
(c.f. https://mailman.alsa-project.org/pipermail/alsa-devel/2021-March/181275.html ).

The patch #3 now only contains changes related to DJM-850 support as the
fix it was previously containing was applied in linux 5.12
(c.f. https://mailman.alsa-project.org/pipermail/alsa-devel/2021-March/181279.html ).

The patches should be ready to merge into linux 5.13 .


Thank you :)

Patches list :

[PATCH v2 1/4] ALSA: usb-audio: Add Pioneer DJM-850 to quirks-table
[PATCH v2 2/4] ASLA: usb-audio: Declare Pioneer DJM-850 mixer
[PATCH v2 3/4] ALSA: usb-audio: Configure Pioneer DJM-850 samplerate
[PATCH v2 4/4] ASLA: usb-audio: fix Pioneer DJM-850 control label


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 1/4] ALSA: usb-audio: Add Pioneer DJM-850 to quirks-table
  2021-03-01 15:27     ` [PATCH v2 0/4] ALSA: usb-audio: Add Pioneer DJM-850 support Nicolas MURE
@ 2021-03-01 15:27       ` Nicolas MURE
  2021-03-01 15:27       ` [PATCH v2 2/4] ASLA: usb-audio: Declare Pioneer DJM-850 mixer controls Nicolas MURE
                         ` (3 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Nicolas MURE @ 2021-03-01 15:27 UTC (permalink / raw)
  To: tiwai; +Cc: Nicolas MURE, alsa-devel, livvy

Declare the Pioneer DJM-850 interfaces for capture and playback.

See https://github.com/nm2107/Pioneer-DJM-850-driver-reverse-engineering/blob/172fb9a61055960c88c67b7c416fe5bf3609807b/doc/usb-device-specifications.md
for the complete device spec.

Signed-off-by: Nicolas MURE <nicolas.mure2019@gmail.com>
---
 sound/usb/quirks-table.h | 63 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
index 1165a5ac60f2..9716a9f7c095 100644
--- a/sound/usb/quirks-table.h
+++ b/sound/usb/quirks-table.h
@@ -3817,6 +3817,69 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
 		}
 	}
 },
+{
+	/*
+	 * Pioneer DJ DJM-850
+	 * 8 channels playback and 8 channels capture @ 44.1/48/96kHz S24LE
+	 * Playback on EP 0x05
+	 * Capture on EP 0x86
+	 */
+	USB_DEVICE_VENDOR_SPEC(0x08e4, 0x0163),
+	.driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
+		.ifnum = QUIRK_ANY_INTERFACE,
+		.type = QUIRK_COMPOSITE,
+		.data = (const struct snd_usb_audio_quirk[]) {
+			{
+				.ifnum = 0,
+				.type = QUIRK_AUDIO_FIXED_ENDPOINT,
+				.data = &(const struct audioformat) {
+					.formats = SNDRV_PCM_FMTBIT_S24_3LE,
+					.channels = 8,
+					.iface = 0,
+					.altsetting = 1,
+					.altset_idx = 1,
+					.endpoint = 0x05,
+					.ep_attr = USB_ENDPOINT_XFER_ISOC|
+					    USB_ENDPOINT_SYNC_ASYNC|
+						USB_ENDPOINT_USAGE_DATA,
+					.rates = SNDRV_PCM_RATE_44100|
+						SNDRV_PCM_RATE_48000|
+						SNDRV_PCM_RATE_96000,
+					.rate_min = 44100,
+					.rate_max = 96000,
+					.nr_rates = 3,
+					.rate_table = (unsigned int[]) { 44100, 48000, 96000 }
+				}
+			},
+			{
+				.ifnum = 0,
+				.type = QUIRK_AUDIO_FIXED_ENDPOINT,
+				.data = &(const struct audioformat) {
+					.formats = SNDRV_PCM_FMTBIT_S24_3LE,
+					.channels = 8,
+					.iface = 0,
+					.altsetting = 1,
+					.altset_idx = 1,
+					.endpoint = 0x86,
+					.ep_idx = 1,
+					.ep_attr = USB_ENDPOINT_XFER_ISOC|
+						USB_ENDPOINT_SYNC_ASYNC|
+						USB_ENDPOINT_USAGE_DATA,
+					.rates = SNDRV_PCM_RATE_44100|
+						SNDRV_PCM_RATE_48000|
+						SNDRV_PCM_RATE_96000,
+					.rate_min = 44100,
+					.rate_max = 96000,
+					.nr_rates = 3,
+					.rate_table = (unsigned int[]) { 44100, 48000, 96000 }
+				}
+			},
+			{
+				.ifnum = -1
+			}
+		}
+	}
+},
 {
 	/*
 	 * Pioneer DJ DJM-450
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 2/4] ASLA: usb-audio: Declare Pioneer DJM-850 mixer controls
  2021-03-01 15:27     ` [PATCH v2 0/4] ALSA: usb-audio: Add Pioneer DJM-850 support Nicolas MURE
  2021-03-01 15:27       ` [PATCH v2 1/4] ALSA: usb-audio: Add Pioneer DJM-850 to quirks-table Nicolas MURE
@ 2021-03-01 15:27       ` Nicolas MURE
  2021-03-01 15:27       ` [PATCH v2 3/4] ALSA: usb-audio: Configure Pioneer DJM-850 samplerate Nicolas MURE
                         ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Nicolas MURE @ 2021-03-01 15:27 UTC (permalink / raw)
  To: tiwai; +Cc: Nicolas MURE, alsa-devel, livvy

Declare audio capture controls to choose the audio source, and also to
set the capture level (in dB).

See https://github.com/nm2107/Pioneer-DJM-850-driver-reverse-engineering/blob/172fb9a61055960c88c67b7c416fe5bf3609807b/doc/windows-djm-850-setting-utility/mixer-output-tab/README.md

Signed-off-by: Nicolas MURE <nicolas.mure2019@gmail.com>
---
 sound/usb/mixer_quirks.c | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index 08873d2afe4d..b325b6597d91 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -2649,9 +2649,11 @@ static int snd_bbfpro_controls_create(struct usb_mixer_interface *mixer)
 #define SND_DJM_DEVICE_SHIFT	24
 
 // device table index
+// used for the snd_djm_devices table, so please update accordingly
 #define SND_DJM_250MK2_IDX	0x0
 #define SND_DJM_750_IDX		0x1
-#define SND_DJM_900NXS2_IDX	0x2
+#define SND_DJM_850_IDX		0x2
+#define SND_DJM_900NXS2_IDX	0x3
 
 
 #define SND_DJM_CTL(_name, suffix, _default_value, _windex) { \
@@ -2733,11 +2735,12 @@ static const char *snd_djm_get_label(u16 wvalue, u16 windex)
 	}
 };
 
-
-// DJM-250MK2
+// common DJM capture level option values
 static const u16 snd_djm_opts_cap_level[] = {
 	0x0000, 0x0100, 0x0200, 0x0300 };
 
+
+// DJM-250MK2
 static const u16 snd_djm_opts_250mk2_cap1[] = {
 	0x0103, 0x0100, 0x0106, 0x0107, 0x0108, 0x0109, 0x010d, 0x010a };
 
@@ -2781,6 +2784,25 @@ static const struct snd_djm_ctl snd_djm_ctls_750[] = {
 };
 
 
+// DJM-850
+static const u16 snd_djm_opts_850_cap1[] = {
+	0x0100, 0x0103, 0x0106, 0x0107, 0x0108, 0x0109, 0x010a, 0x010f };
+static const u16 snd_djm_opts_850_cap2[] = {
+	0x0200, 0x0201, 0x0206, 0x0207, 0x0208, 0x0209, 0x020a, 0x020f };
+static const u16 snd_djm_opts_850_cap3[] = {
+	0x0300, 0x0301, 0x0306, 0x0307, 0x0308, 0x0309, 0x030a, 0x030f };
+static const u16 snd_djm_opts_850_cap4[] = {
+	0x0400, 0x0403, 0x0406, 0x0407, 0x0408, 0x0409, 0x040a, 0x040f };
+
+static const struct snd_djm_ctl snd_djm_ctls_850[] = {
+	SND_DJM_CTL("Capture Level", cap_level, 0, SND_DJM_WINDEX_CAPLVL),
+	SND_DJM_CTL("Ch1 Input",   850_cap1, 1, SND_DJM_WINDEX_CAP),
+	SND_DJM_CTL("Ch2 Input",   850_cap2, 0, SND_DJM_WINDEX_CAP),
+	SND_DJM_CTL("Ch3 Input",   850_cap3, 0, SND_DJM_WINDEX_CAP),
+	SND_DJM_CTL("Ch4 Input",   850_cap4, 1, SND_DJM_WINDEX_CAP)
+};
+
+
 // DJM-900NXS2
 static const u16 snd_djm_opts_900nxs2_cap1[] = {
 	0x0100, 0x0102, 0x0103, 0x0106, 0x0107, 0x0108, 0x0109, 0x010a };
@@ -2806,6 +2828,7 @@ static const struct snd_djm_ctl snd_djm_ctls_900nxs2[] = {
 static const struct snd_djm_device snd_djm_devices[] = {
 	SND_DJM_DEVICE(250mk2),
 	SND_DJM_DEVICE(750),
+	SND_DJM_DEVICE(850),
 	SND_DJM_DEVICE(900nxs2)
 };
 
@@ -3045,6 +3068,9 @@ int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
 	case USB_ID(0x08e4, 0x017f): /* Pioneer DJ DJM-750 */
 		err = snd_djm_controls_create(mixer, SND_DJM_750_IDX);
 		break;
+	case USB_ID(0x08e4, 0x0163): /* Pioneer DJ DJM-850 */
+		err = snd_djm_controls_create(mixer, SND_DJM_850_IDX);
+		break;
 	case USB_ID(0x2b73, 0x000a): /* Pioneer DJ DJM-900NXS2 */
 		err = snd_djm_controls_create(mixer, SND_DJM_900NXS2_IDX);
 		break;
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 3/4] ALSA: usb-audio: Configure Pioneer DJM-850 samplerate
  2021-03-01 15:27     ` [PATCH v2 0/4] ALSA: usb-audio: Add Pioneer DJM-850 support Nicolas MURE
  2021-03-01 15:27       ` [PATCH v2 1/4] ALSA: usb-audio: Add Pioneer DJM-850 to quirks-table Nicolas MURE
  2021-03-01 15:27       ` [PATCH v2 2/4] ASLA: usb-audio: Declare Pioneer DJM-850 mixer controls Nicolas MURE
@ 2021-03-01 15:27       ` Nicolas MURE
  2021-03-01 15:27       ` [PATCH v2 4/4] ASLA: usb-audio: fix Pioneer DJM-850 control label info Nicolas MURE
  2021-03-02  9:20       ` [PATCH v2 0/4] ALSA: usb-audio: Add Pioneer DJM-850 support Takashi Iwai
  4 siblings, 0 replies; 12+ messages in thread
From: Nicolas MURE @ 2021-03-01 15:27 UTC (permalink / raw)
  To: tiwai; +Cc: Nicolas MURE, alsa-devel, livvy

Send an `URB_CONTROL out` USB frame to the device to configure its
samplerate. This should be done before using the device for audio
streaming (capture or playback).

See https://github.com/nm2107/Pioneer-DJM-850-driver-reverse-engineering/blob/172fb9a61055960c88c67b7c416fe5bf3609807b/doc/windows-dvs/framerate-setting/README.md

Signed-off-by: Nicolas MURE <nicolas.mure2019@gmail.com>
---
 sound/usb/quirks.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 737b2729c0d3..d02dac5fcd40 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1503,6 +1503,9 @@ void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
 	case USB_ID(0x2b73, 0x0013): /* Pioneer DJM-450 */
 		pioneer_djm_set_format_quirk(subs, 0x0082);
 		break;
+	case USB_ID(0x08e4, 0x0163): /* Pioneer DJM-850 */
+		pioneer_djm_set_format_quirk(subs, 0x0086);
+		break;
 	}
 }
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 4/4] ASLA: usb-audio: fix Pioneer DJM-850 control label info
  2021-03-01 15:27     ` [PATCH v2 0/4] ALSA: usb-audio: Add Pioneer DJM-850 support Nicolas MURE
                         ` (2 preceding siblings ...)
  2021-03-01 15:27       ` [PATCH v2 3/4] ALSA: usb-audio: Configure Pioneer DJM-850 samplerate Nicolas MURE
@ 2021-03-01 15:27       ` Nicolas MURE
  2021-03-02  9:20       ` [PATCH v2 0/4] ALSA: usb-audio: Add Pioneer DJM-850 support Takashi Iwai
  4 siblings, 0 replies; 12+ messages in thread
From: Nicolas MURE @ 2021-03-01 15:27 UTC (permalink / raw)
  To: tiwai; +Cc: Nicolas MURE, alsa-devel, livvy

Unlike the other DJM, the value to set the "CD/LINE" and "LINE" capture
control options are inverted. This fix makes sure that the displayed
info label while using `alsamixer` matches the input switches label
on the DJM-850 mixer.

Signed-off-by: Nicolas MURE <nicolas.mure2019@gmail.com>
---
 sound/usb/mixer_quirks.c | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index b325b6597d91..5b77e8140ba6 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -2693,7 +2693,7 @@ static const char *snd_djm_get_label_caplevel(u16 wvalue)
 	}
 };
 
-static const char *snd_djm_get_label_cap(u16 wvalue)
+static const char *snd_djm_get_label_cap_common(u16 wvalue)
 {
 	switch (wvalue & 0x00ff) {
 	case SND_DJM_CAP_LINE:		return "Control Tone LINE";
@@ -2715,6 +2715,25 @@ static const char *snd_djm_get_label_cap(u16 wvalue)
 	}
 };
 
+// The DJM-850 has different values for CD/LINE and LINE capture
+// control options than the other DJM declared in this file.
+static const char *snd_djm_get_label_cap_850(u16 wvalue)
+{
+	switch (wvalue & 0x00ff) {
+	case 0x00:		return "Control Tone CD/LINE";
+	case 0x01:		return "Control Tone LINE";
+	default:		return snd_djm_get_label_cap_common(wvalue);
+	}
+};
+
+static const char *snd_djm_get_label_cap(u8 device_idx, u16 wvalue)
+{
+	switch (device_idx) {
+	case SND_DJM_850_IDX:		return snd_djm_get_label_cap_850(wvalue);
+	default:			return snd_djm_get_label_cap_common(wvalue);
+	}
+};
+
 static const char *snd_djm_get_label_pb(u16 wvalue)
 {
 	switch (wvalue & 0x00ff) {
@@ -2725,11 +2744,11 @@ static const char *snd_djm_get_label_pb(u16 wvalue)
 	}
 };
 
-static const char *snd_djm_get_label(u16 wvalue, u16 windex)
+static const char *snd_djm_get_label(u8 device_idx, u16 wvalue, u16 windex)
 {
 	switch (windex) {
 	case SND_DJM_WINDEX_CAPLVL:	return snd_djm_get_label_caplevel(wvalue);
-	case SND_DJM_WINDEX_CAP:	return snd_djm_get_label_cap(wvalue);
+	case SND_DJM_WINDEX_CAP:	return snd_djm_get_label_cap(device_idx, wvalue);
 	case SND_DJM_WINDEX_PB:		return snd_djm_get_label_pb(wvalue);
 	default:			return NULL;
 	}
@@ -2852,7 +2871,8 @@ static int snd_djm_controls_info(struct snd_kcontrol *kctl,
 	if (info->value.enumerated.item >= noptions)
 		info->value.enumerated.item = noptions - 1;
 
-	name = snd_djm_get_label(ctl->options[info->value.enumerated.item],
+	name = snd_djm_get_label(device_idx,
+				ctl->options[info->value.enumerated.item],
 				ctl->wIndex);
 	if (!name)
 		return -EINVAL;
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 0/4] ALSA: usb-audio: Add Pioneer DJM-850 support
  2021-03-01 15:27     ` [PATCH v2 0/4] ALSA: usb-audio: Add Pioneer DJM-850 support Nicolas MURE
                         ` (3 preceding siblings ...)
  2021-03-01 15:27       ` [PATCH v2 4/4] ASLA: usb-audio: fix Pioneer DJM-850 control label info Nicolas MURE
@ 2021-03-02  9:20       ` Takashi Iwai
  4 siblings, 0 replies; 12+ messages in thread
From: Takashi Iwai @ 2021-03-02  9:20 UTC (permalink / raw)
  To: Nicolas MURE; +Cc: alsa-devel, livvy

On Mon, 01 Mar 2021 16:27:25 +0100,
Nicolas MURE wrote:
> 
> Hello,
> 
> I updated the patches to consider the request to split patch #3
> (c.f. https://mailman.alsa-project.org/pipermail/alsa-devel/2021-March/181275.html ).
> 
> The patch #3 now only contains changes related to DJM-850 support as the
> fix it was previously containing was applied in linux 5.12
> (c.f. https://mailman.alsa-project.org/pipermail/alsa-devel/2021-March/181279.html ).
> 
> The patches should be ready to merge into linux 5.13 .
> 
> 
> Thank you :)
> 
> Patches list :
> 
> [PATCH v2 1/4] ALSA: usb-audio: Add Pioneer DJM-850 to quirks-table
> [PATCH v2 2/4] ASLA: usb-audio: Declare Pioneer DJM-850 mixer
> [PATCH v2 3/4] ALSA: usb-audio: Configure Pioneer DJM-850 samplerate
> [PATCH v2 4/4] ASLA: usb-audio: fix Pioneer DJM-850 control label

Applied all four patches now (with correction of subject prefix :)


thanks,

Takashi

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-03-02  9:21 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-26 13:34 [PATCH 0/4]: ALSA: usb-audio: Add Pioneer DJM-850 support Nicolas MURE
2021-02-26 13:34 ` [PATCH 1/4] ALSA: usb-audio: Add Pioneer DJM-850 to quirks-table Nicolas MURE
2021-02-26 13:34 ` [PATCH 2/4] ASLA: usb-audio: Declare Pioneer DJM-850 mixer controls Nicolas MURE
2021-02-26 13:34 ` [PATCH 3/4] ALSA: usb-audio: Configure Pioneer DJM-850 samplerate Nicolas MURE
2021-03-01 13:58   ` Takashi Iwai
2021-03-01 15:27     ` [PATCH v2 0/4] ALSA: usb-audio: Add Pioneer DJM-850 support Nicolas MURE
2021-03-01 15:27       ` [PATCH v2 1/4] ALSA: usb-audio: Add Pioneer DJM-850 to quirks-table Nicolas MURE
2021-03-01 15:27       ` [PATCH v2 2/4] ASLA: usb-audio: Declare Pioneer DJM-850 mixer controls Nicolas MURE
2021-03-01 15:27       ` [PATCH v2 3/4] ALSA: usb-audio: Configure Pioneer DJM-850 samplerate Nicolas MURE
2021-03-01 15:27       ` [PATCH v2 4/4] ASLA: usb-audio: fix Pioneer DJM-850 control label info Nicolas MURE
2021-03-02  9:20       ` [PATCH v2 0/4] ALSA: usb-audio: Add Pioneer DJM-850 support Takashi Iwai
2021-02-26 13:34 ` [PATCH 4/4] ASLA: usb-audio: fix Pioneer DJM-850 control label info Nicolas MURE

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.