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>
19 #define MAG_TAG "<MAGNETIC> "
20 #define MAG_FUN(f) printk(MAG_TAG"%s\n", __func__)
21 #define MAG_ERR(fmt, args...) printk(MAG_TAG"%s %d : "fmt, __func__, __LINE__, ##args)
22 #define MAG_LOG(fmt, args...) printk(MAG_TAG fmt, ##args)
23 #define MAG_VER(fmt, args...) printk(MAG_TAG"%s: "fmt, __func__, ##args) //((void)0)
25 #define OP_MAG_DELAY 0X01
26 #define OP_MAG_ENABLE 0X02
27 #define OP_MAG_GET_DATA 0X04
30 #define MAG_INVALID_VALUE -1
32 #define EVENT_TYPE_MAGEL_X ABS_X
33 #define EVENT_TYPE_MAGEL_Y ABS_Y
34 #define EVENT_TYPE_MAGEL_Z ABS_Z
35 #define EVENT_DIV_MAGEL ABS_RUDDER
36 #define EVENT_TYPE_MAGEL_STATUS ABS_WHEEL
38 #define EVENT_TYPE_O_X ABS_RX
39 #define EVENT_TYPE_O_Y ABS_RY
40 #define EVENT_TYPE_O_Z ABS_RZ
41 #define EVENT_DIV_O ABS_GAS
42 #define EVENT_TYPE_O_STATUS ABS_THROTTLE
44 #define MAG_DIV_MAX (32767)
45 #define MAG_DIV_MIN (1)
47 #define MAG_VALUE_MAX (32767)
48 #define MAG_VALUE_MIN (-32768)
49 #define MAG_STATUS_MIN (0)
50 #define MAG_STATUS_MAX (64)
52 #define MAX_CHOOSE_G_NUM 5
54 #define MAX_M_V_SENSOR 5
56 #define ID_M_V_MAGNETIC 0
57 #define ID_M_V_ORIENTATION 1
59 typedef enum mag_type
{
71 struct mag_control_path
73 int (*m_open_report_data
)(int en
);
74 int (*m_set_delay
)(u64 delay
);
75 int (*m_enable
)(int en
);
76 int (*o_open_report_data
)(int en
);
77 int (*o_set_delay
)(u64 delay
);
78 int (*o_enable
)(int en
);
79 bool is_report_input_direct
;
80 bool is_support_batch
;
89 struct platform_driver
* platform_diver_addr
;
93 hwm_sensor_data mag_data
;
101 int (*mag_operate
)(void* self
, uint32_t command
, void* buff_in
, int size_in
,
102 void* buff_out
, int size_out
, int* actualout
);
106 struct input_dev
*idev
;
107 struct miscdevice mdev
;
108 struct work_struct report
;
109 struct mutex mag_op_mutex
;
110 atomic_t delay
; /*polling period for reporting input event*/
111 atomic_t wake
; /*user-space request to wake-up, used with stop*/
112 struct timer_list timer
; /* polling timer */
115 struct early_suspend early_drv
;
116 struct mag_data_path mag_dev_data
;
117 struct mag_control_path mag_ctl
;
118 atomic_t early_suspend
;
119 struct mag_drv_obj
* drv_obj
[MAX_M_V_SENSOR
];
120 struct mag_data drv_data
[MAX_M_V_SENSOR
];
121 bool is_first_data_after_enable
;
123 bool is_batch_enable
;
124 uint32_t active_nodata_sensor
;
125 uint32_t active_data_sensor
;
126 //bool mag_type_enabled[MAX_M_V_SENSOR];
127 //uint32_t mag_active_sensor;
131 extern int mag_attach(int sensor
,struct mag_drv_obj
*obj
);
133 extern int mag_driver_add(struct mag_init_info
* obj
) ;
134 extern int mag_data_report(MAG_TYPE type
,int x
, int y
, int z
,int status
);
135 extern int mag_register_control_path(struct mag_control_path
*ctl
);
136 extern int mag_register_data_path(struct mag_data_path
*ctl
);