Commit graph

194 commits

Author SHA1 Message Date
Simon Ser
1700cbf1c9
Force re-alloc when setting FB to 0 2020-12-05 12:18:36 +01:00
Simon Ser
b4bddc77a2
test: refactor dynamic test
Make it easier for dynamic tests to change the initial configuration and the
expected final allocation.
2020-12-05 11:54:39 +01:00
Simon Ser
93a346ff95
example: fix exit status after failed drmModeAtomicCommit 2020-11-12 15:15:55 +01:00
Simon Ser
24abeb923f
Remove DRM_MODE_PAGE_FLIP_EVENT from commit flags
It's illegal to request a page-flip event when performing a test-only commit.
The kernel returns EINVAL in this case [1].

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/drm_atomic_uapi.c?id=407ab579637ced6dc32cfb2295afb7259cca4b22#n1318
2020-11-10 16:42:06 +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
Simon Ser
f7837738c4
ci: add freebsd CI 2020-11-05 15:21:51 +01:00
Jan Beich
0095702303 build: ignore warnings in libdrm headers
In file included from ../log.c:4:
In file included from ../include/log.h:4:
In file included from ../include/libliftoff.h:8:
/usr/local/include/xf86drmMode.h:551:19: error: zero size arrays are an extension [-Werror,-Wzero-length-array]
        uint32_t lessees[0];
                         ^
/usr/local/include/xf86drmMode.h:558:19: error: zero size arrays are an extension [-Werror,-Wzero-length-array]
        uint32_t objects[0];
                         ^
2020-10-31 09:17:13 +01:00
Jan Beich
ca097d55bc test: bump POSIX version for CLOCK_MONOTONIC
test/bench.c:99:16: error: use of undeclared identifier 'CLOCK_MONOTONIC'
        clock_gettime(CLOCK_MONOTONIC, &start);
                      ^
test/bench.c:106:16: error: use of undeclared identifier 'CLOCK_MONOTONIC'
        clock_gettime(CLOCK_MONOTONIC, &end);
                      ^
2020-10-31 09:17:13 +01:00
Simon Ser
b0042828ad
test: add test with fully transparent layer 2020-05-26 21:30:31 +02:00
Simon Ser
8ff01dc6a1
Don't pick a plane for fully transparent layers
Layers with alpha = 0 don't need a plane since they aren't visible.

Closes: https://github.com/emersion/libliftoff/issues/48
2020-05-26 21:29:59 +02:00
Simon Ser
5603060a9b
Take disabled layers into account in non_composition_layers_len
Disabled layers (with FB_ID = 0) don't need a plane. Fix the
non_composition_layers_len count in this case.

Closes: https://github.com/emersion/libliftoff/issues/49
2020-05-26 20:08:12 +02:00
Simon Ser
46095c6428
test/libdrm_mock: add prefix to logs
Allows to easily tell where they're coming from.
2020-05-26 18:55:47 +02:00
Simon Ser
6d4e22a5f8
test: a test-only commit doesn't apply properties
This fixes a misunderstanding of the DRM API. Only a regular commit applies
properties.

Fixes: b16078769e ("test/libdrm_mock: a test-only commit applies properties")
2020-05-26 18:49:04 +02:00
Simon Ser
95da3ee649
Add support for the rotation property 2020-05-26 11:35:50 +02:00
Simon Ser
234dce4f20
test: add test for alpha prop 2020-05-22 17:44:41 +02:00
Simon Ser
44946c44d8
Add support for the alpha property
If the layer is completely opaque, we don't need a plane with the alpha
property.
2020-05-22 17:40:33 +02:00
Simon Ser
c214afa3ee
test: allow to attach props to mock planes
This allows tests to have planes which have additional properties, like
"alpha".
2020-05-22 17:39:56 +02:00
Simon Ser
7cca504ae6
test: add internal mutable prop list
This will allow tests to register their own properties.
2020-05-22 17:39:33 +02:00
Simon Ser
2b02f50553
Replace assert(0) with abort()
This avoids -Wreturn-type warnings.
2020-05-19 12:10:17 +02:00
Simon Ser
ded5bd083c
Print composition layer in logs 2020-04-09 18:25:37 +02:00
Simon Ser
049077aee5
readme: add link to FOSDEM 2020 talk 2020-03-25 16:23:59 +01:00
Simon Ser
950e100d7e
readme: add contributing section 2020-03-10 12:10:51 +01:00
Roman Gilg
52cd24a904
Omit logging inactive layer information
It is only of interest to log the currently active layers when debugging.
A layer is inactive when it does not have an fb and composition is not forced.

