ngle_manual.txt revision 1.5
11.5Smacallan$NetBSD: ngle_manual.txt,v 1.5 2025/12/30 08:36:59 macallan Exp $
21.1Smacallan
31.1SmacallanThe Unofficial NGLE Manual
41.1Smacallan
51.1SmacallanPreface
61.1SmacallanThis manual covers what I've been able to figure out about HP's NGLE family of
71.1Smacallangraphics devices commonly used in HP PA-RISC workstations, namely HCRX24 and
81.2SmacallanPCI Visualize EG. It doesn't explain basic concepts but anyone with some
91.2Smacallangraphics driver writing experience should be able to understand it.
101.1SmacallanSince there is no official documentation available I used the NGLE code found in
111.1SmacallanXFree86 3.3 as a starting point, with plenty of guesswork and experimentation.
121.2SmacallanThe xf86 code is somewhat obfuscated ( register names are random numbers, values
131.2Smacallanwritten are almost all magic numbers ) and does not actually accelerate any
141.2Smacallangraphics operations. It does however use the blitter to clear the framebuffer
151.2Smacallanand attribute planes, show how to use a cursor sprite, colour LUTs and so on.
161.1SmacallanNone of this is endorsed, supported, or (likely) known to Hewlett-Packard.
171.1SmacallanAll register definitions are from
181.1Smacallanhttps://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/ic/nglereg.h
191.1Smacallankernel drivers for HCRX and PCI Visualize EG:
201.1Smacallanhttps://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/hppa/dev/hyperfb.c
211.1Smacallanhttps://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/hppa/dev/gftfb.c
221.1SmacallanXorg driver:
231.1Smacallanhttps://cvsweb.netbsd.org/bsdweb.cgi/xsrc/external/mit/xf86-video-ngle/dist/src/
241.1Smacallan
251.1Smacallan1. Now how does this thing work
261.1SmacallanAll NGLE devices work in more or less the same way, with some differences in
271.1Smacallandetails and additional features. Every device occupies a 32MB range, half of
281.1Smacallanwhich contains the STI ROM and registers, the other is for framebuffer access.
291.5SmacallanMy HCRX, living at 0xf6000000, lists the following regions:
301.5Smacallan 000c0000 @ 0xf6000000 btlb
311.5Smacallan 01000000 @ 0xf7000000 btlb - fb
321.5Smacallan 00280000 @ 0xf6100000 btlb
331.5Smacallan 00040000 @ 0xf60c0000 btlb
341.5Smacallan 00400000 @ 0xf6c00000 btlb
351.5Smacallan 00001000 @ 0xf6380000 sys last
361.5SmacallanThe ones we know what to do with are:
371.5Smacallan 000c0000 @ 0xf6000000 - this is the STI ROM
381.5Smacallan 01000000 @ 0xf7000000 - framebuffer aperture
391.5Smacallan 00280000 @ 0xf6100000 - drawing engine registers
401.5SmacallanSizes vary, but these offsets are the same on my PCI EG and I assue on most if
411.5Smacallannot all other NGLE devices. Nothing is known about the others, I would assume
421.5Smacallanthe 'sys' region at the end contains DMA engine registers we don't want to show
431.5Smacallanto userland.
441.5Smacallan
451.2SmacallanThe framebuffer aperture can map exactly one chunk of video memory - things like
461.1Smacallanfront or back buffers, overlay, attribute planes, and a few unusual things, like
471.1Smacallancolour maps and cursor sprite bitmaps. Read and write access can be controlled
481.1Smacallanindependently, and all settings apply to both the drawing engine and CPU access
491.1Smacallanthrough the framebuffer aperture.
501.1SmacallanThat means there is no such thing as direct framebuffer access, everything goes
511.1Smacallanthrough the graphics pipeline. If you set the engine to 32bit colour expansion
521.1Smacallanthen whatever you write into the aperture will be expanded. Also, care must be
531.2Smacallantaken to not attempt to access video memory while updating the cursor image or
541.1Smacallancolour maps.
551.1SmacallanAll framebuffer access applies a fixed pitch of 2048 pixels.
561.1SmacallanThe chips support the usual selection of graphics primitives - rectangle fill,
571.1Smacallancopy, colour expansion, and indirect access. There's plenty more ( many have 3D
581.1Smacallanfeatures ) but these are completely unknown.
591.2SmacallanAll register addresses listed here are relative to STI region 2, and all
601.2Smacallanregisters are 32bit big endian, even on PCI.
611.2SmacallanThere is no available information on video mode programming other than
621.2Smacallandisassembling STI ROMs, and the details are very likely board specific ( HCRX
631.2Smacallanis fixed at 1280x1024 for example ). So in order to get going one would:
641.2Smacallan- setup STI access
651.2Smacallan- get the board type, hardware addresses, video mode etc. from STI's INIT_GRAPH
661.2Smacallan  and INQ_CONF calls
671.2Smacallan- map framebuffer and registers ( STI region 1 and 2 should be enough )
681.2Smacallan- do our own initialization - STI likes to set the planemask to only allow
691.2Smacallan  access to the planes used for text output, and leaves bitmap access modes at
701.2Smacallan  something suitable for rectangle fills and character drawing, not something
711.2Smacallan  useful to write into the framebuffer
721.1Smacallan
731.1Smacallan2. Framebuffer access
741.1Smacallan#define	NGLE_BAboth		0x018000	/* read and write mode */
751.1Smacallan#define	NGLE_DBA		0x018004	/* Dest. Bitmap Access */
761.1Smacallan#define	NGLE_SBA		0x018008	/* Source Bitmap Access */
771.1Smacallan
781.1Smacallan#define BA(F,C,S,A,J,B,I)						\
791.1Smacallan	(((F)<<31)|((C)<<27)|((S)<<24)|((A)<<21)|((J)<<16)|((B)<<12)|(I))
801.1Smacallan	/* FCCC CSSS AAAJ JJJJ BBBB IIII IIII IIII */
811.1Smacallan
821.1Smacallan/* F */
831.1Smacallan#define	    IndexedDcd	0	/* Pixel data is indexed (pseudo) color */
841.1Smacallan#define	    FractDcd	1	/* Pixel data is Fractional 8-8-8 */
851.1Smacallan/* C */
861.1Smacallan#define	    Otc04	2	/* Pixels in each longword transfer (4) */
871.1Smacallan#define	    Otc32	5	/* Pixels in each longword transfer (32) */
881.1Smacallan#define	    Otc24	7	/* NGLE uses this for 24bit blits */
891.1Smacallan				/* Should really be... */
901.1Smacallan#define	    Otc01	7	/* one pixel per longword */
911.1Smacallan/* S */
921.1Smacallan#define	    Ots08	3	/* Each pixel is size (8)d transfer (1) */
931.1Smacallan#define	    OtsIndirect	6	/* Each bit goes through FG/BG color(8) */
941.1Smacallan/* A */
951.1Smacallan#define	    AddrByte	3	/* byte access? Used by NGLE for direct fb */
961.1Smacallan#define	    AddrLong	5	/* FB address is Long aligned (pixel) */
971.1Smacallan#define     Addr24	7	/* used for colour map access */
981.1Smacallan/* B */
991.1Smacallan#define	    BINapp0I	0x0	/* Application Buffer 0, Indexed */
1001.1Smacallan#define	    BINapp1I	0x1	/* Application Buffer 1, Indexed */
1011.1Smacallan#define	    BINovly	0x2	/* 8 bit overlay */
1021.1Smacallan#define	    BINcursor	0x6	/* cursor bitmap on EG */
1031.1Smacallan#define	    BINcmask	0x7	/* cursor mask on EG */
1041.1Smacallan#define	    BINapp0F8	0xa	/* Application Buffer 0, Fractional 8-8-8 */
1051.1Smacallan/* next one is a guess, my HCRX24 doesn't seem to have it */
1061.1Smacallan#define	    BINapp1F8	0xb	/* Application Buffer 1, Fractional 8-8-8 */
1071.1Smacallan#define	    BINattr	0xd	/* Attribute Bitmap */
1081.1Smacallan#define	    BINcmap	0xf	/* colour map(s) */
1091.1Smacallan/* I assume one of the undefined BIN* accesses the HCRX Z-buffer add-on. No clue
1101.1Smacallan * about bit depth or if any bits are used for stencil */
1111.1Smacallan 
1121.1Smacallan/* other buffers are unknown */
1131.1Smacallan/* J - 'BA just point' - function unknown */
1141.1Smacallan/* I - 'BA index base' - function unknown */
1151.1Smacallan
1161.1SmacallanThe BIN* values control which buffer we access, Addr* controls how memory is
1171.1Smacallanpresented to the CPU. With AddrLong all pixels are at 32bit boundaries, no
1181.1Smacallanmatter the actual colour depth. Otc* controls how many pixels we write with a
1191.2Smacallansingle 32bit access, so for 8bit pixels we would use Otc04, for 24bit colour
1201.2SmacallanOtc01, and Otc32 is for mono to colour expansion. OtsIndirect enables colour
1211.1Smacallanexpansion, combined with Otc32 every set bit writes a foreground colour pixel,
1221.1Smacallanunset bits can be transparent or background.
1231.1SmacallanThe *Dcd bit's exact function is a bit unclear - we set it for 24bit colour
1241.1Smacallanaccess to both framebuffer and colour maps. I suspect enabling it on an 8bit
1251.1Smacallanbuffer will result in R3G3B2 output from rendering and blending operations,
1261.1Smacallanwhich we know nothing about.
1271.1SmacallanSo, for normal access to the overlay on an HCRX we would use IndexedDcd, Otc04,
1281.2SmacallanOts8, AddrByte, BINovly, and set a suitable planemask and binary operation.
1291.2Smacallan
1301.2SmacallanAll writes to the framebuffer, by CPU or drawing engine, have binary operations
1311.2Smacallanand a plane maskapplied to them:
1321.2Smacallan
1331.2Smacallan#define	NGLE_PLANEMASK		0x018018	/* image planemask */
1341.2Smacallan
1351.2Smacallan#define	NGLE_IBO		0x01801c	/* image binary op */
1361.2Smacallan
1371.2Smacallan#define IBOvals(R,M,X,S,D,L,B,F)					\
1381.2Smacallan	(((R)<<8)|((M)<<16)|((X)<<24)|((S)<<29)|((D)<<28)|((L)<<31)|((B)<<1)|(F))
1391.2Smacallan	/* LSSD XXXX MMMM MMMM RRRR RRRR ???? ??BF */
1401.2Smacallan
1411.2Smacallan/* R is a standard X11 ROP, no idea if the other bits are used for anything  */
1421.2Smacallan#define	    RopClr 	0x0
1431.2Smacallan#define	    RopSrc 	0x3
1441.2Smacallan#define	    RopInv 	0xc
1451.2Smacallan#define	    RopSet 	0xf
1461.2Smacallan/* M: 'mask addr offset' - function unknown */
1471.2Smacallan/* X */
1481.2Smacallan#define	    BitmapExtent08  3	/* Each write hits ( 8) bits in depth */
1491.2Smacallan#define	    BitmapExtent32  5	/* Each write hits (32) bits in depth */
1501.2Smacallan/* S: 'static reg' flag, NGLE sets it for blits, function is unknown but
1511.2Smacallan      we get occasional garbage in 8bit blits without it  */
1521.2Smacallan/* D */
1531.2Smacallan#define	    DataDynamic	    0	/* Data register reloaded by direct access */
1541.2Smacallan#define	    MaskDynamic	    1	/* Mask register reloaded by direct access */
1551.2Smacallan/* L */
1561.2SmacallanI suspect this selects how many mask bits to use in Otc* less than 32.
1571.2Smacallan#define	    MaskOtc	    0	/* Mask contains Object Count valid bits */
1581.2Smacallan/* B = 1 -> background transparency for masked fills */
1591.2Smacallan/* F probably the same for foreground */
1601.2Smacallan
1611.2SmacallanThese bit definitions are from xf86, the S bit seems to control masking off
1621.2Smacallanextra bits when the number of pixels written Otc* exceeds the right border.
1631.2SmacallanNot sure what exactly the *Dynamic and MaskOtc bits do.
1641.2Smacallan
1651.2SmacallanFor plain framebuffer memory access just use RopSrc, BitmapExtent* matching your
1661.2Smacallantarget buffer, and everything else zero.
1671.2Smacallan
1681.1SmacallanFramebuffer geometry is always 2048 pixels ( with pixel size determined by
1691.2SmacallanAddr* ) by whatever your hardware allows, areas outside the visible screen may
1701.2Smacallanor may not be accessible, or backed by memory.
1711.1SmacallanHCRX always runs in 1280x1024, there is always an overlay and at least one 8bit
1721.1Smacallanimage buffer, HCRX24 has a 24bit buffer that can be used as two 8bit buffers.
1731.1SmacallanThere is no usable off-screen memory, in fact there seem to be registers to the
1741.1Smacallanright of the visible area.
1751.2SmacallanOn a PCI Visualize EG with 4MB we get an actual 2048x2048 buffer which we can
1761.2Smacallanuse any way we want.
1771.2SmacallanFinally, the xf86 code writes an 8bit one into
1781.1Smacallan#define	NGLE_CONTROL_FB		0x200005
1791.1Smacallanbefore framebuffer access, function is unknown but I suspect it turns off
1801.1Smacallanpipeline pacing, which is then re-enabled whenever we touch the blitter.
1811.1Smacallan
1821.1Smacallan3. Drawing engine
1831.1SmacallanBasically, you poke coordinates into registers and apply an opcode to the last
1841.1Smacallanwrite's address to start an operation ( and specify which ), and there are
1851.1Smacallanregisters to control drawing mode, ROPs etc.
1861.1SmacallanAll register writes go through a pipeline which has 32 entries on HCRX.
1871.1Smacallan
1881.1Smacallan#define	NGLE_BUSY		0x200000	/* busy register */
1891.3Smacallanthe first byte will be non-zero if the drawing engine is busy, xf86 uses 8bit
1901.3Smacallanreads here.
1911.1Smacallan
1921.1Smacallan#define	NGLE_FIFO		0x200008	/* # of fifo slots */
1931.1Smacallan
1941.1SmacallanX and width in the upper 16bit, Y / height in the lower.
1951.1Smacallan#define	NGLE_DST_XY		0x000800	/* destination XY */
1961.1Smacallan#define	NGLE_SIZE		0x000804	/* size WH */
1971.1Smacallan#define	NGLE_SRC_XY		0x000808	/* source XY */
1981.1Smacallan#define	NGLE_TRANSFER_DATA	0x000820	/* 'transfer data' - this is */
1991.1Smacallan						/* a pixel mask on fills */
2001.1Smacallan#define NGLE_RECT		0x000200	/* opcode to start a fill */
2011.1Smacallan#define NGLE_BLIT		0x000300	/* opcode to start a blit */
2021.1Smacallan#define NGLE_HCRX_FASTFILL	0x000140	/* opcode for HCRX fast rect */
2031.1Smacallan#define	NGLE_RECT_SIZE_START	(NGLE_SIZE | NGLE_RECT)
2041.1Smacallan#define	NGLE_BLT_DST_START	(NGLE_DST_XY | NGLE_BLIT)
2051.1Smacallan
2061.1SmacallanSo, in order to draw a rectangle you write coordinates into NGLE_DST_XY, set
2071.1SmacallanNGLE_TRANSFER_DATA to all ones unless you want it stippled, then write the
2081.1Smacallanwidth/height into NGLE_SIZE|NGLE_RECT. Rectangle fills move the destination
2091.1Smacallancoordinates down by the rectangle's height.
2101.1SmacallanNGLE_BLIT copies a retangle from SRC_XY to DST_XY with ROP etc. applied. It is
2111.1Smacallanpossible to copy data between buffers, supported combinations of source and
2121.1Smacallandestination access modes need to be investigated.
2131.1SmacallanThere are likely other opcodes for things like vectors, triangles and so on.
2141.1SmacallanHCRX_FASTFILL is implied by the xf86 code, but not actually used. It seems to
2151.1Smacallanwork, more or less, but with strange side effects. More invastigation is needed.
2161.1Smacallan
2171.1Smacallan#define	NGLE_CPR		0x01800c	/* control plane register */
2181.1SmacallanThis is used when drawing into BINattr, on EG we use 0x00000102, on HCRX 
2191.1Smacallan0x04000F00 for 24bit. There has to be some conversion, there is no way the
2201.1Smacallanattribute plane is actually 32bit. No idea what the individual bits do, has to
2211.1Smacallanbe a combination of buffer selection ( front or back), colour mode / LUT
2221.1Smacallanselection, likely chip specific. Known values are from xf86.
2231.1Smacallan
2241.3Smacallan#define	NGLE_FG			0x018010	/* foreground colour */
2251.3Smacallan#define	NGLE_BG			0x018014	/* background colour */
2261.1Smacallan
2271.1SmacallanFor a plain rectangle fill into the overlay we would use 
2281.1SmacallanIBOvals(RopSrc, 0, BitmapExtent08, 1, DataDynamic, 0, 0, 0)
2291.1Smacallanand
2301.1SmacallanBA(IndexedDcd, Otc32, OtsIndirect, AddrLong, 0, BINovly, 0)
2311.2Smacallan... which draws 32 pixels at a time, apparently rectangle fills are internally
2321.2Smacallanimplemented as 32-at-a-time colour expansion, and the S bit makes sure overflow
2331.2Smacallanpixels on the right border are masked off automatically. Set FG for plain fills,
2341.2SmacallanBG if using a mask ( in TRANSFER_DATA ), set the B bit to make the background
2351.2Smacallantransparent. For writes into BINattr use the CPR register instead of FG.
2361.1Smacallan
2371.1SmacallanFor a simple copy we would use
2381.1SmacallanBA(IndexedDcd, Otc04, Ots08, AddrLong, 0, BINovly, 0))
2391.2Smacallan... to copy four pixels at a time, Addr* doesn't seem to matter, disable colour
2401.1Smacallanexpansion.
2411.1SmacallanIBOvals(RopSrc, 0, BitmapExtent08, 1, DataDynamic, MaskOtc, 0, 0)
2421.1Smacallan... to write 8bit deep, plain copy, mask off extra pixels if our width isn't a
2431.1Smacallanmultiple of 4.
2441.1Smacallan
2451.1SmacallanTo do the same operations on a 24bit buffer just use Otc01, FractionalDcd and
2461.1SmacallanBitmapExtent32. No need to set the S bit on copies since all pixels are 32bit
2471.2Smacallananyway, and in order to copy between different buffers just set DBA and SBA
2481.2Smacallanseparately. Make sure they use the same depth or results may get weird.
2491.1Smacallan
2501.1Smacallan4. Indirect framebuffer writes
2511.1SmacallanHP calls the mechanism 'BINC', no idea what it stands for. Basically, you set a
2521.1Smacallantarget address and then write data into registers which trigger operations
2531.2Smacallanprogrammed in DBA and IBO, with the target address being updated according to
2541.1Smacallanwhich data register we write to. There is also a mechanism to copy blocks, used
2551.2Smacallanfor colour maps.
2561.1Smacallan
2571.1Smacallan#define	NGLE_BINC_SRC		0x000480	/* BINC src */
2581.1Smacallan#define	NGLE_BINC_DST		0x0004a0	/* BINC dst */
2591.1Smacallan#define	NGLE_BINC_MASK		0x0005a0	/* BINC pixel mask */
2601.1Smacallan#define	NGLE_BINC_DATA		0x0005c0	/* BINC data, inc X, some sort of blending */
2611.1Smacallan#define	NGLE_BINC_DATA_R	0x000600	/* BINC data, inc X */
2621.1Smacallan#define	NGLE_BINC_DATA_D	0x000620	/* BINC data, inc Y */
2631.1Smacallan#define	NGLE_BINC_DATA_U	0x000640	/* BINC data, dec Y */
2641.1Smacallan#define	NGLE_BINC_DATA_L	0x000660	/* BINC data, dec X */
2651.1Smacallan#define	NGLE_BINC_DATA_DR	0x000680	/* BINC data, inc X, inc Y */
2661.1Smacallan#define	NGLE_BINC_DATA_DL	0x0006a0	/* BINC data, dec X, inc Y */
2671.1Smacallan#define	NGLE_BINC_DATA_UR	0x0006c0	/* BINC data, inc X, dec Y */
2681.1Smacallan#define	NGLE_BINC_DATA_UL	0x0006e0	/* BINC data, dec X, dec Y */
2691.1Smacallan
2701.1SmacallanSRC and DST are 'linear' addresses, depending on Addr* in DBA, pitch is Addr*
2711.1Smacallantimes 2048.
2721.1SmacallanThe BINC_DATA registers differ only in the way the destination address is
2731.1Smacallanupdated, up or down a line, left or right by Otc* pixels.
2741.1SmacallanSo, in order to draw a 12x20 pixel character to (100,150) we would use the same
2751.1SmacallanDBA and IBO values we used for rectangles, write 0xfff00000 into NGLE_BINC_MASK
2761.1Smacallanto make sure we only write 12 pixels per line, set FG and BG as needed, set
2771.1SmacallanBINC_DST to (100 * 4 + 150 * 8192) - we're in AddrLong - then poke our character
2781.1Smacallanbitmap into NGLE_BINC_DATA_D, one left aligned line at a time.
2791.1SmacallanBINC operations by themselves are unlikely to overrun the pipeline but they may
2801.1Smacallanif a lot of them happen while something more time consuming, like a full screen
2811.1Smacallanscroll, is in progress.
2821.1SmacallanNot sure what exactly NGLE_BINC_DATA does, the xf86 code uses it for colour map
2831.1Smacallanupdates.
2841.5SmacallanIndirect framebuffer writes are generally faster than writing into the aperture,
2851.5Smacallanx11perf -copypixwin500 went from 22/s when using memcpy() to 74/s using BINC on
2861.5SmacallanHCRX in 24bit.
2871.1Smacallan
2881.1Smacallan5. Colour maps
2891.1SmacallanLUTs are held in their own buffer ( BINcmap ), size is likely chip-specific.
2901.1SmacallanHCRX has room for at least three 256 entry colour maps, EG probably has two or
2911.1Smacallanthree.
2921.1SmacallanBasically, we BINC-write our colour map into BINcmap, then tell the hardware to
2931.1Smacallanupdate the actual colour map(s) from that buffer.
2941.1SmacallanWe'd use:
2951.1SmacallanBA(FractDcd, Otc01, Ots08, Addr24, 0, BINcmap, 0)
2961.1SmacallanIBOvals(RopSrc, 0, BitmapExtent08, 0, DataDynamic, MaskOtc, 0, 0)
2971.1SmacallanNot sure how 'Addr24' differs from AddrLong, but that's what the xf86 code uses.
2981.1SmacallanThen set BINC_DST to 0 ( or whichever entry we want to update - 4 for the 2nd
2991.1Smacallanentry etc. ) and poke our colour map into BINC_DATA_R, one entry at a time.
3001.1SmacallanSending it to the DAC works like this - set BINC_SRC to 0, then write a command
3011.1Smacallaninto the appropriate LUTBLT register:
3021.1Smacallan#define	NGLE_EG_LUTBLT		0x200118	/* EG LUT blt ctrl */
3031.1Smacallan	/* EWRRRROO OOOOOOOO TTRRRRLL LLLLLLLL */
3041.1Smacallan	#define LBC_ENABLE	0x80000000
3051.1Smacallan	#define LBC_WAIT_BLANK	0x40000000
3061.1Smacallan	#define LBS_OFFSET_SHIFT	16
3071.1Smacallan	#define LBC_TYPE_MASK		0xc000
3081.1Smacallan	#define LBC_TYPE_CMAP		0
3091.1Smacallan	#define LBC_TYPE_CURSOR		0x8000
3101.1Smacallan	#define LBC_TYPE_OVERLAY	0xc000
3111.1Smacallan	#define LBC_LENGTH_SHIFT	0
3121.1SmacallanIn order to update the whole thing we would use 
3131.1SmacallanLBC_ENABLE | LBC_TYPE_CMAP | 0x100
3141.1SmacallanLength and offset are in 32bit words.
3151.1Smacallan
3161.1SmacallanHCRX uses a different register:
3171.1Smacallan#define	NGLE_HCRX_LUTBLT	0x210020	/* HCRX LUT blt ctrl */
3181.1Smacallan... which otherwise works exactly the same way.
3191.1Smacallan
3201.1SmacallanOn HCRX we need:
3211.1Smacallan- a linear ramp in the first 256 entries, 24bit output goes through this.
3221.1Smacallan- the overlay's colour map starts at entry 512
3231.1Smacallan- hardware sprite colours are controlled by two entries using LBC_TYPE_CURSOR
3241.1Smacallan  and offset 0
3251.1Smacallan
3261.1SmacallanOn EG:
3271.1Smacallan- the main colour map lives at offset 0, type LBC_TYPE_CMAP
3281.1Smacallan- four entries at offset 0 with LBC_TYPE_CURSOR, the first two do nothing, the
3291.1Smacallan  other two are cursor sprite colours
3301.1Smacallan
3311.2SmacallanThere seems to be at least 512 entries worth of buffer space on both HCRX and
3321.2SmacallanEG, xf86 keeps the entire palette in there, updates entries as needed and always
3331.2SmacallanLUTBLTs the whole thing.
3341.2Smacallan
3351.1Smacallan6. Hardware cursor
3361.1SmacallanAgain, chip-specific. Cursor position works the same on HCRX and  PCI EG, uses
3371.1Smacallandifferent registers though. Older chips use a different register layout.
3381.1SmacallanBitmap access is different on HCRX, both support a 64x64 sprite.
3391.1Smacallan
3401.1Smacallan#define	NGLE_EG_CURSOR		0x200100	/* cursor coordinates on EG */
3411.1Smacallan	#define EG_ENABLE_CURSOR	0x80000000
3421.1Smacallan#define	NGLE_HCRX_CURSOR	0x210000	/* HCRX cursor coord & enable */
3431.1Smacallan	#define HCRX_ENABLE_CURSOR	0x80000000
3441.1SmacallanCoordinates are signed 12bit quantities, X in the upper halfword, Y in the
3451.1Smacallanlower, enable bit at 0x80000000. There is no hotspot register, negative
3461.1Smacallancoordinates will move the sprite partially off screen as expected.
3471.1SmacallanOn HCRX we need to write zero into
3481.1Smacallan#define	NGLE_HCRX_VBUS		0x000420	/* HCRX video bus access */
3491.1Smacallanbefore writing NGLE_HCRX_CURSOR.
3501.1Smacallan
3511.1SmacallanCursor bitmap access on HCRX is simple:
3521.1Smacallan#define	NGLE_HCRX_CURSOR_ADDR	0x210004	/* HCRX cursor address */
3531.1Smacallan#define	NGLE_HCRX_CURSOR_DATA	0x210008	/* HCRX cursor data */
3541.1SmacallanThe mask is at offset 0, bitmap at 0x80. Subsequent writes to CURSOR_DATA update
3551.1Smacallanthe address as expected.
3561.1Smacallan
3571.1SmacallanOn EG we have to use BINC writes:
3581.1SmacallanBA(IndexedDcd, Otc32, 0, AddrLong, 0, BINcmask, 0)
3591.1SmacallanIBOvals(RopSrc, 0, 0, 0, DataDynamic, MaskOtc, 0, 0)
3601.1Smacallanset BINC_DST to 0, then poke the mask into NGLE_BINC_DATA_R and
3611.1SmacallanNGLE_BINC_DATA_DL - write 32bit, move right, write the rest of the line, move
3621.1Smacallandown/left to the next line etc.
3631.1SmacallanNo LUTBLT analog here, for the the cursor bitmap use BINcursor.
3641.1Smacallan
3651.1Smacallan7. Miscellaneous
3661.4Smacallan#define	NGLE_EG_MISCVID		0x200218	/* Artist misc video */
3671.4Smacallan	#define MISCVID_VIDEO_ON	0x0a000000
3681.4Smacallan#define	NGLE_EG_MISCCTL		0x200308	/* Artist misc ctrl */
3691.4Smacallan	#define MISCCTL_VIDEO_ON	0x00800000
3701.4SmacallanThese control video output on EG - xf86 sets both to enable output, clears both
3711.4Smacallanto turn it off. Need to check which bit does what exactly.
3721.4Smacallan
3731.1Smacallan#define	NGLE_HCRX_PLANE_ENABLE	0x21003c	/* HCRX plane enable */ 
3741.1Smacallan#define	NGLE_HCRX_MISCVID	0x210040	/* HCRX misc video */
3751.1Smacallan	#define HCRX_BOOST_ENABLE	0x80000000 /* extra high signal level */
3761.1Smacallan	#define HCRX_VIDEO_ENABLE	0x0A000000
3771.1Smacallan	#define HCRX_OUTPUT_ENABLE	0x01000000
3781.1Smacallanxf86 uses HCRX_VIDEO_ENABLE, the other bits were found by experiment, functions
3791.1Smacallanare guesswork. There are other bits with unknown function.
3801.1Smacallan
3811.1SmacallanThis is set by xf86, other values unknown.
3821.1Smacallan#define	NGLE_HCRX_HB_MODE2	0x210120	/* HCRX 'hyperbowl' mode 2 */
3831.1Smacallan	#define HYPERBOWL_MODE2_8_24					15
3841.1Smacallan
3851.1SmacallanThis seems to be the HCRX's analogue to FX's force attribute register - we can
3861.1Smacallanswitch between overlay opacity and image plane display mode on the fly
3871.1Smacallan#define	NGLE_HCRX_HB_MODE	0x210130	/* HCRX 'hyperbowl' */
3881.1Smacallan	#define HYPERBOWL_MODE_FOR_8_OVER_88_LUT0_NO_TRANSPARENCIES	4
3891.1Smacallan	#define HYPERBOWL_MODE01_8_24_LUT0_TRANSPARENT_LUT1_OPAQUE	8
3901.1Smacallan	#define HYPERBOWL_MODE01_8_24_LUT0_OPAQUE_LUT1_OPAQUE		10
3911.1Smacallan
3921.1Smacallan8. Visualize EG notes
3931.1SmacallanAll referenves to 'EG' and the like strictly refer to the PCI Visualize EG card
3941.2Smacallanwith 4MB video memory. There is a GSC variant which may have 2MB or 4MB, other
3951.1Smacallandifferences are unknown.
3961.1SmacallanThe xf86 code does not support the PCI EG at all, it seems to be somewhat
3971.1Smacallansimilar to the 'Artist' variant, the cursor register is at the same address but
3981.1Smacallanworks as on HCRX. I suspect the GSC variant to be more like Artist.
3991.1SmacallanIt is possible to put cards with enough memory into double buffer mode using
4001.1Smacallanthe firmware configuration menu - I need to figure out what exactly that does.
4011.4SmacallanSame with grey scale mode, which may just select a different default palette.
4021.3Smacallan
4031.3Smacallan9. HCRX notes
4041.3SmacallanXf86 always writes NGLE_HCRX_HB_MODE twice, apparently working around a hardware
4051.3Smacallanbug. It also initializes a few unexplained registers with magic numbers:
4061.3Smacallan#define	NGLE_REG_42		0x210028	/* these seem to control */
4071.3Smacallan#define	NGLE_REG_43		0x21002c	/* how the 24bit planes */
4081.3Smacallan#define	NGLE_REG_44		0x210030	/* are displayed on HCRX - */
4091.3Smacallan#define	NGLE_REG_45		0x210034	/* no info on bits */
4101.3Smacallan
4111.3SmacallanFor 24bit it writes:
4121.3SmacallanNGLE_REG_42, 0x014c0148
4131.3SmacallanNGLE_REG_43, 0x404c4048
4141.3SmacallanNGLE_REG_44, 0x034c0348
4151.3SmacallanNGLE_REG_45, 0x444c4448
4161.3Smacallan
4171.3Smacallan... and for 8bit:
4181.3SmacallanNGLE_REG_42, 0
4191.3SmacallanNGLE_REG_43, 0
4201.3SmacallanNGLE_REG_44, 0
4211.3SmacallanNGLE_REG_45, 0x444c4048
4221.3Smacallan
4231.5SmacallanThe ROM is in byte mode, as expected of a GSC device, with every 32bit word
4241.3Smacallancontaining one byte of ROM data. The first word also has configuration bits:
4251.3Smacallan#define HCRX_CONFIG_24BIT	0x100
4261.3Smacallan
4271.3SmacallanOn my HCRX24Z this reads 0x700, I assume 0x200 or 0x400 indicates the Z-Buffer
4281.3Smacallanadd-on's presence.
4291.5Smacallan
4301.5SmacallanAlso, xf86 has this comment when setting things up for 24bit display:
4311.5Smacallan    /**********************************************
4321.5Smacallan     * Write overlay transparency mask so only entry 255 is transparent
4331.5Smacallan     **********************************************/
4341.5Smacallan... and then proceeds to BINC write 0 to (1532,0) in the overlay
4351.5Smacallan
436