Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lukas2511/ecfe7e29cb80a28e2857f48be86953ad to your computer and use it in GitHub Desktop.
Save lukas2511/ecfe7e29cb80a28e2857f48be86953ad to your computer and use it in GitHub Desktop.
ugly decklink fix, meh. (see revisions for even uglier fixes including slightly illegal license rewrites! fun for the whole family!)
From 5248c039c1353bf3b5647cf1659004fbbf33ac54 Mon Sep 17 00:00:00 2001
From: Lukas Schauer <lukas@schauer.so>
Date: Wed, 6 Mar 2019 23:00:39 +0100
Subject: [PATCH] fix for linux 5.0 (might result in some slowdown)
---
blackmagic-10.11.4a9/blackmagic_lib.c | 26 ++++++++++++++++++++++++--
blackmagic-io-10.11.4a9/bm_util.c | 13 +++++++++++--
2 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/blackmagic-10.11.4a9/blackmagic_lib.c b/blackmagic-10.11.4a9/blackmagic_lib.c
index ffe0a89..89d83bd 100644
--- a/blackmagic-10.11.4a9/blackmagic_lib.c
+++ b/blackmagic-10.11.4a9/blackmagic_lib.c
@@ -74,8 +74,14 @@
const unsigned int bmd_page_shift = PAGE_SHIFT;
const unsigned int bmd_page_size = PAGE_SIZE;
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
+const int bmd_verify_read = NULL;
+const int bmd_verify_write = NULL;
+#else
const int bmd_verify_read = VERIFY_READ;
const int bmd_verify_write = VERIFY_WRITE;
+#endif
const char *DL_KERN_INFO = KERN_INFO;
const char *DL_KERN_WARNING = KERN_WARNING;
@@ -353,7 +359,14 @@ dl_uptime(void)
inline unsigned long long dl_get_time_us()
{
struct timeval t;
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
+ struct timespec64 ts;
+ ktime_get_real_ts64(&ts);
+ t.tv_sec = ts.tv_sec;
+ t.tv_usec = ts.tv_nsec / 1000;
+ #else
do_gettimeofday(&t);
+ #endif
return (t.tv_sec * USEC_PER_SEC + t.tv_usec);
}
@@ -635,7 +648,12 @@ __dl_copy_to_user(void *to, const void *from, unsigned long n)
inline int
dl_access_ok(int type, void *addr, unsigned long size)
{
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
+ (void) type;
+ return access_ok(addr, size);
+ #else
return access_ok(type, addr, size);
+ #endif
}
void *
@@ -803,7 +821,9 @@ dl_poll_wait(void *filp, struct dl_wait_queue_head_t *queue, void *wait, int wri
inline void
dl_kernel_fpu_begin()
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
+ preempt_disable();
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
preempt_disable();
__kernel_fpu_begin();
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0) || RHEL_RELEASE_OR_LATER(6, 10)
@@ -845,7 +865,9 @@ dl_kernel_fpu_begin()
inline void dl_kernel_fpu_end(void)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
+ preempt_enable();
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
__kernel_fpu_end();
preempt_enable();
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0) || RHEL_RELEASE_OR_LATER(6, 10)
diff --git a/blackmagic-io-10.11.4a9/bm_util.c b/blackmagic-io-10.11.4a9/bm_util.c
index 428605b..b58df1d 100644
--- a/blackmagic-io-10.11.4a9/bm_util.c
+++ b/blackmagic-io-10.11.4a9/bm_util.c
@@ -833,7 +833,12 @@ void bm_event_wakeup(void* event, bool one)
// User IO
unsigned long bm_access_ok(unsigned int type, void* addr, size_t size)
{
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
+ (void) type;
+ return access_ok(addr, size);
+ #else
return access_ok(type, addr, size);
+ #endif
}
unsigned long bm_copy_to_user(void *to, const void *from, unsigned len)
@@ -900,7 +905,9 @@ void bm_iowrite32be(uint32_t val, volatile void* addr)
void bm_fpu_begin(void)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
+ preempt_disable();
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
preempt_disable();
__kernel_fpu_begin();
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0) || RHEL_RELEASE_OR_LATER(6, 10)
@@ -942,7 +949,9 @@ void bm_fpu_begin(void)
void bm_fpu_end(void)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
+ preempt_enable();
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
__kernel_fpu_end();
preempt_enable();
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0) || RHEL_RELEASE_OR_LATER(6, 10)
--
2.21.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment