Focusrite Scarlett Gen 4 mixer driver

Talk about your MIDI interfaces, microphones, keyboards...

Moderators: MattKingUSA, khz

User avatar
bluebell
Established Member
Posts: 1927
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 113 times
Been thanked: 122 times

Re: Focusrite Scarlett Gen 4 mixer driver

Post by bluebell »

@geoffrey

I have problems with my Scarlett 18i20 Gen3: I cannot change jack buffer size on the fly with jack_bufsize.

It happens both with Debian Bookworm's kernel 6.1.0-13 and with a self compiled 5.15.134. IIRC changing buffer size worked for a day, so it may be that my interface is in a changed state.

Jackd (jack2) says: "cannot configure capture channel"

Is this a known issue?

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

geoffrey
Established Member
Posts: 259
Joined: Mon Jul 30, 2018 2:08 am
Has thanked: 34 times
Been thanked: 174 times

Re: Focusrite Scarlett Gen 4 mixer driver

Post by geoffrey »

bluebell wrote: Mon Oct 23, 2023 8:49 am

@geoffrey

I have problems with my Scarlett 18i20 Gen3: I cannot change jack buffer size on the fly with jack_bufsize.

It happens both with Debian Bookworm's kernel 6.1.0-13 and with a self compiled 5.15.134. IIRC changing buffer size worked for a day, so it may be that my interface is in a changed state.

Jackd (jack2) says: "cannot configure capture channel"

Is this a known issue?

Hi bluebell,

Sorry, I don't really have any idea as I use Fedora 38 and PipeWire, and I'm only really familiar with the Scarlett-specific controls.

Your issue is with JACK and/or ALSA, and the Scarlett mixer driver doesn't interfere with that. You can confirm this by disabling the driver (remove the config from /etc/modprobe.d or set device_setup=0).

I did try just now uninstalling PipeWire and installing JACK and unfortunately there's no jack_bufsize utility anymore, but I did try changing the buffer size in qjackctl and that worked okay; I saw the change reflect in /proc/asound/USB/pcm0c/sub0/hw_params. I don't know if that's "on the fly" like jack_bufsize does. I'd suggest asking in a JACK-specific forum for advice on this.

Regards,
Geoffrey.

User avatar
bluebell
Established Member
Posts: 1927
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 113 times
Been thanked: 122 times

Re: Focusrite Scarlett Gen 4 mixer driver

Post by bluebell »

geoffrey wrote: Mon Oct 23, 2023 12:50 pm

I did try just now uninstalling PipeWire and installing JACK and unfortunately there's no jack_bufsize utility anymore, but I did try changing the buffer size in qjackctl and that worked okay; I saw the change reflect in /proc/asound/USB/pcm0c/sub0/hw_params. I don't know if that's "on the fly" like jack_bufsize does. I'd suggest asking in a JACK-specific forum for advice on this.

Qjackctl stops and starts jackd. That's my workaround. I can live with it.

alsa-scarlett-gui is such a great help. Thx.

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

geoffrey
Established Member
Posts: 259
Joined: Mon Jul 30, 2018 2:08 am
Has thanked: 34 times
Been thanked: 174 times

Re: Focusrite Scarlett Gen 4 mixer driver

Post by geoffrey »

Time for another status update...

