step_counter.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #ifndef __STEP_C_H__
  2. #define __STEP_C_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 STEP_C_TAG "<STEP_COUNTER> "
  15. #define STEP_C_FUN(f) pr_debug(STEP_C_TAG"%s\n", __func__)
  16. #define STEP_C_ERR(fmt, args...) pr_err(STEP_C_TAG"%s %d : "fmt, __func__, __LINE__, ##args)
  17. #define STEP_C_LOG(fmt, args...) pr_debug(STEP_C_TAG fmt, ##args)
  18. #define STEP_C_VER(fmt, args...) pr_debug(STEP_C_TAG"%s: "fmt, __func__, ##args) /* ((void)0) */
  19. #define OP_STEP_C_DELAY 0X01
  20. #define OP_STEP_C_ENABLE 0X02
  21. #define OP_STEP_C_GET_DATA 0X04
  22. #define STEP_C_INVALID_VALUE -1
  23. #define EVENT_TYPE_STEP_C_VALUE ABS_X
  24. #define EVENT_TYPE_STEP_C_STATUS ABS_WHEEL
  25. #define EVENT_TYPE_STEP_DETECTOR_VALUE REL_Y
  26. #define EVENT_TYPE_SIGNIFICANT_VALUE REL_Z
  27. #define STEP_C_VALUE_MAX (32767)
  28. #define STEP_C_VALUE_MIN (-32768)
  29. #define STEP_C_STATUS_MIN (0)
  30. #define STEP_C_STATUS_MAX (64)
  31. #define STEP_C_DIV_MAX (32767)
  32. #define STEP_C_DIV_MIN (1)
  33. #define MAX_CHOOSE_STEP_C_NUM 5
  34. struct step_c_control_path {
  35. int (*open_report_data)(int open); /* open data rerport to HAL */
  36. int (*enable_nodata)(int en); /* only enable not report event to HAL */
  37. int (*enable_step_detect)(int en);
  38. int (*enable_significant)(int en);
  39. int (*set_delay)(u64 delay);
  40. bool is_report_input_direct;
  41. bool is_support_batch; /* version2.used for batch mode support flag */
  42. };
  43. struct step_c_data_path {
  44. int (*get_data)(u64 *value, int *status);
  45. int (*get_data_step_d)(u64 *value, int *status);
  46. int (*get_data_significant)(u64 *value, int *status);
  47. int vender_div;
  48. };
  49. struct step_c_init_info {
  50. char *name;
  51. int (*init)(void);
  52. int (*uninit)(void);
  53. struct platform_driver *platform_diver_addr;
  54. };
  55. struct step_c_data {
  56. hwm_sensor_data step_c_data;
  57. int data_updata;
  58. /* struct mutex lock; */
  59. };
  60. struct step_c_drv_obj {
  61. void *self;
  62. int polling;
  63. int (*step_c_operate)(void *self, uint32_t command, void *buff_in, int size_in,
  64. void *buff_out, int size_out, int *actualout);
  65. };
  66. struct step_c_context {
  67. struct input_dev *idev;
  68. struct miscdevice mdev;
  69. struct work_struct report;
  70. struct mutex step_c_op_mutex;
  71. atomic_t delay; /*polling period for reporting input event */
  72. atomic_t wake; /*user-space request to wake-up, used with stop */
  73. struct timer_list timer; /* polling timer */
  74. atomic_t trace;
  75. struct early_suspend early_drv;
  76. atomic_t early_suspend;
  77. struct step_c_data drv_data;
  78. struct step_c_control_path step_c_ctl;
  79. struct step_c_data_path step_c_data;
  80. bool is_active_nodata; /* Active, but HAL don't need data sensor. such as orientation need */
  81. bool is_active_data; /* Active and HAL need data . */
  82. bool is_first_data_after_enable;
  83. bool is_polling_run;
  84. bool is_batch_enable; /* version2.this is used for judging whether sensor is in batch mode */
  85. };
  86. /* for auto detect */
  87. typedef enum {
  88. TYPE_STEP_NON = 0,
  89. TYPE_STEP_DETECTOR = 1,
  90. TYPE_SIGNIFICANT = 2
  91. } STEP_NOTIFY_TYPE;
  92. extern int step_notify(STEP_NOTIFY_TYPE type);
  93. extern int step_c_driver_add(struct step_c_init_info *obj);
  94. extern int step_c_data_report(struct input_dev *dev, int value, int status);
  95. extern int step_c_register_control_path(struct step_c_control_path *ctl);
  96. extern int step_c_register_data_path(struct step_c_data_path *data);
  97. #endif