smilingthax / alsa-driver_scarlett

ALSA Mixer support for Focusrite Scarlett
16 stars 1 forks source link

Mainline Kernel? #2

Closed kroll-j closed 8 years ago

kroll-j commented 10 years ago

Hello,

you guys did some great work here! The patch created by trrichard applies cleanly to a 3.11.0-15-lowlatency Ubuntu kernel as well.

Is there any chance the driver will get merged into the mainline kernel/alsa code? That would be awesome!

kunitoki commented 10 years ago

i'm a owner of a scarlett 6i6 and i would like to test it with my kernel. How do i generate a patch file from the github master so last commits regarding 6i6 are included? any help is appreciated

smilingthax commented 10 years ago

In certain circumstances you can compile it even out-of-tree: I use make -C /usr/src/linux-2.6/ M=$PWD modules where $PWD is alsa-driver_scarlett/sound/usb . You'll still have to install and insmod/modprobe the module.

The other option is something like git diff b044dfe . > scarlett.patch in alsa-driver_scarlett/sound (otherwise there will be one superfluous file in the patch) and then applying it to the kernel (e.g. in /usr/src/linux-2.6) via something like patch -p1 < ...scarlett.path (untested...)

On 01/02/14 10:34, Lucio Asnaghi wrote:

i'm a owner of a scarlett 6i6 and i would like to test it with my kernel. How do i generate a patch file from the github master so last commits regarding 6i6 are included? any help is appreciated

— Reply to this email directly or view it on GitHub https://github.com/smilingthax/alsa-driver_scarlett/issues/2#issuecomment-33867485.

smilingthax commented 10 years ago

Regarding upstreaming into the mainline kernel... I'm all for it... but I'm currently not willing to invest much time into it.

kunitoki commented 10 years ago

thanx i've been able to make a patch. i initially tried with out of tree compilation, but there were missing symbols when trying to insmod the snd-usb-audio...

kunitoki commented 10 years ago

wonderful work by the way. the mixer works out of the box on my scarlett with no major drawbacks so far ! the only problems are related to the snd-usb-audio module and kernel's ehci-hcd handling of the device.

kroll-j commented 10 years ago

Well, if you won't integrate the code into the kernel, are you planning to support the driver outside of the kernel tree, integrating changes from mainline? If you don't, the code will diverge sooner or later and the patch will no longer apply cleanly to newer kernels, making it rather useless. What are we going to do? Should I try to integrate your code into mainline? I would be willing to try, but I haven't done that before.

smilingthax commented 10 years ago

Well, I'll keep my tree up-to-date so that it works for me -- and I don't expect that many breaking changes in the future.

That being said, I'm all for integrating the code into the kernel, by submitting it to the alsa project; the alsa-devel mailing list is probably the right place to go. As I've extended Robin Gareus' work to support more devices, you can also reference his mail on the subject [1].

[1] http://mailman.alsa-project.org/pipermail/alsa-devel/2013-January/058766.html

On 21/02/14 17:45, j. kroll wrote:

Well, if you won't integrate the code into the kernel, are you planning to support the driver outside of the kernel tree, integrating changes from mainline? If you don't, the code will diverge sooner or later and the patch will no longer apply cleanly to newer kernels, making it rather useless. What are we going to do? Should I try to integrate your code into mainline? I would be willing to try, but I haven't done that before.

— Reply to this email directly or view it on GitHub https://github.com/smilingthax/alsa-driver_scarlett/issues/2#issuecomment-35748461.

gabrgomes commented 10 years ago

I found this thread on alsa-devel http://comments.gmane.org/gmane.linux.alsa.devel/126241, where they are talking about integrating Tobias' code (and yours too, of course) into mainline. Daniel Mack zonque@gmail.com was even looking for his mail address, so I think he is interested and could help.

Edited: I was able to compile and load the modules after modprobe snd_pcm snd_hwdep.

When I plug the scarlett 6i6, it does not show in alsa.

