132b578d3Smrg/*
232b578d3Smrg * Copyright 1997 through 2004 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org
332b578d3Smrg *
432b578d3Smrg * Permission to use, copy, modify, distribute, and sell this software and its
532b578d3Smrg * documentation for any purpose is hereby granted without fee, provided that
632b578d3Smrg * the above copyright notice appear in all copies and that both that copyright
732b578d3Smrg * notice and this permission notice appear in supporting documentation, and
832b578d3Smrg * that the name of Marc Aurele La France not be used in advertising or
932b578d3Smrg * publicity pertaining to distribution of the software without specific,
1032b578d3Smrg * written prior permission.  Marc Aurele La France makes no representations
1132b578d3Smrg * about the suitability of this software for any purpose.  It is provided
1232b578d3Smrg * "as-is" without express or implied warranty.
1332b578d3Smrg *
1432b578d3Smrg * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1532b578d3Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO
1632b578d3Smrg * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1732b578d3Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
1832b578d3Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
1932b578d3Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2032b578d3Smrg * PERFORMANCE OF THIS SOFTWARE.
2132b578d3Smrg */
2232b578d3Smrg
2332b578d3Smrg#ifdef HAVE_CONFIG_H
2432b578d3Smrg#include "config.h"
2532b578d3Smrg#endif
2632b578d3Smrg
2732b578d3Smrg#include "ati.h"
2832b578d3Smrg#include "atibank.h"
2932b578d3Smrg#include "atimach64io.h"
3032b578d3Smrg#include "atiwonderio.h"
3132b578d3Smrg
3232b578d3Smrg#ifndef AVOID_CPIO
3332b578d3Smrg
3432b578d3Smrg/*
3532b578d3Smrg * ATIx8800SetBank --
3632b578d3Smrg *
3732b578d3Smrg * Set an ATI 28800's, 68800's or 88800's read and write bank numbers.
3832b578d3Smrg */
3932b578d3Smrgvoid
4032b578d3SmrgATIx8800SetBank
4132b578d3Smrg(
4232b578d3Smrg    ATIPtr       pATI,
4332b578d3Smrg    unsigned int iBank
4432b578d3Smrg)
4532b578d3Smrg{
4632b578d3Smrg    (void)iBank; /* always called with iBank = 0 */
4732b578d3Smrg
4832b578d3Smrg    ATIPutExtReg(0xB2U, 0x00U);
4932b578d3Smrg    ATIModifyExtReg(pATI, 0xAEU, -1, (CARD8)(~0x0FU), 0x00U);
5032b578d3Smrg}
5132b578d3Smrg
5232b578d3Smrg/*
5332b578d3Smrg * Functions to simulate a banked VGA aperture using a Mach64's small dual
5432b578d3Smrg * paged apertures.  There are two sets of these:  one for packed modes, the
5532b578d3Smrg * other for planar modes.
5632b578d3Smrg */
5732b578d3Smrg
5832b578d3Smrgstatic CARD32
5932b578d3SmrgATIMach64MassagePackedBankNumber
6032b578d3Smrg(
6132b578d3Smrg    CARD8 iBank
6232b578d3Smrg)
6332b578d3Smrg{
6432b578d3Smrg    iBank <<= 1;
6532b578d3Smrg    return ((iBank + 1) << 16) | iBank;
6632b578d3Smrg}
6732b578d3Smrg
6832b578d3Smrg/*
6932b578d3Smrg * ATIMach64SetBankPacked --
7032b578d3Smrg *
7132b578d3Smrg * Set read and write bank numbers for small dual paged apertures.
7232b578d3Smrg */
7332b578d3Smrgvoid
7432b578d3SmrgATIMach64SetBankPacked
7532b578d3Smrg(
7632b578d3Smrg    ATIPtr       pATI,
7732b578d3Smrg    unsigned int iBank
7832b578d3Smrg)
7932b578d3Smrg{
8032b578d3Smrg    CARD32 tmp = ATIMach64MassagePackedBankNumber(iBank);
8132b578d3Smrg
8232b578d3Smrg    outr(MEM_VGA_RP_SEL, tmp);
8332b578d3Smrg    outr(MEM_VGA_WP_SEL, tmp);
8432b578d3Smrg}
8532b578d3Smrg
8632b578d3Smrgstatic CARD32
8732b578d3SmrgATIMach64MassagePlanarBankNumber
8832b578d3Smrg(
8932b578d3Smrg    CARD8 iBank
9032b578d3Smrg)
9132b578d3Smrg{
9232b578d3Smrg    iBank <<= 3;
9332b578d3Smrg    return ((iBank + 4) << 16) | iBank;
9432b578d3Smrg}
9532b578d3Smrg
9632b578d3Smrg/*
9732b578d3Smrg * ATIMach64SetBankPlanar --
9832b578d3Smrg *
9932b578d3Smrg * Set read and write bank numbers for small dual paged apertures.
10032b578d3Smrg */
10132b578d3Smrgvoid
10232b578d3SmrgATIMach64SetBankPlanar
10332b578d3Smrg(
10432b578d3Smrg    ATIPtr       pATI,
10532b578d3Smrg    unsigned int iBank
10632b578d3Smrg)
10732b578d3Smrg{
10832b578d3Smrg    CARD32 tmp = ATIMach64MassagePlanarBankNumber(iBank);
10932b578d3Smrg
11032b578d3Smrg    outr(MEM_VGA_RP_SEL, tmp);
11132b578d3Smrg    outr(MEM_VGA_WP_SEL, tmp);
11232b578d3Smrg}
11332b578d3Smrg
11432b578d3Smrg#endif /* AVOID_CPIO */
115