Check layers for that and otherwise skip them. Also tell if composition is
actually forced on the layer.
2020-03-08 22:31:59 +01:00
Roman Gilg
71bd11377a
Respect implicit type on layer props log
The CRTC_X and CRTC_Y values can be negative. Log respectively. Additionally
the SRC_W and SRC_H values are shifted. Shift these values back for the log.
2020-03-08 22:30:08 +01:00
Roman Gilg
6b2cbeb0d4
Indent log on property applying and layer assignment
Indent when applying properties and assigning the layers. The log is better to
read this way. Example:

    Apply on output 0x55c447db2b50.
    Layers on CRTC 62:
      Layer 0x55c447db2a40:
        FB_ID = 108
        zpos = 0
        alpha = 65535
        SRC_X = 0
        SRC_Y = 0
        SRC_W = 3840
        SRC_H = 2160
        CRTC_X = 0
        CRTC_Y = 0
        CRTC_W = 3840
        CRTC_H = 2160
    Disabling planes: 55 52 49 46 43 40 71 69 67 65 63 61 58
    Performing allocation for plane 55 (1/13)
      Layer 0x55c447db2a40 -> plane 55: applying properties...
      Layer 0x55c447db2a40 -> plane 55: incompatible properties
    Performing allocation for plane 61 (12/13)
      Layer 0x55c447db2a40 -> plane 61: applying properties...
      Layer 0x55c447db2a40 -> plane 61: incompatible properties
    Performing allocation for plane 58 (13/13)
      Layer 0x55c447db2a40 -> plane 58: applying properties...
      Layer 0x55c447db2a40 -> plane 58: success
    Found a better allocation with score=1
    Found plane allocation for output 0x55c447db2b50 with score=1
    Assigning layers to planes:
      Layer 0x55c447db2a40 -> plane 58
2020-03-08 14:18:09 +01:00
Roman Gilg
375a8123d2
Skip layer debug early
If the verbosity is low we can skip logging layer information early and do not
need to run the loop.
2020-03-08 13:06:11 +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
a3b7c19204
Log layer priority only on change
Similar to reuse log print debug information only when the priority of a layer
changes not whenever priority gets updated but without change.

Otherwise the debug log is spammed (depending on LIFTOFF_PRIORITY_PERIOD).
2020-03-08 13:03:05 +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
7f5b699f2c
build: install public header file
Closes: https://github.com/emersion/libliftoff/issues/41
2020-01-27 11:04:52 +01:00
Simon Ser
f6b4cd6197
Retry atomic commit on EINTR and EAGAIN
From the kernel docs:

> -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted. This can
> either be due to a pending signal, or because the driver needs to completely
> bail out to recover from an exceptional situation like a GPU hang. From a
> userspace point of view all errors are treated equally.

We're not handling ERESTARTSYS because it's non-POSIX.
2020-01-13 12:28:39 +01:00
Simon Ser
95d16704b9
Move device_test_commit to device.c 2020-01-13 12:22:47 +01:00
Simon Ser
b16078769e
test/libdrm_mock: a test-only commit applies properties
The previous mock library assumed the DRM client would always set all
properties in the atomic request. However, if a previous test-only commit
has set a property, there's no need to set it again.

Accomodate for this in libdrm_mock. This will be useful when we'll skip
setting properties that haven't changed in libliftoff.

References: https://github.com/emersion/libliftoff/issues/37
2020-01-13 12:14:33 +01:00
Simon Ser
64cfbc8e58
Fix format string for plane ID 2020-01-13 10:42:46 +01:00
Simon Ser
cfeee41ec1
Allow NULL to be passed to destructors
In this case, the destructor will be a no-op. This is similar to free(3)'s
behavior and allows to omit a NULL check for callers.
2019-12-31 20:46:08 +01:00
Simon Ser
7286146341
test: add a test with a zero FB_ID
References: 53a7bfebc9 ("Don't allocate planes for layers without a FB")
2019-12-19 17:54:49 +01:00
Simon Ser
71200724c5
test: add a test with a layer without any prop set
Makes sure libliftoff doesn't allocate a plane for the layer and doesn't crash.

References: 799f694587 ("Fix segfault when FB_ID isn't set")
References: 53a7bfebc9 ("Don't allocate planes for layers without a FB")
2019-12-19 17:50:40 +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
799f694587
Fix segfault when FB_ID isn't set
This would previously result in a crash:

    ==169727==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000028 (pc 0x7f3e0c4d7dc7 bp 0x7ffc97f8aff0 sp 0x7ffc97f8afc0 T0)
    ==169727==The signal is caused by a READ memory access.
    ==169727==Hint: address points to the zero page.
        #0 0x7f3e0c4d7dc6 in layer_update_priority ../subprojects/libliftoff/layer.c:152
        #1 0x7f3e0c4d3a4c in update_layers_priority ../subprojects/libliftoff/alloc.c:573
        #2 0x7f3e0c4d3d7f in liftoff_output_apply ../subprojects/libliftoff/alloc.c:590
        …
2019-12-19 17:37:18 +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
dcca965fc1
Remove chatty debug log 2019-12-12 23:26:05 +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
99ef3d5b2e
Unset plane->layer and layer->plane on destroy
This fixes a use-after-free when destroying a layer/plane early.
2019-12-06 15:06:14 +01:00
Simon Ser
333e454e98
test: make mock drmModeAtomicAddProperty return cursor
For consistency with the original libdrm function.
2019-11-29 11:06:57 +01:00
Simon Ser
e09ebdac27
test: add empty test
Make sure calling apply() with no layer works as expected.
2019-11-29 10:57:24 +01:00
Simon Ser
49b4f46762
Rename display.c to device.c
Forgot to do that when renaming the struct.
2019-11-29 01:51:22 +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