diff options
author | dawes <dawes> | 2003-12-17 18:58:35 +0000 |
---|---|---|
committer | dawes <dawes> | 2003-12-17 18:58:35 +0000 |
commit | 4893f7e9327082e8f2cf6585e994574d9799139b (patch) | |
tree | e0fccf40235a9f1812622013b4b17e4dad380d2d | |
parent | 9e005dd212b868776a4e7e02f893f5381da410e2 (diff) |
new file
+ remove system includes
-rw-r--r-- | programs/Xserver/hw/xfree86/drivers/via/via_memory.c | 160 | ||||
-rw-r--r-- | programs/Xserver/hw/xfree86/drivers/via/via_swov.c | 6 |
2 files changed, 161 insertions, 5 deletions
diff --git a/programs/Xserver/hw/xfree86/drivers/via/via_memory.c b/programs/Xserver/hw/xfree86/drivers/via/via_memory.c new file mode 100644 index 000000000..32f19888d --- /dev/null +++ b/programs/Xserver/hw/xfree86/drivers/via/via_memory.c @@ -0,0 +1,160 @@ +/* + * Copyright 2003 Red Hat, Inc. All Rights Reserved. + * + * 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, sub license, + * 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS 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. + */ +/* $XFree86$ */ + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86_ansic.h" +#include "xf86fbman.h" + +#include "via_compose.h" +#include "via_capture.h" +#include "via.h" +#include "ddmpeg.h" +#include "xf86drm.h" + +#include "via_overlay.h" +#include "via_driver.h" +#include "via_regrec.h" +#include "via_priv.h" +#include "via_swov.h" +#include "via_common.h" + + +/* + * Isolate the wonders of X memory allocation, DRI memory allocation + * and 4.3 or 4.4 differences in once abstraction + * + * The pool code indicates who provided the memory + * 0 - nobody + * 1 - xf86 linear (Used in 4.4 only) + * 2 - DRM + * 3 - Preallocated buffer (Used in 4.3 only) + */ + +void VIAFreeLinear(VIAMemPtr mem) +{ + VIAPtr pVia; + DEBUG(ErrorF("Freed %lu (pool %d)\n", mem->base, mem->pool)); + switch(mem->pool) + { + case 0: + return; + case 1: + xf86FreeOffscreenLinear(mem->linear); + mem->linear = NULL; + mem->pool = 0; + return; + case 2: + if(drmCommandWrite(mem->drm_fd, DRM_VIA_FREEMEM, + &mem->drm, sizeof(drmViaMem)) < 0) + ErrorF("DRM module failed free.\n"); + drmClose(mem->drm_fd); + mem->pool = 0; + return; + case 3: + mem->pool = 0; + pVia = mem->pVia; + pVia->SWOVUsed[mem->slot] = 0; + return; + } +} + +unsigned long VIAAllocLinear(VIAMemPtr mem, ScrnInfoPtr pScrn, unsigned long size) +{ +#ifdef XF86DRI + VIAPtr pVia = VIAPTR(pScrn); + + if(mem->pool) + ErrorF("VIA Double Alloc.\n"); + + if(pVia->graphicInfo.DRMEnabled) + { + mem->drm_fd = pVia->drmFD; + mem->drm.context = 1; + mem->drm.size = size; + mem->drm.type = VIDEO; + + if(drmCommandWrite(mem->drm_fd, DRM_VIA_ALLOCMEM, + &mem->drm, sizeof(drmViaMem)) < 0) + { + ErrorF("Cannot allocate memory using DRM.\n"); + return BadAccess; + } + + mem->base = mem->drm.offset; + mem->pool = 2; + DEBUG(ErrorF("Fulfilled via DRI at %lu\n", mem->base)); + return 0; + } +#endif + +#ifdef XFREE_44 + { + int depth = (pScrn->bitsPerPixel + 7) >> 3; + mem->linear = xf86AllocateOffscreenLinear(pScrn->pScreen, size/depth, + 32, NULL, NULL, NULL); + if(mem->linear == NULL) + { + ErrorF("Out of memory for surface.\n"); + return BadAlloc; + } + mem->base = mem->linear->offset * depth; + mem->pool = 1; + DEBUG(ErrorF("Fulfilled via Linear at %lu\n", mem->base)); + return 0; + } +#else + { + int i; + if(size > pVia->SWOVSize) + return BadAccess; + for(i = 0; i < MEM_BLOCKS; i++) + { + if(!pVia->SWOVUsed[i]) + { + pVia->SWOVUsed[i] = 1; + mem->pool = 3; + mem->base = pVia->SWOVPool + pVia->SWOVSize * i; + mem->pVia = pVia; + mem->slot = i; + DEBUG(ErrorF("Fulfilled via pool at %lu\n", mem->base)); + return 0; + } + } + } + ErrorF("Out of pools.\n"); + return BadAlloc; +#endif +} + +void VIAInitPool(VIAPtr pVia, unsigned long offset, unsigned long size) +{ + DEBUG(ErrorF("VIAInitPool %lu bytes at %lu\n", size, offset)); + + size /= 4; + + DEBUG(ErrorF("VIAInitPool %d pools of %lu bytes\n", MEM_BLOCKS, size)); + pVia->SWOVPool = offset; + pVia->SWOVSize = size; +} diff --git a/programs/Xserver/hw/xfree86/drivers/via/via_swov.c b/programs/Xserver/hw/xfree86/drivers/via/via_swov.c index 975a2db49..ff1735247 100644 --- a/programs/Xserver/hw/xfree86/drivers/via/via_swov.c +++ b/programs/Xserver/hw/xfree86/drivers/via/via_swov.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_swov.c,v 1.7 2003/11/06 18:38:11 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_swov.c,v 1.8 2003/12/17 18:57:18 dawes Exp $ */ /* * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. @@ -23,10 +23,6 @@ * DEALINGS IN THE SOFTWARE. */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - #include "xf86.h" #include "xf86_OSproc.h" #include "xf86_ansic.h" |