lsm_params.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. #ifndef _UAPI_LSM_PARAMS_H__
  2. #define _UAPI_LSM_PARAMS_H__
  3. #define LSM_POLLING_ENABLE_SUPPORT
  4. #define LSM_EVENT_TIMESTAMP_MODE_SUPPORT
  5. #include <linux/types.h>
  6. #include <sound/asound.h>
  7. #define SNDRV_LSM_VERSION SNDRV_PROTOCOL_VERSION(0, 1, 0)
  8. #define LSM_OUT_FORMAT_PCM (0)
  9. #define LSM_OUT_FORMAT_ADPCM (1 << 0)
  10. #define LSM_OUT_DATA_RAW (0)
  11. #define LSM_OUT_DATA_PACKED (1)
  12. #define LSM_OUT_DATA_EVENTS_DISABLED (0)
  13. #define LSM_OUT_DATA_EVENTS_ENABLED (1)
  14. #define LSM_OUT_TRANSFER_MODE_RT (0)
  15. #define LSM_OUT_TRANSFER_MODE_FTRT (1)
  16. #define LSM_ENDPOINT_DETECT_THRESHOLD (0)
  17. #define LSM_OPERATION_MODE (1)
  18. #define LSM_GAIN (2)
  19. #define LSM_MIN_CONFIDENCE_LEVELS (3)
  20. #define LSM_REG_SND_MODEL (4)
  21. #define LSM_DEREG_SND_MODEL (5)
  22. #define LSM_CUSTOM_PARAMS (6)
  23. #define LSM_POLLING_ENABLE (7)
  24. #define LSM_PARAMS_MAX (LSM_POLLING_ENABLE + 1)
  25. #define LSM_EVENT_NON_TIME_STAMP_MODE (0)
  26. #define LSM_EVENT_TIME_STAMP_MODE (1)
  27. enum lsm_app_id {
  28. LSM_VOICE_WAKEUP_APP_ID = 1,
  29. LSM_VOICE_WAKEUP_APP_ID_V2 = 2,
  30. };
  31. enum lsm_detection_mode {
  32. LSM_MODE_KEYWORD_ONLY_DETECTION = 1,
  33. LSM_MODE_USER_KEYWORD_DETECTION
  34. };
  35. enum lsm_vw_status {
  36. LSM_VOICE_WAKEUP_STATUS_RUNNING = 1,
  37. LSM_VOICE_WAKEUP_STATUS_DETECTED,
  38. LSM_VOICE_WAKEUP_STATUS_END_SPEECH,
  39. LSM_VOICE_WAKEUP_STATUS_REJECTED
  40. };
  41. /*
  42. * Data for LSM_ENDPOINT_DETECT_THRESHOLD param_type
  43. * @epd_begin: Begin threshold
  44. * @epd_end: End threshold
  45. */
  46. struct snd_lsm_ep_det_thres {
  47. __u32 epd_begin;
  48. __u32 epd_end;
  49. };
  50. /*
  51. * Data for LSM_OPERATION_MODE param_type
  52. * @mode: The detection mode to be used
  53. * @detect_failure: Setting to enable failure detections.
  54. */
  55. struct snd_lsm_detect_mode {
  56. enum lsm_detection_mode mode;
  57. bool detect_failure;
  58. };
  59. /*
  60. * Data for LSM_GAIN param_type
  61. * @gain: The gain to be applied on LSM
  62. */
  63. struct snd_lsm_gain {
  64. __u16 gain;
  65. };
  66. /*
  67. * Data for LSM_POLLING_ENABLE param_type
  68. * @poll_en: Polling enable or disable
  69. */
  70. struct snd_lsm_poll_enable {
  71. bool poll_en;
  72. };
  73. struct snd_lsm_sound_model_v2 {
  74. __u8 __user *data;
  75. __u8 *confidence_level;
  76. __u32 data_size;
  77. enum lsm_detection_mode detection_mode;
  78. __u8 num_confidence_levels;
  79. bool detect_failure;
  80. };
  81. struct snd_lsm_session_data {
  82. enum lsm_app_id app_id;
  83. };
  84. struct snd_lsm_event_status {
  85. __u16 status;
  86. __u16 payload_size;
  87. __u8 payload[0];
  88. };
  89. struct snd_lsm_event_status_v3 {
  90. __u32 timestamp_lsw;
  91. __u32 timestamp_msw;
  92. __u16 status;
  93. __u16 payload_size;
  94. __u8 payload[0];
  95. };
  96. struct snd_lsm_detection_params {
  97. __u8 *conf_level;
  98. enum lsm_detection_mode detect_mode;
  99. __u8 num_confidence_levels;
  100. bool detect_failure;
  101. bool poll_enable;
  102. };
  103. /*
  104. * Param info for each parameter type
  105. * @module_id: Module to which parameter is to be set
  106. * @param_id: Parameter that is to be set
  107. * @param_size: size (in number of bytes) for the data
  108. * in param_data.
  109. * For confidence levels, this is num_conf_levels
  110. * For REG_SND_MODEL, this is size of sound model
  111. * For CUSTOM_PARAMS, this is size of the entire blob of data
  112. * @param_data: Data for the parameter.
  113. * For some param_types this is a structure defined, ex: LSM_GAIN
  114. * For CONFIDENCE_LEVELS, this is array of confidence levels
  115. * For REG_SND_MODEL, this is the sound model data
  116. * For CUSTOM_PARAMS, this is the blob of custom data.
  117. */
  118. struct lsm_params_info {
  119. __u32 module_id;
  120. __u32 param_id;
  121. __u32 param_size;
  122. __u8 __user *param_data;
  123. uint32_t param_type;
  124. };
  125. /*
  126. * Data passed to the SET_PARAM_V2 IOCTL
  127. * @num_params: Number of params that are to be set
  128. * should not be greater than LSM_PARAMS_MAX
  129. * @params: Points to an array of lsm_params_info
  130. * Each entry points to one parameter to set
  131. * @data_size: size (in bytes) for params
  132. * should be equal to
  133. * num_params * sizeof(struct lsm_parms_info)
  134. */
  135. struct snd_lsm_module_params {
  136. __u8 __user *params;
  137. __u32 num_params;
  138. __u32 data_size;
  139. };
  140. /*
  141. * Data passed to LSM_OUT_FORMAT_CFG IOCTL
  142. * @format: The media format enum
  143. * @packing: indicates the packing method used for data path
  144. * @events: indicates whether data path events need to be enabled
  145. * @transfer_mode: indicates whether FTRT mode or RT mode.
  146. */
  147. struct snd_lsm_output_format_cfg {
  148. __u8 format;
  149. __u8 packing;
  150. __u8 events;
  151. __u8 mode;
  152. };
  153. #define SNDRV_LSM_DEREG_SND_MODEL _IOW('U', 0x01, int)
  154. #define SNDRV_LSM_EVENT_STATUS _IOW('U', 0x02, struct snd_lsm_event_status)
  155. #define SNDRV_LSM_ABORT_EVENT _IOW('U', 0x03, int)
  156. #define SNDRV_LSM_START _IOW('U', 0x04, int)
  157. #define SNDRV_LSM_STOP _IOW('U', 0x05, int)
  158. #define SNDRV_LSM_SET_SESSION_DATA _IOW('U', 0x06, struct snd_lsm_session_data)
  159. #define SNDRV_LSM_REG_SND_MODEL_V2 _IOW('U', 0x07,\
  160. struct snd_lsm_sound_model_v2)
  161. #define SNDRV_LSM_LAB_CONTROL _IOW('U', 0x08, uint32_t)
  162. #define SNDRV_LSM_STOP_LAB _IO('U', 0x09)
  163. #define SNDRV_LSM_SET_PARAMS _IOW('U', 0x0A, \
  164. struct snd_lsm_detection_params)
  165. #define SNDRV_LSM_SET_MODULE_PARAMS _IOW('U', 0x0B, \
  166. struct snd_lsm_module_params)
  167. #define SNDRV_LSM_OUT_FORMAT_CFG _IOW('U', 0x0C, \
  168. struct snd_lsm_output_format_cfg)
  169. #define SNDRV_LSM_SET_PORT _IO('U', 0x0D)
  170. #define SNDRV_LSM_SET_FWK_MODE_CONFIG _IOW('U', 0x0E, uint32_t)
  171. #define SNDRV_LSM_EVENT_STATUS_V3 _IOW('U', 0x0F, \
  172. struct snd_lsm_event_status_v3)
  173. #endif