68 if (ncode->
next && node != NULL)
74get_next_ir_code_node(
const struct ir_ncode* ncode,
82static inline int bit_count(
const struct ir_remote* remote)
84 return remote->pre_data_bits + remote->bits + remote->post_data_bits;
87static inline int bits_set(
ir_code data)
105 for (i = 0; i < bits; i++)
111static inline int is_pulse(lirc_t data)
113 return ((data & LIRC_MODE2_MASK)==LIRC_MODE2_PULSE) ? 1 : 0;
116static inline int is_space(lirc_t data)
118 return ((data & LIRC_MODE2_MASK)==LIRC_MODE2_SPACE) ? 1 : 0;
121static inline int is_timeout(lirc_t data)
123 return ((data & LIRC_MODE2_MASK)==LIRC_MODE2_TIMEOUT) ? 1 : 0;
126static inline int is_overflow(lirc_t data)
128 return ((data & LIRC_MODE2_MASK)==LIRC_MODE2_OVERFLOW) ? 1 : 0;
131static inline int has_repeat(
const struct ir_remote* remote)
133 if (remote->prepeat > 0 && remote->srepeat > 0)
139static inline void set_protocol(
struct ir_remote* remote,
int protocol)
141 remote->flags &= ~(IR_PROTOCOL_MASK);
142 remote->flags |= protocol;
145static inline int is_raw(
const struct ir_remote* remote)
147 if ((remote->flags & IR_PROTOCOL_MASK) ==
RAW_CODES)
153static inline int is_space_enc(
const struct ir_remote* remote)
155 if ((remote->flags & IR_PROTOCOL_MASK) ==
SPACE_ENC)
161static inline int is_space_first(
const struct ir_remote* remote)
163 if ((remote->flags & IR_PROTOCOL_MASK) ==
SPACE_FIRST)
169static inline int is_rc5(
const struct ir_remote* remote)
171 if ((remote->flags & IR_PROTOCOL_MASK) ==
RC5)
177static inline int is_rc6(
const struct ir_remote* remote)
179 if ((remote->flags & IR_PROTOCOL_MASK) ==
RC6 || remote->rc6_mask)
185static inline int is_biphase(
const struct ir_remote* remote)
187 if (is_rc5(remote) || is_rc6(remote))
193static inline int is_rcmm(
const struct ir_remote* remote)
195 if ((remote->flags & IR_PROTOCOL_MASK) ==
RCMM)
201static inline int is_grundig(
const struct ir_remote* remote)
203 if ((remote->flags & IR_PROTOCOL_MASK) ==
GRUNDIG)
209static inline int is_bo(
const struct ir_remote* remote)
211 if ((remote->flags & IR_PROTOCOL_MASK) ==
BO)
217static inline int is_serial(
const struct ir_remote* remote)
219 if ((remote->flags & IR_PROTOCOL_MASK) ==
SERIAL)
225static inline int is_xmp(
const struct ir_remote* remote)
227 if ((remote->flags & IR_PROTOCOL_MASK) ==
XMP)
233static inline int is_const(
const struct ir_remote* remote)
241static inline int has_repeat_gap(
const struct ir_remote* remote)
243 if (remote->repeat_gap > 0)
249static inline int has_pre(
const struct ir_remote* remote)
251 if (remote->pre_data_bits > 0)
257static inline int has_post(
const struct ir_remote* remote)
259 if (remote->post_data_bits > 0)
265static inline int has_header(
const struct ir_remote* remote)
267 if (remote->phead > 0 && remote->shead > 0)
273static inline int has_foot(
const struct ir_remote* remote)
275 if (remote->pfoot > 0 && remote->sfoot > 0)
281static inline int has_toggle_bit_mask(
const struct ir_remote* remote)
283 if (remote->toggle_bit_mask > 0)
289static inline int has_ignore_mask(
const struct ir_remote* remote)
291 if (remote->ignore_mask > 0)
297static inline int has_repeat_mask(
struct ir_remote* remote)
299 if (remote->repeat_mask > 0)
305static inline int has_toggle_mask(
const struct ir_remote* remote)
307 if (remote->toggle_mask > 0)
313static inline lirc_t min_gap(
const struct ir_remote* remote)
315 if (remote->gap2 != 0 && remote->gap2 < remote->gap)
321static inline lirc_t max_gap(
const struct ir_remote* remote)
323 if (remote->gap2 > remote->gap)
329static inline unsigned int get_duty_cycle(
const struct ir_remote* remote)
331 if (remote->duty_cycle == 0)
333 else if (remote->duty_cycle < 0)
335 else if (remote->duty_cycle > 100)
338 return remote->duty_cycle;
343static inline int expect(
const struct ir_remote* remote,
350 if (abs(exdelta - delta) <= exdelta * remote->eps / 100
351 || abs(exdelta - delta) <=
aeps)
356static inline int expect_at_least(
const struct ir_remote* remote,
363 if (delta + exdelta * remote->eps / 100 >= exdelta
364 || delta +
aeps >= exdelta)
369static inline int expect_at_most(
const struct ir_remote* remote,
376 if (delta <= exdelta + exdelta * remote->
eps / 100
377 || delta <= exdelta +
aeps)
382static inline lirc_t upper_limit(
const struct ir_remote* remote, lirc_t val)
386 lirc_t eps_val = val * (100 + remote->eps) / 100;
387 lirc_t aeps_val = val +
aeps;
389 return eps_val > aeps_val ? eps_val : aeps_val;
392static inline lirc_t lower_limit(
const struct ir_remote* remote, lirc_t val)
396 lirc_t eps_val = val * (100 - remote->eps) / 100;
397 lirc_t aeps_val = val -
aeps;
404 return eps_val < aeps_val ? eps_val : aeps_val;
408static inline unsigned long time_elapsed(
const struct timeval* last,
409 const struct timeval* current)
411 unsigned long secs, diff;
413 secs = current->tv_sec - last->tv_sec;
415 diff = 1000000 * secs + current->tv_usec - last->tv_usec;
420static inline ir_code gen_mask(
int bits)
426 for (i = 0; i < bits; i++) {
440 all = (pre & gen_mask(remote->pre_data_bits));
441 all <<= remote->bits;
442 all |= is_raw(remote) ? code : (code & gen_mask(remote->bits));
443 all <<= remote->post_data_bits;
444 all |= post & gen_mask(remote->post_data_bits);
464 unsigned int* min_freq,
465 unsigned int* max_freq);
468 lirc_t* max_gap_lengthp,
469 lirc_t* min_pulse_lengthp,
470 lirc_t* min_space_lengthp,
471 lirc_t* max_pulse_lengthp,
472 lirc_t* max_space_lengthp);
485 const struct timeval* start,
486 const struct timeval* last,
487 lirc_t signal_length);
495 const char* remote_name,
496 const char* button_name,
497 const char* button_suffix,
const struct driver *const curr_driver
Read-only access to drv for client code.
Interface to the userspace drivers.
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)
Formats the arguments into a readable string.
struct ir_ncode * get_code_by_name(const struct ir_remote *remote, const char *name)
Return code with given name in remote's list of codes or NULL.
void get_frequency_range(const struct ir_remote *remotes, unsigned int *min_freq, unsigned int *max_freq)
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_ncode * repeat_code
Global pointer to the code currently repeating.
void ncode_free(struct ir_ncode *ncode)
Dispose an ir_ncode instance obtained from ncode_dup().
struct ir_remote * last_remote
TODO.
int send_ir_ncode(struct ir_remote *remote, struct ir_ncode *code, int delay)
Transmits the actual code in the second argument by calling the current hardware driver.
char * decode_all(struct ir_remote *remotes)
Tries to decode current signal trying all known remotes.
struct ir_remote * repeat_remote
Global pointer to the remote that contains the code currently repeating.
void ir_remote_init(int use_dyncodes)
Initiate: define if dynamic codes should be used.
const struct ir_remote * get_decoding(void)
Return pointer to currently decoded remote.
struct ir_remote * get_ir_remote(const struct ir_remote *remotes, const char *name)
Return ir_remote with given name in remotes list, or NULL if not found.
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)
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)
const struct ir_remote * is_in_remotes(const struct ir_remote *remotes, const struct ir_remote *remote)
Test if a given remote is in a list of remotes.
struct ir_ncode * ncode_dup(struct ir_ncode *ncode)
Create a malloc'd, deep copy of ncode.
Describes and decodes the signals from IR remotes.
#define RAW_CODES
for internal use only
#define RC6
IR data follows RC6 protocol.
#define GRUNDIG
encoding found on Grundig remote
#define BO
encoding found on Bang & Olufsen remote
uint64_t ir_code
Denotes an internal coded representation for an IR transmission.
#define SPACE_FIRST
bits are encoded as space+pulse
#define SPACE_ENC
IR data is space encoded.
#define RC5
IR data follows RC5 protocol.
#define SERIAL
serial protocol
#define CONST_LENGTH
signal length+gap is always constant
#define RCMM
IR data follows RC-MM protocol.
unsigned int eps
Shared list of remotes.
lirc_t aeps
Error tolerance in per cent.
State describing code, pre, post + gap and repeat state.
An ir_code for entering into (singly) linked lists, i.e.
IR Command, corresponding to one (command defining) line of the configuration file.
struct ir_code_node * next
Linked list of the subsequent ir_code's, after the first one.
ir_code code
The first code of the command.
One remote as represented in the configuration file.
int bits
bits (length of code)