q6lsm.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * Copyright (c) 2013-2014, Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef __Q6LSM_H__
  14. #define __Q6LSM_H__
  15. #include <linux/list.h>
  16. #include <linux/msm_ion.h>
  17. #include <sound/apr_audio-v2.h>
  18. #include <sound/lsm_params.h>
  19. #include <mach/qdsp6v2/apr.h>
  20. typedef void (*lsm_app_cb)(uint32_t opcode, uint32_t token,
  21. uint32_t *payload, void *priv);
  22. struct lsm_sound_model {
  23. dma_addr_t phys;
  24. void *data;
  25. uint32_t size; /* size of buffer */
  26. uint32_t actual_size; /* actual number of bytes read by DSP */
  27. struct ion_handle *handle;
  28. struct ion_client *client;
  29. uint32_t mem_map_handle;
  30. };
  31. struct lsm_client {
  32. int session;
  33. lsm_app_cb cb;
  34. atomic_t cmd_state;
  35. void *priv;
  36. struct apr_svc *apr;
  37. struct apr_svc *mmap_apr;
  38. struct mutex cmd_lock;
  39. struct lsm_sound_model sound_model;
  40. wait_queue_head_t cmd_wait;
  41. uint16_t mode;
  42. uint16_t connect_to_port;
  43. uint16_t user_sensitivity;
  44. uint16_t kw_sensitivity;
  45. bool opened;
  46. bool started;
  47. dma_addr_t lsm_cal_phy_addr;
  48. uint32_t lsm_cal_size;
  49. };
  50. struct lsm_stream_cmd_open_tx {
  51. struct apr_hdr hdr;
  52. uint16_t app_id;
  53. uint16_t reserved;
  54. uint32_t sampling_rate;
  55. } __packed;
  56. struct lsm_param_payload_common {
  57. uint32_t module_id;
  58. uint32_t param_id;
  59. uint16_t param_size;
  60. uint16_t reserved;
  61. } __packed;
  62. struct lsm_param_op_mode {
  63. struct lsm_param_payload_common common;
  64. uint32_t minor_version;
  65. uint16_t mode;
  66. uint16_t reserved;
  67. } __packed;
  68. struct lsm_param_connect_to_port {
  69. struct lsm_param_payload_common common;
  70. uint32_t minor_version;
  71. /* AFE port id that receives voice wake up data */
  72. uint16_t port_id;
  73. uint16_t reserved;
  74. } __packed;
  75. struct lsm_param_kw_detect_sensitivity {
  76. struct lsm_param_payload_common common;
  77. uint32_t minor_version;
  78. /* scale factor to change the keyword confidence thresholds */
  79. uint16_t keyword_sensitivity;
  80. uint16_t reserved;
  81. } __packed;
  82. struct lsm_param_user_detect_sensitivity {
  83. struct lsm_param_payload_common common;
  84. uint32_t minor_version;
  85. /* scale factor to change the user confidence thresholds */
  86. uint16_t user_sensitivity;
  87. uint16_t reserved;
  88. } __packed;
  89. struct lsm_params_payload {
  90. struct lsm_param_connect_to_port connect_to_port;
  91. struct lsm_param_op_mode op_mode;
  92. struct lsm_param_kw_detect_sensitivity kwds;
  93. struct lsm_param_user_detect_sensitivity uds;
  94. } __packed;
  95. struct lsm_cmd_set_params {
  96. struct apr_hdr hdr;
  97. uint32_t data_payload_size;
  98. uint32_t data_payload_addr_lsw;
  99. uint32_t data_payload_addr_msw;
  100. uint32_t mem_map_handle;
  101. struct lsm_params_payload payload;
  102. } __packed;
  103. struct lsm_cmd_reg_snd_model {
  104. struct apr_hdr hdr;
  105. uint32_t model_size;
  106. uint32_t model_addr_lsw;
  107. uint32_t model_addr_msw;
  108. uint32_t mem_map_handle;
  109. } __packed;
  110. struct lsm_client *q6lsm_client_alloc(lsm_app_cb cb, void *priv);
  111. void q6lsm_client_free(struct lsm_client *client);
  112. int q6lsm_open(struct lsm_client *client);
  113. int q6lsm_start(struct lsm_client *client, bool wait);
  114. int q6lsm_stop(struct lsm_client *client, bool wait);
  115. int q6lsm_snd_model_buf_alloc(struct lsm_client *client, size_t len);
  116. int q6lsm_snd_model_buf_free(struct lsm_client *client);
  117. int q6lsm_close(struct lsm_client *client);
  118. int q6lsm_register_sound_model(struct lsm_client *client,
  119. enum lsm_detection_mode mode, u16 minkeyword,
  120. u16 minuser, bool detectfailure);
  121. int q6lsm_deregister_sound_model(struct lsm_client *client);
  122. #endif /* __Q6LSM_H__ */