summaryrefslogtreecommitdiffstats
path: root/meta/recipes-graphics/tslib/tslib/32bitBE-support.patch
blob: 49232ef6e9550aaf8a2dfb31e2d50855b0caccac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#! /bin/sh /usr/share/dpatch/dpatch-run
## 030-32bitBE-support.dpatch by Neil Williams <codehelp@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: See bug #496759 - being tested upstream for 32bit BE devices

@DPATCH@

Upstream-Status: Pending

diff -urNad tslib-1.0~/plugins/input-raw.c tslib-1.0/plugins/input-raw.c
--- tslib-1.0~/plugins/input-raw.c	2008-12-09 10:56:47.000000000 +0000
+++ tslib-1.0/plugins/input-raw.c	2008-12-09 11:05:41.000000000 +0000
@@ -44,25 +44,33 @@
 	int	using_syn;
 };
 
+#define BITS_PER_LONG	(sizeof(long) * 8)
+#ifndef EV_CNT
+#define EV_CNT	(EV_MAX+1)
+#endif
+#ifndef ABS_CNT
+#define ABS_CNT	(ABS_MAX+1)
+#endif
+
 static int check_fd(struct tslib_input *i)
 {
 	struct tsdev *ts = i->module.dev;
 	int version;
-	u_int32_t bit;
-	u_int64_t absbit;
+	unsigned long bit[EV_CNT / BITS_PER_LONG + 1];
+	unsigned long absbit[ABS_MAX / BITS_PER_LONG + 1];
 
 	if (! ((ioctl(ts->fd, EVIOCGVERSION, &version) >= 0) &&
 		(version == EV_VERSION) &&
-		(ioctl(ts->fd, EVIOCGBIT(0, sizeof(bit) * 8), &bit) >= 0) &&
-		(bit & (1 << EV_ABS)) &&
-		(ioctl(ts->fd, EVIOCGBIT(EV_ABS, sizeof(absbit) * 8), &absbit) >= 0) &&
-		(absbit & (1 << ABS_X)) &&
-		(absbit & (1 << ABS_Y)) && (absbit & (1 << ABS_PRESSURE)))) {
+		(ioctl(ts->fd, EVIOCGBIT(0, sizeof(bit)), bit) >= 0) &&
+		(bit[0] & (1 << EV_ABS)) &&
+		(ioctl(ts->fd, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit) >= 0) &&
+		(absbit[0] & (1 << ABS_X)) &&
+		(absbit[0] & (1 << ABS_Y)) && (absbit[0] & (1 << ABS_PRESSURE)))) {
 		fprintf(stderr, "selected device is not a touchscreen I understand\n");
 		return -1;
 	}
 
-	if (bit & (1 << EV_SYN))
+	if (bit[0] & (1 << EV_SYN))
 		i->using_syn = 1;
 
 	return 0;