glance_gesture.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #ifndef __GLG_H__
  2. #define __GLG_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 GLG_TAG "<GLANCE_GESTURE> "
  15. #define GLG_FUN(f) printk(GLG_TAG"%s\n", __func__)
  16. #define GLG_ERR(fmt, args...) printk(GLG_TAG"%s %d : "fmt, __func__, __LINE__, ##args)
  17. #define GLG_LOG(fmt, args...) printk(GLG_TAG fmt, ##args)
  18. #define GLG_VER(fmt, args...) printk(GLG_TAG"%s: "fmt, __func__, ##args) /* ((void)0) */
  19. /* #define OP_GLG_DELAY 0X01 */
  20. #define OP_GLG_ENABLE 0X02
  21. /* #define OP_GLG_GET_DATA 0X04 */
  22. #define GLG_INVALID_VALUE -1
  23. #define EVENT_TYPE_GLG_VALUE REL_X
  24. #define GLG_VALUE_MAX (32767)
  25. #define GLG_VALUE_MIN (-32768)
  26. #define GLG_STATUS_MIN (0)
  27. #define GLG_STATUS_MAX (64)
  28. #define GLG_DIV_MAX (32767)
  29. #define GLG_DIV_MIN (1)
  30. typedef enum {
  31. GLG_DEACTIVATE,
  32. GLG_ACTIVATE,
  33. GLG_SUSPEND,
  34. GLG_RESUME
  35. } glg_state_e;
  36. struct glg_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 glg_data_path {
  43. int (*get_data)(u16 *value, int *status);
  44. };
  45. struct glg_init_info {
  46. char *name;
  47. int (*init)(void);
  48. int (*uninit)(void);
  49. struct platform_driver *platform_diver_addr;
  50. };
  51. struct glg_data {
  52. hwm_sensor_data glg_data;
  53. int data_updata;
  54. /* struct mutex lock; */
  55. };
  56. struct glg_drv_obj {
  57. void *self;
  58. int polling;
  59. int (*glg_operate)(void *self, uint32_t command, void *buff_in, int size_in,
  60. void *buff_out, int size_out, int *actualout);
  61. };
  62. struct glg_context {
  63. struct input_dev *idev;
  64. struct miscdevice mdev;
  65. struct work_struct report;
  66. struct mutex glg_op_mutex;
  67. atomic_t wake; /*user-space request to wake-up, used with stop */
  68. atomic_t trace;
  69. struct timer_list notify_timer;
  70. struct early_suspend early_drv;
  71. atomic_t early_suspend;
  72. atomic_t suspend;
  73. struct glg_data drv_data;
  74. struct glg_control_path glg_ctl;
  75. struct glg_data_path glg_data;
  76. bool is_active_nodata; /* Active, but HAL don't need data sensor. such as orientation need */
  77. bool is_active_data; /* Active and HAL need data . */
  78. bool is_batch_enable; /* version2.this is used for judging whether sensor is in batch mode */
  79. };
  80. extern int glg_notify(void);
  81. extern int glg_driver_add(struct glg_init_info *obj);
  82. extern int glg_register_control_path(struct glg_control_path *ctl);
  83. extern int glg_register_data_path(struct glg_data_path *data);
  84. #endif