diff --git a/lirc-0.8.4-cvs-update.patch b/lirc-0.8.4-cvs-update.patch index 80e29e9..4c6ddb6 100644 --- a/lirc-0.8.4-cvs-update.patch +++ b/lirc-0.8.4-cvs-update.patch @@ -10,17 +10,424 @@ diff -Naurp lirc-0.8.4a.orig/daemons/hw_devinput.c lirc-0.8.4a.upd/daemons/hw_de hw.device); } #endif +diff -Naurp lirc-0.8.4a.orig/daemons/input_map.c lirc-0.8.4a.upd/daemons/input_map.c +--- lirc-0.8.4a.orig/daemons/input_map.c 1969-12-31 19:00:00.000000000 -0500 ++++ lirc-0.8.4a.upd/daemons/input_map.c 2008-12-08 17:51:33.087443731 -0500 +@@ -0,0 +1,58 @@ ++/* $Id: input_map.c,v 5.1 2008/10/26 15:10:17 lirc Exp $ */ ++ ++/**************************************************************************** ++ ** input_map.c ************************************************************* ++ **************************************************************************** ++ * ++ * input_map.c - button namespace derived from Linux input layer ++ * ++ * Copyright (C) 2008 Christoph Bartelmus ++ * ++ */ ++ ++#include ++#include ++ ++#include "input_map.h" ++ ++struct ++{ ++ char *name; ++ linux_input_code code; ++ ++} input_map[] = { ++#include "input_map.inc" ++ {NULL, 0} ++}; ++ ++int get_input_code(const char *name, linux_input_code *code) ++{ ++ int i; ++ ++ for(i=0; input_map[i].name != NULL; i++) ++ { ++ if(strcasecmp(name, input_map[i].name) == 0) ++ { ++ *code = input_map[i].code; ++ return i; ++ } ++ } ++ return -1; ++} ++ ++void fprint_namespace(FILE *f) ++{ ++ int i; ++ ++ for(i=0; input_map[i].name != NULL; i++) ++ { ++ fprintf(stdout, "%s\n", input_map[i].name); ++ } ++} ++ ++int is_in_namespace(const char *name) ++{ ++ linux_input_code dummy; ++ ++ return get_input_code(name, &dummy) == -1 ? 0 : 1; ++} +diff -Naurp lirc-0.8.4a.orig/daemons/input_map.h lirc-0.8.4a.upd/daemons/input_map.h +--- lirc-0.8.4a.orig/daemons/input_map.h 1969-12-31 19:00:00.000000000 -0500 ++++ lirc-0.8.4a.upd/daemons/input_map.h 2008-12-08 17:51:33.106519735 -0500 +@@ -0,0 +1,35 @@ ++/* $Id: input_map.h,v 5.1 2008/10/26 15:10:17 lirc Exp $ */ ++ ++/**************************************************************************** ++ ** input_map.h ************************************************************* ++ **************************************************************************** ++ * ++ * input_map.h - button namespace derived from Linux input layer ++ * ++ * Copyright (C) 2008 Christoph Bartelmus ++ * ++ */ ++ ++#ifndef INPUT_MAP_H ++#define INPUT_MAP_H ++ ++#include ++#include ++#include ++ ++#if defined __linux__ ++#include ++#include ++#endif ++ ++#if defined __linux__ ++typedef __u16 linux_input_code; ++#else ++typedef unsigned short linux_input_code; ++#endif ++ ++int get_input_code(const char *name, linux_input_code *code); ++void fprint_namespace(FILE *f); ++int is_in_namespace(const char *name); ++ ++#endif /* INPUT_MAP_H */ +diff -Naurp lirc-0.8.4a.orig/daemons/input_map.sh lirc-0.8.4a.upd/daemons/input_map.sh +--- lirc-0.8.4a.orig/daemons/input_map.sh 1969-12-31 19:00:00.000000000 -0500 ++++ lirc-0.8.4a.upd/daemons/input_map.sh 2008-12-08 17:51:33.106519735 -0500 +@@ -0,0 +1,11 @@ ++#! /bin/sh ++ ++TYPES="KEY BTN" ++file=${1:-/usr/include/linux/input.h} ++ ++for type in $TYPES; do ++ grep "^#define ${type}_" < $file|sort|while read; do ++ sed --expression="s/^#define \([^ ]*\)\(.*\)/{\"\1\", \2},/"|grep -v "KEY_HANGUEL\|KEY_MIN_INTERESTING" ++ done ++done ++ diff -Naurp lirc-0.8.4a.orig/daemons/irrecord.c lirc-0.8.4a.upd/daemons/irrecord.c --- lirc-0.8.4a.orig/daemons/irrecord.c 2008-12-08 16:47:25.358745194 -0500 -+++ lirc-0.8.4a.upd/daemons/irrecord.c 2008-12-08 16:55:26.208557409 -0500 -@@ -1395,6 +1395,7 @@ void analyse_remote(struct ir_remote *ra ++++ lirc-0.8.4a.upd/daemons/irrecord.c 2008-12-08 18:10:06.096432179 -0500 +@@ -52,6 +52,7 @@ + #include "ir_remote.h" + #include "config_file.h" + #include "receive.h" ++#include "input_map.h" + + void flushhw(void); + int resethw(void); +@@ -80,7 +81,7 @@ void get_scheme(struct ir_remote *remote + struct lengths *get_max_length(struct lengths *first,unsigned int *sump); + void unlink_length(struct lengths **first,struct lengths *remove); + int get_trail_length(struct ir_remote *remote, int interactive); +-int get_lead_length(struct ir_remote *remote); ++int get_lead_length(struct ir_remote *remote, int interactive); + int get_repeat_length(struct ir_remote *remote, int interactive); + int get_header_length(struct ir_remote *remote, int interactive); + int get_data_length(struct ir_remote *remote, int interactive); +@@ -96,7 +97,7 @@ const char *usage="Usage: %s [options] f + struct ir_remote remote; + struct ir_ncode ncode; + +-#define IRRECORD_VERSION "0.5" ++#define IRRECORD_VERSION "5.84" + #define BUTTON 80+1 + #define RETRIES 10 + +@@ -120,7 +121,7 @@ lirc_t aeps = 100; + #define TH_REPEAT 90 + #define TH_TRAIL 90 + #define TH_LEAD 90 +-#define TH_IS_BIT 15 ++#define TH_IS_BIT 10 + #define TH_RC6_SIGNAL 550 + + #define MIN_GAP 20000 +@@ -314,6 +315,7 @@ int main(int argc,char **argv) + int repeat_flag; + lirc_t min_remaining_gap, max_remaining_gap; + int force; ++ int disable_namespace = 0; + int retries; + int no_data = 0; + struct ir_remote *remotes=NULL; +@@ -338,6 +340,8 @@ int main(int argc,char **argv) + {"device",required_argument,NULL,'d'}, + {"driver",required_argument,NULL,'H'}, + {"force",no_argument,NULL,'f'}, ++ {"disable-namespace",no_argument,NULL,'n'}, ++ {"list-namespace",no_argument,NULL,'l'}, + #ifdef DEBUG + {"pre",no_argument,NULL,'p'}, + {"post",no_argument,NULL,'P'}, +@@ -348,9 +352,9 @@ int main(int argc,char **argv) + {0, 0, 0, 0} + }; + #ifdef DEBUG +- c = getopt_long(argc,argv,"hvad:H:fpPtiT",long_options,NULL); ++ c = getopt_long(argc,argv,"hvad:H:fnlpPtiT",long_options,NULL); + #else +- c = getopt_long(argc,argv,"hvad:H:f",long_options,NULL); ++ c = getopt_long(argc,argv,"hvad:H:fnl",long_options,NULL); + #endif + if(c==-1) + break; +@@ -362,6 +366,8 @@ int main(int argc,char **argv) + printf("\t -v --version\t\tdisplay version\n"); + printf("\t -a --analyse\t\tanalyse raw_codes config files\n"); + printf("\t -f --force\t\tforce raw mode\n"); ++ printf("\t -n --disable-namespace\t\tdisables namespace checks\n"); ++ printf("\t -l --list-namespace\t\tlist valid button names\n"); + printf("\t -H --driver=driver\tuse given driver\n"); + printf("\t -d --device=device\tread from given device\n"); + exit(EXIT_SUCCESS); +@@ -385,6 +391,13 @@ int main(int argc,char **argv) + case 'f': + force=1; + break; ++ case 'n': ++ disable_namespace = 1; ++ break; ++ case 'l': ++ fprint_namespace(stdout); ++ exit(EXIT_SUCCESS); ++ break; + #ifdef DEBUG + case 'p': + get_pre=1; +@@ -502,7 +515,7 @@ int main(int argc,char **argv) + exit(EXIT_FAILURE); + } + strcpy(filename_new, filename); +- strcat(filename_new, ".new"); ++ strcat(filename_new, ".conf"); + filename = filename_new; + } + else +@@ -717,6 +730,17 @@ int main(int argc,char **argv) + { + break; + } ++ if(!disable_namespace && !is_in_namespace(buffer)) ++ { ++ printf("'%s' is not in name space (use " ++ "--disable-namespace to disable checks)\n", ++ buffer); ++ printf("Use '%s --list-namespace' to see a full list " ++ "of valid button names\n", ++ progname); ++ printf("Please try again.\n"); ++ continue; ++ } + + if(is_raw(&remote)) + { +@@ -1379,7 +1403,8 @@ void analyse_remote(struct ir_remote *ra + ir_code pre, code, post; + int repeat_flag; + lirc_t min_remaining_gap, max_remaining_gap; +- struct ir_ncode new_codes[100]; ++ struct ir_ncode *new_codes; ++ size_t new_codes_count = 100; + int new_index = 0; + int ret; + +@@ -1395,18 +1420,27 @@ void analyse_remote(struct ir_remote *ra next_code = NULL; current_code = NULL; current_index = 0; + memset(&remote, 0, sizeof(remote)); get_lengths(&remote, 0, 0 /* not interactive */ ); - if(is_rc6(&remote)) +- if(is_rc6(&remote)) ++ if(is_rc6(&remote) && remote.bits >= 5) + { + /* have to assume something as it's very difficult to + extract the rc6_mask from the data that we have */ +- remote.rc6_mask = (ir_code) 0x100000000ll; ++ remote.rc6_mask = ((ir_code) 0x1ll) << (remote.bits-5); + } + + remote.name = raw_data->name; ++ remote.freq = raw_data->freq; + +- memset(new_codes, 0, sizeof(new_codes)); ++ new_codes = malloc(new_codes_count * sizeof(*new_codes)); ++ if(new_codes == NULL) ++ { ++ fprintf(stderr, "%s: out of memory\n", ++ progname); ++ return; ++ } ++ memset(new_codes, 0 , new_codes_count * sizeof(*new_codes)); + codes = raw_data->codes; + while(codes->name!=NULL) + { +@@ -1429,6 +1463,25 @@ void analyse_remote(struct ir_remote *ra + } + else + { ++ if(new_index+1 >= new_codes_count) ++ { ++ struct ir_ncode *renew_codes; ++ ++ new_codes_count *= 2; ++ renew_codes = realloc ++ (new_codes, ++ new_codes_count * sizeof(*new_codes)); ++ if(renew_codes == NULL) ++ { ++ fprintf(stderr, "%s: out of memory\n", ++ progname); ++ free(new_codes); ++ return; ++ } ++ memset(&new_codes[new_codes_count/2], 0 , new_codes_count/2 * sizeof(*new_codes)); ++ new_codes = renew_codes; ++ } ++ + new_codes[new_index].name = codes->name; + new_codes[new_index].code = code; + new_index++; +@@ -1438,6 +1491,8 @@ void analyse_remote(struct ir_remote *ra + new_codes[new_index].name = NULL; + remote.codes = new_codes; + fprint_remotes(stdout, &remote); ++ remote.codes = NULL; ++ free(new_codes); + } + + #ifdef DEBUG +@@ -1610,7 +1665,7 @@ inline lirc_t calc_signal(struct lengths + int get_lengths(struct ir_remote *remote, int force, int interactive) + { + int retval; +- lirc_t data,average,sum,remaining_gap,header; ++ lirc_t data,average,maxspace,sum,remaining_gap,header; + enum analyse_mode mode=MODE_GAP; + int first_signal; + +@@ -1628,7 +1683,7 @@ int get_lengths(struct ir_remote *remote + flushhw(); + } + retval=1; +- average=0;sum=0;count=0;count_spaces=0; ++ average=0;maxspace=0;sum=0;count=0;count_spaces=0; + count_3repeats=0;count_5repeats=0;count_signals=0; + first_signal=-1;header=0; + first_length=0; +@@ -1657,12 +1712,15 @@ int get_lengths(struct ir_remote *remote + continue; + } + average=data; ++ maxspace=data; + } + else if(is_space(data)) + { + if(data>MIN_GAP || data>100*average || + /* this MUST be a gap */ +- (count_spaces>10 && data>5*average)) ++ (count_spaces>10 && data>5*average) ++ /* || Echostar ++ (count_spaces>20 && data>9*maxspace/10)*/) + /* this should be a gap */ + { + struct lengths *scan; +@@ -1674,7 +1732,7 @@ int get_lengths(struct ir_remote *remote + merge_lengths(first_sum); + add_length(&first_gap,data); + merge_lengths(first_gap); +- sum=0;count_spaces=0;average=0; ++ sum=0;count_spaces=0;average=0;maxspace=0; + + maxcount=0; + scan=first_sum; +@@ -1740,6 +1798,10 @@ int get_lengths(struct ir_remote *remote + average=(average*count_spaces+data) + /(count_spaces+1); + count_spaces++; ++ if(data>maxspace) ++ { ++ maxspace=data; ++ } + } + if(count>SAMPLES*MAX_SIGNALS*2) + { +@@ -1773,8 +1835,9 @@ int get_lengths(struct ir_remote *remote + } + sum+=data&PULSE_MASK; + +- if((data&PULSE_MASK)>=remaining_gap*(100-eps)/100 +- || (data&PULSE_MASK)>=remaining_gap-aeps) ++ if(count>2 && ++ ((data&PULSE_MASK)>=remaining_gap*(100-eps)/100 ++ || (data&PULSE_MASK)>=remaining_gap-aeps)) + { + if(is_space(data)) + { +@@ -1882,7 +1945,7 @@ int get_lengths(struct ir_remote *remote + get_scheme(remote, interactive); + if(!get_header_length(remote, interactive) || + !get_trail_length(remote, interactive) || +- !get_lead_length(remote) || ++ !get_lead_length(remote, interactive) || + !get_repeat_length(remote, interactive) || + !get_data_length(remote, interactive)) + { +@@ -2173,7 +2236,7 @@ int get_trail_length(struct ir_remote *r + return(1); + } + +-int get_lead_length(struct ir_remote *remote) ++int get_lead_length(struct ir_remote *remote, int interactive) + { + unsigned int sum,max_count; + struct lengths *first_lead,*max_length,*max2_length; +@@ -2190,7 +2253,7 @@ int get_lead_length(struct ir_remote *re + # endif + if(max_count>=sum*TH_LEAD/100) + { +- printf("Found lead pulse: %lu\n", ++ iprintf(interactive, "Found lead pulse: %lu\n", + (unsigned long) calc_signal(max_length)); + remote->plead=calc_signal(max_length); + return(1); +@@ -2207,12 +2270,12 @@ int get_lead_length(struct ir_remote *re + } + if(abs(2*a-b)