📄 atimach64exa.c
字号:
/* * Copyright 2003 through 2004 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting documentation, and * that the name of Marc Aurele La France not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Marc Aurele La France makes no representations * about the suitability of this software for any purpose. It is provided * "as-is" without express or implied warranty. * * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. *//* * Copyright 1999-2000 Precision Insight, Inc., Cedar Park, Texas. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *//* * DRI support by: * Manuel Teira * Leif Delgass <ldelgass@retinalburn.net> * * EXA support by: * Jakub Stachowski <qbast@go2.pl> * George Sapountzis <gsap7@yahoo.gr> */#ifdef HAVE_CONFIG_H#include "config.h"#endif#include <string.h>#include "ati.h"#include "atichip.h"#include "atidri.h"#include "atimach64accel.h"#include "atimach64io.h"#include "atipriv.h"#include "atiregs.h"#ifdef XF86DRI_DEVEL#include "mach64_dri.h"#include "mach64_sarea.h"#endif#ifdef USE_EXAextern CARD8 ATIMach64ALU[];extern voidATIMach64ValidateClip( ATIPtr pATI, int sc_left, int sc_right, int sc_top, int sc_bottom);#if 0#define MACH64_TRACE(x) \do { \ ErrorF("Mach64(%s): ", __FUNCTION__); \ ErrorF x; \} while(0)#else#define MACH64_TRACE(x) do { } while(0)#endif#if 0#define MACH64_FALLBACK(x) \do { \ ErrorF("Fallback(%s): ", __FUNCTION__); \ ErrorF x; \ return FALSE; \} while (0)#else#define MACH64_FALLBACK(x) return FALSE#endifstatic voidMach64WaitMarker(ScreenPtr pScreenInfo, int Marker){ ATIMach64Sync(xf86Screens[pScreenInfo->myNum]);}static BoolMach64GetDatatypeBpp(PixmapPtr pPix, CARD32 *pix_width){ int bpp = pPix->drawable.bitsPerPixel; switch (bpp) { case 8: *pix_width = SetBits(PIX_WIDTH_8BPP, DP_DST_PIX_WIDTH) | SetBits(PIX_WIDTH_8BPP, DP_SRC_PIX_WIDTH) | SetBits(PIX_WIDTH_1BPP, DP_HOST_PIX_WIDTH); break; case 16: *pix_width = SetBits(PIX_WIDTH_16BPP, DP_DST_PIX_WIDTH) | SetBits(PIX_WIDTH_16BPP, DP_SRC_PIX_WIDTH) | SetBits(PIX_WIDTH_1BPP, DP_HOST_PIX_WIDTH); break; case 24: *pix_width = SetBits(PIX_WIDTH_8BPP, DP_DST_PIX_WIDTH) | SetBits(PIX_WIDTH_8BPP, DP_SRC_PIX_WIDTH) | SetBits(PIX_WIDTH_1BPP, DP_HOST_PIX_WIDTH); break; case 32: *pix_width = SetBits(PIX_WIDTH_32BPP, DP_DST_PIX_WIDTH) | SetBits(PIX_WIDTH_32BPP, DP_SRC_PIX_WIDTH) | SetBits(PIX_WIDTH_1BPP, DP_HOST_PIX_WIDTH); break; default: MACH64_FALLBACK(("Unsupported bpp: %d\n", bpp)); }#if X_BYTE_ORDER == X_LITTLE_ENDIAN *pix_width |= DP_BYTE_PIX_ORDER;#endif /* X_BYTE_ORDER */ return TRUE;}static BoolMach64GetOffsetPitch(PixmapPtr pPix, int bpp, CARD32 *pitch_offset, unsigned int offset, unsigned int pitch){#if 0 ScrnInfoPtr pScreenInfo = xf86Screens[pPix->drawable.pScreen->myNum]; ATIPtr pATI = ATIPTR(pScreenInfo); if (pitch % pATI->pExa->pixmapPitchAlign != 0) MACH64_FALLBACK(("Bad pitch 0x%08x\n", pitch)); if (offset % pATI->pExa->pixmapOffsetAlign != 0) MACH64_FALLBACK(("Bad offset 0x%08x\n", offset));#endif /* pixels / 8 = ((bytes * 8) / bpp) / 8 = bytes / bpp */ pitch = pitch / bpp; /* bytes / 8 */ offset = offset >> 3; *pitch_offset = ((pitch << 22) | (offset << 0)); return TRUE;}static BoolMach64GetPixmapOffsetPitch(PixmapPtr pPix, CARD32 *pitch_offset){ CARD32 pitch, offset; int bpp; bpp = pPix->drawable.bitsPerPixel; if (bpp == 24) bpp = 8; pitch = exaGetPixmapPitch(pPix); offset = exaGetPixmapOffset(pPix); return Mach64GetOffsetPitch(pPix, bpp, pitch_offset, offset, pitch);}static BoolMach64PrepareCopy( PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, int ydir, int alu, Pixel planemask){ ScrnInfoPtr pScreenInfo = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; ATIPtr pATI = ATIPTR(pScreenInfo); CARD32 src_pitch_offset, dst_pitch_offset, dp_pix_width; ATIDRISync(pScreenInfo); if (!Mach64GetDatatypeBpp(pDstPixmap, &dp_pix_width)) return FALSE; if (!Mach64GetPixmapOffsetPitch(pSrcPixmap, &src_pitch_offset)) return FALSE; if (!Mach64GetPixmapOffsetPitch(pDstPixmap, &dst_pitch_offset)) return FALSE; ATIMach64WaitForFIFO(pATI, 7); outf(DP_WRITE_MASK, planemask); outf(DP_PIX_WIDTH, dp_pix_width); outf(SRC_OFF_PITCH, src_pitch_offset); outf(DST_OFF_PITCH, dst_pitch_offset); outf(DP_SRC, DP_MONO_SRC_ALLONES | SetBits(SRC_BLIT, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC)); outf(DP_MIX, SetBits(ATIMach64ALU[alu], DP_FRGD_MIX)); outf(CLR_CMP_CNTL, CLR_CMP_FN_FALSE); pATI->dst_cntl = 0; if (ydir > 0) pATI->dst_cntl |= DST_Y_DIR; if (xdir > 0) pATI->dst_cntl |= DST_X_DIR; if (pATI->XModifier == 1) outf(DST_CNTL, pATI->dst_cntl); else pATI->dst_cntl |= DST_24_ROT_EN; return TRUE;}static voidMach64Copy( PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY, int w, int h){ ScrnInfoPtr pScreenInfo = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; ATIPtr pATI = ATIPTR(pScreenInfo); srcX *= pATI->XModifier; dstY *= pATI->XModifier; w *= pATI->XModifier; ATIDRISync(pScreenInfo); /* Disable clipping if it gets in the way */ ATIMach64ValidateClip(pATI, dstX, dstX + w - 1, dstY, dstY + h - 1); if (!(pATI->dst_cntl & DST_X_DIR)) { srcX += w - 1; dstX += w - 1; } if (!(pATI->dst_cntl & DST_Y_DIR)) { srcY += h - 1; dstY += h - 1; } if (pATI->XModifier != 1) outf(DST_CNTL, pATI->dst_cntl | SetBits((dstX / 4) % 6, DST_24_ROT)); ATIMach64WaitForFIFO(pATI, 4); outf(SRC_Y_X, SetWord(srcX, 1) | SetWord(srcY, 0)); outf(SRC_WIDTH1, w); outf(DST_Y_X, SetWord(dstX, 1) | SetWord(dstY, 0)); outf(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0)); /* * On VTB's and later, the engine will randomly not wait for a copy * operation to commit its results to video memory before starting the next * one. The probability of such occurrences increases with GUI_WB_FLUSH * (or GUI_WB_FLUSH_P) setting, bitsPerPixel and/or CRTC clock. This * would point to some kind of video memory bandwidth problem were it noti * for the fact that the problem occurs less often (but still occurs) when * copying larger rectangles. */ if ((pATI->Chip >= ATI_CHIP_264VTB) && !pATI->OptionDevel) { exaMarkSync(pScreenInfo->pScreen); /* Force sync. */ exaWaitSync(pScreenInfo->pScreen); /* Sync and notify EXA. */ }}static void Mach64DoneCopy(PixmapPtr pDstPixmap) { }static BoolMach64PrepareSolid( PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg){ ScrnInfoPtr pScreenInfo = xf86Screens[pPixmap->drawable.pScreen->myNum]; ATIPtr pATI = ATIPTR(pScreenInfo); CARD32 dst_pitch_offset, dp_pix_width; ATIDRISync(pScreenInfo); if (!Mach64GetDatatypeBpp(pPixmap, &dp_pix_width)) return FALSE; if (!Mach64GetPixmapOffsetPitch(pPixmap, &dst_pitch_offset)) return FALSE; ATIMach64WaitForFIFO(pATI, 7); outf(DP_WRITE_MASK, planemask); outf(DP_PIX_WIDTH, dp_pix_width); outf(DST_OFF_PITCH, dst_pitch_offset); outf(DP_SRC, DP_MONO_SRC_ALLONES | SetBits(SRC_FRGD, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC)); outf(DP_FRGD_CLR, fg); outf(DP_MIX, SetBits(ATIMach64ALU[alu], DP_FRGD_MIX)); outf(CLR_CMP_CNTL, CLR_CMP_FN_FALSE); if (pATI->XModifier == 1) outf(DST_CNTL, DST_X_DIR | DST_Y_DIR); return TRUE;}static voidMach64Solid( PixmapPtr pPixmap,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -