2013-07-30 09:36:18 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
2014-05-02 13:34:02 +00:00
|
|
|
/*
|
2013-07-30 09:36:18 +00:00
|
|
|
* Copyright (C) 2013 Red Hat Inc.
|
2018-09-17 11:03:18 +00:00
|
|
|
* Copyright (C) 2018 DisplayLink (UK) Ltd.
|
2014-05-02 13:34:02 +00:00
|
|
|
*
|
2013-07-30 09:36:18 +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
|
|
|
*
|
2013-07-30 09:36:18 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* Author: Giovanni Campagna <gcampagn@redhat.com>
|
|
|
|
*/
|
|
|
|
|
2018-10-19 07:15:54 +00:00
|
|
|
/**
|
2020-12-17 21:12:41 +00:00
|
|
|
* SECTION:meta-monitor-manager-native
|
|
|
|
* @title: MetaMonitorManagerNative
|
2018-10-19 07:15:54 +00:00
|
|
|
* @short_description: A subclass of #MetaMonitorManager using Linux DRM
|
|
|
|
*
|
2020-12-17 21:12:41 +00:00
|
|
|
* #MetaMonitorManagerNative is a subclass of #MetaMonitorManager which
|
2018-10-19 07:15:54 +00:00
|
|
|
* implements its functionality "natively": it uses the appropriate
|
|
|
|
* functions of the Linux DRM kernel module and using a udev client.
|
|
|
|
*
|
|
|
|
* See also #MetaMonitorManagerXrandr for an implementation using XRandR.
|
|
|
|
*/
|
|
|
|
|
2013-07-30 09:36:18 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2020-12-17 21:12:41 +00:00
|
|
|
#include "backends/native/meta-monitor-manager-native.h"
|
2013-07-30 09:36:18 +00:00
|
|
|
|
2016-05-12 06:55:06 +00:00
|
|
|
#include <drm.h>
|
2018-07-10 08:36:24 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2013-07-30 09:36:18 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2018-07-10 08:36:24 +00:00
|
|
|
#include "backends/meta-backend-private.h"
|
|
|
|
#include "backends/meta-crtc.h"
|
|
|
|
#include "backends/meta-monitor-config-manager.h"
|
2022-01-25 15:43:47 +00:00
|
|
|
#include "backends/meta-monitor.h"
|
2018-07-10 08:36:24 +00:00
|
|
|
#include "backends/meta-output.h"
|
|
|
|
#include "backends/native/meta-backend-native.h"
|
|
|
|
#include "backends/native/meta-crtc-kms.h"
|
|
|
|
#include "backends/native/meta-gpu-kms.h"
|
2022-01-25 15:43:47 +00:00
|
|
|
#include "backends/native/meta-kms-device.h"
|
backend/native: Add and use transactional KMS API
This commit introduces, and makes use of, a transactional API used for
setting up KMS state, later to be applied, potentially atomically. From
an API point of view, so is always the case, but in the current
implementation, it still uses legacy drmMode* API to apply the state
non-atomically.
The API consists of various buliding blocks:
* MetaKmsUpdate - a set of configuration changes, the higher level
handle for handing over configuration to the impl backend. It's used to
set mode, assign framebuffers to planes, queue page flips and set
connector properties.
* MetaKmsPlaneAssignment - the assignment of a framebuffer to a plane.
Currently used to map a framebuffer to the primary plane of a CRTC. In
the legacy KMS implementation, the plane assignment is used to derive
the framebuffer used for mode setting and page flipping.
This also means various high level changes:
State, excluding configuring the cursor plane and creating/destroying
DRM framebuffer handles, are applied in the end of a clutter frame, in
one go. From an API point of view, this is done atomically, but as
mentioned, only the non-atomic implementation exists so far.
From MetaRendererNative's point of view, a page flip now initially
always succeeds; the handling of EBUSY errors are done asynchronously in
the MetaKmsImpl backend (still by retrying at refresh rate, but
postponing flip callbacks instead of manipulating the frame clock).
Handling of falling back to mode setting instead of page flipping is
notified after the fact by a more precise page flip feedback API.
EGLStream based page flipping relies on the impl backend not being
atomic, as the page flipping is done in the EGLStream backend (e.g.
nvidia driver). It uses a 'custom' page flip queueing method, keeping
the EGLStream logic inside meta-renderer-native.c.
Page flip handling is moved to meta-kms-impl-device.c from
meta-gpu-kms.c. It goes via an extra idle callback before reaching
meta-renderer-native.c to make sure callbacks are invoked outside of the
impl context.
While dummy power save page flipping is kept in meta-renderer-native.c, the
EBUSY handling is moved to meta-kms-impl-simple.c. Instead of freezing the
frame clock, actual page flip callbacks are postponed until all EBUSY retries
have either succeeded or failed due to some other error than EBUSY. This
effectively inhibits new frames to be drawn, meaning we won't stall waiting on
the file descriptor for pending page flips.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-04-04 20:36:41 +00:00
|
|
|
#include "backends/native/meta-kms.h"
|
2018-07-10 08:36:24 +00:00
|
|
|
#include "backends/native/meta-launcher.h"
|
|
|
|
#include "backends/native/meta-output-kms.h"
|
|
|
|
#include "backends/native/meta-renderer-native.h"
|
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
|
|
|
#include "backends/native/meta-virtual-monitor-native.h"
|
2018-07-10 08:36:24 +00:00
|
|
|
#include "clutter/clutter.h"
|
|
|
|
#include "meta/main.h"
|
|
|
|
#include "meta/meta-x11-errors.h"
|
2014-10-12 20:05:31 +00:00
|
|
|
|
2021-03-21 22:11:24 +00:00
|
|
|
#include "meta-dbus-display-config.h"
|
|
|
|
|
2021-01-18 21:34:04 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
|
|
|
|
PROP_NEED_OUTPUTS,
|
|
|
|
|
|
|
|
N_PROPS
|
|
|
|
};
|
|
|
|
|
|
|
|
static GParamSpec *obj_props[N_PROPS];
|
|
|
|
|
2020-12-17 21:12:41 +00:00
|
|
|
struct _MetaMonitorManagerNative
|
2013-07-30 09:36:18 +00:00
|
|
|
{
|
|
|
|
MetaMonitorManager parent_instance;
|
|
|
|
|
2019-08-22 13:15:51 +00:00
|
|
|
gulong kms_resources_changed_handler_id;
|
2020-10-10 09:47:58 +00:00
|
|
|
|
|
|
|
GHashTable *crtc_gamma_cache;
|
2021-01-18 21:34:04 +00:00
|
|
|
|
|
|
|
gboolean needs_outputs;
|
2021-12-16 10:25:37 +00:00
|
|
|
|
|
|
|
guint rebuild_virtual_idle_id;
|
2013-07-30 09:36:18 +00:00
|
|
|
};
|
|
|
|
|
2020-12-17 21:12:41 +00:00
|
|
|
struct _MetaMonitorManagerNativeClass
|
2013-07-30 09:36:18 +00:00
|
|
|
{
|
|
|
|
MetaMonitorManagerClass parent_class;
|
|
|
|
};
|
|
|
|
|
2017-07-06 08:00:56 +00:00
|
|
|
static void
|
|
|
|
initable_iface_init (GInitableIface *initable_iface);
|
|
|
|
|
2020-12-17 21:12:41 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (MetaMonitorManagerNative, meta_monitor_manager_native,
|
2017-07-06 08:00:56 +00:00
|
|
|
META_TYPE_MONITOR_MANAGER,
|
|
|
|
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
|
|
|
|
initable_iface_init))
|
2013-07-30 09:36:18 +00:00
|
|
|
|
|
|
|
static GBytes *
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_read_edid (MetaMonitorManager *manager,
|
|
|
|
MetaOutput *output)
|
2013-07-30 09:36:18 +00:00
|
|
|
{
|
2020-12-17 21:48:28 +00:00
|
|
|
return meta_output_native_read_edid (META_OUTPUT_NATIVE (output));
|
2013-07-30 09:36:18 +00:00
|
|
|
}
|
|
|
|
|
2019-01-11 13:45:44 +00:00
|
|
|
static void
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_read_current_state (MetaMonitorManager *manager)
|
2019-01-11 13:45:44 +00:00
|
|
|
{
|
|
|
|
MetaMonitorManagerClass *parent_class =
|
2020-12-17 21:12:41 +00:00
|
|
|
META_MONITOR_MANAGER_CLASS (meta_monitor_manager_native_parent_class);
|
2019-01-11 13:45:44 +00:00
|
|
|
MetaPowerSave power_save_mode;
|
|
|
|
|
|
|
|
power_save_mode = meta_monitor_manager_get_power_save_mode (manager);
|
|
|
|
if (power_save_mode != META_POWER_SAVE_ON)
|
|
|
|
meta_monitor_manager_power_save_mode_changed (manager,
|
|
|
|
META_POWER_SAVE_ON);
|
|
|
|
|
|
|
|
parent_class->read_current_state (manager);
|
|
|
|
}
|
|
|
|
|
2020-10-10 09:10:47 +00:00
|
|
|
uint64_t
|
|
|
|
meta_power_save_to_dpms_state (MetaPowerSave power_save)
|
|
|
|
{
|
|
|
|
switch (power_save)
|
|
|
|
{
|
|
|
|
case META_POWER_SAVE_ON:
|
|
|
|
return DRM_MODE_DPMS_ON;
|
|
|
|
case META_POWER_SAVE_STANDBY:
|
|
|
|
return DRM_MODE_DPMS_STANDBY;
|
|
|
|
case META_POWER_SAVE_SUSPEND:
|
|
|
|
return DRM_MODE_DPMS_SUSPEND;
|
|
|
|
case META_POWER_SAVE_OFF:
|
|
|
|
return DRM_MODE_DPMS_OFF;
|
|
|
|
case META_POWER_SAVE_UNSUPPORTED:
|
|
|
|
return DRM_MODE_DPMS_ON;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_warn_if_reached ();
|
|
|
|
return DRM_MODE_DPMS_ON;
|
|
|
|
}
|
|
|
|
|
2013-07-30 09:36:18 +00:00
|
|
|
static void
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_set_power_save_mode (MetaMonitorManager *manager,
|
|
|
|
MetaPowerSave mode)
|
2013-07-30 09:36:18 +00:00
|
|
|
{
|
backend/native: Add and use transactional KMS API
This commit introduces, and makes use of, a transactional API used for
setting up KMS state, later to be applied, potentially atomically. From
an API point of view, so is always the case, but in the current
implementation, it still uses legacy drmMode* API to apply the state
non-atomically.
The API consists of various buliding blocks:
* MetaKmsUpdate - a set of configuration changes, the higher level
handle for handing over configuration to the impl backend. It's used to
set mode, assign framebuffers to planes, queue page flips and set
connector properties.
* MetaKmsPlaneAssignment - the assignment of a framebuffer to a plane.
Currently used to map a framebuffer to the primary plane of a CRTC. In
the legacy KMS implementation, the plane assignment is used to derive
the framebuffer used for mode setting and page flipping.
This also means various high level changes:
State, excluding configuring the cursor plane and creating/destroying
DRM framebuffer handles, are applied in the end of a clutter frame, in
one go. From an API point of view, this is done atomically, but as
mentioned, only the non-atomic implementation exists so far.
From MetaRendererNative's point of view, a page flip now initially
always succeeds; the handling of EBUSY errors are done asynchronously in
the MetaKmsImpl backend (still by retrying at refresh rate, but
postponing flip callbacks instead of manipulating the frame clock).
Handling of falling back to mode setting instead of page flipping is
notified after the fact by a more precise page flip feedback API.
EGLStream based page flipping relies on the impl backend not being
atomic, as the page flipping is done in the EGLStream backend (e.g.
nvidia driver). It uses a 'custom' page flip queueing method, keeping
the EGLStream logic inside meta-renderer-native.c.
Page flip handling is moved to meta-kms-impl-device.c from
meta-gpu-kms.c. It goes via an extra idle callback before reaching
meta-renderer-native.c to make sure callbacks are invoked outside of the
impl context.
While dummy power save page flipping is kept in meta-renderer-native.c, the
EBUSY handling is moved to meta-kms-impl-simple.c. Instead of freezing the
frame clock, actual page flip callbacks are postponed until all EBUSY retries
have either succeeded or failed due to some other error than EBUSY. This
effectively inhibits new frames to be drawn, meaning we won't stall waiting on
the file descriptor for pending page flips.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-04-04 20:36:41 +00:00
|
|
|
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
|
2017-03-24 09:35:51 +00:00
|
|
|
GList *l;
|
2013-07-30 09:36:18 +00:00
|
|
|
|
backend/native: Add and use transactional KMS API
This commit introduces, and makes use of, a transactional API used for
setting up KMS state, later to be applied, potentially atomically. From
an API point of view, so is always the case, but in the current
implementation, it still uses legacy drmMode* API to apply the state
non-atomically.
The API consists of various buliding blocks:
* MetaKmsUpdate - a set of configuration changes, the higher level
handle for handing over configuration to the impl backend. It's used to
set mode, assign framebuffers to planes, queue page flips and set
connector properties.
* MetaKmsPlaneAssignment - the assignment of a framebuffer to a plane.
Currently used to map a framebuffer to the primary plane of a CRTC. In
the legacy KMS implementation, the plane assignment is used to derive
the framebuffer used for mode setting and page flipping.
This also means various high level changes:
State, excluding configuring the cursor plane and creating/destroying
DRM framebuffer handles, are applied in the end of a clutter frame, in
one go. From an API point of view, this is done atomically, but as
mentioned, only the non-atomic implementation exists so far.
From MetaRendererNative's point of view, a page flip now initially
always succeeds; the handling of EBUSY errors are done asynchronously in
the MetaKmsImpl backend (still by retrying at refresh rate, but
postponing flip callbacks instead of manipulating the frame clock).
Handling of falling back to mode setting instead of page flipping is
notified after the fact by a more precise page flip feedback API.
EGLStream based page flipping relies on the impl backend not being
atomic, as the page flipping is done in the EGLStream backend (e.g.
nvidia driver). It uses a 'custom' page flip queueing method, keeping
the EGLStream logic inside meta-renderer-native.c.
Page flip handling is moved to meta-kms-impl-device.c from
meta-gpu-kms.c. It goes via an extra idle callback before reaching
meta-renderer-native.c to make sure callbacks are invoked outside of the
impl context.
While dummy power save page flipping is kept in meta-renderer-native.c, the
EBUSY handling is moved to meta-kms-impl-simple.c. Instead of freezing the
frame clock, actual page flip callbacks are postponed until all EBUSY retries
have either succeeded or failed due to some other error than EBUSY. This
effectively inhibits new frames to be drawn, meaning we won't stall waiting on
the file descriptor for pending page flips.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-04-04 20:36:41 +00:00
|
|
|
for (l = meta_backend_get_gpus (backend); l; l = l->next)
|
2013-07-30 09:36:18 +00:00
|
|
|
{
|
2017-07-10 10:19:32 +00:00
|
|
|
MetaGpuKms *gpu_kms = l->data;
|
2021-04-21 08:44:13 +00:00
|
|
|
|
|
|
|
switch (mode)
|
2020-10-02 08:38:57 +00:00
|
|
|
{
|
2021-04-21 08:44:13 +00:00
|
|
|
case META_POWER_SAVE_ON:
|
|
|
|
case META_POWER_SAVE_UNSUPPORTED:
|
|
|
|
{
|
|
|
|
g_list_foreach (meta_gpu_get_crtcs (META_GPU (gpu_kms)),
|
|
|
|
(GFunc) meta_crtc_kms_invalidate_gamma,
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case META_POWER_SAVE_STANDBY:
|
|
|
|
case META_POWER_SAVE_SUSPEND:
|
|
|
|
case META_POWER_SAVE_OFF:
|
|
|
|
{
|
2021-06-28 08:11:31 +00:00
|
|
|
meta_kms_device_disable (meta_gpu_kms_get_kms_device (gpu_kms));
|
2021-04-21 08:44:13 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-10-02 08:38:57 +00:00
|
|
|
}
|
2019-11-08 23:14:36 +00:00
|
|
|
}
|
2013-07-30 09:36:18 +00:00
|
|
|
}
|
|
|
|
|
2017-01-06 05:27:21 +00:00
|
|
|
static void
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_ensure_initial_config (MetaMonitorManager *manager)
|
2017-01-06 05:27:21 +00:00
|
|
|
{
|
2017-01-09 06:31:18 +00:00
|
|
|
MetaMonitorsConfig *config;
|
2017-01-06 05:27:21 +00:00
|
|
|
|
2017-01-09 06:31:18 +00:00
|
|
|
config = meta_monitor_manager_ensure_configured (manager);
|
|
|
|
|
2017-03-24 07:36:12 +00:00
|
|
|
meta_monitor_manager_update_logical_state (manager, config);
|
2017-01-06 05:27:21 +00:00
|
|
|
}
|
|
|
|
|
2013-07-30 09:36:18 +00:00
|
|
|
static void
|
2020-02-25 19:30:46 +00:00
|
|
|
apply_crtc_assignments (MetaMonitorManager *manager,
|
|
|
|
MetaCrtcAssignment **crtcs,
|
|
|
|
unsigned int n_crtcs,
|
|
|
|
MetaOutputAssignment **outputs,
|
|
|
|
unsigned int n_outputs)
|
2013-07-30 09:36:18 +00:00
|
|
|
{
|
2019-01-11 14:35:42 +00:00
|
|
|
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
|
2020-02-25 15:54:20 +00:00
|
|
|
g_autoptr (GList) to_configure_outputs = NULL;
|
|
|
|
g_autoptr (GList) to_configure_crtcs = NULL;
|
2013-07-30 09:36:18 +00:00
|
|
|
unsigned i;
|
2019-01-11 14:35:42 +00:00
|
|
|
GList *gpus;
|
2017-03-24 09:35:51 +00:00
|
|
|
GList *l;
|
2013-07-30 09:36:18 +00:00
|
|
|
|
2020-02-25 15:54:20 +00:00
|
|
|
gpus = meta_backend_get_gpus (backend);
|
|
|
|
for (l = gpus; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaGpu *gpu = l->data;
|
|
|
|
GList *crtcs;
|
|
|
|
GList *outputs;
|
|
|
|
|
|
|
|
outputs = g_list_copy (meta_gpu_get_outputs (gpu));
|
|
|
|
to_configure_outputs = g_list_concat (to_configure_outputs, outputs);
|
|
|
|
|
|
|
|
crtcs = g_list_copy (meta_gpu_get_crtcs (gpu));
|
|
|
|
to_configure_crtcs = g_list_concat (to_configure_crtcs, crtcs);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
for (l = meta_monitor_manager_get_virtual_monitors (manager); l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaVirtualMonitor *virtual_monitor = l->data;
|
|
|
|
MetaOutput *output = meta_virtual_monitor_get_output (virtual_monitor);
|
|
|
|
MetaCrtc *crtc = meta_virtual_monitor_get_crtc (virtual_monitor);
|
|
|
|
|
|
|
|
to_configure_outputs = g_list_append (to_configure_outputs, output);
|
|
|
|
to_configure_crtcs = g_list_append (to_configure_crtcs, crtc);
|
|
|
|
}
|
|
|
|
|
2013-07-30 09:36:18 +00:00
|
|
|
for (i = 0; i < n_crtcs; i++)
|
|
|
|
{
|
2020-02-25 19:30:46 +00:00
|
|
|
MetaCrtcAssignment *crtc_assignment = crtcs[i];
|
|
|
|
MetaCrtc *crtc = crtc_assignment->crtc;
|
2013-07-30 09:36:18 +00:00
|
|
|
|
2020-02-25 15:54:20 +00:00
|
|
|
to_configure_crtcs = g_list_remove (to_configure_crtcs, crtc);
|
2013-07-30 09:36:18 +00:00
|
|
|
|
2020-02-25 19:30:46 +00:00
|
|
|
if (crtc_assignment->mode == NULL)
|
2013-07-30 09:36:18 +00:00
|
|
|
{
|
2020-01-14 21:34:44 +00:00
|
|
|
meta_crtc_unset_config (crtc);
|
2013-07-30 09:36:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-12 06:55:06 +00:00
|
|
|
unsigned int j;
|
2013-07-30 09:36:18 +00:00
|
|
|
|
2020-01-14 21:34:44 +00:00
|
|
|
meta_crtc_set_config (crtc,
|
2020-02-25 19:30:46 +00:00
|
|
|
&crtc_assignment->layout,
|
|
|
|
crtc_assignment->mode,
|
|
|
|
crtc_assignment->transform);
|
2016-08-03 07:16:16 +00:00
|
|
|
|
2020-02-25 19:30:46 +00:00
|
|
|
for (j = 0; j < crtc_assignment->outputs->len; j++)
|
2016-08-03 07:16:16 +00:00
|
|
|
{
|
2020-02-25 19:30:46 +00:00
|
|
|
MetaOutput *output = g_ptr_array_index (crtc_assignment->outputs,
|
|
|
|
j);
|
|
|
|
MetaOutputAssignment *output_assignment;
|
2016-08-03 07:16:16 +00:00
|
|
|
|
2020-02-25 15:54:20 +00:00
|
|
|
to_configure_outputs = g_list_remove (to_configure_outputs,
|
|
|
|
output);
|
2020-02-25 17:37:21 +00:00
|
|
|
|
2020-02-25 19:30:46 +00:00
|
|
|
output_assignment = meta_find_output_assignment (outputs,
|
|
|
|
n_outputs,
|
|
|
|
output);
|
|
|
|
meta_output_assign_crtc (output, crtc, output_assignment);
|
2016-08-03 07:16:16 +00:00
|
|
|
}
|
2013-07-30 09:36:18 +00:00
|
|
|
}
|
2016-07-31 21:41:26 +00:00
|
|
|
}
|
2017-07-10 10:19:32 +00:00
|
|
|
|
2020-02-25 17:37:21 +00:00
|
|
|
g_list_foreach (to_configure_crtcs,
|
|
|
|
(GFunc) meta_crtc_unset_config,
|
|
|
|
NULL);
|
|
|
|
g_list_foreach (to_configure_outputs,
|
|
|
|
(GFunc) meta_output_unassign_crtc,
|
|
|
|
NULL);
|
2017-01-09 06:31:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_screen_size (MetaMonitorManager *manager,
|
|
|
|
MetaMonitorsConfig *config)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
int screen_width = 0;
|
|
|
|
int screen_height = 0;
|
|
|
|
|
|
|
|
for (l = config->logical_monitor_configs; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaLogicalMonitorConfig *logical_monitor_config = l->data;
|
|
|
|
int right_edge;
|
|
|
|
int bottom_edge;
|
|
|
|
|
|
|
|
right_edge = (logical_monitor_config->layout.width +
|
|
|
|
logical_monitor_config->layout.x);
|
|
|
|
if (right_edge > screen_width)
|
|
|
|
screen_width = right_edge;
|
|
|
|
|
|
|
|
bottom_edge = (logical_monitor_config->layout.height +
|
|
|
|
logical_monitor_config->layout.y);
|
|
|
|
if (bottom_edge > screen_height)
|
|
|
|
screen_height = bottom_edge;
|
|
|
|
}
|
2013-07-30 09:36:18 +00:00
|
|
|
|
|
|
|
manager->screen_width = screen_width;
|
|
|
|
manager->screen_height = screen_height;
|
2017-01-09 06:31:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_apply_monitors_config (MetaMonitorManager *manager,
|
|
|
|
MetaMonitorsConfig *config,
|
|
|
|
MetaMonitorsConfigMethod method,
|
|
|
|
GError **error)
|
2017-01-09 06:31:18 +00:00
|
|
|
{
|
2020-02-25 19:30:46 +00:00
|
|
|
GPtrArray *crtc_assignments;
|
|
|
|
GPtrArray *output_assignments;
|
2017-01-09 06:31:18 +00:00
|
|
|
|
2017-01-12 05:47:54 +00:00
|
|
|
if (!config)
|
|
|
|
{
|
2020-12-21 06:59:32 +00:00
|
|
|
if (!manager->in_init)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
MetaRenderer *renderer = meta_backend_get_renderer (backend);
|
|
|
|
|
|
|
|
meta_renderer_native_reset_modes (META_RENDERER_NATIVE (renderer));
|
|
|
|
}
|
|
|
|
|
2017-04-12 06:15:33 +00:00
|
|
|
manager->screen_width = META_MONITOR_MANAGER_MIN_SCREEN_WIDTH;
|
|
|
|
manager->screen_height = META_MONITOR_MANAGER_MIN_SCREEN_HEIGHT;
|
2017-01-20 06:50:11 +00:00
|
|
|
meta_monitor_manager_rebuild (manager, NULL);
|
2017-01-12 05:47:54 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2017-01-09 06:31:18 +00:00
|
|
|
if (!meta_monitor_config_manager_assign (manager, config,
|
2020-02-25 19:30:46 +00:00
|
|
|
&crtc_assignments,
|
|
|
|
&output_assignments,
|
2017-01-09 06:31:18 +00:00
|
|
|
error))
|
|
|
|
return FALSE;
|
|
|
|
|
2017-02-14 11:54:04 +00:00
|
|
|
if (method == META_MONITORS_CONFIG_METHOD_VERIFY)
|
|
|
|
{
|
2020-02-25 19:30:46 +00:00
|
|
|
g_ptr_array_free (crtc_assignments, TRUE);
|
|
|
|
g_ptr_array_free (output_assignments, TRUE);
|
2017-02-14 11:54:04 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2017-01-09 06:31:18 +00:00
|
|
|
apply_crtc_assignments (manager,
|
2020-02-25 19:30:46 +00:00
|
|
|
(MetaCrtcAssignment **) crtc_assignments->pdata,
|
|
|
|
crtc_assignments->len,
|
|
|
|
(MetaOutputAssignment **) output_assignments->pdata,
|
|
|
|
output_assignments->len);
|
2017-01-09 06:31:18 +00:00
|
|
|
|
2020-02-25 19:30:46 +00:00
|
|
|
g_ptr_array_free (crtc_assignments, TRUE);
|
|
|
|
g_ptr_array_free (output_assignments, TRUE);
|
2017-01-09 06:31:18 +00:00
|
|
|
|
|
|
|
update_screen_size (manager, config);
|
|
|
|
meta_monitor_manager_rebuild (manager, config);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-10-10 09:47:58 +00:00
|
|
|
MetaKmsCrtcGamma *
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_get_cached_crtc_gamma (MetaMonitorManagerNative *manager_native,
|
|
|
|
MetaCrtcKms *crtc_kms)
|
2020-10-10 09:47:58 +00:00
|
|
|
{
|
|
|
|
uint64_t crtc_id;
|
|
|
|
|
|
|
|
crtc_id = meta_crtc_get_id (META_CRTC (crtc_kms));
|
2020-12-17 21:12:41 +00:00
|
|
|
return g_hash_table_lookup (manager_native->crtc_gamma_cache,
|
2020-10-10 09:47:58 +00:00
|
|
|
GUINT_TO_POINTER (crtc_id));
|
|
|
|
}
|
|
|
|
|
2022-08-01 21:05:28 +00:00
|
|
|
void
|
|
|
|
meta_monitor_manager_native_update_cached_crtc_gamma (MetaMonitorManagerNative *manager_native,
|
|
|
|
MetaCrtcKms *crtc_kms,
|
|
|
|
MetaKmsCrtcGamma *crtc_gamma)
|
2013-07-30 09:36:18 +00:00
|
|
|
{
|
2022-08-01 21:05:28 +00:00
|
|
|
MetaCrtc *crtc = META_CRTC (crtc_kms);
|
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
|
|
|
|
2020-12-17 21:12:41 +00:00
|
|
|
g_hash_table_replace (manager_native->crtc_gamma_cache,
|
2020-10-10 09:47:58 +00:00
|
|
|
GUINT_TO_POINTER (meta_crtc_get_id (crtc)),
|
2022-08-01 21:05:28 +00:00
|
|
|
crtc_gamma);
|
2013-07-30 09:36:18 +00:00
|
|
|
}
|
|
|
|
|
2016-12-21 08:00:29 +00:00
|
|
|
static void
|
|
|
|
handle_hotplug_event (MetaMonitorManager *manager)
|
|
|
|
{
|
2021-01-25 20:10:53 +00:00
|
|
|
meta_monitor_manager_reload (manager);
|
2016-12-21 08:00:29 +00:00
|
|
|
}
|
|
|
|
|
2019-01-10 18:01:29 +00:00
|
|
|
static void
|
2022-03-17 09:22:05 +00:00
|
|
|
on_kms_resources_changed (MetaKms *kms,
|
|
|
|
MetaKmsResourceChanges changes,
|
|
|
|
MetaMonitorManager *manager)
|
2019-08-05 12:08:08 +00:00
|
|
|
{
|
2022-02-10 13:53:38 +00:00
|
|
|
gboolean needs_emit_privacy_screen_change = FALSE;
|
|
|
|
|
2022-03-17 09:22:05 +00:00
|
|
|
g_assert (changes != META_KMS_RESOURCE_CHANGE_NONE);
|
2020-07-31 19:37:17 +00:00
|
|
|
|
2022-03-17 09:22:05 +00:00
|
|
|
if (changes == META_KMS_RESOURCE_CHANGE_GAMMA)
|
2021-03-21 22:11:24 +00:00
|
|
|
{
|
|
|
|
meta_dbus_display_config_emit_monitors_changed (manager->display_config);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-17 09:22:05 +00:00
|
|
|
if (changes & META_KMS_RESOURCE_CHANGE_PRIVACY_SCREEN)
|
2021-08-02 16:22:46 +00:00
|
|
|
{
|
|
|
|
if (manager->privacy_screen_change_state ==
|
|
|
|
META_PRIVACY_SCREEN_CHANGE_STATE_NONE)
|
|
|
|
{
|
|
|
|
/* Privacy screen has been changed by "something", the best guess
|
|
|
|
* we can do is that has been triggered by an hotkey.
|
|
|
|
*/
|
|
|
|
manager->privacy_screen_change_state =
|
|
|
|
META_PRIVACY_SCREEN_CHANGE_STATE_PENDING_HOTKEY;
|
|
|
|
}
|
|
|
|
|
2022-02-10 13:53:38 +00:00
|
|
|
needs_emit_privacy_screen_change = TRUE;
|
2021-08-02 16:22:46 +00:00
|
|
|
|
2022-03-17 09:22:05 +00:00
|
|
|
if (changes == META_KMS_RESOURCE_CHANGE_PRIVACY_SCREEN)
|
2022-02-10 13:53:38 +00:00
|
|
|
goto out;
|
2021-08-02 16:22:46 +00:00
|
|
|
}
|
2021-03-22 00:27:39 +00:00
|
|
|
|
2019-08-05 12:08:08 +00:00
|
|
|
handle_hotplug_event (manager);
|
2022-02-10 13:53:38 +00:00
|
|
|
|
|
|
|
out:
|
|
|
|
if (needs_emit_privacy_screen_change)
|
|
|
|
meta_monitor_manager_maybe_emit_privacy_screen_change (manager);
|
2019-08-05 12:08:08 +00:00
|
|
|
}
|
|
|
|
|
2019-01-10 18:01:29 +00:00
|
|
|
static void
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_connect_hotplug_handler (MetaMonitorManagerNative *manager_native)
|
2019-01-10 18:01:29 +00:00
|
|
|
{
|
2020-12-17 21:12:41 +00:00
|
|
|
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_native);
|
2019-01-10 18:01:29 +00:00
|
|
|
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
|
2019-08-22 13:15:51 +00:00
|
|
|
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
|
|
|
|
MetaKms *kms = meta_backend_native_get_kms (backend_native);
|
|
|
|
|
2020-12-17 21:12:41 +00:00
|
|
|
manager_native->kms_resources_changed_handler_id =
|
2019-08-22 13:15:51 +00:00
|
|
|
g_signal_connect (kms, "resources-changed",
|
|
|
|
G_CALLBACK (on_kms_resources_changed), manager);
|
2019-01-10 18:01:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_disconnect_hotplug_handler (MetaMonitorManagerNative *manager_native)
|
2019-01-10 18:01:29 +00:00
|
|
|
{
|
2020-12-17 21:12:41 +00:00
|
|
|
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_native);
|
2019-01-10 18:01:29 +00:00
|
|
|
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
|
2019-08-22 13:15:51 +00:00
|
|
|
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
|
|
|
|
MetaKms *kms = meta_backend_native_get_kms (backend_native);
|
2019-01-10 18:01:29 +00:00
|
|
|
|
2020-12-17 21:12:41 +00:00
|
|
|
g_clear_signal_handler (&manager_native->kms_resources_changed_handler_id, kms);
|
2019-01-10 18:01:29 +00:00
|
|
|
}
|
|
|
|
|
2017-03-10 08:29:11 +00:00
|
|
|
void
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_pause (MetaMonitorManagerNative *manager_native)
|
2017-03-10 08:29:11 +00:00
|
|
|
{
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_disconnect_hotplug_handler (manager_native);
|
2017-03-10 08:29:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_resume (MetaMonitorManagerNative *manager_native)
|
2017-03-10 08:29:11 +00:00
|
|
|
{
|
2021-04-21 08:44:13 +00:00
|
|
|
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_native);
|
|
|
|
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
|
|
|
|
GList *l;
|
|
|
|
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_connect_hotplug_handler (manager_native);
|
2021-04-21 08:44:13 +00:00
|
|
|
|
|
|
|
for (l = meta_backend_get_gpus (backend); l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaGpu *gpu = l->data;
|
|
|
|
|
|
|
|
g_list_foreach (meta_gpu_get_crtcs (gpu),
|
|
|
|
(GFunc) meta_crtc_kms_invalidate_gamma,
|
|
|
|
NULL);
|
|
|
|
}
|
2017-03-10 08:29:11 +00:00
|
|
|
}
|
|
|
|
|
2017-03-08 08:05:00 +00:00
|
|
|
static gboolean
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_is_transform_handled (MetaMonitorManager *manager,
|
|
|
|
MetaCrtc *crtc,
|
|
|
|
MetaMonitorTransform transform)
|
2017-03-08 08:05:00 +00:00
|
|
|
{
|
2021-01-26 15:13:18 +00:00
|
|
|
return meta_crtc_native_is_transform_handled (META_CRTC_NATIVE (crtc),
|
|
|
|
transform);
|
2017-03-08 08:05:00 +00:00
|
|
|
}
|
|
|
|
|
2017-06-10 14:10:57 +00:00
|
|
|
static MetaMonitorScalesConstraint
|
|
|
|
get_monitor_scale_constraints_from_layout_mode (MetaLogicalMonitorLayoutMode layout_mode)
|
2017-01-26 09:14:32 +00:00
|
|
|
{
|
2017-06-05 07:59:47 +00:00
|
|
|
MetaMonitorScalesConstraint constraints =
|
|
|
|
META_MONITOR_SCALES_CONSTRAINT_NONE;
|
|
|
|
|
2017-05-25 09:20:59 +00:00
|
|
|
switch (layout_mode)
|
|
|
|
{
|
|
|
|
case META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL:
|
|
|
|
break;
|
|
|
|
case META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL:
|
2017-06-05 07:59:47 +00:00
|
|
|
constraints |= META_MONITOR_SCALES_CONSTRAINT_NO_FRAC;
|
2017-05-25 09:20:59 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-06-05 07:59:47 +00:00
|
|
|
|
2017-06-10 14:10:57 +00:00
|
|
|
return constraints;
|
|
|
|
}
|
|
|
|
|
|
|
|
static float
|
|
|
|
meta_monitor_manager_native_calculate_monitor_mode_scale (MetaMonitorManager *manager,
|
|
|
|
MetaLogicalMonitorLayoutMode layout_mode,
|
|
|
|
MetaMonitor *monitor,
|
|
|
|
MetaMonitorMode *monitor_mode)
|
|
|
|
{
|
|
|
|
MetaMonitorScalesConstraint constraints =
|
|
|
|
get_monitor_scale_constraints_from_layout_mode (layout_mode);
|
|
|
|
|
|
|
|
return meta_monitor_calculate_mode_scale (monitor, monitor_mode, constraints);
|
|
|
|
}
|
|
|
|
|
|
|
|
static float *
|
|
|
|
meta_monitor_manager_native_calculate_supported_scales (MetaMonitorManager *manager,
|
|
|
|
MetaLogicalMonitorLayoutMode layout_mode,
|
|
|
|
MetaMonitor *monitor,
|
|
|
|
MetaMonitorMode *monitor_mode,
|
|
|
|
int *n_supported_scales)
|
|
|
|
{
|
|
|
|
MetaMonitorScalesConstraint constraints =
|
|
|
|
get_monitor_scale_constraints_from_layout_mode (layout_mode);
|
|
|
|
|
2017-06-05 07:59:47 +00:00
|
|
|
return meta_monitor_calculate_supported_scales (monitor, monitor_mode,
|
|
|
|
constraints,
|
|
|
|
n_supported_scales);
|
2017-01-26 09:14:32 +00:00
|
|
|
}
|
|
|
|
|
2017-02-07 08:01:40 +00:00
|
|
|
static MetaMonitorManagerCapability
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_get_capabilities (MetaMonitorManager *manager)
|
2017-02-07 08:01:40 +00:00
|
|
|
{
|
2017-07-10 09:39:07 +00:00
|
|
|
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
|
2017-04-21 08:40:51 +00:00
|
|
|
MetaSettings *settings = meta_backend_get_settings (backend);
|
2017-02-07 08:01:40 +00:00
|
|
|
MetaMonitorManagerCapability capabilities =
|
|
|
|
META_MONITOR_MANAGER_CAPABILITY_NONE;
|
|
|
|
|
2017-04-21 08:40:51 +00:00
|
|
|
if (meta_settings_is_experimental_feature_enabled (
|
|
|
|
settings,
|
2017-02-24 10:10:52 +00:00
|
|
|
META_EXPERIMENTAL_FEATURE_SCALE_MONITOR_FRAMEBUFFER))
|
|
|
|
capabilities |= META_MONITOR_MANAGER_CAPABILITY_LAYOUT_MODE;
|
|
|
|
|
2017-02-07 08:01:40 +00:00
|
|
|
return capabilities;
|
|
|
|
}
|
|
|
|
|
2017-02-15 08:06:46 +00:00
|
|
|
static gboolean
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_get_max_screen_size (MetaMonitorManager *manager,
|
|
|
|
int *max_width,
|
|
|
|
int *max_height)
|
2017-02-15 08:06:46 +00:00
|
|
|
{
|
2018-12-04 13:55:05 +00:00
|
|
|
return FALSE;
|
2017-02-15 08:06:46 +00:00
|
|
|
}
|
|
|
|
|
2017-02-24 10:10:52 +00:00
|
|
|
static MetaLogicalMonitorLayoutMode
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_get_default_layout_mode (MetaMonitorManager *manager)
|
2017-02-24 10:10:52 +00:00
|
|
|
{
|
2017-07-10 09:39:07 +00:00
|
|
|
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
|
2017-04-21 08:40:51 +00:00
|
|
|
MetaSettings *settings = meta_backend_get_settings (backend);
|
|
|
|
|
|
|
|
if (meta_settings_is_experimental_feature_enabled (
|
|
|
|
settings,
|
2017-02-24 10:10:52 +00:00
|
|
|
META_EXPERIMENTAL_FEATURE_SCALE_MONITOR_FRAMEBUFFER))
|
|
|
|
return META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL;
|
|
|
|
else
|
|
|
|
return META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
static MetaVirtualMonitorNative *
|
|
|
|
find_virtual_monitor (MetaMonitorManagerNative *manager_native,
|
|
|
|
uint64_t id)
|
|
|
|
{
|
|
|
|
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_native);
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = meta_monitor_manager_get_virtual_monitors (manager); l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaVirtualMonitorNative *virtual_monitor_native = l->data;
|
|
|
|
|
|
|
|
if (meta_virtual_monitor_native_get_id (virtual_monitor_native) == id)
|
|
|
|
return virtual_monitor_native;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint64_t
|
|
|
|
allocate_virtual_monitor_id (MetaMonitorManagerNative *manager_native)
|
|
|
|
{
|
|
|
|
uint64_t id;
|
|
|
|
|
|
|
|
id = 0;
|
|
|
|
|
|
|
|
while (TRUE)
|
|
|
|
{
|
|
|
|
if (!find_virtual_monitor (manager_native, id))
|
|
|
|
return id;
|
|
|
|
|
|
|
|
id++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-16 10:25:37 +00:00
|
|
|
static gboolean
|
|
|
|
rebuild_virtual_idle_cb (gpointer user_data)
|
|
|
|
{
|
|
|
|
MetaMonitorManager *manager = user_data;
|
|
|
|
MetaMonitorManagerNative *manager_native =
|
|
|
|
META_MONITOR_MANAGER_NATIVE (manager);
|
|
|
|
|
|
|
|
manager_native->rebuild_virtual_idle_id = 0;
|
|
|
|
|
|
|
|
meta_monitor_manager_reconfigure (manager);
|
|
|
|
|
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_virtual_monitor_mode_changed (MetaVirtualMonitor *virtual_monitor,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
MetaMonitorManager *manager)
|
|
|
|
{
|
|
|
|
MetaMonitorManagerNative *manager_native =
|
|
|
|
META_MONITOR_MANAGER_NATIVE (manager);
|
|
|
|
|
|
|
|
if (manager_native->rebuild_virtual_idle_id)
|
|
|
|
return;
|
|
|
|
|
|
|
|
manager_native->rebuild_virtual_idle_id =
|
|
|
|
g_idle_add (rebuild_virtual_idle_cb, 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
|
|
|
static MetaVirtualMonitor *
|
|
|
|
meta_monitor_manager_native_create_virtual_monitor (MetaMonitorManager *manager,
|
|
|
|
const MetaVirtualMonitorInfo *info,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
MetaMonitorManagerNative *manager_native =
|
|
|
|
META_MONITOR_MANAGER_NATIVE (manager);
|
|
|
|
MetaVirtualMonitorNative *virtual_monitor_native;
|
|
|
|
uint64_t id;
|
|
|
|
|
|
|
|
id = allocate_virtual_monitor_id (manager_native);
|
|
|
|
virtual_monitor_native = meta_virtual_monitor_native_new (id, info);
|
2021-12-16 10:25:37 +00:00
|
|
|
g_signal_connect (virtual_monitor_native, "notify::crtc-mode",
|
|
|
|
G_CALLBACK (on_virtual_monitor_mode_changed),
|
|
|
|
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
|
|
|
return META_VIRTUAL_MONITOR (virtual_monitor_native);
|
|
|
|
}
|
|
|
|
|
2021-01-18 21:34:04 +00:00
|
|
|
static void
|
|
|
|
meta_monitor_manager_native_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
MetaMonitorManagerNative *manager_native =
|
|
|
|
META_MONITOR_MANAGER_NATIVE (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_NEED_OUTPUTS:
|
|
|
|
manager_native->needs_outputs = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-10 09:47:58 +00:00
|
|
|
static void
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_dispose (GObject *object)
|
2020-10-10 09:47:58 +00:00
|
|
|
{
|
2020-12-17 21:12:41 +00:00
|
|
|
MetaMonitorManagerNative *manager_native =
|
|
|
|
META_MONITOR_MANAGER_NATIVE (object);
|
2020-10-10 09:47:58 +00:00
|
|
|
|
2021-12-16 10:25:37 +00:00
|
|
|
g_clear_handle_id (&manager_native->rebuild_virtual_idle_id, g_source_remove);
|
2020-12-17 21:12:41 +00:00
|
|
|
g_clear_pointer (&manager_native->crtc_gamma_cache,
|
2020-10-10 09:47:58 +00:00
|
|
|
g_hash_table_unref);
|
|
|
|
|
2020-12-17 21:12:41 +00:00
|
|
|
G_OBJECT_CLASS (meta_monitor_manager_native_parent_class)->dispose (object);
|
2020-10-10 09:47:58 +00:00
|
|
|
}
|
|
|
|
|
2017-07-06 08:00:56 +00:00
|
|
|
static gboolean
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_initable_init (GInitable *initable,
|
|
|
|
GCancellable *cancellable,
|
|
|
|
GError **error)
|
2017-07-06 08:00:56 +00:00
|
|
|
{
|
2020-12-17 21:12:41 +00:00
|
|
|
MetaMonitorManagerNative *manager_native =
|
|
|
|
META_MONITOR_MANAGER_NATIVE (initable);
|
|
|
|
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_native);
|
2019-01-11 14:35:42 +00:00
|
|
|
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
|
2018-08-13 10:22:22 +00:00
|
|
|
gboolean can_have_outputs;
|
2019-01-11 14:35:42 +00:00
|
|
|
GList *l;
|
2017-07-06 08:00:56 +00:00
|
|
|
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_connect_hotplug_handler (manager_native);
|
2017-07-05 10:06:06 +00:00
|
|
|
|
2018-08-13 10:22:22 +00:00
|
|
|
can_have_outputs = FALSE;
|
2019-01-11 14:35:42 +00:00
|
|
|
for (l = meta_backend_get_gpus (backend); l; l = l->next)
|
2018-08-13 10:22:22 +00:00
|
|
|
{
|
|
|
|
MetaGpuKms *gpu_kms = l->data;
|
|
|
|
|
|
|
|
if (meta_gpu_kms_can_have_outputs (gpu_kms))
|
|
|
|
{
|
|
|
|
can_have_outputs = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-01-18 21:34:04 +00:00
|
|
|
|
|
|
|
if (manager_native->needs_outputs && !can_have_outputs)
|
2018-08-13 10:22:22 +00:00
|
|
|
{
|
|
|
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
|
|
|
|
"No GPUs with outputs found");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-12-17 21:12:41 +00:00
|
|
|
manager_native->crtc_gamma_cache =
|
2020-10-10 09:47:58 +00:00
|
|
|
g_hash_table_new_full (NULL, NULL,
|
|
|
|
NULL,
|
|
|
|
(GDestroyNotify) meta_kms_crtc_gamma_free);
|
|
|
|
|
2017-07-06 08:00:56 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
initable_iface_init (GInitableIface *initable_iface)
|
|
|
|
{
|
2020-12-17 21:12:41 +00:00
|
|
|
initable_iface->init = meta_monitor_manager_native_initable_init;
|
2017-07-06 08:00:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_init (MetaMonitorManagerNative *manager_native)
|
2017-07-06 08:00:56 +00:00
|
|
|
{
|
2021-01-18 21:34:04 +00:00
|
|
|
manager_native->needs_outputs = TRUE;
|
2017-07-05 10:06:06 +00:00
|
|
|
}
|
|
|
|
|
2013-07-30 09:36:18 +00:00
|
|
|
static void
|
2020-12-17 21:12:41 +00:00
|
|
|
meta_monitor_manager_native_class_init (MetaMonitorManagerNativeClass *klass)
|
2013-07-30 09:36:18 +00:00
|
|
|
{
|
2020-10-10 09:47:58 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2013-07-30 09:36:18 +00:00
|
|
|
MetaMonitorManagerClass *manager_class = META_MONITOR_MANAGER_CLASS (klass);
|
|
|
|
|
2021-01-18 21:34:04 +00:00
|
|
|
object_class->set_property = meta_monitor_manager_native_set_property;
|
2020-12-17 21:12:41 +00:00
|
|
|
object_class->dispose = meta_monitor_manager_native_dispose;
|
|
|
|
|
|
|
|
manager_class->read_edid =
|
|
|
|
meta_monitor_manager_native_read_edid;
|
|
|
|
manager_class->read_current_state =
|
|
|
|
meta_monitor_manager_native_read_current_state;
|
|
|
|
manager_class->ensure_initial_config =
|
|
|
|
meta_monitor_manager_native_ensure_initial_config;
|
|
|
|
manager_class->apply_monitors_config =
|
|
|
|
meta_monitor_manager_native_apply_monitors_config;
|
|
|
|
manager_class->set_power_save_mode =
|
|
|
|
meta_monitor_manager_native_set_power_save_mode;
|
|
|
|
manager_class->is_transform_handled =
|
|
|
|
meta_monitor_manager_native_is_transform_handled;
|
|
|
|
manager_class->calculate_monitor_mode_scale =
|
|
|
|
meta_monitor_manager_native_calculate_monitor_mode_scale;
|
|
|
|
manager_class->calculate_supported_scales =
|
|
|
|
meta_monitor_manager_native_calculate_supported_scales;
|
|
|
|
manager_class->get_capabilities =
|
|
|
|
meta_monitor_manager_native_get_capabilities;
|
|
|
|
manager_class->get_max_screen_size =
|
|
|
|
meta_monitor_manager_native_get_max_screen_size;
|
|
|
|
manager_class->get_default_layout_mode =
|
|
|
|
meta_monitor_manager_native_get_default_layout_mode;
|
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
|
|
|
manager_class->create_virtual_monitor =
|
|
|
|
meta_monitor_manager_native_create_virtual_monitor;
|
2021-01-18 21:34:04 +00:00
|
|
|
|
|
|
|
obj_props[PROP_NEED_OUTPUTS] =
|
|
|
|
g_param_spec_boolean ("needs-outputs",
|
|
|
|
"needs-outputs",
|
|
|
|
"Whether any outputs are needed for operation",
|
|
|
|
TRUE,
|
|
|
|
G_PARAM_WRITABLE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
g_object_class_install_properties (object_class, N_PROPS, obj_props);
|
2016-07-31 21:41:26 +00:00
|
|
|
}
|