summaryrefslogtreecommitdiffstats
path: root/soundtrigger
diff options
context:
space:
mode:
authorKevin Rocard <krocard@google.com>2018-01-24 04:04:47 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-01-24 04:04:47 +0000
commitcd603ca9e85a2bfaf8049f66e661e94b7d062c5a (patch)
tree33d6259b73f46e9bc4d0741b91c59631701bc12c /soundtrigger
parent84a51275b5e62cbb632428f7ac3ccddb5b523626 (diff)
parent49c56de516b4e9556ae1b0af0ccfa7d695f5807b (diff)
downloadandroid_hardware_interfaces-cd603ca9e85a2bfaf8049f66e661e94b7d062c5a.tar.gz
android_hardware_interfaces-cd603ca9e85a2bfaf8049f66e661e94b7d062c5a.tar.bz2
android_hardware_interfaces-cd603ca9e85a2bfaf8049f66e661e94b7d062c5a.zip
Merge "Audio V4: Split system and vendor Audio.h"
Diffstat (limited to 'soundtrigger')
-rw-r--r--soundtrigger/2.0/default/Android.bp7
-rw-r--r--soundtrigger/2.0/default/Android.mk1
-rw-r--r--soundtrigger/2.0/legacy/Android.bp11
-rw-r--r--soundtrigger/2.0/legacy/OWNERS3
-rw-r--r--soundtrigger/2.0/legacy/include/hardware/sound_trigger.h130
-rw-r--r--soundtrigger/2.0/legacy/include/system/sound_trigger.h228
-rw-r--r--soundtrigger/2.1/default/Android.mk2
7 files changed, 377 insertions, 5 deletions
diff --git a/soundtrigger/2.0/default/Android.bp b/soundtrigger/2.0/default/Android.bp
index cc20f91cd..21e50e1f5 100644
--- a/soundtrigger/2.0/default/Android.bp
+++ b/soundtrigger/2.0/default/Android.bp
@@ -16,10 +16,7 @@
cc_library_shared {
name: "android.hardware.soundtrigger@2.0-core",
defaults: ["hidl_defaults"],
- vendor_available: true,
- vndk: {
- enabled: true,
- },
+ vendor: true,
srcs: [
"SoundTriggerHalImpl.cpp",
],
@@ -37,7 +34,7 @@ cc_library_shared {
],
header_libs: [
- "libaudio_system_headers",
+ "android.hardware.soundtrigger.legacy@2.0",
"libhardware_headers",
],
}
diff --git a/soundtrigger/2.0/default/Android.mk b/soundtrigger/2.0/default/Android.mk
index 835a02080..1b6360b2b 100644
--- a/soundtrigger/2.0/default/Android.mk
+++ b/soundtrigger/2.0/default/Android.mk
@@ -32,6 +32,7 @@ LOCAL_SHARED_LIBRARIES := \
android.hardware.soundtrigger@2.0-core
LOCAL_C_INCLUDE_DIRS := $(LOCAL_PATH)
+LOCAL_HEADER_LIBRARIES += android.hardware.soundtrigger.legacy@2.0
ifeq ($(strip $(AUDIOSERVER_MULTILIB)),)
LOCAL_MULTILIB := 32
diff --git a/soundtrigger/2.0/legacy/Android.bp b/soundtrigger/2.0/legacy/Android.bp
new file mode 100644
index 000000000..995477965
--- /dev/null
+++ b/soundtrigger/2.0/legacy/Android.bp
@@ -0,0 +1,11 @@
+cc_library_headers {
+ name: "android.hardware.soundtrigger.legacy@2.0",
+ vendor: true,
+ export_include_dirs: ["include"],
+ header_libs: [
+ "android.hardware.audio.common.legacy@2.0",
+ ],
+ export_header_lib_headers: [
+ "android.hardware.audio.common.legacy@2.0",
+ ],
+}
diff --git a/soundtrigger/2.0/legacy/OWNERS b/soundtrigger/2.0/legacy/OWNERS
new file mode 100644
index 000000000..6fdc97ca2
--- /dev/null
+++ b/soundtrigger/2.0/legacy/OWNERS
@@ -0,0 +1,3 @@
+elaurent@google.com
+krocard@google.com
+mnaganov@google.com
diff --git a/soundtrigger/2.0/legacy/include/hardware/sound_trigger.h b/soundtrigger/2.0/legacy/include/hardware/sound_trigger.h
new file mode 100644
index 000000000..57b405e66
--- /dev/null
+++ b/soundtrigger/2.0/legacy/include/hardware/sound_trigger.h
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <hardware/hardware.h>
+#include <system/audio.h>
+#include <system/sound_trigger.h>
+
+#ifndef ANDROID_SOUND_TRIGGER_HAL_H
+#define ANDROID_SOUND_TRIGGER_HAL_H
+
+__BEGIN_DECLS
+
+/**
+ * The id of this module
+ */
+#define SOUND_TRIGGER_HARDWARE_MODULE_ID "sound_trigger"
+
+/**
+ * Name of the audio devices to open
+ */
+#define SOUND_TRIGGER_HARDWARE_INTERFACE "sound_trigger_hw_if"
+
+#define SOUND_TRIGGER_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
+#define SOUND_TRIGGER_MODULE_API_VERSION_CURRENT SOUND_TRIGGER_MODULE_API_VERSION_1_0
+
+#define SOUND_TRIGGER_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0)
+#define SOUND_TRIGGER_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION(1, 1)
+#define SOUND_TRIGGER_DEVICE_API_VERSION_CURRENT SOUND_TRIGGER_DEVICE_API_VERSION_1_1
+
+/**
+ * List of known sound trigger HAL modules. This is the base name of the sound_trigger HAL
+ * library composed of the "sound_trigger." prefix, one of the base names below and
+ * a suffix specific to the device.
+ * e.g: sondtrigger.primary.goldfish.so or sound_trigger.primary.default.so
+ */
+
+#define SOUND_TRIGGER_HARDWARE_MODULE_ID_PRIMARY "primary"
+
+/**
+ * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
+ * and the fields of this data structure must begin with hw_module_t
+ * followed by module specific information.
+ */
+struct sound_trigger_module {
+ struct hw_module_t common;
+};
+
+typedef void (*recognition_callback_t)(struct sound_trigger_recognition_event* event, void* cookie);
+typedef void (*sound_model_callback_t)(struct sound_trigger_model_event* event, void* cookie);
+
+struct sound_trigger_hw_device {
+ struct hw_device_t common;
+
+ /*
+ * Retrieve implementation properties.
+ */
+ int (*get_properties)(const struct sound_trigger_hw_device* dev,
+ struct sound_trigger_properties* properties);
+
+ /*
+ * Load a sound model. Once loaded, recognition of this model can be started and stopped.
+ * Only one active recognition per model at a time. The SoundTrigger service will handle
+ * concurrent recognition requests by different users/applications on the same model.
+ * The implementation returns a unique handle used by other functions (unload_sound_model(),
+ * start_recognition(), etc...
+ */
+ int (*load_sound_model)(const struct sound_trigger_hw_device* dev,
+ struct sound_trigger_sound_model* sound_model,
+ sound_model_callback_t callback, void* cookie,
+ sound_model_handle_t* handle);
+
+ /*
+ * Unload a sound model. A sound model can be unloaded to make room for a new one to overcome
+ * implementation limitations.
+ */
+ int (*unload_sound_model)(const struct sound_trigger_hw_device* dev,
+ sound_model_handle_t handle);
+
+ /* Start recognition on a given model. Only one recognition active at a time per model.
+ * Once recognition succeeds of fails, the callback is called.
+ * TODO: group recognition configuration parameters into one struct and add key phrase options.
+ */
+ int (*start_recognition)(const struct sound_trigger_hw_device* dev,
+ sound_model_handle_t sound_model_handle,
+ const struct sound_trigger_recognition_config* config,
+ recognition_callback_t callback, void* cookie);
+
+ /* Stop recognition on a given model.
+ * The implementation does not have to call the callback when stopped via this method.
+ */
+ int (*stop_recognition)(const struct sound_trigger_hw_device* dev,
+ sound_model_handle_t sound_model_handle);
+
+ /* Stop recognition on all models.
+ * Only supported for device api versions SOUND_TRIGGER_DEVICE_API_VERSION_1_1 or above.
+ * If no implementation is provided, stop_recognition will be called for each running model.
+ */
+ int (*stop_all_recognitions)(const struct sound_trigger_hw_device* dev);
+};
+
+typedef struct sound_trigger_hw_device sound_trigger_hw_device_t;
+
+/** convenience API for opening and closing a supported device */
+
+static inline int sound_trigger_hw_device_open(const struct hw_module_t* module,
+ struct sound_trigger_hw_device** device) {
+ return module->methods->open(module, SOUND_TRIGGER_HARDWARE_INTERFACE,
+ TO_HW_DEVICE_T_OPEN(device));
+}
+
+static inline int sound_trigger_hw_device_close(struct sound_trigger_hw_device* device) {
+ return device->common.close(&device->common);
+}
+
+__END_DECLS
+
+#endif // ANDROID_SOUND_TRIGGER_HAL_H
diff --git a/soundtrigger/2.0/legacy/include/system/sound_trigger.h b/soundtrigger/2.0/legacy/include/system/sound_trigger.h
new file mode 100644
index 000000000..5d00c1240
--- /dev/null
+++ b/soundtrigger/2.0/legacy/include/system/sound_trigger.h
@@ -0,0 +1,228 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_SOUND_TRIGGER_H
+#define ANDROID_SOUND_TRIGGER_H
+
+#include <stdbool.h>
+#include <system/audio.h>
+
+#define SOUND_TRIGGER_MAX_STRING_LEN 64 // max length of strings in properties & descriptor structs
+#define SOUND_TRIGGER_MAX_LOCALE_LEN 6 // max length of locale string. e.g en_US
+#define SOUND_TRIGGER_MAX_USERS 10 // max number of concurrent users
+#define SOUND_TRIGGER_MAX_PHRASES 10 // max number of concurrent phrases
+
+typedef enum {
+ SOUND_TRIGGER_STATE_NO_INIT = -1, /* The sound trigger service is not initialized */
+ SOUND_TRIGGER_STATE_ENABLED = 0, /* The sound trigger service is enabled */
+ SOUND_TRIGGER_STATE_DISABLED = 1 /* The sound trigger service is disabled */
+} sound_trigger_service_state_t;
+
+#define RECOGNITION_MODE_VOICE_TRIGGER 0x1 // simple voice trigger
+#define RECOGNITION_MODE_USER_IDENTIFICATION 0x2 // trigger only if one user in model identified
+#define RECOGNITION_MODE_USER_AUTHENTICATION 0x4 // trigger only if one user in mode authenticated
+#define RECOGNITION_MODE_GENERIC_TRIGGER 0x8 // generic sound trigger
+
+#define RECOGNITION_STATUS_SUCCESS 0
+#define RECOGNITION_STATUS_ABORT 1
+#define RECOGNITION_STATUS_FAILURE 2
+
+#define SOUND_MODEL_STATUS_UPDATED 0
+
+typedef enum {
+ SOUND_MODEL_TYPE_UNKNOWN = -1, /* use for unspecified sound model type */
+ SOUND_MODEL_TYPE_KEYPHRASE = 0, /* use for key phrase sound models */
+ SOUND_MODEL_TYPE_GENERIC = 1 /* use for all models other than keyphrase */
+} sound_trigger_sound_model_type_t;
+
+typedef audio_uuid_t sound_trigger_uuid_t;
+
+/*
+ * sound trigger implementation descriptor read by the framework via get_properties().
+ * Used by SoundTrigger service to report to applications and manage concurrency and policy.
+ */
+struct sound_trigger_properties {
+ char implementor[SOUND_TRIGGER_MAX_STRING_LEN]; /* implementor name */
+ char description[SOUND_TRIGGER_MAX_STRING_LEN]; /* implementation description */
+ unsigned int version; /* implementation version */
+ sound_trigger_uuid_t uuid; /* unique implementation ID.
+ Must change with version each version */
+ unsigned int max_sound_models; /* maximum number of concurrent sound models
+ loaded */
+ unsigned int max_key_phrases; /* maximum number of key phrases */
+ unsigned int max_users; /* maximum number of concurrent users detected */
+ unsigned int recognition_modes; /* all supported modes.
+ e.g RECOGNITION_MODE_VOICE_TRIGGER */
+ bool capture_transition; /* supports seamless transition from detection
+ to capture */
+ unsigned int max_buffer_ms; /* maximum buffering capacity in ms if
+ capture_transition is true*/
+ bool concurrent_capture; /* supports capture by other use cases while
+ detection is active */
+ bool trigger_in_event; /* returns the trigger capture in event */
+ unsigned int power_consumption_mw; /* Rated power consumption when detection is active
+ with TDB silence/sound/speech ratio */
+};
+
+typedef int sound_trigger_module_handle_t;
+
+struct sound_trigger_module_descriptor {
+ sound_trigger_module_handle_t handle;
+ struct sound_trigger_properties properties;
+};
+
+typedef int sound_model_handle_t;
+
+/*
+ * Base sound model descriptor. This struct is the header of a larger block passed to
+ * load_sound_model() and containing the binary data of the sound model.
+ * Proprietary representation of users in binary data must match information indicated
+ * by users field
+ */
+struct sound_trigger_sound_model {
+ sound_trigger_sound_model_type_t type; /* model type. e.g. SOUND_MODEL_TYPE_KEYPHRASE */
+ sound_trigger_uuid_t uuid; /* unique sound model ID. */
+ sound_trigger_uuid_t vendor_uuid; /* unique vendor ID. Identifies the engine the
+ sound model was build for */
+ unsigned int data_size; /* size of opaque model data */
+ unsigned int data_offset; /* offset of opaque data start from head of struct
+ (e.g sizeof struct sound_trigger_sound_model) */
+};
+
+/* key phrase descriptor */
+struct sound_trigger_phrase {
+ unsigned int id; /* keyphrase ID */
+ unsigned int recognition_mode; /* recognition modes supported by this key phrase */
+ unsigned int num_users; /* number of users in the key phrase */
+ unsigned int users[SOUND_TRIGGER_MAX_USERS]; /* users ids: (not uid_t but sound trigger
+ specific IDs */
+ char locale[SOUND_TRIGGER_MAX_LOCALE_LEN]; /* locale - JAVA Locale style (e.g. en_US) */
+ char text[SOUND_TRIGGER_MAX_STRING_LEN]; /* phrase text in UTF-8 format. */
+};
+
+/*
+ * Specialized sound model for key phrase detection.
+ * Proprietary representation of key phrases in binary data must match information indicated
+ * by phrases field
+ */
+struct sound_trigger_phrase_sound_model {
+ struct sound_trigger_sound_model common;
+ unsigned int num_phrases; /* number of key phrases in model */
+ struct sound_trigger_phrase phrases[SOUND_TRIGGER_MAX_PHRASES];
+};
+
+/*
+ * Generic sound model, used for all cases except key phrase detection.
+ */
+struct sound_trigger_generic_sound_model {
+ struct sound_trigger_sound_model common;
+};
+
+/*
+ * Generic recognition event sent via recognition callback
+ * Must be aligned to transmit as raw memory through Binder.
+ */
+struct __attribute__((aligned(8))) sound_trigger_recognition_event {
+ int status; /* recognition status e.g.
+ RECOGNITION_STATUS_SUCCESS */
+ sound_trigger_sound_model_type_t type; /* event type, same as sound model type.
+ e.g. SOUND_MODEL_TYPE_KEYPHRASE */
+ sound_model_handle_t model; /* loaded sound model that triggered the
+ event */
+ bool capture_available; /* it is possible to capture audio from this
+ utterance buffered by the
+ implementation */
+ int capture_session; /* audio session ID. framework use */
+ int capture_delay_ms; /* delay in ms between end of model
+ detection and start of audio available
+ for capture. A negative value is possible
+ (e.g. if key phrase is also available for
+ capture */
+ int capture_preamble_ms; /* duration in ms of audio captured
+ before the start of the trigger.
+ 0 if none. */
+ bool trigger_in_data; /* the opaque data is the capture of
+ the trigger sound */
+ audio_config_t audio_config; /* audio format of either the trigger in
+ event data or to use for capture of the
+ rest of the utterance */
+ unsigned int data_size; /* size of opaque event data */
+ unsigned int data_offset; /* offset of opaque data start from start of
+ this struct (e.g sizeof struct
+ sound_trigger_phrase_recognition_event) */
+};
+
+/*
+ * Confidence level for each user in struct sound_trigger_phrase_recognition_extra
+ */
+struct sound_trigger_confidence_level {
+ unsigned int user_id; /* user ID */
+ unsigned int level; /* confidence level in percent (0 - 100).
+ - min level for recognition configuration
+ - detected level for recognition event */
+};
+
+/*
+ * Specialized recognition event for key phrase detection
+ */
+struct sound_trigger_phrase_recognition_extra {
+ unsigned int id; /* keyphrase ID */
+ unsigned int recognition_modes; /* recognition modes used for this keyphrase */
+ unsigned int confidence_level; /* confidence level for mode RECOGNITION_MODE_VOICE_TRIGGER */
+ unsigned int num_levels; /* number of user confidence levels */
+ struct sound_trigger_confidence_level levels[SOUND_TRIGGER_MAX_USERS];
+};
+
+struct sound_trigger_phrase_recognition_event {
+ struct sound_trigger_recognition_event common;
+ unsigned int num_phrases;
+ struct sound_trigger_phrase_recognition_extra phrase_extras[SOUND_TRIGGER_MAX_PHRASES];
+};
+
+struct sound_trigger_generic_recognition_event {
+ struct sound_trigger_recognition_event common;
+};
+
+/*
+ * configuration for sound trigger capture session passed to start_recognition()
+ */
+struct sound_trigger_recognition_config {
+ audio_io_handle_t capture_handle; /* IO handle that will be used for capture.
+ N/A if capture_requested is false */
+ audio_devices_t capture_device; /* input device requested for detection capture */
+ bool capture_requested; /* capture and buffer audio for this recognition
+ instance */
+ unsigned int num_phrases; /* number of key phrases recognition extras */
+ struct sound_trigger_phrase_recognition_extra phrases[SOUND_TRIGGER_MAX_PHRASES];
+ /* configuration for each key phrase */
+ unsigned int data_size; /* size of opaque capture configuration data */
+ unsigned int data_offset; /* offset of opaque data start from start of this struct
+ (e.g sizeof struct sound_trigger_recognition_config) */
+};
+
+/*
+ * Event sent via load sound model callback
+ */
+struct sound_trigger_model_event {
+ int status; /* sound model status e.g. SOUND_MODEL_STATUS_UPDATED */
+ sound_model_handle_t model; /* loaded sound model that triggered the event */
+ unsigned int data_size; /* size of event data if any. Size of updated sound model if
+ status is SOUND_MODEL_STATUS_UPDATED */
+ unsigned int data_offset; /* offset of data start from start of this struct
+ (e.g sizeof struct sound_trigger_model_event) */
+};
+
+#endif // ANDROID_SOUND_TRIGGER_H
diff --git a/soundtrigger/2.1/default/Android.mk b/soundtrigger/2.1/default/Android.mk
index 5851d63ed..04d3f3650 100644
--- a/soundtrigger/2.1/default/Android.mk
+++ b/soundtrigger/2.1/default/Android.mk
@@ -38,6 +38,8 @@ LOCAL_SHARED_LIBRARIES := \
android.hidl.allocator@1.0 \
android.hidl.memory@1.0
+LOCAL_HEADER_LIBRARIES := android.hardware.soundtrigger.legacy@2.0
+
LOCAL_C_INCLUDE_DIRS := $(LOCAL_PATH)
ifeq ($(strip $(AUDIOSERVER_MULTILIB)),)