Find a file
Roman Gilg 273cf8a432
feat: log current planes on apply
It is helpful for debugging to know in which state the available planes on an
output are when a layout is applied that leads to a change.

For that log all planes that are compatible with the output. Currently disabled
planes have multiple properties logged per line to keep the log short.

Example:

== Apply request for output 62 ==
  Note: Reused previous plane allocation 5 times.

Available planes (on output 62):
  Plane 55:
    type: primary
    FB_ID: 93
    IN_FENCE_FD: -1
    CRTC_ID: 62
    CRTC_X: 39
    CRTC_Y: 0
    CRTC_W: 3761
    CRTC_H: 2160
    SRC_X: 0
    SRC_Y: 0
    SRC_W: 2349
    SRC_H: 1349
    COLOR_ENCODING: 0
    COLOR_RANGE: 0
  Plane 61 (inactive):
    type: cursor FB_ID: 0 IN_FENCE_FD: -1 CRTC_ID: 0
    CRTC_X: 0 CRTC_Y: 0 CRTC_W: 0 CRTC_H: 0
    SRC_X: 0 SRC_Y: 0 SRC_W: 0 SRC_H: 0
  Plane 58 (inactive):
    type: overlay FB_ID: 0 IN_FENCE_FD: -1 CRTC_ID: 0
    CRTC_X: 0 CRTC_Y: 0 CRTC_W: 0 CRTC_H: 0
    SRC_X: 0 SRC_Y: 0 SRC_W: 0 SRC_H: 0
    alpha: 65535 pixel blend mode: 0

Committed layers:
  Layer 0x561febd41260:
    FB_ID = 93
    zpos = 0
    SRC_X = 0
    SRC_Y = 0
    SRC_W = 2349
    SRC_H = 1349
    CRTC_X = 39
    CRTC_Y = 0
    CRTC_W = 3761
    CRTC_H = 2160
  Layer 0x561febd3c830:
    FB_ID = 110
    zpos = 2
    SRC_X = 0
    SRC_Y = 0
    SRC_W = 48
    SRC_H = 48
    CRTC_X = 66
    CRTC_Y = 39
    CRTC_W = 48
    CRTC_H = 48

Reset planes: 55 52 49 46 43 40 <p|c> 71 69 67 65 63 61 <c|o> 58

Performing allocation for plane 55 (1/13)
  Layer 0x561febd41260 -> plane 55: applying properties...
  Layer 0x561febd41260 -> plane 55: success
Performing allocation for plane 61 (12/13)
  Layer 0x561febd3c830 -> plane 61: applying properties...
  Layer 0x561febd3c830 -> plane 61: success
Performing allocation for plane 58 (13/13)
Found a better allocation with score=2
  Layer 0x561febd3c830 -> plane 55: applying properties...
  Layer 0x561febd3c830 -> plane 55: success
Performing allocation for plane 61 (12/13)
  Layer 0x561febd41260 -> plane 61: applying properties...
  Layer 0x561febd41260 -> plane 61: success
Performing allocation for plane 58 (13/13)
Found plane allocation for output 0x561febd3e2a0 with score=2

Final assignment of layers to planes:
  [1] Layer 0x561febd41260 -> plane 55 (primary)
  [2] Layer 0x561febd3c830 -> plane 61 (cursor)
2020-03-10 11:59:38 +01:00
example Replace liftoff_device_apply with liftoff_output_apply 2019-11-24 18:13:40 +01:00
include feat: log disabling planes without line breaks 2020-03-10 11:52:37 +01:00
test test/libdrm_mock: a test-only commit applies properties 2020-01-13 12:14:33 +01:00
.build.yml ci: add codecov 2019-10-14 18:04:59 +03:00
.editorconfig Initial experiments 2019-08-21 23:07:37 +03:00
.gitignore Add build-* to .gitignore 2019-10-19 13:46:11 +03:00
alloc.c feat: log current planes on apply 2020-03-10 11:59:38 +01:00
device.c feat: log device creation 2020-03-10 11:52:37 +01:00
layer.c Log layer priority only on change 2020-03-08 13:03:05 +01:00
LICENSE Add LICENSE 2019-08-21 23:13:35 +03:00
list.c Rename library to liftoff 2019-09-12 11:40:21 +03:00
log.c feat: log disabling planes without line breaks 2020-03-10 11:52:37 +01:00
meson.build build: install public header file 2020-01-27 11:04:52 +01:00
output.c feat: log current planes on apply 2020-03-10 11:59:38 +01:00
plane.c feat: log device creation 2020-03-10 11:52:37 +01:00
README.md Replace liftoff_device_apply with liftoff_output_apply 2019-11-24 18:13:40 +01:00

libliftoff

builds.sr.ht status

Lightweight hardware composer library for libdrm.

libliftoff eases the use of KMS planes from userspace without standing in your way. Users create "virtual planes" called layers, set KMS properties on them, and libliftoff will allocate planes for these layers if possible.

See the blog post introducing the project for more context.

Building

Depends on libdrm. Requires universal planes and atomic.

meson build/
ninja -C build/

Usage

See liftoff.h. Here's the general idea:

struct liftoff_device *device;
struct liftoff_output *output;
struct liftoff_layer *layer;
drmModeAtomicReq *req;
int ret;

device = liftoff_device_create(drm_fd);
output = liftoff_output_create(device, crtc_id);

layer = liftoff_layer_create(output);
liftoff_layer_set_property(layer, "FB_ID", fb_id);
/* Probably setup more properties and more layers */

req = drmModeAtomicAlloc();
if (!liftoff_output_apply(output, req)) {
	perror("liftoff_output_apply");
	exit(1);
}

ret = drmModeAtomicCommit(drm_fd, req, DRM_MODE_ATOMIC_NONBLOCK, NULL);
if (ret < 0) {
	perror("drmModeAtomicCommit");
	exit(1);
}
drmModeAtomicFree(req);

License

MIT