1
0
Fork 0
Commit graph

37 commits

Author SHA1 Message Date
Daniel van Vugt
2b561a369c kms-update: Add function meta_kms_update_set_max_bpc
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Jonas Ådahl
2e774e8e14 tests/kms: Check predicted state is correctly predicted
When we're predicting state, i.e. when having posted an update while
avoiding reading KMS state, copy the predicted state, update the actual
state, and check that the predicted state matches the newly updated one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
4276e9ddd3 tests/kms-update: Add mode setting sanity tests
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
de06d5d9e7 kms/update: Add init helper macros for fixed 16 rects
META_FIXED_16_INIT(), taking MetaFixed16's, and META_FIXED_16_INIT_INT()
taking integers, converting them to MetaFixed16.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
acd51a7e69 tests: Add some basic MetaKmsUpdate unit tests
Mostly rudimentary sanity testing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Marco Trevisan (Treviño)
47d7bc7a13 backends/kms: Implement privacy screen handling and setting
Privacy screen events on connector are handled as notification events
that won't cause any monitors reconfiguration but will emit monitors
changed on DBus, so that the new value can be fetched.

We monitor the hardware state so that we can also handle the case of
devices with hw-switchers only.

In case a software state is available it means we can also support
changing the state, and if so expose the state as unlocked.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1952>
2022-01-25 07:31:19 +00:00
Marco Trevisan (Treviño)
4b0a10c562 backends/kms/update: Add ability to remove result listeners
We may need to remove a result listener once we've added it, and before
that it ha been processed, so add support for this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1952>
2022-01-25 07:31:19 +00:00
Piotr Lopatka
af0460d0ce kms: Allow passing framebuffer damage metadata
This commit adds support to atomic KMS backend for optional plane property
prop_fb_damage_clips. Some drivers (e.g. EVDI) take advantage of this
property and process only updated regions of the screen instead of
processing the full frame. This can save system resources.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1879>
2021-09-03 21:10:35 +01:00
Daniel van Vugt
b59c5386b9 kms: Add a trivial meta_fixed_16_to_double conversion function
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1923>
2021-07-13 15:26:43 +08:00
Jonas Ådahl
1d7920872d kms: Gracefully handle page flipping direct scanouts failing
When drmModePageFlip() or drmModeAtomicCommit() unexpectedly failed (e.g.
ENOSPC, which has been seen in the wild), this failure was not handled
very gracefully. The page flip listener for the scanout was left in the
MetaKmsUpdate, meaning when the primary plane composition was later page
flipped, two page flip listeners were added, one for the primary plane,
and one for the scanout. This caused the 'page-flipped' event to be
handled twice, the second time being fatal.

Handle this by making 'no-discard' listener flag be somewhat reversed,
and say 'drop-on-error', and then drop all 'drop-on-error' listeners
when a MetaKmsUpdate failed to be processed.

Also for a "preserve" flagged update, don't ever trigger "discard"
callbacks just yet, as preserved updates are used again for the primary
plane composition, in order to not miss e.g. CRTC gamma updates, or
cursor plane updates, which were added separately.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1809
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1910>
2021-07-02 13:29:54 +00:00
Jonas Ådahl
6bffeeed28 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>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
5f6aee3419 kms/update: Make power saving an update wide change
This makes "power save" (i.e. when you make a monitor go into power save
mode, or make it come out of power save mode), a per device action when
turning on power saving (power save being set to 'off'), and implicitly
handled when turning off power saving (power save being set to 'on')
when doing a mode set.

This is needed as with atomic mode setting, the configuration of DPMS
(Display Power Management Signaling), is replaced by directly turning on
or off CRTCs, and via the CRTC drm properties. Thus in order to handle
both with a common API, make that API high level enough for both cases
being covered.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
487ea0dd95 kms: Add symbolic page flips and cogl frame infos
This makes it possible to post a symbolic page flip and frame callback,
meant to be used by immediate symbolic page flip reply when emulating
cursor plane changes using legacy drmMode* functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
afd0a272cd kms/update: Add way to receive result from later posted update
Something might want to affect the next update that is going to be
posted, but without posting it immediately. For example, changing the
cursor might need to wait for mode setting. Make it possible to get
feedback from posting the update, in order to gracefully handle any
errors.

Note, the API for notifiying about results take out the result listener
from the update, and notifies them in an open coded for loop. The reason
for this is that in the next commit we'll sometimes reuse updates, and
we only want notify about the results once.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
5c7e2bfe22 kms/update: Make explicit page flip just listeners
Page flipping shouldn't necessarily be an actively requested action, but
happen implicitly depending on the given state. Thus, change the "page
flip" update into adding listeners for page flip feedback instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
0acae7f3c1 kms/feedback: Make getter take consts
This will be necessary later, as places that wants to use them will only
have the const variants of the feedback pointers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
411ec5fd18 kms: Allow update passing with failed plane assignments
This will later make it possible to pass cursor plane assignments,
together with a complete update including the primary plane, but not
failing the whole update if just processing the cursor plane failed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
a2b8668544 kms/impl: Dont discard page flips in callback when failed up front
If posting an update resulted in an immediate error, don't communicate
this failure using the page flip feedback callbacks, but directly as a
return value.

