summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2015-10-17 16:06:08 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2015-10-17 16:06:08 -0700
commit3c3472131e42dd7637317cf5eda57c963e985a07 (patch)
tree665fb3c02b61b6aff24c804a855ddd6c70812aa3
parent875b9330c95e6a78e5f4b3eda04d06b519ef299a (diff)
parente00c4e938559947d878b1fbec2e61ca001a14191 (diff)
downloadhardware_qcom_audio-3c3472131e42dd7637317cf5eda57c963e985a07.tar.gz
hardware_qcom_audio-3c3472131e42dd7637317cf5eda57c963e985a07.tar.bz2
hardware_qcom_audio-3c3472131e42dd7637317cf5eda57c963e985a07.zip
Merge "hal: integrate ADM module"
-rw-r--r--hal/audio_hw.c78
-rw-r--r--hal/audio_hw.h21
-rw-r--r--hal/msm8974/platform.c5
-rw-r--r--hal/msm8974/platform.h1
4 files changed, 101 insertions, 4 deletions
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 35d26618..ebc6b1b7 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -165,7 +165,8 @@ struct pcm_config pcm_config_afe_proxy_record = {
const char * const use_case_table[AUDIO_USECASE_MAX] = {
[USECASE_AUDIO_PLAYBACK_DEEP_BUFFER] = "deep-buffer-playback",
[USECASE_AUDIO_PLAYBACK_LOW_LATENCY] = "low-latency-playback",
- [USECASE_AUDIO_PLAYBACK_MULTI_CH] = "multi-channel-playback",
+ [USECASE_AUDIO_PLAYBACK_ULL] = "audio-ull-playback",
+ [USECASE_AUDIO_PLAYBACK_MULTI_CH] = "multi-channel-playback",
[USECASE_AUDIO_PLAYBACK_OFFLOAD] = "compress-offload-playback",
#ifdef MULTIPLE_OFFLOAD_ENABLED
[USECASE_AUDIO_PLAYBACK_OFFLOAD2] = "compress-offload-playback2",
@@ -1117,7 +1118,10 @@ int start_input_stream(struct stream_in *in)
}
audio_extn_perf_lock_release();
+ ALOGV("%s: pcm_prepare start", __func__);
+ pcm_prepare(in->pcm);
ALOGV("%s: exit", __func__);
+
return ret;
error_open:
@@ -1599,8 +1603,14 @@ int start_output_stream(struct stream_out *out)
}
break;
}
+
platform_set_stream_channel_map(adev->platform, out->channel_mask,
out->pcm_device_id);
+
+ ALOGV("%s: pcm_prepare start", __func__);
+ if (pcm_is_ready(out->pcm))
+ pcm_prepare(out->pcm);
+
} else {
platform_set_stream_channel_map(adev->platform, out->channel_mask,
out->pcm_device_id);
@@ -1646,7 +1656,9 @@ int start_output_stream(struct stream_out *out)
audio_extn_check_and_set_dts_hpx_state(adev);
}
}
+
ALOGV("%s: exit", __func__);
+
return 0;
error_open:
stop_output_stream(out);
@@ -1782,6 +1794,9 @@ static int out_standby(struct audio_stream *stream)
lock_output_stream(out);
if (!out->standby) {
+ if (adev->adm_deregister_stream)
+ adev->adm_deregister_stream(adev->adm_data, out->handle);
+
pthread_mutex_lock(&adev->lock);
out->standby = true;
if (!is_offload_usecase(out->usecase)) {
@@ -2122,6 +2137,8 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
out->standby = true;
goto exit;
}
+ if (!is_offload_usecase(out->usecase) && adev->adm_register_output_stream)
+ adev->adm_register_output_stream(adev->adm_data, out->handle, out->flags);
}
if (is_offload_usecase(out->usecase)) {
@@ -2168,15 +2185,24 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
if (out->pcm) {
if (out->muted)
memset((void *)buffer, 0, bytes);
+
ALOGVV("%s: writing buffer (%d bytes) to pcm device", __func__, bytes);
+
+ if (adev->adm_request_focus)
+ adev->adm_request_focus(adev->adm_data, out->handle);
+
if (out->usecase == USECASE_AUDIO_PLAYBACK_AFE_PROXY)
ret = pcm_mmap_write(out->pcm, (void *)buffer, bytes);
else
ret = pcm_write(out->pcm, (void *)buffer, bytes);
+
if (ret < 0)
ret = -errno;
else if (ret == 0)
out->written += bytes / (out->config.channels * sizeof(short));
+
+ if (adev->adm_abandon_focus)
+ adev->adm_abandon_focus(adev->adm_data, out->handle);
}
}
@@ -2476,6 +2502,9 @@ static int in_standby(struct audio_stream *stream)
}
if (!in->standby) {
+ if (adev->adm_deregister_stream)
+ adev->adm_deregister_stream(adev->adm_data, in->capture_handle);
+
pthread_mutex_lock(&adev->lock);
in->standby = true;
if (in->pcm) {
@@ -2623,8 +2652,13 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer,
}
}
in->standby = 0;
+ if (adev->adm_register_input_stream)
+ adev->adm_register_input_stream(adev->adm_data, in->capture_handle, in->flags);
}
+ if (adev->adm_request_focus)
+ adev->adm_request_focus(adev->adm_data, in->capture_handle);
+
if (in->pcm) {
if (audio_extn_ssr_get_enabled() && (audio_extn_ssr_get_stream() == in))
ret = audio_extn_ssr_read(stream, buffer, bytes);
@@ -2638,6 +2672,9 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer,
ret = -errno;
}
+ if (adev->adm_abandon_focus)
+ adev->adm_abandon_focus(adev->adm_data, in->capture_handle);
+
/*
* Instead of writing zeroes here, we could trust the hardware
* to always provide zeroes when muted.
@@ -2980,6 +3017,10 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
out->usecase = USECASE_AUDIO_PLAYBACK_AFE_PROXY;
out->config = pcm_config_afe_proxy_playback;
adev->voice_tx_output = out;
+ } else if (out->flags & AUDIO_OUTPUT_FLAG_RAW) {
+ out->usecase = USECASE_AUDIO_PLAYBACK_ULL;
+ out->config = pcm_config_low_latency;
+ out->sample_rate = out->config.rate;
} else if (out->flags & AUDIO_OUTPUT_FLAG_FAST) {
format = AUDIO_FORMAT_PCM_16_BIT;
out->usecase = USECASE_AUDIO_PLAYBACK_LOW_LATENCY;
@@ -3393,7 +3434,7 @@ static int adev_open_input_stream(struct audio_hw_device *dev,
audio_devices_t devices,
struct audio_config *config,
struct audio_stream_in **stream_in,
- audio_input_flags_t flags __unused,
+ audio_input_flags_t flags,
const char *address __unused,
audio_source_t source)
{
@@ -3443,6 +3484,7 @@ static int adev_open_input_stream(struct audio_hw_device *dev,
in->standby = 1;
in->channel_mask = config->channel_mask;
in->capture_handle = handle;
+ in->flags = flags;
/* Update config params with the requested sample rate and channels */
in->usecase = USECASE_AUDIO_RECORD;
@@ -3596,10 +3638,13 @@ static int adev_close(hw_device_t *device)
audio_route_free(adev->audio_route);
free(adev->snd_dev_ref_cnt);
platform_deinit(adev->platform);
+ if (adev->adm_deinit)
+ adev->adm_deinit(adev->adm_data);
free(device);
adev = NULL;
}
pthread_mutex_unlock(&adev_init_lock);
+
return 0;
}
@@ -3611,6 +3656,7 @@ static int period_size_is_plausible_for_low_latency(int period_size)
{
switch (period_size) {
case 160:
+ case 192:
case 240:
case 320:
case 480:
@@ -3738,6 +3784,29 @@ static int adev_open(const hw_module_t *module, const char *name,
}
}
+ if (access(ADM_LIBRARY_PATH, R_OK) == 0) {
+ adev->adm_lib = dlopen(ADM_LIBRARY_PATH, RTLD_NOW);
+ if (adev->adm_lib == NULL) {
+ ALOGE("%s: DLOPEN failed for %s", __func__, ADM_LIBRARY_PATH);
+ } else {
+ ALOGV("%s: DLOPEN successful for %s", __func__, ADM_LIBRARY_PATH);
+ adev->adm_init = (adm_init_t)
+ dlsym(adev->adm_lib, "adm_init");
+ adev->adm_deinit = (adm_deinit_t)
+ dlsym(adev->adm_lib, "adm_deinit");
+ adev->adm_register_input_stream = (adm_register_input_stream_t)
+ dlsym(adev->adm_lib, "adm_register_input_stream");
+ adev->adm_register_output_stream = (adm_register_output_stream_t)
+ dlsym(adev->adm_lib, "adm_register_output_stream");
+ adev->adm_deregister_stream = (adm_deregister_stream_t)
+ dlsym(adev->adm_lib, "adm_deregister_stream");
+ adev->adm_request_focus = (adm_request_focus_t)
+ dlsym(adev->adm_lib, "adm_request_focus");
+ adev->adm_abandon_focus = (adm_abandon_focus_t)
+ dlsym(adev->adm_lib, "adm_abandon_focus");
+ }
+ }
+
adev->bt_wb_speech_enabled = false;
audio_extn_ds2_enable(adev);
@@ -3768,6 +3837,9 @@ static int adev_open(const hw_module_t *module, const char *name,
pthread_mutex_unlock(&adev_init_lock);
+ if (adev->adm_init)
+ adev->adm_data = adev->adm_init();
+
ALOGV("%s: exit", __func__);
return 0;
}
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index 4756c90e..0f11f63e 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -50,6 +50,7 @@
#define VISUALIZER_LIBRARY_PATH "/system/lib/soundfx/libqcomvisualizer.so"
#define OFFLOAD_EFFECTS_BUNDLE_LIBRARY_PATH "/system/lib/soundfx/libqcompostprocbundle.so"
+#define ADM_LIBRARY_PATH "/system/vendor/lib/libadm.so"
/* Flags used to initialize acdb_settings variable that goes to ACDB library */
#define NONE_FLAG 0x00000000
@@ -94,6 +95,7 @@ enum {
USECASE_AUDIO_PLAYBACK_OFFLOAD8,
USECASE_AUDIO_PLAYBACK_OFFLOAD9,
#endif
+ USECASE_AUDIO_PLAYBACK_ULL,
USECASE_AUDIO_DIRECT_PCM_OFFLOAD,
@@ -239,6 +241,7 @@ struct stream_in {
bool enable_ns;
audio_format_t format;
audio_io_handle_t capture_handle;
+ audio_input_flags_t flags;
bool is_st_session;
bool is_st_session_active;
@@ -291,6 +294,14 @@ struct streams_output_cfg {
struct stream_app_type_cfg app_type_cfg;
};
+typedef void* (*adm_init_t)();
+typedef void (*adm_deinit_t)(void *);
+typedef void (*adm_register_output_stream_t)(void *, audio_io_handle_t, audio_output_flags_t);
+typedef void (*adm_register_input_stream_t)(void *, audio_io_handle_t, audio_input_flags_t);
+typedef void (*adm_deregister_stream_t)(void *, audio_io_handle_t);
+typedef void (*adm_request_focus_t)(void *, audio_io_handle_t);
+typedef void (*adm_abandon_focus_t)(void *, audio_io_handle_t);
+
struct audio_device {
struct audio_hw_device device;
pthread_mutex_t lock; /* see note below on mutex acquisition order */
@@ -328,6 +339,16 @@ struct audio_device {
struct sound_card_status snd_card_status;
int (*offload_effects_set_hpx_state)(bool);
+
+ void *adm_data;
+ void *adm_lib;
+ adm_init_t adm_init;
+ adm_deinit_t adm_deinit;
+ adm_register_input_stream_t adm_register_input_stream;
+ adm_register_output_stream_t adm_register_output_stream;
+ adm_deregister_stream_t adm_deregister_stream;
+ adm_request_focus_t adm_request_focus;
+ adm_abandon_focus_t adm_abandon_focus;
};
int select_devices(struct audio_device *adev,
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index cca4796a..b2fa577b 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -206,8 +206,10 @@ static int pcm_device_table[AUDIO_USECASE_MAX][2] = {
DEEP_BUFFER_PCM_DEVICE},
[USECASE_AUDIO_PLAYBACK_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE,
LOWLATENCY_PCM_DEVICE},
+ [USECASE_AUDIO_PLAYBACK_ULL] = {MULTIMEDIA3_PCM_DEVICE,
+ MULTIMEDIA3_PCM_DEVICE},
[USECASE_AUDIO_PLAYBACK_MULTI_CH] = {MULTIMEDIA2_PCM_DEVICE,
- MULTIMEDIA2_PCM_DEVICE},
+ MULTIMEDIA2_PCM_DEVICE},
[USECASE_AUDIO_PLAYBACK_OFFLOAD] =
{PLAYBACK_OFFLOAD_DEVICE, PLAYBACK_OFFLOAD_DEVICE},
#ifdef MULTIPLE_OFFLOAD_ENABLED
@@ -568,6 +570,7 @@ static char * backend_table[SND_DEVICE_MAX] = {0};
static struct name_to_index usecase_name_index[AUDIO_USECASE_MAX] = {
{TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_DEEP_BUFFER)},
{TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_LOW_LATENCY)},
+ {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_ULL)},
{TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_MULTI_CH)},
{TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD)},
#ifdef MULTIPLE_OFFLOAD_ENABLED
diff --git a/hal/msm8974/platform.h b/hal/msm8974/platform.h
index 006540ea..d6ba1ef1 100644
--- a/hal/msm8974/platform.h
+++ b/hal/msm8974/platform.h
@@ -205,6 +205,7 @@ enum {
#define AUDIO_RECORD_PCM_DEVICE 0
#define AUDIO_RECORD_3MIC_PCM_DEVICE 44
#define MULTIMEDIA2_PCM_DEVICE 1
+#define MULTIMEDIA3_PCM_DEVICE 4
#define FM_PLAYBACK_PCM_DEVICE 5
#define FM_CAPTURE_PCM_DEVICE 6
#define HFP_PCM_RX 5