summaryrefslogtreecommitdiff
path: root/sys/dev/videomode
diff options
context:
space:
mode:
authormacallan <macallan@NetBSD.org>2010-10-12 16:18:19 +0000
committermacallan <macallan@NetBSD.org>2010-10-12 16:18:19 +0000
commitd199f85d708e8fd3cd89eb06376a06a06ab5457f (patch)
tree66fe50e033820665675a90ebc6fc501e45efed3d /sys/dev/videomode
parent598ca8db3ef3d7f2f7d3e57c6aa904b99785d31e (diff)
fix off-by-one error which happened when the first mode with matching size is
also the best match by refresh rate
Diffstat (limited to 'sys/dev/videomode')
-rw-r--r--sys/dev/videomode/pickmode.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/dev/videomode/pickmode.c b/sys/dev/videomode/pickmode.c
index 86cc10cb461..072bcc24790 100644
--- a/sys/dev/videomode/pickmode.c
+++ b/sys/dev/videomode/pickmode.c
@@ -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 @@ pick_mode_by_ref(int width, int height, int refresh)
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 @@ pick_mode_by_ref(int width, int height, int refresh)
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;
}