From c6c3f340ece541eb2a21bc21b844424fdedff255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 26 Oct 2021 11:45:17 +0200 Subject: [PATCH] monitor: Add API to get GAMMA LUT size Will be used to generate look up tables. Part-of: --- src/backends/meta-monitor-manager-private.h | 7 +++++ src/backends/meta-monitor-manager.c | 2 +- src/backends/meta-monitor.c | 30 +++++++++++++++++++++ src/backends/meta-monitor.h | 2 ++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h index c8255ba0c..1943e8150 100644 --- a/src/backends/meta-monitor-manager-private.h +++ b/src/backends/meta-monitor-manager-private.h @@ -459,4 +459,11 @@ GList * meta_monitor_manager_get_virtual_monitors (MetaMonitorManager *manager); void meta_monitor_manager_maybe_emit_privacy_screen_change (MetaMonitorManager *manager); +void meta_monitor_manager_get_crtc_gamma (MetaMonitorManager *manager, + MetaCrtc *crtc, + size_t *size, + unsigned short **red, + unsigned short **green, + unsigned short **blue); + #endif /* META_MONITOR_MANAGER_PRIVATE_H */ diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c index 36e8a53e7..b58a05f2d 100644 --- a/src/backends/meta-monitor-manager.c +++ b/src/backends/meta-monitor-manager.c @@ -1152,7 +1152,7 @@ update_has_builtin_panel (MetaMonitorManager *manager) obj_props[PROP_HAS_BUILTIN_PANEL]); } -static void +void meta_monitor_manager_get_crtc_gamma (MetaMonitorManager *manager, MetaCrtc *crtc, size_t *size, diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c index e002f9d93..120fa2e60 100644 --- a/src/backends/meta-monitor.c +++ b/src/backends/meta-monitor.c @@ -618,6 +618,36 @@ meta_monitor_create_spec (MetaMonitor *monitor, }; } +/** + * meta_monitor_get_gamma_lut_size: + * @monitor: The MetaMonitor instance to retrieve the size from. + * + * Get the size of the look-up tables (LUTs) for the monitor. + * + * Retrieve the size of the LUT used to implement the encoding or decoding + * transfer functions ("gamma", "degamma") for the CRTC or CRTCs that backs + * this monitor. + * + * Returns: The number of look-up table entries possible for the monitor. It is + * assumed that each CRTC of a monitor has identical gamma LUT sizes. + */ +size_t +meta_monitor_get_gamma_lut_size (MetaMonitor *monitor) +{ + MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor); + MetaMonitorManager *monitor_manager = + meta_backend_get_monitor_manager (priv->backend); + MetaOutput *output; + MetaCrtc *crtc; + size_t size; + + output = meta_monitor_get_main_output (monitor); + crtc = meta_output_get_assigned_crtc (output); + meta_monitor_manager_get_crtc_gamma (monitor_manager, crtc, + &size, NULL, NULL, NULL); + return size; +} + static void meta_monitor_normal_generate_modes (MetaMonitorNormal *monitor_normal) { diff --git a/src/backends/meta-monitor.h b/src/backends/meta-monitor.h index b24eaabfb..cf0ffa99c 100644 --- a/src/backends/meta-monitor.h +++ b/src/backends/meta-monitor.h @@ -295,4 +295,6 @@ gboolean meta_monitor_set_privacy_screen_enabled (MetaMonitor *monitor, gboolean enabled, GError **error); +size_t meta_monitor_get_gamma_lut_size (MetaMonitor *monitor); + #endif /* META_MONITOR_H */