nglereg.h revision 1.2
1/*	$NetBSD: nglereg.h,v 1.2 2025/12/14 10:19:14 macallan Exp $	*/
2
3/*
4 * Copyright (c) 2025 Michael Lorenz
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26 * THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/*
30 * HP Visualize EG and HCRX
31 * sensible register names instead of random numbers
32 * mostly found by experiment
33 */
34
35#ifndef NGLEREG_H
36#define NGLEREG_H
37
38#define	NGLE_HCRX_VBUS		0x000420	/* HCRX video bus access */
39
40/*
41 * BINC writes work more or less like FX4, except pixel addressing is a linear
42 * address in whatever unit specified in NGLE_DBA ( AddrByte or AddrWord )
43 */
44#define	NGLE_BINC_SRC		0x000480	/* BINC src */
45#define	NGLE_BINC_DST		0x0004a0	/* BINC dst */
46#define	NGLE_BINC_MASK		0x0005a0	/* BINC pixel mask */
47#define	NGLE_BINC_DATA		0x0005c0	/* BINC data, inc X, some sort of blending */
48#define	NGLE_BINC_DATA_R	0x000600	/* BINC data, inc X */
49#define	NGLE_BINC_DATA_D	0x000620	/* BINC data, inc Y */
50#define	NGLE_BINC_DATA_U	0x000640	/* BINC data, dec Y */
51#define	NGLE_BINC_DATA_L	0x000660	/* BINC data, dec X */
52#define	NGLE_BINC_DATA_DR	0x000680	/* BINC data, inc X, inc Y */
53#define	NGLE_BINC_DATA_DL	0x0006a0	/* BINC data, dec X, inc Y */
54#define	NGLE_BINC_DATA_UR	0x0006c0	/* BINC data, inc X, dec Y */
55#define	NGLE_BINC_DATA_UL	0x0006e0	/* BINC data, dec X, dec Y */
56
57/*
58 * coordinate registers
59 * these *do* work like FX4 - you poke coordinates into registers and OR an
60 * opcode on the last register write's address
61 */
62#define	NGLE_DST_XY		0x000800	/* destination XY */
63#define	NGLE_SIZE		0x000804	/* size WH */
64#define	NGLE_SRC_XY		0x000808	/* source XY */
65#define	NGLE_TRANSFER_DATA	0x000820	/* 'transfer data' - this is */
66						/* a pixel mask on fills */
67#define NGLE_RECT		0x000200	/* opcode to start a fill */
68#define NGLE_BLIT		0x000300	/* opcode to start a blit */
69#define NGLE_HCRX_FASTFILL	0x000140	/* opcode for HCRX fast rect */
70#define	NGLE_RECT_SIZE_START	(NGLE_SIZE | NGLE_RECT)
71#define	NGLE_BLT_DST_START	(NGLE_DST_XY | NGLE_BLIT)
72
73/*
74 * bitmap access
75 * works more or less like FX4, with completely different bit assignments
76 */
77#define	NGLE_BAboth		0x018000	/* read and write mode */
78#define	NGLE_DBA		0x018004	/* write mode */
79#define	NGLE_SBA		0x018008	/* read mode */
80
81#define BA(F,C,S,A,J,B,I)						\
82	(((F)<<31)|((C)<<27)|((S)<<24)|((A)<<21)|((J)<<16)|((B)<<12)|(I))
83	/* FCCC CSSS AAAJ JJJJ BBBB IIII IIII IIII */
84
85/* F */
86#define	    IndexedDcd	0	/* Pixel data is indexed (pseudo) color */
87#define	    FractDcd	1	/* Pixel data is Fractional 8-8-8 */
88/* C */
89#define	    Otc04	2	/* Pixels in each longword transfer (4) */
90#define	    Otc32	5	/* Pixels in each longword transfer (32) */
91#define	    Otc24	7	/* NGLE uses this for 24bit blits */
92				/* Should really be... */
93#define	    Otc01	7	/* one pixel per longword */
94/* S */
95#define	    Ots08	3	/* Each pixel is size (8)d transfer (1) */
96#define	    OtsIndirect	6	/* Each bit goes through FG/BG color(8) */
97/* A */
98#define	    AddrByte	3	/* byte access? Used by NGLE for direct fb */
99#define	    AddrLong	5	/* FB address is Long aligned (pixel) */
100#define     Addr24	7	/* used for colour map access */
101/* B */
102#define	    BINapp0I	0x0	/* Application Buffer 0, Indexed */
103#define	    BINapp1I	0x1	/* Application Buffer 1, Indexed */
104#define	    BINovly	0x2	/* 8 bit overlay */
105#define	    BINcursor	0x6	/* cursor bitmap on EG */
106#define	    BINcmask	0x7	/* cursor mask on EG */
107#define	    BINapp0F8	0xa	/* Application Buffer 0, Fractional 8-8-8 */
108/* next one is a guess, my HCRX24 doesn't seem to have it */
109#define	    BINapp1F8	0xb	/* Application Buffer 1, Fractional 8-8-8 */
110#define	    BINattr	0xd	/* Attribute Bitmap */
111#define	    BINcmap	0xf	/* colour map(s) */
112/* I assume one of the undefined BIN* accesses the HCRX Z-buffer add-on. No clue
113 * about bit depth or if any bits are used for stencil */
114
115/* other buffers are unknown */
116/* J - 'BA just point' - function unknown */
117/* I - 'BA index base' - function unknown */
118
119#define	NGLE_CPR		0x01800c	/* control plane register */
120#define	NGLE_FG			0x018010	/* fg colour */
121#define	NGLE_BG			0x018014	/* bg colour */
122#define	NGLE_PLANEMASK		0x018018	/* image planemask */
123#define	NGLE_IBO		0x01801c	/* image binary op */
124
125#define IBOvals(R,M,X,S,D,L,B,F)					\
126	(((R)<<8)|((M)<<16)|((X)<<24)|((S)<<29)|((D)<<28)|((L)<<31)|((B)<<1)|(F))
127	/* LSSD XXXX MMMM MMMM RRRR RRRR ???? ??BF */
128
129/* R is a standard X11 ROP, no idea if the other bits are used for anything  */
130#define	    RopClr 	0x0
131#define	    RopSrc 	0x3
132#define	    RopInv 	0xc
133#define	    RopSet 	0xf
134/* M: 'mask addr offset' - function unknown */
135/* X */
136#define	    BitmapExtent08  3	/* Each write hits ( 8) bits in depth */
137#define	    BitmapExtent32  5	/* Each write hits (32) bits in depth */
138/* S: 'static reg' flag, NGLE sets it for blits, function is unknown but
139      we get occasional garbage in 8bit blits without it  */
140/* D */
141#define	    DataDynamic	    0	/* Data register reloaded by direct access */
142#define	    MaskDynamic	    1	/* Mask register reloaded by direct access */
143/* L */
144#define	    MaskOtc	    0	/* Mask contains Object Count valid bits */
145/* B = 1 -> background transparency for masked fills */
146/* F probably the same for foreground */
147
148#define	NGLE_DODGER		0x200000	/* 'busy dodger' idle */
149	#define DODGER_IDLE	0x1000	/* or 0x10000, likely tpyo */
150#define	NGLE_BUSY		0x200000	/* busy register */
151#define	NGLE_CONTROL		0x200004	/* a guess */
152/*
153 * byte access, need to write 1 here for fb access to work properly
154 */
155#define	NGLE_CONTROL_FB		0x200005
156#define	NGLE_FIFO		0x200008	/* # of fifo slots */
157#define	NGLE_EG_CURSOR		0x200100	/* cursor coordinates on EG */
158	#define EG_ENABLE_CURSOR	0x80000000
159//#define	NGLE_REG_18		0x200104	/* cursor enable */
160#define	NGLE_EG_LUTBLT		0x200118	/* EG LUT blt ctrl */
161	/* EWRRRROO OOOOOOOO TTRRRRLL LLLLLLLL */
162	#define LBC_ENABLE	0x80000000
163	#define LBC_WAIT_BLANK	0x40000000
164	#define LBS_OFFSET_SHIFT	16
165	#define LBC_TYPE_MASK		0xc000
166	#define LBC_TYPE_CMAP		0
167	#define LBC_TYPE_CURSOR		0x8000
168	#define LBC_TYPE_OVERLAY	0xc000
169	#define LBC_LENGTH_SHIFT	0
170//#define	NGLE_REG_19		0x200200	/* artist sprite size */
171//#define	NGLE_REG_20		0x200208	/* cursor geometry */
172#define	NGLE_EG_MISCVID		0x200218	/* Artist misc video */
173#define	NGLE_EG_MISCCTL		0x200308	/* Artist misc ctrl */
174#define	NGLE_HCRX_CURSOR	0x210000	/* HCRX cursor coord & enable */
175	#define HCRX_ENABLE_CURSOR	0x80000000
176/* HCRX uses those to access the cursor image instead of BINcursor/BINcmask */
177#define	NGLE_HCRC_CURSOR_ADDR	0x210004	/* HCRX cursor address */
178#define	NGLE_HCRX_CURSOR_DATA	0x210008	/* HCRX cursor data */
179
180#define	NGLE_HCRX_LUTBLT	0x210020	/* HCRX LUT blt ctrl */
181#define	NGLE_HCRX_PLANE_ENABLE	0x21003c	/* HCRX plane enable */
182#define	NGLE_HCRX_MISCVID	0x210040	/* HCRX misc video */
183	#define HCRX_BOOST_ENABLE	0x80000000 /* extra high signal level */
184	#define HCRX_VIDEO_ENABLE	0x0A000000
185	#define HCRX_OUTPUT_ENABLE	0x01000000
186#define	NGLE_HCRX_HB_MODE2	0x210120	/* HCRX 'hyperbowl' mode 2 */
187	#define HYPERBOWL_MODE2_8_24					15
188/*
189 * this seems to be the HCRX's analogue to FX's force attribute register - we
190 * can switch between overlay opacity and image plane display mode on the fly
191 */
192#define	NGLE_HCRX_HB_MODE	0x210130	/* HCRX 'hyperbowl' */
193	#define HYPERBOWL_MODE_FOR_8_OVER_88_LUT0_NO_TRANSPARENCIES	4
194	#define HYPERBOWL_MODE01_8_24_LUT0_TRANSPARENT_LUT1_OPAQUE	8
195	#define HYPERBOWL_MODE01_8_24_LUT0_OPAQUE_LUT1_OPAQUE		10
196
197#endif /* NGLEREG_H */