diff --git a/src/backends/native/meta-kms-crtc-private.h b/src/backends/native/meta-kms-crtc-private.h index 5429989bf..9e2937a3b 100644 --- a/src/backends/native/meta-kms-crtc-private.h +++ b/src/backends/native/meta-kms-crtc-private.h @@ -22,7 +22,7 @@ #include -#include "backends/native/meta-kms-types.h" +#include "backends/native/meta-kms-crtc.h" typedef enum _MetaKmsCrtcProp { diff --git a/src/backends/native/meta-kms-device.c b/src/backends/native/meta-kms-device.c index 4179c623c..5849eebba 100644 --- a/src/backends/native/meta-kms-device.c +++ b/src/backends/native/meta-kms-device.c @@ -26,6 +26,7 @@ #include #include "backends/native/meta-backend-native.h" +#include "backends/native/meta-kms-impl-device-simple.h" #include "backends/native/meta-kms-impl-device.h" #include "backends/native/meta-kms-impl.h" #include "backends/native/meta-kms-plane.h" @@ -254,7 +255,7 @@ meta_create_kms_impl_device (MetaKmsDevice *device, return NULL; } - return g_initable_new (META_TYPE_KMS_IMPL_DEVICE, NULL, error, + return g_initable_new (META_TYPE_KMS_IMPL_DEVICE_SIMPLE, NULL, error, "device", device, "impl", impl, "fd", fd, diff --git a/src/backends/native/meta-kms-impl-simple.c b/src/backends/native/meta-kms-impl-device-simple.c similarity index 70% rename from src/backends/native/meta-kms-impl-simple.c rename to src/backends/native/meta-kms-impl-device-simple.c index 9d5fcccd9..58924f227 100644 --- a/src/backends/native/meta-kms-impl-simple.c +++ b/src/backends/native/meta-kms-impl-device-simple.c @@ -1,6 +1,5 @@ /* - * Copyright (C) 2018-2019 Red Hat - * Copyright (C) 2019-2020 DisplayLink (UK) Ltd. + * Copyright (C) 2019-2020 Red Hat * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -20,17 +19,12 @@ #include "config.h" -#include "backends/native/meta-kms-impl-simple.h" - -#include -#include -#include +#include "backends/native/meta-kms-impl-device-simple.h" #include "backends/native/meta-kms-connector-private.h" -#include "backends/native/meta-kms-crtc.h" +#include "backends/native/meta-kms-crtc-private.h" #include "backends/native/meta-kms-device-private.h" -#include "backends/native/meta-kms-mode.h" -#include "backends/native/meta-kms-page-flip-private.h" +#include "backends/native/meta-kms-mode-private.h" #include "backends/native/meta-kms-plane-private.h" #include "backends/native/meta-kms-private.h" #include "backends/native/meta-kms-update-private.h" @@ -42,9 +36,9 @@ typedef struct _CachedModeSet drmModeModeInfo *drm_mode; } CachedModeSet; -struct _MetaKmsImplSimple +struct _MetaKmsImplDeviceSimple { - MetaKmsImpl parent; + MetaKmsImplDevice parent; GSource *mode_set_fallback_feedback_source; GList *mode_set_fallback_page_flip_datas; @@ -58,29 +52,26 @@ struct _MetaKmsImplSimple GHashTable *cached_mode_sets; }; -G_DEFINE_TYPE (MetaKmsImplSimple, meta_kms_impl_simple, - META_TYPE_KMS_IMPL) +static GInitableIface *initable_parent_iface; static void -flush_postponed_page_flip_datas (MetaKmsImplSimple *impl_simple); +initable_iface_init (GInitableIface *iface); -MetaKmsImplSimple * -meta_kms_impl_simple_new (MetaKms *kms, - GError **error) -{ - return g_object_new (META_TYPE_KMS_IMPL_SIMPLE, - "kms", kms, - NULL); -} +G_DEFINE_TYPE_WITH_CODE (MetaKmsImplDeviceSimple, meta_kms_impl_device_simple, + META_TYPE_KMS_IMPL_DEVICE, + G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, + initable_iface_init)) + +static void +flush_postponed_page_flip_datas (MetaKmsImplDeviceSimple *impl_device_simple); static gboolean -set_connector_property (MetaKmsConnector *connector, +set_connector_property (MetaKmsImplDevice *impl_device, + MetaKmsConnector *connector, MetaKmsConnectorProp prop, uint64_t value, GError **error) { - MetaKmsDevice *device = meta_kms_connector_get_device (connector); - MetaKmsImplDevice *impl_device = meta_kms_device_get_impl_device (device); uint32_t prop_id; int fd; int ret; @@ -116,17 +107,18 @@ set_connector_property (MetaKmsConnector *connector, } static gboolean -process_connector_update (MetaKmsImpl *impl, - MetaKmsUpdate *update, - gpointer update_entry, - GError **error) +process_connector_update (MetaKmsImplDevice *impl_device, + MetaKmsUpdate *update, + gpointer update_entry, + GError **error) { MetaKmsConnectorUpdate *connector_update = update_entry; MetaKmsConnector *connector = connector_update->connector; if (connector_update->dpms.has_update) { - if (!set_connector_property (connector, + if (!set_connector_property (impl_device, + connector, META_KMS_CONNECTOR_PROP_DPMS, connector_update->dpms.state, error)) @@ -136,17 +128,20 @@ process_connector_update (MetaKmsImpl *impl, if (connector_update->underscanning.has_update && connector_update->underscanning.is_active) { - if (!set_connector_property (connector, + if (!set_connector_property (impl_device, + connector, META_KMS_CONNECTOR_PROP_UNDERSCAN, 1, error)) return FALSE; - if (!set_connector_property (connector, + if (!set_connector_property (impl_device, + connector, META_KMS_CONNECTOR_PROP_UNDERSCAN_HBORDER, connector_update->underscanning.hborder, error)) return FALSE; - if (!set_connector_property (connector, + if (!set_connector_property (impl_device, + connector, META_KMS_CONNECTOR_PROP_UNDERSCAN_VBORDER, connector_update->underscanning.vborder, error)) @@ -154,7 +149,8 @@ process_connector_update (MetaKmsImpl *impl, } else if (connector_update->underscanning.has_update) { - if (!set_connector_property (connector, + if (!set_connector_property (impl_device, + connector, META_KMS_CONNECTOR_PROP_UNDERSCAN, 0, error)) @@ -207,13 +203,11 @@ fill_connector_ids_array (GList *connectors, } static gboolean -set_plane_rotation (MetaKmsImpl *impl, - MetaKmsPlane *plane, - uint64_t rotation, - GError **error) +set_plane_rotation (MetaKmsImplDevice *impl_device, + MetaKmsPlane *plane, + uint64_t rotation, + GError **error) { - MetaKmsDevice *device = meta_kms_plane_get_device (plane); - MetaKmsImplDevice *impl_device = meta_kms_device_get_impl_device (device); int fd; uint32_t rotation_prop_id; int ret; @@ -243,16 +237,15 @@ set_plane_rotation (MetaKmsImpl *impl, } static gboolean -process_mode_set (MetaKmsImpl *impl, - MetaKmsUpdate *update, - gpointer update_entry, - GError **error) +process_mode_set (MetaKmsImplDevice *impl_device, + MetaKmsUpdate *update, + gpointer update_entry, + GError **error) { + MetaKmsImplDeviceSimple *impl_device_simple = + META_KMS_IMPL_DEVICE_SIMPLE (impl_device); MetaKmsModeSet *mode_set = update_entry; - MetaKmsImplSimple *impl_simple = META_KMS_IMPL_SIMPLE (impl); MetaKmsCrtc *crtc = mode_set->crtc; - MetaKmsDevice *device = meta_kms_crtc_get_device (crtc); - MetaKmsImplDevice *impl_device = meta_kms_device_get_impl_device (device); g_autofree uint32_t *connectors = NULL; int n_connectors; MetaKmsPlaneAssignment *plane_assignment; @@ -288,7 +281,7 @@ process_mode_set (MetaKmsImpl *impl, if (plane_assignment->rotation) { - if (!set_plane_rotation (impl, + if (!set_plane_rotation (impl_device, plane_assignment->plane, plane_assignment->rotation, error)) @@ -325,29 +318,27 @@ process_mode_set (MetaKmsImpl *impl, if (drm_mode) { - g_hash_table_replace (impl_simple->cached_mode_sets, + g_hash_table_replace (impl_device_simple->cached_mode_sets, crtc, cached_mode_set_new (mode_set->connectors, drm_mode)); } else { - g_hash_table_remove (impl_simple->cached_mode_sets, crtc); + g_hash_table_remove (impl_device_simple->cached_mode_sets, crtc); } return TRUE; } static gboolean -process_crtc_gamma (MetaKmsImpl *impl, - MetaKmsUpdate *update, - gpointer update_entry, - GError **error) +process_crtc_gamma (MetaKmsImplDevice *impl_device, + MetaKmsUpdate *update, + gpointer update_entry, + GError **error) { MetaKmsCrtcGamma *gamma = update_entry; MetaKmsCrtc *crtc = gamma->crtc; - MetaKmsDevice *device = meta_kms_crtc_get_device (crtc); - MetaKmsImplDevice *impl_device = meta_kms_device_get_impl_device (device); int fd; int ret; @@ -398,43 +389,44 @@ retry_page_flip_data_free (RetryPageFlipData *retry_page_flip_data) } static CachedModeSet * -get_cached_mode_set (MetaKmsImplSimple *impl_simple, - MetaKmsCrtc *crtc) +get_cached_mode_set (MetaKmsImplDeviceSimple *impl_device_simple, + MetaKmsCrtc *crtc) { - return g_hash_table_lookup (impl_simple->cached_mode_sets, crtc); + return g_hash_table_lookup (impl_device_simple->cached_mode_sets, crtc); } static float -get_cached_crtc_refresh_rate (MetaKmsImplSimple *impl_simple, - MetaKmsCrtc *crtc) +get_cached_crtc_refresh_rate (MetaKmsImplDeviceSimple *impl_device_simple, + MetaKmsCrtc *crtc) { CachedModeSet *cached_mode_set; - cached_mode_set = g_hash_table_lookup (impl_simple->cached_mode_sets, + cached_mode_set = g_hash_table_lookup (impl_device_simple->cached_mode_sets, crtc); g_assert (cached_mode_set); return meta_calculate_drm_mode_refresh_rate (cached_mode_set->drm_mode); } +#define meta_assert_in_kms_impl(kms) \ + g_assert (meta_kms_in_impl_task (kms)) + static gboolean retry_page_flips (gpointer user_data) { - MetaKmsImplSimple *impl_simple = META_KMS_IMPL_SIMPLE (user_data); + MetaKmsImplDeviceSimple *impl_device_simple = + META_KMS_IMPL_DEVICE_SIMPLE (user_data); + MetaKmsImplDevice *impl_device = META_KMS_IMPL_DEVICE (impl_device_simple); uint64_t now_us; GList *l; - meta_assert_in_kms_impl (meta_kms_impl_get_kms (META_KMS_IMPL (impl_simple))); + now_us = g_source_get_time (impl_device_simple->retry_page_flips_source); - now_us = g_source_get_time (impl_simple->retry_page_flips_source); - - l = impl_simple->pending_page_flip_retries; + l = impl_device_simple->pending_page_flip_retries; while (l) { RetryPageFlipData *retry_page_flip_data = l->data; MetaKmsCrtc *crtc = retry_page_flip_data->crtc; - MetaKmsDevice *device = meta_kms_crtc_get_device (crtc); - MetaKmsImplDevice *impl_device = meta_kms_device_get_impl_device (device); GList *l_next = l->next; int fd; int ret; @@ -468,15 +460,16 @@ retry_page_flips (gpointer user_data) { float refresh_rate; - refresh_rate = get_cached_crtc_refresh_rate (impl_simple, crtc); + refresh_rate = + get_cached_crtc_refresh_rate (impl_device_simple, crtc); retry_page_flip_data->retry_time_us += (uint64_t) (G_USEC_PER_SEC / refresh_rate); l = l_next; continue; } - impl_simple->pending_page_flip_retries = - g_list_remove_link (impl_simple->pending_page_flip_retries, l); + impl_device_simple->pending_page_flip_retries = + g_list_remove_link (impl_device_simple->pending_page_flip_retries, l); page_flip_data = g_steal_pointer (&retry_page_flip_data->page_flip_data); if (ret != 0) @@ -500,38 +493,38 @@ retry_page_flips (gpointer user_data) l = l_next; } - if (impl_simple->pending_page_flip_retries) + if (impl_device_simple->pending_page_flip_retries) { GList *l; uint64_t earliest_retry_time_us = 0; - for (l = impl_simple->pending_page_flip_retries; l; l = l->next) + for (l = impl_device_simple->pending_page_flip_retries; l; l = l->next) { RetryPageFlipData *retry_page_flip_data = l->data; - if (l == impl_simple->pending_page_flip_retries || + if (l == impl_device_simple->pending_page_flip_retries || is_timestamp_earlier_than (retry_page_flip_data->retry_time_us, earliest_retry_time_us)) earliest_retry_time_us = retry_page_flip_data->retry_time_us; } - g_source_set_ready_time (impl_simple->retry_page_flips_source, + g_source_set_ready_time (impl_device_simple->retry_page_flips_source, earliest_retry_time_us); return G_SOURCE_CONTINUE; } else { - g_clear_pointer (&impl_simple->retry_page_flips_source, + g_clear_pointer (&impl_device_simple->retry_page_flips_source, g_source_unref); - flush_postponed_page_flip_datas (impl_simple); + flush_postponed_page_flip_datas (impl_device_simple); return G_SOURCE_REMOVE; } } static void -schedule_retry_page_flip (MetaKmsImplSimple *impl_simple, +schedule_retry_page_flip (MetaKmsImplDeviceSimple *impl_device_simple, MetaKmsCrtc *crtc, uint32_t fb_id, float refresh_rate, @@ -557,22 +550,25 @@ schedule_retry_page_flip (MetaKmsImplSimple *impl_simple, .custom_page_flip_user_data = custom_page_flip_user_data, }; - if (!impl_simple->retry_page_flips_source) + if (!impl_device_simple->retry_page_flips_source) { - MetaKms *kms = meta_kms_impl_get_kms (META_KMS_IMPL (impl_simple)); + MetaKmsImplDevice *impl_device = + META_KMS_IMPL_DEVICE (impl_device_simple); + MetaKmsDevice *device = meta_kms_impl_device_get_device (impl_device); + MetaKms *kms = meta_kms_device_get_kms (device); GSource *source; source = meta_kms_add_source_in_impl (kms, retry_page_flips, - impl_simple, NULL); + impl_device_simple, NULL); g_source_set_ready_time (source, retry_time_us); - impl_simple->retry_page_flips_source = source; + impl_device_simple->retry_page_flips_source = source; } else { GList *l; - for (l = impl_simple->pending_page_flip_retries; l; l = l->next) + for (l = impl_device_simple->pending_page_flip_retries; l; l = l->next) { RetryPageFlipData *pending_retry_page_flip_data = l->data; uint64_t pending_retry_time_us = @@ -580,15 +576,15 @@ schedule_retry_page_flip (MetaKmsImplSimple *impl_simple, if (is_timestamp_earlier_than (retry_time_us, pending_retry_time_us)) { - g_source_set_ready_time (impl_simple->retry_page_flips_source, + g_source_set_ready_time (impl_device_simple->retry_page_flips_source, retry_time_us); break; } } } - impl_simple->pending_page_flip_retries = - g_list_append (impl_simple->pending_page_flip_retries, + impl_device_simple->pending_page_flip_retries = + g_list_append (impl_device_simple->pending_page_flip_retries, retry_page_flip_data); } @@ -610,38 +606,38 @@ clear_page_flip_datas (GList **page_flip_datas) static gboolean mode_set_fallback_feedback_idle (gpointer user_data) { - MetaKmsImplSimple *impl_simple = user_data; + MetaKmsImplDeviceSimple *impl_device_simple = user_data; - g_clear_pointer (&impl_simple->mode_set_fallback_feedback_source, + g_clear_pointer (&impl_device_simple->mode_set_fallback_feedback_source, g_source_unref); - if (impl_simple->pending_page_flip_retries) + if (impl_device_simple->pending_page_flip_retries) { - impl_simple->postponed_mode_set_fallback_datas = - g_steal_pointer (&impl_simple->mode_set_fallback_page_flip_datas); + impl_device_simple->postponed_mode_set_fallback_datas = + g_steal_pointer (&impl_device_simple->mode_set_fallback_page_flip_datas); } else { - invoke_page_flip_datas (impl_simple->mode_set_fallback_page_flip_datas, + invoke_page_flip_datas (impl_device_simple->mode_set_fallback_page_flip_datas, meta_kms_page_flip_data_mode_set_fallback_in_impl); - clear_page_flip_datas (&impl_simple->mode_set_fallback_page_flip_datas); + clear_page_flip_datas (&impl_device_simple->mode_set_fallback_page_flip_datas); } return G_SOURCE_REMOVE; } static gboolean -mode_set_fallback (MetaKmsImplSimple *impl_simple, - MetaKmsUpdate *update, - MetaKmsPageFlip *page_flip, - MetaKmsPlaneAssignment *plane_assignment, - MetaKmsPageFlipData *page_flip_data, - GError **error) +mode_set_fallback (MetaKmsImplDeviceSimple *impl_device_simple, + MetaKmsUpdate *update, + MetaKmsPageFlip *page_flip, + MetaKmsPlaneAssignment *plane_assignment, + MetaKmsPageFlipData *page_flip_data, + GError **error) { - MetaKms *kms = meta_kms_impl_get_kms (META_KMS_IMPL (impl_simple)); + MetaKmsImplDevice *impl_device = META_KMS_IMPL_DEVICE (impl_device_simple); + MetaKmsDevice *device = meta_kms_impl_device_get_device (impl_device); + MetaKms *kms = meta_kms_device_get_kms (device); MetaKmsCrtc *crtc = page_flip->crtc; - MetaKmsDevice *device = meta_kms_crtc_get_device (crtc); - MetaKmsImplDevice *impl_device = meta_kms_device_get_impl_device (device); CachedModeSet *cached_mode_set; g_autofree uint32_t *connectors = NULL; int n_connectors; @@ -649,7 +645,7 @@ mode_set_fallback (MetaKmsImplSimple *impl_simple, int fd; int ret; - cached_mode_set = g_hash_table_lookup (impl_simple->cached_mode_sets, + cached_mode_set = g_hash_table_lookup (impl_device_simple->cached_mode_sets, crtc); if (!cached_mode_set) { @@ -682,35 +678,34 @@ mode_set_fallback (MetaKmsImplSimple *impl_simple, return FALSE; } - if (!impl_simple->mode_set_fallback_feedback_source) + if (!impl_device_simple->mode_set_fallback_feedback_source) { GSource *source; source = meta_kms_add_source_in_impl (kms, mode_set_fallback_feedback_idle, - impl_simple, + impl_device_simple, NULL); - impl_simple->mode_set_fallback_feedback_source = source; + impl_device_simple->mode_set_fallback_feedback_source = source; } - impl_simple->mode_set_fallback_page_flip_datas = - g_list_prepend (impl_simple->mode_set_fallback_page_flip_datas, + impl_device_simple->mode_set_fallback_page_flip_datas = + g_list_prepend (impl_device_simple->mode_set_fallback_page_flip_datas, meta_kms_page_flip_data_ref (page_flip_data)); return TRUE; } static gboolean -process_page_flip (MetaKmsImpl *impl, - MetaKmsUpdate *update, - gpointer update_entry, - GError **error) +process_page_flip (MetaKmsImplDevice *impl_device, + MetaKmsUpdate *update, + gpointer update_entry, + GError **error) { + MetaKmsImplDeviceSimple *impl_device_simple = + META_KMS_IMPL_DEVICE_SIMPLE (impl_device); MetaKmsPageFlip *page_flip = update_entry; - MetaKmsImplSimple *impl_simple = META_KMS_IMPL_SIMPLE (impl); MetaKmsCrtc *crtc; - MetaKmsDevice *device; - MetaKmsImplDevice *impl_device; MetaKmsPlaneAssignment *plane_assignment; MetaKmsPageFlipData *page_flip_data; MetaKmsCustomPageFlipFunc custom_page_flip_func; @@ -721,13 +716,11 @@ process_page_flip (MetaKmsImpl *impl, plane_assignment = meta_kms_update_get_primary_plane_assignment (update, crtc); - page_flip_data = meta_kms_page_flip_data_new (impl, + page_flip_data = meta_kms_page_flip_data_new (impl_device, crtc, page_flip->feedback, page_flip->user_data); - device = meta_kms_crtc_get_device (crtc); - impl_device = meta_kms_device_get_impl_device (device); fd = meta_kms_impl_device_get_fd (impl_device); custom_page_flip_func = page_flip->custom_page_flip_func; if (custom_page_flip_func) @@ -751,7 +744,7 @@ process_page_flip (MetaKmsImpl *impl, { CachedModeSet *cached_mode_set; - cached_mode_set = get_cached_mode_set (impl_simple, crtc); + cached_mode_set = get_cached_mode_set (impl_device_simple, crtc); if (cached_mode_set) { drmModeModeInfo *drm_mode; @@ -759,7 +752,7 @@ process_page_flip (MetaKmsImpl *impl, drm_mode = cached_mode_set->drm_mode; refresh_rate = meta_calculate_drm_mode_refresh_rate (drm_mode); - schedule_retry_page_flip (impl_simple, + schedule_retry_page_flip (impl_device_simple, crtc, plane_assignment ? plane_assignment->fb_id : 0, @@ -779,7 +772,7 @@ process_page_flip (MetaKmsImpl *impl, } else if (ret == -EINVAL) { - if (!mode_set_fallback (impl_simple, + if (!mode_set_fallback (impl_device_simple, update, page_flip, plane_assignment, @@ -805,15 +798,15 @@ process_page_flip (MetaKmsImpl *impl, } static void -discard_page_flip (MetaKmsImpl *impl, - MetaKmsUpdate *update, - MetaKmsPageFlip *page_flip) +discard_page_flip (MetaKmsImplDevice *impl_device, + MetaKmsUpdate *update, + MetaKmsPageFlip *page_flip) { MetaKmsCrtc *crtc; MetaKmsPageFlipData *page_flip_data; crtc = page_flip->crtc; - page_flip_data = meta_kms_page_flip_data_new (impl, + page_flip_data = meta_kms_page_flip_data_new (impl_device, crtc, page_flip->feedback, page_flip->user_data); @@ -822,20 +815,20 @@ discard_page_flip (MetaKmsImpl *impl, } static gboolean -process_entries (MetaKmsImpl *impl, - MetaKmsUpdate *update, - GList *entries, - gboolean (* func) (MetaKmsImpl *impl, - MetaKmsUpdate *update, - gpointer entry_data, - GError **error), - GError **error) +process_entries (MetaKmsImplDevice *impl_device, + MetaKmsUpdate *update, + GList *entries, + gboolean (* func) (MetaKmsImplDevice *impl_device, + MetaKmsUpdate *update, + gpointer entry_data, + GError **error), + GError **error) { GList *l; for (l = entries; l; l = l->next) { - if (!func (impl, update, l->data, error)) + if (!func (impl_device, update, l->data, error)) return FALSE; } @@ -843,19 +836,15 @@ process_entries (MetaKmsImpl *impl, } static gboolean -process_cursor_plane_assignment (MetaKmsImpl *impl, +process_cursor_plane_assignment (MetaKmsImplDevice *impl_device, MetaKmsUpdate *update, MetaKmsPlaneAssignment *plane_assignment, GError **error) { - MetaKmsPlane *plane; - MetaKmsDevice *device; - MetaKmsImplDevice *impl_device; + uint32_t crtc_id; int fd; - plane = plane_assignment->plane; - device = meta_kms_plane_get_device (plane); - impl_device = meta_kms_device_get_impl_device (device); + crtc_id = meta_kms_crtc_get_id (plane_assignment->crtc), fd = meta_kms_impl_device_get_fd (impl_device); if (!(plane_assignment->flags & META_KMS_ASSIGN_PLANE_FLAG_FB_UNCHANGED)) @@ -868,7 +857,8 @@ process_cursor_plane_assignment (MetaKmsImpl *impl, if (plane_assignment->cursor_hotspot.is_valid) { - ret = drmModeSetCursor2 (fd, meta_kms_crtc_get_id (plane_assignment->crtc), + ret = drmModeSetCursor2 (fd, + crtc_id, plane_assignment->fb_id, width, height, plane_assignment->cursor_hotspot.x, @@ -877,7 +867,7 @@ process_cursor_plane_assignment (MetaKmsImpl *impl, if (ret != 0) { - ret = drmModeSetCursor (fd, meta_kms_crtc_get_id (plane_assignment->crtc), + ret = drmModeSetCursor (fd, crtc_id, plane_assignment->fb_id, width, height); } @@ -891,7 +881,7 @@ process_cursor_plane_assignment (MetaKmsImpl *impl, } drmModeMoveCursor (fd, - meta_kms_crtc_get_id (plane_assignment->crtc), + crtc_id, meta_fixed_16_to_int (plane_assignment->dst_rect.x), meta_fixed_16_to_int (plane_assignment->dst_rect.y)); @@ -899,7 +889,7 @@ process_cursor_plane_assignment (MetaKmsImpl *impl, } static gboolean -process_plane_assignment (MetaKmsImpl *impl, +process_plane_assignment (MetaKmsImplDevice *impl_device, MetaKmsUpdate *update, MetaKmsPlaneAssignment *plane_assignment, MetaKmsPlaneFeedback **plane_feedback) @@ -916,7 +906,7 @@ process_plane_assignment (MetaKmsImpl *impl, /* Handled as part of the mode-set and page flip. */ return TRUE; case META_KMS_PLANE_TYPE_CURSOR: - if (!process_cursor_plane_assignment (impl, update, + if (!process_cursor_plane_assignment (impl_device, update, plane_assignment, &error)) { @@ -944,8 +934,8 @@ process_plane_assignment (MetaKmsImpl *impl, } static GList * -process_plane_assignments (MetaKmsImpl *impl, - MetaKmsUpdate *update) +process_plane_assignments (MetaKmsImplDevice *impl_device, + MetaKmsUpdate *update) { GList *failed_planes = NULL; GList *l; @@ -955,7 +945,7 @@ process_plane_assignments (MetaKmsImpl *impl, MetaKmsPlaneAssignment *plane_assignment = l->data; MetaKmsPlaneFeedback *plane_feedback; - if (!process_plane_assignment (impl, update, plane_assignment, + if (!process_plane_assignment (impl_device, update, plane_assignment, &plane_feedback)) failed_planes = g_list_prepend (failed_planes, plane_feedback); } @@ -1000,37 +990,35 @@ generate_all_failed_feedbacks (MetaKmsUpdate *update) } static MetaKmsFeedback * -meta_kms_impl_simple_process_update (MetaKmsImpl *impl, - MetaKmsUpdate *update) +meta_kms_impl_device_simple_process_update (MetaKmsImplDevice *impl_device, + MetaKmsUpdate *update) { GError *error = NULL; GList *failed_planes; GList *l; - meta_assert_in_kms_impl (meta_kms_impl_get_kms (impl)); - - if (!process_entries (impl, + if (!process_entries (impl_device, update, meta_kms_update_get_connector_updates (update), process_connector_update, &error)) goto err_planes_not_assigned; - if (!process_entries (impl, + if (!process_entries (impl_device, update, meta_kms_update_get_mode_sets (update), process_mode_set, &error)) goto err_planes_not_assigned; - if (!process_entries (impl, + if (!process_entries (impl_device, update, meta_kms_update_get_crtc_gammas (update), process_crtc_gamma, &error)) goto err_planes_not_assigned; - failed_planes = process_plane_assignments (impl, update); + failed_planes = process_plane_assignments (impl_device, update); if (failed_planes) { g_set_error (&error, G_IO_ERROR, G_IO_ERROR_FAILED, @@ -1038,7 +1026,7 @@ meta_kms_impl_simple_process_update (MetaKmsImpl *impl, goto err_planes_assigned; } - if (!process_entries (impl, + if (!process_entries (impl_device, update, meta_kms_update_get_page_flips (update), process_page_flip, @@ -1058,34 +1046,35 @@ err_planes_assigned: if (page_flip->flags & META_KMS_PAGE_FLIP_FLAG_NO_DISCARD_FEEDBACK) continue; - discard_page_flip (impl, update, page_flip); + discard_page_flip (impl_device, update, page_flip); } return meta_kms_feedback_new_failed (failed_planes, error); } static void -flush_postponed_page_flip_datas (MetaKmsImplSimple *impl_simple) +flush_postponed_page_flip_datas (MetaKmsImplDeviceSimple *impl_device_simple) { - invoke_page_flip_datas (impl_simple->postponed_page_flip_datas, + invoke_page_flip_datas (impl_device_simple->postponed_page_flip_datas, meta_kms_page_flip_data_flipped_in_impl); - clear_page_flip_datas (&impl_simple->postponed_page_flip_datas); + clear_page_flip_datas (&impl_device_simple->postponed_page_flip_datas); - invoke_page_flip_datas (impl_simple->postponed_mode_set_fallback_datas, + invoke_page_flip_datas (impl_device_simple->postponed_mode_set_fallback_datas, meta_kms_page_flip_data_mode_set_fallback_in_impl); - clear_page_flip_datas (&impl_simple->postponed_mode_set_fallback_datas); + clear_page_flip_datas (&impl_device_simple->postponed_mode_set_fallback_datas); } static void -meta_kms_impl_simple_handle_page_flip_callback (MetaKmsImpl *impl, - MetaKmsPageFlipData *page_flip_data) +meta_kms_impl_device_simple_handle_page_flip_callback (MetaKmsImplDevice *impl_device, + MetaKmsPageFlipData *page_flip_data) { - MetaKmsImplSimple *impl_simple = META_KMS_IMPL_SIMPLE (impl); + MetaKmsImplDeviceSimple *impl_device_simple = + META_KMS_IMPL_DEVICE_SIMPLE (impl_device); - if (impl_simple->pending_page_flip_retries) + if (impl_device_simple->pending_page_flip_retries) { - impl_simple->postponed_page_flip_datas = - g_list_append (impl_simple->postponed_page_flip_datas, + impl_device_simple->postponed_page_flip_datas = + g_list_append (impl_device_simple->postponed_page_flip_datas, meta_kms_page_flip_data_ref (page_flip_data)); } else @@ -1097,15 +1086,16 @@ meta_kms_impl_simple_handle_page_flip_callback (MetaKmsImpl *impl, } static void -meta_kms_impl_simple_discard_pending_page_flips (MetaKmsImpl *impl) +meta_kms_impl_device_simple_discard_pending_page_flips (MetaKmsImplDevice *impl_device) { - MetaKmsImplSimple *impl_simple = META_KMS_IMPL_SIMPLE (impl); + MetaKmsImplDeviceSimple *impl_device_simple = + META_KMS_IMPL_DEVICE_SIMPLE (impl_device); GList *l; - if (!impl_simple->pending_page_flip_retries) + if (!impl_device_simple->pending_page_flip_retries) return; - for (l = impl_simple->pending_page_flip_retries; l; l = l->next) + for (l = impl_device_simple->pending_page_flip_retries; l; l = l->next) { RetryPageFlipData *retry_page_flip_data = l->data; MetaKmsPageFlipData *page_flip_data; @@ -1114,18 +1104,52 @@ meta_kms_impl_simple_discard_pending_page_flips (MetaKmsImpl *impl) meta_kms_page_flip_data_discard_in_impl (page_flip_data, NULL); retry_page_flip_data_free (retry_page_flip_data); } - g_clear_pointer (&impl_simple->pending_page_flip_retries, g_list_free); + g_clear_pointer (&impl_device_simple->pending_page_flip_retries, g_list_free); - g_clear_pointer (&impl_simple->retry_page_flips_source, + g_clear_pointer (&impl_device_simple->retry_page_flips_source, g_source_destroy); } static void -meta_kms_impl_simple_notify_device_created (MetaKmsImpl *impl, - MetaKmsDevice *device) +meta_kms_impl_device_simple_finalize (GObject *object) { + MetaKmsImplDeviceSimple *impl_device_simple = + META_KMS_IMPL_DEVICE_SIMPLE (object); + + g_list_free_full (impl_device_simple->pending_page_flip_retries, + (GDestroyNotify) retry_page_flip_data_free); + g_list_free_full (impl_device_simple->postponed_page_flip_datas, + (GDestroyNotify) meta_kms_page_flip_data_unref); + g_list_free_full (impl_device_simple->postponed_mode_set_fallback_datas, + (GDestroyNotify) meta_kms_page_flip_data_unref); + + g_clear_pointer (&impl_device_simple->mode_set_fallback_feedback_source, + g_source_destroy); + g_hash_table_destroy (impl_device_simple->cached_mode_sets); + + G_OBJECT_CLASS (meta_kms_impl_device_simple_parent_class)->finalize (object); +} + +static gboolean +meta_kms_impl_device_simple_initable_init (GInitable *initable, + GCancellable *cancellable, + GError **error) +{ + MetaKmsImplDeviceSimple *impl_device_simple = + META_KMS_IMPL_DEVICE_SIMPLE (initable); + MetaKmsImplDevice *impl_device = META_KMS_IMPL_DEVICE (impl_device_simple); + MetaKmsDevice *device = meta_kms_impl_device_get_device (impl_device); GList *l; + if (!initable_parent_iface->init (initable, cancellable, error)) + return FALSE; + + impl_device_simple->cached_mode_sets = + g_hash_table_new_full (NULL, + NULL, + NULL, + (GDestroyNotify) cached_mode_set_free); + for (l = meta_kms_device_get_crtcs (device); l; l = l->next) { MetaKmsCrtc *crtc = l->data; @@ -1139,46 +1163,36 @@ meta_kms_impl_simple_notify_device_created (MetaKmsImpl *impl, META_KMS_PLANE_TYPE_CURSOR, crtc); } + + return TRUE; } static void -meta_kms_impl_simple_finalize (GObject *object) +meta_kms_impl_device_simple_init (MetaKmsImplDeviceSimple *impl_device_simple) { - MetaKmsImplSimple *impl_simple = META_KMS_IMPL_SIMPLE (object); - - g_list_free_full (impl_simple->pending_page_flip_retries, - (GDestroyNotify) retry_page_flip_data_free); - g_list_free_full (impl_simple->postponed_page_flip_datas, - (GDestroyNotify) meta_kms_page_flip_data_unref); - g_list_free_full (impl_simple->postponed_mode_set_fallback_datas, - (GDestroyNotify) meta_kms_page_flip_data_unref); - g_clear_pointer (&impl_simple->mode_set_fallback_feedback_source, - g_source_destroy); - g_hash_table_destroy (impl_simple->cached_mode_sets); - - G_OBJECT_CLASS (meta_kms_impl_simple_parent_class)->finalize (object); } static void -meta_kms_impl_simple_init (MetaKmsImplSimple *impl_simple) +initable_iface_init (GInitableIface *iface) { - impl_simple->cached_mode_sets = - g_hash_table_new_full (NULL, - NULL, - NULL, - (GDestroyNotify) cached_mode_set_free); + initable_parent_iface = g_type_interface_peek_parent (iface); + + iface->init = meta_kms_impl_device_simple_initable_init; } static void -meta_kms_impl_simple_class_init (MetaKmsImplSimpleClass *klass) +meta_kms_impl_device_simple_class_init (MetaKmsImplDeviceSimpleClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - MetaKmsImplClass *impl_class = META_KMS_IMPL_CLASS (klass); + MetaKmsImplDeviceClass *impl_device_class = + META_KMS_IMPL_DEVICE_CLASS (klass); - object_class->finalize = meta_kms_impl_simple_finalize; + object_class->finalize = meta_kms_impl_device_simple_finalize; - impl_class->process_update = meta_kms_impl_simple_process_update; - impl_class->handle_page_flip_callback = meta_kms_impl_simple_handle_page_flip_callback; - impl_class->discard_pending_page_flips = meta_kms_impl_simple_discard_pending_page_flips; - impl_class->notify_device_created = meta_kms_impl_simple_notify_device_created; + impl_device_class->process_update = + meta_kms_impl_device_simple_process_update; + impl_device_class->handle_page_flip_callback = + meta_kms_impl_device_simple_handle_page_flip_callback; + impl_device_class->discard_pending_page_flips = + meta_kms_impl_device_simple_discard_pending_page_flips; } diff --git a/src/backends/native/meta-kms-impl-simple.h b/src/backends/native/meta-kms-impl-device-simple.h similarity index 60% rename from src/backends/native/meta-kms-impl-simple.h rename to src/backends/native/meta-kms-impl-device-simple.h index e2cf6296e..7be5f0a83 100644 --- a/src/backends/native/meta-kms-impl-simple.h +++ b/src/backends/native/meta-kms-impl-device-simple.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Red Hat + * Copyright (C) 2018-2020 Red Hat * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -17,16 +17,13 @@ * 02111-1307, USA. */ -#ifndef META_KMS_IMPL_SIMPLE_H -#define META_KMS_IMPL_SIMPLE_H +#ifndef META_KMS_IMPL_DEVICE_SIMPLE_H +#define META_KMS_IMPL_DEVICE_SIMPLE_H -#include "backends/native/meta-kms-impl.h" +#include "backends/native/meta-kms-impl-device.h" -#define META_TYPE_KMS_IMPL_SIMPLE meta_kms_impl_simple_get_type () -G_DECLARE_FINAL_TYPE (MetaKmsImplSimple, meta_kms_impl_simple, - META, KMS_IMPL_SIMPLE, MetaKmsImpl) +#define META_TYPE_KMS_IMPL_DEVICE_SIMPLE (meta_kms_impl_device_simple_get_type ()) +G_DECLARE_FINAL_TYPE (MetaKmsImplDeviceSimple, meta_kms_impl_device_simple, + META, KMS_IMPL_DEVICE_SIMPLE, MetaKmsImplDevice) -MetaKmsImplSimple * meta_kms_impl_simple_new (MetaKms *kms, - GError **error); - -#endif /* META_KMS_IMPL_SIMPLE_H */ +#endif /* META_KMS_IMPL_DEVICE_SIMPLE_H */ diff --git a/src/backends/native/meta-kms-impl-device.c b/src/backends/native/meta-kms-impl-device.c index 3581f2aae..c0989ec58 100644 --- a/src/backends/native/meta-kms-impl-device.c +++ b/src/backends/native/meta-kms-impl-device.c @@ -80,6 +80,10 @@ G_DEFINE_TYPE_WITH_CODE (MetaKmsImplDevice, meta_kms_impl_device, G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, initable_iface_init)) +static void +meta_kms_impl_device_handle_page_flip_callback (MetaKmsImplDevice *impl_device, + MetaKmsPageFlipData *page_flip_data); + MetaKmsDevice * meta_kms_impl_device_get_device (MetaKmsImplDevice *impl_device) { @@ -160,13 +164,13 @@ page_flip_handler (int fd, void *user_data) { MetaKmsPageFlipData *page_flip_data = user_data; - MetaKmsImpl *impl; + MetaKmsImplDevice *impl_device; meta_kms_page_flip_data_set_timings_in_impl (page_flip_data, sequence, sec, usec); - impl = meta_kms_page_flip_data_get_kms_impl (page_flip_data); - meta_kms_impl_handle_page_flip_callback (impl, page_flip_data); + impl_device = meta_kms_page_flip_data_get_impl_device (page_flip_data); + meta_kms_impl_device_handle_page_flip_callback (impl_device, page_flip_data); } gboolean @@ -626,6 +630,32 @@ meta_kms_impl_device_leak_fd (MetaKmsImplDevice *impl_device) return priv->fd; } +MetaKmsFeedback * +meta_kms_impl_device_process_update (MetaKmsImplDevice *impl_device, + MetaKmsUpdate *update) +{ + MetaKmsImplDeviceClass *klass = META_KMS_IMPL_DEVICE_GET_CLASS (impl_device); + + return klass->process_update (impl_device, update); +} + +static void +meta_kms_impl_device_handle_page_flip_callback (MetaKmsImplDevice *impl_device, + MetaKmsPageFlipData *page_flip_data) +{ + MetaKmsImplDeviceClass *klass = META_KMS_IMPL_DEVICE_GET_CLASS (impl_device); + + klass->handle_page_flip_callback (impl_device, page_flip_data); +} + +void +meta_kms_impl_device_discard_pending_page_flips (MetaKmsImplDevice *impl_device) +{ + MetaKmsImplDeviceClass *klass = META_KMS_IMPL_DEVICE_GET_CLASS (impl_device); + + klass->discard_pending_page_flips (impl_device); +} + int meta_kms_impl_device_close (MetaKmsImplDevice *impl_device) { diff --git a/src/backends/native/meta-kms-impl-device.h b/src/backends/native/meta-kms-impl-device.h index 003a2a721..e712e47e0 100644 --- a/src/backends/native/meta-kms-impl-device.h +++ b/src/backends/native/meta-kms-impl-device.h @@ -25,6 +25,7 @@ #include #include "backends/native/meta-kms-device.h" +#include "backends/native/meta-kms-page-flip-private.h" #include "backends/native/meta-kms-types.h" #include "backends/native/meta-kms-update.h" @@ -58,6 +59,12 @@ G_DECLARE_DERIVABLE_TYPE (MetaKmsImplDevice, meta_kms_impl_device, struct _MetaKmsImplDeviceClass { GObjectClass parent_class; + + MetaKmsFeedback * (* process_update) (MetaKmsImplDevice *impl, + MetaKmsUpdate *update); + void (* handle_page_flip_callback) (MetaKmsImplDevice *impl, + MetaKmsPageFlipData *page_flip_data); + void (* discard_pending_page_flips) (MetaKmsImplDevice *impl); }; MetaKmsDevice * meta_kms_impl_device_get_device (MetaKmsImplDevice *impl_device); @@ -105,6 +112,11 @@ void meta_kms_impl_device_init_prop_table (MetaKmsImplDevice *impl_device, int n_props, gpointer user_data); +MetaKmsFeedback * meta_kms_impl_device_process_update (MetaKmsImplDevice *impl_device, + MetaKmsUpdate *update); + +void meta_kms_impl_device_discard_pending_page_flips (MetaKmsImplDevice *impl_device); + int meta_kms_impl_device_close (MetaKmsImplDevice *impl_device); #endif /* META_KMS_IMPL_DEVICE_H */ diff --git a/src/backends/native/meta-kms-impl.c b/src/backends/native/meta-kms-impl.c index 29faf932b..87fe45492 100644 --- a/src/backends/native/meta-kms-impl.c +++ b/src/backends/native/meta-kms-impl.c @@ -23,6 +23,8 @@ #include "backends/native/meta-kms-impl.h" #include "backends/native/meta-kms-private.h" +#include "backends/native/meta-kms-device-private.h" +#include "backends/native/meta-kms-update-private.h" enum { @@ -31,6 +33,11 @@ enum PROP_KMS, }; +struct _MetaKmsImpl +{ + GObject parent; +}; + typedef struct _MetaKmsImplPrivate { MetaKms *kms; @@ -38,7 +45,7 @@ typedef struct _MetaKmsImplPrivate GList *impl_devices; } MetaKmsImplPrivate; -G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaKmsImpl, meta_kms_impl, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (MetaKmsImpl, meta_kms_impl, G_TYPE_OBJECT) MetaKms * meta_kms_impl_get_kms (MetaKmsImpl *impl) @@ -74,28 +81,34 @@ MetaKmsFeedback * meta_kms_impl_process_update (MetaKmsImpl *impl, MetaKmsUpdate *update) { - return META_KMS_IMPL_GET_CLASS (impl)->process_update (impl, update); -} + MetaKmsImplPrivate *priv = meta_kms_impl_get_instance_private (impl); + MetaKmsDevice *device; + MetaKmsImplDevice *impl_device; -void -meta_kms_impl_handle_page_flip_callback (MetaKmsImpl *impl, - MetaKmsPageFlipData *page_flip_data) -{ - META_KMS_IMPL_GET_CLASS (impl)->handle_page_flip_callback (impl, - page_flip_data); + meta_assert_in_kms_impl (priv->kms); + + device = meta_kms_update_get_device (update); + impl_device = meta_kms_device_get_impl_device (device); + + return meta_kms_impl_device_process_update (impl_device, update); } void meta_kms_impl_discard_pending_page_flips (MetaKmsImpl *impl) { - META_KMS_IMPL_GET_CLASS (impl)->discard_pending_page_flips (impl); + MetaKmsImplPrivate *priv = meta_kms_impl_get_instance_private (impl); + + g_list_foreach (priv->impl_devices, + (GFunc) meta_kms_impl_device_discard_pending_page_flips, + NULL); } -void -meta_kms_impl_notify_device_created (MetaKmsImpl *impl, - MetaKmsDevice *device) +MetaKmsImpl * +meta_kms_impl_new (MetaKms *kms) { - META_KMS_IMPL_GET_CLASS (impl)->notify_device_created (impl, device); + return g_object_new (META_TYPE_KMS_IMPL, + "kms", kms, + NULL); } static void diff --git a/src/backends/native/meta-kms-impl.h b/src/backends/native/meta-kms-impl.h index 11498a795..372f47721 100644 --- a/src/backends/native/meta-kms-impl.h +++ b/src/backends/native/meta-kms-impl.h @@ -26,21 +26,8 @@ #include "backends/native/meta-kms.h" #define META_TYPE_KMS_IMPL (meta_kms_impl_get_type ()) -G_DECLARE_DERIVABLE_TYPE (MetaKmsImpl, meta_kms_impl, - META, KMS_IMPL, GObject) - -struct _MetaKmsImplClass -{ - GObjectClass parent_class; - - MetaKmsFeedback * (* process_update) (MetaKmsImpl *impl, - MetaKmsUpdate *update); - void (* handle_page_flip_callback) (MetaKmsImpl *impl, - MetaKmsPageFlipData *page_flip_data); - void (* discard_pending_page_flips) (MetaKmsImpl *impl); - void (* notify_device_created) (MetaKmsImpl *impl, - MetaKmsDevice *impl_device); -}; +G_DECLARE_FINAL_TYPE (MetaKmsImpl, meta_kms_impl, + META, KMS_IMPL, GObject) MetaKms * meta_kms_impl_get_kms (MetaKmsImpl *impl); @@ -53,12 +40,8 @@ void meta_kms_impl_add_impl_device (MetaKmsImpl *impl, void meta_kms_impl_remove_impl_device (MetaKmsImpl *impl, MetaKmsImplDevice *impl_device); -void meta_kms_impl_handle_page_flip_callback (MetaKmsImpl *impl, - MetaKmsPageFlipData *page_flip_data); - void meta_kms_impl_discard_pending_page_flips (MetaKmsImpl *impl); -void meta_kms_impl_notify_device_created (MetaKmsImpl *impl, - MetaKmsDevice *impl_device); +MetaKmsImpl * meta_kms_impl_new (MetaKms *kms); #endif /* META_KMS_IMPL_H */ diff --git a/src/backends/native/meta-kms-page-flip-private.h b/src/backends/native/meta-kms-page-flip-private.h index ef8faf7ad..2bb6e8b50 100644 --- a/src/backends/native/meta-kms-page-flip-private.h +++ b/src/backends/native/meta-kms-page-flip-private.h @@ -28,7 +28,7 @@ typedef struct _MetaKmsPageFlipData MetaKmsPageFlipData; typedef void (* MetaPageFlipDataFeedbackFunc) (MetaKmsPageFlipData *page_flip_data); -MetaKmsPageFlipData * meta_kms_page_flip_data_new (MetaKmsImpl *impl, +MetaKmsPageFlipData * meta_kms_page_flip_data_new (MetaKmsImplDevice *impl_device, MetaKmsCrtc *crtc, const MetaKmsPageFlipFeedback *feedback, gpointer user_data); @@ -37,7 +37,7 @@ MetaKmsPageFlipData * meta_kms_page_flip_data_ref (MetaKmsPageFlipData *page_fli void meta_kms_page_flip_data_unref (MetaKmsPageFlipData *page_flip_data); -MetaKmsImpl * meta_kms_page_flip_data_get_kms_impl (MetaKmsPageFlipData *page_flip_data); +MetaKmsImplDevice * meta_kms_page_flip_data_get_impl_device (MetaKmsPageFlipData *page_flip_data); void meta_kms_page_flip_data_set_timings_in_impl (MetaKmsPageFlipData *page_flip_data, unsigned int sequence, diff --git a/src/backends/native/meta-kms-page-flip.c b/src/backends/native/meta-kms-page-flip.c index 997c3fca5..45222892c 100644 --- a/src/backends/native/meta-kms-page-flip.c +++ b/src/backends/native/meta-kms-page-flip.c @@ -29,7 +29,7 @@ struct _MetaKmsPageFlipData { int ref_count; - MetaKmsImpl *impl; + MetaKmsImplDevice *impl_device; MetaKmsCrtc *crtc; const MetaKmsPageFlipFeedback *feedback; @@ -43,7 +43,7 @@ struct _MetaKmsPageFlipData }; MetaKmsPageFlipData * -meta_kms_page_flip_data_new (MetaKmsImpl *impl, +meta_kms_page_flip_data_new (MetaKmsImplDevice *impl_device, MetaKmsCrtc *crtc, const MetaKmsPageFlipFeedback *feedback, gpointer user_data) @@ -53,7 +53,7 @@ meta_kms_page_flip_data_new (MetaKmsImpl *impl, page_flip_data = g_new0 (MetaKmsPageFlipData , 1); *page_flip_data = (MetaKmsPageFlipData) { .ref_count = 1, - .impl = impl, + .impl_device = impl_device, .crtc = crtc, .feedback = feedback, .user_data = user_data, @@ -82,10 +82,10 @@ meta_kms_page_flip_data_unref (MetaKmsPageFlipData *page_flip_data) } } -MetaKmsImpl * -meta_kms_page_flip_data_get_kms_impl (MetaKmsPageFlipData *page_flip_data) +MetaKmsImplDevice * +meta_kms_page_flip_data_get_impl_device (MetaKmsPageFlipData *page_flip_data) { - return page_flip_data->impl; + return page_flip_data->impl_device; } static void @@ -103,13 +103,21 @@ meta_kms_page_flip_data_flipped (MetaKms *kms, page_flip_data->user_data); } +static MetaKms * +meta_kms_from_impl_device (MetaKmsImplDevice *impl_device) +{ + MetaKmsDevice *device = meta_kms_impl_device_get_device (impl_device); + + return meta_kms_device_get_kms (device); +} + void meta_kms_page_flip_data_set_timings_in_impl (MetaKmsPageFlipData *page_flip_data, unsigned int sequence, unsigned int sec, unsigned int usec) { - MetaKms *kms = meta_kms_impl_get_kms (page_flip_data->impl); + MetaKms *kms = meta_kms_from_impl_device (page_flip_data->impl_device); meta_assert_in_kms_impl (kms); @@ -121,7 +129,7 @@ meta_kms_page_flip_data_set_timings_in_impl (MetaKmsPageFlipData *page_flip_data void meta_kms_page_flip_data_flipped_in_impl (MetaKmsPageFlipData *page_flip_data) { - MetaKms *kms = meta_kms_impl_get_kms (page_flip_data->impl); + MetaKms *kms = meta_kms_from_impl_device (page_flip_data->impl_device); meta_assert_in_kms_impl (kms); @@ -146,7 +154,7 @@ meta_kms_page_flip_data_mode_set_fallback (MetaKms *kms, void meta_kms_page_flip_data_mode_set_fallback_in_impl (MetaKmsPageFlipData *page_flip_data) { - MetaKms *kms = meta_kms_impl_get_kms (page_flip_data->impl); + MetaKms *kms = meta_kms_from_impl_device (page_flip_data->impl_device); meta_assert_in_kms_impl (kms); @@ -182,7 +190,7 @@ void meta_kms_page_flip_data_discard_in_impl (MetaKmsPageFlipData *page_flip_data, const GError *error) { - MetaKms *kms = meta_kms_impl_get_kms (page_flip_data->impl); + MetaKms *kms = meta_kms_from_impl_device (page_flip_data->impl_device); meta_assert_in_kms_impl (kms); diff --git a/src/backends/native/meta-kms.c b/src/backends/native/meta-kms.c index 1a7afe2ad..f658dda1f 100644 --- a/src/backends/native/meta-kms.c +++ b/src/backends/native/meta-kms.c @@ -25,7 +25,6 @@ #include "backends/native/meta-backend-native.h" #include "backends/native/meta-kms-device-private.h" #include "backends/native/meta-kms-impl.h" -#include "backends/native/meta-kms-impl-simple.h" #include "backends/native/meta-kms-update-private.h" #include "backends/native/meta-udev.h" #include "cogl/cogl.h" @@ -103,15 +102,7 @@ * * #MetaKmsImpl: * - * The KMS backend implementation, running in the impl context. #MetaKmsImpl - * itself is an abstract object, with potentially multiple implementations. - * Currently only #MetaKmsImplSimple exists. - * - * #MetaKmsImplSimple: - * - * A KMS backend implementation using the non-atomic drmMode* API. While it's - * interacted with using the transactional API, the #MetaKmsUpdate is processed - * non-atomically. + * The KMS impl context object, managing things in the impl context. * * #MetaKmsImplDevice: * @@ -119,6 +110,9 @@ * context. It takes care of the updating of the various KMS object (CRTC, * connector, ..) states. * + * This is an abstract type, with currently #MetaKmsImplDeviceSimple, + * implementing mode setting and page flipping using legacy DRM API. + * * #MetaKmsPageFlip: * * A object representing a page flip. It's created when a page flip is queued, @@ -590,18 +584,6 @@ meta_kms_get_backend (MetaKms *kms) return kms->backend; } -static gpointer -notify_device_created_in_impl (MetaKmsImpl *impl, - gpointer user_data, - GError **error) -{ - MetaKmsDevice *device = user_data; - - meta_kms_impl_notify_device_created (impl, device); - - return GINT_TO_POINTER (TRUE); -} - MetaKmsDevice * meta_kms_create_device (MetaKms *kms, const char *path, @@ -614,9 +596,6 @@ meta_kms_create_device (MetaKms *kms, if (!device) return NULL; - meta_kms_run_impl_task_sync (kms, notify_device_created_in_impl, - device, NULL); - kms->devices = g_list_append (kms->devices, device); return device; @@ -632,7 +611,7 @@ meta_kms_new (MetaBackend *backend, kms = g_object_new (META_TYPE_KMS, NULL); kms->backend = backend; - kms->impl = META_KMS_IMPL (meta_kms_impl_simple_new (kms, error)); + kms->impl = meta_kms_impl_new (kms); if (!kms->impl) { g_object_unref (kms); diff --git a/src/meson.build b/src/meson.build index 097c73984..1dcddde3f 100644 --- a/src/meson.build +++ b/src/meson.build @@ -678,10 +678,10 @@ if have_native_backend 'backends/native/meta-kms-device-private.h', 'backends/native/meta-kms-device.c', 'backends/native/meta-kms-device.h', + 'backends/native/meta-kms-impl-device-simple.c', + 'backends/native/meta-kms-impl-device-simple.h', 'backends/native/meta-kms-impl-device.c', 'backends/native/meta-kms-impl-device.h', - 'backends/native/meta-kms-impl-simple.c', - 'backends/native/meta-kms-impl-simple.h', 'backends/native/meta-kms-impl.c', 'backends/native/meta-kms-impl.h', 'backends/native/meta-kms-mode.c',