ALSA: usb-audio: support Roland Capture sample rates
cover ALSA: usb-audio: support Roland Capture sample rates
The fixed quirks for these devices currently describe 44.1 kHz:
0582:0120 Roland OCTA-CAPTURE
0582:012f Roland QUAD-CAPTURE
Add their 48, 96 and 192 kHz alternate settings. The OCTA-CAPTURE's existing S32_LE format description causes the white-noise playback reported by Niklas Aldervall and other users. Change it to the packed S24_3LE format used by the device.
Expose the OCTA-CAPTURE control MIDI cables and synchronize the hardware clock with the selected endpoint rate during stream preparation.
Tested on physical OCTA-CAPTURE and QUAD-CAPTURE units. Rate changes followed by full-duplex streaming succeeded at 44.1, 48, 96 and 192 kHz on both models. External digital clocking on the OCTA-CAPTURE was tested at all supported
rates: 44.1, 48 and 96 kHz. The OCTA-CAPTURE disables its digital input and output at 192 kHz, so external clocking is unavailable at that rate.
Jonathan Seth Mainguy (4):
ALSA: usb-audio: add Roland OCTA-CAPTURE multirate support
ALSA: usb-audio: expose OCTA-CAPTURE control MIDI cables
ALSA: usb-audio: add Roland QUAD-CAPTURE multirate support
ALSA: usb-audio: set Roland Capture rate during stream preparation
sound/usb/quirks-table.h | 206 +++++++++++++++++++++++++++++++++++++-- sound/usb/quirks.c | 74 ++++++++++++++ 2 files changed, 273 insertions(+), 7 deletions(-)
base-commit: 548e7bcd0c5460ddcbca9600cea603ebeebf4da7
Signature · 1 line
2.55.0
PATCH 1/4 ALSA: usb-audio: add Roland OCTA-CAPTURE multirate support
The OCTA-CAPTURE provides one alternate setting for each supported sample rate. Add the 48, 96 and 192 kHz playback and capture settings.
The existing S32_LE description causes the white-noise playback reported by Niklas Aldervall and other users. The device sends packed 24-bit samples, but S32_LE makes ALSA interpret each sample as a four-byte value, which misaligns the stream. USB captures and PCM streaming tests confirm that S24_3LE is the correct format for every setting.
The device provides 10 playback and 12 capture channels through 96 kHz, and four channels in each direction at 192 kHz. Correct the product name in the commented override.
Tested on a physical OCTA-CAPTURE with full-duplex streams at 44.1, 48, 96 and 192 kHz.
--- sound/usb/quirks-table.h | 104 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 100 insertions(+), 4 deletions(-)
sound/usb/quirks-table.h +100 -4
@@ -1227,15 +1227,15 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { -/* only 44.1 kHz works at the moment */ +/* S24_3LE; altsettings 1-4 match the device clock. */ USB_DEVICE (0x0582 ,0x0120 ), QUIRK_DRIVER_INFO {/* .vendor_name = "Roland", */ -/* .product_name = "OCTO-CAPTURE", */ +/* .product_name = "OCTA-CAPTURE", */ QUIRK_DATA_COMPOSITE { { QUIRK_DATA_AUDIOFORMAT(0) { - .formats = SNDRV_PCM_FMTBIT_S32_LE, + .formats = SNDRV_PCM_FMTBIT_S24_3LE, .channels = 10, .iface = 0, .altsetting = 1,
@@ -1249,9 +1249,57 @@ YAMAHA_DEVICE(0x7010, "UB99"), .rate_table = (unsigned int[]) { 44100 } } }, + { + QUIRK_DATA_AUDIOFORMAT(0) { + .formats = SNDRV_PCM_FMTBIT_S24_3LE, + .channels = 10, + .iface = 0, + .altsetting = 2, + .altset_idx = 2, + .endpoint = 0x05, + .ep_attr = 0x05, + .rates = SNDRV_PCM_RATE_48000, + .rate_min = 48000, + .rate_max = 48000, + .nr_rates = 1, + .rate_table = (unsigned int[]) { 48000 } + } + }, + { + QUIRK_DATA_AUDIOFORMAT(0) { + .formats = SNDRV_PCM_FMTBIT_S24_3LE, + .channels = 10, + .iface = 0, + .altsetting = 3, + .altset_idx = 3, + .endpoint = 0x05, + .ep_attr = 0x05, + .rates = SNDRV_PCM_RATE_96000, + .rate_min = 96000, + .rate_max = 96000, + .nr_rates = 1, + .rate_table = (unsigned int []) {96000 } + } + }, + { + QUIRK_DATA_AUDIOFORMAT(0) { + .formats = SNDRV_PCM_FMTBIT_S24_3LE, + .channels = 4, + .iface = 0, + .altsetting = 4, + .altset_idx = 4, + .endpoint = 0x05, + .ep_attr = 0x05, + .rates = SNDRV_PCM_RATE_192000, + .rate_min = 192000, + .rate_max = 192000, + .nr_rates = 1, + .rate_table = (unsigned int []) {192000 } + } + }, { QUIRK_DATA_AUDIOFORMAT(1) { - .formats = SNDRV_PCM_FMTBIT_S32_LE, + .formats = SNDRV_PCM_FMTBIT_S24_3LE, .channels = 12, .iface = 1, .altsetting = 1,
@@ -1265,6 +1313,54 @@ YAMAHA_DEVICE(0x7010, "UB99"), .rate_table = (unsigned int[]) { 44100 } } }, + { + QUIRK_DATA_AUDIOFORMAT(1) { + .formats = SNDRV_PCM_FMTBIT_S24_3LE, + .channels = 12, + .iface = 1, + .altsetting = 2, + .altset_idx = 2, + .endpoint = 0x85, + .ep_attr = 0x25, + .rates = SNDRV_PCM_RATE_48000, + .rate_min = 48000, + .rate_max = 48000, + .nr_rates = 1, + .rate_table = (unsigned int[]) { 48000 } + } + }, + { + QUIRK_DATA_AUDIOFORMAT(1) { + .formats = SNDRV_PCM_FMTBIT_S24_3LE, + .channels = 12, + .iface = 1, + .altsetting = 3, + .altset_idx = 3, + .endpoint = 0x85, + .ep_attr = 0x25, + .rates = SNDRV_PCM_RATE_96000, + .rate_min = 96000, + .rate_max = 96000, + .nr_rates = 1, + .rate_table = (unsigned int []) {96000 } + } + }, + { + QUIRK_DATA_AUDIOFORMAT(1) { + .formats = SNDRV_PCM_FMTBIT_S24_3LE, + .channels = 4, + .iface = 1, + .altsetting = 4, + .altset_idx = 4, + .endpoint = 0x85, + .ep_attr = 0x25, + .rates = SNDRV_PCM_RATE_192000, + .rate_min = 192000, + .rate_max = 192000, + .nr_rates = 1, + .rate_table = (unsigned int []) {192000 } + } + }, { QUIRK_DATA_MIDI_FIXED_ENDPOINT(2) { .out_cables = 0x0001,
Signature · 1 line
2.55.0
PATCH 2/4 ALSA: usb-audio: expose OCTA-CAPTURE control MIDI cables
In reply to Jonathan Seth MainguyThe OCTA-CAPTURE uses cable 0 for MIDI. Control requests use cable 2, and replies use cable 1.
Expose output cables 0 and 2 with mask 0x0005, and input cables 0 and 1 with mask 0x0003.
Tested on a physical OCTA-CAPTURE. Control requests sent on cable 2 received matching readback replies on cable 1, while cable 0 remained available for MIDI.
--- sound/usb/quirks-table.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/usb/quirks-table.h +2 -2
@@ -1363,8 +1363,8 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { QUIRK_DATA_MIDI_FIXED_ENDPOINT(2) { - .out_cables = 0x0001, - .in_cables = 0x0001 + .out_cables = 0x0005, + .in_cables = 0x0003 } }, { QUIRK_DATA_IGNORE(3) },
Signature · 1 line
2.55.0
PATCH 3/4 ALSA: usb-audio: add Roland QUAD-CAPTURE multirate support
In reply to Jonathan Seth MainguyThe QUAD-CAPTURE provides alternate settings for 44.1, 48, 96 and 192 kHz. Its fixed quirk currently describes only 44.1 kHz.
Add the remaining playback and capture settings. The device provides four playback and six capture channels through 96 kHz, and two channels in each direction at 192 kHz. Each setting uses an S32_LE container.
Tested on a physical QUAD-CAPTURE with full-duplex streams at 44.1, 48, 96 and 192 kHz.
--- sound/usb/quirks-table.h | 98 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-)
sound/usb/quirks-table.h +97 -1
@@ -1374,7 +1374,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { -/* only 44.1 kHz works at the moment */ +/* S32_LE; altsettings 1-4 match the device clock. */ USB_DEVICE (0x0582 ,0x012f ), QUIRK_DRIVER_INFO {/* .vendor_name = "Roland", */
@@ -1396,6 +1396,54 @@ YAMAHA_DEVICE(0x7010, "UB99"), .rate_table = (unsigned int[]) { 44100 } } }, + { + QUIRK_DATA_AUDIOFORMAT(0) { + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels = 4, + .iface = 0, + .altsetting = 2, + .altset_idx = 2, + .endpoint = 0x05, + .ep_attr = 0x05, + .rates = SNDRV_PCM_RATE_48000, + .rate_min = 48000, + .rate_max = 48000, + .nr_rates = 1, + .rate_table = (unsigned int[]) { 48000 } + } + }, + { + QUIRK_DATA_AUDIOFORMAT(0) { + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels = 4, + .iface = 0, + .altsetting = 3, + .altset_idx = 3, + .endpoint = 0x05, + .ep_attr = 0x05, + .rates = SNDRV_PCM_RATE_96000, + .rate_min = 96000, + .rate_max = 96000, + .nr_rates = 1, + .rate_table = (unsigned int []) {96000 } + } + }, + { + QUIRK_DATA_AUDIOFORMAT(0) { + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels = 2, + .iface = 0, + .altsetting = 4, + .altset_idx = 4, + .endpoint = 0x05, + .ep_attr = 0x05, + .rates = SNDRV_PCM_RATE_192000, + .rate_min = 192000, + .rate_max = 192000, + .nr_rates = 1, + .rate_table = (unsigned int []) {192000 } + } + }, { QUIRK_DATA_AUDIOFORMAT(1) { .formats = SNDRV_PCM_FMTBIT_S32_LE,
@@ -1412,6 +1460,54 @@ YAMAHA_DEVICE(0x7010, "UB99"), .rate_table = (unsigned int[]) { 44100 } } }, + { + QUIRK_DATA_AUDIOFORMAT(1) { + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels = 6, + .iface = 1, + .altsetting = 2, + .altset_idx = 2, + .endpoint = 0x85, + .ep_attr = 0x25, + .rates = SNDRV_PCM_RATE_48000, + .rate_min = 48000, + .rate_max = 48000, + .nr_rates = 1, + .rate_table = (unsigned int[]) { 48000 } + } + }, + { + QUIRK_DATA_AUDIOFORMAT(1) { + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels = 6, + .iface = 1, + .altsetting = 3, + .altset_idx = 3, + .endpoint = 0x85, + .ep_attr = 0x25, + .rates = SNDRV_PCM_RATE_96000, + .rate_min = 96000, + .rate_max = 96000, + .nr_rates = 1, + .rate_table = (unsigned int []) {96000 } + } + }, + { + QUIRK_DATA_AUDIOFORMAT(1) { + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels = 2, + .iface = 1, + .altsetting = 4, + .altset_idx = 4, + .endpoint = 0x85, + .ep_attr = 0x25, + .rates = SNDRV_PCM_RATE_192000, + .rate_min = 192000, + .rate_max = 192000, + .nr_rates = 1, + .rate_table = (unsigned int []) {192000 } + } + }, { QUIRK_DATA_MIDI_FIXED_ENDPOINT(2) { .out_cables = 0x0001,
Signature · 1 line
2.55.0
PATCH 4/4 ALSA: usb-audio: set Roland Capture rate during stream preparation
In reply to Jonathan Seth MainguyRoland OCTA-CAPTURE and QUAD-CAPTURE select their hardware clock with a vendor control request. Streaming fails when the hardware clock differs from the rate selected for the USB endpoint.
During stream preparation, read the hardware rate and send the rate request only when it differs from the selected endpoint rate. The control transfer can complete before the device reports the new clock rate, so poll readback every 25 ms and continue as soon as it matches. Forty attempts avoid hammering the control endpoint while bounding an unresponsive transition to one second.
Run the transaction from the existing format-setup quirk, after ALSA has selected the endpoint rate and before data URBs are submitted. Hold the USB-audio device mutex so playback and capture preparation cannot issue overlapping clock changes.
Apply the quirk to:
0582:0120 Roland OCTA-CAPTURE
0582:012f Roland QUAD-CAPTURE
Tested on physical OCTA-CAPTURE and QUAD-CAPTURE units. Rate changes followed by full-duplex streaming succeeded at 44.1, 48, 96 and 192 kHz on both. External digital clocking on the OCTA-CAPTURE was tested at all supported rates: 44.1, 48 and 96 kHz. The OCTA-CAPTURE disables its digital input and output at 192 kHz, so external clocking is unavailable at that rate.
--- sound/usb/quirks.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+)
sound/usb/quirks.c +74 -0
@@ -3,6 +3,7 @@*/ #include <linux/cleanup.h> +#include <linux/delay.h> #include <linux/err.h> #include <linux/init.h> #include <linux/slab.h>
@@ -1855,6 +1856,75 @@ static int rme_digiface_set_format_quirk(struct snd_usb_substream *subs)return 0 ; } +#define ROLAND_CAPTURE_RATE_REQUEST 3 +#define ROLAND_CAPTURE_RATE_READ_VALUE 0x0001 +#define ROLAND_CAPTURE_RATE_WRITE_VALUE 0x0008 +#define ROLAND_CAPTURE_RATE_WRITE_PREFIX 0x40 +#define ROLAND_CAPTURE_RATE_RETRIES 40 +#define ROLAND_CAPTURE_RATE_POLL_MS 25 + +/* +* OCTA-CAPTURE and QUAD-CAPTURE use the same vendor request for their +* hardware clock. A read returns the 24-bit little-endian rate followed by +* a transition-status byte. A write carries 0x40 followed by the rate. +*/ +static int roland_capture_read_rate (struct usb_device *dev,u32 *rate) +{ +u8 data[4 ]; +int err; + + err =snd_usb_ctl_msg (dev,usb_rcvctrlpipe (dev,0 ), +ROLAND_CAPTURE_RATE_REQUEST , +USB_DIR_IN |USB_TYPE_VENDOR |USB_RECIP_DEVICE , +ROLAND_CAPTURE_RATE_READ_VALUE ,0 , + data,sizeof (data)); +if (err !=sizeof (data)) +return err <0 ? err : -EIO ; + + *rate =combine_triple (data); +return 0 ; +} + +static void roland_capture_set_rate (struct snd_usb_substream *subs) +{ +struct snd_usb_audio *chip = subs->stream->chip; +struct usb_device *dev = chip->dev; +u32 rate = subs->data_endpoint->cur_rate; +u32 current_rate; +u8 data[4 ]; +int err; +int i; + +/* Serialize playback and capture endpoint starts during a clock change. */ +guard (mutex)(&chip->mutex); + err =roland_capture_read_rate (dev, ¤t_rate); +if (!err && current_rate == rate) +return ; + + data[0 ] =ROLAND_CAPTURE_RATE_WRITE_PREFIX ; + data[1 ] = rate; + data[2 ] = rate >>8 ; + data[3 ] = rate >>16 ; + err =snd_usb_ctl_msg (dev,usb_sndctrlpipe (dev,0 ), +ROLAND_CAPTURE_RATE_REQUEST , +USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_DEVICE , +ROLAND_CAPTURE_RATE_WRITE_VALUE ,0 , + data,sizeof (data)); +if (err !=sizeof (data)) { +usb_audio_warn (chip,"cannot set Roland sample rate to %u Hz: %d\n" , + rate, err <0 ? err : -EIO ); +return ; + } + +for (i =0 ; i <ROLAND_CAPTURE_RATE_RETRIES ; i++) { + err =roland_capture_read_rate (dev, ¤t_rate); +if (!err && current_rate == rate) +return ; +msleep (ROLAND_CAPTURE_RATE_POLL_MS ); + } +usb_audio_warn (chip,"Roland sample rate did not reach %u Hz\n" , rate); +} +void snd_usb_set_format_quirk (struct snd_usb_substream *subs,const struct audioformat *fmt) {
@@ -1885,6 +1955,10 @@ void snd_usb_set_format_quirk(struct snd_usb_substream *subs,case USB_ID (0x2a39 ,0x3fa0 ):/* RME Digiface USB (alternate) */ rme_digiface_set_format_quirk (subs);break ; +case USB_ID (0x0582 ,0x0120 ):/* Roland OCTA-CAPTURE */ +case USB_ID (0x0582 ,0x012f ):/* Roland QUAD-CAPTURE */ +roland_capture_set_rate (subs); +break ; } }
Signature · 1 line
2.55.0
Takashi Iwai
AppliedQuoted 24 lines · Jonathan Seth Mainguy
The fixed quirks for these devices currently describe 44.1 kHz:
0582:0120 Roland OCTA-CAPTURE
0582:012f Roland QUAD-CAPTUREAdd their 48, 96 and 192 kHz alternate settings. The OCTA-CAPTURE's existing
S32_LEformat description causes the white-noise playback reported by Niklas Aldervall and other users. Change it to the packedS24_3LEformat used by the device.Expose the OCTA-CAPTURE control MIDI cables and synchronize the hardware clock with the selected endpoint rate during stream preparation.
Tested on physical OCTA-CAPTURE and QUAD-CAPTURE units. Rate changes followed by full-duplex streaming succeeded at 44.1, 48, 96 and 192 kHz on both models. External digital clocking on the OCTA-CAPTURE was tested at all supported
rates: 44.1, 48 and 96 kHz. The OCTA-CAPTURE disables its digital input and output at 192 kHz, so external clocking is unavailable at that rate.
Quoted 5 lines
Jonathan Seth Mainguy (4):
ALSA: usb-audio: add Roland OCTA-CAPTURE multirate support
ALSA: usb-audio: expose OCTA-CAPTURE control MIDI cables
ALSA: usb-audio: add Roland QUAD-CAPTURE multirate support
ALSA: usb-audio: set Roland Capture rate during stream preparation
Applied to for-next branch. Thanks.
Takashi