1 /* $Id: ir_remote_types.h,v 5.17 2010/04/11 18:50:38 lirc Exp $ */ 2 3 /**************************************************************************** 4 ** ir_remote_types.h ******************************************************* 5 **************************************************************************** 6 * 7 * ir_remote_types.h - describes and decodes the signals from IR remotes 8 * 9 * Copyright (C) 1996,97 Ralph Metzler <rjkm@thp.uni-koeln.de> 10 * Copyright (C) 1998 Christoph Bartelmus <lirc@bartelmus.de> 11 * 12 */ 13 14 #ifndef IR_REMOTE_TYPES_H 15 #define IR_REMOTE_TYPES_H 16 17 #include <sys/types.h> 18 #include <sys/time.h> 19 #include <unistd.h> 20 #include <string.h> 21 #include <math.h> 22 #include <stdlib.h> 23 24 #include "drivers/lirc.h" 25 26 typedef __u64 ir_code; 27 28 struct ir_code_node { 29 ir_code code; 30 struct ir_code_node *next; 31 }; 32 33 /* 34 Code with name string 35 */ 36 37 struct ir_ncode { 38 char *name; 39 ir_code code; 40 int length; 41 lirc_t *signals; 42 struct ir_code_node *next; 43 struct ir_code_node *current; 44 struct ir_code_node *transmit_state; 45 }; 46 47 /* 48 struct ir_remote 49 defines the encoding of a remote control 50 */ 51 52 /* definitions for flags */ 53 54 #define IR_PROTOCOL_MASK 0x07ff 55 56 /* protocols: must not be combined */ 57 /* Don't forget to take a look at config_file.h when adding new flags */ 58 59 #define RAW_CODES 0x0001 /* for internal use only */ 60 #define RC5 0x0002 /* IR data follows RC5 protocol */ 61 #define SHIFT_ENC RC5 /* IR data is shift encoded (name obsolete) */ 62 /* Hm, RC6 protocols seem to have changed the biphase semantics so 63 that lircd will calculate the bit-wise complement of the codes. But 64 this is only a guess as I did not have a datasheet... */ 65 66 #define RC6 0x0004 /* IR data follows RC6 protocol */ 67 #define RCMM 0x0008 /* IR data follows RC-MM protocol */ 68 #define SPACE_ENC 0x0010 /* IR data is space encoded */ 69 #define SPACE_FIRST 0x0020 /* bits are encoded as space+pulse */ 70 #define GOLDSTAR 0x0040 /* encoding found on Goldstar remote */ 71 #define GRUNDIG 0x0080 /* encoding found on Grundig remote */ 72 #define BO 0x0100 /* encoding found on Bang & Olufsen remote */ 73 #define SERIAL 0x0200 /* serial protocol */ 74 #define XMP 0x0400 /* XMP protocol */ 75 76 /* additinal flags: can be orred together with protocol flag */ 77 #define REVERSE 0x0800 78 #define NO_HEAD_REP 0x1000 /* no header for key repeats */ 79 #define NO_FOOT_REP 0x2000 /* no foot for key repeats */ 80 #define CONST_LENGTH 0x4000 /* signal length+gap is always constant */ 81 #define REPEAT_HEADER 0x8000 /* header is also sent before repeat code */ 82 83 #define COMPAT_REVERSE 0x00010000 /* compatibility mode for REVERSE flag */ 84 85 /* stop repeating after 600 signals (approx. 1 minute) */ 86 /* update technical.html when changing this value */ 87 #define REPEAT_MAX_DEFAULT 600 88 89 #define DEFAULT_FREQ 38000 90 91 #define IR_PARITY_NONE 0 92 #define IR_PARITY_EVEN 1 93 #define IR_PARITY_ODD 2 94 95 struct ir_remote { 96 char *name; /* name of remote control */ 97 struct ir_ncode *codes; 98 int bits; /* bits (length of code) */ 99 int flags; /* flags */ 100 int eps; /* eps (_relative_ tolerance) */ 101 int aeps; /* detecing _very short_ pulses is 102 difficult with relative tolerance 103 for some remotes, 104 this is an _absolute_ tolerance 105 to solve this problem 106 usually you can say 0 here */ 107 # ifdef DYNCODES 108 char *dyncodes_name; /* name for unknown buttons */ 109 int dyncode; /* last received code */ 110 struct ir_ncode dyncodes[2]; /* helper structs for unknown buttons */ 111 # endif 112 113 /* pulse and space lengths of: */ 114 115 lirc_t phead, shead; /* header */ 116 lirc_t pthree, sthree; /* 3 (only used for RC-MM) */ 117 lirc_t ptwo, stwo; /* 2 (only used for RC-MM) */ 118 lirc_t pone, sone; /* 1 */ 119 lirc_t pzero, szero; /* 0 */ 120 lirc_t plead; /* leading pulse */ 121 lirc_t ptrail; /* trailing pulse */ 122 lirc_t pfoot, sfoot; /* foot */ 123 lirc_t prepeat, srepeat; /* indicate repeating */ 124 125 int pre_data_bits; /* length of pre_data */ 126 ir_code pre_data; /* data which the remote sends before 127 actual keycode */ 128 int post_data_bits; /* length of post_data */ 129 ir_code post_data; /* data which the remote sends after 130 actual keycode */ 131 lirc_t pre_p, pre_s; /* signal between pre_data and keycode */ 132 lirc_t post_p, post_s; /* signal between keycode and post_code */ 133 134 __u32 gap; /* time between signals in usecs */ 135 __u32 gap2; /* time between signals in usecs */ 136 __u32 repeat_gap; /* time between two repeat codes 137 if different from gap */ 138 int toggle_bit; /* obsolete */ 139 ir_code toggle_bit_mask; /* previously only one bit called 140 toggle_bit */ 141 int suppress_repeat; /* suppress unwanted repeats */ 142 int min_repeat; /* code is repeated at least x times 143 code sent once -> min_repeat=0 */ 144 unsigned int min_code_repeat; /*meaningful only if remote sends 145 a repeat code: in this case 146 this value indicates how often 147 the real code is repeated 148 before the repeat code is being 149 sent */ 150 unsigned int freq; /* modulation frequency */ 151 unsigned int duty_cycle; /* 0<duty cycle<=100 */ 152 ir_code toggle_mask; /* Sharp (?) error detection scheme */ 153 ir_code rc6_mask; /* RC-6 doubles signal length of 154 some bits */ 155 156 /* serial protocols */ 157 unsigned int baud; /* can be overridden by [p|s]zero, 158 [p|s]one */ 159 unsigned int bits_in_byte; /* default: 8 */ 160 unsigned int parity; /* currently unsupported */ 161 unsigned int stop_bits; /* mapping: 1->2 1.5->3 2->4 */ 162 163 ir_code ignore_mask; /* mask defines which bits can be 164 ignored when matching a 165 code */ 166 /* end of user editable values */ 167 168 ir_code toggle_bit_mask_state; 169 int toggle_mask_state; 170 int repeat_countdown; 171 struct ir_ncode *last_code; /* code received or sent last */ 172 struct ir_ncode *toggle_code; /* toggle code received or sent last */ 173 int reps; 174 struct timeval last_send; /* time last_code was received or sent */ 175 lirc_t min_remaining_gap; /* remember gap for CONST_LENGTH remotes */ 176 lirc_t max_remaining_gap; /* gap range */ 177 178 lirc_t min_total_signal_length; /* how long is the shortest 179 signal including gap */ 180 lirc_t max_total_signal_length; /* how long is the longest 181 signal including gap */ 182 lirc_t min_gap_length; /* how long is the shortest gap */ 183 lirc_t max_gap_length; /* how long is the longest gap */ 184 lirc_t min_pulse_length, max_pulse_length; 185 lirc_t min_space_length, max_space_length; 186 int release_detected; /* set by release generator */ 187 struct ir_remote *next; 188 }; 189 190 #endif 191