summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1996-02-26 21:08:04 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1996-02-26 21:08:04 +0000
commitb7f23c0788e0d61b57ce8e8dc76f060bb84a2dc7 (patch)
tree36a2b6a0274a1ac739be75950d9238dfb053e4f5
parentd0eb1fa63c2d07d454a083374a90eff2e6bfa869 (diff)
From NetBSD:
remove floating point expressions. gen_cvtab.c generates a conversion table to replace a specific floating point expression in grf_cv.c
-rw-r--r--sys/arch/amiga/dev/gen_cvtab.c66
-rw-r--r--sys/arch/amiga/dev/grf_cv.c38
-rw-r--r--sys/arch/amiga/dev/sfas.c10
3 files changed, 105 insertions, 9 deletions
diff --git a/sys/arch/amiga/dev/gen_cvtab.c b/sys/arch/amiga/dev/gen_cvtab.c
new file mode 100644
index 00000000000..a78f9e4c867
--- /dev/null
+++ b/sys/arch/amiga/dev/gen_cvtab.c
@@ -0,0 +1,66 @@
+/* $OpenBSD: gen_cvtab.c,v 1.1 1996/02/26 21:08:03 niklas Exp $ */
+/* $NetBSD: gen_cvtab.c,v 1.1 1996/02/24 20:13:00 chopps Exp $ */
+
+/*
+ * Copyright (c) 1996 Christian E. Hopps
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Christian E. Hopps.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/types.h>
+#include <stdio.h>
+
+/*
+ * generate a conversion table to replace the use of the
+ * floating point expression below in grf_cv.c
+ */
+int
+main(int argc, char** argv)
+{
+ u_long vals[31];
+ u_long clock;
+ int m = 33;
+ int lastm = -1;
+
+ for (clock = 0; clock < 1080 && m > 0; ++clock) {
+ m = ((55 * .72 + 16.867) * 89.736 / (clock + 39) - 21.1543);
+ m = m / 2 - 1;
+ if (m > 31)
+ continue;
+ if (m != lastm) {
+ vals[m] = clock;
+ lastm = m;
+ }
+ }
+ printf("/* generated by gen_cvtab */\n");
+ printf("static int cv_convtab[31] = {");
+ for (m = 0; m < 31; ++m) {
+ if (m % 5 == 0)
+ printf("\n");
+ printf("\t%ld,", vals[m]);
+ }
+ printf("\n};\n");
+}
diff --git a/sys/arch/amiga/dev/grf_cv.c b/sys/arch/amiga/dev/grf_cv.c
index 2e8e0a78057..ea2cf5f15ab 100644
--- a/sys/arch/amiga/dev/grf_cv.c
+++ b/sys/arch/amiga/dev/grf_cv.c
@@ -1,4 +1,5 @@
-/* $NetBSD: grf_cv.c,v 1.5 1995/12/27 07:15:53 chopps Exp $ */
+/* $OpenBSD: grf_cv.c,v 1.5 1996/02/26 21:08:00 niklas Exp $ */
+/* $NetBSD: grf_cv.c,v 1.6 1996/02/24 20:13:01 chopps Exp $ */
/*
* Copyright (c) 1995 Michael Teske
@@ -109,6 +110,16 @@ static struct grfvideo_mode monitor_def[8] = {
static struct grfvideo_mode *monitor_current = &monitor_def[0];
#define MAXPIXELCLOCK 135000000 /* safety */
+/* generated by gen_cvtab.c */
+static int cv_convtab[31] = {
+ 163, 148, 135, 124, 114,
+ 106, 98, 91, 85, 79,
+ 74, 69, 65, 61, 57,
+ 53, 50, 47, 44, 42,
+ 39, 37, 35, 33, 31,
+ 29, 27, 26, 24, 22,
+ 21,
+};
/* Console display definition.
* Default hardcoded text mode. This grf_cv is set up to
@@ -885,7 +896,7 @@ cv_load_mon(gp, md)
char LACE, DBLSCAN, TEXT;
int uplim, lowlim;
int cr33, sr15, sr18, clock_mode, test;
- int m, n, clock; /* For calc'ing display FIFO */
+ int m, n, clock, i; /* For calc'ing display FIFO */
/* identity */
gv = &md->gv;
@@ -1124,20 +1135,31 @@ cv_load_mon(gp, md)
n = 0xff;
if (gv->depth < 9)
- clock = gv->pixel_clock / 500000.0;
+ clock = gv->pixel_clock / 500000;
else if (gv->depth == 15)
- clock = gv->pixel_clock / 250000.0;
+ clock = gv->pixel_clock / 250000;
else
- clock = (gv->pixel_clock * (gv->depth / 8)) / 500000.0;
-
- m = ((int)((55 * .72 + 16.867) * 89.736 / (clock + 39) - 21.1543) / 2) - 1;
-
+ clock = (gv->pixel_clock * (gv->depth / 8)) / 500000;
+#if 0
+ /*
+ * Note: if you change this you should change it in
+ * gen_cvtab.c and regenerate the conversion table
+ * rerun gen_cvtab
+ */
+ m = (int)((55 * .72 + 16.867) * 89.736 / (clock + 39) - 21.1543)
+ m = (m / 2) - 1;
if (m > 31)
m = 31;
else if (m <= 0) {
m = 0;
n = 16;
}
+#endif
+ for (m = 0; m < 31; ++m)
+ if (clock >= cv_convtab[m])
+ break;
+ if (m == 0)
+ n = 16;
m = m << 3;
WCrt(ba, CRT_ID_EXT_MEM_CNTL_2, m);
diff --git a/sys/arch/amiga/dev/sfas.c b/sys/arch/amiga/dev/sfas.c
index 5e9eedaafba..06e483a5a04 100644
--- a/sys/arch/amiga/dev/sfas.c
+++ b/sys/arch/amiga/dev/sfas.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: sfas.c,v 1.4 1996/02/26 21:08:02 niklas Exp $ */
+
/*
* Copyright (c) 1995 Daniel Widenfalk
* Copyright (c) 1994 Christian E. Hopps
@@ -165,9 +167,15 @@ sfasinitialize(dev)
dev->sc_config2 = SFAS_CFG2_FEATURES_ENABLE;
dev->sc_config3 = (dev->sc_clock_freq > 25 ? SFAS_CFG3_FASTCLK : 0);
-/* Precalculate timeout value and clock period. */
+#if 0 /* don't use floating point */
dev->sc_timeout_val = 1+dev->sc_timeout*dev->sc_clock_freq/
(7.682*dev->sc_clock_conv_fact);
+#endif
+ /* Precalculate timeout value and clock period. */
+ dev->sc_timeout_val = 1 +
+ (dev->sc_timeout * dev->sc_clock_freq * 1000)
+ / (7682 * dev->sc_clock_conv_fact);
+
dev->sc_clock_period = 1000/dev->sc_clock_freq;
sfasreset(dev, 1 | 2); /* Reset Chip and Bus */