summaryrefslogtreecommitdiff
path: root/tests/testdisplay.c
diff options
context:
space:
mode:
authorDamien Lespiau <damien.lespiau@intel.com>2013-09-03 19:46:19 +0100
committerDamien Lespiau <damien.lespiau@intel.com>2013-09-30 18:04:21 +0100
commiteecd0061eb5bf45a3db515fa1cedb1184f98ca44 (patch)
treec47c53eca700e3aba52d48e727cf207ca7e59a9d /tests/testdisplay.c
parent5a1d84300ba31bec08c05db7d1c602c80e932021 (diff)
testdisplay: Properly handle the life cycle of framebuffers
When cycling through the modes, let's make sure to free the previous framebuffers. This is the perfect occasion to use kmstest_remove_fb(). Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Diffstat (limited to 'tests/testdisplay.c')
-rw-r--r--tests/testdisplay.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index 3d696a06..6e47ae22 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -338,7 +338,8 @@ static void
set_mode(struct connector *c)
{
unsigned int fb_id = 0;
- int j, test_mode_num;
+ struct kmstest_fb fb_info[2] = { };
+ int j, test_mode_num, current_fb = 0, old_fb = -1;
test_mode_num = 1;
if (force_mode){
@@ -350,7 +351,6 @@ set_mode(struct connector *c)
test_mode_num = c->connector->count_modes;
for (j = 0; j < test_mode_num; j++) {
- struct kmstest_fb fb_info;
if (test_all_modes)
c->mode = c->connector->modes[j];
@@ -362,11 +362,9 @@ set_mode(struct connector *c)
height = c->mode.vdisplay;
fb_id = kmstest_create_fb(drm_fd, width, height, bpp, depth,
- enable_tiling, &fb_info);
- paint_output_info(c, &fb_info);
- paint_color_key(&fb_info);
-
- gem_close(drm_fd, fb_info.gem_handle);
+ enable_tiling, &fb_info[current_fb]);
+ paint_output_info(c, &fb_info[current_fb]);
+ paint_color_key(&fb_info[current_fb]);
fprintf(stdout, "CRTS(%u):[%d]",c->crtc, j);
kmstest_dump_mode(&c->mode);
@@ -378,6 +376,11 @@ set_mode(struct connector *c)
continue;
}
+ if (old_fb != -1)
+ kmstest_remove_fb(drm_fd, &fb_info[old_fb]);
+ old_fb = current_fb;
+ current_fb = 1 - current_fb;
+
if (sleep_between_modes && test_all_modes && !qr_code)
sleep(sleep_between_modes);
@@ -385,13 +388,10 @@ set_mode(struct connector *c)
set_single();
pause();
}
-
}
- if(test_all_modes){
- drmModeRmFB(drm_fd,fb_id);
- drmModeSetCrtc(drm_fd, c->crtc, fb_id, 0, 0, &c->id, 1, 0);
- }
+ if (test_all_modes)
+ kmstest_remove_fb(drm_fd, &fb_info[old_fb]);
drmModeFreeEncoder(c->encoder);
drmModeFreeConnector(c->connector);