From 2bfdc9840c571dfb50fa7e8ac1934d87dd4d6ca8 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Fri, 24 Jul 2020 13:59:47 +0000
Subject: [PATCH] community/directfb: time64 build fix

---
 ...ld-on-32bit-arches-with-64bit-time_t.patch | 139 ++++++++++++++++++
 community/directfb/APKBUILD                   |   6 +-
 2 files changed, 143 insertions(+), 2 deletions(-)
 create mode 100644 community/directfb/0001-Fix-build-on-32bit-arches-with-64bit-time_t.patch

diff --git a/community/directfb/0001-Fix-build-on-32bit-arches-with-64bit-time_t.patch b/community/directfb/0001-Fix-build-on-32bit-arches-with-64bit-time_t.patch
new file mode 100644
index 000000000000..2f766465e1c2
--- /dev/null
+++ b/community/directfb/0001-Fix-build-on-32bit-arches-with-64bit-time_t.patch
@@ -0,0 +1,139 @@
+From 0b66557f2e924023b12006b58d8e86149c745aed Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sat, 30 Nov 2019 20:34:33 -0800
+Subject: [PATCH] Fix build on 32bit arches with 64bit time_t
+
+time element is deprecated on new input_event structure in kernel's
+input.h [1]
+
+[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=152194fe9c3f
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ inputdrivers/linux_input/linux_input.c | 36 ++++++++++++++++++--------
+ 1 file changed, 25 insertions(+), 11 deletions(-)
+
+diff --git a/inputdrivers/linux_input/linux_input.c b/inputdrivers/linux_input/linux_input.c
+index 7e9a6ad..03deebc 100644
+--- a/inputdrivers/linux_input/linux_input.c
++++ b/inputdrivers/linux_input/linux_input.c
+@@ -42,6 +42,11 @@ typedef unsigned long kernel_ulong_t;
+ 
+ #include <linux/input.h>
+ 
++#ifndef input_event_sec
++#define input_event_sec time.tv_sec
++#define input_event_usec time.tv_usec
++#endif
++
+ #ifndef KEY_OK
+ /* Linux kernel 2.5.42+ defines additional keys in linux/input.h */
+ #include "input_fake.h"
+@@ -754,7 +759,8 @@ translate_event( const LinuxInputData     *data,
+                  DFBInputEvent            *devt )
+ {
+      devt->flags     = DIEF_TIMESTAMP;
+-     devt->timestamp = levt->time;
++     devt->timestamp.tv_sec = levt->input_event_sec;
++     devt->timestamp.tv_usec = levt->input_event_usec;
+ 
+      switch (levt->type) {
+           case EV_KEY:
+@@ -2139,7 +2145,8 @@ touchpad_translate( struct touchpad_fsm_state *state,
+      int abs, rel;
+ 
+      devt->flags     = DIEF_TIMESTAMP | (dfb_config->linux_input_touch_abs ? DIEF_AXISABS : DIEF_AXISREL);
+-     devt->timestamp = levt->time;
++     devt->timestamp.tv_sec = levt->input_event_sec;
++     devt->timestamp.tv_usec = levt->input_event_usec;
+      devt->type      = DIET_AXISMOTION;
+ 
+      switch (levt->code) {
+@@ -2204,7 +2211,7 @@ touchpad_fsm( struct touchpad_fsm_state *state,
+               DFBInputEvent             *devt )
+ {
+      struct timeval timeout = { 0, 125000 };
+-
++     struct timeval tval;
+      /* select() timeout? */
+      if (!levt) {
+           /* Check if button release is due. */
+@@ -2223,6 +2230,8 @@ touchpad_fsm( struct touchpad_fsm_state *state,
+           return 0;
+      }
+ 
++     tval.tv_sec = levt->input_event_sec;
++     tval.tv_usec = levt->input_event_usec;
+      /* More or less ignore these events for now */
+      if ((levt->type == EV_SYN && levt->code == SYN_REPORT) ||
+          (levt->type == EV_ABS && levt->code == ABS_PRESSURE) ||
+@@ -2233,7 +2242,7 @@ touchpad_fsm( struct touchpad_fsm_state *state,
+ 
+           /* Check if button release is due. */
+           if (state->fsm_state == TOUCHPAD_FSM_DRAG_START &&
+-              timeout_passed( &state->timeout, &levt->time )) {
++              timeout_passed( &state->timeout, &tval )) {
+                devt->flags     = DIEF_TIMESTAMP;
+                devt->timestamp = state->timeout; /* timeout of levt->time? */
+                devt->type      = DIET_BUTTONRELEASE;
+@@ -2255,7 +2264,8 @@ touchpad_fsm( struct touchpad_fsm_state *state,
+      case TOUCHPAD_FSM_START:
+           if (touchpad_finger_landing( levt )) {
+                state->fsm_state = TOUCHPAD_FSM_MAIN;
+-               state->timeout = levt->time;
++               state->timeout.tv_sec = levt->input_event_sec;
++               state->timeout.tv_usec = levt->input_event_usec;
+                timeout_add( &state->timeout, &timeout );
+           }
+           return 0;
+@@ -2268,15 +2278,17 @@ touchpad_fsm( struct touchpad_fsm_state *state,
+                }
+           }
+           else if (touchpad_finger_leaving( levt )) {
+-               if (!timeout_passed( &state->timeout, &levt->time )) {
++               if (!timeout_passed( &state->timeout, &tval )) {
+                     devt->flags     = DIEF_TIMESTAMP;
+-                    devt->timestamp = levt->time;
++                    devt->timestamp.tv_sec = levt->input_event_sec;
++                    devt->timestamp.tv_usec = levt->input_event_usec;
+                     devt->type      = DIET_BUTTONPRESS;
+                     devt->button    = DIBI_FIRST;
+ 
+                     touchpad_fsm_init( state );
+                     state->fsm_state = TOUCHPAD_FSM_DRAG_START;
+-                    state->timeout = levt->time;
++                    state->timeout.tv_sec = levt->input_event_sec;
++                    state->timeout.tv_usec = levt->input_event_usec;
+                     timeout_add( &state->timeout, &timeout );
+                     return 1;
+                }
+@@ -2287,7 +2299,7 @@ touchpad_fsm( struct touchpad_fsm_state *state,
+           return 0;
+ 
+      case TOUCHPAD_FSM_DRAG_START:
+-          if (timeout_passed( &state->timeout, &levt->time )){
++          if (timeout_passed( &state->timeout, &tval )){
+                devt->flags     = DIEF_TIMESTAMP;
+                devt->timestamp = state->timeout; /* timeout of levt->time? */
+                devt->type      = DIET_BUTTONRELEASE;
+@@ -2299,7 +2311,8 @@ touchpad_fsm( struct touchpad_fsm_state *state,
+           else {
+                if (touchpad_finger_landing( levt )) {
+                     state->fsm_state = TOUCHPAD_FSM_DRAG_MAIN;
+-                    state->timeout = levt->time;
++                    state->timeout.tv_sec = levt->input_event_sec;
++                    state->timeout.tv_usec = levt->input_event_usec;
+                     timeout_add( &state->timeout, &timeout );
+                }
+           }
+@@ -2314,7 +2327,8 @@ touchpad_fsm( struct touchpad_fsm_state *state,
+           }
+           else if (touchpad_finger_leaving( levt )) {
+                devt->flags     = DIEF_TIMESTAMP;
+-               devt->timestamp = levt->time;
++               devt->timestamp.tv_sec = levt->input_event_sec;
++               devt->timestamp.tv_usec = levt->input_event_usec;
+                devt->type      = DIET_BUTTONRELEASE;
+                devt->button    = DIBI_FIRST;
+ 
diff --git a/community/directfb/APKBUILD b/community/directfb/APKBUILD
index 3b069d25d7fa..9362d43c40fd 100644
--- a/community/directfb/APKBUILD
+++ b/community/directfb/APKBUILD
@@ -2,7 +2,7 @@
 # Maintainer: Clayton Craft <clayton@craftyguy.net>
 pkgname=directfb
 pkgver=1.7.7
-pkgrel=2
+pkgrel=3
 pkgdesc="Library for hw graphics acceleration, input dev, windowing system on top of the Linux fb device"
 arch="all"
 url="https://github.com/DirectFB/directfb"
@@ -19,6 +19,7 @@ source="
 	0005-fix-tslib-configure.patch
 	0006-fix-client-gfx_state-initialisation.patch
 	0007-tslib-Automatically-detect-touchscreens-using-ts_setup.patch
+	0001-Fix-build-on-32bit-arches-with-64bit-time_t.patch
 	"
 
 prepare() {
@@ -59,4 +60,5 @@ bd1d0738c48411e8e065b8a250c1b31334ac65b26a8f6c91d5ad167a4d8fdac1de862c05940567e4
 d68002702f3521a71405bb403b874dced5b123a2de037c9eb05667123a578c0e9a9f13a822fd8d77e31a83f1e1cc8df1d8511f7d2f427688d5ef6ae0fff448c5  0004-disable-fusion_dispatch.patch
 c768ca7a4dae7fc0cd7d4fa559ab74adb6b5f21245e0f9b5d56af15b20effc04e6739e86d52d65c902c5e76ad72e966cd9db68f57a9bad11a004525825d443a4  0005-fix-tslib-configure.patch
 6b118928c2ebe58654e1bf32433b084f4dc150526eec1b53f9eb4b856aee25733bd8d6114fde973fcb64416e4146f458cdb75e5836d7507cf802b84e44544462  0006-fix-client-gfx_state-initialisation.patch
-43000c629eb24bd6b88d284dc010ea5a2a3facbf9498ab752127c25a890fd52b9a29a09d46264befea9fef19dcfe6f24d6cefa103a68d4c2ab185b6142a5c1b9  0007-tslib-Automatically-detect-touchscreens-using-ts_setup.patch"
+43000c629eb24bd6b88d284dc010ea5a2a3facbf9498ab752127c25a890fd52b9a29a09d46264befea9fef19dcfe6f24d6cefa103a68d4c2ab185b6142a5c1b9  0007-tslib-Automatically-detect-touchscreens-using-ts_setup.patch
+a21470281e7886ee37b0c1e49498e250a890894cee8ab6c5d46f563cd75c132d112d993e047ca0649b7cd545f07b5a6476e7027e56bcc9bd2350d282f01f71b3  0001-Fix-build-on-32bit-arches-with-64bit-time_t.patch"
-- 
GitLab