Skip to content
This repository was archived by the owner on Oct 25, 2021. It is now read-only.

Commit fa1c4e3

Browse files
committed
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.
1 parent 8dc2039 commit fa1c4e3

3 files changed

Lines changed: 96 additions & 1 deletion

File tree

alloc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ bool liftoff_output_apply(struct liftoff_output *output, drmModeAtomicReq *req)
602602
}
603603
log_no_reuse(output);
604604

605+
output_log_planes(output);
605606
output_log_layers(output);
606607

607608
/* Unset all existing plane and layer mappings. */

include/private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ struct liftoff_plane_property *plane_get_property(struct liftoff_plane *plane,
9898
bool plane_apply(struct liftoff_plane *plane, struct liftoff_layer *layer,
9999
drmModeAtomicReq *req, bool *compatible);
100100

101+
void output_log_planes(struct liftoff_output *output);
101102
void output_log_layers(struct liftoff_output *output);
102103

103104
#endif

output.c

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,99 @@ void liftoff_output_set_composition_layer(struct liftoff_output *output,
5555
output->composition_layer = layer;
5656
}
5757

58+
void output_log_planes(struct liftoff_output *output)
59+
{
60+
struct liftoff_device *device;
61+
struct liftoff_plane *plane;
62+
drmModeObjectProperties *drm_props;
63+
drmModePropertyRes *drm_prop;
64+
size_t i;
65+
int per_line, max_per_line;
66+
67+
device = output->device;
68+
69+
if (!log_has(LIFTOFF_DEBUG)) {
70+
return;
71+
}
72+
73+
liftoff_log(LIFTOFF_DEBUG, "Planes on CRTC %"PRIu32":", output->crtc_id);
74+
75+
liftoff_list_for_each(plane, &device->planes, link) {
76+
bool active = false;
77+
78+
if ((plane->possible_crtcs & (1 << output->crtc_index)) == 0) {
79+
continue;
80+
}
81+
82+
83+
drm_props = drmModeObjectGetProperties(device->drm_fd,
84+
plane->id, DRM_MODE_OBJECT_PLANE);
85+
if (drm_props == NULL) {
86+
liftoff_log_errno(LIFTOFF_ERROR, "drmModeObjectGetProperties");
87+
continue;
88+
}
89+
90+
for (i = 0; i < drm_props->count_props; i++) {
91+
drm_prop = drmModeGetProperty(device->drm_fd, drm_props->props[i]);
92+
if (drm_prop == NULL) {
93+
liftoff_log_errno(LIFTOFF_ERROR, "drmModeObjectGetProperties");
94+
continue;
95+
}
96+
97+
if (strcmp(drm_prop->name, "CRTC_ID") == 0
98+
&& drm_props->prop_values[i] != 0) {
99+
active = true;
100+
break;
101+
}
102+
}
103+
104+
struct liftoff_log_buffer log_buf = {0};
105+
liftoff_log_buffer_append(&log_buf, " Plane %"PRIu32 "%s", plane->id,
106+
active ? ":" : " (inactive):");
107+
108+
max_per_line = active ? 1 : 4;
109+
per_line = max_per_line - 1;
110+
for (i = 0; i < drm_props->count_props; i++) {
111+
uint64_t value = drm_props->prop_values[i];
112+
char *name;
113+
114+
if (++per_line == max_per_line) {
115+
liftoff_log_buffer_append(&log_buf, "\n ");
116+
per_line = 0;
117+
}
118+
119+
drm_prop = drmModeGetProperty(device->drm_fd,
120+
drm_props->props[i]);
121+
if (drm_prop == NULL) {
122+
liftoff_log_buffer_append(&log_buf, "ERR!");
123+
continue;
124+
}
125+
126+
name = drm_prop->name;
127+
128+
if (strcmp(name, "type") == 0) {
129+
liftoff_log_buffer_append(&log_buf, " %s: %s", name,
130+
value == DRM_PLANE_TYPE_PRIMARY ? "primary" :
131+
value == DRM_PLANE_TYPE_CURSOR ? "cursor" : "overlay");
132+
continue;
133+
}
134+
135+
if (strcmp(name, "CRTC_X") == 0 || strcmp(name, "CRTC_Y") == 0
136+
|| strcmp(name, "IN_FENCE_FD") == 0) {
137+
liftoff_log_buffer_append(LIFTOFF_DEBUG, " %s: %"PRIi32, name,
138+
(int32_t)value);
139+
continue;
140+
}
141+
142+
if (strcmp(name, "SRC_W") == 0 || strcmp(name, "SRC_H") == 0) {
143+
value = value >> 16;
144+
}
145+
liftoff_log_buffer_append(&log_buf, " %s: %"PRIu64, name, value);
146+
}
147+
liftoff_log_buffer_flush(&log_buf, LIFTOFF_DEBUG);
148+
}
149+
}
150+
58151
void output_log_layers(struct liftoff_output *output) {
59152
struct liftoff_layer *layer;
60153
size_t i;
@@ -63,7 +156,7 @@ void output_log_layers(struct liftoff_output *output) {
63156
return;
64157
}
65158

66-
liftoff_log(LIFTOFF_DEBUG, "Layers on CRTC %"PRIu32":", output->crtc_id);
159+
liftoff_log(LIFTOFF_DEBUG, "Available layers:");
67160
liftoff_list_for_each(layer, &output->layers, link) {
68161
if (layer->force_composition) {
69162
liftoff_log(LIFTOFF_DEBUG, " Layer %p "

0 commit comments

Comments
 (0)