Thu May 27 04:48:10 2021 UTC ()
Add support for EXA, so that the pnozz driver works again with Xorg.
Note, that only minimal acceleration is currently supported.

Thanks to macallan for the pointers to get this working.


(jdc)
diff -r0 -r1.1 xsrc/external/mit/xf86-video-pnozz/dist/src/compat-api.h
diff -r0 -r1.1 xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c
diff -r1.1 -r1.2 xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz.h
diff -r1.2 -r1.3 xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_accel.c
diff -r1.2 -r1.3 xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_cursor.c
diff -r1.6 -r1.7 xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_driver.c

File Added: xsrc/external/mit/xf86-video-pnozz/dist/src/compat-api.h
/*
 * Copyright 2012 Red Hat, Inc.
 *
 * 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 NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS 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.
 *
 * Author: Dave Airlie <airlied@redhat.com>
 */

/* this file provides API compat between server post 1.13 and pre it,
   it should be reused inside as many drivers as possible */
#ifndef COMPAT_API_H
#define COMPAT_API_H

#ifndef GLYPH_HAS_GLYPH_PICTURE_ACCESSOR
#define GetGlyphPicture(g, s) GlyphPicture((g))[(s)->myNum]
#define SetGlyphPicture(g, s, p) GlyphPicture((g))[(s)->myNum] = p
#endif

#ifndef XF86_HAS_SCRN_CONV
#define xf86ScreenToScrn(s) xf86Screens[(s)->myNum]
#define xf86ScrnToScreen(s) screenInfo.screens[(s)->scrnIndex]
#endif

#ifndef XF86_SCRN_INTERFACE

#define SCRN_ARG_TYPE int
#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = xf86Screens[(arg1)]

#define SCREEN_ARG_TYPE int
#define SCREEN_PTR(arg1) ScreenPtr pScreen = screenInfo.screens[(arg1)]

#define SCREEN_INIT_ARGS_DECL int i, ScreenPtr pScreen, int argc, char **argv

#define BLOCKHANDLER_ARGS_DECL int arg, pointer blockData, pointer pTimeout, pointer pReadmask
#define BLOCKHANDLER_ARGS arg, blockData, pTimeout, pReadmask

#define CLOSE_SCREEN_ARGS_DECL int scrnIndex, ScreenPtr pScreen
#define CLOSE_SCREEN_ARGS scrnIndex, pScreen

#define ADJUST_FRAME_ARGS_DECL int arg, int x, int y, int flags
#define ADJUST_FRAME_ARGS(arg, x, y) (arg)->scrnIndex, x, y, 0

#define SWITCH_MODE_ARGS_DECL int arg, DisplayModePtr mode, int flags
#define SWITCH_MODE_ARGS(arg, m) (arg)->scrnIndex, m, 0

#define FREE_SCREEN_ARGS_DECL int arg, int flags

#define VT_FUNC_ARGS_DECL int arg, int flags
#define VT_FUNC_ARGS pScrn->scrnIndex, 0

#define XF86_SCRN_ARG(x) ((x)->scrnIndex)
#else
#define SCRN_ARG_TYPE ScrnInfoPtr
#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = (arg1)

#define SCREEN_ARG_TYPE ScreenPtr
#define SCREEN_PTR(arg1) ScreenPtr pScreen = (arg1)

#define SCREEN_INIT_ARGS_DECL ScreenPtr pScreen, int argc, char **argv

#define BLOCKHANDLER_ARGS_DECL ScreenPtr arg, pointer pTimeout, pointer pReadmask
#define BLOCKHANDLER_ARGS arg, pTimeout, pReadmask

#define CLOSE_SCREEN_ARGS_DECL ScreenPtr pScreen
#define CLOSE_SCREEN_ARGS pScreen

#define ADJUST_FRAME_ARGS_DECL ScrnInfoPtr arg, int x, int y
#define ADJUST_FRAME_ARGS(arg, x, y) arg, x, y

#define SWITCH_MODE_ARGS_DECL ScrnInfoPtr arg, DisplayModePtr mode
#define SWITCH_MODE_ARGS(arg, m) arg, m

#define FREE_SCREEN_ARGS_DECL ScrnInfoPtr arg

#define VT_FUNC_ARGS_DECL ScrnInfoPtr arg
#define VT_FUNC_ARGS pScrn

#define XF86_SCRN_ARG(x) (x)

#endif

#endif

File Added: xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c
/*
 * SBus Weitek P9100 EXA support
 *
/*-
 * Copyright (c) 2021 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Julian Coleman.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "pnozz.h"
#include "pnozz_regs.h"


static CARD32 PnozzCopyROP[] = {
	/*GXclear*/		0,
	/*GXand*/		ROP_SRC & ROP_DST,
	/*GXandReverse*/	ROP_SRC & (~ROP_DST),
	/*GXcopy*/		ROP_SRC,
	/*GXandInverted*/	(~ROP_SRC) & ROP_DST,
	/*GXnoop*/		ROP_DST,
	/*GXxor*/		ROP_SRC ^ ROP_DST,
	/*GXor*/		ROP_SRC | ROP_DST,
	/*GXnor*/		(~ROP_SRC) & (~ROP_DST),
	/*GXequiv*/		(~ROP_SRC) ^ ROP_DST,
	/*GXinvert*/		(~ROP_DST),
	/*GXorReverse*/		ROP_SRC | (~ROP_DST),
	/*GXcopyInverted*/	(~ROP_SRC),
	/*GXorInverted*/	(~ROP_SRC) | ROP_DST,
	/*GXnand*/		(~ROP_SRC) | (~ROP_DST),
	/*GXset*/		ROP_SET
};

static CARD32 PnozzDrawROP[] = {
	/*GXclear*/		0,
	/*GXand*/		ROP_PAT & ROP_DST,
	/*GXandReverse*/	ROP_PAT & (~ROP_DST),
	/*GXcopy*/		ROP_PAT,
	/*GXandInverted*/	(~ROP_PAT) & ROP_DST,
	/*GXnoop*/		ROP_DST,
	/*GXxor*/		ROP_PAT ^ ROP_DST,
	/*GXor*/		ROP_PAT | ROP_DST,
	/*GXnor*/		(~ROP_PAT) & (~ROP_DST),
	/*GXequiv*/		(~ROP_PAT) ^ ROP_DST,
	/*GXinvert*/		(~ROP_DST),
	/*GXorReverse*/		ROP_PAT | (~ROP_DST),
	/*GXcopyInverted*/	(~ROP_PAT),
	/*GXorInverted*/	(~ROP_PAT) | ROP_DST,
	/*GXnand*/		(~ROP_PAT) | (~ROP_DST),
	/*GXset*/		ROP_PAT
};

#define waitReady(pPnozz) while((pnozz_read_4(pPnozz, ENGINE_STATUS) & \
				(ENGINE_BUSY | BLITTER_BUSY)) !=0 )

void PnozzInitEngine(PnozzPtr);
void pnozz_write_colour(PnozzPtr pPnozz, int reg, CARD32 colour);

CARD32 MaxClip, junk;

static void
PnozzWaitMarker(ScreenPtr pScreen, int Marker)
{
    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
    PnozzPtr p = GET_PNOZZ_FROM_SCRN(pScrn);

    waitReady(p);
}

static Bool
PnozzPrepareCopy
(
    PixmapPtr pSrcPixmap,
    PixmapPtr pDstPixmap,
    int       xdir,
    int       ydir,
    int       alu,
    Pixel     planemask
)
{
    ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
    PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
    
    waitReady(pPnozz);
    pnozz_write_4(pPnozz, RASTER_OP, (PnozzCopyROP[alu] & 0xff));
    pnozz_write_4(pPnozz, PLANE_MASK, planemask);
    pPnozz->srcoff = exaGetPixmapOffset(pSrcPixmap) / pPnozz->width;

    return TRUE;
}

static void
PnozzCopy
(
    PixmapPtr pDstPixmap,
    int       xSrc,
    int       ySrc,
    int       xDst,
    int       yDst,
    int       w,
    int       h
)
{
    ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
    PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
    CARD32 src, dst, srcw, dstw;
    int doff = exaGetPixmapOffset(pDstPixmap) / pPnozz->width;
    
    src = (((xSrc << pPnozz->depthshift) & 0x1fff) << 16) |
	((ySrc + pPnozz->srcoff) & 0x1fff);
    dst = (((xDst << pPnozz->depthshift) & 0x1fff) << 16) |
	((yDst + doff) & 0x1fff);
    srcw = ((((xSrc + w) << pPnozz->depthshift) - 1) << 16) | 
        ((ySrc + pPnozz->srcoff + h - 1) & 0x1fff);
    dstw = ((((xDst + w) << pPnozz->depthshift) - 1) << 16) |
        ((yDst + doff + h - 1) & 0x1fff);

    waitReady(pPnozz);

    pnozz_write_4(pPnozz, ABS_XY0, src);
    pnozz_write_4(pPnozz, ABS_XY1, srcw);
    pnozz_write_4(pPnozz, ABS_XY2, dst);
    pnozz_write_4(pPnozz, ABS_XY3, dstw);
    junk = pnozz_read_4(pPnozz, COMMAND_BLIT);
    exaMarkSync(pDstPixmap->drawable.pScreen);
}

static void
PnozzDoneCopy(PixmapPtr pDstPixmap)
{
    ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
    PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);

    waitReady(pPnozz);
}

static Bool
PnozzPrepareSolid(
    PixmapPtr pPixmap,
    int alu,
    Pixel planemask,
    Pixel fg)
{
    ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
    PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
    
    waitReady(pPnozz);
    pnozz_write_colour(pPnozz, FOREGROUND_COLOR, fg);
    pnozz_write_4(pPnozz, RASTER_OP, PnozzDrawROP[alu] & 0xff);
    pnozz_write_4(pPnozz, PLANE_MASK, planemask);
    pnozz_write_4(pPnozz, COORD_INDEX, 0);

    return TRUE;
}

static void
PnozzSolid(
    PixmapPtr pPixmap,
    int x,
    int y,
    int x2,
    int y2)
{
    ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
    PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
    int w = x2 - x - 1;
    int h = y2 - y - 1;

    waitReady(pPnozz);
    pnozz_write_4(pPnozz, RECT_RTW_XY, ((x & 0x1fff) << 16) | 
        (y & 0x1fff));
    pnozz_write_4(pPnozz, RECT_RTP_XY, (((w & 0x1fff) << 16) | 
        (h & 0x1fff)));
    junk = pnozz_read_4(pPnozz, COMMAND_QUAD);
    exaMarkSync(pPixmap->drawable.pScreen);
}

int
PnozzEXAInit(ScreenPtr pScreen)
{
    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
    PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
    ExaDriverPtr pExa;
    
    PnozzInitEngine(pPnozz);

    pExa = exaDriverAlloc();
    if (!pExa)
	return FALSE;

    pPnozz->pExa = pExa;

    pExa->exa_major = EXA_VERSION_MAJOR;
    pExa->exa_minor = EXA_VERSION_MINOR;

    pExa->memoryBase = pPnozz->fb;

    /* round to multiple of pixmap pitch */
    pExa->memorySize = (pPnozz->vidmem / pPnozz->width) * pPnozz->width;
    pExa->offScreenBase = pPnozz->width * pPnozz->height;

    /*
     * our blitter can't deal with variable pitches
     */
    pExa->pixmapOffsetAlign = pPnozz->width;
    pExa->pixmapPitchAlign = pPnozz->width;

    pExa->flags = EXA_MIXED_PIXMAPS;

    pExa->maxX = 4096;
    pExa->maxY = 4096;

    pExa->WaitMarker = PnozzWaitMarker;

    pExa->PrepareSolid = PnozzPrepareSolid;
    pExa->Solid = PnozzSolid;
    pExa->DoneSolid = PnozzDoneCopy;

    pExa->PrepareCopy = PnozzPrepareCopy;
    pExa->Copy = PnozzCopy;
    pExa->DoneCopy = PnozzDoneCopy;

    return exaDriverInit(pScreen, pExa);;
}

cvs diff -r1.1 -r1.2 xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz.h (switch to unified diff)

--- xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz.h 2009/08/26 22:28:26 1.1
+++ xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz.h 2021/05/27 04:48:10 1.2
@@ -1,120 +1,136 @@ @@ -1,120 +1,136 @@
1/* 1/*
2 * SBus Weitek P9100 driver - defines 2 * SBus Weitek P9100 driver - defines
3 * 3 *
4 * Copyright (C) 2005 Michael Lorenz 4 * Copyright (C) 2005 Michael Lorenz
5 * 5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal 7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights 8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is 10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions: 11 * furnished to do so, subject to the following conditions:
12 * 12 *
13 * The above copyright notice and this permission notice shall be included in 13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software. 14 * all copies or substantial portions of the Software.
15 * 15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * MICHAEL LORENZ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 * MICHAEL LORENZ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */ 22 */
23/* $NetBSD: pnozz.h,v 1.1 2009/08/26 22:28:26 macallan Exp $ */ 23/* $NetBSD: pnozz.h,v 1.2 2021/05/27 04:48:10 jdc Exp $ */
24 24
25#ifndef PNOZZ_H 25#ifndef PNOZZ_H
26#define PNOZZ_H 26#define PNOZZ_H
27 27
28#include "xf86.h" 28#include "xf86.h"
29#include "xf86_OSproc.h" 29#include "xf86_OSproc.h"
30#include "xf86RamDac.h" 30#include "xf86RamDac.h"
31#include <X11/Xmd.h> 31#include <X11/Xmd.h>
 32#include <dev/sun/fbio.h>
32#include "gcstruct.h" 33#include "gcstruct.h"
33#include "pnozz_regs.h" 34#include "pnozz_regs.h"
34#include "xf86sbusBus.h" 35#include "xf86sbusBus.h"
 36#ifdef HAVE_XAA_H
35#include "xaa.h" 37#include "xaa.h"
 38#endif
 39#include "exa.h"
36 40
37typedef struct { 41typedef struct {
38 unsigned int fg, bg; /* FG/BG colors for stipple */ 42 unsigned int fg, bg; /* FG/BG colors for stipple */
39 unsigned int patalign; /* X/Y alignment of bits */ 43 unsigned int patalign; /* X/Y alignment of bits */
40 unsigned int alu; /* Transparent/Opaque + rop */ 44 unsigned int alu; /* Transparent/Opaque + rop */
41 unsigned int bits[32]; /* The stipple bits themselves */ 45 unsigned int bits[32]; /* The stipple bits themselves */
42} PnozzStippleRec, *PnozzStipplePtr; 46} PnozzStippleRec, *PnozzStipplePtr;
43 47
44typedef struct { 48typedef struct {
45 int type; 49 int type;
46 PnozzStipplePtr stipple; 50 PnozzStipplePtr stipple;
47} PnozzPrivGCRec, *PnozzPrivGCPtr; 51} PnozzPrivGCRec, *PnozzPrivGCPtr;
48 52
49typedef struct { 53typedef struct {
50 unsigned char *fb; /* 2MB framebuffer */ 54 unsigned char *fb; /* 2MB framebuffer */
51 unsigned char *fbc; /* registers, so we can just add a byte offset */ 55 unsigned char *fbc; /* registers, so we can just add a byte offset */
52 int vclipmax; 56 int vclipmax;
53 int width; 57 int width;
54 int height, scanlinesize, maxheight; 58 int height, scanlinesize, maxheight;
55 int depthshift; 59 int depthshift;
 60 int vidmem;
56 61
57 sbusDevicePtr psdp; 62 sbusDevicePtr psdp;
 63 struct fbcursor Cursor;
58 Bool HWCursor; 64 Bool HWCursor;
59 Bool NoAccel; 65 Bool NoAccel;
 66 Bool useXAA;
60 CloseScreenProcPtr CloseScreen; 67 CloseScreenProcPtr CloseScreen;
61  68
62 xf86CursorInfoPtr CursorInfoRec; 69 xf86CursorInfoPtr CursorInfoRec;
63 struct fbcursor Cursor; 70 unsigned int CursorXY;
 71 int CursorBg, CursorFg;
 72 Bool CursorEnabled;
 73 unsigned int cursmask[32]; /* cursor mask bits */
 74 unsigned int cursbits[32]; /* what to show where mask enabled */
64 unsigned char pal[9]; 75 unsigned char pal[9];
65  76
66 OptionInfoPtr Options; 77 OptionInfoPtr Options;
67 XAAInfoRecPtr pXAA; 78 ExaDriverPtr pExa;
 79 int srcoff;
 80#ifdef HAVE_XAA_H
68 unsigned char *buffers[2]; 81 unsigned char *buffers[2];
 82#endif
69 /* 83 /*
70 * XXX this is enough for everything a SPARCbook could do on it's 84 * XXX this is enough for everything a SPARCbook could do on it's
71 * internal display but not necessarily for an external one 85 * internal display but not necessarily for an external one
72 */ 86 */
73 CARD32 Buffer[6400]; 87 CARD32 Buffer[6400];
74 int words, last_word; 88 int words, last_word;
75 int offset_mask; 89 int offset_mask;
76 90
77 int DidSave; 91 int DidSave;
78 unsigned int SvSysConf; /* System Configuration Register */ 92 unsigned int SvSysConf; /* System Configuration Register */
79 unsigned int CRTC[4]; /* CRTC values for horizontal timing */ 93 unsigned int CRTC[4]; /* CRTC values for horizontal timing */
80 unsigned int SvMemCtl; /* memory control register */ 94 unsigned int SvMemCtl; /* memory control register */
81 unsigned char SvDAC_MCCR; /* DAC Misc Clock Ctrl (0x02) */ 95 unsigned char SvDAC_MCCR; /* DAC Misc Clock Ctrl (0x02) */
82 unsigned char SvDAC_PF; /* DAC Pixel Format (0x0a) */ 96 unsigned char SvDAC_PF; /* DAC Pixel Format (0x0a) */
83 unsigned char SvDAC_MC3; /* DAC Misc Control 3 */ 97 unsigned char SvDAC_MC3; /* DAC Misc Control 3 */
84 unsigned char SvVCO; /* DAC System PLL VCO divider */ 98 unsigned char SvVCO; /* DAC System PLL VCO divider */
85 unsigned char SvPLL; /* clock multiplier / divider */ 99 unsigned char SvPLL; /* clock multiplier / divider */
86  100
87} PnozzRec, *PnozzPtr; 101} PnozzRec, *PnozzPtr;
88 102
89extern int PnozzScreenPrivateIndex; 103extern int PnozzScreenPrivateIndex;
90extern int PnozzGCPrivateIndex; 104extern int PnozzGCPrivateIndex;
91extern int PnozzWindowPrivateIndex; 105extern int PnozzWindowPrivateIndex;
92 106
93#define GET_PNOZZ_FROM_SCRN(p) ((p->driverPrivate)) 107#define GET_PNOZZ_FROM_SCRN(p) ((p->driverPrivate))
94 108
95#define PnozzGetScreenPrivate(s) \ 109#define PnozzGetScreenPrivate(s) \
96((PnozzPtr) (s)->devPrivates[PnozzScreenPrivateIndex].ptr) 110((PnozzPtr) (s)->devPrivates[PnozzScreenPrivateIndex].ptr)
97 111
98#define PnozzGetGCPrivate(g) \ 112#define PnozzGetGCPrivate(g) \
99((PnozzPrivGCPtr) (g)->devPrivates [PnozzGCPrivateIndex].ptr) 113((PnozzPrivGCPtr) (g)->devPrivates [PnozzGCPrivateIndex].ptr)
100 114
101#define PnozzGetWindowPrivate(w) \ 115#define PnozzGetWindowPrivate(w) \
102((PnozzStipplePtr) (w)->devPrivates[PnozzWindowPrivateIndex].ptr) 116((PnozzStipplePtr) (w)->devPrivates[PnozzWindowPrivateIndex].ptr)
103  117
104#define PnozzSetWindowPrivate(w,p) \ 118#define PnozzSetWindowPrivate(w,p) \
105((w)->devPrivates[PnozzWindowPrivateIndex].ptr = (pointer) p) 119((w)->devPrivates[PnozzWindowPrivateIndex].ptr = (pointer) p)
106 120
107void pnozz_write_4(PnozzPtr, int, unsigned int); 121void pnozz_write_4(PnozzPtr, int, unsigned int);
108unsigned int pnozz_read_4(PnozzPtr, int); 122unsigned int pnozz_read_4(PnozzPtr, int);
109void pnozz_write_dac(PnozzPtr, int, unsigned char); 123void pnozz_write_dac(PnozzPtr, int, unsigned char);
110unsigned char pnozz_read_dac(PnozzPtr, int); 124unsigned char pnozz_read_dac(PnozzPtr, int);
111void pnozz_write_dac_ctl_reg(PnozzPtr, int, unsigned char); 125void pnozz_write_dac_ctl_reg(PnozzPtr, int, unsigned char);
112void pnozz_write_dac_ctl_reg_2(PnozzPtr, int, unsigned short); 126void pnozz_write_dac_ctl_reg_2(PnozzPtr, int, unsigned short);
113unsigned char pnozz_read_dac_ctl_reg(PnozzPtr, int); 127unsigned char pnozz_read_dac_ctl_reg(PnozzPtr, int);
114void pnozz_write_dac_cmap_reg(PnozzPtr, int, unsigned int); 128void pnozz_write_dac_cmap_reg(PnozzPtr, int, unsigned int);
115 129
116int PnozzAccelInit(ScrnInfoPtr); 130int PnozzAccelInit(ScrnInfoPtr);
 131Bool PnozzDGAInit(ScreenPtr);
 132int PnozzEXAInit(ScreenPtr);
