mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 17:40:40 -05:00
monitor-manager/kms: Use 'hotplug' event from MetaUdev
Instead of dealing with udev details here, use the newly added 'hotplug' event emitted from MetaUdev. https://gitlab.gnome.org/GNOME/mutter/issues/548 https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
This commit is contained in:
parent
171e5fc3c2
commit
e7fd068a78
@ -86,6 +86,7 @@ struct _MetaMonitorManagerKms
|
|||||||
|
|
||||||
GUdevClient *udev;
|
GUdevClient *udev;
|
||||||
guint uevent_handler_id;
|
guint uevent_handler_id;
|
||||||
|
guint hotplug_handler_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MetaMonitorManagerKmsClass
|
struct _MetaMonitorManagerKmsClass
|
||||||
@ -444,6 +445,35 @@ handle_gpu_hotplug (MetaMonitorManagerKms *manager_kms,
|
|||||||
g_signal_emit (manager_kms, signals[GPU_ADDED], 0, gpu_kms);
|
g_signal_emit (manager_kms, signals[GPU_ADDED], 0, gpu_kms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_udev_hotplug (MetaUdev *udev,
|
||||||
|
MetaMonitorManager *manager)
|
||||||
|
{
|
||||||
|
handle_hotplug_event (manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_monitor_manager_kms_connect_hotplug_handler (MetaMonitorManagerKms *manager_kms)
|
||||||
|
{
|
||||||
|
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
|
||||||
|
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
|
||||||
|
MetaUdev *udev = meta_backend_native_get_udev (META_BACKEND_NATIVE (backend));
|
||||||
|
|
||||||
|
manager_kms->hotplug_handler_id =
|
||||||
|
g_signal_connect (udev, "hotplug", G_CALLBACK (on_udev_hotplug), manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_monitor_manager_kms_disconnect_hotplug_handler (MetaMonitorManagerKms *manager_kms)
|
||||||
|
{
|
||||||
|
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
|
||||||
|
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
|
||||||
|
MetaUdev *udev = meta_backend_native_get_udev (META_BACKEND_NATIVE (backend));
|
||||||
|
|
||||||
|
g_signal_handler_disconnect (udev, manager_kms->hotplug_handler_id);
|
||||||
|
manager_kms->hotplug_handler_id = 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_uevent (GUdevClient *client,
|
on_uevent (GUdevClient *client,
|
||||||
const char *action,
|
const char *action,
|
||||||
@ -471,11 +501,6 @@ on_uevent (GUdevClient *client,
|
|||||||
if (!g_strcmp0 (seat_id, device_seat))
|
if (!g_strcmp0 (seat_id, device_seat))
|
||||||
handle_gpu_hotplug (manager_kms, device);
|
handle_gpu_hotplug (manager_kms, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_udev_device_get_property_as_boolean (device, "HOTPLUG"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
handle_hotplug_event (manager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -499,6 +524,7 @@ void
|
|||||||
meta_monitor_manager_kms_pause (MetaMonitorManagerKms *manager_kms)
|
meta_monitor_manager_kms_pause (MetaMonitorManagerKms *manager_kms)
|
||||||
{
|
{
|
||||||
meta_monitor_manager_kms_disconnect_uevent_handler (manager_kms);
|
meta_monitor_manager_kms_disconnect_uevent_handler (manager_kms);
|
||||||
|
meta_monitor_manager_kms_disconnect_hotplug_handler (manager_kms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -507,6 +533,7 @@ meta_monitor_manager_kms_resume (MetaMonitorManagerKms *manager_kms)
|
|||||||
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
|
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
|
||||||
|
|
||||||
meta_monitor_manager_kms_connect_uevent_handler (manager_kms);
|
meta_monitor_manager_kms_connect_uevent_handler (manager_kms);
|
||||||
|
meta_monitor_manager_kms_connect_hotplug_handler (manager_kms);
|
||||||
handle_hotplug_event (manager);
|
handle_hotplug_event (manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -713,6 +740,7 @@ meta_monitor_manager_kms_initable_init (GInitable *initable,
|
|||||||
manager_kms->udev = g_udev_client_new (subsystems);
|
manager_kms->udev = g_udev_client_new (subsystems);
|
||||||
|
|
||||||
meta_monitor_manager_kms_connect_uevent_handler (manager_kms);
|
meta_monitor_manager_kms_connect_uevent_handler (manager_kms);
|
||||||
|
meta_monitor_manager_kms_connect_hotplug_handler (manager_kms);
|
||||||
|
|
||||||
if (!init_gpus (manager_kms, error))
|
if (!init_gpus (manager_kms, error))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user