audio: 24 bit audio output profiles
1) Use 24 bit COPP as default,
2) Select 24 bit as backend bit width if possible
3) Allow output streams in audio HAL to be configured by
AF with format(s) listed in the policy_config xml
Test: low-latency, deep buffer, offload, ULL, voice call,
USB playback, USB+Speaker combo playback
Bug: 62918461
Change-Id: I62575c1d7072abe782be58baad4bad30aa5fd0be
diff --git a/hal/audio_extn/usb.c b/hal/audio_extn/usb.c
index 6b3ee7b..b863103 100644
--- a/hal/audio_extn/usb.c
+++ b/hal/audio_extn/usb.c
@@ -573,7 +573,7 @@
}
}
-static bool usb_get_best_match_for_bit_width(
+static bool usb_get_best_bit_width(
struct listnode *dev_list,
unsigned int stream_bit_width,
unsigned int *bit_width)
@@ -588,29 +588,17 @@
"%s: USB bw(%d), stream bw(%d), candidate(%d)",
__func__, dev_info->bit_width,
stream_bit_width, candidate);
- if (dev_info->bit_width == stream_bit_width) {
- *bit_width = dev_info->bit_width;
- ALOGV("%s: Found match bit-width (%d)",
+ if (candidate == 0) {
+ ALOGV("%s: candidate bit-width (%d)",
__func__, dev_info->bit_width);
- goto exit;
- } else if (candidate == 0) {
- candidate = dev_info->bit_width;
- }
- /*
- * If stream bit is 24, USB supports both 16 bit and 32 bit, then
- * higher bit width 32 is picked up instead of 16-bit
- */
- else if (ABS_SUB(stream_bit_width, dev_info->bit_width) <
- ABS_SUB(stream_bit_width, candidate)) {
candidate = dev_info->bit_width;
- }
- else if ((ABS_SUB(stream_bit_width, dev_info->bit_width) ==
- ABS_SUB(stream_bit_width, candidate)) &&
- (dev_info->bit_width > candidate)) {
+ } else if (dev_info->bit_width > candidate) {
candidate = dev_info->bit_width;
+ ALOGV("%s: Found better candidate bit-width (%d)",
+ __func__, dev_info->bit_width);
}
}
- ALOGV("%s: No match found, use the best candidate bw(%d)",
+ ALOGV("%s: Use the best candidate bw(%d)",
__func__, candidate);
*bit_width = candidate;
exit:
@@ -788,7 +776,7 @@
ALOGE("%s: list is empty,fall back to default setting", __func__);
goto exit;
}
- usb_get_best_match_for_bit_width(dev_list, *bit_width, bit_width);
+ usb_get_best_bit_width(dev_list, *bit_width, bit_width);
usb_get_best_match_for_channels(dev_list,
*bit_width,
*channel_count,
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index bd39f0b..1f52590 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -286,9 +286,13 @@
app_type_cfg->mode = flags_to_mode(0 /*playback*/, out->flags);
if (!audio_is_linear_pcm(out->format)) {
- platform_get_default_app_type_v2(adev->platform,
- PCM_PLAYBACK,
- app_type);
+ platform_get_app_type_v2(adev->platform,
+ PCM_PLAYBACK,
+ app_type_cfg->mode,
+ 24,
+ *sample_rate,
+ app_type);
+ ALOGV("Non pcm got app type %d", *app_type);
} else if (out->format == AUDIO_FORMAT_PCM_16_BIT) {
platform_get_app_type_v2(adev->platform,
PCM_PLAYBACK,
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index c616221..77a693c 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -3678,19 +3678,7 @@
out->config = pcm_config_low_latency;
}
if (config->format != audio_format_from_pcm_format(out->config.format)) {
- if (k_enable_extended_precision
- && pcm_params_format_test(adev->use_case_table[out->usecase],
- pcm_format_from_audio_format(config->format))) {
- out->config.format = pcm_format_from_audio_format(config->format);
- /* out->format already set to config->format */
- } else {
- /* deny the externally proposed config format
- * and use the one specified in audio_hw layer configuration.
- * Note: out->format is returned by out->stream.common.get_format()
- * and is used to set config->format in the code several lines below.
- */
- out->format = audio_format_from_pcm_format(out->config.format);
- }
+ out->config.format = pcm_format_from_audio_format(config->format);
}
out->sample_rate = out->config.rate;
}