summaryrefslogtreecommitdiff
path: root/modules/audio/audio_amplifier.c
diff options
context:
space:
mode:
authorEthan Chen <intervigil@gmail.com>2015-06-07 11:34:30 -0700
committerVishalcj17 <vishalcj@aospa.co>2021-10-20 21:06:29 +0900
commitfff55eaf71d44da7a003bccc4f835351b61efd6e (patch)
treeb5506313dc4975ffc1dc35a7e42e375e83e79b0c /modules/audio/audio_amplifier.c
parent81c45290fc6de91e68c2ed3efa62908688e2b822 (diff)
audio: Add audio amplifier HALsugisawa
This is a squash of the following commits. commit dabc25c1d073a0f32b706e59b87ac89f67389107 Author: Ethan Chen <intervigil@gmail.com> Date: Fri, 03 Jul 2015 21:35:30 -0700 audio: Notify amplifier HAL of device enable/disable Change-Id: Ice808c9b55a9e3bc8bafe5ca3ff555377d38dd8f commit 5b2337c434acff34d85ae14b9cc2d3507fdffe52 Author: Scott Mertz <scott@cyngn.com> Date: Fri, 11 Sep 2015 12:09:06 -0700 amplifier: add set_parameters method - audio hal should pass the audio_device parameters to the amplifier to allow the amplifier to make decisions based on the additional parameters. For example, we may want to change settings for DTS TrueMedia use case. Change-Id: Iccf6ef7ced2abd2e12e857eea8e580cda15eec04 commit 6a6c815e74bc9c8da0cead508dfa722229ea878f Author: Scott Mertz <scott@cyngn.com> Date: Wed, 21 Oct 2015 10:11:49 -0700 audio_amplifier: fix compilation stdlib.h is needed explicitely with the new toolchain/toolchain options. Change-Id: I876041828310ec8f9fb1e0d636a38cce1977d9b9 commit dcc6b5fd693b129492a45ec75038ca582689bd5d Author: Ethan Chen <intervigil@gmail.com> Date: Fri, 15 Jan 2016 16:12:39 -0800 amplifier: Fix compilation warning * Forward declare str_parms Change-Id: Iafb0ad8e4b0696807cfe568d0f89ce5dad6bcade commit 978ac098d6cde55bc5090ea83a9bda2ee176577b Author: codeworkx <daniel.hillenbrand@codeworkx.de> Date: Sat Mar 24 21:30:34 2018 +0100 audio_amplifier: add hooks for stream parameter manipulation This allows to modify audio parameters before the first device selection happens which is necessary when setting ANC parameter since it must happen before audio hal hits voice_start_call() and selects devices. If setting ANC after stream has been started it will trigger a re-selection of devices and cause a short downtime. Change-Id: Icfddab5ce27235c1567a0557e63b3a7421778187 commit fbd7069e5c87772338608e026f60d2fef37ca5f3 (HEAD) Author: Pig <pig.priv@gmail.com> Date: Tue Sep 22 21:41:59 2020 +0800 audio_amplifier: Add new hook for setting amp feedback Change-Id: Ifcea8b0c680c5066ed17cd41c29a49a8a9508aea
Diffstat (limited to 'modules/audio/audio_amplifier.c')
-rw-r--r--modules/audio/audio_amplifier.c161
1 files changed, 161 insertions, 0 deletions
diff --git a/modules/audio/audio_amplifier.c b/modules/audio/audio_amplifier.c
new file mode 100644
index 00000000..b2cbd895
--- /dev/null
+++ b/modules/audio/audio_amplifier.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2015 The CyanogenMod 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.
+ */
+
+#define LOG_TAG "amplifier_default"
+//#define LOG_NDEBUG 0
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+#include <cutils/log.h>
+#include <cutils/str_parms.h>
+
+#include <hardware/audio_amplifier.h>
+#include <hardware/hardware.h>
+
+static int amp_set_input_devices(amplifier_device_t *device, uint32_t devices)
+{
+ return 0;
+}
+
+static int amp_set_output_devices(amplifier_device_t *device, uint32_t devices)
+{
+ return 0;
+}
+
+static int amp_enable_output_devices(amplifier_device_t *device,
+ uint32_t devices, bool enable)
+{
+ return 0;
+}
+
+static int amp_enable_input_devices(amplifier_device_t *device,
+ uint32_t devices, bool enable)
+{
+ return 0;
+}
+
+static int amp_set_mode(amplifier_device_t *device, audio_mode_t mode)
+{
+ return 0;
+}
+
+static int amp_output_stream_start(amplifier_device_t *device,
+ struct audio_stream_out *stream, bool offload)
+{
+ return 0;
+}
+
+static int amp_input_stream_start(amplifier_device_t *device,
+ struct audio_stream_in *stream)
+{
+ return 0;
+}
+
+static int amp_output_stream_standby(amplifier_device_t *device,
+ struct audio_stream_out *stream)
+{
+ return 0;
+}
+
+static int amp_input_stream_standby(amplifier_device_t *device,
+ struct audio_stream_in *stream)
+{
+ return 0;
+}
+
+static int amp_set_parameters(struct amplifier_device *device,
+ struct str_parms *parms)
+{
+ return 0;
+}
+
+static int amp_out_set_parameters(struct amplifier_device *device,
+ struct str_parms *parms)
+{
+ return 0;
+}
+
+static int amp_in_set_parameters(struct amplifier_device *device,
+ struct str_parms *parms)
+{
+ return 0;
+}
+
+static int amp_dev_close(hw_device_t *device)
+{
+ if (device)
+ free(device);
+
+ return 0;
+}
+
+static int amp_module_open(const hw_module_t *module, const char *name,
+ hw_device_t **device)
+{
+ if (strcmp(name, AMPLIFIER_HARDWARE_INTERFACE)) {
+ ALOGE("%s:%d: %s does not match amplifier hardware interface name\n",
+ __func__, __LINE__, name);
+ return -ENODEV;
+ }
+
+ amplifier_device_t *amp_dev = calloc(1, sizeof(amplifier_device_t));
+ if (!amp_dev) {
+ ALOGE("%s:%d: Unable to allocate memory for amplifier device\n",
+ __func__, __LINE__);
+ return -ENOMEM;
+ }
+
+ amp_dev->common.tag = HARDWARE_DEVICE_TAG;
+ amp_dev->common.module = (hw_module_t *) module;
+ amp_dev->common.version = HARDWARE_DEVICE_API_VERSION(1, 0);
+ amp_dev->common.close = amp_dev_close;
+
+ amp_dev->set_input_devices = amp_set_input_devices;
+ amp_dev->set_output_devices = amp_set_output_devices;
+ amp_dev->enable_output_devices = amp_enable_output_devices;
+ amp_dev->enable_input_devices = amp_enable_input_devices;
+ amp_dev->set_mode = amp_set_mode;
+ amp_dev->output_stream_start = amp_output_stream_start;
+ amp_dev->input_stream_start = amp_input_stream_start;
+ amp_dev->output_stream_standby = amp_output_stream_standby;
+ amp_dev->input_stream_standby = amp_input_stream_standby;
+ amp_dev->set_parameters = amp_set_parameters;
+ amp_dev->out_set_parameters = amp_out_set_parameters;
+ amp_dev->in_set_parameters = amp_in_set_parameters;
+ amp_dev->set_feedback = amp_set_feedback;
+
+ *device = (hw_device_t *) amp_dev;
+
+ return 0;
+}
+
+static struct hw_module_methods_t hal_module_methods = {
+ .open = amp_module_open,
+};
+
+amplifier_module_t HAL_MODULE_INFO_SYM = {
+ .common = {
+ .tag = HARDWARE_MODULE_TAG,
+ .module_api_version = AMPLIFIER_MODULE_API_VERSION_0_1,
+ .hal_api_version = HARDWARE_HAL_API_VERSION,
+ .id = AMPLIFIER_HARDWARE_MODULE_ID,
+ .name = "Default audio amplifier HAL",
+ .author = "The CyanogenMod Open Source Project",
+ .methods = &hal_module_methods,
+ },
+};