cg14_accel.c revision f7cb851f
1f7cb851fSmacallan/* $NetBSD: cg14_accel.c,v 1.5 2013/07/03 15:29:34 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 */ 314261fa58Smacallan 324261fa58Smacallan#include <sys/types.h> 334261fa58Smacallan 344261fa58Smacallan/* all driver need this */ 354261fa58Smacallan#include "xf86.h" 364261fa58Smacallan#include "xf86_OSproc.h" 374261fa58Smacallan#include "compiler.h" 384261fa58Smacallan 394261fa58Smacallan#include "cg14.h" 404261fa58Smacallan#include <sparc/sxreg.h> 414261fa58Smacallan 424261fa58Smacallan#define SX_SINGLE 434261fa58Smacallan/*#define SX_DEBUG*/ 444261fa58Smacallan/*#define SX_ADD_SOFTWARE*/ 454261fa58Smacallan 464261fa58Smacallan#ifdef SX_DEBUG 474261fa58Smacallan#define ENTER xf86Msg(X_ERROR, "%s>\n", __func__); 484261fa58Smacallan#define DPRINTF xf86Msg 494261fa58Smacallan#else 504261fa58Smacallan#define ENTER 514261fa58Smacallan#define DPRINTF while (0) xf86Msg 524261fa58Smacallan#endif 534261fa58Smacallan 544261fa58Smacallan#define arraysize(ary) (sizeof(ary) / sizeof(ary[0])) 554261fa58Smacallan 564261fa58Smacallan/* 0xcc is SX's GXcopy equivalent */ 574261fa58Smacallanuint32_t sx_rop[] = { 0x00, 0x88, 0x44, 0xcc, 0x22, 0xaa, 0x66, 0xee, 584261fa58Smacallan 0x11, 0x99, 0x55, 0xdd, 0x33, 0xbb, 0x77, 0xff}; 594261fa58Smacallan 604261fa58Smacallanint src_formats[] = {PICT_a8r8g8b8, PICT_x8r8g8b8, 614261fa58Smacallan PICT_a8b8g8r8, PICT_x8b8g8r8, PICT_a8}; 624261fa58Smacallanint tex_formats[] = {PICT_a8r8g8b8, PICT_a8b8g8r8, PICT_a8}; 634261fa58Smacallan 644261fa58Smacallanstatic inline void 654261fa58SmacallanCG14Wait(Cg14Ptr p) 664261fa58Smacallan{ 674261fa58Smacallan /* we just wait until the instruction queue is empty */ 684261fa58Smacallan while ((read_sx_reg(p, SX_CONTROL_STATUS) & SX_MT) != 0) {}; 694261fa58Smacallan} 704261fa58Smacallan 714261fa58Smacallanstatic void 724261fa58SmacallanCG14WaitMarker(ScreenPtr pScreen, int Marker) 734261fa58Smacallan{ 744261fa58Smacallan ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; 754261fa58Smacallan Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); 764261fa58Smacallan 774261fa58Smacallan CG14Wait(p); 784261fa58Smacallan} 794261fa58Smacallan 804261fa58Smacallanstatic Bool 814261fa58SmacallanCG14PrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, 824261fa58Smacallan int xdir, int ydir, int alu, Pixel planemask) 834261fa58Smacallan{ 844261fa58Smacallan ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; 854261fa58Smacallan Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); 864261fa58Smacallan 874261fa58Smacallan ENTER; 884261fa58Smacallan DPRINTF(X_ERROR, "bits per pixel: %d\n", 894261fa58Smacallan pSrcPixmap->drawable.bitsPerPixel); 904261fa58Smacallan 914261fa58Smacallan if (planemask != p->last_mask) { 924261fa58Smacallan CG14Wait(p); 934261fa58Smacallan write_sx_reg(p, SX_PLANEMASK, planemask); 944261fa58Smacallan p->last_mask = planemask; 954261fa58Smacallan } 964261fa58Smacallan alu = sx_rop[alu]; 974261fa58Smacallan if (alu != p->last_rop) { 984261fa58Smacallan CG14Wait(p); 994261fa58Smacallan write_sx_reg(p, SX_ROP_CONTROL, alu); 1004261fa58Smacallan p->last_rop = alu; 1014261fa58Smacallan } 1024261fa58Smacallan p->srcpitch = exaGetPixmapPitch(pSrcPixmap); 1034261fa58Smacallan p->srcoff = exaGetPixmapOffset(pSrcPixmap); 1044261fa58Smacallan p->xdir = xdir; 1054261fa58Smacallan p->ydir = ydir; 1064261fa58Smacallan return TRUE; 1074261fa58Smacallan} 1084261fa58Smacallan 1094261fa58Smacallanstatic void 1104261fa58SmacallanCG14Copy(PixmapPtr pDstPixmap, 1114261fa58Smacallan int srcX, int srcY, int dstX, int dstY, int w, int h) 1124261fa58Smacallan{ 1134261fa58Smacallan ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; 1144261fa58Smacallan Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); 1154261fa58Smacallan int dstpitch, dstoff, srcpitch, srcoff; 1164261fa58Smacallan int srcstart, dststart, xinc, srcinc, dstinc; 1174261fa58Smacallan int line, count, s, d, num; 1184261fa58Smacallan 1194261fa58Smacallan ENTER; 1204261fa58Smacallan dstpitch = exaGetPixmapPitch(pDstPixmap); 1214261fa58Smacallan dstoff = exaGetPixmapOffset(pDstPixmap); 1224261fa58Smacallan srcpitch = p->srcpitch; 1234261fa58Smacallan srcoff = p->srcoff; 1244261fa58Smacallan /* 1254261fa58Smacallan * should clear the WO bit in SX_CONTROL_STATUS, then check if SX 1264261fa58Smacallan * actually wrote anything and only sync if it did 1274261fa58Smacallan */ 1284261fa58Smacallan srcstart = (srcX << 2) + (srcpitch * srcY) + srcoff; 1294261fa58Smacallan dststart = (dstX << 2) + (dstpitch * dstY) + dstoff; 1304261fa58Smacallan 1314261fa58Smacallan /* 1324261fa58Smacallan * we always copy up to 32 pixels at a time so direction doesn't 1334261fa58Smacallan * matter if w<=32 1344261fa58Smacallan */ 1354261fa58Smacallan if (w > 32) { 1364261fa58Smacallan if (p->xdir < 0) { 1374261fa58Smacallan srcstart += (w - 32) << 2; 1384261fa58Smacallan dststart += (w - 32) << 2; 1394261fa58Smacallan xinc = -128; 1404261fa58Smacallan } else 1414261fa58Smacallan xinc = 128; 1424261fa58Smacallan } else 1434261fa58Smacallan xinc = 128; 1444261fa58Smacallan if (p->ydir < 0) { 1454261fa58Smacallan srcstart += (h - 1) * srcpitch; 1464261fa58Smacallan dststart += (h - 1) * dstpitch; 1474261fa58Smacallan srcinc = -srcpitch; 1484261fa58Smacallan dstinc = -dstpitch; 1494261fa58Smacallan } else { 1504261fa58Smacallan srcinc = srcpitch; 1514261fa58Smacallan dstinc = dstpitch; 1524261fa58Smacallan } 1534261fa58Smacallan if (p->last_rop == 0xcc) { 1544261fa58Smacallan /* plain old copy */ 1554261fa58Smacallan if ( xinc > 0) { 1564261fa58Smacallan /* going left to right */ 1574261fa58Smacallan for (line = 0; line < h; line++) { 1584261fa58Smacallan count = 0; 1594261fa58Smacallan s = srcstart; 1604261fa58Smacallan d = dststart; 1614261fa58Smacallan while ( count < w) { 1624261fa58Smacallan num = min(32, w - count); 1634261fa58Smacallan write_sx_io(p, s, 1644261fa58Smacallan SX_LD(10, num - 1, s & 7)); 1654261fa58Smacallan write_sx_io(p, d, 1664261fa58Smacallan SX_STM(10, num - 1, d & 7)); 1674261fa58Smacallan s += xinc; 1684261fa58Smacallan d += xinc; 1694261fa58Smacallan count += 32; 1704261fa58Smacallan } 1714261fa58Smacallan srcstart += srcinc; 1724261fa58Smacallan dststart += dstinc; 1734261fa58Smacallan } 1744261fa58Smacallan } else { 1754261fa58Smacallan /* going right to left */ 1764261fa58Smacallan int i, chunks = (w >> 5); 1774261fa58Smacallan for (line = 0; line < h; line++) { 1784261fa58Smacallan s = srcstart; 1794261fa58Smacallan d = dststart; 1804261fa58Smacallan count = w; 1814261fa58Smacallan for (i = 0; i < chunks; i++) { 1824261fa58Smacallan write_sx_io(p, s, 1834261fa58Smacallan SX_LD(10, 31, s & 7)); 1844261fa58Smacallan write_sx_io(p, d, 1854261fa58Smacallan SX_STM(10, 31, d & 7)); 1864261fa58Smacallan s -= 128; 1874261fa58Smacallan d -= 128; 1884261fa58Smacallan count -= 32; 1894261fa58Smacallan } 1904261fa58Smacallan /* leftovers, if any */ 1914261fa58Smacallan if (count > 0) { 1924261fa58Smacallan s += (32 - count) << 2; 1934261fa58Smacallan d += (32 - count) << 2; 1944261fa58Smacallan write_sx_io(p, s, 1954261fa58Smacallan SX_LD(10, count - 1, s & 7)); 1964261fa58Smacallan write_sx_io(p, d, 1974261fa58Smacallan SX_STM(10, count - 1, d & 7)); 1984261fa58Smacallan } 1994261fa58Smacallan srcstart += srcinc; 2004261fa58Smacallan dststart += dstinc; 2014261fa58Smacallan } 2024261fa58Smacallan } 2034261fa58Smacallan } else { 2044261fa58Smacallan /* ROPs needed */ 2054261fa58Smacallan if ( xinc > 0) { 2064261fa58Smacallan /* going left to right */ 2074261fa58Smacallan for (line = 0; line < h; line++) { 2084261fa58Smacallan count = 0; 2094261fa58Smacallan s = srcstart; 2104261fa58Smacallan d = dststart; 2114261fa58Smacallan while ( count < w) { 2124261fa58Smacallan num = min(32, w - count); 2134261fa58Smacallan write_sx_io(p, s, 2144261fa58Smacallan SX_LD(10, num - 1, s & 7)); 2154261fa58Smacallan write_sx_io(p, d, 2164261fa58Smacallan SX_LD(42, num - 1, d & 7)); 2174261fa58Smacallan if (num > 16) { 2184261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 2194261fa58Smacallan SX_ROP(10, 42, 74, 15)); 2204261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 2214261fa58Smacallan SX_ROP(26, 58, 90, num - 17)); 2224261fa58Smacallan } else { 2234261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 2244261fa58Smacallan SX_ROP(10, 42, 74, num - 1)); 2254261fa58Smacallan } 2264261fa58Smacallan write_sx_io(p, d, 2274261fa58Smacallan SX_STM(74, num - 1, d & 7)); 2284261fa58Smacallan s += xinc; 2294261fa58Smacallan d += xinc; 2304261fa58Smacallan count += 32; 2314261fa58Smacallan } 2324261fa58Smacallan srcstart += srcinc; 2334261fa58Smacallan dststart += dstinc; 2344261fa58Smacallan } 2354261fa58Smacallan } else { 2364261fa58Smacallan /* going right to left */ 2374261fa58Smacallan int i, chunks = (w >> 5); 2384261fa58Smacallan for (line = 0; line < h; line++) { 2394261fa58Smacallan s = srcstart; 2404261fa58Smacallan d = dststart; 2414261fa58Smacallan count = w; 2424261fa58Smacallan for (i = 0; i < chunks; i++) { 2434261fa58Smacallan write_sx_io(p, s, SX_LD(10, 31, s & 7)); 2444261fa58Smacallan write_sx_io(p, d, SX_LD(42, 31, d & 7)); 2454261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 2464261fa58Smacallan SX_ROP(10, 42, 74, 15)); 2474261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 2484261fa58Smacallan SX_ROP(26, 58, 90, 15)); 2494261fa58Smacallan write_sx_io(p, d, 2504261fa58Smacallan SX_STM(74, 31, d & 7)); 2514261fa58Smacallan s -= 128; 2524261fa58Smacallan d -= 128; 2534261fa58Smacallan count -= 32; 2544261fa58Smacallan } 2554261fa58Smacallan /* leftovers, if any */ 2564261fa58Smacallan if (count > 0) { 2574261fa58Smacallan s += (32 - count) << 2; 2584261fa58Smacallan d += (32 - count) << 2; 2594261fa58Smacallan write_sx_io(p, s, 2604261fa58Smacallan SX_LD(10, count - 1, s & 7)); 2614261fa58Smacallan write_sx_io(p, d, 2624261fa58Smacallan SX_LD(42, count - 1, d & 7)); 2634261fa58Smacallan if (count > 16) { 2644261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 2654261fa58Smacallan SX_ROP(10, 42, 74, 15)); 2664261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 2674261fa58Smacallan SX_ROP(26, 58, 90, count - 17)); 2684261fa58Smacallan } else { 2694261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 2704261fa58Smacallan SX_ROP(10, 42, 74, count - 1)); 2714261fa58Smacallan } 2724261fa58Smacallan 2734261fa58Smacallan write_sx_io(p, d, 2744261fa58Smacallan SX_STM(74, count - 1, d & 7)); 2754261fa58Smacallan } 2764261fa58Smacallan srcstart += srcinc; 2774261fa58Smacallan dststart += dstinc; 2784261fa58Smacallan } 2794261fa58Smacallan } 2804261fa58Smacallan } 2814261fa58Smacallan exaMarkSync(pDstPixmap->drawable.pScreen); 2824261fa58Smacallan} 2834261fa58Smacallan 2844261fa58Smacallanstatic void 2854261fa58SmacallanCG14DoneCopy(PixmapPtr pDstPixmap) 2864261fa58Smacallan{ 2874261fa58Smacallan} 2884261fa58Smacallan 2894261fa58Smacallanstatic Bool 2904261fa58SmacallanCG14PrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg) 2914261fa58Smacallan{ 2924261fa58Smacallan ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; 2934261fa58Smacallan Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); 2944261fa58Smacallan 2954261fa58Smacallan ENTER; 2966bdc2ffdSmacallan DPRINTF(X_ERROR, "bits per pixel: %d\n", 2976bdc2ffdSmacallan pPixmap->drawable.bitsPerPixel); 2984261fa58Smacallan write_sx_reg(p, SX_QUEUED(8), fg); 2994261fa58Smacallan write_sx_reg(p, SX_QUEUED(9), fg); 3004261fa58Smacallan if (planemask != p->last_mask) { 3014261fa58Smacallan CG14Wait(p); 3024261fa58Smacallan write_sx_reg(p, SX_PLANEMASK, planemask); 3034261fa58Smacallan p->last_mask = planemask; 3044261fa58Smacallan } 3054261fa58Smacallan alu = sx_rop[alu]; 3064261fa58Smacallan if (alu != p->last_rop) { 3074261fa58Smacallan CG14Wait(p); 3084261fa58Smacallan write_sx_reg(p, SX_ROP_CONTROL, alu); 3094261fa58Smacallan p->last_rop = alu; 3104261fa58Smacallan } 3114261fa58Smacallan DPRINTF(X_ERROR, "%s: %x\n", __func__, alu); 3124261fa58Smacallan return TRUE; 3134261fa58Smacallan} 3144261fa58Smacallan 3154261fa58Smacallanstatic void 3164261fa58SmacallanCG14Solid32(Cg14Ptr p, uint32_t start, uint32_t pitch, int w, int h) 3174261fa58Smacallan{ 3184261fa58Smacallan int line, x, num; 3194261fa58Smacallan uint32_t ptr; 3204261fa58Smacallan 3214261fa58Smacallan ENTER; 3224261fa58Smacallan if (p->last_rop == 0xcc) { 3234261fa58Smacallan /* simple fill */ 3244261fa58Smacallan for (line = 0; line < h; line++) { 3254261fa58Smacallan x = 0; 3264261fa58Smacallan while (x < w) { 3274261fa58Smacallan ptr = start + (x << 2); 3284261fa58Smacallan num = min(32, w - x); 3294261fa58Smacallan write_sx_io(p, ptr, 3304261fa58Smacallan SX_STS(8, num - 1, ptr & 7)); 3314261fa58Smacallan x += 32; 3324261fa58Smacallan } 3334261fa58Smacallan start += pitch; 3344261fa58Smacallan } 3354261fa58Smacallan } else if (p->last_rop == 0xaa) { 3364261fa58Smacallan /* nothing to do here */ 3374261fa58Smacallan return; 3384261fa58Smacallan } else { 3394261fa58Smacallan /* alright, let's do actual ROP stuff */ 3404261fa58Smacallan 3414261fa58Smacallan /* first repeat the fill colour into 16 registers */ 3424261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 3434261fa58Smacallan SX_SELECT_S(8, 8, 10, 15)); 3444261fa58Smacallan 3454261fa58Smacallan for (line = 0; line < h; line++) { 3464261fa58Smacallan x = 0; 3474261fa58Smacallan while (x < w) { 3484261fa58Smacallan ptr = start + (x << 2); 3494261fa58Smacallan num = min(32, w - x); 3504261fa58Smacallan /* now suck fb data into registers */ 3514261fa58Smacallan write_sx_io(p, ptr, 3524261fa58Smacallan SX_LD(42, num - 1, ptr & 7)); 3534261fa58Smacallan /* 3544261fa58Smacallan * ROP them with the fill data we left in 10 3554261fa58Smacallan * non-memory ops can only have counts up to 16 3564261fa58Smacallan */ 3574261fa58Smacallan if (num <= 16) { 3584261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 3594261fa58Smacallan SX_ROP(10, 42, 74, num - 1)); 3604261fa58Smacallan } else { 3614261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 3624261fa58Smacallan SX_ROP(10, 42, 74, 15)); 3634261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 3644261fa58Smacallan SX_ROP(10, 58, 90, num - 17)); 3654261fa58Smacallan } 3664261fa58Smacallan /* and write the result back into memory */ 3674261fa58Smacallan write_sx_io(p, ptr, 3684261fa58Smacallan SX_ST(74, num - 1, ptr & 7)); 3694261fa58Smacallan x += 32; 3704261fa58Smacallan } 3714261fa58Smacallan start += pitch; 3724261fa58Smacallan } 3734261fa58Smacallan } 3744261fa58Smacallan} 3754261fa58Smacallan 3764261fa58Smacallanstatic void 3774261fa58SmacallanCG14Solid8(Cg14Ptr p, uint32_t start, uint32_t pitch, int w, int h) 3784261fa58Smacallan{ 3794261fa58Smacallan int line, x, num, off; 3804261fa58Smacallan uint32_t ptr; 3814261fa58Smacallan 3824261fa58Smacallan ENTER; 3834261fa58Smacallan off = start & 7; 3844261fa58Smacallan start &= ~7; 3854261fa58Smacallan 3864261fa58Smacallan if (p->last_rop == 0xcc) { 3874261fa58Smacallan /* simple fill */ 3884261fa58Smacallan for (line = 0; line < h; line++) { 3894261fa58Smacallan x = 0; 3904261fa58Smacallan while (x < w) { 3914261fa58Smacallan ptr = start + x; 3924261fa58Smacallan num = min(32, w - x); 3934261fa58Smacallan write_sx_io(p, ptr, 3944261fa58Smacallan SX_STBS(8, num - 1, off)); 3954261fa58Smacallan x += 32; 3964261fa58Smacallan } 3974261fa58Smacallan start += pitch; 3984261fa58Smacallan } 3994261fa58Smacallan } else if (p->last_rop == 0xaa) { 4004261fa58Smacallan /* nothing to do here */ 4014261fa58Smacallan return; 4024261fa58Smacallan } else { 4034261fa58Smacallan /* alright, let's do actual ROP stuff */ 4044261fa58Smacallan 4054261fa58Smacallan /* first repeat the fill colour into 16 registers */ 4064261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 4074261fa58Smacallan SX_SELECT_S(8, 8, 10, 15)); 4084261fa58Smacallan 4094261fa58Smacallan for (line = 0; line < h; line++) { 4104261fa58Smacallan x = 0; 4114261fa58Smacallan while (x < w) { 4124261fa58Smacallan ptr = start + x; 4134261fa58Smacallan num = min(32, w - x); 4144261fa58Smacallan /* now suck fb data into registers */ 4154261fa58Smacallan write_sx_io(p, ptr, 4164261fa58Smacallan SX_LDB(42, num - 1, off)); 4174261fa58Smacallan /* 4184261fa58Smacallan * ROP them with the fill data we left in 10 4194261fa58Smacallan * non-memory ops can only have counts up to 16 4204261fa58Smacallan */ 4214261fa58Smacallan if (num <= 16) { 4224261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 4234261fa58Smacallan SX_ROP(10, 42, 74, num - 1)); 4244261fa58Smacallan } else { 4254261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 4264261fa58Smacallan SX_ROP(10, 42, 74, 15)); 4274261fa58Smacallan write_sx_reg(p, SX_INSTRUCTIONS, 4284261fa58Smacallan SX_ROP(10, 58, 90, num - 17)); 4294261fa58Smacallan } 4304261fa58Smacallan /* and write the result back into memory */ 4314261fa58Smacallan write_sx_io(p, ptr, 4324261fa58Smacallan SX_STB(74, num - 1, off)); 4334261fa58Smacallan x += 32; 4344261fa58Smacallan } 4354261fa58Smacallan start += pitch; 4364261fa58Smacallan } 4374261fa58Smacallan } 4384261fa58Smacallan} 4394261fa58Smacallan 4404261fa58Smacallanstatic void 4414261fa58SmacallanCG14Solid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2) 4424261fa58Smacallan{ 4434261fa58Smacallan ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; 4444261fa58Smacallan Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); 4454261fa58Smacallan int w = x2 - x1, h = y2 - y1, dstoff, dstpitch; 4464261fa58Smacallan int start, depth; 4474261fa58Smacallan 4484261fa58Smacallan ENTER; 4494261fa58Smacallan dstpitch = exaGetPixmapPitch(pPixmap); 4504261fa58Smacallan dstoff = exaGetPixmapOffset(pPixmap); 4514261fa58Smacallan 4524261fa58Smacallan depth = pPixmap->drawable.bitsPerPixel; 4534261fa58Smacallan switch (depth) { 4544261fa58Smacallan case 32: 4554261fa58Smacallan start = dstoff + (y1 * dstpitch) + (x1 << 2); 4564261fa58Smacallan CG14Solid32(p, start, dstpitch, w, h); 4574261fa58Smacallan break; 4584261fa58Smacallan case 8: 4594261fa58Smacallan start = dstoff + (y1 * dstpitch) + x1; 4604261fa58Smacallan CG14Solid8(p, start, dstpitch, w, h); 4614261fa58Smacallan break; 4624261fa58Smacallan } 4634261fa58Smacallan 4644261fa58Smacallan DPRINTF(X_ERROR, "Solid %d %d %d %d, %d %d -> %d\n", x1, y1, x2, y2, 4654261fa58Smacallan dstpitch, dstoff, start); 4664261fa58Smacallan DPRINTF(X_ERROR, "%x %x %x\n", p->last_rop, 4674261fa58Smacallan read_sx_reg(p, SX_QUEUED(8)), read_sx_reg(p, SX_QUEUED(9))); 4684261fa58Smacallan exaMarkSync(pPixmap->drawable.pScreen); 4694261fa58Smacallan} 4704261fa58Smacallan 4714261fa58Smacallan/* 4724261fa58Smacallan * Memcpy-based UTS. 4734261fa58Smacallan */ 4744261fa58Smacallanstatic Bool 4754261fa58SmacallanCG14UploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, 4764261fa58Smacallan char *src, int src_pitch) 4774261fa58Smacallan{ 4784261fa58Smacallan ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; 4794261fa58Smacallan Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); 4804261fa58Smacallan char *dst = p->fb + exaGetPixmapOffset(pDst); 4814261fa58Smacallan int dst_pitch = exaGetPixmapPitch(pDst); 4824261fa58Smacallan 4834261fa58Smacallan int bpp = pDst->drawable.bitsPerPixel; 4844261fa58Smacallan int cpp = (bpp + 7) >> 3; 4854261fa58Smacallan int wBytes = w * cpp; 4864261fa58Smacallan 4874261fa58Smacallan ENTER; 4884261fa58Smacallan dst += (x * cpp) + (y * dst_pitch); 4894261fa58Smacallan 4904261fa58Smacallan CG14Wait(p); 4914261fa58Smacallan 4924261fa58Smacallan while (h--) { 4934261fa58Smacallan memcpy(dst, src, wBytes); 4944261fa58Smacallan src += src_pitch; 4954261fa58Smacallan dst += dst_pitch; 4964261fa58Smacallan } 4974261fa58Smacallan __asm("stbar;"); 4984261fa58Smacallan return TRUE; 4994261fa58Smacallan} 5004261fa58Smacallan 5014261fa58Smacallan/* 5024261fa58Smacallan * Memcpy-based DFS. 5034261fa58Smacallan */ 5044261fa58Smacallanstatic Bool 5054261fa58SmacallanCG14DownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, 5064261fa58Smacallan char *dst, int dst_pitch) 5074261fa58Smacallan{ 5084261fa58Smacallan ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum]; 5094261fa58Smacallan Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); 5104261fa58Smacallan char *src = p->fb + exaGetPixmapOffset(pSrc); 5114261fa58Smacallan int src_pitch = exaGetPixmapPitch(pSrc); 5124261fa58Smacallan 5134261fa58Smacallan ENTER; 5144261fa58Smacallan int bpp = pSrc->drawable.bitsPerPixel; 5154261fa58Smacallan int cpp = (bpp + 7) >> 3; 5164261fa58Smacallan int wBytes = w * cpp; 5174261fa58Smacallan 5184261fa58Smacallan src += (x * cpp) + (y * src_pitch); 5194261fa58Smacallan 5204261fa58Smacallan CG14Wait(p); 5214261fa58Smacallan 5224261fa58Smacallan while (h--) { 5234261fa58Smacallan memcpy(dst, src, wBytes); 5244261fa58Smacallan src += src_pitch; 5254261fa58Smacallan dst += dst_pitch; 5264261fa58Smacallan } 5274261fa58Smacallan 5284261fa58Smacallan return TRUE; 5294261fa58Smacallan} 5304261fa58Smacallan 5314261fa58SmacallanBool 5324261fa58SmacallanCG14CheckComposite(int op, PicturePtr pSrcPicture, 5334261fa58Smacallan PicturePtr pMaskPicture, 5344261fa58Smacallan PicturePtr pDstPicture) 5354261fa58Smacallan{ 5364261fa58Smacallan int i, ok = FALSE; 5374261fa58Smacallan 5384261fa58Smacallan ENTER; 5394261fa58Smacallan 5404261fa58Smacallan /* 5414261fa58Smacallan * SX is in theory capable of accelerating pretty much all Xrender ops, 5424261fa58Smacallan * even coordinate transformation and gradients. Support will be added 5434261fa58Smacallan * over time and likely have to spill over into its own source file. 5444261fa58Smacallan */ 5454261fa58Smacallan 546a3a2ba44Smacallan if ((op != PictOpOver) && (op != PictOpAdd) && (op != PictOpSrc)) { 5474261fa58Smacallan xf86Msg(X_ERROR, "%s: rejecting %d\n", __func__, op); 5484261fa58Smacallan return FALSE; 5494261fa58Smacallan } 5504261fa58Smacallan i = 0; 5514261fa58Smacallan while ((i < arraysize(src_formats)) && (!ok)) { 5524261fa58Smacallan ok = (pSrcPicture->format == src_formats[i]); 5534261fa58Smacallan i++; 5544261fa58Smacallan } 5554261fa58Smacallan 5564261fa58Smacallan if (!ok) { 5574261fa58Smacallan xf86Msg(X_ERROR, "%s: unsupported src format %x\n", 5584261fa58Smacallan __func__, pSrcPicture->format); 5594261fa58Smacallan return FALSE; 5604261fa58Smacallan } 5614261fa58Smacallan 562a3a2ba44Smacallan DPRINTF(X_ERROR, "src is %x, %d: %d %d\n", pSrcPicture->format, op, 5634261fa58Smacallan pSrcPicture->pDrawable->width, pSrcPicture->pDrawable->height); 5644261fa58Smacallan 5654261fa58Smacallan if (pMaskPicture != NULL) { 5664261fa58Smacallan DPRINTF(X_ERROR, "mask is %x %d %d\n", pMaskPicture->format, 5674261fa58Smacallan pMaskPicture->pDrawable->width, 5684261fa58Smacallan pMaskPicture->pDrawable->height); 5694261fa58Smacallan } 5704261fa58Smacallan return TRUE; 5714261fa58Smacallan} 5724261fa58Smacallan 5734261fa58SmacallanBool 5744261fa58SmacallanCG14PrepareComposite(int op, PicturePtr pSrcPicture, 5754261fa58Smacallan PicturePtr pMaskPicture, 5764261fa58Smacallan PicturePtr pDstPicture, 5774261fa58Smacallan PixmapPtr pSrc, 5784261fa58Smacallan PixmapPtr pMask, 5794261fa58Smacallan PixmapPtr pDst) 5804261fa58Smacallan{ 5814261fa58Smacallan ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; 5824261fa58Smacallan Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); 5834261fa58Smacallan 5844261fa58Smacallan ENTER; 5854261fa58Smacallan 586f7cb851fSmacallan p->no_source_pixmap = FALSE; 587f7cb851fSmacallan p->source_is_solid = FALSE; 588f7cb851fSmacallan 589a3a2ba44Smacallan if (pSrcPicture->format == PICT_a1) { 5906bdc2ffdSmacallan xf86Msg(X_ERROR, "src mono, dst %x, op %d\n", 5916bdc2ffdSmacallan pDstPicture->format, op); 592a3a2ba44Smacallan if (pMaskPicture != NULL) { 593a3a2ba44Smacallan xf86Msg(X_ERROR, "msk %x\n", pMaskPicture->format); 594a3a2ba44Smacallan } 595f7cb851fSmacallan } 5964261fa58Smacallan if (pSrcPicture->pSourcePict != NULL) { 5974261fa58Smacallan if (pSrcPicture->pSourcePict->type == SourcePictTypeSolidFill) { 5984261fa58Smacallan p->fillcolour = 5994261fa58Smacallan pSrcPicture->pSourcePict->solidFill.color; 600f7cb851fSmacallan DPRINTF(X_ERROR, "%s: solid src %08x\n", 6014261fa58Smacallan __func__, p->fillcolour); 602f7cb851fSmacallan p->no_source_pixmap = TRUE; 603f7cb851fSmacallan p->source_is_solid = TRUE; 6044261fa58Smacallan } 6054261fa58Smacallan } 6064261fa58Smacallan if ((pMaskPicture != NULL) && (pMaskPicture->pSourcePict != NULL)) { 6074261fa58Smacallan if (pMaskPicture->pSourcePict->type == 6084261fa58Smacallan SourcePictTypeSolidFill) { 6094261fa58Smacallan p->fillcolour = 6104261fa58Smacallan pMaskPicture->pSourcePict->solidFill.color; 611a3a2ba44Smacallan xf86Msg(X_ERROR, "%s: solid mask %08x\n", 6124261fa58Smacallan __func__, p->fillcolour); 6134261fa58Smacallan } 6144261fa58Smacallan } 6154261fa58Smacallan if (pMaskPicture != NULL) { 6164261fa58Smacallan p->mskoff = exaGetPixmapOffset(pMask); 6174261fa58Smacallan p->mskpitch = exaGetPixmapPitch(pMask); 6184261fa58Smacallan p->mskformat = pMaskPicture->format; 619a3a2ba44Smacallan } else { 620a3a2ba44Smacallan p->mskoff = 0; 621a3a2ba44Smacallan p->mskpitch = 0; 622a3a2ba44Smacallan p->mskformat = 0; 6234261fa58Smacallan } 624f7cb851fSmacallan if (pSrc != NULL) { 625f7cb851fSmacallan p->source_is_solid = 626f7cb851fSmacallan ((pSrc->drawable.width == 1) && (pSrc->drawable.height == 1)); 627f7cb851fSmacallan p->srcoff = exaGetPixmapOffset(pSrc); 628f7cb851fSmacallan p->srcpitch = exaGetPixmapPitch(pSrc); 629f7cb851fSmacallan if (p->source_is_solid) { 630f7cb851fSmacallan p->fillcolour = *(uint32_t *)(p->fb + p->srcoff); 631f7cb851fSmacallan } 632f7cb851fSmacallan } 6334261fa58Smacallan p->srcformat = pSrcPicture->format; 6344261fa58Smacallan p->dstformat = pDstPicture->format; 635f7cb851fSmacallan 636f7cb851fSmacallan if (p->source_is_solid) { 637f7cb851fSmacallan uint32_t temp; 638f7cb851fSmacallan 639f7cb851fSmacallan /* stuff source colour into SX registers, swap as needed */ 640f7cb851fSmacallan temp = p->fillcolour; 641f7cb851fSmacallan switch (p->srcformat) { 642f7cb851fSmacallan case PICT_a8r8g8b8: 643f7cb851fSmacallan case PICT_x8r8g8b8: 644f7cb851fSmacallan write_sx_reg(p, SX_QUEUED(9), temp & 0xff); 645f7cb851fSmacallan temp = temp >> 8; 646f7cb851fSmacallan write_sx_reg(p, SX_QUEUED(10), temp & 0xff); 647f7cb851fSmacallan temp = temp >> 8; 648f7cb851fSmacallan write_sx_reg(p, SX_QUEUED(11), temp & 0xff); 649f7cb851fSmacallan break; 650f7cb851fSmacallan case PICT_a8b8g8r8: 651f7cb851fSmacallan case PICT_x8b8g8r8: 652f7cb851fSmacallan write_sx_reg(p, SX_QUEUED(11), temp & 0xff); 653f7cb851fSmacallan temp = temp >> 8; 654f7cb851fSmacallan write_sx_reg(p, SX_QUEUED(10), temp & 0xff); 655f7cb851fSmacallan temp = temp >> 8; 656f7cb851fSmacallan write_sx_reg(p, SX_QUEUED(9), temp & 0xff); 657f7cb851fSmacallan break; 658f7cb851fSmacallan } 659f7cb851fSmacallan write_sx_reg(p, SX_QUEUED(8), 0xff); 660f7cb851fSmacallan } 6614261fa58Smacallan p->op = op; 662a3a2ba44Smacallan if (op == PictOpSrc) { 663a3a2ba44Smacallan CG14PrepareCopy(pSrc, pDst, 1, 1, GXcopy, 0xffffffff); 664a3a2ba44Smacallan } 6654261fa58Smacallan#ifdef SX_DEBUG 6664261fa58Smacallan DPRINTF(X_ERROR, "%x %x -> %x\n", p->srcoff, p->mskoff, 6674261fa58Smacallan *(uint32_t *)(p->fb + p->srcoff)); 6684261fa58Smacallan#endif 6694261fa58Smacallan return TRUE; 6704261fa58Smacallan} 6714261fa58Smacallan 6724261fa58Smacallanvoid 6734261fa58SmacallanCG14Composite(PixmapPtr pDst, int srcX, int srcY, 6744261fa58Smacallan int maskX, int maskY, 6754261fa58Smacallan int dstX, int dstY, 6764261fa58Smacallan int width, int height) 6774261fa58Smacallan{ 6784261fa58Smacallan ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; 6794261fa58Smacallan Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); 6804261fa58Smacallan uint32_t dstoff, dstpitch; 6814261fa58Smacallan uint32_t dst, msk, src; 6824261fa58Smacallan 6834261fa58Smacallan ENTER; 6844261fa58Smacallan dstoff = exaGetPixmapOffset(pDst); 6854261fa58Smacallan dstpitch = exaGetPixmapPitch(pDst); 6864261fa58Smacallan 6874261fa58Smacallan switch (p->op) { 6884261fa58Smacallan case PictOpOver: 6894261fa58Smacallan dst = dstoff + (dstY * dstpitch) + (dstX << 2); 6904261fa58Smacallan DPRINTF(X_ERROR, "Over %08x %08x, %d %d\n", 6914261fa58Smacallan p->mskformat, p->dstformat, srcX, srcY); 692a3a2ba44Smacallan if (p->source_is_solid) { 693a3a2ba44Smacallan switch (p->mskformat) { 694a3a2ba44Smacallan case PICT_a8: 695a3a2ba44Smacallan msk = p->mskoff + 696a3a2ba44Smacallan (maskY * p->mskpitch) + 697a3a2ba44Smacallan maskX; 698a3a2ba44Smacallan CG14Comp_Over8Solid(p, 699a3a2ba44Smacallan msk, p->mskpitch, 700a3a2ba44Smacallan dst, dstpitch, 701a3a2ba44Smacallan width, height); 702a3a2ba44Smacallan break; 703a3a2ba44Smacallan case PICT_a8r8g8b8: 704a3a2ba44Smacallan case PICT_a8b8g8r8: 705a3a2ba44Smacallan msk = p->mskoff + 706a3a2ba44Smacallan (maskY * p->mskpitch) + 707a3a2ba44Smacallan (maskX << 2); 708a3a2ba44Smacallan CG14Comp_Over32Solid(p, 709a3a2ba44Smacallan msk, p->mskpitch, 710a3a2ba44Smacallan dst, dstpitch, 711a3a2ba44Smacallan width, height); 712a3a2ba44Smacallan break; 713a3a2ba44Smacallan default: 714a3a2ba44Smacallan xf86Msg(X_ERROR, 7156bdc2ffdSmacallan "unsupported mask format\n"); 716a3a2ba44Smacallan } 717a3a2ba44Smacallan } else { 7186bdc2ffdSmacallan DPRINTF(X_ERROR, "non-solid over with msk %x\n", 7196bdc2ffdSmacallan p->mskformat); 720a3a2ba44Smacallan switch (p->srcformat) { 721a3a2ba44Smacallan case PICT_a8r8g8b8: 722a3a2ba44Smacallan case PICT_a8b8g8r8: 723a3a2ba44Smacallan src = p->srcoff + 724a3a2ba44Smacallan (srcY * p->srcpitch) + 725a3a2ba44Smacallan (srcX << 2); 726a3a2ba44Smacallan dst = dstoff + 727a3a2ba44Smacallan (dstY * dstpitch) + 728a3a2ba44Smacallan (dstX << 2); 729a3a2ba44Smacallan if (p->mskformat == PICT_a8) { 730a3a2ba44Smacallan msk = p->mskoff + 731a3a2ba44Smacallan (maskY * p->mskpitch) + 732a3a2ba44Smacallan maskX; 733a3a2ba44Smacallan CG14Comp_Over32Mask(p, 734a3a2ba44Smacallan src, p->srcpitch, 735a3a2ba44Smacallan msk, p->mskpitch, 736a3a2ba44Smacallan dst, dstpitch, 737a3a2ba44Smacallan width, height); 738a3a2ba44Smacallan } else { 739a3a2ba44Smacallan CG14Comp_Over32(p, 740a3a2ba44Smacallan src, p->srcpitch, 741a3a2ba44Smacallan dst, dstpitch, 742a3a2ba44Smacallan width, height); 743a3a2ba44Smacallan } 744a3a2ba44Smacallan break; 745a3a2ba44Smacallan case PICT_x8r8g8b8: 746a3a2ba44Smacallan case PICT_x8b8g8r8: 7476bdc2ffdSmacallan src = p->srcoff + 7486bdc2ffdSmacallan (srcY * p->srcpitch) + 7496bdc2ffdSmacallan (srcX << 2); 7506bdc2ffdSmacallan dst = dstoff + 7516bdc2ffdSmacallan (dstY * dstpitch) + 7526bdc2ffdSmacallan (dstX << 2); 7536bdc2ffdSmacallan if (p->mskformat == PICT_a8) { 7546bdc2ffdSmacallan msk = p->mskoff + 7556bdc2ffdSmacallan (maskY * p->mskpitch) + 7566bdc2ffdSmacallan maskX; 7576bdc2ffdSmacallan CG14Comp_Over32Mask_noalpha(p, 7586bdc2ffdSmacallan src, p->srcpitch, 7596bdc2ffdSmacallan msk, p->mskpitch, 7606bdc2ffdSmacallan dst, dstpitch, 7616bdc2ffdSmacallan width, height); 7626bdc2ffdSmacallan } else { 7636bdc2ffdSmacallan xf86Msg(X_ERROR, "no src alpha, mask is %x\n", p->mskformat); 7646bdc2ffdSmacallan } 765a3a2ba44Smacallan break; 766a3a2ba44Smacallan default: 767a3a2ba44Smacallan xf86Msg(X_ERROR, "%s: format %x in non-solid Over op\n", 768a3a2ba44Smacallan __func__, p->srcformat); 769a3a2ba44Smacallan } 770a3a2ba44Smacallan } 7714261fa58Smacallan break; 7724261fa58Smacallan case PictOpAdd: 7734261fa58Smacallan DPRINTF(X_ERROR, "Add %08x %08x\n", 7744261fa58Smacallan p->srcformat, p->dstformat); 7754261fa58Smacallan switch (p->srcformat) { 7764261fa58Smacallan case PICT_a8: 7774261fa58Smacallan src = p->srcoff + 7784261fa58Smacallan (srcY * p->srcpitch) + srcX; 7794261fa58Smacallan dst = dstoff + (dstY * dstpitch) + dstX; 7804261fa58Smacallan CG14Comp_Add8(p, src, p->srcpitch, 7814261fa58Smacallan dst, dstpitch, width, height); 7824261fa58Smacallan break; 7834261fa58Smacallan case PICT_a8r8g8b8: 7844261fa58Smacallan case PICT_x8r8g8b8: 7854261fa58Smacallan src = p->srcoff + 7864261fa58Smacallan (srcY * p->srcpitch) + (srcX << 2); 7874261fa58Smacallan dst = dstoff + (dstY * dstpitch) + 7884261fa58Smacallan (dstX << 2); 7894261fa58Smacallan CG14Comp_Add32(p, src, p->srcpitch, 7904261fa58Smacallan dst, dstpitch, width, height); 7914261fa58Smacallan break; 7924261fa58Smacallan default: 7934261fa58Smacallan xf86Msg(X_ERROR, 7944261fa58Smacallan "unsupported src format\n"); 7954261fa58Smacallan } 7964261fa58Smacallan break; 797a3a2ba44Smacallan case PictOpSrc: 798a3a2ba44Smacallan DPRINTF(X_ERROR, "Src %08x %08x\n", 799a3a2ba44Smacallan p->srcformat, p->dstformat); 800a3a2ba44Smacallan CG14Copy(pDst, srcX, srcY, dstX, dstY, width, height); 801a3a2ba44Smacallan break; 8024261fa58Smacallan default: 8034261fa58Smacallan xf86Msg(X_ERROR, "unsupported op %d\n", p->op); 8044261fa58Smacallan } 8054261fa58Smacallan exaMarkSync(pDst->drawable.pScreen); 8064261fa58Smacallan} 8074261fa58Smacallan 8084261fa58Smacallan 8094261fa58Smacallan 8104261fa58SmacallanBool 8114261fa58SmacallanCG14InitAccel(ScreenPtr pScreen) 8124261fa58Smacallan{ 8134261fa58Smacallan ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; 8144261fa58Smacallan Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); 8154261fa58Smacallan ExaDriverPtr pExa; 8164261fa58Smacallan 8174261fa58Smacallan pExa = exaDriverAlloc(); 8184261fa58Smacallan if (!pExa) 8194261fa58Smacallan return FALSE; 8204261fa58Smacallan 8214261fa58Smacallan p->pExa = pExa; 8224261fa58Smacallan 8234261fa58Smacallan pExa->exa_major = EXA_VERSION_MAJOR; 8244261fa58Smacallan pExa->exa_minor = EXA_VERSION_MINOR; 8254261fa58Smacallan 8264261fa58Smacallan pExa->memoryBase = p->fb; 8274261fa58Smacallan pExa->memorySize = p->memsize; 8284261fa58Smacallan pExa->offScreenBase = p->width * p->height * 4; 8294261fa58Smacallan 8304261fa58Smacallan /* 8314261fa58Smacallan * SX memory instructions are written to 64bit aligned addresses with 8324261fa58Smacallan * a 3 bit displacement. Make sure the displacement remains constant 8334261fa58Smacallan * within one column 8344261fa58Smacallan */ 8354261fa58Smacallan 8364261fa58Smacallan pExa->pixmapOffsetAlign = 8; 8374261fa58Smacallan pExa->pixmapPitchAlign = 8; 8384261fa58Smacallan 8394261fa58Smacallan pExa->flags = EXA_OFFSCREEN_PIXMAPS | 8404261fa58Smacallan /*EXA_SUPPORTS_OFFSCREEN_OVERLAPS |*/ 8414261fa58Smacallan EXA_MIXED_PIXMAPS; 8424261fa58Smacallan 8434261fa58Smacallan /* 8444261fa58Smacallan * these limits are bogus 8454261fa58Smacallan * SX doesn't deal with coordinates at all, so there is no limit but 8464261fa58Smacallan * we have to put something here 8474261fa58Smacallan */ 8484261fa58Smacallan pExa->maxX = 4096; 8494261fa58Smacallan pExa->maxY = 4096; 8504261fa58Smacallan 8514261fa58Smacallan pExa->WaitMarker = CG14WaitMarker; 8524261fa58Smacallan 8534261fa58Smacallan pExa->PrepareSolid = CG14PrepareSolid; 8544261fa58Smacallan pExa->Solid = CG14Solid; 8554261fa58Smacallan pExa->DoneSolid = CG14DoneCopy; 8564261fa58Smacallan pExa->PrepareCopy = CG14PrepareCopy; 8574261fa58Smacallan pExa->Copy = CG14Copy; 8584261fa58Smacallan pExa->DoneCopy = CG14DoneCopy; 8594261fa58Smacallan if (p->use_xrender) { 8604261fa58Smacallan pExa->CheckComposite = CG14CheckComposite; 8614261fa58Smacallan pExa->PrepareComposite = CG14PrepareComposite; 8624261fa58Smacallan pExa->Composite = CG14Composite; 8634261fa58Smacallan pExa->DoneComposite = CG14DoneCopy; 8644261fa58Smacallan } 8654261fa58Smacallan 8664261fa58Smacallan /* EXA hits more optimized paths when it does not have to fallback 8674261fa58Smacallan * because of missing UTS/DFS, hook memcpy-based UTS/DFS. 8684261fa58Smacallan */ 8694261fa58Smacallan pExa->UploadToScreen = CG14UploadToScreen; 8704261fa58Smacallan pExa->DownloadFromScreen = CG14DownloadFromScreen; 8714261fa58Smacallan 8724261fa58Smacallan /* do some hardware init */ 8734261fa58Smacallan write_sx_reg(p, SX_PLANEMASK, 0xffffffff); 8744261fa58Smacallan p->last_mask = 0xffffffff; 8754261fa58Smacallan write_sx_reg(p, SX_ROP_CONTROL, 0xcc); 8764261fa58Smacallan p->last_rop = 0xcc; 8774261fa58Smacallan return exaDriverInit(pScreen, pExa); 8784261fa58Smacallan} 879