Module Name: src Committed By: macallan Date: Tue Oct 12 16:18:20 UTC 2010
Modified Files: src/sys/dev/videomode: pickmode.c Log Message: fix off-by-one error which happened when the first mode with matching size is also the best match by refresh rate To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/videomode/pickmode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/videomode/pickmode.c diff -u src/sys/dev/videomode/pickmode.c:1.1 src/sys/dev/videomode/pickmode.c:1.2 --- src/sys/dev/videomode/pickmode.c:1.1 Tue May 4 21:17:10 2010 +++ src/sys/dev/videomode/pickmode.c Tue Oct 12 16:18:19 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pickmode.c,v 1.1 2010/05/04 21:17:10 macallan Exp $ */ +/* $NetBSD: pickmode.c,v 1.2 2010/10/12 16:18:19 macallan Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pickmode.c,v 1.1 2010/05/04 21:17:10 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pickmode.c,v 1.2 2010/10/12 16:18:19 macallan Exp $"); #include <sys/param.h> #include <dev/videomode/videomode.h> @@ -81,9 +81,9 @@ this = &videomode_list[i]; mref = this->dot_clock * 1000 / (this->htotal * this->vtotal); diff = abs(mref - refresh); - if ((this->hdisplay != width) || (this->vdisplay != height) || - (diff > closest)) + if ((this->hdisplay != width) || (this->vdisplay != height)) continue; + DPRINTF("%s in %d hz, diff %d\n", this->name, mref, diff); if (best != NULL) { if (diff < closest) { @@ -91,11 +91,13 @@ best = this; closest = diff; } - } else + } else { best = this; + closest = diff; + } } if (best!= NULL) - DPRINTF("found %s\n", best->name); + DPRINTF("found %s %d\n", best->name, best->dot_clock); return best; }