leo_accel.c revision 37510ae2
1/* 2 * Acceleration for the LEO (ZX) framebuffer. 3 * 4 * Copyright (C) 1999, 2000 Jakub Jelinek (jakub@redhat.com) 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 * copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 */ 23/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_accel.c,v 1.2tsi Exp $ */ 24 25#ifdef HAVE_CONFIG_H 26#include "config.h" 27#endif 28 29#define PSZ 32 30 31#include "scrnintstr.h" 32#include "pixmapstr.h" 33#include "regionstr.h" 34#include "mistruct.h" 35#include <X11/fonts/fontstruct.h> 36#include "dixfontstr.h" 37#include "fb.h" 38#include "mibstore.h" 39#include "mifillarc.h" 40#include "miwideline.h" 41#include "mi.h" 42 43#include "leo.h" 44 45#if LEO_OLDPRIV 46int LeoGCPrivateIndex; 47#else 48DevPrivateKeyRec LeoGCPrivateIndex; 49#endif 50 51int leoRopTable[16] = { 52 LEO_ATTR_RGBE_ENABLE|LEO_ROP_ZERO, /* GXclear */ 53 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_AND_OLD, /* GXand */ 54 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_AND_NOLD, /* GXandReverse */ 55 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW, /* GXcopy */ 56 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_AND_OLD, /* GXandInverted */ 57 LEO_ATTR_RGBE_ENABLE|LEO_ROP_OLD, /* GXnoop */ 58 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_XOR_OLD, /* GXxor */ 59 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_OR_OLD, /* GXor */ 60 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_AND_NOLD, /* GXnor */ 61 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_XOR_NOLD, /* GXequiv */ 62 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NOLD, /* GXinvert */ 63 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_OR_NOLD, /* GXorReverse */ 64 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW, /* GXcopyInverted */ 65 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_OR_OLD, /* GXorInverted */ 66 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_OR_NOLD, /* GXnand */ 67 LEO_ATTR_RGBE_ENABLE|LEO_ROP_ONES /* GXset */ 68}; 69 70void LeoVtChange (ScreenPtr pScreen, int enter) 71{ 72 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; 73 LeoPtr pLeo = GET_LEO_FROM_SCRN (pScrn); 74 LeoCommand0 *lc0 = pLeo->lc0; 75 LeoDraw *ld0 = pLeo->ld0; 76 77 ld0->wid = 1; 78 ld0->widclip = 0; 79 ld0->wmask = 0xffff; 80 ld0->planemask = 0xffffff; 81 ld0->rop = LEO_ATTR_WE_ENABLE|LEO_ATTR_RGBE_ENABLE|LEO_ATTR_FORCE_WID; 82 ld0->fg = 0; 83 ld0->vclipmin = 0; 84 ld0->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16); 85 86 while (lc0->csr & LEO_CSR_BLT_BUSY); 87 88 lc0->extent = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 11); 89 lc0->fill = 0; 90 91 while (lc0->csr & LEO_CSR_BLT_BUSY); 92 93 lc0->addrspace = LEO_ADDRSPC_OBGR; 94 ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW; 95} 96 97extern Bool LeoCreateGC (GCPtr pGC); 98 99Bool LeoAccelInit (ScreenPtr pScreen, LeoPtr pLeo) 100{ 101 LeoCommand0 *lc0; 102 LeoDraw *ld0; 103 104#if LEO_OLDPRIV 105 static int LeoGeneration; 106 if (serverGeneration != LeoGeneration) { 107 LeoGCPrivateIndex = AllocateGCPrivateIndex(); 108 LeoGeneration = serverGeneration; 109 } 110 if (!AllocateGCPrivate(pScreen, LeoGCPrivateIndex, sizeof(LeoPrivGCRec))) 111 return FALSE; 112#else 113 if (!dixRequestPrivate(&LeoGCPrivateIndex, sizeof(LeoPrivGCRec))) 114 return FALSE; 115#endif 116 117 pLeo->lc0 = lc0 = (LeoCommand0 *) ((char *)pLeo->fb + LEO_LC0_VOFF); 118 pLeo->ld0 = ld0 = (LeoDraw *) ((char *)pLeo->fb + LEO_LD0_VOFF); 119 120 if (!pLeo->NoAccel) /* XXX do nothing */ ; 121 122 /* We will now clear the screen: we'll draw a rectangle covering all the 123 * viewscreen, using a 'blackness' ROP. 124 */ 125 ld0->wid = 0x10; 126 ld0->widclip = 0; 127 ld0->wmask = 0xffff; 128 ld0->planemask = 0x00ffffff; 129 ld0->rop = LEO_ATTR_WE_ENABLE|LEO_ATTR_RGBE_ENABLE|LEO_ATTR_FORCE_WID; 130 ld0->fg = 0; 131 ld0->vclipmin = 0; 132 ld0->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16); 133 pLeo->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16); 134 pLeo->width = pLeo->psdp->width; 135 pLeo->height = pLeo->psdp->height; 136 137 while (lc0->csr & LEO_CSR_BLT_BUSY); 138 139 lc0->extent = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 11); 140 lc0->fill = 0; 141 142 while (lc0->csr & LEO_CSR_BLT_BUSY); 143 144 lc0->addrspace = LEO_ADDRSPC_OBGR; 145 ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW|LEO_ATTR_FORCE_WID; 146 147 /* Success */ 148 return TRUE; 149} 150