Driver updates accepted into Linux 6.7: https://lore.kernel.org/lkml/878r7gjlbw ... i@suse.de/

  • Enabled by default! No need for device_setup=1 (can use device_setup=4 to disable in case that's needed)
  • Support for all Clarett USB & Clarett+ interfaces
  • Level Meter fixes
  • Read Firmware Version through ALSA control

Completed:

  • Added kernel support and CLI for reset-to-factory-config, reset-to-factory-firmware, and update-firmware:

Code: Select all

[g@f38 ~]$ scarlett2 --erase-firmware
Resetting configuration to factory default...
Erase progress: Done!
Erasing upgrade firmware...
Erase progress: Done!
Rebooting interface...

[g@f38 ~]$ scarlett2 -l
Found 1 supported device:
  card0: Scarlett 4th Gen 4i4 (firmware 2052, update to 2082 available)

[g@f38 ~]$ scarlett2 -u
Updating Scarlett 4th Gen 4i4 from firmware version 2052 to 2082
Resetting configuration to factory default...
Erase progress: Done!
Erasing upgrade firmware...
Erase progress: Done!
Firmware write progress: Done!
Rebooting interface...

[g@f38 ~]$ scarlett2 -l
Found 1 supported device:
  card0: Scarlett 4th Gen 4i4 (firmware version 2082)

Tested the above on 13 Scarlett/Clarett models (2 to go).

And continuing with the actual 4th Gen support:

  • More refactoring
  • Fixed up DSP mux controls in the kernel and in alsa-scarlett-gui:
Screenshot from 2023-11-11 03-13-02.png
Screenshot from 2023-11-11 03-13-02.png (118.73 KiB) Viewed 80977 times

I wrote before that "mixer inputs 11/12 are hardwired to mixer outputs G/H". That's actually the DSP, which is used for the Air modes. Analogue Inputs 1/2 are normally connected to DSP Inputs 1/2, and the DSP Outputs are connected to the PCM Inputs 1/2. But that can be rearranged with the Linux driver.

Whew!

It continues... :)

geoffrey
Established Member
Posts: 259
Joined: Mon Jul 30, 2018 2:08 am
Has thanked: 34 times
Been thanked: 174 times

Re: Focusrite Scarlett Gen 4 mixer driver

Post by geoffrey »

It's getting close to done! And there's a lot there!

Code: Select all

$ git show upstream:sound/usb/mixer_scarlett2.c | wc -l
4549
$ git show scarlett-gen4:sound/usb/mixer_scarlett2.c | wc -l
7065

$ cat 0000-cover-letter.patch 
Geoffrey D. Bennett (45):
  ALSA: scarlett2: Add missing error check to scarlett2_config_save()
  ALSA: scarlett2: Add missing error check to scarlett2_usb_set_config()
  ALSA: scarlett2: Add missing error checks to *_ctl_get()
  ALSA: scarlett2: Add clamp() in scarlett2_mixer_ctl_put()
  ALSA: scarlett2: Add missing mutex lock around get meter levels
  ALSA: scarlett2: Add #defines for firmware upgrade
  ALSA: scarlett2: Retrieve useful flash segment numbers
  ALSA: scarlett2: Add hwdep interface for flash management
  ALSA: scarlett2: Infer has_msd_mode from config items
  ALSA: scarlett2: Infer standalone switch from config items
  ALSA: scarlett2: Check for phantom persistence config item
  ALSA: scarlett2: Check presence of mixer using mux_assignment
  ALSA: scarlett2: Add config set struct
  ALSA: scarlett2: Remove scarlett2_config_sets array
  ALSA: scarlett2: Add check for config_item presence
  ALSA: scarlett2: Refactor scarlett2_usb_set_config()
  ALSA: scarlett2: Refactor scarlett2_config_save()
  ALSA: scarlett2: Formatting fix on function parameter lists
  ALSA: scarlett2: Parameterise notifications
  ALSA: scarlett2: Allow for interfaces without per-channel volume
  ALSA: scarlett2: Remove repeated test in scarlett2_add_line_out_ctls()
  ALSA: scarlett2: Change num_mux_* from int to u8
  ALSA: scarlett2: Refactor common port_count lookups
  ALSA: scarlett2: Remove struct scarlett2_usb_volume_status
  ALSA: scarlett2: Split dim_mute_update from vol_updated
  ALSA: scarlett2: Add scarlett2_mixer_value_to_db()
  ALSA: scarlett2: Add #define for SCARLETT2_MIX_MAX
  ALSA: scarlett2: Rename db_scale_scarlett2_gain to volume
  ALSA: scarlett2: Split input_other into level/pad/air/phantom
  ALSA: scarlett2: Split direct_monitor out from monitor_other
  ALSA: scarlett2: Add support for air/phantom control on input 2
  ALSA: scarlett2: Add support for Gen 4 style parameters
  ALSA: scarlett2: Allow for controls with a "mute mode"
  ALSA: scarlett2: Add support for Air Presence + Drive option
  ALSA: scarlett2: Add support for software-controllable input gain
  ALSA: scarlett2: Add power status control
  ALSA: scarlett2: Store mix_ctls for Gen 4 Direct Monitor
  ALSA: scarlett2: Handle Gen 4 Direct Monitor mix updates
  ALSA: scarlett2: Add support for custom Gen 4 Direct Monitor mixes
  ALSA: scarlett2: Add support for DSP mux channels
  ALSA: scarlett2: Rename DSP mux channels
  ALSA: scarlett2: Minor refactor MSD mode check
  ALSA: scarlett2: Add minimum firmware version check
  ALSA: scarlett2: Add R/O headphone volume control
  ALSA: scarlett2: Add support for Solo, 2i2, and 4i4 Gen 4

 MAINTAINERS                    |    1 +
 include/uapi/sound/scarlett2.h |   54 +
 sound/usb/mixer_quirks.c       |    3 +
 sound/usb/mixer_scarlett2.c    | 3948 ++++++++++++++++++++++++++------
 4 files changed, 3290 insertions(+), 716 deletions(-)
 create mode 100644 include/uapi/sound/scarlett2.h
