Page 1 of 1

Kernel 4.15 osscore.c compile fix

Posted: Thu Feb 01, 2018 10:54 pm
by seawright
Following changes to linux/timer.h in Kernel version 4.15 osscore.c will not compile.
igorzwx wrote:So that, a new "magic patch" might be needed to compile OSS4 for Linux kernel 4.15. Right?

I'm no magician but, for what it's worth, I have wrote the following patch:

Code: Select all

--- oss-v4.2-build2017-src-gpl-orig/setup/Linux/oss/build/osscore.c   2018-02-01 21:02:56.396940512 +0000
+++ oss-v4.2-build2017-src-gpl/setup/Linux/oss/build/osscore.c   2018-02-01 21:42:35.156620086 +0000
@@ -495,6 +495,9 @@
   int timestamp;
   void (*func) (void *);
   void *arg;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0)
+  int data;
+#endif
 
   struct timer_list timer;
 } tmout_desc_t;
@@ -507,8 +510,16 @@
 int timeout_random = 0x12123400;
 
 void
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0)
+oss_timer_callback (struct timer_list *t)
+#else
 oss_timer_callback (unsigned long id)
+#endif
 {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0)
+  tmout_desc_t *priv = container_of(t, typeof(*priv), timer);
+  int id = priv->data;
+#endif
   tmout_desc_t *tmout;
   int ix;
   void *arg;
@@ -567,10 +578,17 @@
   tmout->arg = arg;
   tmout->timestamp = id | (timeout_random & ~0xff);
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0)
+  tmout->data = id | (timeout_random & ~0xff);
+  timer_setup (&tmout->timer, oss_timer_callback, 0);
+#else
   init_timer (&tmout->timer);
+#endif
   tmout->timer.expires = jiffies + ticks;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,15,0)
   tmout->timer.data = id | (timeout_random & ~0xff);
   tmout->timer.function = oss_timer_callback;
+#endif
   add_timer (&tmout->timer);
 
   return id | (timeout_random & ~0xff);

I've compiled and installed it on Ubuntu with kernel v4.14.13 and kernel v4.15 and checked sound output using ossplay.
All appears well though further testing maybe advisable.

Re: Kernel 4.15 osscore.c compile fix

Posted: Fri Feb 02, 2018 5:39 pm
by igorzwx
seawright wrote:I'm no magician but...


Don't be so modest. Many thanks for the patch.

"Practice is the sole criterion of truth" (Deng Xiaoping).
_http://afe.easia.columbia.edu/special/china_1950_leaders.htm#deng
_https://en.wikisource.org/wiki/On_Practice

If your "magic patch" works, you are a true magician.

Re: Kernel 4.15 osscore.c compile fix

Posted: Sat Feb 03, 2018 3:28 pm
by Matti
I confirm that the "magic patch" created by seawright works.

I installed kernel 4.15 from http://kernel.ubuntu.com/~kernel-ppa/mainline/ and made .deb package with the patch applied to OSSv4 source code. And it build the modules for this kernel. That didn't work without the patch.

Sound works in every program that I've tried so far (Spotify, Opera and Gloobus Preview).

Re: Kernel 4.15 osscore.c compile fix

Posted: Sun Feb 18, 2018 8:23 pm
by alexdw
seawright wrote:Following changes to linux/timer.h in Kernel version 4.15 osscore.c will not compile.
igorzwx wrote:So that, a new "magic patch" might be needed to compile OSS4 for Linux kernel 4.15. Right?

I'm no magician but, for what it's worth, I have wrote the following patch:

Code: Select all

--- oss-v4.2-build2017-src-gpl-orig/setup/Linux/oss/build/osscore.c   2018-02-01 21:02:56.396940512 +0000
+++ oss-v4.2-build2017-src-gpl/setup/Linux/oss/build/osscore.c   2018-02-01 21:42:35.156620086 +0000
@@ -495,6 +495,9 @@
   int timestamp;
   void (*func) (void *);
   void *arg;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0)
+  int data;
+#endif
 
   struct timer_list timer;
 } tmout_desc_t;
@@ -507,8 +510,16 @@
 int timeout_random = 0x12123400;
 
 void
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0)
+oss_timer_callback (struct timer_list *t)
+#else
 oss_timer_callback (unsigned long id)
+#endif
 {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0)
+  tmout_desc_t *priv = container_of(t, typeof(*priv), timer);
+  int id = priv->data;
+#endif
   tmout_desc_t *tmout;
   int ix;
   void *arg;
@@ -567,10 +578,17 @@
   tmout->arg = arg;
   tmout->timestamp = id | (timeout_random & ~0xff);
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0)
+  tmout->data = id | (timeout_random & ~0xff);
+  timer_setup (&tmout->timer, oss_timer_callback, 0);
+#else
   init_timer (&tmout->timer);
+#endif
   tmout->timer.expires = jiffies + ticks;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,15,0)
   tmout->timer.data = id | (timeout_random & ~0xff);
   tmout->timer.function = oss_timer_callback;
+#endif
   add_timer (&tmout->timer);
 
   return id | (timeout_random & ~0xff);

I've compiled and installed it on Ubuntu with kernel v4.14.13 and kernel v4.15 and checked sound output using ossplay.
All appears well though further testing maybe advisable.


Thanks for the patch! :)
Do you want to submit it to the main repo (here, I think: https://sourceforge.net/p/opensound/git/ci/master/tree/)?

Re: Kernel 4.15 osscore.c compile fix

Posted: Sun Feb 18, 2018 11:10 pm
by tedbell
Would anyone be willing to patch this for Arch Linux?

Re: Kernel 4.15 osscore.c compile fix

Posted: Mon Feb 19, 2018 2:22 am
by seawright
alexdw wrote:Thanks for the patch! :)
Do you want to submit it to the main repo (here, I think: https://sourceforge.net/p/opensound/git/ci/master/tree/)?

Not sure that it would get approved. I see that your merge request from Christmas 2016 is still awaiting approval.
I've no objection if you want to include the patch in the AUR oss.git package though an acknowledgement would be appreciated.

Re: Kernel 4.15 osscore.c compile fix

Posted: Mon Feb 19, 2018 11:21 pm
by alexdw
seawright wrote:
alexdw wrote:Thanks for the patch! :)
Do you want to submit it to the main repo (here, I think: https://sourceforge.net/p/opensound/git/ci/master/tree/)?

Not sure that it would get approved. I see that your merge request from Christmas 2016 is still awaiting approval.
I've no objection if you want to include the patch in the AUR oss.git package though an acknowledgement would be appreciated.


I think they included the commits as part of build 2017 though. :)
But sure, I'll have a look when I have some time this weekend; if I do include it how do you want to be acknowledged - courtesy of "seawright" with a link back to here? 8)

Re: Kernel 4.15 osscore.c compile fix

Posted: Tue Feb 20, 2018 12:29 am
by seawright
alexdw wrote:But sure, I'll have a look when I have some time this weekend; if I do include it how do you want to be acknowledged - courtesy of "seawright" with a link back to here? 8)
That would be fine.

Re: Kernel 4.15 osscore.c compile fix

Posted: Sun Feb 25, 2018 7:57 am
by tedbell
Thank you so much for this.
Can't live without oss :D