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
15
20#ifndef _HARDWARE_H
21#define _HARDWARE_H
22
23#include <glob.h>
24#include <stdint.h>
25
26#include "media/lirc.h"
27
28#include "lirc/ir_remote_types.h"
29#include "lirc/curl_poll.h"
30
31#ifndef MAXPATHLEN
32#define MAXPATHLEN 4096
33#endif
34
36#define HAVE_SERVER_VERSION 1
37
39int get_server_version(void);
40
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
47#define DRV_ERR_NOT_IMPLEMENTED 1
48
50int default_open(const char* path);
51
53int default_close(void);
54
56int default_drvctl(unsigned int cmd, void* arg);
57
59struct option_t {
60 char key[32];
61 char value[64];
62};
63
68int drv_handle_options(const char* options);
69
70
72#define DRVCTL_GET_STATE 1
73
75#define DRVCTL_SEND_SPACE 2
76
78#define DRVCTL_SET_OPTION 3
79
84#define DRVCTL_GET_RAW_CODELENGTH 4
85
95#define DRVCTL_GET_DEVICES 5
96
98#define DRVCTL_FREE_DEVICES 6
99
104
105#define DRVCTL_NOTIFY_DECODE 7
106
108#define DRVCTL_MAX 128
109
111#define DRV_ERR_NOT_IMPLEMENTED 1
112
114#define DRV_ERR_BAD_STATE 2
115
117#define DRV_ERR_BAD_OPTION 3
118
120#define DRV_ERR_BAD_VALUE 4
121
123#define DRV_ERR_ENUM_EMPTY 5
124
126#define DRV_ERR_INTERNAL 6
127
132struct driver {
133// Old-style implicit API version 1:
134
139 const char* device;
140
142 int fd;
143
145 uint32_t features;
146
151 uint32_t send_mode;
152
157 uint32_t rec_mode;
158
160 const uint32_t code_length;
161
168 int (*const open_func) (const char* device);
169
174 int (*const init_func)(void);
175
180 int (*const deinit_func) (void);
181
188 int (*const send_func)(struct ir_remote* remote,
189 struct ir_ncode* code);
190
197 char* (*const rec_func)(struct ir_remote* remotes);
198
202 int (*const decode_func)(struct ir_remote* remote,
203 struct decode_ctx_t* ctx);
204
209 int (*const drvctl_func)(unsigned int cmd, void* arg);
210
218 lirc_t (*const readdata)(lirc_t timeout);
219
224 const char* name;
225
230 unsigned int resolution;
231
232/* API version 2 addons: */
233
234 const int api_version;
235 const char* driver_version;
236 const char* info;
237
238 int (*const close_func)(void);
239
240/* API version 3 addons: */
255 const char* const device_hint;
256};
257
259
260#ifdef IN_DRIVER
262extern struct driver drv;
263#endif
264
266extern const struct driver* const curr_driver;
267
268
269#ifdef __cplusplus
270}
271#endif
272
273#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 client code.
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:132
const int api_version
API version (from version 2+).
Definition driver.h:234
int fd
Set by the driver after init().
Definition driver.h:142
const char * driver_version
Driver version (free text).
Definition driver.h:235
const char * name
Driver name, as listed by -H help and used as argument to i –driver.
Definition driver.h:224
uint32_t send_mode
Possible values are: LIRC_MODE_RAW, LIRC_MODE_PULSE, LIRC_MODE_MODE2, LIRC_MODE_LIRCCODE.
Definition driver.h:151
const uint32_t code_length
Length in bits of the code.
Definition driver.h:160
int(*const decode_func)(struct ir_remote *remote, struct decode_ctx_t *ctx)
TODO.
Definition driver.h:202
uint32_t features
Code for the features of the present device, valid after init().
Definition driver.h:145
const char * info
Free text driver info.
Definition driver.h:236
char *(*const rec_func)(struct ir_remote *remotes)
Receive data from remote.
Definition driver.h:197
lirc_t(*const readdata)(lirc_t timeout)
Get length of next pulse/space from hardware.
Definition driver.h:218
int(*const deinit_func)(void)
Function called when transmitting/receiving stops.
Definition driver.h:180
int(*const init_func)(void)
Function called for initializing the driver and the hardware.
Definition driver.h:174
int(*const send_func)(struct ir_remote *remote, struct ir_ncode *code)
Send data to the remote.
Definition driver.h:188
unsigned int resolution
The resolution in microseconds of the recorded durations when reading signals.
Definition driver.h:230
const char *const device_hint
device_hint is a mean for config tools to autodetect devices.
Definition driver.h:255
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:209
const char * device
Name of the device (string).
Definition driver.h:139
int(*const close_func)(void)
Hard closing, returns 0 on OK.
Definition driver.h:238
int(*const open_func)(const char *device)
Function called to do basic driver setup.
Definition driver.h:168
uint32_t rec_mode
Possible values are: LIRC_MODE_RAW, LIRC_MODE_PULSE, LIRC_MODE_MODE2, LIRC_MODE_LIRCCODE.
Definition driver.h:157
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:59