Commit | Line | Data |
---|---|---|
6fa3eb70 S |
1 | |
2 | #ifndef __ALSPS_H__ | |
3 | #define __ALSPS_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 ALSPS_TAG "<ALS/PS> " | |
20 | #define ALSPS_FUN(f) printk(ALSPS_TAG"%s\n", __func__) | |
21 | #define ALSPS_ERR(fmt, args...) printk(ALSPS_TAG"%s %d : "fmt, __func__, __LINE__, ##args) | |
22 | #define ALSPS_LOG(fmt, args...) printk(ALSPS_TAG fmt, ##args) | |
23 | #define ALSPS_VER(fmt, args...) printk(ALSPS_TAG"%s: "fmt, __func__, ##args) //((void)0) | |
24 | ||
25 | #define OP_ALSPS_DELAY 0X01 | |
26 | #define OP_ALSPS_ENABLE 0X02 | |
27 | #define OP_ALSPS_GET_DATA 0X04 | |
28 | ||
29 | #define ALSPS_INVALID_VALUE -1 | |
30 | ||
31 | #define EVENT_TYPE_ALS_VALUE ABS_X | |
32 | #define EVENT_TYPE_PS_VALUE ABS_Z | |
33 | #define EVENT_TYPE_ALS_STATUS ABS_WHEEL | |
34 | #define EVENT_TYPE_PS_STATUS ABS_Y | |
35 | ||
36 | ||
37 | #define ALSPS_VALUE_MAX (32767) | |
38 | #define ALSPS_VALUE_MIN (-32768) | |
39 | #define ALSPS_STATUS_MIN (0) | |
40 | #define ALSPS_STATUS_MAX (64) | |
41 | #define ALSPS_DIV_MAX (32767) | |
42 | #define ALSPS_DIV_MIN (1) | |
43 | ||
44 | ||
45 | #define MAX_CHOOSE_ALSPS_NUM 5 | |
46 | ||
47 | struct als_control_path | |
48 | { | |
49 | int (*open_report_data)(int open);//open data rerport to HAL | |
50 | int (*enable_nodata)(int en);//only enable not report event to HAL | |
51 | int (*set_delay)(u64 delay); | |
52 | int (*access_data_fifo)();//version2.used for flush operate | |
53 | bool is_report_input_direct; | |
54 | bool is_support_batch;//version2.used for batch mode support flag | |
55 | bool is_polling_mode; | |
56 | }; | |
57 | ||
58 | struct ps_control_path | |
59 | { | |
60 | int (*open_report_data)(int open);//open data rerport to HAL | |
61 | int (*enable_nodata)(int en);//only enable not report event to HAL | |
62 | int (*set_delay)(u64 delay); | |
63 | int (*access_data_fifo)();//version2.used for flush operate | |
64 | bool is_report_input_direct; | |
65 | bool is_support_batch;//version2.used for batch mode support flag | |
66 | bool is_polling_mode; | |
67 | }; | |
68 | ||
69 | struct als_data_path | |
70 | { | |
71 | int (*get_data)(int *als_value, int *status); | |
72 | int vender_div; | |
73 | }; | |
74 | ||
75 | struct ps_data_path | |
76 | { | |
77 | int (*get_data)(int *ps_value, int *status); | |
78 | int vender_div; | |
79 | }; | |
80 | ||
81 | struct alsps_init_info | |
82 | { | |
83 | char *name; | |
84 | int (*init)(void); | |
85 | int (*uninit)(void); | |
86 | struct platform_driver* platform_diver_addr; | |
87 | }; | |
88 | ||
89 | struct alsps_data{ | |
90 | hwm_sensor_data als_data ; | |
91 | hwm_sensor_data ps_data ; | |
92 | int data_updata; | |
93 | }; | |
94 | ||
95 | struct alsps_drv_obj { | |
96 | void *self; | |
97 | int polling; | |
98 | int (*alsps_operate)(void* self, uint32_t command, void* buff_in, int size_in, | |
99 | void* buff_out, int size_out, int* actualout); | |
100 | }; | |
101 | ||
102 | struct alsps_context { | |
103 | struct input_dev *idev; | |
104 | struct miscdevice mdev; | |
105 | struct work_struct report_ps; | |
106 | struct work_struct report_als; | |
107 | struct mutex alsps_op_mutex; | |
108 | struct timer_list timer_als; /*als polling timer */ | |
109 | struct timer_list timer_ps; /* ps polling timer */ | |
110 | ||
111 | atomic_t trace; | |
112 | atomic_t delay_als; /*als polling period for reporting input event*/ | |
113 | atomic_t delay_ps;/*ps polling period for reporting input event*/ | |
114 | atomic_t wake; /*user-space request to wake-up, used with stop*/ | |
115 | ||
116 | struct early_suspend early_drv; | |
117 | atomic_t early_suspend; | |
118 | ||
119 | struct alsps_data drv_data; | |
120 | struct als_control_path als_ctl; | |
121 | struct als_data_path als_data; | |
122 | struct ps_control_path ps_ctl; | |
123 | struct ps_data_path ps_data; | |
124 | ||
125 | bool is_als_active_nodata;// Active, but HAL don't need data sensor. such as orientation need | |
126 | bool is_als_active_data;// Active and HAL need data . | |
127 | bool is_ps_active_nodata;// Active, but HAL don't need data sensor. such as orientation need | |
128 | bool is_ps_active_data;// Active and HAL need data . | |
129 | ||
130 | bool is_als_first_data_after_enable; | |
131 | bool is_ps_first_data_after_enable; | |
132 | bool is_als_polling_run; | |
133 | bool is_ps_polling_run; | |
134 | bool is_als_batch_enable; //version2.this is used for judging whether sensor is in batch mode | |
135 | bool is_ps_batch_enable; //version2.this is used for judging whether sensor is in batch mode | |
136 | ||
137 | }; | |
138 | ||
139 | //for auto detect | |
140 | extern int alsps_driver_add(struct alsps_init_info* obj) ; | |
141 | extern int ps_report_interrupt_data(int value); | |
142 | extern int als_data_report(struct input_dev *dev, int value,int status); | |
143 | extern int als_register_control_path(struct als_control_path *ctl); | |
144 | extern int als_register_data_path(struct als_data_path *data); | |
145 | extern int ps_data_report(struct input_dev *dev, int value,int status); | |
146 | extern int ps_register_control_path(struct ps_control_path *ctl); | |
147 | extern int ps_register_data_path(struct ps_data_path *data); | |
148 | ||
149 | ||
150 | ||
151 | ||
152 | ||
153 | #endif |