From 54bb501cae179583030bb0930016d044bfa7850e Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 13 Sep 2019 19:46:21 +0300 Subject: [PATCH] test: add liftoff_mock_drm_get_plane Allows to get a mock plane from a plane ID. --- test/include/libdrm_mock.h | 1 + test/libdrm_mock.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/test/include/libdrm_mock.h b/test/include/libdrm_mock.h index 97fc027..9d52936 100644 --- a/test/include/libdrm_mock.h +++ b/test/include/libdrm_mock.h @@ -12,6 +12,7 @@ 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, diff --git a/test/libdrm_mock.c b/test/libdrm_mock.c index 23829f2..0bb10fa 100644 --- a/test/libdrm_mock.c +++ b/test/libdrm_mock.c @@ -98,6 +98,21 @@ 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 *plane; + + plane = &mock_planes[0]; + while (plane->id != 0) { + if (plane->id == id) { + return plane; + } + plane++; + } + + assert(0); +} + void liftoff_mock_plane_add_compatible_layer(struct liftoff_mock_plane *plane, struct liftoff_layer *layer) {