kms/device: Use device pool to open/close dri devices
This replaces the usage of MetaLauncher. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
This commit is contained in:
parent
ee8c252a8c
commit
f3457b678c
@ -28,7 +28,8 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
|
|
||||||
#include "backends/native/meta-backend-native.h"
|
#include "backends/native/meta-backend-native-private.h"
|
||||||
|
#include "backends/native/meta-device-pool.h"
|
||||||
#include "backends/native/meta-kms-impl-device-atomic.h"
|
#include "backends/native/meta-kms-impl-device-atomic.h"
|
||||||
#include "backends/native/meta-kms-impl-device-dummy.h"
|
#include "backends/native/meta-kms-impl-device-dummy.h"
|
||||||
#include "backends/native/meta-kms-impl-device-simple.h"
|
#include "backends/native/meta-kms-impl-device-simple.h"
|
||||||
@ -229,7 +230,7 @@ meta_kms_device_add_fake_plane_in_impl (MetaKmsDevice *device,
|
|||||||
typedef struct _CreateImplDeviceData
|
typedef struct _CreateImplDeviceData
|
||||||
{
|
{
|
||||||
MetaKmsDevice *device;
|
MetaKmsDevice *device;
|
||||||
int fd;
|
MetaDeviceFile *device_file;
|
||||||
const char *path;
|
const char *path;
|
||||||
MetaKmsDeviceFlag flags;
|
MetaKmsDeviceFlag flags;
|
||||||
|
|
||||||
@ -281,7 +282,7 @@ get_driver_info (int fd,
|
|||||||
static MetaKmsImplDevice *
|
static MetaKmsImplDevice *
|
||||||
meta_create_kms_impl_device (MetaKmsDevice *device,
|
meta_create_kms_impl_device (MetaKmsDevice *device,
|
||||||
MetaKmsImpl *impl,
|
MetaKmsImpl *impl,
|
||||||
int fd,
|
MetaDeviceFile *device_file,
|
||||||
const char *path,
|
const char *path,
|
||||||
MetaKmsDeviceFlag flags,
|
MetaKmsDeviceFlag flags,
|
||||||
GError **error)
|
GError **error)
|
||||||
@ -291,12 +292,13 @@ meta_create_kms_impl_device (MetaKmsDevice *device,
|
|||||||
g_autofree char *driver_name = NULL;
|
g_autofree char *driver_name = NULL;
|
||||||
g_autofree char *driver_description = NULL;
|
g_autofree char *driver_description = NULL;
|
||||||
const char *atomic_kms_enable_env;
|
const char *atomic_kms_enable_env;
|
||||||
int impl_fd;
|
int fd;
|
||||||
g_autofree char *impl_path = NULL;
|
g_autoptr (MetaDeviceFile) impl_device_file = NULL;
|
||||||
MetaKmsImplDevice *impl_device;
|
MetaKmsImplDevice *impl_device;
|
||||||
|
|
||||||
meta_assert_in_kms_impl (meta_kms_impl_get_kms (impl));
|
meta_assert_in_kms_impl (meta_kms_impl_get_kms (impl));
|
||||||
|
|
||||||
|
fd = meta_device_file_get_fd (device_file);
|
||||||
if (!get_driver_info (fd, &driver_name, &driver_description))
|
if (!get_driver_info (fd, &driver_name, &driver_description))
|
||||||
{
|
{
|
||||||
driver_name = g_strdup ("unknown");
|
driver_name = g_strdup ("unknown");
|
||||||
@ -308,6 +310,7 @@ meta_create_kms_impl_device (MetaKmsDevice *device,
|
|||||||
if (flags & META_KMS_DEVICE_FLAG_NO_MODE_SETTING)
|
if (flags & META_KMS_DEVICE_FLAG_NO_MODE_SETTING)
|
||||||
{
|
{
|
||||||
g_autofree char *render_node_path = NULL;
|
g_autofree char *render_node_path = NULL;
|
||||||
|
MetaDevicePool *device_pool;
|
||||||
|
|
||||||
render_node_path = drmGetRenderDeviceNameFromFd (fd);
|
render_node_path = drmGetRenderDeviceNameFromFd (fd);
|
||||||
if (!render_node_path)
|
if (!render_node_path)
|
||||||
@ -318,19 +321,17 @@ meta_create_kms_impl_device (MetaKmsDevice *device,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_fd = open (render_node_path, O_RDWR | O_CLOEXEC, 0);
|
device_pool = meta_device_file_get_pool (device_file);
|
||||||
if (impl_fd == -1)
|
|
||||||
{
|
impl_device_file = meta_device_pool_open (device_pool, render_node_path,
|
||||||
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno),
|
META_DEVICE_FILE_FLAG_NONE,
|
||||||
"Failed to open render node '%s': %s",
|
error);
|
||||||
render_node_path, g_strerror (errno));
|
if (!impl_device_file)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
g_message ("Adding device '%s' (from '%s', %s) using no mode setting.",
|
g_message ("Adding device '%s' (from '%s', %s) using no mode setting.",
|
||||||
render_node_path, path, driver_name);
|
render_node_path, path, driver_name);
|
||||||
|
|
||||||
impl_path = g_steal_pointer (&render_node_path);
|
|
||||||
impl_device_type = META_TYPE_KMS_IMPL_DEVICE_DUMMY;
|
impl_device_type = META_TYPE_KMS_IMPL_DEVICE_DUMMY;
|
||||||
}
|
}
|
||||||
else if (atomic_kms_enable_env)
|
else if (atomic_kms_enable_env)
|
||||||
@ -355,8 +356,7 @@ meta_create_kms_impl_device (MetaKmsDevice *device,
|
|||||||
atomic_kms_enable_env);
|
atomic_kms_enable_env);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_fd = dup (fd);
|
impl_device_file = meta_device_file_acquire (device_file);
|
||||||
impl_path = g_strdup (path);
|
|
||||||
|
|
||||||
g_message ("Mode setting implementation for '%s' (%s) forced (%s).",
|
g_message ("Mode setting implementation for '%s' (%s) forced (%s).",
|
||||||
path, driver_name,
|
path, driver_name,
|
||||||
@ -368,8 +368,7 @@ meta_create_kms_impl_device (MetaKmsDevice *device,
|
|||||||
g_message ("Adding device '%s' (%s) using non-atomic mode setting"
|
g_message ("Adding device '%s' (%s) using non-atomic mode setting"
|
||||||
" (using atomic mode setting not allowed).",
|
" (using atomic mode setting not allowed).",
|
||||||
path, driver_name);
|
path, driver_name);
|
||||||
impl_fd = dup (fd);
|
impl_device_file = meta_device_file_acquire (device_file);
|
||||||
impl_path = g_strdup (path);
|
|
||||||
impl_device_type = META_TYPE_KMS_IMPL_DEVICE_SIMPLE;
|
impl_device_type = META_TYPE_KMS_IMPL_DEVICE_SIMPLE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -395,26 +394,19 @@ meta_create_kms_impl_device (MetaKmsDevice *device,
|
|||||||
impl_device_type = META_TYPE_KMS_IMPL_DEVICE_SIMPLE;
|
impl_device_type = META_TYPE_KMS_IMPL_DEVICE_SIMPLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_fd = dup (fd);
|
impl_device_file = meta_device_file_acquire (device_file);
|
||||||
impl_path = g_strdup (path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_device = g_initable_new (impl_device_type, NULL, error,
|
impl_device = g_initable_new (impl_device_type, NULL, error,
|
||||||
"device", device,
|
"device", device,
|
||||||
"impl", impl,
|
"impl", impl,
|
||||||
"fd", impl_fd,
|
"device-file", impl_device_file,
|
||||||
"path", impl_path,
|
|
||||||
"flags", flags,
|
"flags", flags,
|
||||||
"driver-name", driver_name,
|
"driver-name", driver_name,
|
||||||
"driver-description", driver_description,
|
"driver-description", driver_description,
|
||||||
NULL);
|
NULL);
|
||||||
if (!impl_device)
|
if (!impl_device)
|
||||||
{
|
return NULL;
|
||||||
close (impl_fd);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
close (fd);
|
|
||||||
|
|
||||||
return impl_device;
|
return impl_device;
|
||||||
}
|
}
|
||||||
@ -429,7 +421,7 @@ create_impl_device_in_impl (MetaKmsImpl *impl,
|
|||||||
|
|
||||||
impl_device = meta_create_kms_impl_device (data->device,
|
impl_device = meta_create_kms_impl_device (data->device,
|
||||||
impl,
|
impl,
|
||||||
data->fd,
|
data->device_file,
|
||||||
data->path,
|
data->path,
|
||||||
data->flags,
|
data->flags,
|
||||||
error);
|
error);
|
||||||
@ -462,44 +454,33 @@ meta_kms_device_new (MetaKms *kms,
|
|||||||
{
|
{
|
||||||
MetaBackend *backend = meta_kms_get_backend (kms);
|
MetaBackend *backend = meta_kms_get_backend (kms);
|
||||||
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
|
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
|
||||||
MetaLauncher *launcher = meta_backend_native_get_launcher (backend_native);
|
MetaDevicePool *device_pool =
|
||||||
|
meta_backend_native_get_device_pool (backend_native);
|
||||||
MetaKmsDevice *device;
|
MetaKmsDevice *device;
|
||||||
CreateImplDeviceData data;
|
CreateImplDeviceData data;
|
||||||
int fd;
|
g_autoptr (MetaDeviceFile) device_file = NULL;
|
||||||
|
MetaDeviceFileFlags device_file_flags;
|
||||||
|
|
||||||
if (flags & META_KMS_DEVICE_FLAG_NO_MODE_SETTING)
|
device_file_flags = META_DEVICE_FILE_FLAG_NONE;
|
||||||
{
|
if (!(flags & META_KMS_DEVICE_FLAG_NO_MODE_SETTING))
|
||||||
fd = open (path, O_RDWR | O_CLOEXEC, 0);
|
device_file_flags |= META_DEVICE_FILE_FLAG_TAKE_CONTROL;
|
||||||
if (fd == -1)
|
|
||||||
{
|
device_file = meta_device_pool_open (device_pool, path, flags, error);
|
||||||
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno),
|
if (!device_file)
|
||||||
"Failed to open DRM device: %s", g_strerror (errno));
|
return NULL;
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fd = meta_launcher_open_restricted (launcher, path, error);
|
|
||||||
if (fd == -1)
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
device = g_object_new (META_TYPE_KMS_DEVICE, NULL);
|
device = g_object_new (META_TYPE_KMS_DEVICE, NULL);
|
||||||
device->kms = kms;
|
device->kms = kms;
|
||||||
|
|
||||||
data = (CreateImplDeviceData) {
|
data = (CreateImplDeviceData) {
|
||||||
.device = device,
|
.device = device,
|
||||||
.fd = fd,
|
.device_file = device_file,
|
||||||
.path = path,
|
.path = path,
|
||||||
.flags = flags,
|
.flags = flags,
|
||||||
};
|
};
|
||||||
if (!meta_kms_run_impl_task_sync (kms, create_impl_device_in_impl, &data,
|
if (!meta_kms_run_impl_task_sync (kms, create_impl_device_in_impl, &data,
|
||||||
error))
|
error))
|
||||||
{
|
{
|
||||||
if (flags & META_KMS_DEVICE_FLAG_NO_MODE_SETTING)
|
|
||||||
close (fd);
|
|
||||||
else
|
|
||||||
meta_launcher_close_restricted (launcher, fd);
|
|
||||||
g_object_unref (device);
|
g_object_unref (device);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -520,27 +501,15 @@ meta_kms_device_new (MetaKms *kms,
|
|||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct _FreeImplDeviceData
|
|
||||||
{
|
|
||||||
MetaKmsImplDevice *impl_device;
|
|
||||||
|
|
||||||
int out_fd;
|
|
||||||
} FreeImplDeviceData;
|
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
free_impl_device_in_impl (MetaKmsImpl *impl,
|
free_impl_device_in_impl (MetaKmsImpl *impl,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
FreeImplDeviceData *data = user_data;
|
MetaKmsImplDevice *impl_device = user_data;
|
||||||
MetaKmsImplDevice *impl_device = data->impl_device;
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
fd = meta_kms_impl_device_close (impl_device);
|
|
||||||
g_object_unref (impl_device);
|
g_object_unref (impl_device);
|
||||||
|
|
||||||
data->out_fd = fd;
|
|
||||||
|
|
||||||
return GINT_TO_POINTER (TRUE);
|
return GINT_TO_POINTER (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -548,9 +517,6 @@ static void
|
|||||||
meta_kms_device_finalize (GObject *object)
|
meta_kms_device_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
MetaKmsDevice *device = META_KMS_DEVICE (object);
|
MetaKmsDevice *device = META_KMS_DEVICE (object);
|
||||||
MetaBackend *backend = meta_kms_get_backend (device->kms);
|
|
||||||
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
|
|
||||||
MetaLauncher *launcher = meta_backend_native_get_launcher (backend_native);
|
|
||||||
|
|
||||||
g_free (device->path);
|
g_free (device->path);
|
||||||
g_list_free (device->crtcs);
|
g_list_free (device->crtcs);
|
||||||
@ -559,26 +525,11 @@ meta_kms_device_finalize (GObject *object)
|
|||||||
|
|
||||||
if (device->impl_device)
|
if (device->impl_device)
|
||||||
{
|
{
|
||||||
FreeImplDeviceData data;
|
meta_kms_run_impl_task_sync (device->kms, free_impl_device_in_impl,
|
||||||
GError *error = NULL;
|
device->impl_device,
|
||||||
|
NULL);
|
||||||
data = (FreeImplDeviceData) {
|
|
||||||
.impl_device = device->impl_device,
|
|
||||||
};
|
|
||||||
if (!meta_kms_run_impl_task_sync (device->kms, free_impl_device_in_impl, &data,
|
|
||||||
&error))
|
|
||||||
{
|
|
||||||
g_warning ("Failed to close KMS impl device: %s", error->message);
|
|
||||||
g_error_free (error);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (device->flags & META_KMS_DEVICE_FLAG_NO_MODE_SETTING)
|
|
||||||
close (data.out_fd);
|
|
||||||
else
|
|
||||||
meta_launcher_close_restricted (launcher, data.out_fd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
G_OBJECT_CLASS (meta_kms_device_parent_class)->finalize (object);
|
G_OBJECT_CLASS (meta_kms_device_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
|
|
||||||
|
#include "backends/native/meta-backend-native.h"
|
||||||
|
#include "backends/native/meta-device-pool.h"
|
||||||
#include "backends/native/meta-kms-connector-private.h"
|
#include "backends/native/meta-kms-connector-private.h"
|
||||||
#include "backends/native/meta-kms-connector.h"
|
#include "backends/native/meta-kms-connector.h"
|
||||||
#include "backends/native/meta-kms-crtc-private.h"
|
#include "backends/native/meta-kms-crtc-private.h"
|
||||||
@ -45,8 +47,7 @@ enum
|
|||||||
|
|
||||||
PROP_DEVICE,
|
PROP_DEVICE,
|
||||||
PROP_IMPL,
|
PROP_IMPL,
|
||||||
PROP_FD,
|
PROP_DEVICE_FILE,
|
||||||
PROP_PATH,
|
|
||||||
PROP_FLAGS,
|
PROP_FLAGS,
|
||||||
PROP_DRIVER_NAME,
|
PROP_DRIVER_NAME,
|
||||||
PROP_DRIVER_DESCRIPTION,
|
PROP_DRIVER_DESCRIPTION,
|
||||||
@ -61,7 +62,7 @@ typedef struct _MetaKmsImplDevicePrivate
|
|||||||
MetaKmsDevice *device;
|
MetaKmsDevice *device;
|
||||||
MetaKmsImpl *impl;
|
MetaKmsImpl *impl;
|
||||||
|
|
||||||
int fd;
|
MetaDeviceFile *device_file;
|
||||||
GSource *fd_source;
|
GSource *fd_source;
|
||||||
char *path;
|
char *path;
|
||||||
MetaKmsDeviceFlag flags;
|
MetaKmsDeviceFlag flags;
|
||||||
@ -197,6 +198,7 @@ meta_kms_impl_device_dispatch (MetaKmsImplDevice *impl_device,
|
|||||||
MetaKmsImplDevicePrivate *priv =
|
MetaKmsImplDevicePrivate *priv =
|
||||||
meta_kms_impl_device_get_instance_private (impl_device);
|
meta_kms_impl_device_get_instance_private (impl_device);
|
||||||
MetaKmsImplDeviceClass *klass = META_KMS_IMPL_DEVICE_GET_CLASS (impl_device);
|
MetaKmsImplDeviceClass *klass = META_KMS_IMPL_DEVICE_GET_CLASS (impl_device);
|
||||||
|
int fd;
|
||||||
|
|
||||||
drmEventContext drm_event_context;
|
drmEventContext drm_event_context;
|
||||||
|
|
||||||
@ -205,9 +207,11 @@ meta_kms_impl_device_dispatch (MetaKmsImplDevice *impl_device,
|
|||||||
drm_event_context = (drmEventContext) { 0 };
|
drm_event_context = (drmEventContext) { 0 };
|
||||||
klass->setup_drm_event_context (impl_device, &drm_event_context);
|
klass->setup_drm_event_context (impl_device, &drm_event_context);
|
||||||
|
|
||||||
|
fd = meta_device_file_get_fd (priv->device_file);
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
if (drmHandleEvent (priv->fd, &drm_event_context) != 0)
|
if (drmHandleEvent (fd, &drm_event_context) != 0)
|
||||||
{
|
{
|
||||||
struct pollfd pfd;
|
struct pollfd pfd;
|
||||||
int ret;
|
int ret;
|
||||||
@ -220,7 +224,7 @@ meta_kms_impl_device_dispatch (MetaKmsImplDevice *impl_device,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
pfd.fd = priv->fd;
|
pfd.fd = fd;
|
||||||
pfd.events = POLL_IN | POLL_ERR;
|
pfd.events = POLL_IN | POLL_ERR;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -257,15 +261,18 @@ meta_kms_impl_device_find_property (MetaKmsImplDevice *impl_device,
|
|||||||
{
|
{
|
||||||
MetaKmsImplDevicePrivate *priv =
|
MetaKmsImplDevicePrivate *priv =
|
||||||
meta_kms_impl_device_get_instance_private (impl_device);
|
meta_kms_impl_device_get_instance_private (impl_device);
|
||||||
|
int fd;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
meta_assert_in_kms_impl (meta_kms_impl_get_kms (priv->impl));
|
meta_assert_in_kms_impl (meta_kms_impl_get_kms (priv->impl));
|
||||||
|
|
||||||
|
fd = meta_device_file_get_fd (priv->device_file);
|
||||||
|
|
||||||
for (i = 0; i < props->count_props; i++)
|
for (i = 0; i < props->count_props; i++)
|
||||||
{
|
{
|
||||||
drmModePropertyPtr prop;
|
drmModePropertyPtr prop;
|
||||||
|
|
||||||
prop = drmModeGetProperty (priv->fd, props->props[i]);
|
prop = drmModeGetProperty (fd, props->props[i]);
|
||||||
if (!prop)
|
if (!prop)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -286,9 +293,10 @@ init_caps (MetaKmsImplDevice *impl_device)
|
|||||||
{
|
{
|
||||||
MetaKmsImplDevicePrivate *priv =
|
MetaKmsImplDevicePrivate *priv =
|
||||||
meta_kms_impl_device_get_instance_private (impl_device);
|
meta_kms_impl_device_get_instance_private (impl_device);
|
||||||
int fd = priv->fd;
|
int fd;
|
||||||
uint64_t cursor_width, cursor_height;
|
uint64_t cursor_width, cursor_height;
|
||||||
|
|
||||||
|
fd = meta_device_file_get_fd (priv->device_file);
|
||||||
if (drmGetCap (fd, DRM_CAP_CURSOR_WIDTH, &cursor_width) == 0 &&
|
if (drmGetCap (fd, DRM_CAP_CURSOR_WIDTH, &cursor_width) == 0 &&
|
||||||
drmGetCap (fd, DRM_CAP_CURSOR_HEIGHT, &cursor_height) == 0)
|
drmGetCap (fd, DRM_CAP_CURSOR_HEIGHT, &cursor_height) == 0)
|
||||||
{
|
{
|
||||||
@ -305,6 +313,9 @@ init_crtcs (MetaKmsImplDevice *impl_device,
|
|||||||
MetaKmsImplDevicePrivate *priv =
|
MetaKmsImplDevicePrivate *priv =
|
||||||
meta_kms_impl_device_get_instance_private (impl_device);
|
meta_kms_impl_device_get_instance_private (impl_device);
|
||||||
int idx;
|
int idx;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
fd = meta_device_file_get_fd (priv->device_file);
|
||||||
|
|
||||||
for (idx = 0; idx < drm_resources->count_crtcs; idx++)
|
for (idx = 0; idx < drm_resources->count_crtcs; idx++)
|
||||||
{
|
{
|
||||||
@ -314,7 +325,7 @@ init_crtcs (MetaKmsImplDevice *impl_device,
|
|||||||
g_autoptr (GError) error = NULL;
|
g_autoptr (GError) error = NULL;
|
||||||
|
|
||||||
crtc_id = drm_resources->crtcs[idx];
|
crtc_id = drm_resources->crtcs[idx];
|
||||||
drm_crtc = drmModeGetCrtc (priv->fd, crtc_id);
|
drm_crtc = drmModeGetCrtc (fd, crtc_id);
|
||||||
if (!drm_crtc)
|
if (!drm_crtc)
|
||||||
{
|
{
|
||||||
g_warning ("Failed to get CRTC %u info on '%s': %s",
|
g_warning ("Failed to get CRTC %u info on '%s': %s",
|
||||||
@ -365,14 +376,16 @@ update_connectors (MetaKmsImplDevice *impl_device,
|
|||||||
meta_kms_impl_device_get_instance_private (impl_device);
|
meta_kms_impl_device_get_instance_private (impl_device);
|
||||||
GList *connectors = NULL;
|
GList *connectors = NULL;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
fd = meta_device_file_get_fd (priv->device_file);
|
||||||
|
|
||||||
for (i = 0; i < drm_resources->count_connectors; i++)
|
for (i = 0; i < drm_resources->count_connectors; i++)
|
||||||
{
|
{
|
||||||
drmModeConnector *drm_connector;
|
drmModeConnector *drm_connector;
|
||||||
MetaKmsConnector *connector;
|
MetaKmsConnector *connector;
|
||||||
|
|
||||||
drm_connector = drmModeGetConnector (priv->fd,
|
drm_connector = drmModeGetConnector (fd, drm_resources->connectors[i]);
|
||||||
drm_resources->connectors[i]);
|
|
||||||
if (!drm_connector)
|
if (!drm_connector)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -510,10 +523,12 @@ init_planes (MetaKmsImplDevice *impl_device)
|
|||||||
{
|
{
|
||||||
MetaKmsImplDevicePrivate *priv =
|
MetaKmsImplDevicePrivate *priv =
|
||||||
meta_kms_impl_device_get_instance_private (impl_device);
|
meta_kms_impl_device_get_instance_private (impl_device);
|
||||||
int fd = priv->fd;
|
int fd;
|
||||||
drmModePlaneRes *drm_planes;
|
drmModePlaneRes *drm_planes;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
fd = meta_device_file_get_fd (priv->device_file);
|
||||||
|
|
||||||
drm_planes = drmModeGetPlaneResources (fd);
|
drm_planes = drmModeGetPlaneResources (fd);
|
||||||
if (!drm_planes)
|
if (!drm_planes)
|
||||||
return;
|
return;
|
||||||
@ -589,13 +604,15 @@ meta_kms_impl_device_update_states (MetaKmsImplDevice *impl_device)
|
|||||||
{
|
{
|
||||||
MetaKmsImplDevicePrivate *priv =
|
MetaKmsImplDevicePrivate *priv =
|
||||||
meta_kms_impl_device_get_instance_private (impl_device);
|
meta_kms_impl_device_get_instance_private (impl_device);
|
||||||
|
int fd;
|
||||||
drmModeRes *drm_resources;
|
drmModeRes *drm_resources;
|
||||||
|
|
||||||
meta_assert_in_kms_impl (meta_kms_impl_get_kms (priv->impl));
|
meta_assert_in_kms_impl (meta_kms_impl_get_kms (priv->impl));
|
||||||
|
|
||||||
meta_topic (META_DEBUG_KMS, "Updating device state for %s", priv->path);
|
meta_topic (META_DEBUG_KMS, "Updating device state for %s", priv->path);
|
||||||
|
|
||||||
drm_resources = drmModeGetResources (priv->fd);
|
fd = meta_device_file_get_fd (priv->device_file);
|
||||||
|
drm_resources = drmModeGetResources (fd);
|
||||||
if (!drm_resources)
|
if (!drm_resources)
|
||||||
{
|
{
|
||||||
g_list_free_full (priv->planes, g_object_unref);
|
g_list_free_full (priv->planes, g_object_unref);
|
||||||
@ -637,7 +654,7 @@ meta_kms_impl_device_get_fd (MetaKmsImplDevice *impl_device)
|
|||||||
|
|
||||||
meta_assert_in_kms_impl (meta_kms_impl_get_kms (priv->impl));
|
meta_assert_in_kms_impl (meta_kms_impl_get_kms (priv->impl));
|
||||||
|
|
||||||
return priv->fd;
|
return meta_device_file_get_fd (priv->device_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -646,7 +663,7 @@ meta_kms_impl_device_leak_fd (MetaKmsImplDevice *impl_device)
|
|||||||
MetaKmsImplDevicePrivate *priv =
|
MetaKmsImplDevicePrivate *priv =
|
||||||
meta_kms_impl_device_get_instance_private (impl_device);
|
meta_kms_impl_device_get_instance_private (impl_device);
|
||||||
|
|
||||||
return priv->fd;
|
return meta_device_file_get_fd (priv->device_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaKmsFeedback *
|
MetaKmsFeedback *
|
||||||
@ -676,22 +693,6 @@ meta_kms_impl_device_discard_pending_page_flips (MetaKmsImplDevice *impl_device)
|
|||||||
klass->discard_pending_page_flips (impl_device);
|
klass->discard_pending_page_flips (impl_device);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
meta_kms_impl_device_close (MetaKmsImplDevice *impl_device)
|
|
||||||
{
|
|
||||||
MetaKmsImplDevicePrivate *priv =
|
|
||||||
meta_kms_impl_device_get_instance_private (impl_device);
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
meta_assert_in_kms_impl (meta_kms_impl_get_kms (priv->impl));
|
|
||||||
|
|
||||||
g_clear_pointer (&priv->fd_source, g_source_destroy);
|
|
||||||
fd = priv->fd;
|
|
||||||
priv->fd = -1;
|
|
||||||
|
|
||||||
return fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_kms_impl_device_get_property (GObject *object,
|
meta_kms_impl_device_get_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
@ -710,11 +711,8 @@ meta_kms_impl_device_get_property (GObject *object,
|
|||||||
case PROP_IMPL:
|
case PROP_IMPL:
|
||||||
g_value_set_object (value, priv->impl);
|
g_value_set_object (value, priv->impl);
|
||||||
break;
|
break;
|
||||||
case PROP_FD:
|
case PROP_DEVICE_FILE:
|
||||||
g_value_set_int (value, priv->fd);
|
g_value_set_pointer (value, priv->device_file);
|
||||||
break;
|
|
||||||
case PROP_PATH:
|
|
||||||
g_value_set_string (value, priv->path);
|
|
||||||
break;
|
break;
|
||||||
case PROP_FLAGS:
|
case PROP_FLAGS:
|
||||||
g_value_set_flags (value, priv->flags);
|
g_value_set_flags (value, priv->flags);
|
||||||
@ -749,11 +747,9 @@ meta_kms_impl_device_set_property (GObject *object,
|
|||||||
case PROP_IMPL:
|
case PROP_IMPL:
|
||||||
priv->impl = g_value_get_object (value);
|
priv->impl = g_value_get_object (value);
|
||||||
break;
|
break;
|
||||||
case PROP_FD:
|
case PROP_DEVICE_FILE:
|
||||||
priv->fd = g_value_get_int (value);
|
priv->device_file =
|
||||||
break;
|
meta_device_file_acquire (g_value_get_pointer (value));
|
||||||
case PROP_PATH:
|
|
||||||
priv->path = g_value_dup_string (value);
|
|
||||||
break;
|
break;
|
||||||
case PROP_FLAGS:
|
case PROP_FLAGS:
|
||||||
priv->flags = g_value_get_flags (value);
|
priv->flags = g_value_get_flags (value);
|
||||||
@ -784,6 +780,9 @@ meta_kms_impl_device_finalize (GObject *object)
|
|||||||
g_list_free_full (priv->connectors, g_object_unref);
|
g_list_free_full (priv->connectors, g_object_unref);
|
||||||
g_list_free_full (priv->fallback_modes,
|
g_list_free_full (priv->fallback_modes,
|
||||||
(GDestroyNotify) meta_kms_mode_free);
|
(GDestroyNotify) meta_kms_mode_free);
|
||||||
|
|
||||||
|
g_clear_pointer (&priv->device_file, meta_device_file_release);
|
||||||
|
|
||||||
g_free (priv->driver_name);
|
g_free (priv->driver_name);
|
||||||
g_free (priv->driver_description);
|
g_free (priv->driver_description);
|
||||||
g_free (priv->path);
|
g_free (priv->path);
|
||||||
@ -797,10 +796,13 @@ meta_kms_impl_device_init_mode_setting (MetaKmsImplDevice *impl_device,
|
|||||||
{
|
{
|
||||||
MetaKmsImplDevicePrivate *priv =
|
MetaKmsImplDevicePrivate *priv =
|
||||||
meta_kms_impl_device_get_instance_private (impl_device);
|
meta_kms_impl_device_get_instance_private (impl_device);
|
||||||
|
int fd;
|
||||||
int ret;
|
int ret;
|
||||||
drmModeRes *drm_resources;
|
drmModeRes *drm_resources;
|
||||||
|
|
||||||
ret = drmSetClientCap (priv->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
|
fd = meta_device_file_get_fd (priv->device_file);
|
||||||
|
|
||||||
|
ret = drmSetClientCap (fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (-ret),
|
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (-ret),
|
||||||
@ -809,7 +811,7 @@ meta_kms_impl_device_init_mode_setting (MetaKmsImplDevice *impl_device,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
drm_resources = drmModeGetResources (priv->fd);
|
drm_resources = drmModeGetResources (fd);
|
||||||
if (!drm_resources)
|
if (!drm_resources)
|
||||||
{
|
{
|
||||||
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno),
|
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno),
|
||||||
@ -830,7 +832,8 @@ meta_kms_impl_device_init_mode_setting (MetaKmsImplDevice *impl_device,
|
|||||||
drmModeFreeResources (drm_resources);
|
drmModeFreeResources (drm_resources);
|
||||||
|
|
||||||
priv->fd_source =
|
priv->fd_source =
|
||||||
meta_kms_register_fd_in_impl (meta_kms_impl_get_kms (priv->impl), priv->fd,
|
meta_kms_register_fd_in_impl (meta_kms_impl_get_kms (priv->impl),
|
||||||
|
fd,
|
||||||
kms_event_dispatch_in_impl,
|
kms_event_dispatch_in_impl,
|
||||||
impl_device);
|
impl_device);
|
||||||
|
|
||||||
@ -846,6 +849,18 @@ meta_kms_impl_device_prepare_shutdown (MetaKmsImplDevice *impl_device)
|
|||||||
klass->prepare_shutdown (impl_device);
|
klass->prepare_shutdown (impl_device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_kms_impl_device_constructed (GObject *object)
|
||||||
|
{
|
||||||
|
MetaKmsImplDevice *impl_device = META_KMS_IMPL_DEVICE (object);
|
||||||
|
MetaKmsImplDevicePrivate *priv =
|
||||||
|
meta_kms_impl_device_get_instance_private (impl_device);
|
||||||
|
|
||||||
|
priv->path = g_strdup (meta_device_file_get_path (priv->device_file));
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (meta_kms_impl_device_parent_class)->constructed (object);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_kms_impl_device_init (MetaKmsImplDevice *impl_device)
|
meta_kms_impl_device_init (MetaKmsImplDevice *impl_device)
|
||||||
{
|
{
|
||||||
@ -858,6 +873,7 @@ meta_kms_impl_device_class_init (MetaKmsImplDeviceClass *klass)
|
|||||||
|
|
||||||
object_class->get_property = meta_kms_impl_device_get_property;
|
object_class->get_property = meta_kms_impl_device_get_property;
|
||||||
object_class->set_property = meta_kms_impl_device_set_property;
|
object_class->set_property = meta_kms_impl_device_set_property;
|
||||||
|
object_class->constructed = meta_kms_impl_device_constructed;
|
||||||
object_class->finalize = meta_kms_impl_device_finalize;
|
object_class->finalize = meta_kms_impl_device_finalize;
|
||||||
|
|
||||||
obj_props[PROP_DEVICE] =
|
obj_props[PROP_DEVICE] =
|
||||||
@ -876,22 +892,13 @@ meta_kms_impl_device_class_init (MetaKmsImplDeviceClass *klass)
|
|||||||
G_PARAM_READWRITE |
|
G_PARAM_READWRITE |
|
||||||
G_PARAM_CONSTRUCT_ONLY |
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
G_PARAM_STATIC_STRINGS);
|
G_PARAM_STATIC_STRINGS);
|
||||||
obj_props[PROP_FD] =
|
obj_props[PROP_DEVICE_FILE] =
|
||||||
g_param_spec_int ("fd",
|
g_param_spec_pointer ("device-file",
|
||||||
"fd",
|
"device-file",
|
||||||
"DRM device file descriptor",
|
"Device file",
|
||||||
INT_MIN, INT_MAX, 0,
|
G_PARAM_READWRITE |
|
||||||
G_PARAM_READWRITE |
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
G_PARAM_CONSTRUCT_ONLY |
|
G_PARAM_STATIC_STRINGS);
|
||||||
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_FLAGS] =
|
obj_props[PROP_FLAGS] =
|
||||||
g_param_spec_flags ("flags",
|
g_param_spec_flags ("flags",
|
||||||
"flags",
|
"flags",
|
||||||
|
@ -142,8 +142,6 @@ void meta_kms_impl_device_handle_page_flip_callback (MetaKmsImplDevice *impl_d
|
|||||||
|
|
||||||
void meta_kms_impl_device_discard_pending_page_flips (MetaKmsImplDevice *impl_device);
|
void meta_kms_impl_device_discard_pending_page_flips (MetaKmsImplDevice *impl_device);
|
||||||
|
|
||||||
int meta_kms_impl_device_close (MetaKmsImplDevice *impl_device);
|
|
||||||
|
|
||||||
gboolean meta_kms_impl_device_init_mode_setting (MetaKmsImplDevice *impl_device,
|
gboolean meta_kms_impl_device_init_mode_setting (MetaKmsImplDevice *impl_device,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user