Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/amiga/dev use an inline function for the "4 reads"



details:   https://anonhg.NetBSD.org/src/rev/af7e2e27be2b
branches:  trunk
changeset: 320925:af7e2e27be2b
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Mar 05 02:41:19 2018 +0000

description:
use an inline function for the "4 reads"

diffstat:

 sys/arch/amiga/dev/grf_et.c |  51 ++++++++++++++------------------------------
 1 files changed, 16 insertions(+), 35 deletions(-)

diffs (119 lines):

diff -r 8a7efd485014 -r af7e2e27be2b sys/arch/amiga/dev/grf_et.c
--- a/sys/arch/amiga/dev/grf_et.c       Mon Mar 05 02:41:03 2018 +0000
+++ b/sys/arch/amiga/dev/grf_et.c       Mon Mar 05 02:41:19 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: grf_et.c,v 1.34 2018/03/04 22:28:18 mrg Exp $ */
+/*     $NetBSD: grf_et.c,v 1.35 2018/03/05 02:41:19 christos Exp $ */
 
 /*
  * Copyright (c) 1997 Klaus Burkert
@@ -37,7 +37,7 @@
 #include "opt_amigacons.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: grf_et.c,v 1.34 2018/03/04 22:28:18 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: grf_et.c,v 1.35 2018/03/05 02:41:19 christos Exp $");
 
 #include "grfet.h"
 #include "ite.h"
@@ -1586,6 +1586,11 @@
        return ((*mem == 0xff) ? ETW32 : ET4000);
 }
 
+/* We MUST do 4 HW reads to switch into command mode */
+static inline int vgar4HDR(volatile unsigned char *ba)
+{
+       return vgar(ba, HDR) + vgar(ba, HDR) + vgar(ba, HDR) + vgar(ba, HDR);
+}
 
 static int
 et_getDACType(struct grf_softc *gp)
@@ -1598,11 +1603,8 @@
 
        /* check for Sierra SC 15025 */
 
-       /* We MUST do 4 HW reads to switch into command mode */
-       vgar(ba, HDR);
-       vgar(ba, HDR);
-       vgar(ba, HDR);
-       vgar(ba, HDR);
+       vgar4HDR(ba);
+       vgaw(ba, VDAC_COMMAND, 0x10); /* set ERPF */
        vgaw(ba, VDAC_COMMAND, 0x10); /* set ERPF */
 
        vgaw(ba, VDAC_XINDEX, 9);
@@ -1614,17 +1616,11 @@
        vgaw(ba, VDAC_XINDEX, 12);
        check.cc[3] = vgar(ba, VDAC_XDATA);
 
-       vgar(ba, HDR);
-       vgar(ba, HDR);
-       vgar(ba, HDR);
-       vgar(ba, HDR);
+       vgar4HDR(ba);
        vgaw(ba, VDAC_COMMAND, 0x00); /* clear ERPF */
 
        if (check.tt == 0x533ab141) {
-               vgar(ba, HDR);
-               vgar(ba, HDR);
-               vgar(ba, HDR);
-               vgar(ba, HDR);
+               vgar4HDR(ba);
                vgaw(ba, VDAC_COMMAND, 0x10); /* set ERPF */
 
                /* switch to 8 bits per color */
@@ -1633,10 +1629,7 @@
                /* do not shift color values */
                etcmap_shift = 0;
 
-               vgar(ba, HDR);
-               vgar(ba, HDR);
-               vgar(ba, HDR);
-               vgar(ba, HDR);
+               vgar4HDR(ba);
                vgaw(ba, VDAC_COMMAND, 0x00); /* clear ERPF */
 
                vgaw(ba, VDAC_MASK, 0xff);
@@ -1645,10 +1638,7 @@
 
        /* check for MUSIC DAC */
 
-       vgar(ba, HDR);
-       vgar(ba, HDR);
-       vgar(ba, HDR);
-       vgar(ba, HDR);
+       vgar4HDR(ba);
        vgaw(ba, VDAC_COMMAND, 0x02);   /* set some strange MUSIC mode (???) */
 
        vgaw(ba, VDAC_XINDEX, 0x01);
@@ -1661,16 +1651,10 @@
        }
 
        /* check for AT&T ATT20c491 DAC (crest) */
-       vgar(ba, HDR);
-       vgar(ba, HDR);
-       vgar(ba, HDR);
-       vgar(ba, HDR);
+       vgar4HDR(ba);
        vgaw(ba, HDR, 0xff);
        vgaw(ba, VDAC_MASK, 0x01);
-       vgar(ba, HDR);
-       vgar(ba, HDR);
-       vgar(ba, HDR);
-       vgar(ba, HDR);
+       vgar4HDR(ba);
        if (vgar(ba, HDR) == 0xff) {
                /* do not shift color values */
                etcmap_shift = 0;
@@ -1680,10 +1664,7 @@
        }
 
        /* restore PowerUp settings (crest) */
-       vgar(ba, HDR);
-       vgar(ba, HDR);
-       vgar(ba, HDR);
-       vgar(ba, HDR);
+       vgar4HDR(ba);
        vgaw(ba, HDR, 0x00);
 
        /*



Home | Main Index | Thread Index | Old Index