dmesg shows this: [ 416.825307] usb 2-1.5: new high-speed USB device number 3 using ehci-pci [ 416.912108] usb 2-1.5: New USB device found, idVendor=1235, idProduct=8012 [ 416.912113] usb 2-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 416.912117] usb 2-1.5: Product: Scarlett 6i6 USB [ 416.912119] usb 2-1.5: Manufacturer: Focusrite [ 416.912121] usb 2-1.5: SerialNumber: 0000A069 [ 416.990224] BUG: unable to handle kernel paging request at ffffffffa04a3240 [ 416.990275] IP: [] memcpy+0x6/0x110 [ 416.990311] PGD 1c11067 PUD 1c12063 PMD 21147d067 PTE 800000021178b161 [ 416.990358] Oops: 0003 [#1] PREEMPT SMP [ 416.990389] Modules linked in: snd_usb_audio(OF) snd_hwdep snd_pcm snd_page_alloc snd_usbmidi_lib(OF) snd_seq_midi snd_seq_midi_event snd_rawmidi snd_seq snd_seq_device snd_timer snd soundcore pci_stub vboxpci(OF) vboxnetadp(OF) vboxnetflt(OF) vboxdrv(OF) cuse bnep rfcomm bluetooth joydev eeepc_wmi asus_wmi sparse_keymap mxm_wmi intel_rapl x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel kvm crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel aes_x86_64 lrw gf128mul glue_helper ablk_helper cryptd serio_raw lpc_ich i915 mei_me mei drm_kms_helper video drm mac_hid wmi i2c_algo_bit parport_pc ppdev lp parport usb_storage hid_generic usbhid hid ahci psmouse r8169 libahci mii [ 416.990882] CPU: 2 PID: 49 Comm: khubd Tainted: GF O 3.13.0-35-lowlatency #62-Ubuntu [ 416.990930] Hardware name: System manufacturer System Product Name/P8Z77-M PRO, BIOS 0907 04/02/2012 [ 416.990981] task: ffff880213c36080 ti: ffff880213d20000 task.ti: ffff880213d20000 [ 416.991023] RIP: 0010:[] [] memcpy+0x6/0x110 [ 416.991068] RSP: 0018:ffff880213d21748 EFLAGS: 00010286 [ 416.991098] RAX: ffffffffa04a3240 RBX: ffff880211d03800 RCX: 0000000000000004 [ 416.991138] RDX: 0000000000000004 RSI: ffff880036b22ed0 RDI: ffffffffa04a3240 [ 416.991178] RBP: ffff880213d217b0 R08: 0000000000017340 R09: ffff88021fb17340 [ 416.991217] R10: ffffea0000dac880 R11: ffffffff8154aff4 R12: 0000000080000300 [ 416.991258] R13: 0000000000000001 R14: 0000000000000021 R15: 0000000000000100 [ 416.991297] FS: 0000000000000000(0000) GS:ffff88021fb00000(0000) knlGS:0000000000000000 [ 416.991342] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 416.991374] CR2: ffffffffa04a3240 CR3: 0000000001c0e000 CR4: 00000000001407e0 [ 416.991413] Stack: [ 416.991426] ffffffffa04911d2 ffff880036b22ed0 ffff880000000004 ffff880200001388 [ 416.991476] 0000000400000001 0000000000000004 ffff880036b22ed0 0000000400002900 [ 416.991525] 000000000000000a ffff880211d6cf00 0000000000000004 0000000000000001 [ 416.991575] Call Trace: [ 416.991599] [] ? snd_usb_ctl_msg+0xc2/0x160 [snd_usb_audio] [ 416.991645] [] set_ctl_urb2+0xaa/0x100 [snd_usb_audio] [ 416.991688] [] scarlett_mixer_controls+0x28a/0x4c0 [snd_usb_audio] [ 416.991736] [] snd_usb_create_mixer+0x19d/0x2f0 [snd_usb_audio] [ 416.991782] [] ? snd_usb_create_stream+0x1a3/0x200 [snd_usb_audio] [ 416.991828] [] usb_audio_probe+0x238/0x960 [snd_usb_audio] [ 416.991871] [] usb_probe_interface+0x1c4/0x2f0 [ 416.991907] [] driver_probe_device+0x12d/0x3e0 [ 416.991943] [] ? driver_probe_device+0x3e0/0x3e0 [ 416.991979] [] __device_attach+0x3b/0x40 [ 416.992012] [] bus_for_each_drv+0x63/0xa0 [ 416.992046] [] device_attach+0x88/0xa0 [ 416.992078] [] bus_probe_device+0x98/0xc0 [ 416.992112] [] device_add+0x4c5/0x640 [ 416.992144] [] usb_set_configuration+0x4fb/0x810 [ 416.992182] [] generic_probe+0x2e/0xa0 [ 416.992213] [] usb_probe_device+0x32/0x80 [ 416.992246] [] driver_probe_device+0x12d/0x3e0 [ 416.992282] [] ? driver_probe_device+0x3e0/0x3e0 [ 416.992318] [] __device_attach+0x3b/0x40 [ 416.992351] [] bus_for_each_drv+0x63/0xa0 [ 416.992384] [] device_attach+0x88/0xa0 [ 416.992415] [] bus_probe_device+0x98/0xc0 [ 416.992449] [] device_add+0x4c5/0x640 [ 416.992482] [] usb_new_device+0x268/0x430 [ 416.992516] [] hub_port_connect_change+0x2c2/0xad0 [ 416.992554] [] hub_events+0x474/0x9a0 [ 416.992586] [] hub_thread+0x35/0x150 [ 416.992619] [] ? prepare_to_wait_event+0x100/0x100 [ 416.992657] [] ? hub_events+0x9a0/0x9a0 [ 416.992690] [] kthread+0xd2/0xf0 [ 416.992719] [] ? kthread_create_on_node+0x1c0/0x1c0 [ 416.992758] [] ret_from_fork+0x7c/0xb0 [ 416.992790] [] ? kthread_create_on_node+0x1c0/0x1c0 [ 416.992827] Code: 43 58 48 2b 43 50 88 43 4e 5b 5d c3 66 0f 1f 84 00 00 00 00 00 e8 fb fb ff ff eb e2 90 90 90 90 90 90 90 90 90 48 89 f8 48 89 d1 a4 c3 03 83 e2 07 f3 48 a5 89 d1 f3 a4 c3 20 4c 8b 06 4c 8b [ 416.993086] RIP [] memcpy+0x6/0x110 [ 416.993118] RSP [ 416.993139] CR2: ffffffffa04a3240 [ 417.006824] ---[ end trace d3a18902ab462f4b ]---

$ aplay -l aplay: device_list:268: no soundcards found...

$ alsamixer cannot open mixer: No such file or directory

smilingthax commented 10 years ago

It seems not to be smart to try to use the "old" alsa-driver together with parts from the more up-to-date in-kernel alsa. You might want to try the ...-kernel.patch [1] against your current kernel sources (or: a copy of the drivers/sound/ subtree). I'm currently using my 18i8 on a 3.16.0 kernel using that patch. BTW, Daniel gets this as CC.

[1] https://github.com/smilingthax/alsa-driver_scarlett/tree/patches

On 03/09/14 22:49, gabrgomes wrote:

I was able to compile your module (both out-of-tree and patched), and snd-usbmidi-lib.ko loads fine but I'm getting an error when trying to insmod snd-usb-audio.ko:

insmod snd-usb-audio.ko

insmod: ERROR: could not insert module snd-usb-audio.ko: Unknown symbol in module

What am I missing?

I found this thread on alsa-devel http://comments.gmane.org/gmane.linux.alsa.devel/126241 but the modules_prepare did not help.

Also, they are talking about integrating Tobias' code (and yours too, of course) into mainline. Daniel Mack zonque@gmail.com mailto:zonque@gmail.com was even looking for his mail address, so I think he is interested and could help.

— Reply to this email directly or view it on GitHub https://github.com/smilingthax/alsa-driver_scarlett/issues/2#issuecomment-54364354.

zonque commented 10 years ago

I can only encourage you to bring this driver addition to mainline. The Linux kernel is a rapidly moving target, and hence maintaining patches out of tree certainly results in more work eventually. Also, no distribution kernel will ship your patches, so no common user will be able to benefit from them, which is sad and also leads to poorer test coverage.

If you're up for it, please prepare patches for the 'for-next' branch of this tree:

https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/

Checking for style problems with scripts/checkpatch.pl before posting is advisable. The rest can be discussued on the ALSA mailing list then :)

