kms/impl-device: Keep a path string around

This is useful for e.g. logging.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
This commit is contained in:
Jonas Ådahl 2020-09-29 16:43:04 +02:00 committed by Marge Bot
parent deb8f07c65
commit 7842517519
3 changed files with 33 additions and 0 deletions

View File

@ -225,6 +225,7 @@ typedef struct _CreateImplDeviceData
{
MetaKmsDevice *device;
int fd;
const char *path;
MetaKmsImplDevice *out_impl_device;
GList *out_crtcs;
@ -260,6 +261,7 @@ static MetaKmsImplDevice *
meta_create_kms_impl_device (MetaKmsDevice *device,
MetaKmsImpl *impl,
int fd,
const char *path,
GError **error)
{
int ret;
@ -287,6 +289,7 @@ meta_create_kms_impl_device (MetaKmsDevice *device,
"device", device,
"impl", impl,
"fd", fd,
"path", path,
"driver-name", driver_name,
"driver-description", driver_description,
NULL);
@ -303,6 +306,7 @@ create_impl_device_in_impl (MetaKmsImpl *impl,
impl_device = meta_create_kms_impl_device (data->device,
impl,
data->fd,
data->path,
error);
if (!impl_device)
return FALSE;
@ -347,6 +351,7 @@ meta_kms_device_new (MetaKms *kms,
data = (CreateImplDeviceData) {
.device = device,
.fd = fd,
.path = path,
};
if (!meta_kms_run_impl_task_sync (kms, create_impl_device_in_impl, &data,
error))

View File

@ -45,6 +45,7 @@ enum
PROP_DEVICE,
PROP_IMPL,
PROP_FD,
PROP_PATH,
PROP_DRIVER_NAME,
PROP_DRIVER_DESCRIPTION,
@ -60,6 +61,7 @@ typedef struct _MetaKmsImplDevicePrivate
int fd;
GSource *fd_source;
char *path;
char *driver_name;
char *driver_description;
@ -158,6 +160,15 @@ meta_kms_impl_device_get_driver_description (MetaKmsImplDevice *impl_device)
return priv->driver_description;
}
const char *
meta_kms_impl_device_get_path (MetaKmsImplDevice *impl_device)
{
MetaKmsImplDevicePrivate *priv =
meta_kms_impl_device_get_instance_private (impl_device);
return priv->path;
}
static void
page_flip_handler (int fd,
unsigned int sequence,
@ -677,6 +688,9 @@ meta_kms_impl_device_get_property (GObject *object,
case PROP_FD:
g_value_set_int (value, priv->fd);
break;
case PROP_PATH:
g_value_set_string (value, priv->path);
break;
case PROP_DRIVER_NAME:
g_value_set_string (value, priv->driver_name);
break;
@ -710,6 +724,9 @@ meta_kms_impl_device_set_property (GObject *object,
case PROP_FD:
priv->fd = g_value_get_int (value);
break;
case PROP_PATH:
priv->path = g_value_dup_string (value);
break;
case PROP_DRIVER_NAME:
priv->driver_name = g_value_dup_string (value);
break;
@ -738,6 +755,7 @@ meta_kms_impl_device_finalize (GObject *object)
(GDestroyNotify) meta_kms_mode_free);
g_free (priv->driver_name);
g_free (priv->driver_description);
g_free (priv->path);
G_OBJECT_CLASS (meta_kms_impl_device_parent_class)->finalize (object);
}
@ -824,6 +842,14 @@ meta_kms_impl_device_class_init (MetaKmsImplDeviceClass *klass)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
obj_props[PROP_PATH] =
g_param_spec_string ("path",
"path",
"DRM device file path",
NULL,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
obj_props[PROP_DRIVER_NAME] =
g_param_spec_string ("driver-name",
"driver-name",

View File

@ -83,6 +83,8 @@ const char * meta_kms_impl_device_get_driver_name (MetaKmsImplDevice *impl_devic
const char * meta_kms_impl_device_get_driver_description (MetaKmsImplDevice *impl_device);
const char * meta_kms_impl_device_get_path (MetaKmsImplDevice *impl_device);
gboolean meta_kms_impl_device_dispatch (MetaKmsImplDevice *impl_device,
GError **error);