lsm_params.h 8.6 KB

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