summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-11-11 21:16:15 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-11-11 21:16:15 +0000
commit8f3dce5491bc5b9ee9c794a75b53b3044e93e73e (patch)
treed4351a77e777123c1242f4d18761b1ff3020ef79
parent2f168444b92b00465d59fb5f93ed3055580109ba (diff)
parent1c51016fae53386ed6ae67c53ef2d0504c431591 (diff)
downloadyukawa-8f3dce5491bc5b9ee9c794a75b53b3044e93e73e.tar.gz
Snap for 6001391 from 1c51016fae53386ed6ae67c53ef2d0504c431591 to qt-aml-resolv-releaseandroid-mainline-10.0.0_r8android10-mainline-resolv-release
Change-Id: I1739a5c6ba0206d0b364bcb51e4af17a1c9f07a4
-rw-r--r--audio/audio_aec.c82
-rw-r--r--audio/audio_aec.h20
-rw-r--r--audio/audio_hw.c70
-rw-r--r--audio/audio_hw.h11
-rw-r--r--audio/audio_policy_configuration.xml2
-rw-r--r--device-common.mk6
-rwxr-xr-xmanifest.xml9
-rw-r--r--overlay/frameworks/base/core/res/res/values/config.xml3
8 files changed, 124 insertions, 79 deletions
diff --git a/audio/audio_aec.c b/audio/audio_aec.c
index 6e39fdd..4e3fa43 100644
--- a/audio/audio_aec.c
+++ b/audio/audio_aec.c
@@ -82,18 +82,6 @@ uint64_t timespec_to_usec(struct timespec ts) {
return (ts.tv_sec * 1e6L + ts.tv_nsec/1000);
}
-void timestamp_adjust(struct timespec *ts, size_t frames, uint32_t sampling_rate) {
- /* This function assumes the adjustment (in nsec) is less than the max value of long,
- * which for 32-bit long this is 2^31 * 1e-9 seconds, slightly over 2 seconds.
- * For 64-bit long it is 9e+9 seconds. */
- long adj_nsec = (frames / (float) sampling_rate) * 1E9L;
- ts->tv_nsec -= adj_nsec;
- if (ts->tv_nsec < 0) {
- ts->tv_sec--;
- ts->tv_nsec += 1E9L;
- }
-}
-
void get_reference_audio_in_place(struct aec_t *aec, size_t frames) {
if (aec->num_reference_channels == aec->spk_num_channels) {
/* Reference count equals speaker channels, nothing to do here. */
@@ -121,13 +109,10 @@ void print_queue_status_to_log(struct aec_t *aec, bool write_side) {
ssize_t q1 = fifo_available_to_read(aec->spk_fifo);
ssize_t q2 = fifo_available_to_read(aec->ts_fifo);
- if (write_side) {
- ALOGV("Queue available (POST-WRITE): Spk %zd (count %zd) TS %zd (count %zd)",
- q1, q1/aec->spk_frame_size_bytes/PLAYBACK_PERIOD_SIZE, q2, q2/sizeof(struct ts_fifo_payload));
- } else {
- ALOGV("Queue available (PRE-READ): Spk %zd (count %zd) TS %zd (count %zd)",
- q1, q1/aec->spk_frame_size_bytes/PLAYBACK_PERIOD_SIZE, q2, q2/sizeof(struct ts_fifo_payload));
- }
+ ALOGV("Queue available %s: Spk %zd (count %zd) TS %zd (count %zd)",
+ (write_side) ? "(POST-WRITE)" : "(PRE-READ)",
+ q1, q1/aec->spk_frame_size_bytes/PLAYBACK_PERIOD_SIZE,
+ q2, q2/sizeof(struct aec_info));
}
void flush_aec_fifos(struct aec_t *aec) {
@@ -230,7 +215,7 @@ int init_aec_reference_config(struct aec_t *aec, struct alsa_stream_out *out) {
goto exit;
}
aec->ts_fifo = fifo_init(
- out->config.period_count * sizeof(struct ts_fifo_payload),
+ out->config.period_count * sizeof(struct aec_info),
false /* reader_throttles_writer */);
if (aec->ts_fifo == NULL) {
ALOGE("AEC: Speaker timestamp FIFO Init failed!");
@@ -361,7 +346,7 @@ void destroy_aec_reference_config(struct aec_t *aec) {
aec_set_spk_running(aec, false);
fifo_release(aec->spk_fifo);
fifo_release(aec->ts_fifo);
- memset(&aec->last_spk_ts, 0, sizeof(struct ts_fifo_payload));
+ memset(&aec->last_spk_info, 0, sizeof(struct aec_info));
pthread_mutex_unlock(&aec->lock);
ALOGV("%s exit", __func__);
}
@@ -378,15 +363,15 @@ void destroy_aec_mic_config(struct aec_t *aec) {
free(aec->spk_buf);
free(aec->spk_buf_playback_format);
free(aec->spk_buf_resampler_out);
- memset(&aec->last_mic_ts, 0, sizeof(struct ts_fifo_payload));
+ memset(&aec->last_mic_info, 0, sizeof(struct aec_info));
pthread_mutex_unlock(&aec->lock);
ALOGV("%s exit", __func__);
}
-int write_to_reference_fifo(struct aec_t *aec, struct alsa_stream_out *out,
- void *buffer, size_t bytes) {
+int write_to_reference_fifo (struct aec_t *aec, void *buffer, struct aec_info *info) {
ALOGV("%s enter", __func__);
int ret = 0;
+ size_t bytes = info->bytes;
/* Write audio samples to FIFO */
ssize_t written_bytes = fifo_write(aec->spk_fifo, buffer, bytes);
@@ -395,17 +380,10 @@ int write_to_reference_fifo(struct aec_t *aec, struct alsa_stream_out *out,
ret = -ENOMEM;
}
- /* Get current timestamp and write to FIFO */
- struct ts_fifo_payload spk_ts;
- pcm_get_htimestamp(out->pcm, &spk_ts.available, &spk_ts.timestamp);
- /* We need the timestamp of the first frame, adjust htimestamp */
- timestamp_adjust(
- &spk_ts.timestamp,
- pcm_get_buffer_size(out->pcm) - spk_ts.available,
- aec->spk_sampling_rate);
- spk_ts.bytes = written_bytes;
- ALOGV("Speaker timestamp: %ld s, %ld nsec", spk_ts.timestamp.tv_sec, spk_ts.timestamp.tv_nsec);
- ssize_t ts_bytes = fifo_write(aec->ts_fifo, &spk_ts, sizeof(struct ts_fifo_payload));
+ /* Write timestamp to FIFO */
+ info->bytes = written_bytes;
+ ALOGV("Speaker timestamp: %ld s, %ld nsec", info->timestamp.tv_sec, info->timestamp.tv_nsec);
+ ssize_t ts_bytes = fifo_write(aec->ts_fifo, info, sizeof(struct aec_info));
ALOGV("Wrote TS bytes: %zu", ts_bytes);
print_queue_status_to_log(aec, true);
ALOGV("%s exit", __func__);
@@ -421,7 +399,7 @@ void get_spk_timestamp(struct aec_t *aec, ssize_t read_bytes, uint64_t *spk_time
* so even if we straddle packets we only care about the first one)
* So we just use the previous timestamp, with an appropriate offset
* based on the number of bytes remaining to be read from that write packet. */
- spk_time_offset = (aec->last_spk_ts.bytes + aec->read_write_diff_bytes) * usec_per_byte;
+ spk_time_offset = (aec->last_spk_info.bytes + aec->read_write_diff_bytes) * usec_per_byte;
ALOGV("Reusing previous timestamp, calculated offset (usec) %"PRIu64, spk_time_offset);
} else {
/* If read_write_diff_bytes > 0, there are no new writes, so there won't be timestamps in
@@ -431,16 +409,16 @@ void get_spk_timestamp(struct aec_t *aec, ssize_t read_bytes, uint64_t *spk_time
return;
}
/* We just read valid data, so if we're here, we should have a valid timestamp to use. */
- ssize_t ts_bytes = fifo_read(aec->ts_fifo, &aec->last_spk_ts,
- sizeof(struct ts_fifo_payload));
- ALOGV("Read TS bytes: %zd, expected %zu", ts_bytes, sizeof(struct ts_fifo_payload));
- aec->read_write_diff_bytes -= aec->last_spk_ts.bytes;
+ ssize_t ts_bytes = fifo_read(aec->ts_fifo, &aec->last_spk_info,
+ sizeof(struct aec_info));
+ ALOGV("Read TS bytes: %zd, expected %zu", ts_bytes, sizeof(struct aec_info));
+ aec->read_write_diff_bytes -= aec->last_spk_info.bytes;
}
- *spk_time = timespec_to_usec(aec->last_spk_ts.timestamp) + spk_time_offset;
+ *spk_time = timespec_to_usec(aec->last_spk_info.timestamp) + spk_time_offset;
aec->read_write_diff_bytes += read_bytes;
- struct ts_fifo_payload spk_ts = aec->last_spk_ts;
+ struct aec_info spk_info = aec->last_spk_info;
while (aec->read_write_diff_bytes > 0) {
/* If read_write_diff_bytes > 0, it means that there are more write packet timestamps
* in FIFO (since there we read more valid data the size of the current timestamp's
@@ -450,16 +428,16 @@ void get_spk_timestamp(struct aec_t *aec, ssize_t read_bytes, uint64_t *spk_time
ALOGV("At the end of timestamp FIFO, breaking...");
break;
}
- fifo_read(aec->ts_fifo, &spk_ts, sizeof(struct ts_fifo_payload));
+ fifo_read(aec->ts_fifo, &spk_info, sizeof(struct aec_info));
ALOGV("Fast-forwarded timestamp by %zd bytes, remaining bytes: %zd,"
" new timestamp (usec) %"PRIu64,
- spk_ts.bytes, aec->read_write_diff_bytes, timespec_to_usec(spk_ts.timestamp));
- aec->read_write_diff_bytes -= spk_ts.bytes;
+ spk_info.bytes, aec->read_write_diff_bytes, timespec_to_usec(spk_info.timestamp));
+ aec->read_write_diff_bytes -= spk_info.bytes;
}
- aec->last_spk_ts = spk_ts;
+ aec->last_spk_info = spk_info;
}
-int process_aec(struct aec_t *aec, struct alsa_stream_in *in, void* buffer, size_t bytes) {
+int process_aec(struct aec_t *aec, void* buffer, struct aec_info *info) {
ALOGV("%s enter", __func__);
int ret = 0;
@@ -468,19 +446,15 @@ int process_aec(struct aec_t *aec, struct alsa_stream_in *in, void* buffer, size
return -EINVAL;
}
+ size_t bytes = info->bytes;
+
size_t frame_size = aec->mic_frame_size_bytes;
size_t in_frames = bytes / frame_size;
/* Copy raw mic samples to AEC input buffer */
memcpy(aec->mic_buf, buffer, bytes);
- pcm_get_htimestamp(in->pcm, &aec->last_mic_ts.available, &aec->last_mic_ts.timestamp);
- /* We need the timestamp of the first frame, adjust htimestamp */
- timestamp_adjust(
- &aec->last_mic_ts.timestamp,
- pcm_get_buffer_size(in->pcm) - aec->last_mic_ts.available,
- aec->mic_sampling_rate);
- uint64_t mic_time = timespec_to_usec(aec->last_mic_ts.timestamp);
+ uint64_t mic_time = timespec_to_usec(info->timestamp);
uint64_t spk_time = 0;
/*
diff --git a/audio/audio_aec.h b/audio/audio_aec.h
index 24bcf7a..9cfc9aa 100644
--- a/audio/audio_aec.h
+++ b/audio/audio_aec.h
@@ -33,17 +33,6 @@
#include "audio_hw.h"
#include "fifo_wrapper.h"
-/* 'bytes' are the number of bytes written to audio FIFO, for which 'timestamp' is valid.
- * 'available' is the number of frames available to read (for input) or yet to be played
- * (for output) frames in the PCM buffer.
- * timestamp and available are updated by pcm_get_htimestamp(), so they use the same
- * datatypes as the corresponding arguments to that function. */
-struct ts_fifo_payload {
- struct timespec timestamp;
- unsigned int available;
- size_t bytes;
-};
-
struct aec_t {
pthread_mutex_t lock;
size_t num_reference_channels;
@@ -52,13 +41,13 @@ struct aec_t {
size_t mic_buf_size_bytes;
size_t mic_frame_size_bytes;
uint32_t mic_sampling_rate;
- struct ts_fifo_payload last_mic_ts;
+ struct aec_info last_mic_info;
int32_t *spk_buf;
size_t spk_num_channels;
size_t spk_buf_size_bytes;
size_t spk_frame_size_bytes;
uint32_t spk_sampling_rate;
- struct ts_fifo_payload last_spk_ts;
+ struct aec_info last_spk_info;
int16_t *spk_buf_playback_format;
int16_t *spk_buf_resampler_out;
void *spk_fifo;
@@ -74,14 +63,13 @@ struct aec_t {
/* Write audio samples to AEC reference FIFO for use in AEC.
* Both audio samples and timestamps are added in FIFO fashion.
* Must be called after every write to PCM. */
-int write_to_reference_fifo (struct aec_t *aec, struct alsa_stream_out *out,
- void *buffer, size_t bytes);
+int write_to_reference_fifo (struct aec_t *aec, void *buffer, struct aec_info *info);
/* Processing function call for AEC.
* AEC output is updated at location pointed to by 'buffer'.
* This function does not run AEC when there is no playback -
* as communicated to this AEC interface using aec_set_spk_running().*/
-int process_aec (struct aec_t *aec, struct alsa_stream_in *in, void* buffer, size_t bytes);
+int process_aec (struct aec_t *aec, void* buffer, struct aec_info *info);
/* Initialize AEC object.
* This must be called when the audio device is opened.
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index 49b00d5..cd72172 100644
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -47,6 +47,37 @@
#include "audio_hw.h"
#include "audio_aec.h"
+
+static void timestamp_adjust(struct timespec *ts, size_t frames, uint32_t sampling_rate) {
+ /* This function assumes the adjustment (in nsec) is less than the max value of long,
+ * which for 32-bit long this is 2^31 * 1e-9 seconds, slightly over 2 seconds.
+ * For 64-bit long it is 9e+9 seconds. */
+ long adj_nsec = (frames / (float) sampling_rate) * 1E9L;
+ ts->tv_nsec += adj_nsec;
+ while (ts->tv_nsec > 1E9L) {
+ ts->tv_sec++;
+ ts->tv_nsec -= 1E9L;
+ }
+}
+
+/* Helper function to get PCM hardware timestamp.
+ * Only the field 'timestamp' of argument 'ts' is updated. */
+static int get_pcm_timestamp(struct pcm *pcm, uint32_t sample_rate,
+ struct aec_info *info) {
+ int ret = 0;
+ if (pcm_get_htimestamp(pcm, &info->available, &info->timestamp) < 0) {
+ ALOGE("Error getting PCM timestamp!");
+ info->timestamp.tv_sec = 0;
+ info->timestamp.tv_nsec = 0;
+ return -EINVAL;
+ }
+ timestamp_adjust(
+ &info->timestamp,
+ pcm_get_buffer_size(pcm) - info->available,
+ sample_rate);
+ return ret;
+}
+
/* must be called with hw device and output stream mutexes locked */
static int start_output_stream(struct alsa_stream_out *out)
{
@@ -62,7 +93,7 @@ static int start_output_stream(struct alsa_stream_out *out)
unsigned int pcm_retry_count = PCM_OPEN_RETRIES;
while (1) {
- out->pcm = pcm_open(CARD_OUT, PORT_HDMI, PCM_OUT, &out->config);
+ out->pcm = pcm_open(CARD_OUT, PORT_HDMI, PCM_OUT | PCM_MONOTONIC, &out->config);
if ((out->pcm != NULL) && pcm_is_ready(out->pcm)) {
break;
} else {
@@ -240,8 +271,10 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
if (ret == 0) {
out->written += out_frames;
- int aec_ret = write_to_reference_fifo(adev->aec, out, (void *)buffer,
- out_frames * frame_size);
+ struct aec_info info;
+ get_pcm_timestamp(out->pcm, out->config.rate, &info);
+ info.bytes = out_frames * frame_size;
+ int aec_ret = write_to_reference_fifo(adev->aec, (void *)buffer, &info);
if (aec_ret) {
ALOGE("AEC: Write to speaker loopback FIFO failed!");
}
@@ -318,7 +351,7 @@ static int start_input_stream(struct alsa_stream_in *in)
unsigned int pcm_retry_count = PCM_OPEN_RETRIES;
while (1) {
- in->pcm = pcm_open(CARD_IN, PORT_BUILTIN_MIC, PCM_IN, &in->config);
+ in->pcm = pcm_open(CARD_IN, PORT_BUILTIN_MIC, PCM_IN | PCM_MONOTONIC, &in->config);
if ((in->pcm != NULL) && pcm_is_ready(in->pcm)) {
break;
} else {
@@ -489,7 +522,10 @@ exit:
/* Process AEC if available */
/* TODO move to a separate thread */
if (!adev->mic_mute) {
- int aec_ret = process_aec(adev->aec, in, buffer, bytes);
+ struct aec_info info;
+ get_pcm_timestamp(in->pcm, in->config.rate, &info);
+ info.bytes = bytes;
+ int aec_ret = process_aec(adev->aec, buffer, &info);
if (aec_ret) {
ALOGE("process_aec returned error code %d", aec_ret);
}
@@ -620,6 +656,29 @@ static char * adev_get_parameters(const struct audio_hw_device *dev,
return strdup("");
}
+static void set_mic_characteristics(struct audio_microphone_characteristic_t* mic_data) {
+ strcpy(mic_data->device_id, "builtin_mic");
+ strcpy(mic_data->address, "top");
+ mic_data->sensitivity = -37.0;
+ mic_data->max_spl = AUDIO_MICROPHONE_SPL_UNKNOWN;
+ mic_data->min_spl = AUDIO_MICROPHONE_SPL_UNKNOWN;
+ mic_data->orientation.x = 0.0f;
+ mic_data->orientation.y = 0.0f;
+ mic_data->orientation.z = 0.0f;
+ mic_data->geometric_location.x = AUDIO_MICROPHONE_COORDINATE_UNKNOWN;
+ mic_data->geometric_location.y = AUDIO_MICROPHONE_COORDINATE_UNKNOWN;
+ mic_data->geometric_location.z = AUDIO_MICROPHONE_COORDINATE_UNKNOWN;
+}
+
+static int adev_get_microphones(const struct audio_hw_device* dev,
+ struct audio_microphone_characteristic_t* mic_array,
+ size_t* mic_count) {
+ ALOGV("adev_get_microphones");
+ set_mic_characteristics(mic_array);
+ *mic_count = 1;
+ return 0;
+}
+
static int adev_init_check(const struct audio_hw_device *dev)
{
ALOGV("adev_init_check");
@@ -828,6 +887,7 @@ static int adev_open(const hw_module_t* module, const char* name,
adev->hw_device.open_input_stream = adev_open_input_stream;
adev->hw_device.close_input_stream = adev_close_input_stream;
adev->hw_device.dump = adev_dump;
+ adev->hw_device.get_microphones = adev_get_microphones;
adev->devices = AUDIO_DEVICE_NONE;
diff --git a/audio/audio_hw.h b/audio/audio_hw.h
index d1af55d..0eb786d 100644
--- a/audio/audio_hw.h
+++ b/audio/audio_hw.h
@@ -95,4 +95,15 @@ struct alsa_stream_out {
unsigned int written;
};
+/* 'bytes' are the number of bytes written to audio FIFO, for which 'timestamp' is valid.
+ * 'available' is the number of frames available to read (for input) or yet to be played
+ * (for output) frames in the PCM buffer.
+ * timestamp and available are updated by pcm_get_htimestamp(), so they use the same
+ * datatypes as the corresponding arguments to that function. */
+struct aec_info {
+ struct timespec timestamp;
+ unsigned int available;
+ size_t bytes;
+};
+
#endif /* #ifndef _YUKAWA_AUDIO_HW_H_ */
diff --git a/audio/audio_policy_configuration.xml b/audio/audio_policy_configuration.xml
index 646fae1..6c696cb 100644
--- a/audio/audio_policy_configuration.xml
+++ b/audio/audio_policy_configuration.xml
@@ -159,7 +159,7 @@
<route type="mix" sink="primary input"
sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic"/>
<route type="mix" sink="Telephony Tx"
- sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic, voice_tx"/>
+ sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic,voice_tx"/>
<route type="mix" sink="voice_rx"
sources="Telephony Rx"/>
</routes>
diff --git a/device-common.mk b/device-common.mk
index b0e0087..a36074e 100644
--- a/device-common.mk
+++ b/device-common.mk
@@ -141,6 +141,12 @@ PRODUCT_PACKAGES += \
android.hardware.graphics.allocator@2.0-impl \
android.hardware.graphics.mapper@2.0-impl
+# PowerHAL
+PRODUCT_PACKAGES += \
+ power.default \
+ android.hardware.power@1.0-impl \
+ android.hardware.power@1.0-service
+
# Software Gatekeeper HAL
PRODUCT_PACKAGES += \
android.hardware.gatekeeper@1.0-service.software
diff --git a/manifest.xml b/manifest.xml
index 765b92e..cf7c024 100755
--- a/manifest.xml
+++ b/manifest.xml
@@ -174,4 +174,13 @@
<instance>default</instance>
</interface>
</hal>
+ <hal format="hidl">
+ <name>android.hardware.power</name>
+ <transport>hwbinder</transport>
+ <version>1.0</version>
+ <interface>
+ <name>IPower</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
</manifest>
diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml
index f241581..acdf91d 100644
--- a/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/overlay/frameworks/base/core/res/res/values/config.xml
@@ -30,9 +30,6 @@
<!-- Separate software navigation bar required on this device. -->
<bool name="config_showNavigationBar">true</bool>
- <!-- Integer indicating the framework scan interval in milliseconds. -->
- <integer translatable="false" name="config_wifi_framework_scan_interval">10000</integer>
-
<!-- XXXXX NOTE THE FOLLOWING RESOURCES USE THE WRONG NAMING CONVENTION.
Please don't copy them, copy anything else. -->