/arch/arm/mach-msm/include/mach/qdsp6v2/apr.h

https://bitbucket.org/sammyz/iscream_thunderc-2.6.35-rebase · C++ Header · 178 lines · 119 code · 24 blank · 35 comment · 0 complexity · 088cc823188a3c03fb33c5c4b12ad5aa MD5 · raw file

  1. /* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
  2. *
  3. * Redistribution and use in source and binary forms, with or without
  4. * modification, are permitted provided that the following conditions are
  5. * met:
  6. * * Redistributions of source code must retain the above copyright
  7. * notice, this list of conditions and the following disclaimer.
  8. * * Redistributions in binary form must reproduce the above
  9. * copyright notice, this list of conditions and the following
  10. * disclaimer in the documentation and/or other materials provided
  11. * with the distribution.
  12. * * Neither the name of Code Aurora Forum, Inc. nor the names of its
  13. * contributors may be used to endorse or promote products derived
  14. * from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  17. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  18. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
  19. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  20. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  21. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  22. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  23. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  24. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  25. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  26. * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. *
  28. */
  29. #ifndef __APR_H_
  30. #define __APR_H_
  31. #define APR_Q6_NOIMG 0
  32. #define APR_Q6_LOADING 1
  33. #define APR_Q6_LOADED 2
  34. struct apr_q6 {
  35. void *pil;
  36. uint32_t state;
  37. struct mutex lock;
  38. };
  39. struct apr_hdr {
  40. uint16_t hdr_field;
  41. uint16_t pkt_size;
  42. uint8_t src_svc;
  43. uint8_t src_domain;
  44. uint16_t src_port;
  45. uint8_t dest_svc;
  46. uint8_t dest_domain;
  47. uint16_t dest_port;
  48. uint32_t token;
  49. uint32_t opcode;
  50. };
  51. #define APR_HDR_LEN(hdr_len) ((hdr_len)/4)
  52. #define APR_PKT_SIZE(hdr_len, payload_len) ((hdr_len) + (payload_len))
  53. #define APR_HDR_FIELD(msg_type, hdr_len, ver)\
  54. (((msg_type & 0x3) << 8) | ((hdr_len & 0xF) << 4) | (ver & 0xF))
  55. #define APR_HDR_SIZE sizeof(struct apr_hdr)
  56. /* Version */
  57. #define APR_PKT_VER 0x0
  58. /* Command and Response Types */
  59. #define APR_MSG_TYPE_EVENT 0x0
  60. #define APR_MSG_TYPE_CMD_RSP 0x1
  61. #define APR_MSG_TYPE_SEQ_CMD 0x2
  62. #define APR_MSG_TYPE_NSEQ_CMD 0x3
  63. #define APR_MSG_TYPE_MAX 0x04
  64. /* APR Basic Response Message */
  65. #define APR_BASIC_RSP_RESULT 0x000110E8
  66. #define APR_RSP_ACCEPTED 0x000100BE
  67. /* Domain IDs */
  68. #define APR_DOMAIN_SIM 0x1
  69. #define APR_DOMAIN_PC 0x2
  70. #define APR_DOMAIN_MODEM 0x3
  71. #define APR_DOMAIN_ADSP 0x4
  72. #define APR_DOMAIN_APPS 0x5
  73. #define APR_DOMAIN_MAX 0x6
  74. /* ADSP service IDs */
  75. #define APR_SVC_TEST_CLIENT 0x2
  76. #define APR_SVC_ADSP_CORE 0x3
  77. #define APR_SVC_AFE 0x4
  78. #define APR_SVC_VSM 0x5
  79. #define APR_SVC_VPM 0x6
  80. #define APR_SVC_ASM 0x7
  81. #define APR_SVC_ADM 0x8
  82. #define APR_SVC_ADSP_MVM 0x09
  83. #define APR_SVC_ADSP_CVS 0x0A
  84. #define APR_SVC_ADSP_CVP 0x0B
  85. #define APR_SVC_MAX 0x0C
  86. /* Modem Service IDs */
  87. #define APR_SVC_MVS 0x3
  88. #define APR_SVC_MVM 0x4
  89. #define APR_SVC_CVS 0x5
  90. #define APR_SVC_CVP 0x6
  91. #define APR_SVC_SRD 0x7
  92. /* APR Port IDs */
  93. #define APR_MAX_PORTS 0x40
  94. #define APR_NAME_MAX 0x40
  95. struct apr_client_data {
  96. uint16_t payload_size;
  97. uint16_t hdr_len;
  98. uint16_t msg_type;
  99. uint16_t src;
  100. uint16_t dest_svc;
  101. uint16_t src_port;
  102. uint16_t dest_port;
  103. uint32_t token;
  104. uint32_t opcode;
  105. void *payload;
  106. };
  107. typedef int32_t (*apr_fn)(struct apr_client_data *data, void *priv);
  108. struct apr_svc {
  109. uint16_t id;
  110. uint16_t dest_id;
  111. uint16_t client_id;
  112. uint8_t rvd;
  113. uint8_t port_cnt;
  114. uint8_t svc_cnt;
  115. apr_fn port_fn[APR_MAX_PORTS];
  116. void *port_priv[APR_MAX_PORTS];
  117. apr_fn fn;
  118. void *priv;
  119. struct mutex m_lock;
  120. spinlock_t w_lock;
  121. };
  122. struct apr_client {
  123. uint8_t id;
  124. uint8_t svc_cnt;
  125. uint8_t rvd;
  126. struct mutex m_lock;
  127. struct apr_svc_ch_dev *handle;
  128. struct apr_svc svc[APR_SVC_MAX];
  129. };
  130. #define ADSP_GET_VERSION 0x00011152
  131. #define ADSP_GET_VERSION_RSP 0x00011153
  132. struct adsp_get_version {
  133. uint32_t build_id;
  134. uint32_t svc_cnt;
  135. };
  136. struct adsp_service_info {
  137. uint32_t svc_id;
  138. uint32_t svc_ver;
  139. };
  140. #define ADSP_CMD_SET_POWER_COLLAPSE_STATE 0x0001115C
  141. struct adsp_power_collapse {
  142. struct apr_hdr hdr;
  143. uint32_t power_collapse;
  144. };
  145. struct apr_svc *apr_register(char *dest, char *svc_name, apr_fn svc_fn,
  146. uint32_t src_port, void *priv);
  147. inline int apr_fill_hdr(void *handle, uint32_t *buf, uint16_t src_port,
  148. uint16_t msg_type, uint16_t dest_port,
  149. uint32_t token, uint32_t opcode, uint16_t len);
  150. int apr_send_pkt(void *handle, uint32_t *buf);
  151. int apr_deregister(void *handle);
  152. void change_q6_state(int state);
  153. void q6audio_dsp_not_responding(void);
  154. #endif