This makes it possible for the direct client buffer scanout path not to
pass around flags triggering this behavior, meaning we can handle such
direct scanouts better.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
5ba2d79076 kms/update: Make custom page flip be per update
Custom page flips are meant to allow using e.g. EGLStream API to
indirectly trigger page flip queueing, when the KMS API cannot be used
directly. This is really something that is specific to a device, so
instead of making part of the page flip API, make it a configuration of
the update itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
28facbfa3a kms/update: Assign planes with MetaDrmBuffer instead of fb ids
This will eventually allow better lifetime control.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
17712f7905 kms/update: Make dst_rect a int rectangle
It's never used as a 16.16 fixed point rectangle so no reason it should
be passed around as one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
37fe30c515 kms/update: Make each MetaKmsUpdate update a single device
For now feedbacks from an update are combined, meaning we might lose
error information. The feedback API may have to be reconsidered and
redesigned when planes gets a more front seat position.

This means we need to avoid trying to post updates if we're in power
save mode, as it may be empty.

Note that this is an intermediate state during refactoring that aims to
introduce atomic mode setting support, and we'll stop combining
feedbacks completely in the future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
9d7be40502 monitor-manager-kms: Set gamma on MetaKmsUpdate directly
The meta_kms_crtc_* helper didn't do anything more than call another
function with the exact same arguments.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
ec7667fc31 kms/connector: Set DPMS and underscanning directly on the update
Instead of telling MetaKmsConnector fill a MetaKmsUpdate with connector
property changes, make the update itself aware of the changes, making
the impl side translate that to property changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
309651df6b kms/update: Make change updates to take MetaKmsMode
This will be needed for state keeping connected to turning mode infos
into blobs later used by the atomic modesetting implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
6e3ecadb79 backends/native: Fall back to compositing if direct scanout failed
Even when a direct client buffer has a compatible format, stride and
modifier for direct scanout, drmModePageFlip() may still fail sometimes.

From testing, it has been observed that it may seemingly randomly fail
with ENOSPC, where all subsequent attempts later on the same CRTC
failing with EBUSY.

Handle this by falling back to flipping after having composited a full
frame again.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1410
2020-09-17 12:17:35 +00:00
Jonas Ådahl
e089e53b24 crtc-kms: Make KMS CRTC mode a type inheriting MetaCrtcMode
It carries the drmModeModeInfo copy in it's instance struct, instead of
the `driver_private` it was using before.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1287

This version of the commit includes fixes from:

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1305
2020-06-11 09:20:16 +00:00
Georges Basile Stavracas Neto
49408e8f9f Revert "crtc-kms: Make KMS CRTC mode a type inheriting MetaCrtcMode"
This reverts commit 09078762a, which breaks Mutter.
2020-06-10 23:11:21 -03:00
Jonas Ådahl
09078762ac crtc-kms: Make KMS CRTC mode a type inheriting MetaCrtcMode
It carries the drmModeModeInfo copy in it's instance struct, instead of
the `driver_private` it was using before.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1287
2020-06-10 18:54:51 +00:00
Jonas Ådahl
55cf1c1496 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-26 16:18:28 +00:00
Jonas Ådahl
7c3172a0af kms/impl-simple: Add cursor plane processing
A cursor plane can now be assigned, and for the simple KMS
implementation, it'll translate into drmModeSetCursor() and
drmModeMoveCursor() calls.

When assignments failed, the cursor planes that failed to be assigned
are communicated via the feedback object.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
73dcb9fa22 kms: Make update processing return direct feedback
The current API as all synchronous, so they can be made to return
feedback immediately. This will be needed for the cursor renderer which
needs to know whether it should fall back to OpenGL cursor rendering.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
3ace2b9a28 kms/update: Move auto-cleanup declaration to the bottom
It relies on visible function declarations, so move it to the bottom so
we can add more auto-cleanup declarations same without them being spread
out.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
01bab81727 kms/update: Add flags to plane assignment
Currently unused, but will used to let the implementation know when it
can avoid setting the plane content (i.e. not call drmModeSetCursor()).

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
851024f730 kms/update: Add unassign_plane() API
Meant to disable a plane.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:27:46 +01:00
Jonas Ådahl
2a990cc140 kms/update: Add helper to turn fixed point rect into int rect
Currently unused, but will in the following commit.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/826
2019-10-07 14:59:18 +00:00
Jonas Ådahl
75dff3e7c9 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-06-20 13:31:56 +00:00