From ee91655f7d6502f325272b5694313b2864a2d560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 7 Jul 2022 12:23:53 +0200 Subject: [PATCH] output/native: Set privacy screen KMS state in prepare-frame This makes it behave the same as the gamma look up table of CRTCs. Part-of: --- src/backends/native/meta-onscreen-native.c | 2 ++ src/backends/native/meta-output-kms.c | 32 ++++++++++++++++++---- src/backends/native/meta-output-kms.h | 3 ++ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/backends/native/meta-onscreen-native.c b/src/backends/native/meta-onscreen-native.c index cb7b6b313..9cbb37c87 100644 --- a/src/backends/native/meta-onscreen-native.c +++ b/src/backends/native/meta-onscreen-native.c @@ -1392,10 +1392,12 @@ meta_onscreen_native_prepare_frame (CoglOnscreen *onscreen, { MetaOnscreenNative *onscreen_native = META_ONSCREEN_NATIVE (onscreen); MetaCrtcKms *crtc_kms = META_CRTC_KMS (onscreen_native->crtc); + MetaOutputKms *output_kms = META_OUTPUT_KMS (onscreen_native->output); MetaKmsCrtc *kms_crtc = meta_crtc_kms_get_kms_crtc (crtc_kms); MetaKmsDevice *kms_device = meta_kms_crtc_get_device (kms_crtc); meta_crtc_kms_maybe_set_gamma (crtc_kms, kms_device); + meta_output_kms_maybe_set_privacy_screen (output_kms, kms_device); } void diff --git a/src/backends/native/meta-output-kms.c b/src/backends/native/meta-output-kms.c index 0393a6217..470187d95 100644 --- a/src/backends/native/meta-output-kms.c +++ b/src/backends/native/meta-output-kms.c @@ -45,6 +45,9 @@ struct _MetaOutputKms MetaOutputNative parent; MetaKmsConnector *kms_connector; + + gboolean is_privacy_screen_valid; + gboolean is_privacy_screen_enabled; }; G_DEFINE_TYPE (MetaOutputKms, meta_output_kms, META_TYPE_OUTPUT_NATIVE) @@ -147,11 +150,8 @@ meta_output_kms_set_privacy_screen_enabled (MetaOutput *output, MetaGpu *gpu = meta_output_get_gpu (output); MetaBackend *backend = meta_gpu_get_backend (gpu); MetaRenderer *renderer = meta_backend_get_renderer (backend); - MetaKmsDevice *kms_device = meta_gpu_kms_get_kms_device (META_GPU_KMS (gpu)); - MetaKms *kms = meta_kms_device_get_kms (kms_device); MetaOutputKms *output_kms = META_OUTPUT_KMS (output); MetaKmsConnector *connector = meta_output_kms_get_kms_connector (output_kms); - MetaKmsUpdate *kms_update; MetaCrtc *crtc; if (!meta_kms_connector_is_privacy_screen_supported (connector)) @@ -161,9 +161,8 @@ meta_output_kms_set_privacy_screen_enabled (MetaOutput *output, return FALSE; } - kms_update = meta_kms_ensure_pending_update (kms, kms_device); - - meta_kms_update_set_privacy_screen (kms_update, connector, enabled); + output_kms->is_privacy_screen_valid = FALSE; + output_kms->is_privacy_screen_enabled = enabled; crtc = meta_output_get_assigned_crtc (output); if (crtc) @@ -177,6 +176,27 @@ meta_output_kms_set_privacy_screen_enabled (MetaOutput *output, return TRUE; } +void +meta_output_kms_maybe_set_privacy_screen (MetaOutputKms *output_kms, + MetaKmsDevice *kms_device) +{ + MetaKms *kms = meta_kms_device_get_kms (kms_device); + MetaKmsConnector *connector = meta_output_kms_get_kms_connector (output_kms); + MetaKmsUpdate *kms_update; + + if (output_kms->is_privacy_screen_valid) + return; + + output_kms->is_privacy_screen_valid = TRUE; + + if (!meta_kms_connector_is_privacy_screen_supported (connector)) + return; + + kms_update = meta_kms_ensure_pending_update (kms, kms_device); + meta_kms_update_set_privacy_screen (kms_update, connector, + output_kms->is_privacy_screen_enabled); +} + uint32_t meta_output_kms_get_connector_id (MetaOutputKms *output_kms) { diff --git a/src/backends/native/meta-output-kms.h b/src/backends/native/meta-output-kms.h index 1e35dbb17..f4f1615cc 100644 --- a/src/backends/native/meta-output-kms.h +++ b/src/backends/native/meta-output-kms.h @@ -43,6 +43,9 @@ void meta_output_kms_set_underscan (MetaOutputKms *output_kms, void meta_output_kms_set_max_bpc (MetaOutputKms *output_kms, MetaKmsUpdate *kms_update); +void meta_output_kms_maybe_set_privacy_screen (MetaOutputKms *output_kms, + MetaKmsDevice *kms_device); + gboolean meta_output_kms_can_clone (MetaOutputKms *output_kms, MetaOutputKms *other_output_kms);