Commit graph

283 commits

Author SHA1 Message Date
Simon Ser
3200016033
test: add basic zpos tests
zpos-3x maps three layers to primary, cursor and one of the overlays planes.

zpos-4x-partial sets up 4 layers but is only able to find a plane for 3 layers,
because ordering between the two overlay planes is undefined.
2019-09-13 22:53:15 +03:00
Simon Ser
de8175c998
test: add an alloc test with 3 layers 2019-09-13 22:35:23 +03:00
Simon Ser
060023c6f1
test: fix atomic commit layer compatibility
Used wrong index while iterating.
2019-09-13 22:34:34 +03:00
Simon Ser
fccdebfd6e
test: introduce structured alloc tests
This is a new kind of tests defined by a static structure. The structure
contains the layers and planes to setup as well as the expected result.
2019-09-13 19:47:00 +03:00
Simon Ser
54bb501cae
test: add liftoff_mock_drm_get_plane
Allows to get a mock plane from a plane ID.
2019-09-13 19:46:21 +03:00
Simon Ser
1cd18f9156
test: mock atomic commit improvements
Don't fail the commit if FB_ID and CRTC_ID are set to zero. Print the reason
why the commit fails.
2019-09-13 19:44:12 +03:00
Simon Ser
a1e3798f6f
Use PRIu32 for printing plane IDs 2019-09-13 19:43:01 +03:00
Simon Ser
5afeeb531a
Add test framework
When testing the library, the libdrm dependency is swapped with a mock libdrm.
The test sets up the mock libdrm's internal state and then runs the test.
2019-09-13 10:33:49 +03:00
Simon Ser
bb887aa7d0
Fix segfault when dup fails in liftoff_display_create 2019-09-12 20:15:50 +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
fc901d0e26
Fix early bailout when we already have a better allocation
In case we can't do better than the current best allocation even if we manage
to allocate all remaining planes, we bail out early. However the bailout
condition was incorrect and didn't account for the current score.
2019-09-12 10:17:03 +03:00
Simon Ser
1509e50fd5
Extract allocation arguments to a struct
Just trying to keep the number of arguments under a reasonable limit. More
arguments will be added in the future.
2019-09-11 19:23:35 +03:00
Simon Ser
4d641041bb
Don't assign layer to plane if missing props
Sometimes the properties applied on a layer are missing on a plane. Instead of
making the whole allocation fail, just mark the plane as incompatible with the
layer.
2019-09-10 22:58:29 +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
dac885222b
Add support for reading immutable plane zpos
If zpos is present, instead of guessing the zpos from the plane type, just use
it. If two planes have the same zpos, we consider their relative position as
undefined.

We don't handle the case where some planes have zpos set but some others don't.

References: https://github.com/emersion/libhwc/issues/4
2019-09-09 19:46:44 +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
66bedbc854
Reset best allocation to NULL
Without this, if no allocation has been found, garbage will be read from
alloc.best.
2019-09-08 17:39:55 +03:00
Simon Ser
b3eb0e323c
Basic brute-force plane allocation
This is the very first complete allocator. There are many things that can be
improved, but at least it works.

Closes: https://github.com/emersion/libhwc/issues/8
2019-09-08 16:32:38 +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
14848bb802
Iterate over layers in example 2019-08-23 19:49:56 +03:00
Simon Ser
c3f546328e
Add basic docs 2019-08-23 19:37:53 +03:00
Simon Ser
7bea0c7bf7
Better hwc_display_apply error handling 2019-08-23 19:27:13 +03:00
Simon Ser
1ca4a03224
Disable all planes before building the mapping 2019-08-23 19:20:05 +03:00
Simon Ser
c5601aef5d
Add another layer to the example 2019-08-23 18:59:44 +03:00
Simon Ser
559bd2bf3a
Don't pick a busy plane in layer_choose_plane 2019-08-23 18:59:20 +03:00
Simon Ser
9a6237026a
Reset all mappings in hwc_display_apply 2019-08-23 18:56:44 +03:00
Simon Ser
6d5221370e
Disable unused planes 2019-08-23 18:48:13 +03:00
Simon Ser
00f85c4eca
Add missing static qualifiers 2019-08-23 18:20:42 +03:00
Simon Ser
4bce10a7a5
Add LICENSE 2019-08-21 23:13:35 +03:00
Simon Ser
d70b45b36d
Add README 2019-08-21 23:12:11 +03:00
Simon Ser
9fe471dd6b
Initial experiments 2019-08-21 23:07:37 +03:00