lsm_params.h 8.6 KB

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