mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2026-01-01 15:20:15 +01:00
Another state packet.
This commit is contained in:
parent
d8a234d2a8
commit
deb296f395
52 changed files with 43744 additions and 13 deletions
378
bsd-core/drm_os_netbsd.h
Normal file
378
bsd-core/drm_os_netbsd.h
Normal file
|
|
@ -0,0 +1,378 @@
|
|||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/filio.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/mman.h>
|
||||
#include <uvm/uvm.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/poll.h>
|
||||
/* For TIOCSPGRP/TIOCGPGRP */
|
||||
#include <sys/ttycom.h>
|
||||
|
||||
#include <uvm/uvm.h>
|
||||
|
||||
#include <machine/pmap.h>
|
||||
#include <machine/bus.h>
|
||||
#include <sys/resourcevar.h>
|
||||
#include <machine/sysarch.h>
|
||||
#include <machine/mtrr.h>
|
||||
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
|
||||
#include "drmvar.h"
|
||||
|
||||
#define __REALLY_HAVE_AGP __HAVE_AGP
|
||||
|
||||
#define __REALLY_HAVE_MTRR 0
|
||||
#define __REALLY_HAVE_SG 0
|
||||
|
||||
#if __REALLY_HAVE_AGP
|
||||
#include <dev/pci/agpvar.h>
|
||||
#include <sys/agpio.h>
|
||||
#endif
|
||||
|
||||
#define device_t struct device *
|
||||
extern struct cfdriver DRM(_cd);
|
||||
|
||||
#if DRM_DEBUG
|
||||
#undef DRM_DEBUG_CODE
|
||||
#define DRM_DEBUG_CODE 2
|
||||
#endif
|
||||
#undef DRM_DEBUG
|
||||
|
||||
#define DRM_TIME_SLICE (hz/20) /* Time slice for GLXContexts */
|
||||
|
||||
#define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
|
||||
#define DRM_DEV_UID 0
|
||||
#define DRM_DEV_GID 0
|
||||
#define CDEV_MAJOR 90
|
||||
|
||||
#define DRM_CURPROC curproc
|
||||
#define DRM_STRUCTPROC struct proc
|
||||
#define DRM_SPINTYPE struct simplelock
|
||||
#define DRM_SPININIT(l,name) simple_lock_init(&l)
|
||||
#define DRM_SPINLOCK(l) simple_lock(l)
|
||||
#define DRM_SPINUNLOCK(u) simple_unlock(u);
|
||||
#define DRM_CURRENTPID curproc->p_pid
|
||||
|
||||
#define DRM_IOCTL_ARGS dev_t kdev, u_long cmd, caddr_t data, int flags, DRM_STRUCTPROC *p
|
||||
#define DRM_LOCK lockmgr(&dev->dev_lock, LK_EXCLUSIVE, NULL)
|
||||
#define DRM_UNLOCK lockmgr(&dev->dev_lock, LK_RELEASE, NULL)
|
||||
#define DRM_SUSER(p) suser(p->p_ucred, &p->p_acflag)
|
||||
#define DRM_TASKQUEUE_ARGS void *dev, int pending
|
||||
#define DRM_IRQ_ARGS void *device
|
||||
#define DRM_DEVICE drm_device_t *dev = device_lookup(&DRM(_cd), minor(kdev))
|
||||
#define DRM_MALLOC(size) malloc( size, DRM(M_DRM), M_NOWAIT )
|
||||
#define DRM_FREE(pt) free( pt, DRM(M_DRM) )
|
||||
#define DRM_VTOPHYS(addr) vtophys(addr)
|
||||
#define DRM_READ8(addr) *((volatile char *)(addr))
|
||||
#define DRM_READ32(addr) *((volatile long *)(addr))
|
||||
#define DRM_WRITE8(addr, val) *((volatile char *)(addr)) = (val)
|
||||
#define DRM_WRITE32(addr, val) *((volatile long *)(addr)) = (val)
|
||||
#define DRM_AGP_FIND_DEVICE()
|
||||
|
||||
#define DRM_PRIV \
|
||||
drm_file_t *priv = (drm_file_t *) DRM(find_file_by_proc)(dev, p); \
|
||||
if (!priv) { \
|
||||
DRM_DEBUG("can't find authenticator\n"); \
|
||||
return EINVAL; \
|
||||
}
|
||||
|
||||
#define DRM_UDELAY( udelay ) \
|
||||
do { \
|
||||
struct timeval tv1, tv2; \
|
||||
microtime(&tv1); \
|
||||
do { \
|
||||
microtime(&tv2); \
|
||||
} \
|
||||
while (((tv2.tv_sec-tv1.tv_sec)*1000000 + tv2.tv_usec - tv1.tv_usec) < udelay ); \
|
||||
} while (0)
|
||||
|
||||
#define DRM_GETSAREA() \
|
||||
do { \
|
||||
drm_map_list_entry_t *listentry; \
|
||||
TAILQ_FOREACH(listentry, dev->maplist, link) { \
|
||||
drm_map_t *map = listentry->map; \
|
||||
if (map->type == _DRM_SHM && \
|
||||
map->flags & _DRM_CONTAINS_LOCK) { \
|
||||
dev_priv->sarea = map; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define return DRM_ERR(v) return v;
|
||||
#define DRM_ERR(v) v
|
||||
|
||||
#define DRM_COPY_TO_USER_IOCTL(arg1, arg2, arg3) \
|
||||
*arg1 = arg2
|
||||
#define DRM_COPY_FROM_USER_IOCTL(arg1, arg2, arg3) \
|
||||
arg1 = *arg2
|
||||
#define DRM_COPY_TO_USER(arg1, arg2, arg3) \
|
||||
copyout(arg2, arg1, arg3)
|
||||
#define DRM_COPY_FROM_USER(arg1, arg2, arg3) \
|
||||
copyin(arg2, arg1, arg3)
|
||||
|
||||
#define DRM_READMEMORYBARRIER \
|
||||
{ \
|
||||
int xchangeDummy; \
|
||||
DRM_DEBUG("%s\n", __FUNCTION__); \
|
||||
__asm__ volatile(" push %%eax ; xchg %%eax, %0 ; pop %%eax" : : "m" (xchangeDummy)); \
|
||||
__asm__ volatile(" push %%eax ; push %%ebx ; push %%ecx ; push %%edx ;" \
|
||||
" movl $0,%%eax ; cpuid ; pop %%edx ; pop %%ecx ; pop %%ebx ;" \
|
||||
" pop %%eax" : /* no outputs */ : /* no inputs */ ); \
|
||||
} while (0);
|
||||
|
||||
#define DRM_WRITEMEMORYBARRIER DRM_READMEMORYBARRIER
|
||||
|
||||
#define DRM_WAKEUP(w) wakeup(w)
|
||||
#define DRM_WAKEUP_INT(w) wakeup(w)
|
||||
|
||||
#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
|
||||
|
||||
typedef struct drm_chipinfo
|
||||
{
|
||||
int vendor;
|
||||
int device;
|
||||
int supported;
|
||||
char *name;
|
||||
} drm_chipinfo_t;
|
||||
|
||||
typedef u_int32_t dma_addr_t;
|
||||
typedef volatile u_int32_t atomic_t;
|
||||
typedef u_int32_t cycles_t;
|
||||
typedef u_int32_t spinlock_t;
|
||||
typedef u_int32_t u32;
|
||||
typedef u_int16_t u16;
|
||||
typedef u_int8_t u8;
|
||||
typedef dev_type_ioctl(d_ioctl_t);
|
||||
typedef vaddr_t vm_offset_t;
|
||||
|
||||
#define atomic_set(p, v) (*(p) = (v))
|
||||
#define atomic_read(p) (*(p))
|
||||
#define atomic_inc(p) atomic_add_int(p, 1)
|
||||
#define atomic_dec(p) atomic_subtract_int(p, 1)
|
||||
#define atomic_add(n, p) atomic_add_int(p, n)
|
||||
#define atomic_sub(n, p) atomic_subtract_int(p, n)
|
||||
|
||||
/* FIXME: Is NetBSD's kernel non-reentrant? */
|
||||
#define atomic_add_int(p, v) *(p) += v
|
||||
#define atomic_subtract_int(p, v) *(p) -= v
|
||||
#define atomic_set_int(p, bits) *(p) |= (bits)
|
||||
#define atomic_clear_int(p, bits) *(p) &= ~(bits)
|
||||
|
||||
/* Fake this */
|
||||
static __inline atomic_t
|
||||
test_and_set_bit(int b, atomic_t *p)
|
||||
{
|
||||
int s = splhigh();
|
||||
unsigned int m = 1<<b;
|
||||
unsigned int r = *p & m;
|
||||
*p |= m;
|
||||
splx(s);
|
||||
return r;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
clear_bit(int b, atomic_t *p)
|
||||
{
|
||||
atomic_clear_int(p + (b >> 5), 1 << (b & 0x1f));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
set_bit(int b, atomic_t *p)
|
||||
{
|
||||
atomic_set_int(p + (b >> 5), 1 << (b & 0x1f));
|
||||
}
|
||||
|
||||
static __inline int
|
||||
test_bit(int b, atomic_t *p)
|
||||
{
|
||||
return p[b >> 5] & (1 << (b & 0x1f));
|
||||
}
|
||||
|
||||
static __inline int
|
||||
find_first_zero_bit(atomic_t *p, int max)
|
||||
{
|
||||
int b;
|
||||
|
||||
for (b = 0; b < max; b += 32) {
|
||||
if (p[b >> 5] != ~0) {
|
||||
for (;;) {
|
||||
if ((p[b >> 5] & (1 << (b & 0x1f))) == 0)
|
||||
return b;
|
||||
b++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
#define spldrm() spltty()
|
||||
#define jiffies hardclock_ticks
|
||||
|
||||
#define __drm_dummy_lock(lock) (*(__volatile__ unsigned int *)lock)
|
||||
#define _DRM_CAS(lock,old,new,__ret) \
|
||||
do { \
|
||||
int __dummy; /* Can't mark eax as clobbered */ \
|
||||
__asm__ __volatile__( \
|
||||
"lock ; cmpxchg %4,%1\n\t" \
|
||||
"setnz %0" \
|
||||
: "=d" (__ret), \
|
||||
"=m" (__drm_dummy_lock(lock)), \
|
||||
"=a" (__dummy) \
|
||||
: "2" (old), \
|
||||
"r" (new)); \
|
||||
} while (0)
|
||||
|
||||
/* Redefinitions to make templating easy */
|
||||
#define wait_queue_head_t atomic_t
|
||||
#define agp_memory void
|
||||
|
||||
/* Macros to make printf easier */
|
||||
#define DRM_ERROR(fmt, arg...) \
|
||||
do { \
|
||||
printf("error: [" DRM_NAME ":%s] *ERROR* ", __func__ ); \
|
||||
printf( fmt,## arg ); \
|
||||
} while (0)
|
||||
|
||||
#define DRM_MEM_ERROR(area, fmt, arg...) \
|
||||
printf("error: [" DRM_NAME ":%s:%s] *ERROR* " fmt , \
|
||||
__func__, DRM(mem_stats)[area].name ,## arg)
|
||||
#define DRM_INFO(fmt, arg...) printf("info: " "[" DRM_NAME "] " fmt ,## arg)
|
||||
|
||||
#if DRM_DEBUG_CODE
|
||||
#define DRM_DEBUG(fmt, arg...) \
|
||||
do { \
|
||||
if (DRM(flags) & DRM_FLAG_DEBUG) \
|
||||
printf("[" DRM_NAME ":%s] " fmt , __FUNCTION__,## arg); \
|
||||
} while (0)
|
||||
#else
|
||||
#define DRM_DEBUG(fmt, arg...) do { } while (0)
|
||||
#endif
|
||||
|
||||
#define DRM_PROC_LIMIT (PAGE_SIZE-80)
|
||||
|
||||
#define DRM_SYSCTL_PRINT(fmt, arg...) \
|
||||
snprintf(buf, sizeof(buf), fmt, ##arg); \
|
||||
error = SYSCTL_OUT(req, buf, strlen(buf)); \
|
||||
if (error) return error;
|
||||
|
||||
#define DRM_SYSCTL_PRINT_RET(ret, fmt, arg...) \
|
||||
snprintf(buf, sizeof(buf), fmt, ##arg); \
|
||||
error = SYSCTL_OUT(req, buf, strlen(buf)); \
|
||||
if (error) { ret; return error; }
|
||||
|
||||
|
||||
#define DRM_FIND_MAP(dest, o) \
|
||||
do { \
|
||||
drm_map_list_entry_t *listentry; \
|
||||
TAILQ_FOREACH(listentry, dev->maplist, link) { \
|
||||
if ( listentry->map->offset == o ) { \
|
||||
dest = listentry->map; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Internal functions */
|
||||
|
||||
/* drm_drv.h */
|
||||
extern dev_type_ioctl(DRM(ioctl));
|
||||
extern dev_type_ioctl(DRM(lock));
|
||||
extern dev_type_ioctl(DRM(unlock));
|
||||
extern dev_type_open(DRM(open));
|
||||
extern dev_type_close(DRM(close));
|
||||
extern dev_type_read(DRM(read));
|
||||
extern dev_type_write(DRM(write));
|
||||
extern dev_type_poll(DRM(poll));
|
||||
extern dev_type_mmap(DRM(mmap));
|
||||
extern int DRM(open_helper)(dev_t kdev, int flags, int fmt,
|
||||
DRM_STRUCTPROC *p, drm_device_t *dev);
|
||||
extern drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev,
|
||||
DRM_STRUCTPROC *p);
|
||||
|
||||
/* Misc. IOCTL support (drm_ioctl.h) */
|
||||
extern dev_type_ioctl(DRM(irq_busid));
|
||||
extern dev_type_ioctl(DRM(getunique));
|
||||
extern dev_type_ioctl(DRM(setunique));
|
||||
extern dev_type_ioctl(DRM(getmap));
|
||||
extern dev_type_ioctl(DRM(getclient));
|
||||
extern dev_type_ioctl(DRM(getstats));
|
||||
|
||||
/* Context IOCTL support (drm_context.h) */
|
||||
extern dev_type_ioctl(DRM(resctx));
|
||||
extern dev_type_ioctl(DRM(addctx));
|
||||
extern dev_type_ioctl(DRM(modctx));
|
||||
extern dev_type_ioctl(DRM(getctx));
|
||||
extern dev_type_ioctl(DRM(switchctx));
|
||||
extern dev_type_ioctl(DRM(newctx));
|
||||
extern dev_type_ioctl(DRM(rmctx));
|
||||
extern dev_type_ioctl(DRM(setsareactx));
|
||||
extern dev_type_ioctl(DRM(getsareactx));
|
||||
|
||||
/* Drawable IOCTL support (drm_drawable.h) */
|
||||
extern dev_type_ioctl(DRM(adddraw));
|
||||
extern dev_type_ioctl(DRM(rmdraw));
|
||||
|
||||
/* Authentication IOCTL support (drm_auth.h) */
|
||||
extern dev_type_ioctl(DRM(getmagic));
|
||||
extern dev_type_ioctl(DRM(authmagic));
|
||||
|
||||
/* Locking IOCTL support (drm_lock.h) */
|
||||
extern dev_type_ioctl(DRM(block));
|
||||
extern dev_type_ioctl(DRM(unblock));
|
||||
extern dev_type_ioctl(DRM(finish));
|
||||
|
||||
/* Buffer management support (drm_bufs.h) */
|
||||
extern dev_type_ioctl(DRM(addmap));
|
||||
extern dev_type_ioctl(DRM(rmmap));
|
||||
#if __HAVE_DMA
|
||||
extern dev_type_ioctl(DRM(addbufs_agp));
|
||||
extern dev_type_ioctl(DRM(addbufs_pci));
|
||||
extern dev_type_ioctl(DRM(addbufs_sg));
|
||||
extern dev_type_ioctl(DRM(addbufs));
|
||||
extern dev_type_ioctl(DRM(infobufs));
|
||||
extern dev_type_ioctl(DRM(markbufs));
|
||||
extern dev_type_ioctl(DRM(freebufs));
|
||||
extern dev_type_ioctl(DRM(mapbufs));
|
||||
#endif
|
||||
|
||||
/* DMA support (drm_dma.h) */
|
||||
#if __HAVE_DMA
|
||||
extern dev_type_ioctl(DRM(control));
|
||||
#endif
|
||||
|
||||
/* AGP/GART support (drm_agpsupport.h) */
|
||||
#if __REALLY_HAVE_AGP
|
||||
extern dev_type_ioctl(DRM(agp_acquire));
|
||||
extern dev_type_ioctl(DRM(agp_release));
|
||||
extern dev_type_ioctl(DRM(agp_enable));
|
||||
extern dev_type_ioctl(DRM(agp_info));
|
||||
extern dev_type_ioctl(DRM(agp_alloc));
|
||||
extern dev_type_ioctl(DRM(agp_free));
|
||||
extern dev_type_ioctl(DRM(agp_unbind));
|
||||
extern dev_type_ioctl(DRM(agp_bind));
|
||||
#endif
|
||||
|
||||
/* Scatter Gather Support (drm_scatter.h) */
|
||||
#if __HAVE_SG
|
||||
extern dev_type_ioctl(DRM(sg_alloc));
|
||||
extern dev_type_ioctl(DRM(sg_free));
|
||||
#endif
|
||||
|
||||
/* SysCtl Support (drm_sysctl.h) */
|
||||
extern int DRM(sysctl_init)(drm_device_t *dev);
|
||||
extern int DRM(sysctl_cleanup)(drm_device_t *dev);
|
||||
66
bsd-core/mga_drv.c
Normal file
66
bsd-core/mga_drv.c
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/* mga_drv.c -- Matrox G200/G400 driver -*- linux-c -*-
|
||||
* Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS 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.
|
||||
*
|
||||
* Authors:
|
||||
* Rickard E. (Rik) Faith <faith@valinux.com>
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "mga.h"
|
||||
#include "drmP.h"
|
||||
#include "drm.h"
|
||||
#include "mga_drm.h"
|
||||
#include "mga_drv.h"
|
||||
|
||||
/* List acquired from http://www.yourvote.com/pci/pcihdr.h and xc/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
|
||||
* Please report to anholt@teleport.com inaccuracies or if a chip you have works that is marked unsupported here.
|
||||
*/
|
||||
drm_chipinfo_t DRM(devicelist)[] = {
|
||||
{0x102b, 0x0520, 0, "Matrox G200 (PCI)"},
|
||||
{0x102b, 0x0521, 1, "Matrox G200 (AGP)"},
|
||||
{0x102b, 0x0525, 1, "Matrox G400/G450 (AGP)"},
|
||||
{0x102b, 0x2527, 1, "Matrox G550 (AGP)"},
|
||||
{0, 0, 0, NULL}
|
||||
};
|
||||
|
||||
#include "drm_agpsupport.h"
|
||||
#include "drm_auth.h"
|
||||
#include "drm_bufs.h"
|
||||
#include "drm_context.h"
|
||||
#include "drm_dma.h"
|
||||
#include "drm_drawable.h"
|
||||
#include "drm_drv.h"
|
||||
#include "drm_fops.h"
|
||||
#include "drm_init.h"
|
||||
#include "drm_ioctl.h"
|
||||
#include "drm_lock.h"
|
||||
#include "drm_memory.h"
|
||||
#include "drm_vm.h"
|
||||
#include "drm_sysctl.h"
|
||||
|
||||
DRIVER_MODULE(mga, pci, mga_driver, mga_devclass, 0, 0);
|
||||
86
bsd-core/r128_drv.c
Normal file
86
bsd-core/r128_drv.c
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
/* r128_drv.c -- ATI Rage 128 driver -*- linux-c -*-
|
||||
* Created: Mon Dec 13 09:47:27 1999 by faith@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS 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.
|
||||
*
|
||||
* Authors:
|
||||
* Rickard E. (Rik) Faith <faith@valinux.com>
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "r128.h"
|
||||
#include "drmP.h"
|
||||
#include "drm.h"
|
||||
#include "r128_drm.h"
|
||||
#include "r128_drv.h"
|
||||
#if __REALLY_HAVE_SG
|
||||
#include "ati_pcigart.h"
|
||||
#endif
|
||||
|
||||
/* List acquired from http://www.yourvote.com/pci/pcihdr.h and xc/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
|
||||
* Please report to eta@lclark.edu inaccuracies or if a chip you have works that is marked unsupported here.
|
||||
*/
|
||||
drm_chipinfo_t DRM(devicelist)[] = {
|
||||
{0x1002, 0x4c45, __REALLY_HAVE_SG, "ATI Rage 128 Mobility LE (PCI)"},
|
||||
{0x1002, 0x4c46, 1, "ATI Rage 128 Mobility LF (AGP)"},
|
||||
{0x1002, 0x4d46, 1, "ATI Rage 128 Mobility MF (AGP)"},
|
||||
{0x1002, 0x4d4c, 1, "ATI Rage 128 Mobility ML (AGP)"},
|
||||
{0x1002, 0x5044, __REALLY_HAVE_SG, "ATI Rage 128 Pro PD (PCI)"},
|
||||
{0x1002, 0x5046, 1, "ATI Rage 128 Pro PF (AGP)"},
|
||||
{0x1002, 0x5050, __REALLY_HAVE_SG, "ATI Rage 128 Pro PP (PCI)"},
|
||||
{0x1002, 0x5052, __REALLY_HAVE_SG, "ATI Rage 128 Pro PR (PCI)"},
|
||||
{0x1002, 0x5245, __REALLY_HAVE_SG, "ATI Rage 128 RE (PCI)"},
|
||||
{0x1002, 0x5246, 1, "ATI Rage 128 RF (AGP)"},
|
||||
{0x1002, 0x5247, 1, "ATI Rage 128 RG (AGP)"},
|
||||
{0x1002, 0x524b, __REALLY_HAVE_SG, "ATI Rage 128 RK (PCI)"},
|
||||
{0x1002, 0x524c, 1, "ATI Rage 128 RL (AGP)"},
|
||||
{0x1002, 0x534d, 1, "ATI Rage 128 SM (AGP)"},
|
||||
{0x1002, 0x5446, 1, "ATI Rage 128 Pro Ultra TF (AGP)"},
|
||||
{0x1002, 0x544C, 1, "ATI Rage 128 Pro Ultra TL (AGP)"},
|
||||
{0x1002, 0x5452, 1, "ATI Rage 128 Pro Ultra TR (AGP)"},
|
||||
{0, 0, 0, NULL}
|
||||
};
|
||||
|
||||
#include "drm_agpsupport.h"
|
||||
#include "drm_auth.h"
|
||||
#include "drm_bufs.h"
|
||||
#include "drm_context.h"
|
||||
#include "drm_dma.h"
|
||||
#include "drm_drawable.h"
|
||||
#include "drm_drv.h"
|
||||
#include "drm_fops.h"
|
||||
#include "drm_init.h"
|
||||
#include "drm_ioctl.h"
|
||||
#include "drm_lock.h"
|
||||
#include "drm_memory.h"
|
||||
#include "drm_sysctl.h"
|
||||
#include "drm_vm.h"
|
||||
#if __HAVE_SG
|
||||
#include "drm_scatter.h"
|
||||
#endif
|
||||
|
||||
DRIVER_MODULE(r128, pci, r128_driver, r128_devclass, 0, 0);
|
||||
76
bsd-core/radeon_drv.c
Normal file
76
bsd-core/radeon_drv.c
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/* radeon_drv.c -- ATI Radeon driver -*- linux-c -*-
|
||||
* Created: Wed Feb 14 17:10:04 2001 by gareth@valinux.com
|
||||
*
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS 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.
|
||||
*
|
||||
* Authors:
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "radeon.h"
|
||||
#include "drmP.h"
|
||||
#include "drm.h"
|
||||
#include "radeon_drm.h"
|
||||
#include "radeon_drv.h"
|
||||
#if __REALLY_HAVE_SG
|
||||
#include "ati_pcigart.h"
|
||||
#endif
|
||||
|
||||
/* List acquired from http://www.yourvote.com/pci/pcihdr.h and xc/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
|
||||
* Please report to eta@lclark.edu inaccuracies or if a chip you have works that is marked unsupported here.
|
||||
*/
|
||||
drm_chipinfo_t DRM(devicelist)[] = {
|
||||
{0x1002, 0x4C57, 1, "ATI Radeon LW Mobility 7 (AGP)"},
|
||||
{0x1002, 0x4C59, 1, "ATI Radeon LY Mobility 6 (AGP)"},
|
||||
{0x1002, 0x4C5A, 1, "ATI Radeon LZ Mobility 6 (AGP)"},
|
||||
{0x1002, 0x5144, 1, "ATI Radeon QD (AGP)"},
|
||||
{0x1002, 0x5145, 1, "ATI Radeon QE (AGP)"},
|
||||
{0x1002, 0x5146, 1, "ATI Radeon QF (AGP)"},
|
||||
{0x1002, 0x5147, 1, "ATI Radeon QG (AGP)"},
|
||||
{0x1002, 0x5157, 1, "ATI Radeon QW 7500 (AGP)"},
|
||||
{0x1002, 0x5159, 1, "ATI Radeon QY VE (AGP)"},
|
||||
{0x1002, 0x515A, 1, "ATI Radeon QZ VE (AGP)"},
|
||||
{0, 0, 0, NULL}
|
||||
};
|
||||
|
||||
#include "drm_agpsupport.h"
|
||||
#include "drm_auth.h"
|
||||
#include "drm_bufs.h"
|
||||
#include "drm_context.h"
|
||||
#include "drm_dma.h"
|
||||
#include "drm_drawable.h"
|
||||
#include "drm_drv.h"
|
||||
#include "drm_fops.h"
|
||||
#include "drm_init.h"
|
||||
#include "drm_ioctl.h"
|
||||
#include "drm_lock.h"
|
||||
#include "drm_memory.h"
|
||||
#include "drm_vm.h"
|
||||
#include "drm_sysctl.h"
|
||||
#if __HAVE_SG
|
||||
#include "drm_scatter.h"
|
||||
#endif
|
||||
|
||||
DRIVER_MODULE(DRIVER_NAME, pci, DRM(driver), DRM(devclass), 0, 0);
|
||||
99
bsd-core/tdfx_drv.c
Normal file
99
bsd-core/tdfx_drv.c
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
/* tdfx_drv.c -- tdfx driver -*- linux-c -*-
|
||||
* Created: Thu Oct 7 10:38:32 1999 by faith@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PRECISION INSIGHT 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.
|
||||
*
|
||||
* Authors:
|
||||
* Rickard E. (Rik) Faith <faith@valinux.com>
|
||||
* Daryll Strauss <daryll@valinux.com>
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "tdfx.h"
|
||||
#include "drmP.h"
|
||||
|
||||
#define DRIVER_AUTHOR "VA Linux Systems Inc."
|
||||
|
||||
#define DRIVER_NAME "tdfx"
|
||||
#define DRIVER_DESC "3dfx Banshee/Voodoo3+"
|
||||
#define DRIVER_DATE "20010216"
|
||||
|
||||
#define DRIVER_MAJOR 1
|
||||
#define DRIVER_MINOR 0
|
||||
#define DRIVER_PATCHLEVEL 0
|
||||
|
||||
#ifndef PCI_VENDOR_ID_3DFX
|
||||
#define PCI_VENDOR_ID_3DFX 0x121A
|
||||
#endif
|
||||
#ifndef PCI_DEVICE_ID_3DFX_VOODOO5
|
||||
#define PCI_DEVICE_ID_3DFX_VOODOO5 0x0009
|
||||
#endif
|
||||
#ifndef PCI_DEVICE_ID_3DFX_VOODOO4
|
||||
#define PCI_DEVICE_ID_3DFX_VOODOO4 0x0007
|
||||
#endif
|
||||
#ifndef PCI_DEVICE_ID_3DFX_VOODOO3_3000 /* Voodoo3 3000 */
|
||||
#define PCI_DEVICE_ID_3DFX_VOODOO3_3000 0x0005
|
||||
#endif
|
||||
#ifndef PCI_DEVICE_ID_3DFX_VOODOO3_2000 /* Voodoo3 3000 */
|
||||
#define PCI_DEVICE_ID_3DFX_VOODOO3_2000 0x0004
|
||||
#endif
|
||||
#ifndef PCI_DEVICE_ID_3DFX_BANSHEE
|
||||
#define PCI_DEVICE_ID_3DFX_BANSHEE 0x0003
|
||||
#endif
|
||||
|
||||
/* List acquired from http://www.yourvote.com/pci/pcihdr.h and xc/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
|
||||
* Please report to anholt@teleport.com inaccuracies or if a chip you have works that is marked unsupported here.
|
||||
*/
|
||||
drm_chipinfo_t DRM(devicelist)[] = {
|
||||
{0x121a, 0x0003, 1, "3dfx Voodoo Banshee"},
|
||||
{0x121a, 0x0004, 1, "3dfx Voodoo3 2000"},
|
||||
{0x121a, 0x0005, 1, "3dfx Voodoo3 3000"},
|
||||
{0x121a, 0x0007, 1, "3dfx Voodoo4"},
|
||||
{0x121a, 0x0009, 1, "3dfx Voodoo5"},
|
||||
{0, 0, 0, NULL}
|
||||
};
|
||||
|
||||
|
||||
#include "drm_auth.h"
|
||||
#include "drm_bufs.h"
|
||||
#include "drm_context.h"
|
||||
#include "drm_dma.h"
|
||||
#include "drm_drawable.h"
|
||||
#include "drm_drv.h"
|
||||
|
||||
|
||||
#include "drm_fops.h"
|
||||
#include "drm_init.h"
|
||||
#include "drm_ioctl.h"
|
||||
#include "drm_lock.h"
|
||||
#include "drm_memory.h"
|
||||
#include "drm_vm.h"
|
||||
#include "drm_sysctl.h"
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
DRIVER_MODULE(tdfx, pci, tdfx_driver, tdfx_devclass, 0, 0);
|
||||
#endif /* __FreeBSD__ */
|
||||
378
bsd/drm_os_netbsd.h
Normal file
378
bsd/drm_os_netbsd.h
Normal file
|
|
@ -0,0 +1,378 @@
|
|||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/filio.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/mman.h>
|
||||
#include <uvm/uvm.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/poll.h>
|
||||
/* For TIOCSPGRP/TIOCGPGRP */
|
||||
#include <sys/ttycom.h>
|
||||
|
||||
#include <uvm/uvm.h>
|
||||
|
||||
#include <machine/pmap.h>
|
||||
#include <machine/bus.h>
|
||||
#include <sys/resourcevar.h>
|
||||
#include <machine/sysarch.h>
|
||||
#include <machine/mtrr.h>
|
||||
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
|
||||
#include "drmvar.h"
|
||||
|
||||
#define __REALLY_HAVE_AGP __HAVE_AGP
|
||||
|
||||
#define __REALLY_HAVE_MTRR 0
|
||||
#define __REALLY_HAVE_SG 0
|
||||
|
||||
#if __REALLY_HAVE_AGP
|
||||
#include <dev/pci/agpvar.h>
|
||||
#include <sys/agpio.h>
|
||||
#endif
|
||||
|
||||
#define device_t struct device *
|
||||
extern struct cfdriver DRM(_cd);
|
||||
|
||||
#if DRM_DEBUG
|
||||
#undef DRM_DEBUG_CODE
|
||||
#define DRM_DEBUG_CODE 2
|
||||
#endif
|
||||
#undef DRM_DEBUG
|
||||
|
||||
#define DRM_TIME_SLICE (hz/20) /* Time slice for GLXContexts */
|
||||
|
||||
#define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
|
||||
#define DRM_DEV_UID 0
|
||||
#define DRM_DEV_GID 0
|
||||
#define CDEV_MAJOR 90
|
||||
|
||||
#define DRM_CURPROC curproc
|
||||
#define DRM_STRUCTPROC struct proc
|
||||
#define DRM_SPINTYPE struct simplelock
|
||||
#define DRM_SPININIT(l,name) simple_lock_init(&l)
|
||||
#define DRM_SPINLOCK(l) simple_lock(l)
|
||||
#define DRM_SPINUNLOCK(u) simple_unlock(u);
|
||||
#define DRM_CURRENTPID curproc->p_pid
|
||||
|
||||
#define DRM_IOCTL_ARGS dev_t kdev, u_long cmd, caddr_t data, int flags, DRM_STRUCTPROC *p
|
||||
#define DRM_LOCK lockmgr(&dev->dev_lock, LK_EXCLUSIVE, NULL)
|
||||
#define DRM_UNLOCK lockmgr(&dev->dev_lock, LK_RELEASE, NULL)
|
||||
#define DRM_SUSER(p) suser(p->p_ucred, &p->p_acflag)
|
||||
#define DRM_TASKQUEUE_ARGS void *dev, int pending
|
||||
#define DRM_IRQ_ARGS void *device
|
||||
#define DRM_DEVICE drm_device_t *dev = device_lookup(&DRM(_cd), minor(kdev))
|
||||
#define DRM_MALLOC(size) malloc( size, DRM(M_DRM), M_NOWAIT )
|
||||
#define DRM_FREE(pt) free( pt, DRM(M_DRM) )
|
||||
#define DRM_VTOPHYS(addr) vtophys(addr)
|
||||
#define DRM_READ8(addr) *((volatile char *)(addr))
|
||||
#define DRM_READ32(addr) *((volatile long *)(addr))
|
||||
#define DRM_WRITE8(addr, val) *((volatile char *)(addr)) = (val)
|
||||
#define DRM_WRITE32(addr, val) *((volatile long *)(addr)) = (val)
|
||||
#define DRM_AGP_FIND_DEVICE()
|
||||
|
||||
#define DRM_PRIV \
|
||||
drm_file_t *priv = (drm_file_t *) DRM(find_file_by_proc)(dev, p); \
|
||||
if (!priv) { \
|
||||
DRM_DEBUG("can't find authenticator\n"); \
|
||||
return EINVAL; \
|
||||
}
|
||||
|
||||
#define DRM_UDELAY( udelay ) \
|
||||
do { \
|
||||
struct timeval tv1, tv2; \
|
||||
microtime(&tv1); \
|
||||
do { \
|
||||
microtime(&tv2); \
|
||||
} \
|
||||
while (((tv2.tv_sec-tv1.tv_sec)*1000000 + tv2.tv_usec - tv1.tv_usec) < udelay ); \
|
||||
} while (0)
|
||||
|
||||
#define DRM_GETSAREA() \
|
||||
do { \
|
||||
drm_map_list_entry_t *listentry; \
|
||||
TAILQ_FOREACH(listentry, dev->maplist, link) { \
|
||||
drm_map_t *map = listentry->map; \
|
||||
if (map->type == _DRM_SHM && \
|
||||
map->flags & _DRM_CONTAINS_LOCK) { \
|
||||
dev_priv->sarea = map; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define return DRM_ERR(v) return v;
|
||||
#define DRM_ERR(v) v
|
||||
|
||||
#define DRM_COPY_TO_USER_IOCTL(arg1, arg2, arg3) \
|
||||
*arg1 = arg2
|
||||
#define DRM_COPY_FROM_USER_IOCTL(arg1, arg2, arg3) \
|
||||
arg1 = *arg2
|
||||
#define DRM_COPY_TO_USER(arg1, arg2, arg3) \
|
||||
copyout(arg2, arg1, arg3)
|
||||
#define DRM_COPY_FROM_USER(arg1, arg2, arg3) \
|
||||
copyin(arg2, arg1, arg3)
|
||||
|
||||
#define DRM_READMEMORYBARRIER \
|
||||
{ \
|
||||
int xchangeDummy; \
|
||||
DRM_DEBUG("%s\n", __FUNCTION__); \
|
||||
__asm__ volatile(" push %%eax ; xchg %%eax, %0 ; pop %%eax" : : "m" (xchangeDummy)); \
|
||||
__asm__ volatile(" push %%eax ; push %%ebx ; push %%ecx ; push %%edx ;" \
|
||||
" movl $0,%%eax ; cpuid ; pop %%edx ; pop %%ecx ; pop %%ebx ;" \
|
||||
" pop %%eax" : /* no outputs */ : /* no inputs */ ); \
|
||||
} while (0);
|
||||
|
||||
#define DRM_WRITEMEMORYBARRIER DRM_READMEMORYBARRIER
|
||||
|
||||
#define DRM_WAKEUP(w) wakeup(w)
|
||||
#define DRM_WAKEUP_INT(w) wakeup(w)
|
||||
|
||||
#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
|
||||
|
||||
typedef struct drm_chipinfo
|
||||
{
|
||||
int vendor;
|
||||
int device;
|
||||
int supported;
|
||||
char *name;
|
||||
} drm_chipinfo_t;
|
||||
|
||||
typedef u_int32_t dma_addr_t;
|
||||
typedef volatile u_int32_t atomic_t;
|
||||
typedef u_int32_t cycles_t;
|
||||
typedef u_int32_t spinlock_t;
|
||||
typedef u_int32_t u32;
|
||||
typedef u_int16_t u16;
|
||||
typedef u_int8_t u8;
|
||||
typedef dev_type_ioctl(d_ioctl_t);
|
||||
typedef vaddr_t vm_offset_t;
|
||||
|
||||
#define atomic_set(p, v) (*(p) = (v))
|
||||
#define atomic_read(p) (*(p))
|
||||
#define atomic_inc(p) atomic_add_int(p, 1)
|
||||
#define atomic_dec(p) atomic_subtract_int(p, 1)
|
||||
#define atomic_add(n, p) atomic_add_int(p, n)
|
||||
#define atomic_sub(n, p) atomic_subtract_int(p, n)
|
||||
|
||||
/* FIXME: Is NetBSD's kernel non-reentrant? */
|
||||
#define atomic_add_int(p, v) *(p) += v
|
||||
#define atomic_subtract_int(p, v) *(p) -= v
|
||||
#define atomic_set_int(p, bits) *(p) |= (bits)
|
||||
#define atomic_clear_int(p, bits) *(p) &= ~(bits)
|
||||
|
||||
/* Fake this */
|
||||
static __inline atomic_t
|
||||
test_and_set_bit(int b, atomic_t *p)
|
||||
{
|
||||
int s = splhigh();
|
||||
unsigned int m = 1<<b;
|
||||
unsigned int r = *p & m;
|
||||
*p |= m;
|
||||
splx(s);
|
||||
return r;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
clear_bit(int b, atomic_t *p)
|
||||
{
|
||||
atomic_clear_int(p + (b >> 5), 1 << (b & 0x1f));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
set_bit(int b, atomic_t *p)
|
||||
{
|
||||
atomic_set_int(p + (b >> 5), 1 << (b & 0x1f));
|
||||
}
|
||||
|
||||
static __inline int
|
||||
test_bit(int b, atomic_t *p)
|
||||
{
|
||||
return p[b >> 5] & (1 << (b & 0x1f));
|
||||
}
|
||||
|
||||
static __inline int
|
||||
find_first_zero_bit(atomic_t *p, int max)
|
||||
{
|
||||
int b;
|
||||
|
||||
for (b = 0; b < max; b += 32) {
|
||||
if (p[b >> 5] != ~0) {
|
||||
for (;;) {
|
||||
if ((p[b >> 5] & (1 << (b & 0x1f))) == 0)
|
||||
return b;
|
||||
b++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
#define spldrm() spltty()
|
||||
#define jiffies hardclock_ticks
|
||||
|
||||
#define __drm_dummy_lock(lock) (*(__volatile__ unsigned int *)lock)
|
||||
#define _DRM_CAS(lock,old,new,__ret) \
|
||||
do { \
|
||||
int __dummy; /* Can't mark eax as clobbered */ \
|
||||
__asm__ __volatile__( \
|
||||
"lock ; cmpxchg %4,%1\n\t" \
|
||||
"setnz %0" \
|
||||
: "=d" (__ret), \
|
||||
"=m" (__drm_dummy_lock(lock)), \
|
||||
"=a" (__dummy) \
|
||||
: "2" (old), \
|
||||
"r" (new)); \
|
||||
} while (0)
|
||||
|
||||
/* Redefinitions to make templating easy */
|
||||
#define wait_queue_head_t atomic_t
|
||||
#define agp_memory void
|
||||
|
||||
/* Macros to make printf easier */
|
||||
#define DRM_ERROR(fmt, arg...) \
|
||||
do { \
|
||||
printf("error: [" DRM_NAME ":%s] *ERROR* ", __func__ ); \
|
||||
printf( fmt,## arg ); \
|
||||
} while (0)
|
||||
|
||||
#define DRM_MEM_ERROR(area, fmt, arg...) \
|
||||
printf("error: [" DRM_NAME ":%s:%s] *ERROR* " fmt , \
|
||||
__func__, DRM(mem_stats)[area].name ,## arg)
|
||||
#define DRM_INFO(fmt, arg...) printf("info: " "[" DRM_NAME "] " fmt ,## arg)
|
||||
|
||||
#if DRM_DEBUG_CODE
|
||||
#define DRM_DEBUG(fmt, arg...) \
|
||||
do { \
|
||||
if (DRM(flags) & DRM_FLAG_DEBUG) \
|
||||
printf("[" DRM_NAME ":%s] " fmt , __FUNCTION__,## arg); \
|
||||
} while (0)
|
||||
#else
|
||||
#define DRM_DEBUG(fmt, arg...) do { } while (0)
|
||||
#endif
|
||||
|
||||
#define DRM_PROC_LIMIT (PAGE_SIZE-80)
|
||||
|
||||
#define DRM_SYSCTL_PRINT(fmt, arg...) \
|
||||
snprintf(buf, sizeof(buf), fmt, ##arg); \
|
||||
error = SYSCTL_OUT(req, buf, strlen(buf)); \
|
||||
if (error) return error;
|
||||
|
||||
#define DRM_SYSCTL_PRINT_RET(ret, fmt, arg...) \
|
||||
snprintf(buf, sizeof(buf), fmt, ##arg); \
|
||||
error = SYSCTL_OUT(req, buf, strlen(buf)); \
|
||||
if (error) { ret; return error; }
|
||||
|
||||
|
||||
#define DRM_FIND_MAP(dest, o) \
|
||||
do { \
|
||||
drm_map_list_entry_t *listentry; \
|
||||
TAILQ_FOREACH(listentry, dev->maplist, link) { \
|
||||
if ( listentry->map->offset == o ) { \
|
||||
dest = listentry->map; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Internal functions */
|
||||
|
||||
/* drm_drv.h */
|
||||
extern dev_type_ioctl(DRM(ioctl));
|
||||
extern dev_type_ioctl(DRM(lock));
|
||||
extern dev_type_ioctl(DRM(unlock));
|
||||
extern dev_type_open(DRM(open));
|
||||
extern dev_type_close(DRM(close));
|
||||
extern dev_type_read(DRM(read));
|
||||
extern dev_type_write(DRM(write));
|
||||
extern dev_type_poll(DRM(poll));
|
||||
extern dev_type_mmap(DRM(mmap));
|
||||
extern int DRM(open_helper)(dev_t kdev, int flags, int fmt,
|
||||
DRM_STRUCTPROC *p, drm_device_t *dev);
|
||||
extern drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev,
|
||||
DRM_STRUCTPROC *p);
|
||||
|
||||
/* Misc. IOCTL support (drm_ioctl.h) */
|
||||
extern dev_type_ioctl(DRM(irq_busid));
|
||||
extern dev_type_ioctl(DRM(getunique));
|
||||
extern dev_type_ioctl(DRM(setunique));
|
||||
extern dev_type_ioctl(DRM(getmap));
|
||||
extern dev_type_ioctl(DRM(getclient));
|
||||
extern dev_type_ioctl(DRM(getstats));
|
||||
|
||||
/* Context IOCTL support (drm_context.h) */
|
||||
extern dev_type_ioctl(DRM(resctx));
|
||||
extern dev_type_ioctl(DRM(addctx));
|
||||
extern dev_type_ioctl(DRM(modctx));
|
||||
extern dev_type_ioctl(DRM(getctx));
|
||||
extern dev_type_ioctl(DRM(switchctx));
|
||||
extern dev_type_ioctl(DRM(newctx));
|
||||
extern dev_type_ioctl(DRM(rmctx));
|
||||
extern dev_type_ioctl(DRM(setsareactx));
|
||||
extern dev_type_ioctl(DRM(getsareactx));
|
||||
|
||||
/* Drawable IOCTL support (drm_drawable.h) */
|
||||
extern dev_type_ioctl(DRM(adddraw));
|
||||
extern dev_type_ioctl(DRM(rmdraw));
|
||||
|
||||
/* Authentication IOCTL support (drm_auth.h) */
|
||||
extern dev_type_ioctl(DRM(getmagic));
|
||||
extern dev_type_ioctl(DRM(authmagic));
|
||||
|
||||
/* Locking IOCTL support (drm_lock.h) */
|
||||
extern dev_type_ioctl(DRM(block));
|
||||
extern dev_type_ioctl(DRM(unblock));
|
||||
extern dev_type_ioctl(DRM(finish));
|
||||
|
||||
/* Buffer management support (drm_bufs.h) */
|
||||
extern dev_type_ioctl(DRM(addmap));
|
||||
extern dev_type_ioctl(DRM(rmmap));
|
||||
#if __HAVE_DMA
|
||||
extern dev_type_ioctl(DRM(addbufs_agp));
|
||||
extern dev_type_ioctl(DRM(addbufs_pci));
|
||||
extern dev_type_ioctl(DRM(addbufs_sg));
|
||||
extern dev_type_ioctl(DRM(addbufs));
|
||||
extern dev_type_ioctl(DRM(infobufs));
|
||||
extern dev_type_ioctl(DRM(markbufs));
|
||||
extern dev_type_ioctl(DRM(freebufs));
|
||||
extern dev_type_ioctl(DRM(mapbufs));
|
||||
#endif
|
||||
|
||||
/* DMA support (drm_dma.h) */
|
||||
#if __HAVE_DMA
|
||||
extern dev_type_ioctl(DRM(control));
|
||||
#endif
|
||||
|
||||
/* AGP/GART support (drm_agpsupport.h) */
|
||||
#if __REALLY_HAVE_AGP
|
||||
extern dev_type_ioctl(DRM(agp_acquire));
|
||||
extern dev_type_ioctl(DRM(agp_release));
|
||||
extern dev_type_ioctl(DRM(agp_enable));
|
||||
extern dev_type_ioctl(DRM(agp_info));
|
||||
extern dev_type_ioctl(DRM(agp_alloc));
|
||||
extern dev_type_ioctl(DRM(agp_free));
|
||||
extern dev_type_ioctl(DRM(agp_unbind));
|
||||
extern dev_type_ioctl(DRM(agp_bind));
|
||||
#endif
|
||||
|
||||
/* Scatter Gather Support (drm_scatter.h) */
|
||||
#if __HAVE_SG
|
||||
extern dev_type_ioctl(DRM(sg_alloc));
|
||||
extern dev_type_ioctl(DRM(sg_free));
|
||||
#endif
|
||||
|
||||
/* SysCtl Support (drm_sysctl.h) */
|
||||
extern int DRM(sysctl_init)(drm_device_t *dev);
|
||||
extern int DRM(sysctl_cleanup)(drm_device_t *dev);
|
||||
93
bsd/gamma.h
Normal file
93
bsd/gamma.h
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
/* gamma.c -- 3dlabs GMX 2000 driver -*- linux-c -*-
|
||||
* Created: Mon Jan 4 08:58:31 1999 by gareth@valinux.com
|
||||
*
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PRECISION INSIGHT 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.
|
||||
*
|
||||
* Authors:
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#ifndef __GAMMA_H__
|
||||
#define __GAMMA_H__
|
||||
|
||||
/* This remains constant for all DRM template files.
|
||||
*/
|
||||
#define DRM(x) gamma_##x
|
||||
|
||||
/* General customization:
|
||||
*/
|
||||
#define __HAVE_MTRR 1
|
||||
|
||||
/* DMA customization:
|
||||
*/
|
||||
#define __HAVE_DMA 1
|
||||
#define __HAVE_OLD_DMA 1
|
||||
#define __HAVE_PCI_DMA 1
|
||||
|
||||
#define __HAVE_MULTIPLE_DMA_QUEUES 1
|
||||
#define __HAVE_DMA_WAITQUEUE 1
|
||||
|
||||
#define __HAVE_DMA_WAITLIST 1
|
||||
#define __HAVE_DMA_FREELIST 1
|
||||
|
||||
#define __HAVE_DMA_FLUSH 1
|
||||
#define __HAVE_DMA_SCHEDULE 1
|
||||
|
||||
#define __HAVE_DMA_READY 1
|
||||
#define DRIVER_DMA_READY() do { \
|
||||
gamma_dma_ready(dev); \
|
||||
} while (0)
|
||||
|
||||
#define __HAVE_DMA_QUIESCENT 1
|
||||
#define DRIVER_DMA_QUIESCENT() do { \
|
||||
/* FIXME ! */ \
|
||||
gamma_dma_quiescent_dual(dev); \
|
||||
return 0; \
|
||||
} while (0)
|
||||
|
||||
#define __HAVE_DMA_IRQ 1
|
||||
#define __HAVE_DMA_IRQ_BH 1
|
||||
#define DRIVER_PREINSTALL() do { \
|
||||
drm_gamma_private_t *dev_priv = \
|
||||
(drm_gamma_private_t *)dev->dev_private;\
|
||||
GAMMA_WRITE( GAMMA_GCOMMANDMODE, 0x00000000 ); \
|
||||
GAMMA_WRITE( GAMMA_GDMACONTROL, 0x00000000 ); \
|
||||
} while (0)
|
||||
|
||||
#define DRIVER_POSTINSTALL() do { \
|
||||
drm_gamma_private_t *dev_priv = \
|
||||
(drm_gamma_private_t *)dev->dev_private;\
|
||||
GAMMA_WRITE( GAMMA_GINTENABLE, 0x00002001 ); \
|
||||
GAMMA_WRITE( GAMMA_COMMANDINTENABLE, 0x00000008 ); \
|
||||
GAMMA_WRITE( GAMMA_GDELAYTIMER, 0x00039090 ); \
|
||||
} while (0)
|
||||
|
||||
#define DRIVER_UNINSTALL() do { \
|
||||
drm_gamma_private_t *dev_priv = \
|
||||
(drm_gamma_private_t *)dev->dev_private;\
|
||||
GAMMA_WRITE( GAMMA_GDELAYTIMER, 0x00000000 ); \
|
||||
GAMMA_WRITE( GAMMA_COMMANDINTENABLE, 0x00000000 ); \
|
||||
GAMMA_WRITE( GAMMA_GINTENABLE, 0x00000000 ); \
|
||||
} while (0)
|
||||
|
||||
#endif /* __GAMMA_H__ */
|
||||
569
bsd/gamma_dma.c
Normal file
569
bsd/gamma_dma.c
Normal file
|
|
@ -0,0 +1,569 @@
|
|||
/* gamma_dma.c -- DMA support for GMX 2000 -*- linux-c -*-
|
||||
* Created: Fri Mar 19 14:30:16 1999 by faith@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PRECISION INSIGHT 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.
|
||||
*
|
||||
* Authors:
|
||||
* Rickard E. (Rik) Faith <faith@valinux.com>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "gamma.h"
|
||||
#include "drmP.h"
|
||||
#include "drm.h"
|
||||
#include "gamma_drm.h"
|
||||
#include "gamma_drv.h"
|
||||
|
||||
|
||||
static __inline__ void gamma_dma_dispatch(drm_device_t *dev, unsigned long address,
|
||||
unsigned long length)
|
||||
{
|
||||
drm_gamma_private_t *dev_priv =
|
||||
(drm_gamma_private_t *)dev->dev_private;
|
||||
|
||||
GAMMA_WRITE(GAMMA_DMAADDRESS, DRM_VTOPHYS((void *)address));
|
||||
while (GAMMA_READ(GAMMA_GCOMMANDSTATUS) != 4)
|
||||
;
|
||||
GAMMA_WRITE(GAMMA_DMACOUNT, length / 4);
|
||||
}
|
||||
|
||||
void gamma_dma_quiescent_single(drm_device_t *dev)
|
||||
{
|
||||
drm_gamma_private_t *dev_priv =
|
||||
(drm_gamma_private_t *)dev->dev_private;
|
||||
|
||||
while (GAMMA_READ(GAMMA_DMACOUNT))
|
||||
;
|
||||
while (GAMMA_READ(GAMMA_INFIFOSPACE) < 3)
|
||||
;
|
||||
|
||||
GAMMA_WRITE(GAMMA_FILTERMODE, 1 << 10);
|
||||
GAMMA_WRITE(GAMMA_SYNC, 0);
|
||||
|
||||
do {
|
||||
while (!GAMMA_READ(GAMMA_OUTFIFOWORDS))
|
||||
;
|
||||
} while (GAMMA_READ(GAMMA_OUTPUTFIFO) != GAMMA_SYNC_TAG);
|
||||
}
|
||||
|
||||
void gamma_dma_quiescent_dual(drm_device_t *dev)
|
||||
{
|
||||
drm_gamma_private_t *dev_priv =
|
||||
(drm_gamma_private_t *)dev->dev_private;
|
||||
|
||||
while (GAMMA_READ(GAMMA_DMACOUNT))
|
||||
;
|
||||
while (GAMMA_READ(GAMMA_INFIFOSPACE) < 3)
|
||||
;
|
||||
|
||||
GAMMA_WRITE(GAMMA_BROADCASTMASK, 3);
|
||||
|
||||
GAMMA_WRITE(GAMMA_FILTERMODE, 1 << 10);
|
||||
GAMMA_WRITE(GAMMA_SYNC, 0);
|
||||
|
||||
/* Read from first MX */
|
||||
do {
|
||||
while (!GAMMA_READ(GAMMA_OUTFIFOWORDS))
|
||||
;
|
||||
} while (GAMMA_READ(GAMMA_OUTPUTFIFO) != GAMMA_SYNC_TAG);
|
||||
|
||||
/* Read from second MX */
|
||||
do {
|
||||
while (!GAMMA_READ(GAMMA_OUTFIFOWORDS + 0x10000))
|
||||
;
|
||||
} while (GAMMA_READ(GAMMA_OUTPUTFIFO + 0x10000) != GAMMA_SYNC_TAG);
|
||||
}
|
||||
|
||||
void gamma_dma_ready(drm_device_t *dev)
|
||||
{
|
||||
drm_gamma_private_t *dev_priv =
|
||||
(drm_gamma_private_t *)dev->dev_private;
|
||||
|
||||
while (GAMMA_READ(GAMMA_DMACOUNT))
|
||||
;
|
||||
}
|
||||
|
||||
static __inline__ int gamma_dma_is_ready(drm_device_t *dev)
|
||||
{
|
||||
drm_gamma_private_t *dev_priv =
|
||||
(drm_gamma_private_t *)dev->dev_private;
|
||||
|
||||
return !GAMMA_READ(GAMMA_DMACOUNT);
|
||||
}
|
||||
|
||||
void gamma_dma_service( DRM_IRQ_ARGS)
|
||||
{
|
||||
drm_device_t *dev = (drm_device_t *)device;
|
||||
drm_device_dma_t *dma = dev->dma;
|
||||
drm_gamma_private_t *dev_priv =
|
||||
(drm_gamma_private_t *)dev->dev_private;
|
||||
|
||||
atomic_inc(&dev->counts[6]); /* _DRM_STAT_IRQ */
|
||||
GAMMA_WRITE(GAMMA_GDELAYTIMER, 0xc350/2); /* 0x05S */
|
||||
GAMMA_WRITE(GAMMA_GCOMMANDINTFLAGS, 8);
|
||||
GAMMA_WRITE(GAMMA_GINTFLAGS, 0x2001);
|
||||
if (gamma_dma_is_ready(dev)) {
|
||||
/* Free previous buffer */
|
||||
if (test_and_set_bit(0, &dev->dma_flag)) return;
|
||||
if (dma->this_buffer) {
|
||||
gamma_free_buffer(dev, dma->this_buffer);
|
||||
dma->this_buffer = NULL;
|
||||
}
|
||||
clear_bit(0, &dev->dma_flag);
|
||||
|
||||
taskqueue_enqueue(taskqueue_swi, &dev->task);
|
||||
}
|
||||
}
|
||||
|
||||
/* Only called by gamma_dma_schedule. */
|
||||
static int gamma_do_dma(drm_device_t *dev, int locked)
|
||||
{
|
||||
unsigned long address;
|
||||
unsigned long length;
|
||||
drm_buf_t *buf;
|
||||
int retcode = 0;
|
||||
drm_device_dma_t *dma = dev->dma;
|
||||
#if DRM_DMA_HISTOGRAM
|
||||
cycles_t dma_start, dma_stop;
|
||||
#endif
|
||||
|
||||
if (test_and_set_bit(0, &dev->dma_flag)) return DRM_ERR( EBUSY );
|
||||
|
||||
#if DRM_DMA_HISTOGRAM
|
||||
dma_start = get_cycles();
|
||||
#endif
|
||||
|
||||
if (!dma->next_buffer) {
|
||||
DRM_ERROR("No next_buffer\n");
|
||||
clear_bit(0, &dev->dma_flag);
|
||||
return DRM_ERR( EINVAL );
|
||||
}
|
||||
|
||||
buf = dma->next_buffer;
|
||||
address = (unsigned long)buf->address;
|
||||
length = buf->used;
|
||||
|
||||
DRM_DEBUG("context %d, buffer %d (%ld bytes)\n",
|
||||
buf->context, buf->idx, length);
|
||||
|
||||
if (buf->list == DRM_LIST_RECLAIM) {
|
||||
gamma_clear_next_buffer(dev);
|
||||
gamma_free_buffer(dev, buf);
|
||||
clear_bit(0, &dev->dma_flag);
|
||||
return DRM_ERR( EINVAL );
|
||||
}
|
||||
|
||||
if (!length) {
|
||||
DRM_ERROR("0 length buffer\n");
|
||||
gamma_clear_next_buffer(dev);
|
||||
gamma_free_buffer(dev, buf);
|
||||
clear_bit(0, &dev->dma_flag);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!gamma_dma_is_ready(dev)) {
|
||||
clear_bit(0, &dev->dma_flag);
|
||||
return DRM_ERR( EBUSY );
|
||||
}
|
||||
|
||||
if (buf->while_locked) {
|
||||
if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
|
||||
DRM_ERROR("Dispatching buffer %d from pid %d"
|
||||
" \"while locked\", but no lock held\n",
|
||||
buf->idx, buf->pid);
|
||||
}
|
||||
} else {
|
||||
if (!locked && !gamma_lock_take(&dev->lock.hw_lock->lock,
|
||||
DRM_KERNEL_CONTEXT)) {
|
||||
clear_bit(0, &dev->dma_flag);
|
||||
return DRM_ERR( EBUSY );
|
||||
}
|
||||
}
|
||||
|
||||
if (dev->last_context != buf->context
|
||||
&& !(dev->queuelist[buf->context]->flags
|
||||
& _DRM_CONTEXT_PRESERVED)) {
|
||||
/* PRE: dev->last_context != buf->context */
|
||||
if (DRM(context_switch)(dev, dev->last_context,
|
||||
buf->context)) {
|
||||
DRM(clear_next_buffer)(dev);
|
||||
DRM(free_buffer)(dev, buf);
|
||||
}
|
||||
retcode = EBUSY;
|
||||
goto cleanup;
|
||||
|
||||
/* POST: we will wait for the context
|
||||
switch and will dispatch on a later call
|
||||
when dev->last_context == buf->context.
|
||||
NOTE WE HOLD THE LOCK THROUGHOUT THIS
|
||||
TIME! */
|
||||
}
|
||||
|
||||
gamma_clear_next_buffer(dev);
|
||||
buf->pending = 1;
|
||||
buf->waiting = 0;
|
||||
buf->list = DRM_LIST_PEND;
|
||||
#if DRM_DMA_HISTOGRAM
|
||||
buf->time_dispatched = get_cycles();
|
||||
#endif
|
||||
|
||||
gamma_dma_dispatch(dev, address, length);
|
||||
gamma_free_buffer(dev, dma->this_buffer);
|
||||
dma->this_buffer = buf;
|
||||
|
||||
atomic_inc(&dev->counts[7]); /* _DRM_STAT_DMA */
|
||||
atomic_add(length, &dev->counts[8]); /* _DRM_STAT_PRIMARY */
|
||||
|
||||
if (!buf->while_locked && !dev->context_flag && !locked) {
|
||||
if (gamma_lock_free(dev, &dev->lock.hw_lock->lock,
|
||||
DRM_KERNEL_CONTEXT)) {
|
||||
DRM_ERROR("\n");
|
||||
}
|
||||
}
|
||||
cleanup:
|
||||
|
||||
clear_bit(0, &dev->dma_flag);
|
||||
|
||||
#if DRM_DMA_HISTOGRAM
|
||||
dma_stop = get_cycles();
|
||||
atomic_inc(&dev->histo.dma[gamma_histogram_slot(dma_stop - dma_start)]);
|
||||
#endif
|
||||
|
||||
return DRM_ERR( retcode );
|
||||
}
|
||||
|
||||
static void gamma_dma_timer_bh(unsigned long dev)
|
||||
{
|
||||
gamma_dma_schedule((drm_device_t *)dev, 0);
|
||||
}
|
||||
|
||||
void gamma_dma_immediate_bh(DRM_TASKQUEUE_ARGS)
|
||||
{
|
||||
gamma_dma_schedule(dev, 0);
|
||||
}
|
||||
|
||||
int gamma_dma_schedule(drm_device_t *dev, int locked)
|
||||
{
|
||||
int next;
|
||||
drm_queue_t *q;
|
||||
drm_buf_t *buf;
|
||||
int retcode = 0;
|
||||
int processed = 0;
|
||||
int missed;
|
||||
int expire = 20;
|
||||
drm_device_dma_t *dma = dev->dma;
|
||||
#if DRM_DMA_HISTOGRAM
|
||||
cycles_t schedule_start;
|
||||
#endif
|
||||
|
||||
if (test_and_set_bit(0, &dev->interrupt_flag)) {
|
||||
/* Not reentrant */
|
||||
atomic_inc(&dev->counts[10]); /* _DRM_STAT_MISSED */
|
||||
return DRM_ERR( EBUSY );
|
||||
}
|
||||
missed = atomic_read(&dev->counts[10]);
|
||||
|
||||
#if DRM_DMA_HISTOGRAM
|
||||
schedule_start = get_cycles();
|
||||
#endif
|
||||
|
||||
again:
|
||||
if (dev->context_flag) {
|
||||
clear_bit(0, &dev->interrupt_flag);
|
||||
return DRM_ERR( EBUSY );
|
||||
}
|
||||
if (dma->next_buffer) {
|
||||
/* Unsent buffer that was previously
|
||||
selected, but that couldn't be sent
|
||||
because the lock could not be obtained
|
||||
or the DMA engine wasn't ready. Try
|
||||
again. */
|
||||
if (!(retcode = gamma_do_dma(dev, locked))) ++processed;
|
||||
} else {
|
||||
do {
|
||||
next = gamma_select_queue(dev, gamma_dma_timer_bh);
|
||||
if (next >= 0) {
|
||||
q = dev->queuelist[next];
|
||||
buf = gamma_waitlist_get(&q->waitlist);
|
||||
dma->next_buffer = buf;
|
||||
dma->next_queue = q;
|
||||
if (buf && buf->list == DRM_LIST_RECLAIM) {
|
||||
gamma_clear_next_buffer(dev);
|
||||
gamma_free_buffer(dev, buf);
|
||||
}
|
||||
}
|
||||
} while (next >= 0 && !dma->next_buffer);
|
||||
if (dma->next_buffer) {
|
||||
if (!(retcode = gamma_do_dma(dev, locked))) {
|
||||
++processed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (--expire) {
|
||||
if (missed != atomic_read(&dev->counts[10])) {
|
||||
if (gamma_dma_is_ready(dev)) goto again;
|
||||
}
|
||||
if (processed && gamma_dma_is_ready(dev)) {
|
||||
processed = 0;
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
|
||||
clear_bit(0, &dev->interrupt_flag);
|
||||
|
||||
#if DRM_DMA_HISTOGRAM
|
||||
atomic_inc(&dev->histo.schedule[gamma_histogram_slot(get_cycles()
|
||||
- schedule_start)]);
|
||||
#endif
|
||||
return retcode;
|
||||
}
|
||||
|
||||
static int gamma_dma_priority(drm_device_t *dev, drm_dma_t *d)
|
||||
{
|
||||
unsigned long address;
|
||||
unsigned long length;
|
||||
int must_free = 0;
|
||||
int retcode = 0;
|
||||
int i;
|
||||
int idx;
|
||||
drm_buf_t *buf;
|
||||
drm_buf_t *last_buf = NULL;
|
||||
drm_device_dma_t *dma = dev->dma;
|
||||
static int never;
|
||||
|
||||
/* Turn off interrupt handling */
|
||||
while (test_and_set_bit(0, &dev->interrupt_flag)) {
|
||||
retcode = tsleep(&never, PZERO|PCATCH, "gamp1", 1);
|
||||
if (retcode)
|
||||
return retcode;
|
||||
}
|
||||
if (!(d->flags & _DRM_DMA_WHILE_LOCKED)) {
|
||||
while (!gamma_lock_take(&dev->lock.hw_lock->lock,
|
||||
DRM_KERNEL_CONTEXT)) {
|
||||
retcode = tsleep(&never, PZERO|PCATCH, "gamp2", 1);
|
||||
if (retcode)
|
||||
return retcode;
|
||||
}
|
||||
++must_free;
|
||||
}
|
||||
|
||||
for (i = 0; i < d->send_count; i++) {
|
||||
idx = d->send_indices[i];
|
||||
if (idx < 0 || idx >= dma->buf_count) {
|
||||
DRM_ERROR("Index %d (of %d max)\n",
|
||||
d->send_indices[i], dma->buf_count - 1);
|
||||
continue;
|
||||
}
|
||||
buf = dma->buflist[ idx ];
|
||||
if (buf->pid != DRM_CURRENTPID) {
|
||||
DRM_ERROR("Process %d using buffer owned by %d\n",
|
||||
DRM_CURRENTPID, buf->pid);
|
||||
retcode = EINVAL;
|
||||
goto cleanup;
|
||||
}
|
||||
if (buf->list != DRM_LIST_NONE) {
|
||||
DRM_ERROR("Process %d using %d's buffer on list %d\n",
|
||||
DRM_CURRENTPID, buf->pid, buf->list);
|
||||
retcode = EINVAL;
|
||||
goto cleanup;
|
||||
}
|
||||
/* This isn't a race condition on
|
||||
buf->list, since our concern is the
|
||||
buffer reclaim during the time the
|
||||
process closes the /dev/drm? handle, so
|
||||
it can't also be doing DMA. */
|
||||
buf->list = DRM_LIST_PRIO;
|
||||
buf->used = d->send_sizes[i];
|
||||
buf->context = d->context;
|
||||
buf->while_locked = d->flags & _DRM_DMA_WHILE_LOCKED;
|
||||
address = (unsigned long)buf->address;
|
||||
length = buf->used;
|
||||
if (!length) {
|
||||
DRM_ERROR("0 length buffer\n");
|
||||
}
|
||||
if (buf->pending) {
|
||||
DRM_ERROR("Sending pending buffer:"
|
||||
" buffer %d, offset %d\n",
|
||||
d->send_indices[i], i);
|
||||
retcode = EINVAL;
|
||||
goto cleanup;
|
||||
}
|
||||
if (buf->waiting) {
|
||||
DRM_ERROR("Sending waiting buffer:"
|
||||
" buffer %d, offset %d\n",
|
||||
d->send_indices[i], i);
|
||||
retcode = EINVAL;
|
||||
goto cleanup;
|
||||
}
|
||||
buf->pending = 1;
|
||||
|
||||
if (dev->last_context != buf->context
|
||||
&& !(dev->queuelist[buf->context]->flags
|
||||
& _DRM_CONTEXT_PRESERVED)) {
|
||||
/* PRE: dev->last_context != buf->context */
|
||||
DRM(context_switch)(dev, dev->last_context,
|
||||
buf->context);
|
||||
/* POST: we will wait for the context
|
||||
switch and will dispatch on a later call
|
||||
when dev->last_context == buf->context.
|
||||
NOTE WE HOLD THE LOCK THROUGHOUT THIS
|
||||
TIME! */
|
||||
retcode = tsleep(&dev->context_wait, PZERO|PCATCH,
|
||||
"gamctx", 0);
|
||||
if (retcode)
|
||||
goto cleanup;
|
||||
if (dev->last_context != buf->context) {
|
||||
DRM_ERROR("Context mismatch: %d %d\n",
|
||||
dev->last_context,
|
||||
buf->context);
|
||||
}
|
||||
}
|
||||
|
||||
#if DRM_DMA_HISTOGRAM
|
||||
buf->time_queued = get_cycles();
|
||||
buf->time_dispatched = buf->time_queued;
|
||||
#endif
|
||||
gamma_dma_dispatch(dev, address, length);
|
||||
atomic_inc(&dev->counts[9]); /* _DRM_STAT_SPECIAL */
|
||||
atomic_add(length, &dev->counts[8]); /* _DRM_STAT_PRIMARY */
|
||||
|
||||
if (last_buf) {
|
||||
gamma_free_buffer(dev, last_buf);
|
||||
}
|
||||
last_buf = buf;
|
||||
}
|
||||
|
||||
|
||||
cleanup:
|
||||
if (last_buf) {
|
||||
gamma_dma_ready(dev);
|
||||
gamma_free_buffer(dev, last_buf);
|
||||
}
|
||||
|
||||
if (must_free && !dev->context_flag) {
|
||||
if (gamma_lock_free(dev, &dev->lock.hw_lock->lock,
|
||||
DRM_KERNEL_CONTEXT)) {
|
||||
DRM_ERROR("\n");
|
||||
}
|
||||
}
|
||||
clear_bit(0, &dev->interrupt_flag);
|
||||
return DRM_ERR( retcode );
|
||||
}
|
||||
|
||||
static int gamma_dma_send_buffers(drm_device_t *dev, drm_dma_t *d)
|
||||
{
|
||||
drm_buf_t *last_buf = NULL;
|
||||
int retcode = 0;
|
||||
drm_device_dma_t *dma = dev->dma;
|
||||
|
||||
if (d->flags & _DRM_DMA_BLOCK) {
|
||||
last_buf = dma->buflist[d->send_indices[d->send_count-1]];
|
||||
atomic_inc(&last_buf->dma_wait);
|
||||
}
|
||||
|
||||
if ((retcode = gamma_dma_enqueue(dev, d))) {
|
||||
if (d->flags & _DRM_DMA_BLOCK)
|
||||
atomic_dec(&last_buf->dma_wait);
|
||||
return retcode;
|
||||
}
|
||||
|
||||
gamma_dma_schedule(dev, 0);
|
||||
|
||||
if (d->flags & _DRM_DMA_BLOCK) {
|
||||
DRM_DEBUG("%d waiting\n", DRM_CURRENTPID);
|
||||
for (;;) {
|
||||
retcode = tsleep(&last_buf->dma_wait, PZERO|PCATCH,
|
||||
"gamdw", 0);
|
||||
if (!last_buf->waiting
|
||||
&& !last_buf->pending)
|
||||
break; /* finished */
|
||||
if (retcode)
|
||||
break;
|
||||
}
|
||||
atomic_dec(&last_buf->dma_wait);
|
||||
DRM_DEBUG("%d running\n", DRM_CURRENTPID);
|
||||
if (!retcode
|
||||
|| (last_buf->list==DRM_LIST_PEND && !last_buf->pending)) {
|
||||
if (!last_buf->dma_wait) {
|
||||
gamma_free_buffer(dev, last_buf);
|
||||
}
|
||||
}
|
||||
if (retcode) {
|
||||
DRM_ERROR("ctx%d w%d p%d c%d i%d l%d %d/%d\n",
|
||||
d->context,
|
||||
last_buf->waiting,
|
||||
last_buf->pending,
|
||||
DRM_WAITCOUNT(dev, d->context),
|
||||
last_buf->idx,
|
||||
last_buf->list,
|
||||
last_buf->pid,
|
||||
DRM_CURRENTPID);
|
||||
}
|
||||
}
|
||||
return DRM_ERR( retcode );
|
||||
}
|
||||
|
||||
int gamma_dma( DRM_IOCTL_ARGS )
|
||||
{
|
||||
DRM_DEVICE;
|
||||
drm_device_dma_t *dma = dev->dma;
|
||||
int retcode = 0;
|
||||
drm_dma_t d;
|
||||
|
||||
DRM_COPY_FROM_USER_IOCTL(d, (drm_dma_t *) data, sizeof(d));
|
||||
|
||||
if (d.send_count < 0 || d.send_count > dma->buf_count) {
|
||||
DRM_ERROR("Process %d trying to send %d buffers (of %d max)\n",
|
||||
DRM_CURRENTPID, d.send_count, dma->buf_count);
|
||||
return DRM_ERR( EINVAL );
|
||||
}
|
||||
|
||||
if (d.request_count < 0 || d.request_count > dma->buf_count) {
|
||||
DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n",
|
||||
DRM_CURRENTPID, d.request_count, dma->buf_count);
|
||||
return DRM_ERR( EINVAL );
|
||||
}
|
||||
|
||||
if (d.send_count) {
|
||||
if (d.flags & _DRM_DMA_PRIORITY)
|
||||
retcode = gamma_dma_priority(dev, &d);
|
||||
else
|
||||
retcode = gamma_dma_send_buffers(dev, &d);
|
||||
}
|
||||
|
||||
d.granted_count = 0;
|
||||
|
||||
if (!retcode && d.request_count) {
|
||||
retcode = gamma_dma_get_buffers(dev, &d);
|
||||
}
|
||||
|
||||
DRM_DEBUG("%d returning, granted = %d\n",
|
||||
DRM_CURRENTPID, d.granted_count);
|
||||
DRM_COPY_TO_USER_IOCTL((drm_dma_t *) data, d, sizeof(d));
|
||||
|
||||
return retcode;
|
||||
}
|
||||
86
bsd/gamma_drv.c
Normal file
86
bsd/gamma_drv.c
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
/* gamma.c -- 3dlabs GMX 2000 driver -*- linux-c -*-
|
||||
* Created: Mon Jan 4 08:58:31 1999 by faith@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PRECISION INSIGHT 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.
|
||||
*
|
||||
* Authors:
|
||||
* Rickard E. (Rik) Faith <faith@valinux.com>
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "gamma.h"
|
||||
#include "drmP.h"
|
||||
#include "drm.h"
|
||||
#include "gamma_drm.h"
|
||||
#include "gamma_drv.h"
|
||||
|
||||
#define DRIVER_AUTHOR "VA Linux Systems Inc."
|
||||
|
||||
#define DRIVER_NAME "gamma"
|
||||
#define DRIVER_DESC "3DLabs gamma"
|
||||
#define DRIVER_DATE "20010216"
|
||||
|
||||
#define DRIVER_MAJOR 1
|
||||
#define DRIVER_MINOR 0
|
||||
#define DRIVER_PATCHLEVEL 0
|
||||
|
||||
#define DRIVER_IOCTLS \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { gamma_dma, 1, 0 }
|
||||
|
||||
/* List acquired from http://www.yourvote.com/pci/pcihdr.h and xc/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
|
||||
* Please report to anholt@teleport.com inaccuracies or if a chip you have works that is marked unsupported here.
|
||||
*/
|
||||
drm_chipinfo_t DRM(devicelist)[] = {
|
||||
{0x3d3d, 0x0008, 1, "3DLabs Gamma"},
|
||||
{0, 0, 0, NULL}
|
||||
};
|
||||
|
||||
|
||||
#define __HAVE_COUNTERS 5
|
||||
#define __HAVE_COUNTER6 _DRM_STAT_IRQ
|
||||
#define __HAVE_COUNTER7 _DRM_STAT_DMA
|
||||
#define __HAVE_COUNTER8 _DRM_STAT_PRIMARY
|
||||
#define __HAVE_COUNTER9 _DRM_STAT_SPECIAL
|
||||
#define __HAVE_COUNTER10 _DRM_STAT_MISSED
|
||||
|
||||
|
||||
#include "drm_auth.h"
|
||||
#include "drm_bufs.h"
|
||||
#include "drm_context.h"
|
||||
#include "drm_dma.h"
|
||||
#include "drm_drawable.h"
|
||||
#include "drm_drv.h"
|
||||
|
||||
|
||||
#include "drm_fops.h"
|
||||
#include "drm_init.h"
|
||||
#include "drm_ioctl.h"
|
||||
#include "drm_lists.h"
|
||||
#include "drm_lock.h"
|
||||
#include "drm_memory.h"
|
||||
#include "drm_vm.h"
|
||||
#include "drm_sysctl.h"
|
||||
|
||||
DRIVER_MODULE(gamma, pci, gamma_driver, gamma_devclass, 0, 0);
|
||||
104
bsd/gamma_drv.h
Normal file
104
bsd/gamma_drv.h
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
/* gamma_drv.h -- Private header for 3dlabs GMX 2000 driver -*- linux-c -*-
|
||||
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PRECISION INSIGHT 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.
|
||||
*
|
||||
* Authors:
|
||||
* Rickard E. (Rik) Faith <faith@valinux.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _GAMMA_DRV_H_
|
||||
#define _GAMMA_DRV_H_
|
||||
|
||||
|
||||
typedef struct drm_gamma_private {
|
||||
drm_map_t *buffers;
|
||||
drm_map_t *mmio0;
|
||||
drm_map_t *mmio1;
|
||||
drm_map_t *mmio2;
|
||||
drm_map_t *mmio3;
|
||||
} drm_gamma_private_t;
|
||||
|
||||
#define LOCK_TEST_WITH_RETURN( dev ) \
|
||||
do { \
|
||||
if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
|
||||
dev->lock.pid != DRM_CURRENTPID ) { \
|
||||
DRM_ERROR( "%s called without lock held\n", \
|
||||
__FUNCTION__ ); \
|
||||
return DRM_ERR( EINVAL ); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
extern void gamma_dma_ready(drm_device_t *dev);
|
||||
extern void gamma_dma_quiescent_single(drm_device_t *dev);
|
||||
extern void gamma_dma_quiescent_dual(drm_device_t *dev);
|
||||
|
||||
/* gamma_dma.c */
|
||||
extern int gamma_dma_schedule(drm_device_t *dev, int locked);
|
||||
extern int gamma_dma( DRM_IOCTL_ARGS );
|
||||
extern int gamma_find_devices(void);
|
||||
extern int gamma_found(void);
|
||||
|
||||
|
||||
#define GAMMA_OFF(reg) \
|
||||
((reg < 0x1000) \
|
||||
? reg \
|
||||
: ((reg < 0x10000) \
|
||||
? (reg - 0x1000) \
|
||||
: ((reg < 0x11000) \
|
||||
? (reg - 0x10000) \
|
||||
: (reg - 0x11000))))
|
||||
|
||||
#define GAMMA_BASE(reg) ((unsigned long) \
|
||||
((reg < 0x1000) ? dev_priv->mmio0->handle : \
|
||||
((reg < 0x10000) ? dev_priv->mmio1->handle : \
|
||||
((reg < 0x11000) ? dev_priv->mmio2->handle : \
|
||||
dev_priv->mmio3->handle))))
|
||||
|
||||
#define GAMMA_ADDR(reg) (GAMMA_BASE(reg) + GAMMA_OFF(reg))
|
||||
#define GAMMA_DEREF(reg) *(__volatile__ int *)GAMMA_ADDR(reg)
|
||||
#define GAMMA_READ(reg) GAMMA_DEREF(reg)
|
||||
#define GAMMA_WRITE(reg,val) do { GAMMA_DEREF(reg) = val; } while (0)
|
||||
|
||||
#define GAMMA_BROADCASTMASK 0x9378
|
||||
#define GAMMA_COMMANDINTENABLE 0x0c48
|
||||
#define GAMMA_DMAADDRESS 0x0028
|
||||
#define GAMMA_DMACOUNT 0x0030
|
||||
#define GAMMA_FILTERMODE 0x8c00
|
||||
#define GAMMA_GCOMMANDINTFLAGS 0x0c50
|
||||
#define GAMMA_GCOMMANDMODE 0x0c40
|
||||
#define GAMMA_GCOMMANDSTATUS 0x0c60
|
||||
#define GAMMA_GDELAYTIMER 0x0c38
|
||||
#define GAMMA_GDMACONTROL 0x0060
|
||||
#define GAMMA_GINTENABLE 0x0808
|
||||
#define GAMMA_GINTFLAGS 0x0810
|
||||
#define GAMMA_INFIFOSPACE 0x0018
|
||||
#define GAMMA_OUTFIFOWORDS 0x0020
|
||||
#define GAMMA_OUTPUTFIFO 0x2000
|
||||
#define GAMMA_SYNC 0x8c40
|
||||
#define GAMMA_SYNC_TAG 0x0188
|
||||
|
||||
#endif
|
||||
116
bsd/i810.h
Normal file
116
bsd/i810.h
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
/* i810.h -- Intel i810/i815 DRM template customization -*- linux-c -*-
|
||||
* Created: Thu Feb 15 00:01:12 2001 by gareth@valinux.com
|
||||
*
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS 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.
|
||||
*
|
||||
* Authors:
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#ifndef __I810_H__
|
||||
#define __I810_H__
|
||||
|
||||
/* This remains constant for all DRM template files.
|
||||
*/
|
||||
#define DRM(x) i810_##x
|
||||
|
||||
/* General customization:
|
||||
*/
|
||||
#define __HAVE_AGP 1
|
||||
#define __MUST_HAVE_AGP 1
|
||||
#define __HAVE_MTRR 1
|
||||
#define __HAVE_CTX_BITMAP 1
|
||||
|
||||
/* Driver customization:
|
||||
*/
|
||||
#define __HAVE_RELEASE 1
|
||||
#define DRIVER_RELEASE() do { \
|
||||
i810_reclaim_buffers( dev, priv->pid ); \
|
||||
} while (0)
|
||||
|
||||
/* DMA customization:
|
||||
*/
|
||||
#define __HAVE_DMA 1
|
||||
#define __HAVE_DMA_QUEUE 1
|
||||
#define __HAVE_DMA_WAITLIST 1
|
||||
#define __HAVE_DMA_RECLAIM 1
|
||||
|
||||
#define __HAVE_DMA_QUIESCENT 1
|
||||
#define DRIVER_DMA_QUIESCENT() do { \
|
||||
i810_dma_quiescent( dev ); \
|
||||
} while (0)
|
||||
|
||||
#define __HAVE_DMA_IRQ 1
|
||||
#define __HAVE_DMA_IRQ_BH 1
|
||||
#define __HAVE_SHARED_IRQ 1
|
||||
#define DRIVER_PREINSTALL() do { \
|
||||
drm_i810_private_t *dev_priv = \
|
||||
(drm_i810_private_t *)dev->dev_private; \
|
||||
u16 tmp; \
|
||||
tmp = I810_READ16( I810REG_HWSTAM ); \
|
||||
tmp = tmp & 0x6000; \
|
||||
I810_WRITE16( I810REG_HWSTAM, tmp ); \
|
||||
\
|
||||
tmp = I810_READ16( I810REG_INT_MASK_R ); \
|
||||
tmp = tmp & 0x6000; /* Unmask interrupts */ \
|
||||
I810_WRITE16( I810REG_INT_MASK_R, tmp ); \
|
||||
tmp = I810_READ16( I810REG_INT_ENABLE_R ); \
|
||||
tmp = tmp & 0x6000; /* Disable all interrupts */ \
|
||||
I810_WRITE16( I810REG_INT_ENABLE_R, tmp ); \
|
||||
} while (0)
|
||||
|
||||
#define DRIVER_POSTINSTALL() do { \
|
||||
drm_i810_private_t *dev_priv = \
|
||||
(drm_i810_private_t *)dev->dev_private; \
|
||||
u16 tmp; \
|
||||
tmp = I810_READ16( I810REG_INT_ENABLE_R ); \
|
||||
tmp = tmp & 0x6000; \
|
||||
tmp = tmp | 0x0003; /* Enable bp & user interrupts */ \
|
||||
I810_WRITE16( I810REG_INT_ENABLE_R, tmp ); \
|
||||
} while (0)
|
||||
|
||||
#define DRIVER_UNINSTALL() do { \
|
||||
drm_i810_private_t *dev_priv = \
|
||||
(drm_i810_private_t *)dev->dev_private; \
|
||||
u16 tmp; \
|
||||
if ( dev_priv ) { \
|
||||
tmp = I810_READ16( I810REG_INT_IDENTITY_R ); \
|
||||
tmp = tmp & ~(0x6000); /* Clear all interrupts */ \
|
||||
if ( tmp != 0 ) \
|
||||
I810_WRITE16( I810REG_INT_IDENTITY_R, tmp ); \
|
||||
\
|
||||
tmp = I810_READ16( I810REG_INT_ENABLE_R ); \
|
||||
tmp = tmp & 0x6000; /* Disable all interrupts */ \
|
||||
I810_WRITE16( I810REG_INT_ENABLE_R, tmp ); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Buffer customization:
|
||||
*/
|
||||
|
||||
#define DRIVER_BUF_PRIV_T drm_i810_buf_priv_t
|
||||
|
||||
#define DRIVER_AGP_BUFFERS_MAP( dev ) \
|
||||
((drm_i810_private_t *)((dev)->dev_private))->buffer_map
|
||||
|
||||
#endif
|
||||
1223
bsd/i810_dma.c
Normal file
1223
bsd/i810_dma.c
Normal file
File diff suppressed because it is too large
Load diff
96
bsd/i810_drv.c
Normal file
96
bsd/i810_drv.c
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/* i810_drv.c -- I810 driver -*- linux-c -*-
|
||||
* Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS 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.
|
||||
*
|
||||
* Authors:
|
||||
* Rickard E. (Rik) Faith <faith@valinux.com>
|
||||
* Jeff Hartmann <jhartmann@valinux.com>
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/bus.h>
|
||||
#include <pci/pcivar.h>
|
||||
|
||||
#include "i810.h"
|
||||
#include "drmP.h"
|
||||
#include "drm.h"
|
||||
#include "i810_drm.h"
|
||||
#include "i810_drv.h"
|
||||
|
||||
#define DRIVER_AUTHOR "VA Linux Systems Inc."
|
||||
|
||||
#define DRIVER_NAME "i810"
|
||||
#define DRIVER_DESC "Intel i810"
|
||||
#define DRIVER_DATE "20010616"
|
||||
|
||||
#define DRIVER_MAJOR 1
|
||||
#define DRIVER_MINOR 2
|
||||
#define DRIVER_PATCHLEVEL 0
|
||||
|
||||
/* Device IDs unknown. Can someone help? anholt@teleport.com */
|
||||
drm_chipinfo_t DRM(devicelist)[] = {
|
||||
{0, 0, 0, NULL}
|
||||
};
|
||||
|
||||
#define DRIVER_IOCTLS \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_I810_INIT)] = { i810_dma_init, 1, 1 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_I810_VERTEX)] = { i810_dma_vertex, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_I810_CLEAR)] = { i810_clear_bufs, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_I810_FLUSH)] = { i810_flush_ioctl, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_I810_GETAGE)] = { i810_getage, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_I810_GETBUF)] = { i810_getbuf, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_I810_SWAP)] = { i810_swap_bufs, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_I810_COPY)] = { i810_copybuf, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_I810_DOCOPY)] = { i810_docopy, 1, 0 },
|
||||
|
||||
|
||||
#define __HAVE_COUNTERS 4
|
||||
#define __HAVE_COUNTER6 _DRM_STAT_IRQ
|
||||
#define __HAVE_COUNTER7 _DRM_STAT_PRIMARY
|
||||
#define __HAVE_COUNTER8 _DRM_STAT_SECONDARY
|
||||
#define __HAVE_COUNTER9 _DRM_STAT_DMA
|
||||
|
||||
|
||||
#include "drm_agpsupport.h"
|
||||
#include "drm_auth.h"
|
||||
#include "drm_bufs.h"
|
||||
#include "drm_context.h"
|
||||
#include "drm_dma.h"
|
||||
#include "drm_drawable.h"
|
||||
#include "drm_drv.h"
|
||||
|
||||
|
||||
#include "drm_fops.h"
|
||||
#include "drm_init.h"
|
||||
#include "drm_ioctl.h"
|
||||
#include "drm_lock.h"
|
||||
#include "drm_lists.h"
|
||||
#include "drm_memory.h"
|
||||
#include "drm_vm.h"
|
||||
#include "drm_sysctl.h"
|
||||
|
||||
DRIVER_MODULE(i810, pci, i810_driver, i810_devclass, 0, 0);
|
||||
179
bsd/i810_drv.h
Normal file
179
bsd/i810_drv.h
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
/* i810_drv.h -- Private header for the Matrox g200/g400 driver -*- linux-c -*-
|
||||
* Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PRECISION INSIGHT 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.
|
||||
*
|
||||
* Authors: Rickard E. (Rik) Faith <faith@valinux.com>
|
||||
* Jeff Hartmann <jhartmann@valinux.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _I810_DRV_H_
|
||||
#define _I810_DRV_H_
|
||||
|
||||
typedef struct drm_i810_buf_priv {
|
||||
u32 *in_use;
|
||||
int my_use_idx;
|
||||
int currently_mapped;
|
||||
void *virtual;
|
||||
void *kernel_virtual;
|
||||
int map_count;
|
||||
struct vm_area_struct *vma;
|
||||
} drm_i810_buf_priv_t;
|
||||
|
||||
typedef struct _drm_i810_ring_buffer{
|
||||
int tail_mask;
|
||||
unsigned long Start;
|
||||
unsigned long End;
|
||||
unsigned long Size;
|
||||
u8 *virtual_start;
|
||||
int head;
|
||||
int tail;
|
||||
int space;
|
||||
} drm_i810_ring_buffer_t;
|
||||
|
||||
typedef struct drm_i810_private {
|
||||
drm_map_t *sarea_map;
|
||||
drm_map_t *buffer_map;
|
||||
drm_map_t *mmio_map;
|
||||
|
||||
drm_i810_sarea_t *sarea_priv;
|
||||
drm_i810_ring_buffer_t ring;
|
||||
|
||||
unsigned long hw_status_page;
|
||||
unsigned long counter;
|
||||
|
||||
atomic_t flush_done;
|
||||
wait_queue_head_t flush_queue; /* Processes waiting until flush */
|
||||
drm_buf_t *mmap_buffer;
|
||||
|
||||
|
||||
u32 front_di1, back_di1, zi1;
|
||||
|
||||
int back_offset;
|
||||
int depth_offset;
|
||||
int w, h;
|
||||
int pitch;
|
||||
} drm_i810_private_t;
|
||||
|
||||
/* i810_dma.c */
|
||||
extern int i810_dma_schedule(drm_device_t *dev, int locked);
|
||||
extern int i810_getbuf( DRM_IOCTL_ARGS );
|
||||
extern int i810_dma_init( DRM_IOCTL_ARGS );
|
||||
extern int i810_flush_ioctl( DRM_IOCTL_ARGS );
|
||||
extern int i810_getage( DRM_IOCTL_ARGS );
|
||||
extern int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma);
|
||||
extern int i810_copybuf( DRM_IOCTL_ARGS );
|
||||
extern int i810_docopy( DRM_IOCTL_ARGS );
|
||||
|
||||
extern void i810_dma_quiescent(drm_device_t *dev);
|
||||
|
||||
#define I810_VERBOSE 0
|
||||
|
||||
|
||||
int i810_dma_vertex( DRM_IOCTL_ARGS );
|
||||
int i810_swap_bufs( DRM_IOCTL_ARGS );
|
||||
int i810_clear_bufs( DRM_IOCTL_ARGS );
|
||||
|
||||
#define I810_BASE(reg) ((unsigned long) \
|
||||
dev_priv->mmio_map->handle)
|
||||
#define I810_ADDR(reg) (I810_BASE(reg) + reg)
|
||||
#define I810_DEREF(reg) *(__volatile__ int *)I810_ADDR(reg)
|
||||
#define I810_READ(reg) I810_DEREF(reg)
|
||||
#define I810_WRITE(reg,val) do { I810_DEREF(reg) = val; } while (0)
|
||||
#define I810_DEREF16(reg) *(__volatile__ u16 *)I810_ADDR(reg)
|
||||
#define I810_READ16(reg) I810_DEREF16(reg)
|
||||
#define I810_WRITE16(reg,val) do { I810_DEREF16(reg) = val; } while (0)
|
||||
|
||||
|
||||
#define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23))
|
||||
#define GFX_OP_BREAKPOINT_INTERRUPT ((0<<29)|(1<<23))
|
||||
#define CMD_REPORT_HEAD (7<<23)
|
||||
#define CMD_STORE_DWORD_IDX ((0x21<<23) | 0x1)
|
||||
#define CMD_OP_BATCH_BUFFER ((0x0<<29)|(0x30<<23)|0x1)
|
||||
|
||||
#define INST_PARSER_CLIENT 0x00000000
|
||||
#define INST_OP_FLUSH 0x02000000
|
||||
#define INST_FLUSH_MAP_CACHE 0x00000001
|
||||
|
||||
|
||||
#define BB1_START_ADDR_MASK (~0x7)
|
||||
#define BB1_PROTECTED (1<<0)
|
||||
#define BB1_UNPROTECTED (0<<0)
|
||||
#define BB2_END_ADDR_MASK (~0x7)
|
||||
|
||||
#define I810REG_HWSTAM 0x02098
|
||||
#define I810REG_INT_IDENTITY_R 0x020a4
|
||||
#define I810REG_INT_MASK_R 0x020a8
|
||||
#define I810REG_INT_ENABLE_R 0x020a0
|
||||
|
||||
#define LP_RING 0x2030
|
||||
#define HP_RING 0x2040
|
||||
#define RING_TAIL 0x00
|
||||
#define TAIL_ADDR 0x000FFFF8
|
||||
#define RING_HEAD 0x04
|
||||
#define HEAD_WRAP_COUNT 0xFFE00000
|
||||
#define HEAD_WRAP_ONE 0x00200000
|
||||
#define HEAD_ADDR 0x001FFFFC
|
||||
#define RING_START 0x08
|
||||
#define START_ADDR 0x00FFFFF8
|
||||
#define RING_LEN 0x0C
|
||||
#define RING_NR_PAGES 0x000FF000
|
||||
#define RING_REPORT_MASK 0x00000006
|
||||
#define RING_REPORT_64K 0x00000002
|
||||
#define RING_REPORT_128K 0x00000004
|
||||
#define RING_NO_REPORT 0x00000000
|
||||
#define RING_VALID_MASK 0x00000001
|
||||
#define RING_VALID 0x00000001
|
||||
#define RING_INVALID 0x00000000
|
||||
|
||||
#define GFX_OP_SCISSOR ((0x3<<29)|(0x1c<<24)|(0x10<<19))
|
||||
#define SC_UPDATE_SCISSOR (0x1<<1)
|
||||
#define SC_ENABLE_MASK (0x1<<0)
|
||||
#define SC_ENABLE (0x1<<0)
|
||||
|
||||
#define GFX_OP_SCISSOR_INFO ((0x3<<29)|(0x1d<<24)|(0x81<<16)|(0x1))
|
||||
#define SCI_YMIN_MASK (0xffff<<16)
|
||||
#define SCI_XMIN_MASK (0xffff<<0)
|
||||
#define SCI_YMAX_MASK (0xffff<<16)
|
||||
#define SCI_XMAX_MASK (0xffff<<0)
|
||||
|
||||
#define GFX_OP_COLOR_FACTOR ((0x3<<29)|(0x1d<<24)|(0x1<<16)|0x0)
|
||||
#define GFX_OP_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16))
|
||||
#define GFX_OP_MAP_INFO ((0x3<<29)|(0x1d<<24)|0x2)
|
||||
#define GFX_OP_DESTBUFFER_VARS ((0x3<<29)|(0x1d<<24)|(0x85<<16)|0x0)
|
||||
#define GFX_OP_DRAWRECT_INFO ((0x3<<29)|(0x1d<<24)|(0x80<<16)|(0x3))
|
||||
#define GFX_OP_PRIMITIVE ((0x3<<29)|(0x1f<<24))
|
||||
|
||||
#define CMD_OP_Z_BUFFER_INFO ((0x0<<29)|(0x16<<23))
|
||||
#define CMD_OP_DESTBUFFER_INFO ((0x0<<29)|(0x15<<23))
|
||||
|
||||
#define BR00_BITBLT_CLIENT 0x40000000
|
||||
#define BR00_OP_COLOR_BLT 0x10000000
|
||||
#define BR00_OP_SRC_COPY_BLT 0x10C00000
|
||||
#define BR13_SOLID_PATTERN 0x80000000
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
116
bsd/i830.h
Normal file
116
bsd/i830.h
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
/* i830.h -- Intel I830 DRM template customization -*- linux-c -*-
|
||||
* Created: Thu Feb 15 00:01:12 2001 by gareth@valinux.com
|
||||
*
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS 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.
|
||||
*
|
||||
* Authors:
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#ifndef __I830_H__
|
||||
#define __I830_H__
|
||||
|
||||
/* This remains constant for all DRM template files.
|
||||
*/
|
||||
#define DRM(x) i830_##x
|
||||
|
||||
/* General customization:
|
||||
*/
|
||||
#define __HAVE_AGP 1
|
||||
#define __MUST_HAVE_AGP 1
|
||||
#define __HAVE_MTRR 1
|
||||
#define __HAVE_CTX_BITMAP 1
|
||||
|
||||
/* Driver customization:
|
||||
*/
|
||||
#define __HAVE_RELEASE 1
|
||||
#define DRIVER_RELEASE() do { \
|
||||
i830_reclaim_buffers( dev, priv->pid ); \
|
||||
} while (0)
|
||||
|
||||
/* DMA customization:
|
||||
*/
|
||||
#define __HAVE_DMA 1
|
||||
#define __HAVE_DMA_QUEUE 1
|
||||
#define __HAVE_DMA_WAITLIST 1
|
||||
#define __HAVE_DMA_RECLAIM 1
|
||||
|
||||
#define __HAVE_DMA_QUIESCENT 1
|
||||
#define DRIVER_DMA_QUIESCENT() do { \
|
||||
i830_dma_quiescent( dev ); \
|
||||
} while (0)
|
||||
|
||||
#define __HAVE_DMA_IRQ 1
|
||||
#define __HAVE_DMA_IRQ_BH 1
|
||||
#define __HAVE_SHARED_IRQ 1
|
||||
#define DRIVER_PREINSTALL() do { \
|
||||
drm_i830_private_t *dev_priv = \
|
||||
(drm_i830_private_t *)dev->dev_private; \
|
||||
u16 tmp; \
|
||||
tmp = I830_READ16( I830REG_HWSTAM ); \
|
||||
tmp = tmp & 0x6000; \
|
||||
I830_WRITE16( I830REG_HWSTAM, tmp ); \
|
||||
\
|
||||
tmp = I830_READ16( I830REG_INT_MASK_R ); \
|
||||
tmp = tmp & 0x6000; /* Unmask interrupts */ \
|
||||
I830_WRITE16( I830REG_INT_MASK_R, tmp ); \
|
||||
tmp = I830_READ16( I830REG_INT_ENABLE_R ); \
|
||||
tmp = tmp & 0x6000; /* Disable all interrupts */ \
|
||||
I830_WRITE16( I830REG_INT_ENABLE_R, tmp ); \
|
||||
} while (0)
|
||||
|
||||
#define DRIVER_POSTINSTALL() do { \
|
||||
drm_i830_private_t *dev_priv = \
|
||||
(drm_i830_private_t *)dev->dev_private; \
|
||||
u16 tmp; \
|
||||
tmp = I830_READ16( I830REG_INT_ENABLE_R ); \
|
||||
tmp = tmp & 0x6000; \
|
||||
tmp = tmp | 0x0003; /* Enable bp & user interrupts */ \
|
||||
I830_WRITE16( I830REG_INT_ENABLE_R, tmp ); \
|
||||
} while (0)
|
||||
|
||||
#define DRIVER_UNINSTALL() do { \
|
||||
drm_i830_private_t *dev_priv = \
|
||||
(drm_i830_private_t *)dev->dev_private; \
|
||||
u16 tmp; \
|
||||
if ( dev_priv ) { \
|
||||
tmp = I830_READ16( I830REG_INT_IDENTITY_R ); \
|
||||
tmp = tmp & ~(0x6000); /* Clear all interrupts */ \
|
||||
if ( tmp != 0 ) \
|
||||
I830_WRITE16( I830REG_INT_IDENTITY_R, tmp ); \
|
||||
\
|
||||
tmp = I830_READ16( I830REG_INT_ENABLE_R ); \
|
||||
tmp = tmp & 0x6000; /* Disable all interrupts */ \
|
||||
I830_WRITE16( I830REG_INT_ENABLE_R, tmp ); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Buffer customization:
|
||||
*/
|
||||
|
||||
#define DRIVER_BUF_PRIV_T drm_i830_buf_priv_t
|
||||
|
||||
#define DRIVER_AGP_BUFFERS_MAP( dev ) \
|
||||
((drm_i830_private_t *)((dev)->dev_private))->buffer_map
|
||||
|
||||
#endif
|
||||
1420
bsd/i830_dma.c
Normal file
1420
bsd/i830_dma.c
Normal file
File diff suppressed because it is too large
Load diff
104
bsd/i830_drv.c
Normal file
104
bsd/i830_drv.c
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
/* i830_drv.c -- I810 driver -*- linux-c -*-
|
||||
* Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS 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.
|
||||
*
|
||||
* Authors:
|
||||
* Rickard E. (Rik) Faith <faith@valinux.com>
|
||||
* Jeff Hartmann <jhartmann@valinux.com>
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
* Abraham vd Merwe <abraham@2d3d.co.za>
|
||||
*/
|
||||
|
||||
#include <linux/config.h>
|
||||
#include "i830.h"
|
||||
#include "drmP.h"
|
||||
#include "drm.h"
|
||||
#include "i830_drm.h"
|
||||
#include "i830_drv.h"
|
||||
|
||||
#define DRIVER_AUTHOR "VA Linux Systems Inc."
|
||||
|
||||
#define DRIVER_NAME "i830"
|
||||
#define DRIVER_DESC "Intel 830M"
|
||||
#define DRIVER_DATE "20011004"
|
||||
|
||||
#define DRIVER_MAJOR 1
|
||||
#define DRIVER_MINOR 2
|
||||
#define DRIVER_PATCHLEVEL 0
|
||||
|
||||
#define DRIVER_IOCTLS \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_I830_INIT)] = { i830_dma_init, 1, 1 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_I830_VERTEX)] = { i830_dma_vertex, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_I830_CLEAR)] = { i830_clear_bufs, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_I830_FLUSH)] = { i830_flush_ioctl, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_I830_GETAGE)] = { i830_getage, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_I830_GETBUF)] = { i830_getbuf, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_I830_SWAP)] = { i830_swap_bufs, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_I830_COPY)] = { i830_copybuf, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_I830_DOCOPY)] = { i830_docopy, 1, 0 },
|
||||
|
||||
#define __HAVE_COUNTERS 4
|
||||
#define __HAVE_COUNTER6 _DRM_STAT_IRQ
|
||||
#define __HAVE_COUNTER7 _DRM_STAT_PRIMARY
|
||||
#define __HAVE_COUNTER8 _DRM_STAT_SECONDARY
|
||||
#define __HAVE_COUNTER9 _DRM_STAT_DMA
|
||||
|
||||
|
||||
#include "drm_agpsupport.h"
|
||||
#include "drm_auth.h"
|
||||
#include "drm_bufs.h"
|
||||
#include "drm_context.h"
|
||||
#include "drm_dma.h"
|
||||
#include "drm_drawable.h"
|
||||
#include "drm_drv.h"
|
||||
|
||||
#ifndef MODULE
|
||||
/* DRM(options) is called by the kernel to parse command-line options
|
||||
* passed via the boot-loader (e.g., LILO). It calls the insmod option
|
||||
* routine, drm_parse_drm.
|
||||
*/
|
||||
|
||||
/* JH- We have to hand expand the string ourselves because of the cpp. If
|
||||
* anyone can think of a way that we can fit into the __setup macro without
|
||||
* changing it, then please send the solution my way.
|
||||
*/
|
||||
static int __init i830_options( char *str )
|
||||
{
|
||||
DRM(parse_options)( str );
|
||||
return 1;
|
||||
}
|
||||
|
||||
__setup( DRIVER_NAME "=", i830_options );
|
||||
#endif
|
||||
|
||||
#include "drm_fops.h"
|
||||
#include "drm_init.h"
|
||||
#include "drm_ioctl.h"
|
||||
#include "drm_lock.h"
|
||||
#include "drm_lists.h"
|
||||
#include "drm_memory.h"
|
||||
#include "drm_proc.h"
|
||||
#include "drm_vm.h"
|
||||
#include "drm_stub.h"
|
||||
213
bsd/i830_drv.h
Normal file
213
bsd/i830_drv.h
Normal file
|
|
@ -0,0 +1,213 @@
|
|||
/* i830_drv.h -- Private header for the I830 driver -*- linux-c -*-
|
||||
* Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PRECISION INSIGHT 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.
|
||||
*
|
||||
* Authors: Rickard E. (Rik) Faith <faith@valinux.com>
|
||||
* Jeff Hartmann <jhartmann@valinux.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _I830_DRV_H_
|
||||
#define _I830_DRV_H_
|
||||
|
||||
typedef struct drm_i830_buf_priv {
|
||||
u32 *in_use;
|
||||
int my_use_idx;
|
||||
int currently_mapped;
|
||||
void *virtual;
|
||||
void *kernel_virtual;
|
||||
int map_count;
|
||||
struct vm_area_struct *vma;
|
||||
} drm_i830_buf_priv_t;
|
||||
|
||||
typedef struct _drm_i830_ring_buffer{
|
||||
int tail_mask;
|
||||
unsigned long Start;
|
||||
unsigned long End;
|
||||
unsigned long Size;
|
||||
u8 *virtual_start;
|
||||
int head;
|
||||
int tail;
|
||||
int space;
|
||||
} drm_i830_ring_buffer_t;
|
||||
|
||||
typedef struct drm_i830_private {
|
||||
drm_map_t *sarea_map;
|
||||
drm_map_t *buffer_map;
|
||||
drm_map_t *mmio_map;
|
||||
|
||||
drm_i830_sarea_t *sarea_priv;
|
||||
drm_i830_ring_buffer_t ring;
|
||||
|
||||
unsigned long hw_status_page;
|
||||
unsigned long counter;
|
||||
|
||||
atomic_t flush_done;
|
||||
wait_queue_head_t flush_queue; /* Processes waiting until flush */
|
||||
drm_buf_t *mmap_buffer;
|
||||
|
||||
u32 front_di1, back_di1, zi1;
|
||||
|
||||
int back_offset;
|
||||
int depth_offset;
|
||||
int w, h;
|
||||
int pitch;
|
||||
int back_pitch;
|
||||
int depth_pitch;
|
||||
unsigned int cpp;
|
||||
} drm_i830_private_t;
|
||||
|
||||
/* i830_dma.c */
|
||||
extern int i830_dma_schedule(drm_device_t *dev, int locked);
|
||||
extern int i830_getbuf(struct inode *inode, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg);
|
||||
extern int i830_dma_init(struct inode *inode, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg);
|
||||
extern int i830_flush_ioctl(struct inode *inode, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg);
|
||||
extern void i830_reclaim_buffers(drm_device_t *dev, pid_t pid);
|
||||
extern int i830_getage(struct inode *inode, struct file *filp, unsigned int cmd,
|
||||
unsigned long arg);
|
||||
extern int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma);
|
||||
extern int i830_copybuf(struct inode *inode, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg);
|
||||
extern int i830_docopy(struct inode *inode, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg);
|
||||
|
||||
extern void i830_dma_quiescent(drm_device_t *dev);
|
||||
|
||||
extern int i830_dma_vertex(struct inode *inode, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg);
|
||||
|
||||
extern int i830_swap_bufs(struct inode *inode, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg);
|
||||
|
||||
extern int i830_clear_bufs(struct inode *inode, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg);
|
||||
|
||||
#define I830_VERBOSE 0
|
||||
|
||||
#define I830_BASE(reg) ((unsigned long) \
|
||||
dev_priv->mmio_map->handle)
|
||||
#define I830_ADDR(reg) (I830_BASE(reg) + reg)
|
||||
#define I830_DEREF(reg) *(__volatile__ int *)I830_ADDR(reg)
|
||||
#define I830_READ(reg) I830_DEREF(reg)
|
||||
#define I830_WRITE(reg,val) do { I830_DEREF(reg) = val; } while (0)
|
||||
#define I830_DEREF16(reg) *(__volatile__ u16 *)I830_ADDR(reg)
|
||||
#define I830_READ16(reg) I830_DEREF16(reg)
|
||||
#define I830_WRITE16(reg,val) do { I830_DEREF16(reg) = val; } while (0)
|
||||
|
||||
#define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23))
|
||||
#define GFX_OP_BREAKPOINT_INTERRUPT ((0<<29)|(1<<23))
|
||||
#define CMD_REPORT_HEAD (7<<23)
|
||||
#define CMD_STORE_DWORD_IDX ((0x21<<23) | 0x1)
|
||||
#define CMD_OP_BATCH_BUFFER ((0x0<<29)|(0x30<<23)|0x1)
|
||||
|
||||
#define INST_PARSER_CLIENT 0x00000000
|
||||
#define INST_OP_FLUSH 0x02000000
|
||||
#define INST_FLUSH_MAP_CACHE 0x00000001
|
||||
|
||||
|
||||
#define BB1_START_ADDR_MASK (~0x7)
|
||||
#define BB1_PROTECTED (1<<0)
|
||||
#define BB1_UNPROTECTED (0<<0)
|
||||
#define BB2_END_ADDR_MASK (~0x7)
|
||||
|
||||
#define I830REG_HWSTAM 0x02098
|
||||
#define I830REG_INT_IDENTITY_R 0x020a4
|
||||
#define I830REG_INT_MASK_R 0x020a8
|
||||
#define I830REG_INT_ENABLE_R 0x020a0
|
||||
|
||||
#define LP_RING 0x2030
|
||||
#define HP_RING 0x2040
|
||||
#define RING_TAIL 0x00
|
||||
#define TAIL_ADDR 0x000FFFF8
|
||||
#define RING_HEAD 0x04
|
||||
#define HEAD_WRAP_COUNT 0xFFE00000
|
||||
#define HEAD_WRAP_ONE 0x00200000
|
||||
#define HEAD_ADDR 0x001FFFFC
|
||||
#define RING_START 0x08
|
||||
#define START_ADDR 0x00FFFFF8
|
||||
#define RING_LEN 0x0C
|
||||
#define RING_NR_PAGES 0x000FF000
|
||||
#define RING_REPORT_MASK 0x00000006
|
||||
#define RING_REPORT_64K 0x00000002
|
||||
#define RING_REPORT_128K 0x00000004
|
||||
#define RING_NO_REPORT 0x00000000
|
||||
#define RING_VALID_MASK 0x00000001
|
||||
#define RING_VALID 0x00000001
|
||||
#define RING_INVALID 0x00000000
|
||||
|
||||
#define GFX_OP_SCISSOR ((0x3<<29)|(0x1c<<24)|(0x10<<19))
|
||||
#define SC_UPDATE_SCISSOR (0x1<<1)
|
||||
#define SC_ENABLE_MASK (0x1<<0)
|
||||
#define SC_ENABLE (0x1<<0)
|
||||
|
||||
#define GFX_OP_SCISSOR_INFO ((0x3<<29)|(0x1d<<24)|(0x81<<16)|(0x1))
|
||||
#define SCI_YMIN_MASK (0xffff<<16)
|
||||
#define SCI_XMIN_MASK (0xffff<<0)
|
||||
#define SCI_YMAX_MASK (0xffff<<16)
|
||||
#define SCI_XMAX_MASK (0xffff<<0)
|
||||
|
||||
#define GFX_OP_SCISSOR_ENABLE ((0x3<<29)|(0x1c<<24)|(0x10<<19))
|
||||
#define GFX_OP_SCISSOR_RECT ((0x3<<29)|(0x1d<<24)|(0x81<<16)|1)
|
||||
#define GFX_OP_COLOR_FACTOR ((0x3<<29)|(0x1d<<24)|(0x1<<16)|0x0)
|
||||
#define GFX_OP_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16))
|
||||
#define GFX_OP_MAP_INFO ((0x3<<29)|(0x1d<<24)|0x4)
|
||||
#define GFX_OP_DESTBUFFER_VARS ((0x3<<29)|(0x1d<<24)|(0x85<<16)|0x0)
|
||||
#define GFX_OP_DRAWRECT_INFO ((0x3<<29)|(0x1d<<24)|(0x80<<16)|(0x3))
|
||||
#define GFX_OP_PRIMITIVE ((0x3<<29)|(0x1f<<24))
|
||||
|
||||
#define CMD_OP_DESTBUFFER_INFO ((0x3<<29)|(0x1d<<24)|(0x8e<<16)|1)
|
||||
|
||||
|
||||
#define BR00_BITBLT_CLIENT 0x40000000
|
||||
#define BR00_OP_COLOR_BLT 0x10000000
|
||||
#define BR00_OP_SRC_COPY_BLT 0x10C00000
|
||||
#define BR13_SOLID_PATTERN 0x80000000
|
||||
|
||||
#define BUF_3D_ID_COLOR_BACK (0x3<<24)
|
||||
#define BUF_3D_ID_DEPTH (0x7<<24)
|
||||
#define BUF_3D_USE_FENCE (1<<23)
|
||||
#define BUF_3D_PITCH(x) (((x)/4)<<2)
|
||||
|
||||
#define CMD_OP_MAP_PALETTE_LOAD ((3<<29)|(0x1d<<24)|(0x82<<16)|255)
|
||||
#define MAP_PALETTE_NUM(x) ((x<<8) & (1<<8))
|
||||
#define MAP_PALETTE_BOTH (1<<11)
|
||||
|
||||
#define XY_COLOR_BLT_CMD ((2<<29)|(0x50<<22)|0x4)
|
||||
#define XY_COLOR_BLT_WRITE_ALPHA (1<<21)
|
||||
#define XY_COLOR_BLT_WRITE_RGB (1<<20)
|
||||
|
||||
#define XY_SRC_COPY_BLT_CMD ((2<<29)|(0x53<<22)|6)
|
||||
#define XY_SRC_COPY_BLT_WRITE_ALPHA (1<<21)
|
||||
#define XY_SRC_COPY_BLT_WRITE_RGB (1<<20)
|
||||
|
||||
#define MI_BATCH_BUFFER ((0x30<<23)|1)
|
||||
#define MI_BATCH_NON_SECURE (1)
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
66
bsd/mga_drv.c
Normal file
66
bsd/mga_drv.c
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/* mga_drv.c -- Matrox G200/G400 driver -*- linux-c -*-
|
||||
* Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS 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.
|
||||
*
|
||||
* Authors:
|
||||
* Rickard E. (Rik) Faith <faith@valinux.com>
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "mga.h"
|
||||
#include "drmP.h"
|
||||
#include "drm.h"
|
||||
#include "mga_drm.h"
|
||||
#include "mga_drv.h"
|
||||
|
||||
/* List acquired from http://www.yourvote.com/pci/pcihdr.h and xc/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
|
||||
* Please report to anholt@teleport.com inaccuracies or if a chip you have works that is marked unsupported here.
|
||||
*/
|
||||
drm_chipinfo_t DRM(devicelist)[] = {
|
||||
{0x102b, 0x0520, 0, "Matrox G200 (PCI)"},
|
||||
{0x102b, 0x0521, 1, "Matrox G200 (AGP)"},
|
||||
{0x102b, 0x0525, 1, "Matrox G400/G450 (AGP)"},
|
||||
{0x102b, 0x2527, 1, "Matrox G550 (AGP)"},
|
||||
{0, 0, 0, NULL}
|
||||
};
|
||||
|
||||
#include "drm_agpsupport.h"
|
||||
#include "drm_auth.h"
|
||||
#include "drm_bufs.h"
|
||||
#include "drm_context.h"
|
||||
#include "drm_dma.h"
|
||||
#include "drm_drawable.h"
|
||||
#include "drm_drv.h"
|
||||
#include "drm_fops.h"
|
||||
#include "drm_init.h"
|
||||
#include "drm_ioctl.h"
|
||||
#include "drm_lock.h"
|
||||
#include "drm_memory.h"
|
||||
#include "drm_vm.h"
|
||||
#include "drm_sysctl.h"
|
||||
|
||||
DRIVER_MODULE(mga, pci, mga_driver, mga_devclass, 0, 0);
|
||||
86
bsd/r128_drv.c
Normal file
86
bsd/r128_drv.c
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
/* r128_drv.c -- ATI Rage 128 driver -*- linux-c -*-
|
||||
* Created: Mon Dec 13 09:47:27 1999 by faith@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS 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.
|
||||
*
|
||||
* Authors:
|
||||
* Rickard E. (Rik) Faith <faith@valinux.com>
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "r128.h"
|
||||
#include "drmP.h"
|
||||
#include "drm.h"
|
||||
#include "r128_drm.h"
|
||||
#include "r128_drv.h"
|
||||
#if __REALLY_HAVE_SG
|
||||
#include "ati_pcigart.h"
|
||||
#endif
|
||||
|
||||
/* List acquired from http://www.yourvote.com/pci/pcihdr.h and xc/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
|
||||
* Please report to eta@lclark.edu inaccuracies or if a chip you have works that is marked unsupported here.
|
||||
*/
|
||||
drm_chipinfo_t DRM(devicelist)[] = {
|
||||
{0x1002, 0x4c45, __REALLY_HAVE_SG, "ATI Rage 128 Mobility LE (PCI)"},
|
||||
{0x1002, 0x4c46, 1, "ATI Rage 128 Mobility LF (AGP)"},
|
||||
{0x1002, 0x4d46, 1, "ATI Rage 128 Mobility MF (AGP)"},
|
||||
{0x1002, 0x4d4c, 1, "ATI Rage 128 Mobility ML (AGP)"},
|
||||
{0x1002, 0x5044, __REALLY_HAVE_SG, "ATI Rage 128 Pro PD (PCI)"},
|
||||
{0x1002, 0x5046, 1, "ATI Rage 128 Pro PF (AGP)"},
|
||||
{0x1002, 0x5050, __REALLY_HAVE_SG, "ATI Rage 128 Pro PP (PCI)"},
|
||||
{0x1002, 0x5052, __REALLY_HAVE_SG, "ATI Rage 128 Pro PR (PCI)"},
|
||||
{0x1002, 0x5245, __REALLY_HAVE_SG, "ATI Rage 128 RE (PCI)"},
|
||||
{0x1002, 0x5246, 1, "ATI Rage 128 RF (AGP)"},
|
||||
{0x1002, 0x5247, 1, "ATI Rage 128 RG (AGP)"},
|
||||
{0x1002, 0x524b, __REALLY_HAVE_SG, "ATI Rage 128 RK (PCI)"},
|
||||
{0x1002, 0x524c, 1, "ATI Rage 128 RL (AGP)"},
|
||||
{0x1002, 0x534d, 1, "ATI Rage 128 SM (AGP)"},
|
||||
{0x1002, 0x5446, 1, "ATI Rage 128 Pro Ultra TF (AGP)"},
|
||||
{0x1002, 0x544C, 1, "ATI Rage 128 Pro Ultra TL (AGP)"},
|
||||
{0x1002, 0x5452, 1, "ATI Rage 128 Pro Ultra TR (AGP)"},
|
||||
{0, 0, 0, NULL}
|
||||
};
|
||||
|
||||
#include "drm_agpsupport.h"
|
||||
#include "drm_auth.h"
|
||||
#include "drm_bufs.h"
|
||||
#include "drm_context.h"
|
||||
#include "drm_dma.h"
|
||||
#include "drm_drawable.h"
|
||||
#include "drm_drv.h"
|
||||
#include "drm_fops.h"
|
||||
#include "drm_init.h"
|
||||
#include "drm_ioctl.h"
|
||||
#include "drm_lock.h"
|
||||
#include "drm_memory.h"
|
||||
#include "drm_sysctl.h"
|
||||
#include "drm_vm.h"
|
||||
#if __HAVE_SG
|
||||
#include "drm_scatter.h"
|
||||
#endif
|
||||
|
||||
DRIVER_MODULE(r128, pci, r128_driver, r128_devclass, 0, 0);
|
||||
76
bsd/radeon_drv.c
Normal file
76
bsd/radeon_drv.c
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/* radeon_drv.c -- ATI Radeon driver -*- linux-c -*-
|
||||
* Created: Wed Feb 14 17:10:04 2001 by gareth@valinux.com
|
||||
*
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS 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.
|
||||
*
|
||||
* Authors:
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "radeon.h"
|
||||
#include "drmP.h"
|
||||
#include "drm.h"
|
||||
#include "radeon_drm.h"
|
||||
#include "radeon_drv.h"
|
||||
#if __REALLY_HAVE_SG
|
||||
#include "ati_pcigart.h"
|
||||
#endif
|
||||
|
||||
/* List acquired from http://www.yourvote.com/pci/pcihdr.h and xc/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
|
||||
* Please report to eta@lclark.edu inaccuracies or if a chip you have works that is marked unsupported here.
|
||||
*/
|
||||
drm_chipinfo_t DRM(devicelist)[] = {
|
||||
{0x1002, 0x4C57, 1, "ATI Radeon LW Mobility 7 (AGP)"},
|
||||
{0x1002, 0x4C59, 1, "ATI Radeon LY Mobility 6 (AGP)"},
|
||||
{0x1002, 0x4C5A, 1, "ATI Radeon LZ Mobility 6 (AGP)"},
|
||||
{0x1002, 0x5144, 1, "ATI Radeon QD (AGP)"},
|
||||
{0x1002, 0x5145, 1, "ATI Radeon QE (AGP)"},
|
||||
{0x1002, 0x5146, 1, "ATI Radeon QF (AGP)"},
|
||||
{0x1002, 0x5147, 1, "ATI Radeon QG (AGP)"},
|
||||
{0x1002, 0x5157, 1, "ATI Radeon QW 7500 (AGP)"},
|
||||
{0x1002, 0x5159, 1, "ATI Radeon QY VE (AGP)"},
|
||||
{0x1002, 0x515A, 1, "ATI Radeon QZ VE (AGP)"},
|
||||
{0, 0, 0, NULL}
|
||||
};
|
||||
|
||||
#include "drm_agpsupport.h"
|
||||
#include "drm_auth.h"
|
||||
#include "drm_bufs.h"
|
||||
#include "drm_context.h"
|
||||
#include "drm_dma.h"
|
||||
#include "drm_drawable.h"
|
||||
#include "drm_drv.h"
|
||||
#include "drm_fops.h"
|
||||
#include "drm_init.h"
|
||||
#include "drm_ioctl.h"
|
||||
#include "drm_lock.h"
|
||||
#include "drm_memory.h"
|
||||
#include "drm_vm.h"
|
||||
#include "drm_sysctl.h"
|
||||
#if __HAVE_SG
|
||||
#include "drm_scatter.h"
|
||||
#endif
|
||||
|
||||
DRIVER_MODULE(DRIVER_NAME, pci, DRM(driver), DRM(devclass), 0, 0);
|
||||
42
bsd/tdfx.h
Normal file
42
bsd/tdfx.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* tdfx.h -- 3dfx DRM template customization -*- linux-c -*-
|
||||
* Created: Wed Feb 14 12:32:32 2001 by gareth@valinux.com
|
||||
*
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS 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.
|
||||
*
|
||||
* Authors:
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#ifndef __TDFX_H__
|
||||
#define __TDFX_H__
|
||||
|
||||
/* This remains constant for all DRM template files.
|
||||
*/
|
||||
#define DRM(x) tdfx_##x
|
||||
|
||||
/* General customization:
|
||||
*/
|
||||
#define __HAVE_MTRR 1
|
||||
#define __HAVE_CTX_BITMAP 1
|
||||
|
||||
#endif
|
||||
99
bsd/tdfx_drv.c
Normal file
99
bsd/tdfx_drv.c
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
/* tdfx_drv.c -- tdfx driver -*- linux-c -*-
|
||||
* Created: Thu Oct 7 10:38:32 1999 by faith@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PRECISION INSIGHT 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.
|
||||
*
|
||||
* Authors:
|
||||
* Rickard E. (Rik) Faith <faith@valinux.com>
|
||||
* Daryll Strauss <daryll@valinux.com>
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "tdfx.h"
|
||||
#include "drmP.h"
|
||||
|
||||
#define DRIVER_AUTHOR "VA Linux Systems Inc."
|
||||
|
||||
#define DRIVER_NAME "tdfx"
|
||||
#define DRIVER_DESC "3dfx Banshee/Voodoo3+"
|
||||
#define DRIVER_DATE "20010216"
|
||||
|
||||
#define DRIVER_MAJOR 1
|
||||
#define DRIVER_MINOR 0
|
||||
#define DRIVER_PATCHLEVEL 0
|
||||
|
||||
#ifndef PCI_VENDOR_ID_3DFX
|
||||
#define PCI_VENDOR_ID_3DFX 0x121A
|
||||
#endif
|
||||
#ifndef PCI_DEVICE_ID_3DFX_VOODOO5
|
||||
#define PCI_DEVICE_ID_3DFX_VOODOO5 0x0009
|
||||
#endif
|
||||
#ifndef PCI_DEVICE_ID_3DFX_VOODOO4
|
||||
#define PCI_DEVICE_ID_3DFX_VOODOO4 0x0007
|
||||
#endif
|
||||
#ifndef PCI_DEVICE_ID_3DFX_VOODOO3_3000 /* Voodoo3 3000 */
|
||||
#define PCI_DEVICE_ID_3DFX_VOODOO3_3000 0x0005
|
||||
#endif
|
||||
#ifndef PCI_DEVICE_ID_3DFX_VOODOO3_2000 /* Voodoo3 3000 */
|
||||
#define PCI_DEVICE_ID_3DFX_VOODOO3_2000 0x0004
|
||||
#endif
|
||||
#ifndef PCI_DEVICE_ID_3DFX_BANSHEE
|
||||
#define PCI_DEVICE_ID_3DFX_BANSHEE 0x0003
|
||||
#endif
|
||||
|
||||
/* List acquired from http://www.yourvote.com/pci/pcihdr.h and xc/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
|
||||
* Please report to anholt@teleport.com inaccuracies or if a chip you have works that is marked unsupported here.
|
||||
*/
|
||||
drm_chipinfo_t DRM(devicelist)[] = {
|
||||
{0x121a, 0x0003, 1, "3dfx Voodoo Banshee"},
|
||||
{0x121a, 0x0004, 1, "3dfx Voodoo3 2000"},
|
||||
{0x121a, 0x0005, 1, "3dfx Voodoo3 3000"},
|
||||
{0x121a, 0x0007, 1, "3dfx Voodoo4"},
|
||||
{0x121a, 0x0009, 1, "3dfx Voodoo5"},
|
||||
{0, 0, 0, NULL}
|
||||
};
|
||||
|
||||
|
||||
#include "drm_auth.h"
|
||||
#include "drm_bufs.h"
|
||||
#include "drm_context.h"
|
||||
#include "drm_dma.h"
|
||||
#include "drm_drawable.h"
|
||||
#include "drm_drv.h"
|
||||
|
||||
|
||||
#include "drm_fops.h"
|
||||
#include "drm_init.h"
|
||||
#include "drm_ioctl.h"
|
||||
#include "drm_lock.h"
|
||||
#include "drm_memory.h"
|
||||
#include "drm_vm.h"
|
||||
#include "drm_sysctl.h"
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
DRIVER_MODULE(tdfx, pci, tdfx_driver, tdfx_devclass, 0, 0);
|
||||
#endif /* __FreeBSD__ */
|
||||
56
linux-core/drm_os_linux.h
Normal file
56
linux-core/drm_os_linux.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#define __NO_VERSION__
|
||||
|
||||
#include <linux/interrupt.h> /* For task queue support */
|
||||
#include <linux/delay.h>
|
||||
|
||||
#define DRM_IOCTL_ARGS struct inode *inode, struct file *filp, unsigned int cmd, unsigned long data
|
||||
#define DRM_ERR(d) -(d)
|
||||
#define DRM_CURRENTPID current->pid
|
||||
#define DRM_UDELAY(d) udelay(d)
|
||||
#define DRM_READ8(addr) readb(addr)
|
||||
#define DRM_READ32(addr) readl(addr)
|
||||
#define DRM_WRITE8(addr, val) writeb(val, addr)
|
||||
#define DRM_WRITE32(addr, val) writel(val, addr)
|
||||
#define DRM_READMEMORYBARRIER() mb()
|
||||
#define DRM_WRITEMEMORYBARRIER() wmb()
|
||||
#define DRM_DEVICE drm_file_t *priv = filp->private_data; \
|
||||
drm_device_t *dev = priv->dev
|
||||
|
||||
/* For data going from/to the kernel through the ioctl argument */
|
||||
#define DRM_COPY_FROM_USER_IOCTL(arg1, arg2, arg3) \
|
||||
if ( copy_from_user(&arg1, arg2, arg3) ) \
|
||||
return -EFAULT
|
||||
#define DRM_COPY_TO_USER_IOCTL(arg1, arg2, arg3) \
|
||||
if ( copy_to_user(arg1, &arg2, arg3) ) \
|
||||
return -EFAULT
|
||||
/* Other copying of data from/to kernel space */
|
||||
#define DRM_COPY_FROM_USER(arg1, arg2, arg3) \
|
||||
copy_from_user(arg1, arg2, arg3)
|
||||
#define DRM_COPY_TO_USER(arg1, arg2, arg3) \
|
||||
copy_to_user(arg1, arg2, arg3)
|
||||
/* Macros for copyfrom user, but checking readability only once */
|
||||
#define DRM_VERIFYAREA_READ( uaddr, size ) \
|
||||
verify_area( VERIFY_READ, uaddr, size )
|
||||
#define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) \
|
||||
__copy_from_user(arg1, arg2, arg3)
|
||||
#define DRM_GET_USER_UNCHECKED(val, uaddr) \
|
||||
__get_user(val, uaddr)
|
||||
|
||||
|
||||
/* malloc/free without the overhead of DRM(alloc) */
|
||||
#define DRM_MALLOC(x) kmalloc(x, GFP_KERNEL)
|
||||
#define DRM_FREE(x) kfree(x)
|
||||
|
||||
#define DRM_GETSAREA() \
|
||||
do { \
|
||||
struct list_head *list; \
|
||||
list_for_each( list, &dev->maplist->head ) { \
|
||||
drm_map_list_t *entry = (drm_map_list_t *)list; \
|
||||
if ( entry->map && \
|
||||
entry->map->type == _DRM_SHM && \
|
||||
(entry->map->flags & _DRM_CONTAINS_LOCK) ) { \
|
||||
dev_priv->sarea = entry->map; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
56
linux/drm_os_linux.h
Normal file
56
linux/drm_os_linux.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#define __NO_VERSION__
|
||||
|
||||
#include <linux/interrupt.h> /* For task queue support */
|
||||
#include <linux/delay.h>
|
||||
|
||||
#define DRM_IOCTL_ARGS struct inode *inode, struct file *filp, unsigned int cmd, unsigned long data
|
||||
#define DRM_ERR(d) -(d)
|
||||
#define DRM_CURRENTPID current->pid
|
||||
#define DRM_UDELAY(d) udelay(d)
|
||||
#define DRM_READ8(addr) readb(addr)
|
||||
#define DRM_READ32(addr) readl(addr)
|
||||
#define DRM_WRITE8(addr, val) writeb(val, addr)
|
||||
#define DRM_WRITE32(addr, val) writel(val, addr)
|
||||
#define DRM_READMEMORYBARRIER() mb()
|
||||
#define DRM_WRITEMEMORYBARRIER() wmb()
|
||||
#define DRM_DEVICE drm_file_t *priv = filp->private_data; \
|
||||
drm_device_t *dev = priv->dev
|
||||
|
||||
/* For data going from/to the kernel through the ioctl argument */
|
||||
#define DRM_COPY_FROM_USER_IOCTL(arg1, arg2, arg3) \
|
||||
if ( copy_from_user(&arg1, arg2, arg3) ) \
|
||||
return -EFAULT
|
||||
#define DRM_COPY_TO_USER_IOCTL(arg1, arg2, arg3) \
|
||||
if ( copy_to_user(arg1, &arg2, arg3) ) \
|
||||
return -EFAULT
|
||||
/* Other copying of data from/to kernel space */
|
||||
#define DRM_COPY_FROM_USER(arg1, arg2, arg3) \
|
||||
copy_from_user(arg1, arg2, arg3)
|
||||
#define DRM_COPY_TO_USER(arg1, arg2, arg3) \
|
||||
copy_to_user(arg1, arg2, arg3)
|
||||
/* Macros for copyfrom user, but checking readability only once */
|
||||
#define DRM_VERIFYAREA_READ( uaddr, size ) \
|
||||
verify_area( VERIFY_READ, uaddr, size )
|
||||
#define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) \
|
||||
__copy_from_user(arg1, arg2, arg3)
|
||||
#define DRM_GET_USER_UNCHECKED(val, uaddr) \
|
||||
__get_user(val, uaddr)
|
||||
|
||||
|
||||
/* malloc/free without the overhead of DRM(alloc) */
|
||||
#define DRM_MALLOC(x) kmalloc(x, GFP_KERNEL)
|
||||
#define DRM_FREE(x) kfree(x)
|
||||
|
||||
#define DRM_GETSAREA() \
|
||||
do { \
|
||||
struct list_head *list; \
|
||||
list_for_each( list, &dev->maplist->head ) { \
|
||||
drm_map_list_t *entry = (drm_map_list_t *)list; \
|
||||
if ( entry->map && \
|
||||
entry->map->type == _DRM_SHM && \
|
||||
(entry->map->flags & _DRM_CONTAINS_LOCK) ) { \
|
||||
dev_priv->sarea = entry->map; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
|
@ -128,7 +128,8 @@
|
|||
#define R200_EMIT_SE_VAP_CNTL_STATUS 57 /* cst/1 */
|
||||
#define R200_EMIT_SE_VTX_STATE_CNTL 58 /* cst/1 */
|
||||
#define R200_EMIT_RE_POINTSIZE 59 /* cst/1 */
|
||||
#define RADEON_MAX_STATE_PACKETS 60
|
||||
#define R200_EMIT_TCL_INPUT_VTX_VECTOR_ADDR_0 60 /* cst/4 */
|
||||
#define RADEON_MAX_STATE_PACKETS 61
|
||||
|
||||
|
||||
/* Commands understood by cmd_buffer ioctl. More can be added but
|
||||
|
|
|
|||
|
|
@ -568,9 +568,10 @@ extern int radeon_cp_flip( struct inode *inode, struct file *filp,
|
|||
#define R200_RE_SCISSOR_TL_1 0x1ce0
|
||||
#define R200_RE_SCISSOR_TL_2 0x1ce8
|
||||
#define R200_RB3D_DEPTHXY_OFFSET 0x1d60
|
||||
#define R200_RE_AUX_SCISSOR_CNTL 0x26f0
|
||||
#define R200_SE_VTX_STATE_CNTL 0x2180
|
||||
#define R200_RE_POINTSIZE 0x2648
|
||||
#define R200_RE_AUX_SCISSOR_CNTL 0x26f0
|
||||
#define R200_SE_VTX_STATE_CNTL 0x2180
|
||||
#define R200_RE_POINTSIZE 0x2648
|
||||
#define R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0 0x2554
|
||||
|
||||
|
||||
#define SE_VAP_CNTL__TCL_ENA_MASK 0x00000001
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ static inline void radeon_emit_clip_rect( drm_radeon_private_t *dev_priv,
|
|||
DRM_DEBUG( " box: x1=%d y1=%d x2=%d y2=%d\n",
|
||||
box->x1, box->y1, box->x2, box->y2 );
|
||||
|
||||
#if 1
|
||||
BEGIN_RING( 4 );
|
||||
OUT_RING( CP_PACKET0( RADEON_RE_TOP_LEFT, 0 ) );
|
||||
OUT_RING( (box->y1 << 16) | box->x1 );
|
||||
|
|
@ -56,13 +55,6 @@ static inline void radeon_emit_clip_rect( drm_radeon_private_t *dev_priv,
|
|||
/* OUT_RING( ((box->y2 - 1) << 16) | (box->x2 - 1) );*/
|
||||
OUT_RING( (box->y2 << 16) | box->x2 );
|
||||
ADVANCE_RING();
|
||||
#else
|
||||
BEGIN_RING( 3 );
|
||||
OUT_RING( CP_PACKET3( RADEON_CCE_SET_SCISSORS, 1 ));
|
||||
OUT_RING( (box->y1 << 16) | box->x1 );
|
||||
OUT_RING( (box->y2 << 16) | box->x2 );
|
||||
ADVANCE_RING();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Emit 1.1 state
|
||||
|
|
@ -289,6 +281,7 @@ static struct {
|
|||
{ R200_SE_VAP_CNTL_STATUS, 1, "R200_SE_VAP_CNTL_STATUS" },
|
||||
{ R200_SE_VTX_STATE_CNTL, 1, "R200_SE_VTX_STATE_CNTL" },
|
||||
{ R200_RE_POINTSIZE, 1, "R200_RE_POINTSIZE" },
|
||||
{ R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0, 4, "R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0" },
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -385,7 +378,6 @@ static void radeon_cp_dispatch_clear( drm_device_t *dev,
|
|||
if ( tmp & RADEON_BACK ) flags |= RADEON_FRONT;
|
||||
}
|
||||
|
||||
|
||||
if ( flags & (RADEON_FRONT | RADEON_BACK) ) {
|
||||
|
||||
BEGIN_RING( 4 );
|
||||
|
|
|
|||
786
shared-core/mga_dma.c
Normal file
786
shared-core/mga_dma.c
Normal file
|
|
@ -0,0 +1,786 @@
|
|||
/* mga_dma.c -- DMA support for mga g200/g400 -*- linux-c -*-
|
||||
* Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PRECISION INSIGHT 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.
|
||||
*
|
||||
* Authors:
|
||||
* Rickard E. (Rik) Faith <faith@valinux.com>
|
||||
* Jeff Hartmann <jhartmann@valinux.com>
|
||||
* Keith Whitwell <keithw@valinux.com>
|
||||
*
|
||||
* Rewritten by:
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#include "mga.h"
|
||||
#include "drmP.h"
|
||||
#include "drm.h"
|
||||
#include "mga_drm.h"
|
||||
#include "mga_drv.h"
|
||||
|
||||
#define MGA_DEFAULT_USEC_TIMEOUT 10000
|
||||
#define MGA_FREELIST_DEBUG 0
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Engine control
|
||||
*/
|
||||
|
||||
int mga_do_wait_for_idle( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
u32 status = 0;
|
||||
int i;
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) {
|
||||
status = MGA_READ( MGA_STATUS ) & MGA_ENGINE_IDLE_MASK;
|
||||
if ( status == MGA_ENDPRDMASTS ) {
|
||||
MGA_WRITE8( MGA_CRTC_INDEX, 0 );
|
||||
return 0;
|
||||
}
|
||||
DRM_UDELAY( 1 );
|
||||
}
|
||||
|
||||
#if MGA_DMA_DEBUG
|
||||
DRM_ERROR( "failed!\n" );
|
||||
DRM_INFO( " status=0x%08x\n", status );
|
||||
#endif
|
||||
return DRM_ERR(EBUSY);
|
||||
}
|
||||
|
||||
int mga_do_dma_idle( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
u32 status = 0;
|
||||
int i;
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) {
|
||||
status = MGA_READ( MGA_STATUS ) & MGA_DMA_IDLE_MASK;
|
||||
if ( status == MGA_ENDPRDMASTS ) return 0;
|
||||
DRM_UDELAY( 1 );
|
||||
}
|
||||
|
||||
#if MGA_DMA_DEBUG
|
||||
DRM_ERROR( "failed! status=0x%08x\n", status );
|
||||
#endif
|
||||
return DRM_ERR(EBUSY);
|
||||
}
|
||||
|
||||
int mga_do_dma_reset( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
||||
drm_mga_primary_buffer_t *primary = &dev_priv->prim;
|
||||
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
/* The primary DMA stream should look like new right about now.
|
||||
*/
|
||||
primary->tail = 0;
|
||||
primary->space = primary->size;
|
||||
primary->last_flush = 0;
|
||||
|
||||
sarea_priv->last_wrap = 0;
|
||||
|
||||
/* FIXME: Reset counters, buffer ages etc...
|
||||
*/
|
||||
|
||||
/* FIXME: What else do we need to reinitialize? WARP stuff?
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mga_do_engine_reset( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
/* Okay, so we've completely screwed up and locked the engine.
|
||||
* How about we clean up after ourselves?
|
||||
*/
|
||||
MGA_WRITE( MGA_RST, MGA_SOFTRESET );
|
||||
DRM_UDELAY( 15 ); /* Wait at least 10 usecs */
|
||||
MGA_WRITE( MGA_RST, 0 );
|
||||
|
||||
/* Initialize the registers that get clobbered by the soft
|
||||
* reset. Many of the core register values survive a reset,
|
||||
* but the drawing registers are basically all gone.
|
||||
*
|
||||
* 3D clients should probably die after calling this. The X
|
||||
* server should reset the engine state to known values.
|
||||
*/
|
||||
#if 0
|
||||
MGA_WRITE( MGA_PRIMPTR,
|
||||
virt_to_bus((void *)dev_priv->prim.status_page) |
|
||||
MGA_PRIMPTREN0 |
|
||||
MGA_PRIMPTREN1 );
|
||||
#endif
|
||||
|
||||
MGA_WRITE( MGA_ICLEAR, MGA_SOFTRAPICLR );
|
||||
MGA_WRITE( MGA_IEN, MGA_SOFTRAPIEN );
|
||||
|
||||
/* The primary DMA stream should look like new right about now.
|
||||
*/
|
||||
mga_do_dma_reset( dev_priv );
|
||||
|
||||
/* This bad boy will never fail.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Primary DMA stream
|
||||
*/
|
||||
|
||||
void mga_do_dma_flush( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
drm_mga_primary_buffer_t *primary = &dev_priv->prim;
|
||||
u32 head, tail;
|
||||
DMA_LOCALS;
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
if ( primary->tail == primary->last_flush ) {
|
||||
DRM_DEBUG( " bailing out...\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
tail = primary->tail + dev_priv->primary->offset;
|
||||
|
||||
/* We need to pad the stream between flushes, as the card
|
||||
* actually (partially?) reads the first of these commands.
|
||||
* See page 4-16 in the G400 manual, middle of the page or so.
|
||||
*/
|
||||
BEGIN_DMA( 1 );
|
||||
|
||||
DMA_BLOCK( MGA_DMAPAD, 0x00000000,
|
||||
MGA_DMAPAD, 0x00000000,
|
||||
MGA_DMAPAD, 0x00000000,
|
||||
MGA_DMAPAD, 0x00000000 );
|
||||
|
||||
ADVANCE_DMA();
|
||||
|
||||
primary->last_flush = primary->tail;
|
||||
|
||||
head = MGA_READ( MGA_PRIMADDRESS );
|
||||
|
||||
if ( head <= tail ) {
|
||||
primary->space = primary->size - primary->tail;
|
||||
} else {
|
||||
primary->space = head - tail;
|
||||
}
|
||||
|
||||
DRM_DEBUG( " head = 0x%06lx\n", head - dev_priv->primary->offset );
|
||||
DRM_DEBUG( " tail = 0x%06lx\n", tail - dev_priv->primary->offset );
|
||||
DRM_DEBUG( " space = 0x%06x\n", primary->space );
|
||||
|
||||
mga_flush_write_combine();
|
||||
MGA_WRITE( MGA_PRIMEND, tail | MGA_PAGPXFER );
|
||||
|
||||
DRM_DEBUG( "done.\n" );
|
||||
}
|
||||
|
||||
void mga_do_dma_wrap_start( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
drm_mga_primary_buffer_t *primary = &dev_priv->prim;
|
||||
u32 head, tail;
|
||||
DMA_LOCALS;
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
BEGIN_DMA_WRAP();
|
||||
|
||||
DMA_BLOCK( MGA_DMAPAD, 0x00000000,
|
||||
MGA_DMAPAD, 0x00000000,
|
||||
MGA_DMAPAD, 0x00000000,
|
||||
MGA_DMAPAD, 0x00000000 );
|
||||
|
||||
ADVANCE_DMA();
|
||||
|
||||
tail = primary->tail + dev_priv->primary->offset;
|
||||
|
||||
primary->tail = 0;
|
||||
primary->last_flush = 0;
|
||||
primary->last_wrap++;
|
||||
|
||||
head = MGA_READ( MGA_PRIMADDRESS );
|
||||
|
||||
if ( head == dev_priv->primary->offset ) {
|
||||
primary->space = primary->size;
|
||||
} else {
|
||||
primary->space = head - dev_priv->primary->offset;
|
||||
}
|
||||
|
||||
DRM_DEBUG( " head = 0x%06lx\n",
|
||||
head - dev_priv->primary->offset );
|
||||
DRM_DEBUG( " tail = 0x%06x\n", primary->tail );
|
||||
DRM_DEBUG( " wrap = %d\n", primary->last_wrap );
|
||||
DRM_DEBUG( " space = 0x%06x\n", primary->space );
|
||||
|
||||
mga_flush_write_combine();
|
||||
MGA_WRITE( MGA_PRIMEND, tail | MGA_PAGPXFER );
|
||||
|
||||
set_bit( 0, &primary->wrapped );
|
||||
DRM_DEBUG( "done.\n" );
|
||||
}
|
||||
|
||||
void mga_do_dma_wrap_end( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
drm_mga_primary_buffer_t *primary = &dev_priv->prim;
|
||||
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
||||
u32 head = dev_priv->primary->offset;
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
sarea_priv->last_wrap++;
|
||||
DRM_DEBUG( " wrap = %d\n", sarea_priv->last_wrap );
|
||||
|
||||
mga_flush_write_combine();
|
||||
MGA_WRITE( MGA_PRIMADDRESS, head | MGA_DMA_GENERAL );
|
||||
|
||||
clear_bit( 0, &primary->wrapped );
|
||||
DRM_DEBUG( "done.\n" );
|
||||
}
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Freelist management
|
||||
*/
|
||||
|
||||
#define MGA_BUFFER_USED ~0
|
||||
#define MGA_BUFFER_FREE 0
|
||||
|
||||
#if MGA_FREELIST_DEBUG
|
||||
static void mga_freelist_print( drm_device_t *dev )
|
||||
{
|
||||
drm_mga_private_t *dev_priv = dev->dev_private;
|
||||
drm_mga_freelist_t *entry;
|
||||
|
||||
DRM_INFO( "\n" );
|
||||
DRM_INFO( "current dispatch: last=0x%x done=0x%x\n",
|
||||
dev_priv->sarea_priv->last_dispatch,
|
||||
(unsigned int)(MGA_READ( MGA_PRIMADDRESS ) -
|
||||
dev_priv->primary->offset) );
|
||||
DRM_INFO( "current freelist:\n" );
|
||||
|
||||
for ( entry = dev_priv->head->next ; entry ; entry = entry->next ) {
|
||||
DRM_INFO( " %p idx=%2d age=0x%x 0x%06lx\n",
|
||||
entry, entry->buf->idx, entry->age.head,
|
||||
entry->age.head - dev_priv->primary->offset );
|
||||
}
|
||||
DRM_INFO( "\n" );
|
||||
}
|
||||
#endif
|
||||
|
||||
static int mga_freelist_init( drm_device_t *dev, drm_mga_private_t *dev_priv )
|
||||
{
|
||||
drm_device_dma_t *dma = dev->dma;
|
||||
drm_buf_t *buf;
|
||||
drm_mga_buf_priv_t *buf_priv;
|
||||
drm_mga_freelist_t *entry;
|
||||
int i;
|
||||
DRM_DEBUG( "count=%d\n", dma->buf_count );
|
||||
|
||||
dev_priv->head = DRM(alloc)( sizeof(drm_mga_freelist_t),
|
||||
DRM_MEM_DRIVER );
|
||||
if ( dev_priv->head == NULL )
|
||||
return DRM_ERR(ENOMEM);
|
||||
|
||||
memset( dev_priv->head, 0, sizeof(drm_mga_freelist_t) );
|
||||
SET_AGE( &dev_priv->head->age, MGA_BUFFER_USED, 0 );
|
||||
|
||||
for ( i = 0 ; i < dma->buf_count ; i++ ) {
|
||||
buf = dma->buflist[i];
|
||||
buf_priv = buf->dev_private;
|
||||
|
||||
entry = DRM(alloc)( sizeof(drm_mga_freelist_t),
|
||||
DRM_MEM_DRIVER );
|
||||
if ( entry == NULL )
|
||||
return DRM_ERR(ENOMEM);
|
||||
|
||||
memset( entry, 0, sizeof(drm_mga_freelist_t) );
|
||||
|
||||
entry->next = dev_priv->head->next;
|
||||
entry->prev = dev_priv->head;
|
||||
SET_AGE( &entry->age, MGA_BUFFER_FREE, 0 );
|
||||
entry->buf = buf;
|
||||
|
||||
if ( dev_priv->head->next != NULL )
|
||||
dev_priv->head->next->prev = entry;
|
||||
if ( entry->next == NULL )
|
||||
dev_priv->tail = entry;
|
||||
|
||||
buf_priv->list_entry = entry;
|
||||
buf_priv->discard = 0;
|
||||
buf_priv->dispatched = 0;
|
||||
|
||||
dev_priv->head->next = entry;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mga_freelist_cleanup( drm_device_t *dev )
|
||||
{
|
||||
drm_mga_private_t *dev_priv = dev->dev_private;
|
||||
drm_mga_freelist_t *entry;
|
||||
drm_mga_freelist_t *next;
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
entry = dev_priv->head;
|
||||
while ( entry ) {
|
||||
next = entry->next;
|
||||
DRM(free)( entry, sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER );
|
||||
entry = next;
|
||||
}
|
||||
|
||||
dev_priv->head = dev_priv->tail = NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* FIXME: Still needed?
|
||||
*/
|
||||
static void mga_freelist_reset( drm_device_t *dev )
|
||||
{
|
||||
drm_device_dma_t *dma = dev->dma;
|
||||
drm_buf_t *buf;
|
||||
drm_mga_buf_priv_t *buf_priv;
|
||||
int i;
|
||||
|
||||
for ( i = 0 ; i < dma->buf_count ; i++ ) {
|
||||
buf = dma->buflist[i];
|
||||
buf_priv = buf->dev_private;
|
||||
SET_AGE( &buf_priv->list_entry->age,
|
||||
MGA_BUFFER_FREE, 0 );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static drm_buf_t *mga_freelist_get( drm_device_t *dev )
|
||||
{
|
||||
drm_mga_private_t *dev_priv = dev->dev_private;
|
||||
drm_mga_freelist_t *next;
|
||||
drm_mga_freelist_t *prev;
|
||||
drm_mga_freelist_t *tail = dev_priv->tail;
|
||||
u32 head, wrap;
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
head = MGA_READ( MGA_PRIMADDRESS );
|
||||
wrap = dev_priv->sarea_priv->last_wrap;
|
||||
|
||||
DRM_DEBUG( " tail=0x%06lx %d\n",
|
||||
tail->age.head ?
|
||||
tail->age.head - dev_priv->primary->offset : 0,
|
||||
tail->age.wrap );
|
||||
DRM_DEBUG( " head=0x%06lx %d\n",
|
||||
head - dev_priv->primary->offset, wrap );
|
||||
|
||||
if ( TEST_AGE( &tail->age, head, wrap ) ) {
|
||||
prev = dev_priv->tail->prev;
|
||||
next = dev_priv->tail;
|
||||
prev->next = NULL;
|
||||
next->prev = next->next = NULL;
|
||||
dev_priv->tail = prev;
|
||||
SET_AGE( &next->age, MGA_BUFFER_USED, 0 );
|
||||
return next->buf;
|
||||
}
|
||||
|
||||
DRM_DEBUG( "returning NULL!\n" );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int mga_freelist_put( drm_device_t *dev, drm_buf_t *buf )
|
||||
{
|
||||
drm_mga_private_t *dev_priv = dev->dev_private;
|
||||
drm_mga_buf_priv_t *buf_priv = buf->dev_private;
|
||||
drm_mga_freelist_t *head, *entry, *prev;
|
||||
|
||||
DRM_DEBUG( "age=0x%06lx wrap=%d\n",
|
||||
buf_priv->list_entry->age.head -
|
||||
dev_priv->primary->offset,
|
||||
buf_priv->list_entry->age.wrap );
|
||||
|
||||
entry = buf_priv->list_entry;
|
||||
head = dev_priv->head;
|
||||
|
||||
if ( buf_priv->list_entry->age.head == MGA_BUFFER_USED ) {
|
||||
SET_AGE( &entry->age, MGA_BUFFER_FREE, 0 );
|
||||
prev = dev_priv->tail;
|
||||
prev->next = entry;
|
||||
entry->prev = prev;
|
||||
entry->next = NULL;
|
||||
} else {
|
||||
prev = head->next;
|
||||
head->next = entry;
|
||||
prev->prev = entry;
|
||||
entry->prev = head;
|
||||
entry->next = prev;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* DMA initialization, cleanup
|
||||
*/
|
||||
|
||||
static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
|
||||
{
|
||||
drm_mga_private_t *dev_priv;
|
||||
int ret;
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
dev_priv = DRM(alloc)( sizeof(drm_mga_private_t), DRM_MEM_DRIVER );
|
||||
if ( !dev_priv )
|
||||
return DRM_ERR(ENOMEM);
|
||||
|
||||
memset( dev_priv, 0, sizeof(drm_mga_private_t) );
|
||||
|
||||
dev_priv->chipset = init->chipset;
|
||||
|
||||
dev_priv->usec_timeout = MGA_DEFAULT_USEC_TIMEOUT;
|
||||
|
||||
if ( init->sgram ) {
|
||||
dev_priv->clear_cmd = MGA_DWGCTL_CLEAR | MGA_ATYPE_BLK;
|
||||
} else {
|
||||
dev_priv->clear_cmd = MGA_DWGCTL_CLEAR | MGA_ATYPE_RSTR;
|
||||
}
|
||||
dev_priv->maccess = init->maccess;
|
||||
|
||||
dev_priv->fb_cpp = init->fb_cpp;
|
||||
dev_priv->front_offset = init->front_offset;
|
||||
dev_priv->front_pitch = init->front_pitch;
|
||||
dev_priv->back_offset = init->back_offset;
|
||||
dev_priv->back_pitch = init->back_pitch;
|
||||
|
||||
dev_priv->depth_cpp = init->depth_cpp;
|
||||
dev_priv->depth_offset = init->depth_offset;
|
||||
dev_priv->depth_pitch = init->depth_pitch;
|
||||
|
||||
/* FIXME: Need to support AGP textures...
|
||||
*/
|
||||
dev_priv->texture_offset = init->texture_offset[0];
|
||||
dev_priv->texture_size = init->texture_size[0];
|
||||
|
||||
DRM_GETSAREA();
|
||||
|
||||
if(!dev_priv->sarea) {
|
||||
DRM_ERROR( "failed to find sarea!\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
|
||||
DRM_FIND_MAP( dev_priv->fb, init->fb_offset );
|
||||
if(!dev_priv->fb) {
|
||||
DRM_ERROR( "failed to find framebuffer!\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset );
|
||||
if(!dev_priv->mmio) {
|
||||
DRM_ERROR( "failed to find mmio region!\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
DRM_FIND_MAP( dev_priv->status, init->status_offset );
|
||||
if(!dev_priv->status) {
|
||||
DRM_ERROR( "failed to find status page!\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
|
||||
DRM_FIND_MAP( dev_priv->warp, init->warp_offset );
|
||||
if(!dev_priv->warp) {
|
||||
DRM_ERROR( "failed to find warp microcode region!\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
DRM_FIND_MAP( dev_priv->primary, init->primary_offset );
|
||||
if(!dev_priv->primary) {
|
||||
DRM_ERROR( "failed to find primary dma region!\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
|
||||
if(!dev_priv->buffers) {
|
||||
DRM_ERROR( "failed to find dma buffer region!\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
|
||||
dev_priv->sarea_priv =
|
||||
(drm_mga_sarea_t *)((u8 *)dev_priv->sarea->handle +
|
||||
init->sarea_priv_offset);
|
||||
|
||||
DRM_IOREMAP( dev_priv->warp );
|
||||
DRM_IOREMAP( dev_priv->primary );
|
||||
DRM_IOREMAP( dev_priv->buffers );
|
||||
|
||||
if(!dev_priv->warp->handle ||
|
||||
!dev_priv->primary->handle ||
|
||||
!dev_priv->buffers->handle ) {
|
||||
DRM_ERROR( "failed to ioremap agp regions!\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return DRM_ERR(ENOMEM);
|
||||
}
|
||||
|
||||
ret = mga_warp_install_microcode( dev_priv );
|
||||
if ( ret < 0 ) {
|
||||
DRM_ERROR( "failed to install WARP ucode!\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = mga_warp_init( dev_priv );
|
||||
if ( ret < 0 ) {
|
||||
DRM_ERROR( "failed to init WARP engine!\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return ret;
|
||||
}
|
||||
|
||||
dev_priv->prim.status = (u32 *)dev_priv->status->handle;
|
||||
|
||||
mga_do_wait_for_idle( dev_priv );
|
||||
|
||||
/* Init the primary DMA registers.
|
||||
*/
|
||||
MGA_WRITE( MGA_PRIMADDRESS,
|
||||
dev_priv->primary->offset | MGA_DMA_GENERAL );
|
||||
#if 0
|
||||
MGA_WRITE( MGA_PRIMPTR,
|
||||
virt_to_bus((void *)dev_priv->prim.status) |
|
||||
MGA_PRIMPTREN0 | /* Soft trap, SECEND, SETUPEND */
|
||||
MGA_PRIMPTREN1 ); /* DWGSYNC */
|
||||
#endif
|
||||
|
||||
dev_priv->prim.start = (u8 *)dev_priv->primary->handle;
|
||||
dev_priv->prim.end = ((u8 *)dev_priv->primary->handle
|
||||
+ dev_priv->primary->size);
|
||||
dev_priv->prim.size = dev_priv->primary->size;
|
||||
|
||||
dev_priv->prim.tail = 0;
|
||||
dev_priv->prim.space = dev_priv->prim.size;
|
||||
dev_priv->prim.wrapped = 0;
|
||||
|
||||
dev_priv->prim.last_flush = 0;
|
||||
dev_priv->prim.last_wrap = 0;
|
||||
|
||||
dev_priv->prim.high_mark = 256 * DMA_BLOCK_SIZE;
|
||||
|
||||
dev_priv->prim.status[0] = dev_priv->primary->offset;
|
||||
dev_priv->prim.status[1] = 0;
|
||||
|
||||
dev_priv->sarea_priv->last_wrap = 0;
|
||||
dev_priv->sarea_priv->last_frame.head = 0;
|
||||
dev_priv->sarea_priv->last_frame.wrap = 0;
|
||||
|
||||
if ( mga_freelist_init( dev, dev_priv ) < 0 ) {
|
||||
DRM_ERROR( "could not initialize freelist\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return DRM_ERR(ENOMEM);
|
||||
}
|
||||
|
||||
/* Make dev_private visable to others. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mga_do_cleanup_dma( drm_device_t *dev )
|
||||
{
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
if ( dev->dev_private ) {
|
||||
drm_mga_private_t *dev_priv = dev->dev_private;
|
||||
|
||||
DRM_IOREMAPFREE( dev_priv->warp );
|
||||
DRM_IOREMAPFREE( dev_priv->primary );
|
||||
DRM_IOREMAPFREE( dev_priv->buffers );
|
||||
|
||||
if ( dev_priv->head != NULL ) {
|
||||
mga_freelist_cleanup( dev );
|
||||
}
|
||||
|
||||
DRM(free)( dev->dev_private, sizeof(drm_mga_private_t),
|
||||
DRM_MEM_DRIVER );
|
||||
dev->dev_private = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mga_dma_init( DRM_IOCTL_ARGS )
|
||||
{
|
||||
DRM_DEVICE;
|
||||
drm_mga_init_t init;
|
||||
|
||||
DRM_COPY_FROM_USER_IOCTL( init, (drm_mga_init_t *)data, sizeof(init) );
|
||||
|
||||
switch ( init.func ) {
|
||||
case MGA_INIT_DMA:
|
||||
return mga_do_init_dma( dev, &init );
|
||||
case MGA_CLEANUP_DMA:
|
||||
return mga_do_cleanup_dma( dev );
|
||||
}
|
||||
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Primary DMA stream management
|
||||
*/
|
||||
|
||||
int mga_dma_flush( DRM_IOCTL_ARGS )
|
||||
{
|
||||
DRM_DEVICE;
|
||||
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
|
||||
drm_lock_t lock;
|
||||
|
||||
LOCK_TEST_WITH_RETURN( dev );
|
||||
|
||||
DRM_COPY_FROM_USER_IOCTL( lock, (drm_lock_t *)data, sizeof(lock) );
|
||||
|
||||
DRM_DEBUG( "%s%s%s\n",
|
||||
(lock.flags & _DRM_LOCK_FLUSH) ? "flush, " : "",
|
||||
(lock.flags & _DRM_LOCK_FLUSH_ALL) ? "flush all, " : "",
|
||||
(lock.flags & _DRM_LOCK_QUIESCENT) ? "idle, " : "" );
|
||||
|
||||
WRAP_WAIT_WITH_RETURN( dev_priv );
|
||||
|
||||
if ( lock.flags & (_DRM_LOCK_FLUSH | _DRM_LOCK_FLUSH_ALL) ) {
|
||||
mga_do_dma_flush( dev_priv );
|
||||
}
|
||||
|
||||
if ( lock.flags & _DRM_LOCK_QUIESCENT ) {
|
||||
#if MGA_DMA_DEBUG
|
||||
int ret = mga_do_wait_for_idle( dev_priv );
|
||||
if ( ret < 0 )
|
||||
DRM_INFO( "%s: -EBUSY\n", __func__ );
|
||||
return ret;
|
||||
#else
|
||||
return mga_do_wait_for_idle( dev_priv );
|
||||
#endif
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int mga_dma_reset( DRM_IOCTL_ARGS )
|
||||
{
|
||||
DRM_DEVICE;
|
||||
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
|
||||
|
||||
LOCK_TEST_WITH_RETURN( dev );
|
||||
|
||||
return mga_do_dma_reset( dev_priv );
|
||||
}
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* DMA buffer management
|
||||
*/
|
||||
|
||||
static int mga_dma_get_buffers( drm_device_t *dev, drm_dma_t *d )
|
||||
{
|
||||
drm_buf_t *buf;
|
||||
int i;
|
||||
|
||||
for ( i = d->granted_count ; i < d->request_count ; i++ ) {
|
||||
buf = mga_freelist_get( dev );
|
||||
if ( !buf ) return DRM_ERR(EAGAIN);
|
||||
|
||||
buf->pid = DRM_CURRENTPID;
|
||||
|
||||
if ( DRM_COPY_TO_USER( &d->request_indices[i],
|
||||
&buf->idx, sizeof(buf->idx) ) )
|
||||
return DRM_ERR(EFAULT);
|
||||
if ( DRM_COPY_TO_USER( &d->request_sizes[i],
|
||||
&buf->total, sizeof(buf->total) ) )
|
||||
return DRM_ERR(EFAULT);
|
||||
|
||||
d->granted_count++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mga_dma_buffers( DRM_IOCTL_ARGS )
|
||||
{
|
||||
DRM_DEVICE;
|
||||
drm_device_dma_t *dma = dev->dma;
|
||||
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
|
||||
drm_dma_t d;
|
||||
int ret = 0;
|
||||
|
||||
LOCK_TEST_WITH_RETURN( dev );
|
||||
|
||||
DRM_COPY_FROM_USER_IOCTL( d, (drm_dma_t *)data, sizeof(d) );
|
||||
|
||||
/* Please don't send us buffers.
|
||||
*/
|
||||
if ( d.send_count != 0 ) {
|
||||
DRM_ERROR( "Process %d trying to send %d buffers via drmDMA\n",
|
||||
DRM_CURRENTPID, d.send_count );
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
|
||||
/* We'll send you buffers.
|
||||
*/
|
||||
if ( d.request_count < 0 || d.request_count > dma->buf_count ) {
|
||||
DRM_ERROR( "Process %d trying to get %d buffers (of %d max)\n",
|
||||
DRM_CURRENTPID, d.request_count, dma->buf_count );
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
|
||||
WRAP_TEST_WITH_RETURN( dev_priv );
|
||||
|
||||
d.granted_count = 0;
|
||||
|
||||
if ( d.request_count ) {
|
||||
ret = mga_dma_get_buffers( dev, &d );
|
||||
}
|
||||
|
||||
DRM_COPY_TO_USER_IOCTL( (drm_dma_t *)data, d, sizeof(d) );
|
||||
|
||||
return ret;
|
||||
}
|
||||
325
shared-core/mga_drm.h
Normal file
325
shared-core/mga_drm.h
Normal file
|
|
@ -0,0 +1,325 @@
|
|||
/* mga_drm.h -- Public header for the Matrox g200/g400 driver -*- linux-c -*-
|
||||
* Created: Tue Jan 25 01:50:01 1999 by jhartmann@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS 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.
|
||||
*
|
||||
* Authors:
|
||||
* Jeff Hartmann <jhartmann@valinux.com>
|
||||
* Keith Whitwell <keithw@valinux.com>
|
||||
*
|
||||
* Rewritten by:
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#ifndef __MGA_DRM_H__
|
||||
#define __MGA_DRM_H__
|
||||
|
||||
/* WARNING: If you change any of these defines, make sure to change the
|
||||
* defines in the Xserver file (mga_sarea.h)
|
||||
*/
|
||||
|
||||
#ifndef __MGA_SAREA_DEFINES__
|
||||
#define __MGA_SAREA_DEFINES__
|
||||
|
||||
/* WARP pipe flags
|
||||
*/
|
||||
#define MGA_F 0x1 /* fog */
|
||||
#define MGA_A 0x2 /* alpha */
|
||||
#define MGA_S 0x4 /* specular */
|
||||
#define MGA_T2 0x8 /* multitexture */
|
||||
|
||||
#define MGA_WARP_TGZ 0
|
||||
#define MGA_WARP_TGZF (MGA_F)
|
||||
#define MGA_WARP_TGZA (MGA_A)
|
||||
#define MGA_WARP_TGZAF (MGA_F|MGA_A)
|
||||
#define MGA_WARP_TGZS (MGA_S)
|
||||
#define MGA_WARP_TGZSF (MGA_S|MGA_F)
|
||||
#define MGA_WARP_TGZSA (MGA_S|MGA_A)
|
||||
#define MGA_WARP_TGZSAF (MGA_S|MGA_F|MGA_A)
|
||||
#define MGA_WARP_T2GZ (MGA_T2)
|
||||
#define MGA_WARP_T2GZF (MGA_T2|MGA_F)
|
||||
#define MGA_WARP_T2GZA (MGA_T2|MGA_A)
|
||||
#define MGA_WARP_T2GZAF (MGA_T2|MGA_A|MGA_F)
|
||||
#define MGA_WARP_T2GZS (MGA_T2|MGA_S)
|
||||
#define MGA_WARP_T2GZSF (MGA_T2|MGA_S|MGA_F)
|
||||
#define MGA_WARP_T2GZSA (MGA_T2|MGA_S|MGA_A)
|
||||
#define MGA_WARP_T2GZSAF (MGA_T2|MGA_S|MGA_F|MGA_A)
|
||||
|
||||
#define MGA_MAX_G200_PIPES 8 /* no multitex */
|
||||
#define MGA_MAX_G400_PIPES 16
|
||||
#define MGA_MAX_WARP_PIPES MGA_MAX_G400_PIPES
|
||||
#define MGA_WARP_UCODE_SIZE 32768 /* in bytes */
|
||||
|
||||
#define MGA_CARD_TYPE_G200 1
|
||||
#define MGA_CARD_TYPE_G400 2
|
||||
|
||||
|
||||
#define MGA_FRONT 0x1
|
||||
#define MGA_BACK 0x2
|
||||
#define MGA_DEPTH 0x4
|
||||
|
||||
/* What needs to be changed for the current vertex dma buffer?
|
||||
*/
|
||||
#define MGA_UPLOAD_CONTEXT 0x1
|
||||
#define MGA_UPLOAD_TEX0 0x2
|
||||
#define MGA_UPLOAD_TEX1 0x4
|
||||
#define MGA_UPLOAD_PIPE 0x8
|
||||
#define MGA_UPLOAD_TEX0IMAGE 0x10 /* handled client-side */
|
||||
#define MGA_UPLOAD_TEX1IMAGE 0x20 /* handled client-side */
|
||||
#define MGA_UPLOAD_2D 0x40
|
||||
#define MGA_WAIT_AGE 0x80 /* handled client-side */
|
||||
#define MGA_UPLOAD_CLIPRECTS 0x100 /* handled client-side */
|
||||
#if 0
|
||||
#define MGA_DMA_FLUSH 0x200 /* set when someone gets the lock
|
||||
quiescent */
|
||||
#endif
|
||||
|
||||
/* 32 buffers of 64k each, total 2 meg.
|
||||
*/
|
||||
#define MGA_BUFFER_SIZE (1 << 16)
|
||||
#define MGA_NUM_BUFFERS 128
|
||||
|
||||
/* Keep these small for testing.
|
||||
*/
|
||||
#define MGA_NR_SAREA_CLIPRECTS 8
|
||||
|
||||
/* 2 heaps (1 for card, 1 for agp), each divided into upto 128
|
||||
* regions, subject to a minimum region size of (1<<16) == 64k.
|
||||
*
|
||||
* Clients may subdivide regions internally, but when sharing between
|
||||
* clients, the region size is the minimum granularity.
|
||||
*/
|
||||
|
||||
#define MGA_CARD_HEAP 0
|
||||
#define MGA_AGP_HEAP 1
|
||||
#define MGA_NR_TEX_HEAPS 2
|
||||
#define MGA_NR_TEX_REGIONS 16
|
||||
#define MGA_LOG_MIN_TEX_REGION_SIZE 16
|
||||
|
||||
#endif /* __MGA_SAREA_DEFINES__ */
|
||||
|
||||
|
||||
/* Setup registers for 3D context
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int dstorg;
|
||||
unsigned int maccess;
|
||||
unsigned int plnwt;
|
||||
unsigned int dwgctl;
|
||||
unsigned int alphactrl;
|
||||
unsigned int fogcolor;
|
||||
unsigned int wflag;
|
||||
unsigned int tdualstage0;
|
||||
unsigned int tdualstage1;
|
||||
unsigned int fcol;
|
||||
unsigned int stencil;
|
||||
unsigned int stencilctl;
|
||||
} drm_mga_context_regs_t;
|
||||
|
||||
/* Setup registers for 2D, X server
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int pitch;
|
||||
} drm_mga_server_regs_t;
|
||||
|
||||
/* Setup registers for each texture unit
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int texctl;
|
||||
unsigned int texctl2;
|
||||
unsigned int texfilter;
|
||||
unsigned int texbordercol;
|
||||
unsigned int texorg;
|
||||
unsigned int texwidth;
|
||||
unsigned int texheight;
|
||||
unsigned int texorg1;
|
||||
unsigned int texorg2;
|
||||
unsigned int texorg3;
|
||||
unsigned int texorg4;
|
||||
} drm_mga_texture_regs_t;
|
||||
|
||||
/* General aging mechanism
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int head; /* Position of head pointer */
|
||||
unsigned int wrap; /* Primary DMA wrap count */
|
||||
} drm_mga_age_t;
|
||||
|
||||
typedef struct _drm_mga_sarea {
|
||||
/* The channel for communication of state information to the kernel
|
||||
* on firing a vertex dma buffer.
|
||||
*/
|
||||
drm_mga_context_regs_t context_state;
|
||||
drm_mga_server_regs_t server_state;
|
||||
drm_mga_texture_regs_t tex_state[2];
|
||||
unsigned int warp_pipe;
|
||||
unsigned int dirty;
|
||||
unsigned int vertsize;
|
||||
|
||||
/* The current cliprects, or a subset thereof.
|
||||
*/
|
||||
drm_clip_rect_t boxes[MGA_NR_SAREA_CLIPRECTS];
|
||||
unsigned int nbox;
|
||||
|
||||
/* Information about the most recently used 3d drawable. The
|
||||
* client fills in the req_* fields, the server fills in the
|
||||
* exported_ fields and puts the cliprects into boxes, above.
|
||||
*
|
||||
* The client clears the exported_drawable field before
|
||||
* clobbering the boxes data.
|
||||
*/
|
||||
unsigned int req_drawable; /* the X drawable id */
|
||||
unsigned int req_draw_buffer; /* MGA_FRONT or MGA_BACK */
|
||||
|
||||
unsigned int exported_drawable;
|
||||
unsigned int exported_index;
|
||||
unsigned int exported_stamp;
|
||||
unsigned int exported_buffers;
|
||||
unsigned int exported_nfront;
|
||||
unsigned int exported_nback;
|
||||
int exported_back_x, exported_front_x, exported_w;
|
||||
int exported_back_y, exported_front_y, exported_h;
|
||||
drm_clip_rect_t exported_boxes[MGA_NR_SAREA_CLIPRECTS];
|
||||
|
||||
/* Counters for aging textures and for client-side throttling.
|
||||
*/
|
||||
unsigned int status[4];
|
||||
unsigned int last_wrap;
|
||||
|
||||
drm_mga_age_t last_frame;
|
||||
unsigned int last_enqueue; /* last time a buffer was enqueued */
|
||||
unsigned int last_dispatch; /* age of the most recently dispatched buffer */
|
||||
unsigned int last_quiescent; /* */
|
||||
|
||||
/* LRU lists for texture memory in agp space and on the card.
|
||||
*/
|
||||
drm_tex_region_t texList[MGA_NR_TEX_HEAPS][MGA_NR_TEX_REGIONS+1];
|
||||
unsigned int texAge[MGA_NR_TEX_HEAPS];
|
||||
|
||||
/* Mechanism to validate card state.
|
||||
*/
|
||||
int ctxOwner;
|
||||
} drm_mga_sarea_t;
|
||||
|
||||
|
||||
/* WARNING: If you change any of these defines, make sure to change the
|
||||
* defines in the Xserver file (xf86drmMga.h)
|
||||
*/
|
||||
|
||||
/* MGA specific ioctls
|
||||
* The device specific ioctl range is 0x40 to 0x79.
|
||||
*/
|
||||
#define DRM_IOCTL_MGA_INIT DRM_IOW( 0x40, drm_mga_init_t)
|
||||
#define DRM_IOCTL_MGA_FLUSH DRM_IOW( 0x41, drm_lock_t)
|
||||
#define DRM_IOCTL_MGA_RESET DRM_IO( 0x42)
|
||||
#define DRM_IOCTL_MGA_SWAP DRM_IO( 0x43)
|
||||
#define DRM_IOCTL_MGA_CLEAR DRM_IOW( 0x44, drm_mga_clear_t)
|
||||
#define DRM_IOCTL_MGA_VERTEX DRM_IOW( 0x45, drm_mga_vertex_t)
|
||||
#define DRM_IOCTL_MGA_INDICES DRM_IOW( 0x46, drm_mga_indices_t)
|
||||
#define DRM_IOCTL_MGA_ILOAD DRM_IOW( 0x47, drm_mga_iload_t)
|
||||
#define DRM_IOCTL_MGA_BLIT DRM_IOW( 0x48, drm_mga_blit_t)
|
||||
|
||||
typedef struct _drm_mga_warp_index {
|
||||
int installed;
|
||||
unsigned long phys_addr;
|
||||
int size;
|
||||
} drm_mga_warp_index_t;
|
||||
|
||||
typedef struct drm_mga_init {
|
||||
enum {
|
||||
MGA_INIT_DMA = 0x01,
|
||||
MGA_CLEANUP_DMA = 0x02
|
||||
} func;
|
||||
|
||||
unsigned long sarea_priv_offset;
|
||||
|
||||
int chipset;
|
||||
int sgram;
|
||||
|
||||
unsigned int maccess;
|
||||
|
||||
unsigned int fb_cpp;
|
||||
unsigned int front_offset, front_pitch;
|
||||
unsigned int back_offset, back_pitch;
|
||||
|
||||
unsigned int depth_cpp;
|
||||
unsigned int depth_offset, depth_pitch;
|
||||
|
||||
unsigned int texture_offset[MGA_NR_TEX_HEAPS];
|
||||
unsigned int texture_size[MGA_NR_TEX_HEAPS];
|
||||
|
||||
unsigned long fb_offset;
|
||||
unsigned long mmio_offset;
|
||||
unsigned long status_offset;
|
||||
unsigned long warp_offset;
|
||||
unsigned long primary_offset;
|
||||
unsigned long buffers_offset;
|
||||
} drm_mga_init_t;
|
||||
|
||||
typedef struct drm_mga_fullscreen {
|
||||
enum {
|
||||
MGA_INIT_FULLSCREEN = 0x01,
|
||||
MGA_CLEANUP_FULLSCREEN = 0x02
|
||||
} func;
|
||||
} drm_mga_fullscreen_t;
|
||||
|
||||
typedef struct drm_mga_clear {
|
||||
unsigned int flags;
|
||||
unsigned int clear_color;
|
||||
unsigned int clear_depth;
|
||||
unsigned int color_mask;
|
||||
unsigned int depth_mask;
|
||||
} drm_mga_clear_t;
|
||||
|
||||
typedef struct drm_mga_vertex {
|
||||
int idx; /* buffer to queue */
|
||||
int used; /* bytes in use */
|
||||
int discard; /* client finished with buffer? */
|
||||
} drm_mga_vertex_t;
|
||||
|
||||
typedef struct drm_mga_indices {
|
||||
int idx; /* buffer to queue */
|
||||
unsigned int start;
|
||||
unsigned int end;
|
||||
int discard; /* client finished with buffer? */
|
||||
} drm_mga_indices_t;
|
||||
|
||||
typedef struct drm_mga_iload {
|
||||
int idx;
|
||||
unsigned int dstorg;
|
||||
unsigned int length;
|
||||
} drm_mga_iload_t;
|
||||
|
||||
typedef struct _drm_mga_blit {
|
||||
unsigned int planemask;
|
||||
unsigned int srcorg;
|
||||
unsigned int dstorg;
|
||||
int src_pitch, dst_pitch;
|
||||
int delta_sx, delta_sy;
|
||||
int delta_dx, delta_dy;
|
||||
int height, ydir; /* flip image vertically */
|
||||
int source_pitch, dest_pitch;
|
||||
} drm_mga_blit_t;
|
||||
|
||||
#endif
|
||||
631
shared-core/mga_drv.h
Normal file
631
shared-core/mga_drv.h
Normal file
|
|
@ -0,0 +1,631 @@
|
|||
/* mga_drv.h -- Private header for the Matrox G200/G400 driver -*- linux-c -*-
|
||||
* Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS 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.
|
||||
*
|
||||
* Authors:
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#ifndef __MGA_DRV_H__
|
||||
#define __MGA_DRV_H__
|
||||
|
||||
typedef struct drm_mga_primary_buffer {
|
||||
u8 *start;
|
||||
u8 *end;
|
||||
int size;
|
||||
|
||||
u32 tail;
|
||||
int space;
|
||||
int wrapped;
|
||||
|
||||
volatile u32 *status;
|
||||
|
||||
u32 last_flush;
|
||||
u32 last_wrap;
|
||||
|
||||
u32 high_mark;
|
||||
} drm_mga_primary_buffer_t;
|
||||
|
||||
typedef struct drm_mga_freelist {
|
||||
struct drm_mga_freelist *next;
|
||||
struct drm_mga_freelist *prev;
|
||||
drm_mga_age_t age;
|
||||
drm_buf_t *buf;
|
||||
} drm_mga_freelist_t;
|
||||
|
||||
typedef struct {
|
||||
drm_mga_freelist_t *list_entry;
|
||||
int discard;
|
||||
int dispatched;
|
||||
} drm_mga_buf_priv_t;
|
||||
|
||||
typedef struct drm_mga_private {
|
||||
drm_mga_primary_buffer_t prim;
|
||||
drm_mga_sarea_t *sarea_priv;
|
||||
|
||||
drm_mga_freelist_t *head;
|
||||
drm_mga_freelist_t *tail;
|
||||
|
||||
unsigned int warp_pipe;
|
||||
unsigned long warp_pipe_phys[MGA_MAX_WARP_PIPES];
|
||||
|
||||
int chipset;
|
||||
int usec_timeout;
|
||||
|
||||
u32 clear_cmd;
|
||||
u32 maccess;
|
||||
|
||||
unsigned int fb_cpp;
|
||||
unsigned int front_offset;
|
||||
unsigned int front_pitch;
|
||||
unsigned int back_offset;
|
||||
unsigned int back_pitch;
|
||||
|
||||
unsigned int depth_cpp;
|
||||
unsigned int depth_offset;
|
||||
unsigned int depth_pitch;
|
||||
|
||||
unsigned int texture_offset;
|
||||
unsigned int texture_size;
|
||||
|
||||
drm_map_t *sarea;
|
||||
drm_map_t *fb;
|
||||
drm_map_t *mmio;
|
||||
drm_map_t *status;
|
||||
drm_map_t *warp;
|
||||
drm_map_t *primary;
|
||||
drm_map_t *buffers;
|
||||
drm_map_t *agp_textures;
|
||||
} drm_mga_private_t;
|
||||
|
||||
/* mga_dma.c */
|
||||
extern int mga_dma_init( DRM_IOCTL_ARGS );
|
||||
extern int mga_dma_flush( DRM_IOCTL_ARGS );
|
||||
extern int mga_dma_reset( DRM_IOCTL_ARGS );
|
||||
extern int mga_dma_buffers( DRM_IOCTL_ARGS );
|
||||
|
||||
extern int mga_do_wait_for_idle( drm_mga_private_t *dev_priv );
|
||||
extern int mga_do_dma_idle( drm_mga_private_t *dev_priv );
|
||||
extern int mga_do_dma_reset( drm_mga_private_t *dev_priv );
|
||||
extern int mga_do_engine_reset( drm_mga_private_t *dev_priv );
|
||||
extern int mga_do_cleanup_dma( drm_device_t *dev );
|
||||
|
||||
extern void mga_do_dma_flush( drm_mga_private_t *dev_priv );
|
||||
extern void mga_do_dma_wrap_start( drm_mga_private_t *dev_priv );
|
||||
extern void mga_do_dma_wrap_end( drm_mga_private_t *dev_priv );
|
||||
|
||||
extern int mga_freelist_put( drm_device_t *dev, drm_buf_t *buf );
|
||||
|
||||
/* mga_state.c */
|
||||
extern int mga_dma_clear( DRM_IOCTL_ARGS );
|
||||
extern int mga_dma_swap( DRM_IOCTL_ARGS );
|
||||
extern int mga_dma_vertex( DRM_IOCTL_ARGS );
|
||||
extern int mga_dma_indices( DRM_IOCTL_ARGS );
|
||||
extern int mga_dma_iload( DRM_IOCTL_ARGS );
|
||||
extern int mga_dma_blit( DRM_IOCTL_ARGS );
|
||||
|
||||
/* mga_warp.c */
|
||||
extern int mga_warp_install_microcode( drm_mga_private_t *dev_priv );
|
||||
extern int mga_warp_init( drm_mga_private_t *dev_priv );
|
||||
|
||||
#define mga_flush_write_combine() DRM_WRITEMEMORYBARRIER()
|
||||
|
||||
|
||||
#define MGA_BASE( reg ) ((unsigned long)(dev_priv->mmio->handle))
|
||||
#define MGA_ADDR( reg ) (MGA_BASE(reg) + reg)
|
||||
|
||||
#define MGA_DEREF( reg ) *(volatile u32 *)MGA_ADDR( reg )
|
||||
#define MGA_DEREF8( reg ) *(volatile u8 *)MGA_ADDR( reg )
|
||||
|
||||
#ifdef __alpha__
|
||||
#define MGA_READ( reg ) (_MGA_READ((u32 *)MGA_ADDR(reg)))
|
||||
#define MGA_WRITE( reg, val ) do { DRM_WRITEMEMORYBARRIER(); MGA_DEREF( reg ) = val; } while (0)
|
||||
#define MGA_WRITE8( reg, val ) do { DRM_WRITEMEMORYBARRIER(); MGA_DEREF8( reg ) = val; } while (0)
|
||||
|
||||
static inline u32 _MGA_READ(u32 *addr)
|
||||
{
|
||||
DRM_READMEMORYBARRIER();
|
||||
return *(volatile u32 *)addr;
|
||||
}
|
||||
|
||||
#else
|
||||
#define MGA_READ( reg ) MGA_DEREF( reg )
|
||||
#define MGA_WRITE( reg, val ) do { MGA_DEREF( reg ) = val; } while (0)
|
||||
#define MGA_WRITE8( reg, val ) do { MGA_DEREF8( reg ) = val; } while (0)
|
||||
#endif
|
||||
|
||||
#define DWGREG0 0x1c00
|
||||
#define DWGREG0_END 0x1dff
|
||||
#define DWGREG1 0x2c00
|
||||
#define DWGREG1_END 0x2dff
|
||||
|
||||
#define ISREG0(r) (r >= DWGREG0 && r <= DWGREG0_END)
|
||||
#define DMAREG0(r) (u8)((r - DWGREG0) >> 2)
|
||||
#define DMAREG1(r) (u8)(((r - DWGREG1) >> 2) | 0x80)
|
||||
#define DMAREG(r) (ISREG0(r) ? DMAREG0(r) : DMAREG1(r))
|
||||
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Helper macross...
|
||||
*/
|
||||
|
||||
#define MGA_EMIT_STATE( dev_priv, dirty ) \
|
||||
do { \
|
||||
if ( (dirty) & ~MGA_UPLOAD_CLIPRECTS ) { \
|
||||
if ( dev_priv->chipset == MGA_CARD_TYPE_G400 ) { \
|
||||
mga_g400_emit_state( dev_priv ); \
|
||||
} else { \
|
||||
mga_g200_emit_state( dev_priv ); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define LOCK_TEST_WITH_RETURN( dev ) \
|
||||
do { \
|
||||
if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
|
||||
dev->lock.pid != DRM_CURRENTPID ) { \
|
||||
DRM_ERROR( "%s called without lock held\n", \
|
||||
__func__ ); \
|
||||
return DRM_ERR(EINVAL); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define WRAP_TEST_WITH_RETURN( dev_priv ) \
|
||||
do { \
|
||||
if ( test_bit( 0, &dev_priv->prim.wrapped ) ) { \
|
||||
if ( mga_is_idle( dev_priv ) ) { \
|
||||
mga_do_dma_wrap_end( dev_priv ); \
|
||||
} else if ( dev_priv->prim.space < \
|
||||
dev_priv->prim.high_mark ) { \
|
||||
if ( MGA_DMA_DEBUG ) \
|
||||
DRM_INFO( "%s: wrap...\n", __func__ ); \
|
||||
return DRM_ERR(EBUSY); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define WRAP_WAIT_WITH_RETURN( dev_priv ) \
|
||||
do { \
|
||||
if ( test_bit( 0, &dev_priv->prim.wrapped ) ) { \
|
||||
if ( mga_do_wait_for_idle( dev_priv ) < 0 ) { \
|
||||
if ( MGA_DMA_DEBUG ) \
|
||||
DRM_INFO( "%s: wrap...\n", __func__ ); \
|
||||
return DRM_ERR(EBUSY); \
|
||||
} \
|
||||
mga_do_dma_wrap_end( dev_priv ); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Primary DMA command stream
|
||||
*/
|
||||
|
||||
#define MGA_VERBOSE 0
|
||||
|
||||
#define DMA_LOCALS unsigned int write; volatile u8 *prim;
|
||||
|
||||
#define DMA_BLOCK_SIZE (5 * sizeof(u32))
|
||||
|
||||
#define BEGIN_DMA( n ) \
|
||||
do { \
|
||||
if ( MGA_VERBOSE ) { \
|
||||
DRM_INFO( "BEGIN_DMA( %d ) in %s\n", \
|
||||
(n), __func__ ); \
|
||||
DRM_INFO( " space=0x%x req=0x%x\n", \
|
||||
dev_priv->prim.space, (n) * DMA_BLOCK_SIZE ); \
|
||||
} \
|
||||
prim = dev_priv->prim.start; \
|
||||
write = dev_priv->prim.tail; \
|
||||
} while (0)
|
||||
|
||||
#define BEGIN_DMA_WRAP() \
|
||||
do { \
|
||||
if ( MGA_VERBOSE ) { \
|
||||
DRM_INFO( "BEGIN_DMA() in %s\n", __func__ ); \
|
||||
DRM_INFO( " space=0x%x\n", dev_priv->prim.space ); \
|
||||
} \
|
||||
prim = dev_priv->prim.start; \
|
||||
write = dev_priv->prim.tail; \
|
||||
} while (0)
|
||||
|
||||
#define ADVANCE_DMA() \
|
||||
do { \
|
||||
dev_priv->prim.tail = write; \
|
||||
if ( MGA_VERBOSE ) { \
|
||||
DRM_INFO( "ADVANCE_DMA() tail=0x%05x sp=0x%x\n", \
|
||||
write, dev_priv->prim.space ); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define FLUSH_DMA() \
|
||||
do { \
|
||||
if ( 0 ) { \
|
||||
DRM_INFO( "%s:\n", __func__ ); \
|
||||
DRM_INFO( " tail=0x%06x head=0x%06lx\n", \
|
||||
dev_priv->prim.tail, \
|
||||
MGA_READ( MGA_PRIMADDRESS ) - \
|
||||
dev_priv->primary->offset ); \
|
||||
} \
|
||||
if ( !test_bit( 0, &dev_priv->prim.wrapped ) ) { \
|
||||
if ( dev_priv->prim.space < \
|
||||
dev_priv->prim.high_mark ) { \
|
||||
mga_do_dma_wrap_start( dev_priv ); \
|
||||
} else { \
|
||||
mga_do_dma_flush( dev_priv ); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Never use this, always use DMA_BLOCK(...) for primary DMA output.
|
||||
*/
|
||||
#define DMA_WRITE( offset, val ) \
|
||||
do { \
|
||||
if ( MGA_VERBOSE ) { \
|
||||
DRM_INFO( " DMA_WRITE( 0x%08x ) at 0x%04x\n", \
|
||||
(u32)(val), write + (offset) * sizeof(u32) ); \
|
||||
} \
|
||||
*(volatile u32 *)(prim + write + (offset) * sizeof(u32)) = val; \
|
||||
} while (0)
|
||||
|
||||
#define DMA_BLOCK( reg0, val0, reg1, val1, reg2, val2, reg3, val3 ) \
|
||||
do { \
|
||||
DMA_WRITE( 0, ((DMAREG( reg0 ) << 0) | \
|
||||
(DMAREG( reg1 ) << 8) | \
|
||||
(DMAREG( reg2 ) << 16) | \
|
||||
(DMAREG( reg3 ) << 24)) ); \
|
||||
DMA_WRITE( 1, val0 ); \
|
||||
DMA_WRITE( 2, val1 ); \
|
||||
DMA_WRITE( 3, val2 ); \
|
||||
DMA_WRITE( 4, val3 ); \
|
||||
write += DMA_BLOCK_SIZE; \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* Buffer aging via primary DMA stream head pointer.
|
||||
*/
|
||||
|
||||
#define SET_AGE( age, h, w ) \
|
||||
do { \
|
||||
(age)->head = h; \
|
||||
(age)->wrap = w; \
|
||||
} while (0)
|
||||
|
||||
#define TEST_AGE( age, h, w ) ( (age)->wrap < w || \
|
||||
( (age)->wrap == w && \
|
||||
(age)->head < h ) )
|
||||
|
||||
#define AGE_BUFFER( buf_priv ) \
|
||||
do { \
|
||||
drm_mga_freelist_t *entry = (buf_priv)->list_entry; \
|
||||
if ( (buf_priv)->dispatched ) { \
|
||||
entry->age.head = (dev_priv->prim.tail + \
|
||||
dev_priv->primary->offset); \
|
||||
entry->age.wrap = dev_priv->sarea_priv->last_wrap; \
|
||||
} else { \
|
||||
entry->age.head = 0; \
|
||||
entry->age.wrap = 0; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define MGA_ENGINE_IDLE_MASK (MGA_SOFTRAPEN | \
|
||||
MGA_DWGENGSTS | \
|
||||
MGA_ENDPRDMASTS)
|
||||
#define MGA_DMA_IDLE_MASK (MGA_SOFTRAPEN | \
|
||||
MGA_ENDPRDMASTS)
|
||||
|
||||
#define MGA_DMA_DEBUG 0
|
||||
|
||||
|
||||
|
||||
/* A reduced set of the mga registers.
|
||||
*/
|
||||
#define MGA_CRTC_INDEX 0x1fd4
|
||||
|
||||
#define MGA_ALPHACTRL 0x2c7c
|
||||
#define MGA_AR0 0x1c60
|
||||
#define MGA_AR1 0x1c64
|
||||
#define MGA_AR2 0x1c68
|
||||
#define MGA_AR3 0x1c6c
|
||||
#define MGA_AR4 0x1c70
|
||||
#define MGA_AR5 0x1c74
|
||||
#define MGA_AR6 0x1c78
|
||||
|
||||
#define MGA_CXBNDRY 0x1c80
|
||||
#define MGA_CXLEFT 0x1ca0
|
||||
#define MGA_CXRIGHT 0x1ca4
|
||||
|
||||
#define MGA_DMAPAD 0x1c54
|
||||
#define MGA_DSTORG 0x2cb8
|
||||
#define MGA_DWGCTL 0x1c00
|
||||
# define MGA_OPCOD_MASK (15 << 0)
|
||||
# define MGA_OPCOD_TRAP (4 << 0)
|
||||
# define MGA_OPCOD_TEXTURE_TRAP (6 << 0)
|
||||
# define MGA_OPCOD_BITBLT (8 << 0)
|
||||
# define MGA_OPCOD_ILOAD (9 << 0)
|
||||
# define MGA_ATYPE_MASK (7 << 4)
|
||||
# define MGA_ATYPE_RPL (0 << 4)
|
||||
# define MGA_ATYPE_RSTR (1 << 4)
|
||||
# define MGA_ATYPE_ZI (3 << 4)
|
||||
# define MGA_ATYPE_BLK (4 << 4)
|
||||
# define MGA_ATYPE_I (7 << 4)
|
||||
# define MGA_LINEAR (1 << 7)
|
||||
# define MGA_ZMODE_MASK (7 << 8)
|
||||
# define MGA_ZMODE_NOZCMP (0 << 8)
|
||||
# define MGA_ZMODE_ZE (2 << 8)
|
||||
# define MGA_ZMODE_ZNE (3 << 8)
|
||||
# define MGA_ZMODE_ZLT (4 << 8)
|
||||
# define MGA_ZMODE_ZLTE (5 << 8)
|
||||
# define MGA_ZMODE_ZGT (6 << 8)
|
||||
# define MGA_ZMODE_ZGTE (7 << 8)
|
||||
# define MGA_SOLID (1 << 11)
|
||||
# define MGA_ARZERO (1 << 12)
|
||||
# define MGA_SGNZERO (1 << 13)
|
||||
# define MGA_SHIFTZERO (1 << 14)
|
||||
# define MGA_BOP_MASK (15 << 16)
|
||||
# define MGA_BOP_ZERO (0 << 16)
|
||||
# define MGA_BOP_DST (10 << 16)
|
||||
# define MGA_BOP_SRC (12 << 16)
|
||||
# define MGA_BOP_ONE (15 << 16)
|
||||
# define MGA_TRANS_SHIFT 20
|
||||
# define MGA_TRANS_MASK (15 << 20)
|
||||
# define MGA_BLTMOD_MASK (15 << 25)
|
||||
# define MGA_BLTMOD_BMONOLEF (0 << 25)
|
||||
# define MGA_BLTMOD_BMONOWF (4 << 25)
|
||||
# define MGA_BLTMOD_PLAN (1 << 25)
|
||||
# define MGA_BLTMOD_BFCOL (2 << 25)
|
||||
# define MGA_BLTMOD_BU32BGR (3 << 25)
|
||||
# define MGA_BLTMOD_BU32RGB (7 << 25)
|
||||
# define MGA_BLTMOD_BU24BGR (11 << 25)
|
||||
# define MGA_BLTMOD_BU24RGB (15 << 25)
|
||||
# define MGA_PATTERN (1 << 29)
|
||||
# define MGA_TRANSC (1 << 30)
|
||||
# define MGA_CLIPDIS (1 << 31)
|
||||
#define MGA_DWGSYNC 0x2c4c
|
||||
|
||||
#define MGA_FCOL 0x1c24
|
||||
#define MGA_FIFOSTATUS 0x1e10
|
||||
#define MGA_FOGCOL 0x1cf4
|
||||
#define MGA_FXBNDRY 0x1c84
|
||||
#define MGA_FXLEFT 0x1ca8
|
||||
#define MGA_FXRIGHT 0x1cac
|
||||
|
||||
#define MGA_ICLEAR 0x1e18
|
||||
# define MGA_SOFTRAPICLR (1 << 0)
|
||||
#define MGA_IEN 0x1e1c
|
||||
# define MGA_SOFTRAPIEN (1 << 0)
|
||||
|
||||
#define MGA_LEN 0x1c5c
|
||||
|
||||
#define MGA_MACCESS 0x1c04
|
||||
|
||||
#define MGA_PITCH 0x1c8c
|
||||
#define MGA_PLNWT 0x1c1c
|
||||
#define MGA_PRIMADDRESS 0x1e58
|
||||
# define MGA_DMA_GENERAL (0 << 0)
|
||||
# define MGA_DMA_BLIT (1 << 0)
|
||||
# define MGA_DMA_VECTOR (2 << 0)
|
||||
# define MGA_DMA_VERTEX (3 << 0)
|
||||
#define MGA_PRIMEND 0x1e5c
|
||||
# define MGA_PRIMNOSTART (1 << 0)
|
||||
# define MGA_PAGPXFER (1 << 1)
|
||||
#define MGA_PRIMPTR 0x1e50
|
||||
# define MGA_PRIMPTREN0 (1 << 0)
|
||||
# define MGA_PRIMPTREN1 (1 << 1)
|
||||
|
||||
#define MGA_RST 0x1e40
|
||||
# define MGA_SOFTRESET (1 << 0)
|
||||
# define MGA_SOFTEXTRST (1 << 1)
|
||||
|
||||
#define MGA_SECADDRESS 0x2c40
|
||||
#define MGA_SECEND 0x2c44
|
||||
#define MGA_SETUPADDRESS 0x2cd0
|
||||
#define MGA_SETUPEND 0x2cd4
|
||||
#define MGA_SGN 0x1c58
|
||||
#define MGA_SOFTRAP 0x2c48
|
||||
#define MGA_SRCORG 0x2cb4
|
||||
# define MGA_SRMMAP_MASK (1 << 0)
|
||||
# define MGA_SRCMAP_FB (0 << 0)
|
||||
# define MGA_SRCMAP_SYSMEM (1 << 0)
|
||||
# define MGA_SRCACC_MASK (1 << 1)
|
||||
# define MGA_SRCACC_PCI (0 << 1)
|
||||
# define MGA_SRCACC_AGP (1 << 1)
|
||||
#define MGA_STATUS 0x1e14
|
||||
# define MGA_SOFTRAPEN (1 << 0)
|
||||
# define MGA_DWGENGSTS (1 << 16)
|
||||
# define MGA_ENDPRDMASTS (1 << 17)
|
||||
#define MGA_STENCIL 0x2cc8
|
||||
#define MGA_STENCILCTL 0x2ccc
|
||||
|
||||
#define MGA_TDUALSTAGE0 0x2cf8
|
||||
#define MGA_TDUALSTAGE1 0x2cfc
|
||||
#define MGA_TEXBORDERCOL 0x2c5c
|
||||
#define MGA_TEXCTL 0x2c30
|
||||
#define MGA_TEXCTL2 0x2c3c
|
||||
# define MGA_DUALTEX (1 << 7)
|
||||
# define MGA_G400_TC2_MAGIC (1 << 15)
|
||||
# define MGA_MAP1_ENABLE (1 << 31)
|
||||
#define MGA_TEXFILTER 0x2c58
|
||||
#define MGA_TEXHEIGHT 0x2c2c
|
||||
#define MGA_TEXORG 0x2c24
|
||||
# define MGA_TEXORGMAP_MASK (1 << 0)
|
||||
# define MGA_TEXORGMAP_FB (0 << 0)
|
||||
# define MGA_TEXORGMAP_SYSMEM (1 << 0)
|
||||
# define MGA_TEXORGACC_MASK (1 << 1)
|
||||
# define MGA_TEXORGACC_PCI (0 << 1)
|
||||
# define MGA_TEXORGACC_AGP (1 << 1)
|
||||
#define MGA_TEXORG1 0x2ca4
|
||||
#define MGA_TEXORG2 0x2ca8
|
||||
#define MGA_TEXORG3 0x2cac
|
||||
#define MGA_TEXORG4 0x2cb0
|
||||
#define MGA_TEXTRANS 0x2c34
|
||||
#define MGA_TEXTRANSHIGH 0x2c38
|
||||
#define MGA_TEXWIDTH 0x2c28
|
||||
|
||||
#define MGA_WACCEPTSEQ 0x1dd4
|
||||
#define MGA_WCODEADDR 0x1e6c
|
||||
#define MGA_WFLAG 0x1dc4
|
||||
#define MGA_WFLAG1 0x1de0
|
||||
#define MGA_WFLAGNB 0x1e64
|
||||
#define MGA_WFLAGNB1 0x1e08
|
||||
#define MGA_WGETMSB 0x1dc8
|
||||
#define MGA_WIADDR 0x1dc0
|
||||
#define MGA_WIADDR2 0x1dd8
|
||||
# define MGA_WMODE_SUSPEND (0 << 0)
|
||||
# define MGA_WMODE_RESUME (1 << 0)
|
||||
# define MGA_WMODE_JUMP (2 << 0)
|
||||
# define MGA_WMODE_START (3 << 0)
|
||||
# define MGA_WAGP_ENABLE (1 << 2)
|
||||
#define MGA_WMISC 0x1e70
|
||||
# define MGA_WUCODECACHE_ENABLE (1 << 0)
|
||||
# define MGA_WMASTER_ENABLE (1 << 1)
|
||||
# define MGA_WCACHEFLUSH_ENABLE (1 << 3)
|
||||
#define MGA_WVRTXSZ 0x1dcc
|
||||
|
||||
#define MGA_YBOT 0x1c9c
|
||||
#define MGA_YDST 0x1c90
|
||||
#define MGA_YDSTLEN 0x1c88
|
||||
#define MGA_YDSTORG 0x1c94
|
||||
#define MGA_YTOP 0x1c98
|
||||
|
||||
#define MGA_ZORG 0x1c0c
|
||||
|
||||
/* This finishes the current batch of commands
|
||||
*/
|
||||
#define MGA_EXEC 0x0100
|
||||
|
||||
/* Warp registers
|
||||
*/
|
||||
#define MGA_WR0 0x2d00
|
||||
#define MGA_WR1 0x2d04
|
||||
#define MGA_WR2 0x2d08
|
||||
#define MGA_WR3 0x2d0c
|
||||
#define MGA_WR4 0x2d10
|
||||
#define MGA_WR5 0x2d14
|
||||
#define MGA_WR6 0x2d18
|
||||
#define MGA_WR7 0x2d1c
|
||||
#define MGA_WR8 0x2d20
|
||||
#define MGA_WR9 0x2d24
|
||||
#define MGA_WR10 0x2d28
|
||||
#define MGA_WR11 0x2d2c
|
||||
#define MGA_WR12 0x2d30
|
||||
#define MGA_WR13 0x2d34
|
||||
#define MGA_WR14 0x2d38
|
||||
#define MGA_WR15 0x2d3c
|
||||
#define MGA_WR16 0x2d40
|
||||
#define MGA_WR17 0x2d44
|
||||
#define MGA_WR18 0x2d48
|
||||
#define MGA_WR19 0x2d4c
|
||||
#define MGA_WR20 0x2d50
|
||||
#define MGA_WR21 0x2d54
|
||||
#define MGA_WR22 0x2d58
|
||||
#define MGA_WR23 0x2d5c
|
||||
#define MGA_WR24 0x2d60
|
||||
#define MGA_WR25 0x2d64
|
||||
#define MGA_WR26 0x2d68
|
||||
#define MGA_WR27 0x2d6c
|
||||
#define MGA_WR28 0x2d70
|
||||
#define MGA_WR29 0x2d74
|
||||
#define MGA_WR30 0x2d78
|
||||
#define MGA_WR31 0x2d7c
|
||||
#define MGA_WR32 0x2d80
|
||||
#define MGA_WR33 0x2d84
|
||||
#define MGA_WR34 0x2d88
|
||||
#define MGA_WR35 0x2d8c
|
||||
#define MGA_WR36 0x2d90
|
||||
#define MGA_WR37 0x2d94
|
||||
#define MGA_WR38 0x2d98
|
||||
#define MGA_WR39 0x2d9c
|
||||
#define MGA_WR40 0x2da0
|
||||
#define MGA_WR41 0x2da4
|
||||
#define MGA_WR42 0x2da8
|
||||
#define MGA_WR43 0x2dac
|
||||
#define MGA_WR44 0x2db0
|
||||
#define MGA_WR45 0x2db4
|
||||
#define MGA_WR46 0x2db8
|
||||
#define MGA_WR47 0x2dbc
|
||||
#define MGA_WR48 0x2dc0
|
||||
#define MGA_WR49 0x2dc4
|
||||
#define MGA_WR50 0x2dc8
|
||||
#define MGA_WR51 0x2dcc
|
||||
#define MGA_WR52 0x2dd0
|
||||
#define MGA_WR53 0x2dd4
|
||||
#define MGA_WR54 0x2dd8
|
||||
#define MGA_WR55 0x2ddc
|
||||
#define MGA_WR56 0x2de0
|
||||
#define MGA_WR57 0x2de4
|
||||
#define MGA_WR58 0x2de8
|
||||
#define MGA_WR59 0x2dec
|
||||
#define MGA_WR60 0x2df0
|
||||
#define MGA_WR61 0x2df4
|
||||
#define MGA_WR62 0x2df8
|
||||
#define MGA_WR63 0x2dfc
|
||||
# define MGA_G400_WR_MAGIC (1 << 6)
|
||||
# define MGA_G400_WR56_MAGIC 0x46480000 /* 12800.0f */
|
||||
|
||||
|
||||
#define MGA_ILOAD_ALIGN 64
|
||||
#define MGA_ILOAD_MASK (MGA_ILOAD_ALIGN - 1)
|
||||
|
||||
#define MGA_DWGCTL_FLUSH (MGA_OPCOD_TEXTURE_TRAP | \
|
||||
MGA_ATYPE_I | \
|
||||
MGA_ZMODE_NOZCMP | \
|
||||
MGA_ARZERO | \
|
||||
MGA_SGNZERO | \
|
||||
MGA_BOP_SRC | \
|
||||
(15 << MGA_TRANS_SHIFT))
|
||||
|
||||
#define MGA_DWGCTL_CLEAR (MGA_OPCOD_TRAP | \
|
||||
MGA_ZMODE_NOZCMP | \
|
||||
MGA_SOLID | \
|
||||
MGA_ARZERO | \
|
||||
MGA_SGNZERO | \
|
||||
MGA_SHIFTZERO | \
|
||||
MGA_BOP_SRC | \
|
||||
(0 << MGA_TRANS_SHIFT) | \
|
||||
MGA_BLTMOD_BMONOLEF | \
|
||||
MGA_TRANSC | \
|
||||
MGA_CLIPDIS)
|
||||
|
||||
#define MGA_DWGCTL_COPY (MGA_OPCOD_BITBLT | \
|
||||
MGA_ATYPE_RPL | \
|
||||
MGA_SGNZERO | \
|
||||
MGA_SHIFTZERO | \
|
||||
MGA_BOP_SRC | \
|
||||
(0 << MGA_TRANS_SHIFT) | \
|
||||
MGA_BLTMOD_BFCOL | \
|
||||
MGA_CLIPDIS)
|
||||
|
||||
/* Simple idle test.
|
||||
*/
|
||||
static __inline__ int mga_is_idle( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
u32 status = MGA_READ( MGA_STATUS ) & MGA_ENGINE_IDLE_MASK;
|
||||
return ( status == MGA_ENDPRDMASTS );
|
||||
}
|
||||
|
||||
#endif
|
||||
1078
shared-core/mga_state.c
Normal file
1078
shared-core/mga_state.c
Normal file
File diff suppressed because it is too large
Load diff
11645
shared-core/mga_ucode.h
Normal file
11645
shared-core/mga_ucode.h
Normal file
File diff suppressed because it is too large
Load diff
212
shared-core/mga_warp.c
Normal file
212
shared-core/mga_warp.c
Normal file
|
|
@ -0,0 +1,212 @@
|
|||
/* mga_warp.c -- Matrox G200/G400 WARP engine management -*- linux-c -*-
|
||||
* Created: Thu Jan 11 21:29:32 2001 by gareth@valinux.com
|
||||
*
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS 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.
|
||||
*
|
||||
* Authors:
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#define __NO_VERSION__
|
||||
#include "mga.h"
|
||||
#include "drmP.h"
|
||||
#include "drm.h"
|
||||
#include "mga_drm.h"
|
||||
#include "mga_drv.h"
|
||||
#include "mga_ucode.h"
|
||||
|
||||
|
||||
#define MGA_WARP_CODE_ALIGN 256 /* in bytes */
|
||||
|
||||
#define WARP_UCODE_SIZE( which ) \
|
||||
((sizeof(which) / MGA_WARP_CODE_ALIGN + 1) * MGA_WARP_CODE_ALIGN)
|
||||
|
||||
#define WARP_UCODE_INSTALL( which, where ) \
|
||||
do { \
|
||||
DRM_DEBUG( " pcbase = 0x%08lx vcbase = %p\n", pcbase, vcbase );\
|
||||
dev_priv->warp_pipe_phys[where] = pcbase; \
|
||||
memcpy( vcbase, which, sizeof(which) ); \
|
||||
pcbase += WARP_UCODE_SIZE( which ); \
|
||||
vcbase += WARP_UCODE_SIZE( which ); \
|
||||
} while (0)
|
||||
|
||||
|
||||
static unsigned int mga_warp_g400_microcode_size( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
unsigned int size;
|
||||
|
||||
size = ( WARP_UCODE_SIZE( warp_g400_tgz ) +
|
||||
WARP_UCODE_SIZE( warp_g400_tgza ) +
|
||||
WARP_UCODE_SIZE( warp_g400_tgzaf ) +
|
||||
WARP_UCODE_SIZE( warp_g400_tgzf ) +
|
||||
WARP_UCODE_SIZE( warp_g400_tgzs ) +
|
||||
WARP_UCODE_SIZE( warp_g400_tgzsa ) +
|
||||
WARP_UCODE_SIZE( warp_g400_tgzsaf ) +
|
||||
WARP_UCODE_SIZE( warp_g400_tgzsf ) +
|
||||
WARP_UCODE_SIZE( warp_g400_t2gz ) +
|
||||
WARP_UCODE_SIZE( warp_g400_t2gza ) +
|
||||
WARP_UCODE_SIZE( warp_g400_t2gzaf ) +
|
||||
WARP_UCODE_SIZE( warp_g400_t2gzf ) +
|
||||
WARP_UCODE_SIZE( warp_g400_t2gzs ) +
|
||||
WARP_UCODE_SIZE( warp_g400_t2gzsa ) +
|
||||
WARP_UCODE_SIZE( warp_g400_t2gzsaf ) +
|
||||
WARP_UCODE_SIZE( warp_g400_t2gzsf ) );
|
||||
|
||||
size = PAGE_ALIGN( size );
|
||||
|
||||
DRM_DEBUG( "G400 ucode size = %d bytes\n", size );
|
||||
return size;
|
||||
}
|
||||
|
||||
static unsigned int mga_warp_g200_microcode_size( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
unsigned int size;
|
||||
|
||||
size = ( WARP_UCODE_SIZE( warp_g200_tgz ) +
|
||||
WARP_UCODE_SIZE( warp_g200_tgza ) +
|
||||
WARP_UCODE_SIZE( warp_g200_tgzaf ) +
|
||||
WARP_UCODE_SIZE( warp_g200_tgzf ) +
|
||||
WARP_UCODE_SIZE( warp_g200_tgzs ) +
|
||||
WARP_UCODE_SIZE( warp_g200_tgzsa ) +
|
||||
WARP_UCODE_SIZE( warp_g200_tgzsaf ) +
|
||||
WARP_UCODE_SIZE( warp_g200_tgzsf ) );
|
||||
|
||||
size = PAGE_ALIGN( size );
|
||||
|
||||
DRM_DEBUG( "G200 ucode size = %d bytes\n", size );
|
||||
return size;
|
||||
}
|
||||
|
||||
static int mga_warp_install_g400_microcode( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
unsigned char *vcbase = dev_priv->warp->handle;
|
||||
unsigned long pcbase = dev_priv->warp->offset;
|
||||
unsigned int size;
|
||||
|
||||
size = mga_warp_g400_microcode_size( dev_priv );
|
||||
if ( size > dev_priv->warp->size ) {
|
||||
DRM_ERROR( "microcode too large! (%u > %lu)\n",
|
||||
size, dev_priv->warp->size );
|
||||
return DRM_ERR(ENOMEM);
|
||||
}
|
||||
|
||||
memset( dev_priv->warp_pipe_phys, 0,
|
||||
sizeof(dev_priv->warp_pipe_phys) );
|
||||
|
||||
WARP_UCODE_INSTALL( warp_g400_tgz, MGA_WARP_TGZ );
|
||||
WARP_UCODE_INSTALL( warp_g400_tgzf, MGA_WARP_TGZF );
|
||||
WARP_UCODE_INSTALL( warp_g400_tgza, MGA_WARP_TGZA );
|
||||
WARP_UCODE_INSTALL( warp_g400_tgzaf, MGA_WARP_TGZAF );
|
||||
WARP_UCODE_INSTALL( warp_g400_tgzs, MGA_WARP_TGZS );
|
||||
WARP_UCODE_INSTALL( warp_g400_tgzsf, MGA_WARP_TGZSF );
|
||||
WARP_UCODE_INSTALL( warp_g400_tgzsa, MGA_WARP_TGZSA );
|
||||
WARP_UCODE_INSTALL( warp_g400_tgzsaf, MGA_WARP_TGZSAF );
|
||||
|
||||
WARP_UCODE_INSTALL( warp_g400_t2gz, MGA_WARP_T2GZ );
|
||||
WARP_UCODE_INSTALL( warp_g400_t2gzf, MGA_WARP_T2GZF );
|
||||
WARP_UCODE_INSTALL( warp_g400_t2gza, MGA_WARP_T2GZA );
|
||||
WARP_UCODE_INSTALL( warp_g400_t2gzaf, MGA_WARP_T2GZAF );
|
||||
WARP_UCODE_INSTALL( warp_g400_t2gzs, MGA_WARP_T2GZS );
|
||||
WARP_UCODE_INSTALL( warp_g400_t2gzsf, MGA_WARP_T2GZSF );
|
||||
WARP_UCODE_INSTALL( warp_g400_t2gzsa, MGA_WARP_T2GZSA );
|
||||
WARP_UCODE_INSTALL( warp_g400_t2gzsaf, MGA_WARP_T2GZSAF );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mga_warp_install_g200_microcode( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
unsigned char *vcbase = dev_priv->warp->handle;
|
||||
unsigned long pcbase = dev_priv->warp->offset;
|
||||
unsigned int size;
|
||||
|
||||
size = mga_warp_g200_microcode_size( dev_priv );
|
||||
if ( size > dev_priv->warp->size ) {
|
||||
DRM_ERROR( "microcode too large! (%u > %lu)\n",
|
||||
size, dev_priv->warp->size );
|
||||
return DRM_ERR(ENOMEM);
|
||||
}
|
||||
|
||||
memset( dev_priv->warp_pipe_phys, 0,
|
||||
sizeof(dev_priv->warp_pipe_phys) );
|
||||
|
||||
WARP_UCODE_INSTALL( warp_g200_tgz, MGA_WARP_TGZ );
|
||||
WARP_UCODE_INSTALL( warp_g200_tgzf, MGA_WARP_TGZF );
|
||||
WARP_UCODE_INSTALL( warp_g200_tgza, MGA_WARP_TGZA );
|
||||
WARP_UCODE_INSTALL( warp_g200_tgzaf, MGA_WARP_TGZAF );
|
||||
WARP_UCODE_INSTALL( warp_g200_tgzs, MGA_WARP_TGZS );
|
||||
WARP_UCODE_INSTALL( warp_g200_tgzsf, MGA_WARP_TGZSF );
|
||||
WARP_UCODE_INSTALL( warp_g200_tgzsa, MGA_WARP_TGZSA );
|
||||
WARP_UCODE_INSTALL( warp_g200_tgzsaf, MGA_WARP_TGZSAF );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mga_warp_install_microcode( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
switch ( dev_priv->chipset ) {
|
||||
case MGA_CARD_TYPE_G400:
|
||||
return mga_warp_install_g400_microcode( dev_priv );
|
||||
case MGA_CARD_TYPE_G200:
|
||||
return mga_warp_install_g200_microcode( dev_priv );
|
||||
default:
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
}
|
||||
|
||||
#define WMISC_EXPECTED (MGA_WUCODECACHE_ENABLE | MGA_WMASTER_ENABLE)
|
||||
|
||||
int mga_warp_init( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
u32 wmisc;
|
||||
|
||||
/* FIXME: Get rid of these damned magic numbers...
|
||||
*/
|
||||
switch ( dev_priv->chipset ) {
|
||||
case MGA_CARD_TYPE_G400:
|
||||
MGA_WRITE( MGA_WIADDR2, MGA_WMODE_SUSPEND );
|
||||
MGA_WRITE( MGA_WGETMSB, 0x00000E00 );
|
||||
MGA_WRITE( MGA_WVRTXSZ, 0x00001807 );
|
||||
MGA_WRITE( MGA_WACCEPTSEQ, 0x18000000 );
|
||||
break;
|
||||
case MGA_CARD_TYPE_G200:
|
||||
MGA_WRITE( MGA_WIADDR, MGA_WMODE_SUSPEND );
|
||||
MGA_WRITE( MGA_WGETMSB, 0x1606 );
|
||||
MGA_WRITE( MGA_WVRTXSZ, 7 );
|
||||
break;
|
||||
default:
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
|
||||
MGA_WRITE( MGA_WMISC, (MGA_WUCODECACHE_ENABLE |
|
||||
MGA_WMASTER_ENABLE |
|
||||
MGA_WCACHEFLUSH_ENABLE) );
|
||||
wmisc = MGA_READ( MGA_WMISC );
|
||||
if ( wmisc != WMISC_EXPECTED ) {
|
||||
DRM_ERROR( "WARP engine config failed! 0x%x != 0x%x\n",
|
||||
wmisc, WMISC_EXPECTED );
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
1010
shared-core/r128_cce.c
Normal file
1010
shared-core/r128_cce.c
Normal file
File diff suppressed because it is too large
Load diff
308
shared-core/r128_drm.h
Normal file
308
shared-core/r128_drm.h
Normal file
|
|
@ -0,0 +1,308 @@
|
|||
/* r128_drm.h -- Public header for the r128 driver -*- linux-c -*-
|
||||
* Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com
|
||||
*
|
||||
* Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PRECISION INSIGHT 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.
|
||||
*
|
||||
* Authors:
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
* Kevin E. Martin <martin@valinux.com>
|
||||
*/
|
||||
|
||||
#ifndef __R128_DRM_H__
|
||||
#define __R128_DRM_H__
|
||||
|
||||
/* WARNING: If you change any of these defines, make sure to change the
|
||||
* defines in the X server file (r128_sarea.h)
|
||||
*/
|
||||
#ifndef __R128_SAREA_DEFINES__
|
||||
#define __R128_SAREA_DEFINES__
|
||||
|
||||
/* What needs to be changed for the current vertex buffer?
|
||||
*/
|
||||
#define R128_UPLOAD_CONTEXT 0x001
|
||||
#define R128_UPLOAD_SETUP 0x002
|
||||
#define R128_UPLOAD_TEX0 0x004
|
||||
#define R128_UPLOAD_TEX1 0x008
|
||||
#define R128_UPLOAD_TEX0IMAGES 0x010
|
||||
#define R128_UPLOAD_TEX1IMAGES 0x020
|
||||
#define R128_UPLOAD_CORE 0x040
|
||||
#define R128_UPLOAD_MASKS 0x080
|
||||
#define R128_UPLOAD_WINDOW 0x100
|
||||
#define R128_UPLOAD_CLIPRECTS 0x200 /* handled client-side */
|
||||
#define R128_REQUIRE_QUIESCENCE 0x400
|
||||
#define R128_UPLOAD_ALL 0x7ff
|
||||
|
||||
#define R128_FRONT 0x1
|
||||
#define R128_BACK 0x2
|
||||
#define R128_DEPTH 0x4
|
||||
|
||||
/* Primitive types
|
||||
*/
|
||||
#define R128_POINTS 0x1
|
||||
#define R128_LINES 0x2
|
||||
#define R128_LINE_STRIP 0x3
|
||||
#define R128_TRIANGLES 0x4
|
||||
#define R128_TRIANGLE_FAN 0x5
|
||||
#define R128_TRIANGLE_STRIP 0x6
|
||||
|
||||
/* Vertex/indirect buffer size
|
||||
*/
|
||||
#define R128_BUFFER_SIZE 16384
|
||||
|
||||
/* Byte offsets for indirect buffer data
|
||||
*/
|
||||
#define R128_INDEX_PRIM_OFFSET 20
|
||||
#define R128_HOSTDATA_BLIT_OFFSET 32
|
||||
|
||||
/* Keep these small for testing.
|
||||
*/
|
||||
#define R128_NR_SAREA_CLIPRECTS 12
|
||||
|
||||
/* There are 2 heaps (local/AGP). Each region within a heap is a
|
||||
* minimum of 64k, and there are at most 64 of them per heap.
|
||||
*/
|
||||
#define R128_LOCAL_TEX_HEAP 0
|
||||
#define R128_AGP_TEX_HEAP 1
|
||||
#define R128_NR_TEX_HEAPS 2
|
||||
#define R128_NR_TEX_REGIONS 64
|
||||
#define R128_LOG_TEX_GRANULARITY 16
|
||||
|
||||
#define R128_NR_CONTEXT_REGS 12
|
||||
|
||||
#define R128_MAX_TEXTURE_LEVELS 11
|
||||
#define R128_MAX_TEXTURE_UNITS 2
|
||||
|
||||
#endif /* __R128_SAREA_DEFINES__ */
|
||||
|
||||
typedef struct {
|
||||
/* Context state - can be written in one large chunk */
|
||||
unsigned int dst_pitch_offset_c;
|
||||
unsigned int dp_gui_master_cntl_c;
|
||||
unsigned int sc_top_left_c;
|
||||
unsigned int sc_bottom_right_c;
|
||||
unsigned int z_offset_c;
|
||||
unsigned int z_pitch_c;
|
||||
unsigned int z_sten_cntl_c;
|
||||
unsigned int tex_cntl_c;
|
||||
unsigned int misc_3d_state_cntl_reg;
|
||||
unsigned int texture_clr_cmp_clr_c;
|
||||
unsigned int texture_clr_cmp_msk_c;
|
||||
unsigned int fog_color_c;
|
||||
|
||||
/* Texture state */
|
||||
unsigned int tex_size_pitch_c;
|
||||
unsigned int constant_color_c;
|
||||
|
||||
/* Setup state */
|
||||
unsigned int pm4_vc_fpu_setup;
|
||||
unsigned int setup_cntl;
|
||||
|
||||
/* Mask state */
|
||||
unsigned int dp_write_mask;
|
||||
unsigned int sten_ref_mask_c;
|
||||
unsigned int plane_3d_mask_c;
|
||||
|
||||
/* Window state */
|
||||
unsigned int window_xy_offset;
|
||||
|
||||
/* Core state */
|
||||
unsigned int scale_3d_cntl;
|
||||
} drm_r128_context_regs_t;
|
||||
|
||||
/* Setup registers for each texture unit
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int tex_cntl;
|
||||
unsigned int tex_combine_cntl;
|
||||
unsigned int tex_size_pitch;
|
||||
unsigned int tex_offset[R128_MAX_TEXTURE_LEVELS];
|
||||
unsigned int tex_border_color;
|
||||
} drm_r128_texture_regs_t;
|
||||
|
||||
|
||||
typedef struct drm_r128_sarea {
|
||||
/* The channel for communication of state information to the kernel
|
||||
* on firing a vertex buffer.
|
||||
*/
|
||||
drm_r128_context_regs_t context_state;
|
||||
drm_r128_texture_regs_t tex_state[R128_MAX_TEXTURE_UNITS];
|
||||
unsigned int dirty;
|
||||
unsigned int vertsize;
|
||||
unsigned int vc_format;
|
||||
|
||||
/* The current cliprects, or a subset thereof.
|
||||
*/
|
||||
drm_clip_rect_t boxes[R128_NR_SAREA_CLIPRECTS];
|
||||
unsigned int nbox;
|
||||
|
||||
/* Counters for client-side throttling of rendering clients.
|
||||
*/
|
||||
unsigned int last_frame;
|
||||
unsigned int last_dispatch;
|
||||
|
||||
drm_tex_region_t tex_list[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS+1];
|
||||
int tex_age[R128_NR_TEX_HEAPS];
|
||||
int ctx_owner;
|
||||
} drm_r128_sarea_t;
|
||||
|
||||
|
||||
/* WARNING: If you change any of these defines, make sure to change the
|
||||
* defines in the Xserver file (xf86drmR128.h)
|
||||
*/
|
||||
|
||||
/* Rage 128 specific ioctls
|
||||
* The device specific ioctl range is 0x40 to 0x79.
|
||||
*/
|
||||
#define DRM_IOCTL_R128_INIT DRM_IOW( 0x40, drm_r128_init_t)
|
||||
#define DRM_IOCTL_R128_CCE_START DRM_IO( 0x41)
|
||||
#define DRM_IOCTL_R128_CCE_STOP DRM_IOW( 0x42, drm_r128_cce_stop_t)
|
||||
#define DRM_IOCTL_R128_CCE_RESET DRM_IO( 0x43)
|
||||
#define DRM_IOCTL_R128_CCE_IDLE DRM_IO( 0x44)
|
||||
#define DRM_IOCTL_R128_RESET DRM_IO( 0x46)
|
||||
#define DRM_IOCTL_R128_SWAP DRM_IO( 0x47)
|
||||
#define DRM_IOCTL_R128_CLEAR DRM_IOW( 0x48, drm_r128_clear_t)
|
||||
#define DRM_IOCTL_R128_VERTEX DRM_IOW( 0x49, drm_r128_vertex_t)
|
||||
#define DRM_IOCTL_R128_INDICES DRM_IOW( 0x4a, drm_r128_indices_t)
|
||||
#define DRM_IOCTL_R128_BLIT DRM_IOW( 0x4b, drm_r128_blit_t)
|
||||
#define DRM_IOCTL_R128_DEPTH DRM_IOW( 0x4c, drm_r128_depth_t)
|
||||
#define DRM_IOCTL_R128_STIPPLE DRM_IOW( 0x4d, drm_r128_stipple_t)
|
||||
#define DRM_IOCTL_R128_INDIRECT DRM_IOWR(0x4f, drm_r128_indirect_t)
|
||||
#define DRM_IOCTL_R128_FULLSCREEN DRM_IOW( 0x50, drm_r128_fullscreen_t)
|
||||
#define DRM_IOCTL_R128_CLEAR2 DRM_IOW( 0x51, drm_r128_clear2_t)
|
||||
|
||||
typedef struct drm_r128_init {
|
||||
enum {
|
||||
R128_INIT_CCE = 0x01,
|
||||
R128_CLEANUP_CCE = 0x02
|
||||
} func;
|
||||
#if CONFIG_XFREE86_VERSION < XFREE86_VERSION(4,1,0,0)
|
||||
int sarea_priv_offset;
|
||||
#else
|
||||
unsigned long sarea_priv_offset;
|
||||
#endif
|
||||
int is_pci;
|
||||
int cce_mode;
|
||||
int cce_secure;
|
||||
int ring_size;
|
||||
int usec_timeout;
|
||||
|
||||
unsigned int fb_bpp;
|
||||
unsigned int front_offset, front_pitch;
|
||||
unsigned int back_offset, back_pitch;
|
||||
unsigned int depth_bpp;
|
||||
unsigned int depth_offset, depth_pitch;
|
||||
unsigned int span_offset;
|
||||
|
||||
#if CONFIG_XFREE86_VERSION < XFREE86_VERSION(4,1,0,0)
|
||||
unsigned int fb_offset;
|
||||
unsigned int mmio_offset;
|
||||
unsigned int ring_offset;
|
||||
unsigned int ring_rptr_offset;
|
||||
unsigned int buffers_offset;
|
||||
unsigned int agp_textures_offset;
|
||||
#else
|
||||
unsigned long fb_offset;
|
||||
unsigned long mmio_offset;
|
||||
unsigned long ring_offset;
|
||||
unsigned long ring_rptr_offset;
|
||||
unsigned long buffers_offset;
|
||||
unsigned long agp_textures_offset;
|
||||
#endif
|
||||
} drm_r128_init_t;
|
||||
|
||||
typedef struct drm_r128_cce_stop {
|
||||
int flush;
|
||||
int idle;
|
||||
} drm_r128_cce_stop_t;
|
||||
|
||||
typedef struct drm_r128_clear {
|
||||
unsigned int flags;
|
||||
#if CONFIG_XFREE86_VERSION < XFREE86_VERSION(4,1,0,0)
|
||||
int x, y, w, h;
|
||||
#endif
|
||||
unsigned int clear_color;
|
||||
unsigned int clear_depth;
|
||||
#if CONFIG_XFREE86_VERSION >= XFREE86_VERSION(4,1,0,0)
|
||||
unsigned int color_mask;
|
||||
unsigned int depth_mask;
|
||||
#endif
|
||||
} drm_r128_clear_t;
|
||||
|
||||
typedef struct drm_r128_vertex {
|
||||
int prim;
|
||||
int idx; /* Index of vertex buffer */
|
||||
int count; /* Number of vertices in buffer */
|
||||
int discard; /* Client finished with buffer? */
|
||||
} drm_r128_vertex_t;
|
||||
|
||||
typedef struct drm_r128_indices {
|
||||
int prim;
|
||||
int idx;
|
||||
int start;
|
||||
int end;
|
||||
int discard; /* Client finished with buffer? */
|
||||
} drm_r128_indices_t;
|
||||
|
||||
typedef struct drm_r128_blit {
|
||||
int idx;
|
||||
int pitch;
|
||||
int offset;
|
||||
int format;
|
||||
unsigned short x, y;
|
||||
unsigned short width, height;
|
||||
} drm_r128_blit_t;
|
||||
|
||||
typedef struct drm_r128_depth {
|
||||
enum {
|
||||
R128_WRITE_SPAN = 0x01,
|
||||
R128_WRITE_PIXELS = 0x02,
|
||||
R128_READ_SPAN = 0x03,
|
||||
R128_READ_PIXELS = 0x04
|
||||
} func;
|
||||
int n;
|
||||
int *x;
|
||||
int *y;
|
||||
unsigned int *buffer;
|
||||
unsigned char *mask;
|
||||
} drm_r128_depth_t;
|
||||
|
||||
typedef struct drm_r128_stipple {
|
||||
unsigned int *mask;
|
||||
} drm_r128_stipple_t;
|
||||
|
||||
typedef struct drm_r128_indirect {
|
||||
int idx;
|
||||
int start;
|
||||
int end;
|
||||
int discard;
|
||||
} drm_r128_indirect_t;
|
||||
|
||||
typedef struct drm_r128_fullscreen {
|
||||
enum {
|
||||
R128_INIT_FULLSCREEN = 0x01,
|
||||
R128_CLEANUP_FULLSCREEN = 0x02
|
||||
} func;
|
||||
} drm_r128_fullscreen_t;
|
||||
|
||||
#endif
|
||||
504
shared-core/r128_drv.h
Normal file
504
shared-core/r128_drv.h
Normal file
|
|
@ -0,0 +1,504 @@
|
|||
/* r128_drv.h -- Private header for r128 driver -*- linux-c -*-
|
||||
* Created: Mon Dec 13 09:51:11 1999 by faith@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PRECISION INSIGHT 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.
|
||||
*
|
||||
* Authors:
|
||||
* Rickard E. (Rik) Faith <faith@valinux.com>
|
||||
* Kevin E. Martin <martin@valinux.com>
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
* Michel Dänzer <daenzerm@student.ethz.ch>
|
||||
*/
|
||||
|
||||
#ifndef __R128_DRV_H__
|
||||
#define __R128_DRV_H__
|
||||
|
||||
#define GET_RING_HEAD(ring) DRM_READ32( (volatile u32 *) (ring)->head )
|
||||
#define SET_RING_HEAD(ring,val) DRM_WRITE32( (volatile u32 *) (ring)->head, (val) )
|
||||
|
||||
typedef struct drm_r128_freelist {
|
||||
unsigned int age;
|
||||
drm_buf_t *buf;
|
||||
struct drm_r128_freelist *next;
|
||||
struct drm_r128_freelist *prev;
|
||||
} drm_r128_freelist_t;
|
||||
|
||||
typedef struct drm_r128_ring_buffer {
|
||||
u32 *start;
|
||||
u32 *end;
|
||||
int size;
|
||||
int size_l2qw;
|
||||
|
||||
volatile u32 *head;
|
||||
u32 tail;
|
||||
u32 tail_mask;
|
||||
int space;
|
||||
|
||||
int high_mark;
|
||||
} drm_r128_ring_buffer_t;
|
||||
|
||||
typedef struct drm_r128_private {
|
||||
drm_r128_ring_buffer_t ring;
|
||||
drm_r128_sarea_t *sarea_priv;
|
||||
|
||||
int cce_mode;
|
||||
int cce_fifo_size;
|
||||
int cce_running;
|
||||
|
||||
drm_r128_freelist_t *head;
|
||||
drm_r128_freelist_t *tail;
|
||||
|
||||
int usec_timeout;
|
||||
int is_pci;
|
||||
unsigned long phys_pci_gart;
|
||||
dma_addr_t bus_pci_gart;
|
||||
unsigned long cce_buffers_offset;
|
||||
|
||||
atomic_t idle_count;
|
||||
|
||||
int page_flipping;
|
||||
int current_page;
|
||||
u32 crtc_offset;
|
||||
u32 crtc_offset_cntl;
|
||||
|
||||
u32 color_fmt;
|
||||
unsigned int front_offset;
|
||||
unsigned int front_pitch;
|
||||
unsigned int back_offset;
|
||||
unsigned int back_pitch;
|
||||
|
||||
u32 depth_fmt;
|
||||
unsigned int depth_offset;
|
||||
unsigned int depth_pitch;
|
||||
unsigned int span_offset;
|
||||
|
||||
u32 front_pitch_offset_c;
|
||||
u32 back_pitch_offset_c;
|
||||
u32 depth_pitch_offset_c;
|
||||
u32 span_pitch_offset_c;
|
||||
|
||||
drm_map_t *sarea;
|
||||
drm_map_t *fb;
|
||||
drm_map_t *mmio;
|
||||
drm_map_t *cce_ring;
|
||||
drm_map_t *ring_rptr;
|
||||
drm_map_t *buffers;
|
||||
drm_map_t *agp_textures;
|
||||
} drm_r128_private_t;
|
||||
|
||||
typedef struct drm_r128_buf_priv {
|
||||
u32 age;
|
||||
int prim;
|
||||
int discard;
|
||||
int dispatched;
|
||||
drm_r128_freelist_t *list_entry;
|
||||
} drm_r128_buf_priv_t;
|
||||
|
||||
/* r128_cce.c */
|
||||
extern int r128_cce_init( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_start( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_stop( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_reset( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_idle( DRM_IOCTL_ARGS );
|
||||
extern int r128_engine_reset( DRM_IOCTL_ARGS );
|
||||
extern int r128_fullscreen( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_buffers( DRM_IOCTL_ARGS );
|
||||
|
||||
extern void r128_freelist_reset( drm_device_t *dev );
|
||||
extern drm_buf_t *r128_freelist_get( drm_device_t *dev );
|
||||
|
||||
extern int r128_wait_ring( drm_r128_private_t *dev_priv, int n );
|
||||
|
||||
static __inline__ void
|
||||
r128_update_ring_snapshot( drm_r128_ring_buffer_t *ring )
|
||||
{
|
||||
ring->space = (GET_RING_HEAD( ring ) - ring->tail) * sizeof(u32);
|
||||
if ( ring->space <= 0 )
|
||||
ring->space += ring->size;
|
||||
}
|
||||
|
||||
extern int r128_do_cce_idle( drm_r128_private_t *dev_priv );
|
||||
extern int r128_do_cleanup_cce( drm_device_t *dev );
|
||||
extern int r128_do_cleanup_pageflip( drm_device_t *dev );
|
||||
|
||||
/* r128_state.c */
|
||||
extern int r128_cce_clear( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_swap( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_vertex( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_indices( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_blit( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_depth( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_stipple( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_indirect( DRM_IOCTL_ARGS );
|
||||
|
||||
|
||||
/* Register definitions, register access macros and drmAddMap constants
|
||||
* for Rage 128 kernel driver.
|
||||
*/
|
||||
|
||||
#define R128_AUX_SC_CNTL 0x1660
|
||||
# define R128_AUX1_SC_EN (1 << 0)
|
||||
# define R128_AUX1_SC_MODE_OR (0 << 1)
|
||||
# define R128_AUX1_SC_MODE_NAND (1 << 1)
|
||||
# define R128_AUX2_SC_EN (1 << 2)
|
||||
# define R128_AUX2_SC_MODE_OR (0 << 3)
|
||||
# define R128_AUX2_SC_MODE_NAND (1 << 3)
|
||||
# define R128_AUX3_SC_EN (1 << 4)
|
||||
# define R128_AUX3_SC_MODE_OR (0 << 5)
|
||||
# define R128_AUX3_SC_MODE_NAND (1 << 5)
|
||||
#define R128_AUX1_SC_LEFT 0x1664
|
||||
#define R128_AUX1_SC_RIGHT 0x1668
|
||||
#define R128_AUX1_SC_TOP 0x166c
|
||||
#define R128_AUX1_SC_BOTTOM 0x1670
|
||||
#define R128_AUX2_SC_LEFT 0x1674
|
||||
#define R128_AUX2_SC_RIGHT 0x1678
|
||||
#define R128_AUX2_SC_TOP 0x167c
|
||||
#define R128_AUX2_SC_BOTTOM 0x1680
|
||||
#define R128_AUX3_SC_LEFT 0x1684
|
||||
#define R128_AUX3_SC_RIGHT 0x1688
|
||||
#define R128_AUX3_SC_TOP 0x168c
|
||||
#define R128_AUX3_SC_BOTTOM 0x1690
|
||||
|
||||
#define R128_BRUSH_DATA0 0x1480
|
||||
#define R128_BUS_CNTL 0x0030
|
||||
# define R128_BUS_MASTER_DIS (1 << 6)
|
||||
|
||||
#define R128_CLOCK_CNTL_INDEX 0x0008
|
||||
#define R128_CLOCK_CNTL_DATA 0x000c
|
||||
# define R128_PLL_WR_EN (1 << 7)
|
||||
#define R128_CONSTANT_COLOR_C 0x1d34
|
||||
#define R128_CRTC_OFFSET 0x0224
|
||||
#define R128_CRTC_OFFSET_CNTL 0x0228
|
||||
# define R128_CRTC_OFFSET_FLIP_CNTL (1 << 16)
|
||||
|
||||
#define R128_DP_GUI_MASTER_CNTL 0x146c
|
||||
# define R128_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0)
|
||||
# define R128_GMC_DST_PITCH_OFFSET_CNTL (1 << 1)
|
||||
# define R128_GMC_BRUSH_SOLID_COLOR (13 << 4)
|
||||
# define R128_GMC_BRUSH_NONE (15 << 4)
|
||||
# define R128_GMC_DST_16BPP (4 << 8)
|
||||
# define R128_GMC_DST_24BPP (5 << 8)
|
||||
# define R128_GMC_DST_32BPP (6 << 8)
|
||||
# define R128_GMC_DST_DATATYPE_SHIFT 8
|
||||
# define R128_GMC_SRC_DATATYPE_COLOR (3 << 12)
|
||||
# define R128_DP_SRC_SOURCE_MEMORY (2 << 24)
|
||||
# define R128_DP_SRC_SOURCE_HOST_DATA (3 << 24)
|
||||
# define R128_GMC_CLR_CMP_CNTL_DIS (1 << 28)
|
||||
# define R128_GMC_AUX_CLIP_DIS (1 << 29)
|
||||
# define R128_GMC_WR_MSK_DIS (1 << 30)
|
||||
# define R128_ROP3_S 0x00cc0000
|
||||
# define R128_ROP3_P 0x00f00000
|
||||
#define R128_DP_WRITE_MASK 0x16cc
|
||||
#define R128_DST_PITCH_OFFSET_C 0x1c80
|
||||
# define R128_DST_TILE (1 << 31)
|
||||
|
||||
#define R128_GEN_RESET_CNTL 0x00f0
|
||||
# define R128_SOFT_RESET_GUI (1 << 0)
|
||||
|
||||
#define R128_GUI_SCRATCH_REG0 0x15e0
|
||||
#define R128_GUI_SCRATCH_REG1 0x15e4
|
||||
#define R128_GUI_SCRATCH_REG2 0x15e8
|
||||
#define R128_GUI_SCRATCH_REG3 0x15ec
|
||||
#define R128_GUI_SCRATCH_REG4 0x15f0
|
||||
#define R128_GUI_SCRATCH_REG5 0x15f4
|
||||
|
||||
#define R128_GUI_STAT 0x1740
|
||||
# define R128_GUI_FIFOCNT_MASK 0x0fff
|
||||
# define R128_GUI_ACTIVE (1 << 31)
|
||||
|
||||
#define R128_MCLK_CNTL 0x000f
|
||||
# define R128_FORCE_GCP (1 << 16)
|
||||
# define R128_FORCE_PIPE3D_CP (1 << 17)
|
||||
# define R128_FORCE_RCP (1 << 18)
|
||||
|
||||
#define R128_PC_GUI_CTLSTAT 0x1748
|
||||
#define R128_PC_NGUI_CTLSTAT 0x0184
|
||||
# define R128_PC_FLUSH_GUI (3 << 0)
|
||||
# define R128_PC_RI_GUI (1 << 2)
|
||||
# define R128_PC_FLUSH_ALL 0x00ff
|
||||
# define R128_PC_BUSY (1 << 31)
|
||||
|
||||
#define R128_PCI_GART_PAGE 0x017c
|
||||
#define R128_PRIM_TEX_CNTL_C 0x1cb0
|
||||
|
||||
#define R128_SCALE_3D_CNTL 0x1a00
|
||||
#define R128_SEC_TEX_CNTL_C 0x1d00
|
||||
#define R128_SEC_TEXTURE_BORDER_COLOR_C 0x1d3c
|
||||
#define R128_SETUP_CNTL 0x1bc4
|
||||
#define R128_STEN_REF_MASK_C 0x1d40
|
||||
|
||||
#define R128_TEX_CNTL_C 0x1c9c
|
||||
# define R128_TEX_CACHE_FLUSH (1 << 23)
|
||||
|
||||
#define R128_WAIT_UNTIL 0x1720
|
||||
# define R128_EVENT_CRTC_OFFSET (1 << 0)
|
||||
#define R128_WINDOW_XY_OFFSET 0x1bcc
|
||||
|
||||
|
||||
/* CCE registers
|
||||
*/
|
||||
#define R128_PM4_BUFFER_OFFSET 0x0700
|
||||
#define R128_PM4_BUFFER_CNTL 0x0704
|
||||
# define R128_PM4_MASK (15 << 28)
|
||||
# define R128_PM4_NONPM4 (0 << 28)
|
||||
# define R128_PM4_192PIO (1 << 28)
|
||||
# define R128_PM4_192BM (2 << 28)
|
||||
# define R128_PM4_128PIO_64INDBM (3 << 28)
|
||||
# define R128_PM4_128BM_64INDBM (4 << 28)
|
||||
# define R128_PM4_64PIO_128INDBM (5 << 28)
|
||||
# define R128_PM4_64BM_128INDBM (6 << 28)
|
||||
# define R128_PM4_64PIO_64VCBM_64INDBM (7 << 28)
|
||||
# define R128_PM4_64BM_64VCBM_64INDBM (8 << 28)
|
||||
# define R128_PM4_64PIO_64VCPIO_64INDPIO (15 << 28)
|
||||
|
||||
#define R128_PM4_BUFFER_WM_CNTL 0x0708
|
||||
# define R128_WMA_SHIFT 0
|
||||
# define R128_WMB_SHIFT 8
|
||||
# define R128_WMC_SHIFT 16
|
||||
# define R128_WB_WM_SHIFT 24
|
||||
|
||||
#define R128_PM4_BUFFER_DL_RPTR_ADDR 0x070c
|
||||
#define R128_PM4_BUFFER_DL_RPTR 0x0710
|
||||
#define R128_PM4_BUFFER_DL_WPTR 0x0714
|
||||
# define R128_PM4_BUFFER_DL_DONE (1 << 31)
|
||||
|
||||
#define R128_PM4_VC_FPU_SETUP 0x071c
|
||||
|
||||
#define R128_PM4_IW_INDOFF 0x0738
|
||||
#define R128_PM4_IW_INDSIZE 0x073c
|
||||
|
||||
#define R128_PM4_STAT 0x07b8
|
||||
# define R128_PM4_FIFOCNT_MASK 0x0fff
|
||||
# define R128_PM4_BUSY (1 << 16)
|
||||
# define R128_PM4_GUI_ACTIVE (1 << 31)
|
||||
|
||||
#define R128_PM4_MICROCODE_ADDR 0x07d4
|
||||
#define R128_PM4_MICROCODE_RADDR 0x07d8
|
||||
#define R128_PM4_MICROCODE_DATAH 0x07dc
|
||||
#define R128_PM4_MICROCODE_DATAL 0x07e0
|
||||
|
||||
#define R128_PM4_BUFFER_ADDR 0x07f0
|
||||
#define R128_PM4_MICRO_CNTL 0x07fc
|
||||
# define R128_PM4_MICRO_FREERUN (1 << 30)
|
||||
|
||||
#define R128_PM4_FIFO_DATA_EVEN 0x1000
|
||||
#define R128_PM4_FIFO_DATA_ODD 0x1004
|
||||
|
||||
|
||||
/* CCE command packets
|
||||
*/
|
||||
#define R128_CCE_PACKET0 0x00000000
|
||||
#define R128_CCE_PACKET1 0x40000000
|
||||
#define R128_CCE_PACKET2 0x80000000
|
||||
#define R128_CCE_PACKET3 0xC0000000
|
||||
# define R128_CNTL_HOSTDATA_BLT 0x00009400
|
||||
# define R128_CNTL_PAINT_MULTI 0x00009A00
|
||||
# define R128_CNTL_BITBLT_MULTI 0x00009B00
|
||||
# define R128_3D_RNDR_GEN_INDX_PRIM 0x00002300
|
||||
|
||||
#define R128_CCE_PACKET_MASK 0xC0000000
|
||||
#define R128_CCE_PACKET_COUNT_MASK 0x3fff0000
|
||||
#define R128_CCE_PACKET0_REG_MASK 0x000007ff
|
||||
#define R128_CCE_PACKET1_REG0_MASK 0x000007ff
|
||||
#define R128_CCE_PACKET1_REG1_MASK 0x003ff800
|
||||
|
||||
#define R128_CCE_VC_CNTL_PRIM_TYPE_NONE 0x00000000
|
||||
#define R128_CCE_VC_CNTL_PRIM_TYPE_POINT 0x00000001
|
||||
#define R128_CCE_VC_CNTL_PRIM_TYPE_LINE 0x00000002
|
||||
#define R128_CCE_VC_CNTL_PRIM_TYPE_POLY_LINE 0x00000003
|
||||
#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST 0x00000004
|
||||
#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN 0x00000005
|
||||
#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_STRIP 0x00000006
|
||||
#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2 0x00000007
|
||||
#define R128_CCE_VC_CNTL_PRIM_WALK_IND 0x00000010
|
||||
#define R128_CCE_VC_CNTL_PRIM_WALK_LIST 0x00000020
|
||||
#define R128_CCE_VC_CNTL_PRIM_WALK_RING 0x00000030
|
||||
#define R128_CCE_VC_CNTL_NUM_SHIFT 16
|
||||
|
||||
#define R128_DATATYPE_CI8 2
|
||||
#define R128_DATATYPE_ARGB1555 3
|
||||
#define R128_DATATYPE_RGB565 4
|
||||
#define R128_DATATYPE_RGB888 5
|
||||
#define R128_DATATYPE_ARGB8888 6
|
||||
#define R128_DATATYPE_RGB332 7
|
||||
#define R128_DATATYPE_RGB8 9
|
||||
#define R128_DATATYPE_ARGB4444 15
|
||||
|
||||
/* Constants */
|
||||
#define R128_AGP_OFFSET 0x02000000
|
||||
|
||||
#define R128_WATERMARK_L 16
|
||||
#define R128_WATERMARK_M 8
|
||||
#define R128_WATERMARK_N 8
|
||||
#define R128_WATERMARK_K 128
|
||||
|
||||
#define R128_MAX_USEC_TIMEOUT 100000 /* 100 ms */
|
||||
|
||||
#define R128_LAST_FRAME_REG R128_GUI_SCRATCH_REG0
|
||||
#define R128_LAST_DISPATCH_REG R128_GUI_SCRATCH_REG1
|
||||
#define R128_MAX_VB_AGE 0x7fffffff
|
||||
#define R128_MAX_VB_VERTS (0xffff)
|
||||
|
||||
#define R128_RING_HIGH_MARK 128
|
||||
|
||||
#define R128_PERFORMANCE_BOXES 0
|
||||
|
||||
|
||||
#define R128_BASE(reg) ((unsigned long)(dev_priv->mmio->handle))
|
||||
#define R128_ADDR(reg) (R128_BASE( reg ) + reg)
|
||||
|
||||
#define R128_READ(reg) DRM_READ32( (volatile u32 *) R128_ADDR(reg) )
|
||||
#define R128_WRITE(reg,val) DRM_WRITE32( (volatile u32 *) R128_ADDR(reg), (val) )
|
||||
|
||||
#define R128_READ8(reg) DRM_READ8( (volatile u8 *) R128_ADDR(reg) )
|
||||
#define R128_WRITE8(reg,val) DRM_WRITE8( (volatile u8 *) R128_ADDR(reg), (val) )
|
||||
|
||||
#define R128_WRITE_PLL(addr,val) \
|
||||
do { \
|
||||
R128_WRITE8(R128_CLOCK_CNTL_INDEX, \
|
||||
((addr) & 0x1f) | R128_PLL_WR_EN); \
|
||||
R128_WRITE(R128_CLOCK_CNTL_DATA, (val)); \
|
||||
} while (0)
|
||||
|
||||
extern int R128_READ_PLL(drm_device_t *dev, int addr);
|
||||
|
||||
|
||||
#define CCE_PACKET0( reg, n ) (R128_CCE_PACKET0 | \
|
||||
((n) << 16) | ((reg) >> 2))
|
||||
#define CCE_PACKET1( reg0, reg1 ) (R128_CCE_PACKET1 | \
|
||||
(((reg1) >> 2) << 11) | ((reg0) >> 2))
|
||||
#define CCE_PACKET2() (R128_CCE_PACKET2)
|
||||
#define CCE_PACKET3( pkt, n ) (R128_CCE_PACKET3 | \
|
||||
(pkt) | ((n) << 16))
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Misc helper macros
|
||||
*/
|
||||
|
||||
#define LOCK_TEST_WITH_RETURN( dev ) \
|
||||
do { \
|
||||
if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
|
||||
dev->lock.pid != DRM_CURRENTPID ) { \
|
||||
DRM_ERROR( "%s called without lock held\n", __func__ ); \
|
||||
return DRM_ERR(EINVAL); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define RING_SPACE_TEST_WITH_RETURN( dev_priv ) \
|
||||
do { \
|
||||
drm_r128_ring_buffer_t *ring = &dev_priv->ring; int i; \
|
||||
if ( ring->space < ring->high_mark ) { \
|
||||
for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) { \
|
||||
r128_update_ring_snapshot( ring ); \
|
||||
if ( ring->space >= ring->high_mark ) \
|
||||
goto __ring_space_done; \
|
||||
DRM_UDELAY(1); \
|
||||
} \
|
||||
DRM_ERROR( "ring space check failed!\n" ); \
|
||||
return DRM_ERR(EBUSY); \
|
||||
} \
|
||||
__ring_space_done: \
|
||||
; \
|
||||
} while (0)
|
||||
|
||||
#define VB_AGE_TEST_WITH_RETURN( dev_priv ) \
|
||||
do { \
|
||||
drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; \
|
||||
if ( sarea_priv->last_dispatch >= R128_MAX_VB_AGE ) { \
|
||||
int __ret = r128_do_cce_idle( dev_priv ); \
|
||||
if ( __ret ) return __ret; \
|
||||
sarea_priv->last_dispatch = 0; \
|
||||
r128_freelist_reset( dev ); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define R128_WAIT_UNTIL_PAGE_FLIPPED() do { \
|
||||
OUT_RING( CCE_PACKET0( R128_WAIT_UNTIL, 0 ) ); \
|
||||
OUT_RING( R128_EVENT_CRTC_OFFSET ); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Ring control
|
||||
*/
|
||||
|
||||
#if defined(__powerpc__)
|
||||
#define r128_flush_write_combine() (void) GET_RING_HEAD( &dev_priv->ring )
|
||||
#else
|
||||
#define r128_flush_write_combine() DRM_WRITEMEMORYBARRIER()
|
||||
#endif
|
||||
|
||||
|
||||
#define R128_VERBOSE 0
|
||||
|
||||
#define RING_LOCALS \
|
||||
int write; unsigned int tail_mask; volatile u32 *ring;
|
||||
|
||||
#define BEGIN_RING( n ) do { \
|
||||
if ( R128_VERBOSE ) { \
|
||||
DRM_INFO( "BEGIN_RING( %d ) in %s\n", \
|
||||
(n), __func__ ); \
|
||||
} \
|
||||
if ( dev_priv->ring.space <= (n) * sizeof(u32) ) { \
|
||||
r128_wait_ring( dev_priv, (n) * sizeof(u32) ); \
|
||||
} \
|
||||
dev_priv->ring.space -= (n) * sizeof(u32); \
|
||||
ring = dev_priv->ring.start; \
|
||||
write = dev_priv->ring.tail; \
|
||||
tail_mask = dev_priv->ring.tail_mask; \
|
||||
} while (0)
|
||||
|
||||
/* You can set this to zero if you want. If the card locks up, you'll
|
||||
* need to keep this set. It works around a bug in early revs of the
|
||||
* Rage 128 chipset, where the CCE would read 32 dwords past the end of
|
||||
* the ring buffer before wrapping around.
|
||||
*/
|
||||
#define R128_BROKEN_CCE 1
|
||||
|
||||
#define ADVANCE_RING() do { \
|
||||
if ( R128_VERBOSE ) { \
|
||||
DRM_INFO( "ADVANCE_RING() wr=0x%06x tail=0x%06x\n", \
|
||||
write, dev_priv->ring.tail ); \
|
||||
} \
|
||||
if ( R128_BROKEN_CCE && write < 32 ) { \
|
||||
memcpy( dev_priv->ring.end, \
|
||||
dev_priv->ring.start, \
|
||||
write * sizeof(u32) ); \
|
||||
} \
|
||||
r128_flush_write_combine(); \
|
||||
dev_priv->ring.tail = write; \
|
||||
R128_WRITE( R128_PM4_BUFFER_DL_WPTR, write ); \
|
||||
} while (0)
|
||||
|
||||
#define OUT_RING( x ) do { \
|
||||
if ( R128_VERBOSE ) { \
|
||||
DRM_INFO( " OUT_RING( 0x%08x ) at 0x%x\n", \
|
||||
(unsigned int)(x), write ); \
|
||||
} \
|
||||
ring[write++] = cpu_to_le32( x ); \
|
||||
write &= tail_mask; \
|
||||
} while (0)
|
||||
|
||||
#endif /* __R128_DRV_H__ */
|
||||
1566
shared-core/r128_state.c
Normal file
1566
shared-core/r128_state.c
Normal file
File diff suppressed because it is too large
Load diff
760
shared-core/radeon_drv.h
Normal file
760
shared-core/radeon_drv.h
Normal file
|
|
@ -0,0 +1,760 @@
|
|||
/* radeon_drv.h -- Private header for radeon driver -*- linux-c -*-
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Fremont, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PRECISION INSIGHT 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.
|
||||
*
|
||||
* Authors:
|
||||
* Kevin E. Martin <martin@valinux.com>
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#ifndef __RADEON_DRV_H__
|
||||
#define __RADEON_DRV_H__
|
||||
|
||||
#define GET_RING_HEAD(ring) DRM_READ32( (volatile u32 *) (ring)->head )
|
||||
#define SET_RING_HEAD(ring,val) DRM_WRITE32( (volatile u32 *) (ring)->head , (val))
|
||||
|
||||
typedef struct drm_radeon_freelist {
|
||||
unsigned int age;
|
||||
drm_buf_t *buf;
|
||||
struct drm_radeon_freelist *next;
|
||||
struct drm_radeon_freelist *prev;
|
||||
} drm_radeon_freelist_t;
|
||||
|
||||
typedef struct drm_radeon_ring_buffer {
|
||||
u32 *start;
|
||||
u32 *end;
|
||||
int size;
|
||||
int size_l2qw;
|
||||
|
||||
volatile u32 *head;
|
||||
u32 tail;
|
||||
u32 tail_mask;
|
||||
int space;
|
||||
|
||||
int high_mark;
|
||||
} drm_radeon_ring_buffer_t;
|
||||
|
||||
typedef struct drm_radeon_depth_clear_t {
|
||||
u32 rb3d_cntl;
|
||||
u32 rb3d_zstencilcntl;
|
||||
u32 se_cntl;
|
||||
} drm_radeon_depth_clear_t;
|
||||
|
||||
typedef struct drm_radeon_private {
|
||||
drm_radeon_ring_buffer_t ring;
|
||||
drm_radeon_sarea_t *sarea_priv;
|
||||
|
||||
int agp_size;
|
||||
u32 agp_vm_start;
|
||||
unsigned long agp_buffers_offset;
|
||||
|
||||
int cp_mode;
|
||||
int cp_running;
|
||||
|
||||
drm_radeon_freelist_t *head;
|
||||
drm_radeon_freelist_t *tail;
|
||||
int last_buf;
|
||||
volatile u32 *scratch;
|
||||
|
||||
int usec_timeout;
|
||||
int is_pci;
|
||||
unsigned long phys_pci_gart;
|
||||
dma_addr_t bus_pci_gart;
|
||||
|
||||
atomic_t idle_count;
|
||||
|
||||
int page_flipping;
|
||||
int current_page;
|
||||
u32 crtc_offset;
|
||||
u32 crtc_offset_cntl;
|
||||
|
||||
u32 color_fmt;
|
||||
unsigned int front_offset;
|
||||
unsigned int front_pitch;
|
||||
unsigned int back_offset;
|
||||
unsigned int back_pitch;
|
||||
|
||||
u32 depth_fmt;
|
||||
unsigned int depth_offset;
|
||||
unsigned int depth_pitch;
|
||||
|
||||
u32 front_pitch_offset;
|
||||
u32 back_pitch_offset;
|
||||
u32 depth_pitch_offset;
|
||||
|
||||
drm_radeon_depth_clear_t depth_clear;
|
||||
|
||||
drm_map_t *sarea;
|
||||
drm_map_t *fb;
|
||||
drm_map_t *mmio;
|
||||
drm_map_t *cp_ring;
|
||||
drm_map_t *ring_rptr;
|
||||
drm_map_t *buffers;
|
||||
drm_map_t *agp_textures;
|
||||
} drm_radeon_private_t;
|
||||
|
||||
typedef struct drm_radeon_buf_priv {
|
||||
u32 age;
|
||||
} drm_radeon_buf_priv_t;
|
||||
|
||||
/* radeon_cp.c */
|
||||
extern int radeon_cp_init( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_start( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_stop( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_reset( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_idle( DRM_IOCTL_ARGS );
|
||||
extern int radeon_engine_reset( DRM_IOCTL_ARGS );
|
||||
extern int radeon_fullscreen( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_buffers( DRM_IOCTL_ARGS );
|
||||
|
||||
extern void radeon_freelist_reset( drm_device_t *dev );
|
||||
extern drm_buf_t *radeon_freelist_get( drm_device_t *dev );
|
||||
|
||||
extern int radeon_wait_ring( drm_radeon_private_t *dev_priv, int n );
|
||||
|
||||
static __inline__ void
|
||||
radeon_update_ring_snapshot( drm_radeon_ring_buffer_t *ring )
|
||||
{
|
||||
ring->space = (GET_RING_HEAD(ring) - ring->tail) * sizeof(u32);
|
||||
if ( ring->space <= 0 )
|
||||
ring->space += ring->size;
|
||||
}
|
||||
|
||||
extern int radeon_do_cp_idle( drm_radeon_private_t *dev_priv );
|
||||
extern int radeon_do_cleanup_cp( drm_device_t *dev );
|
||||
extern int radeon_do_cleanup_pageflip( drm_device_t *dev );
|
||||
|
||||
/* radeon_state.c */
|
||||
extern int radeon_cp_clear( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_swap( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_vertex( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_indices( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_texture( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_stipple( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_indirect( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_vertex2( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_cmdbuf( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_getparam( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_flip( DRM_IOCTL_ARGS );
|
||||
|
||||
|
||||
|
||||
/* Register definitions, register access macros and drmAddMap constants
|
||||
* for Radeon kernel driver.
|
||||
*/
|
||||
|
||||
#define RADEON_AGP_COMMAND 0x0f60
|
||||
#define RADEON_AUX_SCISSOR_CNTL 0x26f0
|
||||
# define RADEON_EXCLUSIVE_SCISSOR_0 (1 << 24)
|
||||
# define RADEON_EXCLUSIVE_SCISSOR_1 (1 << 25)
|
||||
# define RADEON_EXCLUSIVE_SCISSOR_2 (1 << 26)
|
||||
# define RADEON_SCISSOR_0_ENABLE (1 << 28)
|
||||
# define RADEON_SCISSOR_1_ENABLE (1 << 29)
|
||||
# define RADEON_SCISSOR_2_ENABLE (1 << 30)
|
||||
|
||||
#define RADEON_BUS_CNTL 0x0030
|
||||
# define RADEON_BUS_MASTER_DIS (1 << 6)
|
||||
|
||||
#define RADEON_CLOCK_CNTL_DATA 0x000c
|
||||
# define RADEON_PLL_WR_EN (1 << 7)
|
||||
#define RADEON_CLOCK_CNTL_INDEX 0x0008
|
||||
#define RADEON_CONFIG_APER_SIZE 0x0108
|
||||
#define RADEON_CRTC_OFFSET 0x0224
|
||||
#define RADEON_CRTC_OFFSET_CNTL 0x0228
|
||||
# define RADEON_CRTC_TILE_EN (1 << 15)
|
||||
# define RADEON_CRTC_OFFSET_FLIP_CNTL (1 << 16)
|
||||
|
||||
#define RADEON_RB3D_COLORPITCH 0x1c48
|
||||
|
||||
#define RADEON_DP_GUI_MASTER_CNTL 0x146c
|
||||
# define RADEON_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0)
|
||||
# define RADEON_GMC_DST_PITCH_OFFSET_CNTL (1 << 1)
|
||||
# define RADEON_GMC_BRUSH_SOLID_COLOR (13 << 4)
|
||||
# define RADEON_GMC_BRUSH_NONE (15 << 4)
|
||||
# define RADEON_GMC_DST_16BPP (4 << 8)
|
||||
# define RADEON_GMC_DST_24BPP (5 << 8)
|
||||
# define RADEON_GMC_DST_32BPP (6 << 8)
|
||||
# define RADEON_GMC_DST_DATATYPE_SHIFT 8
|
||||
# define RADEON_GMC_SRC_DATATYPE_COLOR (3 << 12)
|
||||
# define RADEON_DP_SRC_SOURCE_MEMORY (2 << 24)
|
||||
# define RADEON_DP_SRC_SOURCE_HOST_DATA (3 << 24)
|
||||
# define RADEON_GMC_CLR_CMP_CNTL_DIS (1 << 28)
|
||||
# define RADEON_GMC_WR_MSK_DIS (1 << 30)
|
||||
# define RADEON_ROP3_S 0x00cc0000
|
||||
# define RADEON_ROP3_P 0x00f00000
|
||||
#define RADEON_DP_WRITE_MASK 0x16cc
|
||||
#define RADEON_DST_PITCH_OFFSET 0x142c
|
||||
#define RADEON_DST_PITCH_OFFSET_C 0x1c80
|
||||
# define RADEON_DST_TILE_LINEAR (0 << 30)
|
||||
# define RADEON_DST_TILE_MACRO (1 << 30)
|
||||
# define RADEON_DST_TILE_MICRO (2 << 30)
|
||||
# define RADEON_DST_TILE_BOTH (3 << 30)
|
||||
|
||||
#define RADEON_SCRATCH_REG0 0x15e0
|
||||
#define RADEON_SCRATCH_REG1 0x15e4
|
||||
#define RADEON_SCRATCH_REG2 0x15e8
|
||||
#define RADEON_SCRATCH_REG3 0x15ec
|
||||
#define RADEON_SCRATCH_REG4 0x15f0
|
||||
#define RADEON_SCRATCH_REG5 0x15f4
|
||||
#define RADEON_SCRATCH_UMSK 0x0770
|
||||
#define RADEON_SCRATCH_ADDR 0x0774
|
||||
|
||||
#define RADEON_HOST_PATH_CNTL 0x0130
|
||||
# define RADEON_HDP_SOFT_RESET (1 << 26)
|
||||
# define RADEON_HDP_WC_TIMEOUT_MASK (7 << 28)
|
||||
# define RADEON_HDP_WC_TIMEOUT_28BCLK (7 << 28)
|
||||
|
||||
#define RADEON_ISYNC_CNTL 0x1724
|
||||
# define RADEON_ISYNC_ANY2D_IDLE3D (1 << 0)
|
||||
# define RADEON_ISYNC_ANY3D_IDLE2D (1 << 1)
|
||||
# define RADEON_ISYNC_TRIG2D_IDLE3D (1 << 2)
|
||||
# define RADEON_ISYNC_TRIG3D_IDLE2D (1 << 3)
|
||||
# define RADEON_ISYNC_WAIT_IDLEGUI (1 << 4)
|
||||
# define RADEON_ISYNC_CPSCRATCH_IDLEGUI (1 << 5)
|
||||
|
||||
#define RADEON_RBBM_GUICNTL 0x172c
|
||||
# define RADEON_HOST_DATA_SWAP_NONE (0 << 0)
|
||||
# define RADEON_HOST_DATA_SWAP_16BIT (1 << 0)
|
||||
# define RADEON_HOST_DATA_SWAP_32BIT (2 << 0)
|
||||
# define RADEON_HOST_DATA_SWAP_HDW (3 << 0)
|
||||
|
||||
#define RADEON_MC_AGP_LOCATION 0x014c
|
||||
#define RADEON_MC_FB_LOCATION 0x0148
|
||||
#define RADEON_MCLK_CNTL 0x0012
|
||||
# define RADEON_FORCEON_MCLKA (1 << 16)
|
||||
# define RADEON_FORCEON_MCLKB (1 << 17)
|
||||
# define RADEON_FORCEON_YCLKA (1 << 18)
|
||||
# define RADEON_FORCEON_YCLKB (1 << 19)
|
||||
# define RADEON_FORCEON_MC (1 << 20)
|
||||
# define RADEON_FORCEON_AIC (1 << 21)
|
||||
|
||||
#define RADEON_PP_BORDER_COLOR_0 0x1d40
|
||||
#define RADEON_PP_BORDER_COLOR_1 0x1d44
|
||||
#define RADEON_PP_BORDER_COLOR_2 0x1d48
|
||||
#define RADEON_PP_CNTL 0x1c38
|
||||
# define RADEON_SCISSOR_ENABLE (1 << 1)
|
||||
#define RADEON_PP_LUM_MATRIX 0x1d00
|
||||
#define RADEON_PP_MISC 0x1c14
|
||||
#define RADEON_PP_ROT_MATRIX_0 0x1d58
|
||||
#define RADEON_PP_TXFILTER_0 0x1c54
|
||||
#define RADEON_PP_TXFILTER_1 0x1c6c
|
||||
#define RADEON_PP_TXFILTER_2 0x1c84
|
||||
|
||||
#define RADEON_RB2D_DSTCACHE_CTLSTAT 0x342c
|
||||
# define RADEON_RB2D_DC_FLUSH (3 << 0)
|
||||
# define RADEON_RB2D_DC_FREE (3 << 2)
|
||||
# define RADEON_RB2D_DC_FLUSH_ALL 0xf
|
||||
# define RADEON_RB2D_DC_BUSY (1 << 31)
|
||||
#define RADEON_RB3D_CNTL 0x1c3c
|
||||
# define RADEON_ALPHA_BLEND_ENABLE (1 << 0)
|
||||
# define RADEON_PLANE_MASK_ENABLE (1 << 1)
|
||||
# define RADEON_DITHER_ENABLE (1 << 2)
|
||||
# define RADEON_ROUND_ENABLE (1 << 3)
|
||||
# define RADEON_SCALE_DITHER_ENABLE (1 << 4)
|
||||
# define RADEON_DITHER_INIT (1 << 5)
|
||||
# define RADEON_ROP_ENABLE (1 << 6)
|
||||
# define RADEON_STENCIL_ENABLE (1 << 7)
|
||||
# define RADEON_Z_ENABLE (1 << 8)
|
||||
#define RADEON_RB3D_DEPTHOFFSET 0x1c24
|
||||
#define RADEON_RB3D_PLANEMASK 0x1d84
|
||||
#define RADEON_RB3D_STENCILREFMASK 0x1d7c
|
||||
#define RADEON_RB3D_ZCACHE_MODE 0x3250
|
||||
#define RADEON_RB3D_ZCACHE_CTLSTAT 0x3254
|
||||
# define RADEON_RB3D_ZC_FLUSH (1 << 0)
|
||||
# define RADEON_RB3D_ZC_FREE (1 << 2)
|
||||
# define RADEON_RB3D_ZC_FLUSH_ALL 0x5
|
||||
# define RADEON_RB3D_ZC_BUSY (1 << 31)
|
||||
#define RADEON_RB3D_ZSTENCILCNTL 0x1c2c
|
||||
# define RADEON_Z_TEST_MASK (7 << 4)
|
||||
# define RADEON_Z_TEST_ALWAYS (7 << 4)
|
||||
# define RADEON_STENCIL_TEST_ALWAYS (7 << 12)
|
||||
# define RADEON_STENCIL_S_FAIL_REPLACE (2 << 16)
|
||||
# define RADEON_STENCIL_ZPASS_REPLACE (2 << 20)
|
||||
# define RADEON_STENCIL_ZFAIL_REPLACE (2 << 24)
|
||||
# define RADEON_Z_WRITE_ENABLE (1 << 30)
|
||||
#define RADEON_RBBM_SOFT_RESET 0x00f0
|
||||
# define RADEON_SOFT_RESET_CP (1 << 0)
|
||||
# define RADEON_SOFT_RESET_HI (1 << 1)
|
||||
# define RADEON_SOFT_RESET_SE (1 << 2)
|
||||
# define RADEON_SOFT_RESET_RE (1 << 3)
|
||||
# define RADEON_SOFT_RESET_PP (1 << 4)
|
||||
# define RADEON_SOFT_RESET_E2 (1 << 5)
|
||||
# define RADEON_SOFT_RESET_RB (1 << 6)
|
||||
# define RADEON_SOFT_RESET_HDP (1 << 7)
|
||||
#define RADEON_RBBM_STATUS 0x0e40
|
||||
# define RADEON_RBBM_FIFOCNT_MASK 0x007f
|
||||
# define RADEON_RBBM_ACTIVE (1 << 31)
|
||||
#define RADEON_RE_LINE_PATTERN 0x1cd0
|
||||
#define RADEON_RE_MISC 0x26c4
|
||||
#define RADEON_RE_TOP_LEFT 0x26c0
|
||||
#define RADEON_RE_WIDTH_HEIGHT 0x1c44
|
||||
#define RADEON_RE_STIPPLE_ADDR 0x1cc8
|
||||
#define RADEON_RE_STIPPLE_DATA 0x1ccc
|
||||
|
||||
#define RADEON_SCISSOR_TL_0 0x1cd8
|
||||
#define RADEON_SCISSOR_BR_0 0x1cdc
|
||||
#define RADEON_SCISSOR_TL_1 0x1ce0
|
||||
#define RADEON_SCISSOR_BR_1 0x1ce4
|
||||
#define RADEON_SCISSOR_TL_2 0x1ce8
|
||||
#define RADEON_SCISSOR_BR_2 0x1cec
|
||||
#define RADEON_SE_COORD_FMT 0x1c50
|
||||
#define RADEON_SE_CNTL 0x1c4c
|
||||
# define RADEON_FFACE_CULL_CW (0 << 0)
|
||||
# define RADEON_BFACE_SOLID (3 << 1)
|
||||
# define RADEON_FFACE_SOLID (3 << 3)
|
||||
# define RADEON_FLAT_SHADE_VTX_LAST (3 << 6)
|
||||
# define RADEON_DIFFUSE_SHADE_FLAT (1 << 8)
|
||||
# define RADEON_DIFFUSE_SHADE_GOURAUD (2 << 8)
|
||||
# define RADEON_ALPHA_SHADE_FLAT (1 << 10)
|
||||
# define RADEON_ALPHA_SHADE_GOURAUD (2 << 10)
|
||||
# define RADEON_SPECULAR_SHADE_FLAT (1 << 12)
|
||||
# define RADEON_SPECULAR_SHADE_GOURAUD (2 << 12)
|
||||
# define RADEON_FOG_SHADE_FLAT (1 << 14)
|
||||
# define RADEON_FOG_SHADE_GOURAUD (2 << 14)
|
||||
# define RADEON_VPORT_XY_XFORM_ENABLE (1 << 24)
|
||||
# define RADEON_VPORT_Z_XFORM_ENABLE (1 << 25)
|
||||
# define RADEON_VTX_PIX_CENTER_OGL (1 << 27)
|
||||
# define RADEON_ROUND_MODE_TRUNC (0 << 28)
|
||||
# define RADEON_ROUND_PREC_8TH_PIX (1 << 30)
|
||||
#define RADEON_SE_CNTL_STATUS 0x2140
|
||||
#define RADEON_SE_LINE_WIDTH 0x1db8
|
||||
#define RADEON_SE_VPORT_XSCALE 0x1d98
|
||||
#define RADEON_SE_ZBIAS_FACTOR 0x1db0
|
||||
#define RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED 0x2210
|
||||
#define RADEON_SE_TCL_OUTPUT_VTX_FMT 0x2254
|
||||
#define RADEON_SE_TCL_VECTOR_INDX_REG 0x2200
|
||||
# define RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT 16
|
||||
# define RADEON_VEC_INDX_DWORD_COUNT_SHIFT 28
|
||||
#define RADEON_SE_TCL_VECTOR_DATA_REG 0x2204
|
||||
#define RADEON_SE_TCL_SCALAR_INDX_REG 0x2208
|
||||
# define RADEON_SCAL_INDX_DWORD_STRIDE_SHIFT 16
|
||||
#define RADEON_SE_TCL_SCALAR_DATA_REG 0x220C
|
||||
#define RADEON_SURFACE_ACCESS_FLAGS 0x0bf8
|
||||
#define RADEON_SURFACE_ACCESS_CLR 0x0bfc
|
||||
#define RADEON_SURFACE_CNTL 0x0b00
|
||||
# define RADEON_SURF_TRANSLATION_DIS (1 << 8)
|
||||
# define RADEON_NONSURF_AP0_SWP_MASK (3 << 20)
|
||||
# define RADEON_NONSURF_AP0_SWP_LITTLE (0 << 20)
|
||||
# define RADEON_NONSURF_AP0_SWP_BIG16 (1 << 20)
|
||||
# define RADEON_NONSURF_AP0_SWP_BIG32 (2 << 20)
|
||||
# define RADEON_NONSURF_AP1_SWP_MASK (3 << 22)
|
||||
# define RADEON_NONSURF_AP1_SWP_LITTLE (0 << 22)
|
||||
# define RADEON_NONSURF_AP1_SWP_BIG16 (1 << 22)
|
||||
# define RADEON_NONSURF_AP1_SWP_BIG32 (2 << 22)
|
||||
#define RADEON_SURFACE0_INFO 0x0b0c
|
||||
# define RADEON_SURF_PITCHSEL_MASK (0x1ff << 0)
|
||||
# define RADEON_SURF_TILE_MODE_MASK (3 << 16)
|
||||
# define RADEON_SURF_TILE_MODE_MACRO (0 << 16)
|
||||
# define RADEON_SURF_TILE_MODE_MICRO (1 << 16)
|
||||
# define RADEON_SURF_TILE_MODE_32BIT_Z (2 << 16)
|
||||
# define RADEON_SURF_TILE_MODE_16BIT_Z (3 << 16)
|
||||
#define RADEON_SURFACE0_LOWER_BOUND 0x0b04
|
||||
#define RADEON_SURFACE0_UPPER_BOUND 0x0b08
|
||||
#define RADEON_SURFACE1_INFO 0x0b1c
|
||||
#define RADEON_SURFACE1_LOWER_BOUND 0x0b14
|
||||
#define RADEON_SURFACE1_UPPER_BOUND 0x0b18
|
||||
#define RADEON_SURFACE2_INFO 0x0b2c
|
||||
#define RADEON_SURFACE2_LOWER_BOUND 0x0b24
|
||||
#define RADEON_SURFACE2_UPPER_BOUND 0x0b28
|
||||
#define RADEON_SURFACE3_INFO 0x0b3c
|
||||
#define RADEON_SURFACE3_LOWER_BOUND 0x0b34
|
||||
#define RADEON_SURFACE3_UPPER_BOUND 0x0b38
|
||||
#define RADEON_SURFACE4_INFO 0x0b4c
|
||||
#define RADEON_SURFACE4_LOWER_BOUND 0x0b44
|
||||
#define RADEON_SURFACE4_UPPER_BOUND 0x0b48
|
||||
#define RADEON_SURFACE5_INFO 0x0b5c
|
||||
#define RADEON_SURFACE5_LOWER_BOUND 0x0b54
|
||||
#define RADEON_SURFACE5_UPPER_BOUND 0x0b58
|
||||
#define RADEON_SURFACE6_INFO 0x0b6c
|
||||
#define RADEON_SURFACE6_LOWER_BOUND 0x0b64
|
||||
#define RADEON_SURFACE6_UPPER_BOUND 0x0b68
|
||||
#define RADEON_SURFACE7_INFO 0x0b7c
|
||||
#define RADEON_SURFACE7_LOWER_BOUND 0x0b74
|
||||
#define RADEON_SURFACE7_UPPER_BOUND 0x0b78
|
||||
#define RADEON_SW_SEMAPHORE 0x013c
|
||||
|
||||
#define RADEON_WAIT_UNTIL 0x1720
|
||||
# define RADEON_WAIT_CRTC_PFLIP (1 << 0)
|
||||
# define RADEON_WAIT_2D_IDLECLEAN (1 << 16)
|
||||
# define RADEON_WAIT_3D_IDLECLEAN (1 << 17)
|
||||
# define RADEON_WAIT_HOST_IDLECLEAN (1 << 18)
|
||||
|
||||
#define RADEON_RB3D_ZMASKOFFSET 0x1c34
|
||||
#define RADEON_RB3D_ZSTENCILCNTL 0x1c2c
|
||||
# define RADEON_DEPTH_FORMAT_16BIT_INT_Z (0 << 0)
|
||||
# define RADEON_DEPTH_FORMAT_24BIT_INT_Z (2 << 0)
|
||||
|
||||
|
||||
/* CP registers */
|
||||
#define RADEON_CP_ME_RAM_ADDR 0x07d4
|
||||
#define RADEON_CP_ME_RAM_RADDR 0x07d8
|
||||
#define RADEON_CP_ME_RAM_DATAH 0x07dc
|
||||
#define RADEON_CP_ME_RAM_DATAL 0x07e0
|
||||
|
||||
#define RADEON_CP_RB_BASE 0x0700
|
||||
#define RADEON_CP_RB_CNTL 0x0704
|
||||
# define RADEON_BUF_SWAP_32BIT (2 << 16)
|
||||
#define RADEON_CP_RB_RPTR_ADDR 0x070c
|
||||
#define RADEON_CP_RB_RPTR 0x0710
|
||||
#define RADEON_CP_RB_WPTR 0x0714
|
||||
|
||||
#define RADEON_CP_RB_WPTR_DELAY 0x0718
|
||||
# define RADEON_PRE_WRITE_TIMER_SHIFT 0
|
||||
# define RADEON_PRE_WRITE_LIMIT_SHIFT 23
|
||||
|
||||
#define RADEON_CP_IB_BASE 0x0738
|
||||
|
||||
#define RADEON_CP_CSQ_CNTL 0x0740
|
||||
# define RADEON_CSQ_CNT_PRIMARY_MASK (0xff << 0)
|
||||
# define RADEON_CSQ_PRIDIS_INDDIS (0 << 28)
|
||||
# define RADEON_CSQ_PRIPIO_INDDIS (1 << 28)
|
||||
# define RADEON_CSQ_PRIBM_INDDIS (2 << 28)
|
||||
# define RADEON_CSQ_PRIPIO_INDBM (3 << 28)
|
||||
# define RADEON_CSQ_PRIBM_INDBM (4 << 28)
|
||||
# define RADEON_CSQ_PRIPIO_INDPIO (15 << 28)
|
||||
|
||||
#define RADEON_AIC_CNTL 0x01d0
|
||||
# define RADEON_PCIGART_TRANSLATE_EN (1 << 0)
|
||||
#define RADEON_AIC_STAT 0x01d4
|
||||
#define RADEON_AIC_PT_BASE 0x01d8
|
||||
#define RADEON_AIC_LO_ADDR 0x01dc
|
||||
#define RADEON_AIC_HI_ADDR 0x01e0
|
||||
#define RADEON_AIC_TLB_ADDR 0x01e4
|
||||
#define RADEON_AIC_TLB_DATA 0x01e8
|
||||
|
||||
/* CP command packets */
|
||||
#define RADEON_CP_PACKET0 0x00000000
|
||||
# define RADEON_ONE_REG_WR (1 << 15)
|
||||
#define RADEON_CP_PACKET1 0x40000000
|
||||
#define RADEON_CP_PACKET2 0x80000000
|
||||
#define RADEON_CP_PACKET3 0xC0000000
|
||||
# define RADEON_3D_RNDR_GEN_INDX_PRIM 0x00002300
|
||||
# define RADEON_WAIT_FOR_IDLE 0x00002600
|
||||
# define RADEON_3D_DRAW_VBUF 0x00002800
|
||||
# define RADEON_3D_DRAW_IMMD 0x00002900
|
||||
# define RADEON_3D_DRAW_INDX 0x00002A00
|
||||
# define RADEON_3D_LOAD_VBPNTR 0x00002F00
|
||||
# define RADEON_CNTL_HOSTDATA_BLT 0x00009400
|
||||
# define RADEON_CNTL_PAINT_MULTI 0x00009A00
|
||||
# define RADEON_CNTL_BITBLT_MULTI 0x00009B00
|
||||
# define RADEON_CNTL_SET_SCISSORS 0xC0001E00
|
||||
|
||||
#define RADEON_CP_PACKET_MASK 0xC0000000
|
||||
#define RADEON_CP_PACKET_COUNT_MASK 0x3fff0000
|
||||
#define RADEON_CP_PACKET0_REG_MASK 0x000007ff
|
||||
#define RADEON_CP_PACKET1_REG0_MASK 0x000007ff
|
||||
#define RADEON_CP_PACKET1_REG1_MASK 0x003ff800
|
||||
|
||||
#define RADEON_VTX_Z_PRESENT (1 << 31)
|
||||
#define RADEON_VTX_PKCOLOR_PRESENT (1 << 3)
|
||||
|
||||
#define RADEON_PRIM_TYPE_NONE (0 << 0)
|
||||
#define RADEON_PRIM_TYPE_POINT (1 << 0)
|
||||
#define RADEON_PRIM_TYPE_LINE (2 << 0)
|
||||
#define RADEON_PRIM_TYPE_LINE_STRIP (3 << 0)
|
||||
#define RADEON_PRIM_TYPE_TRI_LIST (4 << 0)
|
||||
#define RADEON_PRIM_TYPE_TRI_FAN (5 << 0)
|
||||
#define RADEON_PRIM_TYPE_TRI_STRIP (6 << 0)
|
||||
#define RADEON_PRIM_TYPE_TRI_TYPE2 (7 << 0)
|
||||
#define RADEON_PRIM_TYPE_RECT_LIST (8 << 0)
|
||||
#define RADEON_PRIM_TYPE_3VRT_POINT_LIST (9 << 0)
|
||||
#define RADEON_PRIM_TYPE_3VRT_LINE_LIST (10 << 0)
|
||||
#define RADEON_PRIM_TYPE_MASK 0xf
|
||||
#define RADEON_PRIM_WALK_IND (1 << 4)
|
||||
#define RADEON_PRIM_WALK_LIST (2 << 4)
|
||||
#define RADEON_PRIM_WALK_RING (3 << 4)
|
||||
#define RADEON_COLOR_ORDER_BGRA (0 << 6)
|
||||
#define RADEON_COLOR_ORDER_RGBA (1 << 6)
|
||||
#define RADEON_MAOS_ENABLE (1 << 7)
|
||||
#define RADEON_VTX_FMT_R128_MODE (0 << 8)
|
||||
#define RADEON_VTX_FMT_RADEON_MODE (1 << 8)
|
||||
#define RADEON_NUM_VERTICES_SHIFT 16
|
||||
|
||||
#define RADEON_COLOR_FORMAT_CI8 2
|
||||
#define RADEON_COLOR_FORMAT_ARGB1555 3
|
||||
#define RADEON_COLOR_FORMAT_RGB565 4
|
||||
#define RADEON_COLOR_FORMAT_ARGB8888 6
|
||||
#define RADEON_COLOR_FORMAT_RGB332 7
|
||||
#define RADEON_COLOR_FORMAT_RGB8 9
|
||||
#define RADEON_COLOR_FORMAT_ARGB4444 15
|
||||
|
||||
#define RADEON_TXFORMAT_I8 0
|
||||
#define RADEON_TXFORMAT_AI88 1
|
||||
#define RADEON_TXFORMAT_RGB332 2
|
||||
#define RADEON_TXFORMAT_ARGB1555 3
|
||||
#define RADEON_TXFORMAT_RGB565 4
|
||||
#define RADEON_TXFORMAT_ARGB4444 5
|
||||
#define RADEON_TXFORMAT_ARGB8888 6
|
||||
#define RADEON_TXFORMAT_RGBA8888 7
|
||||
|
||||
/* Constants */
|
||||
#define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */
|
||||
|
||||
#define RADEON_LAST_FRAME_REG RADEON_SCRATCH_REG0
|
||||
#define RADEON_LAST_DISPATCH_REG RADEON_SCRATCH_REG1
|
||||
#define RADEON_LAST_CLEAR_REG RADEON_SCRATCH_REG2
|
||||
#define RADEON_LAST_DISPATCH 1
|
||||
|
||||
#define RADEON_MAX_VB_AGE 0x7fffffff
|
||||
#define RADEON_MAX_VB_VERTS (0xffff)
|
||||
|
||||
#define RADEON_RING_HIGH_MARK 128
|
||||
|
||||
|
||||
#define RADEON_BASE(reg) ((unsigned long)(dev_priv->mmio->handle))
|
||||
#define RADEON_ADDR(reg) (RADEON_BASE( reg ) + reg)
|
||||
|
||||
#define RADEON_READ(reg) DRM_READ32( (volatile u32 *) RADEON_ADDR(reg) )
|
||||
#define RADEON_WRITE(reg,val) DRM_WRITE32( (volatile u32 *) RADEON_ADDR(reg), (val) )
|
||||
|
||||
#define RADEON_READ8(reg) DRM_READ8( (volatile u8 *) RADEON_ADDR(reg) )
|
||||
#define RADEON_WRITE8(reg,val) DRM_WRITE8( (volatile u8 *) RADEON_ADDR(reg), (val) )
|
||||
|
||||
#define RADEON_WRITE_PLL( addr, val ) \
|
||||
do { \
|
||||
RADEON_WRITE8( RADEON_CLOCK_CNTL_INDEX, \
|
||||
((addr) & 0x1f) | RADEON_PLL_WR_EN ); \
|
||||
RADEON_WRITE( RADEON_CLOCK_CNTL_DATA, (val) ); \
|
||||
} while (0)
|
||||
|
||||
extern int RADEON_READ_PLL( drm_device_t *dev, int addr );
|
||||
|
||||
|
||||
#define CP_PACKET0( reg, n ) \
|
||||
(RADEON_CP_PACKET0 | ((n) << 16) | ((reg) >> 2))
|
||||
#define CP_PACKET0_TABLE( reg, n ) \
|
||||
(RADEON_CP_PACKET0 | RADEON_ONE_REG_WR | ((n) << 16) | ((reg) >> 2))
|
||||
#define CP_PACKET1( reg0, reg1 ) \
|
||||
(RADEON_CP_PACKET1 | (((reg1) >> 2) << 15) | ((reg0) >> 2))
|
||||
#define CP_PACKET2() \
|
||||
(RADEON_CP_PACKET2)
|
||||
#define CP_PACKET3( pkt, n ) \
|
||||
(RADEON_CP_PACKET3 | (pkt) | ((n) << 16))
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Engine control helper macros
|
||||
*/
|
||||
|
||||
#define RADEON_WAIT_UNTIL_2D_IDLE() do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) ); \
|
||||
OUT_RING( (RADEON_WAIT_2D_IDLECLEAN | \
|
||||
RADEON_WAIT_HOST_IDLECLEAN) ); \
|
||||
} while (0)
|
||||
|
||||
#define RADEON_WAIT_UNTIL_3D_IDLE() do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) ); \
|
||||
OUT_RING( (RADEON_WAIT_3D_IDLECLEAN | \
|
||||
RADEON_WAIT_HOST_IDLECLEAN) ); \
|
||||
} while (0)
|
||||
|
||||
#define RADEON_WAIT_UNTIL_IDLE() do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) ); \
|
||||
OUT_RING( (RADEON_WAIT_2D_IDLECLEAN | \
|
||||
RADEON_WAIT_3D_IDLECLEAN | \
|
||||
RADEON_WAIT_HOST_IDLECLEAN) ); \
|
||||
} while (0)
|
||||
|
||||
#define RADEON_WAIT_UNTIL_PAGE_FLIPPED() do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) ); \
|
||||
OUT_RING( RADEON_WAIT_CRTC_PFLIP ); \
|
||||
} while (0)
|
||||
|
||||
#define RADEON_FLUSH_CACHE() do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_RB2D_DSTCACHE_CTLSTAT, 0 ) ); \
|
||||
OUT_RING( RADEON_RB2D_DC_FLUSH ); \
|
||||
} while (0)
|
||||
|
||||
#define RADEON_PURGE_CACHE() do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_RB2D_DSTCACHE_CTLSTAT, 0 ) ); \
|
||||
OUT_RING( RADEON_RB2D_DC_FLUSH_ALL ); \
|
||||
} while (0)
|
||||
|
||||
#define RADEON_FLUSH_ZCACHE() do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_RB3D_ZCACHE_CTLSTAT, 0 ) ); \
|
||||
OUT_RING( RADEON_RB3D_ZC_FLUSH ); \
|
||||
} while (0)
|
||||
|
||||
#define RADEON_PURGE_ZCACHE() do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_RB3D_ZCACHE_CTLSTAT, 0 ) ); \
|
||||
OUT_RING( RADEON_RB3D_ZC_FLUSH_ALL ); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Misc helper macros
|
||||
*/
|
||||
|
||||
#define LOCK_TEST_WITH_RETURN( dev ) \
|
||||
do { \
|
||||
if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
|
||||
dev->lock.pid != DRM_CURRENTPID ) { \
|
||||
DRM_ERROR( "%s called without lock held\n", __func__ ); \
|
||||
return DRM_ERR(EINVAL); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define RING_SPACE_TEST_WITH_RETURN( dev_priv ) \
|
||||
do { \
|
||||
drm_radeon_ring_buffer_t *ring = &dev_priv->ring; int i; \
|
||||
if ( ring->space < ring->high_mark ) { \
|
||||
for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) { \
|
||||
radeon_update_ring_snapshot( ring ); \
|
||||
if ( ring->space >= ring->high_mark ) \
|
||||
goto __ring_space_done; \
|
||||
DRM_UDELAY( 1 ); \
|
||||
} \
|
||||
DRM_ERROR( "ring space check from memory failed, reading register...\n" ); \
|
||||
/* If ring space check fails from RAM, try reading the \
|
||||
register directly */ \
|
||||
ring->space = 4 * ( RADEON_READ( RADEON_CP_RB_RPTR ) - ring->tail ); \
|
||||
if ( ring->space <= 0 ) \
|
||||
ring->space += ring->size; \
|
||||
if ( ring->space >= ring->high_mark ) \
|
||||
goto __ring_space_done; \
|
||||
\
|
||||
DRM_ERROR( "ring space check failed!\n" ); \
|
||||
return DRM_ERR(EBUSY); \
|
||||
} \
|
||||
__ring_space_done: \
|
||||
; \
|
||||
} while (0)
|
||||
|
||||
#define VB_AGE_TEST_WITH_RETURN( dev_priv ) \
|
||||
do { \
|
||||
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; \
|
||||
if ( sarea_priv->last_dispatch >= RADEON_MAX_VB_AGE ) { \
|
||||
int __ret = radeon_do_cp_idle( dev_priv ); \
|
||||
if ( __ret ) return __ret; \
|
||||
sarea_priv->last_dispatch = 0; \
|
||||
radeon_freelist_reset( dev ); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define RADEON_DISPATCH_AGE( age ) do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_LAST_DISPATCH_REG, 0 ) ); \
|
||||
OUT_RING( age ); \
|
||||
} while (0)
|
||||
|
||||
#define RADEON_FRAME_AGE( age ) do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_LAST_FRAME_REG, 0 ) ); \
|
||||
OUT_RING( age ); \
|
||||
} while (0)
|
||||
|
||||
#define RADEON_CLEAR_AGE( age ) do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_LAST_CLEAR_REG, 0 ) ); \
|
||||
OUT_RING( age ); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Ring control
|
||||
*/
|
||||
|
||||
#if defined(__powerpc__)
|
||||
#define radeon_flush_write_combine() (void) GET_RING_HEAD( &dev_priv->ring )
|
||||
#else
|
||||
#define radeon_flush_write_combine() DRM_WRITEMEMORYBARRIER()
|
||||
#endif
|
||||
|
||||
|
||||
#define RADEON_VERBOSE 0
|
||||
|
||||
#define RING_LOCALS int write, _nr; unsigned int mask; u32 *ring;
|
||||
|
||||
#define BEGIN_RING( n ) do { \
|
||||
if ( RADEON_VERBOSE ) { \
|
||||
DRM_INFO( "BEGIN_RING( %d ) in %s\n", \
|
||||
n, __func__ ); \
|
||||
} \
|
||||
if ( dev_priv->ring.space <= (n) * sizeof(u32) ) { \
|
||||
COMMIT_RING(); \
|
||||
radeon_wait_ring( dev_priv, (n) * sizeof(u32) ); \
|
||||
} \
|
||||
_nr = n; dev_priv->ring.space -= (n) * sizeof(u32); \
|
||||
ring = dev_priv->ring.start; \
|
||||
write = dev_priv->ring.tail; \
|
||||
mask = dev_priv->ring.tail_mask; \
|
||||
} while (0)
|
||||
|
||||
#define ADVANCE_RING() do { \
|
||||
if ( RADEON_VERBOSE ) { \
|
||||
DRM_INFO( "ADVANCE_RING() wr=0x%06x tail=0x%06x\n", \
|
||||
write, dev_priv->ring.tail ); \
|
||||
} \
|
||||
if (((dev_priv->ring.tail + _nr) & mask) != write) { \
|
||||
DRM_ERROR( \
|
||||
"ADVANCE_RING(): mismatch: nr: %x write: %x\n", \
|
||||
((dev_priv->ring.tail + _nr) & mask), \
|
||||
write); \
|
||||
} else \
|
||||
dev_priv->ring.tail = write; \
|
||||
} while (0)
|
||||
|
||||
#define COMMIT_RING() do { \
|
||||
radeon_flush_write_combine(); \
|
||||
RADEON_WRITE( RADEON_CP_RB_WPTR, dev_priv->ring.tail ); \
|
||||
} while (0)
|
||||
|
||||
#define OUT_RING( x ) do { \
|
||||
if ( RADEON_VERBOSE ) { \
|
||||
DRM_INFO( " OUT_RING( 0x%08x ) at 0x%x\n", \
|
||||
(unsigned int)(x), write ); \
|
||||
} \
|
||||
ring[write++] = (x); \
|
||||
write &= mask; \
|
||||
} while (0)
|
||||
|
||||
#define OUT_RING_REG( reg, val ) do { \
|
||||
OUT_RING( CP_PACKET0( reg, 0 ) ); \
|
||||
OUT_RING( val ); \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define OUT_RING_USER_TABLE( tab, sz ) do { \
|
||||
int _size = (sz); \
|
||||
int *_tab = (tab); \
|
||||
\
|
||||
if (write + _size > mask) { \
|
||||
int i = (mask+1) - write; \
|
||||
if (DRM_COPY_FROM_USER_UNCHECKED( (int *)(ring+write), \
|
||||
_tab, i*4 )) \
|
||||
return DRM_ERR(EFAULT); \
|
||||
write = 0; \
|
||||
_size -= i; \
|
||||
_tab += i; \
|
||||
} \
|
||||
\
|
||||
if (_size && DRM_COPY_FROM_USER_UNCHECKED( (int *)(ring+write), \
|
||||
_tab, _size*4 )) \
|
||||
return DRM_ERR(EFAULT); \
|
||||
\
|
||||
write += _size; \
|
||||
write &= mask; \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define RADEON_PERFORMANCE_BOXES 0
|
||||
|
||||
#endif /* __RADEON_DRV_H__ */
|
||||
94
shared/mga.h
Normal file
94
shared/mga.h
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
/* mga.h -- Matrox G200/G400 DRM template customization -*- linux-c -*-
|
||||
* Created: Thu Jan 11 21:29:32 2001 by gareth@valinux.com
|
||||
*
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS 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.
|
||||
*
|
||||
* Authors:
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#ifndef __MGA_H__
|
||||
#define __MGA_H__
|
||||
|
||||
/* This remains constant for all DRM template files.
|
||||
*/
|
||||
#define DRM(x) mga_##x
|
||||
|
||||
/* General customization:
|
||||
*/
|
||||
#define __HAVE_AGP 1
|
||||
#define __MUST_HAVE_AGP 1
|
||||
#define __HAVE_MTRR 1
|
||||
#define __HAVE_CTX_BITMAP 1
|
||||
|
||||
#define DRIVER_AUTHOR "Gareth Hughes, VA Linux Systems Inc."
|
||||
|
||||
#define DRIVER_NAME "mga"
|
||||
#define DRIVER_DESC "Matrox G200/G400"
|
||||
#define DRIVER_DATE "20010321"
|
||||
|
||||
#define DRIVER_MAJOR 3
|
||||
#define DRIVER_MINOR 0
|
||||
#define DRIVER_PATCHLEVEL 2
|
||||
|
||||
#define DRIVER_IOCTLS \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { mga_dma_buffers, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_MGA_INIT)] = { mga_dma_init, 1, 1 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_MGA_FLUSH)] = { mga_dma_flush, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_MGA_RESET)] = { mga_dma_reset, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_MGA_SWAP)] = { mga_dma_swap, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_MGA_CLEAR)] = { mga_dma_clear, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_MGA_VERTEX)] = { mga_dma_vertex, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_MGA_INDICES)] = { mga_dma_indices, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_MGA_ILOAD)] = { mga_dma_iload, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_MGA_BLIT)] = { mga_dma_blit, 1, 0 },
|
||||
|
||||
#define __HAVE_COUNTERS 3
|
||||
#define __HAVE_COUNTER6 _DRM_STAT_IRQ
|
||||
#define __HAVE_COUNTER7 _DRM_STAT_PRIMARY
|
||||
#define __HAVE_COUNTER8 _DRM_STAT_SECONDARY
|
||||
|
||||
/* Driver customization:
|
||||
*/
|
||||
#define DRIVER_PRETAKEDOWN() do { \
|
||||
if ( dev->dev_private ) mga_do_cleanup_dma( dev ); \
|
||||
} while (0)
|
||||
|
||||
/* DMA customization:
|
||||
*/
|
||||
#define __HAVE_DMA 1
|
||||
|
||||
#define __HAVE_DMA_QUIESCENT 1
|
||||
#define DRIVER_DMA_QUIESCENT() do { \
|
||||
drm_mga_private_t *dev_priv = dev->dev_private; \
|
||||
return mga_do_wait_for_idle( dev_priv ); \
|
||||
} while (0)
|
||||
|
||||
/* Buffer customization:
|
||||
*/
|
||||
#define DRIVER_BUF_PRIV_T drm_mga_buf_priv_t
|
||||
|
||||
#define DRIVER_AGP_BUFFERS_MAP( dev ) \
|
||||
((drm_mga_private_t *)((dev)->dev_private))->buffers
|
||||
|
||||
#endif
|
||||
786
shared/mga_dma.c
Normal file
786
shared/mga_dma.c
Normal file
|
|
@ -0,0 +1,786 @@
|
|||
/* mga_dma.c -- DMA support for mga g200/g400 -*- linux-c -*-
|
||||
* Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PRECISION INSIGHT 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.
|
||||
*
|
||||
* Authors:
|
||||
* Rickard E. (Rik) Faith <faith@valinux.com>
|
||||
* Jeff Hartmann <jhartmann@valinux.com>
|
||||
* Keith Whitwell <keithw@valinux.com>
|
||||
*
|
||||
* Rewritten by:
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#include "mga.h"
|
||||
#include "drmP.h"
|
||||
#include "drm.h"
|
||||
#include "mga_drm.h"
|
||||
#include "mga_drv.h"
|
||||
|
||||
#define MGA_DEFAULT_USEC_TIMEOUT 10000
|
||||
#define MGA_FREELIST_DEBUG 0
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Engine control
|
||||
*/
|
||||
|
||||
int mga_do_wait_for_idle( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
u32 status = 0;
|
||||
int i;
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) {
|
||||
status = MGA_READ( MGA_STATUS ) & MGA_ENGINE_IDLE_MASK;
|
||||
if ( status == MGA_ENDPRDMASTS ) {
|
||||
MGA_WRITE8( MGA_CRTC_INDEX, 0 );
|
||||
return 0;
|
||||
}
|
||||
DRM_UDELAY( 1 );
|
||||
}
|
||||
|
||||
#if MGA_DMA_DEBUG
|
||||
DRM_ERROR( "failed!\n" );
|
||||
DRM_INFO( " status=0x%08x\n", status );
|
||||
#endif
|
||||
return DRM_ERR(EBUSY);
|
||||
}
|
||||
|
||||
int mga_do_dma_idle( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
u32 status = 0;
|
||||
int i;
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) {
|
||||
status = MGA_READ( MGA_STATUS ) & MGA_DMA_IDLE_MASK;
|
||||
if ( status == MGA_ENDPRDMASTS ) return 0;
|
||||
DRM_UDELAY( 1 );
|
||||
}
|
||||
|
||||
#if MGA_DMA_DEBUG
|
||||
DRM_ERROR( "failed! status=0x%08x\n", status );
|
||||
#endif
|
||||
return DRM_ERR(EBUSY);
|
||||
}
|
||||
|
||||
int mga_do_dma_reset( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
||||
drm_mga_primary_buffer_t *primary = &dev_priv->prim;
|
||||
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
/* The primary DMA stream should look like new right about now.
|
||||
*/
|
||||
primary->tail = 0;
|
||||
primary->space = primary->size;
|
||||
primary->last_flush = 0;
|
||||
|
||||
sarea_priv->last_wrap = 0;
|
||||
|
||||
/* FIXME: Reset counters, buffer ages etc...
|
||||
*/
|
||||
|
||||
/* FIXME: What else do we need to reinitialize? WARP stuff?
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mga_do_engine_reset( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
/* Okay, so we've completely screwed up and locked the engine.
|
||||
* How about we clean up after ourselves?
|
||||
*/
|
||||
MGA_WRITE( MGA_RST, MGA_SOFTRESET );
|
||||
DRM_UDELAY( 15 ); /* Wait at least 10 usecs */
|
||||
MGA_WRITE( MGA_RST, 0 );
|
||||
|
||||
/* Initialize the registers that get clobbered by the soft
|
||||
* reset. Many of the core register values survive a reset,
|
||||
* but the drawing registers are basically all gone.
|
||||
*
|
||||
* 3D clients should probably die after calling this. The X
|
||||
* server should reset the engine state to known values.
|
||||
*/
|
||||
#if 0
|
||||
MGA_WRITE( MGA_PRIMPTR,
|
||||
virt_to_bus((void *)dev_priv->prim.status_page) |
|
||||
MGA_PRIMPTREN0 |
|
||||
MGA_PRIMPTREN1 );
|
||||
#endif
|
||||
|
||||
MGA_WRITE( MGA_ICLEAR, MGA_SOFTRAPICLR );
|
||||
MGA_WRITE( MGA_IEN, MGA_SOFTRAPIEN );
|
||||
|
||||
/* The primary DMA stream should look like new right about now.
|
||||
*/
|
||||
mga_do_dma_reset( dev_priv );
|
||||
|
||||
/* This bad boy will never fail.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Primary DMA stream
|
||||
*/
|
||||
|
||||
void mga_do_dma_flush( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
drm_mga_primary_buffer_t *primary = &dev_priv->prim;
|
||||
u32 head, tail;
|
||||
DMA_LOCALS;
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
if ( primary->tail == primary->last_flush ) {
|
||||
DRM_DEBUG( " bailing out...\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
tail = primary->tail + dev_priv->primary->offset;
|
||||
|
||||
/* We need to pad the stream between flushes, as the card
|
||||
* actually (partially?) reads the first of these commands.
|
||||
* See page 4-16 in the G400 manual, middle of the page or so.
|
||||
*/
|
||||
BEGIN_DMA( 1 );
|
||||
|
||||
DMA_BLOCK( MGA_DMAPAD, 0x00000000,
|
||||
MGA_DMAPAD, 0x00000000,
|
||||
MGA_DMAPAD, 0x00000000,
|
||||
MGA_DMAPAD, 0x00000000 );
|
||||
|
||||
ADVANCE_DMA();
|
||||
|
||||
primary->last_flush = primary->tail;
|
||||
|
||||
head = MGA_READ( MGA_PRIMADDRESS );
|
||||
|
||||
if ( head <= tail ) {
|
||||
primary->space = primary->size - primary->tail;
|
||||
} else {
|
||||
primary->space = head - tail;
|
||||
}
|
||||
|
||||
DRM_DEBUG( " head = 0x%06lx\n", head - dev_priv->primary->offset );
|
||||
DRM_DEBUG( " tail = 0x%06lx\n", tail - dev_priv->primary->offset );
|
||||
DRM_DEBUG( " space = 0x%06x\n", primary->space );
|
||||
|
||||
mga_flush_write_combine();
|
||||
MGA_WRITE( MGA_PRIMEND, tail | MGA_PAGPXFER );
|
||||
|
||||
DRM_DEBUG( "done.\n" );
|
||||
}
|
||||
|
||||
void mga_do_dma_wrap_start( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
drm_mga_primary_buffer_t *primary = &dev_priv->prim;
|
||||
u32 head, tail;
|
||||
DMA_LOCALS;
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
BEGIN_DMA_WRAP();
|
||||
|
||||
DMA_BLOCK( MGA_DMAPAD, 0x00000000,
|
||||
MGA_DMAPAD, 0x00000000,
|
||||
MGA_DMAPAD, 0x00000000,
|
||||
MGA_DMAPAD, 0x00000000 );
|
||||
|
||||
ADVANCE_DMA();
|
||||
|
||||
tail = primary->tail + dev_priv->primary->offset;
|
||||
|
||||
primary->tail = 0;
|
||||
primary->last_flush = 0;
|
||||
primary->last_wrap++;
|
||||
|
||||
head = MGA_READ( MGA_PRIMADDRESS );
|
||||
|
||||
if ( head == dev_priv->primary->offset ) {
|
||||
primary->space = primary->size;
|
||||
} else {
|
||||
primary->space = head - dev_priv->primary->offset;
|
||||
}
|
||||
|
||||
DRM_DEBUG( " head = 0x%06lx\n",
|
||||
head - dev_priv->primary->offset );
|
||||
DRM_DEBUG( " tail = 0x%06x\n", primary->tail );
|
||||
DRM_DEBUG( " wrap = %d\n", primary->last_wrap );
|
||||
DRM_DEBUG( " space = 0x%06x\n", primary->space );
|
||||
|
||||
mga_flush_write_combine();
|
||||
MGA_WRITE( MGA_PRIMEND, tail | MGA_PAGPXFER );
|
||||
|
||||
set_bit( 0, &primary->wrapped );
|
||||
DRM_DEBUG( "done.\n" );
|
||||
}
|
||||
|
||||
void mga_do_dma_wrap_end( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
drm_mga_primary_buffer_t *primary = &dev_priv->prim;
|
||||
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
||||
u32 head = dev_priv->primary->offset;
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
sarea_priv->last_wrap++;
|
||||
DRM_DEBUG( " wrap = %d\n", sarea_priv->last_wrap );
|
||||
|
||||
mga_flush_write_combine();
|
||||
MGA_WRITE( MGA_PRIMADDRESS, head | MGA_DMA_GENERAL );
|
||||
|
||||
clear_bit( 0, &primary->wrapped );
|
||||
DRM_DEBUG( "done.\n" );
|
||||
}
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Freelist management
|
||||
*/
|
||||
|
||||
#define MGA_BUFFER_USED ~0
|
||||
#define MGA_BUFFER_FREE 0
|
||||
|
||||
#if MGA_FREELIST_DEBUG
|
||||
static void mga_freelist_print( drm_device_t *dev )
|
||||
{
|
||||
drm_mga_private_t *dev_priv = dev->dev_private;
|
||||
drm_mga_freelist_t *entry;
|
||||
|
||||
DRM_INFO( "\n" );
|
||||
DRM_INFO( "current dispatch: last=0x%x done=0x%x\n",
|
||||
dev_priv->sarea_priv->last_dispatch,
|
||||
(unsigned int)(MGA_READ( MGA_PRIMADDRESS ) -
|
||||
dev_priv->primary->offset) );
|
||||
DRM_INFO( "current freelist:\n" );
|
||||
|
||||
for ( entry = dev_priv->head->next ; entry ; entry = entry->next ) {
|
||||
DRM_INFO( " %p idx=%2d age=0x%x 0x%06lx\n",
|
||||
entry, entry->buf->idx, entry->age.head,
|
||||
entry->age.head - dev_priv->primary->offset );
|
||||
}
|
||||
DRM_INFO( "\n" );
|
||||
}
|
||||
#endif
|
||||
|
||||
static int mga_freelist_init( drm_device_t *dev, drm_mga_private_t *dev_priv )
|
||||
{
|
||||
drm_device_dma_t *dma = dev->dma;
|
||||
drm_buf_t *buf;
|
||||
drm_mga_buf_priv_t *buf_priv;
|
||||
drm_mga_freelist_t *entry;
|
||||
int i;
|
||||
DRM_DEBUG( "count=%d\n", dma->buf_count );
|
||||
|
||||
dev_priv->head = DRM(alloc)( sizeof(drm_mga_freelist_t),
|
||||
DRM_MEM_DRIVER );
|
||||
if ( dev_priv->head == NULL )
|
||||
return DRM_ERR(ENOMEM);
|
||||
|
||||
memset( dev_priv->head, 0, sizeof(drm_mga_freelist_t) );
|
||||
SET_AGE( &dev_priv->head->age, MGA_BUFFER_USED, 0 );
|
||||
|
||||
for ( i = 0 ; i < dma->buf_count ; i++ ) {
|
||||
buf = dma->buflist[i];
|
||||
buf_priv = buf->dev_private;
|
||||
|
||||
entry = DRM(alloc)( sizeof(drm_mga_freelist_t),
|
||||
DRM_MEM_DRIVER );
|
||||
if ( entry == NULL )
|
||||
return DRM_ERR(ENOMEM);
|
||||
|
||||
memset( entry, 0, sizeof(drm_mga_freelist_t) );
|
||||
|
||||
entry->next = dev_priv->head->next;
|
||||
entry->prev = dev_priv->head;
|
||||
SET_AGE( &entry->age, MGA_BUFFER_FREE, 0 );
|
||||
entry->buf = buf;
|
||||
|
||||
if ( dev_priv->head->next != NULL )
|
||||
dev_priv->head->next->prev = entry;
|
||||
if ( entry->next == NULL )
|
||||
dev_priv->tail = entry;
|
||||
|
||||
buf_priv->list_entry = entry;
|
||||
buf_priv->discard = 0;
|
||||
buf_priv->dispatched = 0;
|
||||
|
||||
dev_priv->head->next = entry;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mga_freelist_cleanup( drm_device_t *dev )
|
||||
{
|
||||
drm_mga_private_t *dev_priv = dev->dev_private;
|
||||
drm_mga_freelist_t *entry;
|
||||
drm_mga_freelist_t *next;
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
entry = dev_priv->head;
|
||||
while ( entry ) {
|
||||
next = entry->next;
|
||||
DRM(free)( entry, sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER );
|
||||
entry = next;
|
||||
}
|
||||
|
||||
dev_priv->head = dev_priv->tail = NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* FIXME: Still needed?
|
||||
*/
|
||||
static void mga_freelist_reset( drm_device_t *dev )
|
||||
{
|
||||
drm_device_dma_t *dma = dev->dma;
|
||||
drm_buf_t *buf;
|
||||
drm_mga_buf_priv_t *buf_priv;
|
||||
int i;
|
||||
|
||||
for ( i = 0 ; i < dma->buf_count ; i++ ) {
|
||||
buf = dma->buflist[i];
|
||||
buf_priv = buf->dev_private;
|
||||
SET_AGE( &buf_priv->list_entry->age,
|
||||
MGA_BUFFER_FREE, 0 );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static drm_buf_t *mga_freelist_get( drm_device_t *dev )
|
||||
{
|
||||
drm_mga_private_t *dev_priv = dev->dev_private;
|
||||
drm_mga_freelist_t *next;
|
||||
drm_mga_freelist_t *prev;
|
||||
drm_mga_freelist_t *tail = dev_priv->tail;
|
||||
u32 head, wrap;
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
head = MGA_READ( MGA_PRIMADDRESS );
|
||||
wrap = dev_priv->sarea_priv->last_wrap;
|
||||
|
||||
DRM_DEBUG( " tail=0x%06lx %d\n",
|
||||
tail->age.head ?
|
||||
tail->age.head - dev_priv->primary->offset : 0,
|
||||
tail->age.wrap );
|
||||
DRM_DEBUG( " head=0x%06lx %d\n",
|
||||
head - dev_priv->primary->offset, wrap );
|
||||
|
||||
if ( TEST_AGE( &tail->age, head, wrap ) ) {
|
||||
prev = dev_priv->tail->prev;
|
||||
next = dev_priv->tail;
|
||||
prev->next = NULL;
|
||||
next->prev = next->next = NULL;
|
||||
dev_priv->tail = prev;
|
||||
SET_AGE( &next->age, MGA_BUFFER_USED, 0 );
|
||||
return next->buf;
|
||||
}
|
||||
|
||||
DRM_DEBUG( "returning NULL!\n" );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int mga_freelist_put( drm_device_t *dev, drm_buf_t *buf )
|
||||
{
|
||||
drm_mga_private_t *dev_priv = dev->dev_private;
|
||||
drm_mga_buf_priv_t *buf_priv = buf->dev_private;
|
||||
drm_mga_freelist_t *head, *entry, *prev;
|
||||
|
||||
DRM_DEBUG( "age=0x%06lx wrap=%d\n",
|
||||
buf_priv->list_entry->age.head -
|
||||
dev_priv->primary->offset,
|
||||
buf_priv->list_entry->age.wrap );
|
||||
|
||||
entry = buf_priv->list_entry;
|
||||
head = dev_priv->head;
|
||||
|
||||
if ( buf_priv->list_entry->age.head == MGA_BUFFER_USED ) {
|
||||
SET_AGE( &entry->age, MGA_BUFFER_FREE, 0 );
|
||||
prev = dev_priv->tail;
|
||||
prev->next = entry;
|
||||
entry->prev = prev;
|
||||
entry->next = NULL;
|
||||
} else {
|
||||
prev = head->next;
|
||||
head->next = entry;
|
||||
prev->prev = entry;
|
||||
entry->prev = head;
|
||||
entry->next = prev;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* DMA initialization, cleanup
|
||||
*/
|
||||
|
||||
static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
|
||||
{
|
||||
drm_mga_private_t *dev_priv;
|
||||
int ret;
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
dev_priv = DRM(alloc)( sizeof(drm_mga_private_t), DRM_MEM_DRIVER );
|
||||
if ( !dev_priv )
|
||||
return DRM_ERR(ENOMEM);
|
||||
|
||||
memset( dev_priv, 0, sizeof(drm_mga_private_t) );
|
||||
|
||||
dev_priv->chipset = init->chipset;
|
||||
|
||||
dev_priv->usec_timeout = MGA_DEFAULT_USEC_TIMEOUT;
|
||||
|
||||
if ( init->sgram ) {
|
||||
dev_priv->clear_cmd = MGA_DWGCTL_CLEAR | MGA_ATYPE_BLK;
|
||||
} else {
|
||||
dev_priv->clear_cmd = MGA_DWGCTL_CLEAR | MGA_ATYPE_RSTR;
|
||||
}
|
||||
dev_priv->maccess = init->maccess;
|
||||
|
||||
dev_priv->fb_cpp = init->fb_cpp;
|
||||
dev_priv->front_offset = init->front_offset;
|
||||
dev_priv->front_pitch = init->front_pitch;
|
||||
dev_priv->back_offset = init->back_offset;
|
||||
dev_priv->back_pitch = init->back_pitch;
|
||||
|
||||
dev_priv->depth_cpp = init->depth_cpp;
|
||||
dev_priv->depth_offset = init->depth_offset;
|
||||
dev_priv->depth_pitch = init->depth_pitch;
|
||||
|
||||
/* FIXME: Need to support AGP textures...
|
||||
*/
|
||||
dev_priv->texture_offset = init->texture_offset[0];
|
||||
dev_priv->texture_size = init->texture_size[0];
|
||||
|
||||
DRM_GETSAREA();
|
||||
|
||||
if(!dev_priv->sarea) {
|
||||
DRM_ERROR( "failed to find sarea!\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
|
||||
DRM_FIND_MAP( dev_priv->fb, init->fb_offset );
|
||||
if(!dev_priv->fb) {
|
||||
DRM_ERROR( "failed to find framebuffer!\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset );
|
||||
if(!dev_priv->mmio) {
|
||||
DRM_ERROR( "failed to find mmio region!\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
DRM_FIND_MAP( dev_priv->status, init->status_offset );
|
||||
if(!dev_priv->status) {
|
||||
DRM_ERROR( "failed to find status page!\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
|
||||
DRM_FIND_MAP( dev_priv->warp, init->warp_offset );
|
||||
if(!dev_priv->warp) {
|
||||
DRM_ERROR( "failed to find warp microcode region!\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
DRM_FIND_MAP( dev_priv->primary, init->primary_offset );
|
||||
if(!dev_priv->primary) {
|
||||
DRM_ERROR( "failed to find primary dma region!\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
|
||||
if(!dev_priv->buffers) {
|
||||
DRM_ERROR( "failed to find dma buffer region!\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
|
||||
dev_priv->sarea_priv =
|
||||
(drm_mga_sarea_t *)((u8 *)dev_priv->sarea->handle +
|
||||
init->sarea_priv_offset);
|
||||
|
||||
DRM_IOREMAP( dev_priv->warp );
|
||||
DRM_IOREMAP( dev_priv->primary );
|
||||
DRM_IOREMAP( dev_priv->buffers );
|
||||
|
||||
if(!dev_priv->warp->handle ||
|
||||
!dev_priv->primary->handle ||
|
||||
!dev_priv->buffers->handle ) {
|
||||
DRM_ERROR( "failed to ioremap agp regions!\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return DRM_ERR(ENOMEM);
|
||||
}
|
||||
|
||||
ret = mga_warp_install_microcode( dev_priv );
|
||||
if ( ret < 0 ) {
|
||||
DRM_ERROR( "failed to install WARP ucode!\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = mga_warp_init( dev_priv );
|
||||
if ( ret < 0 ) {
|
||||
DRM_ERROR( "failed to init WARP engine!\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return ret;
|
||||
}
|
||||
|
||||
dev_priv->prim.status = (u32 *)dev_priv->status->handle;
|
||||
|
||||
mga_do_wait_for_idle( dev_priv );
|
||||
|
||||
/* Init the primary DMA registers.
|
||||
*/
|
||||
MGA_WRITE( MGA_PRIMADDRESS,
|
||||
dev_priv->primary->offset | MGA_DMA_GENERAL );
|
||||
#if 0
|
||||
MGA_WRITE( MGA_PRIMPTR,
|
||||
virt_to_bus((void *)dev_priv->prim.status) |
|
||||
MGA_PRIMPTREN0 | /* Soft trap, SECEND, SETUPEND */
|
||||
MGA_PRIMPTREN1 ); /* DWGSYNC */
|
||||
#endif
|
||||
|
||||
dev_priv->prim.start = (u8 *)dev_priv->primary->handle;
|
||||
dev_priv->prim.end = ((u8 *)dev_priv->primary->handle
|
||||
+ dev_priv->primary->size);
|
||||
dev_priv->prim.size = dev_priv->primary->size;
|
||||
|
||||
dev_priv->prim.tail = 0;
|
||||
dev_priv->prim.space = dev_priv->prim.size;
|
||||
dev_priv->prim.wrapped = 0;
|
||||
|
||||
dev_priv->prim.last_flush = 0;
|
||||
dev_priv->prim.last_wrap = 0;
|
||||
|
||||
dev_priv->prim.high_mark = 256 * DMA_BLOCK_SIZE;
|
||||
|
||||
dev_priv->prim.status[0] = dev_priv->primary->offset;
|
||||
dev_priv->prim.status[1] = 0;
|
||||
|
||||
dev_priv->sarea_priv->last_wrap = 0;
|
||||
dev_priv->sarea_priv->last_frame.head = 0;
|
||||
dev_priv->sarea_priv->last_frame.wrap = 0;
|
||||
|
||||
if ( mga_freelist_init( dev, dev_priv ) < 0 ) {
|
||||
DRM_ERROR( "could not initialize freelist\n" );
|
||||
/* Assign dev_private so we can do cleanup. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
mga_do_cleanup_dma( dev );
|
||||
return DRM_ERR(ENOMEM);
|
||||
}
|
||||
|
||||
/* Make dev_private visable to others. */
|
||||
dev->dev_private = (void *)dev_priv;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mga_do_cleanup_dma( drm_device_t *dev )
|
||||
{
|
||||
DRM_DEBUG( "\n" );
|
||||
|
||||
if ( dev->dev_private ) {
|
||||
drm_mga_private_t *dev_priv = dev->dev_private;
|
||||
|
||||
DRM_IOREMAPFREE( dev_priv->warp );
|
||||
DRM_IOREMAPFREE( dev_priv->primary );
|
||||
DRM_IOREMAPFREE( dev_priv->buffers );
|
||||
|
||||
if ( dev_priv->head != NULL ) {
|
||||
mga_freelist_cleanup( dev );
|
||||
}
|
||||
|
||||
DRM(free)( dev->dev_private, sizeof(drm_mga_private_t),
|
||||
DRM_MEM_DRIVER );
|
||||
dev->dev_private = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mga_dma_init( DRM_IOCTL_ARGS )
|
||||
{
|
||||
DRM_DEVICE;
|
||||
drm_mga_init_t init;
|
||||
|
||||
DRM_COPY_FROM_USER_IOCTL( init, (drm_mga_init_t *)data, sizeof(init) );
|
||||
|
||||
switch ( init.func ) {
|
||||
case MGA_INIT_DMA:
|
||||
return mga_do_init_dma( dev, &init );
|
||||
case MGA_CLEANUP_DMA:
|
||||
return mga_do_cleanup_dma( dev );
|
||||
}
|
||||
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Primary DMA stream management
|
||||
*/
|
||||
|
||||
int mga_dma_flush( DRM_IOCTL_ARGS )
|
||||
{
|
||||
DRM_DEVICE;
|
||||
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
|
||||
drm_lock_t lock;
|
||||
|
||||
LOCK_TEST_WITH_RETURN( dev );
|
||||
|
||||
DRM_COPY_FROM_USER_IOCTL( lock, (drm_lock_t *)data, sizeof(lock) );
|
||||
|
||||
DRM_DEBUG( "%s%s%s\n",
|
||||
(lock.flags & _DRM_LOCK_FLUSH) ? "flush, " : "",
|
||||
(lock.flags & _DRM_LOCK_FLUSH_ALL) ? "flush all, " : "",
|
||||
(lock.flags & _DRM_LOCK_QUIESCENT) ? "idle, " : "" );
|
||||
|
||||
WRAP_WAIT_WITH_RETURN( dev_priv );
|
||||
|
||||
if ( lock.flags & (_DRM_LOCK_FLUSH | _DRM_LOCK_FLUSH_ALL) ) {
|
||||
mga_do_dma_flush( dev_priv );
|
||||
}
|
||||
|
||||
if ( lock.flags & _DRM_LOCK_QUIESCENT ) {
|
||||
#if MGA_DMA_DEBUG
|
||||
int ret = mga_do_wait_for_idle( dev_priv );
|
||||
if ( ret < 0 )
|
||||
DRM_INFO( "%s: -EBUSY\n", __func__ );
|
||||
return ret;
|
||||
#else
|
||||
return mga_do_wait_for_idle( dev_priv );
|
||||
#endif
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int mga_dma_reset( DRM_IOCTL_ARGS )
|
||||
{
|
||||
DRM_DEVICE;
|
||||
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
|
||||
|
||||
LOCK_TEST_WITH_RETURN( dev );
|
||||
|
||||
return mga_do_dma_reset( dev_priv );
|
||||
}
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* DMA buffer management
|
||||
*/
|
||||
|
||||
static int mga_dma_get_buffers( drm_device_t *dev, drm_dma_t *d )
|
||||
{
|
||||
drm_buf_t *buf;
|
||||
int i;
|
||||
|
||||
for ( i = d->granted_count ; i < d->request_count ; i++ ) {
|
||||
buf = mga_freelist_get( dev );
|
||||
if ( !buf ) return DRM_ERR(EAGAIN);
|
||||
|
||||
buf->pid = DRM_CURRENTPID;
|
||||
|
||||
if ( DRM_COPY_TO_USER( &d->request_indices[i],
|
||||
&buf->idx, sizeof(buf->idx) ) )
|
||||
return DRM_ERR(EFAULT);
|
||||
if ( DRM_COPY_TO_USER( &d->request_sizes[i],
|
||||
&buf->total, sizeof(buf->total) ) )
|
||||
return DRM_ERR(EFAULT);
|
||||
|
||||
d->granted_count++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mga_dma_buffers( DRM_IOCTL_ARGS )
|
||||
{
|
||||
DRM_DEVICE;
|
||||
drm_device_dma_t *dma = dev->dma;
|
||||
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
|
||||
drm_dma_t d;
|
||||
int ret = 0;
|
||||
|
||||
LOCK_TEST_WITH_RETURN( dev );
|
||||
|
||||
DRM_COPY_FROM_USER_IOCTL( d, (drm_dma_t *)data, sizeof(d) );
|
||||
|
||||
/* Please don't send us buffers.
|
||||
*/
|
||||
if ( d.send_count != 0 ) {
|
||||
DRM_ERROR( "Process %d trying to send %d buffers via drmDMA\n",
|
||||
DRM_CURRENTPID, d.send_count );
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
|
||||
/* We'll send you buffers.
|
||||
*/
|
||||
if ( d.request_count < 0 || d.request_count > dma->buf_count ) {
|
||||
DRM_ERROR( "Process %d trying to get %d buffers (of %d max)\n",
|
||||
DRM_CURRENTPID, d.request_count, dma->buf_count );
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
|
||||
WRAP_TEST_WITH_RETURN( dev_priv );
|
||||
|
||||
d.granted_count = 0;
|
||||
|
||||
if ( d.request_count ) {
|
||||
ret = mga_dma_get_buffers( dev, &d );
|
||||
}
|
||||
|
||||
DRM_COPY_TO_USER_IOCTL( (drm_dma_t *)data, d, sizeof(d) );
|
||||
|
||||
return ret;
|
||||
}
|
||||
325
shared/mga_drm.h
Normal file
325
shared/mga_drm.h
Normal file
|
|
@ -0,0 +1,325 @@
|
|||
/* mga_drm.h -- Public header for the Matrox g200/g400 driver -*- linux-c -*-
|
||||
* Created: Tue Jan 25 01:50:01 1999 by jhartmann@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS 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.
|
||||
*
|
||||
* Authors:
|
||||
* Jeff Hartmann <jhartmann@valinux.com>
|
||||
* Keith Whitwell <keithw@valinux.com>
|
||||
*
|
||||
* Rewritten by:
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#ifndef __MGA_DRM_H__
|
||||
#define __MGA_DRM_H__
|
||||
|
||||
/* WARNING: If you change any of these defines, make sure to change the
|
||||
* defines in the Xserver file (mga_sarea.h)
|
||||
*/
|
||||
|
||||
#ifndef __MGA_SAREA_DEFINES__
|
||||
#define __MGA_SAREA_DEFINES__
|
||||
|
||||
/* WARP pipe flags
|
||||
*/
|
||||
#define MGA_F 0x1 /* fog */
|
||||
#define MGA_A 0x2 /* alpha */
|
||||
#define MGA_S 0x4 /* specular */
|
||||
#define MGA_T2 0x8 /* multitexture */
|
||||
|
||||
#define MGA_WARP_TGZ 0
|
||||
#define MGA_WARP_TGZF (MGA_F)
|
||||
#define MGA_WARP_TGZA (MGA_A)
|
||||
#define MGA_WARP_TGZAF (MGA_F|MGA_A)
|
||||
#define MGA_WARP_TGZS (MGA_S)
|
||||
#define MGA_WARP_TGZSF (MGA_S|MGA_F)
|
||||
#define MGA_WARP_TGZSA (MGA_S|MGA_A)
|
||||
#define MGA_WARP_TGZSAF (MGA_S|MGA_F|MGA_A)
|
||||
#define MGA_WARP_T2GZ (MGA_T2)
|
||||
#define MGA_WARP_T2GZF (MGA_T2|MGA_F)
|
||||
#define MGA_WARP_T2GZA (MGA_T2|MGA_A)
|
||||
#define MGA_WARP_T2GZAF (MGA_T2|MGA_A|MGA_F)
|
||||
#define MGA_WARP_T2GZS (MGA_T2|MGA_S)
|
||||
#define MGA_WARP_T2GZSF (MGA_T2|MGA_S|MGA_F)
|
||||
#define MGA_WARP_T2GZSA (MGA_T2|MGA_S|MGA_A)
|
||||
#define MGA_WARP_T2GZSAF (MGA_T2|MGA_S|MGA_F|MGA_A)
|
||||
|
||||
#define MGA_MAX_G200_PIPES 8 /* no multitex */
|
||||
#define MGA_MAX_G400_PIPES 16
|
||||
#define MGA_MAX_WARP_PIPES MGA_MAX_G400_PIPES
|
||||
#define MGA_WARP_UCODE_SIZE 32768 /* in bytes */
|
||||
|
||||
#define MGA_CARD_TYPE_G200 1
|
||||
#define MGA_CARD_TYPE_G400 2
|
||||
|
||||
|
||||
#define MGA_FRONT 0x1
|
||||
#define MGA_BACK 0x2
|
||||
#define MGA_DEPTH 0x4
|
||||
|
||||
/* What needs to be changed for the current vertex dma buffer?
|
||||
*/
|
||||
#define MGA_UPLOAD_CONTEXT 0x1
|
||||
#define MGA_UPLOAD_TEX0 0x2
|
||||
#define MGA_UPLOAD_TEX1 0x4
|
||||
#define MGA_UPLOAD_PIPE 0x8
|
||||
#define MGA_UPLOAD_TEX0IMAGE 0x10 /* handled client-side */
|
||||
#define MGA_UPLOAD_TEX1IMAGE 0x20 /* handled client-side */
|
||||
#define MGA_UPLOAD_2D 0x40
|
||||
#define MGA_WAIT_AGE 0x80 /* handled client-side */
|
||||
#define MGA_UPLOAD_CLIPRECTS 0x100 /* handled client-side */
|
||||
#if 0
|
||||
#define MGA_DMA_FLUSH 0x200 /* set when someone gets the lock
|
||||
quiescent */
|
||||
#endif
|
||||
|
||||
/* 32 buffers of 64k each, total 2 meg.
|
||||
*/
|
||||
#define MGA_BUFFER_SIZE (1 << 16)
|
||||
#define MGA_NUM_BUFFERS 128
|
||||
|
||||
/* Keep these small for testing.
|
||||
*/
|
||||
#define MGA_NR_SAREA_CLIPRECTS 8
|
||||
|
||||
/* 2 heaps (1 for card, 1 for agp), each divided into upto 128
|
||||
* regions, subject to a minimum region size of (1<<16) == 64k.
|
||||
*
|
||||
* Clients may subdivide regions internally, but when sharing between
|
||||
* clients, the region size is the minimum granularity.
|
||||
*/
|
||||
|
||||
#define MGA_CARD_HEAP 0
|
||||
#define MGA_AGP_HEAP 1
|
||||
#define MGA_NR_TEX_HEAPS 2
|
||||
#define MGA_NR_TEX_REGIONS 16
|
||||
#define MGA_LOG_MIN_TEX_REGION_SIZE 16
|
||||
|
||||
#endif /* __MGA_SAREA_DEFINES__ */
|
||||
|
||||
|
||||
/* Setup registers for 3D context
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int dstorg;
|
||||
unsigned int maccess;
|
||||
unsigned int plnwt;
|
||||
unsigned int dwgctl;
|
||||
unsigned int alphactrl;
|
||||
unsigned int fogcolor;
|
||||
unsigned int wflag;
|
||||
unsigned int tdualstage0;
|
||||
unsigned int tdualstage1;
|
||||
unsigned int fcol;
|
||||
unsigned int stencil;
|
||||
unsigned int stencilctl;
|
||||
} drm_mga_context_regs_t;
|
||||
|
||||
/* Setup registers for 2D, X server
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int pitch;
|
||||
} drm_mga_server_regs_t;
|
||||
|
||||
/* Setup registers for each texture unit
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int texctl;
|
||||
unsigned int texctl2;
|
||||
unsigned int texfilter;
|
||||
unsigned int texbordercol;
|
||||
unsigned int texorg;
|
||||
unsigned int texwidth;
|
||||
unsigned int texheight;
|
||||
unsigned int texorg1;
|
||||
unsigned int texorg2;
|
||||
unsigned int texorg3;
|
||||
unsigned int texorg4;
|
||||
} drm_mga_texture_regs_t;
|
||||
|
||||
/* General aging mechanism
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int head; /* Position of head pointer */
|
||||
unsigned int wrap; /* Primary DMA wrap count */
|
||||
} drm_mga_age_t;
|
||||
|
||||
typedef struct _drm_mga_sarea {
|
||||
/* The channel for communication of state information to the kernel
|
||||
* on firing a vertex dma buffer.
|
||||
*/
|
||||
drm_mga_context_regs_t context_state;
|
||||
drm_mga_server_regs_t server_state;
|
||||
drm_mga_texture_regs_t tex_state[2];
|
||||
unsigned int warp_pipe;
|
||||
unsigned int dirty;
|
||||
unsigned int vertsize;
|
||||
|
||||
/* The current cliprects, or a subset thereof.
|
||||
*/
|
||||
drm_clip_rect_t boxes[MGA_NR_SAREA_CLIPRECTS];
|
||||
unsigned int nbox;
|
||||
|
||||
/* Information about the most recently used 3d drawable. The
|
||||
* client fills in the req_* fields, the server fills in the
|
||||
* exported_ fields and puts the cliprects into boxes, above.
|
||||
*
|
||||
* The client clears the exported_drawable field before
|
||||
* clobbering the boxes data.
|
||||
*/
|
||||
unsigned int req_drawable; /* the X drawable id */
|
||||
unsigned int req_draw_buffer; /* MGA_FRONT or MGA_BACK */
|
||||
|
||||
unsigned int exported_drawable;
|
||||
unsigned int exported_index;
|
||||
unsigned int exported_stamp;
|
||||
unsigned int exported_buffers;
|
||||
unsigned int exported_nfront;
|
||||
unsigned int exported_nback;
|
||||
int exported_back_x, exported_front_x, exported_w;
|
||||
int exported_back_y, exported_front_y, exported_h;
|
||||
drm_clip_rect_t exported_boxes[MGA_NR_SAREA_CLIPRECTS];
|
||||
|
||||
/* Counters for aging textures and for client-side throttling.
|
||||
*/
|
||||
unsigned int status[4];
|
||||
unsigned int last_wrap;
|
||||
|
||||
drm_mga_age_t last_frame;
|
||||
unsigned int last_enqueue; /* last time a buffer was enqueued */
|
||||
unsigned int last_dispatch; /* age of the most recently dispatched buffer */
|
||||
unsigned int last_quiescent; /* */
|
||||
|
||||
/* LRU lists for texture memory in agp space and on the card.
|
||||
*/
|
||||
drm_tex_region_t texList[MGA_NR_TEX_HEAPS][MGA_NR_TEX_REGIONS+1];
|
||||
unsigned int texAge[MGA_NR_TEX_HEAPS];
|
||||
|
||||
/* Mechanism to validate card state.
|
||||
*/
|
||||
int ctxOwner;
|
||||
} drm_mga_sarea_t;
|
||||
|
||||
|
||||
/* WARNING: If you change any of these defines, make sure to change the
|
||||
* defines in the Xserver file (xf86drmMga.h)
|
||||
*/
|
||||
|
||||
/* MGA specific ioctls
|
||||
* The device specific ioctl range is 0x40 to 0x79.
|
||||
*/
|
||||
#define DRM_IOCTL_MGA_INIT DRM_IOW( 0x40, drm_mga_init_t)
|
||||
#define DRM_IOCTL_MGA_FLUSH DRM_IOW( 0x41, drm_lock_t)
|
||||
#define DRM_IOCTL_MGA_RESET DRM_IO( 0x42)
|
||||
#define DRM_IOCTL_MGA_SWAP DRM_IO( 0x43)
|
||||
#define DRM_IOCTL_MGA_CLEAR DRM_IOW( 0x44, drm_mga_clear_t)
|
||||
#define DRM_IOCTL_MGA_VERTEX DRM_IOW( 0x45, drm_mga_vertex_t)
|
||||
#define DRM_IOCTL_MGA_INDICES DRM_IOW( 0x46, drm_mga_indices_t)
|
||||
#define DRM_IOCTL_MGA_ILOAD DRM_IOW( 0x47, drm_mga_iload_t)
|
||||
#define DRM_IOCTL_MGA_BLIT DRM_IOW( 0x48, drm_mga_blit_t)
|
||||
|
||||
typedef struct _drm_mga_warp_index {
|
||||
int installed;
|
||||
unsigned long phys_addr;
|
||||
int size;
|
||||
} drm_mga_warp_index_t;
|
||||
|
||||
typedef struct drm_mga_init {
|
||||
enum {
|
||||
MGA_INIT_DMA = 0x01,
|
||||
MGA_CLEANUP_DMA = 0x02
|
||||
} func;
|
||||
|
||||
unsigned long sarea_priv_offset;
|
||||
|
||||
int chipset;
|
||||
int sgram;
|
||||
|
||||
unsigned int maccess;
|
||||
|
||||
unsigned int fb_cpp;
|
||||
unsigned int front_offset, front_pitch;
|
||||
unsigned int back_offset, back_pitch;
|
||||
|
||||
unsigned int depth_cpp;
|
||||
unsigned int depth_offset, depth_pitch;
|
||||
|
||||
unsigned int texture_offset[MGA_NR_TEX_HEAPS];
|
||||
unsigned int texture_size[MGA_NR_TEX_HEAPS];
|
||||
|
||||
unsigned long fb_offset;
|
||||
unsigned long mmio_offset;
|
||||
unsigned long status_offset;
|
||||
unsigned long warp_offset;
|
||||
unsigned long primary_offset;
|
||||
unsigned long buffers_offset;
|
||||
} drm_mga_init_t;
|
||||
|
||||
typedef struct drm_mga_fullscreen {
|
||||
enum {
|
||||
MGA_INIT_FULLSCREEN = 0x01,
|
||||
MGA_CLEANUP_FULLSCREEN = 0x02
|
||||
} func;
|
||||
} drm_mga_fullscreen_t;
|
||||
|
||||
typedef struct drm_mga_clear {
|
||||
unsigned int flags;
|
||||
unsigned int clear_color;
|
||||
unsigned int clear_depth;
|
||||
unsigned int color_mask;
|
||||
unsigned int depth_mask;
|
||||
} drm_mga_clear_t;
|
||||
|
||||
typedef struct drm_mga_vertex {
|
||||
int idx; /* buffer to queue */
|
||||
int used; /* bytes in use */
|
||||
int discard; /* client finished with buffer? */
|
||||
} drm_mga_vertex_t;
|
||||
|
||||
typedef struct drm_mga_indices {
|
||||
int idx; /* buffer to queue */
|
||||
unsigned int start;
|
||||
unsigned int end;
|
||||
int discard; /* client finished with buffer? */
|
||||
} drm_mga_indices_t;
|
||||
|
||||
typedef struct drm_mga_iload {
|
||||
int idx;
|
||||
unsigned int dstorg;
|
||||
unsigned int length;
|
||||
} drm_mga_iload_t;
|
||||
|
||||
typedef struct _drm_mga_blit {
|
||||
unsigned int planemask;
|
||||
unsigned int srcorg;
|
||||
unsigned int dstorg;
|
||||
int src_pitch, dst_pitch;
|
||||
int delta_sx, delta_sy;
|
||||
int delta_dx, delta_dy;
|
||||
int height, ydir; /* flip image vertically */
|
||||
int source_pitch, dest_pitch;
|
||||
} drm_mga_blit_t;
|
||||
|
||||
#endif
|
||||
631
shared/mga_drv.h
Normal file
631
shared/mga_drv.h
Normal file
|
|
@ -0,0 +1,631 @@
|
|||
/* mga_drv.h -- Private header for the Matrox G200/G400 driver -*- linux-c -*-
|
||||
* Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS 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.
|
||||
*
|
||||
* Authors:
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#ifndef __MGA_DRV_H__
|
||||
#define __MGA_DRV_H__
|
||||
|
||||
typedef struct drm_mga_primary_buffer {
|
||||
u8 *start;
|
||||
u8 *end;
|
||||
int size;
|
||||
|
||||
u32 tail;
|
||||
int space;
|
||||
int wrapped;
|
||||
|
||||
volatile u32 *status;
|
||||
|
||||
u32 last_flush;
|
||||
u32 last_wrap;
|
||||
|
||||
u32 high_mark;
|
||||
} drm_mga_primary_buffer_t;
|
||||
|
||||
typedef struct drm_mga_freelist {
|
||||
struct drm_mga_freelist *next;
|
||||
struct drm_mga_freelist *prev;
|
||||
drm_mga_age_t age;
|
||||
drm_buf_t *buf;
|
||||
} drm_mga_freelist_t;
|
||||
|
||||
typedef struct {
|
||||
drm_mga_freelist_t *list_entry;
|
||||
int discard;
|
||||
int dispatched;
|
||||
} drm_mga_buf_priv_t;
|
||||
|
||||
typedef struct drm_mga_private {
|
||||
drm_mga_primary_buffer_t prim;
|
||||
drm_mga_sarea_t *sarea_priv;
|
||||
|
||||
drm_mga_freelist_t *head;
|
||||
drm_mga_freelist_t *tail;
|
||||
|
||||
unsigned int warp_pipe;
|
||||
unsigned long warp_pipe_phys[MGA_MAX_WARP_PIPES];
|
||||
|
||||
int chipset;
|
||||
int usec_timeout;
|
||||
|
||||
u32 clear_cmd;
|
||||
u32 maccess;
|
||||
|
||||
unsigned int fb_cpp;
|
||||
unsigned int front_offset;
|
||||
unsigned int front_pitch;
|
||||
unsigned int back_offset;
|
||||
unsigned int back_pitch;
|
||||
|
||||
unsigned int depth_cpp;
|
||||
unsigned int depth_offset;
|
||||
unsigned int depth_pitch;
|
||||
|
||||
unsigned int texture_offset;
|
||||
unsigned int texture_size;
|
||||
|
||||
drm_map_t *sarea;
|
||||
drm_map_t *fb;
|
||||
drm_map_t *mmio;
|
||||
drm_map_t *status;
|
||||
drm_map_t *warp;
|
||||
drm_map_t *primary;
|
||||
drm_map_t *buffers;
|
||||
drm_map_t *agp_textures;
|
||||
} drm_mga_private_t;
|
||||
|
||||
/* mga_dma.c */
|
||||
extern int mga_dma_init( DRM_IOCTL_ARGS );
|
||||
extern int mga_dma_flush( DRM_IOCTL_ARGS );
|
||||
extern int mga_dma_reset( DRM_IOCTL_ARGS );
|
||||
extern int mga_dma_buffers( DRM_IOCTL_ARGS );
|
||||
|
||||
extern int mga_do_wait_for_idle( drm_mga_private_t *dev_priv );
|
||||
extern int mga_do_dma_idle( drm_mga_private_t *dev_priv );
|
||||
extern int mga_do_dma_reset( drm_mga_private_t *dev_priv );
|
||||
extern int mga_do_engine_reset( drm_mga_private_t *dev_priv );
|
||||
extern int mga_do_cleanup_dma( drm_device_t *dev );
|
||||
|
||||
extern void mga_do_dma_flush( drm_mga_private_t *dev_priv );
|
||||
extern void mga_do_dma_wrap_start( drm_mga_private_t *dev_priv );
|
||||
extern void mga_do_dma_wrap_end( drm_mga_private_t *dev_priv );
|
||||
|
||||
extern int mga_freelist_put( drm_device_t *dev, drm_buf_t *buf );
|
||||
|
||||
/* mga_state.c */
|
||||
extern int mga_dma_clear( DRM_IOCTL_ARGS );
|
||||
extern int mga_dma_swap( DRM_IOCTL_ARGS );
|
||||
extern int mga_dma_vertex( DRM_IOCTL_ARGS );
|
||||
extern int mga_dma_indices( DRM_IOCTL_ARGS );
|
||||
extern int mga_dma_iload( DRM_IOCTL_ARGS );
|
||||
extern int mga_dma_blit( DRM_IOCTL_ARGS );
|
||||
|
||||
/* mga_warp.c */
|
||||
extern int mga_warp_install_microcode( drm_mga_private_t *dev_priv );
|
||||
extern int mga_warp_init( drm_mga_private_t *dev_priv );
|
||||
|
||||
#define mga_flush_write_combine() DRM_WRITEMEMORYBARRIER()
|
||||
|
||||
|
||||
#define MGA_BASE( reg ) ((unsigned long)(dev_priv->mmio->handle))
|
||||
#define MGA_ADDR( reg ) (MGA_BASE(reg) + reg)
|
||||
|
||||
#define MGA_DEREF( reg ) *(volatile u32 *)MGA_ADDR( reg )
|
||||
#define MGA_DEREF8( reg ) *(volatile u8 *)MGA_ADDR( reg )
|
||||
|
||||
#ifdef __alpha__
|
||||
#define MGA_READ( reg ) (_MGA_READ((u32 *)MGA_ADDR(reg)))
|
||||
#define MGA_WRITE( reg, val ) do { DRM_WRITEMEMORYBARRIER(); MGA_DEREF( reg ) = val; } while (0)
|
||||
#define MGA_WRITE8( reg, val ) do { DRM_WRITEMEMORYBARRIER(); MGA_DEREF8( reg ) = val; } while (0)
|
||||
|
||||
static inline u32 _MGA_READ(u32 *addr)
|
||||
{
|
||||
DRM_READMEMORYBARRIER();
|
||||
return *(volatile u32 *)addr;
|
||||
}
|
||||
|
||||
#else
|
||||
#define MGA_READ( reg ) MGA_DEREF( reg )
|
||||
#define MGA_WRITE( reg, val ) do { MGA_DEREF( reg ) = val; } while (0)
|
||||
#define MGA_WRITE8( reg, val ) do { MGA_DEREF8( reg ) = val; } while (0)
|
||||
#endif
|
||||
|
||||
#define DWGREG0 0x1c00
|
||||
#define DWGREG0_END 0x1dff
|
||||
#define DWGREG1 0x2c00
|
||||
#define DWGREG1_END 0x2dff
|
||||
|
||||
#define ISREG0(r) (r >= DWGREG0 && r <= DWGREG0_END)
|
||||
#define DMAREG0(r) (u8)((r - DWGREG0) >> 2)
|
||||
#define DMAREG1(r) (u8)(((r - DWGREG1) >> 2) | 0x80)
|
||||
#define DMAREG(r) (ISREG0(r) ? DMAREG0(r) : DMAREG1(r))
|
||||
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Helper macross...
|
||||
*/
|
||||
|
||||
#define MGA_EMIT_STATE( dev_priv, dirty ) \
|
||||
do { \
|
||||
if ( (dirty) & ~MGA_UPLOAD_CLIPRECTS ) { \
|
||||
if ( dev_priv->chipset == MGA_CARD_TYPE_G400 ) { \
|
||||
mga_g400_emit_state( dev_priv ); \
|
||||
} else { \
|
||||
mga_g200_emit_state( dev_priv ); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define LOCK_TEST_WITH_RETURN( dev ) \
|
||||
do { \
|
||||
if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
|
||||
dev->lock.pid != DRM_CURRENTPID ) { \
|
||||
DRM_ERROR( "%s called without lock held\n", \
|
||||
__func__ ); \
|
||||
return DRM_ERR(EINVAL); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define WRAP_TEST_WITH_RETURN( dev_priv ) \
|
||||
do { \
|
||||
if ( test_bit( 0, &dev_priv->prim.wrapped ) ) { \
|
||||
if ( mga_is_idle( dev_priv ) ) { \
|
||||
mga_do_dma_wrap_end( dev_priv ); \
|
||||
} else if ( dev_priv->prim.space < \
|
||||
dev_priv->prim.high_mark ) { \
|
||||
if ( MGA_DMA_DEBUG ) \
|
||||
DRM_INFO( "%s: wrap...\n", __func__ ); \
|
||||
return DRM_ERR(EBUSY); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define WRAP_WAIT_WITH_RETURN( dev_priv ) \
|
||||
do { \
|
||||
if ( test_bit( 0, &dev_priv->prim.wrapped ) ) { \
|
||||
if ( mga_do_wait_for_idle( dev_priv ) < 0 ) { \
|
||||
if ( MGA_DMA_DEBUG ) \
|
||||
DRM_INFO( "%s: wrap...\n", __func__ ); \
|
||||
return DRM_ERR(EBUSY); \
|
||||
} \
|
||||
mga_do_dma_wrap_end( dev_priv ); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Primary DMA command stream
|
||||
*/
|
||||
|
||||
#define MGA_VERBOSE 0
|
||||
|
||||
#define DMA_LOCALS unsigned int write; volatile u8 *prim;
|
||||
|
||||
#define DMA_BLOCK_SIZE (5 * sizeof(u32))
|
||||
|
||||
#define BEGIN_DMA( n ) \
|
||||
do { \
|
||||
if ( MGA_VERBOSE ) { \
|
||||
DRM_INFO( "BEGIN_DMA( %d ) in %s\n", \
|
||||
(n), __func__ ); \
|
||||
DRM_INFO( " space=0x%x req=0x%x\n", \
|
||||
dev_priv->prim.space, (n) * DMA_BLOCK_SIZE ); \
|
||||
} \
|
||||
prim = dev_priv->prim.start; \
|
||||
write = dev_priv->prim.tail; \
|
||||
} while (0)
|
||||
|
||||
#define BEGIN_DMA_WRAP() \
|
||||
do { \
|
||||
if ( MGA_VERBOSE ) { \
|
||||
DRM_INFO( "BEGIN_DMA() in %s\n", __func__ ); \
|
||||
DRM_INFO( " space=0x%x\n", dev_priv->prim.space ); \
|
||||
} \
|
||||
prim = dev_priv->prim.start; \
|
||||
write = dev_priv->prim.tail; \
|
||||
} while (0)
|
||||
|
||||
#define ADVANCE_DMA() \
|
||||
do { \
|
||||
dev_priv->prim.tail = write; \
|
||||
if ( MGA_VERBOSE ) { \
|
||||
DRM_INFO( "ADVANCE_DMA() tail=0x%05x sp=0x%x\n", \
|
||||
write, dev_priv->prim.space ); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define FLUSH_DMA() \
|
||||
do { \
|
||||
if ( 0 ) { \
|
||||
DRM_INFO( "%s:\n", __func__ ); \
|
||||
DRM_INFO( " tail=0x%06x head=0x%06lx\n", \
|
||||
dev_priv->prim.tail, \
|
||||
MGA_READ( MGA_PRIMADDRESS ) - \
|
||||
dev_priv->primary->offset ); \
|
||||
} \
|
||||
if ( !test_bit( 0, &dev_priv->prim.wrapped ) ) { \
|
||||
if ( dev_priv->prim.space < \
|
||||
dev_priv->prim.high_mark ) { \
|
||||
mga_do_dma_wrap_start( dev_priv ); \
|
||||
} else { \
|
||||
mga_do_dma_flush( dev_priv ); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Never use this, always use DMA_BLOCK(...) for primary DMA output.
|
||||
*/
|
||||
#define DMA_WRITE( offset, val ) \
|
||||
do { \
|
||||
if ( MGA_VERBOSE ) { \
|
||||
DRM_INFO( " DMA_WRITE( 0x%08x ) at 0x%04x\n", \
|
||||
(u32)(val), write + (offset) * sizeof(u32) ); \
|
||||
} \
|
||||
*(volatile u32 *)(prim + write + (offset) * sizeof(u32)) = val; \
|
||||
} while (0)
|
||||
|
||||
#define DMA_BLOCK( reg0, val0, reg1, val1, reg2, val2, reg3, val3 ) \
|
||||
do { \
|
||||
DMA_WRITE( 0, ((DMAREG( reg0 ) << 0) | \
|
||||
(DMAREG( reg1 ) << 8) | \
|
||||
(DMAREG( reg2 ) << 16) | \
|
||||
(DMAREG( reg3 ) << 24)) ); \
|
||||
DMA_WRITE( 1, val0 ); \
|
||||
DMA_WRITE( 2, val1 ); \
|
||||
DMA_WRITE( 3, val2 ); \
|
||||
DMA_WRITE( 4, val3 ); \
|
||||
write += DMA_BLOCK_SIZE; \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* Buffer aging via primary DMA stream head pointer.
|
||||
*/
|
||||
|
||||
#define SET_AGE( age, h, w ) \
|
||||
do { \
|
||||
(age)->head = h; \
|
||||
(age)->wrap = w; \
|
||||
} while (0)
|
||||
|
||||
#define TEST_AGE( age, h, w ) ( (age)->wrap < w || \
|
||||
( (age)->wrap == w && \
|
||||
(age)->head < h ) )
|
||||
|
||||
#define AGE_BUFFER( buf_priv ) \
|
||||
do { \
|
||||
drm_mga_freelist_t *entry = (buf_priv)->list_entry; \
|
||||
if ( (buf_priv)->dispatched ) { \
|
||||
entry->age.head = (dev_priv->prim.tail + \
|
||||
dev_priv->primary->offset); \
|
||||
entry->age.wrap = dev_priv->sarea_priv->last_wrap; \
|
||||
} else { \
|
||||
entry->age.head = 0; \
|
||||
entry->age.wrap = 0; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define MGA_ENGINE_IDLE_MASK (MGA_SOFTRAPEN | \
|
||||
MGA_DWGENGSTS | \
|
||||
MGA_ENDPRDMASTS)
|
||||
#define MGA_DMA_IDLE_MASK (MGA_SOFTRAPEN | \
|
||||
MGA_ENDPRDMASTS)
|
||||
|
||||
#define MGA_DMA_DEBUG 0
|
||||
|
||||
|
||||
|
||||
/* A reduced set of the mga registers.
|
||||
*/
|
||||
#define MGA_CRTC_INDEX 0x1fd4
|
||||
|
||||
#define MGA_ALPHACTRL 0x2c7c
|
||||
#define MGA_AR0 0x1c60
|
||||
#define MGA_AR1 0x1c64
|
||||
#define MGA_AR2 0x1c68
|
||||
#define MGA_AR3 0x1c6c
|
||||
#define MGA_AR4 0x1c70
|
||||
#define MGA_AR5 0x1c74
|
||||
#define MGA_AR6 0x1c78
|
||||
|
||||
#define MGA_CXBNDRY 0x1c80
|
||||
#define MGA_CXLEFT 0x1ca0
|
||||
#define MGA_CXRIGHT 0x1ca4
|
||||
|
||||
#define MGA_DMAPAD 0x1c54
|
||||
#define MGA_DSTORG 0x2cb8
|
||||
#define MGA_DWGCTL 0x1c00
|
||||
# define MGA_OPCOD_MASK (15 << 0)
|
||||
# define MGA_OPCOD_TRAP (4 << 0)
|
||||
# define MGA_OPCOD_TEXTURE_TRAP (6 << 0)
|
||||
# define MGA_OPCOD_BITBLT (8 << 0)
|
||||
# define MGA_OPCOD_ILOAD (9 << 0)
|
||||
# define MGA_ATYPE_MASK (7 << 4)
|
||||
# define MGA_ATYPE_RPL (0 << 4)
|
||||
# define MGA_ATYPE_RSTR (1 << 4)
|
||||
# define MGA_ATYPE_ZI (3 << 4)
|
||||
# define MGA_ATYPE_BLK (4 << 4)
|
||||
# define MGA_ATYPE_I (7 << 4)
|
||||
# define MGA_LINEAR (1 << 7)
|
||||
# define MGA_ZMODE_MASK (7 << 8)
|
||||
# define MGA_ZMODE_NOZCMP (0 << 8)
|
||||
# define MGA_ZMODE_ZE (2 << 8)
|
||||
# define MGA_ZMODE_ZNE (3 << 8)
|
||||
# define MGA_ZMODE_ZLT (4 << 8)
|
||||
# define MGA_ZMODE_ZLTE (5 << 8)
|
||||
# define MGA_ZMODE_ZGT (6 << 8)
|
||||
# define MGA_ZMODE_ZGTE (7 << 8)
|
||||
# define MGA_SOLID (1 << 11)
|
||||
# define MGA_ARZERO (1 << 12)
|
||||
# define MGA_SGNZERO (1 << 13)
|
||||
# define MGA_SHIFTZERO (1 << 14)
|
||||
# define MGA_BOP_MASK (15 << 16)
|
||||
# define MGA_BOP_ZERO (0 << 16)
|
||||
# define MGA_BOP_DST (10 << 16)
|
||||
# define MGA_BOP_SRC (12 << 16)
|
||||
# define MGA_BOP_ONE (15 << 16)
|
||||
# define MGA_TRANS_SHIFT 20
|
||||
# define MGA_TRANS_MASK (15 << 20)
|
||||
# define MGA_BLTMOD_MASK (15 << 25)
|
||||
# define MGA_BLTMOD_BMONOLEF (0 << 25)
|
||||
# define MGA_BLTMOD_BMONOWF (4 << 25)
|
||||
# define MGA_BLTMOD_PLAN (1 << 25)
|
||||
# define MGA_BLTMOD_BFCOL (2 << 25)
|
||||
# define MGA_BLTMOD_BU32BGR (3 << 25)
|
||||
# define MGA_BLTMOD_BU32RGB (7 << 25)
|
||||
# define MGA_BLTMOD_BU24BGR (11 << 25)
|
||||
# define MGA_BLTMOD_BU24RGB (15 << 25)
|
||||
# define MGA_PATTERN (1 << 29)
|
||||
# define MGA_TRANSC (1 << 30)
|
||||
# define MGA_CLIPDIS (1 << 31)
|
||||
#define MGA_DWGSYNC 0x2c4c
|
||||
|
||||
#define MGA_FCOL 0x1c24
|
||||
#define MGA_FIFOSTATUS 0x1e10
|
||||
#define MGA_FOGCOL 0x1cf4
|
||||
#define MGA_FXBNDRY 0x1c84
|
||||
#define MGA_FXLEFT 0x1ca8
|
||||
#define MGA_FXRIGHT 0x1cac
|
||||
|
||||
#define MGA_ICLEAR 0x1e18
|
||||
# define MGA_SOFTRAPICLR (1 << 0)
|
||||
#define MGA_IEN 0x1e1c
|
||||
# define MGA_SOFTRAPIEN (1 << 0)
|
||||
|
||||
#define MGA_LEN 0x1c5c
|
||||
|
||||
#define MGA_MACCESS 0x1c04
|
||||
|
||||
#define MGA_PITCH 0x1c8c
|
||||
#define MGA_PLNWT 0x1c1c
|
||||
#define MGA_PRIMADDRESS 0x1e58
|
||||
# define MGA_DMA_GENERAL (0 << 0)
|
||||
# define MGA_DMA_BLIT (1 << 0)
|
||||
# define MGA_DMA_VECTOR (2 << 0)
|
||||
# define MGA_DMA_VERTEX (3 << 0)
|
||||
#define MGA_PRIMEND 0x1e5c
|
||||
# define MGA_PRIMNOSTART (1 << 0)
|
||||
# define MGA_PAGPXFER (1 << 1)
|
||||
#define MGA_PRIMPTR 0x1e50
|
||||
# define MGA_PRIMPTREN0 (1 << 0)
|
||||
# define MGA_PRIMPTREN1 (1 << 1)
|
||||
|
||||
#define MGA_RST 0x1e40
|
||||
# define MGA_SOFTRESET (1 << 0)
|
||||
# define MGA_SOFTEXTRST (1 << 1)
|
||||
|
||||
#define MGA_SECADDRESS 0x2c40
|
||||
#define MGA_SECEND 0x2c44
|
||||
#define MGA_SETUPADDRESS 0x2cd0
|
||||
#define MGA_SETUPEND 0x2cd4
|
||||
#define MGA_SGN 0x1c58
|
||||
#define MGA_SOFTRAP 0x2c48
|
||||
#define MGA_SRCORG 0x2cb4
|
||||
# define MGA_SRMMAP_MASK (1 << 0)
|
||||
# define MGA_SRCMAP_FB (0 << 0)
|
||||
# define MGA_SRCMAP_SYSMEM (1 << 0)
|
||||
# define MGA_SRCACC_MASK (1 << 1)
|
||||
# define MGA_SRCACC_PCI (0 << 1)
|
||||
# define MGA_SRCACC_AGP (1 << 1)
|
||||
#define MGA_STATUS 0x1e14
|
||||
# define MGA_SOFTRAPEN (1 << 0)
|
||||
# define MGA_DWGENGSTS (1 << 16)
|
||||
# define MGA_ENDPRDMASTS (1 << 17)
|
||||
#define MGA_STENCIL 0x2cc8
|
||||
#define MGA_STENCILCTL 0x2ccc
|
||||
|
||||
#define MGA_TDUALSTAGE0 0x2cf8
|
||||
#define MGA_TDUALSTAGE1 0x2cfc
|
||||
#define MGA_TEXBORDERCOL 0x2c5c
|
||||
#define MGA_TEXCTL 0x2c30
|
||||
#define MGA_TEXCTL2 0x2c3c
|
||||
# define MGA_DUALTEX (1 << 7)
|
||||
# define MGA_G400_TC2_MAGIC (1 << 15)
|
||||
# define MGA_MAP1_ENABLE (1 << 31)
|
||||
#define MGA_TEXFILTER 0x2c58
|
||||
#define MGA_TEXHEIGHT 0x2c2c
|
||||
#define MGA_TEXORG 0x2c24
|
||||
# define MGA_TEXORGMAP_MASK (1 << 0)
|
||||
# define MGA_TEXORGMAP_FB (0 << 0)
|
||||
# define MGA_TEXORGMAP_SYSMEM (1 << 0)
|
||||
# define MGA_TEXORGACC_MASK (1 << 1)
|
||||
# define MGA_TEXORGACC_PCI (0 << 1)
|
||||
# define MGA_TEXORGACC_AGP (1 << 1)
|
||||
#define MGA_TEXORG1 0x2ca4
|
||||
#define MGA_TEXORG2 0x2ca8
|
||||
#define MGA_TEXORG3 0x2cac
|
||||
#define MGA_TEXORG4 0x2cb0
|
||||
#define MGA_TEXTRANS 0x2c34
|
||||
#define MGA_TEXTRANSHIGH 0x2c38
|
||||
#define MGA_TEXWIDTH 0x2c28
|
||||
|
||||
#define MGA_WACCEPTSEQ 0x1dd4
|
||||
#define MGA_WCODEADDR 0x1e6c
|
||||
#define MGA_WFLAG 0x1dc4
|
||||
#define MGA_WFLAG1 0x1de0
|
||||
#define MGA_WFLAGNB 0x1e64
|
||||
#define MGA_WFLAGNB1 0x1e08
|
||||
#define MGA_WGETMSB 0x1dc8
|
||||
#define MGA_WIADDR 0x1dc0
|
||||
#define MGA_WIADDR2 0x1dd8
|
||||
# define MGA_WMODE_SUSPEND (0 << 0)
|
||||
# define MGA_WMODE_RESUME (1 << 0)
|
||||
# define MGA_WMODE_JUMP (2 << 0)
|
||||
# define MGA_WMODE_START (3 << 0)
|
||||
# define MGA_WAGP_ENABLE (1 << 2)
|
||||
#define MGA_WMISC 0x1e70
|
||||
# define MGA_WUCODECACHE_ENABLE (1 << 0)
|
||||
# define MGA_WMASTER_ENABLE (1 << 1)
|
||||
# define MGA_WCACHEFLUSH_ENABLE (1 << 3)
|
||||
#define MGA_WVRTXSZ 0x1dcc
|
||||
|
||||
#define MGA_YBOT 0x1c9c
|
||||
#define MGA_YDST 0x1c90
|
||||
#define MGA_YDSTLEN 0x1c88
|
||||
#define MGA_YDSTORG 0x1c94
|
||||
#define MGA_YTOP 0x1c98
|
||||
|
||||
#define MGA_ZORG 0x1c0c
|
||||
|
||||
/* This finishes the current batch of commands
|
||||
*/
|
||||
#define MGA_EXEC 0x0100
|
||||
|
||||
/* Warp registers
|
||||
*/
|
||||
#define MGA_WR0 0x2d00
|
||||
#define MGA_WR1 0x2d04
|
||||
#define MGA_WR2 0x2d08
|
||||
#define MGA_WR3 0x2d0c
|
||||
#define MGA_WR4 0x2d10
|
||||
#define MGA_WR5 0x2d14
|
||||
#define MGA_WR6 0x2d18
|
||||
#define MGA_WR7 0x2d1c
|
||||
#define MGA_WR8 0x2d20
|
||||
#define MGA_WR9 0x2d24
|
||||
#define MGA_WR10 0x2d28
|
||||
#define MGA_WR11 0x2d2c
|
||||
#define MGA_WR12 0x2d30
|
||||
#define MGA_WR13 0x2d34
|
||||
#define MGA_WR14 0x2d38
|
||||
#define MGA_WR15 0x2d3c
|
||||
#define MGA_WR16 0x2d40
|
||||
#define MGA_WR17 0x2d44
|
||||
#define MGA_WR18 0x2d48
|
||||
#define MGA_WR19 0x2d4c
|
||||
#define MGA_WR20 0x2d50
|
||||
#define MGA_WR21 0x2d54
|
||||
#define MGA_WR22 0x2d58
|
||||
#define MGA_WR23 0x2d5c
|
||||
#define MGA_WR24 0x2d60
|
||||
#define MGA_WR25 0x2d64
|
||||
#define MGA_WR26 0x2d68
|
||||
#define MGA_WR27 0x2d6c
|
||||
#define MGA_WR28 0x2d70
|
||||
#define MGA_WR29 0x2d74
|
||||
#define MGA_WR30 0x2d78
|
||||
#define MGA_WR31 0x2d7c
|
||||
#define MGA_WR32 0x2d80
|
||||
#define MGA_WR33 0x2d84
|
||||
#define MGA_WR34 0x2d88
|
||||
#define MGA_WR35 0x2d8c
|
||||
#define MGA_WR36 0x2d90
|
||||
#define MGA_WR37 0x2d94
|
||||
#define MGA_WR38 0x2d98
|
||||
#define MGA_WR39 0x2d9c
|
||||
#define MGA_WR40 0x2da0
|
||||
#define MGA_WR41 0x2da4
|
||||
#define MGA_WR42 0x2da8
|
||||
#define MGA_WR43 0x2dac
|
||||
#define MGA_WR44 0x2db0
|
||||
#define MGA_WR45 0x2db4
|
||||
#define MGA_WR46 0x2db8
|
||||
#define MGA_WR47 0x2dbc
|
||||
#define MGA_WR48 0x2dc0
|
||||
#define MGA_WR49 0x2dc4
|
||||
#define MGA_WR50 0x2dc8
|
||||
#define MGA_WR51 0x2dcc
|
||||
#define MGA_WR52 0x2dd0
|
||||
#define MGA_WR53 0x2dd4
|
||||
#define MGA_WR54 0x2dd8
|
||||
#define MGA_WR55 0x2ddc
|
||||
#define MGA_WR56 0x2de0
|
||||
#define MGA_WR57 0x2de4
|
||||
#define MGA_WR58 0x2de8
|
||||
#define MGA_WR59 0x2dec
|
||||
#define MGA_WR60 0x2df0
|
||||
#define MGA_WR61 0x2df4
|
||||
#define MGA_WR62 0x2df8
|
||||
#define MGA_WR63 0x2dfc
|
||||
# define MGA_G400_WR_MAGIC (1 << 6)
|
||||
# define MGA_G400_WR56_MAGIC 0x46480000 /* 12800.0f */
|
||||
|
||||
|
||||
#define MGA_ILOAD_ALIGN 64
|
||||
#define MGA_ILOAD_MASK (MGA_ILOAD_ALIGN - 1)
|
||||
|
||||
#define MGA_DWGCTL_FLUSH (MGA_OPCOD_TEXTURE_TRAP | \
|
||||
MGA_ATYPE_I | \
|
||||
MGA_ZMODE_NOZCMP | \
|
||||
MGA_ARZERO | \
|
||||
MGA_SGNZERO | \
|
||||
MGA_BOP_SRC | \
|
||||
(15 << MGA_TRANS_SHIFT))
|
||||
|
||||
#define MGA_DWGCTL_CLEAR (MGA_OPCOD_TRAP | \
|
||||
MGA_ZMODE_NOZCMP | \
|
||||
MGA_SOLID | \
|
||||
MGA_ARZERO | \
|
||||
MGA_SGNZERO | \
|
||||
MGA_SHIFTZERO | \
|
||||
MGA_BOP_SRC | \
|
||||
(0 << MGA_TRANS_SHIFT) | \
|
||||
MGA_BLTMOD_BMONOLEF | \
|
||||
MGA_TRANSC | \
|
||||
MGA_CLIPDIS)
|
||||
|
||||
#define MGA_DWGCTL_COPY (MGA_OPCOD_BITBLT | \
|
||||
MGA_ATYPE_RPL | \
|
||||
MGA_SGNZERO | \
|
||||
MGA_SHIFTZERO | \
|
||||
MGA_BOP_SRC | \
|
||||
(0 << MGA_TRANS_SHIFT) | \
|
||||
MGA_BLTMOD_BFCOL | \
|
||||
MGA_CLIPDIS)
|
||||
|
||||
/* Simple idle test.
|
||||
*/
|
||||
static __inline__ int mga_is_idle( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
u32 status = MGA_READ( MGA_STATUS ) & MGA_ENGINE_IDLE_MASK;
|
||||
return ( status == MGA_ENDPRDMASTS );
|
||||
}
|
||||
|
||||
#endif
|
||||
1078
shared/mga_state.c
Normal file
1078
shared/mga_state.c
Normal file
File diff suppressed because it is too large
Load diff
11645
shared/mga_ucode.h
Normal file
11645
shared/mga_ucode.h
Normal file
File diff suppressed because it is too large
Load diff
212
shared/mga_warp.c
Normal file
212
shared/mga_warp.c
Normal file
|
|
@ -0,0 +1,212 @@
|
|||
/* mga_warp.c -- Matrox G200/G400 WARP engine management -*- linux-c -*-
|
||||
* Created: Thu Jan 11 21:29:32 2001 by gareth@valinux.com
|
||||
*
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS 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.
|
||||
*
|
||||
* Authors:
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#define __NO_VERSION__
|
||||
#include "mga.h"
|
||||
#include "drmP.h"
|
||||
#include "drm.h"
|
||||
#include "mga_drm.h"
|
||||
#include "mga_drv.h"
|
||||
#include "mga_ucode.h"
|
||||
|
||||
|
||||
#define MGA_WARP_CODE_ALIGN 256 /* in bytes */
|
||||
|
||||
#define WARP_UCODE_SIZE( which ) \
|
||||
((sizeof(which) / MGA_WARP_CODE_ALIGN + 1) * MGA_WARP_CODE_ALIGN)
|
||||
|
||||
#define WARP_UCODE_INSTALL( which, where ) \
|
||||
do { \
|
||||
DRM_DEBUG( " pcbase = 0x%08lx vcbase = %p\n", pcbase, vcbase );\
|
||||
dev_priv->warp_pipe_phys[where] = pcbase; \
|
||||
memcpy( vcbase, which, sizeof(which) ); \
|
||||
pcbase += WARP_UCODE_SIZE( which ); \
|
||||
vcbase += WARP_UCODE_SIZE( which ); \
|
||||
} while (0)
|
||||
|
||||
|
||||
static unsigned int mga_warp_g400_microcode_size( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
unsigned int size;
|
||||
|
||||
size = ( WARP_UCODE_SIZE( warp_g400_tgz ) +
|
||||
WARP_UCODE_SIZE( warp_g400_tgza ) +
|
||||
WARP_UCODE_SIZE( warp_g400_tgzaf ) +
|
||||
WARP_UCODE_SIZE( warp_g400_tgzf ) +
|
||||
WARP_UCODE_SIZE( warp_g400_tgzs ) +
|
||||
WARP_UCODE_SIZE( warp_g400_tgzsa ) +
|
||||
WARP_UCODE_SIZE( warp_g400_tgzsaf ) +
|
||||
WARP_UCODE_SIZE( warp_g400_tgzsf ) +
|
||||
WARP_UCODE_SIZE( warp_g400_t2gz ) +
|
||||
WARP_UCODE_SIZE( warp_g400_t2gza ) +
|
||||
WARP_UCODE_SIZE( warp_g400_t2gzaf ) +
|
||||
WARP_UCODE_SIZE( warp_g400_t2gzf ) +
|
||||
WARP_UCODE_SIZE( warp_g400_t2gzs ) +
|
||||
WARP_UCODE_SIZE( warp_g400_t2gzsa ) +
|
||||
WARP_UCODE_SIZE( warp_g400_t2gzsaf ) +
|
||||
WARP_UCODE_SIZE( warp_g400_t2gzsf ) );
|
||||
|
||||
size = PAGE_ALIGN( size );
|
||||
|
||||
DRM_DEBUG( "G400 ucode size = %d bytes\n", size );
|
||||
return size;
|
||||
}
|
||||
|
||||
static unsigned int mga_warp_g200_microcode_size( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
unsigned int size;
|
||||
|
||||
size = ( WARP_UCODE_SIZE( warp_g200_tgz ) +
|
||||
WARP_UCODE_SIZE( warp_g200_tgza ) +
|
||||
WARP_UCODE_SIZE( warp_g200_tgzaf ) +
|
||||
WARP_UCODE_SIZE( warp_g200_tgzf ) +
|
||||
WARP_UCODE_SIZE( warp_g200_tgzs ) +
|
||||
WARP_UCODE_SIZE( warp_g200_tgzsa ) +
|
||||
WARP_UCODE_SIZE( warp_g200_tgzsaf ) +
|
||||
WARP_UCODE_SIZE( warp_g200_tgzsf ) );
|
||||
|
||||
size = PAGE_ALIGN( size );
|
||||
|
||||
DRM_DEBUG( "G200 ucode size = %d bytes\n", size );
|
||||
return size;
|
||||
}
|
||||
|
||||
static int mga_warp_install_g400_microcode( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
unsigned char *vcbase = dev_priv->warp->handle;
|
||||
unsigned long pcbase = dev_priv->warp->offset;
|
||||
unsigned int size;
|
||||
|
||||
size = mga_warp_g400_microcode_size( dev_priv );
|
||||
if ( size > dev_priv->warp->size ) {
|
||||
DRM_ERROR( "microcode too large! (%u > %lu)\n",
|
||||
size, dev_priv->warp->size );
|
||||
return DRM_ERR(ENOMEM);
|
||||
}
|
||||
|
||||
memset( dev_priv->warp_pipe_phys, 0,
|
||||
sizeof(dev_priv->warp_pipe_phys) );
|
||||
|
||||
WARP_UCODE_INSTALL( warp_g400_tgz, MGA_WARP_TGZ );
|
||||
WARP_UCODE_INSTALL( warp_g400_tgzf, MGA_WARP_TGZF );
|
||||
WARP_UCODE_INSTALL( warp_g400_tgza, MGA_WARP_TGZA );
|
||||
WARP_UCODE_INSTALL( warp_g400_tgzaf, MGA_WARP_TGZAF );
|
||||
WARP_UCODE_INSTALL( warp_g400_tgzs, MGA_WARP_TGZS );
|
||||
WARP_UCODE_INSTALL( warp_g400_tgzsf, MGA_WARP_TGZSF );
|
||||
WARP_UCODE_INSTALL( warp_g400_tgzsa, MGA_WARP_TGZSA );
|
||||
WARP_UCODE_INSTALL( warp_g400_tgzsaf, MGA_WARP_TGZSAF );
|
||||
|
||||
WARP_UCODE_INSTALL( warp_g400_t2gz, MGA_WARP_T2GZ );
|
||||
WARP_UCODE_INSTALL( warp_g400_t2gzf, MGA_WARP_T2GZF );
|
||||
WARP_UCODE_INSTALL( warp_g400_t2gza, MGA_WARP_T2GZA );
|
||||
WARP_UCODE_INSTALL( warp_g400_t2gzaf, MGA_WARP_T2GZAF );
|
||||
WARP_UCODE_INSTALL( warp_g400_t2gzs, MGA_WARP_T2GZS );
|
||||
WARP_UCODE_INSTALL( warp_g400_t2gzsf, MGA_WARP_T2GZSF );
|
||||
WARP_UCODE_INSTALL( warp_g400_t2gzsa, MGA_WARP_T2GZSA );
|
||||
WARP_UCODE_INSTALL( warp_g400_t2gzsaf, MGA_WARP_T2GZSAF );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mga_warp_install_g200_microcode( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
unsigned char *vcbase = dev_priv->warp->handle;
|
||||
unsigned long pcbase = dev_priv->warp->offset;
|
||||
unsigned int size;
|
||||
|
||||
size = mga_warp_g200_microcode_size( dev_priv );
|
||||
if ( size > dev_priv->warp->size ) {
|
||||
DRM_ERROR( "microcode too large! (%u > %lu)\n",
|
||||
size, dev_priv->warp->size );
|
||||
return DRM_ERR(ENOMEM);
|
||||
}
|
||||
|
||||
memset( dev_priv->warp_pipe_phys, 0,
|
||||
sizeof(dev_priv->warp_pipe_phys) );
|
||||
|
||||
WARP_UCODE_INSTALL( warp_g200_tgz, MGA_WARP_TGZ );
|
||||
WARP_UCODE_INSTALL( warp_g200_tgzf, MGA_WARP_TGZF );
|
||||
WARP_UCODE_INSTALL( warp_g200_tgza, MGA_WARP_TGZA );
|
||||
WARP_UCODE_INSTALL( warp_g200_tgzaf, MGA_WARP_TGZAF );
|
||||
WARP_UCODE_INSTALL( warp_g200_tgzs, MGA_WARP_TGZS );
|
||||
WARP_UCODE_INSTALL( warp_g200_tgzsf, MGA_WARP_TGZSF );
|
||||
WARP_UCODE_INSTALL( warp_g200_tgzsa, MGA_WARP_TGZSA );
|
||||
WARP_UCODE_INSTALL( warp_g200_tgzsaf, MGA_WARP_TGZSAF );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mga_warp_install_microcode( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
switch ( dev_priv->chipset ) {
|
||||
case MGA_CARD_TYPE_G400:
|
||||
return mga_warp_install_g400_microcode( dev_priv );
|
||||
case MGA_CARD_TYPE_G200:
|
||||
return mga_warp_install_g200_microcode( dev_priv );
|
||||
default:
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
}
|
||||
|
||||
#define WMISC_EXPECTED (MGA_WUCODECACHE_ENABLE | MGA_WMASTER_ENABLE)
|
||||
|
||||
int mga_warp_init( drm_mga_private_t *dev_priv )
|
||||
{
|
||||
u32 wmisc;
|
||||
|
||||
/* FIXME: Get rid of these damned magic numbers...
|
||||
*/
|
||||
switch ( dev_priv->chipset ) {
|
||||
case MGA_CARD_TYPE_G400:
|
||||
MGA_WRITE( MGA_WIADDR2, MGA_WMODE_SUSPEND );
|
||||
MGA_WRITE( MGA_WGETMSB, 0x00000E00 );
|
||||
MGA_WRITE( MGA_WVRTXSZ, 0x00001807 );
|
||||
MGA_WRITE( MGA_WACCEPTSEQ, 0x18000000 );
|
||||
break;
|
||||
case MGA_CARD_TYPE_G200:
|
||||
MGA_WRITE( MGA_WIADDR, MGA_WMODE_SUSPEND );
|
||||
MGA_WRITE( MGA_WGETMSB, 0x1606 );
|
||||
MGA_WRITE( MGA_WVRTXSZ, 7 );
|
||||
break;
|
||||
default:
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
|
||||
MGA_WRITE( MGA_WMISC, (MGA_WUCODECACHE_ENABLE |
|
||||
MGA_WMASTER_ENABLE |
|
||||
MGA_WCACHEFLUSH_ENABLE) );
|
||||
wmisc = MGA_READ( MGA_WMISC );
|
||||
if ( wmisc != WMISC_EXPECTED ) {
|
||||
DRM_ERROR( "WARP engine config failed! 0x%x != 0x%x\n",
|
||||
wmisc, WMISC_EXPECTED );
|
||||
return DRM_ERR(EINVAL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
110
shared/r128.h
Normal file
110
shared/r128.h
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
/* r128.h -- ATI Rage 128 DRM template customization -*- linux-c -*-
|
||||
* Created: Wed Feb 14 16:07:10 2001 by gareth@valinux.com
|
||||
*
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS 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.
|
||||
*
|
||||
* Authors:
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#ifndef __R128_H__
|
||||
#define __R128_H__
|
||||
|
||||
/* This remains constant for all DRM template files.
|
||||
*/
|
||||
#define DRM(x) r128_##x
|
||||
|
||||
/* General customization:
|
||||
*/
|
||||
#define __HAVE_AGP 1
|
||||
#define __MUST_HAVE_AGP 0
|
||||
#define __HAVE_MTRR 1
|
||||
#define __HAVE_CTX_BITMAP 1
|
||||
#define __HAVE_SG 1
|
||||
#define __HAVE_PCI_DMA 1
|
||||
|
||||
#define DRIVER_AUTHOR "Gareth Hughes, VA Linux Systems Inc."
|
||||
|
||||
#define DRIVER_NAME "r128"
|
||||
#define DRIVER_DESC "ATI Rage 128"
|
||||
#define DRIVER_DATE "20010917"
|
||||
|
||||
#define DRIVER_MAJOR 2
|
||||
#define DRIVER_MINOR 2
|
||||
#define DRIVER_PATCHLEVEL 0
|
||||
|
||||
|
||||
#define DRIVER_IOCTLS \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { r128_cce_buffers, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_R128_INIT)] = { r128_cce_init, 1, 1 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_R128_CCE_START)] = { r128_cce_start, 1, 1 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_R128_CCE_STOP)] = { r128_cce_stop, 1, 1 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_R128_CCE_RESET)] = { r128_cce_reset, 1, 1 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_R128_CCE_IDLE)] = { r128_cce_idle, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_R128_RESET)] = { r128_engine_reset, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_R128_FULLSCREEN)] = { r128_fullscreen, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_R128_SWAP)] = { r128_cce_swap, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_R128_CLEAR)] = { r128_cce_clear, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_R128_VERTEX)] = { r128_cce_vertex, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_R128_INDICES)] = { r128_cce_indices, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_R128_BLIT)] = { r128_cce_blit, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_R128_DEPTH)] = { r128_cce_depth, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_R128_STIPPLE)] = { r128_cce_stipple, 1, 0 }, \
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_R128_INDIRECT)] = { r128_cce_indirect, 1, 1 },
|
||||
|
||||
/* Driver customization:
|
||||
*/
|
||||
#define DRIVER_PRERELEASE() do { \
|
||||
if ( dev->dev_private ) { \
|
||||
drm_r128_private_t *dev_priv = dev->dev_private; \
|
||||
if ( dev_priv->page_flipping ) { \
|
||||
r128_do_cleanup_pageflip( dev ); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DRIVER_PRETAKEDOWN() do { \
|
||||
if ( dev->dev_private ) r128_do_cleanup_cce( dev ); \
|
||||
} while (0)
|
||||
|
||||
/* DMA customization:
|
||||
*/
|
||||
#define __HAVE_DMA 1
|
||||
|
||||
#if 0
|
||||
/* GH: Remove this for now... */
|
||||
#define __HAVE_DMA_QUIESCENT 1
|
||||
#define DRIVER_DMA_QUIESCENT() do { \
|
||||
drm_r128_private_t *dev_priv = dev->dev_private; \
|
||||
return r128_do_cce_idle( dev_priv ); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
/* Buffer customization:
|
||||
*/
|
||||
#define DRIVER_BUF_PRIV_T drm_r128_buf_priv_t
|
||||
|
||||
#define DRIVER_AGP_BUFFERS_MAP( dev ) \
|
||||
((drm_r128_private_t *)((dev)->dev_private))->buffers
|
||||
|
||||
#endif
|
||||
1010
shared/r128_cce.c
Normal file
1010
shared/r128_cce.c
Normal file
File diff suppressed because it is too large
Load diff
308
shared/r128_drm.h
Normal file
308
shared/r128_drm.h
Normal file
|
|
@ -0,0 +1,308 @@
|
|||
/* r128_drm.h -- Public header for the r128 driver -*- linux-c -*-
|
||||
* Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com
|
||||
*
|
||||
* Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PRECISION INSIGHT 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.
|
||||
*
|
||||
* Authors:
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
* Kevin E. Martin <martin@valinux.com>
|
||||
*/
|
||||
|
||||
#ifndef __R128_DRM_H__
|
||||
#define __R128_DRM_H__
|
||||
|
||||
/* WARNING: If you change any of these defines, make sure to change the
|
||||
* defines in the X server file (r128_sarea.h)
|
||||
*/
|
||||
#ifndef __R128_SAREA_DEFINES__
|
||||
#define __R128_SAREA_DEFINES__
|
||||
|
||||
/* What needs to be changed for the current vertex buffer?
|
||||
*/
|
||||
#define R128_UPLOAD_CONTEXT 0x001
|
||||
#define R128_UPLOAD_SETUP 0x002
|
||||
#define R128_UPLOAD_TEX0 0x004
|
||||
#define R128_UPLOAD_TEX1 0x008
|
||||
#define R128_UPLOAD_TEX0IMAGES 0x010
|
||||
#define R128_UPLOAD_TEX1IMAGES 0x020
|
||||
#define R128_UPLOAD_CORE 0x040
|
||||
#define R128_UPLOAD_MASKS 0x080
|
||||
#define R128_UPLOAD_WINDOW 0x100
|
||||
#define R128_UPLOAD_CLIPRECTS 0x200 /* handled client-side */
|
||||
#define R128_REQUIRE_QUIESCENCE 0x400
|
||||
#define R128_UPLOAD_ALL 0x7ff
|
||||
|
||||
#define R128_FRONT 0x1
|
||||
#define R128_BACK 0x2
|
||||
#define R128_DEPTH 0x4
|
||||
|
||||
/* Primitive types
|
||||
*/
|
||||
#define R128_POINTS 0x1
|
||||
#define R128_LINES 0x2
|
||||
#define R128_LINE_STRIP 0x3
|
||||
#define R128_TRIANGLES 0x4
|
||||
#define R128_TRIANGLE_FAN 0x5
|
||||
#define R128_TRIANGLE_STRIP 0x6
|
||||
|
||||
/* Vertex/indirect buffer size
|
||||
*/
|
||||
#define R128_BUFFER_SIZE 16384
|
||||
|
||||
/* Byte offsets for indirect buffer data
|
||||
*/
|
||||
#define R128_INDEX_PRIM_OFFSET 20
|
||||
#define R128_HOSTDATA_BLIT_OFFSET 32
|
||||
|
||||
/* Keep these small for testing.
|
||||
*/
|
||||
#define R128_NR_SAREA_CLIPRECTS 12
|
||||
|
||||
/* There are 2 heaps (local/AGP). Each region within a heap is a
|
||||
* minimum of 64k, and there are at most 64 of them per heap.
|
||||
*/
|
||||
#define R128_LOCAL_TEX_HEAP 0
|
||||
#define R128_AGP_TEX_HEAP 1
|
||||
#define R128_NR_TEX_HEAPS 2
|
||||
#define R128_NR_TEX_REGIONS 64
|
||||
#define R128_LOG_TEX_GRANULARITY 16
|
||||
|
||||
#define R128_NR_CONTEXT_REGS 12
|
||||
|
||||
#define R128_MAX_TEXTURE_LEVELS 11
|
||||
#define R128_MAX_TEXTURE_UNITS 2
|
||||
|
||||
#endif /* __R128_SAREA_DEFINES__ */
|
||||
|
||||
typedef struct {
|
||||
/* Context state - can be written in one large chunk */
|
||||
unsigned int dst_pitch_offset_c;
|
||||
unsigned int dp_gui_master_cntl_c;
|
||||
unsigned int sc_top_left_c;
|
||||
unsigned int sc_bottom_right_c;
|
||||
unsigned int z_offset_c;
|
||||
unsigned int z_pitch_c;
|
||||
unsigned int z_sten_cntl_c;
|
||||
unsigned int tex_cntl_c;
|
||||
unsigned int misc_3d_state_cntl_reg;
|
||||
unsigned int texture_clr_cmp_clr_c;
|
||||
unsigned int texture_clr_cmp_msk_c;
|
||||
unsigned int fog_color_c;
|
||||
|
||||
/* Texture state */
|
||||
unsigned int tex_size_pitch_c;
|
||||
unsigned int constant_color_c;
|
||||
|
||||
/* Setup state */
|
||||
unsigned int pm4_vc_fpu_setup;
|
||||
unsigned int setup_cntl;
|
||||
|
||||
/* Mask state */
|
||||
unsigned int dp_write_mask;
|
||||
unsigned int sten_ref_mask_c;
|
||||
unsigned int plane_3d_mask_c;
|
||||
|
||||
/* Window state */
|
||||
unsigned int window_xy_offset;
|
||||
|
||||
/* Core state */
|
||||
unsigned int scale_3d_cntl;
|
||||
} drm_r128_context_regs_t;
|
||||
|
||||
/* Setup registers for each texture unit
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int tex_cntl;
|
||||
unsigned int tex_combine_cntl;
|
||||
unsigned int tex_size_pitch;
|
||||
unsigned int tex_offset[R128_MAX_TEXTURE_LEVELS];
|
||||
unsigned int tex_border_color;
|
||||
} drm_r128_texture_regs_t;
|
||||
|
||||
|
||||
typedef struct drm_r128_sarea {
|
||||
/* The channel for communication of state information to the kernel
|
||||
* on firing a vertex buffer.
|
||||
*/
|
||||
drm_r128_context_regs_t context_state;
|
||||
drm_r128_texture_regs_t tex_state[R128_MAX_TEXTURE_UNITS];
|
||||
unsigned int dirty;
|
||||
unsigned int vertsize;
|
||||
unsigned int vc_format;
|
||||
|
||||
/* The current cliprects, or a subset thereof.
|
||||
*/
|
||||
drm_clip_rect_t boxes[R128_NR_SAREA_CLIPRECTS];
|
||||
unsigned int nbox;
|
||||
|
||||
/* Counters for client-side throttling of rendering clients.
|
||||
*/
|
||||
unsigned int last_frame;
|
||||
unsigned int last_dispatch;
|
||||
|
||||
drm_tex_region_t tex_list[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS+1];
|
||||
int tex_age[R128_NR_TEX_HEAPS];
|
||||
int ctx_owner;
|
||||
} drm_r128_sarea_t;
|
||||
|
||||
|
||||
/* WARNING: If you change any of these defines, make sure to change the
|
||||
* defines in the Xserver file (xf86drmR128.h)
|
||||
*/
|
||||
|
||||
/* Rage 128 specific ioctls
|
||||
* The device specific ioctl range is 0x40 to 0x79.
|
||||
*/
|
||||
#define DRM_IOCTL_R128_INIT DRM_IOW( 0x40, drm_r128_init_t)
|
||||
#define DRM_IOCTL_R128_CCE_START DRM_IO( 0x41)
|
||||
#define DRM_IOCTL_R128_CCE_STOP DRM_IOW( 0x42, drm_r128_cce_stop_t)
|
||||
#define DRM_IOCTL_R128_CCE_RESET DRM_IO( 0x43)
|
||||
#define DRM_IOCTL_R128_CCE_IDLE DRM_IO( 0x44)
|
||||
#define DRM_IOCTL_R128_RESET DRM_IO( 0x46)
|
||||
#define DRM_IOCTL_R128_SWAP DRM_IO( 0x47)
|
||||
#define DRM_IOCTL_R128_CLEAR DRM_IOW( 0x48, drm_r128_clear_t)
|
||||
#define DRM_IOCTL_R128_VERTEX DRM_IOW( 0x49, drm_r128_vertex_t)
|
||||
#define DRM_IOCTL_R128_INDICES DRM_IOW( 0x4a, drm_r128_indices_t)
|
||||
#define DRM_IOCTL_R128_BLIT DRM_IOW( 0x4b, drm_r128_blit_t)
|
||||
#define DRM_IOCTL_R128_DEPTH DRM_IOW( 0x4c, drm_r128_depth_t)
|
||||
#define DRM_IOCTL_R128_STIPPLE DRM_IOW( 0x4d, drm_r128_stipple_t)
|
||||
#define DRM_IOCTL_R128_INDIRECT DRM_IOWR(0x4f, drm_r128_indirect_t)
|
||||
#define DRM_IOCTL_R128_FULLSCREEN DRM_IOW( 0x50, drm_r128_fullscreen_t)
|
||||
#define DRM_IOCTL_R128_CLEAR2 DRM_IOW( 0x51, drm_r128_clear2_t)
|
||||
|
||||
typedef struct drm_r128_init {
|
||||
enum {
|
||||
R128_INIT_CCE = 0x01,
|
||||
R128_CLEANUP_CCE = 0x02
|
||||
} func;
|
||||
#if CONFIG_XFREE86_VERSION < XFREE86_VERSION(4,1,0,0)
|
||||
int sarea_priv_offset;
|
||||
#else
|
||||
unsigned long sarea_priv_offset;
|
||||
#endif
|
||||
int is_pci;
|
||||
int cce_mode;
|
||||
int cce_secure;
|
||||
int ring_size;
|
||||
int usec_timeout;
|
||||
|
||||
unsigned int fb_bpp;
|
||||
unsigned int front_offset, front_pitch;
|
||||
unsigned int back_offset, back_pitch;
|
||||
unsigned int depth_bpp;
|
||||
unsigned int depth_offset, depth_pitch;
|
||||
unsigned int span_offset;
|
||||
|
||||
#if CONFIG_XFREE86_VERSION < XFREE86_VERSION(4,1,0,0)
|
||||
unsigned int fb_offset;
|
||||
unsigned int mmio_offset;
|
||||
unsigned int ring_offset;
|
||||
unsigned int ring_rptr_offset;
|
||||
unsigned int buffers_offset;
|
||||
unsigned int agp_textures_offset;
|
||||
#else
|
||||
unsigned long fb_offset;
|
||||
unsigned long mmio_offset;
|
||||
unsigned long ring_offset;
|
||||
unsigned long ring_rptr_offset;
|
||||
unsigned long buffers_offset;
|
||||
unsigned long agp_textures_offset;
|
||||
#endif
|
||||
} drm_r128_init_t;
|
||||
|
||||
typedef struct drm_r128_cce_stop {
|
||||
int flush;
|
||||
int idle;
|
||||
} drm_r128_cce_stop_t;
|
||||
|
||||
typedef struct drm_r128_clear {
|
||||
unsigned int flags;
|
||||
#if CONFIG_XFREE86_VERSION < XFREE86_VERSION(4,1,0,0)
|
||||
int x, y, w, h;
|
||||
#endif
|
||||
unsigned int clear_color;
|
||||
unsigned int clear_depth;
|
||||
#if CONFIG_XFREE86_VERSION >= XFREE86_VERSION(4,1,0,0)
|
||||
unsigned int color_mask;
|
||||
unsigned int depth_mask;
|
||||
#endif
|
||||
} drm_r128_clear_t;
|
||||
|
||||
typedef struct drm_r128_vertex {
|
||||
int prim;
|
||||
int idx; /* Index of vertex buffer */
|
||||
int count; /* Number of vertices in buffer */
|
||||
int discard; /* Client finished with buffer? */
|
||||
} drm_r128_vertex_t;
|
||||
|
||||
typedef struct drm_r128_indices {
|
||||
int prim;
|
||||
int idx;
|
||||
int start;
|
||||
int end;
|
||||
int discard; /* Client finished with buffer? */
|
||||
} drm_r128_indices_t;
|
||||
|
||||
typedef struct drm_r128_blit {
|
||||
int idx;
|
||||
int pitch;
|
||||
int offset;
|
||||
int format;
|
||||
unsigned short x, y;
|
||||
unsigned short width, height;
|
||||
} drm_r128_blit_t;
|
||||
|
||||
typedef struct drm_r128_depth {
|
||||
enum {
|
||||
R128_WRITE_SPAN = 0x01,
|
||||
R128_WRITE_PIXELS = 0x02,
|
||||
R128_READ_SPAN = 0x03,
|
||||
R128_READ_PIXELS = 0x04
|
||||
} func;
|
||||
int n;
|
||||
int *x;
|
||||
int *y;
|
||||
unsigned int *buffer;
|
||||
unsigned char *mask;
|
||||
} drm_r128_depth_t;
|
||||
|
||||
typedef struct drm_r128_stipple {
|
||||
unsigned int *mask;
|
||||
} drm_r128_stipple_t;
|
||||
|
||||
typedef struct drm_r128_indirect {
|
||||
int idx;
|
||||
int start;
|
||||
int end;
|
||||
int discard;
|
||||
} drm_r128_indirect_t;
|
||||
|
||||
typedef struct drm_r128_fullscreen {
|
||||
enum {
|
||||
R128_INIT_FULLSCREEN = 0x01,
|
||||
R128_CLEANUP_FULLSCREEN = 0x02
|
||||
} func;
|
||||
} drm_r128_fullscreen_t;
|
||||
|
||||
#endif
|
||||
504
shared/r128_drv.h
Normal file
504
shared/r128_drv.h
Normal file
|
|
@ -0,0 +1,504 @@
|
|||
/* r128_drv.h -- Private header for r128 driver -*- linux-c -*-
|
||||
* Created: Mon Dec 13 09:51:11 1999 by faith@precisioninsight.com
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PRECISION INSIGHT 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.
|
||||
*
|
||||
* Authors:
|
||||
* Rickard E. (Rik) Faith <faith@valinux.com>
|
||||
* Kevin E. Martin <martin@valinux.com>
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
* Michel Dänzer <daenzerm@student.ethz.ch>
|
||||
*/
|
||||
|
||||
#ifndef __R128_DRV_H__
|
||||
#define __R128_DRV_H__
|
||||
|
||||
#define GET_RING_HEAD(ring) DRM_READ32( (volatile u32 *) (ring)->head )
|
||||
#define SET_RING_HEAD(ring,val) DRM_WRITE32( (volatile u32 *) (ring)->head, (val) )
|
||||
|
||||
typedef struct drm_r128_freelist {
|
||||
unsigned int age;
|
||||
drm_buf_t *buf;
|
||||
struct drm_r128_freelist *next;
|
||||
struct drm_r128_freelist *prev;
|
||||
} drm_r128_freelist_t;
|
||||
|
||||
typedef struct drm_r128_ring_buffer {
|
||||
u32 *start;
|
||||
u32 *end;
|
||||
int size;
|
||||
int size_l2qw;
|
||||
|
||||
volatile u32 *head;
|
||||
u32 tail;
|
||||
u32 tail_mask;
|
||||
int space;
|
||||
|
||||
int high_mark;
|
||||
} drm_r128_ring_buffer_t;
|
||||
|
||||
typedef struct drm_r128_private {
|
||||
drm_r128_ring_buffer_t ring;
|
||||
drm_r128_sarea_t *sarea_priv;
|
||||
|
||||
int cce_mode;
|
||||
int cce_fifo_size;
|
||||
int cce_running;
|
||||
|
||||
drm_r128_freelist_t *head;
|
||||
drm_r128_freelist_t *tail;
|
||||
|
||||
int usec_timeout;
|
||||
int is_pci;
|
||||
unsigned long phys_pci_gart;
|
||||
dma_addr_t bus_pci_gart;
|
||||
unsigned long cce_buffers_offset;
|
||||
|
||||
atomic_t idle_count;
|
||||
|
||||
int page_flipping;
|
||||
int current_page;
|
||||
u32 crtc_offset;
|
||||
u32 crtc_offset_cntl;
|
||||
|
||||
u32 color_fmt;
|
||||
unsigned int front_offset;
|
||||
unsigned int front_pitch;
|
||||
unsigned int back_offset;
|
||||
unsigned int back_pitch;
|
||||
|
||||
u32 depth_fmt;
|
||||
unsigned int depth_offset;
|
||||
unsigned int depth_pitch;
|
||||
unsigned int span_offset;
|
||||
|
||||
u32 front_pitch_offset_c;
|
||||
u32 back_pitch_offset_c;
|
||||
u32 depth_pitch_offset_c;
|
||||
u32 span_pitch_offset_c;
|
||||
|
||||
drm_map_t *sarea;
|
||||
drm_map_t *fb;
|
||||
drm_map_t *mmio;
|
||||
drm_map_t *cce_ring;
|
||||
drm_map_t *ring_rptr;
|
||||
drm_map_t *buffers;
|
||||
drm_map_t *agp_textures;
|
||||
} drm_r128_private_t;
|
||||
|
||||
typedef struct drm_r128_buf_priv {
|
||||
u32 age;
|
||||
int prim;
|
||||
int discard;
|
||||
int dispatched;
|
||||
drm_r128_freelist_t *list_entry;
|
||||
} drm_r128_buf_priv_t;
|
||||
|
||||
/* r128_cce.c */
|
||||
extern int r128_cce_init( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_start( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_stop( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_reset( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_idle( DRM_IOCTL_ARGS );
|
||||
extern int r128_engine_reset( DRM_IOCTL_ARGS );
|
||||
extern int r128_fullscreen( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_buffers( DRM_IOCTL_ARGS );
|
||||
|
||||
extern void r128_freelist_reset( drm_device_t *dev );
|
||||
extern drm_buf_t *r128_freelist_get( drm_device_t *dev );
|
||||
|
||||
extern int r128_wait_ring( drm_r128_private_t *dev_priv, int n );
|
||||
|
||||
static __inline__ void
|
||||
r128_update_ring_snapshot( drm_r128_ring_buffer_t *ring )
|
||||
{
|
||||
ring->space = (GET_RING_HEAD( ring ) - ring->tail) * sizeof(u32);
|
||||
if ( ring->space <= 0 )
|
||||
ring->space += ring->size;
|
||||
}
|
||||
|
||||
extern int r128_do_cce_idle( drm_r128_private_t *dev_priv );
|
||||
extern int r128_do_cleanup_cce( drm_device_t *dev );
|
||||
extern int r128_do_cleanup_pageflip( drm_device_t *dev );
|
||||
|
||||
/* r128_state.c */
|
||||
extern int r128_cce_clear( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_swap( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_vertex( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_indices( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_blit( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_depth( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_stipple( DRM_IOCTL_ARGS );
|
||||
extern int r128_cce_indirect( DRM_IOCTL_ARGS );
|
||||
|
||||
|
||||
/* Register definitions, register access macros and drmAddMap constants
|
||||
* for Rage 128 kernel driver.
|
||||
*/
|
||||
|
||||
#define R128_AUX_SC_CNTL 0x1660
|
||||
# define R128_AUX1_SC_EN (1 << 0)
|
||||
# define R128_AUX1_SC_MODE_OR (0 << 1)
|
||||
# define R128_AUX1_SC_MODE_NAND (1 << 1)
|
||||
# define R128_AUX2_SC_EN (1 << 2)
|
||||
# define R128_AUX2_SC_MODE_OR (0 << 3)
|
||||
# define R128_AUX2_SC_MODE_NAND (1 << 3)
|
||||
# define R128_AUX3_SC_EN (1 << 4)
|
||||
# define R128_AUX3_SC_MODE_OR (0 << 5)
|
||||
# define R128_AUX3_SC_MODE_NAND (1 << 5)
|
||||
#define R128_AUX1_SC_LEFT 0x1664
|
||||
#define R128_AUX1_SC_RIGHT 0x1668
|
||||
#define R128_AUX1_SC_TOP 0x166c
|
||||
#define R128_AUX1_SC_BOTTOM 0x1670
|
||||
#define R128_AUX2_SC_LEFT 0x1674
|
||||
#define R128_AUX2_SC_RIGHT 0x1678
|
||||
#define R128_AUX2_SC_TOP 0x167c
|
||||
#define R128_AUX2_SC_BOTTOM 0x1680
|
||||
#define R128_AUX3_SC_LEFT 0x1684
|
||||
#define R128_AUX3_SC_RIGHT 0x1688
|
||||
#define R128_AUX3_SC_TOP 0x168c
|
||||
#define R128_AUX3_SC_BOTTOM 0x1690
|
||||
|
||||
#define R128_BRUSH_DATA0 0x1480
|
||||
#define R128_BUS_CNTL 0x0030
|
||||
# define R128_BUS_MASTER_DIS (1 << 6)
|
||||
|
||||
#define R128_CLOCK_CNTL_INDEX 0x0008
|
||||
#define R128_CLOCK_CNTL_DATA 0x000c
|
||||
# define R128_PLL_WR_EN (1 << 7)
|
||||
#define R128_CONSTANT_COLOR_C 0x1d34
|
||||
#define R128_CRTC_OFFSET 0x0224
|
||||
#define R128_CRTC_OFFSET_CNTL 0x0228
|
||||
# define R128_CRTC_OFFSET_FLIP_CNTL (1 << 16)
|
||||
|
||||
#define R128_DP_GUI_MASTER_CNTL 0x146c
|
||||
# define R128_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0)
|
||||
# define R128_GMC_DST_PITCH_OFFSET_CNTL (1 << 1)
|
||||
# define R128_GMC_BRUSH_SOLID_COLOR (13 << 4)
|
||||
# define R128_GMC_BRUSH_NONE (15 << 4)
|
||||
# define R128_GMC_DST_16BPP (4 << 8)
|
||||
# define R128_GMC_DST_24BPP (5 << 8)
|
||||
# define R128_GMC_DST_32BPP (6 << 8)
|
||||
# define R128_GMC_DST_DATATYPE_SHIFT 8
|
||||
# define R128_GMC_SRC_DATATYPE_COLOR (3 << 12)
|
||||
# define R128_DP_SRC_SOURCE_MEMORY (2 << 24)
|
||||
# define R128_DP_SRC_SOURCE_HOST_DATA (3 << 24)
|
||||
# define R128_GMC_CLR_CMP_CNTL_DIS (1 << 28)
|
||||
# define R128_GMC_AUX_CLIP_DIS (1 << 29)
|
||||
# define R128_GMC_WR_MSK_DIS (1 << 30)
|
||||
# define R128_ROP3_S 0x00cc0000
|
||||
# define R128_ROP3_P 0x00f00000
|
||||
#define R128_DP_WRITE_MASK 0x16cc
|
||||
#define R128_DST_PITCH_OFFSET_C 0x1c80
|
||||
# define R128_DST_TILE (1 << 31)
|
||||
|
||||
#define R128_GEN_RESET_CNTL 0x00f0
|
||||
# define R128_SOFT_RESET_GUI (1 << 0)
|
||||
|
||||
#define R128_GUI_SCRATCH_REG0 0x15e0
|
||||
#define R128_GUI_SCRATCH_REG1 0x15e4
|
||||
#define R128_GUI_SCRATCH_REG2 0x15e8
|
||||
#define R128_GUI_SCRATCH_REG3 0x15ec
|
||||
#define R128_GUI_SCRATCH_REG4 0x15f0
|
||||
#define R128_GUI_SCRATCH_REG5 0x15f4
|
||||
|
||||
#define R128_GUI_STAT 0x1740
|
||||
# define R128_GUI_FIFOCNT_MASK 0x0fff
|
||||
# define R128_GUI_ACTIVE (1 << 31)
|
||||
|
||||
#define R128_MCLK_CNTL 0x000f
|
||||
# define R128_FORCE_GCP (1 << 16)
|
||||
# define R128_FORCE_PIPE3D_CP (1 << 17)
|
||||
# define R128_FORCE_RCP (1 << 18)
|
||||
|
||||
#define R128_PC_GUI_CTLSTAT 0x1748
|
||||
#define R128_PC_NGUI_CTLSTAT 0x0184
|
||||
# define R128_PC_FLUSH_GUI (3 << 0)
|
||||
# define R128_PC_RI_GUI (1 << 2)
|
||||
# define R128_PC_FLUSH_ALL 0x00ff
|
||||
# define R128_PC_BUSY (1 << 31)
|
||||
|
||||
#define R128_PCI_GART_PAGE 0x017c
|
||||
#define R128_PRIM_TEX_CNTL_C 0x1cb0
|
||||
|
||||
#define R128_SCALE_3D_CNTL 0x1a00
|
||||
#define R128_SEC_TEX_CNTL_C 0x1d00
|
||||
#define R128_SEC_TEXTURE_BORDER_COLOR_C 0x1d3c
|
||||
#define R128_SETUP_CNTL 0x1bc4
|
||||
#define R128_STEN_REF_MASK_C 0x1d40
|
||||
|
||||
#define R128_TEX_CNTL_C 0x1c9c
|
||||
# define R128_TEX_CACHE_FLUSH (1 << 23)
|
||||
|
||||
#define R128_WAIT_UNTIL 0x1720
|
||||
# define R128_EVENT_CRTC_OFFSET (1 << 0)
|
||||
#define R128_WINDOW_XY_OFFSET 0x1bcc
|
||||
|
||||
|
||||
/* CCE registers
|
||||
*/
|
||||
#define R128_PM4_BUFFER_OFFSET 0x0700
|
||||
#define R128_PM4_BUFFER_CNTL 0x0704
|
||||
# define R128_PM4_MASK (15 << 28)
|
||||
# define R128_PM4_NONPM4 (0 << 28)
|
||||
# define R128_PM4_192PIO (1 << 28)
|
||||
# define R128_PM4_192BM (2 << 28)
|
||||
# define R128_PM4_128PIO_64INDBM (3 << 28)
|
||||
# define R128_PM4_128BM_64INDBM (4 << 28)
|
||||
# define R128_PM4_64PIO_128INDBM (5 << 28)
|
||||
# define R128_PM4_64BM_128INDBM (6 << 28)
|
||||
# define R128_PM4_64PIO_64VCBM_64INDBM (7 << 28)
|
||||
# define R128_PM4_64BM_64VCBM_64INDBM (8 << 28)
|
||||
# define R128_PM4_64PIO_64VCPIO_64INDPIO (15 << 28)
|
||||
|
||||
#define R128_PM4_BUFFER_WM_CNTL 0x0708
|
||||
# define R128_WMA_SHIFT 0
|
||||
# define R128_WMB_SHIFT 8
|
||||
# define R128_WMC_SHIFT 16
|
||||
# define R128_WB_WM_SHIFT 24
|
||||
|
||||
#define R128_PM4_BUFFER_DL_RPTR_ADDR 0x070c
|
||||
#define R128_PM4_BUFFER_DL_RPTR 0x0710
|
||||
#define R128_PM4_BUFFER_DL_WPTR 0x0714
|
||||
# define R128_PM4_BUFFER_DL_DONE (1 << 31)
|
||||
|
||||
#define R128_PM4_VC_FPU_SETUP 0x071c
|
||||
|
||||
#define R128_PM4_IW_INDOFF 0x0738
|
||||
#define R128_PM4_IW_INDSIZE 0x073c
|
||||
|
||||
#define R128_PM4_STAT 0x07b8
|
||||
# define R128_PM4_FIFOCNT_MASK 0x0fff
|
||||
# define R128_PM4_BUSY (1 << 16)
|
||||
# define R128_PM4_GUI_ACTIVE (1 << 31)
|
||||
|
||||
#define R128_PM4_MICROCODE_ADDR 0x07d4
|
||||
#define R128_PM4_MICROCODE_RADDR 0x07d8
|
||||
#define R128_PM4_MICROCODE_DATAH 0x07dc
|
||||
#define R128_PM4_MICROCODE_DATAL 0x07e0
|
||||
|
||||
#define R128_PM4_BUFFER_ADDR 0x07f0
|
||||
#define R128_PM4_MICRO_CNTL 0x07fc
|
||||
# define R128_PM4_MICRO_FREERUN (1 << 30)
|
||||
|
||||
#define R128_PM4_FIFO_DATA_EVEN 0x1000
|
||||
#define R128_PM4_FIFO_DATA_ODD 0x1004
|
||||
|
||||
|
||||
/* CCE command packets
|
||||
*/
|
||||
#define R128_CCE_PACKET0 0x00000000
|
||||
#define R128_CCE_PACKET1 0x40000000
|
||||
#define R128_CCE_PACKET2 0x80000000
|
||||
#define R128_CCE_PACKET3 0xC0000000
|
||||
# define R128_CNTL_HOSTDATA_BLT 0x00009400
|
||||
# define R128_CNTL_PAINT_MULTI 0x00009A00
|
||||
# define R128_CNTL_BITBLT_MULTI 0x00009B00
|
||||
# define R128_3D_RNDR_GEN_INDX_PRIM 0x00002300
|
||||
|
||||
#define R128_CCE_PACKET_MASK 0xC0000000
|
||||
#define R128_CCE_PACKET_COUNT_MASK 0x3fff0000
|
||||
#define R128_CCE_PACKET0_REG_MASK 0x000007ff
|
||||
#define R128_CCE_PACKET1_REG0_MASK 0x000007ff
|
||||
#define R128_CCE_PACKET1_REG1_MASK 0x003ff800
|
||||
|
||||
#define R128_CCE_VC_CNTL_PRIM_TYPE_NONE 0x00000000
|
||||
#define R128_CCE_VC_CNTL_PRIM_TYPE_POINT 0x00000001
|
||||
#define R128_CCE_VC_CNTL_PRIM_TYPE_LINE 0x00000002
|
||||
#define R128_CCE_VC_CNTL_PRIM_TYPE_POLY_LINE 0x00000003
|
||||
#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST 0x00000004
|
||||
#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN 0x00000005
|
||||
#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_STRIP 0x00000006
|
||||
#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2 0x00000007
|
||||
#define R128_CCE_VC_CNTL_PRIM_WALK_IND 0x00000010
|
||||
#define R128_CCE_VC_CNTL_PRIM_WALK_LIST 0x00000020
|
||||
#define R128_CCE_VC_CNTL_PRIM_WALK_RING 0x00000030
|
||||
#define R128_CCE_VC_CNTL_NUM_SHIFT 16
|
||||
|
||||
#define R128_DATATYPE_CI8 2
|
||||
#define R128_DATATYPE_ARGB1555 3
|
||||
#define R128_DATATYPE_RGB565 4
|
||||
#define R128_DATATYPE_RGB888 5
|
||||
#define R128_DATATYPE_ARGB8888 6
|
||||
#define R128_DATATYPE_RGB332 7
|
||||
#define R128_DATATYPE_RGB8 9
|
||||
#define R128_DATATYPE_ARGB4444 15
|
||||
|
||||
/* Constants */
|
||||
#define R128_AGP_OFFSET 0x02000000
|
||||
|
||||
#define R128_WATERMARK_L 16
|
||||
#define R128_WATERMARK_M 8
|
||||
#define R128_WATERMARK_N 8
|
||||
#define R128_WATERMARK_K 128
|
||||
|
||||
#define R128_MAX_USEC_TIMEOUT 100000 /* 100 ms */
|
||||
|
||||
#define R128_LAST_FRAME_REG R128_GUI_SCRATCH_REG0
|
||||
#define R128_LAST_DISPATCH_REG R128_GUI_SCRATCH_REG1
|
||||
#define R128_MAX_VB_AGE 0x7fffffff
|
||||
#define R128_MAX_VB_VERTS (0xffff)
|
||||
|
||||
#define R128_RING_HIGH_MARK 128
|
||||
|
||||
#define R128_PERFORMANCE_BOXES 0
|
||||
|
||||
|
||||
#define R128_BASE(reg) ((unsigned long)(dev_priv->mmio->handle))
|
||||
#define R128_ADDR(reg) (R128_BASE( reg ) + reg)
|
||||
|
||||
#define R128_READ(reg) DRM_READ32( (volatile u32 *) R128_ADDR(reg) )
|
||||
#define R128_WRITE(reg,val) DRM_WRITE32( (volatile u32 *) R128_ADDR(reg), (val) )
|
||||
|
||||
#define R128_READ8(reg) DRM_READ8( (volatile u8 *) R128_ADDR(reg) )
|
||||
#define R128_WRITE8(reg,val) DRM_WRITE8( (volatile u8 *) R128_ADDR(reg), (val) )
|
||||
|
||||
#define R128_WRITE_PLL(addr,val) \
|
||||
do { \
|
||||
R128_WRITE8(R128_CLOCK_CNTL_INDEX, \
|
||||
((addr) & 0x1f) | R128_PLL_WR_EN); \
|
||||
R128_WRITE(R128_CLOCK_CNTL_DATA, (val)); \
|
||||
} while (0)
|
||||
|
||||
extern int R128_READ_PLL(drm_device_t *dev, int addr);
|
||||
|
||||
|
||||
#define CCE_PACKET0( reg, n ) (R128_CCE_PACKET0 | \
|
||||
((n) << 16) | ((reg) >> 2))
|
||||
#define CCE_PACKET1( reg0, reg1 ) (R128_CCE_PACKET1 | \
|
||||
(((reg1) >> 2) << 11) | ((reg0) >> 2))
|
||||
#define CCE_PACKET2() (R128_CCE_PACKET2)
|
||||
#define CCE_PACKET3( pkt, n ) (R128_CCE_PACKET3 | \
|
||||
(pkt) | ((n) << 16))
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Misc helper macros
|
||||
*/
|
||||
|
||||
#define LOCK_TEST_WITH_RETURN( dev ) \
|
||||
do { \
|
||||
if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
|
||||
dev->lock.pid != DRM_CURRENTPID ) { \
|
||||
DRM_ERROR( "%s called without lock held\n", __func__ ); \
|
||||
return DRM_ERR(EINVAL); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define RING_SPACE_TEST_WITH_RETURN( dev_priv ) \
|
||||
do { \
|
||||
drm_r128_ring_buffer_t *ring = &dev_priv->ring; int i; \
|
||||
if ( ring->space < ring->high_mark ) { \
|
||||
for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) { \
|
||||
r128_update_ring_snapshot( ring ); \
|
||||
if ( ring->space >= ring->high_mark ) \
|
||||
goto __ring_space_done; \
|
||||
DRM_UDELAY(1); \
|
||||
} \
|
||||
DRM_ERROR( "ring space check failed!\n" ); \
|
||||
return DRM_ERR(EBUSY); \
|
||||
} \
|
||||
__ring_space_done: \
|
||||
; \
|
||||
} while (0)
|
||||
|
||||
#define VB_AGE_TEST_WITH_RETURN( dev_priv ) \
|
||||
do { \
|
||||
drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; \
|
||||
if ( sarea_priv->last_dispatch >= R128_MAX_VB_AGE ) { \
|
||||
int __ret = r128_do_cce_idle( dev_priv ); \
|
||||
if ( __ret ) return __ret; \
|
||||
sarea_priv->last_dispatch = 0; \
|
||||
r128_freelist_reset( dev ); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define R128_WAIT_UNTIL_PAGE_FLIPPED() do { \
|
||||
OUT_RING( CCE_PACKET0( R128_WAIT_UNTIL, 0 ) ); \
|
||||
OUT_RING( R128_EVENT_CRTC_OFFSET ); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Ring control
|
||||
*/
|
||||
|
||||
#if defined(__powerpc__)
|
||||
#define r128_flush_write_combine() (void) GET_RING_HEAD( &dev_priv->ring )
|
||||
#else
|
||||
#define r128_flush_write_combine() DRM_WRITEMEMORYBARRIER()
|
||||
#endif
|
||||
|
||||
|
||||
#define R128_VERBOSE 0
|
||||
|
||||
#define RING_LOCALS \
|
||||
int write; unsigned int tail_mask; volatile u32 *ring;
|
||||
|
||||
#define BEGIN_RING( n ) do { \
|
||||
if ( R128_VERBOSE ) { \
|
||||
DRM_INFO( "BEGIN_RING( %d ) in %s\n", \
|
||||
(n), __func__ ); \
|
||||
} \
|
||||
if ( dev_priv->ring.space <= (n) * sizeof(u32) ) { \
|
||||
r128_wait_ring( dev_priv, (n) * sizeof(u32) ); \
|
||||
} \
|
||||
dev_priv->ring.space -= (n) * sizeof(u32); \
|
||||
ring = dev_priv->ring.start; \
|
||||
write = dev_priv->ring.tail; \
|
||||
tail_mask = dev_priv->ring.tail_mask; \
|
||||
} while (0)
|
||||
|
||||
/* You can set this to zero if you want. If the card locks up, you'll
|
||||
* need to keep this set. It works around a bug in early revs of the
|
||||
* Rage 128 chipset, where the CCE would read 32 dwords past the end of
|
||||
* the ring buffer before wrapping around.
|
||||
*/
|
||||
#define R128_BROKEN_CCE 1
|
||||
|
||||
#define ADVANCE_RING() do { \
|
||||
if ( R128_VERBOSE ) { \
|
||||
DRM_INFO( "ADVANCE_RING() wr=0x%06x tail=0x%06x\n", \
|
||||
write, dev_priv->ring.tail ); \
|
||||
} \
|
||||
if ( R128_BROKEN_CCE && write < 32 ) { \
|
||||
memcpy( dev_priv->ring.end, \
|
||||
dev_priv->ring.start, \
|
||||
write * sizeof(u32) ); \
|
||||
} \
|
||||
r128_flush_write_combine(); \
|
||||
dev_priv->ring.tail = write; \
|
||||
R128_WRITE( R128_PM4_BUFFER_DL_WPTR, write ); \
|
||||
} while (0)
|
||||
|
||||
#define OUT_RING( x ) do { \
|
||||
if ( R128_VERBOSE ) { \
|
||||
DRM_INFO( " OUT_RING( 0x%08x ) at 0x%x\n", \
|
||||
(unsigned int)(x), write ); \
|
||||
} \
|
||||
ring[write++] = cpu_to_le32( x ); \
|
||||
write &= tail_mask; \
|
||||
} while (0)
|
||||
|
||||
#endif /* __R128_DRV_H__ */
|
||||
1566
shared/r128_state.c
Normal file
1566
shared/r128_state.c
Normal file
File diff suppressed because it is too large
Load diff
760
shared/radeon_drv.h
Normal file
760
shared/radeon_drv.h
Normal file
|
|
@ -0,0 +1,760 @@
|
|||
/* radeon_drv.h -- Private header for radeon driver -*- linux-c -*-
|
||||
*
|
||||
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2000 VA Linux Systems, Inc., Fremont, California.
|
||||
* 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, sublicense,
|
||||
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PRECISION INSIGHT 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.
|
||||
*
|
||||
* Authors:
|
||||
* Kevin E. Martin <martin@valinux.com>
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#ifndef __RADEON_DRV_H__
|
||||
#define __RADEON_DRV_H__
|
||||
|
||||
#define GET_RING_HEAD(ring) DRM_READ32( (volatile u32 *) (ring)->head )
|
||||
#define SET_RING_HEAD(ring,val) DRM_WRITE32( (volatile u32 *) (ring)->head , (val))
|
||||
|
||||
typedef struct drm_radeon_freelist {
|
||||
unsigned int age;
|
||||
drm_buf_t *buf;
|
||||
struct drm_radeon_freelist *next;
|
||||
struct drm_radeon_freelist *prev;
|
||||
} drm_radeon_freelist_t;
|
||||
|
||||
typedef struct drm_radeon_ring_buffer {
|
||||
u32 *start;
|
||||
u32 *end;
|
||||
int size;
|
||||
int size_l2qw;
|
||||
|
||||
volatile u32 *head;
|
||||
u32 tail;
|
||||
u32 tail_mask;
|
||||
int space;
|
||||
|
||||
int high_mark;
|
||||
} drm_radeon_ring_buffer_t;
|
||||
|
||||
typedef struct drm_radeon_depth_clear_t {
|
||||
u32 rb3d_cntl;
|
||||
u32 rb3d_zstencilcntl;
|
||||
u32 se_cntl;
|
||||
} drm_radeon_depth_clear_t;
|
||||
|
||||
typedef struct drm_radeon_private {
|
||||
drm_radeon_ring_buffer_t ring;
|
||||
drm_radeon_sarea_t *sarea_priv;
|
||||
|
||||
int agp_size;
|
||||
u32 agp_vm_start;
|
||||
unsigned long agp_buffers_offset;
|
||||
|
||||
int cp_mode;
|
||||
int cp_running;
|
||||
|
||||
drm_radeon_freelist_t *head;
|
||||
drm_radeon_freelist_t *tail;
|
||||
int last_buf;
|
||||
volatile u32 *scratch;
|
||||
|
||||
int usec_timeout;
|
||||
int is_pci;
|
||||
unsigned long phys_pci_gart;
|
||||
dma_addr_t bus_pci_gart;
|
||||
|
||||
atomic_t idle_count;
|
||||
|
||||
int page_flipping;
|
||||
int current_page;
|
||||
u32 crtc_offset;
|
||||
u32 crtc_offset_cntl;
|
||||
|
||||
u32 color_fmt;
|
||||
unsigned int front_offset;
|
||||
unsigned int front_pitch;
|
||||
unsigned int back_offset;
|
||||
unsigned int back_pitch;
|
||||
|
||||
u32 depth_fmt;
|
||||
unsigned int depth_offset;
|
||||
unsigned int depth_pitch;
|
||||
|
||||
u32 front_pitch_offset;
|
||||
u32 back_pitch_offset;
|
||||
u32 depth_pitch_offset;
|
||||
|
||||
drm_radeon_depth_clear_t depth_clear;
|
||||
|
||||
drm_map_t *sarea;
|
||||
drm_map_t *fb;
|
||||
drm_map_t *mmio;
|
||||
drm_map_t *cp_ring;
|
||||
drm_map_t *ring_rptr;
|
||||
drm_map_t *buffers;
|
||||
drm_map_t *agp_textures;
|
||||
} drm_radeon_private_t;
|
||||
|
||||
typedef struct drm_radeon_buf_priv {
|
||||
u32 age;
|
||||
} drm_radeon_buf_priv_t;
|
||||
|
||||
/* radeon_cp.c */
|
||||
extern int radeon_cp_init( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_start( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_stop( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_reset( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_idle( DRM_IOCTL_ARGS );
|
||||
extern int radeon_engine_reset( DRM_IOCTL_ARGS );
|
||||
extern int radeon_fullscreen( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_buffers( DRM_IOCTL_ARGS );
|
||||
|
||||
extern void radeon_freelist_reset( drm_device_t *dev );
|
||||
extern drm_buf_t *radeon_freelist_get( drm_device_t *dev );
|
||||
|
||||
extern int radeon_wait_ring( drm_radeon_private_t *dev_priv, int n );
|
||||
|
||||
static __inline__ void
|
||||
radeon_update_ring_snapshot( drm_radeon_ring_buffer_t *ring )
|
||||
{
|
||||
ring->space = (GET_RING_HEAD(ring) - ring->tail) * sizeof(u32);
|
||||
if ( ring->space <= 0 )
|
||||
ring->space += ring->size;
|
||||
}
|
||||
|
||||
extern int radeon_do_cp_idle( drm_radeon_private_t *dev_priv );
|
||||
extern int radeon_do_cleanup_cp( drm_device_t *dev );
|
||||
extern int radeon_do_cleanup_pageflip( drm_device_t *dev );
|
||||
|
||||
/* radeon_state.c */
|
||||
extern int radeon_cp_clear( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_swap( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_vertex( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_indices( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_texture( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_stipple( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_indirect( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_vertex2( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_cmdbuf( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_getparam( DRM_IOCTL_ARGS );
|
||||
extern int radeon_cp_flip( DRM_IOCTL_ARGS );
|
||||
|
||||
|
||||
|
||||
/* Register definitions, register access macros and drmAddMap constants
|
||||
* for Radeon kernel driver.
|
||||
*/
|
||||
|
||||
#define RADEON_AGP_COMMAND 0x0f60
|
||||
#define RADEON_AUX_SCISSOR_CNTL 0x26f0
|
||||
# define RADEON_EXCLUSIVE_SCISSOR_0 (1 << 24)
|
||||
# define RADEON_EXCLUSIVE_SCISSOR_1 (1 << 25)
|
||||
# define RADEON_EXCLUSIVE_SCISSOR_2 (1 << 26)
|
||||
# define RADEON_SCISSOR_0_ENABLE (1 << 28)
|
||||
# define RADEON_SCISSOR_1_ENABLE (1 << 29)
|
||||
# define RADEON_SCISSOR_2_ENABLE (1 << 30)
|
||||
|
||||
#define RADEON_BUS_CNTL 0x0030
|
||||
# define RADEON_BUS_MASTER_DIS (1 << 6)
|
||||
|
||||
#define RADEON_CLOCK_CNTL_DATA 0x000c
|
||||
# define RADEON_PLL_WR_EN (1 << 7)
|
||||
#define RADEON_CLOCK_CNTL_INDEX 0x0008
|
||||
#define RADEON_CONFIG_APER_SIZE 0x0108
|
||||
#define RADEON_CRTC_OFFSET 0x0224
|
||||
#define RADEON_CRTC_OFFSET_CNTL 0x0228
|
||||
# define RADEON_CRTC_TILE_EN (1 << 15)
|
||||
# define RADEON_CRTC_OFFSET_FLIP_CNTL (1 << 16)
|
||||
|
||||
#define RADEON_RB3D_COLORPITCH 0x1c48
|
||||
|
||||
#define RADEON_DP_GUI_MASTER_CNTL 0x146c
|
||||
# define RADEON_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0)
|
||||
# define RADEON_GMC_DST_PITCH_OFFSET_CNTL (1 << 1)
|
||||
# define RADEON_GMC_BRUSH_SOLID_COLOR (13 << 4)
|
||||
# define RADEON_GMC_BRUSH_NONE (15 << 4)
|
||||
# define RADEON_GMC_DST_16BPP (4 << 8)
|
||||
# define RADEON_GMC_DST_24BPP (5 << 8)
|
||||
# define RADEON_GMC_DST_32BPP (6 << 8)
|
||||
# define RADEON_GMC_DST_DATATYPE_SHIFT 8
|
||||
# define RADEON_GMC_SRC_DATATYPE_COLOR (3 << 12)
|
||||
# define RADEON_DP_SRC_SOURCE_MEMORY (2 << 24)
|
||||
# define RADEON_DP_SRC_SOURCE_HOST_DATA (3 << 24)
|
||||
# define RADEON_GMC_CLR_CMP_CNTL_DIS (1 << 28)
|
||||
# define RADEON_GMC_WR_MSK_DIS (1 << 30)
|
||||
# define RADEON_ROP3_S 0x00cc0000
|
||||
# define RADEON_ROP3_P 0x00f00000
|
||||
#define RADEON_DP_WRITE_MASK 0x16cc
|
||||
#define RADEON_DST_PITCH_OFFSET 0x142c
|
||||
#define RADEON_DST_PITCH_OFFSET_C 0x1c80
|
||||
# define RADEON_DST_TILE_LINEAR (0 << 30)
|
||||
# define RADEON_DST_TILE_MACRO (1 << 30)
|
||||
# define RADEON_DST_TILE_MICRO (2 << 30)
|
||||
# define RADEON_DST_TILE_BOTH (3 << 30)
|
||||
|
||||
#define RADEON_SCRATCH_REG0 0x15e0
|
||||
#define RADEON_SCRATCH_REG1 0x15e4
|
||||
#define RADEON_SCRATCH_REG2 0x15e8
|
||||
#define RADEON_SCRATCH_REG3 0x15ec
|
||||
#define RADEON_SCRATCH_REG4 0x15f0
|
||||
#define RADEON_SCRATCH_REG5 0x15f4
|
||||
#define RADEON_SCRATCH_UMSK 0x0770
|
||||
#define RADEON_SCRATCH_ADDR 0x0774
|
||||
|
||||
#define RADEON_HOST_PATH_CNTL 0x0130
|
||||
# define RADEON_HDP_SOFT_RESET (1 << 26)
|
||||
# define RADEON_HDP_WC_TIMEOUT_MASK (7 << 28)
|
||||
# define RADEON_HDP_WC_TIMEOUT_28BCLK (7 << 28)
|
||||
|
||||
#define RADEON_ISYNC_CNTL 0x1724
|
||||
# define RADEON_ISYNC_ANY2D_IDLE3D (1 << 0)
|
||||
# define RADEON_ISYNC_ANY3D_IDLE2D (1 << 1)
|
||||
# define RADEON_ISYNC_TRIG2D_IDLE3D (1 << 2)
|
||||
# define RADEON_ISYNC_TRIG3D_IDLE2D (1 << 3)
|
||||
# define RADEON_ISYNC_WAIT_IDLEGUI (1 << 4)
|
||||
# define RADEON_ISYNC_CPSCRATCH_IDLEGUI (1 << 5)
|
||||
|
||||
#define RADEON_RBBM_GUICNTL 0x172c
|
||||
# define RADEON_HOST_DATA_SWAP_NONE (0 << 0)
|
||||
# define RADEON_HOST_DATA_SWAP_16BIT (1 << 0)
|
||||
# define RADEON_HOST_DATA_SWAP_32BIT (2 << 0)
|
||||
# define RADEON_HOST_DATA_SWAP_HDW (3 << 0)
|
||||
|
||||
#define RADEON_MC_AGP_LOCATION 0x014c
|
||||
#define RADEON_MC_FB_LOCATION 0x0148
|
||||
#define RADEON_MCLK_CNTL 0x0012
|
||||
# define RADEON_FORCEON_MCLKA (1 << 16)
|
||||
# define RADEON_FORCEON_MCLKB (1 << 17)
|
||||
# define RADEON_FORCEON_YCLKA (1 << 18)
|
||||
# define RADEON_FORCEON_YCLKB (1 << 19)
|
||||
# define RADEON_FORCEON_MC (1 << 20)
|
||||
# define RADEON_FORCEON_AIC (1 << 21)
|
||||
|
||||
#define RADEON_PP_BORDER_COLOR_0 0x1d40
|
||||
#define RADEON_PP_BORDER_COLOR_1 0x1d44
|
||||
#define RADEON_PP_BORDER_COLOR_2 0x1d48
|
||||
#define RADEON_PP_CNTL 0x1c38
|
||||
# define RADEON_SCISSOR_ENABLE (1 << 1)
|
||||
#define RADEON_PP_LUM_MATRIX 0x1d00
|
||||
#define RADEON_PP_MISC 0x1c14
|
||||
#define RADEON_PP_ROT_MATRIX_0 0x1d58
|
||||
#define RADEON_PP_TXFILTER_0 0x1c54
|
||||
#define RADEON_PP_TXFILTER_1 0x1c6c
|
||||
#define RADEON_PP_TXFILTER_2 0x1c84
|
||||
|
||||
#define RADEON_RB2D_DSTCACHE_CTLSTAT 0x342c
|
||||
# define RADEON_RB2D_DC_FLUSH (3 << 0)
|
||||
# define RADEON_RB2D_DC_FREE (3 << 2)
|
||||
# define RADEON_RB2D_DC_FLUSH_ALL 0xf
|
||||
# define RADEON_RB2D_DC_BUSY (1 << 31)
|
||||
#define RADEON_RB3D_CNTL 0x1c3c
|
||||
# define RADEON_ALPHA_BLEND_ENABLE (1 << 0)
|
||||
# define RADEON_PLANE_MASK_ENABLE (1 << 1)
|
||||
# define RADEON_DITHER_ENABLE (1 << 2)
|
||||
# define RADEON_ROUND_ENABLE (1 << 3)
|
||||
# define RADEON_SCALE_DITHER_ENABLE (1 << 4)
|
||||
# define RADEON_DITHER_INIT (1 << 5)
|
||||
# define RADEON_ROP_ENABLE (1 << 6)
|
||||
# define RADEON_STENCIL_ENABLE (1 << 7)
|
||||
# define RADEON_Z_ENABLE (1 << 8)
|
||||
#define RADEON_RB3D_DEPTHOFFSET 0x1c24
|
||||
#define RADEON_RB3D_PLANEMASK 0x1d84
|
||||
#define RADEON_RB3D_STENCILREFMASK 0x1d7c
|
||||
#define RADEON_RB3D_ZCACHE_MODE 0x3250
|
||||
#define RADEON_RB3D_ZCACHE_CTLSTAT 0x3254
|
||||
# define RADEON_RB3D_ZC_FLUSH (1 << 0)
|
||||
# define RADEON_RB3D_ZC_FREE (1 << 2)
|
||||
# define RADEON_RB3D_ZC_FLUSH_ALL 0x5
|
||||
# define RADEON_RB3D_ZC_BUSY (1 << 31)
|
||||
#define RADEON_RB3D_ZSTENCILCNTL 0x1c2c
|
||||
# define RADEON_Z_TEST_MASK (7 << 4)
|
||||
# define RADEON_Z_TEST_ALWAYS (7 << 4)
|
||||
# define RADEON_STENCIL_TEST_ALWAYS (7 << 12)
|
||||
# define RADEON_STENCIL_S_FAIL_REPLACE (2 << 16)
|
||||
# define RADEON_STENCIL_ZPASS_REPLACE (2 << 20)
|
||||
# define RADEON_STENCIL_ZFAIL_REPLACE (2 << 24)
|
||||
# define RADEON_Z_WRITE_ENABLE (1 << 30)
|
||||
#define RADEON_RBBM_SOFT_RESET 0x00f0
|
||||
# define RADEON_SOFT_RESET_CP (1 << 0)
|
||||
# define RADEON_SOFT_RESET_HI (1 << 1)
|
||||
# define RADEON_SOFT_RESET_SE (1 << 2)
|
||||
# define RADEON_SOFT_RESET_RE (1 << 3)
|
||||
# define RADEON_SOFT_RESET_PP (1 << 4)
|
||||
# define RADEON_SOFT_RESET_E2 (1 << 5)
|
||||
# define RADEON_SOFT_RESET_RB (1 << 6)
|
||||
# define RADEON_SOFT_RESET_HDP (1 << 7)
|
||||
#define RADEON_RBBM_STATUS 0x0e40
|
||||
# define RADEON_RBBM_FIFOCNT_MASK 0x007f
|
||||
# define RADEON_RBBM_ACTIVE (1 << 31)
|
||||
#define RADEON_RE_LINE_PATTERN 0x1cd0
|
||||
#define RADEON_RE_MISC 0x26c4
|
||||
#define RADEON_RE_TOP_LEFT 0x26c0
|
||||
#define RADEON_RE_WIDTH_HEIGHT 0x1c44
|
||||
#define RADEON_RE_STIPPLE_ADDR 0x1cc8
|
||||
#define RADEON_RE_STIPPLE_DATA 0x1ccc
|
||||
|
||||
#define RADEON_SCISSOR_TL_0 0x1cd8
|
||||
#define RADEON_SCISSOR_BR_0 0x1cdc
|
||||
#define RADEON_SCISSOR_TL_1 0x1ce0
|
||||
#define RADEON_SCISSOR_BR_1 0x1ce4
|
||||
#define RADEON_SCISSOR_TL_2 0x1ce8
|
||||
#define RADEON_SCISSOR_BR_2 0x1cec
|
||||
#define RADEON_SE_COORD_FMT 0x1c50
|
||||
#define RADEON_SE_CNTL 0x1c4c
|
||||
# define RADEON_FFACE_CULL_CW (0 << 0)
|
||||
# define RADEON_BFACE_SOLID (3 << 1)
|
||||
# define RADEON_FFACE_SOLID (3 << 3)
|
||||
# define RADEON_FLAT_SHADE_VTX_LAST (3 << 6)
|
||||
# define RADEON_DIFFUSE_SHADE_FLAT (1 << 8)
|
||||
# define RADEON_DIFFUSE_SHADE_GOURAUD (2 << 8)
|
||||
# define RADEON_ALPHA_SHADE_FLAT (1 << 10)
|
||||
# define RADEON_ALPHA_SHADE_GOURAUD (2 << 10)
|
||||
# define RADEON_SPECULAR_SHADE_FLAT (1 << 12)
|
||||
# define RADEON_SPECULAR_SHADE_GOURAUD (2 << 12)
|
||||
# define RADEON_FOG_SHADE_FLAT (1 << 14)
|
||||
# define RADEON_FOG_SHADE_GOURAUD (2 << 14)
|
||||
# define RADEON_VPORT_XY_XFORM_ENABLE (1 << 24)
|
||||
# define RADEON_VPORT_Z_XFORM_ENABLE (1 << 25)
|
||||
# define RADEON_VTX_PIX_CENTER_OGL (1 << 27)
|
||||
# define RADEON_ROUND_MODE_TRUNC (0 << 28)
|
||||
# define RADEON_ROUND_PREC_8TH_PIX (1 << 30)
|
||||
#define RADEON_SE_CNTL_STATUS 0x2140
|
||||
#define RADEON_SE_LINE_WIDTH 0x1db8
|
||||
#define RADEON_SE_VPORT_XSCALE 0x1d98
|
||||
#define RADEON_SE_ZBIAS_FACTOR 0x1db0
|
||||
#define RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED 0x2210
|
||||
#define RADEON_SE_TCL_OUTPUT_VTX_FMT 0x2254
|
||||
#define RADEON_SE_TCL_VECTOR_INDX_REG 0x2200
|
||||
# define RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT 16
|
||||
# define RADEON_VEC_INDX_DWORD_COUNT_SHIFT 28
|
||||
#define RADEON_SE_TCL_VECTOR_DATA_REG 0x2204
|
||||
#define RADEON_SE_TCL_SCALAR_INDX_REG 0x2208
|
||||
# define RADEON_SCAL_INDX_DWORD_STRIDE_SHIFT 16
|
||||
#define RADEON_SE_TCL_SCALAR_DATA_REG 0x220C
|
||||
#define RADEON_SURFACE_ACCESS_FLAGS 0x0bf8
|
||||
#define RADEON_SURFACE_ACCESS_CLR 0x0bfc
|
||||
#define RADEON_SURFACE_CNTL 0x0b00
|
||||
# define RADEON_SURF_TRANSLATION_DIS (1 << 8)
|
||||
# define RADEON_NONSURF_AP0_SWP_MASK (3 << 20)
|
||||
# define RADEON_NONSURF_AP0_SWP_LITTLE (0 << 20)
|
||||
# define RADEON_NONSURF_AP0_SWP_BIG16 (1 << 20)
|
||||
# define RADEON_NONSURF_AP0_SWP_BIG32 (2 << 20)
|
||||
# define RADEON_NONSURF_AP1_SWP_MASK (3 << 22)
|
||||
# define RADEON_NONSURF_AP1_SWP_LITTLE (0 << 22)
|
||||
# define RADEON_NONSURF_AP1_SWP_BIG16 (1 << 22)
|
||||
# define RADEON_NONSURF_AP1_SWP_BIG32 (2 << 22)
|
||||
#define RADEON_SURFACE0_INFO 0x0b0c
|
||||
# define RADEON_SURF_PITCHSEL_MASK (0x1ff << 0)
|
||||
# define RADEON_SURF_TILE_MODE_MASK (3 << 16)
|
||||
# define RADEON_SURF_TILE_MODE_MACRO (0 << 16)
|
||||
# define RADEON_SURF_TILE_MODE_MICRO (1 << 16)
|
||||
# define RADEON_SURF_TILE_MODE_32BIT_Z (2 << 16)
|
||||
# define RADEON_SURF_TILE_MODE_16BIT_Z (3 << 16)
|
||||
#define RADEON_SURFACE0_LOWER_BOUND 0x0b04
|
||||
#define RADEON_SURFACE0_UPPER_BOUND 0x0b08
|
||||
#define RADEON_SURFACE1_INFO 0x0b1c
|
||||
#define RADEON_SURFACE1_LOWER_BOUND 0x0b14
|
||||
#define RADEON_SURFACE1_UPPER_BOUND 0x0b18
|
||||
#define RADEON_SURFACE2_INFO 0x0b2c
|
||||
#define RADEON_SURFACE2_LOWER_BOUND 0x0b24
|
||||
#define RADEON_SURFACE2_UPPER_BOUND 0x0b28
|
||||
#define RADEON_SURFACE3_INFO 0x0b3c
|
||||
#define RADEON_SURFACE3_LOWER_BOUND 0x0b34
|
||||
#define RADEON_SURFACE3_UPPER_BOUND 0x0b38
|
||||
#define RADEON_SURFACE4_INFO 0x0b4c
|
||||
#define RADEON_SURFACE4_LOWER_BOUND 0x0b44
|
||||
#define RADEON_SURFACE4_UPPER_BOUND 0x0b48
|
||||
#define RADEON_SURFACE5_INFO 0x0b5c
|
||||
#define RADEON_SURFACE5_LOWER_BOUND 0x0b54
|
||||
#define RADEON_SURFACE5_UPPER_BOUND 0x0b58
|
||||
#define RADEON_SURFACE6_INFO 0x0b6c
|
||||
#define RADEON_SURFACE6_LOWER_BOUND 0x0b64
|
||||
#define RADEON_SURFACE6_UPPER_BOUND 0x0b68
|
||||
#define RADEON_SURFACE7_INFO 0x0b7c
|
||||
#define RADEON_SURFACE7_LOWER_BOUND 0x0b74
|
||||
#define RADEON_SURFACE7_UPPER_BOUND 0x0b78
|
||||
#define RADEON_SW_SEMAPHORE 0x013c
|
||||
|
||||
#define RADEON_WAIT_UNTIL 0x1720
|
||||
# define RADEON_WAIT_CRTC_PFLIP (1 << 0)
|
||||
# define RADEON_WAIT_2D_IDLECLEAN (1 << 16)
|
||||
# define RADEON_WAIT_3D_IDLECLEAN (1 << 17)
|
||||
# define RADEON_WAIT_HOST_IDLECLEAN (1 << 18)
|
||||
|
||||
#define RADEON_RB3D_ZMASKOFFSET 0x1c34
|
||||
#define RADEON_RB3D_ZSTENCILCNTL 0x1c2c
|
||||
# define RADEON_DEPTH_FORMAT_16BIT_INT_Z (0 << 0)
|
||||
# define RADEON_DEPTH_FORMAT_24BIT_INT_Z (2 << 0)
|
||||
|
||||
|
||||
/* CP registers */
|
||||
#define RADEON_CP_ME_RAM_ADDR 0x07d4
|
||||
#define RADEON_CP_ME_RAM_RADDR 0x07d8
|
||||
#define RADEON_CP_ME_RAM_DATAH 0x07dc
|
||||
#define RADEON_CP_ME_RAM_DATAL 0x07e0
|
||||
|
||||
#define RADEON_CP_RB_BASE 0x0700
|
||||
#define RADEON_CP_RB_CNTL 0x0704
|
||||
# define RADEON_BUF_SWAP_32BIT (2 << 16)
|
||||
#define RADEON_CP_RB_RPTR_ADDR 0x070c
|
||||
#define RADEON_CP_RB_RPTR 0x0710
|
||||
#define RADEON_CP_RB_WPTR 0x0714
|
||||
|
||||
#define RADEON_CP_RB_WPTR_DELAY 0x0718
|
||||
# define RADEON_PRE_WRITE_TIMER_SHIFT 0
|
||||
# define RADEON_PRE_WRITE_LIMIT_SHIFT 23
|
||||
|
||||
#define RADEON_CP_IB_BASE 0x0738
|
||||
|
||||
#define RADEON_CP_CSQ_CNTL 0x0740
|
||||
# define RADEON_CSQ_CNT_PRIMARY_MASK (0xff << 0)
|
||||
# define RADEON_CSQ_PRIDIS_INDDIS (0 << 28)
|
||||
# define RADEON_CSQ_PRIPIO_INDDIS (1 << 28)
|
||||
# define RADEON_CSQ_PRIBM_INDDIS (2 << 28)
|
||||
# define RADEON_CSQ_PRIPIO_INDBM (3 << 28)
|
||||
# define RADEON_CSQ_PRIBM_INDBM (4 << 28)
|
||||
# define RADEON_CSQ_PRIPIO_INDPIO (15 << 28)
|
||||
|
||||
#define RADEON_AIC_CNTL 0x01d0
|
||||
# define RADEON_PCIGART_TRANSLATE_EN (1 << 0)
|
||||
#define RADEON_AIC_STAT 0x01d4
|
||||
#define RADEON_AIC_PT_BASE 0x01d8
|
||||
#define RADEON_AIC_LO_ADDR 0x01dc
|
||||
#define RADEON_AIC_HI_ADDR 0x01e0
|
||||
#define RADEON_AIC_TLB_ADDR 0x01e4
|
||||
#define RADEON_AIC_TLB_DATA 0x01e8
|
||||
|
||||
/* CP command packets */
|
||||
#define RADEON_CP_PACKET0 0x00000000
|
||||
# define RADEON_ONE_REG_WR (1 << 15)
|
||||
#define RADEON_CP_PACKET1 0x40000000
|
||||
#define RADEON_CP_PACKET2 0x80000000
|
||||
#define RADEON_CP_PACKET3 0xC0000000
|
||||
# define RADEON_3D_RNDR_GEN_INDX_PRIM 0x00002300
|
||||
# define RADEON_WAIT_FOR_IDLE 0x00002600
|
||||
# define RADEON_3D_DRAW_VBUF 0x00002800
|
||||
# define RADEON_3D_DRAW_IMMD 0x00002900
|
||||
# define RADEON_3D_DRAW_INDX 0x00002A00
|
||||
# define RADEON_3D_LOAD_VBPNTR 0x00002F00
|
||||
# define RADEON_CNTL_HOSTDATA_BLT 0x00009400
|
||||
# define RADEON_CNTL_PAINT_MULTI 0x00009A00
|
||||
# define RADEON_CNTL_BITBLT_MULTI 0x00009B00
|
||||
# define RADEON_CNTL_SET_SCISSORS 0xC0001E00
|
||||
|
||||
#define RADEON_CP_PACKET_MASK 0xC0000000
|
||||
#define RADEON_CP_PACKET_COUNT_MASK 0x3fff0000
|
||||
#define RADEON_CP_PACKET0_REG_MASK 0x000007ff
|
||||
#define RADEON_CP_PACKET1_REG0_MASK 0x000007ff
|
||||
#define RADEON_CP_PACKET1_REG1_MASK 0x003ff800
|
||||
|
||||
#define RADEON_VTX_Z_PRESENT (1 << 31)
|
||||
#define RADEON_VTX_PKCOLOR_PRESENT (1 << 3)
|
||||
|
||||
#define RADEON_PRIM_TYPE_NONE (0 << 0)
|
||||
#define RADEON_PRIM_TYPE_POINT (1 << 0)
|
||||
#define RADEON_PRIM_TYPE_LINE (2 << 0)
|
||||
#define RADEON_PRIM_TYPE_LINE_STRIP (3 << 0)
|
||||
#define RADEON_PRIM_TYPE_TRI_LIST (4 << 0)
|
||||
#define RADEON_PRIM_TYPE_TRI_FAN (5 << 0)
|
||||
#define RADEON_PRIM_TYPE_TRI_STRIP (6 << 0)
|
||||
#define RADEON_PRIM_TYPE_TRI_TYPE2 (7 << 0)
|
||||
#define RADEON_PRIM_TYPE_RECT_LIST (8 << 0)
|
||||
#define RADEON_PRIM_TYPE_3VRT_POINT_LIST (9 << 0)
|
||||
#define RADEON_PRIM_TYPE_3VRT_LINE_LIST (10 << 0)
|
||||
#define RADEON_PRIM_TYPE_MASK 0xf
|
||||
#define RADEON_PRIM_WALK_IND (1 << 4)
|
||||
#define RADEON_PRIM_WALK_LIST (2 << 4)
|
||||
#define RADEON_PRIM_WALK_RING (3 << 4)
|
||||
#define RADEON_COLOR_ORDER_BGRA (0 << 6)
|
||||
#define RADEON_COLOR_ORDER_RGBA (1 << 6)
|
||||
#define RADEON_MAOS_ENABLE (1 << 7)
|
||||
#define RADEON_VTX_FMT_R128_MODE (0 << 8)
|
||||
#define RADEON_VTX_FMT_RADEON_MODE (1 << 8)
|
||||
#define RADEON_NUM_VERTICES_SHIFT 16
|
||||
|
||||
#define RADEON_COLOR_FORMAT_CI8 2
|
||||
#define RADEON_COLOR_FORMAT_ARGB1555 3
|
||||
#define RADEON_COLOR_FORMAT_RGB565 4
|
||||
#define RADEON_COLOR_FORMAT_ARGB8888 6
|
||||
#define RADEON_COLOR_FORMAT_RGB332 7
|
||||
#define RADEON_COLOR_FORMAT_RGB8 9
|
||||
#define RADEON_COLOR_FORMAT_ARGB4444 15
|
||||
|
||||
#define RADEON_TXFORMAT_I8 0
|
||||
#define RADEON_TXFORMAT_AI88 1
|
||||
#define RADEON_TXFORMAT_RGB332 2
|
||||
#define RADEON_TXFORMAT_ARGB1555 3
|
||||
#define RADEON_TXFORMAT_RGB565 4
|
||||
#define RADEON_TXFORMAT_ARGB4444 5
|
||||
#define RADEON_TXFORMAT_ARGB8888 6
|
||||
#define RADEON_TXFORMAT_RGBA8888 7
|
||||
|
||||
/* Constants */
|
||||
#define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */
|
||||
|
||||
#define RADEON_LAST_FRAME_REG RADEON_SCRATCH_REG0
|
||||
#define RADEON_LAST_DISPATCH_REG RADEON_SCRATCH_REG1
|
||||
#define RADEON_LAST_CLEAR_REG RADEON_SCRATCH_REG2
|
||||
#define RADEON_LAST_DISPATCH 1
|
||||
|
||||
#define RADEON_MAX_VB_AGE 0x7fffffff
|
||||
#define RADEON_MAX_VB_VERTS (0xffff)
|
||||
|
||||
#define RADEON_RING_HIGH_MARK 128
|
||||
|
||||
|
||||
#define RADEON_BASE(reg) ((unsigned long)(dev_priv->mmio->handle))
|
||||
#define RADEON_ADDR(reg) (RADEON_BASE( reg ) + reg)
|
||||
|
||||
#define RADEON_READ(reg) DRM_READ32( (volatile u32 *) RADEON_ADDR(reg) )
|
||||
#define RADEON_WRITE(reg,val) DRM_WRITE32( (volatile u32 *) RADEON_ADDR(reg), (val) )
|
||||
|
||||
#define RADEON_READ8(reg) DRM_READ8( (volatile u8 *) RADEON_ADDR(reg) )
|
||||
#define RADEON_WRITE8(reg,val) DRM_WRITE8( (volatile u8 *) RADEON_ADDR(reg), (val) )
|
||||
|
||||
#define RADEON_WRITE_PLL( addr, val ) \
|
||||
do { \
|
||||
RADEON_WRITE8( RADEON_CLOCK_CNTL_INDEX, \
|
||||
((addr) & 0x1f) | RADEON_PLL_WR_EN ); \
|
||||
RADEON_WRITE( RADEON_CLOCK_CNTL_DATA, (val) ); \
|
||||
} while (0)
|
||||
|
||||
extern int RADEON_READ_PLL( drm_device_t *dev, int addr );
|
||||
|
||||
|
||||
#define CP_PACKET0( reg, n ) \
|
||||
(RADEON_CP_PACKET0 | ((n) << 16) | ((reg) >> 2))
|
||||
#define CP_PACKET0_TABLE( reg, n ) \
|
||||
(RADEON_CP_PACKET0 | RADEON_ONE_REG_WR | ((n) << 16) | ((reg) >> 2))
|
||||
#define CP_PACKET1( reg0, reg1 ) \
|
||||
(RADEON_CP_PACKET1 | (((reg1) >> 2) << 15) | ((reg0) >> 2))
|
||||
#define CP_PACKET2() \
|
||||
(RADEON_CP_PACKET2)
|
||||
#define CP_PACKET3( pkt, n ) \
|
||||
(RADEON_CP_PACKET3 | (pkt) | ((n) << 16))
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Engine control helper macros
|
||||
*/
|
||||
|
||||
#define RADEON_WAIT_UNTIL_2D_IDLE() do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) ); \
|
||||
OUT_RING( (RADEON_WAIT_2D_IDLECLEAN | \
|
||||
RADEON_WAIT_HOST_IDLECLEAN) ); \
|
||||
} while (0)
|
||||
|
||||
#define RADEON_WAIT_UNTIL_3D_IDLE() do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) ); \
|
||||
OUT_RING( (RADEON_WAIT_3D_IDLECLEAN | \
|
||||
RADEON_WAIT_HOST_IDLECLEAN) ); \
|
||||
} while (0)
|
||||
|
||||
#define RADEON_WAIT_UNTIL_IDLE() do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) ); \
|
||||
OUT_RING( (RADEON_WAIT_2D_IDLECLEAN | \
|
||||
RADEON_WAIT_3D_IDLECLEAN | \
|
||||
RADEON_WAIT_HOST_IDLECLEAN) ); \
|
||||
} while (0)
|
||||
|
||||
#define RADEON_WAIT_UNTIL_PAGE_FLIPPED() do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) ); \
|
||||
OUT_RING( RADEON_WAIT_CRTC_PFLIP ); \
|
||||
} while (0)
|
||||
|
||||
#define RADEON_FLUSH_CACHE() do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_RB2D_DSTCACHE_CTLSTAT, 0 ) ); \
|
||||
OUT_RING( RADEON_RB2D_DC_FLUSH ); \
|
||||
} while (0)
|
||||
|
||||
#define RADEON_PURGE_CACHE() do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_RB2D_DSTCACHE_CTLSTAT, 0 ) ); \
|
||||
OUT_RING( RADEON_RB2D_DC_FLUSH_ALL ); \
|
||||
} while (0)
|
||||
|
||||
#define RADEON_FLUSH_ZCACHE() do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_RB3D_ZCACHE_CTLSTAT, 0 ) ); \
|
||||
OUT_RING( RADEON_RB3D_ZC_FLUSH ); \
|
||||
} while (0)
|
||||
|
||||
#define RADEON_PURGE_ZCACHE() do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_RB3D_ZCACHE_CTLSTAT, 0 ) ); \
|
||||
OUT_RING( RADEON_RB3D_ZC_FLUSH_ALL ); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Misc helper macros
|
||||
*/
|
||||
|
||||
#define LOCK_TEST_WITH_RETURN( dev ) \
|
||||
do { \
|
||||
if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
|
||||
dev->lock.pid != DRM_CURRENTPID ) { \
|
||||
DRM_ERROR( "%s called without lock held\n", __func__ ); \
|
||||
return DRM_ERR(EINVAL); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define RING_SPACE_TEST_WITH_RETURN( dev_priv ) \
|
||||
do { \
|
||||
drm_radeon_ring_buffer_t *ring = &dev_priv->ring; int i; \
|
||||
if ( ring->space < ring->high_mark ) { \
|
||||
for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) { \
|
||||
radeon_update_ring_snapshot( ring ); \
|
||||
if ( ring->space >= ring->high_mark ) \
|
||||
goto __ring_space_done; \
|
||||
DRM_UDELAY( 1 ); \
|
||||
} \
|
||||
DRM_ERROR( "ring space check from memory failed, reading register...\n" ); \
|
||||
/* If ring space check fails from RAM, try reading the \
|
||||
register directly */ \
|
||||
ring->space = 4 * ( RADEON_READ( RADEON_CP_RB_RPTR ) - ring->tail ); \
|
||||
if ( ring->space <= 0 ) \
|
||||
ring->space += ring->size; \
|
||||
if ( ring->space >= ring->high_mark ) \
|
||||
goto __ring_space_done; \
|
||||
\
|
||||
DRM_ERROR( "ring space check failed!\n" ); \
|
||||
return DRM_ERR(EBUSY); \
|
||||
} \
|
||||
__ring_space_done: \
|
||||
; \
|
||||
} while (0)
|
||||
|
||||
#define VB_AGE_TEST_WITH_RETURN( dev_priv ) \
|
||||
do { \
|
||||
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; \
|
||||
if ( sarea_priv->last_dispatch >= RADEON_MAX_VB_AGE ) { \
|
||||
int __ret = radeon_do_cp_idle( dev_priv ); \
|
||||
if ( __ret ) return __ret; \
|
||||
sarea_priv->last_dispatch = 0; \
|
||||
radeon_freelist_reset( dev ); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define RADEON_DISPATCH_AGE( age ) do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_LAST_DISPATCH_REG, 0 ) ); \
|
||||
OUT_RING( age ); \
|
||||
} while (0)
|
||||
|
||||
#define RADEON_FRAME_AGE( age ) do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_LAST_FRAME_REG, 0 ) ); \
|
||||
OUT_RING( age ); \
|
||||
} while (0)
|
||||
|
||||
#define RADEON_CLEAR_AGE( age ) do { \
|
||||
OUT_RING( CP_PACKET0( RADEON_LAST_CLEAR_REG, 0 ) ); \
|
||||
OUT_RING( age ); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Ring control
|
||||
*/
|
||||
|
||||
#if defined(__powerpc__)
|
||||
#define radeon_flush_write_combine() (void) GET_RING_HEAD( &dev_priv->ring )
|
||||
#else
|
||||
#define radeon_flush_write_combine() DRM_WRITEMEMORYBARRIER()
|
||||
#endif
|
||||
|
||||
|
||||
#define RADEON_VERBOSE 0
|
||||
|
||||
#define RING_LOCALS int write, _nr; unsigned int mask; u32 *ring;
|
||||
|
||||
#define BEGIN_RING( n ) do { \
|
||||
if ( RADEON_VERBOSE ) { \
|
||||
DRM_INFO( "BEGIN_RING( %d ) in %s\n", \
|
||||
n, __func__ ); \
|
||||
} \
|
||||
if ( dev_priv->ring.space <= (n) * sizeof(u32) ) { \
|
||||
COMMIT_RING(); \
|
||||
radeon_wait_ring( dev_priv, (n) * sizeof(u32) ); \
|
||||
} \
|
||||
_nr = n; dev_priv->ring.space -= (n) * sizeof(u32); \
|
||||
ring = dev_priv->ring.start; \
|
||||
write = dev_priv->ring.tail; \
|
||||
mask = dev_priv->ring.tail_mask; \
|
||||
} while (0)
|
||||
|
||||
#define ADVANCE_RING() do { \
|
||||
if ( RADEON_VERBOSE ) { \
|
||||
DRM_INFO( "ADVANCE_RING() wr=0x%06x tail=0x%06x\n", \
|
||||
write, dev_priv->ring.tail ); \
|
||||
} \
|
||||
if (((dev_priv->ring.tail + _nr) & mask) != write) { \
|
||||
DRM_ERROR( \
|
||||
"ADVANCE_RING(): mismatch: nr: %x write: %x\n", \
|
||||
((dev_priv->ring.tail + _nr) & mask), \
|
||||
write); \
|
||||
} else \
|
||||
dev_priv->ring.tail = write; \
|
||||
} while (0)
|
||||
|
||||
#define COMMIT_RING() do { \
|
||||
radeon_flush_write_combine(); \
|
||||
RADEON_WRITE( RADEON_CP_RB_WPTR, dev_priv->ring.tail ); \
|
||||
} while (0)
|
||||
|
||||
#define OUT_RING( x ) do { \
|
||||
if ( RADEON_VERBOSE ) { \
|
||||
DRM_INFO( " OUT_RING( 0x%08x ) at 0x%x\n", \
|
||||
(unsigned int)(x), write ); \
|
||||
} \
|
||||
ring[write++] = (x); \
|
||||
write &= mask; \
|
||||
} while (0)
|
||||
|
||||
#define OUT_RING_REG( reg, val ) do { \
|
||||
OUT_RING( CP_PACKET0( reg, 0 ) ); \
|
||||
OUT_RING( val ); \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define OUT_RING_USER_TABLE( tab, sz ) do { \
|
||||
int _size = (sz); \
|
||||
int *_tab = (tab); \
|
||||
\
|
||||
if (write + _size > mask) { \
|
||||
int i = (mask+1) - write; \
|
||||
if (DRM_COPY_FROM_USER_UNCHECKED( (int *)(ring+write), \
|
||||
_tab, i*4 )) \
|
||||
return DRM_ERR(EFAULT); \
|
||||
write = 0; \
|
||||
_size -= i; \
|
||||
_tab += i; \
|
||||
} \
|
||||
\
|
||||
if (_size && DRM_COPY_FROM_USER_UNCHECKED( (int *)(ring+write), \
|
||||
_tab, _size*4 )) \
|
||||
return DRM_ERR(EFAULT); \
|
||||
\
|
||||
write += _size; \
|
||||
write &= mask; \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define RADEON_PERFORMANCE_BOXES 0
|
||||
|
||||
#endif /* __RADEON_DRV_H__ */
|
||||
Loading…
Add table
Reference in a new issue