lsm_params.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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. #define SNDRV_LSM_VERSION SNDRV_PROTOCOL_VERSION(0, 3, 2)
  7. #define LSM_MAX_STAGES_PER_SESSION 2
  8. #define LSM_STAGE_INDEX_FIRST 0
  9. #define LSM_OUT_FORMAT_PCM (0)
  10. #define LSM_OUT_FORMAT_ADPCM (1 << 0)
  11. #define LSM_OUT_DATA_RAW (0)
  12. #define LSM_OUT_DATA_PACKED (1)
  13. #define LSM_OUT_DATA_EVENTS_DISABLED (0)
  14. #define LSM_OUT_DATA_EVENTS_ENABLED (1)
  15. #define LSM_OUT_TRANSFER_MODE_RT (0)
  16. #define LSM_OUT_TRANSFER_MODE_FTRT (1)
  17. #define LSM_ENDPOINT_DETECT_THRESHOLD (0)
  18. #define LSM_OPERATION_MODE (1)
  19. #define LSM_GAIN (2)
  20. #define LSM_MIN_CONFIDENCE_LEVELS (3)
  21. #define LSM_REG_SND_MODEL (4)
  22. #define LSM_DEREG_SND_MODEL (5)
  23. #define LSM_CUSTOM_PARAMS (6)
  24. #define LSM_POLLING_ENABLE (7)
  25. #define LSM_DET_EVENT_TYPE (8)
  26. #define LSM_LAB_CONTROL (9)
  27. #define LSM_REG_MULTI_SND_MODEL (10)
  28. #define LSM_DEREG_MULTI_SND_MODEL (11)
  29. #define LSM_MULTI_SND_MODEL_CONFIDENCE_LEVELS (12)
  30. #define LSM_PARAMS_MAX (LSM_MULTI_SND_MODEL_CONFIDENCE_LEVELS + 1)
  31. #define LSM_EVENT_NON_TIME_STAMP_MODE (0)
  32. #define LSM_EVENT_TIME_STAMP_MODE (1)
  33. #define LSM_DET_EVENT_TYPE_LEGACY (0)
  34. #define LSM_DET_EVENT_TYPE_GENERIC (1)
  35. /* Valid sample rates for input hw_params */
  36. #define LSM_INPUT_SAMPLE_RATE_16K 16000
  37. #define LSM_INPUT_SAMPLE_RATE_48K 48000
  38. /* Valid bit-widths for input hw_params */
  39. #define LSM_INPUT_BIT_WIDTH_16 16
  40. #define LSM_INPUT_BIT_WIDTH_24 24
  41. /* Min and Max channels for input hw_params */
  42. #define LSM_INPUT_NUM_CHANNELS_MIN 1
  43. #define LSM_INPUT_NUM_CHANNELS_MAX 9
  44. enum lsm_app_id {
  45. LSM_VOICE_WAKEUP_APP_ID = 1,
  46. LSM_VOICE_WAKEUP_APP_ID_V2 = 2,
  47. };
  48. enum lsm_detection_mode {
  49. LSM_MODE_KEYWORD_ONLY_DETECTION = 1,
  50. LSM_MODE_USER_KEYWORD_DETECTION
  51. };
  52. enum lsm_vw_status {
  53. LSM_VOICE_WAKEUP_STATUS_RUNNING = 1,
  54. LSM_VOICE_WAKEUP_STATUS_DETECTED,
  55. LSM_VOICE_WAKEUP_STATUS_END_SPEECH,
  56. LSM_VOICE_WAKEUP_STATUS_REJECTED
  57. };
  58. /*
  59. * Data for LSM_ENDPOINT_DETECT_THRESHOLD param_type
  60. * @epd_begin: Begin threshold
  61. * @epd_end: End threshold
  62. */
  63. struct snd_lsm_ep_det_thres {
  64. __u32 epd_begin;
  65. __u32 epd_end;
  66. };
  67. /*
  68. * Data for LSM_OPERATION_MODE param_type
  69. * @mode: The detection mode to be used
  70. * @detect_failure: Setting to enable failure detections.
  71. */
  72. struct snd_lsm_detect_mode {
  73. enum lsm_detection_mode mode;
  74. _Bool detect_failure;
  75. };
  76. /*
  77. * Data for LSM_GAIN param_type
  78. * @gain: The gain to be applied on LSM
  79. */
  80. struct snd_lsm_gain {
  81. __u16 gain;
  82. };
  83. /*
  84. * Data for LSM_POLLING_ENABLE param_type
  85. * @poll_en: Polling enable or disable
  86. */
  87. struct snd_lsm_poll_enable {
  88. _Bool poll_en;
  89. };
  90. /*
  91. * Data for LSM_DET_EVENT_TYPE param_type
  92. * @event_type: LSM_DET_EVENT_TYPE_LEGACY or LSM_DET_EVENT_TYPE_GENERIC
  93. * @mode: Type of information in detection event payload
  94. */
  95. struct snd_lsm_det_event_type {
  96. __u32 event_type;
  97. __u32 mode;
  98. };
  99. struct snd_lsm_sound_model_v2 {
  100. __u8 __user *data;
  101. __u8 *confidence_level;
  102. __u32 data_size;
  103. enum lsm_detection_mode detection_mode;
  104. __u8 num_confidence_levels;
  105. _Bool detect_failure;
  106. };
  107. struct snd_lsm_session_data {
  108. enum lsm_app_id app_id;
  109. };
  110. /*
  111. * Stage info for multi-stage session
  112. * @app_type: acdb app_type to be used to map topology/cal for the stage
  113. * @lpi_enable: low power island mode applicable for the stage
  114. */
  115. struct snd_lsm_stage_info {
  116. __u32 app_type;
  117. __u32 lpi_enable;
  118. };
  119. /*
  120. * Session info for multi-stage session
  121. * @app_id: VoiceWakeup engine id, this is now used to just validate input arg
  122. * @num_stages: number of detection stages to be used
  123. * @stage_info: stage info for each of the stage being used, ordered by index
  124. */
  125. struct snd_lsm_session_data_v2 {
  126. enum lsm_app_id app_id;
  127. __u32 num_stages;
  128. struct snd_lsm_stage_info stage_info[LSM_MAX_STAGES_PER_SESSION];
  129. };
  130. /*
  131. * Data for LSM_LAB_CONTROL param_type
  132. * @enable: lab enable or disable
  133. */
  134. struct snd_lsm_lab_control {
  135. __u32 enable;
  136. };
  137. struct snd_lsm_event_status {
  138. __u16 status;
  139. __u16 payload_size;
  140. __u8 payload[0];
  141. };
  142. struct snd_lsm_event_status_v3 {
  143. __u32 timestamp_lsw;
  144. __u32 timestamp_msw;
  145. __u16 status;
  146. __u16 payload_size;
  147. __u8 payload[0];
  148. };
  149. struct snd_lsm_detection_params {
  150. __u8 *conf_level;
  151. enum lsm_detection_mode detect_mode;
  152. __u8 num_confidence_levels;
  153. _Bool detect_failure;
  154. _Bool poll_enable;
  155. };
  156. /*
  157. * Param info for each parameter type
  158. * @module_id: Module to which parameter is to be set
  159. * @param_id: Parameter that is to be set
  160. * @param_size: size (in number of bytes) for the data
  161. * in param_data.
  162. * For confidence levels, this is num_conf_levels
  163. * For REG_SND_MODEL, this is size of sound model
  164. * For CUSTOM_PARAMS, this is size of the entire blob of data
  165. * @param_data: Data for the parameter.
  166. * For some param_types this is a structure defined, ex: LSM_GAIN
  167. * For CONFIDENCE_LEVELS, this is array of confidence levels
  168. * For REG_SND_MODEL, this is the sound model data
  169. * For CUSTOM_PARAMS, this is the blob of custom data.
  170. * @param_type: Parameter type as defined in values upto LSM_PARAMS_MAX
  171. */
  172. struct lsm_params_info {
  173. __u32 module_id;
  174. __u32 param_id;
  175. __u32 param_size;
  176. __u8 __user *param_data;
  177. __u32 param_type;
  178. };
  179. /*
  180. * Param info(version 2) for each parameter type
  181. *
  182. * Existing member variables:
  183. * @module_id: Module to which parameter is to be set
  184. * @param_id: Parameter that is to be set
  185. * @param_size: size (in number of bytes) for the data
  186. * in param_data.
  187. * For confidence levels, this is num_conf_levels
  188. * For REG_SND_MODEL, this is size of sound model
  189. * For CUSTOM_PARAMS, this is size of the entire blob of data
  190. * @param_data: Data for the parameter.
  191. * For some param_types this is a structure defined, ex: LSM_GAIN
  192. * For CONFIDENCE_LEVELS, this is array of confidence levels
  193. * For REG_SND_MODEL, this is the sound model data
  194. * For CUSTOM_PARAMS, this is the blob of custom data.
  195. * @param_type: Parameter type as defined in values upto LSM_PARAMS_MAX
  196. *
  197. * Member variables applicable only to V2:
  198. * @instance_id: instance id of the param to which parameter is to be set
  199. * @stage_idx: detection stage for which the param is applicable
  200. * @model_id: an unique number to identify sound models in DSP
  201. */
  202. struct lsm_params_info_v2 {
  203. __u32 module_id;
  204. __u32 param_id;
  205. __u32 param_size;
  206. __u8 __user *param_data;
  207. __u32 param_type;
  208. __u16 instance_id;
  209. __u16 stage_idx;
  210. __u32 model_id;
  211. };
  212. /*
  213. * Data passed to the SET_PARAM_V2 IOCTL
  214. * @num_params: Number of params that are to be set
  215. * should not be greater than LSM_PARAMS_MAX
  216. * @params: Points to an array of lsm_params_info
  217. * Each entry points to one parameter to set
  218. * @data_size: size (in bytes) for params
  219. * should be equal to
  220. * num_params * sizeof(struct lsm_parms_info)
  221. */
  222. struct snd_lsm_module_params {
  223. __u8 __user *params;
  224. __u32 num_params;
  225. __u32 data_size;
  226. };
  227. /*
  228. * Data passed to LSM_OUT_FORMAT_CFG IOCTL
  229. * @format: The media format enum
  230. * @packing: indicates the packing method used for data path
  231. * @events: indicates whether data path events need to be enabled
  232. * @transfer_mode: indicates whether FTRT mode or RT mode.
  233. */
  234. struct snd_lsm_output_format_cfg {
  235. __u8 format;
  236. __u8 packing;
  237. __u8 events;
  238. __u8 mode;
  239. };
  240. /*
  241. * Data passed to SNDRV_LSM_SET_INPUT_HW_PARAMS ioctl
  242. *
  243. * @sample_rate: Sample rate of input to lsm.
  244. * valid values are 16000 and 48000
  245. * @bit_width: Bit width of audio samples input to lsm.
  246. * valid values are 16 and 24
  247. * @num_channels: Number of channels input to lsm.
  248. * valid values are range from 1 to 16
  249. */
  250. struct snd_lsm_input_hw_params {
  251. __u32 sample_rate;
  252. __u16 bit_width;
  253. __u16 num_channels;
  254. } __packed;
  255. #define SNDRV_LSM_DEREG_SND_MODEL _IOW('U', 0x01, int)
  256. #define SNDRV_LSM_EVENT_STATUS _IOW('U', 0x02, struct snd_lsm_event_status)
  257. #define SNDRV_LSM_ABORT_EVENT _IOW('U', 0x03, int)
  258. #define SNDRV_LSM_START _IOW('U', 0x04, int)
  259. #define SNDRV_LSM_STOP _IOW('U', 0x05, int)
  260. #define SNDRV_LSM_SET_SESSION_DATA _IOW('U', 0x06, struct snd_lsm_session_data)
  261. #define SNDRV_LSM_REG_SND_MODEL_V2 _IOW('U', 0x07,\
  262. struct snd_lsm_sound_model_v2)
  263. #define SNDRV_LSM_LAB_CONTROL _IOW('U', 0x08, __u32)
  264. #define SNDRV_LSM_STOP_LAB _IO('U', 0x09)
  265. #define SNDRV_LSM_SET_PARAMS _IOW('U', 0x0A, \
  266. struct snd_lsm_detection_params)
  267. #define SNDRV_LSM_SET_MODULE_PARAMS _IOW('U', 0x0B, \
  268. struct snd_lsm_module_params)
  269. #define SNDRV_LSM_OUT_FORMAT_CFG _IOW('U', 0x0C, \
  270. struct snd_lsm_output_format_cfg)
  271. #define SNDRV_LSM_SET_PORT _IO('U', 0x0D)
  272. #define SNDRV_LSM_SET_FWK_MODE_CONFIG _IOW('U', 0x0E, __u32)
  273. #define SNDRV_LSM_EVENT_STATUS_V3 _IOW('U', 0x0F, \
  274. struct snd_lsm_event_status_v3)
  275. #define SNDRV_LSM_GENERIC_DET_EVENT _IOW('U', 0x10, struct snd_lsm_event_status)
  276. #define SNDRV_LSM_SET_INPUT_HW_PARAMS _IOW('U', 0x11, \
  277. struct snd_lsm_input_hw_params)
  278. #define SNDRV_LSM_SET_SESSION_DATA_V2 _IOW('U', 0x12, \
  279. struct snd_lsm_session_data_v2)
  280. #define SNDRV_LSM_SET_MODULE_PARAMS_V2 _IOW('U', 0x13, \
  281. struct snd_lsm_module_params)
  282. #endif