mirror of
https://gitlab.freedesktop.org/emersion/libliftoff.git
synced 2024-12-26 21:59:18 +01:00
feat: log device creation
For a new device log relevant data including all planes the output/CRTC supports.
This commit is contained in:
parent
8028aef654
commit
afef092218
3 changed files with 49 additions and 3 deletions
2
alloc.c
2
alloc.c
|
@ -614,7 +614,7 @@ bool liftoff_output_apply(struct liftoff_output *output, drmModeAtomicReq *req)
|
||||||
|
|
||||||
/* Disable all planes. Do it before building mappings to make sure not
|
/* Disable all planes. Do it before building mappings to make sure not
|
||||||
to hit bandwidth limits because too many planes are enabled. */
|
to hit bandwidth limits because too many planes are enabled. */
|
||||||
liftoff_log_cnt(LIFTOFF_DEBUG, "Disabling planes:");
|
liftoff_log_cnt(LIFTOFF_DEBUG, "Reset planes:");
|
||||||
liftoff_list_for_each(plane, &device->planes, link) {
|
liftoff_list_for_each(plane, &device->planes, link) {
|
||||||
if (plane->layer == NULL) {
|
if (plane->layer == NULL) {
|
||||||
liftoff_log_cnt(LIFTOFF_DEBUG, " %"PRIu32, plane->id);
|
liftoff_log_cnt(LIFTOFF_DEBUG, " %"PRIu32, plane->id);
|
||||||
|
|
11
device.c
11
device.c
|
@ -1,4 +1,5 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -12,6 +13,8 @@ struct liftoff_device *liftoff_device_create(int drm_fd)
|
||||||
drmModePlaneRes *drm_plane_res;
|
drmModePlaneRes *drm_plane_res;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
|
liftoff_log_cnt(LIFTOFF_DEBUG, "\nCreating device for fd %d. ", drm_fd);
|
||||||
|
|
||||||
device = calloc(1, sizeof(*device));
|
device = calloc(1, sizeof(*device));
|
||||||
if (device == NULL) {
|
if (device == NULL) {
|
||||||
liftoff_log_errno(LIFTOFF_ERROR, "calloc");
|
liftoff_log_errno(LIFTOFF_ERROR, "calloc");
|
||||||
|
@ -56,7 +59,13 @@ struct liftoff_device *liftoff_device_create(int drm_fd)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
liftoff_log(LIFTOFF_DEBUG, "The device has %"PRIu32 " planes:", drm_plane_res->count_planes);
|
||||||
|
|
||||||
for (i = 0; i < drm_plane_res->count_planes; i++) {
|
for (i = 0; i < drm_plane_res->count_planes; i++) {
|
||||||
|
if (i < 9 && drm_plane_res->count_planes >= 9) {
|
||||||
|
liftoff_log_cnt(LIFTOFF_DEBUG, " ");
|
||||||
|
}
|
||||||
|
liftoff_log_cnt(LIFTOFF_DEBUG, "[%d] ", i + 1);
|
||||||
if (plane_create(device, drm_plane_res->planes[i]) == NULL) {
|
if (plane_create(device, drm_plane_res->planes[i]) == NULL) {
|
||||||
liftoff_device_destroy(device);
|
liftoff_device_destroy(device);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -64,6 +73,8 @@ struct liftoff_device *liftoff_device_create(int drm_fd)
|
||||||
}
|
}
|
||||||
drmModeFreePlaneResources(drm_plane_res);
|
drmModeFreePlaneResources(drm_plane_res);
|
||||||
|
|
||||||
|
liftoff_log_cnt(LIFTOFF_DEBUG, "\n");
|
||||||
|
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
39
plane.c
39
plane.c
|
@ -30,6 +30,37 @@ static int guess_plane_zpos_from_type(struct liftoff_device *device,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void log_plane(struct liftoff_plane *plane)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
int per_line = 0;
|
||||||
|
|
||||||
|
if (!log_has(LIFTOFF_DEBUG)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
liftoff_log_cnt(LIFTOFF_DEBUG, " type: ");
|
||||||
|
if (plane->type == DRM_PLANE_TYPE_PRIMARY) {
|
||||||
|
liftoff_log(LIFTOFF_DEBUG, "Primary");
|
||||||
|
} else if (plane->type == DRM_PLANE_TYPE_CURSOR) {
|
||||||
|
liftoff_log(LIFTOFF_DEBUG, "Cursor");
|
||||||
|
} else {
|
||||||
|
liftoff_log(LIFTOFF_DEBUG, "Overlay");
|
||||||
|
}
|
||||||
|
liftoff_log(LIFTOFF_DEBUG, " zpos: %"PRIu32, plane->zpos);
|
||||||
|
|
||||||
|
liftoff_log_cnt(LIFTOFF_DEBUG, " props:");
|
||||||
|
for (i = 0; i < plane->props_len; i++) {
|
||||||
|
if (per_line == 5) {
|
||||||
|
liftoff_log_cnt(LIFTOFF_DEBUG, "\n ");
|
||||||
|
per_line = 0;
|
||||||
|
}
|
||||||
|
liftoff_log_cnt(LIFTOFF_DEBUG, " %s", plane->props[i].name);
|
||||||
|
per_line++;
|
||||||
|
}
|
||||||
|
liftoff_log_cnt(LIFTOFF_DEBUG, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
struct liftoff_plane *plane_create(struct liftoff_device *device, uint32_t id)
|
struct liftoff_plane *plane_create(struct liftoff_device *device, uint32_t id)
|
||||||
{
|
{
|
||||||
struct liftoff_plane *plane, *cur;
|
struct liftoff_plane *plane, *cur;
|
||||||
|
@ -41,6 +72,8 @@ struct liftoff_plane *plane_create(struct liftoff_device *device, uint32_t id)
|
||||||
uint64_t value;
|
uint64_t value;
|
||||||
bool has_type = false, has_zpos = false;
|
bool has_type = false, has_zpos = false;
|
||||||
|
|
||||||
|
liftoff_log(LIFTOFF_DEBUG, "Plane %"PRIu32, id);
|
||||||
|
|
||||||
plane = calloc(1, sizeof(*plane));
|
plane = calloc(1, sizeof(*plane));
|
||||||
if (plane == NULL) {
|
if (plane == NULL) {
|
||||||
liftoff_log_errno(LIFTOFF_ERROR, "calloc");
|
liftoff_log_errno(LIFTOFF_ERROR, "calloc");
|
||||||
|
@ -96,8 +129,8 @@ struct liftoff_plane *plane_create(struct liftoff_device *device, uint32_t id)
|
||||||
|
|
||||||
if (!has_type) {
|
if (!has_type) {
|
||||||
liftoff_log(LIFTOFF_ERROR,
|
liftoff_log(LIFTOFF_ERROR,
|
||||||
"plane %"PRIu32" is missing the 'type' property",
|
"plane %"PRIu32" is missing the 'type' property",
|
||||||
plane->id);
|
plane->id);
|
||||||
free(plane);
|
free(plane);
|
||||||
return NULL;
|
return NULL;
|
||||||
} else if (!has_zpos) {
|
} else if (!has_zpos) {
|
||||||
|
@ -125,6 +158,8 @@ struct liftoff_plane *plane_create(struct liftoff_device *device, uint32_t id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_plane(plane);
|
||||||
|
|
||||||
return plane;
|
return plane;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue