Merge tag 'v3.10.55' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / mach-mt8127 / tpw8127_tb_c_l / gyroscope / gyroscope.h
1
2 #ifndef __GYROSCOPE_H__
3 #define __GYROSCOPE_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 GYRO_TAG "<GYROSCOPE> "
20 #define GYRO_FUN(f) printk(GYRO_TAG"%s\n", __func__)
21 #define GYRO_ERR(fmt, args...) printk(GYRO_TAG"%s %d : "fmt, __func__, __LINE__, ##args)
22 #define GYRO_LOG(fmt, args...) printk(GYRO_TAG fmt, ##args)
23 #define GYRO_VER(fmt, args...) printk(GYRO_TAG"%s: "fmt, __func__, ##args) //((void)0)
24
25 #define OP_GYRO_DELAY 0X01
26 #define OP_GYRO_ENABLE 0X02
27 #define OP_GYRO_GET_DATA 0X04
28
29 #define GYRO_INVALID_VALUE -1
30
31 #define EVENT_TYPE_GYRO_X ABS_X
32 #define EVENT_TYPE_GYRO_Y ABS_Y
33 #define EVENT_TYPE_GYRO_Z ABS_Z
34 #define EVENT_TYPE_GYRO_STATUS ABS_WHEEL
35
36
37 #define GYRO_VALUE_MAX (32767)
38 #define GYRO_VALUE_MIN (-32768)
39 #define GYRO_STATUS_MIN (0)
40 #define GYRO_STATUS_MAX (64)
41 #define GYRO_DIV_MAX (32767)
42 #define GYRO_DIV_MIN (1)
43
44
45 #define MAX_CHOOSE_GYRO_NUM 5
46
47 struct gyro_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 bool is_report_input_direct;
53 bool is_support_batch;
54 };
55
56 struct gyro_data_path
57 {
58 int (*get_data)(int *x,int *y, int *z,int *status);
59 int vender_div;
60 };
61
62 struct gyro_init_info
63 {
64 char *name;
65 int (*init)(void);
66 int (*uninit)(void);
67 struct platform_driver* platform_diver_addr;
68 };
69
70 struct gyro_data{
71 hwm_sensor_data gyro_data ;
72 int data_updata;
73 //struct mutex lock;
74 };
75
76 struct gyro_drv_obj {
77 void *self;
78 int polling;
79 int (*gyro_operate)(void* self, uint32_t command, void* buff_in, int size_in,
80 void* buff_out, int size_out, int* actualout);
81 };
82
83 struct gyro_context {
84 struct input_dev *idev;
85 struct miscdevice mdev;
86 struct work_struct report;
87 struct mutex gyro_op_mutex;
88 atomic_t delay; /*polling period for reporting input event*/
89 atomic_t wake; /*user-space request to wake-up, used with stop*/
90 struct timer_list timer; /* polling timer */
91 atomic_t trace;
92
93 struct early_suspend early_drv;
94 atomic_t early_suspend;
95 //struct gyro_drv_obj drv_obj;
96 struct gyro_data drv_data;
97 struct gyro_control_path gyro_ctl;
98 struct gyro_data_path gyro_data;
99 bool is_active_nodata; // Active, but HAL don't need data sensor. such as orientation need
100 bool is_active_data; // Active and HAL need data .
101 bool is_first_data_after_enable;
102 bool is_polling_run;
103 bool is_batch_enable;
104 };
105
106 //driver API for internal
107 //extern int gyro_enable_nodata(int enable);
108 //extern int gyro_attach(struct gyro_drv_obj *obj);
109 //driver API for third party vendor
110
111 //for auto detect
112 extern int gyro_driver_add(struct gyro_init_info* obj) ;
113 extern int gyro_data_report(int x, int y, int z,int status);
114 extern int gyro_register_control_path(struct gyro_control_path *ctl);
115 extern int gyro_register_data_path(struct gyro_data_path *data);
116 #endif