libliftoff/output.c
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

100 lines
2.3 KiB
C

#include <assert.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "private.h"
struct liftoff_output *liftoff_output_create(struct liftoff_device *device,
uint32_t crtc_id)
{
struct liftoff_output *output;
ssize_t crtc_index;
size_t i;
crtc_index = -1;
for (i = 0; i < device->crtcs_len; i++) {
if (device->crtcs[i] == crtc_id) {
crtc_index = i;
break;
}
}
if (crtc_index < 0) {
return NULL;
}
liftoff_log(LIFTOFF_DEBUG, "Creating output for CRTC id: %"PRIu32 " index: %zu", crtc_id, crtc_index);
output = calloc(1, sizeof(*output));
if (output == NULL) {
liftoff_log_errno(LIFTOFF_ERROR, "calloc");
return NULL;
}
output->device = device;
output->crtc_id = crtc_id;
output->crtc_index = crtc_index;
liftoff_list_init(&output->layers);
liftoff_list_insert(&device->outputs, &output->link);
return output;
}
void liftoff_output_destroy(struct liftoff_output *output)
{
if (output == NULL) {
return;
}
liftoff_list_remove(&output->link);
free(output);
}
void liftoff_output_set_composition_layer(struct liftoff_output *output,
struct liftoff_layer *layer)
{
assert(layer->output == output);
if (layer != output->composition_layer) {
output->layers_changed = true;
}
output->composition_layer = layer;
}
void output_log_layers(struct liftoff_output *output) {
struct liftoff_layer *layer;
size_t i;
if (!log_has(LIFTOFF_DEBUG)) {
return;
}
liftoff_log(LIFTOFF_DEBUG, "\nCommitted layers:");
liftoff_list_for_each(layer, &output->layers, link) {
if (layer->force_composition) {
liftoff_log(LIFTOFF_DEBUG, " Layer %p "
"(forced composition):", (void *)layer);
} else {
if (!layer_has_fb(layer)) {
continue;
}
liftoff_log(LIFTOFF_DEBUG, " Layer %p:", (void *)layer);
}
for (i = 0; i < layer->props_len; i++) {
char *name = layer->props[i].name;
uint64_t value = layer->props[i].value;
if (strcmp(name, "CRTC_X") == 0 ||
strcmp(name, "CRTC_Y") == 0) {
liftoff_log(LIFTOFF_DEBUG, " %s = %"PRIi32,
name, (int32_t)value);
} else if (strcmp(name, "SRC_W") == 0 ||
strcmp(name, "SRC_H") == 0) {
liftoff_log(LIFTOFF_DEBUG, " %s = %"PRIu64,
name, value >> 16);
} else {
liftoff_log(LIFTOFF_DEBUG, " %s = %"PRIu64,
name, value);
}
}
}
}