Focusrite Scarlett 6i6 and 18i8 2nd Gen mixer driver

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

Moderators: khz, MattKingUSA

geoffrey
Established Member
Posts: 62
Joined: Mon Jul 30, 2018 2:08 am

Focusrite Scarlett 6i6 and 18i8 2nd Gen mixer driver

Postby geoffrey » Thu May 02, 2019 1:45 am

Hi all,

I'm after some help from Linux people who have a Focusrite Scarlett 6i6 or 18i8 2nd Gen...

I've written an 18i8/18i20 mixer driver and have feedback from 18i20 users that it works, but no feedback yet from 18i8 users. If you have an 18i8, please test the driver (source and binary packages available here: https://github.com/geoffreybennett/scar ... 2/releases) and let me know if it does or doesn't work.

Extending the driver to support the 6i6 as well would probably be pretty simple if I had one of those interfaces, but I don't. If you have one and can run the Focusrite Control software in a VM while running usbmon to capture the USB messages then I should be able to work out what it needs from that. Let me know if you can assist and I will write up some instructions.

Thanks,
Geoffrey.

random_username
Posts: 1
Joined: Sat May 25, 2019 12:38 pm

Re: Focusrite Scarlett 6i6 and 18i8 2nd Gen mixer driver

Postby random_username » Sat May 25, 2019 12:40 pm

I would be willing to buy a 6i6 gen 2 Interface.

Is this offer of yours still available? It would take about two weeks for me, to capture the usbmon output.

geoffrey
Established Member
Posts: 62
Joined: Mon Jul 30, 2018 2:08 am

Re: Focusrite Scarlett 6i6 and 18i8 2nd Gen mixer driver

Postby geoffrey » Wed Jun 19, 2019 2:42 pm

random_username wrote:I would be willing to buy a 6i6 gen 2 Interface.

Is this offer of yours still available? It would take about two weeks for me, to capture the usbmon output.
Hi random_username! Thanks for your message, and sorry for the delay in responding. I forgot that I need to subscribe to a thread to be notified of responses, even if I created it.

@dawitti this one's for you too (@random_username, dawitti said that he's got a 6i6 and wants to help)

So, what I need is usbmon output captured from Linux while you run the Focusrite Control software in a VM and twiddle with the routing parameters. I used virt-manager to set up the VM and "Add Hardware" -> "USB Host Device" -> "xxx:xxx Focusrite-Novation Scarlett 18i8 2nd Gen" -> Finish to connect my 18i8 to the VM.

The usbmon command I usually use is like:
usbmon -i 2 -fu -s 10000 | grep -v 'Z[io]:'

The "-fu -s 10000" options are to get all the data & in the machine-readable format. "-i 2" is to restrict capturing to bus 2. Your device might be on a different bus, so adjust to suit (use lsusb to check which bus).

What we're looking for are a lot of lines like this:

ffff8a81fc05c780 1159407068 S Co:2:055:0 s 21 02 0000 0005 0114 276 = 02300000 04015d00 00000000 00000000 00000000 00263000 01363000 02260800 03360800 04460800 05560800 06660800 07760800 08061800 09161800 0a062000 0b162000 0c262000 0d362000 0e462000 0f562000 10662000 11762000 80006000 81106000 82206000 83306000 84406000 85506000 86003000 87103000 88003000 89103000 80a16000 81b16000 00c26000 01d26000 02e26000 03f26000 04026100 05126100 06226100 07326100 00030800 01130800 02230800 03330800 04430800 05530800 06630800 07730800 08036000 09136000 0a030000 0b030000 0c030000 0d030000 0e030000 0f030000 10030000 11030000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffff8a81fc05c780 1159407138 C Co:2:055:0 0 276 >
ffff8a81fc05c780 1159407144 S Ci:2:055:0 s a1 03 0000 0005 0010 16 <
ffff8a81fc05c780 1159407946 C Ci:2:055:0 0 16 = 02300000 00005d00 00000000 00000000

If you're curious, "S Co" is a control-output submission to the USB device. 2:055 is the bus and device numbers (so e.g. I could also grep "2:055" if there are other devices on the bus to filter out just the Scarlett communications). "21 02 0000 0005" are the magic numbers to talk to the vendor-specific stuff in the Scarlett. The rest of that particular line is the data to set up the routing for one sample rate. The following 3 lines are acknowledgements. That whole thing gets repeated twice for the two other sample rates.

