static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe, igt_plane_t *plane) { drmModeModeInfo *mode; int fb_id, fb_modeset_id; unsigned int w, h; uint64_t tiling = data->override_tiling ? data->override_tiling : LOCAL_DRM_FORMAT_MOD_NONE; uint32_t pixel_format = data->override_fmt ? data->override_fmt : DRM_FORMAT_XRGB8888; igt_output_set_pipe(output, pipe); /* create the pipe_crc object for this pipe */ igt_pipe_crc_free(data->pipe_crc); data->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); mode = igt_output_get_mode(output); w = mode->hdisplay; h = mode->vdisplay; fb_modeset_id = igt_create_fb(data->gfx_fd, w, h, pixel_format, tiling, &data->fb_modeset); igt_assert(fb_modeset_id); /* * For 90/270, we will use create smaller fb so that the rotated * frame can fit in */ if (data->rotation == IGT_ROTATION_90 || data->rotation == IGT_ROTATION_270) { tiling = data->override_tiling ? data->override_tiling : LOCAL_I915_FORMAT_MOD_Y_TILED; w = h = mode->vdisplay; } else if (plane->is_cursor) { pixel_format = data->override_fmt ? data->override_fmt : DRM_FORMAT_ARGB8888; w = h = 128; } data->w = w; data->h = h; fb_id = igt_create_fb(data->gfx_fd, w, h, pixel_format, tiling, &data->fb); igt_assert(fb_id); if (data->flip_stress) { fb_id = igt_create_fb(data->gfx_fd, w, h, pixel_format, tiling, &data->fb_flip); igt_assert(fb_id); paint_squares(data, mode, IGT_ROTATION_0, &data->fb_flip, 0.92); } /* Step 1: create a reference CRC for a software-rotated fb */ paint_squares(data, mode, data->rotation, &data->fb, 1.0); commit_crtc(data, output, plane); igt_pipe_crc_collect_crc(data->pipe_crc, &data->ref_crc); /* * Step 2: prepare the plane with an non-rotated fb let the hw * rotate it. */ paint_squares(data, mode, IGT_ROTATION_0, &data->fb, 1.0); igt_plane_set_fb(plane, &data->fb); }
static void test(data_t *data) { igt_display_t *display = &data->display; igt_output_t *output = data->output; struct igt_fb *fb = &data->fb[1]; drmModeModeInfo *mode; cairo_t *cr; char *ptr; uint32_t caching; void *buf; igt_crc_t crc; mode = igt_output_get_mode(output); /* create a non-white fb where we can write later */ igt_create_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE, fb); ptr = dmabuf_mmap_framebuffer(data->drm_fd, fb); cr = igt_get_cairo_ctx(data->drm_fd, fb); igt_paint_test_pattern(cr, fb->width, fb->height); cairo_destroy(cr); /* flip to it to make it UC/WC and fully flushed */ igt_plane_set_fb(data->primary, fb); igt_display_commit(display); /* flip back the original white buffer */ igt_plane_set_fb(data->primary, &data->fb[0]); igt_display_commit(display); /* make sure caching mode has become UC/WT */ caching = gem_get_caching(data->drm_fd, fb->gem_handle); igt_assert(caching == I915_CACHING_NONE || caching == I915_CACHING_DISPLAY); /* * firstly demonstrate the need for DMA_BUF_SYNC_START ("begin_cpu_access") */ if (ioctl_sync) prime_sync_start(dma_buf_fd); /* use dmabuf pointer to make the other fb all white too */ buf = malloc(fb->size); igt_assert(buf != NULL); memset(buf, 0xff, fb->size); memcpy(ptr, buf, fb->size); free(buf); /* and flip to it */ igt_plane_set_fb(data->primary, fb); igt_display_commit(display); /* check that the crc is as expected, which requires that caches got flushed */ igt_pipe_crc_collect_crc(data->pipe_crc, &crc); igt_assert_crc_equal(&crc, &data->ref_crc); /* * now demonstrates the need for DMA_BUF_SYNC_END ("end_cpu_access") */ /* start over, writing non-white to the fb again and flip to it to make it * fully flushed */ cr = igt_get_cairo_ctx(data->drm_fd, fb); igt_paint_test_pattern(cr, fb->width, fb->height); cairo_destroy(cr); igt_plane_set_fb(data->primary, fb); igt_display_commit(display); /* sync start, to move to CPU domain */ if (ioctl_sync) prime_sync_start(dma_buf_fd); /* use dmabuf pointer in the same fb to make it all white */ buf = malloc(fb->size); igt_assert(buf != NULL); memset(buf, 0xff, fb->size); memcpy(ptr, buf, fb->size); free(buf); /* if we don't change to the GTT domain again, the whites won't get flushed * and therefore we demonstrates the need for sync end here */ if (ioctl_sync) prime_sync_end(dma_buf_fd); /* check that the crc is as expected, which requires that caches got flushed */ igt_pipe_crc_collect_crc(data->pipe_crc, &crc); igt_assert_crc_equal(&crc, &data->ref_crc); }
static void test_plane_scaling(data_t *d) { igt_display_t *display = &d->display; igt_output_t *output; cairo_surface_t *image; enum pipe pipe; int valid_tests = 0; int primary_plane_scaling = 0; /* For now */ igt_require(d->display.has_universal_planes); igt_require(d->num_scalers); for_each_connected_output(display, output) { drmModeModeInfo *mode; pipe = output->config.pipe; igt_output_set_pipe(output, pipe); mode = igt_output_get_mode(output); /* allocate fb2 with image size */ image = cairo_image_surface_create_from_png(FILE_NAME); igt_assert(cairo_surface_status(image) == CAIRO_STATUS_SUCCESS); d->image_w = cairo_image_surface_get_width(image); d->image_h = cairo_image_surface_get_height(image); cairo_surface_destroy(image); d->fb_id2 = igt_create_fb(d->drm_fd, d->image_w, d->image_h, DRM_FORMAT_XRGB8888, LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */ &d->fb2); igt_assert(d->fb_id2); paint_image(d, &d->fb2, d->fb2.width, d->fb2.height); d->fb_id3 = igt_create_fb(d->drm_fd, mode->hdisplay, mode->vdisplay, DRM_FORMAT_XRGB8888, LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */ &d->fb3); igt_assert(d->fb_id3); paint_color(d, &d->fb3, mode->hdisplay, mode->vdisplay); /* Set up display with plane 1 */ d->plane1 = igt_output_get_plane(output, IGT_PLANE_PRIMARY); prepare_crtc(d, output, pipe, d->plane1, mode, COMMIT_UNIVERSAL); if (primary_plane_scaling) { /* Primary plane upscaling */ igt_fb_set_position(&d->fb1, d->plane1, 100, 100); igt_fb_set_size(&d->fb1, d->plane1, 500, 500); igt_plane_set_position(d->plane1, 0, 0); igt_plane_set_size(d->plane1, mode->hdisplay, mode->vdisplay); igt_display_commit2(display, COMMIT_UNIVERSAL); /* Primary plane 1:1 no scaling */ igt_fb_set_position(&d->fb1, d->plane1, 0, 0); igt_fb_set_size(&d->fb1, d->plane1, d->fb1.width, d->fb1.height); igt_plane_set_position(d->plane1, 0, 0); igt_plane_set_size(d->plane1, mode->hdisplay, mode->vdisplay); igt_display_commit2(display, COMMIT_UNIVERSAL); } /* Set up fb2->plane2 mapping. */ d->plane2 = igt_output_get_plane(output, IGT_PLANE_2); igt_plane_set_fb(d->plane2, &d->fb2); /* 2nd plane windowed */ igt_fb_set_position(&d->fb2, d->plane2, 100, 100); igt_fb_set_size(&d->fb2, d->plane2, d->fb2.width-200, d->fb2.height-200); igt_plane_set_position(d->plane2, 100, 100); igt_plane_set_size(d->plane2, mode->hdisplay-200, mode->vdisplay-200); igt_display_commit2(display, COMMIT_UNIVERSAL); iterate_plane_scaling(d, mode); /* 2nd plane up scaling */ igt_fb_set_position(&d->fb2, d->plane2, 100, 100); igt_fb_set_size(&d->fb2, d->plane2, 500, 500); igt_plane_set_position(d->plane2, 10, 10); igt_plane_set_size(d->plane2, mode->hdisplay-20, mode->vdisplay-20); igt_display_commit2(display, COMMIT_UNIVERSAL); /* 2nd plane downscaling */ igt_fb_set_position(&d->fb2, d->plane2, 0, 0); igt_fb_set_size(&d->fb2, d->plane2, d->fb2.width, d->fb2.height); igt_plane_set_position(d->plane2, 10, 10); igt_plane_set_size(d->plane2, 500, 500 * d->fb2.height/d->fb2.width); igt_display_commit2(display, COMMIT_UNIVERSAL); if (primary_plane_scaling) { /* Primary plane up scaling */ igt_fb_set_position(&d->fb1, d->plane1, 100, 100); igt_fb_set_size(&d->fb1, d->plane1, 500, 500); igt_plane_set_position(d->plane1, 0, 0); igt_plane_set_size(d->plane1, mode->hdisplay, mode->vdisplay); igt_display_commit2(display, COMMIT_UNIVERSAL); } /* Set up fb3->plane3 mapping. */ d->plane3 = igt_output_get_plane(output, IGT_PLANE_3); igt_plane_set_fb(d->plane3, &d->fb3); /* 3rd plane windowed - no scaling */ igt_fb_set_position(&d->fb3, d->plane3, 100, 100); igt_fb_set_size(&d->fb3, d->plane3, d->fb3.width-300, d->fb3.height-300); igt_plane_set_position(d->plane3, 100, 100); igt_plane_set_size(d->plane3, mode->hdisplay-300, mode->vdisplay-300); igt_display_commit2(display, COMMIT_UNIVERSAL); /* Switch scaler from plane 2 to plane 3 */ igt_fb_set_position(&d->fb2, d->plane2, 100, 100); igt_fb_set_size(&d->fb2, d->plane2, d->fb2.width-200, d->fb2.height-200); igt_plane_set_position(d->plane2, 100, 100); igt_plane_set_size(d->plane2, d->fb2.width-200, d->fb2.height-200); igt_fb_set_position(&d->fb3, d->plane3, 100, 100); igt_fb_set_size(&d->fb3, d->plane3, d->fb3.width-400, d->fb3.height-400); igt_plane_set_position(d->plane3, 10, 10); igt_plane_set_size(d->plane3, mode->hdisplay-300, mode->vdisplay-300); igt_display_commit2(display, COMMIT_UNIVERSAL); if (primary_plane_scaling) { /* Switch scaler from plane 1 to plane 2 */ igt_fb_set_position(&d->fb1, d->plane1, 0, 0); igt_fb_set_size(&d->fb1, d->plane1, d->fb1.width, d->fb1.height); igt_plane_set_position(d->plane1, 0, 0); igt_plane_set_size(d->plane1, mode->hdisplay, mode->vdisplay); igt_fb_set_position(&d->fb2, d->plane2, 100, 100); igt_fb_set_size(&d->fb2, d->plane2, d->fb2.width-500,d->fb2.height-500); igt_plane_set_position(d->plane2, 100, 100); igt_plane_set_size(d->plane2, mode->hdisplay-200, mode->vdisplay-200); igt_display_commit2(display, COMMIT_UNIVERSAL); } /* back to single plane mode */ igt_plane_set_fb(d->plane2, NULL); igt_plane_set_fb(d->plane3, NULL); igt_display_commit2(display, COMMIT_UNIVERSAL); valid_tests++; cleanup_crtc(d, output, d->plane1); }