hal: native audio backward compatibility

- all changes for native audio backward
  compatibility and related
- add set parameters from UI
- enable dynamic device switching
- featurize the code
- various backend concurrency changes

Change-Id: Id0f824c4b4c033f42008a4e8868652c8f6fe5c42
diff --git a/hal/platform_info.c b/hal/platform_info.c
index b65411f..02f4988 100644
--- a/hal/platform_info.c
+++ b/hal/platform_info.c
@@ -44,6 +44,7 @@
     ROOT,
     ACDB,
     BITWIDTH,
+    NATIVESUPPORT,
     PCM_ID,
     BACKEND_NAME,
     INTERFACE_NAME,
@@ -53,6 +54,7 @@
 
 static void process_acdb_id(const XML_Char **attr);
 static void process_bit_width(const XML_Char **attr);
+static void process_native_support(const XML_Char **attr);
 static void process_pcm_id(const XML_Char **attr);
 static void process_backend_name(const XML_Char **attr);
 static void process_interface_name(const XML_Char **attr);
@@ -62,6 +64,7 @@
     [ROOT] = process_root,
     [ACDB] = process_acdb_id,
     [BITWIDTH] = process_bit_width,
+    [NATIVESUPPORT] = process_native_support,
     [PCM_ID] = process_pcm_id,
     [BACKEND_NAME] = process_backend_name,
     [INTERFACE_NAME] = process_interface_name,
@@ -273,7 +276,31 @@
                                               (char *)attr[5]);
     if (ret < 0) {
         ALOGE("%s: Audio Interface not set!", __func__);
+        goto done;
+    }
 
+done:
+    return;
+}
+
+static void process_native_support(const XML_Char **attr)
+{
+    int index;
+
+    if (strcmp(attr[0], "name") != 0) {
+        ALOGE("%s: 'name' not found, no NATIVE_AUDIO_44.1 set!", __func__);
+        goto done;
+    }
+
+    if (strcmp(attr[2], "codec_support") != 0) {
+        ALOGE("%s: NATIVE_AUDIO_44.1 in platform info xml has no codec_support set!",
+              __func__);
+        goto done;
+    }
+
+    if (platform_set_native_support(atoi((char *)attr[3])) < 0) {
+        ALOGE("%s: Device %s, ACDB ID %d was not set!",
+              __func__, attr[1], atoi((char *)attr[3]));
         goto done;
     }
 
@@ -298,6 +325,8 @@
         section = BACKEND_NAME;
     } else if (strcmp(tag_name, "interface_names") == 0) {
         section = INTERFACE_NAME;
+    } else if (strcmp(tag_name, "native_configs") == 0) {
+        section = NATIVESUPPORT;
     } else if (strcmp(tag_name, "device") == 0) {
         if ((section != ACDB) && (section != BACKEND_NAME) && (section != BITWIDTH) &&
             (section != INTERFACE_NAME)) {
@@ -316,6 +345,14 @@
 
         section_process_fn fn = section_table[PCM_ID];
         fn(attr);
+    } else if (strcmp(tag_name, "feature") == 0) {
+        if (section != NATIVESUPPORT) {
+            ALOGE("usecase tag only supported with NATIVESUPPORT section");
+            return;
+        }
+
+        section_process_fn fn = section_table[NATIVESUPPORT];
+        fn(attr);
     }
 
     return;
@@ -333,6 +370,8 @@
         section = ROOT;
     } else if (strcmp(tag_name, "interface_names") == 0) {
         section = ROOT;
+    } else if (strcmp(tag_name, "native_configs") == 0) {
+        section = ROOT;
     }
 }