Commit graph

49 commits

Author SHA1 Message Date
Simon Ser
9c84f7945a Introduce liftoff_layer_unset_property()
This can be used when a propperty doesn't have a default/no-op
value, such as COLOR_ENCODING and COLOR_RANGE.
2022-08-05 23:10:14 +02:00
Simon Ser
70eca070b6 Make plane_get_property static 2021-09-30 14:57:19 +02:00
Simon Ser
aa30b8fb97 Log number of atomic test-only commits 2021-09-30 09:41:39 +02:00
Simon Ser
32683879e7 Add newline after function return type
Aligns our style with Linux' and Weston's.
2021-08-13 22:02:33 +02:00
Simon Ser
6321e7c5aa Add needs_composition APIs
Right now, compositors are expected to query liftoff_layer_get_plane_id to
decide whether a layer needs to be composited.

However there are cases where a layer has no plane, but still doesn't need
composition (e.g. when FB_ID is zero or when alpha is zero, in the future when
the layer is out of CRTC bounds etc).

Add a new API to make users' life simpler.

Closes: https://github.com/emersion/libliftoff/issues/54
2021-08-09 11:56:55 +02:00
Simon Ser
89c1d37547 Make liftoff_layer_set_property return negative errno
This allows the caller to check for errors.
2021-08-09 11:27:08 +02:00
Simon Ser
516cf9404d Stop including stdbool.h from libliftoff.h
We don't use bool there anymore.
2021-07-30 16:22:58 +02:00
Simon Ser
f5a2b541ce Make liftoff_device_register_all_planes return an int
For consistency with liftoff_output_apply.
2021-07-30 16:19:29 +02:00
Simon Ser
61fd4c099a Make liftoff_output_apply return an int
Callers may want to get more details about the failure, in
particular EPERM indicates that the user isn't DRM master (can
happen on VT switch).
2021-07-27 12:28:00 +02:00
Simon Ser
326c8d67ad Fixup reference to liftoff_layer_get_plane_id in docs 2021-07-01 13:14:23 +02:00
Simon Ser
bcb6e3cfb8 Replace liftoff_layer_get_plane_id with liftoff_layer_get_plane
Users can get back the plane ID with liftoff_plane_get_id.
2021-07-01 11:49:36 +02:00
Simon Ser
8260fa67d7 Introduce liftoff_plane_get_id
This allow users calling liftoff_device_register_all_planes to
easily figure out what a liftoff_plane represents.
2021-07-01 11:39:52 +02:00
Simon Ser
562f8b0af6 Allow to choose which planes are managed by libliftoff
Closes: https://github.com/emersion/libliftoff/issues/10
2021-07-01 11:37:10 +02:00
Simon Ser
b08bbaa5e6 Split liftoff_log_init into set_handler and set_priority
This allows callers to change only one of those, without the other.
Also rename importance to priority and func to handler.
2021-03-31 12:44:24 +02:00
Simon Ser
c4ef21af35 Move layer_is_visible to layer.c 2021-02-24 11:40:01 +01:00
Simon Ser
27462556db Document that liftoff_device_create takes ownership of the FD 2021-02-23 18:10:47 +01:00
Simon Ser
fbc4cf8dba
Stop enabling UNIVERSAL_PLANES
UNIVERSAL_PLANES is implicitly enabled by ATOMIC. No need to require both.
2020-12-22 15:06:13 +01:00
Simon Ser
c9e42e3c14
Improve doc comments
Improve formatting and expand descriptions.
2020-12-06 15:23:01 +01:00
Simon Ser
b936348acc
Replace liftoff_layer_property.changed with prev_value
Keep track of the previous value, e.g. to figure out when a layer goes from
disabled (no FB_ID or zero alpha) to enabled.
2020-12-05 12:28:50 +01:00
Simon Ser
679e2bb0cd
Allow caller to pass commit flags
When the caller wants to perform a modeset, they will need to pass
DRM_MODE_ATOMIC_ALLOW_MODESET in the atomic commit flags, otherwise the driver
will fail the commit. libliftoff also needs to provide these flags in its
test-only commits.
2020-11-10 16:27:55 +01:00
Roman Gilg
d68b1fc8d7
Add log verbosity helper
Separate function to check verbosity level, which can be used in other internal
parts as well.
2020-03-08 13:05:30 +01:00
Roman Gilg
b713b17d31
Log re-use only on change
On debug verbosity logging every reuse of planes is spamming the log making it
difficult to debug the process.

With this patch only the change of reusing the same allocation is logged and
how often the allocation was reused after this changed back again.
2020-03-08 13:00:08 +01:00
Simon Ser
95d16704b9
Move device_test_commit to device.c 2020-01-13 12:22:47 +01:00
Simon Ser
53a7bfebc9
Don't allocate planes for layers without a FB
When FB_ID is unet or zero, don't try to allocate a plane for the layer. There's
nothing to display anyway.
2019-12-19 17:50:20 +01:00
Simon Ser
657a9917c5
Add a way to force FB composition
Closes: https://github.com/emersion/libliftoff/issues/17
2019-12-13 11:38:14 +01:00
Simon Ser
c9cdf8ec50
Log layer configuration before alloc 2019-12-12 23:40:01 +01:00
Simon Ser
d8c20ddac2
Don't re-use prev alloc on composition layer change 2019-12-12 23:23:53 +01:00
Simon Ser
da59787f4a
Fix DEBUG logs printed when level is set to ERROR 2019-12-12 15:44:45 +01:00
Simon Ser
ceb4a1ff9e
Replace liftoff_device_apply with liftoff_output_apply
Compositors need to drive multiple connectors, each with its own vblank timings.
For each device, there's one separate rendering loop per output.

