HinTak/sound-usb-dkms

attempt to compile under Arch 5.11.5-arch1

Closed this issue · 4 comments

@HinTak Thanks for your work! This discussion is brought here from 18i20 gen3 pq discussion for relevance.

I'm yet to find time to try your code base against Arch 5.11.5-arch1, which I'm currently using. I'll report back after I manage to give it a try.

In the meantime, for your reference, here's my sound/usb/pcm.c.rej when I applied my diffs from 5.10 to 5.11.5. It might help you see whether your code can port to 5.11 easily before I manage to give it a try.

--- sound/usb/pcm.c	2021-01-24 00:22:38.664335939 -0600
+++ sound/usb/pcm.c	2021-01-23 20:04:04.055170193 -0600
@@ -385,6 +385,15 @@
 		ep = 0x82;
 		ifnum = 0;
 		goto add_sync_ep_from_ifnum;
+	case USB_ID(0x1235, 0x8210): /* Focusrite Scarlett 2i2 3rd Gen */
+	case USB_ID(0x1235, 0x8211): /* Focusrite Scarlett Solo 3rd Gen */
+	case USB_ID(0x1235, 0x8212): /* Focusrite Scarlett 4i4 3rd Gen */
+	case USB_ID(0x1235, 0x8213): /* Focusrite Scarlett 8i6 3rd Gen */
+	case USB_ID(0x1235, 0x8214): /* Focusrite Scarlett 18i8 3rd Gen */
+	case USB_ID(0x1235, 0x8215): /* Focusrite Scarlett 18i20 3rd Gen */
+		ep = 0x81;
+		ifnum = 2;
+		goto add_sync_ep_from_ifnum;
 	case USB_ID(0x0582, 0x01d8): /* BOSS Katana */
 		/* BOSS Katana amplifiers do not need quirks */
 		return 0;
@@ -407,10 +416,11 @@
 add_sync_ep_from_ifnum:
 	iface = usb_ifnum_to_if(dev, ifnum);
 
-	if (!iface || iface->num_altsetting < 2)
+	if (!iface || iface->num_altsetting < 2 ||
+	    altsd->bAlternateSetting >= iface->num_altsetting)
 		return -EINVAL;
 
-	alts = &iface->altsetting[1];
+	alts = usb_altnum_to_altsetting(iface, altsd->bAlternateSetting);
 
 add_sync_ep:
 	subs->sync_endpoint = snd_usb_add_endpoint(subs->stream->chip,

By the way, I can't seem to do a cross-fork comparison to the upstream.

So a lot of pcm.c were refactored into implicit.c since 5.11; that's why it failed for me. sadko4u created a new patch for that.

Your dkms approach is now therefore even more attractive.

@tsankuanglee implicit.c is new to 5.11/5.12. That said, it seems to build fine with 5.10. I am still on 5.10, and I just sync'ed up the master branch here to sound maintainer's (5.12-rc1) and it builds okay against 5.10 .

You can do cross-branch comparison with git diff origin/master origin/v5.10-scarlett-gen3 sound/ (this excludes README,md, license at the bottom which are not important in the technical sense). For example, to work out that implicit.c is only on master and not on v5.10-scarlett-gen3 yet, I do:

$ git diff origin/master origin/v5.10-scarlett-gen3 sound/ | grep -1 sound/usb/implicit.c
 				       NULL, 0, 0);
diff --git a/sound/usb/implicit.c b/sound/usb/implicit.c
deleted file mode 100644
index 11a85e6..0000000
--- a/sound/usb/implicit.c
+++ /dev/null

This shows sound/usb/implicit.c is only on origin/master. (by both the "delete mode", and the "/dev/null").

Since 5.12-rc1 builds fine against 5.10, I'll simply create a new branch v5.11-scarlett-gen3, think. I don't want to put pure 5.10/5.11 difference onto the v5.10- branch.

@tsankuanglee I have put v5.11-sadko4u-scarlett-gen3 branch out. It is the single patch you mentioned against v5.11, and it builds fine against 5.10 too. That's expected: despite the internal factoring / re-organization, it is usually fine if one replaces the whole set of related kernel modules as a group, across kernel versions.

I'll carry on with v5.11-scarlett-gen3, which should eventually be functionally identical with v5.11-sadko4u-scarlett-gen3 eventually, just with all the dev history preserved. (that's an important aspect if one wants to submit upstream - they usually want to know where every piece came from, and who did what, and they do not want a single integrated patch for misc enhancements).

branch v5.11-scarlett-gen3 is now functionally identical to v5.11-sadko4u-scarlett-gen3, except with full history of changes. Since it is v5.11 based it should build fine with v5.11; it builds fine against 5.10 too.

To build against your curent kernel, whether it is 5.11 or 5.10, do:

make -C /lib/modules/`uname -r`/build M=`pwd`/sound/usb clean
make -C /lib/modules/`uname -r`/build M=`pwd`/sound/usb modules

then copy all the *.ko generated into "/lib/modules/uname -r/updates" or "/lib/modules/uname -r/extra" ("uname -r" gives your current running kernel's version). Then run "depmod -a -v" to update the kernel module dependencies to let it know you have new versions of kernel modules. If you can unload, you can reload; otherwise just reboot to the same kernel should get the new modules active.

@tsankuanglee let me know if you have any questions. I'll close this now.