mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
kms/device: Handle tracking capabilities
Devices have capabilities that other parts need to know about. Instead of having them probe using drmMode* API, outsource this to MetaKmsDevice. Currently the only capability tracked is HW cursor size. https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
This commit is contained in:
parent
ae00f5653e
commit
f3cdc9906c
@ -43,6 +43,8 @@ struct _MetaKmsDevice
|
||||
GList *crtcs;
|
||||
GList *connectors;
|
||||
GList *planes;
|
||||
|
||||
MetaKmsDeviceCaps caps;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (MetaKmsDevice, meta_kms_device, G_TYPE_OBJECT);
|
||||
@ -71,6 +73,23 @@ meta_kms_device_get_flags (MetaKmsDevice *device)
|
||||
return device->flags;
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_kms_device_get_cursor_size (MetaKmsDevice *device,
|
||||
uint64_t *out_cursor_width,
|
||||
uint64_t *out_cursor_height)
|
||||
{
|
||||
if (device->caps.has_cursor_size)
|
||||
{
|
||||
*out_cursor_width = device->caps.cursor_width;
|
||||
*out_cursor_height = device->caps.cursor_height;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
GList *
|
||||
meta_kms_device_get_connectors (MetaKmsDevice *device)
|
||||
{
|
||||
@ -211,6 +230,7 @@ typedef struct _CreateImplDeviceData
|
||||
GList *out_crtcs;
|
||||
GList *out_connectors;
|
||||
GList *out_planes;
|
||||
MetaKmsDeviceCaps out_caps;
|
||||
} CreateImplDeviceData;
|
||||
|
||||
static gpointer
|
||||
@ -229,6 +249,7 @@ create_impl_device_in_impl (MetaKmsImpl *impl,
|
||||
data->out_crtcs = meta_kms_impl_device_copy_crtcs (impl_device);
|
||||
data->out_connectors = meta_kms_impl_device_copy_connectors (impl_device);
|
||||
data->out_planes = meta_kms_impl_device_copy_planes (impl_device);
|
||||
data->out_caps = *meta_kms_impl_device_get_caps (impl_device);
|
||||
|
||||
return GINT_TO_POINTER (TRUE);
|
||||
}
|
||||
@ -271,6 +292,7 @@ meta_kms_device_new (MetaKms *kms,
|
||||
device->crtcs = data.out_crtcs;
|
||||
device->connectors = data.out_connectors;
|
||||
device->planes = data.out_planes;
|
||||
device->caps = data.out_caps;
|
||||
|
||||
return device;
|
||||
}
|
||||
|
@ -35,6 +35,10 @@ const char * meta_kms_device_get_path (MetaKmsDevice *device);
|
||||
|
||||
MetaKmsDeviceFlag meta_kms_device_get_flags (MetaKmsDevice *device);
|
||||
|
||||
gboolean meta_kms_device_get_cursor_size (MetaKmsDevice *device,
|
||||
uint64_t *out_cursor_width,
|
||||
uint64_t *out_cursor_height);
|
||||
|
||||
GList * meta_kms_device_get_connectors (MetaKmsDevice *device);
|
||||
|
||||
GList * meta_kms_device_get_crtcs (MetaKmsDevice *device);
|
||||
|
@ -48,6 +48,8 @@ struct _MetaKmsImplDevice
|
||||
GList *crtcs;
|
||||
GList *connectors;
|
||||
GList *planes;
|
||||
|
||||
MetaKmsDeviceCaps caps;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (MetaKmsImplDevice, meta_kms_impl_device, G_TYPE_OBJECT)
|
||||
@ -76,6 +78,12 @@ meta_kms_impl_device_copy_planes (MetaKmsImplDevice *impl_device)
|
||||
return g_list_copy (impl_device->planes);
|
||||
}
|
||||
|
||||
const MetaKmsDeviceCaps *
|
||||
meta_kms_impl_device_get_caps (MetaKmsImplDevice *impl_device)
|
||||
{
|
||||
return &impl_device->caps;
|
||||
}
|
||||
|
||||
static void
|
||||
page_flip_handler (int fd,
|
||||
unsigned int sequence,
|
||||
@ -179,6 +187,21 @@ meta_kms_impl_device_find_property (MetaKmsImplDevice *impl_device,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
init_caps (MetaKmsImplDevice *impl_device)
|
||||
{
|
||||
int fd = impl_device->fd;
|
||||
uint64_t cursor_width, cursor_height;
|
||||
|
||||
if (drmGetCap (fd, DRM_CAP_CURSOR_WIDTH, &cursor_width) == 0 &&
|
||||
drmGetCap (fd, DRM_CAP_CURSOR_HEIGHT, &cursor_height) == 0)
|
||||
{
|
||||
impl_device->caps.has_cursor_size = TRUE;
|
||||
impl_device->caps.cursor_width = cursor_width;
|
||||
impl_device->caps.cursor_height = cursor_height;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
init_crtcs (MetaKmsImplDevice *impl_device,
|
||||
drmModeRes *drm_resources)
|
||||
@ -385,6 +408,8 @@ meta_kms_impl_device_new (MetaKmsDevice *device,
|
||||
impl_device->impl = impl;
|
||||
impl_device->fd = fd;
|
||||
|
||||
init_caps (impl_device);
|
||||
|
||||
init_crtcs (impl_device, drm_resources);
|
||||
init_planes (impl_device);
|
||||
|
||||
|
@ -28,6 +28,13 @@
|
||||
#include "backends/native/meta-kms-types.h"
|
||||
#include "backends/native/meta-kms-update.h"
|
||||
|
||||
typedef struct _MetaKmsDeviceCaps
|
||||
{
|
||||
gboolean has_cursor_size;
|
||||
uint64_t cursor_width;
|
||||
uint64_t cursor_height;
|
||||
} MetaKmsDeviceCaps;
|
||||
|
||||
#define META_TYPE_KMS_IMPL_DEVICE (meta_kms_impl_device_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (MetaKmsImplDevice, meta_kms_impl_device,
|
||||
META, KMS_IMPL_DEVICE,
|
||||
@ -41,6 +48,8 @@ GList * meta_kms_impl_device_copy_crtcs (MetaKmsImplDevice *impl_device);
|
||||
|
||||
GList * meta_kms_impl_device_copy_planes (MetaKmsImplDevice *impl_device);
|
||||
|
||||
const MetaKmsDeviceCaps * meta_kms_impl_device_get_caps (MetaKmsImplDevice *impl_device);
|
||||
|
||||
gboolean meta_kms_impl_device_dispatch (MetaKmsImplDevice *impl_device,
|
||||
GError **error);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user