diff options
author | Inki Dae <inki.dae@samsung.com> | 2017-02-03 16:01:58 +0900 |
---|---|---|
committer | Inki Dae <inki.dae@samsung.com> | 2017-02-07 17:22:10 +0900 |
commit | ddb3f215c73d075313960a387cb0ff57b561c3a6 (patch) | |
tree | 01b1412ab43d626f431fca9f2748d56359da6564 | |
parent | 9d3bd95f2c5a9b4b69062a3ff008947054b94f55 (diff) | |
download | libdrm-ddb3f215c73d075313960a387cb0ff57b561c3a6.tar.gz libdrm-ddb3f215c73d075313960a387cb0ff57b561c3a6.tar.bz2 libdrm-ddb3f215c73d075313960a387cb0ff57b561c3a6.zip |
atomictest: enhance box moving way
This patch makes existing inflexible moving of boxes
to more free to check entire overlay region and identify
each overlay easily.
Change-Id: I4d6a6b78cf04d56f20db4780663e4423d6c60a4d
Signed-off-by: Inki Dae <inki.dae@samsung.com>
-rw-r--r-- | tests/atomictest/atomictest.c | 70 |
1 files changed, 61 insertions, 9 deletions
diff --git a/tests/atomictest/atomictest.c b/tests/atomictest/atomictest.c index b7bf7304..a393b01b 100644 --- a/tests/atomictest/atomictest.c +++ b/tests/atomictest/atomictest.c @@ -41,8 +41,8 @@ static void incrementor(int *inc, int *val, int increment, int lower, int upper) int main(int argc, char *argv[]) { int ret, i, j, num_test_planes; - int x_inc = 1, x = 0, y_inc = 1, y = 0; - uint32_t plane_w = 128, plane_h = 128; + int *x_inc = NULL, *x = NULL, *y_inc = NULL, *y = NULL; + uint32_t *plane_w = NULL, *plane_h = NULL; struct sp_dev *dev; struct sp_plane **plane = NULL; struct sp_crtc *test_crtc; @@ -74,23 +74,60 @@ int main(int argc, char *argv[]) goto out; } + srand(time(NULL)); + /* Create our planes */ num_test_planes = test_crtc->num_planes; + + plane_w = calloc(num_test_planes, sizeof(*plane_w)); + if (!plane_w) + goto out; + + plane_h = calloc(num_test_planes, sizeof(*plane_h)); + if (!plane_h) + goto out; + for (i = 0; i < num_test_planes; i++) { + plane_w[i] = rand() % (test_crtc->crtc->mode.hdisplay >> 2); + plane_h[i] = rand() % (test_crtc->crtc->mode.vdisplay >> 2); plane[i] = get_sp_plane(dev, test_crtc); if (!plane[i]) { printf("no unused planes available\n"); goto out; } - plane[i]->bo = create_sp_bo(dev, plane_w, plane_h, 16, 32, + plane[i]->bo = create_sp_bo(dev, plane_w[i], plane_h[i], 16, 32, plane[i]->format, 0); if (!plane[i]->bo) { printf("failed to create plane bo\n"); goto out; } + } + + printf("total planes = %d\n", num_test_planes); + + x = calloc(num_test_planes, sizeof(*x)); + if (!x) + goto out; - fill_bo(plane[i]->bo, 0xFF, 0x00, 0x00, 0xFF); + x_inc = calloc(num_test_planes, sizeof(*x_inc)); + if (!x_inc) + goto out; + + y = calloc(num_test_planes, sizeof(*y)); + if (!y) + goto out; + + y_inc = calloc(num_test_planes, sizeof(*y_inc)); + if (!y_inc) + goto out; + + for (i = 0; i < num_test_planes; i++) { + x[i] = rand() % test_crtc->crtc->mode.hdisplay - plane_w[i]; + y[i] = rand() % test_crtc->crtc->mode.vdisplay - plane_h[i]; + + fill_bo(plane[i]->bo, 0xFF, rand() % 255, rand() % 255, + rand() % 255); } pset = drmModeAtomicAlloc(); @@ -103,16 +140,18 @@ int main(int argc, char *argv[]) FD_ZERO(&fds); FD_SET(dev->fd, &fds); - incrementor(&x_inc, &x, 5, 0, - test_crtc->crtc->mode.hdisplay - plane_w); - incrementor(&y_inc, &y, 5, 0, test_crtc->crtc->mode.vdisplay - - plane_h * num_test_planes); + for (i = 0; i < num_test_planes; i++) { + incrementor(&x_inc[i], &x[i], 5, 0, + test_crtc->crtc->mode.hdisplay - plane_w[i]); + incrementor(&y_inc[i], &y[i], 5, 0, + test_crtc->crtc->mode.vdisplay - plane_h[i]); + } drmModeAtomicSetCursor(pset, 0); for (j = 0; j < num_test_planes; j++) { ret = set_sp_plane_pset(dev, plane[j], pset, test_crtc, - x, y + j * plane_h); + x[j], y[j]); if (ret < 0) { printf("failed to move plane %d\n", ret); goto out; @@ -140,6 +179,19 @@ int main(int argc, char *argv[]) put_sp_plane(plane[i]); out: + if (plane_w) + free(plane_w); + if (plane_h) + free(plane_h); + if (x) + free(x); + if (x_inc) + free(x_inc); + if (y) + free(y); + if (y_inc) + free(y_inc); + destroy_sp_dev(dev); free(plane); return ret; |