leo_accel.c revision 4a041c5b
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 45int LeoGCPrivateIndex; 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 = xf86Screens[pScreen->myNum]; 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#else 109 if (!dixRequestPrivate(&LeoGCPrivateIndex, sizeof(LeoPrivGCRec))) 110 return FALSE; 111#endif 112 113 pLeo->lc0 = lc0 = (LeoCommand0 *) ((char *)pLeo->fb + LEO_LC0_VOFF); 114 pLeo->ld0 = ld0 = (LeoDraw *) ((char *)pLeo->fb + LEO_LD0_VOFF); 115 116 if (!pLeo->NoAccel) /* XXX do nothing */ ; 117 118 /* We will now clear the screen: we'll draw a rectangle covering all the 119 * viewscreen, using a 'blackness' ROP. 120 */ 121 ld0->wid = 1; 122 ld0->widclip = 0; 123 ld0->wmask = 0xffff; 124 ld0->planemask = 0xffffff; 125 ld0->rop = LEO_ATTR_WE_ENABLE|LEO_ATTR_RGBE_ENABLE|LEO_ATTR_FORCE_WID; 126 ld0->fg = 0; 127 ld0->vclipmin = 0; 128 ld0->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16); 129 pLeo->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16); 130 pLeo->width = pLeo->psdp->width; 131 pLeo->height = pLeo->psdp->height; 132 133 while (lc0->csr & LEO_CSR_BLT_BUSY); 134 135 lc0->extent = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 11); 136 lc0->fill = 0; 137 138 while (lc0->csr & LEO_CSR_BLT_BUSY); 139 140 lc0->addrspace = LEO_ADDRSPC_OBGR; 141 ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW; 142 143 /* Success */ 144 return TRUE; 145} 146