172b676d7Smrg/*
272b676d7Smrg * SiS DRI wrapper
372b676d7Smrg *
472b676d7Smrg * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria
572b676d7Smrg *
672b676d7Smrg * Licensed under the following terms:
772b676d7Smrg *
872b676d7Smrg * Permission to use, copy, modify, distribute, and sell this software and its
972b676d7Smrg * documentation for any purpose is hereby granted without fee, provided that
1072b676d7Smrg * the above copyright notice appears in all copies and that both that copyright
1172b676d7Smrg * notice and this permission notice appear in supporting documentation, and
1272b676d7Smrg * and that the name of the copyright holder not be used in advertising
1372b676d7Smrg * or publicity pertaining to distribution of the software without specific,
1472b676d7Smrg * written prior permission. The copyright holder makes no representations
1572b676d7Smrg * about the suitability of this software for any purpose.  It is provided
1672b676d7Smrg * "as is" without expressed or implied warranty.
1772b676d7Smrg *
1872b676d7Smrg * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1972b676d7Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
2072b676d7Smrg * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
2172b676d7Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
2272b676d7Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
2372b676d7Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2472b676d7Smrg * PERFORMANCE OF THIS SOFTWARE.
2572b676d7Smrg *
2672b676d7Smrg * Authors: 	Can-Ru Yeou, SiS Inc.,
2772b676d7Smrg *		Thomas Winischhofer <thomas@winischhofer.net>,
2872b676d7Smrg *		others.
2972b676d7Smrg *
3072b676d7Smrg * Previously taken and modified from tdfx_dri.h
3172b676d7Smrg */
3272b676d7Smrg
3372b676d7Smrg#ifndef _SIS_DRI_H_
3472b676d7Smrg#define _SIS_DRI_H_
3572b676d7Smrg
3672b676d7Smrg#include "xf86drm.h"
3772b676d7Smrg
3872b676d7Smrg/* Hack: When the types were changed, the typedefs
3972b676d7Smrg * went into drm.h. This file did not exist earlier.
4072b676d7Smrg */
4172b676d7Smrg#ifndef _DRM_H_
4272b676d7Smrg#define drm_handle_t drmHandle
4372b676d7Smrg#define drm_context_t drmContext
4472b676d7Smrg#endif
4572b676d7Smrg
4672b676d7Smrg#define SIS_MAX_DRAWABLES 256
4772b676d7Smrg#define SISIOMAPSIZE (64*1024)
4872b676d7Smrg
4972b676d7Smrgtypedef struct {
5072b676d7Smrg  int CtxOwner;
5172b676d7Smrg  int QueueLength;		/* (300: current, 315/etc: total) length of command queue */
5272b676d7Smrg  unsigned int AGPCmdBufNext;   /* (rename to AGPVtxBufNext) */
5372b676d7Smrg  unsigned int FrameCount;
5472b676d7Smrg#ifdef SIS315DRI
5572b676d7Smrg  unsigned int  sharedWPoffset;	/* Offset to current queue position (shared with 2D) */
5672b676d7Smrg  unsigned int  cmdQueueOffset;	/* Offset of start of command queue in VRAM */
5772b676d7Smrg#endif
5872b676d7Smrg} SISSAREAPriv, *SISSAREAPrivPtr;
5972b676d7Smrg
6072b676d7Smrg#define AGPVtxBufNext AGPCmdBufNext
6172b676d7Smrg
6272b676d7Smrg#define SIS_FRONT 0
6372b676d7Smrg#define SIS_BACK 1
6472b676d7Smrg#define SIS_DEPTH 2
6572b676d7Smrg
6672b676d7Smrgtypedef struct {
6772b676d7Smrg  drm_handle_t handle;
6872b676d7Smrg  drmSize size;
6972b676d7Smrg#ifndef SISISXORG6899900
7072b676d7Smrg  drmAddress map;
7172b676d7Smrg#endif
7272b676d7Smrg} sisRegion, *sisRegionPtr;
7372b676d7Smrg
7472b676d7Smrgtypedef struct {
7572b676d7Smrg  sisRegion regs;			/* MMIO registers */
7672b676d7Smrg  sisRegion agp;			/* AGP public area */
7772b676d7Smrg  int deviceID;				/* = pSiS->Chipset (PCI ID) */
7872b676d7Smrg  int width;				/* = pScrn->virtualX */
7972b676d7Smrg  int height;				/* = pScrn->virtualY */
8072b676d7Smrg  int mem;				/* total video RAM; seems unused */
8172b676d7Smrg  int bytesPerPixel;			/* Screen's bpp/8 */
8272b676d7Smrg  int priv1;				/* unused */
8372b676d7Smrg  int priv2;				/* unused */
8472b676d7Smrg  int fbOffset;				/* Front buffer; set up, but unused by DRI driver*/
8572b676d7Smrg  int backOffset;			/* unused (handled by the DRI driver) */
8672b676d7Smrg  int depthOffset;			/* unused (handled by the DRI driver) */
8772b676d7Smrg  int textureOffset;			/* unused (handled by the DRI driver) */
8872b676d7Smrg  int textureSize;			/* unused (handled by the DRI driver) */
8972b676d7Smrg  unsigned int AGPCmdBufOffset;		/* (rename to AGPVtxBufOffset) */
9072b676d7Smrg  unsigned int AGPCmdBufSize;		/* (rename to AGPVtxBufSize)   */
9172b676d7Smrg  int irqEnabled;
9272b676d7Smrg  unsigned int scrnX;			/* TODO: = width = pScrn->virtualX */
9372b676d7Smrg  unsigned int scrnY;			/* TODO: = height = pScrn->virtualY */
9472b676d7Smrg#ifdef SIS315DRI
9572b676d7Smrg  unsigned char *AGPCmdBufBase;
9672b676d7Smrg  unsigned long AGPCmdBufAddr;
9772b676d7Smrg  unsigned long AGPCmdBufOffset2;	/* (rename to AGPCmdBufOffset) */
9872b676d7Smrg  unsigned int  AGPCmdBufSize2;		/* (rename to AGPCmdBufSize)   */
9972b676d7Smrg  int deviceRev;			/* Chip revision */
10072b676d7Smrg#endif
10172b676d7Smrg} SISDRIRec, *SISDRIPtr;
10272b676d7Smrg
10372b676d7Smrg#define AGPVtxBufOffset AGPCmdBufOffset
10472b676d7Smrg#define AGPVtxBufSize AGPCmdBufSize
10572b676d7Smrg
10672b676d7Smrgtypedef struct {
10772b676d7Smrg  /* Nothing here yet */
10872b676d7Smrg  int dummy;
10972b676d7Smrg} SISDRIContextRec, *SISDRIContextPtr;
11072b676d7Smrg
11172b676d7Smrg#include "screenint.h"
11272b676d7Smrg
11372b676d7SmrgBool SISDRIScreenInit(ScreenPtr pScreen);
11472b676d7Smrgvoid SISDRICloseScreen(ScreenPtr pScreen);
11572b676d7SmrgBool SISDRIFinishScreenInit(ScreenPtr pScreen);
11672b676d7Smrg
11772b676d7Smrg#endif
118