/* * buttons.h * * Created on: Apr 27, 2018 * Author: leonid */ #ifndef IO_MODULE_BUTTONS_H_ #define IO_MODULE_BUTTONS_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0) #include #endif #include "mts_io_module.h" #include "mts_io.h" #include "version.h" #define BUTTON_CHECK_PER_SEC 8 #define BUTTON_INTERVAL (HZ / BUTTON_CHECK_PER_SEC) #define BUTTON_HOLD_COUNT (BUTTON_CHECK_PER_SEC * 3) #define BUTTON_LONG_HOLD_COUNT (BUTTON_CHECK_PER_SEC * 30) typedef struct button_info { char name[32]; char label_pin[32]; char label_monitor[32]; char label_monitor_intervals[32]; /* PID to notify */ pid_t pid; /* Unix signals */ int short_signal; int long_signal; int extra_long_signal; /* Monitor intervals */ int short_interval; int long_interval; /* Internal fields */ int pressed_count; bool sent_extra_long; } button_info_t, *button_info_pt; extern void init_buttons(void); extern void cleanup_buttons(void); extern int set_buttons (button_info_pt* platform_buttons); extern ssize_t mts_attr_show_button_monitor_intervals(struct device *dev, struct device_attribute *attr, char *buf); extern ssize_t mts_attr_store_button_monitor_intervals(struct device *dev, struct device_attribute *attr, const char *buf, size_t count); extern ssize_t mts_attr_show_button_monitor(struct device *dev, struct device_attribute *attr, char *buf); extern ssize_t mts_attr_store_button_monitor(struct device *dev, struct device_attribute *attr, const char *buf, size_t count); // Reset button is common for all devices. It is defined in buttons.c extern button_info_t reset_button; extern struct device_attribute dev_attr_reset_monitor_intervals; extern struct device_attribute dev_attr_reset_monitor; extern struct device_attribute dev_attr_reset; extern button_info_pt default_buttons[]; #endif /* IO_MODULE_BUTTONS_H_ */