117void PnozzHideCursor(ScrnInfoPtr); 133void PnozzHideCursor(ScrnInfoPtr);
118void PnozzShowCursor(ScrnInfoPtr); 134void PnozzShowCursor(ScrnInfoPtr);
119 135
120#endif /* CG6_H */ 136#endif /* PNOZZ_H */

cvs diff -r1.2 -r1.3 xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_accel.c (switch to unified diff)

--- xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_accel.c 2011/05/25 14:15:26 1.2
+++ xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_accel.c 2021/05/27 04:48:10 1.3
@@ -1,537 +1,674 @@ @@ -1,537 +1,674 @@
1/* 1/*
2 * SBus Weitek P9100 hardware acceleration support 2 * SBus Weitek P9100 hardware acceleration support
3 * 3 *
4 * Copyright (C) 2005 Michael Lorenz 4 * Copyright (C) 2005 Michael Lorenz
5 * 5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal 7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights 8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is 10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions: 11 * furnished to do so, subject to the following conditions:
12 * 12 *
13 * The above copyright notice and this permission notice shall be included in 13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software. 14 * all copies or substantial portions of the Software.
15 * 15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * MICHAEL LORENZ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 * MICHAEL LORENZ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */ 22 */
23/* $NetBSD: pnozz_accel.c,v 1.2 2011/05/25 14:15:26 christos Exp $ */ 23/* $NetBSD: pnozz_accel.c,v 1.3 2021/05/27 04:48:10 jdc Exp $ */
24 24
25#include <fcntl.h> 25#ifdef HAVE_CONFIG_H
26#include <sys/time.h> 26#include "config.h"
27#include <sys/types.h> 27#endif
28#include <dev/sun/fbio.h> 
29#include <dev/wscons/wsconsio.h> 
30 28
31#include "pnozz.h" 29#include "pnozz.h"
 30#include "pnozz_regs.h"
 31#include "dgaproc.h"
32 32
33static CARD32 PnozzCopyROP[] = { 33static CARD32 PnozzCopyROP[] = {
34 /*GXclear*/ 0, 34 /*GXclear*/ 0,
35 /*GXand*/ ROP_SRC & ROP_DST, 35 /*GXand*/ ROP_SRC & ROP_DST,
36 /*GXandReverse*/ ROP_SRC & (~ROP_DST), 36 /*GXandReverse*/ ROP_SRC & (~ROP_DST),
37 /*GXcopy*/ ROP_SRC, 37 /*GXcopy*/ ROP_SRC,
38 /*GXandInverted*/ (~ROP_SRC) & ROP_DST, 38 /*GXandInverted*/ (~ROP_SRC) & ROP_DST,
39 /*GXnoop*/ ROP_DST, 39 /*GXnoop*/ ROP_DST,
40 /*GXxor*/ ROP_SRC ^ ROP_DST, 40 /*GXxor*/ ROP_SRC ^ ROP_DST,
41 /*GXor*/ ROP_SRC | ROP_DST, 41 /*GXor*/ ROP_SRC | ROP_DST,
42 /*GXnor*/ (~ROP_SRC) & (~ROP_DST), 42 /*GXnor*/ (~ROP_SRC) & (~ROP_DST),
43 /*GXequiv*/ (~ROP_SRC) ^ ROP_DST, 43 /*GXequiv*/ (~ROP_SRC) ^ ROP_DST,
44 /*GXinvert*/ (~ROP_DST), 44 /*GXinvert*/ (~ROP_DST),
45 /*GXorReverse*/ ROP_SRC | (~ROP_DST), 45 /*GXorReverse*/ ROP_SRC | (~ROP_DST),
46 /*GXcopyInverted*/ (~ROP_SRC), 46 /*GXcopyInverted*/ (~ROP_SRC),
47 /*GXorInverted*/ (~ROP_SRC) | ROP_DST, 47 /*GXorInverted*/ (~ROP_SRC) | ROP_DST,
48 /*GXnand*/ (~ROP_SRC) | (~ROP_DST), 48 /*GXnand*/ (~ROP_SRC) | (~ROP_DST),
49 /*GXset*/ ROP_SET 49 /*GXset*/ ROP_SET
50}; 50};
51 51
52static CARD32 PnozzDrawROP[] = { 52static CARD32 PnozzDrawROP[] = {
53 /*GXclear*/ 0, 53 /*GXclear*/ 0,
54 /*GXand*/ ROP_PAT & ROP_DST, 54 /*GXand*/ ROP_PAT & ROP_DST,
55 /*GXandReverse*/ ROP_PAT & (~ROP_DST), 55 /*GXandReverse*/ ROP_PAT & (~ROP_DST),
56 /*GXcopy*/ ROP_PAT, 56 /*GXcopy*/ ROP_PAT,
57 /*GXandInverted*/ (~ROP_PAT) & ROP_DST, 57 /*GXandInverted*/ (~ROP_PAT) & ROP_DST,
58 /*GXnoop*/ ROP_DST, 58 /*GXnoop*/ ROP_DST,
59 /*GXxor*/ ROP_PAT ^ ROP_DST, 59 /*GXxor*/ ROP_PAT ^ ROP_DST,
60 /*GXor*/ ROP_PAT | ROP_DST, 60 /*GXor*/ ROP_PAT | ROP_DST,
61 /*GXnor*/ (~ROP_PAT) & (~ROP_DST), 61 /*GXnor*/ (~ROP_PAT) & (~ROP_DST),
62 /*GXequiv*/ (~ROP_PAT) ^ ROP_DST, 62 /*GXequiv*/ (~ROP_PAT) ^ ROP_DST,
63 /*GXinvert*/ (~ROP_DST), 63 /*GXinvert*/ (~ROP_DST),
64 /*GXorReverse*/ ROP_PAT | (~ROP_DST), 64 /*GXorReverse*/ ROP_PAT | (~ROP_DST),
65 /*GXcopyInverted*/ (~ROP_PAT), 65 /*GXcopyInverted*/ (~ROP_PAT),
66 /*GXorInverted*/ (~ROP_PAT) | ROP_DST, 66 /*GXorInverted*/ (~ROP_PAT) | ROP_DST,
67 /*GXnand*/ (~ROP_PAT) | (~ROP_DST), 67 /*GXnand*/ (~ROP_PAT) | (~ROP_DST),
68 /*GXset*/ ROP_PAT 68 /*GXset*/ ROP_PAT
69}; 69};
70 70
 71/* DGA stuff */
 72
 73static Bool Pnozz_OpenFramebuffer(ScrnInfoPtr pScrn, char **,
 74 unsigned char **mem, int *, int *, int *);
 75static Bool Pnozz_SetMode(ScrnInfoPtr, DGAModePtr);
 76static void Pnozz_SetViewport(ScrnInfoPtr, int, int, int);
 77static int Pnozz_GetViewport(ScrnInfoPtr);
 78static void Pnozz_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long);
 79static void Pnozz_BlitRect(ScrnInfoPtr, int, int, int, int, int, int);
 80
 81static void PnozzSync(ScrnInfoPtr);
 82
 83static DGAFunctionRec Pnozz_DGAFuncs = {
 84 Pnozz_OpenFramebuffer,
 85 NULL,
 86 Pnozz_SetMode,
 87 Pnozz_SetViewport,
 88 Pnozz_GetViewport,
 89 PnozzSync,
 90 Pnozz_FillRect,
 91 Pnozz_BlitRect,
 92 NULL
 93};
 94
 95
71CARD32 MaxClip, junk; 96CARD32 MaxClip, junk;
72 97
73void 98void
74PnozzSync(ScrnInfoPtr pScrn) 99PnozzSync(ScrnInfoPtr pScrn)
75{ 100{
76 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 101 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
77 while((pnozz_read_4(pPnozz, ENGINE_STATUS) &  102 while((pnozz_read_4(pPnozz, ENGINE_STATUS) &
78 (ENGINE_BUSY | BLITTER_BUSY)) !=0 ); 103 (ENGINE_BUSY | BLITTER_BUSY)) !=0 );
79} 104}
80 105
81/* 106/*
82 * Both the framebuffer and the colour registers are apparently little endian. 107 * Both the framebuffer and the colour registers are apparently little endian.
83 * For framebuffer accesses we can just turn on byte swapping, for the colour 108 * For framebuffer accesses we can just turn on byte swapping, for the colour
84 * registers we need to juggle bytes ourselves. 109 * registers we need to juggle bytes ourselves.
85 */ 110 */
86 111
87static void 112void
88pnozz_write_colour(PnozzPtr pPnozz, int reg, CARD32 colour) 113pnozz_write_colour(PnozzPtr pPnozz, int reg, CARD32 colour)
89{ 114{
90 CARD32 c2; 115 CARD32 c2;
91  116
92 switch(pPnozz->depthshift)  117 switch(pPnozz->depthshift)
93 { 118 {
94 case 0: 119 case 0:
95 c2 = (colour << 8 | colour); 120 c2 = (colour << 8 | colour);
96 pnozz_write_4(pPnozz, reg, c2 << 16 | c2); 121 pnozz_write_4(pPnozz, reg, c2 << 16 | c2);
97 break; 122 break;
98 case 1: 123 case 1:
99 c2 = ((colour & 0xff) << 8) | ((colour & 0xff00) >> 8); 124 c2 = ((colour & 0xff) << 8) | ((colour & 0xff00) >> 8);
100 c2 |= c2 << 16; 125 c2 |= c2 << 16;
101 pnozz_write_4(pPnozz, reg, c2); 126 pnozz_write_4(pPnozz, reg, c2);
102 break; 127 break;
103 case 2: 128 case 2:
104 c2 = ((colour & 0x00ff00ff) << 8) | ((colour & 0xff00ff00) >> 8); 129 c2 = ((colour & 0x00ff00ff) << 8) | ((colour & 0xff00ff00) >> 8);
105 c2 = (( c2 & 0xffff0000) >> 16) | ((c2 & 0x0000ffff) << 16); 130 c2 = (( c2 & 0xffff0000) >> 16) | ((c2 & 0x0000ffff) << 16);
106 pnozz_write_4(pPnozz, reg, c2); 131 pnozz_write_4(pPnozz, reg, c2);
107 break; 132 break;
108 } 133 }
109} 134}
110 135
111static void unClip(PnozzPtr pPnozz) 136static void unClip(PnozzPtr pPnozz)
112{ 137{
113 pnozz_write_4(pPnozz, WINDOW_OFFSET, 0); 138 pnozz_write_4(pPnozz, WINDOW_OFFSET, 0);
114 pnozz_write_4(pPnozz, WINDOW_MIN, 0); 139 pnozz_write_4(pPnozz, WINDOW_MIN, 0);
115 pnozz_write_4(pPnozz, WINDOW_MAX, MaxClip); 140 pnozz_write_4(pPnozz, WINDOW_MAX, MaxClip);
116 pnozz_write_4(pPnozz, BYTE_CLIP_MIN, 0); 141 pnozz_write_4(pPnozz, BYTE_CLIP_MIN, 0);
117 pnozz_write_4(pPnozz, BYTE_CLIP_MAX, MaxClip); 142 pnozz_write_4(pPnozz, BYTE_CLIP_MAX, MaxClip);
118} 143}
119 144
120static void 145void
121PnozzInitEngine(PnozzPtr pPnozz) 146PnozzInitEngine(PnozzPtr pPnozz)
122{ 147{
123 unClip(pPnozz); 148 unClip(pPnozz);
124 pnozz_write_4(pPnozz, DRAW_MODE, 0); 149 pnozz_write_4(pPnozz, DRAW_MODE, 0);
125 pnozz_write_4(pPnozz, PLANE_MASK, 0xffffffff);  150 pnozz_write_4(pPnozz, PLANE_MASK, 0xffffffff);
126 pnozz_write_4(pPnozz, PATTERN0, 0xffffffff);  151 pnozz_write_4(pPnozz, PATTERN0, 0xffffffff);
127 pnozz_write_4(pPnozz, PATTERN1, 0xffffffff);  152 pnozz_write_4(pPnozz, PATTERN1, 0xffffffff);
128 pnozz_write_4(pPnozz, PATTERN2, 0xffffffff);  153 pnozz_write_4(pPnozz, PATTERN2, 0xffffffff);
129 pnozz_write_4(pPnozz, PATTERN3, 0xffffffff);  154 pnozz_write_4(pPnozz, PATTERN3, 0xffffffff);
130} 155}
131 156
132static void 157static void
133PnozzSetupForScreenToScreenCopy( 158PnozzSetupForScreenToScreenCopy(
134 ScrnInfoPtr pScrn, 159 ScrnInfoPtr pScrn,
135 int xdir, 160 int xdir,
136 int ydir, 161 int ydir,
137 int rop, 162 int rop,
138 unsigned int planemask, 163 unsigned int planemask,
139 int TransparencyColour 164 int TransparencyColour
140) 165)
141{ 166{
142 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 167 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
143 PnozzSync(pScrn); 168 PnozzSync(pScrn);
144 169
145 pnozz_write_4(pPnozz, RASTER_OP, (PnozzCopyROP[rop] & 0xff)); 170 pnozz_write_4(pPnozz, RASTER_OP, (PnozzCopyROP[rop] & 0xff));
146 pnozz_write_4(pPnozz, PLANE_MASK, planemask); 171 pnozz_write_4(pPnozz, PLANE_MASK, planemask);
147} 172}
148 173
149/* 174/*
150 * the drawing engine is weird. Even though BLIT and QUAD commands use the 175 * the drawing engine is weird. Even though BLIT and QUAD commands use the
151 * same registers to program coordinates there's an important difference - 176 * same registers to program coordinates there's an important difference -
152 * horizontal coordinates for QUAD commands are in pixels, for BLIT commands 177 * horizontal coordinates for QUAD commands are in pixels, for BLIT commands
153 * and the byte clipping registers they're IN BYTES. 178 * and the byte clipping registers they're IN BYTES.
154 */ 179 */
155static void 180static void
156PnozzSubsequentScreenToScreenCopy 181PnozzSubsequentScreenToScreenCopy
157( 182(
158 ScrnInfoPtr pScrn, 183 ScrnInfoPtr pScrn,
159 int xSrc, 184 int xSrc,
160 int ySrc, 185 int ySrc,
161 int xDst, 186 int xDst,
162 int yDst, 187 int yDst,
163 int w, 188 int w,
164 int h 189 int h
165) 190)
166{ 191{
167 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 192 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
168 CARD32 src, dst, srcw, dstw; 193 CARD32 src, dst, srcw, dstw;
169  194
170 src = (((xSrc << pPnozz->depthshift) & 0x1fff) << 16) | (ySrc & 0x1fff); 195 src = (((xSrc << pPnozz->depthshift) & 0x1fff) << 16) | (ySrc & 0x1fff);
171 dst = (((xDst << pPnozz->depthshift) & 0x1fff) << 16) | (yDst & 0x1fff); 196 dst = (((xDst << pPnozz->depthshift) & 0x1fff) << 16) | (yDst & 0x1fff);
172 srcw = ((((xSrc + w) << pPnozz->depthshift) - 1) << 16) |  197 srcw = ((((xSrc + w) << pPnozz->depthshift) - 1) << 16) |
173 ((ySrc + h - 1) & 0x1fff); 198 ((ySrc + h - 1) & 0x1fff);
174 dstw = ((((xDst + w) << pPnozz->depthshift) - 1) << 16) | 199 dstw = ((((xDst + w) << pPnozz->depthshift) - 1) << 16) |
175 ((yDst + h - 1) & 0x1fff); 200 ((yDst + h - 1) & 0x1fff);
176 201
177 PnozzSync(pScrn); 202 PnozzSync(pScrn);
178 203
179 pnozz_write_4(pPnozz, ABS_XY0, src); 204 pnozz_write_4(pPnozz, ABS_XY0, src);
180 pnozz_write_4(pPnozz, ABS_XY1, srcw); 205 pnozz_write_4(pPnozz, ABS_XY1, srcw);
181 pnozz_write_4(pPnozz, ABS_XY2, dst); 206 pnozz_write_4(pPnozz, ABS_XY2, dst);
182 pnozz_write_4(pPnozz, ABS_XY3, dstw); 207 pnozz_write_4(pPnozz, ABS_XY3, dstw);
183 junk = pnozz_read_4(pPnozz, COMMAND_BLIT); 208 junk = pnozz_read_4(pPnozz, COMMAND_BLIT);
184} 209}
185 210
186static void 211static void
187PnozzSetupForSolidFill 212PnozzSetupForSolidFill
188( 213(
189 ScrnInfoPtr pScrn, 214 ScrnInfoPtr pScrn,
190 int colour, 215 int colour,
191 int rop, 216 int rop,
192 unsigned int planemask 217 unsigned int planemask
193) 218)
194{ 219{
195 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 220 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
196 CARD32 c2; 221 CARD32 c2;
197 222
198 PnozzSync(pScrn); 223 PnozzSync(pScrn);
199 224
200 pnozz_write_colour(pPnozz, FOREGROUND_COLOR, colour); 225 pnozz_write_colour(pPnozz, FOREGROUND_COLOR, colour);
201 pnozz_write_4(pPnozz, RASTER_OP, PnozzDrawROP[rop] & 0xff); 226 pnozz_write_4(pPnozz, RASTER_OP, PnozzDrawROP[rop] & 0xff);
202 pnozz_write_4(pPnozz, PLANE_MASK, planemask); 227 pnozz_write_4(pPnozz, PLANE_MASK, planemask);
203 pnozz_write_4(pPnozz, COORD_INDEX, 0); 228 pnozz_write_4(pPnozz, COORD_INDEX, 0);
204} 229}
205 230
206static void 231static void
207PnozzSubsequentSolidFillRect 232PnozzSubsequentSolidFillRect
208( 233(
209 ScrnInfoPtr pScrn, 234 ScrnInfoPtr pScrn,
210 int x, 235 int x,
211 int y, 236 int y,
212 int w, 237 int w,
213 int h 238 int h
214) 239)
215{ 240{
216 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 241 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
217  242
218 PnozzSync(pScrn); 243 PnozzSync(pScrn);
219 pnozz_write_4(pPnozz, RECT_RTW_XY, ((x & 0x1fff) << 16) |  244 pnozz_write_4(pPnozz, RECT_RTW_XY, ((x & 0x1fff) << 16) |
220 (y & 0x1fff)); 245 (y & 0x1fff));
221 pnozz_write_4(pPnozz, RECT_RTP_XY, (((w & 0x1fff) << 16) |  246 pnozz_write_4(pPnozz, RECT_RTP_XY, (((w & 0x1fff) << 16) |
222 (h & 0x1fff))); 247 (h & 0x1fff)));
223 junk = pnozz_read_4(pPnozz, COMMAND_QUAD); 248 junk = pnozz_read_4(pPnozz, COMMAND_QUAD);
224} 249}
225 250
 251#ifdef HAVE_XAA_H
 252