vizeke
Posts: 1
Joined: Fri Nov 24, 2023 1:35 pm

Re: Focusrite Scarlett Gen 4 mixer driver

Post by vizeke »

geoffrey wrote: Sun Sep 24, 2023 2:52 pm

Anyone with a Scarlett Gen 4 who is willing to help test a pre-release version when one is ready, please email me.

Hi, I can help testing the Solo Gen 4 if you still need some testers ^^

geoffrey
Established Member
Posts: 259
Joined: Mon Jul 30, 2018 2:08 am
Has thanked: 34 times
Been thanked: 174 times

Focusrite Scarlett Gen 4 mixer driver First (public) Draft!

Post by geoffrey »

Oh my, here it is!

The first (public) draft of the Scarlett 4th Gen kernel driver, ready (crossed fingers) for the brave to look at and/or test.

https://github.com/geoffreybennett/scar ... .5.11-g4.1

Along with that comes firmware update support for all Scarlett 2nd Gen+ and Clarett interfaces. A first draft of the firmware update utility:

https://github.com/geoffreybennett/scarlett2

Whew!

Updating alsa-scarlett-gui to work with this is next...

Philix
Posts: 2
Joined: Sun Nov 12, 2023 7:04 pm
Has thanked: 4 times
Been thanked: 2 times

Re: Focusrite Scarlett Gen 4 mixer driver

Post by Philix »

Hello Geoffrey,

i got my Scarlett 4i4 4th Gen today and i have a few questions about the upcoming driver in kernel 6.7.
To get good latency and to route signals from inputs 3&4 and to outputs 3-6 i have to use pro audio mode and jack.
With my Babyface i had good latency without pro audio mode and with alsa, altough i didnt have access to any other in- or output except the first two.
Will your driver and the GUI work with pro audio mode? Does it even matter?
Also in the Soundsettings of Gnome i see either no "Front Left" and "Front Right" (Pro Audio) or i just see surround-profiles like "2.1, 4.0, 5.1,.." (non Pro Audio).
Does the driver give the OS the right profiles and naming of the in and outs, regardless of the mode im using?

Sorry if this questions are stupid! I did look around the forum and on the internet but didnt find the answers. A point in the right direction would be appreciated!

