diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2014-06-19 14:54:20 +1000 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2014-06-19 14:54:20 +1000 |
commit | 4b138ab18f58c6d459e21dc319615f536c8e69c8 (patch) | |
tree | a51b09e9119e255181509d126f9c31cd18217efd | |
parent | 5c44e6b86195c22e092db5dae06e70208e8b66a0 (diff) |
merge nv_dma.c into nv_accel_common.c
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/nv_accel_common.c | 104 | ||||
-rw-r--r-- | src/nv_dma.c | 102 | ||||
-rw-r--r-- | src/nv_driver.c | 5 | ||||
-rw-r--r-- | src/nv_proto.h | 6 |
5 files changed, 80 insertions, 138 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 3c12e7e..248298e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -37,7 +37,6 @@ nouveau_drv_la_SOURCES = \ nouveau_exa.c nouveau_xv.c nouveau_dri2.c \ nouveau_wfb.c \ nv_accel_common.c \ - nv_dma.c \ nv_driver.c \ nv_shadow.c \ nv04_exa.c \ diff --git a/src/nv_accel_common.c b/src/nv_accel_common.c index cce15b8..a55171b 100644 --- a/src/nv_accel_common.c +++ b/src/nv_accel_common.c @@ -592,11 +592,86 @@ NVAccelInitImageFromCpu(ScrnInfoPtr pScrn) } \ } while(0) +void +NVAccelCommonFini(ScrnInfoPtr pScrn) +{ + NVPtr pNv = NVPTR(pScrn); + + nouveau_object_del(&pNv->notify0); + nouveau_object_del(&pNv->vblank_sem); + + nouveau_object_del(&pNv->NvContextSurfaces); + nouveau_object_del(&pNv->NvContextBeta1); + nouveau_object_del(&pNv->NvContextBeta4); + nouveau_object_del(&pNv->NvImagePattern); + nouveau_object_del(&pNv->NvRop); + nouveau_object_del(&pNv->NvRectangle); + nouveau_object_del(&pNv->NvImageBlit); + nouveau_object_del(&pNv->NvScaledImage); + nouveau_object_del(&pNv->NvClipRectangle); + nouveau_object_del(&pNv->NvImageFromCpu); + nouveau_object_del(&pNv->Nv2D); + nouveau_object_del(&pNv->NvMemFormat); + nouveau_object_del(&pNv->NvSW); + nouveau_object_del(&pNv->Nv3D); + nouveau_object_del(&pNv->NvCOPY); + + nouveau_bo_ref(NULL, &pNv->scratch); + + nouveau_bufctx_del(&pNv->bufctx); + nouveau_pushbuf_del(&pNv->pushbuf); + nouveau_object_del(&pNv->channel); +} + Bool NVAccelCommonInit(ScrnInfoPtr pScrn) { NVPtr pNv = NVPTR(pScrn); - Bool ret; + struct nv04_fifo nv04_data = { .vram = NvDmaFB, + .gart = NvDmaTT }; + struct nvc0_fifo nvc0_data = { }; + struct nouveau_object *device = &pNv->dev->object; + int size, ret; + void *data; + + if (pNv->dev->drm_version < 0x01000000 && pNv->dev->chipset >= 0xc0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Fermi acceleration not supported on old kernel\n"); + return FALSE; + } + + if (pNv->Architecture < NV_ARCH_C0) { + data = &nv04_data; + size = sizeof(nv04_data); + } else { + data = &nvc0_data; + size = sizeof(nvc0_data); + } + + ret = nouveau_object_new(device, 0, NOUVEAU_FIFO_CHANNEL_CLASS, + data, size, &pNv->channel); + if (ret) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Error creating GPU channel: %d\n", ret); + return FALSE; + } + + ret = nouveau_pushbuf_new(pNv->client, pNv->channel, 4, 32 * 1024, + true, &pNv->pushbuf); + if (ret) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Error allocating DMA push buffer: %d\n",ret); + NVAccelCommonFini(pScrn); + return FALSE; + } + + ret = nouveau_bufctx_new(pNv->client, 1, &pNv->bufctx); + if (ret) { + NVAccelCommonFini(pScrn); + return FALSE; + } + + pNv->pushbuf->user_priv = pNv->bufctx; /* Scratch buffer */ ret = nouveau_bo_new(pNv->dev, NOUVEAU_BO_VRAM | NOUVEAU_BO_MAP, @@ -670,31 +745,6 @@ NVAccelCommonInit(ScrnInfoPtr pScrn) break; } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Channel setup complete.\n"); return TRUE; } - -void NVAccelFree(ScrnInfoPtr pScrn) -{ - NVPtr pNv = NVPTR(pScrn); - - nouveau_object_del(&pNv->notify0); - nouveau_object_del(&pNv->vblank_sem); - - nouveau_object_del(&pNv->NvContextSurfaces); - nouveau_object_del(&pNv->NvContextBeta1); - nouveau_object_del(&pNv->NvContextBeta4); - nouveau_object_del(&pNv->NvImagePattern); - nouveau_object_del(&pNv->NvRop); - nouveau_object_del(&pNv->NvRectangle); - nouveau_object_del(&pNv->NvImageBlit); - nouveau_object_del(&pNv->NvScaledImage); - nouveau_object_del(&pNv->NvClipRectangle); - nouveau_object_del(&pNv->NvImageFromCpu); - nouveau_object_del(&pNv->Nv2D); - nouveau_object_del(&pNv->NvMemFormat); - nouveau_object_del(&pNv->NvSW); - nouveau_object_del(&pNv->Nv3D); - nouveau_object_del(&pNv->NvCOPY); - - nouveau_bo_ref(NULL, &pNv->scratch); -} diff --git a/src/nv_dma.c b/src/nv_dma.c deleted file mode 100644 index 829ca1e..0000000 --- a/src/nv_dma.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2007 Ben Skeggs - * Copyright 2007 Stephane Marchesin - * - * 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 <errno.h> -#include "nv_include.h" - -Bool -NVInitDma(ScrnInfoPtr pScrn) -{ - NVPtr pNv = NVPTR(pScrn); - struct nv04_fifo nv04_data = { .vram = NvDmaFB, - .gart = NvDmaTT }; - struct nvc0_fifo nvc0_data = { }; - struct nouveau_object *device = &pNv->dev->object; - struct nouveau_fifo *fifo; - int size, ret; - void *data; - - if (pNv->dev->drm_version < 0x01000000 && pNv->dev->chipset >= 0xc0) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Fermi acceleration not supported on old kernel\n"); - return FALSE; - } - - if (pNv->Architecture < NV_ARCH_C0) { - data = &nv04_data; - size = sizeof(nv04_data); - } else { - data = &nvc0_data; - size = sizeof(nvc0_data); - } - - ret = nouveau_object_new(device, 0, NOUVEAU_FIFO_CHANNEL_CLASS, - data, size, &pNv->channel); - if (ret) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Error creating GPU channel: %d\n", ret); - return FALSE; - } - - fifo = pNv->channel->data; - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Opened GPU channel %d\n", fifo->channel); - - ret = nouveau_pushbuf_new(pNv->client, pNv->channel, 4, 32 * 1024, - true, &pNv->pushbuf); - if (ret) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Error allocating DMA push buffer: %d\n",ret); - NVTakedownDma(pScrn); - return FALSE; - } - - ret = nouveau_bufctx_new(pNv->client, 1, &pNv->bufctx); - if (ret) { - NVTakedownDma(pScrn); - return FALSE; - } - - pNv->pushbuf->user_priv = pNv->bufctx; - return TRUE; -} - -void -NVTakedownDma(ScrnInfoPtr pScrn) -{ - NVPtr pNv = NVPTR(pScrn); - - if (pNv->channel) { - struct nouveau_fifo *fifo = pNv->channel->data; - int chid = fifo->channel; - - nouveau_bufctx_del(&pNv->bufctx); - nouveau_pushbuf_del(&pNv->pushbuf); - nouveau_object_del(&pNv->channel); - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Closed GPU channel %d\n", chid); - } -} - diff --git a/src/nv_driver.c b/src/nv_driver.c index 04e5b13..8b15b1c 100644 --- a/src/nv_driver.c +++ b/src/nv_driver.c @@ -623,9 +623,8 @@ NVCloseScreen(CLOSE_SCREEN_ARGS_DECL) pScrn->vtSema = FALSE; } - NVAccelFree(pScrn); NVTakedownVideo(pScrn); - NVTakedownDma(pScrn); + NVAccelCommonFini(pScrn); NVUnmapMem(pScrn); xf86_cursors_fini(pScreen); @@ -1287,7 +1286,7 @@ NVScreenInit(SCREEN_INIT_ARGS_DECL) int displayWidth; if (pNv->AccelMethod == EXA) { - if (!NVInitDma(pScrn) || !NVAccelCommonInit(pScrn)) { + if (!NVAccelCommonInit(pScrn)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Error initialising acceleration. " "Falling back to NoAccel\n"); diff --git a/src/nv_proto.h b/src/nv_proto.h index 796df5c..0b16812 100644 --- a/src/nv_proto.h +++ b/src/nv_proto.h @@ -14,10 +14,10 @@ void drmmode_screen_fini(ScreenPtr pScreen); /* in nv_accel_common.c */ Bool NVAccelCommonInit(ScrnInfoPtr pScrn); +void NVAccelCommonFini(ScrnInfoPtr pScrn); Bool NVAccelGetCtxSurf2DFormatFromPixmap(PixmapPtr pPix, int *fmt_ret); Bool NVAccelGetCtxSurf2DFormatFromPicture(PicturePtr pPix, int *fmt_ret); PixmapPtr NVGetDrawablePixmap(DrawablePtr pDraw); -void NVAccelFree(ScrnInfoPtr pScrn); void NV11SyncToVBlank(PixmapPtr ppix, BoxPtr box); Bool nouveau_allocate_surface(ScrnInfoPtr scrn, int width, int height, int bpp, int usage_hint, int *pitch, @@ -39,10 +39,6 @@ void NVSetPortDefaults (ScrnInfoPtr pScrn, NVPortPrivPtr pPriv); void NVXVComputeBicubicFilter(struct nouveau_bo *, unsigned, unsigned); unsigned int nv_window_belongs_to_crtc(ScrnInfoPtr, int, int, int, int); -/* in nv_dma.c */ -Bool NVInitDma(ScrnInfoPtr pScrn); -void NVTakedownDma(ScrnInfoPtr pScrn); - /* in nouveau_exa.c */ Bool nouveau_exa_init(ScreenPtr pScreen); Bool nouveau_exa_pixmap_is_onscreen(PixmapPtr pPixmap); |