226static void  253static void
227PnozzSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, 254PnozzSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn,
228 int fg, int bg, 255 int fg, int bg,
229 int rop, 256 int rop,
230 unsigned int planemask) 257 unsigned int planemask)
231{ 258{
232 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 259 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
233  260
234 PnozzSync(pScrn); 261 PnozzSync(pScrn);
235  262
236 if (bg == -1) { 263 if (bg == -1) {
237 /* transparent */ 264 /* transparent */
238 pnozz_write_colour(pPnozz, FOREGROUND_COLOR, fg);  265 pnozz_write_colour(pPnozz, FOREGROUND_COLOR, fg);
239 pnozz_write_4(pPnozz, RASTER_OP, PnozzDrawROP[rop] | ROP_PIX1_TRANS); 266 pnozz_write_4(pPnozz, RASTER_OP, PnozzDrawROP[rop] | ROP_PIX1_TRANS);
240 } else { 267 } else {
241 /*  268 /*
242 * this doesn't make any sense to me either, but for some reason the 269 * this doesn't make any sense to me either, but for some reason the
243 * chip applies the foreground colour to 0 pixels and background to 1 270 * chip applies the foreground colour to 0 pixels and background to 1
244 * when set to this sort of ROP. The old XF 3.3 driver source claimed 271 * when set to this sort of ROP. The old XF 3.3 driver source claimed
245 * that the chip doesn't support opaque colour expansion at all. 272 * that the chip doesn't support opaque colour expansion at all.
246 */ 273 */
247 pnozz_write_colour(pPnozz, FOREGROUND_COLOR, bg); 274 pnozz_write_colour(pPnozz, FOREGROUND_COLOR, bg);
248 pnozz_write_colour(pPnozz, BACKGROUND_COLOR, fg); 275 pnozz_write_colour(pPnozz, BACKGROUND_COLOR, fg);
249  276
250 pnozz_write_4(pPnozz, RASTER_OP, PnozzCopyROP[rop] & 0xff); 277 pnozz_write_4(pPnozz, RASTER_OP, PnozzCopyROP[rop] & 0xff);
251 } 278 }
252  279
253 pnozz_write_4(pPnozz, PLANE_MASK, planemask); 280 pnozz_write_4(pPnozz, PLANE_MASK, planemask);
254 pnozz_write_4(pPnozz, COORD_INDEX, 0); 281 pnozz_write_4(pPnozz, COORD_INDEX, 0);
255} 282}
256 283
257static void  284static void
258PnozzSubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, 285PnozzSubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn,
259 int x, int y, int w, int h, 286 int x, int y, int w, int h,
260 int skipleft ) 287 int skipleft )
261{ 288{
262 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 289 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
263 CARD32 rest = w & 0x1f; 290 CARD32 rest = w & 0x1f;
264  291
265 pnozz_write_4(pPnozz, ABS_X0, x); 292 pnozz_write_4(pPnozz, ABS_X0, x);
266 pnozz_write_4(pPnozz, ABS_XY1, (x << 16) | (y & 0xFFFFL)); 293 pnozz_write_4(pPnozz, ABS_XY1, (x << 16) | (y & 0xFFFFL));
267 pnozz_write_4(pPnozz, ABS_X2, (x + w)); 294 pnozz_write_4(pPnozz, ABS_X2, (x + w));
268 pnozz_write_4(pPnozz, ABS_Y3, 1); 295 pnozz_write_4(pPnozz, ABS_Y3, 1);
269 296
270 pPnozz->words = (w >> 5); /* whole words to write */ 297 pPnozz->words = (w >> 5); /* whole words to write */
271  298
272 if (rest > 0) { 299 if (rest > 0) {
273 pPnozz->last_word = (rest - 1) << 2; 300 pPnozz->last_word = (rest - 1) << 2;
274 } else 301 } else
275 pPnozz->last_word = -1; 302 pPnozz->last_word = -1;
276} 303}
277 304
278static void 305static void
279PnozzSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) 306PnozzSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno)
280{ 307{
281 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 308 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
282#define PIXEL_1_FULL (PIXEL_1 + (31 << 2)) 309#define PIXEL_1_FULL (PIXEL_1 + (31 << 2))
283 CARD32 *buf; 310 CARD32 *buf;
284 volatile CARD32 *pix = ((volatile CARD32 *)(pPnozz->fbc + PIXEL_1_FULL)); 311 volatile CARD32 *pix = ((volatile CARD32 *)(pPnozz->fbc + PIXEL_1_FULL));
285 int i = 0; 312 int i = 0;
286 313
287 PnozzSync(pScrn); 314 PnozzSync(pScrn);
288 buf = (CARD32 *)pPnozz->buffers[bufno]; 315 buf = (CARD32 *)pPnozz->buffers[bufno];
289 junk = *(volatile CARD32 *)(pPnozz->fb + PIXEL_1_FULL); 316 junk = *(volatile CARD32 *)(pPnozz->fb + PIXEL_1_FULL);
290 for (i = 0; i < pPnozz->words; i++) 317 for (i = 0; i < pPnozz->words; i++)
291 *pix = buf[i]; 318 *pix = buf[i];
292 if (pPnozz->last_word >= 0) 319 if (pPnozz->last_word >= 0)
293 *(volatile CARD32 *)(pPnozz->fbc + PIXEL_1 + pPnozz->last_word) = 320 *(volatile CARD32 *)(pPnozz->fbc + PIXEL_1 + pPnozz->last_word) =
294 buf[i]; 321 buf[i];
295} 322}
296 323
297static void  324static void
298PnozzSetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop,  325PnozzSetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop,
299 unsigned int planemask) 326 unsigned int planemask)
300{ 327{
301 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 328 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
302 329
303 PnozzSync(pScrn); 330 PnozzSync(pScrn);
304  331
305 pnozz_write_colour(pPnozz, FOREGROUND_COLOR, color);  332 pnozz_write_colour(pPnozz, FOREGROUND_COLOR, color);
306 pnozz_write_4(pPnozz, RASTER_OP, (PnozzDrawROP[rop] & 0xff) | ROP_OVERSIZE); 333 pnozz_write_4(pPnozz, RASTER_OP, (PnozzDrawROP[rop] & 0xff) | ROP_OVERSIZE);
307  334
308 pnozz_write_4(pPnozz, PLANE_MASK, planemask); 335 pnozz_write_4(pPnozz, PLANE_MASK, planemask);
309 pnozz_write_4(pPnozz, COORD_INDEX, 0); 336 pnozz_write_4(pPnozz, COORD_INDEX, 0);
310 337
311} 338}
312 339
313static void 340static void
314PnozzSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, int x1, int y1, int x2, 341PnozzSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, int x1, int y1, int x2,
315 int y2, int flags) 342 int y2, int flags)
316{ 343{
317 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 344 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
318 345
319 PnozzSync(pScrn); 346 PnozzSync(pScrn);
320  347
321 /*  348 /*
322 * XXX we're blatantly ignoring the flags parameter which could tell us not  349 * XXX we're blatantly ignoring the flags parameter which could tell us not
323 * to draw the last point. Xsun simply reads it from the framebuffer and  350 * to draw the last point. Xsun simply reads it from the framebuffer and
324 * puts it back after drawing the line but that would mean we have to wait  351 * puts it back after drawing the line but that would mean we have to wait
325 * until the line is actually drawn. On the other hand - line drawing is  352 * until the line is actually drawn. On the other hand - line drawing is
326 * pretty fast so we won't lose too much speed 353 * pretty fast so we won't lose too much speed
327 */ 354 */
328 pnozz_write_4(pPnozz, LINE_RTW_XY, (x1 << 16) | y1); 355 pnozz_write_4(pPnozz, LINE_RTW_XY, (x1 << 16) | y1);
329 pnozz_write_4(pPnozz, LINE_RTW_XY, (x2 << 16) | y2); 356 pnozz_write_4(pPnozz, LINE_RTW_XY, (x2 << 16) | y2);
330 junk = pnozz_read_4(pPnozz, COMMAND_QUAD); 357 junk = pnozz_read_4(pPnozz, COMMAND_QUAD);
331}  358}
332 359
333static void 360static void
334PnozzSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int pat0, int pat1, 361PnozzSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int pat0, int pat1,
335 int fg, int bg, int rop, unsigned int planemask) 362 int fg, int bg, int rop, unsigned int planemask)
336{ 363{
337 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 364 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
338 CARD32 pat; 365 CARD32 pat;
339  366
340 PnozzSync(pScrn); 367 PnozzSync(pScrn);
341 368
342 if (bg == -1) { 369 if (bg == -1) {
343 pnozz_write_4(pPnozz, RASTER_OP,  370 pnozz_write_4(pPnozz, RASTER_OP,
344 (PnozzDrawROP[rop] & 0xff) | ROP_NO_SOLID | ROP_TRANS); 371 (PnozzDrawROP[rop] & 0xff) | ROP_NO_SOLID | ROP_TRANS);
345 } else { 372 } else {
346 pnozz_write_colour(pPnozz, COLOR_0, bg); 373 pnozz_write_colour(pPnozz, COLOR_0, bg);
347 pnozz_write_4(pPnozz, RASTER_OP, 374 pnozz_write_4(pPnozz, RASTER_OP,
348 (PnozzDrawROP[rop] & 0xff) | ROP_NO_SOLID); 375 (PnozzDrawROP[rop] & 0xff) | ROP_NO_SOLID);
349 } 376 }
350 pnozz_write_colour(pPnozz, COLOR_1, fg); 377 pnozz_write_colour(pPnozz, COLOR_1, fg);
351 pnozz_write_4(pPnozz, PLANE_MASK, planemask); 378 pnozz_write_4(pPnozz, PLANE_MASK, planemask);
352 pat = (pat0 & 0xff000000) | ((pat0 >> 8) & 0x00ffff00) |  379 pat = (pat0 & 0xff000000) | ((pat0 >> 8) & 0x00ffff00) |
353 ((pat0 >> 16) & 0x000000ff); 380 ((pat0 >> 16) & 0x000000ff);
354 pnozz_write_4(pPnozz, PATTERN0, pat); 381 pnozz_write_4(pPnozz, PATTERN0, pat);
355 pat = ((pat0 << 8) & 0x00ffff00) | ((pat0 << 16) & 0xff000000) |  382 pat = ((pat0 << 8) & 0x00ffff00) | ((pat0 << 16) & 0xff000000) |
356 (pat0 & 0x000000ff); 383 (pat0 & 0x000000ff);
357 pnozz_write_4(pPnozz, PATTERN1, pat); 384 pnozz_write_4(pPnozz, PATTERN1, pat);
358 pat = (pat1 & 0xff000000) | ((pat1 >> 8) & 0x00ffff00) |  385 pat = (pat1 & 0xff000000) | ((pat1 >> 8) & 0x00ffff00) |
359 ((pat1 >> 16) & 0x000000ff); 386 ((pat1 >> 16) & 0x000000ff);
360 pnozz_write_4(pPnozz, PATTERN2, pat); 387 pnozz_write_4(pPnozz, PATTERN2, pat);
361 pat = ((pat1 << 8) & 0x00ffff00) | ((pat1 << 16) & 0xff000000) |  388 pat = ((pat1 << 8) & 0x00ffff00) | ((pat1 << 16) & 0xff000000) |
362 (pat1 & 0x000000ff); 389 (pat1 & 0x000000ff);
363 pnozz_write_4(pPnozz, PATTERN3, pat); 390 pnozz_write_4(pPnozz, PATTERN3, pat);
364 pnozz_write_4(pPnozz, COORD_INDEX, 0); 391 pnozz_write_4(pPnozz, COORD_INDEX, 0);
365} 392}
366 393
367static void 394static void
368PnozzSubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, 395PnozzSubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn,
369 int patx, int paty, int x, int y, int w, int h) 396 int patx, int paty, int x, int y, int w, int h)
370{ 397{
371 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 398 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
372  399
373 PnozzSync(pScrn); 400 PnozzSync(pScrn);
374 pnozz_write_4(pPnozz, PATTERN_ORIGIN_X, patx); 401 pnozz_write_4(pPnozz, PATTERN_ORIGIN_X, patx);
375 pnozz_write_4(pPnozz, PATTERN_ORIGIN_Y, paty); 402 pnozz_write_4(pPnozz, PATTERN_ORIGIN_Y, paty);
376 pnozz_write_4(pPnozz, RECT_RTW_XY, ((x & 0x1fff) << 16) |  403 pnozz_write_4(pPnozz, RECT_RTW_XY, ((x & 0x1fff) << 16) |
377 (y & 0x1fff)); 404 (y & 0x1fff));
378 pnozz_write_4(pPnozz, RECT_RTP_XY, (((w & 0x1fff) << 16) |  405 pnozz_write_4(pPnozz, RECT_RTP_XY, (((w & 0x1fff) << 16) |
379 (h & 0x1fff))); 406 (h & 0x1fff)));
380 junk = pnozz_read_4(pPnozz, COMMAND_QUAD); 407 junk = pnozz_read_4(pPnozz, COMMAND_QUAD);
381 408
382} 409}
383 410
384static void 411static void
385PnozzSetClippingRectangle(ScrnInfoPtr pScrn, int left, int top, int right,  412PnozzSetClippingRectangle(ScrnInfoPtr pScrn, int left, int top, int right,
386 int bottom) 413 int bottom)
387{ 414{
388 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 415 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
389 CARD32 cmin, cmax; 416 CARD32 cmin, cmax;
390 417
391 cmin = (left << 16) | top; 418 cmin = (left << 16) | top;
392 cmax = (right << 16) | bottom; 419 cmax = (right << 16) | bottom;
393  420
394 pnozz_write_4(pPnozz, WINDOW_MIN, cmin); 421 pnozz_write_4(pPnozz, WINDOW_MIN, cmin);
395 pnozz_write_4(pPnozz, WINDOW_MAX, cmax); 422 pnozz_write_4(pPnozz, WINDOW_MAX, cmax);
396 423
397 cmin = ((left << pPnozz->depthshift) << 16) | top; 424 cmin = ((left << pPnozz->depthshift) << 16) | top;
398 cmax = ((right << pPnozz->depthshift) << 16) | bottom; 425 cmax = ((right << pPnozz->depthshift) << 16) | bottom;
399  426
400 pnozz_write_4(pPnozz, BYTE_CLIP_MIN, cmin); 427 pnozz_write_4(pPnozz, BYTE_CLIP_MIN, cmin);
401 pnozz_write_4(pPnozz, BYTE_CLIP_MAX, cmax); 428 pnozz_write_4(pPnozz, BYTE_CLIP_MAX, cmax);
402} 429}
403 430
404static void 431static void
405PnozzDisableClipping(ScrnInfoPtr pScrn) 432PnozzDisableClipping(ScrnInfoPtr pScrn)
406{ 433{
407 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 434 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
408 435
409 pnozz_write_4(pPnozz, WINDOW_MIN, 0); 436 pnozz_write_4(pPnozz, WINDOW_MIN, 0);
410 pnozz_write_4(pPnozz, WINDOW_MAX, MaxClip); 437 pnozz_write_4(pPnozz, WINDOW_MAX, MaxClip);
411 pnozz_write_4(pPnozz, BYTE_CLIP_MIN, 0); 438 pnozz_write_4(pPnozz, BYTE_CLIP_MIN, 0);
412 pnozz_write_4(pPnozz, BYTE_CLIP_MAX, MaxClip); 439 pnozz_write_4(pPnozz, BYTE_CLIP_MAX, MaxClip);
413} 440}
414 441
415static void 442static void
416PnozzSetupForImageWrite(ScrnInfoPtr pScrn, int rop, unsigned int planemask, 443PnozzSetupForImageWrite(ScrnInfoPtr pScrn, int rop, unsigned int planemask,
417 int trans_color, int depth, int bpp) 444 int trans_color, int depth, int bpp)
418{ 445{
419 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 446 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
420 447
421 pnozz_write_4(pPnozz, RASTER_OP, PnozzCopyROP[rop] & 0xff); 448 pnozz_write_4(pPnozz, RASTER_OP, PnozzCopyROP[rop] & 0xff);
422 pnozz_write_4(pPnozz, PLANE_MASK, planemask); 449 pnozz_write_4(pPnozz, PLANE_MASK, planemask);
423 pnozz_write_4(pPnozz, COORD_INDEX, 0); 450 pnozz_write_4(pPnozz, COORD_INDEX, 0);
424  451
425 xf86Msg(X_ERROR, "setup for image write\n"); 452 xf86Msg(X_ERROR, "setup for image write\n");
426} 453}
427 454
428static void 455static void
429PnozzImageWriteRect(ScrnInfoPtr pScrn, int x, int y, int wi, int he, int skip) 456PnozzImageWriteRect(ScrnInfoPtr pScrn, int x, int y, int wi, int he, int skip)
430{ 457{
431 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 458 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
432 volatile CARD32 junk; 459 volatile CARD32 junk;
433  460
434 pnozz_write_4(pPnozz, ABS_X0, x); 461 pnozz_write_4(pPnozz, ABS_X0, x);
435 pnozz_write_4(pPnozz, ABS_XY1, (x << 16) | y); 462 pnozz_write_4(pPnozz, ABS_XY1, (x << 16) | y);
436 pnozz_write_4(pPnozz, ABS_X2, x + wi); 463 pnozz_write_4(pPnozz, ABS_X2, x + wi);
437 pnozz_write_4(pPnozz, ABS_Y3, 1); 464 pnozz_write_4(pPnozz, ABS_Y3, 1);
438 junk = *(volatile CARD32 *)(pPnozz->fb + PIXEL_8); 465 junk = *(volatile CARD32 *)(pPnozz->fb + PIXEL_8);
439} 466}
440 467
441/* 468/*
442 * TODO: 469 * TODO:
443 * - CPU to VRAM colour blits 470 * - CPU to VRAM colour blits
444 * - DGA support 
445 */ 471 */
446 472
447int 473int
448PnozzAccelInit(ScrnInfoPtr pScrn) 474PnozzAccelInit(ScrnInfoPtr pScrn)
449{ 475{
450 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 476 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
451 XAAInfoRecPtr pXAAInfo = pPnozz->pXAA; 477 XAAInfoRecPtr pXAAInfo = pPnozz->pXAA;
452 478
453 pXAAInfo->Flags = LINEAR_FRAMEBUFFER | PIXMAP_CACHE | OFFSCREEN_PIXMAPS; 479 pXAAInfo->Flags = LINEAR_FRAMEBUFFER | PIXMAP_CACHE | OFFSCREEN_PIXMAPS;
454 pXAAInfo->maxOffPixWidth = pPnozz->width; 480 pXAAInfo->maxOffPixWidth = pPnozz->width;
455 pXAAInfo->maxOffPixHeight = pPnozz->maxheight; 481 pXAAInfo->maxOffPixHeight = pPnozz->maxheight;
456 MaxClip = ((pPnozz->scanlinesize & 0xffff) << 16) | (pPnozz->maxheight); 482 MaxClip = ((pPnozz->scanlinesize & 0xffff) << 16) | (pPnozz->maxheight);
457  483
458 PnozzInitEngine(pPnozz); 484 PnozzInitEngine(pPnozz);
459  485
460#if 1 486#if 1
461 { 487 {
462 CARD32 src, srcw, junk; 488 CARD32 src, srcw, junk;
463 src = 0; 489 src = 0;
464 srcw = pPnozz->width << 16 | pPnozz->height; 490 srcw = pPnozz->width << 16 | pPnozz->height;
465  491
466 /* Blit the screen black. For aesthetic reasons. */ 492 /* Blit the screen black. For aesthetic reasons. */
467  493
468 PnozzSync(pScrn); 494 PnozzSync(pScrn);
469 pnozz_write_4(pPnozz, FOREGROUND_COLOR, 0x00000000); 495 pnozz_write_4(pPnozz, FOREGROUND_COLOR, 0x00000000);
470 pnozz_write_4(pPnozz, BACKGROUND_COLOR, 0xffffffff); 496 pnozz_write_4(pPnozz, BACKGROUND_COLOR, 0xffffffff);
471 pnozz_write_4(pPnozz, RASTER_OP, ROP_PAT); 497 pnozz_write_4(pPnozz, RASTER_OP, ROP_PAT);
472 pnozz_write_4(pPnozz, COORD_INDEX, 0); 498 pnozz_write_4(pPnozz, COORD_INDEX, 0);
473 pnozz_write_4(pPnozz, RECT_RTW_XY, src); 499 pnozz_write_4(pPnozz, RECT_RTW_XY, src);
474 pnozz_write_4(pPnozz, RECT_RTW_XY, srcw);  500 pnozz_write_4(pPnozz, RECT_RTW_XY, srcw);
475 junk = pnozz_read_4(pPnozz, COMMAND_QUAD); 501 junk = pnozz_read_4(pPnozz, COMMAND_QUAD);
476 PnozzSync(pScrn); 502 PnozzSync(pScrn);
477 } 503 }
478#endif 504#endif
479 505
480 /* Sync */ 506 /* Sync */
481 pXAAInfo->Sync = PnozzSync; 507 pXAAInfo->Sync = PnozzSync;
482 508
483 /* Screen-to-screen copy */ 509 /* Screen-to-screen copy */
484 pXAAInfo->ScreenToScreenCopyFlags = NO_TRANSPARENCY; 510 pXAAInfo->ScreenToScreenCopyFlags = NO_TRANSPARENCY;
485 pXAAInfo->SetupForScreenToScreenCopy = PnozzSetupForScreenToScreenCopy; 511 pXAAInfo->SetupForScreenToScreenCopy = PnozzSetupForScreenToScreenCopy;
486 pXAAInfo->SubsequentScreenToScreenCopy = 512 pXAAInfo->SubsequentScreenToScreenCopy =
487 PnozzSubsequentScreenToScreenCopy; 513 PnozzSubsequentScreenToScreenCopy;
488 514
489 /* Solid fills */ 515 /* Solid fills */
490 pXAAInfo->SetupForSolidFill = PnozzSetupForSolidFill; 516 pXAAInfo->SetupForSolidFill = PnozzSetupForSolidFill;
491 pXAAInfo->SubsequentSolidFillRect = PnozzSubsequentSolidFillRect; 517 pXAAInfo->SubsequentSolidFillRect = PnozzSubsequentSolidFillRect;
492 518
493 /* colour expansion */ 519 /* colour expansion */
494 pXAAInfo->ScanlineCPUToScreenColorExpandFillFlags =  520 pXAAInfo->ScanlineCPUToScreenColorExpandFillFlags =
495 /*LEFT_EDGE_CLIPPING|*/SCANLINE_PAD_DWORD; 521 /*LEFT_EDGE_CLIPPING|*/SCANLINE_PAD_DWORD;
496 pXAAInfo->NumScanlineColorExpandBuffers = 2; 522 pXAAInfo->NumScanlineColorExpandBuffers = 2;
497 pPnozz->buffers[0] = (unsigned char *)pPnozz->Buffer; 523 pPnozz->buffers[0] = (unsigned char *)pPnozz->Buffer;
498 pPnozz->buffers[1] = (unsigned char *)&pPnozz->Buffer[pPnozz->scanlinesize]; 524 pPnozz->buffers[1] = (unsigned char *)&pPnozz->Buffer[pPnozz->scanlinesize];
499 pXAAInfo->ScanlineColorExpandBuffers = pPnozz->buffers; 525 pXAAInfo->ScanlineColorExpandBuffers = pPnozz->buffers;
500 pXAAInfo->SetupForScanlineCPUToScreenColorExpandFill =  526 pXAAInfo->SetupForScanlineCPUToScreenColorExpandFill =
501 PnozzSetupForCPUToScreenColorExpandFill; 527 PnozzSetupForCPUToScreenColorExpandFill;
502 pXAAInfo->SubsequentScanlineCPUToScreenColorExpandFill = 528 pXAAInfo->SubsequentScanlineCPUToScreenColorExpandFill =
503 PnozzSubsequentScanlineCPUToScreenColorExpandFill; 529 PnozzSubsequentScanlineCPUToScreenColorExpandFill;
504 pXAAInfo->SubsequentColorExpandScanline = 530 pXAAInfo->SubsequentColorExpandScanline =
505 PnozzSubsequentColorExpandScanline; 531 PnozzSubsequentColorExpandScanline;
506 532
507 /* line drawing */ 533 /* line drawing */
508 pXAAInfo->SetupForSolidLine = PnozzSetupForSolidLine; 534 pXAAInfo->SetupForSolidLine = PnozzSetupForSolidLine;
509 pXAAInfo->SubsequentSolidTwoPointLine = PnozzSubsequentSolidTwoPointLine; 535 pXAAInfo->SubsequentSolidTwoPointLine = PnozzSubsequentSolidTwoPointLine;
510 pXAAInfo->SolidLineFlags = BIT_ORDER_IN_BYTE_MSBFIRST; 536 pXAAInfo->SolidLineFlags = BIT_ORDER_IN_BYTE_MSBFIRST;
511 537
512 /* clipping */ 538 /* clipping */
513 pXAAInfo->SetClippingRectangle = PnozzSetClippingRectangle; 539 pXAAInfo->SetClippingRectangle = PnozzSetClippingRectangle;
514 pXAAInfo->DisableClipping = PnozzDisableClipping; 540 pXAAInfo->DisableClipping = PnozzDisableClipping;
515 pXAAInfo->ClippingFlags = HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY | 541 pXAAInfo->ClippingFlags = HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY |
516 HARDWARE_CLIP_SOLID_FILL | 542 HARDWARE_CLIP_SOLID_FILL |
517 HARDWARE_CLIP_MONO_8x8_FILL | 543 HARDWARE_CLIP_MONO_8x8_FILL |
518 /*HARDWARE_CLIP_COLOR_8x8_FILL |*/ 544 /*HARDWARE_CLIP_COLOR_8x8_FILL |*/
519 HARDWARE_CLIP_SOLID_LINE; 545 HARDWARE_CLIP_SOLID_LINE;
520 546
521 /* 8x8 mono pattern fills */ 547 /* 8x8 mono pattern fills */
522 pXAAInfo->Mono8x8PatternFillFlags = HARDWARE_PATTERN_PROGRAMMED_BITS | 548 pXAAInfo->Mono8x8PatternFillFlags = HARDWARE_PATTERN_PROGRAMMED_BITS |
523 HARDWARE_PATTERN_SCREEN_ORIGIN | HARDWARE_PATTERN_PROGRAMMED_ORIGIN; 549 HARDWARE_PATTERN_SCREEN_ORIGIN | HARDWARE_PATTERN_PROGRAMMED_ORIGIN;
524 pXAAInfo->SetupForMono8x8PatternFill = PnozzSetupForMono8x8PatternFill; 550 pXAAInfo->SetupForMono8x8PatternFill = PnozzSetupForMono8x8PatternFill;
525 pXAAInfo->SubsequentMono8x8PatternFillRect = 551 pXAAInfo->SubsequentMono8x8PatternFillRect =
526 PnozzSubsequentMono8x8PatternFillRect; 552 PnozzSubsequentMono8x8PatternFillRect;
527 553
528 /* image uploads */ 554 /* image uploads */
529 pXAAInfo->ImageWriteBase = pPnozz->fbc + PIXEL_8; 555 pXAAInfo->ImageWriteBase = pPnozz->fbc + PIXEL_8;
530 pXAAInfo->ImageWriteRange = 4; 556 pXAAInfo->ImageWriteRange = 4;
531 pXAAInfo->ImageWriteFlags = /*CPU_TRANSFER_BASE_FIXED |*/ CPU_TRANSFER_PAD_DWORD | 557 pXAAInfo->ImageWriteFlags = /*CPU_TRANSFER_BASE_FIXED |*/ CPU_TRANSFER_PAD_DWORD |
532 NO_TRANSPARENCY; 558 NO_TRANSPARENCY;
533 pXAAInfo->SetupForImageWrite = PnozzSetupForImageWrite; 559 pXAAInfo->SetupForImageWrite = PnozzSetupForImageWrite;
534 pXAAInfo->SubsequentImageWriteRect = PnozzImageWriteRect; 560 pXAAInfo->SubsequentImageWriteRect = PnozzImageWriteRect;
535  561
536 return 0; 562 return 0;
537} 563}
 564
 565#endif /* HAVE_XAA_H */
 566
 567Bool
 568PnozzDGAInit(ScreenPtr pScreen)
 569{
 570 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
 571 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
 572 DGAModePtr mode;
 573 int result;
 574
 575 mode = xnfcalloc(sizeof(DGAModeRec), 1);
 576 if (mode == NULL) {
 577 xf86Msg(X_WARNING, "%s: DGA setup failed, cannot allocate memory\n",
 578 pPnozz->psdp->device);
 579 return FALSE;
 580 }
 581
 582 mode->mode = pScrn->modes;
 583 mode->flags = DGA_PIXMAP_AVAILABLE | DGA_CONCURRENT_ACCESS;
 584 if(!pPnozz->NoAccel) {
 585 mode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT;
 586 }
 587
 588 mode->imageWidth = mode->pixmapWidth = mode->viewportWidth =
 589 pScrn->virtualX;
 590 mode->imageHeight = mode->pixmapHeight = mode->viewportHeight =
 591 pScrn->virtualY;
 592
 593 mode->bytesPerScanline = mode->imageWidth;
 594
 595 mode->byteOrder = pScrn->imageByteOrder;
 596 mode->depth = 8;
 597 mode->bitsPerPixel = 8;
 598 mode->red_mask = pScrn->mask.red;
 599 mode->green_mask = pScrn->mask.green;
 600 mode->blue_mask = pScrn->mask.blue;
 601
 602 mode->visualClass = PseudoColor;
 603 mode->address = pPnozz->fb;
 604
 605 result = DGAInit(pScreen, &Pnozz_DGAFuncs, mode, 1);
 606
 607 if (result) {
 608 xf86Msg(X_INFO, "%s: DGA initialized\n",
 609 pPnozz->psdp->device);
 610 return TRUE;
 611 } else {
 612 xf86Msg(X_WARNING, "%s: DGA setup failed\n",
 613 pPnozz->psdp->device);
 614 return FALSE;
 615 }
 616}
 617
 618static Bool
 619Pnozz_OpenFramebuffer(ScrnInfoPtr pScrn, char **name,
 620 unsigned char **mem,
 621 int *size, int *offset,
 622 int *extra)
 623{
 624 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
 625
 626 *name = pPnozz->psdp->device;
 627
 628 *mem = (unsigned char*)0;
 629 *size = pPnozz->vidmem;
 630 *offset = 0;
 631 *extra = 0;
 632
 633 return TRUE;
 634}
 635
 636static Bool
 637Pnozz_SetMode(ScrnInfoPtr pScrn, DGAModePtr pMode)
 638{
 639 /*
 640 * Nothing to do, we currently only support one mode
 641 * and we are always in it.
 642 */
 643 return TRUE;
 644}
 645
 646static void
 647Pnozz_SetViewport(ScrnInfoPtr pScrn, int x, int y, int flags)
 648{
 649 /* We don't support viewports, so... */
 650}
 651
 652static int
 653Pnozz_GetViewport(ScrnInfoPtr pScrn)
 654{
 655 /* No viewports, none pending... */
 656 return 0;
 657}
 658
 659static void
 660Pnozz_FillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned long color)
 661{
 662
 663 PnozzSetupForSolidFill(pScrn, color, GXset, 8);
 664 PnozzSubsequentSolidFillRect(pScrn, x, y, w, h);
 665}
 666
 667static void
 668Pnozz_BlitRect(ScrnInfoPtr pScrn, int srcx, int srcy,
 669 int w, int h, int dstx, int dsty)
 670{
 671
 672 PnozzSetupForScreenToScreenCopy(pScrn, 0, 0, GXcopy, 8, 0);
 673 PnozzSubsequentScreenToScreenCopy(pScrn, srcx, srcy, dstx, dsty, w, h);
 674}