For reference:
Fedora 39, with pipewire and wireplumber. Fully updated as of today and kernel 6.6.3-200.fc39.x86_64

Thanks!
Philipp

geoffrey
Established Member
Posts: 259
Joined: Mon Jul 30, 2018 2:08 am
Has thanked: 34 times
Been thanked: 174 times

Re: Focusrite Scarlett Gen 4 mixer driver

Post by geoffrey »

Hi @Philix!

Congrats on your new Scarlett 4i4 4th Gen! I hope I can point you in the right direction!

Regarding your mention of "use pro audio mode and jack" vs. "without pro audio mode and with alsa", it's essential to clarify that if you're using PipeWire, then you're always using the ALSA kernel driver regardless of the Pro Audio configuration (which is a PipeWire thing), and JACK doesn't come into play in this scenario.

Here's a breakdown of the pieces involved:

  • ALSA Kernel Driver: Constant across all configurations/combinations of Babyface, Scarlett, ALSA(API), JACK, PulseAudio, or PipeWire, this driver is what communicates with your audio hardware. It only supports one application at a time.

  • Sound Servers (PulseAudio, JACK, PipeWire): These allow multiple applications to use a sound device simultaneously.

  • PipeWire's Role: PipeWire implements the ALSA, PulseAudio, and JACK user-space APIs. So applications may think they're using one of these, but it's actually PipeWire handling the audio.

Your applications' path to the hardware looks like this:

Application → ALSA(userspace API) implemented by PipeWire → ALSA(kernel driver) → hardware
or this
Application → JACK(userspace API) implemented by PipeWire → ALSA(kernel driver) → hardware
or this
Application → PulseAudio(userspace API) implemented by PipeWire → ALSA(kernel driver) → hardware

So, any variation in latency in these cases is to do with the application or PipeWire or how it is using ALSA. If you're not seeing all the channels on your devices, then this is most easily fixed by selecting the Pro Audio configuration. Maybe there's another way to do this, but I don't know enough about PipeWire to say more.

In pavucontrol (interestingly, a PulseAudio app that doesn't realise that it's configuring PipeWire, not PulseAudio), selecting "Pro Audio" uses IRQ based scheduling for low latency, same as what you can get with JACK. For more on this, check the PipeWire FAQ.

Re. your specific questions:

  • Scarlett2 Mixer Driver: The mixer driver functions independently of any audio profile, including the Pro Audio profile. Its purpose is to configure the Scarlett's internal routing, mixing, and other settings. This functionality is separate from and unaffected by the process of audio data transfer managed by the ALSA USB sound driver.

  • Profiles and Channel Naming: The mixer driver does not influence the channel naming. As the playback and recording channels are arbitrarily reassignable (using the Scarlett2 Mixer Driver & alsa-scarlett-gui), PipeWire presenting them as "AUX0" to "AUX5" is appropriate, though starting from 1 might have made more sense.

Your questions are far from stupid — audio configuration in Linux can be complex! PipeWire + the Pro Audio profile is a massive improvement on how things were not so long ago though.

Also, if you're interested in testing the mixer driver, I'd love if you would reach out to me via email or private message and we can chat more.

Regards,
Geoffrey.

geoffrey
Established Member
Posts: 259
Joined: Mon Jul 30, 2018 2:08 am
Has thanked: 34 times
Been thanked: 174 times

Re: Focusrite Scarlett Gen 4 mixer driver

Post by geoffrey »

@Philix, I had some more thoughts...

If you only need to deal with 2 channels of audio going to/from your interface, then it's easiest to use alsa-scarlett-gui to set up the first two channels (AUX0 and AUX1 in PipeWire) to route where you want. Then with the Pro Audio profile any non-pro app will just use those.

For more complex setups, e.g. maybe you want to have 3 different non-pro apps playing different audio streams independently to Line 1/2 vs Line 3/4 vs headphones — then you can use PipeWire coupled streams to create virtual mono or stereo soundcards that are connected to particular inputs or outputs on your Scarlett.

