From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hai Lan Subject: [PATCH] intel-gpu-tools:testdisplay: add gamma test Date: Wed, 13 Jul 2011 17:32:00 -0400 Message-ID: <1310592720-3760-1-git-send-email-hai.lan@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: 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) List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org 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 */ -- 1.7.3.4