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