drv_wcn_ipc.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _DRV_WCN_IPC_H_
  13. #define _DRV_WCN_IPC_H_
  14. #include "osi_compiler.h"
  15. #include "drv_uart.h"
  16. OSI_EXTERN_C_BEGIN
  17. /**
  18. * \brief opaque data struct of wcn ipc uart
  19. */
  20. typedef struct drvWcnIpcUart drvWcnIpcUart_t;
  21. /**
  22. *\brief set bt power rollback
  23. *
  24. *This function is used to reduce the power of bt by 1db
  25. *
  26. *\param if_power_rollback reduce when 1,and not when 0.
  27. */
  28. void drvWcnSetBtPowerRollback(uint32_t if_power_rollback);
  29. /**
  30. * \brief initialize btfw start psram
  31. *
  32. * The main purpose of the func is for dynamic config btfw runing addr and space size
  33. * \param btfw_base ,psram addr load btfw
  34. * \param btfw_ramsize ,psram size used in btfw
  35. */
  36. void drvWcnSetBtfwStartParam(uint32_t btfw_base, uint32_t btfw_ramsize);
  37. /**
  38. * \brief set max adv num
  39. *
  40. * The main purpose of the func is set the max adv num for scan filter,
  41. * \param max_adv_num ,set the max adv num for scan filter,value 0~60,0 is disable
  42. */
  43. void drvWcnSetBtMaxAdvNum(uint32_t max_adv_num);
  44. /**
  45. * \brief initialize wcn ipc
  46. *
  47. * The main purpose of wcn ipc is to provide one instance of
  48. * \p drvWcnIpcUart_t.
  49. */
  50. void drvWcnIpcInit(void);
  51. /**
  52. * \brief reset wcn ipc
  53. *
  54. * This should be called at reload wcn firmware and reset wcn.
  55. */
  56. void drvWcnIpcReset(void);
  57. /**
  58. * \brief open wcn ipc uart
  59. *
  60. * There is buffer for rx (from wcn to ap). It can reduce the latency to
  61. * fetch rx data from shared memory.
  62. *
  63. * At open, the rx data in shared memory will be kept.
  64. *
  65. * \param cb event callback
  66. * \param rx_size rx fifo size
  67. * \param cb_ctx event callback context
  68. * \param event_mask event mask
  69. * \return
  70. * - wcn ipc uart instance
  71. * - NULL on error, out of memory
  72. */
  73. drvWcnIpcUart_t *drvWcnIpcUartOpen(unsigned rx_size, drvUartEventCB_t cb,
  74. void *cb_ctx, unsigned event_mask);
  75. /**
  76. * \brief close wcn ipc usrt
  77. *
  78. * After close, the instance will be freed. So, don't access the instance
  79. * after close.
  80. *
  81. * \param uart wcn ipc uart instance
  82. */
  83. void drvWcnIpcUartClose(drvWcnIpcUart_t *uart);
  84. /**
  85. * \brief read data from uart channel
  86. *
  87. * When the read size may be less than \p size.
  88. *
  89. * \param uart wcn ipc uart instance
  90. * \param data memory for read data
  91. * \param size memory size
  92. * \return
  93. * - real read size
  94. * = -1 on error
  95. */
  96. int drvWcnIpcUartRead(drvWcnIpcUart_t *uart, void *data, unsigned size);
  97. /**
  98. * \brief write data to uart channel
  99. *
  100. * The the written size may be less than \p size.
  101. *
  102. * \param uart wcn ipc uart instance
  103. * \param data data to be written
  104. * \param size data size to be written
  105. * \return
  106. * - real written size
  107. * - -1 on error
  108. */
  109. int drvWcnIpcUartWrite(drvWcnIpcUart_t *uart, const void *data, unsigned size);
  110. /**
  111. * \brief write data to uart channel with waiting
  112. *
  113. * \param uart wcn ipc uart instance
  114. * \param data data to be written
  115. * \param size data size to be written
  116. * \param timeout timeout in milliseconds
  117. * \return
  118. * - real written size
  119. * - -1 on error
  120. */
  121. int drvWcnIpcUartWriteAll(drvWcnIpcUart_t *uart, const void *data, unsigned size, unsigned timeout);
  122. /**
  123. * \brief uart channel read available byte count
  124. *
  125. * \param uart wcn ipc uart instance
  126. * \return
  127. * - read available byte count
  128. * - -1 on error
  129. */
  130. int drvWcnIpcUartReadAvail(drvWcnIpcUart_t *uart);
  131. /**
  132. * \brief uart channel write space byte count
  133. *
  134. * \param uart wcn ipc uart instance
  135. * \return
  136. * - write space byte count
  137. * - -1 on error
  138. */
  139. int drvWcnIpcUartWriteAvail(drvWcnIpcUart_t *uart);
  140. OSI_EXTERN_C_END
  141. #endif