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 22:36:41 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018 Red Hat
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2023-08-07 11:50:23 +02:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
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 22:36:41 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "backends/native/meta-kms-update.h"
|
|
|
|
#include "backends/native/meta-kms-update-private.h"
|
|
|
|
|
|
|
|
#include "backends/meta-display-config-shared.h"
|
2020-07-16 23:38:10 +02:00
|
|
|
#include "backends/native/meta-kms-connector.h"
|
2020-07-17 09:39:32 +02:00
|
|
|
#include "backends/native/meta-kms-crtc.h"
|
2022-06-22 00:23:03 +02:00
|
|
|
#include "backends/native/meta-kms-impl-device.h"
|
2020-07-02 15:58:59 +02:00
|
|
|
#include "backends/native/meta-kms-mode-private.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 22:36:41 +02:00
|
|
|
#include "backends/native/meta-kms-plane.h"
|
2023-02-14 20:15:51 +01:00
|
|
|
#include "backends/native/meta-kms-private.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 22:36:41 +02:00
|
|
|
|
|
|
|
struct _MetaKmsUpdate
|
|
|
|
{
|
2020-07-16 23:38:10 +02:00
|
|
|
MetaKmsDevice *device;
|
|
|
|
|
2022-06-13 22:43:57 +02:00
|
|
|
gboolean is_sealed;
|
2019-06-19 22:15:12 +02:00
|
|
|
|
kms/impl-device: Add deadline based KMS commit scheduling
This makes it possible to post KMS updates that will always defer until
just before the scanout deadline. This is useful to allow queuing cursor
updates where we don't want to post them to KMS immediately, but rather
wait until as late as possible to get lower latency.
We cannot delay primary plane compositions however, and this is due to
how the kernel may prioritize GPU work - not until a pipeline gets
attached to a atomic commit will it in some drivers get bumped to high
priority. This means we still need to post any update that depends on
OpenGL pipelines as soon as possible.
To avoid working on compositing, then getting stomped on the feet by the
deadline scheduler, the deadline timer is disarmed whenever there is a
frame currently being painted. This will still allow new cursor updates
to arrive during composition, but will delay the actual KMS commit until
the primary plane update has been posted.
Still, even for cursor-only we still need higher than default timing
capabilities, thus the deadline scheduler depends on the KMS thread
getting real-time scheduling priority. When the thread isn't realtime
scheduled, the KMS thread instead asks the main thread to "flush" the
commit as part of the regular frame update. A flushing update means one
that isn't set to always defer and has a latching CRTC.
The verbose KMS debug logging makes the processing take too long, making
us more likely to miss the deadline. Avoid this by increasing the
evasion length when debug logging is enabled. Not the best, but better
than changing the behavior completely.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2022-10-26 19:08:30 +02:00
|
|
|
gboolean is_latchable;
|
|
|
|
MetaKmsCrtc *latch_crtc;
|
|
|
|
|
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 22:36:41 +02:00
|
|
|
GList *mode_sets;
|
|
|
|
GList *plane_assignments;
|
2020-07-14 16:48:47 +02:00
|
|
|
GList *connector_updates;
|
2023-02-17 23:18:39 +01:00
|
|
|
GList *crtc_color_updates;
|
2020-10-01 18:28:13 +02:00
|
|
|
|
2021-01-22 11:31:18 +01:00
|
|
|
MetaKmsCustomPageFlip *custom_page_flip;
|
2020-10-02 16:06:35 +02:00
|
|
|
|
|
|
|
GList *page_flip_listeners;
|
2020-10-02 16:35:42 +02:00
|
|
|
GList *result_listeners;
|
2022-06-22 00:23:03 +02:00
|
|
|
|
2023-03-02 01:59:41 +01:00
|
|
|
gboolean needs_modeset;
|
|
|
|
|
2022-06-22 00:23:03 +02:00
|
|
|
MetaKmsImplDevice *impl_device;
|
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 22:36:41 +02:00
|
|
|
};
|
|
|
|
|
2019-11-09 00:17:33 +01:00
|
|
|
void
|
|
|
|
meta_kms_plane_feedback_free (MetaKmsPlaneFeedback *plane_feedback)
|
|
|
|
{
|
|
|
|
g_error_free (plane_feedback->error);
|
|
|
|
g_free (plane_feedback);
|
|
|
|
}
|
|
|
|
|
|
|
|
MetaKmsPlaneFeedback *
|
|
|
|
meta_kms_plane_feedback_new_take_error (MetaKmsPlane *plane,
|
|
|
|
MetaKmsCrtc *crtc,
|
|
|
|
GError *error)
|
|
|
|
{
|
|
|
|
MetaKmsPlaneFeedback *plane_feedback;
|
|
|
|
|
|
|
|
plane_feedback = g_new0 (MetaKmsPlaneFeedback, 1);
|
|
|
|
*plane_feedback = (MetaKmsPlaneFeedback) {
|
|
|
|
.plane = plane,
|
|
|
|
.crtc = crtc,
|
|
|
|
.error = error,
|
|
|
|
};
|
|
|
|
|
|
|
|
return plane_feedback;
|
|
|
|
}
|
|
|
|
|
2021-12-08 21:20:52 +01:00
|
|
|
MetaKmsPlaneFeedback *
|
|
|
|
meta_kms_plane_feedback_new_failed (MetaKmsPlane *plane,
|
|
|
|
MetaKmsCrtc *crtc,
|
|
|
|
const char *error_message)
|
|
|
|
{
|
|
|
|
GError *error;
|
|
|
|
|
|
|
|
error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, error_message);
|
|
|
|
return meta_kms_plane_feedback_new_take_error (plane, crtc, error);
|
|
|
|
}
|
|
|
|
|
2019-11-09 00:14:36 +01:00
|
|
|
MetaKmsFeedback *
|
2020-10-02 15:45:28 +02:00
|
|
|
meta_kms_feedback_new_passed (GList *failed_planes)
|
2019-11-09 00:14:36 +01:00
|
|
|
{
|
|
|
|
MetaKmsFeedback *feedback;
|
|
|
|
|
|
|
|
feedback = g_new0 (MetaKmsFeedback, 1);
|
|
|
|
*feedback = (MetaKmsFeedback) {
|
|
|
|
.result = META_KMS_FEEDBACK_PASSED,
|
2020-10-02 15:45:28 +02:00
|
|
|
.failed_planes = failed_planes,
|
2019-11-09 00:14:36 +01:00
|
|
|
};
|
2022-01-10 17:01:41 +01:00
|
|
|
g_atomic_ref_count_init (&feedback->ref_count);
|
2019-11-09 00:14:36 +01:00
|
|
|
|
|
|
|
return feedback;
|
|
|
|
}
|
|
|
|
|
|
|
|
MetaKmsFeedback *
|
2019-11-09 00:17:33 +01:00
|
|
|
meta_kms_feedback_new_failed (GList *failed_planes,
|
|
|
|
GError *error)
|
2019-11-09 00:14:36 +01:00
|
|
|
{
|
|
|
|
MetaKmsFeedback *feedback;
|
|
|
|
|
|
|
|
feedback = g_new0 (MetaKmsFeedback, 1);
|
|
|
|
*feedback = (MetaKmsFeedback) {
|
|
|
|
.result = META_KMS_FEEDBACK_FAILED,
|
|
|
|
.error = error,
|
2019-11-09 00:17:33 +01:00
|
|
|
.failed_planes = failed_planes,
|
2019-11-09 00:14:36 +01:00
|
|
|
};
|
2022-01-10 17:01:41 +01:00
|
|
|
g_atomic_ref_count_init (&feedback->ref_count);
|
2019-11-09 00:14:36 +01:00
|
|
|
|
|
|
|
return feedback;
|
|
|
|
}
|
|
|
|
|
2022-01-10 17:01:41 +01:00
|
|
|
MetaKmsFeedback *
|
|
|
|
meta_kms_feedback_ref (MetaKmsFeedback *feedback)
|
|
|
|
{
|
|
|
|
g_atomic_ref_count_inc (&feedback->ref_count);
|
|
|
|
return feedback;
|
|
|
|
}
|
|
|
|
|
2019-11-09 00:14:36 +01:00
|
|
|
void
|
2022-01-10 17:01:41 +01:00
|
|
|
meta_kms_feedback_unref (MetaKmsFeedback *feedback)
|
2019-11-09 00:14:36 +01:00
|
|
|
{
|
2022-01-10 17:01:41 +01:00
|
|
|
if (g_atomic_ref_count_dec (&feedback->ref_count))
|
|
|
|
{
|
|
|
|
g_list_free_full (feedback->failed_planes,
|
|
|
|
(GDestroyNotify) meta_kms_plane_feedback_free);
|
|
|
|
g_clear_error (&feedback->error);
|
|
|
|
g_free (feedback);
|
|
|
|
}
|
2019-11-09 00:14:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
MetaKmsFeedbackResult
|
2021-01-07 11:04:35 +01:00
|
|
|
meta_kms_feedback_get_result (const MetaKmsFeedback *feedback)
|
2019-11-09 00:14:36 +01:00
|
|
|
{
|
|
|
|
return feedback->result;
|
|
|
|
}
|
|
|
|
|
2023-05-05 16:37:34 +02:00
|
|
|
gboolean
|
|
|
|
meta_kms_feedback_did_pass (const MetaKmsFeedback *feedback)
|
|
|
|
{
|
|
|
|
return feedback->result == META_KMS_FEEDBACK_PASSED;
|
|
|
|
}
|
|
|
|
|
2019-11-09 00:17:33 +01:00
|
|
|
GList *
|
2021-01-07 11:04:35 +01:00
|
|
|
meta_kms_feedback_get_failed_planes (const MetaKmsFeedback *feedback)
|
2019-11-09 00:17:33 +01:00
|
|
|
{
|
|
|
|
return feedback->failed_planes;
|
|
|
|
}
|
|
|
|
|
2019-11-09 00:14:36 +01:00
|
|
|
const GError *
|
2021-01-07 11:04:35 +01:00
|
|
|
meta_kms_feedback_get_error (const MetaKmsFeedback *feedback)
|
2019-11-09 00:14:36 +01:00
|
|
|
{
|
|
|
|
return feedback->error;
|
|
|
|
}
|
|
|
|
|
2023-02-14 20:15:51 +01:00
|
|
|
void
|
|
|
|
meta_kms_feedback_dispatch_result (MetaKmsFeedback *feedback,
|
|
|
|
MetaKms *kms,
|
|
|
|
GList *result_listeners)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = result_listeners; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaKmsResultListener *listener = l->data;
|
|
|
|
|
|
|
|
meta_kms_result_listener_set_feedback (listener, feedback);
|
|
|
|
meta_kms_queue_result_callback (kms, listener);
|
|
|
|
}
|
|
|
|
g_list_free (result_listeners);
|
|
|
|
}
|
|
|
|
|
2021-09-03 19:39:12 +01:00
|
|
|
static void
|
|
|
|
meta_kms_fb_damage_free (MetaKmsFbDamage *fb_damage)
|
|
|
|
{
|
|
|
|
g_free (fb_damage->rects);
|
|
|
|
g_free (fb_damage);
|
|
|
|
}
|
|
|
|
|
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 22:36:41 +02:00
|
|
|
static void
|
|
|
|
meta_kms_plane_assignment_free (MetaKmsPlaneAssignment *plane_assignment)
|
|
|
|
{
|
2021-09-03 19:39:12 +01:00
|
|
|
g_clear_pointer (&plane_assignment->fb_damage, meta_kms_fb_damage_free);
|
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 22:36:41 +02:00
|
|
|
g_free (plane_assignment);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_kms_mode_set_free (MetaKmsModeSet *mode_set)
|
|
|
|
{
|
|
|
|
g_list_free (mode_set->connectors);
|
|
|
|
g_free (mode_set);
|
|
|
|
}
|
|
|
|
|
kms/impl-device: Add deadline based KMS commit scheduling
This makes it possible to post KMS updates that will always defer until
just before the scanout deadline. This is useful to allow queuing cursor
updates where we don't want to post them to KMS immediately, but rather
wait until as late as possible to get lower latency.
We cannot delay primary plane compositions however, and this is due to
how the kernel may prioritize GPU work - not until a pipeline gets
attached to a atomic commit will it in some drivers get bumped to high
priority. This means we still need to post any update that depends on
OpenGL pipelines as soon as possible.
To avoid working on compositing, then getting stomped on the feet by the
deadline scheduler, the deadline timer is disarmed whenever there is a
frame currently being painted. This will still allow new cursor updates
to arrive during composition, but will delay the actual KMS commit until
the primary plane update has been posted.
Still, even for cursor-only we still need higher than default timing
capabilities, thus the deadline scheduler depends on the KMS thread
getting real-time scheduling priority. When the thread isn't realtime
scheduled, the KMS thread instead asks the main thread to "flush" the
commit as part of the regular frame update. A flushing update means one
that isn't set to always defer and has a latching CRTC.
The verbose KMS debug logging makes the processing take too long, making
us more likely to miss the deadline. Avoid this by increasing the
evasion length when debug logging is enabled. Not the best, but better
than changing the behavior completely.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2022-10-26 19:08:30 +02:00
|
|
|
void
|
2022-06-05 21:16:11 +02:00
|
|
|
meta_kms_page_flip_listener_unref (MetaKmsPageFlipListener *listener)
|
kms/page-flip: Pass ownership of listener user data along with closure
In order to reliably manage the reference count of the user data passed
to page flip listeners - being the stage view - make the ownership of
this data travel through the different objects that take responsibility
of the next step.
Initially this is the MetaKmsPageFlipListener that belongs to a
MetaKmsUpdate.
When a page flip is successfully queued, the ownership is transferred to
a MetaKmsPageFlipClosure that is part of a MetaKmsPageFlipData. In the
simple impl device, the MetaKmsPageFlipData is passed to
drmModePageFlip(), then returned back via the DRM event. In the future
atomic impl device, the MetaKmsPageFlipData is stored in a table, then
retrieved when DRM event are handled.
When the DRM events are handled, the page flip listener's interface
callbacks are invoked, and after that, the user data is freed using the
passed GDestroyNotify function, in the main context, the same as where
the interface callbacks were called.
When a page flip fails, the ownership is also transferred to a
MetaKmsPageFlipClosure that is part of a MetaKmsPageFlipData. This page
flip data will be passed to the main context via a callback, where it
will discard the page flip, and free the user data using the provided
GDestroyNotify.
Note that this adds back a page flip listener type flag for telling the
KMS implementation whether to actively discard a page flip via the
interface, or just free the user data. Avoiding discarding via the
interface is needed for the direct scanout case, where we immediately
need to know the result in order to fall back to the composite pipeline
if the direct scanout failed. We do in fact also need active discard via
the interface paths, e.g. in the simple impl device when we're
asynchronously retrying a page flip, so replace the ad-hoc discard paths
in meta-renderer-native.c and replace them by not asking for no-discard
page flip error handling.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2020-12-16 08:41:14 +01:00
|
|
|
{
|
2022-12-21 18:51:05 +01:00
|
|
|
MetaKmsDevice *device;
|
|
|
|
|
2022-06-05 21:16:11 +02:00
|
|
|
if (!g_atomic_ref_count_dec (&listener->ref_count))
|
|
|
|
return;
|
|
|
|
|
2022-12-21 18:51:05 +01:00
|
|
|
device = meta_kms_crtc_get_device (listener->crtc);
|
|
|
|
meta_kms_queue_callback (meta_kms_device_get_kms (device),
|
|
|
|
listener->main_context,
|
|
|
|
NULL,
|
|
|
|
g_steal_pointer (&listener->user_data),
|
|
|
|
g_steal_pointer (&listener->destroy_notify));
|
|
|
|
g_free (listener);
|
kms/page-flip: Pass ownership of listener user data along with closure
In order to reliably manage the reference count of the user data passed
to page flip listeners - being the stage view - make the ownership of
this data travel through the different objects that take responsibility
of the next step.
Initially this is the MetaKmsPageFlipListener that belongs to a
MetaKmsUpdate.
When a page flip is successfully queued, the ownership is transferred to
a MetaKmsPageFlipClosure that is part of a MetaKmsPageFlipData. In the
simple impl device, the MetaKmsPageFlipData is passed to
drmModePageFlip(), then returned back via the DRM event. In the future
atomic impl device, the MetaKmsPageFlipData is stored in a table, then
retrieved when DRM event are handled.
When the DRM events are handled, the page flip listener's interface
callbacks are invoked, and after that, the user data is freed using the
passed GDestroyNotify function, in the main context, the same as where
the interface callbacks were called.
When a page flip fails, the ownership is also transferred to a
MetaKmsPageFlipClosure that is part of a MetaKmsPageFlipData. This page
flip data will be passed to the main context via a callback, where it
will discard the page flip, and free the user data using the provided
GDestroyNotify.
Note that this adds back a page flip listener type flag for telling the
KMS implementation whether to actively discard a page flip via the
interface, or just free the user data. Avoiding discarding via the
interface is needed for the direct scanout case, where we immediately
need to know the result in order to fall back to the composite pipeline
if the direct scanout failed. We do in fact also need active discard via
the interface paths, e.g. in the simple impl device when we're
asynchronously retrying a page flip, so replace the ad-hoc discard paths
in meta-renderer-native.c and replace them by not asking for no-discard
page flip error handling.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2020-12-16 08:41:14 +01:00
|
|
|
}
|
|
|
|
|
2020-10-02 16:53:16 +02:00
|
|
|
static gboolean
|
|
|
|
drop_plane_assignment (MetaKmsUpdate *update,
|
|
|
|
MetaKmsPlane *plane,
|
|
|
|
MetaKmsAssignPlaneFlag *out_flags)
|
2020-10-02 16:48:34 +02:00
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = update->plane_assignments; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaKmsPlaneAssignment *plane_assignment = l->data;
|
|
|
|
|
|
|
|
if (plane_assignment->plane == plane)
|
|
|
|
{
|
|
|
|
update->plane_assignments =
|
|
|
|
g_list_delete_link (update->plane_assignments, l);
|
2020-10-02 16:53:16 +02:00
|
|
|
if (out_flags)
|
|
|
|
*out_flags = plane_assignment->flags;
|
2020-10-02 16:48:34 +02:00
|
|
|
meta_kms_plane_assignment_free (plane_assignment);
|
2020-10-02 16:53:16 +02:00
|
|
|
return TRUE;
|
2020-10-02 16:48:34 +02:00
|
|
|
}
|
|
|
|
}
|
2020-10-02 16:53:16 +02:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
kms/impl-device: Add deadline based KMS commit scheduling
This makes it possible to post KMS updates that will always defer until
just before the scanout deadline. This is useful to allow queuing cursor
updates where we don't want to post them to KMS immediately, but rather
wait until as late as possible to get lower latency.
We cannot delay primary plane compositions however, and this is due to
how the kernel may prioritize GPU work - not until a pipeline gets
attached to a atomic commit will it in some drivers get bumped to high
priority. This means we still need to post any update that depends on
OpenGL pipelines as soon as possible.
To avoid working on compositing, then getting stomped on the feet by the
deadline scheduler, the deadline timer is disarmed whenever there is a
frame currently being painted. This will still allow new cursor updates
to arrive during composition, but will delay the actual KMS commit until
the primary plane update has been posted.
Still, even for cursor-only we still need higher than default timing
capabilities, thus the deadline scheduler depends on the KMS thread
getting real-time scheduling priority. When the thread isn't realtime
scheduled, the KMS thread instead asks the main thread to "flush" the
commit as part of the regular frame update. A flushing update means one
that isn't set to always defer and has a latching CRTC.
The verbose KMS debug logging makes the processing take too long, making
us more likely to miss the deadline. Avoid this by increasing the
evasion length when debug logging is enabled. Not the best, but better
than changing the behavior completely.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2022-10-26 19:08:30 +02:00
|
|
|
static void
|
|
|
|
update_latch_crtc (MetaKmsUpdate *update,
|
|
|
|
MetaKmsCrtc *crtc)
|
|
|
|
{
|
|
|
|
if (update->is_latchable)
|
|
|
|
{
|
|
|
|
if (update->latch_crtc)
|
|
|
|
{
|
|
|
|
if (update->latch_crtc != crtc)
|
|
|
|
{
|
|
|
|
update->is_latchable = FALSE;
|
|
|
|
update->latch_crtc = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
update->latch_crtc = crtc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 22:36:41 +02:00
|
|
|
MetaKmsPlaneAssignment *
|
2019-11-08 23:54:43 +01:00
|
|
|
meta_kms_update_assign_plane (MetaKmsUpdate *update,
|
|
|
|
MetaKmsCrtc *crtc,
|
|
|
|
MetaKmsPlane *plane,
|
2020-09-21 19:32:46 +02:00
|
|
|
MetaDrmBuffer *buffer,
|
2019-11-08 23:54:43 +01:00
|
|
|
MetaFixed16Rectangle src_rect,
|
2023-07-20 01:46:15 +02:00
|
|
|
MtkRectangle dst_rect,
|
2019-11-08 23:54:43 +01:00
|
|
|
MetaKmsAssignPlaneFlag flags)
|
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 22:36:41 +02:00
|
|
|
{
|
|
|
|
MetaKmsPlaneAssignment *plane_assignment;
|
2020-10-02 16:53:16 +02:00
|
|
|
MetaKmsAssignPlaneFlag old_flags;
|
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 22:36:41 +02:00
|
|
|
|
2020-07-16 23:38:10 +02:00
|
|
|
g_assert (meta_kms_crtc_get_device (crtc) == update->device);
|
|
|
|
g_assert (meta_kms_plane_get_device (plane) == update->device);
|
2020-10-02 15:45:28 +02:00
|
|
|
g_assert (meta_kms_plane_get_plane_type (plane) !=
|
|
|
|
META_KMS_PLANE_TYPE_PRIMARY ||
|
|
|
|
!(flags & META_KMS_ASSIGN_PLANE_FLAG_ALLOW_FAIL));
|
2019-06-19 22:15:12 +02:00
|
|
|
|
2020-10-02 16:53:16 +02:00
|
|
|
if (drop_plane_assignment (update, plane, &old_flags))
|
|
|
|
{
|
|
|
|
if (!(old_flags & META_KMS_ASSIGN_PLANE_FLAG_FB_UNCHANGED))
|
|
|
|
flags &= ~META_KMS_ASSIGN_PLANE_FLAG_FB_UNCHANGED;
|
|
|
|
}
|
|
|
|
|
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 22:36:41 +02:00
|
|
|
plane_assignment = g_new0 (MetaKmsPlaneAssignment, 1);
|
|
|
|
*plane_assignment = (MetaKmsPlaneAssignment) {
|
2019-06-19 22:15:12 +02:00
|
|
|
.update = update,
|
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 22:36:41 +02:00
|
|
|
.crtc = crtc,
|
|
|
|
.plane = plane,
|
2020-09-21 19:32:46 +02:00
|
|
|
.buffer = buffer,
|
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 22:36:41 +02:00
|
|
|
.src_rect = src_rect,
|
|
|
|
.dst_rect = dst_rect,
|
2019-11-08 23:54:43 +01:00
|
|
|
.flags = flags,
|
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 22:36:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
update->plane_assignments = g_list_prepend (update->plane_assignments,
|
|
|
|
plane_assignment);
|
|
|
|
|
kms/impl-device: Add deadline based KMS commit scheduling
This makes it possible to post KMS updates that will always defer until
just before the scanout deadline. This is useful to allow queuing cursor
updates where we don't want to post them to KMS immediately, but rather
wait until as late as possible to get lower latency.
We cannot delay primary plane compositions however, and this is due to
how the kernel may prioritize GPU work - not until a pipeline gets
attached to a atomic commit will it in some drivers get bumped to high
priority. This means we still need to post any update that depends on
OpenGL pipelines as soon as possible.
To avoid working on compositing, then getting stomped on the feet by the
deadline scheduler, the deadline timer is disarmed whenever there is a
frame currently being painted. This will still allow new cursor updates
to arrive during composition, but will delay the actual KMS commit until
the primary plane update has been posted.
Still, even for cursor-only we still need higher than default timing
capabilities, thus the deadline scheduler depends on the KMS thread
getting real-time scheduling priority. When the thread isn't realtime
scheduled, the KMS thread instead asks the main thread to "flush" the
commit as part of the regular frame update. A flushing update means one
that isn't set to always defer and has a latching CRTC.
The verbose KMS debug logging makes the processing take too long, making
us more likely to miss the deadline. Avoid this by increasing the
evasion length when debug logging is enabled. Not the best, but better
than changing the behavior completely.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2022-10-26 19:08:30 +02:00
|
|
|
update_latch_crtc (update, crtc);
|
|
|
|
|
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 22:36:41 +02:00
|
|
|
return plane_assignment;
|
|
|
|
}
|
|
|
|
|
2019-11-01 15:23:19 +01:00
|
|
|
MetaKmsPlaneAssignment *
|
|
|
|
meta_kms_update_unassign_plane (MetaKmsUpdate *update,
|
|
|
|
MetaKmsCrtc *crtc,
|
|
|
|
MetaKmsPlane *plane)
|
|
|
|
{
|
|
|
|
MetaKmsPlaneAssignment *plane_assignment;
|
|
|
|
|
2020-07-16 23:38:10 +02:00
|
|
|
g_assert (meta_kms_crtc_get_device (crtc) == update->device);
|
|
|
|
g_assert (meta_kms_plane_get_device (plane) == update->device);
|
2019-11-01 15:23:19 +01:00
|
|
|
|
2022-09-08 16:45:29 +08:00
|
|
|
drop_plane_assignment (update, plane, NULL);
|
|
|
|
|
2019-11-01 15:23:19 +01:00
|
|
|
plane_assignment = g_new0 (MetaKmsPlaneAssignment, 1);
|
|
|
|
*plane_assignment = (MetaKmsPlaneAssignment) {
|
|
|
|
.update = update,
|
|
|
|
.crtc = crtc,
|
|
|
|
.plane = plane,
|
2020-09-21 19:32:46 +02:00
|
|
|
.buffer = NULL,
|
2019-11-01 15:23:19 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
update->plane_assignments = g_list_prepend (update->plane_assignments,
|
|
|
|
plane_assignment);
|
|
|
|
|
kms/impl-device: Add deadline based KMS commit scheduling
This makes it possible to post KMS updates that will always defer until
just before the scanout deadline. This is useful to allow queuing cursor
updates where we don't want to post them to KMS immediately, but rather
wait until as late as possible to get lower latency.
We cannot delay primary plane compositions however, and this is due to
how the kernel may prioritize GPU work - not until a pipeline gets
attached to a atomic commit will it in some drivers get bumped to high
priority. This means we still need to post any update that depends on
OpenGL pipelines as soon as possible.
To avoid working on compositing, then getting stomped on the feet by the
deadline scheduler, the deadline timer is disarmed whenever there is a
frame currently being painted. This will still allow new cursor updates
to arrive during composition, but will delay the actual KMS commit until
the primary plane update has been posted.
Still, even for cursor-only we still need higher than default timing
capabilities, thus the deadline scheduler depends on the KMS thread
getting real-time scheduling priority. When the thread isn't realtime
scheduled, the KMS thread instead asks the main thread to "flush" the
commit as part of the regular frame update. A flushing update means one
that isn't set to always defer and has a latching CRTC.
The verbose KMS debug logging makes the processing take too long, making
us more likely to miss the deadline. Avoid this by increasing the
evasion length when debug logging is enabled. Not the best, but better
than changing the behavior completely.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2022-10-26 19:08:30 +02:00
|
|
|
update_latch_crtc (update, crtc);
|
|
|
|
|
2019-11-01 15:23:19 +01:00
|
|
|
return plane_assignment;
|
|
|
|
}
|
|
|
|
|
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 22:36:41 +02:00
|
|
|
void
|
2020-07-02 15:58:59 +02:00
|
|
|
meta_kms_update_mode_set (MetaKmsUpdate *update,
|
|
|
|
MetaKmsCrtc *crtc,
|
|
|
|
GList *connectors,
|
|
|
|
MetaKmsMode *mode)
|
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 22:36:41 +02:00
|
|
|
{
|
|
|
|
MetaKmsModeSet *mode_set;
|
|
|
|
|
2020-07-16 23:38:10 +02:00
|
|
|
g_assert (meta_kms_crtc_get_device (crtc) == update->device);
|
2019-06-19 22:15:12 +02: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 22:36:41 +02:00
|
|
|
mode_set = g_new0 (MetaKmsModeSet, 1);
|
|
|
|
*mode_set = (MetaKmsModeSet) {
|
|
|
|
.crtc = crtc,
|
|
|
|
.connectors = connectors,
|
2020-07-02 15:58:59 +02:00
|
|
|
.mode = mode,
|
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 22:36:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
update->mode_sets = g_list_prepend (update->mode_sets, mode_set);
|
|
|
|
}
|
|
|
|
|
2020-07-14 16:48:47 +02:00
|
|
|
static MetaKmsConnectorUpdate *
|
|
|
|
ensure_connector_update (MetaKmsUpdate *update,
|
2020-07-17 09:39:32 +02:00
|
|
|
MetaKmsConnector *connector)
|
2020-07-14 16:48:47 +02:00
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
MetaKmsConnectorUpdate *connector_update;
|
|
|
|
|
|
|
|
for (l = update->connector_updates; l; l = l->next)
|
|
|
|
{
|
|
|
|
connector_update = l->data;
|
|
|
|
|
|
|
|
if (connector_update->connector == connector)
|
|
|
|
return connector_update;
|
|
|
|
}
|
|
|
|
|
|
|
|
connector_update = g_new0 (MetaKmsConnectorUpdate, 1);
|
|
|
|
connector_update->connector = connector;
|
|
|
|
|
|
|
|
update->connector_updates = g_list_prepend (update->connector_updates,
|
|
|
|
connector_update);
|
|
|
|
|
|
|
|
return connector_update;
|
|
|
|
}
|
|
|
|
|
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 22:36:41 +02:00
|
|
|
void
|
2020-07-14 16:48:47 +02:00
|
|
|
meta_kms_update_set_underscanning (MetaKmsUpdate *update,
|
|
|
|
MetaKmsConnector *connector,
|
|
|
|
uint64_t hborder,
|
|
|
|
uint64_t vborder)
|
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 22:36:41 +02:00
|
|
|
{
|
2020-07-14 16:48:47 +02:00
|
|
|
MetaKmsConnectorUpdate *connector_update;
|
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 22:36:41 +02:00
|
|
|
|
2020-07-16 23:38:10 +02:00
|
|
|
g_assert (meta_kms_connector_get_device (connector) == update->device);
|
2019-06-19 22:15:12 +02:00
|
|
|
|
2020-07-14 16:48:47 +02:00
|
|
|
connector_update = ensure_connector_update (update, connector);
|
|
|
|
connector_update->underscanning.has_update = TRUE;
|
|
|
|
connector_update->underscanning.is_active = TRUE;
|
|
|
|
connector_update->underscanning.hborder = hborder;
|
|
|
|
connector_update->underscanning.vborder = vborder;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_kms_update_unset_underscanning (MetaKmsUpdate *update,
|
|
|
|
MetaKmsConnector *connector)
|
|
|
|
{
|
|
|
|
MetaKmsConnectorUpdate *connector_update;
|
|
|
|
|
2020-07-16 23:38:10 +02:00
|
|
|
g_assert (meta_kms_connector_get_device (connector) == update->device);
|
2020-07-14 16:48:47 +02:00
|
|
|
|
|
|
|
connector_update = ensure_connector_update (update, connector);
|
|
|
|
connector_update->underscanning.has_update = TRUE;
|
|
|
|
connector_update->underscanning.is_active = FALSE;
|
|
|
|
}
|
|
|
|
|
2021-03-22 01:27:39 +01:00
|
|
|
void
|
|
|
|
meta_kms_update_set_privacy_screen (MetaKmsUpdate *update,
|
|
|
|
MetaKmsConnector *connector,
|
|
|
|
gboolean enabled)
|
|
|
|
{
|
|
|
|
MetaKmsConnectorUpdate *connector_update;
|
|
|
|
|
|
|
|
g_assert (meta_kms_connector_get_device (connector) == update->device);
|
|
|
|
|
|
|
|
connector_update = ensure_connector_update (update, connector);
|
|
|
|
connector_update->privacy_screen.has_update = TRUE;
|
|
|
|
connector_update->privacy_screen.is_enabled = enabled;
|
|
|
|
}
|
|
|
|
|
2022-05-13 16:26:10 +08:00
|
|
|
void
|
|
|
|
meta_kms_update_set_max_bpc (MetaKmsUpdate *update,
|
|
|
|
MetaKmsConnector *connector,
|
|
|
|
uint64_t max_bpc)
|
|
|
|
{
|
|
|
|
MetaKmsConnectorUpdate *connector_update;
|
|
|
|
|
|
|
|
g_assert (meta_kms_connector_get_device (connector) == update->device);
|
2024-01-23 20:49:54 +01:00
|
|
|
g_return_if_fail (meta_kms_connector_is_max_bpc_supported (connector,
|
|
|
|
max_bpc));
|
2022-05-13 16:26:10 +08:00
|
|
|
|
|
|
|
connector_update = ensure_connector_update (update, connector);
|
|
|
|
connector_update->max_bpc.value = max_bpc;
|
|
|
|
connector_update->max_bpc.has_update = TRUE;
|
|
|
|
}
|
|
|
|
|
2023-03-02 02:04:12 +01:00
|
|
|
void
|
|
|
|
meta_kms_update_set_color_space (MetaKmsUpdate *update,
|
|
|
|
MetaKmsConnector *connector,
|
|
|
|
MetaOutputColorspace color_space)
|
|
|
|
{
|
|
|
|
MetaKmsConnectorUpdate *connector_update;
|
|
|
|
|
|
|
|
g_assert (meta_kms_connector_get_device (connector) == update->device);
|
|
|
|
|
|
|
|
connector_update = ensure_connector_update (update, connector);
|
|
|
|
connector_update->colorspace.has_update = TRUE;
|
|
|
|
connector_update->colorspace.value = color_space;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_kms_update_set_hdr_metadata (MetaKmsUpdate *update,
|
|
|
|
MetaKmsConnector *connector,
|
|
|
|
MetaOutputHdrMetadata *metadata)
|
|
|
|
{
|
|
|
|
MetaKmsConnectorUpdate *connector_update;
|
|
|
|
|
|
|
|
g_assert (meta_kms_connector_get_device (connector) == update->device);
|
|
|
|
g_return_if_fail (meta_kms_connector_is_hdr_metadata_supported (connector));
|
|
|
|
|
|
|
|
connector_update = ensure_connector_update (update, connector);
|
|
|
|
connector_update->hdr.has_update = TRUE;
|
|
|
|
connector_update->hdr.value = *metadata;
|
|
|
|
|
|
|
|
/* Currently required on AMDGPU but should in general not require mode sets */
|
|
|
|
update->needs_modeset = TRUE;
|
|
|
|
}
|
|
|
|
|
2024-01-17 13:22:56 +01:00
|
|
|
void
|
|
|
|
meta_kms_update_set_broadcast_rgb (MetaKmsUpdate *update,
|
|
|
|
MetaKmsConnector *connector,
|
|
|
|
MetaOutputRGBRange rgb_range)
|
|
|
|
{
|
|
|
|
MetaKmsConnectorUpdate *connector_update;
|
|
|
|
|
|
|
|
g_assert (meta_kms_connector_get_device (connector) == update->device);
|
|
|
|
g_return_if_fail (meta_kms_connector_is_broadcast_rgb_supported (connector,
|
|
|
|
rgb_range));
|
|
|
|
|
|
|
|
connector_update = ensure_connector_update (update, connector);
|
|
|
|
connector_update->broadcast_rgb.has_update = TRUE;
|
|
|
|
connector_update->broadcast_rgb.value = rgb_range;
|
|
|
|
}
|
|
|
|
|
2023-02-17 23:47:04 +01:00
|
|
|
static MetaKmsCrtcColorUpdate *
|
|
|
|
ensure_color_update (MetaKmsUpdate *update,
|
|
|
|
MetaKmsCrtc *crtc)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
MetaKmsCrtcColorUpdate *color_update;
|
|
|
|
|
|
|
|
for (l = update->crtc_color_updates; l; l = l->next)
|
|
|
|
{
|
|
|
|
color_update = l->data;
|
|
|
|
|
|
|
|
if (color_update->crtc == crtc)
|
|
|
|
return color_update;
|
|
|
|
}
|
|
|
|
|
|
|
|
color_update = g_new0 (MetaKmsCrtcColorUpdate, 1);
|
|
|
|
color_update->crtc = crtc;
|
|
|
|
|
|
|
|
update->crtc_color_updates = g_list_prepend (update->crtc_color_updates,
|
|
|
|
color_update);
|
|
|
|
|
|
|
|
return color_update;
|
|
|
|
}
|
|
|
|
|
2020-10-10 11:18:10 +02:00
|
|
|
void
|
2023-02-18 03:13:57 +01:00
|
|
|
meta_kms_update_set_crtc_gamma (MetaKmsUpdate *update,
|
|
|
|
MetaKmsCrtc *crtc,
|
|
|
|
const MetaGammaLut *gamma)
|
2019-05-03 19:20:21 +02:00
|
|
|
{
|
2023-02-17 23:47:04 +01:00
|
|
|
MetaKmsCrtcColorUpdate *color_update;
|
2023-02-18 03:13:57 +01:00
|
|
|
MetaGammaLut *gamma_update = NULL;
|
2023-02-18 18:32:24 +01:00
|
|
|
const MetaKmsCrtcState *crtc_state = meta_kms_crtc_get_current_state (crtc);
|
2019-05-03 19:20:21 +02:00
|
|
|
|
2020-07-16 23:38:10 +02:00
|
|
|
g_assert (meta_kms_crtc_get_device (crtc) == update->device);
|
2019-05-03 19:20:21 +02:00
|
|
|
|
2023-02-18 03:13:57 +01:00
|
|
|
if (gamma)
|
2023-02-18 18:32:24 +01:00
|
|
|
gamma_update = meta_gamma_lut_copy_to_size (gamma, crtc_state->gamma.size);
|
2023-02-18 03:13:57 +01:00
|
|
|
|
2023-02-17 23:47:04 +01:00
|
|
|
color_update = ensure_color_update (update, crtc);
|
2023-02-18 03:13:57 +01:00
|
|
|
color_update->gamma.state = gamma_update;
|
2023-02-17 23:47:04 +01:00
|
|
|
color_update->gamma.has_update = TRUE;
|
kms/impl-device: Add deadline based KMS commit scheduling
This makes it possible to post KMS updates that will always defer until
just before the scanout deadline. This is useful to allow queuing cursor
updates where we don't want to post them to KMS immediately, but rather
wait until as late as possible to get lower latency.
We cannot delay primary plane compositions however, and this is due to
how the kernel may prioritize GPU work - not until a pipeline gets
attached to a atomic commit will it in some drivers get bumped to high
priority. This means we still need to post any update that depends on
OpenGL pipelines as soon as possible.
To avoid working on compositing, then getting stomped on the feet by the
deadline scheduler, the deadline timer is disarmed whenever there is a
frame currently being painted. This will still allow new cursor updates
to arrive during composition, but will delay the actual KMS commit until
the primary plane update has been posted.
Still, even for cursor-only we still need higher than default timing
capabilities, thus the deadline scheduler depends on the KMS thread
getting real-time scheduling priority. When the thread isn't realtime
scheduled, the KMS thread instead asks the main thread to "flush" the
commit as part of the regular frame update. A flushing update means one
that isn't set to always defer and has a latching CRTC.
The verbose KMS debug logging makes the processing take too long, making
us more likely to miss the deadline. Avoid this by increasing the
evasion length when debug logging is enabled. Not the best, but better
than changing the behavior completely.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2022-10-26 19:08:30 +02:00
|
|
|
|
|
|
|
update_latch_crtc (update, crtc);
|
2023-02-17 23:47:04 +01:00
|
|
|
}
|
2019-05-03 19:20:21 +02:00
|
|
|
|
2023-02-17 23:47:04 +01:00
|
|
|
static void
|
|
|
|
meta_kms_crtc_color_updates_free (MetaKmsCrtcColorUpdate *color_update)
|
|
|
|
{
|
|
|
|
if (color_update->gamma.has_update)
|
2023-02-18 03:13:57 +01:00
|
|
|
g_clear_pointer (&color_update->gamma.state, meta_gamma_lut_free);
|
2023-08-16 21:13:20 +02:00
|
|
|
g_free (color_update);
|
2019-05-03 19:20:21 +02: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 22:36:41 +02:00
|
|
|
void
|
2020-10-02 16:06:35 +02:00
|
|
|
meta_kms_update_add_page_flip_listener (MetaKmsUpdate *update,
|
|
|
|
MetaKmsCrtc *crtc,
|
|
|
|
const MetaKmsPageFlipListenerVtable *vtable,
|
2021-07-09 19:49:56 +02:00
|
|
|
GMainContext *main_context,
|
kms/page-flip: Pass ownership of listener user data along with closure
In order to reliably manage the reference count of the user data passed
to page flip listeners - being the stage view - make the ownership of
this data travel through the different objects that take responsibility
of the next step.
Initially this is the MetaKmsPageFlipListener that belongs to a
MetaKmsUpdate.
When a page flip is successfully queued, the ownership is transferred to
a MetaKmsPageFlipClosure that is part of a MetaKmsPageFlipData. In the
simple impl device, the MetaKmsPageFlipData is passed to
drmModePageFlip(), then returned back via the DRM event. In the future
atomic impl device, the MetaKmsPageFlipData is stored in a table, then
retrieved when DRM event are handled.
When the DRM events are handled, the page flip listener's interface
callbacks are invoked, and after that, the user data is freed using the
passed GDestroyNotify function, in the main context, the same as where
the interface callbacks were called.
When a page flip fails, the ownership is also transferred to a
MetaKmsPageFlipClosure that is part of a MetaKmsPageFlipData. This page
flip data will be passed to the main context via a callback, where it
will discard the page flip, and free the user data using the provided
GDestroyNotify.
Note that this adds back a page flip listener type flag for telling the
KMS implementation whether to actively discard a page flip via the
interface, or just free the user data. Avoiding discarding via the
interface is needed for the direct scanout case, where we immediately
need to know the result in order to fall back to the composite pipeline
if the direct scanout failed. We do in fact also need active discard via
the interface paths, e.g. in the simple impl device when we're
asynchronously retrying a page flip, so replace the ad-hoc discard paths
in meta-renderer-native.c and replace them by not asking for no-discard
page flip error handling.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2020-12-16 08:41:14 +01:00
|
|
|
gpointer user_data,
|
|
|
|
GDestroyNotify destroy_notify)
|
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 22:36:41 +02:00
|
|
|
{
|
2020-10-02 16:06:35 +02:00
|
|
|
MetaKmsPageFlipListener *listener;
|
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 22:36:41 +02:00
|
|
|
|
2020-07-16 23:38:10 +02:00
|
|
|
g_assert (meta_kms_crtc_get_device (crtc) == update->device);
|
2019-06-19 22:15:12 +02:00
|
|
|
|
2022-12-21 18:52:01 +01:00
|
|
|
if (!main_context)
|
|
|
|
main_context = g_main_context_default ();
|
|
|
|
|
2020-10-02 16:06:35 +02:00
|
|
|
listener = g_new0 (MetaKmsPageFlipListener, 1);
|
|
|
|
*listener = (MetaKmsPageFlipListener) {
|
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 22:36:41 +02:00
|
|
|
.crtc = crtc,
|
2020-10-02 16:06:35 +02:00
|
|
|
.vtable = vtable,
|
2021-07-09 19:49:56 +02:00
|
|
|
.main_context = main_context,
|
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 22:36:41 +02:00
|
|
|
.user_data = user_data,
|
kms/page-flip: Pass ownership of listener user data along with closure
In order to reliably manage the reference count of the user data passed
to page flip listeners - being the stage view - make the ownership of
this data travel through the different objects that take responsibility
of the next step.
Initially this is the MetaKmsPageFlipListener that belongs to a
MetaKmsUpdate.
When a page flip is successfully queued, the ownership is transferred to
a MetaKmsPageFlipClosure that is part of a MetaKmsPageFlipData. In the
simple impl device, the MetaKmsPageFlipData is passed to
drmModePageFlip(), then returned back via the DRM event. In the future
atomic impl device, the MetaKmsPageFlipData is stored in a table, then
retrieved when DRM event are handled.
When the DRM events are handled, the page flip listener's interface
callbacks are invoked, and after that, the user data is freed using the
passed GDestroyNotify function, in the main context, the same as where
the interface callbacks were called.
When a page flip fails, the ownership is also transferred to a
MetaKmsPageFlipClosure that is part of a MetaKmsPageFlipData. This page
flip data will be passed to the main context via a callback, where it
will discard the page flip, and free the user data using the provided
GDestroyNotify.
Note that this adds back a page flip listener type flag for telling the
KMS implementation whether to actively discard a page flip via the
interface, or just free the user data. Avoiding discarding via the
interface is needed for the direct scanout case, where we immediately
need to know the result in order to fall back to the composite pipeline
if the direct scanout failed. We do in fact also need active discard via
the interface paths, e.g. in the simple impl device when we're
asynchronously retrying a page flip, so replace the ad-hoc discard paths
in meta-renderer-native.c and replace them by not asking for no-discard
page flip error handling.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2020-12-16 08:41:14 +01:00
|
|
|
.destroy_notify = destroy_notify,
|
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 22:36:41 +02:00
|
|
|
};
|
2022-06-05 21:16:11 +02:00
|
|
|
g_atomic_ref_count_init (&listener->ref_count);
|
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 22:36:41 +02:00
|
|
|
|
2020-10-02 16:06:35 +02:00
|
|
|
update->page_flip_listeners = g_list_prepend (update->page_flip_listeners,
|
|
|
|
listener);
|
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 22:36:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-10-01 18:28:13 +02:00
|
|
|
meta_kms_update_set_custom_page_flip (MetaKmsUpdate *update,
|
|
|
|
MetaKmsCustomPageFlipFunc func,
|
|
|
|
gpointer user_data)
|
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 22:36:41 +02:00
|
|
|
{
|
2021-01-22 11:31:18 +01:00
|
|
|
MetaKmsCustomPageFlip *custom_page_flip;
|
|
|
|
|
|
|
|
custom_page_flip = g_new0 (MetaKmsCustomPageFlip, 1);
|
|
|
|
custom_page_flip->func = func;
|
|
|
|
custom_page_flip->user_data = user_data;
|
|
|
|
|
|
|
|
update->custom_page_flip = custom_page_flip;
|
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 22:36:41 +02:00
|
|
|
}
|
|
|
|
|
2021-09-03 19:39:12 +01:00
|
|
|
void
|
|
|
|
meta_kms_plane_assignment_set_fb_damage (MetaKmsPlaneAssignment *plane_assignment,
|
|
|
|
const int *rectangles,
|
|
|
|
int n_rectangles)
|
|
|
|
{
|
|
|
|
MetaKmsFbDamage *fb_damage;
|
|
|
|
struct drm_mode_rect *mode_rects;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
mode_rects = g_new0 (struct drm_mode_rect, n_rectangles);
|
|
|
|
for (i = 0; i < n_rectangles; ++i)
|
|
|
|
{
|
|
|
|
mode_rects[i].x1 = rectangles[i * 4];
|
|
|
|
mode_rects[i].y1 = rectangles[i * 4 + 1];
|
|
|
|
mode_rects[i].x2 = mode_rects[i].x1 + rectangles[i * 4 + 2];
|
|
|
|
mode_rects[i].y2 = mode_rects[i].y1 + rectangles[i * 4 + 3];
|
|
|
|
}
|
|
|
|
|
|
|
|
fb_damage = g_new0 (MetaKmsFbDamage, 1);
|
|
|
|
*fb_damage = (MetaKmsFbDamage) {
|
|
|
|
.rects = mode_rects,
|
|
|
|
.n_rects = n_rectangles,
|
|
|
|
};
|
|
|
|
|
|
|
|
plane_assignment->fb_damage = fb_damage;
|
|
|
|
}
|
|
|
|
|
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 22:36:41 +02:00
|
|
|
void
|
2020-07-14 15:10:50 +02:00
|
|
|
meta_kms_plane_assignment_set_rotation (MetaKmsPlaneAssignment *plane_assignment,
|
2022-04-20 22:54:27 +02:00
|
|
|
MetaKmsPlaneRotation rotation)
|
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 22:36:41 +02:00
|
|
|
{
|
2020-07-14 15:10:50 +02:00
|
|
|
g_warn_if_fail (rotation);
|
2019-06-19 22:15:12 +02:00
|
|
|
|
2020-07-14 15:10:50 +02:00
|
|
|
plane_assignment->rotation = rotation;
|
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 22:36:41 +02:00
|
|
|
}
|
|
|
|
|
kms/plane-assignment: Add API to set cursor hotspot metadata
The transactional KMS API has been modelled after atomic KMS. Atomic KMS
currently doesn't support forwarding cursor hotspot metadata, thus it
was left out of the transactional KMS API having the user set the simply
create a plane assigment with the cursor sprite assigned to a cursor
plane using regular coordinates.
This, however, proved to be inadequate for virtual machines using
"seamless mouse mode" where they rely on the cursor position to
correspond to the actual cursor position of the virtual machine, not the
cursor plane. In effect, this caused cursor positions to look "shifted".
Fix this by adding back the hotspot metadata, right now as a optional
field to the plane assignment. In the legacy KMS implementation, this is
translated into drmModeSetCursor2() just as before, while still falling
back to drmModeSetCursor() with the plane coordinates, if either there
was no hotspot set, or if drmModeSetCursor2() failed.
Eventually, the atomic KMS API will learn about hotspots, but when
adding our own atomic KMS backend to the transacitonal KMS API, we must
until then still fall back to legacy KMS for virtual machines.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1136
2020-03-19 09:01:03 +01:00
|
|
|
void
|
|
|
|
meta_kms_plane_assignment_set_cursor_hotspot (MetaKmsPlaneAssignment *plane_assignment,
|
|
|
|
int x,
|
|
|
|
int y)
|
|
|
|
{
|
2024-01-08 15:40:52 +01:00
|
|
|
plane_assignment->cursor_hotspot.has_update = TRUE;
|
kms/plane-assignment: Add API to set cursor hotspot metadata
The transactional KMS API has been modelled after atomic KMS. Atomic KMS
currently doesn't support forwarding cursor hotspot metadata, thus it
was left out of the transactional KMS API having the user set the simply
create a plane assigment with the cursor sprite assigned to a cursor
plane using regular coordinates.
This, however, proved to be inadequate for virtual machines using
"seamless mouse mode" where they rely on the cursor position to
correspond to the actual cursor position of the virtual machine, not the
cursor plane. In effect, this caused cursor positions to look "shifted".
Fix this by adding back the hotspot metadata, right now as a optional
field to the plane assignment. In the legacy KMS implementation, this is
translated into drmModeSetCursor2() just as before, while still falling
back to drmModeSetCursor() with the plane coordinates, if either there
was no hotspot set, or if drmModeSetCursor2() failed.
Eventually, the atomic KMS API will learn about hotspots, but when
adding our own atomic KMS backend to the transacitonal KMS API, we must
until then still fall back to legacy KMS for virtual machines.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1136
2020-03-19 09:01:03 +01:00
|
|
|
plane_assignment->cursor_hotspot.is_valid = TRUE;
|
|
|
|
plane_assignment->cursor_hotspot.x = x;
|
|
|
|
plane_assignment->cursor_hotspot.y = y;
|
|
|
|
}
|
|
|
|
|
2020-10-02 16:35:42 +02:00
|
|
|
void
|
2022-12-21 18:17:33 +01:00
|
|
|
meta_kms_update_add_result_listener (MetaKmsUpdate *update,
|
|
|
|
const MetaKmsResultListenerVtable *vtable,
|
|
|
|
GMainContext *main_context,
|
2023-04-20 16:32:41 +02:00
|
|
|
gpointer user_data,
|
|
|
|
GDestroyNotify destroy_notify)
|
2020-10-02 16:35:42 +02:00
|
|
|
{
|
|
|
|
MetaKmsResultListener *listener;
|
|
|
|
|
|
|
|
listener = g_new0 (MetaKmsResultListener, 1);
|
|
|
|
*listener = (MetaKmsResultListener) {
|
2023-02-14 20:18:26 +01:00
|
|
|
.main_context = main_context,
|
2022-12-21 18:17:33 +01:00
|
|
|
.vtable = vtable,
|
2020-10-02 16:35:42 +02:00
|
|
|
.user_data = user_data,
|
2023-04-20 16:32:41 +02:00
|
|
|
.destroy_notify = destroy_notify,
|
2020-10-02 16:35:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
update->result_listeners = g_list_append (update->result_listeners,
|
|
|
|
listener);
|
|
|
|
}
|
|
|
|
|
|
|
|
GList *
|
|
|
|
meta_kms_update_take_result_listeners (MetaKmsUpdate *update)
|
|
|
|
{
|
|
|
|
return g_steal_pointer (&update->result_listeners);
|
|
|
|
}
|
|
|
|
|
2023-02-14 20:18:26 +01:00
|
|
|
GMainContext *
|
|
|
|
meta_kms_result_listener_get_main_context (MetaKmsResultListener *listener)
|
|
|
|
{
|
|
|
|
return listener->main_context;
|
|
|
|
}
|
|
|
|
|
2020-10-02 16:35:42 +02:00
|
|
|
void
|
2023-02-14 20:15:51 +01:00
|
|
|
meta_kms_result_listener_set_feedback (MetaKmsResultListener *listener,
|
|
|
|
MetaKmsFeedback *feedback)
|
2020-10-02 16:35:42 +02:00
|
|
|
{
|
2023-02-14 20:15:51 +01:00
|
|
|
g_return_if_fail (!listener->feedback);
|
|
|
|
|
|
|
|
listener->feedback = meta_kms_feedback_ref (feedback);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_kms_result_listener_notify (MetaKmsResultListener *listener)
|
|
|
|
{
|
|
|
|
g_return_if_fail (listener->feedback);
|
|
|
|
|
2022-12-21 18:17:33 +01:00
|
|
|
if (listener->vtable->feedback)
|
|
|
|
listener->vtable->feedback (listener->feedback, listener->user_data);
|
2020-10-02 16:35:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_kms_result_listener_free (MetaKmsResultListener *listener)
|
|
|
|
{
|
2023-04-20 16:32:41 +02:00
|
|
|
if (listener->destroy_notify)
|
|
|
|
listener->destroy_notify (listener->user_data);
|
2023-02-14 20:15:51 +01:00
|
|
|
g_clear_pointer (&listener->feedback, meta_kms_feedback_unref);
|
2020-10-02 16:35:42 +02:00
|
|
|
g_free (listener);
|
|
|
|
}
|
|
|
|
|
2021-06-16 10:21:55 +02:00
|
|
|
static MetaKmsPlaneAssignment *
|
|
|
|
get_first_plane_assignment (MetaKmsUpdate *update,
|
|
|
|
MetaKmsCrtc *crtc,
|
|
|
|
MetaKmsPlaneType plane_type)
|
2019-10-04 11:48:46 +02:00
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = meta_kms_update_get_plane_assignments (update); l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaKmsPlaneAssignment *plane_assignment = l->data;
|
|
|
|
|
2020-10-09 22:06:19 +02:00
|
|
|
if (meta_kms_plane_get_plane_type (plane_assignment->plane) !=
|
2021-06-16 10:21:55 +02:00
|
|
|
plane_type)
|
2020-10-09 22:06:19 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (plane_assignment->crtc != crtc)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
return plane_assignment;
|
2019-10-04 11:48:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-06-16 10:21:55 +02:00
|
|
|
MetaKmsPlaneAssignment *
|
|
|
|
meta_kms_update_get_primary_plane_assignment (MetaKmsUpdate *update,
|
|
|
|
MetaKmsCrtc *crtc)
|
|
|
|
{
|
|
|
|
return get_first_plane_assignment (update, crtc, META_KMS_PLANE_TYPE_PRIMARY);
|
|
|
|
}
|
|
|
|
|
|
|
|
MetaKmsPlaneAssignment *
|
|
|
|
meta_kms_update_get_cursor_plane_assignment (MetaKmsUpdate *update,
|
|
|
|
MetaKmsCrtc *crtc)
|
|
|
|
{
|
|
|
|
return get_first_plane_assignment (update, crtc, META_KMS_PLANE_TYPE_CURSOR);
|
|
|
|
}
|
|
|
|
|
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 22:36:41 +02:00
|
|
|
GList *
|
|
|
|
meta_kms_update_get_plane_assignments (MetaKmsUpdate *update)
|
|
|
|
{
|
|
|
|
return update->plane_assignments;
|
|
|
|
}
|
|
|
|
|
|
|
|
GList *
|
|
|
|
meta_kms_update_get_mode_sets (MetaKmsUpdate *update)
|
|
|
|
{
|
|
|
|
return update->mode_sets;
|
|
|
|
}
|
|
|
|
|
|
|
|
GList *
|
2020-10-02 16:06:35 +02:00
|
|
|
meta_kms_update_get_page_flip_listeners (MetaKmsUpdate *update)
|
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 22:36:41 +02:00
|
|
|
{
|
2020-10-02 16:06:35 +02:00
|
|
|
return update->page_flip_listeners;
|
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 22:36:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
GList *
|
2020-07-14 16:48:47 +02:00
|
|
|
meta_kms_update_get_connector_updates (MetaKmsUpdate *update)
|
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 22:36:41 +02:00
|
|
|
{
|
2020-07-14 16:48:47 +02:00
|
|
|
return update->connector_updates;
|
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 22:36:41 +02:00
|
|
|
}
|
|
|
|
|
2019-05-03 19:20:21 +02:00
|
|
|
GList *
|
2023-02-17 23:18:39 +01:00
|
|
|
meta_kms_update_get_crtc_color_updates (MetaKmsUpdate *update)
|
2019-05-03 19:20:21 +02:00
|
|
|
{
|
2023-02-17 23:18:39 +01:00
|
|
|
return update->crtc_color_updates;
|
2019-05-03 19:20:21 +02:00
|
|
|
}
|
|
|
|
|
2020-07-16 23:38:10 +02:00
|
|
|
MetaKmsDevice *
|
|
|
|
meta_kms_update_get_device (MetaKmsUpdate *update)
|
|
|
|
{
|
|
|
|
return update->device;
|
|
|
|
}
|
|
|
|
|
2021-01-22 11:31:18 +01:00
|
|
|
MetaKmsCustomPageFlip *
|
|
|
|
meta_kms_update_take_custom_page_flip_func (MetaKmsUpdate *update)
|
|
|
|
{
|
|
|
|
return g_steal_pointer (&update->custom_page_flip);
|
|
|
|
}
|
|
|
|
|
2020-10-01 18:28:13 +02:00
|
|
|
void
|
2021-01-22 11:31:18 +01:00
|
|
|
meta_kms_custom_page_flip_free (MetaKmsCustomPageFlip *custom_page_flip)
|
2020-10-01 18:28:13 +02:00
|
|
|
{
|
2021-01-22 11:31:18 +01:00
|
|
|
g_free (custom_page_flip);
|
2020-10-01 18:28:13 +02:00
|
|
|
}
|
|
|
|
|
2022-10-20 21:34:25 +02:00
|
|
|
static GList *
|
|
|
|
find_mode_set_link_for (MetaKmsUpdate *update,
|
|
|
|
MetaKmsCrtc *crtc)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = update->mode_sets; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaKmsModeSet *mode_set = l->data;
|
|
|
|
|
|
|
|
if (mode_set->crtc == crtc)
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
merge_mode_sets (MetaKmsUpdate *update,
|
|
|
|
MetaKmsUpdate *other_update)
|
|
|
|
{
|
|
|
|
while (other_update->mode_sets)
|
|
|
|
{
|
|
|
|
GList *l = other_update->mode_sets;
|
|
|
|
MetaKmsModeSet *other_mode_set = l->data;
|
|
|
|
MetaKmsCrtc *crtc = other_mode_set->crtc;
|
|
|
|
GList *el;
|
|
|
|
|
|
|
|
other_update->mode_sets =
|
|
|
|
g_list_remove_link (other_update->mode_sets, l);
|
|
|
|
|
|
|
|
el = find_mode_set_link_for (update, crtc);
|
|
|
|
if (el)
|
|
|
|
{
|
|
|
|
meta_kms_mode_set_free (el->data);
|
|
|
|
update->mode_sets =
|
|
|
|
g_list_insert_before_link (update->mode_sets, el, l);
|
|
|
|
update->mode_sets =
|
|
|
|
g_list_delete_link (update->mode_sets, el);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
update->mode_sets =
|
|
|
|
g_list_insert_before_link (update->mode_sets,
|
|
|
|
update->mode_sets,
|
|
|
|
l);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-18 15:01:35 +02:00
|
|
|
static GList *
|
|
|
|
find_plane_assignment_link_for (MetaKmsUpdate *update,
|
|
|
|
MetaKmsPlane *plane)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = update->plane_assignments; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaKmsPlaneAssignment *plane_assignment = l->data;
|
|
|
|
|
|
|
|
if (plane_assignment->plane == plane)
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
merge_plane_assignments_from (MetaKmsUpdate *update,
|
|
|
|
MetaKmsUpdate *other_update)
|
|
|
|
{
|
|
|
|
while (other_update->plane_assignments)
|
|
|
|
{
|
|
|
|
GList *l = other_update->plane_assignments;
|
|
|
|
MetaKmsPlaneAssignment *other_plane_assignment = l->data;
|
|
|
|
MetaKmsPlane *plane = other_plane_assignment->plane;
|
|
|
|
GList *el;
|
|
|
|
|
|
|
|
other_update->plane_assignments =
|
|
|
|
g_list_remove_link (other_update->plane_assignments, l);
|
|
|
|
|
|
|
|
el = find_plane_assignment_link_for (update, plane);
|
|
|
|
if (el)
|
|
|
|
{
|
|
|
|
meta_kms_plane_assignment_free (el->data);
|
|
|
|
update->plane_assignments =
|
|
|
|
g_list_insert_before_link (update->plane_assignments, el, l);
|
|
|
|
update->plane_assignments =
|
|
|
|
g_list_delete_link (update->plane_assignments, el);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
update->plane_assignments =
|
|
|
|
g_list_insert_before_link (update->plane_assignments,
|
|
|
|
update->plane_assignments,
|
|
|
|
l);
|
|
|
|
}
|
|
|
|
other_plane_assignment->update = update;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GList *
|
|
|
|
find_color_update_link_for (MetaKmsUpdate *update,
|
|
|
|
MetaKmsCrtc *crtc)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = update->crtc_color_updates; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaKmsCrtcColorUpdate *color_update = l->data;
|
|
|
|
|
|
|
|
if (color_update->crtc == crtc)
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
merge_crtc_color_updates_from (MetaKmsUpdate *update,
|
|
|
|
MetaKmsUpdate *other_update)
|
|
|
|
{
|
|
|
|
while (other_update->crtc_color_updates)
|
|
|
|
{
|
|
|
|
GList *l = other_update->crtc_color_updates;
|
|
|
|
MetaKmsCrtcColorUpdate *other_crtc_color_update = l->data;
|
|
|
|
MetaKmsCrtc *crtc = other_crtc_color_update->crtc;
|
|
|
|
GList *el;
|
|
|
|
|
|
|
|
other_update->crtc_color_updates =
|
|
|
|
g_list_remove_link (other_update->crtc_color_updates, l);
|
|
|
|
|
|
|
|
el = find_color_update_link_for (update, crtc);
|
|
|
|
if (el)
|
|
|
|
{
|
|
|
|
meta_kms_crtc_color_updates_free (el->data);
|
|
|
|
update->crtc_color_updates =
|
|
|
|
g_list_insert_before_link (update->crtc_color_updates, el, l);
|
|
|
|
update->crtc_color_updates =
|
|
|
|
g_list_delete_link (update->crtc_color_updates, el);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
update->crtc_color_updates =
|
|
|
|
g_list_insert_before_link (update->crtc_color_updates,
|
|
|
|
update->crtc_color_updates,
|
|
|
|
l);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-02 22:09:16 +01:00
|
|
|
static GList *
|
|
|
|
find_connector_update_link_for (MetaKmsUpdate *update,
|
|
|
|
MetaKmsConnector *connector)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = update->connector_updates; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaKmsConnectorUpdate *connector_update = l->data;
|
|
|
|
|
|
|
|
if (connector_update->connector == connector)
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
merge_connector_updates_from (MetaKmsUpdate *update,
|
|
|
|
MetaKmsUpdate *other_update)
|
|
|
|
{
|
|
|
|
while (other_update->connector_updates)
|
|
|
|
{
|
|
|
|
GList *l = other_update->connector_updates;
|
|
|
|
MetaKmsConnectorUpdate *other_connector_update = l->data;
|
|
|
|
MetaKmsConnector *connector = other_connector_update->connector;
|
|
|
|
GList *el;
|
|
|
|
|
|
|
|
other_update->connector_updates =
|
|
|
|
g_list_remove_link (other_update->connector_updates, l);
|
|
|
|
el = find_connector_update_link_for (update, connector);
|
|
|
|
if (el)
|
|
|
|
{
|
|
|
|
MetaKmsConnectorUpdate *connector_update = el->data;
|
|
|
|
|
|
|
|
if (other_connector_update->underscanning.has_update)
|
|
|
|
{
|
|
|
|
connector_update->underscanning =
|
|
|
|
other_connector_update->underscanning;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (other_connector_update->privacy_screen.has_update)
|
|
|
|
{
|
|
|
|
connector_update->privacy_screen =
|
|
|
|
other_connector_update->privacy_screen;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (other_connector_update->max_bpc.has_update)
|
|
|
|
{
|
|
|
|
connector_update->max_bpc =
|
|
|
|
other_connector_update->max_bpc;
|
|
|
|
}
|
2023-03-02 02:04:12 +01:00
|
|
|
|
|
|
|
if (other_connector_update->colorspace.has_update)
|
|
|
|
{
|
|
|
|
connector_update->colorspace =
|
|
|
|
other_connector_update->colorspace;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (other_connector_update->hdr.has_update)
|
|
|
|
{
|
|
|
|
connector_update->hdr = other_connector_update->hdr;
|
|
|
|
}
|
2023-03-02 22:09:16 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
update->connector_updates =
|
|
|
|
g_list_insert_before_link (update->connector_updates,
|
|
|
|
update->connector_updates,
|
|
|
|
l);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-18 15:01:35 +02:00
|
|
|
static void
|
|
|
|
merge_custom_page_flip_from (MetaKmsUpdate *update,
|
|
|
|
MetaKmsUpdate *other_update)
|
|
|
|
{
|
|
|
|
g_warn_if_fail ((!update->custom_page_flip &&
|
|
|
|
!other_update->custom_page_flip) ||
|
|
|
|
((!!update->custom_page_flip) ^
|
|
|
|
(!!other_update->custom_page_flip)));
|
|
|
|
|
|
|
|
g_clear_pointer (&update->custom_page_flip, meta_kms_custom_page_flip_free);
|
|
|
|
update->custom_page_flip = g_steal_pointer (&other_update->custom_page_flip);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
merge_page_flip_listeners_from (MetaKmsUpdate *update,
|
|
|
|
MetaKmsUpdate *other_update)
|
|
|
|
{
|
|
|
|
update->page_flip_listeners =
|
|
|
|
g_list_concat (update->page_flip_listeners,
|
|
|
|
g_steal_pointer (&other_update->page_flip_listeners));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
merge_result_listeners_from (MetaKmsUpdate *update,
|
|
|
|
MetaKmsUpdate *other_update)
|
|
|
|
{
|
|
|
|
update->result_listeners =
|
|
|
|
g_list_concat (update->result_listeners,
|
|
|
|
g_steal_pointer (&other_update->result_listeners));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_kms_update_merge_from (MetaKmsUpdate *update,
|
|
|
|
MetaKmsUpdate *other_update)
|
|
|
|
{
|
|
|
|
g_return_if_fail (update->device == other_update->device);
|
|
|
|
|
2022-10-20 21:34:25 +02:00
|
|
|
merge_mode_sets (update, other_update);
|
2021-06-18 15:01:35 +02:00
|
|
|
merge_plane_assignments_from (update, other_update);
|
|
|
|
merge_crtc_color_updates_from (update, other_update);
|
2023-03-02 22:09:16 +01:00
|
|
|
merge_connector_updates_from (update, other_update);
|
2021-06-18 15:01:35 +02:00
|
|
|
merge_custom_page_flip_from (update, other_update);
|
|
|
|
merge_page_flip_listeners_from (update, other_update);
|
|
|
|
merge_result_listeners_from (update, other_update);
|
|
|
|
}
|
|
|
|
|
2023-03-02 01:59:41 +01:00
|
|
|
gboolean
|
|
|
|
meta_kms_update_get_needs_modeset (MetaKmsUpdate *update)
|
|
|
|
{
|
|
|
|
return update->needs_modeset || update->mode_sets;
|
|
|
|
}
|
|
|
|
|
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 22:36:41 +02:00
|
|
|
MetaKmsUpdate *
|
2020-07-16 23:38:10 +02:00
|
|
|
meta_kms_update_new (MetaKmsDevice *device)
|
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 22:36:41 +02:00
|
|
|
{
|
2020-07-16 23:38:10 +02:00
|
|
|
MetaKmsUpdate *update;
|
|
|
|
|
|
|
|
update = g_new0 (MetaKmsUpdate, 1);
|
|
|
|
update->device = device;
|
kms/impl-device: Add deadline based KMS commit scheduling
This makes it possible to post KMS updates that will always defer until
just before the scanout deadline. This is useful to allow queuing cursor
updates where we don't want to post them to KMS immediately, but rather
wait until as late as possible to get lower latency.
We cannot delay primary plane compositions however, and this is due to
how the kernel may prioritize GPU work - not until a pipeline gets
attached to a atomic commit will it in some drivers get bumped to high
priority. This means we still need to post any update that depends on
OpenGL pipelines as soon as possible.
To avoid working on compositing, then getting stomped on the feet by the
deadline scheduler, the deadline timer is disarmed whenever there is a
frame currently being painted. This will still allow new cursor updates
to arrive during composition, but will delay the actual KMS commit until
the primary plane update has been posted.
Still, even for cursor-only we still need higher than default timing
capabilities, thus the deadline scheduler depends on the KMS thread
getting real-time scheduling priority. When the thread isn't realtime
scheduled, the KMS thread instead asks the main thread to "flush" the
commit as part of the regular frame update. A flushing update means one
that isn't set to always defer and has a latching CRTC.
The verbose KMS debug logging makes the processing take too long, making
us more likely to miss the deadline. Avoid this by increasing the
evasion length when debug logging is enabled. Not the best, but better
than changing the behavior completely.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2022-10-26 19:08:30 +02:00
|
|
|
update->is_latchable = TRUE;
|
2020-07-16 23:38:10 +02:00
|
|
|
|
|
|
|
return update;
|
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 22:36:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_kms_update_free (MetaKmsUpdate *update)
|
|
|
|
{
|
2022-06-22 00:23:03 +02:00
|
|
|
if (update->impl_device)
|
|
|
|
meta_kms_impl_device_unhold_fd (update->impl_device);
|
|
|
|
|
2020-10-02 16:35:42 +02:00
|
|
|
g_list_free_full (update->result_listeners,
|
|
|
|
(GDestroyNotify) meta_kms_result_listener_free);
|
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 22:36:41 +02:00
|
|
|
g_list_free_full (update->plane_assignments,
|
|
|
|
(GDestroyNotify) meta_kms_plane_assignment_free);
|
|
|
|
g_list_free_full (update->mode_sets,
|
|
|
|
(GDestroyNotify) meta_kms_mode_set_free);
|
kms/page-flip: Pass ownership of listener user data along with closure
In order to reliably manage the reference count of the user data passed
to page flip listeners - being the stage view - make the ownership of
this data travel through the different objects that take responsibility
of the next step.
Initially this is the MetaKmsPageFlipListener that belongs to a
MetaKmsUpdate.
When a page flip is successfully queued, the ownership is transferred to
a MetaKmsPageFlipClosure that is part of a MetaKmsPageFlipData. In the
simple impl device, the MetaKmsPageFlipData is passed to
drmModePageFlip(), then returned back via the DRM event. In the future
atomic impl device, the MetaKmsPageFlipData is stored in a table, then
retrieved when DRM event are handled.
When the DRM events are handled, the page flip listener's interface
callbacks are invoked, and after that, the user data is freed using the
passed GDestroyNotify function, in the main context, the same as where
the interface callbacks were called.
When a page flip fails, the ownership is also transferred to a
MetaKmsPageFlipClosure that is part of a MetaKmsPageFlipData. This page
flip data will be passed to the main context via a callback, where it
will discard the page flip, and free the user data using the provided
GDestroyNotify.
Note that this adds back a page flip listener type flag for telling the
KMS implementation whether to actively discard a page flip via the
interface, or just free the user data. Avoiding discarding via the
interface is needed for the direct scanout case, where we immediately
need to know the result in order to fall back to the composite pipeline
if the direct scanout failed. We do in fact also need active discard via
the interface paths, e.g. in the simple impl device when we're
asynchronously retrying a page flip, so replace the ad-hoc discard paths
in meta-renderer-native.c and replace them by not asking for no-discard
page flip error handling.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2020-12-16 08:41:14 +01:00
|
|
|
g_list_free_full (update->page_flip_listeners,
|
2022-06-05 21:16:11 +02:00
|
|
|
(GDestroyNotify) meta_kms_page_flip_listener_unref);
|
2020-07-14 16:48:47 +02:00
|
|
|
g_list_free_full (update->connector_updates, g_free);
|
2023-02-17 23:47:04 +01:00
|
|
|
g_list_free_full (update->crtc_color_updates,
|
|
|
|
(GDestroyNotify) meta_kms_crtc_color_updates_free);
|
2021-01-22 11:31:18 +01:00
|
|
|
g_clear_pointer (&update->custom_page_flip, meta_kms_custom_page_flip_free);
|
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 22:36:41 +02:00
|
|
|
|
|
|
|
g_free (update);
|
|
|
|
}
|
2022-06-22 00:23:03 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_kms_update_realize (MetaKmsUpdate *update,
|
|
|
|
MetaKmsImplDevice *impl_device)
|
|
|
|
{
|
|
|
|
update->impl_device = impl_device;
|
|
|
|
meta_kms_impl_device_hold_fd (impl_device);
|
|
|
|
}
|
kms/impl-device: Add deadline based KMS commit scheduling
This makes it possible to post KMS updates that will always defer until
just before the scanout deadline. This is useful to allow queuing cursor
updates where we don't want to post them to KMS immediately, but rather
wait until as late as possible to get lower latency.
We cannot delay primary plane compositions however, and this is due to
how the kernel may prioritize GPU work - not until a pipeline gets
attached to a atomic commit will it in some drivers get bumped to high
priority. This means we still need to post any update that depends on
OpenGL pipelines as soon as possible.
To avoid working on compositing, then getting stomped on the feet by the
deadline scheduler, the deadline timer is disarmed whenever there is a
frame currently being painted. This will still allow new cursor updates
to arrive during composition, but will delay the actual KMS commit until
the primary plane update has been posted.
Still, even for cursor-only we still need higher than default timing
capabilities, thus the deadline scheduler depends on the KMS thread
getting real-time scheduling priority. When the thread isn't realtime
scheduled, the KMS thread instead asks the main thread to "flush" the
commit as part of the regular frame update. A flushing update means one
that isn't set to always defer and has a latching CRTC.
The verbose KMS debug logging makes the processing take too long, making
us more likely to miss the deadline. Avoid this by increasing the
evasion length when debug logging is enabled. Not the best, but better
than changing the behavior completely.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2022-10-26 19:08:30 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_kms_update_set_flushing (MetaKmsUpdate *update,
|
|
|
|
MetaKmsCrtc *crtc)
|
|
|
|
{
|
|
|
|
update_latch_crtc (update, crtc);
|
|
|
|
}
|
|
|
|
|
|
|
|
MetaKmsCrtc *
|
|
|
|
meta_kms_update_get_latch_crtc (MetaKmsUpdate *update)
|
|
|
|
{
|
|
|
|
return update->latch_crtc;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_kms_update_is_empty (MetaKmsUpdate *update)
|
|
|
|
{
|
|
|
|
return (!update->mode_sets &&
|
|
|
|
!update->plane_assignments &&
|
|
|
|
!update->connector_updates &&
|
|
|
|
!update->crtc_color_updates);
|
|
|
|
}
|