device-manager: update hdmi device management mechanism 70/285470/3 accepted/tizen/unified/20221219.024712
authorSeungbae Shin <seungbae.shin@samsung.com>
Tue, 13 Dec 2022 08:59:44 +0000 (17:59 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Wed, 14 Dec 2022 02:21:57 +0000 (02:21 +0000)
This update is based on the latest RPI kernel,
the related obsolete hdmi handling code is now removed.

[Version] 15.0.34
[Issue Type] Update

Change-Id: I994fb43982c394cfa600219f51cd259a9b14e27f

packaging/pulseaudio-modules-tizen.spec
src/device-manager-dbus.c
src/device-manager-priv.h
src/device-manager.c

index 74c31ae..be642d8 100644 (file)
@@ -2,7 +2,7 @@
 
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          15.0.33
+Version:          15.0.34
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index c5ae84c..6b52c1b 100644 (file)
@@ -407,13 +407,6 @@ static int _translate_external_value(const char *type, int value, device_detecte
             *detected = DEVICE_CONNECTED_AUDIO_JACK_4P;
         else
             return -1;
-    } else if (device_type_is_equal(DEVICE_TYPE_HDMI, type)) {
-        if (value == HDMI_AUDIO_DISCONNECTED)
-            *detected = DEVICE_DISCONNECTED;
-        else if (value == HDMI_AUDIO_AVAILABLE)
-            *detected = DEVICE_CONNECTED;
-        else
-            return -1;
     } else if (device_type_is_equal(DEVICE_TYPE_FORWARDING, type)) {
         if (value == FORWARDING_DISCONNECTED)
             *detected = DEVICE_DISCONNECTED;
@@ -535,16 +528,6 @@ static DBusHandlerResult dbus_filter_device_detect_handler(DBusConnection *c, DB
         }
         handle_device_status_changed(dm, DEVICE_TYPE_AUDIO_JACK, NULL, NULL, detected);
 
-    } else if (dbus_message_is_signal(s, DBUS_INTERFACE_DEVICED_SYSNOTI, "ChangedHDMIAudio")) {
-        if (!dbus_message_get_args(s, NULL, DBUS_TYPE_INT32, &status, DBUS_TYPE_INVALID))
-            goto fail;
-
-        if (_translate_external_value(DEVICE_TYPE_HDMI, status, &detected) < 0) {
-            pa_log_warn("failed to translate HDMI detected value");
-            goto fail;
-        }
-        handle_device_status_changed(dm, DEVICE_TYPE_HDMI, NULL, NULL, detected);
-
     } else if (dbus_message_is_signal(s, DBUS_INTERFACE_MIRRORING_SERVER, "miracast_wfd_source_status_changed")) {
         if (!dbus_message_get_args(s, NULL, DBUS_TYPE_INT32, &status, DBUS_TYPE_INVALID))
             goto fail;
index 5e17f2c..9244640 100644 (file)
@@ -105,12 +105,6 @@ typedef enum external_value_forwarding_type {
     FORWARDING_CONNECTED = 1,
 } external_value_mirroring_t;
 
-typedef enum external_value_hdmi_type {
-    HDMI_AUDIO_DISCONNECTED = -1,
-    HDMI_AUDIO_NOT_AVAILABLE = 0,
-    HDMI_AUDIO_AVAILABLE = 1,
-} external_value_hdmi_t;
-
 typedef enum external_value_bt_sco_type {
     BT_SCO_DISCONNECTED = 0,
     BT_SCO_CONNECTED = 1,
index f541685..1e05eba 100644 (file)
@@ -89,6 +89,7 @@
 #define DEVICE_API_BTSCO                    "btsco"
 #endif
 #define DEVICE_BUS_USB                      "usb"
+#define DEVICE_BUS_PATH_HDMI                "hdmi"
 #define DEVICE_CLASS_SOUND                  "sound"
 #define DEVICE_CLASS_MONITOR                "monitor"
 
@@ -498,6 +499,20 @@ static bool pulse_device_is_btsco(pa_object *pdevice) {
 }
 #endif
 
+static bool pulse_device_is_hdmi(pa_object *pdevice) {
+    const char *bus_path_name = NULL;
+    pa_proplist *prop = pulse_device_get_proplist(pdevice);
+
+    if (!prop)
+        return false;
+
+    if ((bus_path_name = pa_proplist_gets(prop, PA_PROP_DEVICE_BUS_PATH)))
+        return (bool)strstr(bus_path_name, DEVICE_BUS_PATH_HDMI);
+
+    pa_log_debug("This device doesn't have property '%s'", PA_PROP_DEVICE_BUS_PATH);
+    return false;
+}
+
 static const char* pulse_device_get_device_string_removed_argument(pa_object *pdevice) {
     static char removed_param[DEVICE_PARAM_STRING_MAX] = {0,};
     char *device_string_p = NULL;
@@ -1052,6 +1067,8 @@ pa_dynarray* pulse_device_get_belongs_type(pa_object *pdevice, pa_device_manager
         return NULL;
     if (pulse_device_is_usb(pdevice))
         return NULL;
+    if (pulse_device_is_hdmi(pdevice))
+        return NULL;
     if (pulse_device_is_bluez(pdevice))
         return NULL;
 
@@ -1188,7 +1205,7 @@ static const char* pulse_device_get_system_id(pa_object *pdevice) {
 
     prop = pulse_device_get_proplist(pdevice);
 
-    if (pulse_device_is_usb(pdevice))
+    if (pulse_device_is_usb(pdevice) || pulse_device_is_hdmi(pdevice))
         return pa_proplist_gets(prop, "sysfs.path");
     else if (pulse_device_is_bluez(pdevice))
         return pa_proplist_gets(prop, "bluez.path");
@@ -1419,7 +1436,6 @@ static void handle_usb_pulse_device(pa_object *pdevice, bool is_loaded, pa_devic
         pa_tz_device_new_data data;
         int product_id, vendor_id;
         pa_proplist *prop;
-
         prop = pulse_device_get_proplist(pdevice);
         name = pa_proplist_gets(prop, "udev.id");
 
@@ -1453,6 +1469,49 @@ static void handle_usb_pulse_device(pa_object *pdevice, bool is_loaded, pa_devic
     }
 }
 
+static void handle_hdmi_pulse_device(pa_object *pdevice, bool is_loaded, pa_device_manager *dm) {
+    const char *name, *system_id;
+    dm_device_direction_t direction;
+    pa_tz_device *device;
+
+    pa_assert(pdevice);
+    pa_assert(dm);
+
+    pa_log_info("Handle hdmi pulse device");
+
+    system_id = pulse_device_get_system_id(pdevice);
+    direction = pulse_device_get_direction(pdevice);
+
+    if (is_loaded) {
+        pa_tz_device_new_data data;
+        pa_proplist *prop;
+
+        prop = pulse_device_get_proplist(pdevice);
+        name = pa_proplist_gets(prop, "alsa.card_name");
+
+        pa_tz_device_new_data_init(&data, dm->device_list, dm->comm, NULL);
+        pa_tz_device_new_data_set_type(&data, DEVICE_TYPE_HDMI);
+        pa_tz_device_new_data_set_name(&data, name);
+        pa_tz_device_new_data_set_direction(&data, direction);
+        pa_tz_device_new_data_set_system_id(&data, system_id);
+        pa_tz_device_new_data_set_use_internal_codec(&data, false);
+        if (direction == DM_DEVICE_DIRECTION_OUT) {
+            apply_preference(dm, PA_SINK(pdevice));
+            pa_tz_device_new_data_add_sink(&data, DEVICE_ROLE_NORMAL, PA_SINK(pdevice));
+        } else {
+            pa_tz_device_new_data_add_source(&data, DEVICE_ROLE_NORMAL, PA_SOURCE(pdevice));
+        }
+
+        pa_tz_device_new(&data);
+        pa_tz_device_new_data_done(&data);
+    } else {
+        if (!(device = device_list_get_device(dm, DEVICE_TYPE_HDMI, NULL, system_id)))
+            pa_log_warn("Can't get hdmi device for %s", system_id);
+        else
+            pa_tz_device_free(device);
+    }
+}
+
 static void handle_bt_pulse_device(pa_object *pdevice, bool is_loaded, pa_device_manager *dm) {
     dm_device_direction_t direction;
     pa_tz_device *device;
@@ -1721,6 +1780,10 @@ static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, pa_dev
         pulse_device_set_use_internal_codec(PA_OBJECT(sink), false);
         handle_usb_pulse_device(PA_OBJECT(sink), true, dm);
         return PA_HOOK_OK;
+    } else if (pulse_device_is_hdmi(PA_OBJECT(sink))) {
+        pulse_device_set_use_internal_codec(PA_OBJECT(sink), false);
+        handle_hdmi_pulse_device(PA_OBJECT(sink), true, dm);
+        return PA_HOOK_OK;
     } else if (pulse_device_is_bluez(PA_OBJECT(sink))) {
         pulse_device_set_use_internal_codec(PA_OBJECT(sink), false);
         handle_bt_pulse_device(PA_OBJECT(sink), true, dm);
@@ -1763,6 +1826,9 @@ static pa_hook_result_t sink_unlink_hook_callback(pa_core *c, pa_sink *sink, pa_
     if (pulse_device_is_usb(PA_OBJECT(sink))) {
         handle_usb_pulse_device(PA_OBJECT(sink), false, dm);
         return PA_HOOK_OK;
+    } else if (pulse_device_is_hdmi(PA_OBJECT(sink))) {
+        handle_hdmi_pulse_device(PA_OBJECT(sink), false, dm);
+        return PA_HOOK_OK;
     } else if (pulse_device_is_bluez(PA_OBJECT(sink))) {
         handle_bt_pulse_device(PA_OBJECT(sink), false, dm);
         return PA_HOOK_OK;