1*4d7e907cSAndroid Build Coastguard Worker/* 2*4d7e907cSAndroid Build Coastguard Worker * Copyright 2019 The Android Open Source Project 3*4d7e907cSAndroid Build Coastguard Worker * 4*4d7e907cSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*4d7e907cSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*4d7e907cSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*4d7e907cSAndroid Build Coastguard Worker * 8*4d7e907cSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*4d7e907cSAndroid Build Coastguard Worker * 10*4d7e907cSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*4d7e907cSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*4d7e907cSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*4d7e907cSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*4d7e907cSAndroid Build Coastguard Worker * limitations under the License. 15*4d7e907cSAndroid Build Coastguard Worker */ 16*4d7e907cSAndroid Build Coastguard Worker 17*4d7e907cSAndroid Build Coastguard Workerpackage [email protected]; 18*4d7e907cSAndroid Build Coastguard Worker 19*4d7e907cSAndroid Build Coastguard Workerimport @2.0::SoundModelHandle; 20*4d7e907cSAndroid Build Coastguard Workerimport @2.0::ISoundTriggerHwCallback.CallbackCookie; 21*4d7e907cSAndroid Build Coastguard Workerimport @2.2::ISoundTriggerHw; 22*4d7e907cSAndroid Build Coastguard Workerimport @2.1::ISoundTriggerHwCallback; 23*4d7e907cSAndroid Build Coastguard Worker 24*4d7e907cSAndroid Build Coastguard Worker/** 25*4d7e907cSAndroid Build Coastguard Worker * SoundTrigger HAL interface. Used for hardware recognition of hotwords 26*4d7e907cSAndroid Build Coastguard Worker * and other sounds. 27*4d7e907cSAndroid Build Coastguard Worker */ 28*4d7e907cSAndroid Build Coastguard Workerinterface ISoundTriggerHw extends @2.2::ISoundTriggerHw { 29*4d7e907cSAndroid Build Coastguard Worker 30*4d7e907cSAndroid Build Coastguard Worker /** 31*4d7e907cSAndroid Build Coastguard Worker * Retrieve extended implementation properties. 32*4d7e907cSAndroid Build Coastguard Worker * The returned properties includes what is returned from the 33*4d7e907cSAndroid Build Coastguard Worker * getProperties along with expanded implementation details. 34*4d7e907cSAndroid Build Coastguard Worker * 35*4d7e907cSAndroid Build Coastguard Worker * @return retval Operation completion status: 0 in case of success, 36*4d7e907cSAndroid Build Coastguard Worker * -ENODEV in case of initialization error. 37*4d7e907cSAndroid Build Coastguard Worker * @return properties A Properties structure containing implementation 38*4d7e907cSAndroid Build Coastguard Worker * description and capabilities. 39*4d7e907cSAndroid Build Coastguard Worker */ 40*4d7e907cSAndroid Build Coastguard Worker getProperties_2_3() generates (int32_t retval, Properties properties); 41*4d7e907cSAndroid Build Coastguard Worker 42*4d7e907cSAndroid Build Coastguard Worker /** 43*4d7e907cSAndroid Build Coastguard Worker * Start recognition on a given model. Only one recognition active 44*4d7e907cSAndroid Build Coastguard Worker * at a time per model. Once recognition succeeds or fails, the callback 45*4d7e907cSAndroid Build Coastguard Worker * associated with the model handle is called. 46*4d7e907cSAndroid Build Coastguard Worker * 47*4d7e907cSAndroid Build Coastguard Worker * Must have the exact same semantics as startRecognition from 48*4d7e907cSAndroid Build Coastguard Worker * [email protected] except that the RecognitionConfig includes audio 49*4d7e907cSAndroid Build Coastguard Worker * capabilities applied when the recognition is active. 50*4d7e907cSAndroid Build Coastguard Worker * 51*4d7e907cSAndroid Build Coastguard Worker * @param modelHandle the handle of the sound model to use for recognition 52*4d7e907cSAndroid Build Coastguard Worker * @param config A RecognitionConfig structure containing attributes of the 53*4d7e907cSAndroid Build Coastguard Worker * recognition to perform 54*4d7e907cSAndroid Build Coastguard Worker * @return retval Operation completion status: 0 in case of success, 55*4d7e907cSAndroid Build Coastguard Worker * -EINVAL in case of invalid recognition attributes, 56*4d7e907cSAndroid Build Coastguard Worker * -ENOSYS in case of invalid model handle, 57*4d7e907cSAndroid Build Coastguard Worker * -ENOMEM in case of memory allocation failure, 58*4d7e907cSAndroid Build Coastguard Worker * -ENODEV in case of initialization error. 59*4d7e907cSAndroid Build Coastguard Worker */ 60*4d7e907cSAndroid Build Coastguard Worker startRecognition_2_3(SoundModelHandle modelHandle, RecognitionConfig config) 61*4d7e907cSAndroid Build Coastguard Worker generates (int32_t retval); 62*4d7e907cSAndroid Build Coastguard Worker 63*4d7e907cSAndroid Build Coastguard Worker /** 64*4d7e907cSAndroid Build Coastguard Worker * Set a model specific parameter with the given value. This parameter 65*4d7e907cSAndroid Build Coastguard Worker * will keep its value for the duration the model is loaded regardless of starting and stopping 66*4d7e907cSAndroid Build Coastguard Worker * recognition. Once the model is unloaded, the value will be lost. 67*4d7e907cSAndroid Build Coastguard Worker * It is expected to check if the handle supports the parameter via the queryParameter 68*4d7e907cSAndroid Build Coastguard Worker * API prior to calling this method. 69*4d7e907cSAndroid Build Coastguard Worker * 70*4d7e907cSAndroid Build Coastguard Worker * @param modelHandle The sound model handle indicating which model to modify parameters 71*4d7e907cSAndroid Build Coastguard Worker * @param modelParam Parameter to set which will be validated against the 72*4d7e907cSAndroid Build Coastguard Worker * ModelParameter type. Not putting ModelParameter type 73*4d7e907cSAndroid Build Coastguard Worker * directly in the definition and validating internally 74*4d7e907cSAndroid Build Coastguard Worker * allows for forward compatibility. 75*4d7e907cSAndroid Build Coastguard Worker * @param value The value to set for the given model parameter 76*4d7e907cSAndroid Build Coastguard Worker * @return status Operation completion status: 0 in case of success, 77*4d7e907cSAndroid Build Coastguard Worker * -ENODEV if the native service cannot be reached 78*4d7e907cSAndroid Build Coastguard Worker * -EINVAL invalid input parameter 79*4d7e907cSAndroid Build Coastguard Worker */ 80*4d7e907cSAndroid Build Coastguard Worker setParameter(SoundModelHandle modelHandle, ModelParameter modelParam, int32_t value) 81*4d7e907cSAndroid Build Coastguard Worker generates (int32_t status); 82*4d7e907cSAndroid Build Coastguard Worker 83*4d7e907cSAndroid Build Coastguard Worker /** 84*4d7e907cSAndroid Build Coastguard Worker * Get a model specific parameter. This parameter will keep its value 85*4d7e907cSAndroid Build Coastguard Worker * for the duration the model is loaded regardless of starting and stopping recognition. 86*4d7e907cSAndroid Build Coastguard Worker * Once the model is unloaded, the value will be lost. If the value is not set, a default 87*4d7e907cSAndroid Build Coastguard Worker * value is returned. See ModelParameter for parameter default values. 88*4d7e907cSAndroid Build Coastguard Worker * It is expected to check if the handle supports the parameter via the queryParameter 89*4d7e907cSAndroid Build Coastguard Worker * API prior to calling this method. 90*4d7e907cSAndroid Build Coastguard Worker * 91*4d7e907cSAndroid Build Coastguard Worker * @param modelHandle The sound model associated with given modelParam 92*4d7e907cSAndroid Build Coastguard Worker * @param modelParam Parameter to set which will be validated against the 93*4d7e907cSAndroid Build Coastguard Worker * ModelParameter type. Not putting ModelParameter type 94*4d7e907cSAndroid Build Coastguard Worker * directly in the definition and validating internally 95*4d7e907cSAndroid Build Coastguard Worker * allows for forward compatibility. 96*4d7e907cSAndroid Build Coastguard Worker * @return status Operation completion status: 0 in case of success, 97*4d7e907cSAndroid Build Coastguard Worker * -ENODEV if the native service cannot be reached 98*4d7e907cSAndroid Build Coastguard Worker * -EINVAL invalid input parameter 99*4d7e907cSAndroid Build Coastguard Worker * @return value Value set to the requested parameter. Value is only set when status 100*4d7e907cSAndroid Build Coastguard Worker * indicates success. 101*4d7e907cSAndroid Build Coastguard Worker */ 102*4d7e907cSAndroid Build Coastguard Worker getParameter(SoundModelHandle modelHandle, ModelParameter modelParam) 103*4d7e907cSAndroid Build Coastguard Worker generates (int32_t status, int32_t value); 104*4d7e907cSAndroid Build Coastguard Worker 105*4d7e907cSAndroid Build Coastguard Worker /** 106*4d7e907cSAndroid Build Coastguard Worker * Get supported parameter attributes with respect to the provided model 107*4d7e907cSAndroid Build Coastguard Worker * handle. Along with determining the valid range, this API is also used 108*4d7e907cSAndroid Build Coastguard Worker * to determine if a given parameter ID is supported at all by the 109*4d7e907cSAndroid Build Coastguard Worker * modelHandle for use with getParameter and setParameter APIs. 110*4d7e907cSAndroid Build Coastguard Worker * 111*4d7e907cSAndroid Build Coastguard Worker * @param modelHandle The sound model handle indicating which model to query 112*4d7e907cSAndroid Build Coastguard Worker * @param modelParam Parameter to set which will be validated against the 113*4d7e907cSAndroid Build Coastguard Worker * ModelParameter type 114*4d7e907cSAndroid Build Coastguard Worker * @return status Operation completion status: 0 in case of success 115*4d7e907cSAndroid Build Coastguard Worker * -ENODEV if the native service cannot be reached 116*4d7e907cSAndroid Build Coastguard Worker * -EINVAL invalid input parameter 117*4d7e907cSAndroid Build Coastguard Worker * @return retval OptionalModelParameterRange safe union structure wrapping 118*4d7e907cSAndroid Build Coastguard Worker * ModelParameterRange. This structure indicates supported attributes 119*4d7e907cSAndroid Build Coastguard Worker * of the parameter for the given model handle. If the parameter is not 120*4d7e907cSAndroid Build Coastguard Worker * supported the Monostate of the union is used. 121*4d7e907cSAndroid Build Coastguard Worker */ 122*4d7e907cSAndroid Build Coastguard Worker queryParameter(SoundModelHandle modelHandle, ModelParameter modelParam) 123*4d7e907cSAndroid Build Coastguard Worker generates (int32_t status, OptionalModelParameterRange retval); 124*4d7e907cSAndroid Build Coastguard Worker}; 125