Send through a small bit of sample output while the Focusrite Control software is running if you can get that going. The software continually polls the interface's levels so you'll see plenty of USB traffic. I'll check that it's what I'm after and then write up some more info about what things I need you to twiddle with while you capture.

Let me know if this doesn't make sense or if you need more info.

Thanks,
Geoffrey.

User avatar
dawitti
Established Member
Posts: 8
Joined: Wed Mar 14, 2018 3:23 pm
Location: Austria
Contact:

Re: Focusrite Scarlett 6i6 and 18i8 2nd Gen mixer driver

Postby dawitti » Wed Jun 19, 2019 5:22 pm

Thanks for the instructions @geoffrey! Since I never got Focusrite Control working in Virtualbox I tried it with qemu / kvm and was able to get a dump:
https://pastebin.com/zNaCZab2

As stated in the bin I changed the level of analog in 1 on monitor output 1-2 (which is configured as one stereo output) from 0db down and then up again.

On my Ubuntu 18.04 there is no binary usbmon and searching online only told me that it's part of the kernel. I'm not 100% sure this is the right way to do it but
executing "cat /sys/kernel/debug/usb/usbmon/2u|grep 2\:004\:" as root seems to return the dump in the format @geoffrey needs.

If there's a better way to do it let me know :)
If this is helpful I can provide more dumps with specific actions!

Martin

User avatar
dawitti
Established Member
Posts: 8
Joined: Wed Mar 14, 2018 3:23 pm
Location: Austria
Contact:

Re: Focusrite Scarlett 6i6 and 18i8 2nd Gen mixer driver

Postby dawitti » Fri Jun 21, 2019 7:27 am

@geoffrey If you want we can move this over to github issues since you already forked the kernel there :)

geoffrey
Established Member
Posts: 62
Joined: Mon Jul 30, 2018 2:08 am

Re: Focusrite Scarlett 6i6 and 18i8 2nd Gen mixer driver

Postby geoffrey » Tue Jun 25, 2019 1:28 pm

dawitti wrote:Thanks for the instructions @geoffrey! Since I never got Focusrite Control working in Virtualbox I tried it with qemu / kvm and was able to get a dump:
https://pastebin.com/zNaCZab2

As stated in the bin I changed the level of analog in 1 on monitor output 1-2 (which is configured as one stereo output) from 0db down and then up again.

On my Ubuntu 18.04 there is no binary usbmon and searching online only told me that it's part of the kernel. I'm not 100% sure this is the right way to do it but
executing "cat /sys/kernel/debug/usb/usbmon/2u|grep 2\:004\:" as root seems to return the dump in the format @geoffrey needs.

If there's a better way to do it let me know :)
If this is helpful I can provide more dumps with specific actions!

Martin

Excellent! That's almost exactly what I need! :). I can see you modifying the mix levels there, but the packets are truncated. I tried that same "cat" command and got the same result as you show. The number before the "=" indicates the amount of data; in this case from your paste it's meant to be 54 bytes, but you can see that only 32 bytes are shown:

ffff92babd07dc00 1862720319 S Co:2:004:0 s 21 02 0000 0005 0036 54 = 02200000 260031bc 00000000 00000000 0000351e 00200020 00000020 00000000

The usbmon program I'm using came with Fedora; I found the source here: http://people.redhat.com/zaitcev/linux/ — hopefully you'll be able to capture the full packets with it.

Once you get that going, what I need is:
- Load preset Direct Routing
- in Device Settings, toggle all the line/inst and pad buttons on and off
- in Output Routing:
- set all outputs to mono/unlinked
- take a screenshot of all the outputs available
- change Monitor Output 1 from Playback 1 to each of the other options (it would be enough to select the first and last in each group of each of the options, e.g. Playback, Line Output, S/PDIF)
- take screenshots of all the output source options available
- set all outputs to Custom Mix
- remove all mix inputs (the "x" at the top right of the mix volume control)
- click the "+" to add more inputs to the mix
- in the status bar when you hover over the input source list, it should say something like "There are x spaces remaining in the mixer"; what is x?
- take a screenshot of the available mix input options
- add as many mono channels to the mix as you can ("Software Playback 1", not "Software Playback 1 - 2" etc.)
- change all of the mix volumes for one output to -128 (or if they're already all the way down, put them back to 0)
- change one of the mix volumes for each of the other outputs

If you could somehow label the capture with what you're doing at each point that'd be really helpful. Perhaps a screencast would be the easiest way for me to line up what you're doing in Focusrite Control with the USB capture?

Thanks again!
Geoffrey.

geoffrey
Established Member
Posts: 62
Joined: Mon Jul 30, 2018 2:08 am

Re: Focusrite Scarlett 6i6 and 18i8 2nd Gen mixer driver

Postby geoffrey » Tue Jun 25, 2019 1:31 pm

dawitti wrote:@geoffrey If you want we can move this over to github issues since you already forked the kernel there :)

