From d6dc403fa8b0e96684575cc5e81add3f72a6688f Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 10 Jan 2024 14:37:13 +0100 Subject: [PATCH] backends/native: Move KmsUpdate plane assignment to OnscreenNative Part-of: --- src/backends/native/meta-crtc-kms.c | 72 ++----------------- src/backends/native/meta-crtc-kms.h | 8 +-- src/backends/native/meta-onscreen-native.c | 84 +++++++++++++++++++--- 3 files changed, 83 insertions(+), 81 deletions(-) diff --git a/src/backends/native/meta-crtc-kms.c b/src/backends/native/meta-crtc-kms.c index 336060d9b..6d4a8bfc4 100644 --- a/src/backends/native/meta-crtc-kms.c +++ b/src/backends/native/meta-crtc-kms.c @@ -356,78 +356,18 @@ meta_crtc_kms_is_hw_cursor_supported (MetaCrtcNative *crtc_native) return meta_kms_device_has_cursor_plane_for (kms_device, kms_crtc); } -void -meta_crtc_kms_apply_transform (MetaCrtcKms *crtc_kms, - MetaKmsPlaneAssignment *kms_plane_assignment) -{ - MetaCrtc *crtc = META_CRTC (crtc_kms); - const MetaCrtcConfig *crtc_config; - MetaMonitorTransform hw_transform; - - crtc_config = meta_crtc_get_config (crtc); - - hw_transform = crtc_config->transform; - if (!is_transform_handled (crtc_kms, hw_transform)) - hw_transform = META_MONITOR_TRANSFORM_NORMAL; - if (!is_transform_handled (crtc_kms, hw_transform)) - return; - - meta_kms_plane_update_set_rotation (crtc_kms->assigned_primary_plane, - kms_plane_assignment, - hw_transform); -} - -MetaKmsPlaneAssignment * -meta_crtc_kms_assign_primary_plane (MetaCrtcKms *crtc_kms, - MetaDrmBuffer *buffer, - MetaKmsUpdate *kms_update, - MetaKmsAssignPlaneFlag flags) -{ - MetaCrtc *crtc = META_CRTC (crtc_kms); - const MetaCrtcConfig *crtc_config; - const MetaCrtcModeInfo *crtc_mode_info; - MetaFixed16Rectangle src_rect; - MtkRectangle dst_rect; - MetaKmsCrtc *kms_crtc; - MetaKmsPlane *primary_kms_plane; - MetaKmsPlaneAssignment *plane_assignment; - - crtc_config = meta_crtc_get_config (crtc); - crtc_mode_info = meta_crtc_mode_get_info (crtc_config->mode); - - src_rect = (MetaFixed16Rectangle) { - .x = meta_fixed_16_from_int (0), - .y = meta_fixed_16_from_int (0), - .width = meta_fixed_16_from_int (crtc_mode_info->width), - .height = meta_fixed_16_from_int (crtc_mode_info->height), - }; - dst_rect = (MtkRectangle) { - .x = 0, - .y = 0, - .width = crtc_mode_info->width, - .height = crtc_mode_info->height, - }; - - kms_crtc = meta_crtc_kms_get_kms_crtc (crtc_kms); - primary_kms_plane = crtc_kms->assigned_primary_plane; - plane_assignment = meta_kms_update_assign_plane (kms_update, - kms_crtc, - primary_kms_plane, - buffer, - src_rect, - dst_rect, - flags); - meta_crtc_kms_apply_transform (crtc_kms, plane_assignment); - - return plane_assignment; -} - MetaKmsPlane * meta_crtc_kms_get_assigned_cursor_plane (MetaCrtcKms *crtc_kms) { return crtc_kms->assigned_cursor_plane; } +MetaKmsPlane * +meta_crtc_kms_get_assigned_primary_plane (MetaCrtcKms *crtc_kms) +{ + return crtc_kms->assigned_primary_plane; +} + static GList * generate_crtc_connector_list (MetaGpu *gpu, MetaCrtc *crtc) diff --git a/src/backends/native/meta-crtc-kms.h b/src/backends/native/meta-crtc-kms.h index 2df420e73..3d024123c 100644 --- a/src/backends/native/meta-crtc-kms.h +++ b/src/backends/native/meta-crtc-kms.h @@ -37,13 +37,7 @@ G_DECLARE_FINAL_TYPE (MetaCrtcKms, meta_crtc_kms, META, CRTC_KMS, MetaCrtcNative) -void meta_crtc_kms_apply_transform (MetaCrtcKms *crtc_kms, - MetaKmsPlaneAssignment *kms_plane_assignment); - -MetaKmsPlaneAssignment * meta_crtc_kms_assign_primary_plane (MetaCrtcKms *crtc_kms, - MetaDrmBuffer *buffer, - MetaKmsUpdate *kms_update, - MetaKmsAssignPlaneFlag flags); +MetaKmsPlane * meta_crtc_kms_get_assigned_primary_plane (MetaCrtcKms *crtc_kms); MetaKmsPlane * meta_crtc_kms_get_assigned_cursor_plane (MetaCrtcKms *crtc_kms); diff --git a/src/backends/native/meta-onscreen-native.c b/src/backends/native/meta-onscreen-native.c index 1888e0481..0caf20358 100644 --- a/src/backends/native/meta-onscreen-native.c +++ b/src/backends/native/meta-onscreen-native.c @@ -41,6 +41,7 @@ #include "backends/native/meta-frame-native.h" #include "backends/native/meta-kms-connector.h" #include "backends/native/meta-kms-device.h" +#include "backends/native/meta-kms-plane.h" #include "backends/native/meta-kms-utils.h" #include "backends/native/meta-kms.h" #include "backends/native/meta-output-kms.h" @@ -411,6 +412,73 @@ meta_onscreen_native_dummy_power_save_page_flip (CoglOnscreen *onscreen) meta_onscreen_native_notify_frame_complete (onscreen); } +static void +apply_transform (MetaCrtcKms *crtc_kms, + MetaKmsPlaneAssignment *kms_plane_assignment, + MetaKmsPlane *kms_plane) +{ + MetaCrtc *crtc = META_CRTC (crtc_kms); + const MetaCrtcConfig *crtc_config; + MetaMonitorTransform hw_transform; + + crtc_config = meta_crtc_get_config (crtc); + + hw_transform = crtc_config->transform; + if (!meta_kms_plane_is_transform_handled (kms_plane, hw_transform)) + hw_transform = META_MONITOR_TRANSFORM_NORMAL; + if (!meta_kms_plane_is_transform_handled (kms_plane, hw_transform)) + return; + + meta_kms_plane_update_set_rotation (kms_plane, + kms_plane_assignment, + hw_transform); +} + +static MetaKmsPlaneAssignment * +assign_primary_plane (MetaCrtcKms *crtc_kms, + MetaDrmBuffer *buffer, + MetaKmsUpdate *kms_update, + MetaKmsAssignPlaneFlag flags) +{ + MetaCrtc *crtc = META_CRTC (crtc_kms); + const MetaCrtcConfig *crtc_config; + const MetaCrtcModeInfo *crtc_mode_info; + MetaFixed16Rectangle src_rect; + MtkRectangle dst_rect; + MetaKmsCrtc *kms_crtc; + MetaKmsPlane *primary_kms_plane; + MetaKmsPlaneAssignment *plane_assignment; + + crtc_config = meta_crtc_get_config (crtc); + crtc_mode_info = meta_crtc_mode_get_info (crtc_config->mode); + + src_rect = (MetaFixed16Rectangle) { + .x = meta_fixed_16_from_int (0), + .y = meta_fixed_16_from_int (0), + .width = meta_fixed_16_from_int (crtc_mode_info->width), + .height = meta_fixed_16_from_int (crtc_mode_info->height), + }; + dst_rect = (MtkRectangle) { + .x = 0, + .y = 0, + .width = crtc_mode_info->width, + .height = crtc_mode_info->height, + }; + + kms_crtc = meta_crtc_kms_get_kms_crtc (crtc_kms); + primary_kms_plane = meta_crtc_kms_get_assigned_primary_plane (crtc_kms); + plane_assignment = meta_kms_update_assign_plane (kms_update, + kms_crtc, + primary_kms_plane, + buffer, + src_rect, + dst_rect, + flags); + apply_transform (crtc_kms, plane_assignment, primary_kms_plane); + + return plane_assignment; +} + static void meta_onscreen_native_flip_crtc (CoglOnscreen *onscreen, MetaRendererView *view, @@ -444,10 +512,10 @@ meta_onscreen_native_flip_crtc (CoglOnscreen *onscreen, case META_RENDERER_NATIVE_MODE_GBM: buffer = onscreen_native->gbm.next_fb; - plane_assignment = meta_crtc_kms_assign_primary_plane (crtc_kms, - buffer, - kms_update, - flags); + plane_assignment = assign_primary_plane (crtc_kms, + buffer, + kms_update, + flags); if (rectangles != NULL && n_rectangles != 0) { @@ -596,8 +664,8 @@ meta_onscreen_native_set_crtc_mode (CoglOnscreen *onscreen, MetaDrmBuffer *buffer; buffer = META_DRM_BUFFER (onscreen_native->egl.dumb_fb); - meta_crtc_kms_assign_primary_plane (crtc_kms, buffer, kms_update, - META_KMS_ASSIGN_PLANE_FLAG_NONE); + assign_primary_plane (crtc_kms, buffer, kms_update, + META_KMS_ASSIGN_PLANE_FLAG_NONE); break; } #endif @@ -1372,8 +1440,8 @@ meta_onscreen_native_is_buffer_scanout_compatible (CoglOnscreen *onscreen, kms_crtc = meta_crtc_kms_get_kms_crtc (crtc_kms); test_update = meta_kms_update_new (kms_device); - meta_crtc_kms_assign_primary_plane (crtc_kms, fb, test_update, - META_KMS_ASSIGN_PLANE_FLAG_DIRECT_SCANOUT); + assign_primary_plane (crtc_kms, fb, test_update, + META_KMS_ASSIGN_PLANE_FLAG_DIRECT_SCANOUT); meta_topic (META_DEBUG_KMS, "Posting direct scanout test update for CRTC %u (%s) synchronously",