Commit | Line | Data |
---|---|---|
6fa3eb70 S |
1 | #ifndef __TILT_H__ |
2 | #define __TILT_H__ | |
3 | ||
4 | ||
5 | #include <linux/wakelock.h> | |
6 | #include <linux/interrupt.h> | |
7 | #include <linux/miscdevice.h> | |
8 | #include <linux/platform_device.h> | |
9 | #include <linux/input.h> | |
10 | #include <linux/workqueue.h> | |
11 | #include <linux/slab.h> | |
12 | #include <linux/module.h> | |
13 | #include <linux/hwmsensor.h> | |
14 | #include <linux/earlysuspend.h> | |
15 | #include <linux/hwmsen_dev.h> | |
16 | ||
17 | ||
18 | #define TILT_TAG "<TILT_DETECTOR> " | |
19 | #define TILT_FUN(f) printk(TILT_TAG"%s\n", __func__) | |
20 | #define TILT_ERR(fmt, args...) printk(TILT_TAG"%s %d : "fmt, __func__, __LINE__, ##args) | |
21 | #define TILT_LOG(fmt, args...) printk(TILT_TAG fmt, ##args) | |
22 | #define TILT_VER(fmt, args...) printk(TILT_TAG"%s: "fmt, __func__, ##args) //((void)0) | |
23 | ||
24 | //#define OP_TILT_DELAY 0X01 | |
25 | #define OP_TILT_ENABLE 0X02 | |
26 | //#define OP_TILT_GET_DATA 0X04 | |
27 | ||
28 | #define TILT_INVALID_VALUE -1 | |
29 | ||
30 | #define EVENT_TYPE_TILT_VALUE REL_X | |
31 | ||
32 | #define TILT_VALUE_MAX (32767) | |
33 | #define TILT_VALUE_MIN (-32768) | |
34 | #define TILT_STATUS_MIN (0) | |
35 | #define TILT_STATUS_MAX (64) | |
36 | #define TILT_DIV_MAX (32767) | |
37 | #define TILT_DIV_MIN (1) | |
38 | ||
39 | typedef enum { | |
40 | TILT_DEACTIVATE, | |
41 | TILT_ACTIVATE, | |
42 | TILT_SUSPEND, | |
43 | TILT_RESUME | |
44 | } tilt_state_e; | |
45 | ||
46 | struct tilt_control_path | |
47 | { | |
48 | // int (*enable_nodata)(int en);//only enable not report event to HAL | |
49 | int (*open_report_data)(int open);//open data rerport to HAL | |
50 | // int (*enable)(int en); | |
51 | //bool is_support_batch;//version2.used for batch mode support flag | |
52 | }; | |
53 | ||
54 | struct tilt_data_path | |
55 | { | |
56 | int (*get_data)(u16 *value, int *status); | |
57 | }; | |
58 | ||
59 | struct tilt_init_info | |
60 | { | |
61 | char *name; | |
62 | int (*init)(void); | |
63 | int (*uninit)(void); | |
64 | struct platform_driver* platform_diver_addr; | |
65 | }; | |
66 | ||
67 | struct tilt_data{ | |
68 | hwm_sensor_data tilt_data ; | |
69 | int data_updata; | |
70 | //struct mutex lock; | |
71 | }; | |
72 | ||
73 | struct tilt_drv_obj { | |
74 | void *self; | |
75 | int polling; | |
76 | int (*tilt_operate)(void* self, uint32_t command, void* buff_in, int size_in, | |
77 | void* buff_out, int size_out, int* actualout); | |
78 | }; | |
79 | ||
80 | struct tilt_context { | |
81 | struct input_dev *idev; | |
82 | struct miscdevice mdev; | |
83 | struct work_struct report; | |
84 | struct mutex tilt_op_mutex; | |
85 | atomic_t wake; /*user-space request to wake-up, used with stop*/ | |
86 | atomic_t trace; | |
87 | ||
88 | struct early_suspend early_drv; | |
89 | atomic_t early_suspend; | |
90 | atomic_t suspend; | |
91 | ||
92 | struct tilt_data drv_data; | |
93 | struct tilt_control_path tilt_ctl; | |
94 | struct tilt_data_path tilt_data; | |
95 | bool is_active_nodata; // Active, but HAL don't need data sensor. such as orientation need | |
96 | bool is_active_data; // Active and HAL need data . | |
97 | bool is_batch_enable; //version2.this is used for judging whether sensor is in batch mode | |
98 | }; | |
99 | ||
100 | extern int tilt_notify(void); | |
101 | extern int tilt_driver_add(struct tilt_init_info* obj) ; | |
102 | extern int tilt_register_control_path(struct tilt_control_path *ctl); | |
103 | extern int tilt_register_data_path(struct tilt_data_path *data); | |
104 | ||
105 | #endif |