From afef092218cf90e7ab773c45b413cb55616f244e Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 26 Feb 2020 18:35:00 +0100 Subject: [PATCH] feat: log device creation For a new device log relevant data including all planes the output/CRTC supports. --- alloc.c | 2 +- device.c | 11 +++++++++++ plane.c | 39 +++++++++++++++++++++++++++++++++++++-- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/alloc.c b/alloc.c index 1eeff0d..1342422 100644 --- a/alloc.c +++ b/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 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) { if (plane->layer == NULL) { liftoff_log_cnt(LIFTOFF_DEBUG, " %"PRIu32, plane->id); diff --git a/device.c b/device.c index 78a629c..298a8d1 100644 --- a/device.c +++ b/device.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -12,6 +13,8 @@ struct liftoff_device *liftoff_device_create(int drm_fd) drmModePlaneRes *drm_plane_res; uint32_t i; + liftoff_log_cnt(LIFTOFF_DEBUG, "\nCreating device for fd %d. ", drm_fd); + device = calloc(1, sizeof(*device)); if (device == NULL) { liftoff_log_errno(LIFTOFF_ERROR, "calloc"); @@ -56,7 +59,13 @@ struct liftoff_device *liftoff_device_create(int drm_fd) 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++) { + 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) { liftoff_device_destroy(device); return NULL; @@ -64,6 +73,8 @@ struct liftoff_device *liftoff_device_create(int drm_fd) } drmModeFreePlaneResources(drm_plane_res); + liftoff_log_cnt(LIFTOFF_DEBUG, "\n"); + return device; } diff --git a/plane.c b/plane.c index b577fcf..1b76069 100644 --- a/plane.c +++ b/plane.c @@ -30,6 +30,37 @@ static int guess_plane_zpos_from_type(struct liftoff_device *device, 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, *cur; @@ -41,6 +72,8 @@ struct liftoff_plane *plane_create(struct liftoff_device *device, uint32_t id) uint64_t value; bool has_type = false, has_zpos = false; + liftoff_log(LIFTOFF_DEBUG, "Plane %"PRIu32, id); + plane = calloc(1, sizeof(*plane)); if (plane == NULL) { 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) { liftoff_log(LIFTOFF_ERROR, - "plane %"PRIu32" is missing the 'type' property", - plane->id); + "plane %"PRIu32" is missing the 'type' property", + plane->id); free(plane); return NULL; } 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; }