aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2010-11-08 18:21:02 (GMT)
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-11-08 18:22:38 (GMT)
commit2edbfefcdfce7e10ebd844a63a78b69c3d423c83 (patch)
tree376f8133a2cd041aa3037bfa3ab849b424080b49
parentd3d94b467eeb5fac10f38041ad44fd843ffca6bf (diff)
keytable: Move find logic to gen_keytables.pl
Instead of using shell commands, at Makefile, move the logic to happen inside gen_keytables.pl. This will allow adding another parsing logic there, based on the read of include/media/rc-map.h. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--utils/keytable/Makefile23
-rwxr-xr-xutils/keytable/gen_keytables.pl57
2 files changed, 55 insertions, 25 deletions
diff --git a/utils/keytable/Makefile b/utils/keytable/Makefile
index e770ca9..2f241ad 100644
--- a/utils/keytable/Makefile
+++ b/utils/keytable/Makefile
@@ -1,24 +1,5 @@
TARGETS = ir-keytable
-IR_FILES = "drivers/media/dvb/dvb-usb/a800.c \
-drivers/media/dvb/dvb-usb/af9005-remote.c \
-drivers/media/dvb/dvb-usb/af9015.c \
-drivers/media/dvb/dvb-usb/af9015.h \
-drivers/media/dvb/dvb-usb/anysee.c \
-drivers/media/dvb/dvb-usb/cinergyT2-core.c \
-drivers/media/dvb/dvb-usb/cxusb.c \
-drivers/media/dvb/dvb-usb/dibusb-common.c \
-drivers/media/dvb/dvb-usb/digitv.c \
-drivers/media/dvb/dvb-usb/dtt200u.c \
-drivers/media/dvb/dvb-usb/dvb-usb-remote.c \
-drivers/media/dvb/dvb-usb/dvb-usb.h \
-drivers/media/dvb/dvb-usb/dw2102.c \
-drivers/media/dvb/dvb-usb/m920x.c \
-drivers/media/dvb/dvb-usb/nova-t-usb2.c \
-drivers/media/dvb/dvb-usb/opera1.c \
-drivers/media/dvb/dvb-usb/vp702x.c \
-drivers/media/dvb/dvb-usb/vp7045.c "
-
all: $(TARGETS)
-include *.d
@@ -46,9 +27,9 @@ sync-with-kernel:
@printf "\t{ NULL, 0}\n};\n" >>parse.h
@-mkdir -p rc_keymaps
+ @cp rc_maps.cfg.example rc_maps.cfg
@echo storing existing keymaps at rc_keymaps/
- @for i in $(KERNEL_DIR)/drivers/media/IR/keymaps/*.c; do echo $$i;./gen_keytables.pl $$i; done
- @for i in `echo $(IR_FILES)`; do echo $$i;./gen_keytables.pl $(KERNEL_DIR)/$$i; done
+ @./gen_keytables.pl $(KERNEL_DIR);
install: $(TARGETS)
mkdir -p $(DESTDIR)$(PREFIX)/bin $(DESTDIR)/etc
diff --git a/utils/keytable/gen_keytables.pl b/utils/keytable/gen_keytables.pl
index 06400bb..3dfce0f 100755
--- a/utils/keytable/gen_keytables.pl
+++ b/utils/keytable/gen_keytables.pl
@@ -1,19 +1,43 @@
#!/usr/bin/perl
use strict;
+use File::Find;
+my @ir_files = (
+ "drivers/media/dvb/dvb-usb/a800.c",
+ "drivers/media/dvb/dvb-usb/af9005-remote.c",
+ "drivers/media/dvb/dvb-usb/af9015.c",
+ "drivers/media/dvb/dvb-usb/af9015.h",
+ "drivers/media/dvb/dvb-usb/anysee.c",
+ "drivers/media/dvb/dvb-usb/cinergyT2-core.c",
+ "drivers/media/dvb/dvb-usb/cxusb.c",
+ "drivers/media/dvb/dvb-usb/dibusb-common.c",
+ "drivers/media/dvb/dvb-usb/digitv.c",
+ "drivers/media/dvb/dvb-usb/dtt200u.c",
+ "drivers/media/dvb/dvb-usb/dvb-usb-remote.c",
+ "drivers/media/dvb/dvb-usb/dvb-usb.h",
+ "drivers/media/dvb/dvb-usb/dw2102.c",
+ "drivers/media/dvb/dvb-usb/m920x.c",
+ "drivers/media/dvb/dvb-usb/nova-t-usb2.c",
+ "drivers/media/dvb/dvb-usb/opera1.c",
+ "drivers/media/dvb/dvb-usb/vp702x.c",
+ "drivers/media/dvb/dvb-usb/vp7045.c",
+);
+
+my $debug = 1;
my $dir="rc_keymaps";
my $deftype = "UNKNOWN";
my $keyname="";
-my $debug=0;
my $out;
my $read=0;
my $type = $deftype;
my $check_type = 0;
my $name;
my $warn;
+my $warn_all;
+
+my $kernel_dir = shift or die "Need a file name to proceed.";
-my $file = shift or die "Need a file name to proceed.";
sub flush()
{
return if (!$keyname || !$out);
@@ -37,7 +61,10 @@ sub parse_file($)
{
my $filename = shift;
- open IN, "<$filename";
+ $warn = 0;
+
+ printf "processing file $filename\n" if ($debug);
+ open IN, "<$filename" or die "couldn't find $filename";
while (<IN>) {
if (m/struct\s+ir_scancode\s+(\w[\w\d_]+)/) {
flush();
@@ -82,6 +109,28 @@ sub parse_file($)
flush();
printf STDERR "WARNING: keyboard name not found on %d tables at file $filename\n", $warn if ($warn);
+
+ $warn_all += $warn;
+}
+
+sub parse_dir()
+{
+ my $file = $File::Find::name;
+
+ return if ($file =~ m/^\./);
+
+ return if (! ($file =~ m/\.c$/));
+
+ parse_file $file;
+}
+
+# Main logic
+#
+
+find({wanted => \&parse_dir, no_chdir => 1}, "$kernel_dir/drivers/media/IR/keymaps");
+
+foreach my $file (@ir_files) {
+ parse_file "$kernel_dir/$file";
}
-parse_file $file;
+printf STDERR "WARNING: there are %d tables not defined at rc_maps.h\n", $warn_all if ($warn_all);

Privacy Policy