From: Damien Lespiau Subject: [PATCH i-g-t 17/43] kms_rotation_crc: Factor out common primary/sprite code in prepare_crtc() Date: Thu, 10 Jul 2014 19:00:18 +0100 Message-ID: <1405015244-11370-18-git-send-email-damien.lespiau@intel.com> References: <1405015244-11370-1-git-send-email-damien.lespiau@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by gabe.freedesktop.org (Postfix) with ESMTP id 093CA6E1FB for ; Thu, 10 Jul 2014 11:01:30 -0700 (PDT) In-Reply-To: <1405015244-11370-1-git-send-email-damien.lespiau@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org This results in less code, always a good thing. Also, we only really need one reference CRC. Signed-off-by: Damien Lespiau --- tests/kms_rotation_crc.c | 89 +++++++++++++++++------------------------------- 1 file changed, 32 insertions(+), 57 deletions(-) diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c index 5f499d7..bc11b9c 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); -- 1.8.3.1