hal: add auto hal header file for pcm defs

Add auto HAL header file and update PCM config
definitions to media and system for automotive
specific usage.

Change-Id: I663e856ff7be39ff5c8ce31f2fdca93b6bb45e83
diff --git a/NOTICE b/NOTICE
index 73ab934..45be995 100644
--- a/NOTICE
+++ b/NOTICE
@@ -351,3 +351,17 @@
 shall not be used in advertising or otherwise to promote the sale, use
 or other dealings in these Data Files or Software without prior written
 authorization of the copyright holder.
+
+Copyright (C) 2013 The Android 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.
diff --git a/hal/audio_extn/auto_hal.c b/hal/audio_extn/auto_hal.c
index a295a4d..c18b55f 100644
--- a/hal/audio_extn/auto_hal.c
+++ b/hal/audio_extn/auto_hal.c
@@ -38,6 +38,7 @@
 #include "platform_api.h"
 #include "platform.h"
 #include "audio_hal_plugin.h"
+#include "auto_hal.h"
 
 #ifdef DYNAMIC_LOG_ENABLED
 #include <log_xml_parser.h>
@@ -54,44 +55,9 @@
 static fp_get_output_period_size_t                  fp_get_output_period_size;
 static fp_audio_extn_ext_hw_plugin_set_audio_gain_t fp_audio_extn_ext_hw_plugin_set_audio_gain;
 
-typedef struct auto_hal_module {
-    struct audio_device *adev;
-    card_status_t card_status;
-} auto_hal_module_t;
-
 /* Auto hal module struct */
 static struct auto_hal_module *auto_hal = NULL;
 
-struct pcm_config pcm_config_deep_buffer = {
-    .channels = 2,
-    .rate = DEFAULT_OUTPUT_SAMPLING_RATE,
-    .period_size = DEEP_BUFFER_OUTPUT_PERIOD_SIZE,
-    .period_count = DEEP_BUFFER_OUTPUT_PERIOD_COUNT,
-    .format = PCM_FORMAT_S16_LE,
-    .start_threshold = DEEP_BUFFER_OUTPUT_PERIOD_SIZE / 4,
-    .stop_threshold = INT_MAX,
-    .avail_min = DEEP_BUFFER_OUTPUT_PERIOD_SIZE / 4,
-};
-
-struct pcm_config pcm_config_low_latency = {
-    .channels = 2,
-    .rate = DEFAULT_OUTPUT_SAMPLING_RATE,
-    .period_size = LOW_LATENCY_OUTPUT_PERIOD_SIZE,
-    .period_count = LOW_LATENCY_OUTPUT_PERIOD_COUNT,
-    .format = PCM_FORMAT_S16_LE,
-    .start_threshold = LOW_LATENCY_OUTPUT_PERIOD_SIZE / 4,
-    .stop_threshold = INT_MAX,
-    .avail_min = LOW_LATENCY_OUTPUT_PERIOD_SIZE / 4,
-};
-
-static const audio_usecase_t bus_device_usecases[] = {
-    USECASE_AUDIO_PLAYBACK_MEDIA,
-    USECASE_AUDIO_PLAYBACK_SYS_NOTIFICATION,
-    USECASE_AUDIO_PLAYBACK_NAV_GUIDANCE,
-    USECASE_AUDIO_PLAYBACK_PHONE,
-    USECASE_AUDIO_PLAYBACK_REAR_SEAT,
-};
-
 int auto_hal_release_audio_patch(struct audio_hw_device *dev,
                                 audio_patch_handle_t handle);
 
@@ -108,9 +74,6 @@
     return NULL;
 }
 
