From: Mahesh Kumar <mahesh1.kumar@xxxxxxxxx> This patch adds a subtest related to pixel format testing. The test create framebuffer with all supported pixel formats for primary and sprite planes which can be drawn using cairo and commits the same on display. Signed-off-by: Mahesh Kumar <mahesh1.kumar@xxxxxxxxx> Signed-off-by: Jyoti Yadav <jyoti.r.yadav@xxxxxxxxx> Signed-off-by: Vidya Srinivas <vidya.srinivas@xxxxxxxxx> --- tests/kms_plane.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/tests/kms_plane.c b/tests/kms_plane.c index 92bf67f..5f25177 100644 --- a/tests/kms_plane.c +++ b/tests/kms_plane.c @@ -368,6 +368,125 @@ test_plane_panning(data_t *data, enum pipe pipe, unsigned int flags) igt_skip_on(connected_outs == 0); } +static void test_format_primary(data_t *data, + enum pipe pipe, igt_output_t *output) +{ + igt_plane_t *primary; + struct igt_fb primary_fb; + drmModeModeInfo *mode; + cairo_t *cr; + int primary_id; + uint32_t format; + + igt_info("Testing connector %s using pipe %s on primary plane\n", + igt_output_name(output), kmstest_pipe_name(pipe)); + + igt_output_set_pipe(output, pipe); + mode = igt_output_get_mode(output); + + primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY); + + for_each_format_in_plane(primary, format) { + if (igt_is_cairo_supported_format(format)) { + igt_info("Testing format %s on primary now\n", + igt_get_format_name(format)); + primary_id = igt_create_fb(data->drm_fd, + mode->hdisplay, mode->vdisplay, + format, + LOCAL_DRM_FORMAT_MOD_NONE, + &primary_fb); + igt_assert(primary_id); + cr = igt_get_cairo_ctx(data->drm_fd, &primary_fb); + igt_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay, + 0.0, 1.0, 0.0); + igt_paint_color(cr, 100, 100, 64, 64, 0.0, 0.0, 0.0); + igt_assert(cairo_status(cr) == 0); + cairo_destroy(cr); + + igt_plane_set_fb(primary, &primary_fb); + igt_display_commit(&data->display); + } + } + + igt_remove_fb(data->drm_fd, &primary_fb); + igt_plane_set_fb(primary, NULL); +} + +static void test_format_overlay(data_t *data, + enum pipe pipe, igt_output_t *output, + int plane_id) +{ + igt_plane_t *primary, *overlay; + struct igt_fb primary_fb, overlay_fb; + drmModeModeInfo *mode; + cairo_t *cr; + int primary_id, overlay_id; + uint32_t format; + + igt_info("Testing connector %s using pipe %s on overlay plane %d\n", + igt_output_name(output), kmstest_pipe_name(pipe), plane_id); + + igt_output_set_pipe(output, pipe); + mode = igt_output_get_mode(output); + + overlay = igt_output_get_plane(output, plane_id); + primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY); + primary_id = igt_create_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE, + &primary_fb); + igt_assert(primary_id); + igt_plane_set_fb(primary, &primary_fb); + cr = igt_get_cairo_ctx(data->drm_fd, &primary_fb); + igt_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay, 0.0, 0.0, 1.0); + igt_assert(cairo_status(cr) == 0); + cairo_destroy(cr); + + for_each_format_in_plane(overlay, format) { + if (igt_is_cairo_supported_format(format)) { + igt_info("Testing format %s on plane id %d\n", + igt_get_format_name(format), plane_id); + overlay_id = igt_create_fb(data->drm_fd, 300, 300, format, + LOCAL_DRM_FORMAT_MOD_NONE, &overlay_fb); + igt_assert(overlay_id); + + igt_plane_set_fb(overlay, &overlay_fb); + cr = igt_get_cairo_ctx(data->drm_fd, &overlay_fb); + igt_paint_color(cr, 0, 0, 300, 300, 1.0, 0.0, 0.0); + igt_assert(cairo_status(cr) == 0); + cairo_destroy(cr); + igt_display_commit(&data->display); + + igt_remove_fb(data->drm_fd, &overlay_fb); + igt_plane_set_fb(overlay, NULL); + overlay_id = 0; + } + } + igt_remove_fb(data->drm_fd, &primary_fb); + igt_plane_set_fb(primary, NULL); +} + +static void +test_pixel_formats(data_t *data, enum pipe pipe) +{ + igt_output_t *output; + int connected_outs = 0; + + for_each_valid_output_on_pipe(&data->display, pipe, output) { + int n_planes = data->display.pipes[pipe].n_planes; + + igt_info("Testing PRIMARY on pipe %d\n", pipe); + test_format_primary(data, pipe, output); + + /* Run only for SPRITES */ + for (int plane_id = 1; plane_id < n_planes-1; plane_id++) + test_format_overlay(data, pipe, output, plane_id); + + connected_outs++; + igt_output_set_pipe(output, PIPE_ANY); + } + igt_skip_on(connected_outs == 0); +} + static void run_tests_for_pipe_plane(data_t *data, enum pipe pipe) { @@ -376,6 +495,10 @@ run_tests_for_pipe_plane(data_t *data, enum pipe pipe) igt_require(data->display.pipes[pipe].n_planes > 0); } + igt_subtest_f("pixel-format-pipe-%s-planes", + kmstest_pipe_name(pipe)) + test_pixel_formats(data, pipe); + igt_subtest_f("plane-position-covered-pipe-%s-planes", kmstest_pipe_name(pipe)) test_plane_position(data, pipe, TEST_POSITION_FULLY_COVERED); -- 2.7.4 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx