Add ATI Rage 128 server.
This commit is contained in:
		
							parent
							
								
									ed98d3814e
								
							
						
					
					
						commit
						ab3305d0ac
					
				| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
if KDRIVEVESA
 | 
			
		||||
VESA_SUBDIRS = vesa mach64 mga nvidia
 | 
			
		||||
VESA_SUBDIRS = vesa mach64 mga nvidia r128
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
SUBDIRS =	\
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,45 @@
 | 
			
		|||
INCLUDES = 					\
 | 
			
		||||
	-I$(top_srcdir)/fb			\
 | 
			
		||||
	-I$(top_srcdir)/hw/kdrive/src		\
 | 
			
		||||
	-I$(top_srcdir)/hw/kdrive/vesa		\
 | 
			
		||||
	-I$(top_srcdir)/include			\
 | 
			
		||||
	-I$(top_srcdir)/mi			\
 | 
			
		||||
	-I$(top_srcdir)/miext/layer		\
 | 
			
		||||
	-I$(top_srcdir)/miext/shadow		\
 | 
			
		||||
	-I$(top_srcdir)/randr			\
 | 
			
		||||
	-I$(top_srcdir)/render			\
 | 
			
		||||
	$(XSERVER_CFLAGS)
 | 
			
		||||
 | 
			
		||||
bin_PROGRAMS = Xr128
 | 
			
		||||
 | 
			
		||||
noinst_LIBRARIES = libr128.a
 | 
			
		||||
 | 
			
		||||
libr128_a_SOURCES = 	\
 | 
			
		||||
	r128draw.c	\
 | 
			
		||||
	r128.c		\
 | 
			
		||||
	r128.h	
 | 
			
		||||
 | 
			
		||||
Xr128_SOURCES = \
 | 
			
		||||
	r128stub.c
 | 
			
		||||
 | 
			
		||||
Xr128_LDADD = \
 | 
			
		||||
	$(top_builddir)/hw/kdrive/r128/libr128.a \
 | 
			
		||||
	$(top_builddir)/hw/kdrive/vesa/libvesa.a \
 | 
			
		||||
	$(top_builddir)/dix/libdix.a		\
 | 
			
		||||
	$(top_builddir)/os/libos.a		\
 | 
			
		||||
	$(top_builddir)/miext/layer/liblayer.a	\
 | 
			
		||||
	$(top_builddir)/hw/kdrive/src/libkdrive.a  \
 | 
			
		||||
	$(top_builddir)/hw/kdrive/linux/liblinux.a  \
 | 
			
		||||
	$(top_builddir)/miext/shadow/libshadow.a \
 | 
			
		||||
	$(top_builddir)/randr/librandr.a	\
 | 
			
		||||
	$(top_builddir)/render/librender.a	\
 | 
			
		||||
	$(top_builddir)/xfixes/libxfixes.a	\
 | 
			
		||||
	$(top_builddir)/fb/libfb.a		\
 | 
			
		||||
	$(top_builddir)/mi/libmi.a		\
 | 
			
		||||
	$(top_builddir)/Xext/libXext.a		\
 | 
			
		||||
	$(top_builddir)/randr/librandr.a	\
 | 
			
		||||
	$(top_builddir)/render/librender.a	\
 | 
			
		||||
	$(top_builddir)/xfixes/libxfixes.a	\
 | 
			
		||||
	$(top_builddir)/dix/libxpstubs.a	\
 | 
			
		||||
	$(XSERVER_LIBS)				\
 | 
			
		||||
	-lm -lz
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,256 @@
 | 
			
		|||
/*
 | 
			
		||||
 * $Id$
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright © 2003 Anders Carlsson
 | 
			
		||||
 *
 | 
			
		||||
 * 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 Anders Carlsson not be used in
 | 
			
		||||
 * advertising or publicity pertaining to distribution of the software without
 | 
			
		||||
 * specific, written prior permission.  Anders Carlsson makes no
 | 
			
		||||
 * representations about the suitability of this software for any purpose.  It
 | 
			
		||||
 * is provided "as is" without express or implied warranty.
 | 
			
		||||
 *
 | 
			
		||||
 * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 | 
			
		||||
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 | 
			
		||||
 * EVENT SHALL ANDERS CARLSSON 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.
 | 
			
		||||
 */
 | 
			
		||||
/* $Header$ */
 | 
			
		||||
#ifdef HAVE_CONFIG_H
 | 
			
		||||
#include <config.h>
 | 
			
		||||
#endif
 | 
			
		||||