cvs diff -r1.2 -r1.3 xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_cursor.c (switch to unified diff)

--- xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_cursor.c 2011/05/25 23:36:39 1.2
+++ xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_cursor.c 2021/05/27 04:48:10 1.3
@@ -1,150 +1,153 @@ @@ -1,150 +1,153 @@
1/* 1/*
2 * SBus Weitek P9100 hardware cursor support 2 * SBus Weitek P9100 hardware cursor support
3 * 3 *
4 * Copyright (C) 2005 Michael Lorenz 4 * Copyright (C) 2005 Michael Lorenz
5 * 5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal 7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights 8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is 10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions: 11 * furnished to do so, subject to the following conditions:
12 * 12 *
13 * The above copyright notice and this permission notice shall be included in 13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software. 14 * all copies or substantial portions of the Software.
15 * 15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * MICHAEL LORENZ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 * MICHAEL LORENZ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */ 22 */
23/* $NetBSD: pnozz_cursor.c,v 1.2 2011/05/25 23:36:39 macallan Exp $ */ 23/* $NetBSD: pnozz_cursor.c,v 1.3 2021/05/27 04:48:10 jdc Exp $ */
 24
 25#ifdef HAVE_CONFIG_H
 26#include "config.h"
 27#endif
24 28
25#include <fcntl.h> 29#include <fcntl.h>
26#include <sys/time.h> 30#include <sys/time.h>
27#include <sys/types.h> 31#include <sys/types.h>
28#include <sys/ioctl.h> 32#include <sys/ioctl.h>
29#include <dev/sun/fbio.h> 
30#include <dev/wscons/wsconsio.h> 33#include <dev/wscons/wsconsio.h>
31 34
32#include "pnozz.h" 35#include "pnozz.h"
33 36
34static void PnozzLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src); 37static void PnozzLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src);
35static void PnozzSetCursorPosition(ScrnInfoPtr pScrn, int x, int y); 38static void PnozzSetCursorPosition(ScrnInfoPtr pScrn, int x, int y);
36static void PnozzSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg); 39static void PnozzSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg);
37 40
38static void 41static void
39PnozzLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) 42PnozzLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
40{ 43{
41 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 44 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
42  45
43 pPnozz->Cursor.set = FB_CUR_SETSHAPE; 46 pPnozz->Cursor.set = FB_CUR_SETSHAPE;
44 pPnozz->Cursor.image = src; 47 pPnozz->Cursor.image = src;
45 pPnozz->Cursor.mask = src + 0x200; 48 pPnozz->Cursor.mask = src + 0x200;
46  49
47 if (ioctl(pPnozz->psdp->fd, FBIOSCURSOR, &pPnozz->Cursor) == -1)  50 if (ioctl(pPnozz->psdp->fd, FBIOSCURSOR, &pPnozz->Cursor) == -1)
48 xf86Msg(X_ERROR, "FB_CUR_SETSHAPE failed\n"); 51 xf86Msg(X_ERROR, "FB_CUR_SETSHAPE failed\n");
49} 52}
50 53
51void  54void
52PnozzShowCursor(ScrnInfoPtr pScrn) 55PnozzShowCursor(ScrnInfoPtr pScrn)
53{ 56{
54 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 57 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
55 58
56 if (pPnozz->Cursor.enable == 0) { 59 if (pPnozz->Cursor.enable == 0) {
57 pPnozz->Cursor.enable = 1; 60 pPnozz->Cursor.enable = 1;
58 pPnozz->Cursor.set = FB_CUR_SETCUR; 61 pPnozz->Cursor.set = FB_CUR_SETCUR;
59 if (ioctl(pPnozz->psdp->fd, FBIOSCURSOR, &pPnozz->Cursor) == -1)  62 if (ioctl(pPnozz->psdp->fd, FBIOSCURSOR, &pPnozz->Cursor) == -1)
60 xf86Msg(X_ERROR, "FB_CUR_SETCUR failed\n"); 63 xf86Msg(X_ERROR, "FB_CUR_SETCUR failed\n");
61 } 64 }
62} 65}
63 66
64void 67void
65PnozzHideCursor(ScrnInfoPtr pScrn) 68PnozzHideCursor(ScrnInfoPtr pScrn)
66{ 69{
67 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 70 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
68 71
69 if (pPnozz->Cursor.enable == 1) { 72 if (pPnozz->Cursor.enable == 1) {
70 pPnozz->Cursor.enable = 0; 73 pPnozz->Cursor.enable = 0;
71 pPnozz->Cursor.set = FB_CUR_SETCUR; 74 pPnozz->Cursor.set = FB_CUR_SETCUR;
72 if (ioctl(pPnozz->psdp->fd, FBIOSCURSOR, &pPnozz->Cursor) == -1)  75 if (ioctl(pPnozz->psdp->fd, FBIOSCURSOR, &pPnozz->Cursor) == -1)
73 xf86Msg(X_ERROR, "FB_CUR_SETCUR failed\n"); 76 xf86Msg(X_ERROR, "FB_CUR_SETCUR failed\n");
74 } 77 }
75} 78}
76 79
77static void 80static void
78PnozzSetCursorPosition(ScrnInfoPtr pScrn, int x, int y) 81PnozzSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
79{ 82{
80 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 83 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
81 84
82 pPnozz->Cursor.pos.x = x + 63; 85 pPnozz->Cursor.pos.x = x + 63;
83 pPnozz->Cursor.pos.y = y + 63; 86 pPnozz->Cursor.pos.y = y + 63;
84 pPnozz->Cursor.set = FB_CUR_SETPOS; 87 pPnozz->Cursor.set = FB_CUR_SETPOS;
85 if (ioctl(pPnozz->psdp->fd, FBIOSCURSOR, &pPnozz->Cursor) == -1)  88 if (ioctl(pPnozz->psdp->fd, FBIOSCURSOR, &pPnozz->Cursor) == -1)
86 xf86Msg(X_ERROR, "FB_CUR_SETPOS failed\n"); 89 xf86Msg(X_ERROR, "FB_CUR_SETPOS failed\n");
87} 90}
88 91
89static void 92static void
90PnozzSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) 93PnozzSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
91{ 94{
92 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 95 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
93 96
94 pPnozz->Cursor.set = FB_CUR_SETCMAP; 97 pPnozz->Cursor.set = FB_CUR_SETCMAP;
95 pPnozz->Cursor.cmap.red[0] = (bg & 0xff0000) >> 16; 98 pPnozz->Cursor.cmap.red[0] = (bg & 0xff0000) >> 16;
96 pPnozz->Cursor.cmap.green[0] = (bg & 0xff00) >> 8; 99 pPnozz->Cursor.cmap.green[0] = (bg & 0xff00) >> 8;
97 pPnozz->Cursor.cmap.blue[0] = bg & 0xff; 100 pPnozz->Cursor.cmap.blue[0] = bg & 0xff;
98 pPnozz->Cursor.cmap.red[1] = (fg & 0xff0000) >> 16; 101 pPnozz->Cursor.cmap.red[1] = (fg & 0xff0000) >> 16;
99 pPnozz->Cursor.cmap.green[1] = (fg & 0xff00) >> 8; 102 pPnozz->Cursor.cmap.green[1] = (fg & 0xff00) >> 8;
100 pPnozz->Cursor.cmap.blue[1] = fg & 0xff; 103 pPnozz->Cursor.cmap.blue[1] = fg & 0xff;
101 if (ioctl(pPnozz->psdp->fd, FBIOSCURSOR, &pPnozz->Cursor) == -1)  104 if (ioctl(pPnozz->psdp->fd, FBIOSCURSOR, &pPnozz->Cursor) == -1)
102 xf86Msg(X_ERROR, "FB_CUR_SETCMAP failed\n"); 105 xf86Msg(X_ERROR, "FB_CUR_SETCMAP failed\n");
103} 106}
104 107
105Bool  108Bool
106PnozzHWCursorInit(ScreenPtr pScreen) 109PnozzHWCursorInit(ScreenPtr pScreen)
107{ 110{
108 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; 111 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
109 PnozzPtr pPnozz; 112 PnozzPtr pPnozz;
110 xf86CursorInfoPtr infoPtr; 113 xf86CursorInfoPtr infoPtr;
111 114
112 pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 115 pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
113  116
114 pPnozz->Cursor.mask = NULL; 117 pPnozz->Cursor.mask = NULL;
115 pPnozz->Cursor.image = NULL; 118 pPnozz->Cursor.image = NULL;
116 if (ioctl(pPnozz->psdp->fd, FBIOGCURSOR, &pPnozz->Cursor) == -1) { 119 if (ioctl(pPnozz->psdp->fd, FBIOGCURSOR, &pPnozz->Cursor) == -1) {
117 xf86Msg(X_ERROR, "Hardware cursor isn't available\n"); 120 xf86Msg(X_ERROR, "Hardware cursor isn't available\n");
118 return FALSE; 121 return FALSE;
119 } 122 }
120 123
121 infoPtr = xf86CreateCursorInfoRec(); 124 infoPtr = xf86CreateCursorInfoRec();
122 if(!infoPtr) return FALSE; 125 if(!infoPtr) return FALSE;
123  126
124 pPnozz->CursorInfoRec = infoPtr; 127 pPnozz->CursorInfoRec = infoPtr;
125 128
126 infoPtr->MaxWidth = 64; 129 infoPtr->MaxWidth = 64;
127 infoPtr->MaxHeight = 64; 130 infoPtr->MaxHeight = 64;
128  131
129 pPnozz->Cursor.hot.x = 63; 132 pPnozz->Cursor.hot.x = 63;
130 pPnozz->Cursor.hot.y = 63; 133 pPnozz->Cursor.hot.y = 63;
131 pPnozz->Cursor.set = FB_CUR_SETHOT; 134 pPnozz->Cursor.set = FB_CUR_SETHOT;
132 ioctl(pPnozz->psdp->fd, FBIOSCURSOR, &pPnozz->Cursor); 135 ioctl(pPnozz->psdp->fd, FBIOSCURSOR, &pPnozz->Cursor);
133  136
134 pPnozz->Cursor.cmap.red = pPnozz->pal; 137 pPnozz->Cursor.cmap.red = pPnozz->pal;
135 pPnozz->Cursor.cmap.green = pPnozz->pal + 3; 138 pPnozz->Cursor.cmap.green = pPnozz->pal + 3;
136 pPnozz->Cursor.cmap.blue = pPnozz->pal + 6; 139 pPnozz->Cursor.cmap.blue = pPnozz->pal + 6;
137  140
138 infoPtr->Flags = HARDWARE_CURSOR_AND_SOURCE_WITH_MASK | 141 infoPtr->Flags = HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
139 HARDWARE_CURSOR_TRUECOLOR_AT_8BPP /*|  142 HARDWARE_CURSOR_TRUECOLOR_AT_8BPP /*|
140 HARDWARE_CURSOR_BIT_ORDER_MSBFIRST | HARDWARE_CURSOR_NIBBLE_SWAPPED*/; 143 HARDWARE_CURSOR_BIT_ORDER_MSBFIRST | HARDWARE_CURSOR_NIBBLE_SWAPPED*/;
141 144
142 infoPtr->SetCursorColors = PnozzSetCursorColors; 145 infoPtr->SetCursorColors = PnozzSetCursorColors;
143 infoPtr->SetCursorPosition = PnozzSetCursorPosition; 146 infoPtr->SetCursorPosition = PnozzSetCursorPosition;
144 infoPtr->LoadCursorImage = PnozzLoadCursorImage; 147 infoPtr->LoadCursorImage = PnozzLoadCursorImage;
145 infoPtr->HideCursor = PnozzHideCursor; 148 infoPtr->HideCursor = PnozzHideCursor;
146 infoPtr->ShowCursor = PnozzShowCursor; 149 infoPtr->ShowCursor = PnozzShowCursor;
147 infoPtr->UseHWCursor = NULL; 150 infoPtr->UseHWCursor = NULL;
148 151
149 return xf86InitCursor(pScreen, infoPtr); 152 return xf86InitCursor(pScreen, infoPtr);
150} 153}

cvs diff -r1.6 -r1.7 xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_driver.c (switch to unified diff)

--- xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_driver.c 2016/08/16 01:27:47 1.6
+++ xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_driver.c 2021/05/27 04:48:10 1.7
@@ -1,1214 +1,1228 @@ @@ -1,1214 +1,1228 @@
1/* 1/*
2 * SBus Weitek P9100 driver 2 * SBus Weitek P9100 driver
3 * 3 *
4 * Copyright (C) 2005, 2006 Michael Lorenz 4 * Copyright (C) 2005, 2006 Michael Lorenz
5 * 5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal 7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights 8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is 10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions: 11 * furnished to do so, subject to the following conditions:
12 * 12 *
13 * The above copyright notice and this permission notice shall be included in 13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software. 14 * all copies or substantial portions of the Software.
15 * 15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * MICHAEL LORENZ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 * MICHAEL LORENZ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */ 22 */
23/* $NetBSD: pnozz_driver.c,v 1.6 2016/08/16 01:27:47 mrg Exp $ */ 23/* $NetBSD: pnozz_driver.c,v 1.7 2021/05/27 04:48:10 jdc Exp $ */
24 24
25/* 25/*
26 * this driver has been tested on SPARCbook 3GX and 3TX, it supports full  26 * this driver has been tested on SPARCbook 3GX and 3TX, it supports full
27 * acceleration in 8, 16 and 24 bit colour 27 * acceleration in 8, 16 and 24 bit colour
28 */ 28 */
29 29
30#include <fcntl.h> 30#ifdef HAVE_CONFIG_H
31#include <sys/time.h> 31#include "config.h"
32#include <sys/types.h> 32#endif
 33
33#include <sys/ioctl.h> 34#include <sys/ioctl.h>
34#include <dev/sun/fbio.h> 
35#include <dev/wscons/wsconsio.h> 
36 35
 36#include "pnozz.h"
