diff options
author | anholt <anholt@FreeBSD.org> | 2003-03-09 02:08:30 +0000 |
---|---|---|
committer | anholt <anholt@FreeBSD.org> | 2003-03-09 02:08:30 +0000 |
commit | ccdf4ef2d9288d035e56820efb0e79db6acf5ba8 (patch) | |
tree | ef9d3b03548e9f28bd5c265be746871660c0c16a /sys/dev/drm/drm_auth.h | |
parent | 0b60094f80a8137660b368df0b80fb0179b92d04 (diff) | |
download | FreeBSD-src-ccdf4ef2d9288d035e56820efb0e79db6acf5ba8.zip FreeBSD-src-ccdf4ef2d9288d035e56820efb0e79db6acf5ba8.tar.gz |
Update the DRM to latest from DRI CVS. This is approximately the version
included in XFree86 4.3, but includes some fixes. Notable changes include
Radeon 8500-9100 support, PCI Radeon/Rage 128 support, transform & lighting
support for Radeons, and vblank syncing support for r128, radeon, and mga.
The gamma driver was removed due to lack of any users.
Diffstat (limited to 'sys/dev/drm/drm_auth.h')
-rw-r--r-- | sys/dev/drm/drm_auth.h | 64 |
1 files changed, 24 insertions, 40 deletions
diff --git a/sys/dev/drm/drm_auth.h b/sys/dev/drm/drm_auth.h index 4eb62ab..1e08b05 100644 --- a/sys/dev/drm/drm_auth.h +++ b/sys/dev/drm/drm_auth.h @@ -27,11 +27,9 @@ * Authors: * Rickard E. (Rik) Faith <faith@valinux.com> * Gareth Hughes <gareth@valinux.com> - * * $FreeBSD$ */ -#define __NO_VERSION__ #include "dev/drm/drmP.h" static int DRM(hash_magic)(drm_magic_t magic) @@ -45,14 +43,14 @@ static drm_file_t *DRM(find_file)(drm_device_t *dev, drm_magic_t magic) drm_magic_entry_t *pt; int hash = DRM(hash_magic)(magic); - DRM_OS_LOCK; + DRM_LOCK; for (pt = dev->magiclist[hash].head; pt; pt = pt->next) { if (pt->magic == magic) { retval = pt->priv; break; } } - DRM_OS_UNLOCK; + DRM_UNLOCK; return retval; } @@ -65,12 +63,13 @@ int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic) hash = DRM(hash_magic)(magic); entry = (drm_magic_entry_t*) DRM(alloc)(sizeof(*entry), DRM_MEM_MAGIC); - if (!entry) return DRM_OS_ERR(ENOMEM); + if (!entry) return DRM_ERR(ENOMEM); + memset(entry, 0, sizeof(*entry)); entry->magic = magic; entry->priv = priv; entry->next = NULL; - DRM_OS_LOCK; + DRM_LOCK; if (dev->magiclist[hash].tail) { dev->magiclist[hash].tail->next = entry; dev->magiclist[hash].tail = entry; @@ -78,7 +77,7 @@ int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic) dev->magiclist[hash].head = entry; dev->magiclist[hash].tail = entry; } - DRM_OS_UNLOCK; + DRM_UNLOCK; return 0; } @@ -92,7 +91,7 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic) DRM_DEBUG("%d\n", magic); hash = DRM(hash_magic)(magic); - DRM_OS_LOCK; + DRM_LOCK; for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) { if (pt->magic == magic) { if (dev->magiclist[hash].head == pt) { @@ -104,49 +103,34 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic) if (prev) { prev->next = pt->next; } - DRM_OS_UNLOCK; -#ifdef __FreeBSD__ - DRM(free)(pt, sizeof(*pt), DRM_MEM_MAGIC); -#endif /* __FreeBSD__ */ + DRM_UNLOCK; return 0; } } - DRM_OS_UNLOCK; + DRM_UNLOCK; DRM(free)(pt, sizeof(*pt), DRM_MEM_MAGIC); - return DRM_OS_ERR(EINVAL); + return DRM_ERR(EINVAL); } -int DRM(getmagic)(DRM_OS_IOCTL) +int DRM(getmagic)(DRM_IOCTL_ARGS) { static drm_magic_t sequence = 0; drm_auth_t auth; -#ifdef __linux__ - static spinlock_t lock = SPIN_LOCK_UNLOCKED; -#endif /* __linux__ */ -#ifdef __FreeBSD__ - static DRM_OS_SPINTYPE lock; - static int first = 1; -#endif /* __FreeBSD__ */ - DRM_OS_DEVICE; - DRM_OS_PRIV; - -#ifdef __FreeBSD__ - if (first) { - DRM_OS_SPININIT(lock, "drm getmagic"); - first = 0; - } -#endif /* __FreeBSD__ */ + DRM_DEVICE; + DRM_PRIV; /* Find unique magic */ if (priv->magic) { auth.magic = priv->magic; } else { do { - DRM_OS_SPINLOCK(&lock); - if (!sequence) ++sequence; /* reserve 0 */ - auth.magic = sequence++; - DRM_OS_SPINUNLOCK(&lock); + int old = sequence; + + auth.magic = old+1; + + if (!atomic_cmpset_int(&sequence, old, auth.magic)) + continue; } while (DRM(find_file)(dev, auth.magic)); priv->magic = auth.magic; DRM(add_magic)(dev, priv, auth.magic); @@ -154,18 +138,18 @@ int DRM(getmagic)(DRM_OS_IOCTL) DRM_DEBUG("%u\n", auth.magic); - DRM_OS_KRNTOUSR((drm_auth_t *)data, auth, sizeof(auth)); + DRM_COPY_TO_USER_IOCTL((drm_auth_t *)data, auth, sizeof(auth)); return 0; } -int DRM(authmagic)(DRM_OS_IOCTL) +int DRM(authmagic)(DRM_IOCTL_ARGS) { drm_auth_t auth; drm_file_t *file; - DRM_OS_DEVICE; + DRM_DEVICE; - DRM_OS_KRNFROMUSR(auth, (drm_auth_t *)data, sizeof(auth)); + DRM_COPY_FROM_USER_IOCTL(auth, (drm_auth_t *)data, sizeof(auth)); DRM_DEBUG("%u\n", auth.magic); if ((file = DRM(find_file)(dev, auth.magic))) { @@ -173,5 +157,5 @@ int DRM(authmagic)(DRM_OS_IOCTL) DRM(remove_magic)(dev, auth.magic); return 0; } - return DRM_OS_ERR(EINVAL); + return DRM_ERR(EINVAL); } |