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 24#ifdef HAVE_CONFIG_H 25#include "config.h" 26#endif 27 28#define PSZ 32 29 30#include "scrnintstr.h" 31#include "pixmapstr.h" 32#include "regionstr.h" 33#include "mistruct.h" 34#include <X11/fonts/fontstruct.h> 35#include "dixfontstr.h" 36#include "fb.h" 37#include "mi.h" 38 39#include "leo.h" 40 41#if HAS_DEVPRIVATEKEYREC 42DevPrivateKeyRec LeoGCPrivateIndex; 43#else 44int LeoGCPrivateIndex; 45#endif 46 47int leoRopTable[16] = { 48 LEO_ATTR_RGBE_ENABLE|LEO_ROP_ZERO, /* GXclear */ 49 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_AND_OLD, /* GXand */ 50 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_AND_NOLD, /* GXandReverse */ 51 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW, /* GXcopy */ 52 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_AND_OLD, /* GXandInverted */ 53 LEO_ATTR_RGBE_ENABLE|LEO_ROP_OLD, /* GXnoop */ 54 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_XOR_OLD, /* GXxor */ 55 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_OR_OLD, /* GXor */ 56 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_AND_NOLD, /* GXnor */ 57 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_XOR_NOLD, /* GXequiv */ 58 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NOLD, /* GXinvert */ 59 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_OR_NOLD, /* GXorReverse */ 60 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW, /* GXcopyInverted */ 61 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_OR_OLD, /* GXorInverted */ 62 LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_OR_NOLD, /* GXnand */ 63 LEO_ATTR_RGBE_ENABLE|LEO_ROP_ONES /* GXset */ 64}; 65 66void LeoVtChange (ScreenPtr pScreen, int enter) 67{ 68 ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); 69 LeoPtr pLeo = GET_LEO_FROM_SCRN (pScrn); 70 LeoCommand0 *lc0 = pLeo->lc0; 71 LeoDraw *ld0 = pLeo->ld0; 72 73 ld0->wid = 1; 74 ld0->widclip = 0; 75 ld0->wmask = 0xffff; 76 ld0->planemask = 0xffffff; 77 ld0->rop = LEO_ATTR_WE_ENABLE|LEO_ATTR_RGBE_ENABLE|LEO_ATTR_FORCE_WID; 78 ld0->fg = 0; 79 ld0->vclipmin = 0; 80 ld0->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16); 81 82 while (lc0->csr & LEO_CSR_BLT_BUSY); 83 84 lc0->extent = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 11); 85 lc0->fill = 0; 86 87 while (lc0->csr & LEO_CSR_BLT_BUSY); 88 89 lc0->addrspace = LEO_ADDRSPC_OBGR; 90 ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW; 91} 92 93extern Bool LeoCreateGC (GCPtr pGC); 94 95Bool LeoAccelInit (ScreenPtr pScreen, LeoPtr pLeo) 96{ 97 LeoCommand0 *lc0; 98 LeoDraw *ld0; 99 100#if LEO_OLDPRIV 101 static int LeoGeneration; 102 if (serverGeneration != LeoGeneration) { 103 LeoGCPrivateIndex = AllocateGCPrivateIndex(); 104 LeoGeneration = serverGeneration; 105 } 106 if (!AllocateGCPrivate(pScreen, LeoGCPrivateIndex, sizeof(LeoPrivGCRec))) 107 return FALSE; 108#elif HAS_DIXREGISTERPRIVATEKEY 109 if (!dixRegisterPrivateKey(&LeoGCPrivateIndex, PRIVATE_GC, sizeof(LeoPrivGCRec))) 110 return FALSE; 111#else 112 if (!dixRegisterPrivateKey(&LeoGCPrivateIndex, PRIVATE_GC, 113 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