Currently, we are missing to destroy buffer and to remove framebuffer of
planes when terminates modetest.

Signed-off-by: Joonyoung Shim <jy0922.shim at samsung.com>
---
 tests/modetest/modetest.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index eec4fd8..56d49b0 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -730,6 +730,7 @@ struct plane_arg {
        uint32_t w, h;
        double scale;
        unsigned int fb_id;
+       struct bo *bo;
        char format_str[5]; /* need to leave room for terminating \0 */
        unsigned int fourcc;
 };
@@ -1012,6 +1013,8 @@ static int set_plane(struct device *dev, struct plane_arg 
*p)
        if (plane_bo == NULL)
                return -1;

+       p->bo = plane_bo;
+
        /* just use single plane format for now.. */
        if (drmModeAddFB2(dev->fd, p->w, p->h, p->fourcc,
                        handles, pitches, offsets, &p->fb_id, plane_flags)) {
@@ -1133,6 +1136,18 @@ static void set_planes(struct device *dev, struct 
plane_arg *p, unsigned int cou
                        return;
 }

+static void clear_planes(struct device *dev, struct plane_arg *p, unsigned int 
count)
+{
+       unsigned int i;
+
+       for (i = 0; i < count; i++) {
+               if (p[i].fb_id != -1)
+                       drmModeRmFB(dev->fd, p[i].fb_id);
+               if (p[i].bo)
+                       bo_destroy(p[i].bo);
+       }
+}
+
 static void set_cursors(struct device *dev, struct pipe_arg *pipes, unsigned 
int count)
 {
        uint32_t handles[4], pitches[4], offsets[4] = {0}; /* we only use [0] */
@@ -1517,6 +1532,7 @@ int main(int argc, char **argv)
                        if (parse_plane(&plane_args[plane_count], optarg) < 0)
                                usage(argv[0]);

+                       plane_args[plane_count].fb_id = -1;
                        plane_count++;
                        break;
                case 'p':
@@ -1649,6 +1665,9 @@ int main(int argc, char **argv)
                if (test_cursor)
                        clear_cursors(&dev);

+               if (plane_count)
+                       clear_planes(&dev, plane_args, plane_count);
+
                if (count)
                        clear_mode(&dev);
        }
-- 
1.9.1

Reply via email to