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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2814>
This commit is contained in:
Jonas Ådahl 2022-07-07 12:23:53 +02:00
parent 8e7ada70a5
commit ee91655f7d
3 changed files with 31 additions and 6 deletions

View File

@ -1392,10 +1392,12 @@ meta_onscreen_native_prepare_frame (CoglOnscreen *onscreen,
{ {
MetaOnscreenNative *onscreen_native = META_ONSCREEN_NATIVE (onscreen); MetaOnscreenNative *onscreen_native = META_ONSCREEN_NATIVE (onscreen);
MetaCrtcKms *crtc_kms = META_CRTC_KMS (onscreen_native->crtc); 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); MetaKmsCrtc *kms_crtc = meta_crtc_kms_get_kms_crtc (crtc_kms);
MetaKmsDevice *kms_device = meta_kms_crtc_get_device (kms_crtc); MetaKmsDevice *kms_device = meta_kms_crtc_get_device (kms_crtc);
meta_crtc_kms_maybe_set_gamma (crtc_kms, kms_device); meta_crtc_kms_maybe_set_gamma (crtc_kms, kms_device);
meta_output_kms_maybe_set_privacy_screen (output_kms, kms_device);
} }
void void

View File

@ -45,6 +45,9 @@ struct _MetaOutputKms
MetaOutputNative parent; MetaOutputNative parent;
MetaKmsConnector *kms_connector; MetaKmsConnector *kms_connector;
gboolean is_privacy_screen_valid;
gboolean is_privacy_screen_enabled;
}; };
G_DEFINE_TYPE (MetaOutputKms, meta_output_kms, META_TYPE_OUTPUT_NATIVE) 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); MetaGpu *gpu = meta_output_get_gpu (output);
MetaBackend *backend = meta_gpu_get_backend (gpu); MetaBackend *backend = meta_gpu_get_backend (gpu);
MetaRenderer *renderer = meta_backend_get_renderer (backend); 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); MetaOutputKms *output_kms = META_OUTPUT_KMS (output);
MetaKmsConnector *connector = meta_output_kms_get_kms_connector (output_kms); MetaKmsConnector *connector = meta_output_kms_get_kms_connector (output_kms);
MetaKmsUpdate *kms_update;
MetaCrtc *crtc; MetaCrtc *crtc;
if (!meta_kms_connector_is_privacy_screen_supported (connector)) if (!meta_kms_connector_is_privacy_screen_supported (connector))
@ -161,9 +161,8 @@ meta_output_kms_set_privacy_screen_enabled (MetaOutput *output,
return FALSE; return FALSE;
} }
kms_update = meta_kms_ensure_pending_update (kms, kms_device); output_kms->is_privacy_screen_valid = FALSE;
output_kms->is_privacy_screen_enabled = enabled;
meta_kms_update_set_privacy_screen (kms_update, connector, enabled);
crtc = meta_output_get_assigned_crtc (output); crtc = meta_output_get_assigned_crtc (output);
if (crtc) if (crtc)
@ -177,6 +176,27 @@ meta_output_kms_set_privacy_screen_enabled (MetaOutput *output,
return TRUE; 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 uint32_t
meta_output_kms_get_connector_id (MetaOutputKms *output_kms) meta_output_kms_get_connector_id (MetaOutputKms *output_kms)
{ {

View File

@ -43,6 +43,9 @@ void meta_output_kms_set_underscan (MetaOutputKms *output_kms,
void meta_output_kms_set_max_bpc (MetaOutputKms *output_kms, void meta_output_kms_set_max_bpc (MetaOutputKms *output_kms,
MetaKmsUpdate *kms_update); 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, gboolean meta_output_kms_can_clone (MetaOutputKms *output_kms,
MetaOutputKms *other_output_kms); MetaOutputKms *other_output_kms);