rtw_bt_mp.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. *
  19. ******************************************************************************/
  20. #ifndef __RTW_BT_MP_H
  21. #define __RTW_BT_MP_H
  22. #if(MP_DRIVER == 1)
  23. #pragma pack(1)
  24. // definition for BT_UP_OP_BT_READY
  25. #define MP_BT_NOT_READY 0
  26. #define MP_BT_READY 1
  27. // definition for BT_UP_OP_BT_SET_MODE
  28. typedef enum _MP_BT_MODE{
  29. MP_BT_MODE_RF_TXRX_TEST_MODE = 0,
  30. MP_BT_MODE_BT20_DUT_TEST_MODE = 1,
  31. MP_BT_MODE_BT40_DIRECT_TEST_MODE = 2,
  32. MP_BT_MODE_CONNECT_TEST_MODE = 3,
  33. MP_BT_MODE_MAX
  34. }MP_BT_MODE,*PMP_BT_MODE;
  35. // definition for BT_UP_OP_BT_SET_TX_RX_PARAMETER
  36. typedef struct _BT_TXRX_PARAMETERS{
  37. u1Byte txrxChannel;
  38. u4Byte txrxTxPktCnt;
  39. u1Byte txrxTxPktInterval;
  40. u1Byte txrxPayloadType;
  41. u1Byte txrxPktType;
  42. u2Byte txrxPayloadLen;
  43. u4Byte txrxPktHeader;
  44. u1Byte txrxWhitenCoeff;
  45. u1Byte txrxBdaddr[6];
  46. u1Byte txrxTxGainIndex;
  47. } BT_TXRX_PARAMETERS, *PBT_TXRX_PARAMETERS;
  48. // txrxPktType
  49. typedef enum _MP_BT_PKT_TYPE{
  50. MP_BT_PKT_DH1 = 0,
  51. MP_BT_PKT_DH3 = 1,
  52. MP_BT_PKT_DH5 = 2,
  53. MP_BT_PKT_2DH1 = 3,
  54. MP_BT_PKT_2DH3 = 4,
  55. MP_BT_PKT_2DH5 = 5,
  56. MP_BT_PKT_3DH1 = 6,
  57. MP_BT_PKT_3DH3 = 7,
  58. MP_BT_PKT_3DH5 = 8,
  59. MP_BT_PKT_LE = 9,
  60. MP_BT_PKT_MAX
  61. }MP_BT_PKT_TYPE,*PMP_BT_PKT_TYPE;
  62. // txrxPayloadType
  63. typedef enum _MP_BT_PAYLOAD_TYPE{
  64. MP_BT_PAYLOAD_01010101 = 0,
  65. MP_BT_PAYLOAD_ALL_1 = 1,
  66. MP_BT_PAYLOAD_ALL_0 = 2,
  67. MP_BT_PAYLOAD_11110000 = 3,
  68. MP_BT_PAYLOAD_PRBS9 = 4,
  69. MP_BT_PAYLOAD_MAX
  70. }MP_BT_PAYLOAD_TYPE,*PMP_BT_PAYLOAD_TYPE;
  71. // definition for BT_UP_OP_BT_TEST_CTRL
  72. typedef enum _MP_BT_TEST_CTRL{
  73. MP_BT_TEST_STOP_ALL_TESTS = 0,
  74. MP_BT_TEST_START_RX_TEST = 1,
  75. MP_BT_TEST_START_PACKET_TX_TEST = 2,
  76. MP_BT_TEST_START_CONTINUOUS_TX_TEST = 3,
  77. MP_BT_TEST_START_INQUIRY_SCAN_TEST = 4,
  78. MP_BT_TEST_START_PAGE_SCAN_TEST = 5,
  79. MP_BT_TEST_START_INQUIRY_PAGE_SCAN_TEST = 6,
  80. MP_BT_TEST_START_LEGACY_CONNECT_TEST = 7,
  81. MP_BT_TEST_START_LE_CONNECT_TEST_INITIATOR = 8,
  82. MP_BT_TEST_START_LE_CONNECT_TEST_ADVERTISER = 9,
  83. MP_BT_TEST_MAX
  84. }MP_BT_TEST_CTRL,*PMP_BT_TEST_CTRL;
  85. typedef enum _RTL_EXT_C2H_EVT
  86. {
  87. EXT_C2H_WIFI_FW_ACTIVE_RSP = 0,
  88. EXT_C2H_TRIG_BY_BT_FW = 1,
  89. MAX_EXT_C2HEVENT
  90. }RTL_EXT_C2H_EVT;
  91. // return status definition to the user layer
  92. typedef enum _BT_CTRL_STATUS{
  93. BT_STATUS_SUCCESS = 0x00, // Success
  94. BT_STATUS_BT_OP_SUCCESS = 0x01, // bt fw op execution success
  95. BT_STATUS_H2C_SUCCESS = 0x02, // H2c success
  96. BT_STATUS_H2C_TIMTOUT = 0x03, // H2c timeout
  97. BT_STATUS_H2C_BT_NO_RSP = 0x04, // H2c sent, bt no rsp
  98. BT_STATUS_C2H_SUCCESS = 0x05, // C2h success
  99. BT_STATUS_C2H_REQNUM_MISMATCH = 0x06, // bt fw wrong rsp
  100. BT_STATUS_OPCODE_U_VERSION_MISMATCH = 0x07, // Upper layer OP code version mismatch.
  101. BT_STATUS_OPCODE_L_VERSION_MISMATCH = 0x08, // Lower layer OP code version mismatch.
  102. BT_STATUS_UNKNOWN_OPCODE_U = 0x09, // Unknown Upper layer OP code
  103. BT_STATUS_UNKNOWN_OPCODE_L = 0x0a, // Unknown Lower layer OP code
  104. BT_STATUS_PARAMETER_FORMAT_ERROR_U = 0x0b, // Wrong parameters sent by upper layer.
  105. BT_STATUS_PARAMETER_FORMAT_ERROR_L = 0x0c, // bt fw parameter format is not consistency
  106. BT_STATUS_PARAMETER_OUT_OF_RANGE_U = 0x0d, // uppery layer parameter value is out of range
  107. BT_STATUS_PARAMETER_OUT_OF_RANGE_L = 0x0e, // bt fw parameter value is out of range
  108. BT_STATUS_UNKNOWN_STATUS_L = 0x0f, // bt returned an defined status code
  109. BT_STATUS_UNKNOWN_STATUS_H = 0x10, // driver need to do error handle or not handle-well.
  110. BT_STATUS_WRONG_LEVEL = 0x11, // should be under passive level
  111. BT_STATUS_MAX
  112. }BT_CTRL_STATUS,*PBT_CTRL_STATUS;
  113. // OP codes definition between the user layer and driver
  114. typedef enum _BT_CTRL_OPCODE_UPPER{
  115. BT_UP_OP_BT_READY = 0x00,
  116. BT_UP_OP_BT_SET_MODE = 0x01,
  117. BT_UP_OP_BT_SET_TX_RX_PARAMETER = 0x02,
  118. BT_UP_OP_BT_SET_GENERAL = 0x03,
  119. BT_UP_OP_BT_GET_GENERAL = 0x04,
  120. BT_UP_OP_BT_TEST_CTRL = 0x05,
  121. BT_UP_OP_TEST_BT = 0x06,
  122. BT_UP_OP_MAX
  123. }BT_CTRL_OPCODE_UPPER,*PBT_CTRL_OPCODE_UPPER;
  124. typedef enum _BT_SET_GENERAL{
  125. BT_GSET_REG = 0x00,
  126. BT_GSET_RESET = 0x01,
  127. BT_GSET_TARGET_BD_ADDR = 0x02,
  128. BT_GSET_TX_PWR_FINETUNE = 0x03,
  129. BT_GSET_UPDATE_BT_PATCH = 0x04,
  130. BT_GSET_MAX
  131. }BT_SET_GENERAL,*PBT_SET_GENERAL;
  132. typedef enum _BT_GET_GENERAL{
  133. BT_GGET_REG = 0x00,
  134. BT_GGET_STATUS = 0x01,
  135. BT_GGET_REPORT = 0x02,
  136. BT_GGET_MAX
  137. }BT_GET_GENERAL,*PBT_GET_GENERAL;
  138. // definition for BT_UP_OP_BT_SET_GENERAL
  139. typedef enum _BT_REG_TYPE{
  140. BT_REG_RF = 0,
  141. BT_REG_MODEM = 1,
  142. BT_REG_BLUEWIZE = 2,
  143. BT_REG_VENDOR = 3,
  144. BT_REG_LE = 4,
  145. BT_REG_MAX
  146. }BT_REG_TYPE,*PBT_REG_TYPE;
  147. // definition for BT_UP_OP_BT_GET_GENERAL
  148. typedef enum _BT_REPORT_TYPE{
  149. BT_REPORT_RX_PACKET_CNT = 0,
  150. BT_REPORT_RX_ERROR_BITS = 1,
  151. BT_REPORT_RSSI = 2,
  152. BT_REPORT_CFO_HDR_QUALITY = 3,
  153. BT_REPORT_CONNECT_TARGET_BD_ADDR = 4,
  154. BT_REPORT_MAX
  155. }BT_REPORT_TYPE,*PBT_REPORT_TYPE;
  156. VOID
  157. MPTBT_Test(
  158. IN PADAPTER Adapter,
  159. IN u1Byte opCode,
  160. IN u1Byte byte1,
  161. IN u1Byte byte2,
  162. IN u1Byte byte3
  163. );
  164. NDIS_STATUS
  165. MPTBT_SendOidBT(
  166. IN PADAPTER pAdapter,
  167. IN PVOID InformationBuffer,
  168. IN ULONG InformationBufferLength,
  169. OUT PULONG BytesRead,
  170. OUT PULONG BytesNeeded
  171. );
  172. VOID
  173. MPTBT_FwC2hBtMpCtrl(
  174. PADAPTER Adapter,
  175. pu1Byte tmpBuf,
  176. u1Byte length
  177. );
  178. void MPh2c_timeout_handle(void *FunctionContext);
  179. VOID mptbt_BtControlProcess(
  180. PADAPTER Adapter,
  181. PVOID pInBuf
  182. );
  183. #define BT_H2C_MAX_RETRY 1
  184. #define BT_MAX_C2H_LEN 20
  185. typedef struct _BT_REQ_CMD{
  186. UCHAR opCodeVer;
  187. UCHAR OpCode;
  188. USHORT paraLength;
  189. UCHAR pParamStart[100];
  190. } BT_REQ_CMD, *PBT_REQ_CMD;
  191. typedef struct _BT_RSP_CMD{
  192. USHORT status;
  193. USHORT paraLength;
  194. UCHAR pParamStart[100];
  195. } BT_RSP_CMD, *PBT_RSP_CMD;
  196. typedef struct _BT_H2C{
  197. u1Byte opCodeVer:4;
  198. u1Byte reqNum:4;
  199. u1Byte opCode;
  200. u1Byte buf[100];
  201. }BT_H2C, *PBT_H2C;
  202. typedef struct _BT_EXT_C2H{
  203. u1Byte extendId;
  204. u1Byte statusCode:4;
  205. u1Byte retLen:4;
  206. u1Byte opCodeVer:4;
  207. u1Byte reqNum:4;
  208. u1Byte buf[100];
  209. }BT_EXT_C2H, *PBT_EXT_C2H;
  210. typedef enum _BT_OPCODE_STATUS{
  211. BT_OP_STATUS_SUCCESS = 0x00, // Success
  212. BT_OP_STATUS_VERSION_MISMATCH = 0x01,
  213. BT_OP_STATUS_UNKNOWN_OPCODE = 0x02,
  214. BT_OP_STATUS_ERROR_PARAMETER = 0x03,
  215. BT_OP_STATUS_MAX
  216. }BT_OPCODE_STATUS,*PBT_OPCODE_STATUS;
  217. //OP codes definition between driver and bt fw
  218. typedef enum _BT_CTRL_OPCODE_LOWER{
  219. BT_LO_OP_GET_BT_VERSION = 0x00,
  220. BT_LO_OP_RESET = 0x01,
  221. BT_LO_OP_TEST_CTRL = 0x02,
  222. BT_LO_OP_SET_BT_MODE = 0x03,
  223. BT_LO_OP_SET_CHNL_TX_GAIN = 0x04,
  224. BT_LO_OP_SET_PKT_TYPE_LEN = 0x05,
  225. BT_LO_OP_SET_PKT_CNT_L_PL_TYPE = 0x06,
  226. BT_LO_OP_SET_PKT_CNT_H_PKT_INTV = 0x07,
  227. BT_LO_OP_SET_PKT_HEADER = 0x08,
  228. BT_LO_OP_SET_WHITENCOEFF = 0x09,
  229. BT_LO_OP_SET_BD_ADDR_L = 0x0a,
  230. BT_LO_OP_SET_BD_ADDR_H = 0x0b,
  231. BT_LO_OP_WRITE_REG_ADDR = 0x0c,
  232. BT_LO_OP_WRITE_REG_VALUE = 0x0d,
  233. BT_LO_OP_GET_BT_STATUS = 0x0e,
  234. BT_LO_OP_GET_BD_ADDR_L = 0x0f,
  235. BT_LO_OP_GET_BD_ADDR_H = 0x10,
  236. BT_LO_OP_READ_REG = 0x11,
  237. BT_LO_OP_SET_TARGET_BD_ADDR_L = 0x12,
  238. BT_LO_OP_SET_TARGET_BD_ADDR_H = 0x13,
  239. BT_LO_OP_SET_TX_POWER_CALIBRATION = 0x14,
  240. BT_LO_OP_GET_RX_PKT_CNT_L = 0x15,
  241. BT_LO_OP_GET_RX_PKT_CNT_H = 0x16,
  242. BT_LO_OP_GET_RX_ERROR_BITS_L = 0x17,
  243. BT_LO_OP_GET_RX_ERROR_BITS_H = 0x18,
  244. BT_LO_OP_GET_RSSI = 0x19,
  245. BT_LO_OP_GET_CFO_HDR_QUALITY_L = 0x1a,
  246. BT_LO_OP_GET_CFO_HDR_QUALITY_H = 0x1b,
  247. BT_LO_OP_GET_TARGET_BD_ADDR_L = 0x1c,
  248. BT_LO_OP_GET_TARGET_BD_ADDR_H = 0x1d,
  249. BT_LO_OP_MAX
  250. }BT_CTRL_OPCODE_LOWER,*PBT_CTRL_OPCODE_LOWER;
  251. #endif /* #if(MP_DRIVER == 1) */
  252. #endif // #ifndef __INC_MPT_BT_H