Merge "hal: add support for hdmi out device"
diff --git a/hal/AudioDevice.cpp b/hal/AudioDevice.cpp
index 4e750d4..98e1593 100644
--- a/hal/AudioDevice.cpp
+++ b/hal/AudioDevice.cpp
@@ -35,7 +35,7 @@
  *
  * Changes from Qualcomm Innovation Center are provided under the following license:
  *
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022, 2024 Qualcomm Innovation Center, Inc. All rights reserved.
  * SPDX-License-Identifier: BSD-3-Clause-Clear
  */
 
@@ -144,6 +144,11 @@
                                                   | ORIENTATION) | GEOMETRIC_LOCATION) */
 };
 
+enum {
+    DISPLAYPORT_CONTROLLER = 0,
+    HDMI_CONTROLLER = 1,
+};
+
 static bool hdr_set_parameters(std::shared_ptr<AudioDevice> adev,
     struct str_parms *parms) {
 
@@ -2242,20 +2247,28 @@
         auto it = android_device_map_.find(hal_device_id);
         if (it != android_device_map_.end() &&
                 audio_is_input_device(it->first) == audio_is_input_device(hal_device_id)) {
-            AHAL_DBG("Found haldeviceId: %x and PAL Device ID %d",
-                    it->first, it->second);
             if (it->second == PAL_DEVICE_OUT_AUX_DIGITAL ||
                     it->second == PAL_DEVICE_OUT_HDMI) {
                AHAL_DBG("dp_controller: %d dp_stream: %d",
                        dp_controller, dp_stream);
-               if (dp_controller * MAX_STREAMS_PER_CONTROLLER + dp_stream) {
-                  pal_device_id[device_count] = PAL_DEVICE_OUT_AUX_DIGITAL_1;
-               } else {
-                  pal_device_id[device_count] = it->second;
+
+               switch (dp_controller) {
+                   case DISPLAYPORT_CONTROLLER :
+                       if (dp_stream == 0)
+                           pal_device_id[device_count] = it->second;
+                       else
+                           pal_device_id[device_count] = PAL_DEVICE_OUT_AUX_DIGITAL_1;
+                       break;
+                   case HDMI_CONTROLLER :
+                       pal_device_id[device_count] = PAL_DEVICE_OUT_HDMI;
+                       break;
                }
             } else {
                pal_device_id[device_count] = it->second;
             }
+
+            AHAL_DBG("Found haldeviceId: %x and PAL Device ID %d",
+                    it->first, pal_device_id[device_count]);
         }
         ++device_count;
     }
diff --git a/hal/AudioStream.cpp b/hal/AudioStream.cpp
index 3c88c56..3317237 100644
--- a/hal/AudioStream.cpp
+++ b/hal/AudioStream.cpp
@@ -30,7 +30,7 @@
 /*
  *  Changes from Qualcomm Innovation Center are provided under the following license:
  *
- *  Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ *  Copyright (c) 2022-2023, 2024 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  *  Redistribution and use in source and binary forms, with or without
  *  modification, are permitted (subject to the limitations in the
@@ -2564,10 +2564,11 @@
 
     ret = AudioExtn::get_controller_stream_from_params(parms, &controller, &stream);
     if (ret >= 0) {
-        adevice->dp_controller = controller;
-        adevice->dp_stream = stream;
-        if (stream >= 0 || controller >= 0)
+        if (stream >= 0 && controller >= 0) {
+            adevice->dp_controller = controller;
+            adevice->dp_stream = stream;
             AHAL_INFO("ret %d, plugin device cont %d stream %d", ret, controller, stream);
+        }
     } else {
         AHAL_ERR("error %d, failed to get stream and controller", ret);
     }