humidity.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #ifndef __HUMIDITY_H__
  2. #define __HUMIDITY_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 "humidity_factory.h"
  25. #define HMDY_TAG "<HUMIDITY> "
  26. #define HMDY_FUN(f) pr_debug(HMDY_TAG"%s\n", __func__)
  27. #define HMDY_ERR(fmt, args...) pr_err(HMDY_TAG"%s %d : "fmt, __func__, __LINE__, ##args)
  28. #define HMDY_LOG(fmt, args...) pr_debug(HMDY_TAG fmt, ##args)
  29. #define HMDY_VER(fmt, args...) pr_debug(HMDY_TAG"%s: "fmt, __func__, ##args)
  30. #define OP_HMDY_DELAY 0X01
  31. #define OP_HMDY_ENABLE 0X02
  32. #define OP_HMDY_GET_DATA 0X04
  33. #define HMDY_INVALID_VALUE -1
  34. #define EVENT_TYPE_HMDY_VALUE REL_X
  35. #define EVENT_TYPE_HMDY_STATUS ABS_WHEEL
  36. #define HMDY_VALUE_MAX (32767)
  37. #define HMDY_VALUE_MIN (-32768)
  38. #define HMDY_STATUS_MIN (0)
  39. #define HMDY_STATUS_MAX (64)
  40. #define HMDY_DIV_MAX (32767)
  41. #define HMDY_DIV_MIN (1)
  42. #define MAX_CHOOSE_HMDY_NUM 5
  43. struct hmdy_control_path {
  44. int (*open_report_data)(int open);
  45. int (*enable_nodata)(int en);
  46. int (*set_delay)(u64 delay);
  47. int (*hmdyess_data_fifo)(void);
  48. bool is_report_input_direct;
  49. bool is_support_batch;
  50. bool is_use_common_factory;
  51. };
  52. struct hmdy_data_path {
  53. int (*get_data)(int *value, int *status);
  54. int (*get_raw_data)(int type, int *value);
  55. int vender_div;
  56. };
  57. struct hmdy_init_info {
  58. char *name;
  59. int (*init)(void);
  60. int (*uninit)(void);
  61. struct platform_driver *platform_diver_addr;
  62. };
  63. struct hmdy_data {
  64. struct hwm_sensor_data hmdy_data;
  65. int data_updata;
  66. };
  67. struct hmdy_drv_obj {
  68. void *self;
  69. int polling;
  70. int (*hmdy_operate)(void *self, uint32_t command, void *buff_in, int size_in, void *buff_out, int size_out,
  71. int *actualout);
  72. };
  73. struct hmdy_context {
  74. struct input_dev *idev;
  75. struct miscdevice mdev;
  76. struct work_struct report;
  77. struct mutex hmdy_op_mutex;
  78. atomic_t delay;
  79. atomic_t wake;
  80. struct timer_list timer;
  81. atomic_t trace;
  82. struct hmdy_data drv_data;
  83. struct hmdy_control_path hmdy_ctl;
  84. struct hmdy_data_path hmdy_data;
  85. bool is_active_nodata;
  86. bool is_active_data;
  87. bool is_first_data_after_enable;
  88. bool is_polling_run;
  89. bool is_batch_enable;
  90. };
  91. extern int hmdy_driver_add(struct hmdy_init_info *obj);
  92. extern int hmdy_data_report(struct input_dev *dev, int value, int status);
  93. extern int hmdy_register_control_path(struct hmdy_control_path *ctl);
  94. extern int hmdy_register_data_path(struct hmdy_data_path *data);
  95. #endif