dvb/linuxtv-dvb-apps/debian/patches 03_budget_ci_loadkeys.dpatch 00list
Thomas Schmidt
pkg-vdr-dvb-changes@lists.alioth.debian.org
Sat, 16 Oct 2004 08:09:20 +0000
Update of /cvsroot/pkg-vdr-dvb/dvb/linuxtv-dvb-apps/debian/patches
In directory haydn:/tmp/cvs-serv30695/dvb/linuxtv-dvb-apps/debian/patches
Modified Files:
00list
Added Files:
03_budget_ci_loadkeys.dpatch
Log Message:
* added the patch from Darren Salt to add the budget_ci_loadkeys-tool (closes: #276082)
Index: 00list
===================================================================
RCS file: /cvsroot/pkg-vdr-dvb/dvb/linuxtv-dvb-apps/debian/patches/00list,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- 00list 28 Sep 2004 13:54:56 -0000 1.2
+++ 00list 16 Oct 2004 08:09:18 -0000 1.3
@@ -1,2 +1,3 @@
01_README.scan
02_av7110_loadkeys-BTN
+03_budget_ci_loadkeys
--- NEW FILE: 03_budget_ci_loadkeys.dpatch ---
#! /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/av7110_loadkeys.c.orig /tmp/dpep.HGK2iu/linuxtv-dvb-apps/util/av7110_loadkeys/av7110_loadkeys.c.orig
--- linuxtv-dvb-apps/util/av7110_loadkeys/av7110_loadkeys.c.orig 1970-01-01 01:00:00.000000000 +0100
+++ /tmp/dpep.HGK2iu/linuxtv-dvb-apps/util/av7110_loadkeys/av7110_loadkeys.c.orig 2004-05-14 12:32:12.000000000 +0200
@@ -0,0 +1,186 @@
+#include <asm/types.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <ctype.h>
+#include <string.h>
+
+#include "input_keynames.h"
+
+
+static
+void print_error (const char *action, const char *file)
+__attribute__ ((noreturn));
+
+
+static
+void print_error (const char *action, const char *file)
+{
+ static const char msg [] = "\nERROR: could not ";
+
+ write (0, msg, strlen(msg));
+ write (0, action, strlen(action));
+ write (0, " '", 2);
+ write (0, file, strlen(file));
+ write (0, "'\n\n", 3);
+ exit (-1);
+}
+
+
+static
+int parse_keyname (char *pos, char **nend, int limit)
+{
+ int cmp, index;
+ int l = 1;
+ int r = sizeof (key_name) / sizeof (key_name[0]);
+
+ if (limit < 5)
+ return -1;
+
+ while ((*pos == ' ' || *pos == '\t') && limit > 0) {
+ (*nend)++;
+ pos++;
+ limit--;
+ }
+
+ if (pos [0] != 'K' || pos[1] != 'E' || pos[2] != 'Y' || pos[3] != '_')
+ return -2;
+
+ (*nend) += 4;
+ pos += 4;
+ limit -= 4;
+
+ while (r >= l) {
+ int len0, len1 = 0;
+
+ index = (l + r) / 2;
+
+ len0 = strlen(key_name[index-1].name);
+
+ while (len1 < limit && isgraph(pos[len1]))
+ len1++;
+
+ cmp = strncmp (key_name[index-1].name, pos,
+ strlen(key_name[index-1].name));
+
+ if (len0 < len1 && cmp == 0)
+ cmp = -1;
+
+ if (cmp == 0) {
+ *nend = pos + strlen (key_name[index-1].name);
+
+ if (**nend != '\n' &&
+ **nend != '\t' &&
+ **nend != ' ' &&
+ *nend != pos)
+ return -3;
+
+ return key_name[index-1].key;
+ }
+
+ if (cmp < 0)
+ l = index + 1;
+ else
+ r = index - 1;
+
+ if (r < l) {
+ static const char msg [] = "\nunknown key '";
+ write (0, msg, strlen(msg));
+ write (0, pos-4, len1 + 4);
+ write (0, "'\n", 2);
+ }
+ };
+
+ return -4;
+}
+
+
+
+const char usage [] = "\n\tusage: av7110_loadkeys [-i|--invert] [-a|--address <num>] keymap_filename.(rc5|rcmm)\n\n";
+
+
+struct ir_setup {
+ __u32 ir_config;
+ __u16 keytab [256];
+} __attribute__ ((packed));
+
+
+int main (int argc, char **argv)
+{
+ static struct ir_setup setup;
+ int i, fd;
+ size_t len;
+ char *buf, *pos, *fname = NULL;
+
+ for (i=1; i<argc; i++) {
+ 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) {
+ setup.ir_config |= (atoi(argv[i]) & 0xff) << 16;
+ setup.ir_config |= 0x4000;
+ }
+ } else
+ fname = argv[i];
+ }
+
+ if (!fname) {
+ write (0, usage, strlen(usage));
+ exit (-1);
+ }
+
+ if (strncmp(".rcmm", fname + strlen(fname) - 5, 5) == 0)
+ setup.ir_config |= 0x0001;
+ else if (strncmp(".rc5", fname + strlen(fname) - 4, 4) != 0) {
+ const char msg [] = "\nERROR: "
+ "input filename must have suffix .rc5 or .rcmm\n";
+ write (0, msg, strlen(msg));
+ exit (-1);
+ }
+
+ if ((fd = open (fname, O_RDONLY)) < 0)
+ print_error ("open", fname);
+
+ len = lseek (fd, 0, SEEK_END);
+
+ if (!(pos = buf = mmap (NULL, len, PROT_READ, MAP_PRIVATE, fd, 0)))
+ print_error ("mmap", fname);
+
+ while (pos < buf + len) {
+ int key, keycode;
+
+ while (!isxdigit(*pos) && pos < buf + len)
+ pos++;
+
+ if (pos == buf + len)
+ break;
+
+ 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";
+
+ write (0, msg, strlen(msg));
+ exit (-1);
+ }
+
+ if (keycode < 0)
+ print_error ("parse", fname);
+
+ setup.keytab[key] = keycode;
+ }
+
+ munmap (buf, len);
+ close (fd);
+
+ write (1, &setup, 4 + 256 * sizeof(__u16));
+
+ 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
diff -urNad linuxtv-dvb-apps/util/av7110_loadkeys/Makefile.orig /tmp/dpep.HGK2iu/linuxtv-dvb-apps/util/av7110_loadkeys/Makefile.orig
--- linuxtv-dvb-apps/util/av7110_loadkeys/Makefile.orig 1970-01-01 01:00:00.000000000 +0100
+++ /tmp/dpep.HGK2iu/linuxtv-dvb-apps/util/av7110_loadkeys/Makefile.orig 2004-05-14 12:32:12.000000000 +0200
@@ -0,0 +1,48 @@
+CC = gcc
+CFLAGS = -g -Wall -O2
+
+all: av7110_loadkeys evtest
+
+av7110_loadkeys: av7110_loadkeys.o
+
+evtest: evtest.o
+
+av7110_loadkeys.o: av7110_loadkeys.c input_keynames.h
+
+evtest.o: evtest.c input_keynames.h
+
+
+input_keynames.h: /usr/include/linux/input.h input_fake.h
+ @echo 'generate $@...'
+ @echo '#ifndef __INPUT_KEYNAMES_H__' > $@
+ @echo '#define __INPUT_KEYNAMES_H__' >> $@
+ @echo '' >> $@
+ @echo '#include <linux/input.h>' >> $@
+ @echo '' >> $@
+ @echo '#if !defined(KEY_OK)' >> $@
+ @echo '#include "input_fake.h"' >> $@
+ @echo '#endif' >> $@
+ @echo '' >> $@
+ @echo '' >> $@
+ @echo 'struct input_key_name {' >> $@
+ @echo ' const char *name;' >> $@
+ @echo ' int key;' >> $@
+ @echo '};' >> $@
+ @echo '' >> $@
+ @echo '' >> $@
+ @echo 'static struct input_key_name key_name [] = {' >> $@
+ @for x in `cat /usr/include/linux/input.h input_fake.h | \
+ grep KEY_ | grep "#define" | grep -v KEY_MAX | \
+ cut -f 1 | cut -f 2 -d ' ' | sort | uniq` ; do \
+ echo " { \"`echo $$x | cut -b 5-`\", $$x }," >> $@ \
+ ; \
+ done
+ @echo '};' >> $@
+ @echo '' >> $@
+ @echo '#endif /* __INPUT_KEYNAMES_H */' >> $@
+ @echo '' >> $@
+
+
+clean:
+ $(RM) core* *.o input_keynames.h av7110_loadkeys evtest
+