It's not possible to call liftoff_device_apply each time we want to submit a new
frame to one output, because this could touch another's output state, submitting
a new frame there in the process. When the other output will submit a new frame,
it'll get EBUSY (can't submit two frames without waiting for vblank).

Closes: https://github.com/emersion/libliftoff/issues/21
2019-11-24 18:13:40 +01:00
Simon Ser
ef75ba26e0
Don't re-use previous allocation if a layer has been removed
Start from scratch since we may be able to come up with a better allocation
(if the layer made another layer fall back to composition for instance).

Closes: https://github.com/emersion/libliftoff/issues/30
2019-11-24 13:25:59 +01:00
Simon Ser
b0e2b083f9
Rename display to device
"Display" can also mean "screen"/"monitor", so it's kind of confusing for
this usage.
2019-11-24 12:59:10 +01:00
Simon Ser
5f39331f78
Keep track of the update frequency of each layer
Keep track of the number of layer updates per 60 page-flips.

We could implement a more fine-grained tracking, for instance with a sliding
window. However it's a lot more complex than the current solution and the gains
are not clear. I'd prefer to keep the current solution and experiment with other
solutions once we have a good test-bed.

References: https://github.com/emersion/libliftoff/issues/22
2019-11-15 21:43:44 +01:00
Simon Ser
ef29d341cb
Move plane allocation algorithm to alloc.c
And move plane-related functions to plane.c.
2019-10-19 13:43:09 +03:00
Simon Ser
ba80e32054
Introduce liftoff_log_errno
Like perror, but uses the liftoff logging infrastructure.
2019-10-19 13:35:14 +03:00
Simon Ser
5a66e567ec
Track layer property changes
This commit adds basic per-property change tracking.

When only FB_ID has changed, we try to re-use the previous allocation. If that
fails, go on with regular plane allocation.

Closes: https://github.com/emersion/libliftoff/issues/6
2019-10-15 12:07:43 +03:00
Simon Ser
aacbcf40b4
Split plane functions into a separate file 2019-10-11 17:09:35 +03:00
Simon Ser
e9433997d9
Add liftoff_output_set_composition_layer
This lets the library user define a layer where composition will happen. At the
moment there can be at most one composition layer per output, on the primary
plane. It should be possible to remove these restrictions in the future if
desirable.

The composition layer will be put on a plane if and only if composition is
needed.

The compositor needs to know where composited layers will be blended to resolve
zpos conflicts.

Closes: https://github.com/emersion/libliftoff/issues/9
2019-10-11 14:31:17 +03:00
Simon Ser
1ee86c6290
Add logging functions
This allows turning on and off debug logs, as well as defining a logging
callback.
2019-10-11 12:03:14 +03:00
Simon Ser
3671a64ade
Add opaque structs forward declaration in libliftoff.h 2019-09-30 14:19:27 -04:00
Simon Ser
e85a1a5ecf
Add layer_intersects
This will be useful for implementing optimizations in case planes don't collide.
In these cases we can ignore some zpos constraints.

References: https://github.com/emersion/libliftoff/issues/3
2019-09-15 17:00:48 +03:00
Simon Ser
caac9bc87f
Rename library to liftoff
Let's make these planes useful!
2019-09-12 11:40:21 +03:00
Simon Ser
c4a8afb39b
Add basic support for zpos
This commit adds special handling for the layer zpos property. Setting it won't
forward it to KMS, instead it will be handled internally.

The plane zpos (either retrieved from KMS if the property is supported, or
guessed from the plane type and ID) is checked during plane allocation to have
the same ordering as the layer zpos. This adds more constraints to the
allocation.

Note that the new constraints are too strict. In case two layers don't overlap,
there's no need for one plane to be on top of the other. See [1].

Also, the new constraints don't account for underlay planes [2].

[1]: https://github.com/emersion/libhwc/issues/3
[2]: https://github.com/emersion/libhwc/issues/7

Closes: https://github.com/emersion/libhwc/issues/4
2019-09-12 11:27:00 +03:00
Simon Ser
e2df5e73d0
List planes by allocation order
Given a primary plane with zpos=0 and overlay planes with zpos 1 2, we want
first to allocate the primary plane, then the furthest overlay plane, then the
remaining one: 0 2 1.

References: https://github.com/emersion/libhwc/issues/3
2019-09-09 20:55:43 +03:00
Simon Ser
42db49c6fe
Guess zpos from plane type
Many drivers don't expose the zpos plane property. We can guess it from the
plane type though: primary, overlay, cursor. Except some drivers expose
underlays too: underlays, primary, overlay, cursor. Underlay planes don't have a
special type, they are just marked as overlays. To detect them, check whether
their plane ID is less than the primary plane ID.

References: https://github.com/emersion/libhwc/issues/3
2019-09-08 18:33:09 +03:00
Simon Ser
d90d7bdc36
Check plane is compatible with CRTC
This allows us to rule out some potential solutions.

Closes: https://github.com/emersion/libhwc/issues/2
2019-09-08 17:41:25 +03:00
Simon Ser
165d013b80
Change planes to be a linked list instead of an array
We'll need this anyway when we allow users to choose which planes to give us.
Let's not start building algorithms on top of arrays.
2019-09-08 15:26:50 +03:00
Simon Ser
c3f546328e
Add basic docs 2019-08-23 19:37:53 +03:00
Simon Ser
6d5221370e
Disable unused planes 2019-08-23 18:48:13 +03:00
Simon Ser
9fe471dd6b
Initial experiments 2019-08-21 23:07:37 +03:00