freefall.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #ifndef __FREEFALL_H__
  2. #define __FREEFALL_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 FREEFALL_TAG "<FREEFALL> "
  15. #define FREEFALL_FUN(f) printk(FREEFALL_TAG"%s\n", __func__)
  16. #define FREEFALL_ERR(fmt, args...) printk(FREEFALL_TAG"%s %d : "fmt, __func__, __LINE__, ##args)
  17. #define FREEFALL_LOG(fmt, args...) printk(FREEFALL_TAG fmt, ##args)
  18. #define FREEFALL_VER(fmt, args...) printk(FREEFALL_TAG"%s: "fmt, __func__, ##args) /* ((void)0) */
  19. /* #define OP_FREEFALL_DELAY 0X01 */
  20. #define OP_FREEFALL_ENABLE 0X02
  21. /* #define OP_FREEFALL_GET_DATA 0X04 */
  22. #define FREEFALL_INVALID_VALUE -1
  23. #define EVENT_TYPE_FREEFALL_VALUE REL_X
  24. #define FREEFALL_VALUE_MAX (32767)
  25. #define FREEFALL_VALUE_MIN (-32768)
  26. #define FREEFALL_STATUS_MIN (0)
  27. #define FREEFALL_STATUS_MAX (64)
  28. #define FREEFALL_DIV_MAX (32767)
  29. #define FREEFALL_DIV_MIN (1)
  30. typedef enum {
  31. FREEFALL_DEACTIVATE,
  32. FREEFALL_ACTIVATE,
  33. FREEFALL_SUSPEND,
  34. FREEFALL_RESUME
  35. } freefall_state_e;
  36. struct freefall_control_path {
  37. /* int (*enable_nodata)(int en);//only enable not report event to HAL */
  38. int (*open_report_data)(int open); /* open data rerport to HAL */
  39. /* int (*enable)(int en); */
  40. /* bool is_support_batch;//version2.used for batch mode support flag */
  41. };
  42. struct freefall_data_path {
  43. int (*get_data)(u16 *value, int *status);
  44. };
  45. struct freefall_init_info {
  46. char *name;
  47. int (*init)(void);
  48. int (*uninit)(void);
  49. struct platform_driver *platform_diver_addr;
  50. };
  51. struct freefall_data {
  52. hwm_sensor_data freefall_data;
  53. int data_updata;
  54. };
  55. struct freefall_drv_obj {
  56. void *self;
  57. int polling;
  58. int (*freefall_operate)(void *self, uint32_t command, void *buff_in, int size_in,
  59. void *buff_out, int size_out, int *actualout);
  60. };
  61. struct freefall_context {
  62. struct input_dev *idev;
  63. struct miscdevice mdev;
  64. struct work_struct report;
  65. struct mutex freefall_op_mutex;
  66. atomic_t wake; /*user-space request to wake-up, used with stop */
  67. atomic_t trace;
  68. struct timer_list notify_timer;
  69. struct early_suspend early_drv;
  70. atomic_t early_suspend;
  71. atomic_t suspend;
  72. struct freefall_data drv_data;
  73. struct freefall_control_path freefall_ctl;
  74. struct freefall_data_path freefall_data;
  75. bool is_active_nodata; /* Active, but HAL don't need data sensor. such as orientation need */
  76. bool is_active_data; /* Active and HAL need data . */
  77. bool is_batch_enable; /* version2.this is used for judging whether sensor is in batch mode */
  78. };
  79. extern int freefall_notify(void);
  80. extern int freefall_driver_add(struct freefall_init_info *obj);
  81. extern int freefall_register_control_path(struct freefall_control_path *ctl);
  82. extern int freefall_register_data_path(struct freefall_data_path *data);
  83. #endif