barometer.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #ifndef __BARO_H__
  2. #define __BARO_H__
  3. #include <linux/i2c.h>
  4. #include <linux/irq.h>
  5. #include <linux/uaccess.h>
  6. #include <linux/kobject.h>
  7. #include <linux/types.h>
  8. #include <linux/atomic.h>
  9. #include <linux/io.h>
  10. #include <linux/sched.h>
  11. #include <linux/wakelock.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/miscdevice.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/input.h>
  16. #include <linux/workqueue.h>
  17. #include <linux/slab.h>
  18. #include <linux/delay.h>
  19. #include <linux/module.h>
  20. #include <batch.h>
  21. #include <sensors_io.h>
  22. #include <hwmsensor.h>
  23. #include <hwmsen_dev.h>
  24. #include "barometer_factory.h"
  25. #define BARO_TAG "<BAROMETER> "
  26. #define BARO_FUN(f) pr_debug(BARO_TAG"%s\n", __func__)
  27. #define BARO_ERR(fmt, args...) pr_err(BARO_TAG"%s %d : "fmt, __func__, __LINE__, ##args)
  28. #define BARO_LOG(fmt, args...) pr_debug(BARO_TAG fmt, ##args)
  29. #define BARO_VER(fmt, args...) pr_debug(BARO_TAG"%s: "fmt, __func__, ##args)
  30. #define OP_BARO_DELAY 0X01
  31. #define OP_BARO_ENABLE 0X02
  32. #define OP_BARO_GET_DATA 0X04
  33. #define BARO_INVALID_VALUE -1
  34. #define EVENT_TYPE_BARO_VALUE REL_X
  35. #define EVENT_TYPE_BARO_STATUS ABS_WHEEL
  36. #define EVENT_TYPE_BARO_TIMESTAMP_HI REL_HWHEEL
  37. #define EVENT_TYPE_BARO_TIMESTAMP_LO REL_DIAL
  38. #define BARO_VALUE_MAX (32767)
  39. #define BARO_VALUE_MIN (-32768)
  40. #define BARO_STATUS_MIN (0)
  41. #define BARO_STATUS_MAX (64)
  42. #define BARO_DIV_MAX (32767)
  43. #define BARO_DIV_MIN (1)
  44. #define MAX_CHOOSE_BARO_NUM 5
  45. struct baro_control_path {
  46. int (*open_report_data)(int open);
  47. int (*enable_nodata)(int en);
  48. int (*set_delay)(u64 delay);
  49. int (*baroess_data_fifo)(void);
  50. bool is_report_input_direct;
  51. bool is_support_batch;
  52. bool is_use_common_factory;
  53. };
  54. struct baro_data_path {
  55. int (*get_data)(int *value, int *status);
  56. int (*get_raw_data)(int type, int *value);
  57. int vender_div;
  58. };
  59. struct baro_init_info {
  60. char *name;
  61. int (*init)(void);
  62. int (*uninit)(void);
  63. struct platform_driver *platform_diver_addr;
  64. };
  65. struct baro_data {
  66. struct hwm_sensor_data baro_data;
  67. int data_updata;
  68. };
  69. struct baro_drv_obj {
  70. void *self;
  71. int polling;
  72. int (*baro_operate)(void *self, uint32_t command, void *buff_in, int size_in,
  73. void *buff_out, int size_out, int *actualout);
  74. };
  75. struct baro_context {
  76. struct input_dev *idev;
  77. struct miscdevice mdev;
  78. struct work_struct report;
  79. struct mutex baro_op_mutex;
  80. atomic_t delay;
  81. atomic_t wake;
  82. struct timer_list timer;
  83. struct hrtimer hrTimer;
  84. ktime_t target_ktime;
  85. atomic_t trace;
  86. struct workqueue_struct *baro_workqueue;
  87. struct baro_data drv_data;
  88. struct baro_control_path baro_ctl;
  89. struct baro_data_path baro_data;
  90. bool is_active_nodata;
  91. bool is_active_data;
  92. bool is_first_data_after_enable;
  93. bool is_polling_run;
  94. bool is_batch_enable;
  95. };
  96. extern int baro_driver_add(struct baro_init_info *obj);
  97. extern int baro_data_report(struct input_dev *dev, int value, int status, int64_t nt);
  98. extern int baro_register_control_path(struct baro_control_path *ctl);
  99. extern int baro_register_data_path(struct baro_data_path *data);
  100. #endif