Merge "audio: 24 bit audio output profiles" into oc-dr1-dev
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 2224e7e..cb54e80 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -3728,19 +3728,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;
     }