leo_accel.c revision 7a5333bc
14a041c5bSmacallan/* 24a041c5bSmacallan * Acceleration for the LEO (ZX) framebuffer. 34a041c5bSmacallan * 44a041c5bSmacallan * Copyright (C) 1999, 2000 Jakub Jelinek (jakub@redhat.com) 54a041c5bSmacallan * 64a041c5bSmacallan * Permission is hereby granted, free of charge, to any person obtaining a copy 74a041c5bSmacallan * of this software and associated documentation files (the "Software"), to deal 84a041c5bSmacallan * in the Software without restriction, including without limitation the rights 94a041c5bSmacallan * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 104a041c5bSmacallan * copies of the Software, and to permit persons to whom the Software is 114a041c5bSmacallan * furnished to do so, subject to the following conditions: 124a041c5bSmacallan * 134a041c5bSmacallan * The above copyright notice and this permission notice shall be included in 144a041c5bSmacallan * all copies or substantial portions of the Software. 154a041c5bSmacallan * 164a041c5bSmacallan * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 174a041c5bSmacallan * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 184a041c5bSmacallan * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 194a041c5bSmacallan * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 204a041c5bSmacallan * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 214a041c5bSmacallan * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 224a041c5bSmacallan */ 234a041c5bSmacallan 244a041c5bSmacallan#ifdef HAVE_CONFIG_H 254a041c5bSmacallan#include "config.h" 264a041c5bSmacallan#endif 274a041c5bSmacallan 284a041c5bSmacallan#define PSZ 32 294a041c5bSmacallan 304a041c5bSmacallan#include "scrnintstr.h" 314a041c5bSmacallan#include "pixmapstr.h" 324a041c5bSmacallan#include "regionstr.h" 334a041c5bSmacallan#include "mistruct.h" 344a041c5bSmacallan#include <X11/fonts/fontstruct.h> 354a041c5bSmacallan#include "dixfontstr.h" 364a041c5bSmacallan#include "fb.h" 374a041c5bSmacallan#include "mifillarc.h" 384a041c5bSmacallan#include "miwideline.h" 394a041c5bSmacallan#include "mi.h" 404a041c5bSmacallan 414a041c5bSmacallan#include "leo.h" 424a041c5bSmacallan 437a5333bcSmrg#if HAS_DEVPRIVATEKEYREC 4437510ae2SnakayamaDevPrivateKeyRec LeoGCPrivateIndex; 457a5333bcSmrg#else 467a5333bcSmrgint LeoGCPrivateIndex; 4737510ae2Snakayama#endif 484a041c5bSmacallan 494a041c5bSmacallanint leoRopTable[16] = { 504a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_ZERO, /* GXclear */ 514a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_AND_OLD, /* GXand */ 524a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_AND_NOLD, /* GXandReverse */ 534a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW, /* GXcopy */ 544a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_AND_OLD, /* GXandInverted */ 554a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_OLD, /* GXnoop */ 564a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_XOR_OLD, /* GXxor */ 574a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_OR_OLD, /* GXor */ 584a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_AND_NOLD, /* GXnor */ 594a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_XOR_NOLD, /* GXequiv */ 604a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NOLD, /* GXinvert */ 614a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_OR_NOLD, /* GXorReverse */ 624a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW, /* GXcopyInverted */ 634a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_OR_OLD, /* GXorInverted */ 644a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_OR_NOLD, /* GXnand */ 654a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_ONES /* GXset */ 664a041c5bSmacallan}; 674a041c5bSmacallan 684a041c5bSmacallanvoid LeoVtChange (ScreenPtr pScreen, int enter) 694a041c5bSmacallan{ 707a5333bcSmrg ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); 714a041c5bSmacallan LeoPtr pLeo = GET_LEO_FROM_SCRN (pScrn); 724a041c5bSmacallan LeoCommand0 *lc0 = pLeo->lc0; 734a041c5bSmacallan LeoDraw *ld0 = pLeo->ld0; 744a041c5bSmacallan 754a041c5bSmacallan ld0->wid = 1; 764a041c5bSmacallan ld0->widclip = 0; 774a041c5bSmacallan ld0->wmask = 0xffff; 784a041c5bSmacallan ld0->planemask = 0xffffff; 794a041c5bSmacallan ld0->rop = LEO_ATTR_WE_ENABLE|LEO_ATTR_RGBE_ENABLE|LEO_ATTR_FORCE_WID; 804a041c5bSmacallan ld0->fg = 0; 814a041c5bSmacallan ld0->vclipmin = 0; 824a041c5bSmacallan ld0->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16); 834a041c5bSmacallan 844a041c5bSmacallan while (lc0->csr & LEO_CSR_BLT_BUSY); 854a041c5bSmacallan 864a041c5bSmacallan lc0->extent = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 11); 874a041c5bSmacallan lc0->fill = 0; 884a041c5bSmacallan 894a041c5bSmacallan while (lc0->csr & LEO_CSR_BLT_BUSY); 904a041c5bSmacallan 914a041c5bSmacallan lc0->addrspace = LEO_ADDRSPC_OBGR; 924a041c5bSmacallan ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW; 934a041c5bSmacallan} 944a041c5bSmacallan 954a041c5bSmacallanextern Bool LeoCreateGC (GCPtr pGC); 964a041c5bSmacallan 974a041c5bSmacallanBool LeoAccelInit (ScreenPtr pScreen, LeoPtr pLeo) 984a041c5bSmacallan{ 994a041c5bSmacallan LeoCommand0 *lc0; 1004a041c5bSmacallan LeoDraw *ld0; 1014a041c5bSmacallan 1024a041c5bSmacallan#if LEO_OLDPRIV 1034a041c5bSmacallan static int LeoGeneration; 1044a041c5bSmacallan if (serverGeneration != LeoGeneration) { 1054a041c5bSmacallan LeoGCPrivateIndex = AllocateGCPrivateIndex(); 1064a041c5bSmacallan LeoGeneration = serverGeneration; 1074a041c5bSmacallan } 1084a041c5bSmacallan if (!AllocateGCPrivate(pScreen, LeoGCPrivateIndex, sizeof(LeoPrivGCRec))) 1094a041c5bSmacallan return FALSE; 1107a5333bcSmrg#elif HAS_DIXREGISTERPRIVATEKEY 1117a5333bcSmrg if (!dixRegisterPrivateKey(&LeoGCPrivateIndex, PRIVATE_GC, sizeof(LeoPrivGCRec))) 1127a5333bcSmrg return FALSE; 1134a041c5bSmacallan#else 114b2a2650bSchristos if (!dixRegisterPrivateKey(&LeoGCPrivateIndex, PRIVATE_GC, 115cce06770Schristos sizeof(LeoPrivGCRec))) 1164a041c5bSmacallan return FALSE; 1174a041c5bSmacallan#endif 1187a5333bcSmrg 1194a041c5bSmacallan pLeo->lc0 = lc0 = (LeoCommand0 *) ((char *)pLeo->fb + LEO_LC0_VOFF); 1204a041c5bSmacallan pLeo->ld0 = ld0 = (LeoDraw *) ((char *)pLeo->fb + LEO_LD0_VOFF); 1214a041c5bSmacallan 1224a041c5bSmacallan if (!pLeo->NoAccel) /* XXX do nothing */ ; 1234a041c5bSmacallan 1244a041c5bSmacallan /* We will now clear the screen: we'll draw a rectangle covering all the 1254a041c5bSmacallan * viewscreen, using a 'blackness' ROP. 1264a041c5bSmacallan */ 127832e5c3bSmacallan ld0->wid = 0x10; 1284a041c5bSmacallan ld0->widclip = 0; 1294a041c5bSmacallan ld0->wmask = 0xffff; 130832e5c3bSmacallan ld0->planemask = 0x00ffffff; 1314a041c5bSmacallan ld0->rop = LEO_ATTR_WE_ENABLE|LEO_ATTR_RGBE_ENABLE|LEO_ATTR_FORCE_WID; 1324a041c5bSmacallan ld0->fg = 0; 1334a041c5bSmacallan ld0->vclipmin = 0; 1344a041c5bSmacallan ld0->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16); 1354a041c5bSmacallan pLeo->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16); 1364a041c5bSmacallan pLeo->width = pLeo->psdp->width; 1374a041c5bSmacallan pLeo->height = pLeo->psdp->height; 1384a041c5bSmacallan 1394a041c5bSmacallan while (lc0->csr & LEO_CSR_BLT_BUSY); 1404a041c5bSmacallan 1414a041c5bSmacallan lc0->extent = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 11); 1424a041c5bSmacallan lc0->fill = 0; 1434a041c5bSmacallan 1444a041c5bSmacallan while (lc0->csr & LEO_CSR_BLT_BUSY); 1454a041c5bSmacallan 1464a041c5bSmacallan lc0->addrspace = LEO_ADDRSPC_OBGR; 147832e5c3bSmacallan ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW|LEO_ATTR_FORCE_WID; 1484a041c5bSmacallan 1494a041c5bSmacallan /* Success */ 1504a041c5bSmacallan return TRUE; 1514a041c5bSmacallan} 152