cg14_accel.c revision c88c16f8
1c88c16f8Smacallan/* $NetBSD: cg14_accel.c,v 1.8 2016/09/16 21:16:37 macallan Exp $ */ 24261fa58Smacallan/* 34261fa58Smacallan * Copyright (c) 2013 Michael Lorenz 44261fa58Smacallan * All rights reserved. 54261fa58Smacallan * 64261fa58Smacallan * Redistribution and use in source and binary forms, with or without 74261fa58Smacallan * modification, are permitted provided that the following conditions 84261fa58Smacallan * are met: 94261fa58Smacallan * 104261fa58Smacallan * - Redistributions of source code must retain the above copyright 114261fa58Smacallan * notice, this list of conditions and the following disclaimer. 124261fa58Smacallan * - Redistributions in binary form must reproduce the above 134261fa58Smacallan * copyright notice, this list of conditions and the following 144261fa58Smacallan * disclaimer in the documentation and/or other materials provided 154261fa58Smacallan * with the distribution. 164261fa58Smacallan * 174261fa58Smacallan * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 184261fa58Smacallan * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 194261fa58Smacallan * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 204261fa58Smacallan * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 214261fa58Smacallan * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 224261fa58Smacallan * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 234261fa58Smacallan * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 244261fa58Smacallan * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 254261fa58Smacallan * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 264261fa58Smacallan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 274261fa58Smacallan * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 284261fa58Smacallan * POSSIBILITY OF SUCH DAMAGE. 294261fa58Smacallan * 304261fa58Smacallan */ 31c88c16f8Smacallan 32c88c16f8Smacallan#ifdef HAVE_CONFIG_H 33c88c16f8Smacallan#include "config.h" 34c88c16f8Smacallan#endif 35c88c16f8Smacallan 364261fa58Smacallan#include <sys/types.h> 374261fa58Smacallan 384261fa58Smacallan/* all driver need this */ 394261fa58Smacallan#include "xf86.h" 404261fa58Smacallan#include "xf86_OSproc.h" 414261fa58Smacallan#include "compiler.h" 424261fa58Smacallan 434261fa58Smacallan#include "cg14.h" 444261fa58Smacallan#include <sparc/sxreg.h> 454261fa58Smacallan 464261fa58Smacallan#define SX_SINGLE 474261fa58Smacallan/*#define SX_DEBUG*/ 484261fa58Smacallan/*#define SX_ADD_SOFTWARE*/ 494261fa58Smacallan 504261fa58Smacallan#ifdef SX_DEBUG 514261fa58Smacallan#define ENTER xf86Msg(X_ERROR, "%s>\n", __func__); 524261fa58Smacallan#define DPRINTF xf86Msg 534261fa58Smacallan#else 544261fa58Smacallan#define ENTER 554261fa58Smacallan#define DPRINTF while (0) xf86Msg 564261fa58Smacallan#endif 574261fa58Smacallan 584261fa58Smacallan#define arraysize(ary) (sizeof(ary) / sizeof(ary[0])) 594261fa58Smacallan 604261fa58Smacallan/* 0xcc is SX's GXcopy equivalent */ 614261fa58Smacallanuint32_t sx_rop[] = { 0x00, 0x88, 0x44, 0xcc, 0x22, 0xaa, 0x66, 0xee, 624261fa58Smacallan 0x11, 0x99, 0x55, 0xdd, 0x33, 0xbb, 0x77, 0xff}; 634261fa58Smacallan 644261fa58Smacallanint src_formats[] = {PICT_a8r8g8b8, PICT_x8r8g8b8, 654261fa58Smacallan PICT_a8b8g8r8, PICT_x8b8g8r8, PICT_a8}; 664261fa58Smacallanint tex_formats[] = {PICT_a8r8g8b8, PICT_a8b8g8r8, PICT_a8}; 674261fa58Smacallan 684261fa58Smacallanstatic inline void 694261fa58SmacallanCG14Wait(Cg14Ptr p) 704261fa58Smacallan{ 714261fa58Smacallan /* we just wait until the instruction queue is empty */ 724261fa58Smacallan while ((read_sx_reg(p, SX_CONTROL_STATUS) & SX_MT) != 0) {}; 734261fa58Smacallan} 744261fa58Smacallan 754261fa58Smacallanstatic void 764261fa58SmacallanCG14WaitMarker(ScreenPtr pScreen, int Marker) 774261fa58Smacallan{ 784261fa58Smacallan ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; 794261fa58Smacallan Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); 804261fa58Smacallan 814261fa58Smacallan CG14Wait(p); 824261fa58Smacallan} 834261fa58Smacallan 844261fa58Smacallanstatic Bool 854261fa58SmacallanCG14PrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, 864261fa58Smacallan int xdir, int ydir, int alu, Pixel planemask) 874261fa58Smacallan{ 884261fa58Smacallan ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; 894261fa58Smacallan Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); 904261fa58Smacallan 914261fa58Smacallan ENTER; 924261fa58Smacallan DPRINTF(X_ERROR, "bits per pixel: %d\n", 934261fa58Smacallan pSrcPixmap->drawable.bitsPerPixel); 944261fa58Smacallan 954261fa58Smacallan if (planemask != p->last_mask) { 964261fa58Smacallan CG14Wait(p); 974261fa58Smacallan write_sx_reg(p, SX_PLANEMASK, planemask); 984261fa58Smacallan p->last_mask = planemask; 994261fa58Smacallan } 1004261fa58Smacallan alu = sx_rop[alu]; 1014261fa58Smacallan if (alu != p->last_rop) { 1024261fa58Smacallan CG14Wait(p); 1034261fa58Smacallan write_sx_reg(p, SX_ROP_CONTROL, alu); 1044261fa58Smacallan p->last_rop = alu; 1054261fa58Smacallan } 1064261fa58Smacallan p->srcpitch = exaGetPixmapPitch(pSrcPixmap); 1074261fa58Smacallan p->srcoff = exaGetPixmapOffset(pSrcPixmap); 1084261fa58Smacallan p->xdir = xdir; 1094261fa58Smacallan p->ydir = ydir; 1104261fa58Smacallan return TRUE; 1114261fa58Smacallan} 1124261fa58Smacallan 1134261fa58Smacallanstatic void 1144261fa58SmacallanCG14Copy(PixmapPtr pDstPixmap, 1154261fa58Smacallan int srcX, int srcY, int dstX, int dstY, int w, int h) 1164261fa58Smacallan{ 1174261fa58Smacallan ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; 1184261fa58Smacallan Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); 1194261fa58Smacallan int dstpitch, dstoff, srcpitch, srcoff; 1204261fa58Smacallan int srcstart, dststart, xinc, srcinc, dstinc; 1214261fa58Smacallan int line, count, s, d, num; 1224261fa58Smacallan 1234261fa58Smacallan ENTER; 1244261fa58Smacallan dstpitch = exaGetPixmapPitch(pDstPixmap); 1254261fa58Smacallan dstoff = exaGetPixmapOffset(pDstPixmap); 1264261fa58Smacallan srcpitch = p->srcpitch; 1274261fa58Smacallan srcoff = p->srcoff; 1284261fa58Smacallan /* 1294261fa58Smacallan * should clear the WO bit in SX_CONTROL_STATUS, then check if SX 1304261fa58Smacallan * actually wrote anything and only sync if it did 1314261fa58Smacallan */ 1324261fa58Smacallan srcstart = (srcX << 2) + (srcpitch * srcY) + srcoff; 1334261fa58Smacallan dststart = (dstX << 2) + (dstpitch * dstY) + dstoff; 1344261fa58Smacallan 1354261fa58Smacallan /* 1364261fa58Smacallan * we always copy up to 32 pixels at a time so direction doesn't 1374261fa58Smacallan * matter if w<=32 1384261fa58Smacallan */ 1394261fa58Smacallan if (w > 32) { 1404261fa58Smacallan if (p->xdir < 0) { 1414261fa58Smacallan srcstart += (w - 32) << 2; 1424261fa58Smacallan dststart += (w - 32) << 2; 1434261fa58Smacallan xinc = -128; 1444261fa58Smacallan } else 1454261fa58Smacallan xinc = 128; 1464261fa58Smacallan } else 1474261fa58Smacallan xinc = 128; 1484261fa58Smacallan if (p->ydir < 0) { 1494261fa58Smacallan srcstart += (h - 1) * srcpitch; 1504261fa58Smacallan dststart += (h - 1) * dstpitch; 1514261fa58Smacallan srcinc = -srcpitch; 1524261fa58Smacallan dstinc = -dstpitch; 1534261fa58Smacallan } else { 1544261fa58Smacallan srcinc = srcpitch; 1554261fa58Smacallan dstinc = dstpitch; 1564261fa58Smacallan } 1574261fa58Smacallan if (p->last_rop == 0xcc) { 1584261fa58Smacallan /* plain old copy */ 1594261fa58Smacallan if ( xinc > 0) { 1604261fa58Smacallan /* going left to right */ 1614261fa58Smacallan for (line = 0; line < h; line++) { 1624261fa58Smacallan count = 0; 1634261fa58Smacallan s = srcstart; 1644261fa58Smacallan d = dststart; 1654261fa58Smacallan while ( count < w) { 1664261fa58Smacallan num = min(32, w - count); 1674261fa58Smacallan write_sx_io(p, s, 1684261fa58Smacallan SX_LD(10, num - 1, s & 7)); 1694261fa58Smacallan write_sx_io(p, d, 1704261fa58Smacallan SX_STM(10, num - 1, d & 7)); 1714261fa58Smacallan s += xinc; 1724261fa58Smacallan d += xinc; 1734261fa58Smacallan count += 32; 1744261fa58Smacallan } 1754261fa58Smacallan srcstart += srcinc; 1764261fa58Smacallan dststart += dstinc; 1774261fa58Smacallan } 1784261fa58Smacallan } else { 1794261fa58Smacallan /* going right to left */ 1804261fa58Smacallan int i, chunks = (w >> 5); 1814261fa58Smacallan for (line = 0; line < h; line++) { 1824261fa58Smacallan s = srcstart; 1834261fa58Smacallan d = dststart; 1844261fa58Smacallan count = w; 1854261fa58Smacallan for (i = 0; i < chunks; i++) { 1864261fa58Smacallan write_sx_io(p, s, 1874261fa58Smacallan SX_LD(10, 31, s & 7)); 1884261fa58Smacallan write_sx_io(p, d, 1894261fa58Smacallan SX_STM(10, 31, d & 7)); 1904261fa58Smacallan s -= 128; 1914261fa58Smacallan d -= 128; 1924261fa58Smacallan count -= 32; 1934261fa58Smacallan } 1944261fa58Smacallan /* leftovers, if any */ 1954261fa58Smacallan if (count > 0) { 1964261fa58Smacallan s += (32 - count) << 2; 1974261fa58Smacallan d += (32 - count) << 2; 1984261fa58Smacallan write_sx_io(p, s, 1994261fa58Smacallan SX_LD(10, count - 1, s & 7)); 2004261fa58Smacallan write_sx_io(p, d, 2014261fa58Smacallan SX_STM(10, count - 1, d & 7)); 2024261fa58Smacallan } 2034261fa58Smacallan srcstart += srcinc; 2044261fa58Smacallan dststart += dstinc; 2054261fa58Smacallan } 2064261fa58Smacallan } 2074261fa58Smacallan } else { 2084261fa58Smacallan /* ROPs needed */ 2094261fa58Smacallan if ( xinc > 0) { 2104261fa58Smacallan /* going left to right */ 2114261fa58Smacallan for (line = 0; line < h; line++) { 2124261fa58Smacallan count = 0; 2134261fa58Smacallan s = srcstart; 2144261fa58Smacallan d = dststart; 2154261fa58Smacallan while ( count < w) { 2164261fa58Smacallan num = min(32, w - count); 2174261fa58Smacallan write_sx_io(p, s, 2184261fa58Smacallan SX_LD(10, num - 1, s & 7)); 2194261fa58Smacallan write_sx_io(p, d, 2204261fa58Smacallan SX_LD(42, num - 1, d & 7)); 2214261fa58Smacallan if (num > 16) { 2224261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 2234261fa58Smacallan SX_ROP(10, 42, 74, 15)); 2244261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 2254261fa58Smacallan SX_ROP(26, 58, 90, num - 17)); 2264261fa58Smacallan } else { 2274261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 2284261fa58Smacallan SX_ROP(10, 42, 74, num - 1)); 2294261fa58Smacallan } 2304261fa58Smacallan write_sx_io(p, d, 2314261fa58Smacallan SX_STM(74, num - 1, d & 7)); 2324261fa58Smacallan s += xinc; 2334261fa58Smacallan d += xinc; 2344261fa58Smacallan count += 32; 2354261fa58Smacallan } 2364261fa58Smacallan srcstart += srcinc; 2374261fa58Smacallan dststart += dstinc; 2384261fa58Smacallan } 2394261fa58Smacallan } else { 2404261fa58Smacallan /* going right to left */ 2414261fa58Smacallan int i, chunks = (w >> 5); 2424261fa58Smacallan for (line = 0; line < h; line++) { 2434261fa58Smacallan s = srcstart; 2444261fa58Smacallan d = dststart; 2454261fa58Smacallan count = w; 2464261fa58Smacallan for (i = 0; i < chunks; i++) { 2474261fa58Smacallan write_sx_io(p, s, SX_LD(10, 31, s & 7)); 2484261fa58Smacallan write_sx_io(p, d, SX_LD(42, 31, d & 7)); 2494261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 2504261fa58Smacallan SX_ROP(10, 42, 74, 15)); 2514261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 2524261fa58Smacallan SX_ROP(26, 58, 90, 15)); 2534261fa58Smacallan write_sx_io(p, d, 2544261fa58Smacallan SX_STM(74, 31, d & 7)); 2554261fa58Smacallan s -= 128; 2564261fa58Smacallan d -= 128; 2574261fa58Smacallan count -= 32; 2584261fa58Smacallan } 2594261fa58Smacallan /* leftovers, if any */ 2604261fa58Smacallan if (count > 0) { 2614261fa58Smacallan s += (32 - count) << 2; 2624261fa58Smacallan d += (32 - count) << 2; 2634261fa58Smacallan write_sx_io(p, s, 2644261fa58Smacallan SX_LD(10, count - 1, s & 7)); 2654261fa58Smacallan write_sx_io(p, d, 2664261fa58Smacallan SX_LD(42, count - 1, d & 7)); 2674261fa58Smacallan if (count > 16) { 2684261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 2694261fa58Smacallan SX_ROP(10, 42, 74, 15)); 2704261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 2714261fa58Smacallan SX_ROP(26, 58, 90, count - 17)); 2724261fa58Smacallan } else { 2734261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 2744261fa58Smacallan SX_ROP(10, 42, 74, count - 1)); 2754261fa58Smacallan } 2764261fa58Smacallan 2774261fa58Smacallan write_sx_io(p, d, 2784261fa58Smacallan SX_STM(74, count - 1, d & 7)); 2794261fa58Smacallan } 2804261fa58Smacallan srcstart += srcinc; 2814261fa58Smacallan dststart += dstinc; 2824261fa58Smacallan } 2834261fa58Smacallan } 2844261fa58Smacallan } 2854261fa58Smacallan exaMarkSync(pDstPixmap->drawable.pScreen); 2864261fa58Smacallan} 2874261fa58Smacallan 2884261fa58Smacallanstatic void 2894261fa58SmacallanCG14DoneCopy(PixmapPtr pDstPixmap) 2904261fa58Smacallan{ 2914261fa58Smacallan} 2924261fa58Smacallan 2934261fa58Smacallanstatic Bool 2944261fa58SmacallanCG14PrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg) 2954261fa58Smacallan{ 2964261fa58Smacallan ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; 2974261fa58Smacallan Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); 2984261fa58Smacallan 2994261fa58Smacallan ENTER; 3006bdc2ffdSmacallan DPRINTF(X_ERROR, "bits per pixel: %d\n", 3016bdc2ffdSmacallan pPixmap->drawable.bitsPerPixel); 3024261fa58Smacallan write_sx_reg(p, SX_QUEUED(8), fg); 3034261fa58Smacallan write_sx_reg(p, SX_QUEUED(9), fg); 3044261fa58Smacallan if (planemask != p->last_mask) { 3054261fa58Smacallan CG14Wait(p); 3064261fa58Smacallan write_sx_reg(p, SX_PLANEMASK, planemask); 3074261fa58Smacallan p->last_mask = planemask; 3084261fa58Smacallan } 3094261fa58Smacallan alu = sx_rop[alu]; 3104261fa58Smacallan if (alu != p->last_rop) { 3114261fa58Smacallan CG14Wait(p); 3124261fa58Smacallan write_sx_reg(p, SX_ROP_CONTROL, alu); 3134261fa58Smacallan p->last_rop = alu; 3144261fa58Smacallan } 3154261fa58Smacallan DPRINTF(X_ERROR, "%s: %x\n", __func__, alu); 3164261fa58Smacallan return TRUE; 3174261fa58Smacallan} 3184261fa58Smacallan 3194261fa58Smacallanstatic void 3204261fa58SmacallanCG14Solid32(Cg14Ptr p, uint32_t start, uint32_t pitch, int w, int h) 3214261fa58Smacallan{ 3224261fa58Smacallan int line, x, num; 3234261fa58Smacallan uint32_t ptr; 3244261fa58Smacallan 3254261fa58Smacallan ENTER; 3264261fa58Smacallan if (p->last_rop == 0xcc) { 3274261fa58Smacallan /* simple fill */ 3284261fa58Smacallan for (line = 0; line < h; line++) { 3294261fa58Smacallan x = 0; 3304261fa58Smacallan while (x < w) { 3314261fa58Smacallan ptr = start + (x << 2); 3324261fa58Smacallan num = min(32, w - x); 3334261fa58Smacallan write_sx_io(p, ptr, 3344261fa58Smacallan SX_STS(8, num - 1, ptr & 7)); 3354261fa58Smacallan x += 32; 3364261fa58Smacallan } 3374261fa58Smacallan start += pitch; 3384261fa58Smacallan } 3394261fa58Smacallan } else if (p->last_rop == 0xaa) { 3404261fa58Smacallan /* nothing to do here */ 3414261fa58Smacallan return; 3424261fa58Smacallan } else { 3434261fa58Smacallan /* alright, let's do actual ROP stuff */ 3444261fa58Smacallan 3454261fa58Smacallan /* first repeat the fill colour into 16 registers */ 3464261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 3474261fa58Smacallan SX_SELECT_S(8, 8, 10, 15)); 3484261fa58Smacallan 3494261fa58Smacallan for (line = 0; line < h; line++) { 3504261fa58Smacallan x = 0; 3514261fa58Smacallan while (x < w) { 3524261fa58Smacallan ptr = start + (x << 2); 3534261fa58Smacallan num = min(32, w - x); 3544261fa58Smacallan /* now suck fb data into registers */ 3554261fa58Smacallan write_sx_io(p, ptr, 3564261fa58Smacallan SX_LD(42, num - 1, ptr & 7)); 3574261fa58Smacallan /* 3584261fa58Smacallan * ROP them with the fill data we left in 10 3594261fa58Smacallan * non-memory ops can only have counts up to 16 3604261fa58Smacallan */ 3614261fa58Smacallan if (num <= 16) { 3624261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 3634261fa58Smacallan SX_ROP(10, 42, 74, num - 1)); 3644261fa58Smacallan } else { 3654261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 3664261fa58Smacallan SX_ROP(10, 42, 74, 15)); 3674261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 3684261fa58Smacallan SX_ROP(10, 58, 90, num - 17)); 3694261fa58Smacallan } 3704261fa58Smacallan /* and write the result back into memory */ 3714261fa58Smacallan write_sx_io(p, ptr, 3724261fa58Smacallan SX_ST(74, num - 1, ptr & 7)); 3734261fa58Smacallan x += 32; 3744261fa58Smacallan } 3754261fa58Smacallan start += pitch; 3764261fa58Smacallan } 3774261fa58Smacallan } 3784261fa58Smacallan} 3794261fa58Smacallan 3804261fa58Smacallanstatic void 3814261fa58SmacallanCG14Solid8(Cg14Ptr p, uint32_t start, uint32_t pitch, int w, int h) 3824261fa58Smacallan{ 3834261fa58Smacallan int line, x, num, off; 3844261fa58Smacallan uint32_t ptr; 3854261fa58Smacallan 3864261fa58Smacallan ENTER; 3874261fa58Smacallan off = start & 7; 3884261fa58Smacallan start &= ~7; 3894261fa58Smacallan 3904261fa58Smacallan if (p->last_rop == 0xcc) { 3914261fa58Smacallan /* simple fill */ 3924261fa58Smacallan for (line = 0; line < h; line++) { 3934261fa58Smacallan x = 0; 3944261fa58Smacallan while (x < w) { 3954261fa58Smacallan ptr = start + x; 3964261fa58Smacallan num = min(32, w - x); 3974261fa58Smacallan write_sx_io(p, ptr, 3984261fa58Smacallan SX_STBS(8, num - 1, off)); 3994261fa58Smacallan x += 32; 4004261fa58Smacallan } 4014261fa58Smacallan start += pitch; 4024261fa58Smacallan } 4034261fa58Smacallan } else if (p->last_rop == 0xaa) { 4044261fa58Smacallan /* nothing to do here */ 4054261fa58Smacallan return; 4064261fa58Smacallan } else { 4074261fa58Smacallan /* alright, let's do actual ROP stuff */ 4084261fa58Smacallan 4094261fa58Smacallan /* first repeat the fill colour into 16 registers */ 4104261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 4114261fa58Smacallan SX_SELECT_S(8, 8, 10, 15)); 4124261fa58Smacallan 4134261fa58Smacallan for (line = 0; line < h; line++) { 4144261fa58Smacallan x = 0; 4154261fa58Smacallan while (x < w) { 4164261fa58Smacallan ptr = start + x; 4174261fa58Smacallan num = min(32, w - x); 4184261fa58Smacallan /* now suck fb data into registers */ 4194261fa58Smacallan write_sx_io(p, ptr, 4204261fa58Smacallan SX_LDB(42, num - 1, off)); 4214261fa58Smacallan /* 4224261fa58Smacallan * ROP them with the fill data we left in 10 4234261fa58Smacallan * non-memory ops can only have counts up to 16 4244261fa58Smacallan */ 4254261fa58Smacallan if (num <= 16) { 4264261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 4274261fa58Smacallan SX_ROP(10, 42, 74, num - 1)); 4284261fa58Smacallan } else { 4294261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 4304261fa58Smacallan SX_ROP(10, 42, 74, 15)); 4314261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 4324261fa58Smacallan SX_ROP(10, 58, 90, num - 17)); 4334261fa58Smacallan } 4344261fa58Smacallan /* and write the result back into memory */ 4354261fa58Smacallan write_sx_io(p, ptr, 4364261fa58Smacallan SX_STB(74, num - 1, off)); 4374261fa58Smacallan x += 32; 4384261fa58Smacallan } 4394261fa58Smacallan start += pitch; 4404261fa58Smacallan } 4414261fa58Smacallan } 4424261fa58Smacallan} 4434261fa58Smacallan 4444261fa58Smacallanstatic void 4454261fa58SmacallanCG14Solid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2) 4464261fa58Smacallan{ 4474261fa58Smacallan ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; 4484261fa58Smacallan Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); 4494261fa58Smacallan int w = x2 - x1, h = y2 - y1, dstoff, dstpitch; 4504261fa58Smacallan int start, depth; 4514261fa58Smacallan 4524261fa58Smacallan ENTER; 4534261fa58Smacallan dstpitch = exaGetPixmapPitch(pPixmap); 4544261fa58Smacallan dstoff = exaGetPixmapOffset(pPixmap); 4554261fa58Smacallan 4564261fa58Smacallan depth = pPixmap->drawable.bitsPerPixel; 4574261fa58Smacallan switch (depth) { 4584261fa58Smacallan case 32: 4594261fa58Smacallan start = dstoff + (y1 * dstpitch) + (x1 << 2); 4604261fa58Smacallan CG14Solid32(p, start, dstpitch, w, h); 4614261fa58Smacallan break; 4624261fa58Smacallan case 8: 4634261fa58Smacallan start = dstoff + (y1 * dstpitch) + x1; 4644261fa58Smacallan CG14Solid8(p, start, dstpitch, w, h); 4654261fa58Smacallan break; 4664261fa58Smacallan } 4674261fa58Smacallan 4684261fa58Smacallan DPRINTF(X_ERROR, "Solid %d %d %d %d, %d %d -> %d\n", x1, y1, x2, y2, 4694261fa58Smacallan dstpitch, dstoff, start); 4704261fa58Smacallan DPRINTF(X_ERROR, "%x %x %x\n", p->last_rop, 4714261fa58Smacallan read_sx_reg(p, SX_QUEUED(8)), read_sx_reg(p, SX_QUEUED(9))); 4724261fa58Smacallan exaMarkSync(pPixmap->drawable.pScreen); 4734261fa58Smacallan} 4744261fa58Smacallan 4754261fa58Smacallan/* 4764261fa58Smacallan * Memcpy-based UTS. 4774261fa58Smacallan */ 4784261fa58Smacallanstatic Bool 4794261fa58SmacallanCG14UploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, 4804261fa58Smacallan char *src, int src_pitch) 4814261fa58Smacallan{ 4824261fa58Smacallan ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; 4834261fa58Smacallan Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); 4844261fa58Smacallan char *dst = p->fb + exaGetPixmapOffset(pDst); 4854261fa58Smacallan int dst_pitch = exaGetPixmapPitch(pDst); 4864261fa58Smacallan 4874261fa58Smacallan int bpp = pDst->drawable.bitsPerPixel; 4884261fa58Smacallan int cpp = (bpp + 7) >> 3; 4894261fa58Smacallan int wBytes = w * cpp; 4904261fa58Smacallan 4914261fa58Smacallan ENTER; 4924261fa58Smacallan dst += (x * cpp) + (y * dst_pitch); 4934261fa58Smacallan 4944261fa58Smacallan CG14Wait(p); 4954261fa58Smacallan 4964261fa58Smacallan while (h--) { 4974261fa58Smacallan memcpy(dst, src, wBytes); 4984261fa58Smacallan src += src_pitch; 4994261fa58Smacallan dst += dst_pitch; 5004261fa58Smacallan } 5014261fa58Smacallan __asm("stbar;"); 5024261fa58Smacallan return TRUE; 5034261fa58Smacallan} 5044261fa58Smacallan 5054261fa58Smacallan/* 5064261fa58Smacallan * Memcpy-based DFS. 5074261fa58Smacallan */ 5084261fa58Smacallanstatic Bool 5094261fa58SmacallanCG14DownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, 5104261fa58Smacallan char *dst, int dst_pitch) 5114261fa58Smacallan{ 5124261fa58Smacallan ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum]; 5134261fa58Smacallan Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); 5144261fa58Smacallan char *src = p->fb + exaGetPixmapOffset(pSrc); 5154261fa58Smacallan int src_pitch = exaGetPixmapPitch(pSrc); 5164261fa58Smacallan 5174261fa58Smacallan ENTER; 5184261fa58Smacallan int bpp = pSrc->drawable.bitsPerPixel; 5194261fa58Smacallan int cpp = (bpp + 7) >> 3; 5204261fa58Smacallan int wBytes = w * cpp; 5214261fa58Smacallan 5224261fa58Smacallan src += (x * cpp) + (y * src_pitch); 5234261fa58Smacallan 5244261fa58Smacallan CG14Wait(p); 5254261fa58Smacallan 5264261fa58Smacallan while (h--) { 5274261fa58Smacallan memcpy(dst, src, wBytes); 5284261fa58Smacallan src += src_pitch; 5294261fa58Smacallan dst += dst_pitch; 5304261fa58Smacallan } 5314261fa58Smacallan 5324261fa58Smacallan return TRUE; 5334261fa58Smacallan} 5344261fa58Smacallan 5354261fa58SmacallanBool 5364261fa58SmacallanCG14CheckComposite(int op, PicturePtr pSrcPicture, 5374261fa58Smacallan PicturePtr pMaskPicture, 5384261fa58Smacallan PicturePtr pDstPicture) 5394261fa58Smacallan{ 5404261fa58Smacallan int i, ok = FALSE; 5414261fa58Smacallan 5424261fa58Smacallan ENTER; 5434261fa58Smacallan 5444261fa58Smacallan /* 5454261fa58Smacallan * SX is in theory capable of accelerating pretty much all Xrender ops, 5464261fa58Smacallan * even coordinate transformation and gradients. Support will be added 5474261fa58Smacallan * over time and likely have to spill over into its own source file. 5484261fa58Smacallan */ 5494261fa58Smacallan 550a3a2ba44Smacallan if ((op != PictOpOver) && (op != PictOpAdd) && (op != PictOpSrc)) { 5514261fa58Smacallan xf86Msg(X_ERROR, "%s: rejecting %d\n", __func__, op); 5524261fa58Smacallan return FALSE; 5534261fa58Smacallan } 5544261fa58Smacallan i = 0; 5554261fa58Smacallan while ((i < arraysize(src_formats)) && (!ok)) { 5564261fa58Smacallan ok = (pSrcPicture->format == src_formats[i]); 5574261fa58Smacallan i++; 5584261fa58Smacallan } 5594261fa58Smacallan 5604261fa58Smacallan if (!ok) { 5614261fa58Smacallan xf86Msg(X_ERROR, "%s: unsupported src format %x\n", 5624261fa58Smacallan __func__, pSrcPicture->format); 5634261fa58Smacallan return FALSE; 5644261fa58Smacallan } 5654261fa58Smacallan 566a3a2ba44Smacallan DPRINTF(X_ERROR, "src is %x, %d: %d %d\n", pSrcPicture->format, op, 5674261fa58Smacallan pSrcPicture->pDrawable->width, pSrcPicture->pDrawable->height); 5684261fa58Smacallan 5694261fa58Smacallan if (pMaskPicture != NULL) { 5704261fa58Smacallan DPRINTF(X_ERROR, "mask is %x %d %d\n", pMaskPicture->format, 5714261fa58Smacallan pMaskPicture->pDrawable->width, 5724261fa58Smacallan pMaskPicture->pDrawable->height); 5734261fa58Smacallan } 5744261fa58Smacallan return TRUE; 5754261fa58Smacallan} 5764261fa58Smacallan 5774261fa58SmacallanBool 5784261fa58SmacallanCG14PrepareComposite(int op, PicturePtr pSrcPicture, 5794261fa58Smacallan PicturePtr pMaskPicture, 5804261fa58Smacallan PicturePtr pDstPicture, 5814261fa58Smacallan PixmapPtr pSrc, 5824261fa58Smacallan PixmapPtr pMask, 5834261fa58Smacallan PixmapPtr pDst) 5844261fa58Smacallan{ 5854261fa58Smacallan ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; 5864261fa58Smacallan Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); 5874261fa58Smacallan 5884261fa58Smacallan ENTER; 5894261fa58Smacallan 590f7cb851fSmacallan p->no_source_pixmap = FALSE; 591f7cb851fSmacallan p->source_is_solid = FALSE; 592f7cb851fSmacallan 593a3a2ba44Smacallan if (pSrcPicture->format == PICT_a1) { 5946bdc2ffdSmacallan xf86Msg(X_ERROR, "src mono, dst %x, op %d\n", 5956bdc2ffdSmacallan pDstPicture->format, op); 596a3a2ba44Smacallan if (pMaskPicture != NULL) { 597a3a2ba44Smacallan xf86Msg(X_ERROR, "msk %x\n", pMaskPicture->format); 598a3a2ba44Smacallan } 599f7cb851fSmacallan } 6004261fa58Smacallan if (pSrcPicture->pSourcePict != NULL) { 6014261fa58Smacallan if (pSrcPicture->pSourcePict->type == SourcePictTypeSolidFill) { 6024261fa58Smacallan p->fillcolour = 6034261fa58Smacallan pSrcPicture->pSourcePict->solidFill.color; 604f7cb851fSmacallan DPRINTF(X_ERROR, "%s: solid src %08x\n", 6054261fa58Smacallan __func__, p->fillcolour); 606f7cb851fSmacallan p->no_source_pixmap = TRUE; 607f7cb851fSmacallan p->source_is_solid = TRUE; 6084261fa58Smacallan } 6094261fa58Smacallan } 6104261fa58Smacallan if ((pMaskPicture != NULL) && (pMaskPicture->pSourcePict != NULL)) { 6114261fa58Smacallan if (pMaskPicture->pSourcePict->type == 6124261fa58Smacallan SourcePictTypeSolidFill) { 6134261fa58Smacallan p->fillcolour = 6144261fa58Smacallan pMaskPicture->pSourcePict->solidFill.color; 615a3a2ba44Smacallan xf86Msg(X_ERROR, "%s: solid mask %08x\n", 6164261fa58Smacallan __func__, p->fillcolour); 6174261fa58Smacallan } 6184261fa58Smacallan } 6194261fa58Smacallan if (pMaskPicture != NULL) { 620239808baSmacallan p->mskoff = exaGetPixmapOffset(pMask); 6214261fa58Smacallan p->mskpitch = exaGetPixmapPitch(pMask); 6224261fa58Smacallan p->mskformat = pMaskPicture->format; 623a3a2ba44Smacallan } else { 624239808baSmacallan p->mskoff = 0; 625a3a2ba44Smacallan p->mskpitch = 0; 626a3a2ba44Smacallan p->mskformat = 0; 6274261fa58Smacallan } 628f7cb851fSmacallan if (pSrc != NULL) { 629f7cb851fSmacallan p->source_is_solid = 630f7cb851fSmacallan ((pSrc->drawable.width == 1) && (pSrc->drawable.height == 1)); 631f7cb851fSmacallan p->srcoff = exaGetPixmapOffset(pSrc); 632f7cb851fSmacallan p->srcpitch = exaGetPixmapPitch(pSrc); 633f7cb851fSmacallan if (p->source_is_solid) { 634f7cb851fSmacallan p->fillcolour = *(uint32_t *)(p->fb + p->srcoff); 635f7cb851fSmacallan } 636f7cb851fSmacallan } 6374261fa58Smacallan p->srcformat = pSrcPicture->format; 6384261fa58Smacallan p->dstformat = pDstPicture->format; 639f7cb851fSmacallan 640f7cb851fSmacallan if (p->source_is_solid) { 641f7cb851fSmacallan uint32_t temp; 642f7cb851fSmacallan 643f7cb851fSmacallan /* stuff source colour into SX registers, swap as needed */ 644f7cb851fSmacallan temp = p->fillcolour; 645f7cb851fSmacallan switch (p->srcformat) { 646f7cb851fSmacallan case PICT_a8r8g8b8: 647f7cb851fSmacallan case PICT_x8r8g8b8: 648f7cb851fSmacallan write_sx_reg(p, SX_QUEUED(9), temp & 0xff); 649f7cb851fSmacallan temp = temp >> 8; 650f7cb851fSmacallan write_sx_reg(p, SX_QUEUED(10), temp & 0xff); 651f7cb851fSmacallan temp = temp >> 8; 652f7cb851fSmacallan write_sx_reg(p, SX_QUEUED(11), temp & 0xff); 653f7cb851fSmacallan break; 654f7cb851fSmacallan case PICT_a8b8g8r8: 655f7cb851fSmacallan case PICT_x8b8g8r8: 656f7cb851fSmacallan write_sx_reg(p, SX_QUEUED(11), temp & 0xff); 657f7cb851fSmacallan temp = temp >> 8; 658f7cb851fSmacallan write_sx_reg(p, SX_QUEUED(10), temp & 0xff); 659f7cb851fSmacallan temp = temp >> 8; 660f7cb851fSmacallan write_sx_reg(p, SX_QUEUED(9), temp & 0xff); 661f7cb851fSmacallan break; 662f7cb851fSmacallan } 663f7cb851fSmacallan write_sx_reg(p, SX_QUEUED(8), 0xff); 664f7cb851fSmacallan } 6654261fa58Smacallan p->op = op; 666a3a2ba44Smacallan if (op == PictOpSrc) { 667a3a2ba44Smacallan CG14PrepareCopy(pSrc, pDst, 1, 1, GXcopy, 0xffffffff); 668a3a2ba44Smacallan } 6694261fa58Smacallan#ifdef SX_DEBUG 6704261fa58Smacallan DPRINTF(X_ERROR, "%x %x -> %x\n", p->srcoff, p->mskoff, 6714261fa58Smacallan *(uint32_t *)(p->fb + p->srcoff)); 6724261fa58Smacallan#endif 6734261fa58Smacallan return TRUE; 6744261fa58Smacallan} 6754261fa58Smacallan 6764261fa58Smacallanvoid 6774261fa58SmacallanCG14Composite(PixmapPtr pDst, int srcX, int srcY, 6784261fa58Smacallan int maskX, int maskY, 6794261fa58Smacallan int dstX, int dstY, 6804261fa58Smacallan int width, int height) 6814261fa58Smacallan{ 6824261fa58Smacallan ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; 6834261fa58Smacallan Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); 6844261fa58Smacallan uint32_t dstoff, dstpitch; 6854261fa58Smacallan uint32_t dst, msk, src; 6864261fa58Smacallan 6874261fa58Smacallan ENTER; 6884261fa58Smacallan dstoff = exaGetPixmapOffset(pDst); 6894261fa58Smacallan dstpitch = exaGetPixmapPitch(pDst); 6904261fa58Smacallan 6914261fa58Smacallan switch (p->op) { 6924261fa58Smacallan case PictOpOver: 6934261fa58Smacallan dst = dstoff + (dstY * dstpitch) + (dstX << 2); 6944261fa58Smacallan DPRINTF(X_ERROR, "Over %08x %08x, %d %d\n", 6954261fa58Smacallan p->mskformat, p->dstformat, srcX, srcY); 696a3a2ba44Smacallan if (p->source_is_solid) { 697a3a2ba44Smacallan switch (p->mskformat) { 698a3a2ba44Smacallan case PICT_a8: 699a3a2ba44Smacallan msk = p->mskoff + 700a3a2ba44Smacallan (maskY * p->mskpitch) + 701a3a2ba44Smacallan maskX; 702a3a2ba44Smacallan CG14Comp_Over8Solid(p, 703a3a2ba44Smacallan msk, p->mskpitch, 704a3a2ba44Smacallan dst, dstpitch, 705a3a2ba44Smacallan width, height); 706a3a2ba44Smacallan break; 707a3a2ba44Smacallan case PICT_a8r8g8b8: 708a3a2ba44Smacallan case PICT_a8b8g8r8: 709a3a2ba44Smacallan msk = p->mskoff + 710a3a2ba44Smacallan (maskY * p->mskpitch) + 711a3a2ba44Smacallan (maskX << 2); 712a3a2ba44Smacallan CG14Comp_Over32Solid(p, 713a3a2ba44Smacallan msk, p->mskpitch, 714a3a2ba44Smacallan dst, dstpitch, 715a3a2ba44Smacallan width, height); 716a3a2ba44Smacallan break; 717a3a2ba44Smacallan default: 718a3a2ba44Smacallan xf86Msg(X_ERROR, 7196bdc2ffdSmacallan "unsupported mask format\n"); 720a3a2ba44Smacallan } 721a3a2ba44Smacallan } else { 7226bdc2ffdSmacallan DPRINTF(X_ERROR, "non-solid over with msk %x\n", 7236bdc2ffdSmacallan p->mskformat); 724a3a2ba44Smacallan switch (p->srcformat) { 725a3a2ba44Smacallan case PICT_a8r8g8b8: 726a3a2ba44Smacallan case PICT_a8b8g8r8: 727a3a2ba44Smacallan src = p->srcoff + 728a3a2ba44Smacallan (srcY * p->srcpitch) + 729a3a2ba44Smacallan (srcX << 2); 730a3a2ba44Smacallan dst = dstoff + 731a3a2ba44Smacallan (dstY * dstpitch) + 732a3a2ba44Smacallan (dstX << 2); 733a3a2ba44Smacallan if (p->mskformat == PICT_a8) { 734a3a2ba44Smacallan msk = p->mskoff + 735a3a2ba44Smacallan (maskY * p->mskpitch) + 736a3a2ba44Smacallan maskX; 737a3a2ba44Smacallan CG14Comp_Over32Mask(p, 738a3a2ba44Smacallan src, p->srcpitch, 739a3a2ba44Smacallan msk, p->mskpitch, 740a3a2ba44Smacallan dst, dstpitch, 741a3a2ba44Smacallan width, height); 742a3a2ba44Smacallan } else { 743a3a2ba44Smacallan CG14Comp_Over32(p, 744a3a2ba44Smacallan src, p->srcpitch, 745a3a2ba44Smacallan dst, dstpitch, 746a3a2ba44Smacallan width, height); 747a3a2ba44Smacallan } 748a3a2ba44Smacallan break; 749a3a2ba44Smacallan case PICT_x8r8g8b8: 750a3a2ba44Smacallan case PICT_x8b8g8r8: 7516bdc2ffdSmacallan src = p->srcoff + 7526bdc2ffdSmacallan (srcY * p->srcpitch) + 7536bdc2ffdSmacallan (srcX << 2); 7546bdc2ffdSmacallan dst = dstoff + 7556bdc2ffdSmacallan (dstY * dstpitch) + 7566bdc2ffdSmacallan (dstX << 2); 7576bdc2ffdSmacallan if (p->mskformat == PICT_a8) { 7586bdc2ffdSmacallan msk = p->mskoff + 7596bdc2ffdSmacallan (maskY * p->mskpitch) + 7606bdc2ffdSmacallan maskX; 7616bdc2ffdSmacallan CG14Comp_Over32Mask_noalpha(p, 7626bdc2ffdSmacallan src, p->srcpitch, 7636bdc2ffdSmacallan msk, p->mskpitch, 764fa158432Smacallan dst, dstpitch, 765fa158432Smacallan width, height); 766fa158432Smacallan } else if ((p->mskformat == PICT_a8r8g8b8) || 767fa158432Smacallan (p->mskformat == PICT_a8b8g8r8)) { 768fa158432Smacallan msk = p->mskoff + 769fa158432Smacallan (maskY * p->mskpitch) + 770fa158432Smacallan (maskX << 2); 771fa158432Smacallan CG14Comp_Over32Mask32_noalpha(p, 772fa158432Smacallan src, p->srcpitch, 773fa158432Smacallan msk, p->mskpitch, 7746bdc2ffdSmacallan dst, dstpitch, 7756bdc2ffdSmacallan width, height); 7766bdc2ffdSmacallan } else { 7776bdc2ffdSmacallan xf86Msg(X_ERROR, "no src alpha, mask is %x\n", p->mskformat); 7786bdc2ffdSmacallan } 779a3a2ba44Smacallan break; 780a3a2ba44Smacallan default: 781a3a2ba44Smacallan xf86Msg(X_ERROR, "%s: format %x in non-solid Over op\n", 782a3a2ba44Smacallan __func__, p->srcformat); 783a3a2ba44Smacallan } 784a3a2ba44Smacallan } 7854261fa58Smacallan break; 7864261fa58Smacallan case PictOpAdd: 7874261fa58Smacallan DPRINTF(X_ERROR, "Add %08x %08x\n", 7884261fa58Smacallan p->srcformat, p->dstformat); 7894261fa58Smacallan switch (p->srcformat) { 7904261fa58Smacallan case PICT_a8: 7914261fa58Smacallan src = p->srcoff + 7924261fa58Smacallan (srcY * p->srcpitch) + srcX; 7934261fa58Smacallan dst = dstoff + (dstY * dstpitch) + dstX; 7944261fa58Smacallan CG14Comp_Add8(p, src, p->srcpitch, 7954261fa58Smacallan dst, dstpitch, width, height); 7964261fa58Smacallan break; 7974261fa58Smacallan case PICT_a8r8g8b8: 7984261fa58Smacallan case PICT_x8r8g8b8: 7994261fa58Smacallan src = p->srcoff + 8004261fa58Smacallan (srcY * p->srcpitch) + (srcX << 2); 8014261fa58Smacallan dst = dstoff + (dstY * dstpitch) + 8024261fa58Smacallan (dstX << 2); 8034261fa58Smacallan CG14Comp_Add32(p, src, p->srcpitch, 8044261fa58Smacallan dst, dstpitch, width, height); 8054261fa58Smacallan break; 8064261fa58Smacallan default: 8074261fa58Smacallan xf86Msg(X_ERROR, 8084261fa58Smacallan "unsupported src format\n"); 8094261fa58Smacallan } 8104261fa58Smacallan break; 811a3a2ba44Smacallan case PictOpSrc: 812a3a2ba44Smacallan DPRINTF(X_ERROR, "Src %08x %08x\n", 813a3a2ba44Smacallan p->srcformat, p->dstformat); 814239808baSmacallan if (p->mskformat != 0) 815239808baSmacallan xf86Msg(X_ERROR, "Src mask %08x\n", p->mskformat); 816a3a2ba44Smacallan CG14Copy(pDst, srcX, srcY, dstX, dstY, width, height); 817a3a2ba44Smacallan break; 8184261fa58Smacallan default: 8194261fa58Smacallan xf86Msg(X_ERROR, "unsupported op %d\n", p->op); 8204261fa58Smacallan } 8214261fa58Smacallan exaMarkSync(pDst->drawable.pScreen); 8224261fa58Smacallan} 8234261fa58Smacallan 8244261fa58Smacallan 8254261fa58Smacallan 8264261fa58SmacallanBool 8274261fa58SmacallanCG14InitAccel(ScreenPtr pScreen) 8284261fa58Smacallan{ 8294261fa58Smacallan ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; 8304261fa58Smacallan Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); 8314261fa58Smacallan ExaDriverPtr pExa; 8324261fa58Smacallan 8334261fa58Smacallan pExa = exaDriverAlloc(); 8344261fa58Smacallan if (!pExa) 8354261fa58Smacallan return FALSE; 8364261fa58Smacallan 8374261fa58Smacallan p->pExa = pExa; 8384261fa58Smacallan 8394261fa58Smacallan pExa->exa_major = EXA_VERSION_MAJOR; 8404261fa58Smacallan pExa->exa_minor = EXA_VERSION_MINOR; 8414261fa58Smacallan 8424261fa58Smacallan pExa->memoryBase = p->fb; 8434261fa58Smacallan pExa->memorySize = p->memsize; 8444261fa58Smacallan pExa->offScreenBase = p->width * p->height * 4; 8454261fa58Smacallan 8464261fa58Smacallan /* 8474261fa58Smacallan * SX memory instructions are written to 64bit aligned addresses with 8484261fa58Smacallan * a 3 bit displacement. Make sure the displacement remains constant 8494261fa58Smacallan * within one column 8504261fa58Smacallan */ 8514261fa58Smacallan 8524261fa58Smacallan pExa->pixmapOffsetAlign = 8; 8534261fa58Smacallan pExa->pixmapPitchAlign = 8; 8544261fa58Smacallan 8554261fa58Smacallan pExa->flags = EXA_OFFSCREEN_PIXMAPS | 8564261fa58Smacallan /*EXA_SUPPORTS_OFFSCREEN_OVERLAPS |*/ 8574261fa58Smacallan EXA_MIXED_PIXMAPS; 8584261fa58Smacallan 8594261fa58Smacallan /* 8604261fa58Smacallan * these limits are bogus 8614261fa58Smacallan * SX doesn't deal with coordinates at all, so there is no limit but 8624261fa58Smacallan * we have to put something here 8634261fa58Smacallan */ 8644261fa58Smacallan pExa->maxX = 4096; 8654261fa58Smacallan pExa->maxY = 4096; 8664261fa58Smacallan 8674261fa58Smacallan pExa->WaitMarker = CG14WaitMarker; 8684261fa58Smacallan 8694261fa58Smacallan pExa->PrepareSolid = CG14PrepareSolid; 8704261fa58Smacallan pExa->Solid = CG14Solid; 8714261fa58Smacallan pExa->DoneSolid = CG14DoneCopy; 8724261fa58Smacallan pExa->PrepareCopy = CG14PrepareCopy; 8734261fa58Smacallan pExa->Copy = CG14Copy; 8744261fa58Smacallan pExa->DoneCopy = CG14DoneCopy; 8754261fa58Smacallan if (p->use_xrender) { 8764261fa58Smacallan pExa->CheckComposite = CG14CheckComposite; 8774261fa58Smacallan pExa->PrepareComposite = CG14PrepareComposite; 8784261fa58Smacallan pExa->Composite = CG14Composite; 8794261fa58Smacallan pExa->DoneComposite = CG14DoneCopy; 8804261fa58Smacallan } 8814261fa58Smacallan 8824261fa58Smacallan /* EXA hits more optimized paths when it does not have to fallback 8834261fa58Smacallan * because of missing UTS/DFS, hook memcpy-based UTS/DFS. 8844261fa58Smacallan */ 8854261fa58Smacallan pExa->UploadToScreen = CG14UploadToScreen; 8864261fa58Smacallan pExa->DownloadFromScreen = CG14DownloadFromScreen; 8874261fa58Smacallan 8884261fa58Smacallan /* do some hardware init */ 8894261fa58Smacallan write_sx_reg(p, SX_PLANEMASK, 0xffffffff); 8904261fa58Smacallan p->last_mask = 0xffffffff; 8914261fa58Smacallan write_sx_reg(p, SX_ROP_CONTROL, 0xcc); 8924261fa58Smacallan p->last_rop = 0xcc; 8934261fa58Smacallan return exaDriverInit(pScreen, pExa); 8944261fa58Smacallan} 895