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 
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 
126 struct driver {
127 // Old-style implicit API version 1:
128 
133  const char* device;
134 
136  int fd;
137 
139  __u32 features;
140 
145  __u32 send_mode;
146 
151  __u32 rec_mode;
152 
154  const __u32 code_length;
155 
162  int (*const open_func) (const char* device);
163 
168  int (*const init_func)(void);
169 
174  int (*const deinit_func) (void);
175 
182  int (*const send_func)(struct ir_remote* remote,
183  struct ir_ncode* code);
184 
191  char* (*const rec_func)(struct ir_remote* remotes);
192 
196  int (*const decode_func)(struct ir_remote* remote,
197  struct decode_ctx_t* ctx);
198 
203  int (*const drvctl_func)(unsigned int cmd, void* arg);
204 
212  lirc_t (*const readdata)(lirc_t timeout);
213 
218  const char* name;
219 
224  unsigned int resolution;
225 
226 /* API version 2 addons: */
227 
228  const int api_version;
229  const char* driver_version;
230  const char* info;
232  int (*const close_func)(void);
234 /* API version 3 addons: */
248  const char* const device_hint;
249 };
250 
253 #ifdef IN_DRIVER
254 
255 extern struct driver drv;
256 #endif
257 
259 extern const struct driver* const curr_driver;
260 
261 #ifdef __cplusplus
262 }
263 #endif
264 
265 #endif
__u32 features
Definition: driver.h:139
int default_close(void)
Definition: driver.c:79
int fd
Definition: driver.h:136
const char * info
Definition: driver.h:230
const struct driver *const curr_driver
Definition: driver.c:28
unsigned int resolution
Definition: driver.h:224
void glob_t_init(glob_t *glob)
Definition: driver.c:34
const __u32 code_length
Definition: driver.h:154
struct driver drv
Definition: driver.c:22
const char * driver_version
Definition: driver.h:229
const int api_version
Definition: driver.h:228
char *(*const rec_func)(struct ir_remote *remotes)
Definition: driver.h:191
int default_drvctl(unsigned int cmd, void *arg)
Definition: driver.c:84
Definition: driver.h:126
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:248
const char * name
Definition: driver.h:218
__u32 send_mode
Definition: driver.h:145
int default_open(const char *path)
Definition: driver.c:64
ir_code code
__u32 rec_mode
Definition: driver.h:151
const char * device
Definition: driver.h:133
void glob_t_free(glob_t *glob)
Definition: driver.c:54