LIRC libraries
Linux Infrared Remote Control
Loading...
Searching...
No Matches
driver.h
Go to the documentation of this file.
1/****************************************************************************
2** driver.h **************************************************************
3****************************************************************************
4*
5* Copyright (C) 1999 Christoph Bartelmus <lirc@bartelmus.de>
6*
7*/
8
20#ifndef _HARDWARE_H
21#define _HARDWARE_H
22
23#include <glob.h>
24#include <stdint.h>
25
26#ifdef HAVE_KERNEL_LIRC_H
27#include <linux/lirc.h>
28#else
29#include "media/lirc.h"
30#endif
31
32#include "lirc/ir_remote_types.h"
33#include "lirc/curl_poll.h"
34
35#ifndef MAXPATHLEN
36#define MAXPATHLEN 4096
37#endif
38
40#define HAVE_SERVER_VERSION 1
41
43int get_server_version(void);
44
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
51#define DRV_ERR_NOT_IMPLEMENTED 1
52
54int default_open(const char* path);
55
57int default_close(void);
58
60int default_drvctl(unsigned int cmd, void* arg);
61
63struct option_t {
64 char key[32];
65 char value[64];
66};
67
72int drv_handle_options(const char* options);
73
74
76#define DRVCTL_GET_STATE 1
77
79#define DRVCTL_SEND_SPACE 2
80
82#define DRVCTL_SET_OPTION 3
83
88#define DRVCTL_GET_RAW_CODELENGTH 4
89
99#define DRVCTL_GET_DEVICES 5
100
102#define DRVCTL_FREE_DEVICES 6
103
109#define DRVCTL_NOTIFY_DECODE 7
110
112#define DRVCTL_MAX 128
113
115#define DRV_ERR_NOT_IMPLEMENTED 1
116
118#define DRV_ERR_BAD_STATE 2
119
121#define DRV_ERR_BAD_OPTION 3
122
124#define DRV_ERR_BAD_VALUE 4
125
127#define DRV_ERR_ENUM_EMPTY 5
128
130#define DRV_ERR_INTERNAL 6
131
136struct driver {
137// Old-style implicit API version 1:
138
143 const char* device;
144
146 int fd;
147
149 uint32_t features;
150
155 uint32_t send_mode;
156
161 uint32_t rec_mode;
162
164 const uint32_t code_length;
165
172 int (*const open_func) (const char* device);
173
178 int (*const init_func)(void);
179
184 int (*const deinit_func) (void);
185
192 int (*const send_func)(struct ir_remote* remote,
193 struct ir_ncode* code);
194
201 char* (*const rec_func)(struct ir_remote* remotes);
202
206 int (*const decode_func)(struct ir_remote* remote,
207 struct decode_ctx_t* ctx);
208
213 int (*const drvctl_func)(unsigned int cmd, void* arg);
214
222 lirc_t (*const readdata)(lirc_t timeout);
223
228 const char* name;
229
234 unsigned int resolution;
235
236/* API version 2 addons: */
237
238 const int api_version;
239 const char* driver_version;
240 const char* info;
242 int (*const close_func)(void);
244/* API version 3 addons: */
259 const char* const device_hint;
260};
261
264#ifdef IN_DRIVER
266extern struct driver drv;
267#endif
268
270extern const struct driver* const curr_driver;
271
272
273#ifdef __cplusplus
274}
275#endif
276
277#endif
struct driver drv
The global driver data that drivers etc are accessing.
Definition driver.c:28
const struct driver *const curr_driver
Read-only access to drv for application.
Definition driver.c:34
int default_close(void)
For now, a placeholder.
Definition driver.c:52
int get_server_version(void)
Return numeric server version, m.v.r => 10000 * m + 100 * v + r.
Definition driver.c:22
int default_drvctl(unsigned int cmd, void *arg)
Return DRV_ERR_NOTIMPLEMENTED.
Definition driver.c:57
int drv_handle_options(const char *options)
Parse an option string "key:value;key:value..." and invoke drvctl DRV_SET_OPTION as appropriate.
Definition driver.c:63
int default_open(const char *path)
Stores path in drv.device if non-null.
Definition driver.c:37
State describing code, pre, post + gap and repeat state.
The data the driver exports i.
Definition driver.h:136
const int api_version
API version (from version 2+).
Definition driver.h:238
int fd
Set by the driver after init().
Definition driver.h:146
const char * driver_version
Driver version (free text).
Definition driver.h:239
const char * name
Driver name, as listed by -H help and used as argument to i –driver.
Definition driver.h:228
uint32_t send_mode
Possible values are: LIRC_MODE_RAW, LIRC_MODE_PULSE, LIRC_MODE_MODE2, LIRC_MODE_LIRCCODE.
Definition driver.h:155
const uint32_t code_length
Length in bits of the code.
Definition driver.h:164
int(*const decode_func)(struct ir_remote *remote, struct decode_ctx_t *ctx)
TODO.
Definition driver.h:206
uint32_t features
Code for the features of the present device, valid after init().
Definition driver.h:149
const char * info
Free text driver info.
Definition driver.h:240
char *(*const rec_func)(struct ir_remote *remotes)
Receive data from remote.
Definition driver.h:201
lirc_t(*const readdata)(lirc_t timeout)
Get length of next pulse/space from hardware.
Definition driver.h:222
int(*const deinit_func)(void)
Function called when transmitting/receiving stops.
Definition driver.h:184
int(*const init_func)(void)
Function called for initializing the driver and the hardware.
Definition driver.h:178
int(*const send_func)(struct ir_remote *remote, struct ir_ncode *code)
Send data to the remote.
Definition driver.h:192
unsigned int resolution
The resolution in microseconds of the recorded durations when reading signals.
Definition driver.h:234
const char *const device_hint
device_hint is a mean for config tools to autodetect devices.
Definition driver.h:259
int(*const drvctl_func)(unsigned int cmd, void *arg)
Generic driver control function with semantics as defined by driver Returns 0 on success,...
Definition driver.h:213
const char * device
Name of the device (string).
Definition driver.h:143
int(*const close_func)(void)
Hard closing, returns 0 on OK.
Definition driver.h:242
int(*const open_func)(const char *device)
Function called to do basic driver setup.
Definition driver.h:172
uint32_t rec_mode
Possible values are: LIRC_MODE_RAW, LIRC_MODE_PULSE, LIRC_MODE_MODE2, LIRC_MODE_LIRCCODE.
Definition driver.h:161
IR Command, corresponding to one (command defining) line of the configuration file.
One remote as represented in the configuration file.
Argument for DRV_SET_OPTION.
Definition driver.h:63