I don't mind; whatever's easiest for you!

ciolansteen
Established Member
Posts: 5
Joined: Fri Oct 26, 2018 8:22 pm

Re: Focusrite Scarlett 6i6 and 18i8 2nd Gen mixer driver

Postby ciolansteen » Tue Jun 25, 2019 7:52 pm

Hi @geoffrey.

Checked and line / inst works. Same does pan. And most important the interface saves the settings from alsa-mixer internally (line/inst settings, pan and even volumes which is pretty f&@^()% cool! :D (and also wierd cause i recall reading somewhere on the other thread that it does not. Maybe 18i8 is a nice surprise or you fixed in the meantime)

However, the left headphone channel still mutes.

When i'll get some free time i will try and make a dkms package and upload it on aur. Right now because I don't have time to build / rebuild kernels, i'm using your driver patched in https://aur.archlinux.org/packages/snd- ... O=20&PP=10

I'm also for moving this on github and maybe making the driver standalone and out of torvalds's fork since we cannot know how much it will take for this to get into the master branch and frankly this project has a lot of good stuff in it. I mean this can actually complete the Scarlett series support with linux which would be f...amazing!

Thanks again for your hard work and maaan... you really saved me from going back to windows :)


LE - the headphones left channel mute is just a mix issue. Setting the correct mix for analog output 3 and 4 fixed the issue. This is is! Your driver works just fine! This is brilliant! I hope i'll get some time to make the dkms build so this won't be kernel dependent. YAAAAAAY!!!

Btw, did you guys see this https://github.com/x42/scarlett-mixer?

geoffrey
Established Member
Posts: 62
Joined: Mon Jul 30, 2018 2:08 am

Re: Focusrite Scarlett 6i6 and 18i8 2nd Gen mixer driver

Postby geoffrey » Tue Jun 25, 2019 11:27 pm

ciolansteen wrote:Hi @geoffrey.

Checked and line / inst works. Same does pan. And most important the interface saves the settings from alsa-mixer internally (line/inst settings, pan and even volumes which is pretty f&@^()% cool! :D (and also wierd cause i recall reading somewhere on the other thread that it does not. Maybe 18i8 is a nice surprise or you fixed in the meantime)

The interface does save all the settings AFAIK (feature of the latest code, previous versions only saved most of the settings), BUT the problem is that the driver cannot *read* the settings from the interface when it starts. So you can do a config, unplug the interface, turn it off/on and use the interface standalone with the settings it has saved. You can even plug it back in and keep using it with that saved config, BUT the driver doesn't know the settings so if you use alsamixer you won't see the actual config and if you change anything, then that part of the config will be reset to the driver defaults.

ciolansteen wrote:However, the left headphone channel still mutes.

When i'll get some free time i will try and make a dkms package and upload it on aur. Right now because I don't have time to build / rebuild kernels, i'm using your driver patched in https://aur.archlinux.org/packages/snd- ... O=20&PP=10

I'm also for moving this on github and maybe making the driver standalone and out of torvalds's fork since we cannot know how much it will take for this to get into the master branch and frankly this project has a lot of good stuff in it. I mean this can actually complete the Scarlett series support with linux which would be f...amazing!

Thanks again for your hard work and maaan... you really saved me from going back to windows :)

LE - the headphones left channel mute is just a mix issue. Setting the correct mix for analog output 3 and 4 fixed the issue. This is is! Your driver works just fine! This is brilliant! I hope i'll get some time to make the dkms build so this won't be kernel dependent. YAAAAAAY!!!

