Advertisement
jpenguin

akvcam-compile_kernel_5_6_0.diff

Apr 7th, 2020
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.43 KB | None | 0 0
  1. diff --git a/src/events.c b/src/events.c
  2. index d9b0ca0..b9c6f32 100644
  3. --- a/src/events.c
  4. +++ b/src/events.c
  5. @@ -140,6 +140,9 @@ bool akvcam_events_enqueue(akvcam_events_t self,
  6.                             const struct v4l2_event *event)
  7.  {
  8.      struct v4l2_event *qevent;
  9. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
  10. +    struct timespec64 ts;
  11. +#endif
  12.  
  13.      if (event->type != V4L2_EVENT_FRAME_SYNC) {
  14.          // Check if someone is subscribed to this event.
  15. @@ -153,7 +156,13 @@ bool akvcam_events_enqueue(akvcam_events_t self,
  16.  
  17.      qevent = akvcam_rbuffer_queue(self->events, event);
  18.      qevent->sequence = self->sequence++;
  19. +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0)
  20.      ktime_get_ts(&qevent->timestamp);
  21. +#else
  22. +    ktime_get_ts64(&ts);
  23. +    qevent->timestamp.tv_sec = ts.tv_sec;
  24. +    qevent->timestamp.tv_nsec = ts.tv_nsec;
  25. +#endif
  26.      memset(&qevent->reserved, 0, 8 * sizeof(__u32));
  27.  
  28.      // Inform about the new event.
  29. diff --git a/src/utils.c b/src/utils.c
  30. index 06390f0..4465322 100644
  31. --- a/src/utils.c
  32. +++ b/src/utils.c
  33. @@ -273,6 +273,7 @@ void akvcam_replace(char *str, char from, char to)
  34.              *str = to;
  35.  }
  36.  
  37. +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0)
  38.  void akvcam_get_timestamp(struct timeval *tv)
  39.  {
  40.      struct timespec ts;
  41. @@ -280,3 +281,12 @@ void akvcam_get_timestamp(struct timeval *tv)
  42.      tv->tv_sec = ts.tv_sec;
  43.      tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC;
  44.  }
  45. +#else
  46. +void akvcam_get_timestamp(struct __kernel_v4l2_timeval *tv)
  47. +{
  48. +    struct timespec64 ts;
  49. +    ktime_get_ts64(&ts);
  50. +    tv->tv_sec = ts.tv_sec;
  51. +    tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC;
  52. +}
  53. +#endif
  54. diff --git a/src/utils.h b/src/utils.h
  55. index 15671bd..a2d24c0 100644
  56. --- a/src/utils.h
  57. +++ b/src/utils.h
  58. @@ -21,6 +21,9 @@
  59.  
  60.  #include <linux/types.h>
  61.  #include <linux/version.h>
  62. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
  63. +#include <linux/videodev2.h>
  64. +#endif
  65.  
  66.  #define UNUSED(x) (void)(x)
  67.  #define AKVCAM_MAX_STRING_SIZE 1024
  68. @@ -98,6 +101,10 @@ char *akvcam_strip_str_sub(const char *str,
  69.  char *akvcam_strip_move_str(char *str, AKVCAM_MEMORY_TYPE type);
  70.  size_t akvcam_str_count(const char *str, char c);
  71.  void akvcam_replace(char *str, char from, char to);
  72. +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0)
  73.  void akvcam_get_timestamp(struct timeval *tv);
  74. +#else
  75. +void akvcam_get_timestamp(struct __kernel_v4l2_timeval *tv);
  76. +#endif
  77.  
  78.  #endif // AKVCAM_UTILS_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement