1 /* 2 * Copyright (C) 2018 Knowles Electronics 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef _CVQ_IOCTL_H 18 #define _CVQ_IOCTL_H 19 20 #include "iaxxx_odsp_hw.h" 21 #include <audio_route/audio_route.h> 22 #include <tinyalsa/asoundlib.h> 23 24 #define HOTWORD_MASK 0x1 25 #define AMBIENT_MASK 0x2 26 #define ENTITY_MASK 0x4 27 #define PLUGIN1_MASK (HOTWORD_MASK | WAKEUP_MASK) 28 #define PLUGIN2_MASK (AMBIENT_MASK | ENTITY_MASK) 29 #define WAKEUP_MASK 0x8 30 #define OSLO_MASK 0x10 31 #define CHRE_MASK 0x20 32 33 #define HOTWORD_EVT_SRC_ID IAXXX_SYSID_PLUGIN_INSTANCE_0 34 #define AMBIENT_EVT_SRC_ID IAXXX_SYSID_PLUGIN_INSTANCE_2 35 #define CHRE_EVT_SRC_ID IAXXX_SYSID_PLUGIN_INSTANCE_5 36 // HOST1 Plugin instances start from 8 to 15 37 // plugin 8 is assigned for Oslo buffer and 9 for Oslo plugin 38 #define OSLO_EVT_SRC_ID IAXXX_SYSID_PLUGIN_INSTANCE_9 39 40 #define HOTWORD_PKG_ID 11 41 #define HOTWORD_PLUGIN_IDX 0 42 #define HOTWORD_INSTANCE_ID 0 43 #define HOTWORD_PRIORITY 1 44 45 #define AMBIENT_PKG_ID 12 46 #define AMBIENT_PLUGIN_IDX 0 47 #define AMBIENT_INSTANCE_ID 2 48 #define AMBIENT_PRIORITY 1 49 50 #define SENSOR_PKG_ID 0 51 #define SENSOR_PLUGIN_IDX 0 52 #define SENSOR_INSTANCE_ID 9 53 #define SENSOR_PRIORITY 2 54 #define SENSOR_PRESENCE_MODE 0 55 #define SENSOR_DETECTED_MODE 1 56 #define SENSOR_MAX_MODE 2 57 #define OSLO_DATA_EVENT_ID 1 58 #define OSLO_CONFIGURED (0x201) 59 #define OSLO_DESTROYED (0x202) 60 #define OSLO_EP_DISCONNECT (0x205) 61 #define CHRE_EP_DISCONNECT (0x206) 62 #define OSLO_BUF_INSTANCE_ID 8 63 #define OSLO_BUF_PRIORITY 2 64 65 #define AEC_PKG_ID 7 66 #define AEC_PLUGIN_IDX 0 67 #define AEC_INSTANCE_ID 4 68 #define AEC_PRIORITY 1 69 70 #define CHRE_PLUGIN_IDX 0 71 #define CHRE_INSTANCE_ID 5 72 #define CHRE_EVT_ID 3 73 #define CHRE_EVT_PARAM_ID 8 74 #define CHRE_BUF_SIZE 64000 // 320B (160 samples) per 10ms -> 64000B per 2s 75 #define CHRE_CONFIGURED (0x203) 76 #define CHRE_DESTROYED (0x204) 77 #define CHRE_EVT_MASK (0x1f) 78 79 #define IAXXX_SYSID_CTRL_MGR_CM4 0x2610 80 #define IAXXX_HOST1_WAKEUP_EVENT_ID 4 81 82 #define MIXER_PKG_ID 5 83 #define MIXER_PLUGIN_IDX 0 84 #define MIXER_INSTANCE_ID 7 85 #define MIXER_PRIORITY 1 86 87 #define SRC_PKG_ID 3 88 #define SRC_PLUGIN_IDX 0 89 #define SRC_PRIORITY 1 90 #define SRC_MIC_INSTANCE_ID 6 91 #define SRC_AMP_INSTANCE_ID 7 92 93 #define BUF_PKG_ID 4 94 #define BUF_PLUGIN_IDX 0 95 #define BUF_INSTANCE_ID 1 96 #define BUF_PRIORITY 1 97 98 #define DA_BUF_INSTANCE_ID 3 99 100 #define HOTWORD_DETECTION 0 101 #define AMBIENT_DETECTION 1 102 #define ENTITY_DETECTION 2 103 #define WAKEUP_DETECTION 3 104 105 #define HOTWORD_SLOT_ID 1 106 #define AMBIENT_SLOT_ID 3 107 #define ENTITY_SLOT_ID 5 108 #define WAKEUP_SLOT_ID 6 109 110 #define HOTWORD_UNLOAD_PARAM_ID 1 111 #define AMBIENT_UNLOAD_PARAM_ID 1 112 #define AMBIENT_RESET_PARAM_ID 2 113 #define AMBIENT_GET_MODEL_STATE_PARAM_ID 7 114 #define HOTWORD_GET_VERSION_PARAM_ID 8 115 #define AMBIENT_GET_VERSION_PARAM_ID 8 116 #define HOTWORD_DEFAULT_VER 0 117 #define AMBIENT_DEFAULT_VER 0 118 119 #define BUFFER_PACKAGE "BufferPackage.bin" 120 #define BUFFER_CONFIG_OSLO_VAL "BufferConfigValOslo.bin" 121 #define BUFFER_CONFIG_VAL_MULTI_SEC "BufferConfigVal.bin" 122 #define BUFFER_CONFIG_VAL_2_SEC "BufferConfigVal2Sec.bin" 123 #define BUFFER_CONFIG_VAL_CHRE "BufferConfigValCHRE.bin" 124 #define OK_GOOGLE_PACKAGE "OkGooglePackage.bin" 125 #define AMBIENT_EC_PACKAGE "AmbientECPackage.bin" 126 #define AMBIENT_DA_PACKAGE "AmbientDAPackage.bin" 127 #define SENSOR_PACKAGE "OsloSensorPackage.bin" 128 #define SENSOR_CONFIG_VAL "OsloSensorConfig.bin" 129 #define ECHOCANCELLER_PACKAGE "EchoCancellerPackage.bin" 130 #define MIXER_PACKAGE "AScalarSimpleMixerPackage.bin" 131 #define SRC_PACKAGE "SampleRateConverterPackage.bin" 132 #define SRC_CONFIG "SampleRateConverterCreateCfgBlkGen.bin" 133 134 /* The routing definition depend on the platform 135 and the features plugin. 136 */ 137 enum { 138 ST_ROUTE_MIN = 0, 139 140 /* Input Port routing definition */ 141 ST_MIC_ROUTE_INT_CLK = ST_ROUTE_MIN, 142 ST_MIC_ROUTE_EXT_CLK, 143 ST_BARGEIN_AMP_REF, 144 ST_BARGEIN_AMP_REF_48K, 145 146 /* Plugin routing definition */ 147 ST_HOTWORD_WITHOUT_BARGEIN, 148 ST_HOTWORD_WITH_BARGEIN, 149 ST_HOTWORD_BUFFER_WITHOUT_BARGEIN, 150 ST_HOTWORD_BUFFER_WITH_BARGEIN, 151 ST_AMBIENT_WITHOUT_BARGEIN, 152 ST_AMBIENT_WITH_BARGEIN, 153 ST_AMBIENT_BUFFER_WITHOUT_BARGEIN, 154 ST_AMBIENT_BUFFER_WITH_BARGEIN, 155 ST_BARGEIN_ROUTE, 156 ST_CHRE_WITHOUT_BARGEIN, 157 ST_CHRE_WITH_BARGEIN, 158 ST_SRC_ROUTE_MIC, 159 ST_SRC_ROUTE_AMP_REF, 160 ST_SENSOR_ROUTE, 161 ST_ROUTE_MAX, 162 }; 163 164 enum clock_type { 165 INTERNAL_OSCILLATOR, 166 EXTERNAL_OSCILLATOR 167 }; 168 169 enum src_type { 170 SRC_MIC, 171 SRC_AMP_REF 172 }; 173 174 enum strm_type { 175 STRM_16K, 176 STRM_48K 177 }; 178 179 enum sthal_mode { 180 IN_CALL, 181 CON_DISABLED_ST, 182 CON_DISABLED_CAPTURE, 183 CON_ENABLED_ST, 184 CON_ENABLED_CAPTURE_ST 185 }; 186 187 typedef enum { 188 TRANSIT_NONE, 189 TRANSIT_SETUP_AEC 190 } transit_case_t; 191 192 #define PLUGIN_DEF_CONFIG_ID 0 193 194 int write_model(struct iaxxx_odsp_hw *odsp_hdl, unsigned char *data, 195 int length, int kw_type); 196 int get_model_state(struct iaxxx_odsp_hw *odsp_hdl, const uint32_t inst_id, 197 const uint32_t param_val); 198 int get_event(struct iaxxx_odsp_hw *odsp_hdl, 199 struct iaxxx_get_event_info *ge); 200 int setup_chip(struct iaxxx_odsp_hw *odsp_hdl); 201 int setup_buffer_package(struct iaxxx_odsp_hw *odsp_hdl); 202 int destroy_buffer_package(struct iaxxx_odsp_hw *odsp_hdl); 203 int setup_hotword_package(struct iaxxx_odsp_hw *odsp_hdl); 204 int destroy_hotword_package(struct iaxxx_odsp_hw *odsp_hdl); 205 unsigned int get_hotword_version(struct iaxxx_odsp_hw *odsp_hdl); 206 int setup_ambient_package(struct iaxxx_odsp_hw *odsp_hdl); 207 int destroy_ambient_package(struct iaxxx_odsp_hw *odsp_hdl); 208 unsigned int get_ambient_version(struct iaxxx_odsp_hw *odsp_hdl); 209 int setup_aec_package(struct iaxxx_odsp_hw *odsp_hdl); 210 int destroy_aec_package(struct iaxxx_odsp_hw *odsp_hdl); 211 int setup_chre_package(struct iaxxx_odsp_hw *odsp_hdl); 212 int destroy_chre_package(struct iaxxx_odsp_hw *odsp_hdl); 213 int setup_sensor_package(struct iaxxx_odsp_hw *odsp_hdl); 214 int destroy_sensor_package(struct iaxxx_odsp_hw *odsp_hdl); 215 int setup_mixer_package(struct iaxxx_odsp_hw *odsp_hdl); 216 int destroy_mixer_package(struct iaxxx_odsp_hw *odsp_hdl); 217 int setup_src_package(struct iaxxx_odsp_hw *odsp_hdl); 218 int destroy_src_package(struct iaxxx_odsp_hw *odsp_hdl); 219 220 int setup_music_buffer(struct iaxxx_odsp_hw *odsp_hdl); 221 int destroy_music_buffer(struct iaxxx_odsp_hw *odsp_hdl); 222 int setup_howord_buffer(struct iaxxx_odsp_hw *odsp_hdl); 223 int destroy_howord_buffer(struct iaxxx_odsp_hw *odsp_hdl); 224 int setup_src_plugin(struct iaxxx_odsp_hw *odsp_hdl, enum src_type st); 225 int destroy_src_plugin(struct iaxxx_odsp_hw *odsp_hdl, enum src_type st); 226 int set_hotword_buffer_route(struct audio_route *route_hdl, bool bargein); 227 int tear_hotword_buffer_route(struct audio_route *route_hdl, bool bargein); 228 int enable_mic_route(struct audio_route *route_hdl, bool enable, 229 enum clock_type ct); 230 int enable_amp_ref_route(struct audio_route *route_hdl, bool enable, 231 enum strm_type strmt); 232 int enable_src_route(struct audio_route *route_hdl, bool enable, enum src_type st); 233 int set_sensor_route(struct audio_route *route_hdl, bool enable); 234 int set_ambient_state(struct iaxxx_odsp_hw *odsp_hdl, unsigned int current); 235 int tear_ambient_state(struct iaxxx_odsp_hw *odsp_hdl, unsigned int current); 236 int set_ambient_route(struct audio_route *route_hdl, bool bargein); 237 int tear_ambient_route(struct audio_route *route_hdl, bool bargein); 238 int set_hotword_state(struct iaxxx_odsp_hw *odsp_hdl, unsigned int current); 239 int tear_hotword_state(struct iaxxx_odsp_hw *odsp_hdl, unsigned int current); 240 int set_hotword_route(struct audio_route *route_hdl, bool bargein); 241 int tear_hotword_route(struct audio_route *route_hdl, bool bargein); 242 int set_chre_audio_route(struct audio_route *route_hdl, bool bargein); 243 int tear_chre_audio_route(struct audio_route *route_hdl, bool bargein); 244 int reset_ambient_plugin(struct iaxxx_odsp_hw *odsp_hdl); 245 int enable_bargein_route(struct audio_route *route_hdl, bool enable); 246 int set_music_buffer_route(struct audio_route *route_hdl, bool downlink); 247 int tear_music_buffer_route(struct audio_route *route_hdl, bool downlink); 248 249 int flush_model(struct iaxxx_odsp_hw *odsp_hdl, int kw_type); 250 int get_entity_param_blk(struct iaxxx_odsp_hw *odsp_hdl, void *payload, unsigned int payload_size); 251 int get_wakeup_param_blk(struct iaxxx_odsp_hw *odsp_hdl, void *payload, unsigned int payload_size); 252 int set_default_apll_clk(struct mixer *mixer); 253 int get_fw_status(struct iaxxx_odsp_hw *odsp_hdl, unsigned int *status); 254 int reset_fw(struct iaxxx_odsp_hw *odsp_hdl); 255 int reset_all_route(struct audio_route *route_hdl); 256 int trigger_sensor_destroy_event(struct iaxxx_odsp_hw *odsp_hdl); 257 int trigger_chre_destroy_event(struct iaxxx_odsp_hw *odsp_hdl); 258 int setup_slpi_wakeup_event(struct iaxxx_odsp_hw *odsp_hdl, bool enabled); 259 #endif /* _CVQ_IOCTL_H */ 260