25 #include <sys/types.h>
60 if (ncode->
next && node != NULL)
73 static inline int bit_count(
const struct ir_remote *remote)
78 static inline int bits_set(
ir_code data)
95 for (i = 0; i < bits; i++) {
102 static inline int is_pulse(lirc_t data)
104 return (data & PULSE_BIT ? 1 : 0);
107 static inline int is_space(lirc_t data)
109 return (!is_pulse(data));
112 static inline int has_repeat(
const struct ir_remote *remote)
114 if (remote->prepeat > 0 && remote->
srepeat > 0)
120 static inline void set_protocol(
struct ir_remote *remote,
int protocol)
122 remote->
flags &= ~(IR_PROTOCOL_MASK);
123 remote->
flags |= protocol;
126 static inline int is_raw(
const struct ir_remote *remote)
134 static inline int is_space_enc(
const struct ir_remote *remote)
142 static inline int is_space_first(
const struct ir_remote *remote)
150 static inline int is_rc5(
const struct ir_remote *remote)
152 if ((remote->
flags & IR_PROTOCOL_MASK) ==
RC5)
158 static inline int is_rc6(
const struct ir_remote *remote)
166 static inline int is_biphase(
const struct ir_remote *remote)
168 if (is_rc5(remote) || is_rc6(remote))
174 static inline int is_rcmm(
const struct ir_remote *remote)
176 if ((remote->
flags & IR_PROTOCOL_MASK) ==
RCMM)
182 static inline int is_goldstar(
const struct ir_remote *remote)
190 static inline int is_grundig(
const struct ir_remote *remote)
198 static inline int is_bo(
const struct ir_remote *remote)
200 if ((remote->
flags & IR_PROTOCOL_MASK) ==
BO)
206 static inline int is_serial(
const struct ir_remote *remote)
214 static inline int is_xmp(
const struct ir_remote *remote)
216 if ((remote->
flags & IR_PROTOCOL_MASK) ==
XMP)
222 static inline int is_const(
const struct ir_remote *remote)
230 static inline int has_repeat_gap(
const struct ir_remote *remote)
238 static inline int has_pre(
const struct ir_remote *remote)
246 static inline int has_post(
const struct ir_remote *remote)
254 static inline int has_header(
const struct ir_remote *remote)
256 if (remote->phead > 0 && remote->
shead > 0)
262 static inline int has_foot(
const struct ir_remote *remote)
264 if (remote->pfoot > 0 && remote->
sfoot > 0)
270 static inline int has_toggle_bit_mask(
const struct ir_remote *remote)
278 static inline int has_ignore_mask(
const struct ir_remote *remote)
286 static inline int has_repeat_mask(
struct ir_remote *remote)
294 static inline int has_toggle_mask(
const struct ir_remote *remote)
302 static inline lirc_t min_gap(
const struct ir_remote *remote)
304 if (remote->
gap2 != 0 && remote->
gap2 < remote->
gap) {
311 static inline lirc_t max_gap(
const struct ir_remote *remote)
313 if (remote->
gap2 > remote->
gap) {
322 static inline int expect(
const struct ir_remote *remote, lirc_t delta, lirc_t exdelta)
326 if (abs(exdelta - delta) <= exdelta * remote->
eps / 100 || abs(exdelta - delta) <= aeps)
331 static inline int expect_at_least(
const struct ir_remote *remote, lirc_t delta, lirc_t exdelta)
335 if (delta + exdelta * remote->
eps / 100 >= exdelta || delta + aeps >= exdelta) {
341 static inline int expect_at_most(
const struct ir_remote *remote, lirc_t delta, lirc_t exdelta)
345 if (delta <= exdelta + exdelta * remote->eps / 100 || delta <= exdelta + aeps) {
351 static inline lirc_t upper_limit(
const struct ir_remote *remote, lirc_t val)
354 lirc_t eps_val = val * (100 + remote->
eps) / 100;
355 lirc_t aeps_val = val + aeps;
356 return eps_val > aeps_val ? eps_val : aeps_val;
359 static inline lirc_t lower_limit(
const struct ir_remote *remote, lirc_t val)
362 lirc_t eps_val = val * (100 - remote->
eps) / 100;
363 lirc_t aeps_val = val - aeps;
370 return eps_val < aeps_val ? eps_val : aeps_val;
374 static inline unsigned long time_elapsed(
const struct timeval *last,
375 const struct timeval *current)
377 unsigned long secs, diff;
379 secs = current->tv_sec - last->tv_sec;
381 diff = 1000000 * secs + current->tv_usec - last->tv_usec;
386 static inline ir_code gen_mask(
int bits)
392 for (i = 0; i < bits; i++) {
405 all <<= remote->
bits;
406 all |= is_raw(remote) ? code : (code & gen_mask(remote->
bits));
427 unsigned int* min_freq,
428 unsigned int* max_freq);
431 lirc_t* max_gap_lengthp,
432 lirc_t* min_pulse_lengthp,
433 lirc_t* min_space_lengthp,
434 lirc_t* max_pulse_lengthp,
435 lirc_t* max_space_lengthp);
448 const struct timeval* start,
449 const struct timeval* last,
450 lirc_t signal_length);
457 const char* remote_name,
458 const char* button_name,
459 const char* button_suffix,
struct ir_remote * last_remote
struct ir_ncode * repeat_code
void ir_remote_init(int use_dyncodes)
void get_filter_parameters(const struct ir_remote *remotes, lirc_t *max_gap_lengthp, lirc_t *min_pulse_lengthp, lirc_t *min_space_lengthp, lirc_t *max_pulse_lengthp, lirc_t *max_space_lengthp)
struct ir_code_node * next
struct ir_ncode * get_code_by_name(const struct ir_remote *remote, const char *name)
Interface to the userspace drivers.
struct ir_remote * get_ir_remote(const struct ir_remote *remotes, const char *name)
int map_code(const struct ir_remote *remote, struct decode_ctx_t *ctx, int pre_bits, ir_code pre, int bits, ir_code code, int post_bits, ir_code post)
char * decode_all(struct ir_remote *remotes)
Describes and decodes the signals from IR remotes.
int write_message(char *buffer, size_t size, const char *remote_name, const char *button_name, const char *button_suffix, ir_code code, int reps)
const struct ir_remote * is_in_remotes(const struct ir_remote *remotes, const struct ir_remote *remote)
void map_gap(const struct ir_remote *remote, struct decode_ctx_t *ctx, const struct timeval *start, const struct timeval *last, lirc_t signal_length)
void get_frequency_range(const struct ir_remote *remotes, unsigned int *min_freq, unsigned int *max_freq)
const struct driver const * curr_driver
struct ir_remote * repeat_remote
int send_ir_ncode(struct ir_remote *remote, struct ir_ncode *code, int delay)