예제 #1
0
static void test_plane_scaling(data_t *d)
{
    igt_display_t *display = &d->display;
    igt_output_t *output;
    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 */
        d->fb_id2 = igt_create_image_fb(d->drm_fd, 0, 0,
                                        DRM_FORMAT_XRGB8888,
                                        LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */
                                        FILE_NAME, &d->fb2);
        igt_assert(d->fb_id2);

        d->fb_id3 = igt_create_pattern_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);

        /* 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);
    }
예제 #2
0
static int
test_read_crc_for_output(data_t *data, int pipe, igt_output_t *output,
			 unsigned flags)
{
	igt_display_t *display = &data->display;
	igt_plane_t *primary;
	drmModeModeInfo *mode;
	igt_pipe_crc_t *pipe_crc;
	igt_crc_t *crcs = NULL;
	int c, j;

	for (c = 0; c < ARRAY_SIZE(colors); c++) {
		char *crc_str;

		igt_output_set_pipe(output, pipe);
		igt_display_commit(display);

		if (!output->valid) {
			igt_output_set_pipe(output, PIPE_ANY);
			return 0;
		}

		igt_debug("Clearing the fb with color (%.02lf,%.02lf,%.02lf)\n",
			  colors[c].r, colors[c].g, colors[c].b);

		mode = igt_output_get_mode(output);
		igt_create_color_fb(data->drm_fd,
					mode->hdisplay, mode->vdisplay,
					DRM_FORMAT_XRGB8888,
					LOCAL_DRM_FORMAT_MOD_NONE,
					colors[c].r,
					colors[c].g,
					colors[c].b,
					&data->fb);

		primary = igt_output_get_plane(output, 0);
		igt_plane_set_fb(primary, &data->fb);

		igt_display_commit(display);

		pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO);

		igt_pipe_crc_start(pipe_crc);

		/* wait for N_CRCS vblanks and the corresponding N_CRCS CRCs */
		igt_pipe_crc_get_crcs(pipe_crc, N_CRCS, &crcs);

		igt_pipe_crc_stop(pipe_crc);

		/*
		 * save the CRC in colors so it can be compared to the CRC of
		 * other fbs
		 */
		colors[c].crc = crcs[0];

		crc_str = igt_crc_to_string(&crcs[0]);
		igt_debug("CRC for this fb: %s\n", crc_str);
		free(crc_str);

		/* and ensure that they'are all equal, we haven't changed the fb */
		for (j = 0; j < (N_CRCS - 1); j++)
			igt_assert_crc_equal(&crcs[j], &crcs[j + 1]);

		if (flags & TEST_SEQUENCE)
			for (j = 0; j < (N_CRCS - 1); j++)
				igt_assert(crcs[j].frame + 1 == crcs[j + 1].frame);

		free(crcs);
		igt_pipe_crc_free(pipe_crc);
		igt_remove_fb(data->drm_fd, &data->fb);
		igt_plane_set_fb(primary, NULL);

		igt_output_set_pipe(output, PIPE_ANY);
	}

	return 1;
}