disable some mediatekl custom warnings
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / include / linux / batch.h
1
2 #ifndef __BATCH_H__
3 #define __BATCH_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/string.h>
17 #include <linux/hwmsen_dev.h>
18
19 #define BATCH_TAG "<BATCHDEV> "
20 #define BATCH_FUN(f) printk(BATCH_TAG"%s\n", __func__)
21 #define BATCH_ERR(fmt, args...) printk(BATCH_TAG"%s %d : "fmt, __func__, __LINE__, ##args)
22 #define BATCH_LOG(fmt, args...) printk(BATCH_TAG fmt, ##args)
23 #define BATCH_VER(fmt, args...) printk(BATCH_TAG"%s: "fmt, __func__, ##args) //((void)0)
24
25 #define OP_BATCH_DELAY 0X01
26 #define OP_BATCH_ENABLE 0X02
27 #define OP_BATCH_GET_DATA 0X04
28
29 #define BATCH_INVALID_VALUE -1
30
31 #define EVENT_TYPE_BATCH_X ABS_X
32 #define EVENT_TYPE_BATCH_Y ABS_Y
33 #define EVENT_TYPE_BATCH_Z ABS_Z
34 #define EVENT_TYPE_BATCH_STATUS ABS_WHEEL
35 #define EVENT_TYPE_SENSORTYPE REL_RZ
36 #define EVENT_TYPE_BATCH_VALUE ABS_RX
37 #define EVENT_TYPE_END_FLAG REL_RY
38 #define EVENT_TYPE_TIMESTAMP_HI REL_HWHEEL
39 #define EVENT_TYPE_TIMESTAMP_LO REL_DIAL
40
41
42 #define BATCH_VALUE_MAX (32767)
43 #define BATCH_VALUE_MIN (-32768)
44 #define BATCH_STATUS_MIN (0)
45 #define BATCH_STATUS_MAX (64)
46 #define BATCH_TYPE_MIN (0)
47 #define BATCH_TYPE_MAX (64)
48 #define BATCH_DIV_MAX (32767)
49 #define BATCH_DIV_MIN (1)
50
51 enum {
52 SENSORS_BATCH_DRY_RUN = 0x00000001,
53 SENSORS_BATCH_WAKE_UPON_FIFO_FULL = 0x00000002
54 };
55 #define MAX_CHOOSE_BATCH_NUM 5
56 struct batch_init_info
57 {
58 char *name;
59 int (*init)(void);
60 int (*uninit)(void);
61 struct platform_driver* platform_diver_addr;
62 };
63
64 struct batch_control_path
65 {
66 int (*enable_hw_batch)(int handle, int enable, long long samplingPeriodNs,long long maxBatchReportLatencyNs);//let the hardware know that data should be written to fifo
67 int (*flush)(int handle);//open data rerport to HAL
68 };
69
70 struct batch_timestamp_info
71 {
72 int64_t start_t;
73 int64_t end_t;
74 uint32_t total_count;
75 uint32_t num;
76 };
77
78 struct batch_data_path
79 {
80 int (*get_data)(int handle, hwm_sensor_data *data);//sensor data is got one by one, return value: 1 stands for data read not finish 0 stands for read data done
81 int (*get_fifo_status)(int *len, int *status, char *reserved, struct batch_timestamp_info *p_batch_timestampe_info);
82 int delay;//report latency for every sensor
83 int flags;//reserved
84 int is_batch_supported;//batch mode supporting status
85 int div;
86 int is_timestamp_supported;
87 };
88
89 struct batch_dev_list
90 {
91 struct batch_control_path ctl_dev[MAX_ANDROID_SENSOR_NUM+1];//ctl_dev[max] is used for sensor HUB driver to control sensor HUB , ctl_dev[1]... are for single sensor batch mode control
92 struct batch_data_path data_dev[MAX_ANDROID_SENSOR_NUM+1];//data_dev[max] is used for sensor HUB driver to access single fifo sensor data, data_dev[1]... are for single sensor fifo sensor data
93 };
94
95
96 struct batch_context {
97 struct input_dev *idev;
98 struct miscdevice mdev;
99 struct work_struct report;
100 struct mutex batch_op_mutex;
101
102 atomic_t delay; /*polling period for reporting input event*/
103 atomic_t wake; /*user-space request to wake-up, used with stop*/
104 struct timer_list timer; /* polling timer */
105 atomic_t trace;
106
107 struct early_suspend early_drv;
108 struct wake_lock read_data_wake_lock;
109 atomic_t early_suspend;
110
111 struct batch_dev_list dev_list;
112
113 uint32_t active_sensor;
114 int batch_result;
115 int flush_result;
116 bool is_first_data_after_enable;
117 bool is_polling_run;
118 int div_flag;
119
120 struct batch_timestamp_info timestamp_info[MAX_ANDROID_SENSOR_NUM+1];
121 };
122
123 typedef enum {
124 TYPE_NON = 0,
125 TYPE_MOTION = 1,
126 TYPE_GESTURE = 2,
127 TYPE_BATCHTIMEOUT = 3,
128 TYPE_BATCHFULL = 4,
129 TYPE_ERROR = 5,
130 TYPE_DATAREADY = 6
131 } BATCH_NOTIFY_TYPE;
132
133 //driver API for third party vendor
134 extern int batch_notify(BATCH_NOTIFY_TYPE type);
135 extern int batch_driver_add(struct batch_init_info* obj);
136 extern void report_batch_data(struct input_dev *dev, hwm_sensor_data *data);
137 extern void report_batch_finish(struct input_dev *dev, int handle);
138 extern int batch_register_control_path(int handle, struct batch_control_path *ctl);//when you register control path of sensor hub driver, use handle = [MAX_ANDROID_SENSOR_NUM+1]
139 extern int batch_register_data_path(int handle, struct batch_data_path *data);//when you register control path of sensor hub driver, use handle = [MAX_ANDROID_SENSOR_NUM+1]
140 extern int batch_register_support_info(int handle, int support, int div, int timestamp_supported);
141 #endif