face_down.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #ifndef __FDN_H__
  2. #define __FDN_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 FDN_TAG "<FACE_DOWN> "
  15. #define FDN_FUN(f) printk(FDN_TAG"%s\n", __func__)
  16. #define FDN_ERR(fmt, args...) printk(FDN_TAG"%s %d : "fmt, __func__, __LINE__, ##args)
  17. #define FDN_LOG(fmt, args...) printk(FDN_TAG fmt, ##args)
  18. #define FDN_VER(fmt, args...) printk(FDN_TAG"%s: "fmt, __func__, ##args) /* ((void)0) */
  19. /* #define OP_FDN_DELAY 0X01 */
  20. #define OP_FDN_ENABLE 0X02
  21. /* #define OP_FDN_GET_DATA 0X04 */
  22. #define FDN_INVALID_VALUE -1
  23. #define EVENT_TYPE_FDN_VALUE REL_X
  24. #define FDN_VALUE_MAX (32767)
  25. #define FDN_VALUE_MIN (-32768)
  26. #define FDN_STATUS_MIN (0)
  27. #define FDN_STATUS_MAX (64)
  28. #define FDN_DIV_MAX (32767)
  29. #define FDN_DIV_MIN (1)
  30. typedef enum {
  31. FDN_DEACTIVATE,
  32. FDN_ACTIVATE,
  33. FDN_SUSPEND,
  34. FDN_RESUME
  35. } fdn_state_e;
  36. struct fdn_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 fdn_data_path {
  43. int (*get_data)(u16 *value, int *status);
  44. };
  45. struct fdn_init_info {
  46. char *name;
  47. int (*init)(void);
  48. int (*uninit)(void);
  49. struct platform_driver *platform_diver_addr;
  50. };
  51. struct fdn_data {
  52. hwm_sensor_data fdn_data;
  53. int data_updata;
  54. /* struct mutex lock; */
  55. };
  56. struct fdn_drv_obj {
  57. void *self;
  58. int polling;
  59. int (*fdn_operate)(void *self, uint32_t command, void *buff_in, int size_in,
  60. void *buff_out, int size_out, int *actualout);
  61. };
  62. struct fdn_context {
  63. struct input_dev *idev;
  64. struct miscdevice mdev;
  65. struct work_struct report;
  66. struct mutex fdn_op_mutex;
  67. atomic_t wake; /*user-space request to wake-up, used with stop */
  68. atomic_t trace;
  69. struct early_suspend early_drv;
  70. atomic_t early_suspend;
  71. atomic_t suspend;
  72. struct fdn_data drv_data;
  73. struct fdn_control_path fdn_ctl;
  74. struct fdn_data_path fdn_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 fdn_notify(void);
  80. extern int fdn_driver_add(struct fdn_init_info *obj);
  81. extern int fdn_register_control_path(struct fdn_control_path *ctl);
  82. extern int fdn_register_data_path(struct fdn_data_path *data);
  83. #endif