Woo-hoo! I'm so glad you got it working! Feel free to make a dkms package; making it easier for others to try would be excellent! I'm still hopeful of getting it in to the kernel, it just needs a few things:
- Convert the timer usage to delayed work
- Fix the private data usage (ref: https://mailman.alsa-project.org/piperm ... 48394.html)
- Figure out why the patch doesn't work for some people (& stops audio from working); the only theory I have for this is that their interface has never been connected to the Focusrite driver which perhaps performs some first-time initialisation or upgrades the firmware. Perhaps I could just add a module option to make the new mixer driver optional until we figure out why.

ciolansteen wrote:Btw, did you guys see this https://github.com/x42/scarlett-mixer?

I did. Would you like to convert it to work with the Gen 2 driver? :) (it didn't look fun; as the author said, it was a quick hack)

ciolansteen
Established Member
Posts: 5
Joined: Fri Oct 26, 2018 8:22 pm

Re: Focusrite Scarlett 6i6 and 18i8 2nd Gen mixer driver

Postby ciolansteen » Wed Jun 26, 2019 9:37 am

Not sure if i'm getting it right. I just modified some settings in my KVM Win machine, removed the card and alsa read the changes perfectly (again, inst/line and pads). The only issue i can see is that volumes are not kept between alsa and focusrite control - nor vice versa - but i'm not sure that's an issue since both focusrite keeps its volume levels and the same does alsa mixer. Are you sure the volume levels are kept internally and not at app level?

geoffrey
Established Member
Posts: 62
Joined: Mon Jul 30, 2018 2:08 am

Re: Focusrite Scarlett 6i6 and 18i8 2nd Gen mixer driver

Postby geoffrey » Wed Jun 26, 2019 3:06 pm

ciolansteen wrote:Not sure if i'm getting it right. I just modified some settings in my KVM Win machine, removed the card and alsa read the changes perfectly (again, inst/line and pads). The only issue i can see is that volumes are not kept between alsa and focusrite control - nor vice versa - but i'm not sure that's an issue since both focusrite keeps its volume levels and the same does alsa mixer. Are you sure the volume levels are kept internally and not at app level?

Hi Ciolansteen,

Wow, you sure are paying attention! Thank you for the in-depth testing and I'm sorry, the confusion is my fault. It is indeed more complicated than just "the settings can't be read". Here is (what I hope is) a complete and correct explanation (I reserve the right to edit this post if you find that I am wrong again :wink:).

There are a few configuration parameters that can be read:
- level switches (Line/Inst) (18i8 only)
- pad switches (On/Off) (18i8 only)
- line out volume levels
- sw/hw volume switches (18i20 only)

The configuration parameters that can't be read get initialised in ALSA as follows:
- PCM inputs connected to Analogue inputs, S/PDIF inputs, ADAT inputs in that order
- PCM outputs connected to Analogue outputs, S/PDIF output, ADAT outputs in that order
- Mixer inputs disconnected (Off)
- Mixer levels: all zero (-80dB)

Provided that you don't change the routing or mixer levels, they will be left alone (not written to the interface).

If you change any routing (PCM In, PCM Out, or Mixer) then everything you didn't change (PCM In, PCM Out, and Mixer) will be reset to the defaults shown in alsamixer.

If you change any mixer level, the other levels for the Mix will be reset to the -80dB default. E.g. changing Mix A Input 01 will reset Mix A Inputs 02-18 to -80dB (but the levels for Mix B–J will be left alone until/unless you change those).

My apologies again; when I wrote that none of the settings could be read, I wasn't thinking about the switches or the line out volume levels as I don't use that functionality (I only have a need to change the routing and the mixer levels).

Please let me know if your testing doesn't agree with the above or if what I wrote doesn't make sense.

One more thing: you will notice that the Focusrite Control software is able to read the settings that it saves to the interface. I have not decoded/implemented this, as it appeared to me that 1) it saves these settings in a part of the NVRAM that the interface otherwise doesn't use, 2) it uses a format that is specific to the FC GUI which doesn't expose all the functionality that the hardware supports, and 3) it includes a checksum which I wasn't motivated to decode :D. Since I wanted to expose all the hardware functionality in the Linux driver (especially the PCM Input routing!), I didn't see a way that I could save the data back in a way that would be compatible with FC. Possibly I could ignore FC (like I'm doing anyway), and save the data to NVRAM in a format that the Linux driver can understand and read back. But I'd like some certainty as to which bits of the NVRAM would be safe to use for that purpose before I go writing there! There's 64KB and most of it looks unused. Anyone want to risk their interface for some testing? :D It's low risk I'd think, but without advice from Focusrite I'm not willing to risk bricking my interface.

Regards,
Geoffrey.

ciolansteen
Established Member
Posts: 5
Joined: Fri Oct 26, 2018 8:22 pm

Re: Focusrite Scarlett 6i6 and 18i8 2nd Gen mixer driver

Postby ciolansteen » Wed Jun 26, 2019 6:56 pm

I think i can risk it since it still has warranty and there's no way anyone can prove i used anything else but windows / apple and official drivers (here in Romania). The only problem is that i don't know enough C / asm to do it :(. As for the rest I will most definitely test these days when i'll get some free time :)

User avatar
dawitti
Established Member
Posts: 8
Joined: Wed Mar 14, 2018 3:23 pm
Location: Austria
Contact:

Re: Focusrite Scarlett 6i6 and 18i8 2nd Gen mixer driver

Postby dawitti » Thu Jun 27, 2019 1:43 pm

Thanks @geoffrey for the link and instructions, now usbmon works!

These are the first actions + dumps (in the video description there's a link to a pastebin containing the same dump data):

I added all videos / dumps, please let me know if anything is missing or incorrect.

Getting a standalone driver ready would be awesome!
@ciolansteen, let me know if I can help in any way! (I wouldn't trust myself with writing C though :wink:)

geoffrey
Established Member
Posts: 62
Joined: Mon Jul 30, 2018 2:08 am

Re: Focusrite Scarlett 6i6 and 18i8 2nd Gen mixer driver

Postby geoffrey » Fri Jun 28, 2019 6:34 am

dawitti wrote:Thanks @geoffrey for the link and instructions, now usbmon works!

These are the first actions + dumps (in the video description there's a link to a pastebin containing the same dump data):

I added all videos / dumps, please let me know if anything is missing or incorrect.

@dawitti You are awesome! :)

The videos and dumps made it so easy to get the info I needed. Please have a look at this commit which I hope adds support for the 6i6 Gen 2 (apply on top of my 18i8/18i20 patch):
https://github.com/geoffreybennett/scar ... 71f3dfedf8

or this branch; I rebased the 18i8/18i20 commit to Linux 5.1.9 and added the 6i6 commit on top:
https://github.com/geoffreybennett/scar ... rlett-gen2

Obviously I can't test it myself, so this is a very cross-your-fingers sort of thing.

Are you able to build the module from that? If you've got a source tree of your running kernel, "make M=sound/usb modules" could help you avoiding having to build the lot again.

If it works, another set of usbmon dumps while you do the same changes using alsamixer instead of FC will let me verify that the code is doing the right thing.

if it compiles but doesn't do the right thing, a usbmon dump will help me debug.

Thanks again!
Geoffrey

User avatar
dawitti
Established Member
Posts: 8
Joined: Wed Mar 14, 2018 3:23 pm
Location: Austria
Contact:

Re: Focusrite Scarlett 6i6 and 18i8 2nd Gen mixer driver

Postby dawitti » Fri Jun 28, 2019 1:24 pm

@geoffrey wow you're fast!

I checked out your forked branch and compiled the kernel hoping I could install it, but the make install script messed up grub so I had to get that working again before trying other options.
Compiling only the sound/usb modules works too.

Any ideas how to install the compiled kernel correctly? The info I found is that make install handles it -but as stated it fails for me :(

I also tried simply modprobing snd_usb_audio from the newer kernel, but no wonder it does not work since the kernel I'm running is 4.15.0.54.

I thought it should be possible to use a prepackaged linux-image-5.1.9.x and simply swap the snd_usb_audio module. I found some on https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.1.9/
and manually installed the packages since I didn't find a corresponding metapackage, but installing the headers fails due to a compilation error of bcwml. I don't know how to fix or work around this yet.

Right now I'm installing Ubuntu 19.04 in qemu. Maybe I can get a 5.1.9 kernel running there.

BUT, maybe I'm doing things way too complicated. So if you have suggestions please let me know.

Just in case to save you some asking here's some hopefully relevant info:
The machine is running on ubuntu 18.04 with currently linux 4.15.0.54-lowlatency (and 1-2 4.x versions installed).

Any help would be greatly appreciated :)


Return to “Computer Related Hardware”

Who is online

Users browsing this forum: No registered users and 1 guest