From 32683879e7011b2bbf17dd9898f072930c6e857a Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 13 Aug 2021 22:02:33 +0200 Subject: [PATCH] Add newline after function return type Aligns our style with Linux' and Weston's. --- alloc.c | 76 ++++++++++++++++------------ device.c | 14 +++-- example/common.c | 21 +++++--- example/common.h | 25 ++++++--- example/compositor.c | 15 +++--- example/dynamic.c | 21 +++++--- example/multi-output.c | 9 ++-- example/simple.c | 9 ++-- include/libliftoff.h | 77 +++++++++++++++++++--------- include/list.h | 19 +++++-- include/log.h | 12 +++-- include/private.h | 46 +++++++++++------ layer.c | 47 +++++++++++------ list.c | 15 ++++-- log.c | 19 ++++--- output.c | 23 ++++++--- plane.c | 35 +++++++------ test/bench.c | 7 +-- test/check_ndebug.c | 3 +- test/include/libdrm_mock.h | 30 +++++++---- test/libdrm_mock.c | 101 ++++++++++++++++++++++++------------- test/test_alloc.c | 23 ++++++--- test/test_dynamic.c | 76 ++++++++++++++++++++-------- test/test_priority.c | 8 +-- test/test_prop.c | 18 ++++--- 25 files changed, 487 insertions(+), 262 deletions(-) diff --git a/alloc.c b/alloc.c index d45be35..353b5ea 100644 --- a/alloc.c +++ b/alloc.c @@ -95,9 +95,9 @@ struct alloc_step { char log_prefix[64]; }; -static void plane_step_init_next(struct alloc_step *step, - struct alloc_step *prev, - struct liftoff_layer *layer) +static void +plane_step_init_next(struct alloc_step *step, struct alloc_step *prev, + struct liftoff_layer *layer) { struct liftoff_plane *plane; struct liftoff_layer_property *zpos_prop; @@ -146,8 +146,8 @@ static void plane_step_init_next(struct alloc_step *step, } } -static bool is_layer_allocated(struct alloc_step *step, - struct liftoff_layer *layer) +static bool +is_layer_allocated(struct alloc_step *step, struct liftoff_layer *layer) { size_t i; @@ -161,9 +161,9 @@ static bool is_layer_allocated(struct alloc_step *step, return false; } -static bool has_composited_layer_over(struct liftoff_output *output, - struct alloc_step *step, - struct liftoff_layer *layer) +static bool +has_composited_layer_over(struct liftoff_output *output, + struct alloc_step *step, struct liftoff_layer *layer) { struct liftoff_layer *other_layer; struct liftoff_layer_property *zpos_prop, *other_zpos_prop; @@ -192,9 +192,9 @@ static bool has_composited_layer_over(struct liftoff_output *output, return false; } -static bool has_allocated_layer_over(struct liftoff_output *output, - struct alloc_step *step, - struct liftoff_layer *layer) +static bool +has_allocated_layer_over(struct liftoff_output *output, struct alloc_step *step, + struct liftoff_layer *layer) { ssize_t i; struct liftoff_plane *other_plane; @@ -238,9 +238,9 @@ static bool has_allocated_layer_over(struct liftoff_output *output, return false; } -static bool has_allocated_plane_under(struct liftoff_output *output, - struct alloc_step *step, - struct liftoff_layer *layer) +static bool +has_allocated_plane_under(struct liftoff_output *output, + struct alloc_step *step, struct liftoff_layer *layer) { struct liftoff_plane *plane, *other_plane; ssize_t i; @@ -269,9 +269,10 @@ static bool has_allocated_plane_under(struct liftoff_output *output, return false; } -static bool check_layer_plane_compatible(struct alloc_step *step, - struct liftoff_layer *layer, - struct liftoff_plane *plane) +static bool +check_layer_plane_compatible(struct alloc_step *step, + struct liftoff_layer *layer, + struct liftoff_plane *plane) { struct liftoff_output *output; struct liftoff_layer_property *zpos_prop; @@ -332,8 +333,8 @@ static bool check_layer_plane_compatible(struct alloc_step *step, return true; } -static bool check_alloc_valid(struct alloc_result *result, - struct alloc_step *step) +static bool +check_alloc_valid(struct alloc_result *result, struct alloc_step *step) { /* If composition isn't used, we need to have allocated all * layers. */ @@ -362,9 +363,9 @@ static bool check_alloc_valid(struct alloc_result *result, return true; } -static int output_choose_layers(struct liftoff_output *output, - struct alloc_result *result, - struct alloc_step *step) +static int +output_choose_layers(struct liftoff_output *output, struct alloc_result *result, + struct alloc_step *step) { struct liftoff_device *device; struct liftoff_plane *plane; @@ -471,7 +472,8 @@ skip: return 0; } -static int apply_current(struct liftoff_device *device, drmModeAtomicReq *req) +static int +apply_current(struct liftoff_device *device, drmModeAtomicReq *req) { struct liftoff_plane *plane; int cursor, ret; @@ -490,7 +492,8 @@ static int apply_current(struct liftoff_device *device, drmModeAtomicReq *req) return 0; } -static bool layer_needs_realloc(struct liftoff_layer *layer) +static bool +layer_needs_realloc(struct liftoff_layer *layer) { size_t i; struct liftoff_layer_property *prop; @@ -545,8 +548,9 @@ static bool layer_needs_realloc(struct liftoff_layer *layer) return false; } -static int reuse_previous_alloc(struct liftoff_output *output, - drmModeAtomicReq *req, uint32_t flags) +static int +reuse_previous_alloc(struct liftoff_output *output, drmModeAtomicReq *req, + uint32_t flags) { struct liftoff_device *device; struct liftoff_layer *layer; @@ -578,7 +582,8 @@ static int reuse_previous_alloc(struct liftoff_output *output, return ret; } -static void mark_layers_clean(struct liftoff_output *output) +static void +mark_layers_clean(struct liftoff_output *output) { struct liftoff_layer *layer; @@ -589,7 +594,8 @@ static void mark_layers_clean(struct liftoff_output *output) } } -static void update_layers_priority(struct liftoff_device *device) +static void +update_layers_priority(struct liftoff_device *device) { struct liftoff_output *output; struct liftoff_layer *layer; @@ -608,7 +614,8 @@ static void update_layers_priority(struct liftoff_device *device) } } -static void log_reuse(struct liftoff_output *output) +static void +log_reuse(struct liftoff_output *output) { if (output->alloc_reused_counter == 0) { liftoff_log(LIFTOFF_DEBUG, @@ -618,7 +625,8 @@ static void log_reuse(struct liftoff_output *output) output->alloc_reused_counter++; } -static void log_no_reuse(struct liftoff_output *output) +static void +log_no_reuse(struct liftoff_output *output) { liftoff_log(LIFTOFF_DEBUG, "Computing plane allocation on output %p", (void *)output); @@ -632,7 +640,8 @@ static void log_no_reuse(struct liftoff_output *output) } } -static size_t non_composition_layers_length(struct liftoff_output *output) +static size_t +non_composition_layers_length(struct liftoff_output *output) { struct liftoff_layer *layer; size_t n; @@ -648,8 +657,9 @@ static size_t non_composition_layers_length(struct liftoff_output *output) return n; } -int liftoff_output_apply(struct liftoff_output *output, drmModeAtomicReq *req, - uint32_t flags) +int +liftoff_output_apply(struct liftoff_output *output, drmModeAtomicReq *req, + uint32_t flags) { struct liftoff_device *device; struct liftoff_plane *plane; diff --git a/device.c b/device.c index c42f18f..2a2a5d4 100644 --- a/device.c +++ b/device.c @@ -5,7 +5,8 @@ #include "log.h" #include "private.h" -struct liftoff_device *liftoff_device_create(int drm_fd) +struct liftoff_device * +liftoff_device_create(int drm_fd) { struct liftoff_device *device; drmModeRes *drm_res; @@ -49,7 +50,8 @@ struct liftoff_device *liftoff_device_create(int drm_fd) return device; } -void liftoff_device_destroy(struct liftoff_device *device) +void +liftoff_device_destroy(struct liftoff_device *device) { struct liftoff_plane *plane, *tmp; @@ -65,7 +67,8 @@ void liftoff_device_destroy(struct liftoff_device *device) free(device); } -int liftoff_device_register_all_planes(struct liftoff_device *device) +int +liftoff_device_register_all_planes(struct liftoff_device *device) { drmModePlaneRes *drm_plane_res; uint32_t i; @@ -86,8 +89,9 @@ int liftoff_device_register_all_planes(struct liftoff_device *device) return 0; } -int device_test_commit(struct liftoff_device *device, - drmModeAtomicReq *req, uint32_t flags) +int +device_test_commit(struct liftoff_device *device, drmModeAtomicReq *req, + uint32_t flags) { int ret; diff --git a/example/common.c b/example/common.c index 69b206c..79befa5 100644 --- a/example/common.c +++ b/example/common.c @@ -6,7 +6,8 @@ #include #include "common.h" -drmModeConnector *pick_connector(int drm_fd, drmModeRes *drm_res) +drmModeConnector * +pick_connector(int drm_fd, drmModeRes *drm_res) { int i; drmModeConnector *connector; @@ -22,8 +23,8 @@ drmModeConnector *pick_connector(int drm_fd, drmModeRes *drm_res) return NULL; } -drmModeCrtc *pick_crtc(int drm_fd, drmModeRes *drm_res, - drmModeConnector *connector) +drmModeCrtc * +pick_crtc(int drm_fd, drmModeRes *drm_res, drmModeConnector *connector) { drmModeEncoder *enc; uint32_t crtc_id; @@ -66,7 +67,8 @@ drmModeCrtc *pick_crtc(int drm_fd, drmModeRes *drm_res, } } -void disable_all_crtcs_except(int drm_fd, drmModeRes *drm_res, uint32_t crtc_id) +void +disable_all_crtcs_except(int drm_fd, drmModeRes *drm_res, uint32_t crtc_id) { int i; @@ -79,8 +81,9 @@ void disable_all_crtcs_except(int drm_fd, drmModeRes *drm_res, uint32_t crtc_id) } } -bool dumb_fb_init(struct dumb_fb *fb, int drm_fd, uint32_t format, - uint32_t width, uint32_t height) +bool +dumb_fb_init(struct dumb_fb *fb, int drm_fd, uint32_t format, uint32_t width, + uint32_t height) { int ret; uint32_t fb_id; @@ -116,7 +119,8 @@ bool dumb_fb_init(struct dumb_fb *fb, int drm_fd, uint32_t format, return true; } -void *dumb_fb_map(struct dumb_fb *fb, int drm_fd) +void * +dumb_fb_map(struct dumb_fb *fb, int drm_fd) { int ret; @@ -130,7 +134,8 @@ void *dumb_fb_map(struct dumb_fb *fb, int drm_fd) map.offset); } -void dumb_fb_fill(struct dumb_fb *fb, int drm_fd, uint32_t color) +void +dumb_fb_fill(struct dumb_fb *fb, int drm_fd, uint32_t color) { uint32_t *data; size_t i; diff --git a/example/common.h b/example/common.h index 8d4249b..c0ebb31 100644 --- a/example/common.h +++ b/example/common.h @@ -12,14 +12,23 @@ struct dumb_fb { uint32_t id; }; -drmModeConnector *pick_connector(int drm_fd, drmModeRes *drm_res); -drmModeCrtc *pick_crtc(int drm_fd, drmModeRes *drm_res, - drmModeConnector *connector); -void disable_all_crtcs_except(int drm_fd, drmModeRes *drm_res, uint32_t crtc_id); +drmModeConnector * +pick_connector(int drm_fd, drmModeRes *drm_res); -bool dumb_fb_init(struct dumb_fb *fb, int drm_fd, uint32_t format, - uint32_t width, uint32_t height); -void *dumb_fb_map(struct dumb_fb *fb, int drm_fd); -void dumb_fb_fill(struct dumb_fb *fb, int drm_fd, uint32_t color); +drmModeCrtc * +pick_crtc(int drm_fd, drmModeRes *drm_res, drmModeConnector *connector); + +void +disable_all_crtcs_except(int drm_fd, drmModeRes *drm_res, uint32_t crtc_id); + +bool +dumb_fb_init(struct dumb_fb *fb, int drm_fd, uint32_t format, + uint32_t width, uint32_t height); + +void * +dumb_fb_map(struct dumb_fb *fb, int drm_fd); + +void +dumb_fb_fill(struct dumb_fb *fb, int drm_fd, uint32_t color); #endif diff --git a/example/compositor.c b/example/compositor.c index 97d34e6..e04c969 100644 --- a/example/compositor.c +++ b/example/compositor.c @@ -25,10 +25,9 @@ static const uint32_t colors[] = { 0xFFFFFF00, /* yellow */ }; -static struct liftoff_layer *add_layer(int drm_fd, struct liftoff_output *output, - int x, int y, int width, int height, - bool with_alpha, bool white, - struct dumb_fb *fb) +static struct liftoff_layer * +add_layer(int drm_fd, struct liftoff_output *output, int x, int y, int width, + int height, bool with_alpha, bool white, struct dumb_fb *fb) { static size_t color_idx = 0; uint32_t color; @@ -65,8 +64,9 @@ static struct liftoff_layer *add_layer(int drm_fd, struct liftoff_output *output } /* Naive compositor for opaque buffers */ -static void composite(int drm_fd, struct dumb_fb *dst_fb, struct dumb_fb *src_fb, - int dst_x, int dst_y) +static void +composite(int drm_fd, struct dumb_fb *dst_fb, struct dumb_fb *src_fb, int dst_x, + int dst_y) { uint8_t *dst, *src; int i, y, src_width; @@ -97,7 +97,8 @@ static void composite(int drm_fd, struct dumb_fb *dst_fb, struct dumb_fb *src_fb munmap(src, src_fb->size); } -int main(int argc, char *argv[]) +int +main(int argc, char *argv[]) { int opt; size_t layers_len; diff --git a/example/dynamic.c b/example/dynamic.c index 6f3311a..0ff0388 100644 --- a/example/dynamic.c +++ b/example/dynamic.c @@ -33,9 +33,10 @@ static struct liftoff_output *output = NULL; static struct example_layer layers[LAYERS_LEN] = {0}; static size_t active_layer_idx = 2; -static bool init_layer(int drm_fd, struct example_layer *layer, - struct liftoff_output *output, int width, int height, - bool with_alpha) +static bool +init_layer(int drm_fd, struct example_layer *layer, + struct liftoff_output *output, int width, int height, + bool with_alpha) { static size_t color_idx = 0; static float color_value = 1.0; @@ -65,7 +66,8 @@ static bool init_layer(int drm_fd, struct example_layer *layer, return true; } -static void draw_layer(int drm_fd, struct example_layer *layer) +static void +draw_layer(int drm_fd, struct example_layer *layer) { uint32_t color; struct dumb_fb *fb; @@ -85,7 +87,8 @@ static void draw_layer(int drm_fd, struct example_layer *layer) liftoff_layer_set_property(layer->layer, "CRTC_Y", layer->y); } -static bool draw(void) +static bool +draw(void) { struct example_layer *active_layer; drmModeAtomicReq *req; @@ -138,13 +141,15 @@ static bool draw(void) return true; } -static void page_flip_handler(int fd, unsigned seq, unsigned tv_sec, - unsigned tv_usec, unsigned crtc_id, void *data) +static void +page_flip_handler(int fd, unsigned seq, unsigned tv_sec, unsigned tv_usec, + unsigned crtc_id, void *data) { draw(); } -int main(int argc, char *argv[]) +int +main(int argc, char *argv[]) { drmModeRes *drm_res; drmModeCrtc *crtc; diff --git a/example/multi-output.c b/example/multi-output.c index 183c17d..cf86479 100644 --- a/example/multi-output.c +++ b/example/multi-output.c @@ -24,9 +24,9 @@ static const uint32_t colors[] = { 0xFFFFFF00, /* yellow */ }; -static struct liftoff_layer *add_layer(int drm_fd, struct liftoff_output *output, - int x, int y, int width, int height, - bool with_alpha) +static struct liftoff_layer * +add_layer(int drm_fd, struct liftoff_output *output, int x, int y, int width, + int height, bool with_alpha) { static bool first = true; static size_t color_idx = 0; @@ -65,7 +65,8 @@ static struct liftoff_layer *add_layer(int drm_fd, struct liftoff_output *output return layer; } -int main(int argc, char *argv[]) +int +main(int argc, char *argv[]) { int drm_fd; struct liftoff_device *device; diff --git a/example/simple.c b/example/simple.c index 6f9c490..54adf68 100644 --- a/example/simple.c +++ b/example/simple.c @@ -22,9 +22,9 @@ static const uint32_t colors[] = { 0xFFFFFF00, /* yellow */ }; -static struct liftoff_layer *add_layer(int drm_fd, struct liftoff_output *output, - int x, int y, int width, int height, - bool with_alpha) +static struct liftoff_layer * +add_layer(int drm_fd, struct liftoff_output *output, int x, int y, int width, + int height, bool with_alpha) { static bool first = true; static size_t color_idx = 0; @@ -63,7 +63,8 @@ static struct liftoff_layer *add_layer(int drm_fd, struct liftoff_output *output return layer; } -int main(int argc, char *argv[]) +int +main(int argc, char *argv[]) { int drm_fd; struct liftoff_device *device; diff --git a/include/libliftoff.h b/include/libliftoff.h index 15e745e..ce3b406 100644 --- a/include/libliftoff.h +++ b/include/libliftoff.h @@ -18,13 +18,17 @@ struct liftoff_plane; * The node is expected to have DRM_CLIENT_CAP_ATOMIC enabled. libliftoff takes * ownership of the file descriptor. */ -struct liftoff_device *liftoff_device_create(int drm_fd); +struct liftoff_device * +liftoff_device_create(int drm_fd); + /** * Destroy a libliftoff device. * * The caller is expected to destroy the outputs and layers explicitly. */ -void liftoff_device_destroy(struct liftoff_device *device); +void +liftoff_device_destroy(struct liftoff_device *device); + /** * Register all available hardware planes to be managed by the libliftoff * device. @@ -34,7 +38,8 @@ void liftoff_device_destroy(struct liftoff_device *device); * * Zero is returned on success, negative errno on error. */ -int liftoff_device_register_all_planes(struct liftoff_device *device); +int +liftoff_device_register_all_planes(struct liftoff_device *device); /** * Register a hardware plane to be managed by the libliftoff device. @@ -42,17 +47,20 @@ int liftoff_device_register_all_planes(struct liftoff_device *device); * Users should call this function for each plane they don't want to manually * manage. Registering the same plane twice is an error. */ -struct liftoff_plane *liftoff_plane_create(struct liftoff_device *device, - uint32_t plane_id); +struct liftoff_plane * +liftoff_plane_create(struct liftoff_device *device, uint32_t plane_id); + /** * Unregister a hardware plane. */ -void liftoff_plane_destroy(struct liftoff_plane *plane); +void +liftoff_plane_destroy(struct liftoff_plane *plane); /** * Obtain the object ID of the plane. */ -uint32_t liftoff_plane_get_id(struct liftoff_plane *plane); +uint32_t +liftoff_plane_get_id(struct liftoff_plane *plane); /** * Build a layer to plane mapping and append the plane configuration to `req`. @@ -64,22 +72,26 @@ uint32_t liftoff_plane_get_id(struct liftoff_plane *plane); * * Zero is returned on success, negative errno on error. */ -int liftoff_output_apply(struct liftoff_output *output, drmModeAtomicReq *req, - uint32_t flags); +int +liftoff_output_apply(struct liftoff_output *output, drmModeAtomicReq *req, + uint32_t flags); /** * Make the device manage a CRTC's planes. * * The returned output allows callers to attach layers. */ -struct liftoff_output *liftoff_output_create(struct liftoff_device *device, - uint32_t crtc_id); +struct liftoff_output * +liftoff_output_create(struct liftoff_device *device, uint32_t crtc_id); + /** * Destroy a libliftoff output. * * The caller is expected to destroy the output's layers explicitly. */ -void liftoff_output_destroy(struct liftoff_output *output); +void +liftoff_output_destroy(struct liftoff_output *output); + /** * Indicate on which layer composition can take place. * @@ -87,8 +99,10 @@ void liftoff_output_destroy(struct liftoff_output *output); * this layer. The composition layer won't be used if all other layers have been * mapped to a plane. There is at most one composition layer per output. */ -void liftoff_output_set_composition_layer(struct liftoff_output *output, - struct liftoff_layer *layer); +void +liftoff_output_set_composition_layer(struct liftoff_output *output, + struct liftoff_layer *layer); + /** * Check whether this output needs composition. * @@ -96,7 +110,8 @@ void liftoff_output_set_composition_layer(struct liftoff_output *output, * plane. In other words, if an output needs composition, at least one layer * will return true when `liftoff_layer_needs_composition` is called. */ -bool liftoff_output_needs_composition(struct liftoff_output *output); +bool +liftoff_output_needs_composition(struct liftoff_output *output); /** * Create a new layer on an output. @@ -106,11 +121,15 @@ bool liftoff_output_needs_composition(struct liftoff_output *output); * to map layers to hardware planes on a best-effort basis. The user will need * to manually handle layers that couldn't be mapped to a plane. */ -struct liftoff_layer *liftoff_layer_create(struct liftoff_output *output); +struct liftoff_layer * +liftoff_layer_create(struct liftoff_output *output); + /** * Destroy a layer. */ -void liftoff_layer_destroy(struct liftoff_layer *layer); +void +liftoff_layer_destroy(struct liftoff_layer *layer); + /** * Set a property on the layer. * @@ -121,8 +140,10 @@ void liftoff_layer_destroy(struct liftoff_layer *layer); * * Zero is returned on success, negative errno on error. */ -int liftoff_layer_set_property(struct liftoff_layer *layer, const char *name, - uint64_t value); +int +liftoff_layer_set_property(struct liftoff_layer *layer, const char *name, + uint64_t value); + /** * Force composition on this layer. * @@ -132,20 +153,25 @@ int liftoff_layer_set_property(struct liftoff_layer *layer, const char *name, * This can be used when no KMS FB ID is available for this layer but it still * needs to be displayed (e.g. the buffer cannot be imported in KMS). */ -void liftoff_layer_set_fb_composited(struct liftoff_layer *layer); +void +liftoff_layer_set_fb_composited(struct liftoff_layer *layer); + /** * Check whether this layer needs composition. * * A layer needs composition if it's visible and if it couldn't be mapped to a * plane. */ -bool liftoff_layer_needs_composition(struct liftoff_layer *layer); +bool +liftoff_layer_needs_composition(struct liftoff_layer *layer); + /** * Retrieve the plane mapped to this layer. * * NULL is returned if no plane is mapped. */ -struct liftoff_plane *liftoff_layer_get_plane(struct liftoff_layer *layer); +struct liftoff_plane * +liftoff_layer_get_plane(struct liftoff_layer *layer); enum liftoff_log_priority { LIFTOFF_SILENT, @@ -162,13 +188,16 @@ typedef void (*liftoff_log_handler)(enum liftoff_log_priority priority, * Only messages with a priority higher than the provided priority will be * logged. The default priority is LIFTOFF_ERROR. */ -void liftoff_log_set_priority(enum liftoff_log_priority priority); +void +liftoff_log_set_priority(enum liftoff_log_priority priority); + /** * Set libliftoff's log handler. * * The default handler prints messages to stderr. NULL restores the default * handler. */ -void liftoff_log_set_handler(liftoff_log_handler handler); +void +liftoff_log_set_handler(liftoff_log_handler handler); #endif diff --git a/include/list.h b/include/list.h index 4cb9491..527cf85 100644 --- a/include/list.h +++ b/include/list.h @@ -9,11 +9,20 @@ struct liftoff_list { struct liftoff_list *next; }; -void liftoff_list_init(struct liftoff_list *list); -void liftoff_list_insert(struct liftoff_list *list, struct liftoff_list *elm); -void liftoff_list_remove(struct liftoff_list *elm); -size_t liftoff_list_length(const struct liftoff_list *list); -bool liftoff_list_empty(const struct liftoff_list *list); +void +liftoff_list_init(struct liftoff_list *list); + +void +liftoff_list_insert(struct liftoff_list *list, struct liftoff_list *elm); + +void +liftoff_list_remove(struct liftoff_list *elm); + +size_t +liftoff_list_length(const struct liftoff_list *list); + +bool +liftoff_list_empty(const struct liftoff_list *list); #define liftoff_container_of(ptr, sample, member) \ (__typeof__(sample))((char *)(ptr) - \ diff --git a/include/log.h b/include/log.h index f4dd5fc..36525d4 100644 --- a/include/log.h +++ b/include/log.h @@ -11,10 +11,14 @@ #define _LIFTOFF_ATTRIB_PRINTF(start, end) #endif -bool log_has(enum liftoff_log_priority priority); +bool +log_has(enum liftoff_log_priority priority); -void liftoff_log(enum liftoff_log_priority priority, - const char *format, ...) _LIFTOFF_ATTRIB_PRINTF(2, 3); -void liftoff_log_errno(enum liftoff_log_priority priority, const char *msg); +void +liftoff_log(enum liftoff_log_priority priority, const char *format, ...) +_LIFTOFF_ATTRIB_PRINTF(2, 3); + +void +liftoff_log_errno(enum liftoff_log_priority priority, const char *msg); #endif diff --git a/include/private.h b/include/private.h index 636a463..d8d9e6c 100644 --- a/include/private.h +++ b/include/private.h @@ -81,23 +81,39 @@ struct liftoff_rect { int width, height; }; -int device_test_commit(struct liftoff_device *device, - drmModeAtomicReq *req, uint32_t flags); +int +device_test_commit(struct liftoff_device *device, drmModeAtomicReq *req, + uint32_t flags); -struct liftoff_layer_property *layer_get_property(struct liftoff_layer *layer, - const char *name); -void layer_get_rect(struct liftoff_layer *layer, struct liftoff_rect *rect); -bool layer_intersects(struct liftoff_layer *a, struct liftoff_layer *b); -void layer_mark_clean(struct liftoff_layer *layer); -void layer_update_priority(struct liftoff_layer *layer, bool make_current); -bool layer_has_fb(struct liftoff_layer *layer); -bool layer_is_visible(struct liftoff_layer *layer); +struct liftoff_layer_property * +layer_get_property(struct liftoff_layer *layer, const char *name); -struct liftoff_plane_property *plane_get_property(struct liftoff_plane *plane, - const char *name); -int plane_apply(struct liftoff_plane *plane, struct liftoff_layer *layer, - drmModeAtomicReq *req); +void +layer_get_rect(struct liftoff_layer *layer, struct liftoff_rect *rect); -void output_log_layers(struct liftoff_output *output); +bool +layer_intersects(struct liftoff_layer *a, struct liftoff_layer *b); + +void +layer_mark_clean(struct liftoff_layer *layer); + +void +layer_update_priority(struct liftoff_layer *layer, bool make_current); + +bool +layer_has_fb(struct liftoff_layer *layer); + +bool +layer_is_visible(struct liftoff_layer *layer); + +struct liftoff_plane_property * +plane_get_property(struct liftoff_plane *plane, const char *name); + +int +plane_apply(struct liftoff_plane *plane, struct liftoff_layer *layer, + drmModeAtomicReq *req); + +void +output_log_layers(struct liftoff_output *output); #endif diff --git a/layer.c b/layer.c index c3ef0cf..3825780 100644 --- a/layer.c +++ b/layer.c @@ -3,7 +3,8 @@ #include #include "private.h" -struct liftoff_layer *liftoff_layer_create(struct liftoff_output *output) +struct liftoff_layer * +liftoff_layer_create(struct liftoff_output *output) { struct liftoff_layer *layer; @@ -18,7 +19,8 @@ struct liftoff_layer *liftoff_layer_create(struct liftoff_output *output) return layer; } -void liftoff_layer_destroy(struct liftoff_layer *layer) +void +liftoff_layer_destroy(struct liftoff_layer *layer) { if (layer == NULL) { return; @@ -36,8 +38,8 @@ void liftoff_layer_destroy(struct liftoff_layer *layer) free(layer); } -struct liftoff_layer_property *layer_get_property(struct liftoff_layer *layer, - const char *name) +struct liftoff_layer_property * +layer_get_property(struct liftoff_layer *layer, const char *name) { size_t i; @@ -49,8 +51,9 @@ struct liftoff_layer_property *layer_get_property(struct liftoff_layer *layer, return NULL; } -int liftoff_layer_set_property(struct liftoff_layer *layer, const char *name, - uint64_t value) +int +liftoff_layer_set_property(struct liftoff_layer *layer, const char *name, + uint64_t value) { struct liftoff_layer_property *props; struct liftoff_layer_property *prop; @@ -89,7 +92,8 @@ int liftoff_layer_set_property(struct liftoff_layer *layer, const char *name, return 0; } -void liftoff_layer_set_fb_composited(struct liftoff_layer *layer) +void +liftoff_layer_set_fb_composited(struct liftoff_layer *layer) { if (layer->force_composition) { return; @@ -101,12 +105,14 @@ void liftoff_layer_set_fb_composited(struct liftoff_layer *layer) layer->changed = true; } -struct liftoff_plane *liftoff_layer_get_plane(struct liftoff_layer *layer) +struct liftoff_plane * +liftoff_layer_get_plane(struct liftoff_layer *layer) { return layer->plane; } -bool liftoff_layer_needs_composition(struct liftoff_layer *layer) +bool +liftoff_layer_needs_composition(struct liftoff_layer *layer) { if (!layer_is_visible(layer)) { return false; @@ -114,7 +120,8 @@ bool liftoff_layer_needs_composition(struct liftoff_layer *layer) return layer->plane == NULL; } -void layer_get_rect(struct liftoff_layer *layer, struct liftoff_rect *rect) +void +layer_get_rect(struct liftoff_layer *layer, struct liftoff_rect *rect) { struct liftoff_layer_property *x_prop, *y_prop, *w_prop, *h_prop; @@ -129,7 +136,8 @@ void layer_get_rect(struct liftoff_layer *layer, struct liftoff_rect *rect) rect->height = h_prop != NULL ? h_prop->value : 0; } -bool layer_intersects(struct liftoff_layer *a, struct liftoff_layer *b) +bool +layer_intersects(struct liftoff_layer *a, struct liftoff_layer *b) { struct liftoff_rect ra, rb; @@ -140,7 +148,8 @@ bool layer_intersects(struct liftoff_layer *a, struct liftoff_layer *b) ra.x + ra.width > rb.x && ra.y + ra.height > rb.y; } -void layer_mark_clean(struct liftoff_layer *layer) +void +layer_mark_clean(struct liftoff_layer *layer) { size_t i; @@ -151,7 +160,8 @@ void layer_mark_clean(struct liftoff_layer *layer) } } -static void log_priority(struct liftoff_layer *layer) +static void +log_priority(struct liftoff_layer *layer) { if (layer->current_priority == layer->pending_priority) { return; @@ -162,7 +172,9 @@ static void log_priority(struct liftoff_layer *layer) layer->pending_priority); } -void layer_update_priority(struct liftoff_layer *layer, bool make_current) { +void +layer_update_priority(struct liftoff_layer *layer, bool make_current) +{ struct liftoff_layer_property *prop; /* TODO: also bump priority when updating other properties */ @@ -178,14 +190,17 @@ void layer_update_priority(struct liftoff_layer *layer, bool make_current) { } } -bool layer_has_fb(struct liftoff_layer *layer) { +bool +layer_has_fb(struct liftoff_layer *layer) +{ struct liftoff_layer_property *fb_id_prop; fb_id_prop = layer_get_property(layer, "FB_ID"); return fb_id_prop != NULL && fb_id_prop->value != 0; } -bool layer_is_visible(struct liftoff_layer *layer) +bool +layer_is_visible(struct liftoff_layer *layer) { struct liftoff_layer_property *alpha_prop; diff --git a/list.c b/list.c index 7a8fca3..e8d37b0 100644 --- a/list.c +++ b/list.c @@ -1,12 +1,14 @@ #include "list.h" -void liftoff_list_init(struct liftoff_list *list) +void +liftoff_list_init(struct liftoff_list *list) { list->prev = list; list->next = list; } -void liftoff_list_insert(struct liftoff_list *list, struct liftoff_list *elm) +void +liftoff_list_insert(struct liftoff_list *list, struct liftoff_list *elm) { elm->prev = list; elm->next = list->next; @@ -14,7 +16,8 @@ void liftoff_list_insert(struct liftoff_list *list, struct liftoff_list *elm) elm->next->prev = elm; } -void liftoff_list_remove(struct liftoff_list *elm) +void +liftoff_list_remove(struct liftoff_list *elm) { elm->prev->next = elm->next; elm->next->prev = elm->prev; @@ -22,7 +25,8 @@ void liftoff_list_remove(struct liftoff_list *elm) elm->prev = NULL; } -size_t liftoff_list_length(const struct liftoff_list *list) +size_t +liftoff_list_length(const struct liftoff_list *list) { struct liftoff_list *e; size_t count; @@ -37,7 +41,8 @@ size_t liftoff_list_length(const struct liftoff_list *list) return count; } -bool liftoff_list_empty(const struct liftoff_list *list) +bool +liftoff_list_empty(const struct liftoff_list *list) { return list->next == list; } diff --git a/log.c b/log.c index 80bfd6c..1ac1176 100644 --- a/log.c +++ b/log.c @@ -5,8 +5,8 @@ static enum liftoff_log_priority log_priority = LIFTOFF_ERROR; -static void log_stderr(enum liftoff_log_priority priority, const char *fmt, - va_list args) +static void +log_stderr(enum liftoff_log_priority priority, const char *fmt, va_list args) { vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); @@ -14,12 +14,14 @@ static void log_stderr(enum liftoff_log_priority priority, const char *fmt, static liftoff_log_handler log_handler = log_stderr; -void liftoff_log_set_priority(enum liftoff_log_priority priority) +void +liftoff_log_set_priority(enum liftoff_log_priority priority) { log_priority = priority; } -void liftoff_log_set_handler(liftoff_log_handler handler) { +void +liftoff_log_set_handler(liftoff_log_handler handler) { if (handler) { log_handler = handler; } else { @@ -27,12 +29,14 @@ void liftoff_log_set_handler(liftoff_log_handler handler) { } } -bool log_has(enum liftoff_log_priority priority) +bool +log_has(enum liftoff_log_priority priority) { return priority <= log_priority; } -void liftoff_log(enum liftoff_log_priority priority, const char *fmt, ...) +void +liftoff_log(enum liftoff_log_priority priority, const char *fmt, ...) { if (!log_has(priority)) { return; @@ -44,7 +48,8 @@ void liftoff_log(enum liftoff_log_priority priority, const char *fmt, ...) va_end(args); } -void liftoff_log_errno(enum liftoff_log_priority priority, const char *msg) +void +liftoff_log_errno(enum liftoff_log_priority priority, const char *msg) { // Ensure errno is still set to its original value when we return int prev_errno = errno; diff --git a/output.c b/output.c index d34c832..32e6a1a 100644 --- a/output.c +++ b/output.c @@ -5,8 +5,8 @@ #include #include "private.h" -struct liftoff_output *liftoff_output_create(struct liftoff_device *device, - uint32_t crtc_id) +struct liftoff_output * +liftoff_output_create(struct liftoff_device *device, uint32_t crtc_id) { struct liftoff_output *output; ssize_t crtc_index; @@ -35,7 +35,8 @@ struct liftoff_output *liftoff_output_create(struct liftoff_device *device, return output; } -void liftoff_output_destroy(struct liftoff_output *output) +void +liftoff_output_destroy(struct liftoff_output *output) { if (output == NULL) { return; @@ -45,8 +46,9 @@ void liftoff_output_destroy(struct liftoff_output *output) free(output); } -void liftoff_output_set_composition_layer(struct liftoff_output *output, - struct liftoff_layer *layer) +void +liftoff_output_set_composition_layer(struct liftoff_output *output, + struct liftoff_layer *layer) { assert(layer->output == output); if (layer != output->composition_layer) { @@ -55,7 +57,8 @@ void liftoff_output_set_composition_layer(struct liftoff_output *output, output->composition_layer = layer; } -bool liftoff_output_needs_composition(struct liftoff_output *output) +bool +liftoff_output_needs_composition(struct liftoff_output *output) { struct liftoff_layer *layer; @@ -68,11 +71,15 @@ bool liftoff_output_needs_composition(struct liftoff_output *output) return false; } -static double fp16_to_double(uint64_t val) { +static double +fp16_to_double(uint64_t val) +{ return (double)(val >> 16) + (double)(val & 0xFFFF) / 0xFFFF; } -void output_log_layers(struct liftoff_output *output) { +void +output_log_layers(struct liftoff_output *output) +{ struct liftoff_layer *layer; size_t i; bool is_composition_layer; diff --git a/plane.c b/plane.c index 608bd26..1e1835a 100644 --- a/plane.c +++ b/plane.c @@ -4,8 +4,9 @@ #include #include "private.h" -static int guess_plane_zpos_from_type(struct liftoff_device *device, - uint32_t plane_id, uint32_t type) +static int +guess_plane_zpos_from_type(struct liftoff_device *device, uint32_t plane_id, + uint32_t type) { struct liftoff_plane *primary; @@ -31,8 +32,8 @@ static int guess_plane_zpos_from_type(struct liftoff_device *device, return 0; } -struct liftoff_plane *liftoff_plane_create(struct liftoff_device *device, - uint32_t id) +struct liftoff_plane * +liftoff_plane_create(struct liftoff_device *device, uint32_t id) { struct liftoff_plane *plane, *cur; drmModePlane *drm_plane; @@ -140,7 +141,8 @@ struct liftoff_plane *liftoff_plane_create(struct liftoff_device *device, return plane; } -void liftoff_plane_destroy(struct liftoff_plane *plane) +void +liftoff_plane_destroy(struct liftoff_plane *plane) { if (plane->layer != NULL) { plane->layer->plane = NULL; @@ -150,13 +152,14 @@ void liftoff_plane_destroy(struct liftoff_plane *plane) free(plane); } -uint32_t liftoff_plane_get_id(struct liftoff_plane *plane) +uint32_t +liftoff_plane_get_id(struct liftoff_plane *plane) { return plane->id; } -struct liftoff_plane_property *plane_get_property(struct liftoff_plane *plane, - const char *name) +struct liftoff_plane_property * +plane_get_property(struct liftoff_plane *plane, const char *name) { size_t i; @@ -168,8 +171,9 @@ struct liftoff_plane_property *plane_get_property(struct liftoff_plane *plane, return NULL; } -static int plane_set_prop(struct liftoff_plane *plane, drmModeAtomicReq *req, - struct liftoff_plane_property *prop, uint64_t value) +static int +plane_set_prop(struct liftoff_plane *plane, drmModeAtomicReq *req, + struct liftoff_plane_property *prop, uint64_t value) { int ret; @@ -183,9 +187,9 @@ static int plane_set_prop(struct liftoff_plane *plane, drmModeAtomicReq *req, return 0; } -static int set_plane_prop_str(struct liftoff_plane *plane, - drmModeAtomicReq *req, const char *name, - uint64_t value) +static int +set_plane_prop_str(struct liftoff_plane *plane, drmModeAtomicReq *req, + const char *name, uint64_t value) { struct liftoff_plane_property *prop; @@ -200,8 +204,9 @@ static int set_plane_prop_str(struct liftoff_plane *plane, return plane_set_prop(plane, req, prop, value); } -int plane_apply(struct liftoff_plane *plane, struct liftoff_layer *layer, - drmModeAtomicReq *req) +int +plane_apply(struct liftoff_plane *plane, struct liftoff_layer *layer, + drmModeAtomicReq *req) { int cursor, ret; size_t i; diff --git a/test/bench.c b/test/bench.c index 06b99c8..d744e51 100644 --- a/test/bench.c +++ b/test/bench.c @@ -11,8 +11,8 @@ #define MAX_PLANES 128 #define MAX_LAYERS 128 -static struct liftoff_layer *add_layer(struct liftoff_output *output, - int x, int y, int width, int height) +static struct liftoff_layer * +add_layer(struct liftoff_output *output, int x, int y, int width, int height) { uint32_t fb_id; struct liftoff_layer *layer; @@ -32,7 +32,8 @@ static struct liftoff_layer *add_layer(struct liftoff_output *output, return layer; } -int main(int argc, char *argv[]) +int +main(int argc, char *argv[]) { int opt; size_t planes_len, layers_len; diff --git a/test/check_ndebug.c b/test/check_ndebug.c index 7b3bf37..88cf172 100644 --- a/test/check_ndebug.c +++ b/test/check_ndebug.c @@ -1,6 +1,7 @@ #include -int main(int argc, char *argv[]) +int +main(int argc, char *argv[]) { #ifdef NDEBUG fprintf(stderr, "NDEBUG is defined, cannot run tests\n"); diff --git a/test/include/libdrm_mock.h b/test/include/libdrm_mock.h index 7f3b47c..bda493b 100644 --- a/test/include/libdrm_mock.h +++ b/test/include/libdrm_mock.h @@ -16,14 +16,26 @@ extern bool liftoff_mock_require_primary_plane; struct liftoff_layer; -int liftoff_mock_drm_open(void); -uint32_t liftoff_mock_drm_create_fb(struct liftoff_layer *layer); -struct liftoff_mock_plane *liftoff_mock_drm_create_plane(int type); -struct liftoff_mock_plane *liftoff_mock_drm_get_plane(uint32_t id); -void liftoff_mock_plane_add_compatible_layer(struct liftoff_mock_plane *plane, - struct liftoff_layer *layer); -struct liftoff_layer *liftoff_mock_plane_get_layer(struct liftoff_mock_plane *plane); -uint32_t liftoff_mock_plane_add_property(struct liftoff_mock_plane *plane, - const drmModePropertyRes *prop); +int +liftoff_mock_drm_open(void); + +uint32_t +liftoff_mock_drm_create_fb(struct liftoff_layer *layer); + +struct liftoff_mock_plane * +liftoff_mock_drm_create_plane(int type); + +struct liftoff_mock_plane * +liftoff_mock_drm_get_plane(uint32_t id); + +void +liftoff_mock_plane_add_compatible_layer(struct liftoff_mock_plane *plane, + struct liftoff_layer *layer); +struct liftoff_layer * +liftoff_mock_plane_get_layer(struct liftoff_mock_plane *plane); + +uint32_t +liftoff_mock_plane_add_property(struct liftoff_mock_plane *plane, + const drmModePropertyRes *prop); #endif diff --git a/test/libdrm_mock.c b/test/libdrm_mock.c index 34254d2..a7b2587 100644 --- a/test/libdrm_mock.c +++ b/test/libdrm_mock.c @@ -66,7 +66,8 @@ static drmModePropertyRes plane_props[MAX_PLANE_PROPS] = {0}; static size_t plane_props_len = 0; -static void assert_drm_fd(int fd) +static void +assert_drm_fd(int fd) { int ret; struct stat stat_got, stat_want; @@ -80,7 +81,8 @@ static void assert_drm_fd(int fd) stat_got.st_ino == stat_want.st_ino); } -static uint32_t register_prop(const drmModePropertyRes *prop) +static uint32_t +register_prop(const drmModePropertyRes *prop) { drmModePropertyRes *dst; @@ -93,7 +95,8 @@ static uint32_t register_prop(const drmModePropertyRes *prop) return dst->prop_id; } -static void init_basic_props(void) +static void +init_basic_props(void) { size_t i; @@ -108,7 +111,8 @@ static void init_basic_props(void) } } -int liftoff_mock_drm_open(void) +int +liftoff_mock_drm_open(void) { int ret; @@ -121,7 +125,8 @@ int liftoff_mock_drm_open(void) return mock_pipe[0]; } -struct liftoff_mock_plane *liftoff_mock_drm_create_plane(int type) +struct liftoff_mock_plane * +liftoff_mock_drm_create_plane(int type) { struct liftoff_mock_plane *plane; size_t i; @@ -147,7 +152,8 @@ struct liftoff_mock_plane *liftoff_mock_drm_create_plane(int type) return plane; } -struct liftoff_mock_plane *liftoff_mock_drm_get_plane(uint32_t id) +struct liftoff_mock_plane * +liftoff_mock_drm_get_plane(uint32_t id) { struct liftoff_mock_plane *plane; @@ -162,8 +168,9 @@ struct liftoff_mock_plane *liftoff_mock_drm_get_plane(uint32_t id) abort(); // unreachable } -void liftoff_mock_plane_add_compatible_layer(struct liftoff_mock_plane *plane, - struct liftoff_layer *layer) +void +liftoff_mock_plane_add_compatible_layer(struct liftoff_mock_plane *plane, + struct liftoff_layer *layer) { size_t i; @@ -177,7 +184,8 @@ void liftoff_mock_plane_add_compatible_layer(struct liftoff_mock_plane *plane, abort(); // unreachable } -uint32_t liftoff_mock_drm_create_fb(struct liftoff_layer *layer) +uint32_t +liftoff_mock_drm_create_fb(struct liftoff_layer *layer) { size_t i; @@ -191,8 +199,9 @@ uint32_t liftoff_mock_drm_create_fb(struct liftoff_layer *layer) return 0xFB000000 + i; } -static bool mock_atomic_req_get_property(drmModeAtomicReq *req, uint32_t obj_id, - enum plane_prop prop, uint64_t *value) +static bool +mock_atomic_req_get_property(drmModeAtomicReq *req, uint32_t obj_id, + enum plane_prop prop, uint64_t *value) { ssize_t i; uint32_t prop_id; @@ -209,7 +218,8 @@ static bool mock_atomic_req_get_property(drmModeAtomicReq *req, uint32_t obj_id, return false; } -static struct liftoff_layer *mock_fb_get_layer(uint32_t fb_id) +static struct liftoff_layer * +mock_fb_get_layer(uint32_t fb_id) { size_t i; @@ -225,12 +235,14 @@ static struct liftoff_layer *mock_fb_get_layer(uint32_t fb_id) return mock_fbs[i]; } -struct liftoff_layer *liftoff_mock_plane_get_layer(struct liftoff_mock_plane *plane) +struct liftoff_layer * +liftoff_mock_plane_get_layer(struct liftoff_mock_plane *plane) { return mock_fb_get_layer(plane->prop_values[PLANE_FB_ID]); } -static size_t get_prop_index(uint32_t id) +static size_t +get_prop_index(uint32_t id) { size_t i; @@ -242,8 +254,9 @@ static size_t get_prop_index(uint32_t id) return i; } -uint32_t liftoff_mock_plane_add_property(struct liftoff_mock_plane *plane, - const drmModePropertyRes *prop) +uint32_t +liftoff_mock_plane_add_property(struct liftoff_mock_plane *plane, + const drmModePropertyRes *prop) { uint32_t prop_id; @@ -255,7 +268,8 @@ uint32_t liftoff_mock_plane_add_property(struct liftoff_mock_plane *plane, return prop_id; } -static void apply_atomic_req(drmModeAtomicReq *req) +static void +apply_atomic_req(drmModeAtomicReq *req) { int i; size_t prop_index; @@ -273,8 +287,9 @@ static void apply_atomic_req(drmModeAtomicReq *req) } } -int drmModeAtomicCommit(int fd, drmModeAtomicReq *req, uint32_t flags, - void *user_data) +int +drmModeAtomicCommit(int fd, drmModeAtomicReq *req, uint32_t flags, + void *user_data) { size_t i, j; struct liftoff_mock_plane *plane; @@ -362,7 +377,8 @@ int drmModeAtomicCommit(int fd, drmModeAtomicReq *req, uint32_t flags, return 0; } -drmModeRes *drmModeGetResources(int fd) +drmModeRes * +drmModeGetResources(int fd) { drmModeRes *res; @@ -374,12 +390,14 @@ drmModeRes *drmModeGetResources(int fd) return res; } -void drmModeFreeResources(drmModeRes *res) +void +drmModeFreeResources(drmModeRes *res) { free(res); } -drmModePlaneRes *drmModeGetPlaneResources(int fd) +drmModePlaneRes * +drmModeGetPlaneResources(int fd) { static uint32_t plane_ids[MAX_PLANES]; drmModePlaneRes *res; @@ -400,12 +418,14 @@ drmModePlaneRes *drmModeGetPlaneResources(int fd) return res; } -void drmModeFreePlaneResources(drmModePlaneRes *res) +void +drmModeFreePlaneResources(drmModePlaneRes *res) { free(res); } -drmModePlane *drmModeGetPlane(int fd, uint32_t id) +drmModePlane * +drmModeGetPlane(int fd, uint32_t id) { drmModePlane *plane; @@ -417,12 +437,13 @@ drmModePlane *drmModeGetPlane(int fd, uint32_t id) return plane; } -void drmModeFreePlane(drmModePlane *plane) { +void +drmModeFreePlane(drmModePlane *plane) { free(plane); } -drmModeObjectProperties *drmModeObjectGetProperties(int fd, uint32_t obj_id, - uint32_t obj_type) +drmModeObjectProperties * +drmModeObjectGetProperties(int fd, uint32_t obj_id, uint32_t obj_type) { struct liftoff_mock_plane *plane; drmModeObjectProperties *props; @@ -453,35 +474,41 @@ drmModeObjectProperties *drmModeObjectGetProperties(int fd, uint32_t obj_id, return props; } -void drmModeFreeObjectProperties(drmModeObjectProperties *props) { +void +drmModeFreeObjectProperties(drmModeObjectProperties *props) { free(props->props); free(props->prop_values); free(props); } -drmModePropertyRes *drmModeGetProperty(int fd, uint32_t id) +drmModePropertyRes * +drmModeGetProperty(int fd, uint32_t id) { assert_drm_fd(fd); return &plane_props[get_prop_index(id)]; } -void drmModeFreeProperty(drmModePropertyRes *prop) { +void +drmModeFreeProperty(drmModePropertyRes *prop) { /* Owned by plane_props */ } -drmModeAtomicReq *drmModeAtomicAlloc(void) +drmModeAtomicReq * +drmModeAtomicAlloc(void) { return calloc(1, sizeof(drmModeAtomicReq)); } -void drmModeAtomicFree(drmModeAtomicReq *req) +void +drmModeAtomicFree(drmModeAtomicReq *req) { free(req); } -int drmModeAtomicAddProperty(drmModeAtomicReq *req, uint32_t obj_id, - uint32_t prop_id, uint64_t value) +int +drmModeAtomicAddProperty(drmModeAtomicReq *req, uint32_t obj_id, + uint32_t prop_id, uint64_t value) { assert((size_t)req->cursor < sizeof(req->props) / sizeof(req->props[0])); req->props[req->cursor].obj_id = obj_id; @@ -491,12 +518,14 @@ int drmModeAtomicAddProperty(drmModeAtomicReq *req, uint32_t obj_id, return req->cursor; } -int drmModeAtomicGetCursor(drmModeAtomicReq *req) +int +drmModeAtomicGetCursor(drmModeAtomicReq *req) { return req->cursor; } -void drmModeAtomicSetCursor(drmModeAtomicReq *req, int cursor) +void +drmModeAtomicSetCursor(drmModeAtomicReq *req, int cursor) { req->cursor = cursor; } diff --git a/test/test_alloc.c b/test/test_alloc.c index 02d6362..f1571ce 100644 --- a/test/test_alloc.c +++ b/test/test_alloc.c @@ -6,8 +6,8 @@ #include #include "libdrm_mock.h" -static struct liftoff_layer *add_layer(struct liftoff_output *output, - int x, int y, int width, int height) +static struct liftoff_layer * +add_layer(struct liftoff_output *output, int x, int y, int width, int height) { uint32_t fb_id; struct liftoff_layer *layer; @@ -606,7 +606,8 @@ static struct test_case tests[] = { }, }; -static bool test_needs_composition(struct test_layer *test_layers) +static bool +test_needs_composition(struct test_layer *test_layers) { size_t i; @@ -619,7 +620,8 @@ static bool test_needs_composition(struct test_layer *test_layers) return false; } -static void run_test(struct test_layer *test_layers) +static void +run_test(struct test_layer *test_layers) { size_t i, j; ssize_t plane_index_got, plane_index_want; @@ -719,7 +721,8 @@ static void run_test(struct test_layer *test_layers) close(drm_fd); } -static void test_basic(void) +static void +test_basic(void) { struct liftoff_mock_plane *mock_plane; int drm_fd; @@ -756,7 +759,8 @@ static void test_basic(void) /* Checks that the library doesn't allocate a plane for a layer without a * non-zero FB_ID set. */ -static void test_no_fb_fail(bool zero_fb_id) +static void +test_no_fb_fail(bool zero_fb_id) { struct liftoff_mock_plane *mock_plane; int drm_fd; @@ -796,7 +800,8 @@ static void test_no_fb_fail(bool zero_fb_id) /* Checks that the library doesn't fallback to composition when a layer doesn't * have a FB. */ -static void test_composition_zero_fb(void) +static void +test_composition_zero_fb(void) { struct liftoff_mock_plane *mock_plane; int drm_fd; @@ -839,7 +844,9 @@ static void test_composition_zero_fb(void) close(drm_fd); } -int main(int argc, char *argv[]) { +int +main(int argc, char *argv[]) +{ const char *test_name; size_t i; diff --git a/test/test_dynamic.c b/test/test_dynamic.c index 3a6d6a2..c932b2b 100644 --- a/test/test_dynamic.c +++ b/test/test_dynamic.c @@ -19,8 +19,8 @@ struct test_case { void (*run)(struct context *ctx); }; -static struct liftoff_layer *add_layer(struct liftoff_output *output, - int x, int y, int width, int height) +static struct liftoff_layer * +add_layer(struct liftoff_output *output, int x, int y, int width, int height) { uint32_t fb_id; struct liftoff_layer *layer; @@ -40,7 +40,9 @@ static struct liftoff_layer *add_layer(struct liftoff_output *output, return layer; } -static void first_commit(struct context *ctx) { +static void +first_commit(struct context *ctx) +{ drmModeAtomicReq *req; int ret; @@ -62,7 +64,9 @@ static void first_commit(struct context *ctx) { assert(ctx->commit_count > 1); } -static void second_commit(struct context *ctx, bool want_reuse_prev_alloc) { +static void +second_commit(struct context *ctx, bool want_reuse_prev_alloc) +{ drmModeAtomicReq *req; int ret; @@ -83,7 +87,9 @@ static void second_commit(struct context *ctx, bool want_reuse_prev_alloc) { drmModeAtomicFree(req); } -static void run_same(struct context *ctx) { +static void +run_same(struct context *ctx) +{ first_commit(ctx); assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); @@ -91,7 +97,9 @@ static void run_same(struct context *ctx) { assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); } -static void run_change_fb(struct context *ctx) { +static void +run_change_fb(struct context *ctx) +{ first_commit(ctx); assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); @@ -102,7 +110,9 @@ static void run_change_fb(struct context *ctx) { assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); } -static void run_unset_fb(struct context *ctx) { +static void +run_unset_fb(struct context *ctx) +{ first_commit(ctx); assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); @@ -112,7 +122,9 @@ static void run_unset_fb(struct context *ctx) { assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == NULL); } -static void run_set_fb(struct context *ctx) { +static void +run_set_fb(struct context *ctx) +{ liftoff_layer_set_property(ctx->layer, "FB_ID", 0); first_commit(ctx); assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == NULL); @@ -124,7 +136,9 @@ static void run_set_fb(struct context *ctx) { assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); } -static void run_add_layer(struct context *ctx) { +static void +run_add_layer(struct context *ctx) +{ first_commit(ctx); assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); @@ -134,7 +148,9 @@ static void run_add_layer(struct context *ctx) { assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); } -static void run_remove_layer(struct context *ctx) { +static void +run_remove_layer(struct context *ctx) +{ first_commit(ctx); assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); @@ -145,7 +161,9 @@ static void run_remove_layer(struct context *ctx) { assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); } -static void run_change_composition_layer(struct context *ctx) { +static void +run_change_composition_layer(struct context *ctx) +{ first_commit(ctx); assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); @@ -155,7 +173,9 @@ static void run_change_composition_layer(struct context *ctx) { assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); } -static void run_change_alpha(struct context *ctx) { +static void +run_change_alpha(struct context *ctx) +{ liftoff_layer_set_property(ctx->layer, "alpha", 42); first_commit(ctx); @@ -167,7 +187,9 @@ static void run_change_alpha(struct context *ctx) { assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); } -static void run_set_alpha_from_opaque(struct context *ctx) { +static void +run_set_alpha_from_opaque(struct context *ctx) +{ liftoff_layer_set_property(ctx->layer, "alpha", 0xFFFF); /* opaque */ first_commit(ctx); @@ -179,7 +201,9 @@ static void run_set_alpha_from_opaque(struct context *ctx) { assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); } -static void run_set_alpha_from_transparent(struct context *ctx) { +static void +run_set_alpha_from_transparent(struct context *ctx) +{ liftoff_layer_set_property(ctx->layer, "alpha", 0); /* transparent */ first_commit(ctx); @@ -191,7 +215,9 @@ static void run_set_alpha_from_transparent(struct context *ctx) { assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); } -static void run_unset_alpha_to_opaque(struct context *ctx) { +static void +run_unset_alpha_to_opaque(struct context *ctx) +{ liftoff_layer_set_property(ctx->layer, "alpha", 42); first_commit(ctx); @@ -203,7 +229,9 @@ static void run_unset_alpha_to_opaque(struct context *ctx) { assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); } -static void run_unset_alpha_to_transparent(struct context *ctx) { +static void +run_unset_alpha_to_transparent(struct context *ctx) +{ liftoff_layer_set_property(ctx->layer, "alpha", 42); first_commit(ctx); @@ -215,7 +243,9 @@ static void run_unset_alpha_to_transparent(struct context *ctx) { assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == NULL); } -static void run_change_in_fence_fd(struct context *ctx) { +static void +run_change_in_fence_fd(struct context *ctx) +{ liftoff_layer_set_property(ctx->layer, "IN_FENCE_FD", 42); first_commit(ctx); @@ -227,7 +257,9 @@ static void run_change_in_fence_fd(struct context *ctx) { assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); } -static void run_change_fb_damage_clips(struct context *ctx) { +static void +run_change_fb_damage_clips(struct context *ctx) +{ liftoff_layer_set_property(ctx->layer, "FB_DAMAGE_CLIPS", 42); first_commit(ctx); @@ -256,7 +288,9 @@ static const struct test_case tests[] = { { .name = "change-fb-damage-clips", .run = run_change_fb_damage_clips }, }; -static void run(const struct test_case *test) { +static void +run(const struct test_case *test) +{ struct context ctx = {0}; struct liftoff_device *device; const char *prop_name; @@ -306,7 +340,9 @@ static void run(const struct test_case *test) { close(ctx.drm_fd); } -int main(int argc, char *argv[]) { +int +main(int argc, char *argv[]) +{ const char *test_name; liftoff_log_set_priority(LIFTOFF_DEBUG); diff --git a/test/test_priority.c b/test/test_priority.c index cf0417f..1c24ec4 100644 --- a/test/test_priority.c +++ b/test/test_priority.c @@ -8,8 +8,8 @@ /* Number of page-flips before the plane allocation has stabilized */ #define STABILIZE_PAGEFLIP_COUNT 600 /* 10s at 60FPS */ -static struct liftoff_layer *add_layer(struct liftoff_output *output, - int x, int y, int width, int height) +static struct liftoff_layer * +add_layer(struct liftoff_output *output, int x, int y, int width, int height) { uint32_t fb_id; struct liftoff_layer *layer; @@ -29,7 +29,9 @@ static struct liftoff_layer *add_layer(struct liftoff_output *output, return layer; } -int main(int argc, char *argv[]) { +int +main(int argc, char *argv[]) +{ struct liftoff_mock_plane *mock_plane; int drm_fd; struct liftoff_device *device; diff --git a/test/test_prop.c b/test/test_prop.c index fbdf92c..a669f18 100644 --- a/test/test_prop.c +++ b/test/test_prop.c @@ -5,8 +5,8 @@ #include #include "libdrm_mock.h" -static struct liftoff_layer *add_layer(struct liftoff_output *output, - int x, int y, int width, int height) +static struct liftoff_layer * +add_layer(struct liftoff_output *output, int x, int y, int width, int height) { uint32_t fb_id; struct liftoff_layer *layer; @@ -26,7 +26,8 @@ static struct liftoff_layer *add_layer(struct liftoff_output *output, return layer; } -static int test_prop_default(const char *prop_name) +static int +test_prop_default(const char *prop_name) { struct liftoff_mock_plane *mock_plane_with_prop, *mock_plane_without_prop; @@ -123,7 +124,8 @@ static int test_prop_default(const char *prop_name) } /* Checks that a fully transparent layer is ignored. */ -static int test_ignore_alpha(void) +static int +test_ignore_alpha(void) { struct liftoff_mock_plane *mock_plane; drmModePropertyRes prop = {0}; @@ -166,7 +168,9 @@ static int test_ignore_alpha(void) return 0; } -static int test_immutable_zpos(void) { +static int +test_immutable_zpos(void) +{ struct liftoff_mock_plane *mock_plane1, *mock_plane2; drmModePropertyRes prop = {0}; uint64_t prop_value; @@ -239,7 +243,9 @@ static int test_immutable_zpos(void) { return 0; } -int main(int argc, char *argv[]) { +int +main(int argc, char *argv[]) +{ const char *test_name; liftoff_log_set_priority(LIFTOFF_DEBUG);