Loading...
Searching...
No Matches
driver.h
Go to the documentation of this file.
/****************************************************************************
** driver.h **************************************************************
****************************************************************************
*
* Copyright (C) 1999 Christoph Bartelmus <lirc@bartelmus.de>
*
*/
#ifndef _HARDWARE_H
#define _HARDWARE_H
#include <glob.h>
#include <stdint.h>
#include "media/lirc.h"
#include "lirc/ir_remote_types.h"
#include "lirc/curl_poll.h"
#ifndef MAXPATHLEN
#define MAXPATHLEN 4096
#endif
#define HAVE_SERVER_VERSION 1
int get_server_version(void);
#ifdef __cplusplus
extern "C" {
#endif
#define DRV_ERR_NOT_IMPLEMENTED 1
int default_open(const char* path);
int default_close(void);
int default_drvctl(unsigned int cmd, void* arg);
struct option_t {
char key[32];
char value[64];
};
int drv_handle_options(const char* options);
#define DRVCTL_GET_STATE 1
#define DRVCTL_SEND_SPACE 2
#define DRVCTL_SET_OPTION 3
#define DRVCTL_GET_RAW_CODELENGTH 4
#define DRVCTL_GET_DEVICES 5
#define DRVCTL_FREE_DEVICES 6
#define DRVCTL_NOTIFY_DECODE 7
#define DRVCTL_MAX 128
#define DRV_ERR_NOT_IMPLEMENTED 1
#define DRV_ERR_BAD_STATE 2
#define DRV_ERR_BAD_OPTION 3
#define DRV_ERR_BAD_VALUE 4
#define DRV_ERR_ENUM_EMPTY 5
#define DRV_ERR_INTERNAL 6
struct driver {
// Old-style implicit API version 1:
const char* device;
int fd;
uint32_t features;
uint32_t send_mode;
uint32_t rec_mode;
const uint32_t code_length;
int (*const open_func) (const char* device);
int (*const init_func)(void);
int (*const deinit_func) (void);
int (*const send_func)(struct ir_remote* remote,
struct ir_ncode* code);
char* (*const rec_func)(struct ir_remote* remotes);
int (*const decode_func)(struct ir_remote* remote,
struct decode_ctx_t* ctx);
int (*const drvctl_func)(unsigned int cmd, void* arg);
lirc_t (*const readdata)(lirc_t timeout);
const char* name;
unsigned int resolution;
/* API version 2 addons: */
const int api_version;
const char* driver_version;
const char* info;
int (*const close_func)(void);
/* API version 3 addons: */
const char* const device_hint;
};
#ifdef IN_DRIVER
extern struct driver drv;
#endif
extern const struct driver* const curr_driver;
#ifdef __cplusplus
}
#endif
#endif
drv
struct driver drv
The global driver data that drivers etc are accessing.
Definition driver.c:28
curr_driver
const struct driver *const curr_driver
Read-only access to drv for client code.
Definition driver.c:34
default_close
int default_close(void)
For now, a placeholder.
Definition driver.c:52
get_server_version
int get_server_version(void)
Return numeric server version, m.v.r => 10000 * m + 100 * v + r.
Definition driver.c:22
default_drvctl
int default_drvctl(unsigned int cmd, void *arg)
Return DRV_ERR_NOTIMPLEMENTED.
Definition driver.c:57
drv_handle_options
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
default_open
int default_open(const char *path)
Stores path in drv.device if non-null.
Definition driver.c:37
decode_ctx_t
State describing code, pre, post + gap and repeat state.
Definition ir_remote_types.h:137
driver
The data the driver exports i.
Definition driver.h:132
driver::api_version
const int api_version
API version (from version 2+).
Definition driver.h:234
driver::fd
int fd
Set by the driver after init().
Definition driver.h:142
driver::driver_version
const char * driver_version
Driver version (free text).
Definition driver.h:235
driver::name
const char * name
Driver name, as listed by -H help and used as argument to i –driver.
Definition driver.h:224
driver::send_mode
uint32_t send_mode
Possible values are: LIRC_MODE_RAW, LIRC_MODE_PULSE, LIRC_MODE_MODE2, LIRC_MODE_LIRCCODE.
Definition driver.h:151
driver::code_length
const uint32_t code_length
Length in bits of the code.
Definition driver.h:160
driver::decode_func
int(*const decode_func)(struct ir_remote *remote, struct decode_ctx_t *ctx)
TODO.
Definition driver.h:202
driver::features
uint32_t features
Code for the features of the present device, valid after init().
Definition driver.h:145
driver::info
const char * info
Free text driver info.
Definition driver.h:236
driver::rec_func
char *(*const rec_func)(struct ir_remote *remotes)
Receive data from remote.
Definition driver.h:197
driver::readdata
lirc_t(*const readdata)(lirc_t timeout)
Get length of next pulse/space from hardware.
Definition driver.h:218
driver::deinit_func
int(*const deinit_func)(void)
Function called when transmitting/receiving stops.
Definition driver.h:180
driver::init_func
int(*const init_func)(void)
Function called for initializing the driver and the hardware.
Definition driver.h:174
driver::send_func
int(*const send_func)(struct ir_remote *remote, struct ir_ncode *code)
Send data to the remote.
Definition driver.h:188
driver::resolution
unsigned int resolution
The resolution in microseconds of the recorded durations when reading signals.
Definition driver.h:230
driver::device_hint
const char *const device_hint
device_hint is a mean for config tools to autodetect devices.
Definition driver.h:255
driver::drvctl_func
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
driver::device
const char * device
Name of the device (string).
Definition driver.h:139
driver::close_func
int(*const close_func)(void)
Hard closing, returns 0 on OK.
Definition driver.h:238
driver::open_func
int(*const open_func)(const char *device)
Function called to do basic driver setup.
Definition driver.h:168
driver::rec_mode
uint32_t rec_mode
Possible values are: LIRC_MODE_RAW, LIRC_MODE_PULSE, LIRC_MODE_MODE2, LIRC_MODE_LIRCCODE.
Definition driver.h:157
ir_ncode
IR Command, corresponding to one (command defining) line of the configuration file.
Definition ir_remote_types.h:60
ir_remote
One remote as represented in the configuration file.
Definition ir_remote_types.h:150
option_t
Argument for DRV_SET_OPTION.
Definition driver.h:59