37#include "xf86.h" 37#include "xf86.h"
38#include "xf86_OSproc.h" 38#include "xf86_OSproc.h"
39 
40#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 6 
41#include "xf86Resources.h" 
42#endif 
43#include "xf86sbusBus.h" 
44 
45#include "mipointer.h" 39#include "mipointer.h"
46#include "micmap.h" 40#include "micmap.h"
47 41
48#define DEBUG 0 42#define DEBUG 1
49 43
50#include "fb.h" 44#include "fb.h"
51#include "xf86cmap.h" 45#include "xf86cmap.h"
52#include "pnozz.h" 
53 46
54#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) > 6 47#include "compat-api.h"
55#define xf86LoaderReqSymLists(...) do {} while (0) 
56#define LoaderRefSymLists(...) do {} while (0) 
57#endif 
58 48
59static const OptionInfoRec * PnozzAvailableOptions(int chipid, int busid); 49static const OptionInfoRec * PnozzAvailableOptions(int chipid, int busid);
60static void PnozzIdentify(int flags); 50static void PnozzIdentify(int flags);
61static Bool PnozzProbe(DriverPtr drv, int flags); 51static Bool PnozzProbe(DriverPtr drv, int flags);
62static Bool PnozzPreInit(ScrnInfoPtr pScrn, int flags); 52static Bool PnozzPreInit(ScrnInfoPtr pScrn, int flags);
63static Bool PnozzScreenInit(int Index, ScreenPtr pScreen, int argc, 53static Bool PnozzScreenInit(SCREEN_INIT_ARGS_DECL);
64 char **argv); 54static Bool PnozzEnterVT(VT_FUNC_ARGS_DECL);
65static Bool PnozzEnterVT(int scrnIndex, int flags); 55static void PnozzLeaveVT(VT_FUNC_ARGS_DECL);
66static void PnozzLeaveVT(int scrnIndex, int flags); 56static Bool PnozzCloseScreen(CLOSE_SCREEN_ARGS_DECL);
67static Bool PnozzCloseScreen(int scrnIndex, ScreenPtr pScreen); 
68static Bool PnozzSaveScreen(ScreenPtr pScreen, int mode); 57static Bool PnozzSaveScreen(ScreenPtr pScreen, int mode);
69 58
70/* Required if the driver supports mode switching */ 59/* Required if the driver supports mode switching */
71static Bool PnozzSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); 60static Bool PnozzSwitchMode(SWITCH_MODE_ARGS_DECL);
72/* Required if the driver supports moving the viewport */ 61/* Required if the driver supports moving the viewport */
73static void PnozzAdjustFrame(int scrnIndex, int x, int y, int flags); 62static void PnozzAdjustFrame(ADJUST_FRAME_ARGS_DECL);
74 63
75/* Optional functions */ 64/* Optional functions */
76static void PnozzFreeScreen(int scrnIndex, int flags); 65static void PnozzFreeScreen(FREE_SCREEN_ARGS_DECL);
77static ModeStatus PnozzValidMode(int scrnIndex, DisplayModePtr mode, 66static ModeStatus PnozzValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode,
78 Bool verbose, int flags); 67 Bool verbose, int flags);
79 68
80void PnozzSync(ScrnInfoPtr); 69void PnozzSync(ScrnInfoPtr);
81void PnozzSave(PnozzPtr); 70void PnozzSave(PnozzPtr);
82void PnozzRestore(PnozzPtr); 71void PnozzRestore(PnozzPtr);
83int PnozzSetDepth(PnozzPtr, int); /* return true or false */ 72int PnozzSetDepth(PnozzPtr, int); /* return true or false */
84void DumpSCR(unsigned int); 73void DumpSCR(unsigned int);
85 74
86static void PnozzLoadPalette(ScrnInfoPtr, int, int *, LOCO *, VisualPtr); 75static void PnozzLoadPalette(ScrnInfoPtr, int, int *, LOCO *, VisualPtr);
87 76
88#define VERSION 4000 77#define VERSION 4000
89#define PNOZZ_NAME "p9100" 78#define PNOZZ_NAME "p9100"
90#define PNOZZ_DRIVER_NAME "pnozz" 79#define PNOZZ_DRIVER_NAME "pnozz"
91#define PNOZZ_MAJOR_VERSION 1 80#define PNOZZ_MAJOR_VERSION 2
92#define PNOZZ_MINOR_VERSION 0 81#define PNOZZ_MINOR_VERSION 0
93#define PNOZZ_PATCHLEVEL 0 82#define PNOZZ_PATCHLEVEL 0
94 83
95/*  84/*
96 * This contains the functions needed by the server after loading the driver 85 * This contains the functions needed by the server after loading the driver
97 * module. It must be supplied, and gets passed back by the SetupProc 86 * module. It must be supplied, and gets passed back by the SetupProc
98 * function in the dynamic case. In the static case, a reference to this 87 * function in the dynamic case. In the static case, a reference to this
99 * is compiled in, and this requires that the name of this DriverRec be 88 * is compiled in, and this requires that the name of this DriverRec be
100 * an upper-case version of the driver name. 89 * an upper-case version of the driver name.
101 */ 90 */
102 91
103DriverRec PNOZZ = { 92DriverRec PNOZZ = {
104 VERSION, 93 VERSION,
105 PNOZZ_DRIVER_NAME, 94 PNOZZ_DRIVER_NAME,
106 PnozzIdentify, 95 PnozzIdentify,
107 PnozzProbe, 96 PnozzProbe,
108 PnozzAvailableOptions, 97 PnozzAvailableOptions,
109 NULL, 98 NULL,
110 0 99 0
111}; 100};
112 101
113typedef enum { 102typedef enum {
114 OPTION_SW_CURSOR, 103 OPTION_SW_CURSOR,
115 OPTION_HW_CURSOR, 104 OPTION_HW_CURSOR,
116 OPTION_NOACCEL 105 OPTION_NOACCEL,
 106 OPTION_ACCELMETHOD
117} PnozzOpts; 107} PnozzOpts;
118 108
119static const OptionInfoRec PnozzOptions[] = { 109static const OptionInfoRec PnozzOptions[] = {
120 { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, 110 { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE },
121 { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE }, 111 { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE },
122 { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, 112 { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE },
 113 { OPTION_ACCELMETHOD, "AccelMethod", OPTV_STRING, {0}, FALSE },
123 { -1, NULL, OPTV_NONE, {0}, FALSE } 114 { -1, NULL, OPTV_NONE, {0}, FALSE }
124}; 115};
125 116
126static const char *ramdacSymbols[] = { 117static const char *ramdacSymbols[] = {
127 "xf86CreateCursorInfoRec", 118 "xf86CreateCursorInfoRec",
128 "xf86DestroyCursorInfoRec", 119 "xf86DestroyCursorInfoRec",
129 "xf86InitCursor", 120 "xf86InitCursor",
130 NULL 121 NULL
131}; 122};
132 123
133static const char *fbSymbols[] = { 124static const char *fbSymbols[] = {
134 "fbScreenInit", 125 "fbScreenInit",
135 "fbPictureInit", 126 "fbPictureInit",
136 NULL 127 NULL
137}; 128};
138 129
139static const char *xaaSymbols[] = 
140{ 
141 "XAACreateInfoRec", 
142 "XAADestroyInfoRec", 
143 "XAAInit", 
144 NULL 
145}; 
146#ifdef XFree86LOADER 
147 
148static MODULESETUPPROTO(PnozzSetup); 130static MODULESETUPPROTO(PnozzSetup);
149 131
150static XF86ModuleVersionInfo PnozzVersRec = 132static XF86ModuleVersionInfo PnozzVersRec =
151{ 133{
152 "pnozz", 134 "pnozz",
153 MODULEVENDORSTRING, 135 MODULEVENDORSTRING,
154 MODINFOSTRING1, 136 MODINFOSTRING1,
155 MODINFOSTRING2, 137 MODINFOSTRING2,
156 XORG_VERSION_CURRENT, 138 XORG_VERSION_CURRENT,
157 PNOZZ_MAJOR_VERSION, PNOZZ_MINOR_VERSION, PNOZZ_PATCHLEVEL, 139 PNOZZ_MAJOR_VERSION, PNOZZ_MINOR_VERSION, PNOZZ_PATCHLEVEL,
158 ABI_CLASS_VIDEODRV, 140 ABI_CLASS_VIDEODRV,
159 ABI_VIDEODRV_VERSION, 141 ABI_VIDEODRV_VERSION,
160 MOD_CLASS_VIDEODRV, 142 MOD_CLASS_VIDEODRV,
161 {0,0,0,0} 143 {0,0,0,0}
162}; 144};
163 145
164XF86ModuleData pnozzModuleData = { &PnozzVersRec, PnozzSetup, NULL }; 146XF86ModuleData pnozzModuleData = { &PnozzVersRec, PnozzSetup, NULL };
165 147
166pointer 148pointer
167PnozzSetup(pointer module, pointer opts, int *errmaj, int *errmin) 149PnozzSetup(pointer module, pointer opts, int *errmaj, int *errmin)
168{ 150{
169 static Bool setupDone = FALSE; 151 static Bool setupDone = FALSE;
170 152
171 if (!setupDone) { 153 if (!setupDone) {
172 setupDone = TRUE; 154 setupDone = TRUE;
173 xf86AddDriver(&PNOZZ, module, 0); 155 xf86AddDriver(&PNOZZ, module, 0);
174  156
175 LoaderRefSymLists(xaaSymbols, ramdacSymbols, fbSymbols, NULL); 
176 /* 157 /*
177 * Modules that this driver always requires can be loaded here 158 * Modules that this driver always requires can be loaded here
178 * by calling LoadSubModule(). 159 * by calling LoadSubModule().
179 */ 160 */
180 161
181 /* 162 /*
182 * The return value must be non-NULL on success even though there 163 * The return value must be non-NULL on success even though there
183 * is no TearDownProc. 164 * is no TearDownProc.
184 */ 165 */
185 return (pointer)TRUE; 166 return (pointer)TRUE;
186 } else { 167 } else {
187 if (errmaj) *errmaj = LDR_ONCEONLY; 168 if (errmaj) *errmaj = LDR_ONCEONLY;
188 return NULL; 169 return NULL;
189 } 170 }
190} 171}
191 172
192#endif /* XFree86LOADER */ 
193 
194static volatile unsigned int scratch32; 173static volatile unsigned int scratch32;
195 174
196void pnozz_write_4(PnozzPtr p, int offset, unsigned int value) 175void pnozz_write_4(PnozzPtr p, int offset, unsigned int value)
197{ 176{
198 if ((offset & 0xffffff80) != p->offset_mask) { 177 if ((offset & 0xffffff80) != p->offset_mask) {
199 p->offset_mask = offset & 0xffffff80; 178 p->offset_mask = offset & 0xffffff80;
200 scratch32 = *(volatile unsigned int *)(p->fb + offset); 179 scratch32 = *(volatile unsigned int *)(p->fb + offset);
201 } 180 }
202 *((volatile unsigned int *)(p->fbc + offset)) = value; 181 *((volatile unsigned int *)(p->fbc + offset)) = value;
203} 182}
204 183
205unsigned int pnozz_read_4(PnozzPtr p, int offset) 184unsigned int pnozz_read_4(PnozzPtr p, int offset)
206{ 185{
207 if ((offset & 0xffffff80) != p->offset_mask) { 186 if ((offset & 0xffffff80) != p->offset_mask) {
208 p->offset_mask = offset & 0xffffff80; 187 p->offset_mask = offset & 0xffffff80;
209 scratch32 = *(volatile unsigned int *)(p->fb + offset); 188 scratch32 = *(volatile unsigned int *)(p->fb + offset);
210 } 189 }
211 return *(volatile unsigned int *)(p->fbc + offset); 190 return *(volatile unsigned int *)(p->fbc + offset);
212} 191}
213 192
214void pnozz_write_dac(PnozzPtr p, int offset, unsigned char value) 193void pnozz_write_dac(PnozzPtr p, int offset, unsigned char value)
215{ 194{
216 CARD32 val = ((CARD32)value) << 16; 195 CARD32 val = ((CARD32)value) << 16;
217 196
218 scratch32 = pnozz_read_4(p, PWRUP_CNFG); 197 scratch32 = pnozz_read_4(p, PWRUP_CNFG);
219 if ((offset != DAC_INDX_DATA) && (offset != DAC_CMAP_DATA)) { 198 if ((offset != DAC_INDX_DATA) && (offset != DAC_CMAP_DATA)) {
220 do { 199 do {
221 pnozz_write_4(p, offset, val); 200 pnozz_write_4(p, offset, val);
222 } while (pnozz_read_4(p, offset) != val); 201 } while (pnozz_read_4(p, offset) != val);
223 } else { 202 } else {
224 pnozz_write_4(p, offset, val); 203 pnozz_write_4(p, offset, val);
225 } 204 }
226} 205}
227 206
228unsigned char pnozz_read_dac(PnozzPtr p, int offset) 207unsigned char pnozz_read_dac(PnozzPtr p, int offset)
229{ 208{
230 scratch32 = pnozz_read_4(p, PWRUP_CNFG); 209 scratch32 = pnozz_read_4(p, PWRUP_CNFG);
231 return ((pnozz_read_4(p, offset) >> 16) & 0xff); 210 return ((pnozz_read_4(p, offset) >> 16) & 0xff);
232} 211}
233 212
234void pnozz_write_dac_ctl_reg(PnozzPtr p, int offset, unsigned char val) 213void pnozz_write_dac_ctl_reg(PnozzPtr p, int offset, unsigned char val)
235{ 214{
236 215
237 pnozz_write_dac(p, DAC_INDX_HI, (offset & 0xff00) >> 8); 216 pnozz_write_dac(p, DAC_INDX_HI, (offset & 0xff00) >> 8);
238 pnozz_write_dac(p, DAC_INDX_LO, (offset & 0xff)); 217 pnozz_write_dac(p, DAC_INDX_LO, (offset & 0xff));
239 pnozz_write_dac(p, DAC_INDX_DATA, val); 218 pnozz_write_dac(p, DAC_INDX_DATA, val);
240} 219}
241 220
242void pnozz_write_dac_ctl_reg_2(PnozzPtr p, int offset, unsigned short val) 221void pnozz_write_dac_ctl_reg_2(PnozzPtr p, int offset, unsigned short val)
243{ 222{
244 223
245 pnozz_write_dac(p, DAC_INDX_HI, (offset & 0xff00) >> 8); 224 pnozz_write_dac(p, DAC_INDX_HI, (offset & 0xff00) >> 8);
246 pnozz_write_dac(p, DAC_INDX_LO, (offset & 0xff)); 225 pnozz_write_dac(p, DAC_INDX_LO, (offset & 0xff));
247 pnozz_write_dac(p, DAC_INDX_CTL, DAC_INDX_AUTOINCR); 226 pnozz_write_dac(p, DAC_INDX_CTL, DAC_INDX_AUTOINCR);
248 pnozz_write_dac(p, DAC_INDX_DATA, val & 0xff); 227 pnozz_write_dac(p, DAC_INDX_DATA, val & 0xff);
249 pnozz_write_dac(p, DAC_INDX_DATA, (val & 0xff00) >> 8); 228 pnozz_write_dac(p, DAC_INDX_DATA, (val & 0xff00) >> 8);
250} 229}
251 230
252unsigned char pnozz_read_dac_ctl_reg(PnozzPtr p, int offset) 231unsigned char pnozz_read_dac_ctl_reg(PnozzPtr p, int offset)
253{ 232{
254 pnozz_write_dac(p, DAC_INDX_HI, (offset & 0xff00) >> 8); 233 pnozz_write_dac(p, DAC_INDX_HI, (offset & 0xff00) >> 8);
255 pnozz_write_dac(p, DAC_INDX_LO, (offset & 0xff)); 234 pnozz_write_dac(p, DAC_INDX_LO, (offset & 0xff));
256 return pnozz_read_dac(p, DAC_INDX_DATA); 235 return pnozz_read_dac(p, DAC_INDX_DATA);
257} 236}
258 237
259void pnozz_write_dac_cmap_reg(PnozzPtr p, int offset, unsigned int val) 238void pnozz_write_dac_cmap_reg(PnozzPtr p, int offset, unsigned int val)
260{ 239{
261 pnozz_write_dac(p, DAC_CMAP_WRIDX,(offset & 0xff)); 240 pnozz_write_dac(p, DAC_CMAP_WRIDX,(offset & 0xff));
262 pnozz_write_dac(p, DAC_CMAP_DATA,(val & 0xff)); 241 pnozz_write_dac(p, DAC_CMAP_DATA,(val & 0xff));
263 pnozz_write_dac(p, DAC_CMAP_DATA,(val & 0xff00) >> 8); 242 pnozz_write_dac(p, DAC_CMAP_DATA,(val & 0xff00) >> 8);
264 pnozz_write_dac(p, DAC_CMAP_DATA,(val & 0xff0000) >> 16); 243 pnozz_write_dac(p, DAC_CMAP_DATA,(val & 0xff0000) >> 16);
265} 244}
266 245
267static void 246static void
268PnozzLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, 247PnozzLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors,
269 VisualPtr pVisual)  248 VisualPtr pVisual)
270{ 249{
271 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 250 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
272 int i, index; 251 int i, index;
273  252
274 PnozzSync(pScrn); 253 PnozzSync(pScrn);
275 pnozz_write_dac(pPnozz, DAC_INDX_CTL, DAC_INDX_AUTOINCR); 254 pnozz_write_dac(pPnozz, DAC_INDX_CTL, DAC_INDX_AUTOINCR);
276 255
277 for (i = 0; i < numColors; i++) 256 for (i = 0; i < numColors; i++)
278 { 257 {
279 index = indices[i]; 258 index = indices[i];
280 if (index >= 0) { 259 if (index >= 0) {
281 pnozz_write_dac(pPnozz, DAC_CMAP_WRIDX, index); 260 pnozz_write_dac(pPnozz, DAC_CMAP_WRIDX, index);
282 pnozz_write_dac(pPnozz, DAC_CMAP_DATA, colors[index].red); 261 pnozz_write_dac(pPnozz, DAC_CMAP_DATA, colors[index].red);
283 pnozz_write_dac(pPnozz, DAC_CMAP_DATA, colors[index].green); 262 pnozz_write_dac(pPnozz, DAC_CMAP_DATA, colors[index].green);
284 pnozz_write_dac(pPnozz, DAC_CMAP_DATA, colors[index].blue); 263 pnozz_write_dac(pPnozz, DAC_CMAP_DATA, colors[index].blue);
285 } 264 }
286 } 265 }
287 PnozzSync(pScrn); 266 PnozzSync(pScrn);
288} 267}
289 268
290static Bool 269static Bool
291PnozzGetRec(ScrnInfoPtr pScrn) 270PnozzGetRec(ScrnInfoPtr pScrn)
292{ 271{
293 /* 272 /*
294 * Allocate an PnozzRec, and hook it into pScrn->driverPrivate. 273 * Allocate an PnozzRec, and hook it into pScrn->driverPrivate.
295 * pScrn->driverPrivate is initialised to NULL, so we can check if 274 * pScrn->driverPrivate is initialised to NULL, so we can check if
296 * the allocation has already been done. 275 * the allocation has already been done.
297 */ 276 */
298 if (pScrn->driverPrivate != NULL) 277 if (pScrn->driverPrivate != NULL)
299 return TRUE; 278 return TRUE;
300 279
301 pScrn->driverPrivate = xnfcalloc(sizeof(PnozzRec), 1); 280 pScrn->driverPrivate = xnfcalloc(sizeof(PnozzRec), 1);
302 return TRUE; 281 return TRUE;
303} 282}
304 283
305static void 284static void
306PnozzFreeRec(ScrnInfoPtr pScrn) 285PnozzFreeRec(ScrnInfoPtr pScrn)
307{ 286{
308 PnozzPtr pPnozz; 287 PnozzPtr pPnozz;
309 288
310 if (pScrn->driverPrivate == NULL) 289 if (pScrn->driverPrivate == NULL)
311 return; 290 return;
312 291
313 pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 292 pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
314 293
315 xfree(pScrn->driverPrivate); 294 free(pScrn->driverPrivate);
316 pScrn->driverPrivate = NULL; 295 pScrn->driverPrivate = NULL;
317 296
318 return; 297 return;
319} 298}
320 299
321static const OptionInfoRec * 300static const OptionInfoRec *
322PnozzAvailableOptions(int chipid, int busid) 301PnozzAvailableOptions(int chipid, int busid)
323{ 302{
324 return PnozzOptions; 303 return PnozzOptions;
325} 304}
326 305
327/* Mandatory */ 306/* Mandatory */
328static void 307static void
329PnozzIdentify(int flags) 308PnozzIdentify(int flags)
330{ 309{
331 xf86Msg(X_INFO, "%s: driver for Weitek P9100 found in Tadpole SPARCbook 3GX and others\n", PNOZZ_NAME); 310 xf86Msg(X_INFO, "%s: driver for Weitek P9100 found in Tadpole SPARCbook 3GX and others\n", PNOZZ_NAME);
332} 311}
333 312
334 313
335/* Mandatory */ 314/* Mandatory */
336static Bool 315static Bool
337PnozzProbe(DriverPtr drv, int flags) 316PnozzProbe(DriverPtr drv, int flags)
338{ 317{
339 int i; 318 int i;
340 GDevPtr *devSections; 319 GDevPtr *devSections;
341 int *usedChips; 320 int *usedChips;
342 int numDevSections; 321 int numDevSections;
343 int numUsed; 322 int numUsed;
344 Bool foundScreen = FALSE; 323 Bool foundScreen = FALSE;
345 EntityInfoPtr pEnt; 324 EntityInfoPtr pEnt;
346 325
347 /* 326 /*
348 * The aim here is to find all cards that this driver can handle, 327 * The aim here is to find all cards that this driver can handle,
349 * and for the ones not already claimed by another driver, claim the 328 * and for the ones not already claimed by another driver, claim the
350 * slot, and allocate a ScrnInfoRec. 329 * slot, and allocate a ScrnInfoRec.
351 * 330 *
352 * This should be a minimal probe, and it should under no circumstances 331 * This should be a minimal probe, and it should under no circumstances
353 * change the state of the hardware. Because a device is found, don't 332 * change the state of the hardware. Because a device is found, don't
354 * assume that it will be used. Don't do any initialisations other than 333 * assume that it will be used. Don't do any initialisations other than
355 * the required ScrnInfoRec initialisations. Don't allocate any new 334 * the required ScrnInfoRec initialisations. Don't allocate any new
356 * data structures. 335 * data structures.
357 */ 336 */
358 337
359 /* 338 /*
360 * Next we check, if there has been a chipset override in the config file. 339 * Next we check, if there has been a chipset override in the config file.
361 * For this we must find out if there is an active device section which 340 * For this we must find out if there is an active device section which
362 * is relevant, i.e., which has no driver specified or has THIS driver 341 * is relevant, i.e., which has no driver specified or has THIS driver
363 * specified. 342 * specified.
364 */ 343 */
365 344
366 if ((numDevSections = xf86MatchDevice(PNOZZ_DRIVER_NAME, 345 if ((numDevSections = xf86MatchDevice(PNOZZ_DRIVER_NAME,
367 &devSections)) <= 0) { 346 &devSections)) <= 0) {
368 /* 347 /*
369 * There's no matching device section in the config file, so quit 348 * There's no matching device section in the config file, so quit
370 * now. 349 * now.
371 */ 350 */
372 return FALSE; 351 return FALSE;
373 } 352 }
374 353
375 /* 354 /*
376 * We need to probe the hardware first. We then need to see how this 355 * We need to probe the hardware first. We then need to see how this
377 * fits in with what is given in the config file, and allow the config 356 * fits in with what is given in the config file, and allow the config
378 * file info to override any contradictions. 357 * file info to override any contradictions.
379 */ 358 */
380 359
381 numUsed = xf86MatchSbusInstances(PNOZZ_NAME, SBUS_DEVICE_P9100, 360 numUsed = xf86MatchSbusInstances(PNOZZ_NAME, SBUS_DEVICE_P9100,
382 devSections, numDevSections, 361 devSections, numDevSections,
383 drv, &usedChips); 362 drv, &usedChips);
384  363
385 xfree(devSections); 364 free(devSections);
386 if (numUsed <= 0) 365 if (numUsed <= 0)
387 return FALSE; 366 return FALSE;
388 367
389 if (flags & PROBE_DETECT) 368 if (flags & PROBE_DETECT)
390 foundScreen = TRUE; 369 foundScreen = TRUE;
391 else 370 else
392 for (i = 0; i < numUsed; i++) { 371 for (i = 0; i < numUsed; i++) {
393 pEnt = xf86GetEntityInfo(usedChips[i]); 372 pEnt = xf86GetEntityInfo(usedChips[i]);
394  373
395 /* 374 /*
396 * Check that nothing else has claimed the slots. 375 * Check that nothing else has claimed the slots.
397 */ 376 */
398 if(pEnt->active) { 377 if(pEnt->active) {
399 ScrnInfoPtr pScrn; 378 ScrnInfoPtr pScrn;
400  379
401 /* Allocate a ScrnInfoRec and claim the slot */ 380 /* Allocate a ScrnInfoRec and claim the slot */
402 pScrn = xf86AllocateScreen(drv, 0); 381 pScrn = xf86AllocateScreen(drv, 0);
403  382
404 /* Fill in what we can of the ScrnInfoRec */ 383 /* Fill in what we can of the ScrnInfoRec */
405 pScrn->driverVersion = VERSION; 384 pScrn->driverVersion = VERSION;
406 pScrn->driverName = PNOZZ_DRIVER_NAME; 385 pScrn->driverName = PNOZZ_DRIVER_NAME;
407 pScrn->name = PNOZZ_NAME; 386 pScrn->name = PNOZZ_NAME;
408 pScrn->Probe = PnozzProbe; 387 pScrn->Probe = PnozzProbe;
409 pScrn->PreInit = PnozzPreInit; 388 pScrn->PreInit = PnozzPreInit;
410 pScrn->ScreenInit = PnozzScreenInit; 389 pScrn->ScreenInit = PnozzScreenInit;
411 pScrn->SwitchMode = PnozzSwitchMode; 390 pScrn->SwitchMode = PnozzSwitchMode;
412 pScrn->AdjustFrame = PnozzAdjustFrame; 391 pScrn->AdjustFrame = PnozzAdjustFrame;
413 pScrn->EnterVT = PnozzEnterVT; 392 pScrn->EnterVT = PnozzEnterVT;
414 pScrn->LeaveVT = PnozzLeaveVT; 393 pScrn->LeaveVT = PnozzLeaveVT;
415 pScrn->FreeScreen = PnozzFreeScreen; 394 pScrn->FreeScreen = PnozzFreeScreen;
416 pScrn->ValidMode = PnozzValidMode; 395 pScrn->ValidMode = PnozzValidMode;
417 xf86AddEntityToScreen(pScrn, pEnt->index); 396 xf86AddEntityToScreen(pScrn, pEnt->index);
418 foundScreen = TRUE; 397 foundScreen = TRUE;
419 } 398 }
420 xfree(pEnt); 399 free(pEnt);
421 } 400 }
422 xfree(usedChips); 401 free(usedChips);
423 return foundScreen; 402 return foundScreen;
424} 403}
425 404
426/* Mandatory */ 405/* Mandatory */
427static Bool 406static Bool
428PnozzPreInit(ScrnInfoPtr pScrn, int flags) 407PnozzPreInit(ScrnInfoPtr pScrn, int flags)
429{ 408{
430 PnozzPtr pPnozz; 409 PnozzPtr pPnozz;
431 sbusDevicePtr psdp; 410 sbusDevicePtr psdp;
432 MessageType from; 411 MessageType from;
433 rgb defaultWeight = {0, 0, 0}; 412 rgb defaultWeight = {0, 0, 0};
434 int i; 413 int i;
435 414
436 if (flags & PROBE_DETECT) return FALSE; 415 if (flags & PROBE_DETECT) return FALSE;
437 416
438 /* 417 /*
439 * Note: This function is only called once at server startup, and 418 * Note: This function is only called once at server startup, and
440 * not at the start of each server generation. This means that 419 * not at the start of each server generation. This means that
441 * only things that are persistent across server generations can 420 * only things that are persistent across server generations can
442 * be initialised here. xf86Screens[] is (pScrn is a pointer to one 421 * be initialised here. xf86Screens[] is (pScrn is a pointer to one
443 * of these). Privates allocated using xf86AllocateScrnInfoPrivateIndex()  422 * of these). Privates allocated using xf86AllocateScrnInfoPrivateIndex()
444 * are too, and should be used for data that must persist across 423 * are too, and should be used for data that must persist across
445 * server generations. 424 * server generations.
446 * 425 *
447 * Per-generation data should be allocated with 426 * Per-generation data should be allocated with
448 * AllocateScreenPrivateIndex() from the ScreenInit() function. 427 * AllocateScreenPrivateIndex() from the ScreenInit() function.
449 */ 428 */
450 429
451 /* Allocate the PnozzRec driverPrivate */ 430 /* Allocate the PnozzRec driverPrivate */
452 if (!PnozzGetRec(pScrn)) { 431 if (!PnozzGetRec(pScrn)) {
453 return FALSE; 432 return FALSE;
454 } 433 }
455 pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 434 pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
456  435
457 /* always mismatch on first access */ 436 /* always mismatch on first access */
458 pPnozz->offset_mask = 0xffffffff; 437 pPnozz->offset_mask = 0xffffffff;
459  438
460 /* Set pScrn->monitor */ 439 /* Set pScrn->monitor */
461 pScrn->monitor = pScrn->confScreen->monitor; 440 pScrn->monitor = pScrn->confScreen->monitor;
462 441
463 /* This driver doesn't expect more than one entity per screen */ 442 /* This driver doesn't expect more than one entity per screen */
464 if (pScrn->numEntities > 1) 443 if (pScrn->numEntities > 1)
465 return FALSE; 444 return FALSE;
466 /* This is the general case */ 445 /* This is the general case */
467 for (i = 0; i < pScrn->numEntities; i++) { 446 for (i = 0; i < pScrn->numEntities; i++) {
468 EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[i]); 447 EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[i]);
469 448
470 /* PNOZZ is purely SBUS */ 449 /* PNOZZ is purely SBUS */
471 if (pEnt->location.type == BUS_SBUS) { 450 if (pEnt->location.type == BUS_SBUS) {
472 psdp = xf86GetSbusInfoForEntity(pEnt->index); 451 psdp = xf86GetSbusInfoForEntity(pEnt->index);
473 pPnozz->psdp = psdp; 452 pPnozz->psdp = psdp;
474 } else 453 } else
475 return FALSE; 454 return FALSE;
476 } 455 }
477 456
478 /********************* 457 /*********************
479 deal with depth 458 deal with depth
480 *********************/ 459 *********************/
481 if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support32bppFb)) { 460 if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support32bppFb)) {
482 return FALSE; 461 return FALSE;
483 } else { 462 } else {
484 /* Check that the returned depth is one we support */ 463 /* Check that the returned depth is one we support */
485#ifdef DEBUG 464#ifdef DEBUG
486 xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,  465 xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
487 "Depth requested: %d\n", pScrn->depth); 466 "Depth requested: %d\n", pScrn->depth);
488#endif 467#endif
489 switch (pScrn->depth) { 468 switch (pScrn->depth) {
490 case 8: 469 case 8:
491 case 16: 470 case 16:
492 case 24: 471 case 24:
493 /* OK */ 472 /* OK */
494 break; 473 break;
495 default: 474 default:
496 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, 475 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
497 "Given depth (%d) is not supported by this driver\n", 476 "Given depth (%d) is not supported by this driver\n",
498 pScrn->depth); 477 pScrn->depth);
499 return FALSE; 478 return FALSE;
500 } 479 }
501 } 480 }
502 xf86PrintDepthBpp(pScrn); 481 xf86PrintDepthBpp(pScrn);
503 482
504 /* We use a programmable clock */ 483 /* We use a programmable clock */
505 pScrn->progClock = TRUE; 484 pScrn->progClock = TRUE;
506 485
507 /* Set the bits per RGB for 8bpp mode */ 486 /* Set the bits per RGB for 8bpp mode */
508 if (pScrn->depth == 8) 487 if (pScrn->depth == 8)
509 pScrn->rgbBits = 8; 488 pScrn->rgbBits = 8;
510 489
511 if (pScrn->depth > 8) { 490 if (pScrn->depth > 8) {
512 if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight)) 491 if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight))
513 return FALSE; 492 return FALSE;
514 } 493 }
515 494
516 if (!xf86SetDefaultVisual(pScrn, -1)) { 495 if (!xf86SetDefaultVisual(pScrn, -1)) {
517 return FALSE; 496 return FALSE;
518 } else { 497 } else {
519 /* We don't currently support DirectColor at > 8bpp */ 498 /* We don't currently support DirectColor at > 8bpp */
520 if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { 499 if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) {
521 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" 500 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual"
522 " (%s) is not supported at depth %d\n", 501 " (%s) is not supported at depth %d\n",
523 xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); 502 xf86GetVisualName(pScrn->defaultVisual), pScrn->depth);
524 return FALSE; 503 return FALSE;
525 } 504 }
526 } 505 }
527 506
528 /* Collect all of the relevant option flags (fill in pScrn->options) */ 507 /* Collect all of the relevant option flags (fill in pScrn->options) */
529 xf86CollectOptions(pScrn, NULL); 508 xf86CollectOptions(pScrn, NULL);
530 509
531 /* Process the options */ 510 /* Process the options */
532 if (!(pPnozz->Options = xalloc(sizeof(PnozzOptions)))) 511 if (!(pPnozz->Options = malloc(sizeof(PnozzOptions))))
533 return FALSE; 512 return FALSE;
534 513
535 memcpy(pPnozz->Options, PnozzOptions, sizeof(PnozzOptions)); 514 memcpy(pPnozz->Options, PnozzOptions, sizeof(PnozzOptions));
536 xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pPnozz->Options); 515 xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pPnozz->Options);
537  516
538 /* 517 /*
539 * The new cmap code requires this to be initialised. 518 * The new cmap code requires this to be initialised.
540 */ 519 */
541 520
542 { 521 {
543 Gamma zeros = {0.0, 0.0, 0.0}; 522 Gamma zeros = {0.0, 0.0, 0.0};
544 523
545 if (!xf86SetGamma(pScrn, zeros)) { 524 if (!xf86SetGamma(pScrn, zeros)) {
546 return FALSE; 525 return FALSE;
547 } 526 }
548 } 527 }
549 528
550 /* Set the bits per RGB for 8bpp mode */ 529 /* Set the bits per RGB for 8bpp mode */
551 from = X_DEFAULT; 530 from = X_DEFAULT;
552 531
553 /* determine whether we use hardware or software cursor */ 532 /* determine whether we use hardware or software cursor */
554 pPnozz->HWCursor = TRUE; 533 pPnozz->HWCursor = TRUE;
555 if (xf86GetOptValBool(pPnozz->Options, OPTION_HW_CURSOR, &pPnozz->HWCursor)) 534 if (xf86GetOptValBool(pPnozz->Options, OPTION_HW_CURSOR, &pPnozz->HWCursor))
556 from = X_CONFIG; 535 from = X_CONFIG;
557 if (xf86ReturnOptValBool(pPnozz->Options, OPTION_SW_CURSOR, FALSE)) { 536 if (xf86ReturnOptValBool(pPnozz->Options, OPTION_SW_CURSOR, FALSE)) {
558 from = X_CONFIG; 537 from = X_CONFIG;
559 pPnozz->HWCursor = FALSE; 538 pPnozz->HWCursor = FALSE;
560 } 539 }
561  540
562 xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n", 541 xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n",
563 pPnozz->HWCursor ? "HW" : "SW"); 542 pPnozz->HWCursor ? "HW" : "SW");
564 543
565 if (xf86ReturnOptValBool(pPnozz->Options, OPTION_NOACCEL, FALSE)) { 544 if (xf86ReturnOptValBool(pPnozz->Options, OPTION_NOACCEL, FALSE)) {
566 pPnozz->NoAccel = TRUE; 545 pPnozz->NoAccel = TRUE;
567 xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Acceleration disabled\n"); 546 xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Acceleration disabled\n");
568 } 547 }
 548
 549 pPnozz->useXAA = FALSE;
 550
 551 char *optstr;
 552 optstr = (char *)xf86GetOptValString(pPnozz->Options, OPTION_ACCELMETHOD);
 553 if (optstr == NULL) optstr = "exa";
 554 if (xf86NameCmp(optstr, "xaa") == 0)
 555 pPnozz->useXAA = TRUE;
