summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Skeggs <skeggsb@gmail.com>2007-07-12 11:28:58 +1000
committerBen Skeggs <skeggsb@gmail.com>2007-07-12 11:28:58 +1000
commitc91dfdf329f946c8cc581f079359092629cf73dc (patch)
tree26f2abbee7a2ab96ab4f68d79ed168b78d0643f1
parente6a16710033d189aa5d6b2e3b4a75f2dd9d05a5d (diff)
parent4cbd3a1d9dfe6d51648de36ce7ae3d02c920374e (diff)
Merge branch 'randr-1.2' into nv50-branchnv50-branch
Conflicts: src/nv_driver.c
-rw-r--r--src/nv_dma.c8
-rw-r--r--src/nv_dri.c2
-rw-r--r--src/nv_driver.c51
-rw-r--r--src/nv_exa.c21
-rw-r--r--src/nv_mem.c20
-rw-r--r--src/nv_proto.h1
-rw-r--r--src/nv_type.h6
7 files changed, 59 insertions, 50 deletions
diff --git a/src/nv_dma.c b/src/nv_dma.c
index ca5e122..2b37a31 100644
--- a/src/nv_dma.c
+++ b/src/nv_dma.c
@@ -160,7 +160,7 @@ void NVResetGraphics(ScrnInfoPtr pScrn)
NVDmaSetObjectOnSubchannel(pNv, NvSubImagePattern, NvImagePattern );
NVDmaSetObjectOnSubchannel(pNv, NvSubImageBlit , NvImageBlit );
if (pNv->useEXA) {
- if (pNv->AGPScratch)
+ if (pNv->GARTScratch)
NVDmaSetObjectOnSubchannel(pNv, NvSubMemFormat, NvMemFormat);
} else if (!pNv->useEXA) {
NVDmaSetObjectOnSubchannel(pNv, NvSubClipRectangle, NvClipRectangle);
@@ -237,8 +237,8 @@ static void NVInitDmaCB(ScrnInfoPtr pScrn)
* on defaults if anything's wrong (ie. out of AGP, invalid sizes)
*/
#ifndef __powerpc__
- if (pNv->AGPScratch)
- cb_location = NOUVEAU_MEM_AGP;
+ if (pNv->GARTScratch)
+ cb_location = NOUVEAU_MEM_AGP | NOUVEAU_MEM_PCI_ACCEPTABLE;
else
#endif
cb_location = NOUVEAU_MEM_FB;
@@ -247,6 +247,8 @@ static void NVInitDmaCB(ScrnInfoPtr pScrn)
cb_location = NOUVEAU_MEM_AGP;
else if (!xf86NameCmp(s, "VRAM"))
cb_location = NOUVEAU_MEM_FB;
+ else if (!xf86NameCmp(s, "PCI"))
+ cb_location = NOUVEAU_MEM_PCI;
else
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Invalid value \"%s\" for CBLocation\n", s);
}
diff --git a/src/nv_dri.c b/src/nv_dri.c
index a489e68..772f5fc 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 != 7
+#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 9
#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 183f2f1..5b9a9ca 100644
--- a/src/nv_driver.c
+++ b/src/nv_driver.c
@@ -1814,18 +1814,19 @@ NVMapMem(ScrnInfoPtr pScrn)
/*XXX: have to get these after we've allocated something, otherwise
* they're uninitialised in the DRM!
*/
- pNv->VRAMSize = NVDRMGetParam(pNv, NOUVEAU_GETPARAM_FB_SIZE);
- pNv->VRAMPhysical =
- NVDRMGetParam(pNv, NOUVEAU_GETPARAM_FB_PHYSICAL);
- pNv->AGPSize = NVDRMGetParam(pNv, NOUVEAU_GETPARAM_AGP_SIZE);
- pNv->AGPPhysical =
- NVDRMGetParam(pNv, NOUVEAU_GETPARAM_AGP_PHYSICAL);
+ pNv->VRAMSize = NVDRMGetParam(pNv, NOUVEAU_GETPARAM_FB_SIZE);
+ pNv->VRAMPhysical = NVDRMGetParam(pNv, NOUVEAU_GETPARAM_FB_PHYSICAL);
+ pNv->AGPSize = NVDRMGetParam(pNv, NOUVEAU_GETPARAM_AGP_SIZE);
+ pNv->AGPPhysical = NVDRMGetParam(pNv, NOUVEAU_GETPARAM_AGP_PHYSICAL);
+ if ( ! pNv->AGPSize ) /*if no AGP*/
+ /*use PCI*/
+ pNv->SGPhysical = NVDRMGetParam(pNv, NOUVEAU_GETPARAM_PCI_PHYSICAL);
- if (pNv->AGPSize) {
- int gart_scratch_size;
+ int gart_scratch_size;
+ if (pNv->AGPSize) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "GART: %dMiB available\n",
+ "AGPGART: %dMiB available\n",
(unsigned int)(pNv->AGPSize >> 20));
if (pNv->AGPSize > (16 * 1024 * 1024))
@@ -1833,20 +1834,30 @@ NVMapMem(ScrnInfoPtr pScrn)
else
gart_scratch_size = pNv->AGPSize;
- pNv->AGPScratch = NVAllocateMemory(pNv, NOUVEAU_MEM_AGP,
- gart_scratch_size);
- if (!pNv->AGPScratch) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Unable to allocate GART memory\n");
- } else {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "GART: mapped %dMiB at %p\n",
- (unsigned int)(pNv->AGPScratch->size >> 20),
- pNv->AGPScratch->map);
}
+ else {
+
+ gart_scratch_size = (4 << 20) - (1 << 18) ;
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "GART: PCI DMA - using %dKiB\n", gart_scratch_size >> 10);
+
}
- pNv->Cursor = NVAllocateMemory(pNv, NOUVEAU_MEM_FB, 64 * 1024);
+ /*The DRM allocates AGP memory, PCI as a fallback */
+ pNv->GARTScratch = NVAllocateMemory(pNv, NOUVEAU_MEM_AGP | NOUVEAU_MEM_PCI_ACCEPTABLE,
+ gart_scratch_size);
+ if (!pNv->GARTScratch) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Unable to allocate GART memory\n");
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "GART: mapped %dMiB at %p, offset is %d\n",
+ (unsigned int)(pNv->GARTScratch->size >> 20),
+ pNv->GARTScratch->map, pNv->GARTScratch->offset);
+ }
+
+
+ pNv->Cursor = NVAllocateMemory(pNv, NOUVEAU_MEM_FB, 64*1024);
if (!pNv->Cursor) {
ErrorF("Failed to allocate memory for hardware cursor\n");
return FALSE;
diff --git a/src/nv_exa.c b/src/nv_exa.c
index 6380971..dfdbcb4 100644
--- a/src/nv_exa.c
+++ b/src/nv_exa.c
@@ -54,6 +54,7 @@ static void setM2MFDirection(ScrnInfoPtr pScrn, int dir)
NVPtr pNv = NVPTR(pScrn);
if (pNv->M2MFDirection != dir) {
+
NVDmaStart(pNv, NvSubMemFormat, MEMFORMAT_DMA_OBJECT_IN, 2);
NVDmaNext (pNv, dir ? NvDmaTT : NvDmaFB);
NVDmaNext (pNv, dir ? NvDmaFB : NvDmaTT);
@@ -286,13 +287,13 @@ NVAccelDownloadM2MF(ScrnInfoPtr pScrn, char *dst, uint64_t src_offset,
setM2MFDirection(pScrn, 0);
while (line_count) {
- char *src = pNv->AGPScratch->map;
+ char *src = pNv->GARTScratch->map;
int lc, i;
- if (line_count * line_len <= pNv->AGPScratch->size) {
+ if (line_count * line_len <= pNv->GARTScratch->size) {
lc = line_count;
} else {
- lc = pNv->AGPScratch->size / line_len;
+ lc = pNv->GARTScratch->size / line_len;
if (lc > line_count)
lc = line_count;
}
@@ -306,7 +307,7 @@ NVAccelDownloadM2MF(ScrnInfoPtr pScrn, char *dst, uint64_t src_offset,
NVDmaStart(pNv, NvSubMemFormat,
NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8);
NVDmaNext (pNv, (uint32_t)src_offset);
- NVDmaNext (pNv, (uint32_t)pNv->AGPScratch->offset);
+ NVDmaNext (pNv, (uint32_t)pNv->GARTScratch->offset);
NVDmaNext (pNv, src_pitch);
NVDmaNext (pNv, line_len);
NVDmaNext (pNv, line_len);
@@ -349,7 +350,7 @@ static Bool NVDownloadFromScreen(PixmapPtr pSrc,
cpp = pSrc->drawable.bitsPerPixel >> 3;
offset = (y * src_pitch) + (x * cpp);
- if (pNv->AGPScratch) {
+ if (pNv->GARTScratch) {
if (NVAccelDownloadM2MF(pScrn, dst,
NVAccelGetPixmapOffset(pSrc) + offset,
dst_pitch, src_pitch, w * cpp, h))
@@ -374,14 +375,14 @@ NVAccelUploadM2MF(ScrnInfoPtr pScrn, uint64_t dst_offset, const char *src,
setM2MFDirection(pScrn, 1);
while (line_count) {
- char *dst = pNv->AGPScratch->map;
+ char *dst = pNv->GARTScratch->map;
int lc, i;
/* Determine max amount of data we can DMA at once */
- if (line_count * line_len <= pNv->AGPScratch->size) {
+ if (line_count * line_len <= pNv->GARTScratch->size) {
lc = line_count;
} else {
- lc = pNv->AGPScratch->size / line_len;
+ lc = pNv->GARTScratch->size / line_len;
if (lc > line_count)
lc = line_count;
}
@@ -407,7 +408,7 @@ NVAccelUploadM2MF(ScrnInfoPtr pScrn, uint64_t dst_offset, const char *src,
NVDmaStart(pNv, NvSubMemFormat,
NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8);
- NVDmaNext (pNv, (uint32_t)pNv->AGPScratch->offset);
+ NVDmaNext (pNv, (uint32_t)pNv->GARTScratch->offset);
NVDmaNext (pNv, (uint32_t)dst_offset);
NVDmaNext (pNv, line_len);
NVDmaNext (pNv, dst_pitch);
@@ -439,7 +440,7 @@ static Bool NVUploadToScreen(PixmapPtr pDst,
dst_pitch = exaGetPixmapPitch(pDst);
cpp = pDst->drawable.bitsPerPixel >> 3;
- if (pNv->AGPScratch) {
+ if (pNv->GARTScratch) {
dst_offset += (y * dst_pitch) + (x * cpp);
if (NVAccelUploadM2MF(pScrn, dst_offset, src, dst_pitch,
src_pitch, w * cpp, h))
diff --git a/src/nv_mem.c b/src/nv_mem.c
index 99cb8bc..44e3d39 100644
--- a/src/nv_mem.c
+++ b/src/nv_mem.c
@@ -22,21 +22,16 @@ NVAllocRec *NVAllocateMemory(NVPtr pNv, int type, int size)
}
mem->type = memalloc.flags;
mem->size = memalloc.size;
- mem->offset = memalloc.region_offset;
+ mem->offset = memalloc.offset;
- if (drmMap(pNv->drm_fd, mem->offset, mem->size, &mem->map)) {
- ErrorF("drmMap() failed. offset=0x%llx, size=%lld (%d)\n",
- mem->offset, mem->size, errno);
+ if (drmMap(pNv->drm_fd, memalloc.map_handle, mem->size, &mem->map)) {
+ ErrorF("drmMap() failed. handle=0x%llx, size=%lld (%d)\n",
+ memalloc.map_handle, mem->size, errno);
mem->map = NULL;
NVFreeMemory(pNv, mem);
return NULL;
}
- if (mem->type & NOUVEAU_MEM_FB)
- mem->offset -= pNv->VRAMPhysical;
- else if (mem->type & NOUVEAU_MEM_AGP)
- mem->offset -= pNv->AGPPhysical;
-
return mem;
}
@@ -53,11 +48,8 @@ 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;
+ memfree.offset = mem->offset;
+
if (drmCommandWriteRead(pNv->drm_fd,
DRM_NOUVEAU_MEM_FREE, &memfree,
sizeof(memfree))) {
diff --git a/src/nv_proto.h b/src/nv_proto.h
index 6e50bd5..81bda90 100644
--- a/src/nv_proto.h
+++ b/src/nv_proto.h
@@ -64,6 +64,7 @@ void NVSetRopSolid(ScrnInfoPtr pScrn, CARD32 rop, CARD32 planemask);
/* in nv_exa.c */
Bool NVExaInit(ScreenPtr pScreen);
+Bool NVAccelUploadM2MF(ScrnInfoPtr, uint64_t, const char * , int, int, int, int);
/* in riva_hw.c */
void NVCalcStateExt(NVPtr,struct _riva_hw_state *,int,int,int,int,int,int);
diff --git a/src/nv_type.h b/src/nv_type.h
index 73a326f..79575dd 100644
--- a/src/nv_type.h
+++ b/src/nv_type.h
@@ -193,14 +193,16 @@ typedef struct _NVRec {
unsigned long VRAMSize;
/* AGP physical address */
unsigned long AGPPhysical;
- /* Accesible AGP size */
+ /* Accessible AGP size */
unsigned long AGPSize;
+ /* PCI buffer virtual address */
+ unsigned long SGPhysical;
NVAllocRec * FB;
NVAllocRec * Cursor;
NVAllocRec * CLUT; /* NV50 only */
NVAllocRec * ScratchBuffer;
- NVAllocRec * AGPScratch;
+ NVAllocRec * GARTScratch;
Bool NoAccel;
Bool HWCursor;