sebastianzebrowski commented 10 years ago

Why patch removes code from quirks-table.h? Is this intented?

smilingthax commented 10 years ago

The quirks-table in the current kernel contains an entry to block/disable the generic create-mixer-from-usb-descriptor code from creating a mixer for 6i6 devices, because the usb-descriptor delivered by 6i6 is invalid and "crashes" the generic code. To use the mixer in a Scarlett device, the driver (or, for Windows: the mixer app) has to know the internal wiring of each usb device it supports.

My scarlett mixer code has that internal knowledge and is used to create the mixer instead of calls to the generic code. Therefore the quirk entry is no longer needed/wanted.

sebastianzebrowski commented 10 years ago

How do you apply your patch against 3.16? Because even using -F3 fails on quirks-table.h:

patching file sound/usb/quirks-table.h Reversed (or previously applied) patch detected! Assume -R? [n] n Apply anyway? [n] y Hunk #1 FAILED at 3054. 1 out of 1 hunk FAILED -- saving rejects to file sound/usb/quirks-table.h.rej

Also contex of quirks-table.h is different in 3.16: https://github.com/torvalds/linux/blob/v3.16/sound/usb/quirks-table.h

The Scarlett code finishes with: /* Access Music devices */

But in your patch is: * Some USB MIDI devices don't have an audio control interface, * so we have to grab MIDI streaming interfaces here. */

dhaumann commented 9 years ago

In case you are interested, the 18i20 and 18i8 are being discussed on the alsa-devel mailing list right now: http://thread.gmane.org/gmane.linux.alsa.devel/127579/focus=127579 If you want to help getting this into the kernel, it's now the right time to get involved ( http://www.alsa-project.org/mailman/listinfo/alsa-devel ).

jmaibaum commented 8 years ago

Hello, reading through all the mailing list threads linked above, I understand that this useful work has still not found its way into mainline Linux/ALSA. Owning a Focusrite 18i8 myself, I'm all in for helping with tests.

dhaumann commented 8 years ago

It should be supported, since Support was added to Linux kernel 3.19. This is also confirmed e.g. in this thread: https://community.ardour.org/node/5751

So what exactly are you missing? Does it simply not work for you?

jmaibaum commented 8 years ago

Ah, thank you. I was brought here from another spot on the web where it looked like there still was some work to do (it linked here). I should have checked it first. alsamixer works perfectly. Only pulseaudio still wants to treat the 18i8 like a 7.1 surround card... Thank you, and sorry for the noise.