static void do_single_test(data_t *data, int x, int y) { igt_display_t *display = &data->display; igt_pipe_crc_t *pipe_crc = data->pipe_crc; igt_crc_t crc, ref_crc; igt_plane_t *cursor; cairo_t *cr = igt_get_cairo_ctx(data->drm_fd, &data->primary_fb); igt_print_activity(); /* Hardware test */ igt_paint_test_pattern(cr, data->screenw, data->screenh); cursor_enable(data); cursor = igt_output_get_plane(data->output, IGT_PLANE_CURSOR); igt_plane_set_position(cursor, x, y); igt_display_commit(display); igt_wait_for_vblank(data->drm_fd, data->pipe); igt_pipe_crc_collect_crc(pipe_crc, &crc); if (data->flags & (TEST_DPMS | TEST_SUSPEND)) { igt_crc_t crc_after; if (data->flags & TEST_DPMS) { igt_debug("dpms off/on cycle\n"); kmstest_set_connector_dpms(data->drm_fd, data->output->config.connector, DRM_MODE_DPMS_OFF); kmstest_set_connector_dpms(data->drm_fd, data->output->config.connector, DRM_MODE_DPMS_ON); } if (data->flags & TEST_SUSPEND) igt_system_suspend_autoresume(); igt_pipe_crc_collect_crc(pipe_crc, &crc_after); igt_assert_crc_equal(&crc, &crc_after); } cursor_disable(data); igt_display_commit(display); /* Now render the same in software and collect crc */ draw_cursor(cr, x, y, data->curw, data->curh); igt_display_commit(display); igt_wait_for_vblank(data->drm_fd, data->pipe); igt_pipe_crc_collect_crc(pipe_crc, &ref_crc); /* Clear screen afterwards */ igt_assert_crc_equal(&crc, &ref_crc); igt_paint_color(cr, 0, 0, data->screenw, data->screenh, 0.0, 0.0, 0.0); }
/** * igt_create_color_fb: * @fd: open i915 drm file descriptor * @width: width of the framebuffer in pixel * @height: height of the framebuffer in pixel * @format: drm fourcc pixel format code * @tiling: tiling layout of the framebuffer * @r: red value to use as fill color * @g: gree value to use as fill color * @b: blue value to use as fill color * @fb: pointer to an #igt_fb structure * * This function allocates a gem buffer object suitable to back a framebuffer * with the requested properties and then wraps it up in a drm framebuffer * object. All metadata is stored in @fb. * * Compared to igt_create_fb() this function also fills the entire framebuffer * with the given color, which is useful for some simple pipe crc based tests. * * Returns: * The kms id of the created framebuffer on success or a negative error code on * failure. */ unsigned int igt_create_color_fb(int fd, int width, int height, uint32_t format, uint64_t tiling, double r, double g, double b, struct igt_fb *fb /* out */) { unsigned int fb_id; cairo_t *cr; fb_id = igt_create_fb(fd, width, height, format, tiling, fb); igt_assert(fb_id); cr = igt_get_cairo_ctx(fd, fb); igt_paint_color(cr, 0, 0, width, height, r, g, b); igt_assert(cairo_status(cr) == 0); cairo_destroy(cr); return fb_id; }
static void paint_squares(data_t *data, drmModeModeInfo *mode, igt_rotation_t rotation, struct igt_fb *fb, float o) { cairo_t *cr; unsigned int w = data->w; unsigned int h = data->h; cr = igt_get_cairo_ctx(data->gfx_fd, fb); if (rotation == IGT_ROTATION_180) { cairo_translate(cr, w, h); cairo_rotate(cr, M_PI); } if (rotation == IGT_ROTATION_90) { /* Paint 4 squares with width == height in Green, White, Blue, Red Clockwise order to look like 270 degree rotated*/ igt_paint_color(cr, 0, 0, w / 2, h / 2, 0.0, o, 0.0); igt_paint_color(cr, w / 2, 0, w / 2, h / 2, o, o, o); igt_paint_color(cr, 0, h / 2, w / 2, h / 2, o, 0.0, 0.0); igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 0.0, 0.0, o); } else if (rotation == IGT_ROTATION_270) { /* Paint 4 squares with width == height in Blue, Red, Green, White Clockwise order to look like 90 degree rotated*/ igt_paint_color(cr, 0, 0, w / 2, h / 2, 0.0, 0.0, o); igt_paint_color(cr, w / 2, 0, w / 2, h / 2, o, 0.0, 0.0); igt_paint_color(cr, 0, h / 2, w / 2, h / 2, o, o, o); igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 0.0, o, 0.0); } else { /* Paint with 4 squares of Red, Green, White, Blue Clockwise */ igt_paint_color(cr, 0, 0, w / 2, h / 2, o, 0.0, 0.0); igt_paint_color(cr, w / 2, 0, w / 2, h / 2, 0.0, o, 0.0); igt_paint_color(cr, 0, h / 2, w / 2, h / 2, 0.0, 0.0, o); igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, o, o, o); } cairo_destroy(cr); }