I'm not very familiar with coupled streams; it's been 2 years since I set one up, but I can point you to the PipeWire Wiki section on Virtual Devices: Coupled Streams.

This is the config I used to create a virtual stereo sound card called "Qu-16 Stereo Playback" which I could select as if it was a regular sound card. Audio sent to that virtual device got automatically forwarded to my Qu-16 channels 13 & 14:

Code: Select all

    {
        name = libpipewire-module-loopback
        args = {
            node.name = "Qu-16"
            node.description = "Qu-16 Stereo Playback"
            capture.props = {
                media.class = "Audio/Sink"
                audio.position = [ FL FR ]
            }
            playback.props = {
                audio.position = [ AUX12 AUX13 ]
                node.target = "alsa_output.usb-Allen_Heath_Ltd_QU-16-01.pro-output-0"
                stream.dont-remix = true
                node.passive = true
            }
        }
    }

In the last 2 years, the exact configuration has probably changed, but that should give you an idea of what's possible.

geoffrey
Established Member
Posts: 259
Joined: Mon Jul 30, 2018 2:08 am
Has thanked: 34 times
Been thanked: 174 times

Focusrite Scarlett Gen 4 mixer driver sent upstream

Post by geoffrey »

I have a Christmas present for you :)...

Across 57 emails with 4059 lines added and 798 lines deleted, I have submitted my Scarlett 4th Gen mixer driver upstream! If it's accepted in the next few weeks, then it will be a part of Linux 6.8:
https://lore.kernel.org/linux-sound/cov ... t.g@b4.vu/
https://lore.kernel.org/linux-sound/cov ... t.g@b4.vu/
https://lore.kernel.org/linux-sound/cov ... t.g@b4.vu/

If you want to try it out before then, you can build it out-of-tree against your current kernel:
https://github.com/geoffreybennett/scar ... 7-rc2-g4.3

Please contact me by email if you've got a 4th Gen Scarlett and can help test.

User avatar
erlkönig
Established Member
Posts: 210
Joined: Tue May 31, 2022 8:58 am
Has thanked: 42 times
Been thanked: 48 times

Re: Focusrite Scarlett Gen 4 mixer driver

Post by erlkönig »

@geoffrey
can't say it often enough: thank you for your work, and, much more, thank you for your support!

Currently working with
https://www.honeysuckers.rocks/?lang=en
Fiddling with sequencers does not evolve into music necessarily and Mac users have smelly feet and guzzle little children.

geoffrey
Established Member
Posts: 259
Joined: Mon Jul 30, 2018 2:08 am
Has thanked: 34 times
Been thanked: 174 times

Re: Focusrite Scarlett Gen 4 mixer driver sent upstream

Post by geoffrey »

folderol
Established Member
Posts: 2083
Joined: Mon Sep 28, 2015 8:06 pm
Location: Here, of course!
Has thanked: 232 times
Been thanked: 400 times
Contact:

Re: Focusrite Scarlett Gen 4 mixer driver

Post by folderol »

That's fantastic news. Very well done indeed :D

The Yoshimi guy {apparently now an 'elderly'}
radman
Posts: 1
Joined: Thu Sep 14, 2023 10:38 am
Has thanked: 3 times

Re: Focusrite Scarlett Gen 4 mixer driver

Post by radman »

Looks like the Linux 6.7 kernel release has some work done around the scarlett2 driver:

https://kernelnewbies.org/Linux_6.7

This looks like a bit of initial refactoring and some support added for Clarett, plus a few other things:

https://git.kernel.org/pub/scm/linux/ke ... cb1478ab5b

Looks like the mixer is now enabled by default for the Scarlett series which is a huge step forward! (I assume this is not for the 4th gen just yet).

Thanks again for your work Geoffrey!

Post Reply