From patchwork Fri Feb 11 16:14:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hai.lan@intel.com X-Patchwork-Id: 548731 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1B3JgnE008521 for ; Fri, 11 Feb 2011 03:20:08 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B855D9EB29 for ; Thu, 10 Feb 2011 19:19:41 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by gabe.freedesktop.org (Postfix) with ESMTP id D6BD49E778 for ; Thu, 10 Feb 2011 19:19:17 -0800 (PST) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 10 Feb 2011 19:19:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.60,453,1291622400"; d="scan'208";a="387230932" Received: from unknown (HELO lanhai-test.sh.intel.com) ([10.239.36.69]) by azsmga001.ch.intel.com with ESMTP; 10 Feb 2011 19:19:16 -0800 From: hai.lan@intel.com To: intel-gfx@lists.freedesktop.org Date: Fri, 11 Feb 2011 11:14:15 -0500 Message-Id: <1297440855-18493-1-git-send-email-hai.lan@intel.com> X-Mailer: git-send-email 1.7.3.4 Subject: [Intel-gfx] [PATCH] Add a test case into intel-gpu-tools for intel display driver validation. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 11 Feb 2011 03:20:12 +0000 (UTC) diff --git a/tests/testdisplay.c b/tests/testdisplay.c index fe9ef36..1e2810a 100644 --- a/tests/testdisplay.c +++ b/tests/testdisplay.c @@ -69,6 +69,17 @@ struct udev_monitor *uevent_monitor; drmModeRes *resources; int fd, modes; +int dump_info = 0, test_all_modes=0, test_preferred_mode= 0, force_mode = 0; + +float force_clock; +int force_hdisplay; +int force_hsync_start; +int force_hsync_end; +int force_htotal; +int force_vdisplay; +int force_vsync_start; +int force_vsync_end; +int force_vtotal; #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) @@ -141,6 +152,86 @@ struct connector { int crtc; }; +static void dump_mode(drmModeModeInfo *mode) +{ + printf(" %s %.01f %d %d %d %d %d %d %d %d\n", + mode->name, + (float)mode->vrefresh, + mode->hdisplay, + mode->hsync_start, + mode->hsync_end, + mode->htotal, + mode->vdisplay, + mode->vsync_start, + mode->vsync_end, + mode->vtotal); +} + +static void dump_connectors(void) +{ + drmModeConnector *connector; + int i, j; + + printf("Connectors:\n"); + printf("id\tencoder\tstatus\t\ttype\tsize (mm)\tmodes\n"); + for (i = 0; i < resources->count_connectors; i++) { + connector = drmModeGetConnector(fd, resources->connectors[i]); + + if (!connector) { + fprintf(stderr, "could not get connector %i: %s\n", + resources->connectors[i], strerror(errno)); + continue; + } + + printf("%d\t%d\t%s\t%s\t%dx%d\t\t%d\n", + connector->connector_id, + connector->encoder_id, + connector_status_str(connector->connection), + connector_type_str(connector->connector_type), + connector->mmWidth, connector->mmHeight, + connector->count_modes); + + if (!connector->count_modes) + continue; + + printf(" modes:\n"); + printf(" name refresh (Hz) hdisp hss hse htot vdisp " + "vss vse vtot)\n"); + for (j = 0; j < connector->count_modes; j++) + dump_mode(&connector->modes[j]); + + drmModeFreeConnector(connector); + } + printf("\n"); +} + +static void dump_crtcs(void) +{ + drmModeCrtc *crtc; + int i; + + printf("CRTCs:\n"); + printf("id\tfb\tpos\tsize\n"); + for (i = 0; i < resources->count_crtcs; i++) { + crtc = drmModeGetCrtc(fd, resources->crtcs[i]); + + if (!crtc) { + fprintf(stderr, "could not get crtc %i: %s\n", + resources->crtcs[i], strerror(errno)); + continue; + } + printf("%d\t%d\t(%d,%d)\t(%dx%d)\n", + crtc->crtc_id, + crtc->buffer_id, + crtc->x, crtc->y, + crtc->width, crtc->height); + dump_mode(&crtc->mode); + + drmModeFreeCrtc(crtc); + } + printf("\n"); +} + static void connector_find_preferred_mode(struct connector *c) { drmModeConnector *connector; @@ -420,16 +511,40 @@ set_mode(struct connector *c) cairo_surface_t *surface; cairo_t *cr; char buf[128]; + int j, test_mode_num; width = 0; height = 0; connector_find_preferred_mode(c); if (!c->mode_valid) return; - + if (test_preferred_mode|| force_mode) + test_mode_num = 1; + 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]; + width = 0; + height = 0; width += c->mode.hdisplay; if (height < c->mode.vdisplay) height = c->mode.vdisplay; + if (force_mode){ + width = force_hdisplay; + height = force_vdisplay; + c->mode.clock = force_clock*1000; + c->mode.hdisplay = force_hdisplay; + c->mode.hsync_start = force_hsync_start; + c->mode.hsync_end = force_hsync_end; + c->mode.htotal = force_htotal; + c->mode.vdisplay = force_vdisplay; + c->mode.vsync_start = force_vsync_start; + c->mode.vsync_end = force_vsync_end; + c->mode.vtotal = force_vtotal; + c->mode.vrefresh =(force_clock*1e6)/(force_htotal*force_vtotal); + sprintf(c->mode.name,"%d%s%d",width,"x",height); + } bufmgr = drm_intel_bufmgr_gem_init(fd, 2<<20); if (!bufmgr) { @@ -468,6 +583,7 @@ set_mode(struct connector *c) ret = drmModeAddFB(fd, width, height, 32, 32, stride, bo->handle, &fb_id); if (ret) { + printf("drmModeAddFB:width =%d,height=%d\n",width,height); fprintf(stderr, "failed to add fb: %s\n", strerror(errno)); return; } @@ -475,6 +591,7 @@ set_mode(struct connector *c) if (!c->mode_valid) return; + dump_mode(&c->mode); ret = drmModeSetCrtc(fd, c->crtc, fb_id, 0, 0, &c->id, 1, &c->mode); @@ -482,7 +599,9 @@ set_mode(struct connector *c) fprintf(stderr, "failed to set mode: %s\n", strerror(errno)); return; } - + if (test_all_modes) + sleep(5); +} drmModeFreeEncoder(c->encoder); drmModeFreeConnector(c->connector); } @@ -513,24 +632,40 @@ static void update_display(void) if (!connectors) return; - /* Find any connected displays */ - for (c = 0; c < resources->count_connectors; c++) { - connectors[c].id = resources->connectors[c]; - set_mode(&connectors[c]); + if (dump_info) { + dump_connectors(); + dump_crtcs(); + } + if (test_preferred_mode || test_all_modes || force_mode) { + /* Find any connected displays */ + for (c = 0; c < resources->count_connectors; c++) { + connectors[c].id = resources->connectors[c]; + set_mode(&connectors[c]); + } } drmModeFreeResources(resources); + if (dump_info || test_all_modes) + exit(0); } extern char *optarg; extern int optind, opterr, optopt; -static char optstr[] = "h"; +static char optstr[] = "hiaf:"; static void usage(char *name) { - fprintf(stderr, "usage: %s [-h]\n", name); + fprintf(stderr, "usage: %s [-hiaf:]\n", name); + fprintf(stderr, "\t-i\tdump info\n"); + fprintf(stderr, "\t-a\ttest all modes\n"); + fprintf(stderr, "\t-f\t,,,,,\n"); + fprintf(stderr, "\t\t,,,\n"); + fprintf(stderr, "\t\ttest force mode\n"); + fprintf(stderr, "\tDefault is to test the preferred mode.\n"); exit(0); } +#define dump_resource(res) if (res) dump_##res() + static gboolean hotplug_event(GIOChannel *source, GIOCondition condition, gpointer data) { @@ -590,6 +725,20 @@ int main(int argc, char **argv) opterr = 0; while ((c = getopt(argc, argv, optstr)) != -1) { switch (c) { + case 'i': + dump_info = 1; + encoders = connectors = crtcs = modes = framebuffers = 1; + break; + case 'a': + test_all_modes = 1; + break; + case 'f': + force_mode = 1; + if(sscanf(optarg,"%f,%d,%d,%d,%d,%d,%d,%d,%d", + &force_clock,&force_hdisplay, &force_hsync_start,&force_hsync_end,&force_htotal, + &force_vdisplay, &force_vsync_start, &force_vsync_end, &force_vtotal)!= 9) + usage(argv[0]); + break; default: fprintf(stderr, "unknown option %c\n", c); /* fall through */ @@ -598,9 +747,8 @@ int main(int argc, char **argv) break; } } - if (argc == 1) - encoders = connectors = crtcs = modes = framebuffers = 1; + test_preferred_mode = 1; for (i = 0; i < ARRAY_SIZE(modules); i++) { fd = drmOpen(modules[i], NULL);