static void cleanup_crtc(data_t *data, igt_output_t *output, igt_plane_t *plane) { igt_display_t *display = &data->display; igt_pipe_crc_free(data->pipe_crc); data->pipe_crc = NULL; if (data->fb_id1) { igt_remove_fb(data->drm_fd, &data->fb1); data->fb_id1 = 0; } if (data->fb_id2) { igt_remove_fb(data->drm_fd, &data->fb2); data->fb_id2 = 0; } if (data->fb_id3) { igt_remove_fb(data->drm_fd, &data->fb3); data->fb_id3 = 0; } if (!plane->is_primary) { igt_plane_t *primary; primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY); igt_plane_set_fb(primary, NULL); } igt_plane_set_fb(plane, NULL); igt_output_set_pipe(output, PIPE_ANY); igt_display_commit2(display, COMMIT_UNIVERSAL); }
static void cleanup_crtc(data_t *data, igt_output_t *output, igt_plane_t *plane) { igt_display_t *display = &data->display; igt_pipe_crc_free(data->pipe_crc); data->pipe_crc = NULL; igt_remove_fb(data->gfx_fd, &data->fb); igt_remove_fb(data->gfx_fd, &data->fb_modeset); if (data->fb_flip.fb_id) igt_remove_fb(data->gfx_fd, &data->fb_flip); /* XXX: see the note in prepare_crtc() */ if (!plane->is_primary) { igt_plane_t *primary; primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY); igt_plane_set_fb(primary, NULL); } igt_plane_set_fb(plane, NULL); igt_output_set_pipe(output, PIPE_ANY); igt_display_commit(display); }
static void cleanup_crtc(data_t *data) { igt_display_t *display = &data->display; igt_output_t *output = data->output; igt_pipe_crc_free(data->pipe_crc); data->pipe_crc = NULL; igt_plane_set_fb(data->primary, NULL); igt_output_set_pipe(output, PIPE_ANY); igt_display_commit(display); igt_remove_fb(data->drm_fd, &data->fb[0]); igt_remove_fb(data->drm_fd, &data->fb[1]); }
static bool test(data_t *data, enum pipe pipe, igt_output_t *output) { igt_plane_t *primary; drmModeModeInfo *mode; struct igt_fb fb[2]; int fd, ret; /* select the pipe we want to use */ igt_output_set_pipe(output, pipe); igt_display_commit(&data->display); if (!output->valid) { igt_output_set_pipe(output, PIPE_ANY); igt_display_commit(&data->display); return false; } primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY); mode = igt_output_get_mode(output); igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, DRM_FORMAT_XRGB8888, LOCAL_I915_FORMAT_MOD_X_TILED, 0.0, 0.0, 0.0, &fb[0]); igt_plane_set_fb(primary, &fb[0]); igt_display_commit2(&data->display, COMMIT_LEGACY); fd = drm_open_driver(DRIVER_INTEL); ret = drmDropMaster(data->drm_fd); igt_assert_eq(ret, 0); ret = drmSetMaster(fd); igt_assert_eq(ret, 0); igt_create_color_fb(fd, mode->hdisplay, mode->vdisplay, DRM_FORMAT_XRGB8888, LOCAL_I915_FORMAT_MOD_X_TILED, 0.0, 0.0, 0.0, &fb[1]); ret = drmModePageFlip(fd, output->config.crtc->crtc_id, fb[1].fb_id, DRM_MODE_PAGE_FLIP_EVENT, data); igt_assert_eq(ret, 0); ret = close(fd); igt_assert_eq(ret, 0); ret = drmSetMaster(data->drm_fd); igt_assert_eq(ret, 0); igt_plane_set_fb(primary, NULL); igt_output_set_pipe(output, PIPE_ANY); igt_display_commit(&data->display); igt_remove_fb(data->drm_fd, &fb[0]); return true; }
static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe, igt_plane_t *plane, drmModeModeInfo *mode, enum igt_commit_style s) { igt_display_t *display = &data->display; 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); /* before allocating, free if any older fb */ if (data->fb_id1) { igt_remove_fb(data->drm_fd, &data->fb1); data->fb_id1 = 0; } /* allocate fb for plane 1 */ data->fb_id1 = igt_create_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, DRM_FORMAT_XRGB8888, LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */ &data->fb1); igt_assert(data->fb_id1); paint_color(data, &data->fb1, mode->hdisplay, mode->vdisplay); /* * We always set the primary plane to actually enable the pipe as * there's no way (that works) to light up a pipe with only a sprite * plane enabled at the moment. */ if (!plane->is_primary) { igt_plane_t *primary; primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY); igt_plane_set_fb(primary, &data->fb1); } igt_plane_set_fb(plane, &data->fb1); if (s == COMMIT_LEGACY) { int ret; ret = drmModeSetCrtc(data->drm_fd, output->config.crtc->crtc_id, data->fb_id1, plane->pan_x, plane->pan_y, &output->id, 1, mode); igt_assert_eq(ret, 0); } else { igt_display_commit2(display, s); } }
static void cleanup_crtc(data_t *data, igt_output_t *output) { igt_display_t *display = &data->display; igt_plane_t *primary; igt_pipe_crc_free(data->pipe_crc); data->pipe_crc = NULL; igt_remove_fb(data->drm_fd, &data->primary_fb); primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY); igt_plane_set_fb(primary, NULL); igt_output_set_pipe(output, PIPE_ANY); igt_display_commit(display); }
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; int n_crcs; 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); if (flags & TEST_NONBLOCK) pipe_crc = igt_pipe_crc_new_nonblock(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); else 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 */ if (flags & TEST_NONBLOCK) { int i; for (i = 0; i < N_CRCS; i++) igt_wait_for_vblank(data->drm_fd, pipe); n_crcs = igt_pipe_crc_get_crcs(pipe_crc, N_CRCS * 3, &crcs); /* allow a one frame difference */ igt_assert_lte(n_crcs, N_CRCS + 1); igt_assert_lte(N_CRCS, n_crcs + 1); } else { n_crcs = igt_pipe_crc_get_crcs(pipe_crc, N_CRCS, &crcs); igt_assert_eq(n_crcs, N_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_eq(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; }
static int test_format(const char *test_name, struct kmstest_connector_config *cconf, drmModeModeInfo *mode, uint32_t format, enum test_flags flags) { int width; int height; struct igt_fb fb[2]; char *mode_format_str; char *cconf_str; int ret; ret = asprintf(&mode_format_str, "%s @ %dHz / %s", mode->name, mode->vrefresh, igt_format_str(format)); igt_assert_lt(0, ret); ret = asprintf(&cconf_str, "pipe %s, encoder %s, connector %s", kmstest_pipe_name(cconf->pipe), kmstest_encoder_type_str(cconf->encoder->encoder_type), kmstest_connector_type_str(cconf->connector->connector_type)); igt_assert_lt(0, ret); igt_info("Beginning test %s with %s on %s\n", test_name, mode_format_str, cconf_str); width = mode->hdisplay; height = mode->vdisplay; if (!igt_create_fb(drm_fd, width, height, format, LOCAL_DRM_FORMAT_MOD_NONE, &fb[0])) goto err1; if (!igt_create_fb(drm_fd, width, height, format, LOCAL_DRM_FORMAT_MOD_NONE, &fb[1])) goto err2; if (drmModeSetCrtc(drm_fd, cconf->crtc->crtc_id, fb[0].fb_id, 0, 0, &cconf->connector->connector_id, 1, mode)) goto err2; do_or_die(drmModePageFlip(drm_fd, cconf->crtc->crtc_id, fb[0].fb_id, 0, NULL)); sleep(2); if (flags & TEST_DIRECT_RENDER) { paint_fb(&fb[0], test_name, mode_format_str, cconf_str); } else if (flags & TEST_GPU_BLIT) { paint_fb(&fb[1], test_name, mode_format_str, cconf_str); gpu_blit(&fb[0], &fb[1]); } sleep(5); igt_info("Test %s with %s on %s: PASSED\n", test_name, mode_format_str, cconf_str); free(mode_format_str); free(cconf_str); igt_remove_fb(drm_fd, &fb[1]); igt_remove_fb(drm_fd, &fb[0]); return 0; err2: igt_remove_fb(drm_fd, &fb[0]); err1: igt_info("Test %s with %s on %s: SKIPPED\n", test_name, mode_format_str, cconf_str); free(mode_format_str); free(cconf_str); return -1; }
static void teardown_modeset(void) { igt_remove_fb(drm.fd, &fbs[0]); igt_remove_fb(drm.fd, &fbs[1]); igt_remove_fb(drm.fd, &cursor); }
static void set_mode(struct connector *c) { unsigned int fb_id = 0; struct igt_fb fb_info[2] = { }; int j, test_mode_num, current_fb = 0, old_fb = -1; test_mode_num = 1; if (force_mode){ memcpy( &c->mode, &force_timing, sizeof(force_timing)); c->mode.vrefresh =(force_timing.clock*1e3)/(force_timing.htotal*force_timing.vtotal); c->mode_valid = 1; sprintf(c->mode.name, "%dx%d", force_timing.hdisplay, force_timing.vdisplay); } else if (test_all_modes) test_mode_num = c->connector->count_modes; for (j = 0; j < test_mode_num; j++) { if (test_all_modes) c->mode = c->connector->modes[j]; /* set_mode() only tests 2D modes */ if (c->mode.flags & DRM_MODE_FLAG_3D_MASK) continue; if (!c->mode_valid) continue; width = c->mode.hdisplay; height = c->mode.vdisplay; fb_id = igt_create_pattern_fb(drm_fd, width, height, igt_bpp_depth_to_drm_format(bpp, depth), tiling, &fb_info[current_fb]); paint_output_info(c, &fb_info[current_fb]); paint_color_key(&fb_info[current_fb]); igt_info("CRTC(%u):[%d]", c->crtc, j); kmstest_dump_mode(&c->mode); if (drmModeSetCrtc(drm_fd, c->crtc, fb_id, 0, 0, &c->id, 1, &c->mode)) { igt_warn("failed to set mode (%dx%d@%dHz): %s\n", width, height, c->mode.vrefresh, strerror(errno)); igt_remove_fb(drm_fd, &fb_info[current_fb]); continue; } if (old_fb != -1) igt_remove_fb(drm_fd, &fb_info[old_fb]); old_fb = current_fb; current_fb = 1 - current_fb; if (sleep_between_modes && test_all_modes && !qr_code) sleep(sleep_between_modes); if (do_dpms) { kmstest_set_connector_dpms(drm_fd, c->connector, do_dpms); sleep(sleep_between_modes); kmstest_set_connector_dpms(drm_fd, c->connector, DRM_MODE_DPMS_ON); } if (qr_code){ set_single(); pause(); } } if (test_all_modes && old_fb != -1) igt_remove_fb(drm_fd, &fb_info[old_fb]); drmModeFreeEncoder(c->encoder); drmModeFreeConnector(c->connector); }