activity.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #ifndef __ACTIVITY_H__
  2. #define __ACTIVITY_H__
  3. #include <linux/wakelock.h>
  4. #include <linux/interrupt.h>
  5. #include <linux/miscdevice.h>
  6. #include <linux/platform_device.h>
  7. #include <linux/input.h>
  8. #include <linux/workqueue.h>
  9. #include <linux/slab.h>
  10. #include <linux/module.h>
  11. #include <linux/hwmsensor.h>
  12. #include <linux/earlysuspend.h>
  13. #include <linux/hwmsen_dev.h>
  14. #define ACT_TAG "<ACTIVITY> "
  15. #define ACT_FUN(f) printk(ACT_TAG"%s\n", __func__)
  16. #define ACT_ERR(fmt, args...) printk(ACT_TAG"%s %d : "fmt, __func__, __LINE__, ##args)
  17. #define ACT_LOG(fmt, args...) printk(ACT_TAG fmt, ##args)
  18. #define ACT_VER(fmt, args...) printk(ACT_TAG"%s: "fmt, __func__, ##args) /* ((void)0) */
  19. #define OP_ACT_DELAY 0X01
  20. #define OP_ACT_ENABLE 0X02
  21. #define OP_ACT_GET_DATA 0X04
  22. #define ACT_INVALID_VALUE -1
  23. #define EVENT_TYPE_ACT_IN_VEHICLE ABS_X
  24. #define EVENT_TYPE_ACT_ON_BICYCLE ABS_Y
  25. #define EVENT_TYPE_ACT_ON_FOOT ABS_Z
  26. #define EVENT_TYPE_ACT_STILL ABS_RX
  27. #define EVENT_TYPE_ACT_UNKNOWN ABS_RY
  28. #define EVENT_TYPE_ACT_TILT ABS_RZ
  29. #define EVENT_TYPE_ACT_STATUS ABS_WHEEL
  30. #define ACT_VALUE_MAX (32767)
  31. #define ACT_VALUE_MIN (-32768)
  32. #define ACT_STATUS_MIN (0)
  33. #define ACT_STATUS_MAX (64)
  34. #define ACT_DIV_MAX (32767)
  35. #define ACT_DIV_MIN (1)
  36. #define MAX_CHOOSE_ACT_NUM 5
  37. struct act_control_path {
  38. int (*open_report_data)(int open); /* open data rerport to HAL */
  39. int (*enable_nodata)(int en); /* only enable not report event to HAL */
  40. int (*set_delay)(u64 delay);
  41. bool is_report_input_direct;
  42. bool is_support_batch;
  43. };
  44. typedef struct {
  45. uint16_t in_vehicle;
  46. uint16_t on_bicycle;
  47. uint16_t on_foot;
  48. uint16_t still;
  49. uint16_t unknown;
  50. uint16_t tilt;
  51. } activity_t;
  52. struct act_data_path {
  53. int (*get_data)(u16 *value, int *status);
  54. int vender_div;
  55. };
  56. struct act_init_info {
  57. char *name;
  58. int (*init)(void);
  59. int (*uninit)(void);
  60. struct platform_driver *platform_diver_addr;
  61. };
  62. struct act_data {
  63. hwm_sensor_data act_data;
  64. int data_updata;
  65. /* struct mutex lock; */
  66. };
  67. struct act_drv_obj {
  68. void *self;
  69. int polling;
  70. int (*act_operate)(void *self, uint32_t command, void *buff_in, int size_in,
  71. void *buff_out, int size_out, int *actualout);
  72. };
  73. struct act_context {
  74. struct input_dev *idev;
  75. struct miscdevice mdev;
  76. struct work_struct report;
  77. struct mutex act_op_mutex;
  78. atomic_t delay; /*polling period for reporting input event */
  79. atomic_t wake; /*user-space request to wake-up, used with stop */
  80. struct timer_list timer; /* polling timer */
  81. atomic_t trace;
  82. struct early_suspend early_drv;
  83. atomic_t early_suspend;
  84. struct act_data drv_data;
  85. struct act_control_path act_ctl;
  86. struct act_data_path act_data;
  87. bool is_active_nodata; /* Active, but HAL don't need data sensor. such as orientation need */
  88. bool is_active_data; /* Active and HAL need data . */
  89. bool is_first_data_after_enable;
  90. bool is_polling_run;
  91. bool is_batch_enable;
  92. };
  93. /* driver API for internal */
  94. /* extern int act_enable_nodata(int enable); */
  95. /* extern int act_attach(struct act_drv_obj *obj); */
  96. /* driver API for third party vendor */
  97. /* for auto detect */
  98. extern int act_driver_add(struct act_init_info *obj);
  99. extern int act_data_report(hwm_sensor_data data, int status);
  100. extern int act_register_control_path(struct act_control_path *ctl);
  101. extern int act_register_data_path(struct act_data_path *data);
  102. #endif