lsm_params.h 9.6 KB

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