Skip to content
Browse files

link against libdrm_nouveau (installed with libdrm)

  • Loading branch information...
1 parent 2c06308 commit e02813aab0376271ee777a2b8dafc9381f96311a @skeggsb committed
View
4 configure.ac
@@ -65,6 +65,10 @@ XORG_DRIVER_CHECK_EXT(XV, videoproto)
XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
# Checks for pkg-config packages
+PKG_CHECK_MODULES(LIBDRM_NOUVEAU, libdrm_nouveau)
+AC_SUBST(LIBDRM_NOUVEAU_CFLAGS)
+AC_SUBST(LIBDRM_NOUVEAU_LIBS)
+
PKG_CHECK_MODULES(XORG, [xorg-server >= 1.3] xproto fontsproto libdrm xf86driproto $REQUIRED_MODULES)
sdkdir=$(pkg-config --variable=sdkdir xorg-server)
View
11 src/Makefile.am
@@ -23,20 +23,13 @@
# -avoid-version prevents gratuitous .0.0.0 version numbers on the end
# _ladir passes a dummy rpath to libtool so the thing will actually link
# TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
-AM_CFLAGS = @XORG_CFLAGS@
+AM_CFLAGS = @XORG_CFLAGS@ @LIBDRM_NOUVEAU_CFLAGS@
nouveau_drv_la_LTLIBRARIES = nouveau_drv.la
-nouveau_drv_la_LDFLAGS = -module -avoid-version
+nouveau_drv_la_LDFLAGS = -module -avoid-version @LIBDRM_NOUVEAU_LIBS@
nouveau_drv_ladir = @moduledir@/drivers
nouveau_drv_la_SOURCES = \
nouveau_bios.h \
- nouveau_device.c nouveau_device.h nouveau_drmif.h \
- nouveau_channel.c nouveau_channel.h \
- nouveau_grobj.c nouveau_grobj.h \
- nouveau_notifier.c nouveau_notifier.h \
- nouveau_dma.c nouveau_dma.h \
- nouveau_bo.c nouveau_bo.h \
- nouveau_class.h \
nouveau_local.h \
nouveau_exa.c nouveau_xv.c \
nv_accel_common.c \
View
201 src/nouveau_bo.c
@@ -1,201 +0,0 @@
-/*
- * Copyright 2007 Nouveau Project
- *
- * 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 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
- * THE AUTHORS 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.
- */
-
-#include <stdint.h>
-#include <errno.h>
-
-#include "nouveau_drmif.h"
-#include "nouveau_dma.h"
-#include "nouveau_local.h"
-
-static void
-nouveau_bo_del(struct nouveau_bo **userbo)
-{
- struct drm_nouveau_mem_free f;
- struct nouveau_bo_priv *bo;
-
- if (!userbo || !*userbo)
- return;
- bo = nouveau_bo(*userbo);
- *userbo = NULL;
-
- if (--bo->refcount)
- return;
-
- if (bo->fake) {
- free(bo);
- return;
- }
-
- if (bo->map) {
- drmUnmap(bo->map, bo->drm.size);
- bo->map = NULL;
- }
-
- f.flags = bo->drm.flags;
- f.offset = bo->drm.offset;
- drmCommandWrite(nouveau_device(bo->base.device)->fd,
- DRM_NOUVEAU_MEM_FREE, &f, sizeof(f));
-
- free(bo);
-}
-
-int
-nouveau_bo_ref(struct nouveau_bo *ref, struct nouveau_bo **pbo)
-{
- if (!pbo)
- return -EINVAL;
-
- if (ref)
- nouveau_bo(ref)->refcount++;
-
- if (*pbo)
- nouveau_bo_del(pbo);
-
- *pbo = ref;
- return 0;
-}
-
-int
-nouveau_bo_fake(struct nouveau_device *userdev, uint32_t flags, uint64_t offset,
- int size, void *map, struct nouveau_bo **userbo)
-{
- struct nouveau_bo_priv *bo;
-
- if (!userdev || !userbo || *userbo)
- return -EINVAL;
-
- bo = calloc(1, sizeof(*bo));
- if (!bo)
- return -ENOMEM;
-
- bo->refcount = 1;
- bo->fake = 1;
- bo->map = map;
- bo->base.offset = offset;
- bo->base.size = size;
- bo->base.device = userdev;
- *userbo = &bo->base;
- return 0;
-}
-
-int
-nouveau_bo_new(struct nouveau_device *userdev, uint32_t flags, int align,
- int size, struct nouveau_bo **userbo)
-{
- struct nouveau_device_priv *nv = nouveau_device(userdev);
- struct nouveau_bo_priv *bo;
- int ret;
-
- if (!nv || !userbo || *userbo)
- return -EINVAL;
-
- bo = calloc(1, sizeof(*bo));
- if (!bo)
- return -ENOMEM;
- bo->base.device = userdev;
-
- if (flags & NOUVEAU_BO_VRAM)
- bo->drm.flags |= NOUVEAU_MEM_FB;
- if (flags & NOUVEAU_BO_GART)
- bo->drm.flags |= (NOUVEAU_MEM_AGP | NOUVEAU_MEM_PCI);
- if (flags & NOUVEAU_BO_TILE)
- bo->drm.flags |= NOUVEAU_MEM_TILE;
- bo->drm.flags |= NOUVEAU_MEM_MAPPED;
-
- bo->drm.size = size;
- bo->drm.alignment = align;
-
- ret = drmCommandWriteRead(nv->fd, DRM_NOUVEAU_MEM_ALLOC, &bo->drm,
- sizeof(bo->drm));
- if (ret) {
- free(bo);
- return ret;
- }
-
- ret = drmMap(nv->fd, bo->drm.map_handle, bo->drm.size, &bo->map);
- if (ret) {
- bo->map = NULL;
- nouveau_bo_del((void *)&bo);
- return ret;
- }
-
- bo->base.size = bo->drm.size;
- bo->base.offset = bo->drm.offset;
- bo->base.handle = (unsigned long)bo;
- bo->base.map_handle = bo->drm.map_handle;
- bo->refcount = 1;
- *userbo = &bo->base;
- return 0;
-}
-
-int
-nouveau_bo_map(struct nouveau_bo *userbo, uint32_t flags)
-{
- struct nouveau_bo_priv *bo = nouveau_bo(userbo);
-
- if (!bo)
- return -EINVAL;
- userbo->map = bo->map;
- return 0;
-}
-
-void
-nouveau_bo_unmap(struct nouveau_bo *userbo)
-{
- userbo->map = NULL;
-}
-
-void
-nouveau_bo_emit_reloc(struct nouveau_channel *userchan, void *ptr,
- struct nouveau_bo *userbo, uint32_t data, uint32_t flags,
- uint32_t vor, uint32_t tor)
-{
- struct nouveau_channel_priv *chan = nouveau_channel(userchan);
- struct nouveau_bo_priv *bo = nouveau_bo(userbo);
- struct nouveau_bo_reloc *r;
-
- if (chan->num_relocs >= chan->max_relocs)
- FIRE_RING_CH(userchan);
- r = &chan->relocs[chan->num_relocs++];
-
- r->ptr = ptr;
- r->bo = bo;
- r->data = data;
- r->flags = flags;
- r->vor = vor;
- r->tor = tor;
-}
-
-void
-nouveau_bo_validate(struct nouveau_channel *userchan)
-{
- struct nouveau_channel_priv *chan = nouveau_channel(userchan);
- struct nouveau_bo_reloc *r = chan->relocs;
- int nr = chan->num_relocs;
-
- while (nr--) {
- assert(!r->bo->base.map);
- r++;
- }
-}
-
View
51 src/nouveau_bo.h
@@ -1,51 +0,0 @@
-/*
- * Copyright 2007 Nouveau Project
- *
- * 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 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
- * THE AUTHORS 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.
- */
-
-#ifndef __NOUVEAU_BO_H__
-#define __NOUVEAU_BO_H__
-
-/* Relocation/Buffer type flags */
-#define NOUVEAU_BO_VRAM (1 << 0)
-#define NOUVEAU_BO_GART (1 << 1)
-#define NOUVEAU_BO_RD (1 << 2)
-#define NOUVEAU_BO_WR (1 << 3)
-#define NOUVEAU_BO_RDWR (NOUVEAU_BO_RD | NOUVEAU_BO_WR)
-#define NOUVEAU_BO_MAP (1 << 4)
-#define NOUVEAU_BO_PIN (1 << 5)
-#define NOUVEAU_BO_LOW (1 << 6)
-#define NOUVEAU_BO_HIGH (1 << 7)
-#define NOUVEAU_BO_OR (1 << 8)
-#define NOUVEAU_BO_TILE (1 << 9)
-
-struct nouveau_bo {
- struct nouveau_device *device;
- uint64_t handle;
- drm_handle_t map_handle;
-
- uint64_t size;
- void *map;
-
- /*XXX: temporary! */
- uint64_t offset;
-};
-
-#endif
View
136 src/nouveau_channel.c
@@ -1,136 +0,0 @@
-/*
- * Copyright 2007 Nouveau Project
- *
- * 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 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
- * THE AUTHORS 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.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-#include "nouveau_drmif.h"
-#include "nouveau_dma.h"
-
-int
-nouveau_channel_alloc(struct nouveau_device *userdev, uint32_t fb_ctxdma,
- uint32_t tt_ctxdma, struct nouveau_channel **userchan)
-{
- struct nouveau_device_priv *nv = nouveau_device(userdev);
- struct nouveau_channel_priv *chan;
- int ret;
-
- if (!nv || !userchan || *userchan)
- return -EINVAL;
-
- chan = calloc(1, sizeof(*chan));
- if (!chan)
- return -ENOMEM;
- chan->base.device = userdev;
-
- chan->drm.fb_ctxdma_handle = fb_ctxdma;
- chan->drm.tt_ctxdma_handle = tt_ctxdma;
- ret = drmCommandWriteRead(nv->fd, DRM_NOUVEAU_CHANNEL_ALLOC,
- &chan->drm, sizeof(chan->drm));
- if (ret) {
- free(chan);
- return ret;
- }
-
- chan->base.id = chan->drm.channel;
- if (nouveau_grobj_ref(&chan->base, chan->drm.fb_ctxdma_handle,
- &chan->base.vram) ||
- nouveau_grobj_ref(&chan->base, chan->drm.tt_ctxdma_handle,
- &chan->base.gart)) {
- nouveau_channel_free((void *)&chan);
- }
-
- ret = drmMap(nv->fd, chan->drm.ctrl, chan->drm.ctrl_size,
- (void*)&chan->user);
- if (ret) {
- nouveau_channel_free((void *)&chan);
- return ret;
- }
- chan->put = &chan->user[0x40/4];
- chan->get = &chan->user[0x44/4];
- chan->ref_cnt = &chan->user[0x48/4];
-
- ret = drmMap(nv->fd, chan->drm.notifier, chan->drm.notifier_size,
- (drmAddressPtr)&chan->notifier_block);
- if (ret) {
- nouveau_channel_free((void *)&chan);
- return ret;
- }
-
- ret = drmMap(nv->fd, chan->drm.cmdbuf, chan->drm.cmdbuf_size,
- (void*)&chan->pushbuf);
- if (ret) {
- nouveau_channel_free((void *)&chan);
- return ret;
- }
-
- chan->max_relocs = chan->drm.cmdbuf_size / 4;
- chan->num_relocs = 0;
- chan->relocs =
- malloc(sizeof(struct nouveau_bo_reloc) * chan->max_relocs);
-
- nouveau_dma_channel_init(&chan->base);
-
- *userchan = &chan->base;
- return 0;
-}
-
-void
-nouveau_channel_free(struct nouveau_channel **userchan)
-{
- struct nouveau_channel_priv *chan;
-
- if (!userchan)
- return;
- chan = nouveau_channel(*userchan);
-
- if (chan) {
- struct nouveau_device_priv *nv;
- struct drm_nouveau_channel_free cf;
-
- nv = nouveau_device((*userchan)->device);
-
- FIRE_RING_CH(*userchan);
-
- if (chan->relocs)
- free(chan->relocs);
-
- if (chan->pushbuf)
- drmUnmap(chan->pushbuf, chan->drm.cmdbuf_size);
- if (chan->notifier_block)
- drmUnmap(chan->notifier_block, chan->drm.notifier_size);
- if (chan->user)
- drmUnmap((void *)chan->user, chan->drm.ctrl_size);
-
- nouveau_grobj_free(&chan->base.vram);
- nouveau_grobj_free(&chan->base.gart);
-
- cf.channel = chan->drm.channel;
- drmCommandWrite(nv->fd, DRM_NOUVEAU_CHANNEL_FREE,
- &cf, sizeof(cf));
- free(chan);
- *userchan = NULL;
- }
-}
-
-
View
38 src/nouveau_channel.h
@@ -1,38 +0,0 @@
-/*
- * Copyright 2007 Nouveau Project
- *
- * 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 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
- * THE AUTHORS 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.
- */
-
-#ifndef __NOUVEAU_CHANNEL_H__
-#define __NOUVEAU_CHANNEL_H__
-
-struct nouveau_channel {
- struct nouveau_device *device;
- int id;
-
- struct nouveau_grobj *vram;
- struct nouveau_grobj *gart;
-
- void *user_private;
- void (*hang_notify)(struct nouveau_channel *);
- void (*flush_notify)(struct nouveau_channel *);
-};
-
-#endif
View
6,231 src/nouveau_class.h
0 additions, 6,231 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
164 src/nouveau_device.c
@@ -1,164 +0,0 @@
-/*
- * Copyright 2007 Nouveau Project
- *
- * 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 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
- * THE AUTHORS 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.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#include "nouveau_drmif.h"
-
-int
-nouveau_device_open_existing(struct nouveau_device **userdev, int close,
- int fd, drm_context_t ctx)
-{
- struct nouveau_device_priv *nv;
- uint64_t chipset;
- int ret;
-
- if (!userdev || *userdev)
- return -EINVAL;
-
- nv = calloc(1, sizeof(*nv));
- if (!nv)
- return -ENOMEM;
- nv->fd = fd;
- nv->ctx = ctx;
- nv->needs_close = close;
-
- ret = drmCommandNone(nv->fd, DRM_NOUVEAU_CARD_INIT);
- if (ret) {
- free(nv);
- return ret;
- }
-
- ret = nouveau_device_get_param(&nv->base,
- NOUVEAU_GETPARAM_CHIPSET_ID, &chipset);
- if (ret) {
- free(nv);
- return ret;
- }
-
- switch (chipset & 0xf0) {
- case 0x00:
- case 0x10:
- case 0x20:
- case 0x30:
- case 0x40:
- case 0x60:
- nv->base.vm_vram_base = 0;
- break;
- default:
- nv->base.vm_vram_base = 0x20000000;
- break;
- }
-
- *userdev = &nv->base;
- return 0;
-}
-
-int
-nouveau_device_open(struct nouveau_device **userdev, const char *busid)
-{
- drm_context_t ctx;
- int fd, ret;
-
- if (!userdev || *userdev)
- return -EINVAL;
-
- fd = drmOpen("nouveau", busid);
- if (fd < 0)
- return -EINVAL;
-
- ret = drmCreateContext(fd, &ctx);
- if (ret) {
- drmClose(fd);
- return ret;
- }
-
- ret = nouveau_device_open_existing(userdev, 1, fd, ctx);
- if (ret) {
- drmDestroyContext(fd, ctx);
- drmClose(fd);
- return ret;
- }
-
- return 0;
-}
-
-void
-nouveau_device_close(struct nouveau_device **userdev)
-{
- struct nouveau_device_priv *nv;
-
- if (!userdev || !*userdev)
- return;
- nv = (struct nouveau_device_priv *)*userdev;
- *userdev = NULL;
-
- if (nv->needs_close) {
- if (nv->ctx)
- drmDestroyContext(nv->fd, nv->ctx);
- drmClose(nv->fd);
- }
- free(nv);
-}
-
-int
-nouveau_device_get_param(struct nouveau_device *userdev,
- uint64_t param, uint64_t *value)
-{
- struct nouveau_device_priv *nv = (struct nouveau_device_priv *)userdev;
- struct drm_nouveau_getparam g;
- int ret;
-
- if (!nv || !value)
- return -EINVAL;
-
- g.param = param;
- ret = drmCommandWriteRead(nv->fd, DRM_NOUVEAU_GETPARAM, &g, sizeof(g));
- if (ret)
- return ret;
-
- *value = g.value;
- return 0;
-}
-
-int
-nouveau_device_set_param(struct nouveau_device *userdev,
- uint64_t param, uint64_t value)
-{
- struct nouveau_device_priv *nv = (struct nouveau_device_priv *)userdev;
- struct drm_nouveau_setparam s;
- int ret;
-
- if (!nv)
- return -EINVAL;
-
- s.param = param;
- s.value = value;
- ret = drmCommandWriteRead(nv->fd, DRM_NOUVEAU_SETPARAM, &s, sizeof(s));
- if (ret)
- return ret;
-
- return 0;
-}
-
View
30 src/nouveau_device.h
@@ -1,30 +0,0 @@
-/*
- * Copyright 2007 Nouveau Project
- *
- * 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 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
- * THE AUTHORS 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.
- */
-
-#ifndef __NOUVEAU_DEVICE_H__
-#define __NOUVEAU_DEVICE_H__
-
-struct nouveau_device {
- uint64_t vm_vram_base;
-};
-
-#endif
View
200 src/nouveau_dma.c
@@ -1,200 +0,0 @@
-/*
- * Copyright 2007 Nouveau Project
- *
- * 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 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
- * THE AUTHORS 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.
- */
-
-#include <stdint.h>
-#include <assert.h>
-#include <errno.h>
-
-#include "nouveau_drmif.h"
-#include "nouveau_dma.h"
-#include "nouveau_local.h"
-
-#define READ_GET(ch) ((*(ch)->get - (ch)->dma.base) >> 2)
-#define WRITE_PUT(ch, val) do { \
- volatile int dum; \
- NOUVEAU_DMA_BARRIER; \
- dum=READ_GET(ch); \
- *(ch)->put = (((val) << 2) + (ch)->dma.base); \
- NOUVEAU_DMA_BARRIER; \
-} while(0)
-
-#ifdef NOUVEAU_DMA_DEBUG
-char faulty[1024];
-#endif
-
-void
-nouveau_dma_channel_init(struct nouveau_channel *userchan)
-{
- struct nouveau_channel_priv *chan = nouveau_channel(userchan);
- int i;
-
- chan->dma.base = chan->drm.put_base;
- chan->dma.cur = chan->dma.put = RING_SKIPS;
- chan->dma.max = (chan->drm.cmdbuf_size >> 2) - 2;
- chan->dma.free = chan->dma.max - chan->dma.cur;
-
- for (i = 0; i < RING_SKIPS; i++)
- chan->pushbuf[i] = 0x00000000;
-}
-/* Reduce the cost of a very short wait, we're still burning cpu though.
- * It also makes nouveau_dma_wait very visible during profiling.
- */
-#define CHECK_TIMEOUT() do { \
- if (counter == 0) { \
- t_start = NOUVEAU_TIME_MSEC(); \
- counter++; \
- } else if (counter < 0xFFFFFFF) { \
- counter++; \
- } else if ((NOUVEAU_TIME_MSEC() - t_start) > NOUVEAU_DMA_TIMEOUT) { \
- return - EBUSY; \
- } \
-} while(0)
-
-int
-nouveau_dma_wait(struct nouveau_channel *userchan, int size)
-{
- struct nouveau_channel_priv *chan = nouveau_channel(userchan);
- uint32_t get, counter = 0, t_start = 0;
-
- FIRE_RING_CH(userchan);
-
- while (chan->dma.free < size) {
- get = READ_GET(chan);
-
- if (chan->dma.put >= get) {
- chan->dma.free = chan->dma.max - chan->dma.cur;
-
- if (chan->dma.free < size) {
-#ifdef NOUVEAU_DMA_DEBUG
- chan->dma.push_free = 1;
-#endif
- OUT_RING_CH(userchan,
- 0x20000000 | chan->dma.base);
- if (get <= RING_SKIPS) {
- /*corner case - will be idle*/
- if (chan->dma.put <= RING_SKIPS)
- WRITE_PUT(chan, RING_SKIPS + 1);
-
- do {
- CHECK_TIMEOUT();
- get = READ_GET(chan);
- } while (get <= RING_SKIPS);
- }
-
- WRITE_PUT(chan, RING_SKIPS);
- chan->dma.cur = chan->dma.put = RING_SKIPS;
- chan->dma.free = get - (RING_SKIPS + 1);
- }
- } else {
- chan->dma.free = get - chan->dma.cur - 1;
- }
-
- CHECK_TIMEOUT();
- }
-
- return 0;
-}
-
-#ifdef NOUVEAU_DMA_SUBCHAN_LRU
-void
-nouveau_dma_subc_bind(struct nouveau_grobj *grobj)
-{
- struct nouveau_channel_priv *chan = nouveau_channel(grobj->channel);
- int subc = -1, i;
-
- for (i = 0; i < 8; i++) {
- if (chan->subchannel[i].grobj &&
- chan->subchannel[i].grobj->bound ==
- NOUVEAU_GROBJ_EXPLICIT_BIND)
- continue;
- /* Reading into the -1 index gives undefined results, so pick straight away. */
- if (subc == -1 || chan->subchannel[i].seq < chan->subchannel[subc].seq)
- subc = i;
- }
- assert(subc >= 0);
-
- if (chan->subchannel[subc].grobj)
- chan->subchannel[subc].grobj->bound = 0;
- chan->subchannel[subc].grobj = grobj;
- grobj->subc = subc;
- grobj->bound = NOUVEAU_GROBJ_BOUND;
-
- BEGIN_RING_CH(grobj->channel, grobj, 0, 1);
- nouveau_dma_out (grobj->channel, grobj->handle);
-}
-#endif
-
-void
-nouveau_dma_kickoff(struct nouveau_channel *userchan)
-{
- struct nouveau_channel_priv *chan = nouveau_channel(userchan);
- uint32_t put_offset;
- int i;
-
- if (chan->dma.cur == chan->dma.put)
- return;
-
- if (chan->num_relocs) {
- nouveau_bo_validate(userchan);
-
- for (i = 0; i < chan->num_relocs; i++) {
- struct nouveau_bo_reloc *r = &chan->relocs[i];
- uint32_t push;
-
- if (r->flags & NOUVEAU_BO_LOW) {
- push = r->bo->base.offset + r->data;
- } else
- if (r->flags & NOUVEAU_BO_HIGH) {
- push = (r->bo->base.offset + r->data) >> 32;
- } else {
- push = r->data;
- }
-
- if (r->flags & NOUVEAU_BO_OR) {
- if (r->flags & NOUVEAU_BO_VRAM)
- push |= r->vor;
- else
- push |= r->tor;
- }
-
- *r->ptr = push;
- }
-
- chan->num_relocs = 0;
- }
-
-#ifdef NOUVEAU_DMA_DEBUG
- if (chan->dma.push_free) {
- NOUVEAU_ERR("Packet incomplete: %d left\n", chan->dma.push_free);
- return;
- }
-#endif
-
- put_offset = (chan->dma.cur << 2) + chan->dma.base;
-#ifdef NOUVEAU_DMA_TRACE
- NOUVEAU_MSG("FIRE_RING %d/0x%08x\n", chan->drm.channel, put_offset);
-#endif
- chan->dma.put = chan->dma.cur;
- NOUVEAU_DMA_BARRIER;
- *chan->put = put_offset;
- NOUVEAU_DMA_BARRIER;
-}
View
171 src/nouveau_dma.h
@@ -1,171 +0,0 @@
-/*
- * Copyright 2007 Nouveau Project
- *
- * 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 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
- * THE AUTHORS 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.
- */
-
-#ifndef __NOUVEAU_DMA_H__
-#define __NOUVEAU_DMA_H__
-
-#include <string.h>
-#include "nouveau_drmif.h"
-#include "nouveau_local.h"
-
-#define RING_SKIPS 8
-
-NOUVEAU_PRIVATE int nouveau_dma_wait(struct nouveau_channel *chan, int size);
-NOUVEAU_PRIVATE void nouveau_dma_subc_bind(struct nouveau_grobj *);
-NOUVEAU_PRIVATE void nouveau_dma_channel_init(struct nouveau_channel *);
-NOUVEAU_PRIVATE void nouveau_dma_kickoff(struct nouveau_channel *);
-
-#ifdef NOUVEAU_DMA_DEBUG
-NOUVEAU_PRIVATE char faulty[1024];
-#endif
-
-static inline void
-nouveau_dma_out(struct nouveau_channel *userchan, uint32_t data)
-{
- struct nouveau_channel_priv *chan = nouveau_channel(userchan);
-
-#ifdef NOUVEAU_DMA_DEBUG
- if (chan->dma.push_free == 0) {
- NOUVEAU_ERR("No space left in packet. Error at %s\n",faulty);
- return;
- }
- chan->dma.push_free--;
-#endif
-#ifdef NOUVEAU_DMA_TRACE
- {
- uint32_t offset = (chan->dma.cur << 2) + chan->dma.base;
- NOUVEAU_MSG("\tOUT_RING %d/0x%08x -> 0x%08x\n",
- chan->drm.channel, offset, data);
- }
-#endif
- chan->pushbuf[chan->dma.cur++] = data;
-}
-
-static inline void
-nouveau_dma_outp(struct nouveau_channel *userchan, uint32_t *ptr, int size)
-{
- struct nouveau_channel_priv *chan = nouveau_channel(userchan);
- (void)chan;
-
-#ifdef NOUVEAU_DMA_DEBUG
- if (chan->dma.push_free < size) {
- NOUVEAU_ERR("Packet too small. Free=%d, Need=%d\n",
- chan->dma.push_free, size);
- return;
- }
-#endif
-#ifdef NOUVEAU_DMA_TRACE
- while (size--) {
- nouveau_dma_out(userchan, *ptr);
- ptr++;
- }
-#else
- memcpy(&chan->pushbuf[chan->dma.cur], ptr, size << 2);
-#ifdef NOUVEAU_DMA_DEBUG
- chan->dma.push_free -= size;
-#endif
- chan->dma.cur += size;
-#endif
-}
-
-static inline void
-nouveau_dma_begin(struct nouveau_channel *userchan, struct nouveau_grobj *grobj,
- int method, int size, const char* file, int line)
-{
- struct nouveau_channel_priv *chan = nouveau_channel(userchan);
- int push_size = size + 1;
-
-#ifdef NOUVEAU_DMA_SUBCHAN_LRU
- if (grobj->bound == NOUVEAU_GROBJ_UNBOUND)
- nouveau_dma_subc_bind(grobj);
- chan->subchannel[grobj->subc].seq = chan->subc_sequence++;
-#endif
-
-#ifdef NOUVEAU_DMA_TRACE
- NOUVEAU_MSG("BEGIN_RING %d/%08x/%d/0x%04x/%d\n", chan->drm.channel,
- grobj->handle, grobj->subc, method, size);
-#endif
-
-#ifdef NOUVEAU_DMA_DEBUG
- if (chan->dma.push_free) {
- NOUVEAU_ERR("Previous packet incomplete: %d left. Error at %s\n",
- chan->dma.push_free,faulty);
- return;
- }
- sprintf(faulty,"%s:%d",file,line);
-#endif
-
- if (chan->dma.free < push_size) {
- int wait_size = push_size < 2048 ? 2048 : push_size;
-
- if (nouveau_dma_wait(userchan, wait_size) &&
- userchan->hang_notify) {
- userchan->hang_notify(userchan);
- }
-
- if (chan->base.flush_notify)
- chan->base.flush_notify(&chan->base);
- }
- chan->dma.free -= push_size;
-#ifdef NOUVEAU_DMA_DEBUG
- chan->dma.push_free = push_size;
-#endif
-
- nouveau_dma_out(userchan, (size << 18) | (grobj->subc << 13) | method);
-}
-
-static inline void
-nouveau_dma_bind(struct nouveau_channel *userchan, struct nouveau_grobj *grobj,
- int subc)
-{
- struct nouveau_channel_priv *chan = nouveau_channel(userchan);
-
- if (chan->subchannel[subc].grobj == grobj)
- return;
-
- if (chan->subchannel[subc].grobj)
- chan->subchannel[subc].grobj->bound = NOUVEAU_GROBJ_UNBOUND;
- chan->subchannel[subc].grobj = grobj;
- grobj->subc = subc;
- grobj->bound = NOUVEAU_GROBJ_EXPLICIT_BIND;
-
- nouveau_dma_begin(userchan, grobj, 0x0000, 1, __FUNCTION__, __LINE__);
- nouveau_dma_out (userchan, grobj->handle);
-}
-
-#define BIND_RING_CH(ch,gr,sc) nouveau_dma_bind((ch), (gr), (sc))
-#define BEGIN_RING_CH(ch,gr,m,sz) nouveau_dma_begin((ch), (gr), (m), (sz), __FUNCTION__, __LINE__ )
-#define OUT_RING_CH(ch, data) nouveau_dma_out((ch), (data))
-#define OUT_RINGp_CH(ch,ptr,dwords) nouveau_dma_outp((ch), (void*)(ptr), \
- (dwords))
-#define FIRE_RING_CH(ch) nouveau_dma_kickoff((ch))
-#define WAIT_RING_CH(ch,sz) do { \
- if (nouveau_channel(ch)->dma.free < (sz)) { \
- unsigned pp = (sz) < 2048 ? 2048 : (sz); \
- nouveau_dma_wait((ch), pp); \
- if ((ch)->flush_notify) \
- (ch)->flush_notify((ch)); \
- } \
-} while(0)
-#define AVAIL_RING(ch) (((struct nouveau_channel_priv *)(ch))->dma.free)
-
-#endif
View
187 src/nouveau_drmif.h
@@ -1,187 +0,0 @@
-/*
- * Copyright 2007 Nouveau Project
- *
- * 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 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
- * THE AUTHORS 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.
- */
-
-#ifndef __NOUVEAU_DRMIF_H__
-#define __NOUVEAU_DRMIF_H__
-
-#include <stdint.h>
-#include <xf86drm.h>
-#include <nouveau_drm.h>
-
-#include "nouveau_device.h"
-#include "nouveau_channel.h"
-#include "nouveau_grobj.h"
-#include "nouveau_notifier.h"
-#include "nouveau_bo.h"
-#include "nouveau_local.h"
-
-struct nouveau_device_priv {
- struct nouveau_device base;
-
- int fd;
- drm_context_t ctx;
- drmLock *lock;
- int needs_close;
-};
-#define nouveau_device(n) ((struct nouveau_device_priv *)(n))
-
-NOUVEAU_PRIVATE int
-nouveau_device_open_existing(struct nouveau_device **, int close,
- int fd, drm_context_t ctx);
-
-NOUVEAU_PRIVATE int
-nouveau_device_open(struct nouveau_device **, const char *busid);
-
-NOUVEAU_PRIVATE void
-nouveau_device_close(struct nouveau_device **);
-
-NOUVEAU_PRIVATE int
-nouveau_device_get_param(struct nouveau_device *, uint64_t param, uint64_t *v);
-
-NOUVEAU_PRIVATE int
-nouveau_device_set_param(struct nouveau_device *, uint64_t param, uint64_t val);
-
-struct nouveau_channel_priv {
- struct nouveau_channel base;
-
- struct drm_nouveau_channel_alloc drm;
-
- struct {
- struct nouveau_grobj *grobj;
- uint32_t seq;
- } subchannel[8];
- uint32_t subc_sequence;
-
- uint32_t *pushbuf;
- void *notifier_block;
-
- volatile uint32_t *user;
- volatile uint32_t *put;
- volatile uint32_t *get;
- volatile uint32_t *ref_cnt;
-
- struct {
- uint32_t base, max;
- uint32_t cur, put;
- uint32_t free;
-
- int push_free;
- } dma;
-
- struct nouveau_bo_reloc *relocs;
- int num_relocs;
- int max_relocs;
-};
-#define nouveau_channel(n) ((struct nouveau_channel_priv *)(n))
-
-NOUVEAU_PRIVATE int
-nouveau_channel_alloc(struct nouveau_device *, uint32_t fb, uint32_t tt,
- struct nouveau_channel **);
-
-NOUVEAU_PRIVATE void
-nouveau_channel_free(struct nouveau_channel **);
-
-struct nouveau_grobj_priv {
- struct nouveau_grobj base;
-};
-#define nouveau_grobj(n) ((struct nouveau_grobj_priv *)(n))
-
-NOUVEAU_PRIVATE int nouveau_grobj_alloc(struct nouveau_channel *, uint32_t handle,
- int class, struct nouveau_grobj **);
-NOUVEAU_PRIVATE int nouveau_grobj_ref(struct nouveau_channel *, uint32_t handle,
- struct nouveau_grobj **);
-NOUVEAU_PRIVATE void nouveau_grobj_free(struct nouveau_grobj **);
-
-
-struct nouveau_notifier_priv {
- struct nouveau_notifier base;
-
- struct drm_nouveau_notifierobj_alloc drm;
- volatile void *map;
-};
-#define nouveau_notifier(n) ((struct nouveau_notifier_priv *)(n))
-
-NOUVEAU_PRIVATE int
-nouveau_notifier_alloc(struct nouveau_channel *, uint32_t handle, int count,
- struct nouveau_notifier **);
-
-NOUVEAU_PRIVATE void
-nouveau_notifier_free(struct nouveau_notifier **);
-
-NOUVEAU_PRIVATE void
-nouveau_notifier_reset(struct nouveau_notifier *, int id);
-
-NOUVEAU_PRIVATE uint32_t
-nouveau_notifier_status(struct nouveau_notifier *, int id);
-
-NOUVEAU_PRIVATE uint32_t
-nouveau_notifier_return_val(struct nouveau_notifier *, int id);
-
-NOUVEAU_PRIVATE int
-nouveau_notifier_wait_status(struct nouveau_notifier *, int id, int status,
- int timeout);
-
-struct nouveau_bo_priv {
- struct nouveau_bo base;
-
- struct drm_nouveau_mem_alloc drm;
- void *map;
-
- int refcount;
- int fake;
-};
-
-struct nouveau_bo_reloc {
- struct nouveau_bo_priv *bo;
- uint32_t *ptr;
- uint32_t flags;
- uint32_t data, vor, tor;
-};
-
-#define nouveau_bo(n) ((struct nouveau_bo_priv *)(n))
-
-NOUVEAU_PRIVATE int
-nouveau_bo_new(struct nouveau_device *, uint32_t flags, int align, int size,
- struct nouveau_bo **);
-
-NOUVEAU_PRIVATE int
-nouveau_bo_fake(struct nouveau_device *, uint32_t flags, uint64_t offset,
- int size, void *map, struct nouveau_bo **);
-
-NOUVEAU_PRIVATE int
-nouveau_bo_ref(struct nouveau_bo *, struct nouveau_bo **);
-
-NOUVEAU_PRIVATE int
-nouveau_bo_map(struct nouveau_bo *, uint32_t flags);
-
-NOUVEAU_PRIVATE void
-nouveau_bo_unmap(struct nouveau_bo *);
-
-NOUVEAU_PRIVATE void
-nouveau_bo_emit_reloc(struct nouveau_channel *chan, void *ptr,
- struct nouveau_bo *, uint32_t data, uint32_t flags,
- uint32_t vor, uint32_t tor);
-
-NOUVEAU_PRIVATE void
-nouveau_bo_validate(struct nouveau_channel *);
-
-#endif
View
17 src/nouveau_exa.c
@@ -124,7 +124,7 @@ NVAccelDownloadM2MF(PixmapPtr pspix, int x, int y, int w, int h,
BEGIN_RING(chan, m2mf, 0x100, 1);
OUT_RING (chan, 0);
FIRE_RING (chan);
- if (nouveau_notifier_wait_status(pNv->notify0, 0, 0, 2000))
+ if (nouveau_notifier_wait_status(pNv->notify0, 0, 0, 2.0))
return FALSE;
nouveau_bo_map(pNv->GART, NOUVEAU_BO_RD);
@@ -251,7 +251,7 @@ NVAccelUploadM2MF(PixmapPtr pdpix, int x, int y, int w, int h,
BEGIN_RING(chan, m2mf, 0x100, 1);
OUT_RING (chan, 0);
FIRE_RING (chan);
- if (nouveau_notifier_wait_status(pNv->notify0, 0, 0, 2000))
+ if (nouveau_notifier_wait_status(pNv->notify0, 0, 0, 2.0))
return FALSE;
if (linear)
@@ -426,16 +426,9 @@ nouveau_exa_init(ScreenPtr pScreen)
exa->memorySize = pNv->FB->size;
if (pNv->Architecture >= NV_ARCH_50) {
- struct nouveau_device_priv *nvdev = nouveau_device(pNv->dev);
- struct nouveau_bo_priv *nvbo = nouveau_bo(pNv->FB);
- struct drm_nouveau_mem_tile t;
-
- t.offset = nvbo->drm.offset;
- t.flags = nvbo->drm.flags | NOUVEAU_MEM_TILE;
- t.delta = exa->offScreenBase;
- t.size = exa->memorySize -
- exa->offScreenBase;
- drmCommandWrite(nvdev->fd, DRM_NOUVEAU_MEM_TILE, &t, sizeof(t));
+ nouveau_bo_tile(pNv->FB, NOUVEAU_BO_VRAM | NOUVEAU_BO_TILED,
+ exa->offScreenBase,
+ exa->memorySize - exa->offScreenBase);
exa->maxX = 8192;
exa->maxY = 8192;
View
107 src/nouveau_grobj.c
@@ -1,107 +0,0 @@
-/*
- * Copyright 2007 Nouveau Project
- *
- * 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 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
- * THE AUTHORS 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.
- */
-
-#include <stdlib.h>
-#include <errno.h>
-
-#include "nouveau_drmif.h"
-
-int
-nouveau_grobj_alloc(struct nouveau_channel *userchan, uint32_t handle,
- int class, struct nouveau_grobj **usergrobj)
-{
- struct nouveau_device_priv *nv = nouveau_device(userchan->device);
- struct nouveau_grobj_priv *gr;
- struct drm_nouveau_grobj_alloc g;
- int ret;
-
- if (!nv || !usergrobj || *usergrobj)
- return -EINVAL;
-
- gr = calloc(1, sizeof(*gr));
- if (!gr)
- return -ENOMEM;
- gr->base.channel = userchan;
- gr->base.handle = handle;
- gr->base.grclass = class;
-
- g.channel = userchan->id;
- g.handle = handle;
- g.class = class;
- ret = drmCommandWrite(nv->fd, DRM_NOUVEAU_GROBJ_ALLOC, &g, sizeof(g));
- if (ret) {
- nouveau_grobj_free((void *)&gr);
- return ret;
- }
-
- *usergrobj = &gr->base;
- return 0;
-}
-
-int
-nouveau_grobj_ref(struct nouveau_channel *userchan, uint32_t handle,
- struct nouveau_grobj **usergr)
-{
- struct nouveau_grobj_priv *gr;
-
- if (!userchan || !usergr || *usergr)
- return -EINVAL;
-
- gr = calloc(1, sizeof(*gr));
- if (!gr)
- return -ENOMEM;
- gr->base.channel = userchan;
- gr->base.handle = handle;
- gr->base.grclass = 0;
-
- *usergr = &gr->base;
- return 0;
-}
-
-void
-nouveau_grobj_free(struct nouveau_grobj **usergrobj)
-{
- struct nouveau_grobj_priv *gr;
-
- if (!usergrobj)
- return;
- gr = nouveau_grobj(*usergrobj);
- *usergrobj = NULL;
-
- if (gr) {
- struct nouveau_channel_priv *chan;
- struct nouveau_device_priv *nv;
- struct drm_nouveau_gpuobj_free f;
-
- chan = nouveau_channel(gr->base.channel);
- nv = nouveau_device(chan->base.device);
-
- if (gr->base.grclass) {
- f.channel = chan->drm.channel;
- f.handle = gr->base.handle;
- drmCommandWrite(nv->fd, DRM_NOUVEAU_GPUOBJ_FREE,
- &f, sizeof(f));
- }
- free(gr);
- }
-}
-
View
41 src/nouveau_grobj.h
@@ -1,41 +0,0 @@
-/*
- * Copyright 2007 Nouveau Project
- *
- * 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 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
- * THE AUTHORS 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.
- */
-
-#ifndef __NOUVEAU_GROBJ_H__
-#define __NOUVEAU_GROBJ_H__
-
-#include "nouveau_channel.h"
-
-struct nouveau_grobj {
- struct nouveau_channel *channel;
- int grclass;
- uint32_t handle;
-
- enum {
- NOUVEAU_GROBJ_UNBOUND = 0,
- NOUVEAU_GROBJ_BOUND = 1,
- NOUVEAU_GROBJ_EXPLICIT_BIND = 2,
- } bound;
- int subc;
-};
-
-#endif
View
70 src/nouveau_local.h
@@ -26,9 +26,6 @@
#include "compiler.h"
#include "xf86_OSproc.h"
-#define NOUVEAU_PRIVATE _X_HIDDEN
-#define NOUVEAU_PUBLIC _X_EXPORT
-
/* Debug output */
#define NOUVEAU_MSG(fmt,args...) ErrorF(fmt, ##args)
#define NOUVEAU_ERR(fmt,args...) \
@@ -44,74 +41,9 @@
} while(0)
#endif
-#define NOUVEAU_TIME_MSEC() GetTimeInMillis()
-
#define NOUVEAU_ALIGN(x,bytes) (((x) + ((bytes) - 1)) & ~((bytes) - 1))
-/* User FIFO control */
-//#define NOUVEAU_DMA_TRACE
-//#define NOUVEAU_DMA_DEBUG
-#define NOUVEAU_DMA_SUBCHAN_LRU
-#define NOUVEAU_DMA_BARRIER mem_barrier();
-#define NOUVEAU_DMA_TIMEOUT 2000
-
-/* Push buffer access macros */
-#define BEGIN_RING(chan,obj,mthd,size) do { \
- BEGIN_RING_CH((chan), (obj), (mthd), (size)); \
-} while(0)
-
-#define OUT_RING(chan,data) do { \
- OUT_RING_CH((chan), (data)); \
-} while(0)
-
-#define OUT_RINGp(chan,src,size) do { \
- OUT_RINGp_CH((chan), (src), (size)); \
-} while(0)
-
-#define OUT_RINGf(chan,data) do { \
- union { float v; uint32_t u; } c; \
- c.v = (data); \
- OUT_RING((chan), c.u); \
-} while(0)
-
-#define WAIT_RING(chan,size) do { \
- WAIT_RING_CH((chan), (size)); \
-} while(0)
-
-#define FIRE_RING(chan) do { \
- FIRE_RING_CH((chan)); \
-} while(0)
-
-#define OUT_RELOC(chan,bo,data,flags,vor,tor) do { \
- struct nouveau_channel_priv *nvchan = nouveau_channel(chan); \
- nouveau_bo_emit_reloc((chan), &nvchan->pushbuf[nvchan->dma.cur], \
- (bo), (data), (flags), (vor), (tor)); \
- OUT_RING((chan), 0); \
-} while(0)
-
-/* Raw data + flags depending on FB/TT buffer */
-#define OUT_RELOCd(chan,bo,data,flags,vor,tor) do { \
- OUT_RELOC((chan), (bo), (data), (flags) | NOUVEAU_BO_OR, (vor), (tor));\
-} while(0)
-
-/* FB/TT object handle */
-#define OUT_RELOCo(chan,bo,flags) do { \
- OUT_RELOC((chan), (bo), 0, (flags) | NOUVEAU_BO_OR, \
- (chan)->vram->handle, (chan)->gart->handle); \
-} while(0)
-
-/* Low 32-bits of offset */
-#define OUT_RELOCl(chan,bo,delta,flags) do { \
- OUT_RELOC((chan), (bo), (delta), (flags) | NOUVEAU_BO_LOW, 0, 0); \
-} while(0)
-
-/* High 32-bits of offset */
-#define OUT_RELOCh(chan,bo,delta,flags) do { \
- OUT_RELOC((chan), (bo), (delta), (flags) | NOUVEAU_BO_HIGH, 0, 0); \
-} while(0)
-
-
-/* Alternate versions of OUT_RELOCx above, takes pixmaps instead of BOs */
+/* Alternate versions of OUT_RELOCx, takes pixmaps instead of BOs */
#define OUT_PIXMAPd(chan,pm,data,flags,vor,tor) do { \
OUT_RELOCd((chan), pNv->FB, (data), (flags), (vor), (tor)); \
} while(0)
View
140 src/nouveau_notifier.c
@@ -1,140 +0,0 @@
-/*
- * Copyright 2007 Nouveau Project
- *
- * 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 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
- * THE AUTHORS 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.
- */
-
-#include <stdlib.h>
-#include <errno.h>
-
-#include "nouveau_drmif.h"
-#include "nouveau_local.h"
-
-#define NOTIFIER(__v) \
- struct nouveau_notifier_priv *notifier = nouveau_notifier(user); \
- volatile uint32_t *n = (void*)notifier->map + (id * 32)
-
-int
-nouveau_notifier_alloc(struct nouveau_channel *userchan, uint32_t handle,
- int count, struct nouveau_notifier **usernotifier)
-{
- struct nouveau_notifier_priv *notifier;
- int ret;
-
- if (!userchan || !usernotifier || *usernotifier)
- return -EINVAL;
-
- notifier = calloc(1, sizeof(*notifier));
- if (!notifier)
- return -ENOMEM;
- notifier->base.channel = userchan;
- notifier->base.handle = handle;
-
- notifier->drm.channel = userchan->id;
- notifier->drm.handle = handle;
- notifier->drm.count = count;
- if ((ret = drmCommandWriteRead(nouveau_device(userchan->device)->fd,
- DRM_NOUVEAU_NOTIFIEROBJ_ALLOC,
- &notifier->drm,
- sizeof(notifier->drm)))) {
- nouveau_notifier_free((void *)&notifier);
- return ret;
- }
-
- notifier->map = (void *)nouveau_channel(userchan)->notifier_block +
- notifier->drm.offset;
- *usernotifier = &notifier->base;
- return 0;
-}
-
-void
-nouveau_notifier_free(struct nouveau_notifier **usernotifier)
-{
-
- struct nouveau_notifier_priv *notifier;
-
- if (!usernotifier)
- return;
- notifier = nouveau_notifier(*usernotifier);
- *usernotifier = NULL;
-
- if (notifier) {
- struct nouveau_channel_priv *chan;
- struct nouveau_device_priv *nv;
- struct drm_nouveau_gpuobj_free f;
-
- chan = nouveau_channel(notifier->base.channel);
- nv = nouveau_device(chan->base.device);
-
- f.channel = chan->drm.channel;
- f.handle = notifier->base.handle;
- drmCommandWrite(nv->fd, DRM_NOUVEAU_GPUOBJ_FREE, &f, sizeof(f));
- free(notifier);
- }
-}
-
-void
-nouveau_notifier_reset(struct nouveau_notifier *user, int id)
-{
- NOTIFIER(n);
-
- n[NV_NOTIFY_TIME_0 /4] = 0x00000000;
- n[NV_NOTIFY_TIME_1 /4] = 0x00000000;
- n[NV_NOTIFY_RETURN_VALUE/4] = 0x00000000;
- n[NV_NOTIFY_STATE /4] = (NV_NOTIFY_STATE_STATUS_IN_PROCESS <<
- NV_NOTIFY_STATE_STATUS_SHIFT);
-}
-
-uint32_t
-nouveau_notifier_status(struct nouveau_notifier *user, int id)
-{
- NOTIFIER(n);
-
- return n[NV_NOTIFY_STATE/4] >> NV_NOTIFY_STATE_STATUS_SHIFT;
-}
-
-uint32_t
-nouveau_notifier_return_val(struct nouveau_notifier *user, int id)
-{
- NOTIFIER(n);
-
- return n[NV_NOTIFY_RETURN_VALUE/4];
-}
-
-int
-nouveau_notifier_wait_status(struct nouveau_notifier *user, int id,
- int status, int timeout)
-{
- NOTIFIER(n);
- uint32_t time = 0, t_start = NOUVEAU_TIME_MSEC();
-
- while (time <= timeout) {
- uint32_t v;
-
- v = n[NV_NOTIFY_STATE/4] >> NV_NOTIFY_STATE_STATUS_SHIFT;
- if (v == status)
- return 0;
-
- if (timeout)
- time = NOUVEAU_TIME_MSEC() - t_start;
- }
-
- return -EBUSY;
-}
-
View
43 src/nouveau_notifier.h
@@ -1,43 +0,0 @@
-/*
- * Copyright 2007 Nouveau Project
- *
- * 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 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
- * THE AUTHORS 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.
- */
-
-#ifndef __NOUVEAU_NOTIFIER_H__
-#define __NOUVEAU_NOTIFIER_H__
-
-#define NV_NOTIFIER_SIZE 32
-#define NV_NOTIFY_TIME_0 0x00000000
-#define NV_NOTIFY_TIME_1 0x00000004
-#define NV_NOTIFY_RETURN_VALUE 0x00000008
-#define NV_NOTIFY_STATE 0x0000000C
-#define NV_NOTIFY_STATE_STATUS_MASK 0xFF000000
-#define NV_NOTIFY_STATE_STATUS_SHIFT 24
-#define NV_NOTIFY_STATE_STATUS_COMPLETED 0x00
-#define NV_NOTIFY_STATE_STATUS_IN_PROCESS 0x01
-#define NV_NOTIFY_STATE_ERROR_CODE_MASK 0x0000FFFF
-#define NV_NOTIFY_STATE_ERROR_CODE_SHIFT 0
-
-struct nouveau_notifier {
- struct nouveau_channel *channel;
- uint32_t handle;
-};
-
-#endif
View
6 src/nouveau_xv.c
@@ -349,7 +349,7 @@ nouveau_xv_bo_realloc(ScrnInfoPtr pScrn, unsigned flags, unsigned size,
}
if (pNv->Architecture >= NV_ARCH_50 && (flags & NOUVEAU_BO_VRAM))
- flags |= NOUVEAU_BO_TILE;
+ flags |= NOUVEAU_BO_TILED;
ret = nouveau_bo_new(pNv->dev, flags | NOUVEAU_BO_PIN, 0, size, pbo);
if (ret)
@@ -371,10 +371,10 @@ NVFreePortMemory(ScrnInfoPtr pScrn, NVPortPrivPtr pPriv)
nouveau_bo_ref(NULL, &pPriv->video_mem);
if (pPriv->TT_mem_chunk[0] && pPriv->DMANotifier[0])
- nouveau_notifier_wait_status(pPriv->DMANotifier[0], 0, 0, 1000);
+ nouveau_notifier_wait_status(pPriv->DMANotifier[0], 0, 0, 1.0);
if (pPriv->TT_mem_chunk[1] && pPriv->DMANotifier[1])
- nouveau_notifier_wait_status(pPriv->DMANotifier[1], 0, 0, 1000);
+ nouveau_notifier_wait_status(pPriv->DMANotifier[1], 0, 0, 1.0);
nouveau_bo_ref(NULL, &pPriv->TT_mem_chunk[0]);
nouveau_bo_ref(NULL, &pPriv->TT_mem_chunk[1]);
View
4 src/nv10_exa.c
@@ -923,7 +923,7 @@ NVAccelInitNV10TCL(ScrnInfoPtr pScrn)
celcius = pNv->Nv3D;
BEGIN_RING(chan, celcius, NV10TCL_DMA_NOTIFY, 1);
- OUT_RING (chan, pNv->NvNull->handle);
+ OUT_RING (chan, chan->nullobj->handle);
BEGIN_RING(chan, celcius, NV10TCL_DMA_IN_MEMORY0, 2);
OUT_RING (chan, pNv->chan->vram->handle);
@@ -1064,7 +1064,7 @@ NVAccelInitNV10TCL(ScrnInfoPtr pScrn)
OUT_RING (chan, 0);
BEGIN_RING(chan, celcius, NV10TCL_CULL_FACE_ENABLE, 1);
OUT_RING (chan, 0);
- BEGIN_RING(chan, celcius, NV10TCL_CLIP_PLANE_ENABLE(0), 8);
+ BEGIN_RING(chan, celcius, NV10TCL_TX_GEN_S(0), 8);
for (i=0;i<8;i++) {
OUT_RING (chan, 0);
}
View
2 src/nv30_exa.c
@@ -310,7 +310,7 @@ NV30EXATexture(ScrnInfoPtr pScrn, PixmapPtr pPix, PicturePtr pPict, int unit)
OUT_RING (chan, NV34TCL_TX_FORMAT_DIMS_2D |
(fmt->card_fmt << NV34TCL_TX_FORMAT_FORMAT_SHIFT) |
- (1 << NV34TCL_TX_FORMAT_MIPMAP_LEVELS_SHIFT) |
+ (1 << 16) |
(log2i(pPix->drawable.width) << NV34TCL_TX_FORMAT_BASE_SIZE_U_SHIFT) |
(log2i(pPix->drawable.height) << NV34TCL_TX_FORMAT_BASE_SIZE_V_SHIFT) |
8 |
View
4 src/nv30_xv_tex.c
@@ -158,7 +158,7 @@ NV30VideoTexture(ScrnInfoPtr pScrn, struct nouveau_bo *src, int offset,
OUT_RELOCl(chan, src, offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
if (unit==0) {
OUT_RELOCd(chan, pNv->FB, NV34TCL_TX_FORMAT_DIMS_1D | card_fmt |
- (1 << NV34TCL_TX_FORMAT_MIPMAP_LEVELS_SHIFT) |
+ (1 << 16) |
(log2i(width) <<
NV34TCL_TX_FORMAT_BASE_SIZE_U_SHIFT) |
(log2i(height) <<
@@ -171,7 +171,7 @@ NV30VideoTexture(ScrnInfoPtr pScrn, struct nouveau_bo *src, int offset,
NV34TCL_TX_WRAP_R_CLAMP_TO_EDGE);
} else {
OUT_RELOCd(chan, pNv->FB, NV34TCL_TX_FORMAT_DIMS_2D | card_fmt |
- (1 << NV34TCL_TX_FORMAT_MIPMAP_LEVELS_SHIFT) |
+ (1 << 16) |
(log2i(width) <<
NV34TCL_TX_FORMAT_BASE_SIZE_U_SHIFT) |
(log2i(height) <<
View
2 src/nv50_accel.c
@@ -61,7 +61,7 @@ NVAccelInitNV50TCL(ScrnInfoPtr pScrn)
BEGIN_RING(chan, tesla, 0x1558, 1);
OUT_RING (chan, 1);
BEGIN_RING(chan, tesla, NV50TCL_DMA_NOTIFY, 1);
- OUT_RING (chan, pNv->NvNull->handle);
+ OUT_RING (chan, chan->nullobj->handle);
BEGIN_RING(chan, tesla, NV50TCL_DMA_UNK0(0), NV50TCL_DMA_UNK0__SIZE);
for (i = 0; i < NV50TCL_DMA_UNK0__SIZE; i++)
OUT_RING (chan, pNv->chan->vram->handle);
View
44 src/nv_accel_common.c
@@ -23,20 +23,6 @@
#include "nv_include.h"
static Bool
-NVAccelInitNullObject(ScrnInfoPtr pScrn)
-{
- NVPtr pNv = NVPTR(pScrn);
-
- if (!pNv->NvNull) {
- if (nouveau_grobj_alloc(pNv->chan, NvNullObject, NV01_NULL,
- &pNv->NvNull))
- return FALSE;
- }
-
- return TRUE;
-}
-
-static Bool
NVAccelInitDmaNotifier0(ScrnInfoPtr pScrn)
{
NVPtr pNv = NVPTR(pScrn);
@@ -70,7 +56,7 @@ NVAccelInitContextSurfaces(ScrnInfoPtr pScrn)
surf2d = pNv->NvContextSurfaces;
BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_DMA_NOTIFY, 1);
- OUT_RING (chan, pNv->NvNull->handle);
+ OUT_RING (chan, chan->nullobj->handle);
BEGIN_RING(chan, surf2d,
NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2);
OUT_RING (chan, pNv->chan->vram->handle);
@@ -192,7 +178,7 @@ NVAccelInitImagePattern(ScrnInfoPtr pScrn)
patt = pNv->NvImagePattern;
BEGIN_RING(chan, patt, NV04_IMAGE_PATTERN_DMA_NOTIFY, 1);
- OUT_RING (chan, pNv->NvNull->handle);
+ OUT_RING (chan, chan->nullobj->handle);
BEGIN_RING(chan, patt, NV04_IMAGE_PATTERN_MONOCHROME_FORMAT, 3);
#if X_BYTE_ORDER == X_BIG_ENDIAN
OUT_RING (chan, NV04_IMAGE_PATTERN_MONOCHROME_FORMAT_LE);
@@ -220,7 +206,7 @@ NVAccelInitRasterOp(ScrnInfoPtr pScrn)
rop = pNv->NvRop;
BEGIN_RING(chan, rop, NV03_CONTEXT_ROP_DMA_NOTIFY, 1);
- OUT_RING (chan, pNv->NvNull->handle);
+ OUT_RING (chan, chan->nullobj->handle);
pNv->currentRop = ~0;
return TRUE;
@@ -244,7 +230,7 @@ NVAccelInitRectangle(ScrnInfoPtr pScrn)
BEGIN_RING(chan, rect, NV04_GDI_RECTANGLE_TEXT_DMA_NOTIFY, 1);
OUT_RING (chan, pNv->notify0->handle);
BEGIN_RING(chan, rect, NV04_GDI_RECTANGLE_TEXT_DMA_FONTS, 1);
- OUT_RING (chan, pNv->NvNull->handle);
+ OUT_RING (chan, chan->nullobj->handle);
BEGIN_RING(chan, rect, NV04_GDI_RECTANGLE_TEXT_SURFACE, 1);
OUT_RING (chan, pNv->NvContextSurfaces->handle);
BEGIN_RING(chan, rect, NV04_GDI_RECTANGLE_TEXT_ROP, 1);
@@ -284,11 +270,11 @@ NVAccelInitImageBlit(ScrnInfoPtr pScrn)
BEGIN_RING(chan, blit, NV04_IMAGE_BLIT_DMA_NOTIFY, 1);
OUT_RING (chan, pNv->notify0->handle);
BEGIN_RING(chan, blit, NV04_IMAGE_BLIT_COLOR_KEY, 1);
- OUT_RING (chan, pNv->NvNull->handle);
+ OUT_RING (chan, chan->nullobj->handle);
BEGIN_RING(chan, blit, NV04_IMAGE_BLIT_SURFACE, 1);
OUT_RING (chan, pNv->NvContextSurfaces->handle);
BEGIN_RING(chan, blit, NV04_IMAGE_BLIT_CLIP_RECTANGLE, 3);
- OUT_RING (chan, pNv->NvNull->handle);
+ OUT_RING (chan, chan->nullobj->handle);
OUT_RING (chan, pNv->NvImagePattern->handle);
OUT_RING (chan, pNv->NvRop->handle);
BEGIN_RING(chan, blit, NV04_IMAGE_BLIT_OPERATION, 1);
@@ -338,8 +324,8 @@ NVAccelInitScaledImage(ScrnInfoPtr pScrn)
NV04_SCALED_IMAGE_FROM_MEMORY_DMA_NOTIFY, 7);
OUT_RING (chan, pNv->notify0->handle);
OUT_RING (chan, pNv->chan->vram->handle);
- OUT_RING (chan, pNv->NvNull->handle);
- OUT_RING (chan, pNv->NvNull->handle);
+ OUT_RING (chan, chan->nullobj->handle);
+ OUT_RING (chan, chan->nullobj->handle);
OUT_RING (chan, pNv->NvContextBeta1->handle);
OUT_RING (chan, pNv->NvContextBeta4->handle);
OUT_RING (chan, pNv->NvContextSurfaces->handle);
@@ -370,7 +356,7 @@ NVAccelInitClipRectangle(ScrnInfoPtr pScrn)
clip = pNv->NvClipRectangle;
BEGIN_RING(chan, clip, NV01_CONTEXT_CLIP_RECTANGLE_DMA_NOTIFY, 1);
- OUT_RING (chan, pNv->NvNull->handle);
+ OUT_RING (chan, chan->nullobj->handle);
return TRUE;
}
@@ -436,16 +422,16 @@ NVAccelInitImageFromCpu(ScrnInfoPtr pScrn)
BEGIN_RING(chan, ifc, NV01_IMAGE_FROM_CPU_DMA_NOTIFY, 1);
OUT_RING (chan, pNv->notify0->handle);
BEGIN_RING(chan, ifc, NV01_IMAGE_FROM_CPU_CLIP_RECTANGLE, 1);
- OUT_RING (chan, pNv->NvNull->handle);
+ OUT_RING (chan, chan->nullobj->handle);
BEGIN_RING(chan, ifc, NV01_IMAGE_FROM_CPU_PATTERN, 1);
- OUT_RING (chan, pNv->NvNull->handle);
+ OUT_RING (chan, chan->nullobj->handle);
BEGIN_RING(chan, ifc, NV01_IMAGE_FROM_CPU_ROP, 1);
- OUT_RING (chan, pNv->NvNull->handle);
+ OUT_RING (chan, chan->nullobj->handle);
if (pNv->Architecture >= NV_ARCH_10) {
BEGIN_RING(chan, ifc, NV01_IMAGE_FROM_CPU_BETA1, 1);
- OUT_RING (chan, pNv->NvNull->handle);
+ OUT_RING (chan, chan->nullobj->handle);
BEGIN_RING(chan, ifc, NV05_IMAGE_FROM_CPU_BETA4, 1);
- OUT_RING (chan, pNv->NvNull->handle);
+ OUT_RING (chan, chan->nullobj->handle);
}
BEGIN_RING(chan, ifc, NV05_IMAGE_FROM_CPU_SURFACE, 1);
OUT_RING (chan, pNv->NvContextSurfaces->handle);
@@ -509,7 +495,6 @@ NVAccelCommonInit(ScrnInfoPtr pScrn)
return TRUE;
/* General engine objects */
- INIT_CONTEXT_OBJECT(NullObject);
INIT_CONTEXT_OBJECT(DmaNotifier0);
/* 2D engine */
@@ -558,7 +543,6 @@ void NVAccelFree(ScrnInfoPtr pScrn)
if (pNv->NoAccel)
return;
- nouveau_grobj_free(&pNv->NvNull);
nouveau_notifier_free(&pNv->notify0);
if (pNv->Architecture < NV_ARCH_50) {
nouveau_grobj_free(&pNv->NvContextSurfaces);
View
38 src/nv_dma.c
@@ -25,44 +25,24 @@
#include "nv_include.h"
#include "nvreg.h"
-static void NVDumpLockupInfo(NVPtr pNv)
-{
- struct nouveau_channel_priv *chan = nouveau_channel(pNv->chan);
- int i, start;
-
- start = ((*chan->get - chan->dma.base) >> 2) - 20;
- if (start < 0)
- start = 0;
-
- xf86DrvMsg(0, X_INFO, "Fifo dump (lockup 0x%04x,0x%04x):\n",
- (*chan->get - chan->dma.base) >> 2, chan->dma.put);
- for(i = start; i < chan->dma.put + 10; i++)
- xf86DrvMsg(0, X_INFO, "[0x%04x] 0x%08x\n", i, chan->pushbuf[i]);
- xf86DrvMsg(0, X_INFO, "End of fifo dump\n");
-}
-
static void
NVLockedUp(ScrnInfoPtr pScrn)
{
NVPtr pNv = NVPTR(pScrn);
- struct nouveau_channel_priv *chan = nouveau_channel(pNv->chan);
/* avoid re-entering FatalError on shutdown */
if (pNv->LockedUp)
return;
pNv->LockedUp = TRUE;
- NVDumpLockupInfo(pNv);
-
- FatalError("DMA queue hang: dmaPut=%x, current=%x, status=%x\n",
- chan->dma.put, (*chan->get - chan->dma.base) >> 2,
- pNv->PGRAPH[NV_PGRAPH_STATUS/4]);
+ FatalError("Detected GPU lockup\n");
}
static void
NVChannelHangNotify(struct nouveau_channel *chan)
{
ScrnInfoPtr pScrn = chan->user_private;
+
NVLockedUp(pScrn);
}
@@ -70,22 +50,11 @@ void NVSync(ScrnInfoPtr pScrn)
{
NVPtr pNv = NVPTR(pScrn);
struct nouveau_channel *chan = pNv->chan;
- struct nouveau_channel_priv *nvchan = nouveau_channel(chan);
struct nouveau_grobj *gr = pNv->Nv2D ? pNv->Nv2D : pNv->NvImageBlit;
- int t_start, timeout = 2000;
if (pNv->NoAccel)
return;
- /* Wait for entire FIFO to be processed */
- t_start = GetTimeInMillis();
- while((GetTimeInMillis() - t_start) < timeout &&
- (((*nvchan->get - nvchan->dma.base) >> 2)!= nvchan->dma.put));
- if ((GetTimeInMillis() - t_start) >= timeout) {
- NVLockedUp(pScrn);
- return;
- }
-
/* Wait for nvchannel to go completely idle */
nouveau_notifier_reset(pNv->notify0, 0);
BEGIN_RING(chan, gr, 0x104, 1);
@@ -94,8 +63,7 @@ void NVSync(ScrnInfoPtr pScrn)
OUT_RING (chan, 0);
FIRE_RING (chan);
if (nouveau_notifier_wait_status(pNv->notify0, 0,
- NV_NOTIFY_STATE_STATUS_COMPLETED,
- timeout))
+ NV_NOTIFY_STATE_STATUS_COMPLETED, 2.0))
NVLockedUp(pScrn);
}
View
14 src/nv_driver.c
@@ -667,16 +667,10 @@ NVEnterVT(int scrnIndex, int flags)
NVMapMem(pScrn);
if (pNv->Architecture >= NV_ARCH_50 && pNv->EXADriverPtr) {
- struct nouveau_device_priv *nvdev = nouveau_device(pNv->dev);
- struct nouveau_bo_priv *nvbo = nouveau_bo(pNv->FB);
- struct drm_nouveau_mem_tile t;
-
- t.offset = nvbo->drm.offset;
- t.flags = nvbo->drm.flags | NOUVEAU_MEM_TILE;
- t.delta = pNv->EXADriverPtr->offScreenBase;
- t.size = pNv->EXADriverPtr->memorySize -
- pNv->EXADriverPtr->offScreenBase;
- drmCommandWrite(nvdev->fd, DRM_NOUVEAU_MEM_TILE, &t, sizeof(t));
+ nouveau_bo_tile(pNv->FB, NOUVEAU_BO_VRAM | NOUVEAU_BO_TILED,
+ pNv->EXADriverPtr->offScreenBase,
+ pNv->EXADriverPtr->memorySize -
+ pNv->EXADriverPtr->offScreenBase);
}
if (!pNv->kms_enable && pNv->randr12_enable)
View
9 src/nv_include.h
@@ -77,8 +77,13 @@
#include "drmmode_display.h"
-#include "nouveau_device.h"
#include "nouveau_drmif.h"
-#include "nouveau_dma.h"
+#include "nouveau_device.h"
+#include "nouveau_channel.h"
+#include "nouveau_pushbuf.h"
+#include "nouveau_bo.h"
+#include "nouveau_grobj.h"
+#include "nouveau_notifier.h"
+#include "nouveau_local.h"
#endif /* __NV_INCLUDE_H__ */
View
1 src/nv_type.h
@@ -362,7 +362,6 @@ typedef struct _NVRec {
/* GPU context */
struct nouveau_channel *chan;
struct nouveau_notifier *notify0;
- struct nouveau_grobj *NvNull;
struct nouveau_grobj *NvContextSurfaces;
struct nouveau_grobj *NvContextBeta1;
struct nouveau_grobj *NvContextBeta4;

0 comments on commit e02813a

Please sign in to comment.
Something went wrong with that request. Please try again.