#include "r128.h"
 | 
			
		||||
 | 
			
		||||
Bool
 | 
			
		||||
r128CardInit (KdCardInfo *card)
 | 
			
		||||
{
 | 
			
		||||
    R128CardInfo *r128c;
 | 
			
		||||
 | 
			
		||||
    r128c = (R128CardInfo *) xalloc (sizeof (R128CardInfo));
 | 
			
		||||
    if (!r128c)
 | 
			
		||||
	return FALSE;
 | 
			
		||||
 | 
			
		||||
    r128MapReg (card, r128c);
 | 
			
		||||
 | 
			
		||||
    if (!vesaInitialize (card, &r128c->vesa))
 | 
			
		||||
    {
 | 
			
		||||
	xfree (r128c);
 | 
			
		||||
	return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    r128c->fifo_size = 0;
 | 
			
		||||
    
 | 
			
		||||
    card->driver = r128c;
 | 
			
		||||
 | 
			
		||||
    return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Bool
 | 
			
		||||
r128ScreenInit (KdScreenInfo *screen)
 | 
			
		||||
{
 | 
			
		||||
    R128CardInfo *r128c = screen->card->driver;
 | 
			
		||||
    R128ScreenInfo *r128s;
 | 
			
		||||
    int screen_size, memory;
 | 
			
		||||
 | 
			
		||||
    r128s = (R128ScreenInfo *) xalloc (sizeof (R128ScreenInfo));
 | 
			
		||||
    if (!r128s)
 | 
			
		||||
	return FALSE;
 | 
			
		||||
    memset (r128s, '\0', sizeof (R128ScreenInfo));
 | 
			
		||||
    if (!vesaScreenInitialize (screen, &r128s->vesa))
 | 
			
		||||
    {
 | 
			
		||||
	xfree (r128s);
 | 
			
		||||
	return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
#if 0    
 | 
			
		||||
    /* if (!r128c->reg)
 | 
			
		||||
       screen->dumb = TRUE; */
 | 
			
		||||
 | 
			
		||||
    if (r128s->vesa.mapping != VESA_LINEAR)
 | 
			
		||||
	screen->dumb = TRUE;
 | 
			
		||||
 | 
			
		||||
    fprintf (stderr, "vesa mapping is %d\n", r128s->vesa.mapping);
 | 
			
		||||
#endif    
 | 
			
		||||
    r128s->screen = r128s->vesa.fb;
 | 
			
		||||
 | 
			
		||||
    memory = r128s->vesa.fb_size;
 | 
			
		||||
    screen_size = screen->fb[0].byteStride * screen->height;
 | 
			
		||||
 | 
			
		||||
    memory -= screen_size;
 | 
			
		||||
    if (memory > screen->fb[0].byteStride)
 | 
			
		||||
    {
 | 
			
		||||
	r128s->off_screen = r128s->screen + screen_size;
 | 
			
		||||
	r128s->off_screen_size = memory;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
	r128s->off_screen = 0;
 | 
			
		||||
	r128s->off_screen_size = 0;
 | 
			
		||||
    }
 | 
			
		||||
    screen->driver = r128s;
 | 
			
		||||
    return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Bool
 | 
			
		||||
r128InitScreen (ScreenPtr pScreen)
 | 
			
		||||
{
 | 
			
		||||
    return vesaInitScreen (pScreen);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Bool
 | 
			
		||||
r128FinishInitScreen (ScreenPtr pScreen)
 | 
			
		||||
{
 | 
			
		||||
    Bool ret;
 | 
			
		||||
 | 
			
		||||
    ret = vesaFinishInitScreen (pScreen);
 | 
			
		||||
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128Preserve (KdCardInfo *card)
 | 
			
		||||
{
 | 
			
		||||
    R128CardInfo *r128c = card->driver;
 | 
			
		||||
 | 
			
		||||
    vesaPreserve (card);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Bool
 | 
			
		||||
r128MapReg (KdCardInfo *card, R128CardInfo *r128c)
 | 
			
		||||
{
 | 
			
		||||
    r128c->reg_base = (CARD8 *) KdMapDevice (R128_REG_BASE (card),
 | 
			
		||||
					     R128_REG_SIZE (card));
 | 
			
		||||
 | 
			
		||||
    if (!r128c->reg_base)
 | 
			
		||||
    {
 | 
			
		||||
	return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    KdSetMappedMode (R128_REG_BASE (card),
 | 
			
		||||
		     R128_REG_SIZE (card),
 | 
			
		||||
		     KD_MAPPED_MODE_REGISTERS);
 | 
			
		||||
 | 
			
		||||
    return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128UnmapReg (KdCardInfo *card, R128CardInfo *r128c)
 | 
			
		||||
{
 | 
			
		||||
    if (r128c->reg_base)
 | 
			
		||||
    {
 | 
			
		||||
	KdResetMappedMode (R128_REG_BASE (card),
 | 
			
		||||
			   R128_REG_SIZE (card),
 | 
			
		||||
			   KD_MAPPED_MODE_REGISTERS);
 | 
			
		||||
	KdUnmapDevice ((void *) r128c->reg_base, R128_REG_SIZE (card));
 | 
			
		||||
	r128c->reg_base = 0;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128SetMMIO (KdCardInfo *card, R128CardInfo *r128c)
 | 
			
		||||
{
 | 
			
		||||
    if (!r128c->reg_base)
 | 
			
		||||
	r128MapReg (card, r128c);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128ResetMMIO (KdCardInfo *card, R128CardInfo *r128c)
 | 
			
		||||
{
 | 
			
		||||
    r128UnmapReg (card, r128c);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Bool
 | 
			
		||||
r128Enable (ScreenPtr pScreen)
 | 
			
		||||
{
 | 
			
		||||
    KdScreenPriv (pScreen);
 | 
			
		||||
    R128CardInfo *r128c = pScreenPriv->card->driver;
 | 
			
		||||
 | 
			
		||||
    if (!vesaEnable (pScreen))
 | 
			
		||||
	return FALSE;
 | 
			
		||||
    
 | 
			
		||||
    r128SetMMIO (pScreenPriv->card, r128c);
 | 
			
		||||
    r128DPMS (pScreen, KD_DPMS_NORMAL);
 | 
			
		||||
    
 | 
			
		||||
    return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128Disable (ScreenPtr pScreen)
 | 
			
		||||
{
 | 
			
		||||
    KdScreenPriv (pScreen);
 | 
			
		||||
    R128CardInfo *r128c = pScreenPriv->card->driver;
 | 
			
		||||
 | 
			
		||||
    r128ResetMMIO (pScreenPriv->card, r128c);
 | 
			
		||||
    vesaDisable (pScreen);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Bool
 | 
			
		||||
r128DPMS (ScreenPtr pScreen, int mode)
 | 
			
		||||
{
 | 
			
		||||
    /* XXX */
 | 
			
		||||
    return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128Restore (KdCardInfo *card)
 | 
			
		||||
{
 | 
			
		||||
    R128CardInfo *r128c = card->driver;
 | 
			
		||||
    
 | 
			
		||||
    r128ResetMMIO (card, r128c);
 | 
			
		||||
    vesaRestore (card);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128ScreenFini (KdScreenInfo *screen)
 | 
			
		||||
{
 | 
			
		||||
    R128ScreenInfo *r128s = (R128ScreenInfo *) screen->driver;
 | 
			
		||||
 | 
			
		||||
    vesaScreenFini (screen);
 | 
			
		||||
    xfree (r128s);
 | 
			
		||||
    screen->driver = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128CardFini (KdCardInfo *card)
 | 
			
		||||
{
 | 
			
		||||
    R128CardInfo *r128c = (R128CardInfo *)card->driver;
 | 
			
		||||
 | 
			
		||||
    r128UnmapReg (card, r128c);
 | 
			
		||||
    vesaCardFini (card);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
KdCardFuncs r128Funcs = {
 | 
			
		||||
    r128CardInit,	/* cardinit */
 | 
			
		||||
    r128ScreenInit,	/* scrinit */
 | 
			
		||||
    r128InitScreen,	/* initScreen */
 | 
			
		||||
    r128Preserve,	/* preserve */
 | 
			
		||||
    r128Enable,		/* enable */
 | 
			
		||||
    r128DPMS,		/* dpms */
 | 
			
		||||
    r128Disable,	/* disable */
 | 
			
		||||
    r128Restore,	/* restore */
 | 
			
		||||
    r128ScreenFini,	/* scrfini */
 | 
			
		||||
    r128CardFini,	/* cardfini */
 | 
			
		||||
    
 | 
			
		||||
    0,			/* initCursor */
 | 
			
		||||
    0,			/* enableCursor */
 | 
			
		||||
    0,			/* disableCursor */
 | 
			
		||||
    0,			/* finiCursor */
 | 
			
		||||
    0,			/* recolorCursor */
 | 
			
		||||
    
 | 
			
		||||
    r128DrawInit,	/* initAccel */
 | 
			
		||||
    r128DrawEnable,	/* enableAccel */
 | 
			
		||||
    r128DrawSync,	/* syncAccel */
 | 
			
		||||
    r128DrawDisable,	/* disableAccel */
 | 
			
		||||
    r128DrawFini,	/* finiAccel */
 | 
			
		||||
    
 | 
			
		||||
    vesaGetColors,    	 /* getColors */
 | 
			
		||||
    vesaPutColors,	 /* putColors */
 | 
			
		||||
 | 
			
		||||
    r128FinishInitScreen, /* finishInitScreen */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,121 @@
 | 
			
		|||
/*
 | 
			
		||||
 * $Id$
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright © 2003 Anders Carlsson
 | 
			
		||||
 *
 | 
			
		||||
 * 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 Anders Carlsson not be used in
 | 
			
		||||
 * advertising or publicity pertaining to distribution of the software without
 | 
			
		||||
 * specific, written prior permission.  Anders Carlsson makes no
 | 
			
		||||
 * representations about the suitability of this software for any purpose.  It
 | 
			
		||||
 * is provided "as is" without express or implied warranty.
 | 
			
		||||
 *
 | 
			
		||||
 * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 | 
			
		||||
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 | 
			
		||||
 * EVENT SHALL ANDERS CARLSSON 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.
 | 
			
		||||
 */
 | 
			
		||||
/* $Header$ */
 | 
			
		||||
 | 
			
		||||
#ifndef _R128_H_
 | 
			
		||||
#define _R128_H_
 | 
			
		||||
#include <vesa.h>
 | 
			
		||||
 | 
			
		||||
#define R128_REG_BASE(c)	    ((c)->attr.address[1])
 | 
			
		||||
#define R128_REG_SIZE(c)	    (0x4000)
 | 
			
		||||
 | 
			
		||||
#define R128_OUT32(mmio, a, v) (*(VOL32 *) ((mmio) + (a)) = (v))
 | 
			
		||||
#define R128_IN32(mmio, a) (*(VOL32 *) ((mmio) + (a)))
 | 
			
		||||
 | 
			
		||||
#define R128_REG_GUI_STAT		0x1740
 | 
			
		||||
#define R128_REG_DEFAULT_OFFSET 	0x16e0
 | 
			
		||||
#define R128_REG_DEFAULT_PITCH		0x16e4
 | 
			
		||||
#define R128_REG_DP_GUI_MASTER_CNTL	0x146c
 | 
			
		||||
#define R128_REG_DP_BRUSH_FRGD_CLR      0x147c
 | 
			
		||||
#define R128_REG_DP_WRITE_MASK          0x16cc
 | 
			
		||||
#define R128_REG_DP_CNTL                0x16c0
 | 
			
		||||
#define R128_REG_DST_WIDTH_HEIGHT       0x1598
 | 
			
		||||
#define R128_REG_DST_Y_X                0x1438
 | 
			
		||||
#define R128_REG_PC_NGUI_CTLSTAT	0x0184
 | 
			
		||||
#define R128_REG_DST_HEIGHT_WIDTH       0x143c
 | 
			
		||||
#define R128_REG_SRC_Y_X                0x1434
 | 
			
		||||
 | 
			
		||||
#define R128_GMC_DST_DATATYPE_SHIFT     8
 | 
			
		||||
#define R128_GMC_CLR_CMP_CNTL_DIS       (1 << 28)
 | 
			
		||||
#define R128_GMC_AUX_CLIP_DIS           (1 << 29)
 | 
			
		||||
#define R128_GMC_BRUSH_SOLID_COLOR      (13 << 4)
 | 
			
		||||
#define R128_GMC_SRC_DATATYPE_COLOR     (3 << 12)
 | 
			
		||||
#define R128_GMC_ROP3_SHIFT		16
 | 
			
		||||
#define R128_DST_X_LEFT_TO_RIGHT        (1 <<  0)
 | 
			
		||||
#define R128_DST_Y_TOP_TO_BOTTOM        (1 <<  1)
 | 
			
		||||
#define R128_GUI_ACTIVE			(1 << 31)
 | 
			
		||||
#define R128_PC_BUSY                    (1 << 31)
 | 
			
		||||
#define R128_DP_SRC_SOURCE_MEMORY       (2 << 24)
 | 
			
		||||
 | 
			
		||||
typedef volatile CARD8	VOL8;
 | 
			
		||||
typedef volatile CARD16	VOL16;
 | 
			
		||||
typedef volatile CARD32	VOL32;
 | 
			
		||||
			 
 | 
			
		||||
typedef struct _r128CardInfo {
 | 
			
		||||
    VesaCardPrivRec vesa;
 | 
			
		||||
    CARD8 *reg_base;
 | 
			
		||||
    int fifo_size;
 | 
			
		||||
} R128CardInfo;
 | 
			
		||||
 | 
			
		||||
#define getR128CardInfo(kd) ((R128CardInfo *) ((kd)->card->driver))
 | 
			
		||||
#define r128CardInfo(kd)	R128CardInfo *r128c = getR128CardInfo(kd)
 | 
			
		||||
 | 
			
		||||
typedef struct _r128ScreenInfo {
 | 
			
		||||
    VesaScreenPrivRec vesa;
 | 
			
		||||
    CARD8 *screen;
 | 
			
		||||
    CARD8 *off_screen;
 | 
			
		||||
    int off_screen_size;
 | 
			
		||||
 | 
			
		||||
    int pitch;
 | 
			
		||||
    int datatype;
 | 
			
		||||
 | 
			
		||||
    int dp_gui_master_cntl;
 | 
			
		||||
} R128ScreenInfo;
 | 
			
		||||
 | 
			
		||||
#define getR128ScreenInfo(kd) ((R128ScreenInfo *) ((kd)->screen->driver))
 | 
			
		||||
#define r128ScreenInfo(kd)    R128ScreenInfo *r128s = getR128ScreenInfo(kd)
 | 
			
		||||
 | 
			
		||||
Bool
 | 
			
		||||
r128MapReg (KdCardInfo *card, R128CardInfo *r128c);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128UnmapReg (KdCardInfo *card, R128CardInfo *r128c);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128SetMMIO (KdCardInfo *card, R128CardInfo *r128c);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128ResetMMIO (KdCardInfo *card, R128CardInfo *r128c);
 | 
			
		||||
 | 
			
		||||
Bool
 | 
			
		||||
r128DrawSetup (ScreenPtr pScreen);
 | 
			
		||||
 | 
			
		||||
Bool
 | 
			
		||||
r128DrawInit (ScreenPtr pScreen);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128DrawEnable (ScreenPtr pScreen);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128DrawSync (ScreenPtr pScreen);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128DrawDisable (ScreenPtr pScreen);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128DrawFini (ScreenPtr pScreen);
 | 
			
		||||
 | 
			
		||||
extern KdCardFuncs  r128Funcs;
 | 
			
		||||
 | 
			
		||||
#endif /* _R128_H_ */
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,290 @@
 | 
			
		|||
/*
 | 
			
		||||
 * $Id$
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright © 2003 Anders Carlsson
 | 
			
		||||
 *
 | 
			
		||||
 * 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 Anders Carlsson not be used in
 | 
			
		||||
 * advertising or publicity pertaining to distribution of the software without
 | 
			
		||||
 * specific, written prior permission.  Anders Carlsson makes no
 | 
			
		||||
 * representations about the suitability of this software for any purpose.  It
 | 
			
		||||
 * is provided "as is" without express or implied warranty.
 | 
			
		||||
 *
 | 
			
		||||
 * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 | 
			
		||||
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 | 
			
		||||
 * EVENT SHALL ANDERS CARLSSON 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.
 | 
			
		||||
 */
 | 
			
		||||
/* $Header$ */
 | 
			
		||||
#ifdef HAVE_CONFIG_H
 | 
			
		||||
#include <config.h>
 | 
			
		||||
#endif
 | 
			
		||||
#include "r128.h"
 | 
			
		||||
 | 
			
		||||
CARD8 r128SolidRop[16] = {
 | 
			
		||||
    /* GXclear      */      0x00,         /* 0 */
 | 
			
		||||
    /* GXand        */      0xa0,         /* src AND dst */
 | 
			
		||||
    /* GXandReverse */      0x50,         /* src AND NOT dst */
 | 
			
		||||
    /* GXcopy       */      0xf0,         /* src */
 | 
			
		||||
    /* GXandInverted*/      0x0a,         /* NOT src AND dst */
 | 
			
		||||
    /* GXnoop       */      0xaa,         /* dst */
 | 
			
		||||
    /* GXxor        */      0x5a,         /* src XOR dst */
 | 
			
		||||
    /* GXor         */      0xfa,         /* src OR dst */
 | 
			
		||||
    /* GXnor        */      0x05,         /* NOT src AND NOT dst */
 | 
			
		||||
    /* GXequiv      */      0xa5,         /* NOT src XOR dst */
 | 
			
		||||
    /* GXinvert     */      0x55,         /* NOT dst */
 | 
			
		||||
    /* GXorReverse  */      0xf5,         /* src OR NOT dst */
 | 
			
		||||
    /* GXcopyInverted*/     0x0f,         /* NOT src */
 | 
			
		||||
    /* GXorInverted */      0xaf,         /* NOT src OR dst */
 | 
			
		||||
    /* GXnand       */      0x5f,         /* NOT src OR NOT dst */
 | 
			
		||||
    /* GXset        */      0xff,         /* 1 */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
CARD8 r128BltRop[16] = {
 | 
			
		||||
    /* GXclear      */      0x00,         /* 0 */
 | 
			
		||||
    /* GXand        */      0x88,         /* src AND dst */
 | 
			
		||||
    /* GXandReverse */      0x44,         /* src AND NOT dst */
 | 
			
		||||
    /* GXcopy       */      0xcc,         /* src */
 | 
			
		||||
    /* GXandInverted*/      0x22,         /* NOT src AND dst */
 | 
			
		||||
    /* GXnoop       */      0xaa,         /* dst */
 | 
			
		||||
    /* GXxor        */      0x66,         /* src XOR dst */
 | 
			
		||||
    /* GXor         */      0xee,         /* src OR dst */
 | 
			
		||||
    /* GXnor        */      0x11,         /* NOT src AND NOT dst */
 | 
			
		||||
    /* GXequiv      */      0x99,         /* NOT src XOR dst */
 | 
			
		||||
    /* GXinvert     */      0x55,         /* NOT dst */
 | 
			
		||||
    /* GXorReverse  */      0xdd,         /* src OR NOT dst */
 | 
			
		||||
    /* GXcopyInverted*/     0x33,         /* NOT src */
 | 
			
		||||
    /* GXorInverted */      0xbb,         /* NOT src OR dst */
 | 
			
		||||
    /* GXnand       */      0x77,         /* NOT src OR NOT dst */
 | 
			
		||||
    /* GXset        */      0xff,         /* 1 */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
int copydx, copydy;
 | 
			
		||||
int fifo_size;
 | 
			
		||||
char *mmio;
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128WaitAvail (int n)
 | 
			
		||||
{
 | 
			
		||||
    int i;
 | 
			
		||||
 | 
			
		||||
    if (fifo_size < n)
 | 
			
		||||
    {
 | 
			
		||||
	while ((fifo_size = R128_IN32 (mmio, R128_REG_GUI_STAT) & 0xfff) < n)
 | 
			
		||||
	    ;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    fifo_size -= n;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128WaitIdle (void)
 | 
			
		||||
{
 | 
			
		||||
    int tries;
 | 
			
		||||
    
 | 
			
		||||
    r128WaitAvail (64);
 | 
			
		||||
 | 
			
		||||
    tries = 1000000;
 | 
			
		||||
    while (tries--)
 | 
			
		||||
    {
 | 
			
		||||
	if ((R128_IN32 (mmio, R128_REG_GUI_STAT) & R128_GUI_ACTIVE) == 0)
 | 
			
		||||
	    break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    R128_OUT32 (mmio, R128_REG_PC_NGUI_CTLSTAT,
 | 
			
		||||
		R128_IN32 (mmio, R128_REG_PC_NGUI_CTLSTAT | 0xff));
 | 
			
		||||
 | 
			
		||||
    tries = 1000000;
 | 
			
		||||
    while (tries--)
 | 
			
		||||
    {
 | 
			
		||||
	if ((R128_IN32 (mmio, R128_REG_PC_NGUI_CTLSTAT) & R128_PC_BUSY) != R128_PC_BUSY)
 | 
			
		||||
	    break;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Bool
 | 
			
		||||
r128Setup (ScreenPtr pScreen, int wait)
 | 
			
		||||
{
 | 
			
		||||
  KdScreenPriv (pScreen);
 | 
			
		||||
  r128ScreenInfo (pScreenPriv);
 | 
			
		||||
  r128CardInfo (pScreenPriv);
 | 
			
		||||
 | 
			
		||||
  fifo_size = 0;
 | 
			
		||||
 | 
			
		||||
  mmio = r128c->reg_base;
 | 
			
		||||
    
 | 
			
		||||
  if (!mmio)
 | 
			
		||||
      return FALSE;
 | 
			
		||||
 | 
			
		||||
  r128WaitAvail (2);
 | 
			
		||||
  R128_OUT32 (mmio, R128_REG_DEFAULT_OFFSET, 0);
 | 
			
		||||
  R128_OUT32 (mmio, R128_REG_DEFAULT_PITCH, r128s->pitch);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Bool
 | 
			
		||||
r128PrepareSolid (DrawablePtr pDrawable, int alu, Pixel pm, Pixel fg)
 | 
			
		||||
{
 | 
			
		||||
    KdScreenPriv (pDrawable->pScreen);
 | 
			
		||||
    r128ScreenInfo (pScreenPriv);
 | 
			
		||||
 | 
			
		||||
    r128Setup (pDrawable->pScreen, 4);
 | 
			
		||||
    R128_OUT32 (mmio, R128_REG_DP_GUI_MASTER_CNTL, r128s->dp_gui_master_cntl
 | 
			
		||||
		| R128_GMC_BRUSH_SOLID_COLOR
 | 
			
		||||
		| R128_GMC_SRC_DATATYPE_COLOR
 | 
			
		||||
		| (r128SolidRop[alu] << R128_GMC_ROP3_SHIFT));
 | 
			
		||||
    R128_OUT32 (mmio, R128_REG_DP_BRUSH_FRGD_CLR, fg);
 | 
			
		||||
    R128_OUT32 (mmio, R128_REG_DP_WRITE_MASK, pm);
 | 
			
		||||
    R128_OUT32 (mmio, R128_REG_DP_CNTL,
 | 
			
		||||
		(R128_DST_X_LEFT_TO_RIGHT | R128_DST_Y_TOP_TO_BOTTOM));
 | 
			
		||||
    
 | 
			
		||||
    return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128Solid (int x1, int y1, int x2, int y2)
 | 
			
		||||
{
 | 
			
		||||
    r128WaitAvail (2);
 | 
			
		||||
    R128_OUT32 (mmio, R128_REG_DST_Y_X, (y1 << 16) | x1);
 | 
			
		||||
    R128_OUT32 (mmio, R128_REG_DST_WIDTH_HEIGHT, ((x2 - x1) << 16) | (y2 - y1));
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128DoneSolid (void)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Bool
 | 
			
		||||
r128PrepareCopy (DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, int dx, int dy, int alu, Pixel pm)
 | 
			
		||||
{
 | 
			
		||||
    KdScreenPriv (pSrcDrawable->pScreen);
 | 
			
		||||
    r128ScreenInfo (pScreenPriv);
 | 
			
		||||
    
 | 
			
		||||
    copydx = dx;
 | 
			
		||||
    copydy = dy;
 | 
			
		||||
 | 
			
		||||
    r128Setup (pSrcDrawable->pScreen, 3);
 | 
			
		||||
    R128_OUT32 (mmio, R128_REG_DP_GUI_MASTER_CNTL, r128s->dp_gui_master_cntl
 | 
			
		||||
		| R128_GMC_BRUSH_SOLID_COLOR
 | 
			
		||||
		| R128_GMC_SRC_DATATYPE_COLOR
 | 
			
		||||
		| (r128BltRop[alu] << R128_GMC_ROP3_SHIFT)
 | 
			
		||||
		| R128_DP_SRC_SOURCE_MEMORY);
 | 
			
		||||
    R128_OUT32 (mmio, R128_REG_DP_WRITE_MASK, pm);
 | 
			
		||||
    R128_OUT32 (mmio, R128_REG_DP_CNTL,
 | 
			
		||||
		((dx >= 0 ? R128_DST_X_LEFT_TO_RIGHT : 0)
 | 
			
		||||
		 | (dy >= 0 ? R128_DST_Y_TOP_TO_BOTTOM : 0)));
 | 
			
		||||
		   
 | 
			
		||||
 | 
			
		||||
    return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128Copy (int srcX, int srcY, int dstX, int dstY, int w, int h)
 | 
			
		||||
{
 | 
			
		||||
    if (copydx < 0)
 | 
			
		||||
    {
 | 
			
		||||
	srcX += w - 1;
 | 
			
		||||
	dstX += w - 1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (copydy < 0)
 | 
			
		||||
    {
 | 
			
		||||
	srcY += h - 1;
 | 
			
		||||
	dstY += h - 1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    r128WaitAvail (3);
 | 
			
		||||
    R128_OUT32 (mmio, R128_REG_SRC_Y_X, (srcY << 16) | srcX);
 | 
			
		||||
    R128_OUT32 (mmio, R128_REG_DST_Y_X, (dstY << 16) | dstX);
 | 
			
		||||
    R128_OUT32 (mmio, R128_REG_DST_HEIGHT_WIDTH, (h << 16) | w);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128DoneCopy (void)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
KaaScreenPrivRec r128Kaa = {
 | 
			
		||||
    r128PrepareSolid,
 | 
			
		||||
    r128Solid,
 | 
			
		||||
    r128DoneSolid,
 | 
			
		||||
 | 
			
		||||
    r128PrepareCopy,
 | 
			
		||||
    r128Copy,
 | 
			
		||||
    r128DoneCopy,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
Bool
 | 
			
		||||
r128DrawInit (ScreenPtr pScreen)
 | 
			
		||||
{
 | 
			
		||||
    KdScreenPriv(pScreen);
 | 
			
		||||
 | 
			
		||||
    if (!kaaDrawInit (pScreen, &r128Kaa))
 | 
			
		||||
	return FALSE;
 | 
			
		||||
 | 
			
		||||
    return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128DrawEnable (ScreenPtr pScreen)
 | 
			
		||||
{
 | 
			
		||||
    KdScreenPriv (pScreen);
 | 
			
		||||
    r128ScreenInfo (pScreenPriv);
 | 
			
		||||
 | 
			
		||||
    r128s->pitch = pScreenPriv->screen->width >> 3;
 | 
			
		||||
    
 | 
			
		||||
    switch (pScreenPriv->screen->fb[0].depth) {
 | 
			
		||||
    case 8:
 | 
			
		||||
	r128s->datatype = 2;
 | 
			
		||||
	break;
 | 
			
		||||
    case 15:
 | 
			
		||||
	r128s->datatype = 3;
 | 
			
		||||
	break;	
 | 
			
		||||
    case 16:
 | 
			
		||||
	r128s->datatype = 4;
 | 
			
		||||
	break;
 | 
			
		||||
    case 24:
 | 
			
		||||
	r128s->datatype = 5;
 | 
			
		||||
	break;
 | 
			
		||||
    case 32:
 | 
			
		||||
	r128s->datatype = 6;
 | 
			
		||||
	break;
 | 
			
		||||
    default:
 | 
			
		||||
	FatalError ("unsupported pixel format");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    r128s->dp_gui_master_cntl = ((r128s->datatype << R128_GMC_DST_DATATYPE_SHIFT)
 | 
			
		||||
				 | R128_GMC_CLR_CMP_CNTL_DIS
 | 
			
		||||
				 | R128_GMC_AUX_CLIP_DIS);
 | 
			
		||||
    
 | 
			
		||||
    KdMarkSync (pScreen);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128DrawDisable (ScreenPtr pScreen)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128DrawFini (ScreenPtr pScreen)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
r128DrawSync (ScreenPtr pScreen)
 | 
			
		||||
{
 | 
			
		||||
    KdScreenPriv (pScreen);
 | 
			
		||||
    r128CardInfo (pScreenPriv);
 | 
			
		||||
 | 
			
		||||
    mmio = r128c->reg_base;
 | 
			
		||||
 | 
			
		||||
    r128WaitIdle ();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,59 @@
 | 
			
		|||
/*
 | 
			
		||||
 * $Id$
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright © 2003 Anders Carlsson
 | 
			
		||||
 *
 | 
			
		||||
 * 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 Anders Carlsson not be used in
 | 
			
		||||
 * advertising or publicity pertaining to distribution of the software without
 | 
			
		||||
 * specific, written prior permission.  Anders Carlsson makes no
 | 
			
		||||
 * representations about the suitability of this software for any purpose.  It
 | 
			
		||||
 * is provided "as is" without express or implied warranty.
 | 
			
		||||
 *
 | 
			
		||||
 * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 | 
			
		||||
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 | 
			
		||||
 * EVENT SHALL ANDERS CARLSSON 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.
 | 
			
		||||
 */
 | 
			
		||||
/* $Header$ */
 | 
			
		||||
#ifdef HAVE_CONFIG_H
 | 
			
		||||
#include <config.h>
 | 
			
		||||
#endif
 | 
			
		||||
#include "r128.h"
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
InitCard (char *name)
 | 
			
		||||
{
 | 
			
		||||
  KdCardAttr attr;
 | 
			
		||||
 | 
			
		||||
  if (LinuxFindPci (0x1002, 0x4c46, 0, &attr))
 | 
			
		||||
    KdCardInfoAdd (&r128Funcs, &attr, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
    KdInitOutput (pScreenInfo, argc, argv);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
InitInput (int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
    KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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