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, 1, 0) 11 12 #define LSM_OUT_FORMAT_PCM (0) 13 #define LSM_OUT_FORMAT_ADPCM (1 << 0) 14 15 #define LSM_OUT_DATA_RAW (0) 16 #define LSM_OUT_DATA_PACKED (1) 17 18 #define LSM_OUT_DATA_EVENTS_DISABLED (0) 19 #define LSM_OUT_DATA_EVENTS_ENABLED (1) 20 21 #define LSM_OUT_TRANSFER_MODE_RT (0) 22 #define LSM_OUT_TRANSFER_MODE_FTRT (1) 23 24 #define LSM_ENDPOINT_DETECT_THRESHOLD (0) 25 #define LSM_OPERATION_MODE (1) 26 #define LSM_GAIN (2) 27 #define LSM_MIN_CONFIDENCE_LEVELS (3) 28 #define LSM_REG_SND_MODEL (4) 29 #define LSM_DEREG_SND_MODEL (5) 30 #define LSM_CUSTOM_PARAMS (6) 31 #define LSM_POLLING_ENABLE (7) 32 #define LSM_PARAMS_MAX (LSM_POLLING_ENABLE + 1) 33 34 #define LSM_EVENT_NON_TIME_STAMP_MODE (0) 35 #define LSM_EVENT_TIME_STAMP_MODE (1) 36 37 enum lsm_app_id { 38 LSM_VOICE_WAKEUP_APP_ID = 1, 39 LSM_VOICE_WAKEUP_APP_ID_V2 = 2, 40 }; 41 42 enum lsm_detection_mode { 43 LSM_MODE_KEYWORD_ONLY_DETECTION = 1, 44 LSM_MODE_USER_KEYWORD_DETECTION 45 }; 46 47 enum lsm_vw_status { 48 LSM_VOICE_WAKEUP_STATUS_RUNNING = 1, 49 LSM_VOICE_WAKEUP_STATUS_DETECTED, 50 LSM_VOICE_WAKEUP_STATUS_END_SPEECH, 51 LSM_VOICE_WAKEUP_STATUS_REJECTED 52 }; 53 54 /* 55 * Data for LSM_ENDPOINT_DETECT_THRESHOLD param_type 56 * @epd_begin: Begin threshold 57 * @epd_end: End threshold 58 */ 59 struct snd_lsm_ep_det_thres { 60 __u32 epd_begin; 61 __u32 epd_end; 62 }; 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 /* 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 /* 83 * Data for LSM_POLLING_ENABLE param_type 84 * @poll_en: Polling enable or disable 85 */ 86 struct snd_lsm_poll_enable { 87 bool poll_en; 88 }; 89 90 91 struct snd_lsm_sound_model_v2 { 92 __u8 *data; 93 __u8 *confidence_level; 94 __u32 data_size; 95 enum lsm_detection_mode detection_mode; 96 __u8 num_confidence_levels; 97 bool detect_failure; 98 }; 99 100 struct snd_lsm_session_data { 101 enum lsm_app_id app_id; 102 }; 103 104 struct snd_lsm_event_status { 105 __u16 status; 106 __u16 payload_size; 107 __u8 payload[0]; 108 }; 109 110 struct snd_lsm_event_status_v3 { 111 __u32 timestamp_lsw; 112 __u32 timestamp_msw; 113 __u16 status; 114 __u16 payload_size; 115 __u8 payload[0]; 116 }; 117 118 struct snd_lsm_detection_params { 119 __u8 *conf_level; 120 enum lsm_detection_mode detect_mode; 121 __u8 num_confidence_levels; 122 bool detect_failure; 123 bool poll_enable; 124 }; 125 126 /* 127 * Param info for each parameter type 128 * @module_id: Module to which parameter is to be set 129 * @param_id: Parameter that is to be set 130 * @param_size: size (in number of bytes) for the data 131 * in param_data. 132 * For confidence levels, this is num_conf_levels 133 * For REG_SND_MODEL, this is size of sound model 134 * For CUSTOM_PARAMS, this is size of the entire blob of data 135 * @param_data: Data for the parameter. 136 * For some param_types this is a structure defined, ex: LSM_GAIN 137 * For CONFIDENCE_LEVELS, this is array of confidence levels 138 * For REG_SND_MODEL, this is the sound model data 139 * For CUSTOM_PARAMS, this is the blob of custom data. 140 */ 141 struct lsm_params_info { 142 __u32 module_id; 143 __u32 param_id; 144 __u32 param_size; 145 __u8 *param_data; 146 uint32_t param_type; 147 }; 148 149 /* 150 * Data passed to the SET_PARAM_V2 IOCTL 151 * @num_params: Number of params that are to be set 152 * should not be greater than LSM_PARAMS_MAX 153 * @params: Points to an array of lsm_params_info 154 * Each entry points to one parameter to set 155 * @data_size: size (in bytes) for params 156 * should be equal to 157 * num_params * sizeof(struct lsm_parms_info) 158 */ 159 struct snd_lsm_module_params { 160 __u8 *params; 161 __u32 num_params; 162 __u32 data_size; 163 }; 164 165 /* 166 * Data passed to LSM_OUT_FORMAT_CFG IOCTL 167 * @format: The media format enum 168 * @packing: indicates the packing method used for data path 169 * @events: indicates whether data path events need to be enabled 170 * @transfer_mode: indicates whether FTRT mode or RT mode. 171 */ 172 struct snd_lsm_output_format_cfg { 173 __u8 format; 174 __u8 packing; 175 __u8 events; 176 __u8 mode; 177 }; 178 179 #define SNDRV_LSM_DEREG_SND_MODEL _IOW('U', 0x01, int) 180 #define SNDRV_LSM_EVENT_STATUS _IOW('U', 0x02, struct snd_lsm_event_status) 181 #define SNDRV_LSM_ABORT_EVENT _IOW('U', 0x03, int) 182 #define SNDRV_LSM_START _IOW('U', 0x04, int) 183 #define SNDRV_LSM_STOP _IOW('U', 0x05, int) 184 #define SNDRV_LSM_SET_SESSION_DATA _IOW('U', 0x06, struct snd_lsm_session_data) 185 #define SNDRV_LSM_REG_SND_MODEL_V2 _IOW('U', 0x07,\ 186 struct snd_lsm_sound_model_v2) 187 #define SNDRV_LSM_LAB_CONTROL _IOW('U', 0x08, uint32_t) 188 #define SNDRV_LSM_STOP_LAB _IO('U', 0x09) 189 #define SNDRV_LSM_SET_PARAMS _IOW('U', 0x0A, \ 190 struct snd_lsm_detection_params) 191 #define SNDRV_LSM_SET_MODULE_PARAMS _IOW('U', 0x0B, \ 192 struct snd_lsm_module_params) 193 #define SNDRV_LSM_OUT_FORMAT_CFG _IOW('U', 0x0C, \ 194 struct snd_lsm_output_format_cfg) 195 #define SNDRV_LSM_SET_PORT _IO('U', 0x0D) 196 #define SNDRV_LSM_SET_FWK_MODE_CONFIG _IOW('U', 0x0E, uint32_t) 197 #define SNDRV_LSM_EVENT_STATUS_V3 _IOW('U', 0x0F, \ 198 struct snd_lsm_event_status_v3) 199 200 #endif 201