Adding driver for VIA CLE266 graphics chip. Currently it only accelerates
copy and fill operations.
This commit is contained in:
parent
6af411b02e
commit
ea1bbf8d83
|
@ -1,5 +1,5 @@
|
|||
if KDRIVEVESA
|
||||
VESA_SUBDIRS = vesa mach64 mga nvidia r128 smi chips pm2
|
||||
VESA_SUBDIRS = vesa mach64 mga nvidia r128 smi chips pm2 via
|
||||
endif
|
||||
|
||||
if KDRIVEFBDEV
|
||||
|
|
34
hw/kdrive/via/Makefile.am
Normal file
34
hw/kdrive/via/Makefile.am
Normal file
|
@ -0,0 +1,34 @@
|
|||
INCLUDES = \
|
||||
@KDRIVE_INCS@ \
|
||||
-I$(top_srcdir)/hw/kdrive/vesa \
|
||||
@XSERVER_CFLAGS@
|
||||
|
||||
bin_PROGRAMS = Xvia
|
||||
|
||||
if TSLIB
|
||||
TSLIB_FLAG = -lts
|
||||
endif
|
||||
|
||||
noinst_LIBRARIES = libvia.a
|
||||
|
||||
libvia_a_SOURCES = \
|
||||
via.c \
|
||||
viadraw.c \
|
||||
viadraw.h \
|
||||
via.h \
|
||||
via_regs.h
|
||||
|
||||
Xvia_SOURCES = \
|
||||
viastub.c
|
||||
|
||||
VIA_LIBS = \
|
||||
libvia.a \
|
||||
$(top_builddir)/hw/kdrive/vesa/libvesa.a
|
||||
|
||||
Xvia_LDADD = \
|
||||
$(VIA_LIBS) \
|
||||
@KDRIVE_LIBS@ \
|
||||
@XSERVER_LIBS@ \
|
||||
$(TSLIB_FLAG)
|
||||
|
||||
Xvia_DEPENDENCIES = $(VIA_LIBS) @KDRIVE_LIBS@
|
436
hw/kdrive/via/via.c
Normal file
436
hw/kdrive/via/via.c
Normal file
|
@ -0,0 +1,436 @@
|
|||
/*
|
||||
* Copyright © 2004 Ralph Thomas
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Ralph Thomas not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Ralph Thomas makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* RALPH THOMAS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL RALPH THOMAS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
/*
|
||||
** VIA CLE266 driver
|
||||
** Copyright 2004 (C) Ralph Thomas <ralpht@gmail.com>
|
||||
**
|
||||
** http://www.viatech.com.tw/
|
||||
*/
|
||||
|
||||
#include "via.h"
|
||||
#include "viadraw.h"
|
||||
|
||||
/*
|
||||
** viaCardInit( KdCardInfo* card )
|
||||
**
|
||||
** Description:
|
||||
** Create card specific structures, map chip registers and initialize the
|
||||
** VESA driver. We make the VESA driver do boring stuff for us, like set
|
||||
** up a framebuffer and program a mode.
|
||||
**
|
||||
** Parameters:
|
||||
** card Information stucture for the card we want to bring up.
|
||||
** It should be a VIA card.
|
||||
**
|
||||
** Return:
|
||||
** TRUE Initialization went ok.
|
||||
** FALSE Initialization failed.
|
||||
*/
|
||||
static Bool
|
||||
viaCardInit( KdCardInfo* card ) {
|
||||
ViaCardInfo* viac;
|
||||
|
||||
viac = (ViaCardInfo*) xalloc( sizeof( ViaCardInfo ) );
|
||||
if( !viac ) return FALSE;
|
||||
memset( viac, '\0', sizeof( ViaCardInfo ) );
|
||||
|
||||
|
||||
viaMapReg( card, viac );
|
||||
|
||||
if( !vesaInitialize( card, &viac->vesa ) ) {
|
||||
xfree( viac );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
card->driver = viac;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
** Bool viaScreenInit( KdScreenInfo* screen )
|
||||
**
|
||||
** Description:
|
||||
** Initialize a single screen, described by the screen parameter.
|
||||
** This is where fairly low-level screen related things get setup,
|
||||
** such as video mode and resolution. Currently that all gets
|
||||
** handed off to the VESA driver.
|
||||
**
|
||||
** Parameters:
|
||||
** screen Information structure for the screen to enable.
|
||||
**
|
||||
** Return:
|
||||
** TRUE Screen was initialized successfully
|
||||
** FALSE Screen initialization failed
|
||||
*/
|
||||
static Bool
|
||||
viaScreenInit( KdScreenInfo* screen ) {
|
||||
ViaCardInfo* viac = screen->card->driver;
|
||||
ViaScreenInfo* vias;
|
||||
|
||||
vias = (ViaScreenInfo*) xalloc( sizeof( ViaScreenInfo ) );
|
||||
if( !vias ) return FALSE;
|
||||
memset( vias, '\0', sizeof( ViaScreenInfo ) );
|
||||
|
||||
if( !vesaScreenInitialize( screen, &vias->vesa ) ) {
|
||||
xfree( vias );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
** XXX: What does this do?
|
||||
*/
|
||||
if( !viac->mapBase )
|
||||
screen->dumb = TRUE;
|
||||
if( vias->vesa.mapping != VESA_LINEAR )
|
||||
screen->dumb = TRUE;
|
||||
|
||||
screen->driver = vias;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
** Bool viaInitScreen( ScreenPtr pScreen )
|
||||
**
|
||||
** Description:
|
||||
** High level screen initialization occurs here. We could register XV
|
||||
** adaptors, etc, here.
|
||||
**
|
||||
** Arguments:
|
||||
** pScreen X screen information
|
||||
**
|
||||
** Return:
|
||||
** TRUE Initialization was successful,
|
||||
** FALSE Initialization failed.
|
||||
*/
|
||||
static Bool
|
||||
viaInitScreen( ScreenPtr pScreen ) {
|
||||
return vesaInitScreen( pScreen );
|
||||
}
|
||||
|
||||
/*
|
||||
** Bool viaFinishInitScreen
|
||||
**
|
||||
** Description:
|
||||
** Finish up any high-level screen initialization. Per-Screen extension
|
||||
** initialization can be done here.
|
||||
**
|
||||
** Arguments:
|
||||
** pScreen X screen information
|
||||
**
|
||||
** Return:
|
||||
** TRUE Initialization was successful.
|
||||
** FALSE Initialization failed.
|
||||
*/
|
||||
static Bool
|
||||
viaFinishInitScreen( ScreenPtr pScreen ) {
|
||||
return vesaFinishInitScreen( pScreen );
|
||||
}
|
||||
|
||||
/*
|
||||
** Bool viaCreateResources( ScreenPtr pScreen )
|
||||
**
|
||||
** Description:
|
||||
** Do any screen specific configuration.
|
||||
**
|
||||
** Arguments:
|
||||
** pScreen X screen information
|
||||
**
|
||||
** Return:
|
||||
** TRUE configuration was successful.
|
||||
** FALSE configuration failed.
|
||||
*/
|
||||
static Bool
|
||||
viaCreateResources( ScreenPtr pScreen ) {
|
||||
return vesaCreateResources( pScreen );
|
||||
}
|
||||
|
||||
/*
|
||||
** void viaPreserve( KdCardInfo* card )
|
||||
**
|
||||
** Description:
|
||||
** Save the current state of the chip, so that it can be restored by
|
||||
** viaRestore at a later time.
|
||||
**
|
||||
** Arguments:
|
||||
** card Information structure for the chip we want to preserve the
|
||||
** state of.
|
||||
**
|
||||
** Return:
|
||||
** None.
|
||||
**
|
||||
** See Also:
|
||||
** viaRestore
|
||||
*/
|
||||
static void
|
||||
viaPreserve( KdCardInfo* card ) {
|
||||
vesaPreserve( card );
|
||||
}
|
||||
|
||||
/*
|
||||
** void viaRestore( KdCardInfo* card )
|
||||
**
|
||||
** Description:
|
||||
** Restore the previous state of the chip, as saved by viaPreserve
|
||||
** earlier.
|
||||
**
|
||||
** Arguments:
|
||||
** card Information structure for the chip we want to restore the
|
||||
** state of.
|
||||
**
|
||||
** Return:
|
||||
** None.
|
||||
**
|
||||
** See Also:
|
||||
** viaPreserve
|
||||
*/
|
||||
static void viaRestore( KdCardInfo* card ) {
|
||||
ViaCardInfo* viac = card->driver;
|
||||
|
||||
viaResetMMIO( card, viac );
|
||||
vesaRestore( card );
|
||||
}
|
||||
|
||||
/*
|
||||
** Bool viaEnable( ScreenPtr pScreen )
|
||||
**
|
||||
** Description:
|
||||
** This is where we set the card up for drawing the specified screen, e.g.:
|
||||
** set the mode and mmap the framebuffer.
|
||||
**
|
||||
** Arguments:
|
||||
** pScreen X screen information
|
||||
**
|
||||
** Return:
|
||||
** TRUE the screen was enabled
|
||||
** FALSE the screen could not be enabled
|
||||
*/
|
||||
static Bool
|
||||
viaEnable( ScreenPtr pScreen ) {
|
||||
KdScreenPriv( pScreen );
|
||||
ViaCardInfo* viac = pScreenPriv->card->driver;
|
||||
|
||||
if( !vesaEnable( pScreen ) ) return FALSE;
|
||||
|
||||
viaSetMMIO( pScreenPriv->card, viac );
|
||||
|
||||
if( !viac->mapBase ) {
|
||||
ErrorF( "Could not map CLE266 graphics registers" );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
** void viaDisable( ScreenPtr pScreen )
|
||||
**
|
||||
** Description:
|
||||
** Shut down drawing: save some state and unmap the framebuffer.
|
||||
**
|
||||
** Arguments:
|
||||
** pScreen X screen information
|
||||
**
|
||||
** Return:
|
||||
** None.
|
||||
*/
|
||||
static void
|
||||
viaDisable( ScreenPtr pScreen ) {
|
||||
KdScreenPriv( pScreen );
|
||||
ViaCardInfo* viac = pScreenPriv->card->driver;
|
||||
|
||||
viaResetMMIO( pScreenPriv->card, viac );
|
||||
vesaDisable( pScreen );
|
||||
}
|
||||
|
||||
/*
|
||||
** void viaScreenFini( KdScreenInfo* screen )
|
||||
**
|
||||
** Description:
|
||||
** Release memory and resources allocated by viaScreenInit.
|
||||
**
|
||||
** Arguments:
|
||||
** screen Information structure for the screen to release.
|
||||
**
|
||||
** Return:
|
||||
** None.
|
||||
**
|
||||
** See Also:
|
||||
** viaScreenInit
|
||||
*/
|
||||
static void
|
||||
viaScreenFini( KdScreenInfo* screen ) {
|
||||
ViaScreenInfo* vias = screen->driver;
|
||||
|
||||
vesaScreenFini( screen );
|
||||
xfree( vias );
|
||||
screen->driver = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** void viaCardFini( KdCardInfo* card )
|
||||
**
|
||||
** Description:
|
||||
** Release memory and resources allocated by viaCardInit.
|
||||
**
|
||||
** Arguments:
|
||||
** card Information structure for the chip to release.
|
||||
**
|
||||
** Return:
|
||||
** None.
|
||||
**
|
||||
** See Also:
|
||||
** viaCardInit
|
||||
*/
|
||||
static void
|
||||
viaCardFini( KdCardInfo* card ) {
|
||||
ViaCardInfo* viac = card->driver;
|
||||
|
||||
viaUnmapReg( card, viac );
|
||||
vesaCardFini( card );
|
||||
xfree( viac );
|
||||
}
|
||||
|
||||
/*
|
||||
** void viaSetMMIO( KdCardInfo* card, ViaCardInfo* viac )
|
||||
**
|
||||
** Description:
|
||||
** Map the card's registers, if they're not already
|
||||
** mapped.
|
||||
**
|
||||
** Arguments:
|
||||
** card generic chip information
|
||||
** viac VIA-driver specific chip information
|
||||
**
|
||||
** Return:
|
||||
** None.
|
||||
*/
|
||||
void viaSetMMIO( KdCardInfo* card, ViaCardInfo* viac ) {
|
||||
if( !viac->mapBase ) viaMapReg( card, viac );
|
||||
}
|
||||
|
||||
/*
|
||||
** void viaResetMMIO( KdCardInfo* card, ViaCardInfo* viac )
|
||||
**
|
||||
** Description:
|
||||
** Unmap chip's registers.
|
||||
**
|
||||
** Arguments:
|
||||
** card generic chip information
|
||||
** viac VIA-driver specific chip information
|
||||
**
|
||||
** Return:
|
||||
** None.
|
||||
*/
|
||||
void viaResetMMIO( KdCardInfo* card, ViaCardInfo* viac ) {
|
||||
viaUnmapReg( card, viac );
|
||||
}
|
||||
|
||||
/*
|
||||
** Bool viaMapReg( KdCardInfo* card, ViaCardInfo* viac )
|
||||
**
|
||||
** Description:
|
||||
** Map the chip's registers into our address space.
|
||||
**
|
||||
** Arguments:
|
||||
** card the card information
|
||||
** viac the VIA-driver specific card information
|
||||
**
|
||||
** Return:
|
||||
** TRUE the registers were succesfully mapped
|
||||
** FALSE the registers could not be mapped
|
||||
*/
|
||||
Bool
|
||||
viaMapReg( KdCardInfo* card, ViaCardInfo* viac ) {
|
||||
viac->mapBase = (VOL8*) KdMapDevice( VIA_REG_BASE( card ),
|
||||
VIA_REG_SIZE( card ) );
|
||||
|
||||
if( !viac->mapBase ) {
|
||||
ErrorF( "Couldn't allocate viac->mapBase\n" );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
KdSetMappedMode( VIA_REG_BASE( card ), VIA_REG_SIZE( card ),
|
||||
KD_MAPPED_MODE_REGISTERS );
|
||||
|
||||
/*
|
||||
** Enable extended IO space
|
||||
*/
|
||||
VGAOUT8( 0x3C4, 0x10 );
|
||||
VGAOUT8( 0x3C5, 0x01 );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
** void viaUnmapReg( KdCardInfo* card, ViaCardInfo* viac )
|
||||
**
|
||||
** Description:
|
||||
** Unmap the the chip's registers.
|
||||
**
|
||||
** Arguments:
|
||||
** card the card information
|
||||
** viac the VIA-driver specific card information
|
||||
**
|
||||
** Return:
|
||||
** None.
|
||||
*/
|
||||
void
|
||||
viaUnmapReg( KdCardInfo* card, ViaCardInfo* viac ) {
|
||||
if( !viac->mapBase ) return;
|
||||
|
||||
KdResetMappedMode( VIA_REG_BASE( card ), VIA_REG_SIZE( card ),
|
||||
KD_MAPPED_MODE_REGISTERS );
|
||||
KdUnmapDevice( (void*) viac->mapBase, VIA_REG_SIZE( card ) );
|
||||
viac->mapBase = 0;
|
||||
}
|
||||
|
||||
KdCardFuncs viaFuncs = {
|
||||
viaCardInit, /* cardinit */
|
||||
viaScreenInit, /* scrinit */
|
||||
viaInitScreen, /* initScreen */
|
||||
viaFinishInitScreen, /* finishInitScreen */
|
||||
viaCreateResources, /* createRes */
|
||||
viaPreserve, /* preserve */
|
||||
viaEnable, /* enable */
|
||||
vesaDPMS, /* dpms */
|
||||
viaDisable, /* disable */
|
||||
viaRestore, /* restore */
|
||||
viaScreenFini, /* scrfini */
|
||||
viaCardFini, /* cardfini */
|
||||
|
||||
0, /* initCursor */
|
||||
0, /* enableCursor */
|
||||
0, /* disableCursor */
|
||||
0, /* finiCursor */
|
||||
0, /* recolorCursor */
|
||||
|
||||
viaDrawInit, /* initAccel */
|
||||
viaDrawEnable, /* enableAccel */
|
||||
viaDrawSync, /* syncAccel */
|
||||
viaDrawDisable, /* disableAccel */
|
||||
viaDrawFini, /* finiAccel */
|
||||
|
||||
vesaGetColors, /* getColors */
|
||||
vesaPutColors, /* putColors */
|
||||
};
|
||||
|
128
hw/kdrive/via/via.h
Normal file
128
hw/kdrive/via/via.h
Normal file
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* Copyright © 2004 Ralph Thomas
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Ralph Thomas not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Ralph Thomas makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* RALPH THOMAS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL RALPH THOMAS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
/*
|
||||
** VIA CLE266 driver
|
||||
** Copyright 2004 (C) Ralph Thomas <ralpht@gmail.com>
|
||||
**
|
||||
** http://www.viatech.com.tw/
|
||||
*/
|
||||
|
||||
#ifndef _VIA_H_
|
||||
#define _VIA_H_
|
||||
|
||||
#include <vesa.h>
|
||||
#include <klinux.h>
|
||||
|
||||
/*
|
||||
** Define DebugF so that we can spot debug statements easily.
|
||||
*/
|
||||
#define DebugF ErrorF
|
||||
|
||||
typedef volatile CARD8 VOL8;
|
||||
typedef volatile CARD16 VOL16;
|
||||
typedef volatile CARD32 VOL32;
|
||||
|
||||
/*
|
||||
** These macros provide access to data on the card. The VIA graphics chips
|
||||
** are only available on IA-32 architecture, so PCI address space and CPU
|
||||
** address space are always the same (hence accesses can be performed by
|
||||
** dereferencing a pointer into PCI space).
|
||||
*/
|
||||
#define MMIO_OUT32( mmio, a, v ) (*(VOL32 *)((mmio) + (a)) = (v))
|
||||
#define MMIO_IN32( mmio, a ) (*(VOL32 *)((mmio) + (a)))
|
||||
#define MMIO_OUT16( mmio, a, v ) (*(VOL16 *)((mmio) + (a)) = (v))
|
||||
#define MMIO_IN16( mmio, a ) (*(VOL16 *)((mmio) + (a)))
|
||||
#define MMIO_OUT8( mmio, a, v ) (*(VOL8 *)((mmio) + (a)) = (v))
|
||||
#define MMIO_IN8( mmio, a, v ) (*(VOL8 *)((mmio) + (a)))
|
||||
|
||||
/*
|
||||
** VGA regisers are offset 0x8000 from the beginning of the mmap'd register
|
||||
** space.
|
||||
*/
|
||||
#define VIA_MMIO_VGABASE 0x8000
|
||||
|
||||
/*
|
||||
** The size of the register space, used when we mmap the registers. The
|
||||
** argument "c" should be a KdCardInfo*.
|
||||
*/
|
||||
#define VIA_REG_SIZE(c) (0x9000)
|
||||
|
||||
/*
|
||||
** The base of the register space, used when we mmap the registers. The
|
||||
** argument "c" should be a KdCardInfo*.
|
||||
*/
|
||||
#define VIA_REG_BASE(c) ((c)->attr.address[1])
|
||||
|
||||
/*
|
||||
** Access to the mmap'd VGA registers. The VGA registers are offset from the
|
||||
** beginning of the 16M pci space by 0x8000. These macros get used just like
|
||||
** outb/inb would be used to access VGA.
|
||||
*/
|
||||
#define VGAOUT32( addr, v ) MMIO_OUT32( viac->mapBase + VIA_MMIO_VGABASE, addr, v )
|
||||
#define VGAIN32( addr ) MMIO_IN32( viac->mapBase + VIA_MMIO_VGABASE, addr )
|
||||
#define VGAOUT16( addr, v ) MMIO_OUT16( viac->mapBase + VIA_MMIO_VGABASE, addr, v )
|
||||
#define VGAIN16( addr ) MIIO_IN16( viac->mapBase + VIA_MMIO_VGABASE, addr )
|
||||
#define VGAOUT8( addr, v ) MMIO_OUT8( viac->mapBase + VIA_MMIO_VGABASE, addr, v )
|
||||
#define VGAIN8( addr ) MMIO_IN8( viac->mapBase + VIA_MMIO_VGABASE, addr )
|
||||
|
||||
/*
|
||||
** Access to any of the registers on the chip.
|
||||
*/
|
||||
#define OUTREG32( addr, v ) MMIO_OUT32( viac->mapBase, addr, v )
|
||||
#define INREG32( addr ) MMIO_IN32( viac->mapBase, addr )
|
||||
#define OUTREG16( addr, v ) MMIO_OUT16( viac->mapBase, addr, v )
|
||||
#define INREG16( addr ) MMIO_IN16( viac->mapBase, addr )
|
||||
|
||||
/*
|
||||
** We keep all of our chip specific data in a ViaCardInfo.
|
||||
*/
|
||||
typedef struct _viaCardInfo {
|
||||
VesaCardPrivRec vesa; /* card info for VESA driver */
|
||||
VOL8* mapBase; /* mmap'd registers */
|
||||
CARD32 savedCommand; /* command to issue to GE */
|
||||
CARD32 savedFgColor; /* color to issue to GE */
|
||||
} ViaCardInfo;
|
||||
|
||||
/*
|
||||
** We keep all of our screen specific data in a ViaScreenInfo.
|
||||
*/
|
||||
typedef struct _viaScreenInfo {
|
||||
VesaScreenPrivRec vesa;
|
||||
} ViaScreenInfo;
|
||||
|
||||
/*
|
||||
** These function prototypes are for support functions. More infomation on each
|
||||
** function is available at the place the function is implemented, in via.c.
|
||||
*/
|
||||
Bool viaMapReg( KdCardInfo* card, ViaCardInfo* viac );
|
||||
void viaUnmapReg( KdCardInfo* card, ViaCardInfo* viac );
|
||||
void viaSetMMIO( KdCardInfo* card, ViaCardInfo* viac );
|
||||
void viaResetMMIO( KdCardInfo* card, ViaCardInfo* viac );
|
||||
|
||||
/*
|
||||
** The viaFuncs structure gets filled with the addresses of the functions
|
||||
** that we use to talk to the graphics chip.
|
||||
*/
|
||||
extern KdCardFuncs viaFuncs;
|
||||
|
||||
#endif
|
||||
|
154
hw/kdrive/via/via_regs.h
Normal file
154
hw/kdrive/via/via_regs.h
Normal file
|
@ -0,0 +1,154 @@
|
|||
/*
|
||||
* Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
|
||||
* Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sub license,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
* VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* File: via_regs.h
|
||||
* Content: The defines of Via registers
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#ifndef _VIA_REGS_H_
|
||||
#define _VIA_REGS_H_
|
||||
|
||||
/* defines for VIA 2D registers */
|
||||
#define VIA_REG_GECMD 0x000
|
||||
#define VIA_REG_GEMODE 0x004
|
||||
#define VIA_REG_GESTATUS 0x004 /* as same as VIA_REG_GEMODE */
|
||||
#define VIA_REG_SRCPOS 0x008
|
||||
#define VIA_REG_DSTPOS 0x00C
|
||||
#define VIA_REG_LINE_K1K2 0x008
|
||||
#define VIA_REG_LINE_XY 0x00C
|
||||
#define VIA_REG_DIMENSION 0x010 /* width and height */
|
||||
#define VIA_REG_PATADDR 0x014
|
||||
#define VIA_REG_FGCOLOR 0x018
|
||||
#define VIA_REG_DSTCOLORKEY 0x018 /* as same as VIA_REG_FG */
|
||||
#define VIA_REG_BGCOLOR 0x01C
|
||||
#define VIA_REG_SRCCOLORKEY 0x01C /* as same as VIA_REG_BG */
|
||||
#define VIA_REG_CLIPTL 0x020 /* top and left of clipping */
|
||||
#define VIA_REG_CLIPBR 0x024 /* bottom and right of clipping */
|
||||
#define VIA_REG_OFFSET 0x028
|
||||
#define VIA_REG_LINE_ERROR 0x028
|
||||
#define VIA_REG_KEYCONTROL 0x02C /* color key control */
|
||||
#define VIA_REG_SRCBASE 0x030
|
||||
#define VIA_REG_DSTBASE 0x034
|
||||
#define VIA_REG_PITCH 0x038 /* pitch of src and dst */
|
||||
#define VIA_REG_MONOPAT0 0x03C
|
||||
#define VIA_REG_MONOPAT1 0x040
|
||||
#define VIA_REG_COLORPAT 0x100 /* from 0x100 to 0x1ff */
|
||||
|
||||
|
||||
|
||||
/* defines for VIA video registers */
|
||||
#define VIA_REG_INTERRUPT 0x200
|
||||
#define VIA_REG_CRTCSTART 0x214
|
||||
|
||||
|
||||
/* defines for VIA HW cursor registers */
|
||||
#define VIA_REG_CURSOR_MODE 0x2D0
|
||||
#define VIA_REG_CURSOR_POS 0x2D4
|
||||
#define VIA_REG_CURSOR_ORG 0x2D8
|
||||
#define VIA_REG_CURSOR_BG 0x2DC
|
||||
#define VIA_REG_CURSOR_FG 0x2E0
|
||||
|
||||
|
||||
/* defines for VIA 3D registers */
|
||||
#define VIA_REG_STATUS 0x400
|
||||
#define VIA_REG_TRANSET 0x43C
|
||||
#define VIA_REG_TRANSPACE 0x440
|
||||
|
||||
/* VIA_REG_STATUS(0x400): Engine Status */
|
||||
#define VIA_CMD_RGTR_BUSY 0x00000080 /* Command Regulator is busy */
|
||||
#define VIA_2D_ENG_BUSY 0x00000001 /* 2D Engine is busy */
|
||||
#define VIA_3D_ENG_BUSY 0x00000002 /* 3D Engine is busy */
|
||||
#define VIA_VR_QUEUE_BUSY 0x00020000 /* Virtual Queue is busy */
|
||||
#define VIA_BUSY (VIA_CMD_RGTR_BUSY|VIA_2D_ENG_BUSY|VIA_3D_ENG_BUSY)
|
||||
|
||||
|
||||
/* VIA_REG_GECMD(0x00): 2D Engine Command */
|
||||
#define VIA_GEC_NOOP 0x00000000
|
||||
#define VIA_GEC_BLT 0x00000001
|
||||
#define VIA_GEC_LINE 0x00000005
|
||||
|
||||
#define VIA_GEC_SRC_XY 0x00000000
|
||||
#define VIA_GEC_SRC_LINEAR 0x00000010
|
||||
#define VIA_GEC_DST_XY 0x00000000
|
||||
#define VIA_GEC_DST_LINRAT 0x00000020
|
||||
|
||||
#define VIA_GEC_SRC_FB 0x00000000
|
||||
#define VIA_GEC_SRC_SYS 0x00000040
|
||||
#define VIA_GEC_DST_FB 0x00000000
|
||||
#define VIA_GEC_DST_SYS 0x00000080
|
||||
|
||||
#define VIA_GEC_SRC_MONO 0x00000100 /* source is mono */
|
||||
#define VIA_GEC_PAT_MONO 0x00000200 /* pattern is mono */
|
||||
|
||||
#define VIA_GEC_MSRC_OPAQUE 0x00000000 /* mono src is opaque */
|
||||
#define VIA_GEC_MSRC_TRANS 0x00000400 /* mono src is transparent */
|
||||
|
||||
#define VIA_GEC_PAT_FB 0x00000000 /* pattern is in frame buffer */
|
||||
#define VIA_GEC_PAT_REG 0x00000800 /* pattern is from reg setting */
|
||||
|
||||
#define VIA_GEC_CLIP_DISABLE 0x00000000
|
||||
#define VIA_GEC_CLIP_ENABLE 0x00001000
|
||||
|
||||
#define VIA_GEC_FIXCOLOR_PAT 0x00002000
|
||||
|
||||
#define VIA_GEC_INCX 0x00000000
|
||||
#define VIA_GEC_DECY 0x00004000
|
||||
#define VIA_GEC_INCY 0x00000000
|
||||
#define VIA_GEC_DECX 0x00008000
|
||||
|
||||
#define VIA_GEC_MPAT_OPAQUE 0x00000000 /* mono pattern is opaque */
|
||||
#define VIA_GEC_MPAT_TRANS 0x00010000 /* mono pattern is transparent */
|
||||
|
||||
#define VIA_GEC_MONO_UNPACK 0x00000000
|
||||
#define VIA_GEC_MONO_PACK 0x00020000
|
||||
#define VIA_GEC_MONO_DWORD 0x00000000
|
||||
#define VIA_GEC_MONO_WORD 0x00040000
|
||||
#define VIA_GEC_MONO_BYTE 0x00080000
|
||||
|
||||
#define VIA_GEC_LASTPIXEL_ON 0x00000000
|
||||
#define VIA_GEC_LASTPIXEL_OFF 0x00100000
|
||||
#define VIA_GEC_X_MAJOR 0x00000000
|
||||
#define VIA_GEC_Y_MAJOR 0x00200000
|
||||
#define VIA_GEC_QUICK_START 0x00800000
|
||||
|
||||
|
||||
/* VIA_REG_GEMODE(0x04): GE mode */
|
||||
#define VIA_GEM_8bpp 0x00000000
|
||||
#define VIA_GEM_16bpp 0x00000100
|
||||
#define VIA_GEM_32bpp 0x00000300
|
||||
|
||||
#define VIA_GEM_640 0x00000000 /* 640*480 */
|
||||
#define VIA_GEM_800 0x00000400 /* 800*600 */
|
||||
#define VIA_GEM_1024 0x00000800 /* 1024*768 */
|
||||
#define VIA_GEM_1280 0x00000C00 /* 1280*1024 */
|
||||
#define VIA_GEM_1600 0x00001000 /* 1600*1200 */
|
||||
#define VIA_GEM_2048 0x00001400 /* 2048*1536 */
|
||||
|
||||
/* VIA_REG_PITCH(0x38): Pitch Setting */
|
||||
#define VIA_PITCH_ENABLE 0x80000000
|
||||
|
||||
#endif /* _VIA_REGS_H_ */
|
505
hw/kdrive/via/viadraw.c
Normal file
505
hw/kdrive/via/viadraw.c
Normal file
|
@ -0,0 +1,505 @@
|
|||
/*
|
||||
* Copyright © 2004 Ralph Thomas
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Ralph Thomas not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Ralph Thomas makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* RALPH THOMAS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL RALPH THOMAS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
/*
|
||||
** VIA CLE266 driver
|
||||
** Copyright 2004 (C) Ralph Thomas <ralpht@gmail.com>
|
||||
**
|
||||
** http://www.viatech.com.tw/
|
||||
**
|
||||
** This code is for accelerated drawing of solids and accelerated
|
||||
** copies. Note that there is currently no software FIFO implemented,
|
||||
** and no documentation on any hardware FIFO.
|
||||
*/
|
||||
|
||||
#include "via.h"
|
||||
#include "viadraw.h"
|
||||
#include "via_regs.h"
|
||||
#include <sched.h>
|
||||
|
||||
/*
|
||||
** A global to contain card information between calls into this file.
|
||||
** XXX: This is totally brain-damaged. Why don't I get the information
|
||||
** I want in viaSolid/viaCopy/viaDoneXXX?
|
||||
*/
|
||||
static ViaCardInfo* card;
|
||||
|
||||
/*
|
||||
** Translation table from GC raster operation values into ROP3 values
|
||||
** that the VIA chip understands.
|
||||
**
|
||||
** viaPatternRop is used by viaPrepareSolid.
|
||||
** viaCopyRop is used by viaPrepareCopy.
|
||||
*/
|
||||
CARD8 viaPatternRop[16] = {
|
||||
/* GXclear */ 0x00, /* ROP_0 0 */
|
||||
/* GXand */ 0xA0, /* ROP_DPa src AND dst */
|
||||
/* GXandReverse */ 0x50, /* ROP_PDna src AND NOT dst */
|
||||
/* GXcopy */ 0xF0, /* ROP_P src */
|
||||
/* GXandInverted*/ 0x0A, /* ROP_DPna NOT src AND dst */
|
||||
/* GXnoop */ 0xAA, /* ROP_D dst */
|
||||
/* GXxor */ 0x5A, /* ROP_DPx src XOR dst */
|
||||
/* GXor */ 0xFA, /* ROP_DPo src OR dst */
|
||||
/* GXnor */ 0x05, /* ROP_DPon NOT src AND NOT dst */
|
||||
/* GXequiv */ 0xA5, /* ROP_PDxn NOT src XOR dst */
|
||||
/* GXinvert */ 0x55, /* ROP_Dn NOT dst */
|
||||
/* GXorReverse */ 0xF5, /* ROP_PDno src OR NOT dst */
|
||||
/* GXcopyInverted*/ 0x0F, /* ROP_Pn NOT src */
|
||||
/* GXorInverted */ 0xAF, /* ROP_DPno NOT src OR dst */
|
||||
/* GXnand */ 0x5F, /* ROP_DPan NOT src OR NOT dst */
|
||||
/* GXset */ 0xFF, /* ROP_1 1 */
|
||||
};
|
||||
|
||||
CARD8 viaCopyRop[16] = {
|
||||
/* GXclear */ 0x00, /* ROP_0 0 */
|
||||
/* GXand */ 0x88, /* ROP_DSa src AND dst */
|
||||
/* GXandReverse */ 0x44, /* ROP_SDna src AND NOT dst */
|
||||
/* GXcopy */ 0xCC, /* ROP_S src */
|
||||
/* GXandInverted*/ 0x22, /* ROP_DSna NOT src AND dst */
|
||||
/* GXnoop */ 0xAA, /* ROP_D dst */
|
||||
/* GXxor */ 0x66, /* ROP_DSx src XOR dst */
|
||||
/* GXor */ 0xEE, /* ROP_DSo src OR dst */
|
||||
/* GXnor */ 0x11, /* ROP_DSon NOT src AND NOT dst */
|
||||
/* GXequiv */ 0x99, /* ROP_DSxn NOT src XOR dst */
|
||||
/* GXinvert */ 0x55, /* ROP_Dn NOT dst */
|
||||
/* GXorReverse */ 0xDD, /* ROP_SDno src OR NOT dst */
|
||||
/* GXcopyInverted*/ 0x33, /* ROP_Sn NOT src */
|
||||
/* GXorInverted */ 0xBB, /* ROP_DSno NOT src OR dst */
|
||||
/* GXnand */ 0x77, /* ROP_DSan NOT src OR NOT dst */
|
||||
/* GXset */ 0xFF, /* ROP_1 1 */
|
||||
};
|
||||
|
||||
/*
|
||||
** void viaWaitIdle( ViaCardInfo* viac )
|
||||
**
|
||||
** Description:
|
||||
** Block up the CPU while waiting for the last command sent to
|
||||
** the chip to complete. As an experiment I'm going to try to
|
||||
** yield my process to others instead of just tight looping.
|
||||
**
|
||||
** Arguments:
|
||||
** viac VIA-driver specific chip information
|
||||
**
|
||||
** Return:
|
||||
** None.
|
||||
*/
|
||||
void
|
||||
viaWaitIdle( ViaCardInfo* viac ) {
|
||||
while( INREG32( VIA_REG_STATUS ) & VIA_BUSY )
|
||||
sched_yield();
|
||||
}
|
||||
|
||||
/*
|
||||
** Bool viaPrepareSolid( PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg )
|
||||
**
|
||||
** Description:
|
||||
** Decide if the specified solid fill operation can be accelerated or not,
|
||||
** and if the fill can be accelerated, prepare the hardware for doing it.
|
||||
**
|
||||
** Arguments:
|
||||
** pPixmap Pixmap to draw solid into.
|
||||
** alu Raster operation to draw using, these are the same
|
||||
** values which get set by XSetFunction(3X). See the
|
||||
** Xlib PM p. 140 for a list of raster operations as
|
||||
** well as descriptions.
|
||||
** planemask This is the GC plane mask. We only copy bits which
|
||||
** match the plane mask.
|
||||
** fg The foreground pixel of the GC, the pixel to draw in.
|
||||
**
|
||||
** Return:
|
||||
** TRUE This operation can be accelerated, call viaSolid to actually
|
||||
** have it drawn.
|
||||
** FALSE This operation cannot be accelerated, fall back to software.
|
||||
**
|
||||
** See Also:
|
||||
** viaSolid - the function which actually draws the solid.
|
||||
*/
|
||||
static Bool
|
||||
viaPrepareSolid( PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg ) {
|
||||
ScreenPtr pScreen = pPixmap->drawable.pScreen;
|
||||
KdScreenPriv( pScreen );
|
||||
ViaCardInfo* viac = pScreenPriv->card->driver;
|
||||
|
||||
/*
|
||||
** We don't accelerate when the plane mask is not everything.
|
||||
*/
|
||||
if( ~planeMask & FbFullMask( pPixmap->drawable.depth ) ) return FALSE;
|
||||
|
||||
/*
|
||||
** Compose the command, then store the composed command and color
|
||||
** in the viac structure so that when viaSolid gets called we can
|
||||
** write them out.
|
||||
*/
|
||||
viac->savedCommand = VIA_GEC_BLT | VIA_GEC_FIXCOLOR_PAT |
|
||||
(viaPatternRop[alu] << 24);
|
||||
viac->savedFgColor = fg;
|
||||
|
||||
/*
|
||||
** Store pointer to chip information, due to brain-damaged KAA.
|
||||
*/
|
||||
card = viac;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
** void viaSolid( int x1, int y1, int x2, int y2 )
|
||||
**
|
||||
** Description:
|
||||
** Perform a solid fill, using the data that was stored by viaPrepareSolid.
|
||||
**
|
||||
** Arguments:
|
||||
** x1 x-coordinate of fill origin
|
||||
** y1 y-coordinate of fill origin
|
||||
** x2 x-coordinate of fill end point
|
||||
** y2 y-coordinate of fill end point
|
||||
**
|
||||
** Return:
|
||||
** None.
|
||||
**
|
||||
** See Also:
|
||||
** viaPrepareSolid - the function that composes the GE command and saves
|
||||
** the color for us.
|
||||
*/
|
||||
static void
|
||||
viaSolid( int x1, int y1, int x2, int y2 ) {
|
||||
ViaCardInfo* viac = card;
|
||||
int w = x2 - x1; int h = y2 - y1;
|
||||
|
||||
if( !viac ) return;
|
||||
if( !w || !h ) return;
|
||||
|
||||
/*
|
||||
** Wait for the card to finish the current draw.
|
||||
*/
|
||||
viaWaitIdle( viac );
|
||||
|
||||
/*
|
||||
** Do the draw.
|
||||
*/
|
||||
OUTREG32( VIA_REG_DSTPOS, ((y1 << 16) | x1) );
|
||||
OUTREG32( VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)) );
|
||||
OUTREG32( VIA_REG_FGCOLOR, viac->savedFgColor );
|
||||
OUTREG32( VIA_REG_GECMD, viac->savedCommand );
|
||||
}
|
||||
|
||||
/*
|
||||
** void viaDoneSolid
|
||||
**
|
||||
** Description:
|
||||
** Finish up drawing of the solid.
|
||||
**
|
||||
** Arguments:
|
||||
** None.
|
||||
**
|
||||
** Return:
|
||||
** None.
|
||||
*/
|
||||
static void
|
||||
viaDoneSolid() {
|
||||
;
|
||||
}
|
||||
|
||||
/*
|
||||
** Bool viaPrepareCopy( PixmapPtr pSrcPixmap, PixmapPtr pDestPixmap, int dx,
|
||||
** int dy, int alu, Pixel planeMask )
|
||||
**
|
||||
** Description:
|
||||
** Set up the VIA chip for a BitBlt.
|
||||
**
|
||||
** Arguments:
|
||||
** pSrcPixmap the source pixmap to copy from
|
||||
** pDestPixmap the destination pixmap to copy to
|
||||
** dx direction of copy in x
|
||||
** dy direction of copy in y
|
||||
** alu Raster operation to draw using, these are the same
|
||||
** values which get set by XSetFunction(3X). See the
|
||||
** Xlib PM p. 140 for a list of raster operations as
|
||||
** well as descriptions.
|
||||
** planeMask This is the GC plane mask. We only copy bits which
|
||||
** match the plane mask.
|
||||
**
|
||||
** Return:
|
||||
** TRUE the requested copy operation can be accelerated using hardware,
|
||||
** call viaCopy next.
|
||||
** FALSE the requested copy operation cannot be accelerated using
|
||||
** hardware - fallback to software.
|
||||
**
|
||||
** See Also:
|
||||
** viaCopy - the function which does the actual copy.
|
||||
*/
|
||||
static Bool
|
||||
viaPrepareCopy( PixmapPtr pSrcPixmap, PixmapPtr pDestPixmap, int dx, int dy,
|
||||
int alu, Pixel planeMask ) {
|
||||
ScreenPtr pScreen = pDestPixmap->drawable.pScreen;
|
||||
KdScreenPriv( pScreen );
|
||||
ViaCardInfo* viac = pScreenPriv->card->driver;
|
||||
|
||||
/*
|
||||
** Don't accelerate when the plane mask is set.
|
||||
*/
|
||||
if( ~planeMask & FbFullMask( pDestPixmap->drawable.depth ) ) return FALSE;
|
||||
|
||||
viac->savedCommand = VIA_GEC_BLT | (viaCopyRop[alu] << 24);
|
||||
|
||||
if( dx < 0 ) viac->savedCommand |= VIA_GEC_DECX;
|
||||
if( dy < 0 ) viac->savedCommand |= VIA_GEC_DECY;
|
||||
|
||||
/*
|
||||
** Store pointer to chip structure, due to brain-damaged KAA.
|
||||
*/
|
||||
card = viac;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
** void viaCopy( int srcX, int srcY, int dstX, int dstY, int w, int h )
|
||||
**
|
||||
** Description:
|
||||
** Perform a BitBlt from one screen area to another.
|
||||
**
|
||||
** Arguments:
|
||||
** srcX source x-coordinate
|
||||
** srcY source y-coordinate
|
||||
** dstX destination x-coordinate
|
||||
** dstY destination y-coordinate
|
||||
** w width of area to copy (pixels)
|
||||
** h height of area to copy (pixels)
|
||||
**
|
||||
** Return:
|
||||
** None.
|
||||
**
|
||||
** See Also:
|
||||
** viaPrepareCopy - the function which sets up for the copy.
|
||||
*/
|
||||
static void
|
||||
viaCopy( int srcX, int srcY, int dstX, int dstY, int w, int h ) {
|
||||
ViaCardInfo* viac = card;
|
||||
|
||||
if( !viac ) return;
|
||||
if( !w | !h ) return;
|
||||
|
||||
/*
|
||||
** XXX: Check these two "if"s out.
|
||||
*/
|
||||
if( viac->savedCommand & VIA_GEC_DECX ) {
|
||||
srcX += ( w - 1 );
|
||||
dstX += ( w - 1 );
|
||||
}
|
||||
|
||||
if( viac->savedCommand & VIA_GEC_DECY ) {
|
||||
srcY += ( h - 1 );
|
||||
dstY += ( h - 1 );
|
||||
}
|
||||
|
||||
OUTREG32( VIA_REG_SRCPOS, ((srcY << 16) | srcX) );
|
||||
OUTREG32( VIA_REG_DSTPOS, ((dstY << 16) | dstX) );
|
||||
OUTREG32( VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)) );
|
||||
OUTREG32( VIA_REG_GECMD, viac->savedCommand );
|
||||
}
|
||||
|
||||
/*
|
||||
** void viaDoneCopy()
|
||||
**
|
||||
** Description:
|
||||
** Finish up the copy.
|
||||
**
|
||||
** Arguments:
|
||||
** None.
|
||||
**
|
||||
** Return:
|
||||
** None.
|
||||
*/
|
||||
static void
|
||||
viaDoneCopy() {
|
||||
;
|
||||
}
|
||||
|
||||
/*
|
||||
** viaKaa structure
|
||||
**
|
||||
** Description:
|
||||
** Structure to contain function pointers to accelerated KAA operations
|
||||
** in this driver.
|
||||
*/
|
||||
KaaScreenInfoRec viaKaa = {
|
||||
viaPrepareSolid,
|
||||
viaSolid,
|
||||
viaDoneSolid,
|
||||
|
||||
viaPrepareCopy,
|
||||
viaCopy,
|
||||
viaDoneCopy,
|
||||
};
|
||||
|
||||
/*
|
||||
** Bool viaDrawInit( ScreenPtr pScreen )
|
||||
**
|
||||
** Description:
|
||||
** Initialize the 2D acceleration hardware and register the KAA
|
||||
** acceleration layer with the VIA acceleration functions (above).
|
||||
**
|
||||
** Arguments:
|
||||
** pScreen Pointer to screen structure for the screen we're
|
||||
** enabling acceleration on.
|
||||
**
|
||||
** Return:
|
||||
** TRUE initialization and setup of KAA acceleration was successful.
|
||||
** FALSE initialization and setup of KAA acceleration failed.
|
||||
*/
|
||||
Bool
|
||||
viaDrawInit( ScreenPtr pScreen ) {
|
||||
KdScreenPriv( pScreen );
|
||||
ViaCardInfo* viac = pScreenPriv->card->driver;
|
||||
CARD32 geMode = 0;
|
||||
|
||||
if( !viac ) return FALSE;
|
||||
DebugF( "viac->mapBase = 0x%x\n", viac->mapBase );
|
||||
|
||||
/*
|
||||
** We reset the 2D engine to a known state by setting all of it's
|
||||
** registers to zero.
|
||||
*/
|
||||
OUTREG32( VIA_REG_GEMODE, 0x0 );
|
||||
OUTREG32( VIA_REG_SRCPOS, 0x0 );
|
||||
OUTREG32( VIA_REG_DSTPOS, 0x0 );
|
||||
OUTREG32( VIA_REG_DIMENSION, 0x0 );
|
||||
OUTREG32( VIA_REG_PATADDR, 0x0 );
|
||||
OUTREG32( VIA_REG_FGCOLOR, 0x0 );
|
||||
OUTREG32( VIA_REG_BGCOLOR, 0x0 );
|
||||
OUTREG32( VIA_REG_CLIPTL, 0x0 );
|
||||
OUTREG32( VIA_REG_CLIPBR, 0x0 );
|
||||
OUTREG32( VIA_REG_OFFSET, 0x0 );
|
||||
OUTREG32( VIA_REG_KEYCONTROL, 0x0 );
|
||||
OUTREG32( VIA_REG_SRCBASE, 0x0 );
|
||||
OUTREG32( VIA_REG_DSTBASE, 0x0 );
|
||||
OUTREG32( VIA_REG_PITCH, 0x0 );
|
||||
OUTREG32( VIA_REG_MONOPAT0, 0x0 );
|
||||
OUTREG32( VIA_REG_MONOPAT1, 0x0 );
|
||||
|
||||
/*
|
||||
** Set the GE mode up.
|
||||
** XXX: What happens in 24bpp mode?
|
||||
*/
|
||||
switch( pScreenPriv->screen->fb[0].bitsPerPixel ) {
|
||||
case 16:
|
||||
geMode = VIA_GEM_16bpp;
|
||||
break;
|
||||
case 32:
|
||||
geMode = VIA_GEM_32bpp;
|
||||
break;
|
||||
default:
|
||||
geMode = VIA_GEM_8bpp;
|
||||
break;
|
||||
}
|
||||
|
||||
OUTREG32( VIA_REG_GEMODE, geMode );
|
||||
|
||||
/*
|
||||
** Set the source and destination base addresses, and set pitch.
|
||||
*/
|
||||
OUTREG32( VIA_REG_SRCBASE, 0x0 );
|
||||
OUTREG32( VIA_REG_DSTBASE, 0x0 );
|
||||
OUTREG32( VIA_REG_PITCH, VIA_PITCH_ENABLE |
|
||||
((pScreen->width * pScreenPriv->screen->fb[0].bitsPerPixel >> 3) >> 3) |
|
||||
(((pScreen->width * pScreenPriv->screen->fb[0].bitsPerPixel >> 3) >> 3) << 16));
|
||||
|
||||
DebugF( "Initialized 2D engine!\n" );
|
||||
|
||||
return kaaDrawInit( pScreen, &viaKaa );
|
||||
}
|
||||
|
||||
/*
|
||||
** void viaDrawEnable( ScreenPtr pScreen )
|
||||
**
|
||||
** Description:
|
||||
** Enable accelerated drawing on the specified screen.
|
||||
**
|
||||
** Arguments:
|
||||
** pScreen Pointer to screen structure for the screen we're
|
||||
** enabling acceleration on.
|
||||
**
|
||||
** Return:
|
||||
** None.
|
||||
*/
|
||||
void
|
||||
viaDrawEnable( ScreenPtr pScreen ) {
|
||||
KdMarkSync( pScreen );
|
||||
}
|
||||
|
||||
/*
|
||||
** void viaDrawDisable( ScreenPtr pScreen )
|
||||
**
|
||||
** Description:
|
||||
** Disable accelerated drawing to the specified screen.
|
||||
**
|
||||
** Arguments:
|
||||
** pScreen Pointer to screen structure for the screen we're
|
||||
** disabling acceleration on.
|
||||
**
|
||||
** Return:
|
||||
** None
|
||||
*/
|
||||
void
|
||||
viaDrawDisable( ScreenPtr pScreen ) {
|
||||
}
|
||||
|
||||
/*
|
||||
** void viaDrawFini( ScreenPtr pScreen )
|
||||
**
|
||||
** Description:
|
||||
** Shutdown accelerated drawing and free associated strucures and
|
||||
** resources.
|
||||
**
|
||||
** Arguments:
|
||||
** pScreen Pointer to screen structure for the screen we're
|
||||
** disabling acceleration on.
|
||||
**
|
||||
** Return:
|
||||
** None.
|
||||
*/
|
||||
void
|
||||
viaDrawFini( ScreenPtr pScreen ) {
|
||||
}
|
||||
|
||||
/*
|
||||
** void viaDrawSync( ScreenPtr pScreen )
|
||||
**
|
||||
** Description:
|
||||
** Block until the graphics chip has finished all outstanding drawing
|
||||
** operations and the framebuffer contents is static.
|
||||
**
|
||||
** Arguments:
|
||||
** pScreen Pointer to screen strucutre for the screen we're
|
||||
** waiting for drawing to end on.
|
||||
**
|
||||
** Return:
|
||||
** None.
|
||||
*/
|
||||
void
|
||||
viaDrawSync( ScreenPtr pScreen ) {
|
||||
KdScreenPriv( pScreen );
|
||||
ViaCardInfo* viac = pScreenPriv->card->driver;
|
||||
|
||||
viaWaitIdle( viac );
|
||||
}
|
||||
|
45
hw/kdrive/via/viadraw.h
Normal file
45
hw/kdrive/via/viadraw.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright © 2004 Ralph Thomas
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Ralph Thomas not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Ralph Thomas makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* RALPH THOMAS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL RALPH THOMAS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
/*
|
||||
** VIA CLE266 driver
|
||||
** Copyright 2004 (C) Ralph Thomas <ralpht@gmail.com>
|
||||
**
|
||||
** http://www.viatech.com.tw/
|
||||
**
|
||||
** This header has some function prototypes for the hardware
|
||||
** accelerated drawing code in viadraw.c.
|
||||
*/
|
||||
|
||||
#ifndef _VIA_DRAW_H_
|
||||
#define _VIA_DRAW_H_
|
||||
|
||||
/*
|
||||
** More information on these functions is in viadraw.c.
|
||||
*/
|
||||
void viaWaitIdle( ViaCardInfo* card );
|
||||
Bool viaDrawInit( ScreenPtr pScreen );
|
||||
void viaDrawEnable( ScreenPtr pScreen );
|
||||
void viaDrawDisable( ScreenPtr pScreen );
|
||||
void viaDrawFini( ScreenPtr pScreen );
|
||||
void viaDrawSync( ScreenPtr pScreen );
|
||||
|
||||
#endif
|
134
hw/kdrive/via/viastub.c
Normal file
134
hw/kdrive/via/viastub.c
Normal file
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
* Copyright © 2004 Ralph Thomas
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Ralph Thomas not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Ralph Thomas makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* RALPH THOMAS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL RALPH THOMAS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
/*
|
||||
** VIA CLE266 driver
|
||||
** Copyright 2004 (C) Ralph Thomas <ralpht@gmail.com>
|
||||
**
|
||||
** http://www.viatech.com.tw/
|
||||
**
|
||||
** This is the stub code which links the VIA drawing code into the kdrive
|
||||
** framework.
|
||||
*/
|
||||
|
||||
#include "via.h"
|
||||
#include <klinux.h>
|
||||
|
||||
/*
|
||||
** void InitCard( char* name )
|
||||
**
|
||||
** Description:
|
||||
** Initialize the graphics chip. We find the chip on the PCI bus,
|
||||
** register the functions to access the chip.
|
||||
**
|
||||
** Arguments:
|
||||
** name XXX: unknown.
|
||||
**
|
||||
** Return:
|
||||
** None.
|
||||
*/
|
||||
void
|
||||
InitCard( char* name ) {
|
||||
KdCardAttr attr;
|
||||
|
||||
if( LinuxFindPci( 0x1106, 0x3122, 0, &attr ) )
|
||||
KdCardInfoAdd( &viaFuncs, &attr, 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
** void InitOutput( ScreenInfo* pScreenInfo, int argc, char** argv )
|
||||
**
|
||||
** Description:
|
||||
** Initialize I/O, or something. XXX: Or what?
|
||||
**
|
||||
** Arguments:
|
||||
** pScreenInfo XXX
|
||||
** argc command line argument count
|
||||
** argv command line arguments
|
||||
**
|
||||
** Return:
|
||||
** None.
|
||||
*/
|
||||
void
|
||||
InitOutput( ScreenInfo* pScreenInfo, int argc, char** argv ) {
|
||||
KdInitOutput( pScreenInfo, argc, argv );
|
||||
}
|
||||
|
||||
/*
|
||||
** void InitInput( int argc, char** argv )
|
||||
**
|
||||
** Description:
|
||||
** Initialize keyboard and mouse input.
|
||||
**
|
||||
** Arguments:
|
||||
** argc command line argument count
|
||||
** argv command line arguments
|
||||
**
|
||||
** Return:
|
||||
** None.
|
||||
*/
|
||||
void
|
||||
InitInput( int argc, char** argv ) {
|
||||
KdInitInput( &LinuxMouseFuncs, &LinuxKeyboardFuncs );
|
||||
}
|
||||
|
||||
/*
|
||||
** void ddxUseMsg()
|
||||
**
|
||||
** Description:
|
||||
** Print the usage message for Xvia.
|
||||
**
|
||||
** Arguments:
|
||||
** None.
|
||||
**
|
||||
** Return:
|
||||
** None.
|
||||
*/
|
||||
void
|
||||
ddxUseMsg() {
|
||||
KdUseMsg();
|
||||
vesaUseMsg();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** int ddxProcessArgument( int argc, char** argv, int i )
|
||||
**
|
||||
** Description:
|
||||
** Process a single command line argument.
|
||||
**
|
||||
** Arguments:
|
||||
** argc command line argument count
|
||||
** argv command line arguments
|
||||
** i number of argument to process
|
||||
**
|
||||
** Return:
|
||||
** some values.
|
||||
*/
|
||||
int
|
||||
ddxProcessArgument( int argc, char** argv, int i ) {
|
||||
int ret;
|
||||
|
||||
if( !( ret = vesaProcessArgument( argc, argv, i ) ))
|
||||
ret = KdProcessArgument( argc, argv, i );
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user