summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYi Sun <yi.sun@intel.com>2015-03-04 15:53:39 +0800
committerYi Sun <yi.sun@intel.com>2015-03-04 15:53:39 +0800
commite34fcbe4be077930c91effc7e0ecafd9914e8c46 (patch)
tree96d803bed6229872ded6d5d404027e024c224cd8
parent5e4fc0c48c9a44689ec1593f356a8f22e1ca6bb8 (diff)
Crop testdisplay.
Signed-off-by: Yi Sun <yi.sun@intel.com>
-rw-r--r--tests/testdisplay.c372
1 files changed, 25 insertions, 347 deletions
diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index 68bb21fc..35a39f9c 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -63,7 +63,6 @@
#include <sys/types.h>
#include <sys/stat.h>
-#include "ioctl_wrappers.h"
#include "drmtest.h"
#include "testdisplay.h"
#include "igt_kms.h"
@@ -71,22 +70,17 @@
#include <stdlib.h>
#include <signal.h>
-#define SUBTEST_OPTS 1
-#define HELP_DESCRIPTION 2
static int tio_fd;
struct termios saved_tio;
drmModeRes *resources;
int drm_fd, modes;
-int test_all_modes = 0, test_preferred_mode = 0, force_mode = 0, test_plane,
- test_stereo_modes;
-unsigned int tiling = I915_TILING_NONE;
+int test_all_modes = 0, test_preferred_mode = 0;
+
+unsigned int tiling = I915_TILING_X; //tiling = I915_TILING_NONE;
int sleep_between_modes = 5;
-int do_dpms = 0; /* This aliases to DPMS_ON */
-uint32_t depth = 24, stride, bpp;
-int qr_code = 0;
-int specified_mode_num = -1, specified_disp_id = -1;
+uint32_t depth = 24, stride, bpp = 32;
drmModeModeInfo force_timing;
@@ -115,78 +109,6 @@ struct connector {
int pipe;
};
-static void dump_connectors_fd(int drmfd)
-{
- int i, j;
-
- drmModeRes *mode_resources = drmModeGetResources(drmfd);
-
- if (!mode_resources) {
- igt_warn("drmModeGetResources failed: %s\n", strerror(errno));
- return;
- }
-
- igt_info("Connectors:\n");
- igt_info("id\tencoder\tstatus\t\ttype\tsize (mm)\tmodes\n");
- for (i = 0; i < mode_resources->count_connectors; i++) {
- drmModeConnector *connector;
-
- connector = drmModeGetConnector(drmfd, mode_resources->connectors[i]);
- if (!connector) {
- igt_warn("could not get connector %i: %s\n", mode_resources->connectors[i], strerror(errno));
- continue;
- }
-
- igt_info("%d\t%d\t%s\t%s\t%dx%d\t\t%d\n", connector->connector_id, connector->encoder_id, kmstest_connector_status_str(connector->connection), kmstest_connector_type_str(connector->connector_type), connector->mmWidth, connector->mmHeight, connector->count_modes);
-
- if (!connector->count_modes)
- continue;
-
- igt_info(" modes:\n");
- igt_info(" name refresh (Hz) hdisp hss hse htot vdisp ""vss vse vtot flags type clock\n");
- for (j = 0; j < connector->count_modes; j++){
- igt_info("[%d]", j);
- kmstest_dump_mode(&connector->modes[j]);
- }
-
- drmModeFreeConnector(connector);
- }
- igt_info("\n");
-
- drmModeFreeResources(mode_resources);
-}
-
-static void dump_crtcs_fd(int drmfd)
-{
- int i;
- drmModeRes *mode_resources = drmModeGetResources(drmfd);
-
- igt_info("CRTCs:\n");
- igt_info("id\tfb\tpos\tsize\n");
- for (i = 0; i < mode_resources->count_crtcs; i++) {
- drmModeCrtc *crtc;
-
- crtc = drmModeGetCrtc(drmfd, mode_resources->crtcs[i]);
- if (!crtc) {
- igt_warn("could not get crtc %i: %s\n", mode_resources->crtcs[i], strerror(errno));
- continue;
- }
- igt_info("%d\t%d\t(%d,%d)\t(%dx%d)\n", crtc->crtc_id, crtc->buffer_id, crtc->x, crtc->y, crtc->width, crtc->height);
- kmstest_dump_mode(&crtc->mode);
-
- drmModeFreeCrtc(crtc);
- }
- igt_info("\n");
-
- drmModeFreeResources(mode_resources);
-}
-
-static void dump_info(void)
-{
- dump_connectors_fd(drm_fd);
- dump_crtcs_fd(drm_fd);
-}
-
static void connector_find_preferred_mode(uint32_t connector_id,
unsigned long crtc_idx_mask,
int mode_num, struct connector *c)
@@ -214,27 +136,6 @@ static void connector_find_preferred_mode(uint32_t connector_id,
c->mode_valid = 1;
}
-static void
-paint_color_key(struct igt_fb *fb_info)
-{
- int i, j;
- uint32_t *fb_ptr;
-
- fb_ptr = gem_mmap(drm_fd, fb_info->gem_handle,
- fb_info->size, PROT_READ | PROT_WRITE);
- igt_assert(fb_ptr);
-
- for (i = crtc_y; i < crtc_y + crtc_h; i++)
- for (j = crtc_x; j < crtc_x + crtc_w; j++) {
- uint32_t offset;
-
- offset = (i * fb_info->stride / 4) + j;
- fb_ptr[offset] = SPRITE_COLOR_KEY;
- }
-
- munmap(fb_ptr, fb_info->size);
-}
-
static void paint_image(cairo_t *cr, const char *file)
{
int img_x, img_y, img_w, img_h, img_w_o, img_h_o;
@@ -276,45 +177,6 @@ static void paint_output_info(struct connector *c, struct igt_fb *fb)
double max_width;
int i;
- igt_paint_test_pattern(cr, l_width, l_height);
-
- cairo_move_to(cr, l_width / 2, l_height / 2);
-
- /* Print connector and mode name */
- cairo_set_font_size(cr, 48);
- igt_cairo_printf_line(cr, align_hcenter, 10, "%s",
- kmstest_connector_type_str(c->connector->connector_type));
-
- cairo_set_font_size(cr, 36);
- str_width = igt_cairo_printf_line(cr, align_hcenter, 10,
- "%s @ %dHz on %s encoder", c->mode.name, c->mode.vrefresh,
- kmstest_encoder_type_str(c->encoder->encoder_type));
-
- cairo_rel_move_to(cr, -str_width / 2, 0);
-
- /* List available modes */
- cairo_set_font_size(cr, 18);
- str_width = igt_cairo_printf_line(cr, align_left, 10,
- "Available modes:");
- cairo_rel_move_to(cr, str_width, 0);
- cairo_get_current_point(cr, &x, &top_y);
-
- max_width = 0;
- for (i = 0; i < c->connector->count_modes; i++) {
- cairo_get_current_point(cr, &x, &y);
- if (y >= l_height) {
- x += max_width + 10;
- max_width = 0;
- cairo_move_to(cr, x, top_y);
- }
- str_width = igt_cairo_printf_line(cr, align_right, 10,
- "%s @ %dHz", c->connector->modes[i].name,
- c->connector->modes[i].vrefresh);
- if (str_width > max_width)
- max_width = str_width;
- }
-
- if (qr_code)
paint_image(cr, IGT_DATADIR"/pass.png");
igt_assert(!cairo_status(cr));
@@ -322,23 +184,6 @@ static void paint_output_info(struct connector *c, struct igt_fb *fb)
cairo_destroy(cr);
}
-static void sighandler(int signo)
-{
- return;
-}
-
-static void set_single(void)
-{
- int sigs[] = { SIGUSR1 };
- struct sigaction sa;
- sa.sa_handler = sighandler;
-
- sigemptyset(&sa.sa_mask);
-
- igt_warn_on_f(sigaction(sigs[0], &sa, NULL) == -1,
- "Could not set signal handler");
-}
-
static void
set_mode(struct connector *c)
{
@@ -347,25 +192,10 @@ set_mode(struct connector *c)
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)
+ 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;
@@ -374,14 +204,11 @@ set_mode(struct connector *c)
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));
- continue;
}
if (old_fb != -1)
@@ -389,20 +216,9 @@ set_mode(struct connector *c)
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);
+ if (sleep_between_modes && test_all_modes)
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)
igt_remove_fb(drm_fd, &fb_info[old_fb]);
@@ -411,60 +227,6 @@ set_mode(struct connector *c)
drmModeFreeConnector(c->connector);
}
-static void do_set_stereo_mode(struct connector *c)
-{
- uint32_t fb_id;
-
- fb_id = igt_create_stereo_fb(drm_fd, &c->mode,
- igt_bpp_depth_to_drm_format(bpp, depth),
- tiling);
-
- igt_warn_on_f(drmModeSetCrtc(drm_fd, c->crtc, fb_id, 0, 0, &c->id, 1, &c->mode),
- "failed to set mode (%dx%d@%dHz): %s\n", width, height, c->mode.vrefresh, strerror(errno));
-}
-
-static void
-set_stereo_mode(struct connector *c)
-{
- int i, n;
-
-
- if (specified_mode_num != -1)
- n = 1;
- else
- n = c->connector->count_modes;
-
- for (i = 0; i < n; i++) {
- if (specified_mode_num == -1)
- c->mode = c->connector->modes[i];
-
- if (!c->mode_valid)
- continue;
-
- if (!(c->mode.flags & DRM_MODE_FLAG_3D_MASK))
- continue;
-
- igt_info("CRTC(%u): [%d]", c->crtc, i);
- kmstest_dump_mode(&c->mode);
- do_set_stereo_mode(c);
-
- if (qr_code) {
- set_single();
- pause();
- } else if (sleep_between_modes)
- sleep(sleep_between_modes);
-
- if (do_dpms) {
- kmstest_set_connector_dpms(drm_fd, c->connector, DRM_MODE_DPMS_OFF);
- sleep(sleep_between_modes);
- kmstest_set_connector_dpms(drm_fd, c->connector, DRM_MODE_DPMS_ON);
- }
- }
-
- drmModeFreeEncoder(c->encoder);
- drmModeFreeConnector(c->connector);
-}
-
/*
* Re-probe outputs and light up as many as possible.
*
@@ -490,8 +252,7 @@ int update_display(void)
if (!connectors)
return 0;
- if (test_preferred_mode || test_all_modes ||
- force_mode || specified_disp_id != -1) {
+ if (test_preferred_mode || test_all_modes ) {
unsigned long crtc_idx_mask = -1UL;
/* Find any connected displays */
@@ -499,46 +260,22 @@ int update_display(void)
struct connector *connector = &connectors[c];
connector->id = resources->connectors[c];
- if (specified_disp_id != -1 &&
- connector->id != specified_disp_id)
- continue;
connector_find_preferred_mode(connector->id,
crtc_idx_mask,
- specified_mode_num,
+ -1,
connector);
if (!connector->mode_valid)
continue;
set_mode(connector);
- if (test_preferred_mode || force_mode ||
- specified_mode_num != -1)
+ if (test_preferred_mode )
crtc_idx_mask &= ~(1 << connector->crtc_idx);
}
}
- if (test_stereo_modes) {
- for (c = 0; c < resources->count_connectors; c++) {
- struct connector *connector = &connectors[c];
-
- connector->id = resources->connectors[c];
- if (specified_disp_id != -1 &&
- connector->id != specified_disp_id)
- continue;
-
- connector_find_preferred_mode(connector->id,
- -1UL,
- specified_mode_num,
- connector);
- if (!connector->mode_valid)
- continue;
-
- set_stereo_mode(connector);
- }
- }
-
free(connectors);
drmModeFreeResources(resources);
return 1;
@@ -611,25 +348,25 @@ static void enter_exec_path( char **argv )
static void restore_termio_mode(int sig)
{
- tcsetattr(tio_fd, TCSANOW, &saved_tio);
- close(tio_fd);
+ tcsetattr(tio_fd, TCSANOW, &saved_tio);
+ close(tio_fd);
}
static void set_termio_mode(void)
{
- struct termios tio;
-
- /* don't attempt to set terminal attributes if not in the foreground
- * process group */
- if (getpgrp() != tcgetpgrp(STDOUT_FILENO))
- return;
-
- tio_fd = dup(STDIN_FILENO);
- tcgetattr(tio_fd, &saved_tio);
- igt_install_exit_handler(restore_termio_mode);
- tio = saved_tio;
- tio.c_lflag &= ~(ICANON | ECHO);
- tcsetattr(tio_fd, TCSANOW, &tio);
+ struct termios tio;
+
+ /* don't attempt to set terminal attributes if not in the foreground
+ * process group */
+ if (getpgrp() != tcgetpgrp(STDOUT_FILENO))
+ return;
+
+ tio_fd = dup(STDIN_FILENO);
+ tcgetattr(tio_fd, &saved_tio);
+ igt_install_exit_handler(restore_termio_mode);
+ tio = saved_tio;
+ tio.c_lflag &= ~(ICANON | ECHO);
+ tcsetattr(tio_fd, TCSANOW, &tio);
}
int main(int argc, char **argv)
@@ -639,11 +376,7 @@ int main(int argc, char **argv)
GIOChannel *stdinchannel;
GMainLoop *mainloop;
float force_clock;
- bool opt_dump_info = false;
struct option long_opts[] = {
- {"list-subtests", 0, 0, SUBTEST_OPTS},
- {"run-subtest", 1, 0, SUBTEST_OPTS},
- {"help-description", 0, 0, HELP_DESCRIPTION},
{"help", 0, 0, 'h'},
{ 0, 0, 0, 0 }
};
@@ -654,17 +387,10 @@ int main(int argc, char **argv)
while ((c = getopt_long(argc, argv, optstr, long_opts, NULL)) != -1) {
switch (c) {
- case '3':
- test_stereo_modes = 1;
- break;
- case 'i':
- opt_dump_info = true;
- break;
case 'a':
test_all_modes = 1;
break;
case 'f':
- force_mode = 1;
if(sscanf(optarg,"%f,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu",
&force_clock,&force_timing.hdisplay, &force_timing.hsync_start,&force_timing.hsync_end,&force_timing.htotal,
&force_timing.vdisplay, &force_timing.vsync_start, &force_timing.vsync_end, &force_timing.vtotal)!= 9)
@@ -675,42 +401,13 @@ int main(int argc, char **argv)
case 's':
sleep_between_modes = atoi(optarg);
break;
- case 'j':
- do_dpms = atoi(optarg);
- if (do_dpms == 0)
- do_dpms = DRM_MODE_DPMS_OFF;
- break;
case 'd':
depth = atoi(optarg);
igt_info("using depth %d\n", depth);
break;
- case 'p':
- if (sscanf(optarg, "%d,%d,%d,%d,%d,%d", &plane_width,
- &plane_height, &crtc_x, &crtc_y,
- &crtc_w, &crtc_h) != 6)
- usage(argv[0], c);
- test_plane = 1;
- break;
case 'm':
test_preferred_mode = 1;
break;
- case 't':
- tiling = I915_TILING_X;
- break;
- case 'r':
- qr_code = 1;
- break;
- case 'o':
- sscanf(optarg, "%d,%d", &specified_disp_id, &specified_mode_num);
- break;
- case SUBTEST_OPTS:
- /* invalid subtest options */
- exit(IGT_EXIT_INVALID);
- break;
- case HELP_DESCRIPTION:
- printf("Tests display functionality.");
- exit(0);
- break;
default:
/* fall through */
case 'h':
@@ -721,30 +418,11 @@ int main(int argc, char **argv)
set_termio_mode();
- if (depth <= 8)
- bpp = 8;
- else if (depth <= 16)
- bpp = 16;
- else if (depth <= 32)
- bpp = 32;
-
- if (!test_all_modes && !force_mode && !test_preferred_mode &&
- specified_mode_num == -1 && !test_stereo_modes)
+ if (!test_all_modes && !test_preferred_mode )
test_all_modes = 1;
drm_fd = drm_open_any();
- if (test_stereo_modes &&
- drmSetClientCap(drm_fd, DRM_CLIENT_CAP_STEREO_3D, 1) < 0) {
- igt_warn("DRM_CLIENT_CAP_STEREO_3D failed\n");
- goto out_close;
- }
-
- if (opt_dump_info) {
- dump_info();
- goto out_close;
- }
-
kmstest_set_vt_graphics_mode();
mainloop = g_main_loop_new(NULL, FALSE);