summaryrefslogtreecommitdiffstats
path: root/include/hardware/sound_trigger.h
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2014-04-15 10:54:24 -0700
committerEric Laurent <elaurent@google.com>2014-06-04 14:34:06 -0700
commit46bbe8a7822278db4b3bd926e6f7cb2e0326a2df (patch)
tree3026b273521ef1d4b3dc791290d43671a2fd3563 /include/hardware/sound_trigger.h
parent5fa7fb99b087a4959479728a86d355f9fa8bb1e3 (diff)
downloadhardware_libhardware-46bbe8a7822278db4b3bd926e6f7cb2e0326a2df.zip
hardware_libhardware-46bbe8a7822278db4b3bd926e6f7cb2e0326a2df.tar.gz
hardware_libhardware-46bbe8a7822278db4b3bd926e6f7cb2e0326a2df.tar.bz2
added sound trigger HAL.
Defined HAL for hardware voice and sound activity activity detection (sound trigger). Change-Id: I04f3c770c69a81245e8a15dd9e097e2c3f5ef069
Diffstat (limited to 'include/hardware/sound_trigger.h')
-rw-r--r--include/hardware/sound_trigger.h133
1 files changed, 133 insertions, 0 deletions
diff --git a/include/hardware/sound_trigger.h b/include/hardware/sound_trigger.h
new file mode 100644
index 0000000..fc3ac47
--- /dev/null
+++ b/include/hardware/sound_trigger.h
@@ -0,0 +1,133 @@
+/*
+ * 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 <system/audio.h>
+#include <system/sound_trigger.h>
+#include <hardware/hardware.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_CURRENT SOUND_TRIGGER_DEVICE_API_VERSION_1_0
+
+/**
+ * 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,
+ audio_io_handle_t capture_handle,
+ audio_devices_t capture_device,
+ recognition_callback_t callback,
+ void *cookie,
+ unsigned int data_size,
+ char *data);
+
+ /* 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);
+};
+
+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,
+ (struct hw_device_t**)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