diff options
author | John Klug <john.klug@multitech.com> | 2018-05-23 10:14:11 -0500 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2018-05-23 10:14:11 -0500 |
commit | c31d619c83ba2a6c7c803082e804d18da657a389 (patch) | |
tree | f1b751dd1f3ae58a6e722b201b0e64b759ae03b4 /io-module/buttons.h | |
parent | 27a24df1a2c713b070559fc5404258d7b691c833 (diff) | |
download | mts-io-c31d619c83ba2a6c7c803082e804d18da657a389.tar.gz mts-io-c31d619c83ba2a6c7c803082e804d18da657a389.tar.bz2 mts-io-c31d619c83ba2a6c7c803082e804d18da657a389.zip |
Merge in global logic mts-io hotspot code.2.0.5
Diffstat (limited to 'io-module/buttons.h')
-rw-r--r-- | io-module/buttons.h | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/io-module/buttons.h b/io-module/buttons.h new file mode 100644 index 0000000..d324929 --- /dev/null +++ b/io-module/buttons.h @@ -0,0 +1,84 @@ +/* + * buttons.h + * + * Created on: Apr 27, 2018 + * Author: leonid + */ + +#ifndef IO_MODULE_BUTTONS_H_ +#define IO_MODULE_BUTTONS_H_ + +#include <linux/delay.h> +#include <linux/ioctl.h> +#include <linux/input.h> +#include <linux/cdev.h> +#include <linux/clk.h> +#include <linux/sched.h> +#include <linux/reboot.h> +#include <linux/uaccess.h> +#include <linux/gpio.h> +#include <linux/sched.h> +#include <linux/workqueue.h> +#include <linux/platform_device.h> +#include <linux/device.h> +#include <linux/bitops.h> +#include <linux/spi/spi.h> +#include <linux/i2c/at24.h> +#include <linux/kmod.h> +#include <linux/ctype.h> +#include <linux/io.h> +#include <linux/module.h> + +#include "mts_io.h" + +#define NEW_BUTTON_INTERFACE + +#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, 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_ */ |