From cb49463796c56f00570111c4ae5051cba645102b Mon Sep 17 00:00:00 2001 From: Nicholas Ambur Date: Sun, 8 Dec 2019 21:52:36 -0800 Subject: [PATCH] add model arch to SoundTrigger Properties Bug: 142414689 Test: Assist GTS test suite and manual testing Change-Id: Ie8bb4bdd292aceaae92c6f550a9633068cabdd24 --- current.txt | 4 +- soundtrigger/2.3/ISoundTriggerHw.hal | 12 ++++++ soundtrigger/2.3/default/SoundTriggerHw.cpp | 37 ++++++++++++++++++- soundtrigger/2.3/default/SoundTriggerHw.h | 3 ++ soundtrigger/2.3/types.hal | 15 ++++++++ .../VtsHalSoundtriggerV2_3TargetTest.cpp | 28 ++++++++++++++ 6 files changed, 95 insertions(+), 4 deletions(-) diff --git a/current.txt b/current.txt index 8bf63c7d7f..847fed663d 100644 --- a/current.txt +++ b/current.txt @@ -665,5 +665,5 @@ f4888f9676890b43a459c6380f335fea7a6ad32ed3bafafeb018a88d6c0be8a4 android.hardwar b27ab0cd40b0b078cdcd024bfe1061c4c4c065f3519eeb9347fa359a3268a5ae android.hardware.radio.config@1.3::IRadioConfig 742360c775313438b0f82256eac62fb5bbc76a6ae6f388573f3aa142fb2c1eea android.hardware.radio.config@1.3::IRadioConfigIndication 7683fed9d253956071f18b152e6be657719536f98d9b534433d5e411bcde5061 android.hardware.radio.config@1.3::IRadioConfigResponse -c411dc16855fcb786cd5e08fe2889acbd72fd54217bd27fe0373813de230ce5f android.hardware.soundtrigger@2.3::types -5abad7b54d3400fab633cb7a36ffc1747e037bf805d3d9e3517cb6aabf26b002 android.hardware.soundtrigger@2.3::ISoundTriggerHw +b46d358537168c478762c3d34d5fe1555a3fcd89cd1f43621350ada395e6f795 android.hardware.soundtrigger@2.3::types +15924fbf38b3c282299a37e48c72405c97e322f844f815081db6acbca22d4165 android.hardware.soundtrigger@2.3::ISoundTriggerHw diff --git a/soundtrigger/2.3/ISoundTriggerHw.hal b/soundtrigger/2.3/ISoundTriggerHw.hal index 207b9b74f9..23aa36ead0 100644 --- a/soundtrigger/2.3/ISoundTriggerHw.hal +++ b/soundtrigger/2.3/ISoundTriggerHw.hal @@ -25,6 +25,18 @@ import @2.2::ISoundTriggerHw; */ interface ISoundTriggerHw extends @2.2::ISoundTriggerHw { + /** + * Retrieve extended implementation properties. + * The returned properties includes what is returned from the + * getProperties along with expanded implementation details. + * + * @return retval Operation completion status: 0 in case of success, + * -ENODEV in case of initialization error. + * @return properties A Properties structure containing implementation + * description and capabilities. + */ + getProperties_2_3() generates (int32_t retval, Properties properties); + /** * Set a model specific parameter with the given value. This parameter * will keep its value for the duration the model is loaded regardless of starting and stopping diff --git a/soundtrigger/2.3/default/SoundTriggerHw.cpp b/soundtrigger/2.3/default/SoundTriggerHw.cpp index 4a39ab562d..9fd8fe0e5c 100644 --- a/soundtrigger/2.3/default/SoundTriggerHw.cpp +++ b/soundtrigger/2.3/default/SoundTriggerHw.cpp @@ -89,7 +89,7 @@ Return SoundTriggerHw::getProperties(ISoundTriggerHw::getProperties_cb _hi ALOGV("getProperties() mHwDevice %p", mHwDevice); int ret; struct sound_trigger_properties halProperties; - ISoundTriggerHw::Properties properties; + V2_0::ISoundTriggerHw::Properties properties; if (mHwDevice == NULL) { ret = -ENODEV; @@ -333,7 +333,7 @@ void SoundTriggerHw::convertUuidToHal(sound_trigger_uuid_t* halUuid, const Uuid* } void SoundTriggerHw::convertPropertiesFromHal( - ISoundTriggerHw::Properties* properties, + V2_0::ISoundTriggerHw::Properties* properties, const struct sound_trigger_properties* halProperties) { properties->implementor = halProperties->implementor; properties->description = halProperties->description; @@ -350,6 +350,16 @@ void SoundTriggerHw::convertPropertiesFromHal( properties->powerConsumptionMw = halProperties->power_consumption_mw; } +void SoundTriggerHw::convertPropertiesFromHal( + V2_3::Properties* properties, const struct sound_trigger_properties_header* header) { + if (header->version >= SOUND_TRIGGER_DEVICE_API_VERSION_1_3) { + const struct sound_trigger_properties_extended_1_3* halProperties = + (const struct sound_trigger_properties_extended_1_3*)header; + convertPropertiesFromHal(&properties->base, &halProperties->base); + properties->supportedModelArch = halProperties->supported_model_arch; + } +} + void SoundTriggerHw::convertTriggerPhraseToHal(struct sound_trigger_phrase* halTriggerPhrase, const ISoundTriggerHw::Phrase* triggerPhrase) { halTriggerPhrase->id = triggerPhrase->id; @@ -708,6 +718,29 @@ Return SoundTriggerHw::getModelState(int32_t modelHandle) { // Begin V2_3 implementation +Return SoundTriggerHw::getProperties_2_3(ISoundTriggerHw::getProperties_2_3_cb _hidl_cb) { + ALOGV("getProperties_2_3() mHwDevice %p", mHwDevice); + int ret = 0; + V2_3::Properties properties; + const struct sound_trigger_properties_header* header; + + if (mHwDevice == NULL) { + ret = -ENODEV; + goto exit; + } + + header = mHwDevice->get_properties_extended(mHwDevice); + + convertPropertiesFromHal(&properties, header); + + ALOGV("getProperties_2_3 implementor %s supportedModelArch %s", + properties.base.implementor.c_str(), properties.supportedModelArch.c_str()); + +exit: + _hidl_cb(ret, properties); + return Void(); +} + Return SoundTriggerHw::setParameter(V2_0::SoundModelHandle modelHandle, ModelParameter modelParam, int32_t value) { sp client; diff --git a/soundtrigger/2.3/default/SoundTriggerHw.h b/soundtrigger/2.3/default/SoundTriggerHw.h index c82c9ea0e2..078debb81d 100644 --- a/soundtrigger/2.3/default/SoundTriggerHw.h +++ b/soundtrigger/2.3/default/SoundTriggerHw.h @@ -85,6 +85,7 @@ struct SoundTriggerHw : public ISoundTriggerHw { Return getModelState(int32_t modelHandle) override; // Methods from V2_3::ISoundTriggerHw follow. + Return getProperties_2_3(getProperties_2_3_cb _hidl_cb) override; Return setParameter(V2_0::SoundModelHandle modelHandle, ModelParameter modelParam, int32_t value) override; Return getParameter(V2_0::SoundModelHandle modelHandle, ModelParameter modelParam, @@ -156,6 +157,8 @@ struct SoundTriggerHw : public ISoundTriggerHw { void convertUuidToHal(sound_trigger_uuid_t* halUuid, const Uuid* uuid); void convertPropertiesFromHal(V2_0::ISoundTriggerHw::Properties* properties, const struct sound_trigger_properties* halProperties); + void convertPropertiesFromHal(V2_3::Properties* properties, + const struct sound_trigger_properties_header* header); static sound_trigger_model_parameter_t convertModelParameterToHal(ModelParameter param); void convertTriggerPhraseToHal(struct sound_trigger_phrase* halTriggerPhrase, const V2_0::ISoundTriggerHw::Phrase* triggerPhrase); diff --git a/soundtrigger/2.3/types.hal b/soundtrigger/2.3/types.hal index c3a522b31f..614912679a 100644 --- a/soundtrigger/2.3/types.hal +++ b/soundtrigger/2.3/types.hal @@ -17,6 +17,21 @@ package android.hardware.soundtrigger@2.3; import android.hidl.safe_union@1.0::Monostate; +import @2.0::ISoundTriggerHw.Properties; + +/** + * Extended implementation properties providing verbose implementation + * details. + */ +struct Properties { + @2.0::ISoundTriggerHw.Properties base; + + /** + * String naming the architecture used for running the supported models. + * (eg. DSP architecture) + */ + string supportedModelArch; +}; /** * Model specific parameters to be used with parameter set and get APIs diff --git a/soundtrigger/2.3/vts/functional/VtsHalSoundtriggerV2_3TargetTest.cpp b/soundtrigger/2.3/vts/functional/VtsHalSoundtriggerV2_3TargetTest.cpp index 202eb6c09b..ed38368d8c 100644 --- a/soundtrigger/2.3/vts/functional/VtsHalSoundtriggerV2_3TargetTest.cpp +++ b/soundtrigger/2.3/vts/functional/VtsHalSoundtriggerV2_3TargetTest.cpp @@ -26,7 +26,9 @@ using ::android::sp; using ::android::hardware::Return; +using ::android::hardware::soundtrigger::V2_0::RecognitionMode; using ::android::hardware::soundtrigger::V2_3::ISoundTriggerHw; +using ::android::hardware::soundtrigger::V2_3::Properties; /** * Test class holding the instance of the SoundTriggerHW service to test. @@ -53,6 +55,32 @@ class SoundTriggerHidlTest : public testing::TestWithParam { */ TEST_P(SoundTriggerHidlTest, ServiceIsInstantiated) {} +/** + * Test ISoundTriggerHw::getProperties_2_3 method + * + * Verifies that: + * - the implementation implements the method + * - the method returns no error + * - the implementation supports at least one sound model and one key phrase + * - the implementation supports at least VOICE_TRIGGER recognition mode + */ +TEST_P(SoundTriggerHidlTest, GetProperties_2_3) { + Properties halProperties; + Return hidlReturn; + int ret = -ENODEV; + + hidlReturn = soundtrigger->getProperties_2_3([&](int rc, auto res) { + ret = rc; + halProperties = res; + }); + + EXPECT_TRUE(hidlReturn.isOk()); + EXPECT_EQ(0, ret); + EXPECT_GT(halProperties.base.maxSoundModels, 0u); + EXPECT_GT(halProperties.base.maxKeyPhrases, 0u); + EXPECT_NE(0u, (halProperties.base.recognitionModes & (uint32_t)RecognitionMode::VOICE_TRIGGER)); +} + INSTANTIATE_TEST_SUITE_P( PerInstance, SoundTriggerHidlTest, testing::ValuesIn(android::hardware::getAllHalInstanceNames(ISoundTriggerHw::descriptor)),