diff --git a/src/backends/native/meta-crtc-kms.c b/src/backends/native/meta-crtc-kms.c index 02da38136..17264b38a 100644 --- a/src/backends/native/meta-crtc-kms.c +++ b/src/backends/native/meta-crtc-kms.c @@ -176,7 +176,7 @@ meta_crtc_kms_set_mode (MetaCrtcKms *crtc_kms, MetaCrtc *crtc = META_CRTC (crtc_kms); MetaGpu *gpu = meta_crtc_get_gpu (crtc); GList *connectors; - const drmModeModeInfo *mode; + MetaKmsMode *kms_mode; connectors = generate_crtc_connector_list (gpu, crtc); @@ -184,17 +184,15 @@ meta_crtc_kms_set_mode (MetaCrtcKms *crtc_kms, { const MetaCrtcConfig *crtc_config = meta_crtc_get_config (crtc); MetaCrtcModeKms *crtc_mode_kms = META_CRTC_MODE_KMS (crtc_config->mode); - MetaKmsMode *kms_mode; kms_mode = meta_crtc_mode_kms_get_kms_mode (crtc_mode_kms); - mode = meta_kms_mode_get_drm_mode (kms_mode); g_debug ("Setting CRTC (%" G_GUINT64_FORMAT ") mode to %s", - meta_crtc_get_id (crtc), mode->name); + meta_crtc_get_id (crtc), meta_kms_mode_get_name (kms_mode)); } else { - mode = NULL; + kms_mode = NULL; g_debug ("Unsetting CRTC (%" G_GUINT64_FORMAT ") mode", meta_crtc_get_id (crtc)); @@ -203,7 +201,7 @@ meta_crtc_kms_set_mode (MetaCrtcKms *crtc_kms, meta_kms_update_mode_set (kms_update, meta_crtc_kms_get_kms_crtc (crtc_kms), g_steal_pointer (&connectors), - mode); + kms_mode); } void diff --git a/src/backends/native/meta-kms-crtc.c b/src/backends/native/meta-kms-crtc.c index ebdd8ed9d..0040ee340 100644 --- a/src/backends/native/meta-kms-crtc.c +++ b/src/backends/native/meta-kms-crtc.c @@ -24,6 +24,7 @@ #include "backends/native/meta-kms-device-private.h" #include "backends/native/meta-kms-impl-device.h" +#include "backends/native/meta-kms-mode.h" #include "backends/native/meta-kms-update-private.h" struct _MetaKmsCrtc @@ -168,17 +169,19 @@ meta_kms_crtc_predict_state (MetaKmsCrtc *crtc, if (mode_set->crtc != crtc) continue; - if (mode_set->drm_mode) + if (mode_set->mode) { MetaKmsPlaneAssignment *plane_assignment; + const drmModeModeInfo *drm_mode; plane_assignment = meta_kms_update_get_primary_plane_assignment (update, crtc); + drm_mode = meta_kms_mode_get_drm_mode (mode_set->mode); crtc->current_state.rect = meta_fixed_16_rectangle_to_rectangle (plane_assignment->src_rect); crtc->current_state.is_drm_mode_valid = TRUE; - crtc->current_state.drm_mode = *mode_set->drm_mode; + crtc->current_state.drm_mode = *drm_mode; } else { diff --git a/src/backends/native/meta-kms-impl-simple.c b/src/backends/native/meta-kms-impl-simple.c index 1afc89f74..7bcdb489f 100644 --- a/src/backends/native/meta-kms-impl-simple.c +++ b/src/backends/native/meta-kms-impl-simple.c @@ -29,6 +29,7 @@ #include "backends/native/meta-kms-connector.h" #include "backends/native/meta-kms-crtc.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-plane.h" #include "backends/native/meta-kms-private.h" @@ -192,6 +193,7 @@ process_mode_set (MetaKmsImpl *impl, g_autofree uint32_t *connectors = NULL; int n_connectors; MetaKmsPlaneAssignment *plane_assignment; + drmModeModeInfo *drm_mode; uint32_t x, y; uint32_t fb_id; int fd; @@ -199,10 +201,13 @@ process_mode_set (MetaKmsImpl *impl, crtc = mode_set->crtc; - if (mode_set->drm_mode) + if (mode_set->mode) { GList *l; + drm_mode = g_alloca (sizeof *drm_mode); + *drm_mode = *meta_kms_mode_get_drm_mode (mode_set->mode); + fill_connector_ids_array (mode_set->connectors, &connectors, &n_connectors); @@ -233,6 +238,7 @@ process_mode_set (MetaKmsImpl *impl, } else { + drm_mode = NULL; x = y = 0; n_connectors = 0; connectors = NULL; @@ -245,23 +251,23 @@ process_mode_set (MetaKmsImpl *impl, fb_id, x, y, connectors, n_connectors, - mode_set->drm_mode); + drm_mode); if (ret != 0) { g_set_error (error, G_IO_ERROR, g_io_error_from_errno (-ret), "Failed to set mode %s on CRTC %u: %s", - mode_set->drm_mode ? mode_set->drm_mode->name : "off", + drm_mode ? drm_mode->name : "off", meta_kms_crtc_get_id (crtc), g_strerror (-ret)); return FALSE; } - if (mode_set->drm_mode) + if (drm_mode) { g_hash_table_replace (impl_simple->cached_mode_sets, crtc, cached_mode_set_new (mode_set->connectors, - mode_set->drm_mode)); + drm_mode)); } else { diff --git a/src/backends/native/meta-kms-update-private.h b/src/backends/native/meta-kms-update-private.h index df886b8dd..f3d3419d2 100644 --- a/src/backends/native/meta-kms-update-private.h +++ b/src/backends/native/meta-kms-update-private.h @@ -63,7 +63,7 @@ typedef struct _MetaKmsModeSet { MetaKmsCrtc *crtc; GList *connectors; - drmModeModeInfo *drm_mode; + MetaKmsMode *mode; } MetaKmsModeSet; typedef struct _MetaKmsConnectorProperty diff --git a/src/backends/native/meta-kms-update.c b/src/backends/native/meta-kms-update.c index 94dd23e2c..1cdbef1b7 100644 --- a/src/backends/native/meta-kms-update.c +++ b/src/backends/native/meta-kms-update.c @@ -23,6 +23,7 @@ #include "backends/native/meta-kms-update-private.h" #include "backends/meta-display-config-shared.h" +#include "backends/native/meta-kms-mode-private.h" #include "backends/native/meta-kms-plane.h" struct _MetaKmsUpdate @@ -149,7 +150,6 @@ meta_kms_plane_assignment_free (MetaKmsPlaneAssignment *plane_assignment) static void meta_kms_mode_set_free (MetaKmsModeSet *mode_set) { - g_free (mode_set->drm_mode); g_list_free (mode_set->connectors); g_free (mode_set); } @@ -208,10 +208,10 @@ meta_kms_update_unassign_plane (MetaKmsUpdate *update, } void -meta_kms_update_mode_set (MetaKmsUpdate *update, - MetaKmsCrtc *crtc, - GList *connectors, - const drmModeModeInfo *drm_mode) +meta_kms_update_mode_set (MetaKmsUpdate *update, + MetaKmsCrtc *crtc, + GList *connectors, + MetaKmsMode *mode) { MetaKmsModeSet *mode_set; @@ -221,7 +221,7 @@ meta_kms_update_mode_set (MetaKmsUpdate *update, *mode_set = (MetaKmsModeSet) { .crtc = crtc, .connectors = connectors, - .drm_mode = drm_mode ? g_memdup (drm_mode, sizeof *drm_mode) : NULL, + .mode = mode, }; update->mode_sets = g_list_prepend (update->mode_sets, mode_set); diff --git a/src/backends/native/meta-kms-update.h b/src/backends/native/meta-kms-update.h index 0684ad181..5d2b6ef7f 100644 --- a/src/backends/native/meta-kms-update.h +++ b/src/backends/native/meta-kms-update.h @@ -85,10 +85,10 @@ MetaKmsUpdate * meta_kms_update_new (void); void meta_kms_update_free (MetaKmsUpdate *update); -void meta_kms_update_mode_set (MetaKmsUpdate *update, - MetaKmsCrtc *crtc, - GList *connectors, - const drmModeModeInfo *drm_mode); +void meta_kms_update_mode_set (MetaKmsUpdate *update, + MetaKmsCrtc *crtc, + GList *connectors, + MetaKmsMode *mode); MetaKmsPlaneAssignment * meta_kms_update_assign_plane (MetaKmsUpdate *update, MetaKmsCrtc *crtc,