renderer/native: Refactor modeset boilerplate into new helpers

Extract some boilerplate into new functions for next patch.

No functional change intended.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1561>
This commit is contained in:
Kai-Heng Feng 2020-12-21 14:34:43 +08:00
parent 1fa7176d98
commit 45a9c386bb

View File

@ -1892,6 +1892,48 @@ ensure_crtc_modes (CoglOnscreen *onscreen,
} }
} }
static MetaKmsUpdate *
unset_disabled_crtcs (MetaBackend *backend,
MetaKms *kms)
{
MetaKmsUpdate *kms_update = NULL;
GList *l;
for (l = meta_backend_get_gpus (backend); l; l = l->next)
{
MetaGpu *gpu = l->data;
GList *k;
for (k = meta_gpu_get_crtcs (gpu); k; k = k->next)
{
MetaCrtc *crtc = k->data;
if (meta_crtc_get_config (crtc))
continue;
kms_update = meta_kms_ensure_pending_update (kms);
meta_crtc_kms_set_mode (META_CRTC_KMS (crtc), kms_update);
}
}
return kms_update;
}
static void
post_pending_update (MetaKms *kms)
{
g_autoptr (MetaKmsFeedback) kms_feedback = NULL;
kms_feedback = meta_kms_post_pending_update_sync (kms);
if (meta_kms_feedback_get_result (kms_feedback) != META_KMS_FEEDBACK_PASSED)
{
const GError *error = meta_kms_feedback_get_error (kms_feedback);
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED))
g_warning ("Failed to post KMS update: %s", error->message);
}
}
static void static void
meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen, meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
const int *rectangles, const int *rectangles,
@ -1977,14 +2019,7 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
COGL_TRACE_BEGIN (MetaRendererNativePostKmsUpdate, COGL_TRACE_BEGIN (MetaRendererNativePostKmsUpdate,
"Onscreen (post pending update)"); "Onscreen (post pending update)");
kms_feedback = meta_kms_post_pending_update_sync (kms); post_pending_update (kms);
if (meta_kms_feedback_get_result (kms_feedback) != META_KMS_FEEDBACK_PASSED)
{
const GError *error = meta_kms_feedback_get_error (kms_feedback);
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED))
g_warning ("Failed to post KMS update: %s", error->message);
}
COGL_TRACE_END (MetaRendererNativePostKmsUpdate); COGL_TRACE_END (MetaRendererNativePostKmsUpdate);
} }
@ -3128,41 +3163,12 @@ meta_renderer_native_finish_frame (MetaRendererNative *renderer_native)
if (renderer_native->pending_unset_disabled_crtcs) if (renderer_native->pending_unset_disabled_crtcs)
{ {
GList *l; kms_update = unset_disabled_crtcs (backend, kms);
for (l = meta_backend_get_gpus (backend); l; l = l->next)
{
MetaGpu *gpu = l->data;
GList *k;
for (k = meta_gpu_get_crtcs (gpu); k; k = k->next)
{
MetaCrtc *crtc = k->data;
if (meta_crtc_get_config (crtc))
continue;
kms_update = meta_kms_ensure_pending_update (kms);
meta_crtc_kms_set_mode (META_CRTC_KMS (crtc), kms_update);
}
}
renderer_native->pending_unset_disabled_crtcs = FALSE; renderer_native->pending_unset_disabled_crtcs = FALSE;
} }
if (kms_update) if (kms_update)
{ post_pending_update (kms);
g_autoptr (MetaKmsFeedback) kms_feedback = NULL;
kms_feedback = meta_kms_post_pending_update_sync (kms);
if (meta_kms_feedback_get_result (kms_feedback) != META_KMS_FEEDBACK_PASSED)
{
const GError *error = meta_kms_feedback_get_error (kms_feedback);
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED))
g_warning ("Failed to post KMS update: %s", error->message);
}
}
} }
static gboolean static gboolean