From patchwork Wed Jul 13 21:32:00 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: 972422 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6DEqjcY027906 for ; Wed, 13 Jul 2011 14:53:11 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 273519F0E6 for ; Wed, 13 Jul 2011 07:52:45 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id A43E79E9A6 for ; Wed, 13 Jul 2011 07:03:01 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 13 Jul 2011 01:40:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.65,524,1304319600"; d="scan'208";a="29767729" Received: from unknown (HELO lanhai-test.sh.intel.com) ([10.239.36.69]) by fmsmga001.fm.intel.com with ESMTP; 13 Jul 2011 01:40:20 -0700 From: Hai Lan To: intel-gfx@lists.freedesktop.org Date: Wed, 13 Jul 2011 17:32:00 -0400 Message-Id: <1310592720-3760-1-git-send-email-hai.lan@intel.com> X-Mailer: git-send-email 1.7.3.4 Subject: [Intel-gfx] [PATCH] intel-gpu-tools:testdisplay: add gamma test 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 (demeter2.kernel.org [140.211.167.43]); Wed, 13 Jul 2011 14:53:11 +0000 (UTC) Signed-off-by: Hai Lan --- tests/testdisplay.c | 50 ++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 44 insertions(+), 6 deletions(-) diff --git a/tests/testdisplay.c b/tests/testdisplay.c index e8e3309..9ea4e7f 100644 --- a/tests/testdisplay.c +++ b/tests/testdisplay.c @@ -62,6 +62,7 @@ #include #include #include +#include #include "xf86drm.h" #include "xf86drmMode.h" @@ -75,7 +76,7 @@ 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, - test_plane, enable_tiling; + test_plane, enable_tiling, test_gamma=0; int sleep_between_modes = 5; uint32_t depth = 24; @@ -88,6 +89,13 @@ int force_vdisplay; int force_vsync_start; int force_vsync_end; int force_vtotal; +uint16_t red[256], green[256], blue[256]; +float gamma_red, gamma_green, gamma_blue; + +static inline double dmin (double x, double y) +{ + return x < y ? x : y; +} #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) @@ -237,7 +245,6 @@ static void dump_crtcs(void) crtc->x, crtc->y, crtc->width, crtc->height); dump_mode(&crtc->mode); - drmModeFreeCrtc(crtc); } printf("\n"); @@ -784,7 +791,6 @@ set_mode(struct connector *c) char buf[128]; int j, test_mode_num; uint32_t bpp = 32; - if (depth <= 8) bpp = 8; else if (depth > 8 && depth <= 16) @@ -881,7 +887,33 @@ set_mode(struct connector *c) strerror(errno)); continue; } - + if (test_gamma) { + int size = 256; + float brightness = 1.0; + for (int i = 0; i < size; i++) { + if (gamma_red == 1.0 && brightness == 1.0) + red[i] = (i << 8) + i; + else + red[i] = dmin(pow((double)i/(double)(size - 1), + gamma_red) * brightness, + 1.0) * 65535.0; + + if (gamma_green == 1.0 && brightness == 1.0) + green[i] = (i << 8) + i; + else + green[i] = dmin(pow((double)i/(double)(size - 1), + gamma_green) * brightness, + 1.0) * 65535.0; + + if (gamma_blue == 1.0 && brightness == 1.0) + blue[i] = (i << 8) + i; + else + blue[i] = dmin(pow((double)i/(double)(size - 1), + gamma_blue) * brightness, + 1.0) * 65535.0; + } + drmModeCrtcSetGamma(fd, c->crtc, 256, red, green, blue); + } if (test_plane) enable_plane(c); @@ -939,11 +971,11 @@ static void update_display(void) extern char *optarg; extern int optind, opterr, optopt; -static char optstr[] = "hiaf:s:d:pt"; +static char optstr[] = "hiaf:s:d:ptg:s"; static void usage(char *name) { - fprintf(stderr, "usage: %s [-hiafs]\n", name); + fprintf(stderr, "usage: %s [-hiafsgpt]\n", name); fprintf(stderr, "\t-i\tdump info\n"); fprintf(stderr, "\t-a\ttest all modes\n"); fprintf(stderr, "\t-s\t\tsleep between each mode test\n"); @@ -953,6 +985,7 @@ static void usage(char *name) fprintf(stderr, "\t-f\t,,,,,\n"); fprintf(stderr, "\t\t,,,\n"); fprintf(stderr, "\t\ttest force mode\n"); + fprintf(stderr, "\t-g\t,, test gamma\n"); fprintf(stderr, "\tDefault is to test the preferred mode.\n"); exit(0); } @@ -1039,6 +1072,11 @@ int main(int argc, char **argv) case 't': enable_tiling = 1; break; + case 'g': + test_gamma = 1; + if(sscanf(optarg,"%f,%f,%f",&gamma_red,&gamma_green,&gamma_blue)!= 3) + usage(argv[0]); + break; default: fprintf(stderr, "unknown option %c\n", c); /* fall through */