aboutsummaryrefslogtreecommitdiffstats
path: root/debian/patches/03_budget_ci_loadkeys.dpatch
blob: 5a72efbb894722d57c1ec82b807ee0c64f0b1457 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#! /bin/sh /usr/share/dpatch/dpatch-run
## 03_budget_ci_loadkeys.dpatch by Thomas Schmidt <thomas.schmidt@in.stud.tu-ilmenau.de>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: adds the utility budget_ci_loadkeys

@DPATCH@
diff -urNad linuxtv-dvb-apps/util/av7110_loadkeys/av7110_loadkeys.c /tmp/dpep.HGK2iu/linuxtv-dvb-apps/util/av7110_loadkeys/av7110_loadkeys.c
--- linuxtv-dvb-apps/util/av7110_loadkeys/av7110_loadkeys.c	2004-05-14 12:32:12.000000000 +0200
+++ /tmp/dpep.HGK2iu/linuxtv-dvb-apps/util/av7110_loadkeys/av7110_loadkeys.c	2004-10-16 09:59:28.000000000 +0200
@@ -1,5 +1,6 @@
 #include <asm/types.h>
 #include <stdlib.h>
+#include <stdio.h>
 #include <unistd.h>
 #include <sys/mman.h>
 #include <sys/types.h>
@@ -99,12 +100,20 @@
 
 
 
+#ifdef HW_MSP430
+const char usage [] = "\n\tusage: budget_ci_loadkeys keymap_filename.rc5\n\n";
+#else
 const char usage [] = "\n\tusage: av7110_loadkeys [-i|--invert] [-a|--address <num>] keymap_filename.(rc5|rcmm)\n\n";
-
+#endif
 
 struct ir_setup {
+#ifdef HW_MSP430
+#define KEYTAB_SIZE 64
+#else
+#define KEYTAB_SIZE 256
 	__u32 ir_config;
-	__u16 keytab [256];
+#endif
+	__u16 keytab [KEYTAB_SIZE];
 } __attribute__ ((packed));
 
 
@@ -116,7 +125,10 @@
 	char *buf, *pos, *fname = NULL;
 
 	for (i=1; i<argc; i++) {
+#ifndef HW_MSP430
+		/* AV7110 only; not MSP430 */
 		if (!strcmp("-i", argv[i]) || !strcmp("--invert", argv[i]))
+			
 			setup.ir_config |= 0x8000;
 		else if (!strcmp("-a", argv[i]) || !strcmp("--address", argv[i])) {
 			if (++i < argc) {
@@ -124,6 +136,7 @@
 				setup.ir_config |= 0x4000;
 			}
 		} else
+#endif
 			fname = argv[i];
 	}
 
@@ -132,6 +145,14 @@
 		exit (-1);
 	}
 
+#ifdef HW_MSP430
+	if (strncmp(".rc5", fname + strlen(fname) - 4, 4) != 0) {
+		const char msg [] = "\nERROR: "
+			"input filename must have suffix .rc5\n";
+		write (0, msg, strlen(msg));
+		exit (-1);
+	}
+#else
 	if (strncmp(".rcmm", fname + strlen(fname) - 5, 5) == 0)
 		setup.ir_config |= 0x0001;
 	else if (strncmp(".rc5", fname + strlen(fname) - 4, 4) != 0) {
@@ -140,6 +161,7 @@
 		write (0, msg, strlen(msg));
 		exit (-1);
 	}
+#endif
 
 	if ((fd = open (fname, O_RDONLY)) < 0)
 		print_error ("open", fname);
@@ -161,9 +183,11 @@
 		key = strtol (pos, &pos, 0);
 		keycode = parse_keyname (pos, &pos, buf + len - pos);
 
-		if (key < 0 || key > 0xff) {
-			const char msg [] = 
-				"\nERROR: key must be in range 0 ... 0xff!\n\n";
+		if (key < 0 || key >= KEYTAB_SIZE) {
+			char *msg;
+			asprintf (&msg,
+				"\nERROR: key must be in range 0 ... 0x%02x!\n\n",
+				KEYTAB_SIZE);
 
 			write (0, msg, strlen(msg));
 			exit (-1);
@@ -178,7 +202,7 @@
 	munmap (buf, len);
 	close (fd);
 
-	write (1, &setup, 4 + 256 * sizeof(__u16));
+	write (1, &setup, sizeof (setup));
 
 	return 0;
 }
diff -urNad linuxtv-dvb-apps/util/av7110_loadkeys/Makefile /tmp/dpep.HGK2iu/linuxtv-dvb-apps/util/av7110_loadkeys/Makefile
--- linuxtv-dvb-apps/util/av7110_loadkeys/Makefile	2004-05-14 12:32:12.000000000 +0200
+++ /tmp/dpep.HGK2iu/linuxtv-dvb-apps/util/av7110_loadkeys/Makefile	2004-10-16 09:59:27.000000000 +0200
@@ -1,14 +1,23 @@
 CC = gcc
-CFLAGS = -g -Wall -O2
+CFLAGS = -g -Wall -O2 -D_GNU_SOURCE
 
-all: av7110_loadkeys evtest
+all: av7110_loadkeys budget_ci_loadkeys evtest
 
 av7110_loadkeys: av7110_loadkeys.o
 
+budget_ci_loadkeys: budget_ci_loadkeys.o
+
 evtest: evtest.o
 
+av7110_loadkeys.o: CFLAGS += -UHW_MSP430
 av7110_loadkeys.o: av7110_loadkeys.c input_keynames.h
 
+budget_ci_loadkeys.c: av7110_loadkeys.c
+	ln av7110_loadkeys.c budget_ci_loadkeys.c
+
+budget_ci_loadkeys.o: CFLAGS += -DHW_MSP430
+budget_ci_loadkeys.o: budget_ci_loadkeys.c input_keynames.h
+
 evtest.o: evtest.c input_keynames.h
 
 
@@ -44,5 +53,6 @@
 
 
 clean:
-	$(RM) core* *.o input_keynames.h av7110_loadkeys evtest
+	$(RM) core* *.o input_keynames.h av7110_loadkeys budget_ci_loadkeys \
+		 budget_ci_loadkeys.c evtest