569  556
570 if (xf86LoadSubModule(pScrn, "fb") == NULL) { 557 if (xf86LoadSubModule(pScrn, "fb") == NULL) {
571 PnozzFreeRec(pScrn); 558 PnozzFreeRec(pScrn);
572 return FALSE; 559 return FALSE;
573 } 560 }
574 561
575 if (xf86LoadSubModule(pScrn, "ramdac") == NULL) { 562 if (xf86LoadSubModule(pScrn, "ramdac") == NULL) {
576 PnozzFreeRec(pScrn); 563 PnozzFreeRec(pScrn);
577 return FALSE; 564 return FALSE;
578 } 565 }
579 xf86LoaderReqSymLists(ramdacSymbols, NULL); 
580 
581 if (xf86LoadSubModule(pScrn, "xaa") == NULL) { 
582 PnozzFreeRec(pScrn); 
583 return FALSE; 
584 } 
585 xf86LoaderReqSymLists(xaaSymbols, NULL); 
586 566
587 /********************* 567 /*********************
588 set up clock and mode stuff 568 set up clock and mode stuff
589 *********************/ 569 *********************/
590  570
591 pScrn->progClock = TRUE; 571 pScrn->progClock = TRUE;
592 572
593 if(pScrn->display->virtualX || pScrn->display->virtualY) { 573 if(pScrn->display->virtualX || pScrn->display->virtualY) {
594 xf86DrvMsg(pScrn->scrnIndex, X_WARNING, 574 xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
595 "Pnozz does not support a virtual desktop\n"); 575 "Pnozz does not support a virtual desktop\n");
596 pScrn->display->virtualX = 0; 576 pScrn->display->virtualX = 0;
597 pScrn->display->virtualY = 0; 577 pScrn->display->virtualY = 0;
598 } 578 }
599 579
600 xf86SbusUseBuiltinMode(pScrn, pPnozz->psdp); 580 xf86SbusUseBuiltinMode(pScrn, pPnozz->psdp);
601 pScrn->currentMode = pScrn->modes; 581 pScrn->currentMode = pScrn->modes;
602 pScrn->displayWidth = pScrn->virtualX; 582 pScrn->displayWidth = pScrn->virtualX;
603 583
604 /* Set display resolution */ 584 /* Set display resolution */
605 xf86SetDpi(pScrn, 0, 0); 585 xf86SetDpi(pScrn, 0, 0);
606 586
607 return TRUE; 587 return TRUE;
608} 588}
609 589
610/* Mandatory */ 590/* Mandatory */
611 591
612/* This gets called at the start of each server generation */ 592/* This gets called at the start of each server generation */
613 593
614static Bool 594static Bool
615PnozzScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) 595PnozzScreenInit(SCREEN_INIT_ARGS_DECL)
616{ 596{
617 ScrnInfoPtr pScrn; 597 ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
618 PnozzPtr pPnozz; 598 PnozzPtr pPnozz;
619 VisualPtr visual; 599 VisualPtr visual;
620 int ret,len=0,i; 600 int ret,len=0,i;
621 unsigned int *regs, pctl, pfb, *fb; 601 unsigned int *regs, pctl, pfb, *fb;
622 602
623 /*  603 /*
624 * First get the ScrnInfoRec 604 * First get the ScrnInfoRec
625 */ 605 */
626 pScrn = xf86Screens[pScreen->myNum]; 606 pScrn = xf86Screens[pScreen->myNum];
627 607
628 pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 608 pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
629 609
630 /* 610 /*
631 * XXX 611 * XXX
632 * figure out how much video RAM we really have - 2MB is just by far the  612 * figure out how much video RAM we really have - 2MB is just by far the
633 * most common size 613 * most common size
634 */ 614 */
 615 pPnozz->vidmem = 0x200000; /* map 2MB */
635 pPnozz->fb = 616 pPnozz->fb =
636 xf86MapSbusMem (pPnozz->psdp, 0, 0x200000); /* map 2MB */ 617 xf86MapSbusMem (pPnozz->psdp, 0, pPnozz->vidmem);
637 fb=(unsigned int *)pPnozz->fb; 618 fb=(unsigned int *)pPnozz->fb;
638  619
639 pPnozz->fbc = 620 pPnozz->fbc =
640 xf86MapSbusMem (pPnozz->psdp, 0x200000,0x8000); /* map registers */ 621 xf86MapSbusMem (pPnozz->psdp, pPnozz->vidmem,0x8000); /* map registers */
 622
 623 if (! pPnozz->fbc) {
 624 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 625 "xf86MapSbusMem failed fbc:%p fb:%p\n",
 626 pPnozz->fbc, pPnozz->fb);
 627
 628 if (pPnozz->fb) {
 629 xf86UnmapSbusMem(pPnozz->psdp, pPnozz->fb, pPnozz->vidmem);
 630 pPnozz->fb = NULL;
 631 }
641 632
642 if (! pPnozz->fbc) 
643 return FALSE; 633 return FALSE;
 634 }
644 635
645 /* 636 /*
646 * The next step is to setup the screen's visuals, and initialise the 637 * The next step is to setup the screen's visuals, and initialise the
647 * framebuffer code. In cases where the framebuffer's default 638 * framebuffer code. In cases where the framebuffer's default
648 * choices for things like visual layouts and bits per RGB are OK, 639 * choices for things like visual layouts and bits per RGB are OK,
649 * this may be as simple as calling the framebuffer's ScreenInit() 640 * this may be as simple as calling the framebuffer's ScreenInit()
650 * function. If not, the visuals will need to be setup before calling 641 * function. If not, the visuals will need to be setup before calling
651 * a fb ScreenInit() function and fixed up after. 642 * a fb ScreenInit() function and fixed up after.
652 */ 643 */
653 644
654 /* 645 /*
655 * Reset visual list. 646 * Reset visual list.
656 */ 647 */
657 miClearVisualTypes(); 648 miClearVisualTypes();
658 649
659#ifdef DEBUG 650#ifdef DEBUG
660 xf86Msg(X_ERROR, "depth: %d, bpp: %d\n", pScrn->depth, pScrn->bitsPerPixel); 651 xf86Msg(X_ERROR, "depth: %d, bpp: %d\n", pScrn->depth, pScrn->bitsPerPixel);
661#endif  652#endif
662 switch (pScrn->bitsPerPixel) { 653 switch (pScrn->bitsPerPixel) {
663 case 8: 654 case 8:
664 pPnozz->depthshift = 0; 655 pPnozz->depthshift = 0;
665 break;  656 break;
666 case 16: 657 case 16:
667 pPnozz->depthshift = 1; 658 pPnozz->depthshift = 1;
668 break;  659 break;
669 case 32: 660 case 32:
670 pPnozz->depthshift = 2; 661 pPnozz->depthshift = 2;
671 break;  662 break;
672 default: 663 default:
673 return FALSE; 664 return FALSE;
674 } 665 }
675 pPnozz->width = pScrn->virtualX; 666 pPnozz->width = pScrn->virtualX;
676 pPnozz->height = pScrn->virtualY; 667 pPnozz->height = pScrn->virtualY;
677 pPnozz->scanlinesize = pScrn->virtualX << pPnozz->depthshift; 668 pPnozz->scanlinesize = pScrn->virtualX << pPnozz->depthshift;
678  669
679 PnozzSave(pPnozz); 670 PnozzSave(pPnozz);
680 671
681 /*  672 /*
682 * ok, let's switch to whatever depth That Guy Out There wants. 673 * ok, let's switch to whatever depth That Guy Out There wants.
683 * We won't switch video mode, only colour depth -  674 * We won't switch video mode, only colour depth -
684 */ 675 */
685 if(!PnozzSetDepth(pPnozz, pScrn->bitsPerPixel))  676 if(!PnozzSetDepth(pPnozz, pScrn->bitsPerPixel))
686 return FALSE; 677 return FALSE;
687 678
688 /* Setup the visuals we support. */ 679 /* Setup the visuals we support. */
689 680
690 if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), 681 if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth),
691 pScrn->rgbBits, pScrn->defaultVisual)) 682 pScrn->rgbBits, pScrn->defaultVisual))
692 return FALSE; 683 return FALSE;
693  684
694 miSetPixmapDepths(); 685 miSetPixmapDepths();
695 686
696 /* 687 /*
697 * Call the framebuffer layer's ScreenInit function, and fill in other 688 * Call the framebuffer layer's ScreenInit function, and fill in other
698 * pScreen fields. 689 * pScreen fields.
699 */ 690 */
700#if DEBUG 691#if DEBUG
701 xf86Msg(X_ERROR, "sls: %d\n", pPnozz->scanlinesize); 692 xf86Msg(X_ERROR, "sls: %d\n", pPnozz->scanlinesize);
702#endif 693#endif
703 ret = fbScreenInit(pScreen, pPnozz->fb, pScrn->virtualX, 694 ret = fbScreenInit(pScreen, pPnozz->fb, pScrn->virtualX,
704 pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, 695 pScrn->virtualY, pScrn->xDpi, pScrn->yDpi,
705 pScrn->displayWidth, pScrn->bitsPerPixel); 696 pScrn->displayWidth, pScrn->bitsPerPixel);
706 697
707 /* should be set by PnozzSetDepth() */ 698 /* should be set by PnozzSetDepth() */
708 pPnozz->maxheight = (0x200000 / pPnozz->scanlinesize) & 0xffff; 699 pPnozz->maxheight = (pPnozz->vidmem / pPnozz->scanlinesize) & 0xffff;
709#if DEBUG 700#if DEBUG
710 xf86Msg(X_ERROR, "max scanlines: %d\n", pPnozz->maxheight); 701 xf86Msg(X_ERROR, "max scanlines: %d\n", pPnozz->maxheight);
711#endif 702#endif
712 if (!ret) 703 if (!ret)
713 return FALSE; 704 return FALSE;
714 705
715 if (pScrn->bitsPerPixel > 8) { 706 if (pScrn->bitsPerPixel > 8) {
716 visual = pScreen->visuals + pScreen->numVisuals; 707 visual = pScreen->visuals + pScreen->numVisuals;
717 while (--visual >= pScreen->visuals) { 708 while (--visual >= pScreen->visuals) {
718 if ((visual->class | DynamicClass) == DirectColor) { 709 if ((visual->class | DynamicClass) == DirectColor) {
719 visual->offsetRed = pScrn->offset.red; 710 visual->offsetRed = pScrn->offset.red;
720 visual->offsetGreen = pScrn->offset.green; 711 visual->offsetGreen = pScrn->offset.green;
721 visual->offsetBlue = pScrn->offset.blue; 712 visual->offsetBlue = pScrn->offset.blue;
722 visual->redMask = pScrn->mask.red; 713 visual->redMask = pScrn->mask.red;
723 visual->greenMask = pScrn->mask.green; 714 visual->greenMask = pScrn->mask.green;
724 visual->blueMask = pScrn->mask.blue; 715 visual->blueMask = pScrn->mask.blue;
725 } 716 }
726 } 717 }
727 } 718 }
728 719
729 fbPictureInit(pScreen, 0, 0); 720 fbPictureInit(pScreen, 0, 0);
730 721
731 xf86SetBackingStore(pScreen); 722 xf86SetBackingStore(pScreen);
732 xf86SetSilkenMouse(pScreen); 723 xf86SetSilkenMouse(pScreen);
733 xf86SetBlackWhitePixels(pScreen); 724 xf86SetBlackWhitePixels(pScreen);
734 725
735 if (!pPnozz->NoAccel) { 726 if (!pPnozz->NoAccel) {
736 BoxRec bx; 727#ifdef HAVE_XAA_H
737 pPnozz->pXAA = XAACreateInfoRec(); 728 if (pPnozz->useXAA) {
738 PnozzAccelInit(pScrn); 729 BoxRec bx;
739 bx.x1 = bx.y1 = 0; 730 pPnozz->pXAA = XAACreateInfoRec();
740 bx.x2 = pPnozz->width; 731 PnozzAccelInit(pScrn);
741 bx.y2 = pPnozz->maxheight; 732 bx.x1 = bx.y1 = 0;
742 xf86InitFBManager(pScreen, &bx); 733 bx.x2 = pPnozz->width;
743 if(!XAAInit(pScreen, pPnozz->pXAA)) 734 bx.y2 = pPnozz->maxheight;
744 return FALSE; 735 xf86InitFBManager(pScreen, &bx);
745 xf86Msg(X_INFO, "%s: Using acceleration\n", pPnozz->psdp->device); 736 if(!XAAInit(pScreen, pPnozz->pXAA))
 737 return FALSE;
 738 xf86Msg(X_INFO, "%s: Using XAA acceleration\n", pPnozz->psdp->device);
 739 } else
 740#endif /* HAVE_XAA_H */
 741 {
 742 /* EXA */
 743 XF86ModReqInfo req;
 744 int errmaj, errmin;
 745
 746 memset(&req, 0, sizeof(XF86ModReqInfo));
 747 req.majorversion = EXA_VERSION_MAJOR;
 748 req.minorversion = EXA_VERSION_MINOR;
 749 if (!LoadSubModule(pScrn->module, "exa", NULL, NULL, NULL, &req,
 750 &errmaj, &errmin)) {
 751 LoaderErrorMsg(NULL, "exa", errmaj, errmin);
 752 return FALSE;
 753 }
 754 if (!PnozzEXAInit(pScreen))
 755 return FALSE;
 756
 757 xf86Msg(X_INFO, "%s: Using EXA acceleration\n", pPnozz->psdp->device);
 758 }
746 } 759 }
747 760
748 /* Initialise cursor functions */ 761 /* Initialise cursor functions */
749 miDCInitialize (pScreen, xf86GetPointerScreenFuncs()); 762 miDCInitialize (pScreen, xf86GetPointerScreenFuncs());
750 763
751 /* 764 /*
752 * Initialize HW cursor layer.  765 * Initialize HW cursor layer.
753 * Must follow software cursor initialization 766 * Must follow software cursor initialization
754 */ 767 */
755 xf86SbusHideOsHwCursor(pPnozz->psdp); 768 xf86SbusHideOsHwCursor(pPnozz->psdp);
756 if (pPnozz->HWCursor) {  769 if (pPnozz->HWCursor) {
757 extern Bool PnozzHWCursorInit(ScreenPtr pScreen); 770 extern Bool PnozzHWCursorInit(ScreenPtr pScreen);
758 771
759 if(!PnozzHWCursorInit(pScreen)) { 772 if(!PnozzHWCursorInit(pScreen)) {
760 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,  773 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
761 "Hardware cursor initialization failed\n"); 774 "Hardware cursor initialization failed\n");
762 return(FALSE); 775 return(FALSE);
763 } 776 }
764 } 777 }
765 778
766 /* Initialise default colourmap */ 779 /* Initialise default colourmap */
767 if (!miCreateDefColormap(pScreen)) 780 if (!miCreateDefColormap(pScreen))
768 return FALSE; 781 return FALSE;
769#if 1 782#if 1
770 if(!xf86SbusHandleColormaps(pScreen, pPnozz->psdp)) 783 if(!xf86SbusHandleColormaps(pScreen, pPnozz->psdp))
771#else 784#else
772 if(!xf86HandleColormaps(pScreen, 256, pScrn->rgbBits, PnozzLoadPalette, NULL,  785 if(!xf86HandleColormaps(pScreen, 256, pScrn->rgbBits, PnozzLoadPalette, NULL,
773 /*CMAP_PALETTED_TRUECOLOR|*/CMAP_RELOAD_ON_MODE_SWITCH)) 786 /*CMAP_PALETTED_TRUECOLOR|*/CMAP_RELOAD_ON_MODE_SWITCH))
774#endif 787#endif
775 return FALSE; 788 return FALSE;
776 pPnozz->CloseScreen = pScreen->CloseScreen; 789 pPnozz->CloseScreen = pScreen->CloseScreen;
777 pScreen->CloseScreen = PnozzCloseScreen; 790 pScreen->CloseScreen = PnozzCloseScreen;
778 pScreen->SaveScreen = PnozzSaveScreen; 791 pScreen->SaveScreen = PnozzSaveScreen;
779 792
780 /* Report any unused options (only for the first generation) */ 793 /* Report any unused options (only for the first generation) */
781 if (serverGeneration == 1) { 794 if (serverGeneration == 1) {
782 xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); 795 xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
783 } 796 }
784 797
785 /* unblank the screen */ 798 /* unblank the screen */
786 PnozzSaveScreen(pScreen, SCREEN_SAVER_OFF); 799 PnozzSaveScreen(pScreen, SCREEN_SAVER_OFF);
787 800
788 /* Done */ 801 /* Done */
789 return TRUE; 802 return TRUE;
790} 803}
791 804
792 805
793/* Usually mandatory */ 806/* Usually mandatory */
794static Bool 807static Bool
795PnozzSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) 808PnozzSwitchMode(SWITCH_MODE_ARGS_DECL)
796{ 809{
797 xf86Msg(X_ERROR, "SwitchMode: %d %d %d %d\n", mode->CrtcHTotal,  810 xf86Msg(X_ERROR, "SwitchMode: %d %d %d %d\n", mode->CrtcHTotal,
798 mode->CrtcHSyncStart, mode->CrtcHSyncEnd, mode->CrtcHDisplay); 811 mode->CrtcHSyncStart, mode->CrtcHSyncEnd, mode->CrtcHDisplay);
799 return TRUE; 812 return TRUE;
800} 813}
801 814
802 815
803/* 816/*
804 * This function is used to initialize the Start Address - the first 817 * This function is used to initialize the Start Address - the first
805 * displayed location in the video memory. 818 * displayed location in the video memory.
806 */ 819 */
807/* Usually mandatory */ 820/* Usually mandatory */
808static void  821static void
809PnozzAdjustFrame(int scrnIndex, int x, int y, int flags) 822PnozzAdjustFrame(ADJUST_FRAME_ARGS_DECL)
810{ 823{
811 /* we don't support virtual desktops for now */ 824 /* we don't support virtual desktops for now */
812 return; 825 return;
813} 826}
814 827
815/* 828/*
816 * This is called when VT switching back to the X server. Its job is 829 * This is called when VT switching back to the X server. Its job is
817 * to reinitialise the video mode. 830 * to reinitialise the video mode.
818 */ 831 */
819 832
820/* Mandatory */ 833/* Mandatory */
821static Bool 834static Bool
822PnozzEnterVT(int scrnIndex, int flags) 835PnozzEnterVT(VT_FUNC_ARGS_DECL)
823{ 836{
824 ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; 837 SCRN_INFO_PTR(arg);
825 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 838 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
826 839
827 xf86SbusHideOsHwCursor (pPnozz->psdp); 840 xf86SbusHideOsHwCursor (pPnozz->psdp);
828 return TRUE; 841 return TRUE;
829} 842}
830 843
831 844
832/* 845/*
833 * This is called when VT switching away from the X server. 846 * This is called when VT switching away from the X server.
834 */ 847 */
835 848
836/* Mandatory */ 849/* Mandatory */
837static void 850static void
838PnozzLeaveVT(int scrnIndex, int flags) 851PnozzLeaveVT(VT_FUNC_ARGS_DECL)
839{ 852{
840 return; 853 return;
841} 854}
842 855
843 856
844/* 857/*
845 * This is called at the end of each server generation. It restores the 858 * This is called at the end of each server generation. It restores the
846 * original (text) mode. It should really also unmap the video memory too. 859 * original (text) mode. It should really also unmap the video memory too.
847 */ 860 */
848 861
849/* Mandatory */ 862/* Mandatory */
850static Bool 863static Bool
851PnozzCloseScreen(int scrnIndex, ScreenPtr pScreen) 864PnozzCloseScreen(CLOSE_SCREEN_ARGS_DECL)
852{ 865{
853 ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; 866 ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
854 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 867 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
855 int state = 1; 868 int state = 1;
856 869
857 pScrn->vtSema = FALSE; 870 pScrn->vtSema = FALSE;
858  871
859 if (pPnozz->HWCursor) 872 if (pPnozz->HWCursor)
860 PnozzHideCursor(pScrn); 873 PnozzHideCursor(pScrn);
861 874
862 PnozzRestore(pPnozz); /* restore colour depth */ 875 PnozzRestore(pPnozz); /* restore colour depth */
863  876
864 xf86UnmapSbusMem(pPnozz->psdp, pPnozz->fb,0x200000); 877 xf86UnmapSbusMem(pPnozz->psdp, pPnozz->fb,pPnozz->vidmem);
865 xf86UnmapSbusMem(pPnozz->psdp, pPnozz->fbc,0x8000); 878 xf86UnmapSbusMem(pPnozz->psdp, pPnozz->fbc,0x8000);
866 879
867 /* make sure video is turned on */ 880 /* make sure video is turned on */
868 ioctl(pPnozz->psdp->fd, FBIOSVIDEO, &state); 881 ioctl(pPnozz->psdp->fd, FBIOSVIDEO, &state);
869  882
870 pScreen->CloseScreen = pPnozz->CloseScreen; 883 pScreen->CloseScreen = pPnozz->CloseScreen;
871 return (*pScreen->CloseScreen)(scrnIndex, pScreen); 884 return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS);
872 return FALSE; 
873} 885}
874 886
875 887
876/* Free up any per-generation data structures */ 888/* Free up any per-generation data structures */
877 889
878/* Optional */ 890/* Optional */
879static void 891static void
880PnozzFreeScreen(int scrnIndex, int flags) 892PnozzFreeScreen(FREE_SCREEN_ARGS_DECL)
881{ 893{
882 PnozzFreeRec(xf86Screens[scrnIndex]); 894 SCRN_INFO_PTR(arg);
 895 PnozzFreeRec(pScrn);
883} 896}
884 897
885 898
886/* Checks if a mode is suitable for the selected chipset. */ 899/* Checks if a mode is suitable for the selected chipset. */
887 900
888/* Optional */ 901/* Optional */
889static ModeStatus 902static ModeStatus
890PnozzValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) 903PnozzValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags)
891{ 904{
892 if (mode->Flags & V_INTERLACE) 905 if (mode->Flags & V_INTERLACE)
893 return(MODE_BAD); 906 return(MODE_BAD);
894 907
895 return(MODE_OK); 908 return(MODE_OK);
896} 909}
897 910
898/* Do screen blanking */ 911/* Do screen blanking */
899 912
900/* Mandatory */ 913/* Mandatory */
901static Bool 914static Bool
902PnozzSaveScreen(ScreenPtr pScreen, int mode) 915PnozzSaveScreen(ScreenPtr pScreen, int mode)
903{ 916{
904 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; 917 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
905 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 918 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
906 int fd = pPnozz->psdp->fd, state; 919 int fd = pPnozz->psdp->fd, state;
907  920
908 /*  921 /*
909 * we're using ioctl() instead of just whacking the DAC because the  922 * we're using ioctl() instead of just whacking the DAC because the
910 * underlying driver will also turn off the backlight which we couldn't do  923 * underlying driver will also turn off the backlight which we couldn't do
911 * from here without adding lots more hardware dependencies  924 * from here without adding lots more hardware dependencies
912 */ 925 */
913 switch(mode) 926 switch(mode)
914 { 927 {
915 case SCREEN_SAVER_ON: 928 case SCREEN_SAVER_ON:
916 case SCREEN_SAVER_CYCLE: 929 case SCREEN_SAVER_CYCLE:
917 state = 0; 930 state = 0;
918 if(ioctl(fd, FBIOSVIDEO, &state) == -1) 931 if(ioctl(fd, FBIOSVIDEO, &state) == -1)
919 { 932 {
920 /* complain */ 933 /* complain */
921 } 934 }
922 break; 935 break;
923 case SCREEN_SAVER_OFF: 936 case SCREEN_SAVER_OFF:
924 case SCREEN_SAVER_FORCER: 937 case SCREEN_SAVER_FORCER:
925 state = 1; 938 state = 1;
926 if(ioctl(fd, FBIOSVIDEO, &state) == -1) 939 if(ioctl(fd, FBIOSVIDEO, &state) == -1)
927 { 940 {
928 /* complain */ 941 /* complain */
929 } 942 }
930 break; 943 break;
931 default: 944 default:
932 return FALSE; 945 return FALSE;
933 } 946 }
934 return TRUE; 947 return TRUE;
935} 948}
936 949
937int shift_1(int b) 950int shift_1(int b)
938{ 951{
939 if (b > 0) 952 if (b > 0)
940 return (16 << b); 953 return (16 << b);
941 return 0; 954 return 0;
942} 955}
943 956
944int shift_2(int b) 957int shift_2(int b)
945{ 958{
946 if (b > 0) 959 if (b > 0)
947 return (512 << b); 960 return (512 << b);
948 return 0; 961 return 0;
949} 962}
950 963
951void 964void
952PnozzSave(PnozzPtr pPnozz) 965PnozzSave(PnozzPtr pPnozz)
953{ 966{
954 int i; 967 int i;
955 pPnozz->SvSysConf = pnozz_read_4(pPnozz, SYS_CONF); 968 pPnozz->SvSysConf = pnozz_read_4(pPnozz, SYS_CONF);
956 pPnozz->SvDAC_MC3 = pnozz_read_dac_ctl_reg(pPnozz, DAC_MISC_3); 969 pPnozz->SvDAC_MC3 = pnozz_read_dac_ctl_reg(pPnozz, DAC_MISC_3);
957 pPnozz->SvDAC_MCCR = pnozz_read_dac_ctl_reg(pPnozz, DAC_MISC_CLK); 970 pPnozz->SvDAC_MCCR = pnozz_read_dac_ctl_reg(pPnozz, DAC_MISC_CLK);
958 pPnozz->SvDAC_PF = pnozz_read_dac_ctl_reg(pPnozz, DAC_PIXEL_FMT); 971 pPnozz->SvDAC_PF = pnozz_read_dac_ctl_reg(pPnozz, DAC_PIXEL_FMT);
959 pPnozz->SvPLL = pnozz_read_dac_ctl_reg(pPnozz, DAC_PLL0); 972 pPnozz->SvPLL = pnozz_read_dac_ctl_reg(pPnozz, DAC_PLL0);
960 pPnozz->SvVCO = pnozz_read_dac_ctl_reg(pPnozz, DAC_VCO_DIV); 973 pPnozz->SvVCO = pnozz_read_dac_ctl_reg(pPnozz, DAC_VCO_DIV);
961 pPnozz->SvMemCtl = pnozz_read_4(pPnozz, VID_MEM_CONFIG); 974 pPnozz->SvMemCtl = pnozz_read_4(pPnozz, VID_MEM_CONFIG);
962 for (i = 0; i < 4; i++) 975 for (i = 0; i < 4; i++)
963 pPnozz->CRTC[i] = pnozz_read_4(pPnozz, VID_HTOTAL + (i << 2)); 976 pPnozz->CRTC[i] = pnozz_read_4(pPnozz, VID_HTOTAL + (i << 2));
964 pPnozz->DidSave = 1; 977 pPnozz->DidSave = 1;
965#if DEBUG 978#if DEBUG
966 xf86Msg(X_ERROR, "Saved: %x %x %x %x\n", pPnozz->SvSysConf,  979 xf86Msg(X_ERROR, "Saved: %x %x %x %x\n", pPnozz->SvSysConf,
967 pPnozz->SvDAC_MCCR, pPnozz->SvDAC_PF, pPnozz->SvDAC_MC3); 980 pPnozz->SvDAC_MCCR, pPnozz->SvDAC_PF, pPnozz->SvDAC_MC3);
968 DumpSCR(pPnozz->SvSysConf); 981 DumpSCR(pPnozz->SvSysConf);
969#endif 982#endif
970}  983}
971 984
972void DumpSCR(unsigned int scr) 985void DumpSCR(unsigned int scr)
973{ 986{
974#if DEBUG 987#if DEBUG
975 int s0, s1, s2, s3, ps; 988 int s0, s1, s2, s3, ps;
976 int width; 989 int width;
977 ps = (scr >> PIXEL_SHIFT) & 7; 990 ps = (scr >> PIXEL_SHIFT) & 7;
978 s0 = (scr >> SHIFT_0) & 7; 991 s0 = (scr >> SHIFT_0) & 7;
979 s1 = (scr >> SHIFT_1) & 7; 992 s1 = (scr >> SHIFT_1) & 7;
980 s2 = (scr >> SHIFT_2) & 7; 993 s2 = (scr >> SHIFT_2) & 7;
981 s3 = (scr >> SHIFT_3) & 3; 994 s3 = (scr >> SHIFT_3) & 3;
982 width = shift_1(s0) + shift_1(s1) + shift_1(s2) + shift_2(s3); 995 width = shift_1(s0) + shift_1(s1) + shift_1(s2) + shift_2(s3);
983 xf86Msg(X_ERROR, "ps: %d wi: %d\n", ps, width); 996 xf86Msg(X_ERROR, "ps: %d wi: %d\n", ps, width);
984#endif 997#endif
985} 998}
986 999
987void DumpDAC(PnozzPtr pPnozz) 1000void DumpDAC(PnozzPtr pPnozz)
988{ 1001{
989#if DEBUG 1002#if DEBUG
990 int addr, i, val; 1003 int addr, i, val;
991 char line[256], buffer[16]; 1004 char line[256], buffer[16];
992 pnozz_write_dac(pPnozz, DAC_INDX_LO, 0); 1005 pnozz_write_dac(pPnozz, DAC_INDX_LO, 0);
993 pnozz_write_dac(pPnozz, DAC_INDX_HI, 0); 1006 pnozz_write_dac(pPnozz, DAC_INDX_HI, 0);
994 for (addr = 0; addr < 0x100; addr += 16) { 1007 for (addr = 0; addr < 0x100; addr += 16) {
995 snprintf(line, 16, "%02x:", addr); 1008 snprintf(line, 16, "%02x:", addr);
996 for (i=0;i<16;i++) { 1009 for (i=0;i<16;i++) {
997 val = pnozz_read_dac(pPnozz, DAC_INDX_DATA); 1010 val = pnozz_read_dac(pPnozz, DAC_INDX_DATA);
998 snprintf(buffer, 16, " %02x", val); 1011 snprintf(buffer, 16, " %02x", val);
999 strcat(line, buffer); 1012 strcat(line, buffer);
1000 } 1013 }
1001 xf86Msg(X_ERROR, "%s\n", line); 1014 xf86Msg(X_ERROR, "%s\n", line);
1002 } 1015 }
1003#endif 1016#endif
1004} 1017}
1005  1018
1006void DumpCRTC(PnozzPtr pPnozz) 1019void DumpCRTC(PnozzPtr pPnozz)
1007{ 1020{
1008#if DEBUG 1021#if DEBUG
1009 int i; 1022 int i;
1010 unsigned int reg; 1023 unsigned int reg;
1011 for (i = 0x108; i<0x140; i += 4) { 1024 for (i = 0x108; i<0x140; i += 4) {
1012 reg = pnozz_read_4(pPnozz, i); 1025 reg = pnozz_read_4(pPnozz, i);
1013 xf86Msg(X_ERROR, "%x / %d ", reg, reg); 1026 xf86Msg(X_ERROR, "%x / %d ", reg, reg);
1014 } 1027 }
1015 reg = pnozz_read_4(pPnozz, VID_MEM_CONFIG); 1028 reg = pnozz_read_4(pPnozz, VID_MEM_CONFIG);
1016 xf86Msg(X_ERROR, "memcfg: %08x\n", reg); 1029 xf86Msg(X_ERROR, "memcfg: %08x\n", reg);
1017 xf86Msg(X_ERROR, "shiftclk: %x\n", (reg >> 10) & 7); 1030 xf86Msg(X_ERROR, "shiftclk: %x\n", (reg >> 10) & 7);
1018 xf86Msg(X_ERROR, "shiftmode: %x\n", (reg >> 22) & 3); 1031 xf86Msg(X_ERROR, "shiftmode: %x\n", (reg >> 22) & 3);
1019 xf86Msg(X_ERROR, "crtc_clk: %x\n", (reg >> 13) & 7); 1032 xf86Msg(X_ERROR, "crtc_clk: %x\n", (reg >> 13) & 7);
1020#endif 1033#endif
1021} 1034}
1022 1035
1023void 1036void
1024PnozzRestore(PnozzPtr pPnozz) 1037PnozzRestore(PnozzPtr pPnozz)
1025{ 1038{
1026 int i; 1039 int i;
1027 if(pPnozz->DidSave == 1) { 1040 if(pPnozz->DidSave == 1) {
1028 pnozz_write_4(pPnozz, SYS_CONF, pPnozz->SvSysConf); 1041 pnozz_write_4(pPnozz, SYS_CONF, pPnozz->SvSysConf);
1029 pnozz_write_4(pPnozz, VID_MEM_CONFIG, pPnozz->SvMemCtl); 1042 pnozz_write_4(pPnozz, VID_MEM_CONFIG, pPnozz->SvMemCtl);
1030 for (i = 0; i < 4; i++) 1043 for (i = 0; i < 4; i++)
1031 pnozz_write_4(pPnozz, VID_HTOTAL + (i << 2), pPnozz->CRTC[i]); 1044 pnozz_write_4(pPnozz, VID_HTOTAL + (i << 2), pPnozz->CRTC[i]);
1032 1045
1033 pnozz_write_dac_ctl_reg(pPnozz, DAC_PLL0, pPnozz->SvPLL); 1046 pnozz_write_dac_ctl_reg(pPnozz, DAC_PLL0, pPnozz->SvPLL);
1034 pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_3, pPnozz->SvDAC_MC3); 1047 pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_3, pPnozz->SvDAC_MC3);
1035 pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_CLK, pPnozz->SvDAC_MCCR); 1048 pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_CLK, pPnozz->SvDAC_MCCR);
1036 pnozz_write_dac_ctl_reg(pPnozz, DAC_PIXEL_FMT, pPnozz->SvDAC_PF); 1049 pnozz_write_dac_ctl_reg(pPnozz, DAC_PIXEL_FMT, pPnozz->SvDAC_PF);
1037 pnozz_write_dac_ctl_reg(pPnozz, DAC_VCO_DIV, pPnozz->SvVCO); 1050 pnozz_write_dac_ctl_reg(pPnozz, DAC_VCO_DIV, pPnozz->SvVCO);
1038 } 1051 }
1039}  1052}
1040 1053
1041unsigned int upper_bit(unsigned int b) 1054unsigned int upper_bit(unsigned int b)
1042{ 1055{
1043 unsigned int mask=0x80000000; 1056 unsigned int mask=0x80000000;
1044 int cnt = 31; 1057 int cnt = 31;
1045 if (b == 0) 1058 if (b == 0)
1046 return -1; 1059 return -1;
1047 while ((mask != 0) && ((b & mask) == 0)) { 1060 while ((mask != 0) && ((b & mask) == 0)) {
1048 mask = mask >> 1; 1061 mask = mask >> 1;
1049 cnt--; 1062 cnt--;
1050 } 1063 }
1051 return cnt; 1064 return cnt;
1052} 1065}
1053 1066
1054/* 1067/*
1055 * To switch colour depth we need to: 1068 * To switch colour depth we need to:
1056 * - double or quadruple both crtc and shift clock ( for 16 or 32 bit ) 1069 * - double or quadruple both crtc and shift clock ( for 16 or 32 bit )
1057 * - double or quadruple scanline length 1070 * - double or quadruple scanline length
1058 * - switch the DAC to the appropriate pixel format 1071 * - switch the DAC to the appropriate pixel format
1059 * - tell the drawing engine about new line length / pixel size 1072 * - tell the drawing engine about new line length / pixel size
1060 */ 1073 */
1061 1074
1062int 1075int
1063PnozzSetDepth(PnozzPtr pPnozz, int depth) 1076PnozzSetDepth(PnozzPtr pPnozz, int depth)
1064{ 1077{
1065 int new_sls; 1078 int new_sls;
1066 unsigned int bits, scr, sscr, memctl, mem; 1079 unsigned int bits, scr, sscr, memctl, mem;
1067 int s0, s1, s2, s3, ps, crtcline; 1080 int s0, s1, s2, s3, ps, crtcline;
1068 unsigned char pf, mc3, es; 1081 unsigned char pf, mc3, es;
1069 1082
1070#if DEBUG 1083#ifdef DEBUG
 1084 xf86Msg(X_ERROR, "SetDepth: %d\n", depth);
1071 DumpDAC(pPnozz); 1085 DumpDAC(pPnozz);
1072 DumpCRTC(pPnozz); 1086 DumpCRTC(pPnozz);
1073#endif 1087#endif
1074 1088
1075 switch (depth) { 1089 switch (depth) {
1076 case 8: 1090 case 8:
1077 pPnozz->depthshift = 0; 1091 pPnozz->depthshift = 0;
1078 ps = 2; 1092 ps = 2;
1079 pf = 3; 1093 pf = 3;
1080 mc3 = 0; 1094 mc3 = 0;
1081 es = 0; /* no swapping */ 1095 es = 0; /* no swapping */
1082 memctl = 3; 1096 memctl = 3;
1083 break; 1097 break;
1084 case 16: 1098 case 16:
1085 pPnozz->depthshift = 1; 1099 pPnozz->depthshift = 1;
1086 ps = 3; 1100 ps = 3;
1087 pf = 4; 1101 pf = 4;
1088 mc3 = 0; 1102 mc3 = 0;
1089 es = 2; /* swap bytes in 16bit words */ 1103 es = 2; /* swap bytes in 16bit words */
1090 memctl = 2; 1104 memctl = 2;
1091 break; 1105 break;
1092 case 24: 1106 case 24:
1093 /* boo */ 1107 /* boo */
1094 xf86Msg(X_ERROR, "We don't DO 24bit pixels dammit!\n"); 1108 xf86Msg(X_ERROR, "We don't DO 24bit pixels dammit!\n");
1095 return 0; 1109 return 0;
1096 case 32: 1110 case 32:
1097 pPnozz->depthshift = 2; 1111 pPnozz->depthshift = 2;
1098 ps = 5; 1112 ps = 5;
1099 pf = 6; 1113 pf = 6;
1100 mc3 = 0; 1114 mc3 = 0;
1101 es = 6; /* swap both half-words and bytes */ 1115 es = 6; /* swap both half-words and bytes */
1102 memctl = 1; /* 0 */ 1116 memctl = 1; /* 0 */
1103 break; 1117 break;
1104 } 1118 }
1105 /* 1119 /*
1106 * this could be done a lot shorter and faster but then nobody would  1120 * this could be done a lot shorter and faster but then nobody would
1107 * understand what the hell we're doing here without getting a major  1121 * understand what the hell we're doing here without getting a major
1108 * headache. Scanline size is encoded as 4 shift values, 3 of them 3 bits  1122 * headache. Scanline size is encoded as 4 shift values, 3 of them 3 bits
1109 * wide, 16 << n for n>0, one 2 bits, 512 << n for n>0. n==0 means 0 1123 * wide, 16 << n for n>0, one 2 bits, 512 << n for n>0. n==0 means 0
1110 */ 1124 */
1111 new_sls = pPnozz->width << pPnozz->depthshift; 1125 new_sls = pPnozz->width << pPnozz->depthshift;
1112 pPnozz->scanlinesize = new_sls; 1126 pPnozz->scanlinesize = new_sls;
1113 bits = new_sls; 1127 bits = new_sls;
1114 s3 = upper_bit(bits); 1128 s3 = upper_bit(bits);
1115 if (s3 > 9) { 1129 if (s3 > 9) {
1116 bits &= ~(1 << s3); 1130 bits &= ~(1 << s3);
1117 s3 -= 9; 1131 s3 -= 9;
1118 } else s3 = 0; 1132 } else s3 = 0;
1119 s2 = upper_bit(bits); 1133 s2 = upper_bit(bits);
1120 if (s2 > 0) { 1134 if (s2 > 0) {
1121 bits &= ~(1 << s2); 1135 bits &= ~(1 << s2);
1122 s2 -= 4; 1136 s2 -= 4;
1123 } else s2 = 0; 1137 } else s2 = 0;
1124 s1 = upper_bit(bits); 1138 s1 = upper_bit(bits);
1125 if (s1 > 0) { 1139 if (s1 > 0) {
1126 bits &= ~(1 << s1); 1140 bits &= ~(1 << s1);
1127 s1 -= 4; 1141 s1 -= 4;
1128 } else s1 = 0; 1142 } else s1 = 0;
1129 s0 = upper_bit(bits); 1143 s0 = upper_bit(bits);
1130 if (s0 > 0) { 1144 if (s0 > 0) {
1131 bits &= ~(1 << s0); 1145 bits &= ~(1 << s0);
1132 s0 -= 4; 1146 s0 -= 4;
1133 } else s0 = 0; 1147 } else s0 = 0;
1134 1148
1135#if DEBUG 1149#if DEBUG
1136 xf86Msg(X_ERROR, "sls: %x sh: %d %d %d %d leftover: %x\n", new_sls, s0, s1,  1150 xf86Msg(X_ERROR, "sls: %x sh: %d %d %d %d leftover: %x\n", new_sls, s0, s1,
1137 s2, s3, bits); 1151 s2, s3, bits);
1138#endif 1152#endif
1139 1153
1140 /*  1154 /*
1141 * now let's put these values into the System Config Register. No need to  1155 * now let's put these values into the System Config Register. No need to
1142 * read it here since we (hopefully) just saved the content  1156 * read it here since we (hopefully) just saved the content
1143 */ 1157 */
1144 scr = pnozz_read_4(pPnozz, SYS_CONF); 1158 scr = pnozz_read_4(pPnozz, SYS_CONF);
1145 scr = (s0 << SHIFT_0) | (s1 << SHIFT_1) | (s2 << SHIFT_2) |  1159 scr = (s0 << SHIFT_0) | (s1 << SHIFT_1) | (s2 << SHIFT_2) |
1146 (s3 << SHIFT_3) | (ps << PIXEL_SHIFT) | (es << SWAP_SHIFT); 1160 (s3 << SHIFT_3) | (ps << PIXEL_SHIFT) | (es << SWAP_SHIFT);
1147#if DEBUG 1161#if DEBUG
1148 xf86Msg(X_ERROR, "new scr: %x DAC %x %x\n", scr, pf, mc3); 1162 xf86Msg(X_ERROR, "new scr: %x DAC %x %x\n", scr, pf, mc3);
1149 DumpSCR(scr); 1163 DumpSCR(scr);
1150#endif 1164#endif
1151  1165
1152 mem = pnozz_read_4(pPnozz, VID_MEM_CONFIG); 1166 mem = pnozz_read_4(pPnozz, VID_MEM_CONFIG);
1153#if DEBUG 1167#if DEBUG
1154 xf86Msg(X_ERROR, "old memctl: %08x\n", mem); 1168 xf86Msg(X_ERROR, "old memctl: %08x\n", mem);
1155#endif 1169#endif
1156 /* set shift and crtc clock */ 1170 /* set shift and crtc clock */
1157 mem &= ~(0x0000fc00); 1171 mem &= ~(0x0000fc00);
1158 mem |= (memctl << 10) | (memctl << 13); 1172 mem |= (memctl << 10) | (memctl << 13);
1159 pnozz_write_4(pPnozz, VID_MEM_CONFIG, mem); 1173 pnozz_write_4(pPnozz, VID_MEM_CONFIG, mem);
1160#if DEBUG 1174#if DEBUG
1161 xf86Msg(X_ERROR, "new memctl: %08x\n", mem); 1175 xf86Msg(X_ERROR, "new memctl: %08x\n", mem);
1162#endif  1176#endif
1163 /* whack the engine... */ 1177 /* whack the engine... */
1164 pnozz_write_4(pPnozz, SYS_CONF, scr); 1178 pnozz_write_4(pPnozz, SYS_CONF, scr);
1165  1179
1166 /* ok, whack the DAC */ 1180 /* ok, whack the DAC */
1167 pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_1, 0x11); 1181 pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_1, 0x11);
1168 pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_2, 0x45); 1182 pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_2, 0x45);
1169 pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_3, mc3); 1183 pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_3, mc3);
1170 /*  1184 /*
1171 * despite the 3GX manual saying otherwise we don't need to mess with any 1185 * despite the 3GX manual saying otherwise we don't need to mess with any
1172 * clock dividers here 1186 * clock dividers here
1173 */ 1187 */
1174 pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_CLK, 1); 1188 pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_CLK, 1);
1175 pnozz_write_dac_ctl_reg(pPnozz, 3, 0); 1189 pnozz_write_dac_ctl_reg(pPnozz, 3, 0);
1176 pnozz_write_dac_ctl_reg(pPnozz, 4, 0); 1190 pnozz_write_dac_ctl_reg(pPnozz, 4, 0);
1177  1191
1178 pnozz_write_dac_ctl_reg(pPnozz, DAC_POWER_MGT, 0); 1192 pnozz_write_dac_ctl_reg(pPnozz, DAC_POWER_MGT, 0);
1179 pnozz_write_dac_ctl_reg(pPnozz, DAC_OPERATION, 0); 1193 pnozz_write_dac_ctl_reg(pPnozz, DAC_OPERATION, 0);
1180 pnozz_write_dac_ctl_reg(pPnozz, DAC_PALETTE_CTRL, 0); 1194 pnozz_write_dac_ctl_reg(pPnozz, DAC_PALETTE_CTRL, 0);
1181 1195
1182 pnozz_write_dac_ctl_reg(pPnozz, DAC_PIXEL_FMT, pf); 1196 pnozz_write_dac_ctl_reg(pPnozz, DAC_PIXEL_FMT, pf);
1183  1197
1184 /* TODO: distinguish between 15 and 16 bit */ 1198 /* TODO: distinguish between 15 and 16 bit */
1185 pnozz_write_dac_ctl_reg(pPnozz, DAC_8BIT_CTRL, 0); 1199 pnozz_write_dac_ctl_reg(pPnozz, DAC_8BIT_CTRL, 0);
1186 /* direct colour, linear, 565 */ 1200 /* direct colour, linear, 565 */
1187 pnozz_write_dac_ctl_reg(pPnozz, DAC_16BIT_CTRL, 0xc6); 1201 pnozz_write_dac_ctl_reg(pPnozz, DAC_16BIT_CTRL, 0xc6);
1188 /* direct colour */ 1202 /* direct colour */
1189 pnozz_write_dac_ctl_reg(pPnozz, DAC_32BIT_CTRL, 3); 1203 pnozz_write_dac_ctl_reg(pPnozz, DAC_32BIT_CTRL, 3);
1190  1204
1191 pnozz_write_dac_ctl_reg(pPnozz, 0x10, 2); 1205 pnozz_write_dac_ctl_reg(pPnozz, 0x10, 2);
1192 pnozz_write_dac_ctl_reg(pPnozz, 0x11, 0); 1206 pnozz_write_dac_ctl_reg(pPnozz, 0x11, 0);
1193 pnozz_write_dac_ctl_reg(pPnozz, 0x14, 5); 1207 pnozz_write_dac_ctl_reg(pPnozz, 0x14, 5);
1194 pnozz_write_dac_ctl_reg(pPnozz, 0x08, 1); 1208 pnozz_write_dac_ctl_reg(pPnozz, 0x08, 1);
1195 pnozz_write_dac_ctl_reg(pPnozz, 0x15, 5); 1209 pnozz_write_dac_ctl_reg(pPnozz, 0x15, 5);
1196 pnozz_write_dac_ctl_reg(pPnozz, 0x16, 0x63); 1210 pnozz_write_dac_ctl_reg(pPnozz, 0x16, 0x63);
1197  1211
1198 /* whack the CRTC */ 1212 /* whack the CRTC */
1199 /* we always transfer 64bit in one go */ 1213 /* we always transfer 64bit in one go */
1200 crtcline = pPnozz->scanlinesize >> 3; 1214 crtcline = pPnozz->scanlinesize >> 3;
1201#if DEBUG 1215#if DEBUG
1202 xf86Msg(X_ERROR, "crtcline: %d\n", crtcline); 1216 xf86Msg(X_ERROR, "crtcline: %d\n", crtcline);
1203#endif 1217#endif
1204 pnozz_write_4(pPnozz, VID_HTOTAL, (24 << pPnozz->depthshift) + crtcline); 1218 pnozz_write_4(pPnozz, VID_HTOTAL, (24 << pPnozz->depthshift) + crtcline);
1205 pnozz_write_4(pPnozz, VID_HSRE, 8 << pPnozz->depthshift); 1219 pnozz_write_4(pPnozz, VID_HSRE, 8 << pPnozz->depthshift);
1206 pnozz_write_4(pPnozz, VID_HBRE, 18 << pPnozz->depthshift); 1220 pnozz_write_4(pPnozz, VID_HBRE, 18 << pPnozz->depthshift);
1207 pnozz_write_4(pPnozz, VID_HBFE, (18 << pPnozz->depthshift) + crtcline); 1221 pnozz_write_4(pPnozz, VID_HBFE, (18 << pPnozz->depthshift) + crtcline);
1208 1222
1209#if DEBUG 1223#if DEBUG
1210 sscr = pnozz_read_4(pPnozz, SYS_CONF); 1224 sscr = pnozz_read_4(pPnozz, SYS_CONF);
1211 xf86Msg(X_ERROR, "scr: %x\n", sscr); 1225 xf86Msg(X_ERROR, "scr: %x\n", sscr);
1212#endif 1226#endif
1213 return TRUE; 1227 return TRUE;
1214} 1228}