DesktopVideo/Linux : build fail with kernel 4.15

Do you have questions about Desktop Video, Converters, Routers and Monitoring?
  • Author
  • Message
Offline

Jérôme Bihouée

  • Posts: 3
  • Joined: Fri Dec 29, 2017 7:47 pm

DesktopVideo/Linux : build fail with kernel 4.15

PostFri Dec 29, 2017 10:10 pm

Hello everyone,

The linux kernel 4.15 provides moficiations on the timer.
This results in the failure of desktopvideo compilation in the bm_util.c file.
The init_timer function has been removed and the timer_list structure has also been changed.
Does anyone have a solution?

Result of the make:
./usr/src/blackmagic-io-10.9.9a4/bm_util.c:420:2: error: implicit declaration of function 'init_timer'; did you mean 'init_timers'? [= -Werror implicit-function-declaration]
   init_timer (timer);
   ^ ~~~~~~~~~
   init_timers
./usr/src/blackmagic-io-10.9.9a4/bm_util.c:421:18: error: assignment from incompatible pointer type [-Werror = incompatible-pointer-types]
   timer-> function = (void (*) (unsigned long)) callback;
                   ^
./usr/src/blackmagic-io-10.9.9a4/bm_util.c:422:7: error: 'bm_timer_t {aka struct timer_list}' has no member named 'data'
   timer-> data = (long) data;
        ^ ~
Offline

Jérôme Bihouée

  • Posts: 3
  • Joined: Fri Dec 29, 2017 7:47 pm

Re: DesktopVideo/Linux : build fail with kernel 4.15

PostThu Jan 18, 2018 1:40 pm

Problem still present with 4.15-rc8 and desktopVideo 10.9.10
Offline

Steinar H. Gunderson

  • Posts: 51
  • Joined: Fri Aug 14, 2015 12:17 pm

Re: DesktopVideo/Linux : build fail with kernel 4.15

PostWed Jan 31, 2018 10:40 pm

Yet another reason why you should subscribe to LWN if you care about kernel internals :-) The patch is fairly simple:

Code: Select all
diff -u blackmagic-io-10.9.10a2.orig/bm_util.c blackmagic-io-10.9.10a2/bm_util.c
--- blackmagic-io-10.9.10a2.orig/bm_util.c   2018-01-08 02:46:14.000000000 +0100
+++ blackmagic-io-10.9.10a2/bm_util.c   2018-01-31 23:27:01.543121803 +0100
@@ -411,39 +411,45 @@
    return jiffies_to_usecs(jiffies);
 }
 
+static void timer_thunk(struct timer_list* kernel_timer)
+{
+   bm_timer_t* timer = container_of(kernel_timer, bm_timer_t, kernel_timer);
+   (*timer->callback)(timer->data);
+}
+
 bm_timer_t* bm_timer_alloc(bm_timer_callback_t callback, void* data)
 {
    bm_timer_t* timer = bm_kmalloc(sizeof(bm_timer_t));
    if (!timer)
       return NULL;
 
-   init_timer(timer);
-   timer->function = (void(*)(unsigned long))callback;
-   timer->data = (long)data;
+   timer->callback = callback;
+   timer->data = data;
+   timer_setup(&timer->kernel_timer, timer_thunk, 0);
    return timer;
 }
 
 void bm_timer_free(bm_timer_t* timer)
 {
-   del_timer(timer);
+   del_timer(&timer->kernel_timer);
    bm_kfree(timer);
 }
 
 void bm_timer_expire_in(bm_timer_t* timer, uint64_t ns)
 {
-   timer->expires = jiffies + (ns * HZ + NSEC_PER_SEC - 1) / NSEC_PER_SEC;
-   add_timer(timer);
+   timer->kernel_timer.expires = jiffies + (ns * HZ + NSEC_PER_SEC - 1) / NSEC_PER_SEC;
+   add_timer(&timer->kernel_timer);
 }
 
 void bm_timer_expire_at(bm_timer_t* timer, uint64_t ns)
 {
-   timer->expires = (ns * HZ + NSEC_PER_SEC - 1) / NSEC_PER_SEC;
-   add_timer(timer);
+   timer->kernel_timer.expires = (ns * HZ + NSEC_PER_SEC - 1) / NSEC_PER_SEC;
+   add_timer(&timer->kernel_timer);
 }
 
 void bm_timer_cancel(bm_timer_t* timer)
 {
-   del_timer(timer);
+   del_timer(&timer->kernel_timer);
 }
 
 // Event waiting
diff -u blackmagic-io-10.9.10a2.orig/bm_util.h blackmagic-io-10.9.10a2/bm_util.h
--- blackmagic-io-10.9.10a2.orig/bm_util.h   2018-01-08 02:46:14.000000000 +0100
+++ blackmagic-io-10.9.10a2/bm_util.h   2018-01-31 23:27:01.543121803 +0100
@@ -112,8 +112,12 @@
 
 // Timer
 struct timer_list;
-typedef struct timer_list bm_timer_t;
 typedef void (*bm_timer_callback_t)(void*);
+typedef struct {
+   struct timer_list kernel_timer;
+   bm_timer_callback_t callback;
+   void *data;
+} bm_timer_t;
 
 uint64_t bm_absolute_time_us(void);
 


Tested with 4.15.0-rc8 only, with simple MediaExpress preview on a Mini Recorder 4K.

(PS: I really do mean it. LWN is awesome.)
Offline

Jérôme Bihouée

  • Posts: 3
  • Joined: Fri Dec 29, 2017 7:47 pm

Re: DesktopVideo/Linux : build fail with kernel 4.15

PostMon Feb 05, 2018 12:29 am

Thank you for this patch.
Works perfectly with kernel 4.15.0

Return to Post Production

Who is online

Users browsing this forum: No registered users and 9 guests