LIRC libraries
LinuxInfraredRemoteControl
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 
25 #ifdef HAVE_KERNEL_LIRC_H
26 #include <linux/lirc.h>
27 #else
28 #include "include/media/lirc.h"
29 #endif
30 
31 #include "lirc/ir_remote_types.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
38 #define DRV_ERR_NOT_IMPLEMENTED 1
39 
41 int default_open(const char* path);
42 
44 int default_close(void);
45 
47 int default_drvctl(unsigned int cmd, void* arg);
48 
50 void glob_t_init(glob_t* glob);
51 
53 void glob_t_free(glob_t* glob);
54 
56 void glob_t_add_path(glob_t* glob, const char* path);
57 
59 struct option_t {
60  char key[32];
61  char value[64];
62 };
63 
68 int 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 
101 #define DRVCTL_MAX 128
102 
104 #define DRV_ERR_NOT_IMPLEMENTED 1
105 
107 #define DRV_ERR_BAD_STATE 2
108 
110 #define DRV_ERR_BAD_OPTION 3
111 
113 #define DRV_ERR_BAD_VALUE 4
114 
119 struct driver {
120 // Old-style implicit API version 1:
121 
126  const char* device;
127 
129  int fd;
130 
132  __u32 features;
133 
138  __u32 send_mode;
139 
144  __u32 rec_mode;
145 
147  const __u32 code_length;
148 
155  int (*const open_func) (const char* device);
156 
161  int (*const init_func)(void);
162 
167  int (*const deinit_func) (void);
168 
175  int (*const send_func)(struct ir_remote* remote,
176  struct ir_ncode* code);
177 
184  char* (*const rec_func)(struct ir_remote* remotes);
185 
189  int (*const decode_func)(struct ir_remote* remote,
190  struct decode_ctx_t* ctx);
191 
196  int (*const drvctl_func)(unsigned int cmd, void* arg);
197 
205  lirc_t (*const readdata)(lirc_t timeout);
206 
211  const char* name;
212 
217  unsigned int resolution;
218 
219 /* API version 2 addons: */
220 
221  const int api_version;
222  const char* driver_version;
223  const char* info;
225  int (*const close_func)(void);
227 /* API version 3 addons: */
241  const char* const device_hint;
242 };
243 
246 #ifdef IN_DRIVER
247 
248 extern struct driver drv;
249 #endif
250 
252 extern const struct driver* const curr_driver;
253 
254 #ifdef __cplusplus
255 }
256 #endif
257 
258 #endif
__u32 features
Definition: driver.h:132
int default_close(void)
Definition: driver.c:79
int fd
Definition: driver.h:129
const char * info
Definition: driver.h:223
int(*const decode_func)(struct ir_remote *remote, struct decode_ctx_t *ctx)
Definition: driver.h:189
const struct driver *const curr_driver
Definition: driver.c:28
unsigned int resolution
Definition: driver.h:217
void glob_t_init(glob_t *glob)
Definition: driver.c:34
int(*const send_func)(struct ir_remote *remote, struct ir_ncode *code)
Definition: driver.h:175
const __u32 code_length
Definition: driver.h:147
struct driver drv
Definition: driver.c:22
const char * driver_version
Definition: driver.h:222
const int api_version
Definition: driver.h:221
char *(*const rec_func)(struct ir_remote *remotes)
Definition: driver.h:184
lirc_t(*const readdata)(lirc_t timeout)
Definition: driver.h:205
int(*const deinit_func)(void)
Definition: driver.h:167
int(*const close_func)(void)
Definition: driver.h:225
int(*const open_func)(const char *device)
Definition: driver.h:155
int default_drvctl(unsigned int cmd, void *arg)
Definition: driver.c:84
Definition: driver.h:119
void glob_t_add_path(glob_t *glob, const char *path)
Definition: driver.c:42
int drv_handle_options(const char *options)
Definition: driver.c:90
const char *const device_hint
Definition: driver.h:241
int(*const drvctl_func)(unsigned int cmd, void *arg)
Definition: driver.h:196
const char * name
Definition: driver.h:211
__u32 send_mode
Definition: driver.h:138
int default_open(const char *path)
Definition: driver.c:64
int(*const init_func)(void)
Definition: driver.h:161
ir_code code
__u32 rec_mode
Definition: driver.h:144
const char * device
Definition: driver.h:126
void glob_t_free(glob_t *glob)
Definition: driver.c:54