leo_accel.c revision 4a041c5b
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/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_accel.c,v 1.2tsi Exp $ */
244a041c5bSmacallan
254a041c5bSmacallan#ifdef HAVE_CONFIG_H
264a041c5bSmacallan#include "config.h"
274a041c5bSmacallan#endif
284a041c5bSmacallan
294a041c5bSmacallan#define	PSZ	32
304a041c5bSmacallan
314a041c5bSmacallan#include	"scrnintstr.h"
324a041c5bSmacallan#include	"pixmapstr.h"
334a041c5bSmacallan#include	"regionstr.h"
344a041c5bSmacallan#include	"mistruct.h"
354a041c5bSmacallan#include	<X11/fonts/fontstruct.h>
364a041c5bSmacallan#include	"dixfontstr.h"
374a041c5bSmacallan#include	"fb.h"
384a041c5bSmacallan#include	"mibstore.h"
394a041c5bSmacallan#include	"mifillarc.h"
404a041c5bSmacallan#include	"miwideline.h"
414a041c5bSmacallan#include	"mi.h"
424a041c5bSmacallan
434a041c5bSmacallan#include	"leo.h"
444a041c5bSmacallan
454a041c5bSmacallanint LeoGCPrivateIndex;
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{
684a041c5bSmacallan	ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
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;
1084a041c5bSmacallan#else
1094a041c5bSmacallan	if (!dixRequestPrivate(&LeoGCPrivateIndex, sizeof(LeoPrivGCRec)))
1104a041c5bSmacallan		return FALSE;
1114a041c5bSmacallan#endif
1124a041c5bSmacallan
1134a041c5bSmacallan	pLeo->lc0 = lc0 = (LeoCommand0 *) ((char *)pLeo->fb + LEO_LC0_VOFF);
1144a041c5bSmacallan	pLeo->ld0 = ld0 = (LeoDraw *) ((char *)pLeo->fb + LEO_LD0_VOFF);
1154a041c5bSmacallan
1164a041c5bSmacallan	if (!pLeo->NoAccel) /* XXX do nothing */ ;
1174a041c5bSmacallan
1184a041c5bSmacallan	/* We will now clear the screen: we'll draw a rectangle covering all the
1194a041c5bSmacallan	 * viewscreen, using a 'blackness' ROP.
1204a041c5bSmacallan	 */
1214a041c5bSmacallan	ld0->wid = 1;
1224a041c5bSmacallan	ld0->widclip = 0;
1234a041c5bSmacallan	ld0->wmask = 0xffff;
1244a041c5bSmacallan	ld0->planemask = 0xffffff;
1254a041c5bSmacallan	ld0->rop = LEO_ATTR_WE_ENABLE|LEO_ATTR_RGBE_ENABLE|LEO_ATTR_FORCE_WID;
1264a041c5bSmacallan	ld0->fg = 0;
1274a041c5bSmacallan	ld0->vclipmin = 0;
1284a041c5bSmacallan	ld0->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16);
1294a041c5bSmacallan	pLeo->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16);
1304a041c5bSmacallan	pLeo->width = pLeo->psdp->width;
1314a041c5bSmacallan	pLeo->height = pLeo->psdp->height;
1324a041c5bSmacallan
1334a041c5bSmacallan	while (lc0->csr & LEO_CSR_BLT_BUSY);
1344a041c5bSmacallan
1354a041c5bSmacallan	lc0->extent = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 11);
1364a041c5bSmacallan	lc0->fill = 0;
1374a041c5bSmacallan
1384a041c5bSmacallan	while (lc0->csr & LEO_CSR_BLT_BUSY);
1394a041c5bSmacallan
1404a041c5bSmacallan	lc0->addrspace = LEO_ADDRSPC_OBGR;
1414a041c5bSmacallan	ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
1424a041c5bSmacallan
1434a041c5bSmacallan	/* Success */
1444a041c5bSmacallan	return TRUE;
1454a041c5bSmacallan}
146