1
0
Fork 0
mutter-performance-source/src/backends/meta-monitor-manager-private.h

461 lines
19 KiB
C
Raw Normal View History

/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2014-05-02 13:34:02 +00:00
/*
* Copyright (C) 2001 Havoc Pennington
* Copyright (C) 2003 Rob Adams
* Copyright (C) 2004-2006 Elijah Newren
* Copyright (C) 2013 Red Hat Inc.
* Copyright (C) 2020 NVIDIA CORPORATION
2014-05-02 13:34:02 +00:00
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
2014-05-02 13:34:02 +00:00
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef META_MONITOR_MANAGER_PRIVATE_H
#define META_MONITOR_MANAGER_PRIVATE_H
#include <cogl/cogl.h>
#include <graphene.h>
#ifdef HAVE_GNOME_DESKTOP
#include <libgnome-desktop/gnome-pnp-ids.h>
#endif
#include "backends/meta-backend-private.h"
#include "backends/meta-cursor.h"
#include "backends/meta-display-config-shared.h"
#include "backends/meta-monitor-transform.h"
#include "backends/meta-viewport-info.h"
#include "core/util-private.h"
#include "meta/display.h"
#include "meta/meta-monitor-manager.h"
#define META_MONITOR_MANAGER_MIN_SCREEN_WIDTH 640
#define META_MONITOR_MANAGER_MIN_SCREEN_HEIGHT 480
typedef enum _MetaMonitorManagerCapability
{
META_MONITOR_MANAGER_CAPABILITY_NONE = 0,
META_MONITOR_MANAGER_CAPABILITY_LAYOUT_MODE = (1 << 0),
META_MONITOR_MANAGER_CAPABILITY_GLOBAL_SCALE_REQUIRED = (1 << 1)
} MetaMonitorManagerCapability;
/* Equivalent to the 'method' enum in org.gnome.Mutter.DisplayConfig */
typedef enum _MetaMonitorsConfigMethod
{
META_MONITORS_CONFIG_METHOD_VERIFY = 0,
META_MONITORS_CONFIG_METHOD_TEMPORARY = 1,
META_MONITORS_CONFIG_METHOD_PERSISTENT = 2
} MetaMonitorsConfigMethod;
/* Equivalent to the 'layout-mode' enum in org.gnome.Mutter.DisplayConfig */
typedef enum _MetaLogicalMonitorLayoutMode
{
META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL = 1,
META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL = 2
} MetaLogicalMonitorLayoutMode;
/* The source the privacy screen change has been triggered */
typedef enum
{
META_PRIVACY_SCREEN_CHANGE_STATE_NONE,
META_PRIVACY_SCREEN_CHANGE_STATE_INIT,
META_PRIVACY_SCREEN_CHANGE_STATE_PENDING_HOTKEY,
META_PRIVACY_SCREEN_CHANGE_STATE_PENDING_SETTING,
} MetaPrivacyScreenChangeState;
/*
* MetaCrtcAssignment:
*
* A representation of a CRTC configuration, generated by
* MetaMonitorConfigManager.
*/
struct _MetaCrtcAssignment
{
MetaCrtc *crtc;
MetaCrtcMode *mode;
graphene_rect_t layout;
MetaMonitorTransform transform;
GPtrArray *outputs;
};
/*
* MetaOutputAssignment:
*
* A representation of a connector configuration, generated by
* MetaMonitorConfigManager.
*/
struct _MetaOutputAssignment
{
MetaOutput *output;
gboolean is_primary;
gboolean is_presentation;
gboolean is_underscanning;
};
/*
* MetaOutputCtm:
*
* A 3x3 color transform matrix in the fixed-point S31.32 sign-magnitude format
* used by DRM.
*/
typedef struct _MetaOutputCtm
{
uint64_t matrix[9];
} MetaOutputCtm;
#define META_TYPE_MONITOR_MANAGER (meta_monitor_manager_get_type ())
#define META_MONITOR_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_MONITOR_MANAGER, MetaMonitorManager))
#define META_MONITOR_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_MONITOR_MANAGER, MetaMonitorManagerClass))
#define META_IS_MONITOR_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_MONITOR_MANAGER))
#define META_IS_MONITOR_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_MONITOR_MANAGER))
#define META_MONITOR_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_MONITOR_MANAGER, MetaMonitorManagerClass))
typedef struct _MetaDBusDisplayConfig MetaDBusDisplayConfig;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaMonitorManager, g_object_unref)
struct _MetaMonitorManager
{
GObject parent_instance;
MetaDBusDisplayConfig *display_config;
MetaBackend *backend;
/* XXX: this structure is very badly
packed, but I like the logical organization
of fields */
gboolean in_init;
unsigned int serial;
MetaLogicalMonitorLayoutMode layout_mode;
int screen_width;
int screen_height;
GList *monitors;
GList *logical_monitors;
MetaLogicalMonitor *primary_logical_monitor;
int dbus_name_id;
int persistent_timeout_id;
guint panel_orientation_managed : 1;
MetaMonitorConfigManager *config_manager;
#ifdef HAVE_GNOME_DESKTOP
GnomePnpIds *pnp_ids;
#endif
MetaMonitorSwitchConfigType current_switch_config;
MetaPrivacyScreenChangeState privacy_screen_change_state;
};
2018-10-19 07:15:54 +00:00
/**
* MetaMonitorManagerClass:
*
* @read_edid: Returns the raw Extended Display Identification Data (EDID)
* for the given #MetaOutput object.
2018-10-19 07:15:54 +00:00
*
* @ensure_initial_config: Called on setup. Makes sure an initial config
* is loaded.
*
* @apply_monitors_config: Tries to apply the given config using the given
* method. Throws an error if something went wrong.
*
* @set_power_save_mode: Sets the #MetaPowerSave mode (for all displays).
*
* @change_backlight: Changes the backlight intensity to the given value (in
* percent).
*
* @get_crtc_gamma: Queries and returns the gamma rampQueries and returns the
* gamma ramp.
*
* @set_crtc_gamma: Sets custom display LUT (look up table) for each primary
* color. Each table is indexed by a value that represents input intensity,
* and yields a value that represents output intensity.
*
* @tiled_monitor_added: Should be called by a #MetaMonitor when it is created.
*
* @tiled_monitor_removed: Should be called by a #MetaMonitor when it is
* destroyed.
*
* @is_transform_handled: vfunc for
* meta_monitor_manager_is_transform_handled().
* @calculate_monitor_mode_scale: vfunc for
* meta_monitor_manager_calculate_monitor_mode_scale().
* @calculate_supported_scales: vfunc for
* meta_monitor_manager_calculate_supported_scales().
* @get_capabilities: vfunc for meta_monitor_manager_get_capabilities().
* @get_max_screen_size: vfunc for meta_monitor_manager_get_max_screen_size().
* @get_default_layout_mode: vfunc for meta_monitor_manager_get_default_layout_mode().
* @set_output_ctm: vfunc for meta_monitor_manager_output_set_ctm()
2018-10-19 07:15:54 +00:00
*
* The base class for a #MetaMonitorManager.
*/
struct _MetaMonitorManagerClass
{
GObjectClass parent_class;
GBytes * (* read_edid) (MetaMonitorManager *manager,
MetaOutput *output);
void (* read_current_state) (MetaMonitorManager *manager);
void (* ensure_initial_config) (MetaMonitorManager *manager);
gboolean (* apply_monitors_config) (MetaMonitorManager *manager,
MetaMonitorsConfig *config,
MetaMonitorsConfigMethod method,
GError **error);
void (* set_power_save_mode) (MetaMonitorManager *manager,
MetaPowerSave power_save);
void (* change_backlight) (MetaMonitorManager *manager,
MetaOutput *output,
int backlight);
void (* get_crtc_gamma) (MetaMonitorManager *manager,
MetaCrtc *crtc,
size_t *size,
unsigned short **red,
unsigned short **green,
unsigned short **blue);
void (* set_crtc_gamma) (MetaMonitorManager *manager,
MetaCrtc *crtc,
size_t size,
unsigned short *red,
unsigned short *green,
unsigned short *blue);
void (* tiled_monitor_added) (MetaMonitorManager *manager,
MetaMonitor *monitor);
void (* tiled_monitor_removed) (MetaMonitorManager *manager,
MetaMonitor *monitor);
gboolean (* is_transform_handled) (MetaMonitorManager *manager,
MetaCrtc *crtc,
MetaMonitorTransform transform);
float (* calculate_monitor_mode_scale) (MetaMonitorManager *manager,
MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode);
float * (* calculate_supported_scales) (MetaMonitorManager *manager,
MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode,
int *n_supported_scales);
MetaMonitorManagerCapability (* get_capabilities) (MetaMonitorManager *manager);
gboolean (* get_max_screen_size) (MetaMonitorManager *manager,
int *width,
int *height);
MetaLogicalMonitorLayoutMode (* get_default_layout_mode) (MetaMonitorManager *manager);
void (* set_output_ctm) (MetaOutput *output,
const MetaOutputCtm *ctm);
Introduce virtual monitors Virtual monitors are monitors that isn't backed by any monitor like hardware. It would typically be backed by e.g. a remote desktop service, or a network display. It is currently only supported by the native backend, and whether the X11 backend will ever see virtual monitors is an open question. This rest of this commit message describes how it works under the native backend. Each virutal monitor consists of virtualized mode setting components: * A virtual CRTC mode (MetaCrtcModeVirtual) * A virtual CRTC (MetaCrtcVirtual) * A virtual connector (MetaOutputVirtual) In difference to the corresponding mode setting objects that represents KMS objects, the virtual ones isn't directly tied to a MetaGpu, other than the CoglFramebuffer being part of the GPU context of the primary GPU, which is the case for all monitors no matter what GPU they are connected to. Part of the reason for this is that a MetaGpu in practice represents a mode setting device, and its CRTCs and outputs, are all backed by real mode setting objects, while a virtual monitor is only backed by a framebuffer that is tied to the primary GPU. Maybe this will be reevaluated in the future, but since a virtual monitor is not tied to any GPU currently, so is the case for the virtual mode setting objects. The native rendering backend, including the cursor renderer, is adapted to handle the situation where a CRTC does not have a GPU associated with it; this in practice means that it e.g. will not try to upload HW cursor buffers when the cursor is only on a virtual monitor. The same applies to the native renderer, which is made to avoid creating MetaOnscreenNative for views that are backed by virtual CRTCs, as well as to avoid trying to mode set on such views. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-01-26 15:49:28 +00:00
MetaVirtualMonitor * (* create_virtual_monitor) (MetaMonitorManager *manager,
const MetaVirtualMonitorInfo *info,
GError **error);
};
META_EXPORT_TEST
MetaBackend * meta_monitor_manager_get_backend (MetaMonitorManager *manager);
void meta_monitor_manager_setup (MetaMonitorManager *manager);
META_EXPORT_TEST
void meta_monitor_manager_rebuild (MetaMonitorManager *manager,
MetaMonitorsConfig *config);
META_EXPORT_TEST
void meta_monitor_manager_rebuild_derived (MetaMonitorManager *manager,
MetaMonitorsConfig *config);
META_EXPORT_TEST
int meta_monitor_manager_get_num_logical_monitors (MetaMonitorManager *manager);
META_EXPORT_TEST
GList * meta_monitor_manager_get_logical_monitors (MetaMonitorManager *manager);
MetaLogicalMonitor *meta_monitor_manager_get_logical_monitor_from_number (MetaMonitorManager *manager,
int number);
META_EXPORT_TEST
MetaLogicalMonitor *meta_monitor_manager_get_primary_logical_monitor (MetaMonitorManager *manager);
MetaLogicalMonitor *meta_monitor_manager_get_logical_monitor_at (MetaMonitorManager *manager,
float x,
float y);
MetaLogicalMonitor *meta_monitor_manager_get_logical_monitor_from_rect (MetaMonitorManager *manager,
MetaRectangle *rect);
MetaLogicalMonitor *meta_monitor_manager_get_logical_monitor_neighbor (MetaMonitorManager *manager,
MetaLogicalMonitor *logical_monitor,
MetaDisplayDirection direction);
MetaMonitor * meta_monitor_manager_get_primary_monitor (MetaMonitorManager *manager);
META_EXPORT_TEST
MetaMonitor * meta_monitor_manager_get_laptop_panel (MetaMonitorManager *manager);
MetaMonitor * meta_monitor_manager_get_monitor_from_spec (MetaMonitorManager *manager,
MetaMonitorSpec *monitor_spec);
MetaMonitor * meta_monitor_manager_get_monitor_from_connector (MetaMonitorManager *manager,
const char *connector);
META_EXPORT_TEST
GList * meta_monitor_manager_get_monitors (MetaMonitorManager *manager);
void meta_monitor_manager_get_screen_size (MetaMonitorManager *manager,
int *width,
int *height);
MetaPowerSave meta_monitor_manager_get_power_save_mode (MetaMonitorManager *manager);
void meta_monitor_manager_power_save_mode_changed (MetaMonitorManager *manager,
MetaPowerSave mode);
void meta_monitor_manager_confirm_configuration (MetaMonitorManager *manager,
gboolean ok);
gboolean meta_monitor_manager_has_hotplug_mode_update (MetaMonitorManager *manager);
void meta_monitor_manager_read_current_state (MetaMonitorManager *manager);
META_EXPORT_TEST
void meta_monitor_manager_reconfigure (MetaMonitorManager *manager);
META_EXPORT_TEST
void meta_monitor_manager_reload (MetaMonitorManager *manager);
gboolean meta_monitor_manager_get_monitor_matrix (MetaMonitorManager *manager,
MetaMonitor *monitor,
MetaLogicalMonitor *logical_monitor,
gfloat matrix[6]);
void meta_monitor_manager_tiled_monitor_added (MetaMonitorManager *manager,
MetaMonitor *monitor);
void meta_monitor_manager_tiled_monitor_removed (MetaMonitorManager *manager,
MetaMonitor *monitor);
gboolean meta_monitor_manager_is_transform_handled (MetaMonitorManager *manager,
MetaCrtc *crtc,
MetaMonitorTransform transform);
META_EXPORT_TEST
MetaMonitorsConfig * meta_monitor_manager_ensure_configured (MetaMonitorManager *manager);
META_EXPORT_TEST
void meta_monitor_manager_update_logical_state (MetaMonitorManager *manager,
MetaMonitorsConfig *config);
META_EXPORT_TEST
void meta_monitor_manager_update_logical_state_derived (MetaMonitorManager *manager,
MetaMonitorsConfig *config);
META_EXPORT_TEST
void meta_monitor_manager_lid_is_closed_changed (MetaMonitorManager *manager);
gboolean meta_monitor_manager_is_headless (MetaMonitorManager *manager);
float meta_monitor_manager_calculate_monitor_mode_scale (MetaMonitorManager *manager,
MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode);
float * meta_monitor_manager_calculate_supported_scales (MetaMonitorManager *,
MetaLogicalMonitorLayoutMode ,
MetaMonitor *,
MetaMonitorMode *,
int *);
gboolean meta_monitor_manager_is_scale_supported (MetaMonitorManager *manager,
MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode,
float scale);
MetaMonitorManagerCapability
meta_monitor_manager_get_capabilities (MetaMonitorManager *manager);
gboolean meta_monitor_manager_get_max_screen_size (MetaMonitorManager *manager,
int *max_width,
int *max_height);
MetaLogicalMonitorLayoutMode
meta_monitor_manager_get_default_layout_mode (MetaMonitorManager *manager);
META_EXPORT_TEST
Introduce virtual monitors Virtual monitors are monitors that isn't backed by any monitor like hardware. It would typically be backed by e.g. a remote desktop service, or a network display. It is currently only supported by the native backend, and whether the X11 backend will ever see virtual monitors is an open question. This rest of this commit message describes how it works under the native backend. Each virutal monitor consists of virtualized mode setting components: * A virtual CRTC mode (MetaCrtcModeVirtual) * A virtual CRTC (MetaCrtcVirtual) * A virtual connector (MetaOutputVirtual) In difference to the corresponding mode setting objects that represents KMS objects, the virtual ones isn't directly tied to a MetaGpu, other than the CoglFramebuffer being part of the GPU context of the primary GPU, which is the case for all monitors no matter what GPU they are connected to. Part of the reason for this is that a MetaGpu in practice represents a mode setting device, and its CRTCs and outputs, are all backed by real mode setting objects, while a virtual monitor is only backed by a framebuffer that is tied to the primary GPU. Maybe this will be reevaluated in the future, but since a virtual monitor is not tied to any GPU currently, so is the case for the virtual mode setting objects. The native rendering backend, including the cursor renderer, is adapted to handle the situation where a CRTC does not have a GPU associated with it; this in practice means that it e.g. will not try to upload HW cursor buffers when the cursor is only on a virtual monitor. The same applies to the native renderer, which is made to avoid creating MetaOnscreenNative for views that are backed by virtual CRTCs, as well as to avoid trying to mode set on such views. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-01-26 15:49:28 +00:00
MetaVirtualMonitor * meta_monitor_manager_create_virtual_monitor (MetaMonitorManager *manager,
const MetaVirtualMonitorInfo *info,
GError **error);
META_EXPORT_TEST
MetaMonitorConfigManager *
meta_monitor_manager_get_config_manager (MetaMonitorManager *manager);
void meta_monitor_manager_rotate_monitor (MetaMonitorManager *manager);
void meta_monitor_manager_clear_output (MetaOutput *output);
void meta_monitor_manager_clear_mode (MetaCrtcMode *mode);
void meta_monitor_manager_clear_crtc (MetaCrtc *crtc);
gboolean meta_monitor_has_aspect_as_size (MetaMonitor *monitor);
char * meta_monitor_manager_get_vendor_name (MetaMonitorManager *manager,
const char *vendor);
static inline MetaOutputAssignment *
meta_find_output_assignment (MetaOutputAssignment **outputs,
unsigned int n_outputs,
MetaOutput *output)
{
unsigned int i;
for (i = 0; i < n_outputs; i++)
{
MetaOutputAssignment *output_assignment = outputs[i];
if (output == output_assignment->output)
return output_assignment;
}
return NULL;
}
void meta_monitor_manager_post_init (MetaMonitorManager *manager);
MetaViewportInfo * meta_monitor_manager_get_viewports (MetaMonitorManager *manager);
Introduce virtual monitors Virtual monitors are monitors that isn't backed by any monitor like hardware. It would typically be backed by e.g. a remote desktop service, or a network display. It is currently only supported by the native backend, and whether the X11 backend will ever see virtual monitors is an open question. This rest of this commit message describes how it works under the native backend. Each virutal monitor consists of virtualized mode setting components: * A virtual CRTC mode (MetaCrtcModeVirtual) * A virtual CRTC (MetaCrtcVirtual) * A virtual connector (MetaOutputVirtual) In difference to the corresponding mode setting objects that represents KMS objects, the virtual ones isn't directly tied to a MetaGpu, other than the CoglFramebuffer being part of the GPU context of the primary GPU, which is the case for all monitors no matter what GPU they are connected to. Part of the reason for this is that a MetaGpu in practice represents a mode setting device, and its CRTCs and outputs, are all backed by real mode setting objects, while a virtual monitor is only backed by a framebuffer that is tied to the primary GPU. Maybe this will be reevaluated in the future, but since a virtual monitor is not tied to any GPU currently, so is the case for the virtual mode setting objects. The native rendering backend, including the cursor renderer, is adapted to handle the situation where a CRTC does not have a GPU associated with it; this in practice means that it e.g. will not try to upload HW cursor buffers when the cursor is only on a virtual monitor. The same applies to the native renderer, which is made to avoid creating MetaOnscreenNative for views that are backed by virtual CRTCs, as well as to avoid trying to mode set on such views. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-01-26 15:49:28 +00:00
GList * meta_monitor_manager_get_virtual_monitors (MetaMonitorManager *manager);
void meta_monitor_manager_maybe_emit_privacy_screen_change (MetaMonitorManager *manager);
#endif /* META_MONITOR_MANAGER_PRIVATE_H */