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