SCP_sensorHub.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /* SCP sensor hub driver
  2. *
  3. *
  4. * This software program is licensed subject to the GNU General Public License
  5. * (GPL).Version 2,June 1991, available at http://www.fsf.org/copyleft/gpl.html
  6. * (C) Copyright 2011 Bosch Sensortec GmbH
  7. * All Rights Reserved
  8. */
  9. #ifndef SCP_SENSOR_HUB_H
  10. #define SCP_SENSOR_HUB_H
  11. #include <linux/ioctl.h>
  12. #include <cust_acc.h>
  13. #define SCP_SENSOR_HUB_TEMP_BUFSIZE 256
  14. #define SCP_SENSOR_HUB_FIFO_SIZE 32768
  15. #define SCP_SENSOR_HUB_SUCCESS 0
  16. #define SCP_SENSOR_HUB_FAILURE (-1)
  17. struct scp_acc_hw {
  18. int i2c_num; /*!< the i2c bus used by the chip */
  19. int direction; /*!< the direction of the chip */
  20. int power_id; /*!< the VDD LDO ID of the chip,
  21. MT6516_POWER_NONE means the power is always on */
  22. int power_vol; /*!< the VDD Power Voltage used by the chip */
  23. int firlen; /*!< the length of low pass filter */
  24. int reserved;
  25. unsigned char i2c_addr[G_CUST_I2C_ADDR_NUM];
  26. int power_vio_id; /*!< the VIO LDO ID of the chip,
  27. MT6516_POWER_NONE means the power is always on */
  28. int power_vio_vol; /*!< the VIO Power Voltage used by the chip */
  29. bool is_batch_supported;
  30. };
  31. typedef enum {
  32. SENSOR_HUB_ACTIVATE = 0,
  33. SENSOR_HUB_SET_DELAY,
  34. SENSOR_HUB_GET_DATA,
  35. SENSOR_HUB_BATCH,
  36. SENSOR_HUB_SET_CONFIG,
  37. SENSOR_HUB_SET_CUST,
  38. SENSOR_HUB_NOTIFY,
  39. } SCP_ACTION;
  40. typedef enum {
  41. SCP_INIT_DONE = 0,
  42. SCP_FIFO_FULL,
  43. SCP_NOTIFY,
  44. } SCP_NOTIFY_EVENT;
  45. struct SCP_sensorData {
  46. uint8_t dataLength;
  47. uint8_t sensorType;
  48. uint8_t reserve[2];
  49. uint32_t timeStampH;
  50. uint32_t timeStampL;
  51. int16_t data[8];
  52. };
  53. struct sensorFIFO {
  54. int rp;/* use int for store DRAM FIFO LSB 32bit read pointer */
  55. int wp;
  56. uint32_t FIFOSize;
  57. struct SCP_sensorData data[0];
  58. };
  59. typedef struct {
  60. uint32_t sensorType;
  61. SCP_ACTION action;
  62. uint32_t data[10];
  63. } SCP_SENSOR_HUB_REQ;
  64. typedef struct {
  65. uint32_t sensorType;
  66. SCP_ACTION action;
  67. uint32_t errCode;
  68. } SCP_SENSOR_HUB_RSP;
  69. typedef struct {
  70. uint32_t sensorType;
  71. SCP_ACTION action;
  72. uint32_t enable; /* 0 : disable ; 1 : enable */
  73. } SCP_SENSOR_HUB_ACTIVATE_REQ;
  74. typedef SCP_SENSOR_HUB_RSP SCP_SENSOR_HUB_ACTIVATE_RSP;
  75. typedef struct {
  76. uint32_t sensorType;
  77. SCP_ACTION action;
  78. uint32_t delay; /*ms*/
  79. } SCP_SENSOR_HUB_SET_DELAY_REQ;
  80. typedef SCP_SENSOR_HUB_RSP SCP_SENSOR_HUB_SET_DELAY_RSP;
  81. typedef struct {
  82. uint32_t sensorType;
  83. SCP_ACTION action;
  84. } SCP_SENSOR_HUB_GET_DATA_REQ;
  85. typedef struct {
  86. uint32_t sensorType;
  87. SCP_ACTION action;
  88. uint32_t errCode;
  89. union {
  90. int8_t int8_Data[0];
  91. int16_t int16_Data[0];
  92. int32_t int32_Data[0];
  93. };
  94. } SCP_SENSOR_HUB_GET_DATA_RSP;
  95. typedef struct {
  96. uint32_t sensorType;
  97. SCP_ACTION action;
  98. uint32_t flag;/*see SENSORS_BATCH_WAKE_UPON_FIFO_FULL
  99. definition in hardware/libhardware/include/hardware/sensors.h*/
  100. uint32_t period_ms;/*batch reporting time in ms*/
  101. uint32_t timeout_ms;/*sampling time in ms*/
  102. } SCP_SENSOR_HUB_BATCH_REQ;
  103. typedef SCP_SENSOR_HUB_RSP SCP_SENSOR_HUB_BATCH_RSP;
  104. typedef struct {
  105. uint32_t sensorType;
  106. SCP_ACTION action;
  107. int bufferBase;/*use int to store buffer DRAM base LSB 32 bits*/
  108. uint32_t bufferSize;
  109. } SCP_SENSOR_HUB_SET_CONFIG_REQ;
  110. typedef SCP_SENSOR_HUB_RSP SCP_SENSOR_HUB_SET_CONFIG_RSP;
  111. typedef struct {
  112. uint32_t sensorType;
  113. SCP_ACTION action;
  114. uint32_t custData[10];
  115. } SCP_SENSOR_HUB_SET_CUST_REQ;
  116. typedef struct {
  117. uint32_t sensorType;
  118. SCP_ACTION action;
  119. uint32_t errCode;
  120. uint32_t custData[0];
  121. } SCP_SENSOR_HUB_SET_CUST_RSP;
  122. typedef struct {
  123. uint32_t sensorType;
  124. SCP_ACTION action;
  125. SCP_NOTIFY_EVENT event;
  126. uint32_t data[0];
  127. } SCP_SENSOR_HUB_NOTIFY_RSP;
  128. typedef union {
  129. SCP_SENSOR_HUB_REQ req;
  130. SCP_SENSOR_HUB_RSP rsp;
  131. SCP_SENSOR_HUB_ACTIVATE_REQ activate_req;
  132. SCP_SENSOR_HUB_ACTIVATE_RSP activate_rsp;
  133. SCP_SENSOR_HUB_SET_DELAY_REQ set_delay_req;
  134. SCP_SENSOR_HUB_SET_DELAY_RSP set_delay_rsp;
  135. SCP_SENSOR_HUB_GET_DATA_REQ get_data_req;
  136. SCP_SENSOR_HUB_GET_DATA_RSP get_data_rsp;
  137. SCP_SENSOR_HUB_BATCH_REQ batch_req;
  138. SCP_SENSOR_HUB_BATCH_RSP batch_rsp;
  139. SCP_SENSOR_HUB_SET_CONFIG_REQ set_config_req;
  140. SCP_SENSOR_HUB_SET_CONFIG_RSP set_config_rsp;
  141. SCP_SENSOR_HUB_SET_CUST_REQ set_cust_req;
  142. SCP_SENSOR_HUB_SET_CUST_RSP set_cust_rsp;
  143. SCP_SENSOR_HUB_NOTIFY_RSP notify_rsp;
  144. } SCP_SENSOR_HUB_DATA, *SCP_SENSOR_HUB_DATA_P;
  145. typedef int (*SCP_sensorHub_handler) (void *data, uint len);
  146. int SCP_sensorHub_req_send(SCP_SENSOR_HUB_DATA_P data, uint *len, unsigned int wait);
  147. int SCP_sensorHub_rsp_registration(int sensor, SCP_sensorHub_handler handler);
  148. #endif