diff options
author | Ben Skeggs <skeggsb@gmail.com> | 2007-06-24 17:21:27 +1000 |
---|---|---|
committer | Ben Skeggs <skeggsb@gmail.com> | 2007-06-24 17:23:13 +1000 |
commit | c39089b3d686eecef11db2b5a2d606ba1ca2dc0c (patch) | |
tree | 63e35fb2907f62ede4e43efb84d606276262fbb3 | |
parent | 45dccb99a541a0e1e7be7b4e5aab12c3d8d9f30d (diff) | |
download | xorg-driver-xf86-video-nouveau-c39089b3d686eecef11db2b5a2d606ba1ca2dc0c.tar.gz |
Match drm 0.0.7 interface changes
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/nv_accel_common.c | 46 | ||||
-rw-r--r-- | src/nv_dma.c | 180 | ||||
-rw-r--r-- | src/nv_dma.h | 2 | ||||
-rw-r--r-- | src/nv_dri.c | 2 | ||||
-rw-r--r-- | src/nv_driver.c | 23 | ||||
-rw-r--r-- | src/nv_exa.c | 13 | ||||
-rw-r--r-- | src/nv_mem.c | 4 | ||||
-rw-r--r-- | src/nv_notifier.c | 126 | ||||
-rw-r--r-- | src/nv_proto.h | 16 | ||||
-rw-r--r-- | src/nv_type.h | 4 |
11 files changed, 209 insertions, 208 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index bc9e745..783a284 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,6 +46,7 @@ nouveau_drv_la_SOURCES = \ nv_dripriv.h \ nv_local.h \ nv_mem.c \ + nv_notifier.c \ nv_proto.h \ nvreg.h \ nv_setup.c \ diff --git a/src/nv_accel_common.c b/src/nv_accel_common.c index b1ba672..f04d507 100644 --- a/src/nv_accel_common.c +++ b/src/nv_accel_common.c @@ -16,24 +16,6 @@ NVAccelInitNullObject(ScrnInfoPtr pScrn) return TRUE; } -static Bool -NVAccelInitDmaFB(ScrnInfoPtr pScrn) -{ - NVPtr pNv = NVPTR(pScrn); - static int have_object = FALSE; - - if (!have_object) { - if (!NVDmaCreateDMAObject(pNv, NvDmaFB, NV_DMA_IN_MEMORY, - NOUVEAU_MEM_FB, 0, - pNv->VRAMSize, - NOUVEAU_MEM_ACCESS_RW)) - return FALSE; - have_object = TRUE; - } - - return TRUE; -} - uint32_t NVAccelGetPixmapOffset(NVPtr pNv, PixmapPtr pPix) { @@ -51,37 +33,13 @@ NVAccelGetPixmapOffset(NVPtr pNv, PixmapPtr pPix) } static Bool -NVAccelInitDmaAGP(ScrnInfoPtr pScrn) -{ - NVPtr pNv = NVPTR(pScrn); - static int have_object = FALSE; - - if (!pNv->AGPSize) - return TRUE; - - if (!have_object) { - if (!NVDmaCreateDMAObject(pNv, NvDmaAGP, NV_DMA_IN_MEMORY, - NOUVEAU_MEM_AGP, 0, - pNv->AGPSize, - NOUVEAU_MEM_ACCESS_RW)) { - ErrorF("Couldn't create AGP object, disabling AGP\n"); - NVFreeMemory(pNv, pNv->AGPScratch); - pNv->AGPScratch = NULL; - } - have_object = TRUE; - } - - return TRUE; -} - -static Bool NVAccelInitDmaNotifier0(ScrnInfoPtr pScrn) { NVPtr pNv = NVPTR(pScrn); static int have_object = FALSE; if (!have_object) { - pNv->Notifier0 = NVDmaCreateNotifier(pNv, NvDmaNotifier0); + pNv->Notifier0 = NVNotifierAlloc(pScrn, NvDmaNotifier0); if (!pNv->Notifier0) return FALSE; have_object = TRUE; @@ -450,8 +408,6 @@ NVAccelCommonInit(ScrnInfoPtr pScrn) if(pNv->NoAccel) return TRUE; INIT_CONTEXT_OBJECT(NullObject); - INIT_CONTEXT_OBJECT(DmaFB); - INIT_CONTEXT_OBJECT(DmaAGP); INIT_CONTEXT_OBJECT(DmaNotifier0); INIT_CONTEXT_OBJECT(ContextSurfaces); diff --git a/src/nv_dma.c b/src/nv_dma.c index cc5bdd6..a9d0127 100644 --- a/src/nv_dma.c +++ b/src/nv_dma.c @@ -191,137 +191,15 @@ void NVResetGraphics(ScrnInfoPtr pScrn) /*NVDmaKickoff(pNv);*/ } -Bool NVDmaCreateDMAObject(NVPtr pNv, uint32_t handle, int class, - int target, - CARD32 offset, CARD32 size, int access) -{ - drm_nouveau_dma_object_init_t dma; - int ret; - - dma.channel = pNv->fifo.channel; - dma.handle = handle; - dma.class = class; - dma.access = access; - dma.target = target; - dma.size = size; - dma.offset = offset; - ret = drmCommandWrite(pNv->drm_fd, DRM_NOUVEAU_DMA_OBJECT_INIT, - &dma, sizeof(dma)); - - return ret == 0; -} - -Bool NVDmaCreateDMAObjectFromMem(NVPtr pNv, uint32_t handle, int class, - NVAllocRec *mem, int access) -{ - int target; - - target = mem->type & (NOUVEAU_MEM_FB | NOUVEAU_MEM_AGP); - if (!target) - return FALSE; - - return NVDmaCreateDMAObject(pNv, handle, class, target, - mem->offset, mem->size, access); -} - -/* -A DMA notifier is a DMA object that references a small (32 byte it -seems, we use 256 for saftey) memory area that will be used by the HW to give feedback -about a DMA operation. -*/ -NVAllocRec *NVDmaCreateNotifier(NVPtr pNv, int handle) -{ - NVAllocRec *notifier = NULL; - -#ifndef __powerpc__ - notifier = NVAllocateMemory(pNv, NOUVEAU_MEM_AGP | - NOUVEAU_MEM_FB_ACCEPTABLE, - 256); -#else - notifier = NVAllocateMemory(pNv, NOUVEAU_MEM_FB, 256); -#endif - - if (!notifier) - return NULL; - - if (!NVDmaCreateDMAObjectFromMem(pNv, handle, NV_DMA_IN_MEMORY, - notifier, - NOUVEAU_MEM_ACCESS_RW)) { - NVFreeMemory(pNv, notifier); - return NULL; - } - - return notifier; -} - -/* How do we wait for DMA completion (by notifiers) ? - * - * Either repeatedly read the notifier address and wait until it changes, - * or enable a 'wakeup' interrupt by writing NOTIFY_WRITE_LE_AWAKEN into - * the 'notify' field of the object in the channel. My guess is that - * this causes an interrupt in PGRAPH/NOTIFY as soon as the transfer is - * completed. Clients probably can use poll on the nv* devices to get this - * event. All this is a guess. I don't know any details, and I have not - * tested is. Also, I have no idea how the 'nvdriver' reacts if it gets - * notify events that are not registered. - * - * Writing NV_NOTIFY_WRITE_LE_AWAKEN into the 'Notify' field of an object - * in a channel really causes an interrupt in the PGRAPH engine. Thus - * we can determine whether a DMA transfer has finished in the interrupt - * handler. - * - * We can't use interrupts in user land, so we do the simple polling approach. - * The method returns FALSE in case of an error. - */ -Bool NVDmaWaitForNotifier(NVPtr pNv, void *notifier) -{ - int t_start, timeout = 0; - volatile CARD32 *n; - - n = (volatile CARD32 *)notifier; - NVDEBUG("NVDmaWaitForNotifier @%p", n); - t_start = GetTimeInMillis(); - while (1) { - CARD32 a = n[0]; - CARD32 b = n[1]; - CARD32 c = n[2]; - CARD32 status = n[3]; - NVDEBUG("status: n[0]=%x, n[1]=%x, n[2]=%x, n[3]=%x\n", a, b, c, status); - NVDEBUG("status: GET: 0x%08x\n", READ_GET(pNv)); - - if (GetTimeInMillis() - t_start >= 2000) { - /* We've timed out, call NVSync() to detect lockups */ - if (timeout++ == 0) { - NVDoSync(pNv); - /* If we're still here, wait another second for notifier.. */ - t_start = GetTimeInMillis() + 1000; - break; - } - /* Still haven't recieved notification, log error */ - ErrorF("Notifier timeout\n"); - return FALSE; - } - - if (status == 0xffffffff) - continue; - if (!status) - break; - if (status & 0xffff) - return FALSE; - } - - return TRUE; -} - Bool NVDmaCreateContextObject(NVPtr pNv, int handle, int class) { - drm_nouveau_object_init_t cto; + drm_nouveau_grobj_alloc_t cto; int ret; cto.channel = pNv->fifo.channel; cto.handle = handle; cto.class = class; - ret = drmCommandWrite(pNv->drm_fd, DRM_NOUVEAU_OBJECT_INIT, + ret = drmCommandWrite(pNv->drm_fd, DRM_NOUVEAU_GROBJ_ALLOC, &cto, sizeof(cto)); return ret == 0; } @@ -360,32 +238,60 @@ static void NVInitDmaCB(ScrnInfoPtr pScrn) Bool NVInitDma(ScrnInfoPtr pScrn) { NVPtr pNv = NVPTR(pScrn); - int i; + int i, ret; NVInitDmaCB(pScrn); - if(pNv->NoAccel) return TRUE; + if (pNv->NoAccel) + return TRUE; + + pNv->fifo.fb_ctxdma_handle = NvDmaFB; + pNv->fifo.tt_ctxdma_handle = NvDmaTT; + ret = drmCommandWriteRead(pNv->drm_fd, DRM_NOUVEAU_FIFO_ALLOC, + &pNv->fifo, sizeof(pNv->fifo)); + if (ret) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Could not allocate GPU channel: %d\n", ret); + return FALSE; + } - if (drmCommandWriteRead(pNv->drm_fd, DRM_NOUVEAU_FIFO_ALLOC, &pNv->fifo, sizeof(pNv->fifo)) != 0) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Could not initialise kernel module\n"); + ret = drmMap(pNv->drm_fd, pNv->fifo.cmdbuf, pNv->fifo.cmdbuf_size, + (drmAddressPtr)&pNv->dmaBase); + if (ret) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to map DMA push buffer: %d\n", ret); return FALSE; } - if (drmMap(pNv->drm_fd, pNv->fifo.cmdbuf, pNv->fifo.cmdbuf_size, (drmAddressPtr)&pNv->dmaBase)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to map DMA command buffer\n"); + ret = drmMap(pNv->drm_fd, pNv->fifo.ctrl, pNv->fifo.ctrl_size, + (drmAddressPtr)&pNv->FIFO); + if (ret) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to map FIFO control regs: %d\n", ret); return FALSE; } - if (drmMap(pNv->drm_fd, pNv->fifo.ctrl, pNv->fifo.ctrl_size, (drmAddressPtr)&pNv->FIFO)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to map FIFO control regs\n"); + ret = drmMap(pNv->drm_fd, pNv->fifo.notifier, pNv->fifo.notifier_size, + (drmAddressPtr)&pNv->NotifierBlock); + if (ret) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to map notifier block: %d\n", ret); return FALSE; } - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using FIFO channel %d\n", pNv->fifo.channel); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, " Control registers : %p (0x%08x)\n", pNv->FIFO, pNv->fifo.ctrl); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, " DMA command buffer: %p (0x%08x)\n", pNv->dmaBase, pNv->fifo.cmdbuf); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, " DMA cmdbuf length : %d KiB\n", pNv->fifo.cmdbuf_size / 1024); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, " DMA base PUT : 0x%08x\n", pNv->fifo.put_base); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using FIFO channel %d\n", pNv->fifo.channel); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + " Control registers : %p (0x%08x)\n", + pNv->FIFO, pNv->fifo.ctrl); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + " DMA command buffer: %p (0x%08x)\n", + pNv->dmaBase, pNv->fifo.cmdbuf); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + " DMA cmdbuf length : %d KiB\n", + pNv->fifo.cmdbuf_size / 1024); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + " DMA base PUT : 0x%08x\n", pNv->fifo.put_base); pNv->dmaPut = pNv->dmaCurrent = READ_GET(pNv); pNv->dmaMax = (pNv->fifo.cmdbuf_size >> 2) - 1; diff --git a/src/nv_dma.h b/src/nv_dma.h index 3d43fcd..29695e2 100644 --- a/src/nv_dma.h +++ b/src/nv_dma.h @@ -67,7 +67,7 @@ enum DMAObjects { NvMemFormat = 0x80000018, Nv3D = 0x80000019, NvDmaFB = 0xD8000001, - NvDmaAGP = 0xD8000002, + NvDmaTT = 0xD8000002, NvDmaNotifier0 = 0xD8000003 }; diff --git a/src/nv_dri.c b/src/nv_dri.c index b6c38b0..857fb42 100644 --- a/src/nv_dri.c +++ b/src/nv_dri.c @@ -244,7 +244,7 @@ Bool NVDRIGetVersion(ScrnInfoPtr pScrn) } /* temporary lock step versioning */ -#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 6 +#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 7 #error nouveau_drm.h doesn't match expected patchlevel, update libdrm. #endif if (pNv->pKernelDRMVersion->version_patchlevel != diff --git a/src/nv_driver.c b/src/nv_driver.c index 61c89e3..f437bee 100644 --- a/src/nv_driver.c +++ b/src/nv_driver.c @@ -1718,9 +1718,8 @@ NVMapMem(ScrnInfoPtr pScrn) return FALSE; } xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Allocated %lldMiB VRAM for framebuffer + offscreen pixmaps\n", - pNv->FB->size >> 20 - ); + "Allocated %dMiB VRAM for framebuffer + offscreen pixmaps\n", + (unsigned int)(pNv->FB->size >> 20)); /*XXX: have to get these after we've allocated something, otherwise * they're uninitialised in the DRM! @@ -1733,8 +1732,9 @@ NVMapMem(ScrnInfoPtr pScrn) if (pNv->AGPSize) { int gart_scratch_size; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "AGP: %dMiB available\n", - (unsigned int)pNv->AGPSize >> 20); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "GART: %dMiB available\n", + (unsigned int)(pNv->AGPSize >> 20)); if (pNv->AGPSize > (16*1024*1024)) gart_scratch_size = 16*1024*1024; @@ -1743,14 +1743,15 @@ NVMapMem(ScrnInfoPtr pScrn) pNv->AGPScratch = NVAllocateMemory(pNv, NOUVEAU_MEM_AGP, gart_scratch_size); - if (!pNv->AGPScratch) + if (!pNv->AGPScratch) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Unable to allocate AGP memory\n"); - else + "Unable to allocate GART memory\n"); + } else { xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "AGP: mapped %dMiB at %p\n", - (unsigned int)pNv->AGPScratch->size>>20, - pNv->AGPScratch->map); + "GART: mapped %dMiB at %p\n", + (unsigned int)(pNv->AGPScratch->size >> 20), + pNv->AGPScratch->map); + } } pNv->Cursor = NVAllocateMemory(pNv, NOUVEAU_MEM_FB, 64*1024); diff --git a/src/nv_exa.c b/src/nv_exa.c index ae5a14a..c01a4c6 100644 --- a/src/nv_exa.c +++ b/src/nv_exa.c @@ -53,8 +53,8 @@ static void setM2MFDirection(NVPtr pNv, int dir) { if (pNv->M2MFDirection != dir) { NVDmaStart(pNv, NvSubMemFormat, MEMFORMAT_DMA_OBJECT_IN, 2); - NVDmaNext (pNv, dir ? NvDmaAGP : NvDmaFB); - NVDmaNext (pNv, dir ? NvDmaFB : NvDmaAGP); + NVDmaNext (pNv, dir ? NvDmaTT : NvDmaFB); + NVDmaNext (pNv, dir ? NvDmaFB : NvDmaTT); pNv->M2MFDirection = dir; } } @@ -285,7 +285,7 @@ static Bool NVDownloadFromScreen(PixmapPtr pSrc, NVDEBUG(" max_lines=%d, h=%d\n", max_lines, h); /* reset the notification object */ - memset(pNv->Notifier0->map, 0xff, pNv->Notifier0->size); + NVNotifierReset(pScrn, pNv->Notifier0); NVDmaStart(pNv, NvSubMemFormat, MEMFORMAT_NOTIFY, 1); NVDmaNext (pNv, 0); @@ -300,7 +300,7 @@ static Bool NVDownloadFromScreen(PixmapPtr pSrc, NVDmaNext (pNv, 0); NVDmaKickoff(pNv); - if (!NVDmaWaitForNotifier(pNv, pNv->Notifier0->map)) { + if (!NVNotifierWaitStatus(pScrn, pNv->Notifier0, 0, 2000)) { ret = FALSE; goto error; } @@ -347,7 +347,8 @@ static Bool NVUploadToScreen(PixmapPtr pDst, int nlines = h > max_lines ? max_lines : h; /* reset the notification object */ - memset(pNv->Notifier0->map, 0xff, pNv->Notifier0->size); + NVNotifierReset(pScrn, pNv->Notifier0); + memcpy(pNv->AGPScratch->map, src, nlines*src_pitch); NVDmaStart(pNv, NvSubMemFormat, MEMFORMAT_NOTIFY, 1); NVDmaNext (pNv, 0); @@ -363,7 +364,7 @@ static Bool NVUploadToScreen(PixmapPtr pDst, NVDmaNext (pNv, 0); NVDmaKickoff(pNv); - if (!NVDmaWaitForNotifier(pNv, pNv->Notifier0->map)) { + if (!NVNotifierWaitStatus(pScrn, pNv->Notifier0, 0, 2000)) { ret = FALSE; goto error; } diff --git a/src/nv_mem.c b/src/nv_mem.c index 0ecd71a..99cb8bc 100644 --- a/src/nv_mem.c +++ b/src/nv_mem.c @@ -54,6 +54,10 @@ void NVFreeMemory(NVPtr pNv, NVAllocRec *mem) memfree.flags = mem->type; memfree.region_offset = mem->offset; + if (mem->type & NOUVEAU_MEM_FB) + memfree.region_offset += pNv->VRAMPhysical; + else if (mem->type & NOUVEAU_MEM_AGP) + memfree.region_offset += pNv->AGPPhysical; if (drmCommandWriteRead(pNv->drm_fd, DRM_NOUVEAU_MEM_FREE, &memfree, sizeof(memfree))) { diff --git a/src/nv_notifier.c b/src/nv_notifier.c new file mode 100644 index 0000000..88f0edb --- /dev/null +++ b/src/nv_notifier.c @@ -0,0 +1,126 @@ +#include "nv_include.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 + +#define NOTIFIER(__v) \ + NVPtr pNv = NVPTR(pScrn); \ + volatile uint32_t *__v = (void*)pNv->NotifierBlock + notifier->offset + +drm_nouveau_notifier_alloc_t * +NVNotifierAlloc(ScrnInfoPtr pScrn, uint32_t handle) +{ + NVPtr pNv = NVPTR(pScrn); + drm_nouveau_notifier_alloc_t *notifier; + int ret; + + notifier = xcalloc(1, sizeof(*notifier)); + if (!notifier) { + NVNotifierDestroy(pScrn, notifier); + return NULL; + } + + notifier->channel = pNv->fifo.channel; + notifier->handle = handle; + notifier->count = 1; + ret = drmCommandWriteRead(pNv->drm_fd, DRM_NOUVEAU_NOTIFIER_ALLOC, + notifier, sizeof(*notifier)); + if (ret) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to create notifier 0x%08x: %d\n", + handle, ret); + NVNotifierDestroy(pScrn, notifier); + return NULL; + } + + return notifier; +} + +void +NVNotifierDestroy(ScrnInfoPtr pScrn, drm_nouveau_notifier_alloc_t *notifier) +{ + if (notifier) { + /*XXX: destroy notifier object */ + xfree(notifier); + } +} + +void +NVNotifierReset(ScrnInfoPtr pScrn, drm_nouveau_notifier_alloc_t *notifier) +{ + NOTIFIER(n); + + n[NV_NOTIFY_TIME_0 /4] = + n[NV_NOTIFY_TIME_1 /4] = + n[NV_NOTIFY_RETURN_VALUE/4] = 0; + n[NV_NOTIFY_STATE /4] = (NV_NOTIFY_STATE_STATUS_IN_PROCESS << + NV_NOTIFY_STATE_STATUS_SHIFT); +} + +uint32_t +NVNotifierStatus(ScrnInfoPtr pScrn, drm_nouveau_notifier_alloc_t *notifier) +{ + NOTIFIER(n); + + return n[NV_NOTIFY_STATE/4] >> NV_NOTIFY_STATE_STATUS_SHIFT; +} + +uint32_t +NVNotifierErrorCode(ScrnInfoPtr pScrn, drm_nouveau_notifier_alloc_t *notifier) +{ + NOTIFIER(n); + + return n[NV_NOTIFY_STATE/4] & NV_NOTIFY_STATE_ERROR_CODE_MASK; +} + +uint32_t +NVNotifierReturnVal(ScrnInfoPtr pScrn, drm_nouveau_notifier_alloc_t *notifier) +{ + NOTIFIER(n); + + return n[NV_NOTIFY_RETURN_VALUE/4]; +} + +Bool +NVNotifierWaitStatus(ScrnInfoPtr pScrn, drm_nouveau_notifier_alloc_t *notifier, + unsigned int status, unsigned int timeout) +{ + NOTIFIER(n); + unsigned int t_start, time = 0; + + t_start = GetTimeInMillis(); + while (time <= timeout) { +#if 0 + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "N(0x%08x)/%d = 0x%08x/0x%08x/0x%08x/0x%08x\n", + notifier->handle, time, n[0], n[1], n[2], n[3]); +#endif + if (n[NV_NOTIFY_STATE/4] & NV_NOTIFY_STATE_ERROR_CODE_MASK) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Notifier returned error: 0x%04x\n", + NVNotifierErrorCode(pScrn, notifier)); + return FALSE; + } + + if ((n[NV_NOTIFY_STATE/4] >> NV_NOTIFY_STATE_STATUS_SHIFT) + == status) + return TRUE; + + if (timeout) + time = GetTimeInMillis() - t_start; + } + + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Notifier (0x%08x) timeout!\n", notifier->handle); + return FALSE; +} + diff --git a/src/nv_proto.h b/src/nv_proto.h index d40a1cf..a5da5f3 100644 --- a/src/nv_proto.h +++ b/src/nv_proto.h @@ -19,6 +19,16 @@ Bool NVI2CInit(ScrnInfoPtr pScrn); NVAllocRec *NVAllocateMemory(NVPtr pNv, int type, int size); void NVFreeMemory(NVPtr pNv, NVAllocRec *mem); +/* in nv_notifier.c */ +drm_nouveau_notifier_alloc_t *NVNotifierAlloc(ScrnInfoPtr, uint32_t handle); +void NVNotifierDestroy(ScrnInfoPtr, drm_nouveau_notifier_alloc_t *); +void NVNotifierReset(ScrnInfoPtr, drm_nouveau_notifier_alloc_t *); +uint32_t NVNotifierStatus(ScrnInfoPtr, drm_nouveau_notifier_alloc_t *); +uint32_t NVNotifierErrorCode(ScrnInfoPtr, drm_nouveau_notifier_alloc_t *); +uint32_t NVNotifierReturnVal(ScrnInfoPtr, drm_nouveau_notifier_alloc_t *); +Bool NVNotifierWaitStatus(ScrnInfoPtr, drm_nouveau_notifier_alloc_t *, + uint32_t status, uint32_t timeout); + /* in nv_dri.c */ unsigned int NVDRMGetParam(NVPtr pNv, unsigned int param); Bool NVDRMSetParam(NVPtr pNv, unsigned int param, unsigned int value); @@ -56,12 +66,6 @@ void NVDmaWait(NVPtr pNv, int size); void NVDoSync(NVPtr pNv); void NVSync(ScrnInfoPtr pScrn); void NVResetGraphics(ScrnInfoPtr pScrn); -Bool NVDmaCreateDMAObject(NVPtr pNv, uint32_t handle, int class, int target, - CARD32 base_address, CARD32 size, int access); -Bool NVDmaCreateDMAObjectFromMem(NVPtr pNv, uint32_t handle, int class, - NVAllocRec *mem, int access); -NVAllocRec *NVDmaCreateNotifier(NVPtr pNv, int handle); -Bool NVDmaWaitForNotifier(NVPtr pNv, void *notifier); Bool NVDmaCreateContextObject(NVPtr pNv, int handle, int class); Bool NVInitDma(ScrnInfoPtr pScrn); diff --git a/src/nv_type.h b/src/nv_type.h index ec54053..c56c9f5 100644 --- a/src/nv_type.h +++ b/src/nv_type.h @@ -233,7 +233,9 @@ typedef struct _NVRec { int IRQ; Bool LockedUp; - NVAllocRec * Notifier0; + volatile void * NotifierBlock; + drm_nouveau_notifier_alloc_t *Notifier0; + drm_nouveau_fifo_alloc_t fifo; CARD32 dmaPut; CARD32 dmaCurrent; |