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>
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)
24 //#define OP_TILT_DELAY 0X01
25 #define OP_TILT_ENABLE 0X02
26 //#define OP_TILT_GET_DATA 0X04
28 #define TILT_INVALID_VALUE -1
30 #define EVENT_TYPE_TILT_VALUE REL_X
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)
46 struct tilt_control_path
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
56 int (*get_data
)(u16
*value
, int *status
);
64 struct platform_driver
* platform_diver_addr
;
68 hwm_sensor_data tilt_data
;
76 int (*tilt_operate
)(void* self
, uint32_t command
, void* buff_in
, int size_in
,
77 void* buff_out
, int size_out
, int* actualout
);
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*/
88 struct early_suspend early_drv
;
89 atomic_t early_suspend
;
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
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
);