summaryrefslogtreecommitdiff
path: root/tests/kms_rotation_crc.c
diff options
context:
space:
mode:
authorDamien Lespiau <damien.lespiau@intel.com>2014-07-08 12:59:03 +0100
committerDamien Lespiau <damien.lespiau@intel.com>2014-07-11 15:12:22 +0100
commit19743a14357fbc23a0e91d8302ed60a5690530df (patch)
treeaa6795c7f18780585ffbd66b198315506b94cd8b /tests/kms_rotation_crc.c
parent92b29b18ca62d1e1cadf338f1b883a49d3e63a01 (diff)
kms_rotation_crc: Factor out common primary/sprite code in prepare_crtc()
This results in less code, always a good thing. Also, we only really need one reference CRC. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Diffstat (limited to 'tests/kms_rotation_crc.c')
-rw-r--r--tests/kms_rotation_crc.c89
1 files changed, 32 insertions, 57 deletions
diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
index 5f499d7b..bc11b9c5 100644
--- a/tests/kms_rotation_crc.c
+++ b/tests/kms_rotation_crc.c
@@ -61,7 +61,7 @@ typedef struct {
int type;
int pipe;
struct igt_fb fb;
- igt_crc_t ref_crc[2];
+ igt_crc_t ref_crc;
igt_pipe_crc_t *pipe_crc;
int rotate;
} data_t;
@@ -97,7 +97,7 @@ static bool prepare_crtc(data_t *data)
drmModeModeInfo *mode;
igt_display_t *display = &data->display;
igt_output_t *output = data->output;
- igt_plane_t *primary, *sprite;
+ igt_plane_t *plane;
int fb_id;
igt_output_set_pipe(output, data->pipe);
@@ -106,6 +106,19 @@ static bool prepare_crtc(data_t *data)
if (!data->output->valid)
return false;
+ switch (data->type) {
+ case DRM_PLANE_TYPE_OVERLAY: /* Sprite */
+ igt_info("Sprite plane\n");
+ plane = igt_output_get_plane(output, IGT_PLANE_2);
+ break;
+ case DRM_PLANE_TYPE_PRIMARY: /* Primary */
+ igt_info("Primary plane\n");
+ plane = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+ break;
+ default:
+ return false;
+ }
+
/* create the pipe_crc object for this pipe */
if (data->pipe_crc)
igt_pipe_crc_free(data->pipe_crc);
@@ -118,65 +131,27 @@ static bool prepare_crtc(data_t *data)
return false;
}
- switch (data->type) {
-
- case DRM_PLANE_TYPE_OVERLAY: /* Sprite */
- igt_info("Sprite plane\n");
- mode = igt_output_get_mode(output);
-
- fb_id = igt_create_fb(data->gfx_fd,
- mode->hdisplay, mode->vdisplay,
- DRM_FORMAT_XRGB8888,
- false, /* tiled */
- &data->fb);
- igt_assert(fb_id);
-
- paint_squares(data, &data->fb, mode, DRM_ROTATE_180);
-
- sprite = igt_output_get_plane(output, IGT_PLANE_2);
- igt_plane_set_fb(sprite, &data->fb);
- igt_display_commit(display);
-
- /* Collect reference crc */
- igt_pipe_crc_collect_crc(data->pipe_crc, &data->ref_crc[1]);
-
- paint_squares(data, &data->fb, mode, DRM_ROTATE_0);
-
- sprite = igt_output_get_plane(output, IGT_PLANE_2);
- igt_plane_set_fb(sprite, &data->fb);
- igt_display_commit(display);
-
- break;
- case DRM_PLANE_TYPE_PRIMARY: /* Primary */
- igt_info("Primary plane\n");
- mode = igt_output_get_mode(output);
-
- fb_id = igt_create_fb(data->gfx_fd,
- mode->hdisplay, mode->vdisplay,
- DRM_FORMAT_XRGB8888,
- false, /* tiled */
- &data->fb);
- igt_assert(fb_id);
-
- paint_squares(data, &data->fb, mode, DRM_ROTATE_180);
-
- primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
- igt_plane_set_fb(primary, &data->fb);
- igt_display_commit(display);
+ mode = igt_output_get_mode(output);
- /* Collect reference crc */
- igt_pipe_crc_collect_crc(data->pipe_crc, &data->ref_crc[0]);
+ fb_id = igt_create_fb(data->gfx_fd,
+ mode->hdisplay, mode->vdisplay,
+ DRM_FORMAT_XRGB8888,
+ false, /* tiled */
+ &data->fb);
+ igt_assert(fb_id);
- paint_squares(data, &data->fb, mode, DRM_ROTATE_0);
+ paint_squares(data, &data->fb, mode, DRM_ROTATE_180);
- primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
- igt_plane_set_fb(primary, &data->fb);
- igt_display_commit(display);
+ igt_plane_set_fb(plane, &data->fb);
+ igt_display_commit(display);
- break;
+ /* Collect reference crc */
+ igt_pipe_crc_collect_crc(data->pipe_crc, &data->ref_crc);
+ paint_squares(data, &data->fb, mode, DRM_ROTATE_0);
- }
+ igt_plane_set_fb(plane, &data->fb);
+ igt_display_commit(display);
return true;
}
@@ -332,7 +307,7 @@ static void test_sprite_rotation(data_t *data)
return;
}
}
- igt_assert(igt_crc_equal(&data->ref_crc[1], &crc_output));
+ igt_assert(igt_crc_equal(&data->ref_crc, &crc_output));
sleep(2);
valid_tests++;
cleanup_crtc(data, output);
@@ -378,7 +353,7 @@ static void test_primary_rotation(data_t *data)
return;
}
}
- igt_assert(igt_crc_equal(&data->ref_crc[0], &crc_output));
+ igt_assert(igt_crc_equal(&data->ref_crc, &crc_output));
sleep(2);
valid_tests++;
cleanup_crtc(data, output);