-#define MAX_SOURCE_PORTS_PER_PATCH 1
-#define MAX_SINK_PORTS_PER_PATCH 1
-
 int auto_hal_create_audio_patch(struct audio_hw_device *dev,
                                 unsigned int num_sources,
                                 const struct audio_port_config *sources,
@@ -468,7 +431,7 @@
     case CAR_AUDIO_STREAM_MEDIA:
         /* media bus stream shares pcm device with deep-buffer */
         out->usecase = USECASE_AUDIO_PLAYBACK_MEDIA;
-        out->config = pcm_config_deep_buffer;
+        out->config = pcm_config_media;
         out->config.period_size = fp_get_output_period_size(out->sample_rate, out->format,
                                         channels, DEEP_BUFFER_OUTPUT_PERIOD_DURATION);
         if (out->config.period_size <= 0) {
@@ -483,13 +446,13 @@
     case CAR_AUDIO_STREAM_SYS_NOTIFICATION:
         /* sys notification bus stream shares pcm device with low-latency */
         out->usecase = USECASE_AUDIO_PLAYBACK_SYS_NOTIFICATION;
-        out->config = pcm_config_low_latency;
+        out->config = pcm_config_system;
         if (out->flags == AUDIO_OUTPUT_FLAG_NONE)
             out->flags |= AUDIO_OUTPUT_FLAG_SYS_NOTIFICATION;
         break;
     case CAR_AUDIO_STREAM_NAV_GUIDANCE:
         out->usecase = USECASE_AUDIO_PLAYBACK_NAV_GUIDANCE;
-        out->config = pcm_config_deep_buffer;
+        out->config = pcm_config_media;
         out->config.period_size = fp_get_output_period_size(out->sample_rate, out->format,
                                         channels, DEEP_BUFFER_OUTPUT_PERIOD_DURATION);
         if (out->config.period_size <= 0) {
@@ -502,13 +465,13 @@
         break;
     case CAR_AUDIO_STREAM_PHONE:
         out->usecase = USECASE_AUDIO_PLAYBACK_PHONE;
-        out->config = pcm_config_low_latency;
+        out->config = pcm_config_system;
         if (out->flags == AUDIO_OUTPUT_FLAG_NONE)
             out->flags |= AUDIO_OUTPUT_FLAG_PHONE;
         break;
     case CAR_AUDIO_STREAM_REAR_SEAT:
         out->usecase = USECASE_AUDIO_PLAYBACK_REAR_SEAT;
-        out->config = pcm_config_deep_buffer;
+        out->config = pcm_config_media;
         out->config.period_size = fp_get_output_period_size(out->sample_rate, out->format,
                                         channels, DEEP_BUFFER_OUTPUT_PERIOD_DURATION);
         if (out->config.period_size <= 0) {
@@ -573,12 +536,6 @@
     return -ENOSYS;
 }
 
-/* Volume min/max defined by audio policy configuration in millibel.
- * Support a range of -60dB to 6dB.
- */
-#define MIN_VOLUME_VALUE_MB -6000
-#define MAX_VOLUME_VALUE_MB 600
-#define STEP_VALUE_MB 100
 int auto_hal_set_audio_port_config(struct audio_hw_device *dev,
                         const struct audio_port_config *config)
 {
diff --git a/hal/audio_extn/auto_hal.h b/hal/audio_extn/auto_hal.h
new file mode 100644
index 0000000..115e5f7
--- /dev/null
+++ b/hal/audio_extn/auto_hal.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2019 The Linux Foundation. All rights reserved.
+ * Not a contribution.
+ *
+ * Copyright (C) 2013 The Android 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.
+ */
+#include <audio_hw.h>
+#include "platform.h"
+
+#define MAX_SOURCE_PORTS_PER_PATCH 1
+#define MAX_SINK_PORTS_PER_PATCH 1
+
+/* Volume min/max defined by audio policy configuration in millibel.
+ * Support a range of -60dB to 6dB.
+ */
+#define MIN_VOLUME_VALUE_MB -6000
+#define MAX_VOLUME_VALUE_MB 600
+#define STEP_VALUE_MB 100
+
+typedef struct auto_hal_module {
+    struct audio_device *adev;
+    card_status_t card_status;
+} auto_hal_module_t;
+
+struct pcm_config pcm_config_media = {
+    .channels = 2,
+    .rate = DEFAULT_OUTPUT_SAMPLING_RATE,
+    .period_size = DEEP_BUFFER_OUTPUT_PERIOD_SIZE,
+    .period_count = DEEP_BUFFER_OUTPUT_PERIOD_COUNT,
+    .format = PCM_FORMAT_S16_LE,
+    .start_threshold = DEEP_BUFFER_OUTPUT_PERIOD_SIZE / 4,
+    .stop_threshold = INT_MAX,
+    .avail_min = DEEP_BUFFER_OUTPUT_PERIOD_SIZE / 4,
+};
+
+struct pcm_config pcm_config_system = {
+    .channels = 2,
+    .rate = DEFAULT_OUTPUT_SAMPLING_RATE,
+    .period_size = LOW_LATENCY_OUTPUT_PERIOD_SIZE,
+    .period_count = LOW_LATENCY_OUTPUT_PERIOD_COUNT,
+    .format = PCM_FORMAT_S16_LE,
+    .start_threshold = LOW_LATENCY_OUTPUT_PERIOD_SIZE / 4,
+    .stop_threshold = INT_MAX,
+    .avail_min = LOW_LATENCY_OUTPUT_PERIOD_SIZE / 4,
+};
+
+static const audio_usecase_t bus_device_usecases[] = {
+    USECASE_AUDIO_PLAYBACK_MEDIA,
+    USECASE_AUDIO_PLAYBACK_SYS_NOTIFICATION,
+    USECASE_AUDIO_PLAYBACK_NAV_GUIDANCE,
+    USECASE_AUDIO_PLAYBACK_PHONE,
+    USECASE_AUDIO_PLAYBACK_REAR_SEAT,
+};