Kernel 4.15 osscore.c compile fix

OSS specific Linux discussion (x86/amd64)

Moderators: hannu, dev, cesium

seawright
Known Member
Posts: 102
Joined: Sat Jan 06, 2007 9:10 pm
Location: Hampshire UK

Kernel 4.15 osscore.c compile fix

Postby seawright » Thu Feb 01, 2018 10:54 pm

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.
regards
Clive

igorzwx
Known Member
Posts: 1258
Joined: Sun Jun 28, 2009 9:31 pm

Re: Kernel 4.15 osscore.c compile fix

Postby igorzwx » Fri Feb 02, 2018 5:39 pm

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.

Matti
Member
Posts: 42
Joined: Sun May 29, 2011 12:34 pm

Re: Kernel 4.15 osscore.c compile fix

Postby Matti » Sat Feb 03, 2018 3:28 pm

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).

alexdw
Member
Posts: 26
Joined: Sat Jul 06, 2013 12:29 pm

Re: Kernel 4.15 osscore.c compile fix

Postby alexdw » Sun Feb 18, 2018 8:23 pm

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/)?

tedbell
New Member
Posts: 3
Joined: Sun Feb 18, 2018 11:06 pm
Sound Card: Intel HDA
OS: Arch Linux

Re: Kernel 4.15 osscore.c compile fix

Postby tedbell » Sun Feb 18, 2018 11:10 pm

Would anyone be willing to patch this for Arch Linux?

seawright
Known Member
Posts: 102
Joined: Sat Jan 06, 2007 9:10 pm
Location: Hampshire UK

Re: Kernel 4.15 osscore.c compile fix

Postby seawright » Mon Feb 19, 2018 2:22 am

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.
regards

Clive

alexdw
Member
Posts: 26
Joined: Sat Jul 06, 2013 12:29 pm

Re: Kernel 4.15 osscore.c compile fix

Postby alexdw » Mon Feb 19, 2018 11:21 pm

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)

seawright
Known Member
Posts: 102
Joined: Sat Jan 06, 2007 9:10 pm
Location: Hampshire UK

Re: Kernel 4.15 osscore.c compile fix

Postby seawright » Tue Feb 20, 2018 12:29 am

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.
regards

Clive

tedbell
New Member
Posts: 3
Joined: Sun Feb 18, 2018 11:06 pm
Sound Card: Intel HDA
OS: Arch Linux

Re: Kernel 4.15 osscore.c compile fix

Postby tedbell » Sun Feb 25, 2018 7:57 am

Thank you so much for this.
Can't live without oss :D


Return to “Linux”

Who is online

Users browsing this forum: Google [Bot] and 4 guests