24 #include <sys/types.h> 68 if (ncode->
next && node != NULL)
74 get_next_ir_code_node(
const struct ir_ncode* ncode,
82 static inline int bit_count(
const struct ir_remote* remote)
87 static inline int bits_set(
ir_code data)
105 for (i = 0; i < bits; i++)
111 static inline int is_pulse(lirc_t data)
113 return ((data & LIRC_MODE2_MASK)==LIRC_MODE2_PULSE) ? 1 : 0;
116 static inline int is_space(lirc_t data)
118 return ((data & LIRC_MODE2_MASK)==LIRC_MODE2_SPACE) ? 1 : 0;
121 static inline int is_timeout(lirc_t data)
123 return ((data & LIRC_MODE2_MASK)==LIRC_MODE2_TIMEOUT) ? 1 : 0;
126 static inline int has_repeat(
const struct ir_remote* remote)
128 if (remote->prepeat > 0 && remote->
srepeat > 0)
134 static inline void set_protocol(
struct ir_remote* remote,
int protocol)
136 remote->
flags &= ~(IR_PROTOCOL_MASK);
137 remote->
flags |= protocol;
140 static inline int is_raw(
const struct ir_remote* remote)
148 static inline int is_space_enc(
const struct ir_remote* remote)
156 static inline int is_space_first(
const struct ir_remote* remote)
164 static inline int is_rc5(
const struct ir_remote* remote)
166 if ((remote->
flags & IR_PROTOCOL_MASK) ==
RC5)
172 static inline int is_rc6(
const struct ir_remote* remote)
180 static inline int is_biphase(
const struct ir_remote* remote)
182 if (is_rc5(remote) || is_rc6(remote))
188 static inline int is_rcmm(
const struct ir_remote* remote)
190 if ((remote->
flags & IR_PROTOCOL_MASK) ==
RCMM)
196 static inline int is_goldstar(
const struct ir_remote* remote)
204 static inline int is_grundig(
const struct ir_remote* remote)
212 static inline int is_bo(
const struct ir_remote* remote)
214 if ((remote->
flags & IR_PROTOCOL_MASK) ==
BO)
220 static inline int is_serial(
const struct ir_remote* remote)
228 static inline int is_xmp(
const struct ir_remote* remote)
230 if ((remote->
flags & IR_PROTOCOL_MASK) ==
XMP)
236 static inline int is_const(
const struct ir_remote* remote)
244 static inline int has_repeat_gap(
const struct ir_remote* remote)
252 static inline int has_pre(
const struct ir_remote* remote)
260 static inline int has_post(
const struct ir_remote* remote)
268 static inline int has_header(
const struct ir_remote* remote)
270 if (remote->phead > 0 && remote->
shead > 0)
276 static inline int has_foot(
const struct ir_remote* remote)
278 if (remote->pfoot > 0 && remote->
sfoot > 0)
284 static inline int has_toggle_bit_mask(
const struct ir_remote* remote)
292 static inline int has_ignore_mask(
const struct ir_remote* remote)
300 static inline int has_repeat_mask(
struct ir_remote* remote)
308 static inline int has_toggle_mask(
const struct ir_remote* remote)
316 static inline lirc_t min_gap(
const struct ir_remote* remote)
318 if (remote->
gap2 != 0 && remote->
gap2 < remote->
gap)
324 static inline lirc_t max_gap(
const struct ir_remote* remote)
326 if (remote->
gap2 > remote->
gap)
332 static inline unsigned int get_duty_cycle(
const struct ir_remote* remote)
346 static inline int expect(
const struct ir_remote* remote,
353 if (abs(exdelta - delta) <= exdelta * remote->
eps / 100
354 || abs(exdelta - delta) <= aeps)
359 static inline int expect_at_least(
const struct ir_remote* remote,
366 if (delta + exdelta * remote->
eps / 100 >= exdelta
367 || delta + aeps >= exdelta)
372 static inline int expect_at_most(
const struct ir_remote* remote,
379 if (delta <= exdelta + exdelta * remote->
eps / 100
380 || delta <= exdelta + aeps)
385 static inline lirc_t upper_limit(
const struct ir_remote* remote, lirc_t val)
389 lirc_t eps_val = val * (100 + remote->
eps) / 100;
390 lirc_t aeps_val = val +
aeps;
392 return eps_val > aeps_val ? eps_val : aeps_val;
395 static inline lirc_t lower_limit(
const struct ir_remote* remote, lirc_t val)
399 lirc_t eps_val = val * (100 - remote->
eps) / 100;
400 lirc_t aeps_val = val -
aeps;
407 return eps_val < aeps_val ? eps_val : aeps_val;
411 static inline unsigned long time_elapsed(
const struct timeval* last,
412 const struct timeval* current)
414 unsigned long secs, diff;
416 secs = current->tv_sec - last->tv_sec;
418 diff = 1000000 * secs + current->tv_usec - last->tv_usec;
423 static inline ir_code gen_mask(
int bits)
429 for (i = 0; i < bits; i++) {
444 all <<= remote->
bits;
445 all |= is_raw(remote) ? code : (code & gen_mask(remote->
bits));
467 unsigned int* min_freq,
468 unsigned int* max_freq);
471 lirc_t* max_gap_lengthp,
472 lirc_t* min_pulse_lengthp,
473 lirc_t* min_space_lengthp,
474 lirc_t* max_pulse_lengthp,
475 lirc_t* max_space_lengthp);
488 const struct timeval* start,
489 const struct timeval* last,
490 lirc_t signal_length);
498 const char* remote_name,
499 const char* button_name,
500 const char* button_suffix,
struct ir_remote * last_remote
TODO.
struct ir_ncode * repeat_code
Global pointer to the code currently repeating.
One remote as represented in the configuration file.
int bits
bits (length of code)
#define RC6
IR data follows RC6 protocol.
An ir_code for entering into (singly) linked lists, i.e.
#define GOLDSTAR
encoding found on Goldstar remote
void ir_remote_init(int use_dyncodes)
Initiate: define if dynamic codes should be used.
const struct driver *const curr_driver
Read-only access to drv for client code.
ir_code repeat_mask
mask defines which bits are inverted for repeats
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
Linked list of the subsequent ir_code's, after the first one.
const char * name
name of remote control
#define SPACE_ENC
IR data is space encoded.
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.
unsigned int resolution
The resolution in microseconds of the recorded durations when reading signals.
Interface to the userspace drivers.
int eps
eps (relative tolerance)
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)
char * decode_all(struct ir_remote *remotes)
Tries to decode current signal trying all known remotes.
int pre_data_bits
length of pre_data
char * name
Name of command.
unsigned int duty_cycle
0<duty cycle<=100 default: 50
int post_data_bits
length of post_data
#define RCMM
IR data follows RC-MM protocol.
ir_code toggle_mask
Sharp (?) error detection scheme.
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)
Formats the arguments into a readable string.
lirc_t aeps
Error tolerance in per cent.
uint32_t gap
time between signals in usecs
#define RC5
IR data follows RC5 protocol.
uint32_t repeat_gap
time between two repeat codes if different from gap
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.
#define SPACE_FIRST
bits are encoded as space+pulse
const struct ir_remote * get_decoding(void)
Return pointer to currently decoded remote.
unsigned int eps
Shared list of remotes.
#define CONST_LENGTH
signal length+gap is always constant
uint32_t gap2
time between signals in usecs
#define GRUNDIG
encoding found on Grundig remote
void ncode_free(struct ir_ncode *ncode)
Dispose an ir_ncode instance obtained from ncode_dup().
IR Command, corresponding to one (command defining) line of the configuration file.
unsigned int aeps
detecting very short pulses is difficult with relative tolerance for some remotes, this is an absolute tolerance to solve this problem usually you can say 0 here.
lirc_t srepeat
indicate repeating
State describing code, pre, post + gap and repeat state.
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)
#define SERIAL
serial protocol
struct ir_ncode * ncode_dup(struct ir_ncode *ncode)
Create a malloc'd, deep copy of ncode.
void get_frequency_range(const struct ir_remote *remotes, unsigned int *min_freq, unsigned int *max_freq)
#define BO
encoding found on Bang & Olufsen remote
ir_code code
The first code of the command.
ir_code rc6_mask
RC-6 doubles signal length of some bits.
struct ir_remote * repeat_remote
Global pointer to the remote that contains the code currently repeating.
ir_code toggle_bit_mask
previously only one bit called toggle_bit
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.
#define RAW_CODES
for internal use only
ir_code ignore_mask
mask defines which bits can be ignored when matching a code
uint64_t ir_code
Denotes an internal coded representation for an IR transmission.