blob: c9cd198b28d2235de63a53ecd0bbdb9ef83625f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/*
* 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/kmod.h>
#include <linux/ctype.h>
#include <linux/io.h>
#include <linux/module.h>
#include "mts_io_module.h"
#include "mts_io.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_ */
|