Commit | Line | Data |
---|---|---|
6fa3eb70 S |
1 | |
2 | #ifndef __ACC_H__ | |
3 | #define __ACC_H__ | |
4 | ||
5 | ||
6 | #include <linux/wakelock.h> | |
7 | #include <linux/interrupt.h> | |
8 | #include <linux/miscdevice.h> | |
9 | #include <linux/platform_device.h> | |
10 | #include <linux/input.h> | |
11 | #include <linux/workqueue.h> | |
12 | #include <linux/slab.h> | |
13 | #include <linux/module.h> | |
14 | #include <linux/hwmsensor.h> | |
15 | #include <linux/earlysuspend.h> | |
16 | #include <linux/hwmsen_dev.h> | |
17 | ||
18 | ||
19 | #define ACC_TAG "<ACCELEROMETER> " | |
20 | #define ACC_FUN(f) printk(KERN_ERR ACC_TAG"%s\n", __func__) | |
21 | #define ACC_ERR(fmt, args...) printk(KERN_ERR ACC_TAG"%s %d : "fmt, __func__, __LINE__, ##args) | |
22 | #define ACC_LOG(fmt, args...) printk(KERN_ERR ACC_TAG fmt, ##args) | |
23 | #define ACC_VER(fmt, args...) printk(KERN_ERR ACC_TAG"%s: "fmt, __func__, ##args) //((void)0) | |
24 | ||
25 | #define OP_ACC_DELAY 0X01 | |
26 | #define OP_ACC_ENABLE 0X02 | |
27 | #define OP_ACC_GET_DATA 0X04 | |
28 | ||
29 | #define ACC_INVALID_VALUE -1 | |
30 | ||
31 | #define EVENT_TYPE_ACCEL_X ABS_X | |
32 | #define EVENT_TYPE_ACCEL_Y ABS_Y | |
33 | #define EVENT_TYPE_ACCEL_Z ABS_Z | |
34 | #define EVENT_TYPE_ACCEL_STATUS ABS_WHEEL | |
35 | #define EVENT_TYPE_ACCEL_DIV ABS_GAS | |
36 | ||
37 | ||
38 | #define ACC_VALUE_MAX (32767) | |
39 | #define ACC_VALUE_MIN (-32768) | |
40 | #define ACC_STATUS_MIN (0) | |
41 | #define ACC_STATUS_MAX (64) | |
42 | #define ACC_DIV_MAX (32767) | |
43 | #define ACC_DIV_MIN (1) | |
44 | ||
45 | ||
46 | #define MAX_CHOOSE_G_NUM 5 | |
47 | ||
48 | struct acc_control_path | |
49 | { | |
50 | int (*open_report_data)(int open);//open data rerport to HAL | |
51 | int (*enable_nodata)(int en);//only enable not report event to HAL | |
52 | int (*set_delay)(u64 delay); | |
53 | int (*access_data_fifo)();//version2.used for flush operate | |
54 | bool is_report_input_direct; | |
55 | bool is_support_batch;//version2.used for batch mode support flag | |
56 | }; | |
57 | ||
58 | struct acc_data_path | |
59 | { | |
60 | int (*get_data)(int *x,int *y, int *z,int *status); | |
61 | int vender_div; | |
62 | }; | |
63 | ||
64 | struct acc_init_info | |
65 | { | |
66 | char *name; | |
67 | int (*init)(void); | |
68 | int (*uninit)(void); | |
69 | struct platform_driver* platform_diver_addr; | |
70 | }; | |
71 | ||
72 | struct acc_data{ | |
73 | hwm_sensor_data acc_data ; | |
74 | int data_updata; | |
75 | //struct mutex lock; | |
76 | }; | |
77 | ||
78 | struct acc_drv_obj { | |
79 | void *self; | |
80 | int polling; | |
81 | int (*acc_operate)(void* self, uint32_t command, void* buff_in, int size_in, | |
82 | void* buff_out, int size_out, int* actualout); | |
83 | }; | |
84 | ||
85 | struct acc_context { | |
86 | struct input_dev *idev; | |
87 | struct miscdevice mdev; | |
88 | struct work_struct report; | |
89 | struct mutex acc_op_mutex; | |
90 | atomic_t delay; /*polling period for reporting input event*/ | |
91 | atomic_t wake; /*user-space request to wake-up, used with stop*/ | |
92 | struct timer_list timer; /* polling timer */ | |
93 | atomic_t trace; | |
94 | ||
95 | struct early_suspend early_drv; | |
96 | atomic_t early_suspend; | |
97 | //struct acc_drv_obj drv_obj; | |
98 | struct acc_data drv_data; | |
99 | struct acc_control_path acc_ctl; | |
100 | struct acc_data_path acc_data; | |
101 | bool is_active_nodata; // Active, but HAL don't need data sensor. such as orientation need | |
102 | bool is_active_data; // Active and HAL need data . | |
103 | bool is_first_data_after_enable; | |
104 | bool is_polling_run; | |
105 | bool is_batch_enable; //version2.this is used for judging whether sensor is in batch mode | |
106 | }; | |
107 | ||
108 | //driver API for internal | |
109 | //extern int acc_enable_nodata(int enable); | |
110 | //extern int acc_attach(struct acc_drv_obj *obj); | |
111 | //driver API for third party vendor | |
112 | ||
113 | //for auto detect | |
114 | extern int acc_driver_add(struct acc_init_info* obj) ; | |
115 | extern int acc_data_report(int x, int y, int z,int status); | |
116 | extern int acc_register_control_path(struct acc_control_path *ctl); | |
117 | extern int acc_register_data_path(struct acc_data_path *data); | |
118 | ||
119 | ||
120 | ||
121 | ||
122 | ||
123 | #endif |