summaryrefslogtreecommitdiff
path: root/io-module/buttons.h
diff options
context:
space:
mode:
Diffstat (limited to 'io-module/buttons.h')
-rw-r--r--io-module/buttons.h84
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_ */