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 "mi.h" 384a041c5bSmacallan 394a041c5bSmacallan#include "leo.h" 404a041c5bSmacallan 417a5333bcSmrg#if HAS_DEVPRIVATEKEYREC 4237510ae2SnakayamaDevPrivateKeyRec LeoGCPrivateIndex; 437a5333bcSmrg#else 447a5333bcSmrgint LeoGCPrivateIndex; 4537510ae2Snakayama#endif 464a041c5bSmacallan 474a041c5bSmacallanint leoRopTable[16] = { 484a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_ZERO, /* GXclear */ 494a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_AND_OLD, /* GXand */ 504a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_AND_NOLD, /* GXandReverse */ 514a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW, /* GXcopy */ 524a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_AND_OLD, /* GXandInverted */ 534a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_OLD, /* GXnoop */ 544a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_XOR_OLD, /* GXxor */ 554a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_OR_OLD, /* GXor */ 564a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_AND_NOLD, /* GXnor */ 574a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_XOR_NOLD, /* GXequiv */ 584a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NOLD, /* GXinvert */ 594a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_OR_NOLD, /* GXorReverse */ 604a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW, /* GXcopyInverted */ 614a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_OR_OLD, /* GXorInverted */ 624a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_OR_NOLD, /* GXnand */ 634a041c5bSmacallan LEO_ATTR_RGBE_ENABLE|LEO_ROP_ONES /* GXset */ 644a041c5bSmacallan}; 654a041c5bSmacallan 664a041c5bSmacallanvoid LeoVtChange (ScreenPtr pScreen, int enter) 674a041c5bSmacallan{ 687a5333bcSmrg ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); 694a041c5bSmacallan LeoPtr pLeo = GET_LEO_FROM_SCRN (pScrn); 704a041c5bSmacallan LeoCommand0 *lc0 = pLeo->lc0; 714a041c5bSmacallan LeoDraw *ld0 = pLeo->ld0; 724a041c5bSmacallan 734a041c5bSmacallan ld0->wid = 1; 744a041c5bSmacallan ld0->widclip = 0; 754a041c5bSmacallan ld0->wmask = 0xffff; 764a041c5bSmacallan ld0->planemask = 0xffffff; 774a041c5bSmacallan ld0->rop = LEO_ATTR_WE_ENABLE|LEO_ATTR_RGBE_ENABLE|LEO_ATTR_FORCE_WID; 784a041c5bSmacallan ld0->fg = 0; 794a041c5bSmacallan ld0->vclipmin = 0; 804a041c5bSmacallan ld0->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16); 814a041c5bSmacallan 824a041c5bSmacallan while (lc0->csr & LEO_CSR_BLT_BUSY); 834a041c5bSmacallan 844a041c5bSmacallan lc0->extent = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 11); 854a041c5bSmacallan lc0->fill = 0; 864a041c5bSmacallan 874a041c5bSmacallan while (lc0->csr & LEO_CSR_BLT_BUSY); 884a041c5bSmacallan 894a041c5bSmacallan lc0->addrspace = LEO_ADDRSPC_OBGR; 904a041c5bSmacallan ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW; 914a041c5bSmacallan} 924a041c5bSmacallan 934a041c5bSmacallanextern Bool LeoCreateGC (GCPtr pGC); 944a041c5bSmacallan 954a041c5bSmacallanBool LeoAccelInit (ScreenPtr pScreen, LeoPtr pLeo) 964a041c5bSmacallan{ 974a041c5bSmacallan LeoCommand0 *lc0; 984a041c5bSmacallan LeoDraw *ld0; 994a041c5bSmacallan 1004a041c5bSmacallan#if LEO_OLDPRIV 1014a041c5bSmacallan static int LeoGeneration; 1024a041c5bSmacallan if (serverGeneration != LeoGeneration) { 1034a041c5bSmacallan LeoGCPrivateIndex = AllocateGCPrivateIndex(); 1044a041c5bSmacallan LeoGeneration = serverGeneration; 1054a041c5bSmacallan } 1064a041c5bSmacallan if (!AllocateGCPrivate(pScreen, LeoGCPrivateIndex, sizeof(LeoPrivGCRec))) 1074a041c5bSmacallan return FALSE; 1087a5333bcSmrg#elif HAS_DIXREGISTERPRIVATEKEY 1097a5333bcSmrg if (!dixRegisterPrivateKey(&LeoGCPrivateIndex, PRIVATE_GC, sizeof(LeoPrivGCRec))) 1107a5333bcSmrg return FALSE; 1114a041c5bSmacallan#else 112b2a2650bSchristos if (!dixRegisterPrivateKey(&LeoGCPrivateIndex, PRIVATE_GC, 113cce06770Schristos sizeof(LeoPrivGCRec))) 1144a041c5bSmacallan return FALSE; 1154a041c5bSmacallan#endif 1167a5333bcSmrg 1174a041c5bSmacallan pLeo->lc0 = lc0 = (LeoCommand0 *) ((char *)pLeo->fb + LEO_LC0_VOFF); 1184a041c5bSmacallan pLeo->ld0 = ld0 = (LeoDraw *) ((char *)pLeo->fb + LEO_LD0_VOFF); 1194a041c5bSmacallan 12025ad54caSmrg if (!pLeo->NoAccel) { /* XXX do nothing */ } 1214a041c5bSmacallan 1224a041c5bSmacallan /* We will now clear the screen: we'll draw a rectangle covering all the 1234a041c5bSmacallan * viewscreen, using a 'blackness' ROP. 1244a041c5bSmacallan */ 125832e5c3bSmacallan ld0->wid = 0x10; 1264a041c5bSmacallan ld0->widclip = 0; 1274a041c5bSmacallan ld0->wmask = 0xffff; 128832e5c3bSmacallan ld0->planemask = 0x00ffffff; 1294a041c5bSmacallan ld0->rop = LEO_ATTR_WE_ENABLE|LEO_ATTR_RGBE_ENABLE|LEO_ATTR_FORCE_WID; 1304a041c5bSmacallan ld0->fg = 0; 1314a041c5bSmacallan ld0->vclipmin = 0; 1324a041c5bSmacallan ld0->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16); 1334a041c5bSmacallan pLeo->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16); 1344a041c5bSmacallan pLeo->width = pLeo->psdp->width; 1354a041c5bSmacallan pLeo->height = pLeo->psdp->height; 1364a041c5bSmacallan 1374a041c5bSmacallan while (lc0->csr & LEO_CSR_BLT_BUSY); 1384a041c5bSmacallan 1394a041c5bSmacallan lc0->extent = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 11); 1404a041c5bSmacallan lc0->fill = 0; 1414a041c5bSmacallan 1424a041c5bSmacallan while (lc0->csr & LEO_CSR_BLT_BUSY); 1434a041c5bSmacallan 1444a041c5bSmacallan lc0->addrspace = LEO_ADDRSPC_OBGR; 145832e5c3bSmacallan ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW|LEO_ATTR_FORCE_WID; 1464a041c5bSmacallan 1474a041c5bSmacallan /* Success */ 1484a041c5bSmacallan return TRUE; 1494a041c5bSmacallan} 150