1*a0d99befSphx /* $NetBSD: grf_cv3dreg.h,v 1.13 2016/06/17 07:41:56 phx Exp $ */
2c9252fa8Sveego
3c9252fa8Sveego /*
4c9252fa8Sveego * Copyright (c) 1995 Michael Teske
5c9252fa8Sveego * All rights reserved.
6c9252fa8Sveego *
7c9252fa8Sveego * Redistribution and use in source and binary forms, with or without
8c9252fa8Sveego * modification, are permitted provided that the following conditions
9c9252fa8Sveego * are met:
10c9252fa8Sveego * 1. Redistributions of source code must retain the above copyright
11c9252fa8Sveego * notice, this list of conditions and the following disclaimer.
12c9252fa8Sveego * 2. Redistributions in binary form must reproduce the above copyright
13c9252fa8Sveego * notice, this list of conditions and the following disclaimer in the
14c9252fa8Sveego * documentation and/or other materials provided with the distribution.
15c9252fa8Sveego * 3. All advertising materials mentioning features or use of this software
16c9252fa8Sveego * must display the following acknowledgement:
17c9252fa8Sveego * This product includes software developed by Ezra Story and by Kari
18c9252fa8Sveego * Mettinen.
19c9252fa8Sveego * 4. The name of the author may not be used to endorse or promote products
20c9252fa8Sveego * derived from this software without specific prior written permission
21c9252fa8Sveego *
22c9252fa8Sveego * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23c9252fa8Sveego * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24c9252fa8Sveego * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25c9252fa8Sveego * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26c9252fa8Sveego * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27c9252fa8Sveego * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28c9252fa8Sveego * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29c9252fa8Sveego * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30c9252fa8Sveego * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31c9252fa8Sveego * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32c9252fa8Sveego */
33c9252fa8Sveego
34c9252fa8Sveego #ifndef _GRF_CV3DREG_H
35c9252fa8Sveego #define _GRF_CV3DREG_H
36c9252fa8Sveego
37c9252fa8Sveego /*
3801173747Sphx * This is derived from Cirrus driver source.
39c9252fa8Sveego */
40c9252fa8Sveego
41c9252fa8Sveego /* Extension to grfvideo_mode to support text modes.
42c9252fa8Sveego * This can be passed to both text & gfx functions
43c9252fa8Sveego * without worry. If gv.depth == 4, then the extended
44c9252fa8Sveego * fields for a text mode are present.
45c9252fa8Sveego */
46c9252fa8Sveego
47c9252fa8Sveego struct grfcv3dtext_mode {
48c9252fa8Sveego struct grfvideo_mode gv;
49c9252fa8Sveego unsigned short fx; /* font x dimension */
50c9252fa8Sveego unsigned short fy; /* font y dimension */
51c9252fa8Sveego unsigned short cols; /* screen dimensions */
52c9252fa8Sveego unsigned short rows;
53c9252fa8Sveego void *fdata; /* font data */
54c9252fa8Sveego unsigned short fdstart;
55c9252fa8Sveego unsigned short fdend;
56c9252fa8Sveego };
57c9252fa8Sveego
58c9252fa8Sveego /* read VGA register */
598247f5f1She #define vgar(ba, reg) \
608247f5f1She *(((volatile char *)ba)+(reg ^ 3))
61c9252fa8Sveego
62c9252fa8Sveego /* write VGA register */
63c9252fa8Sveego #define vgaw(ba, reg, val) \
648247f5f1She *(((volatile char *)ba)+(reg ^ 3)) = ((val) & 0xff)
65c9252fa8Sveego
66c9252fa8Sveego /* MMIO access */
676352bbdbSveego #define ByteAccessIO(x) ( ((x) & 0x3ffc) | (((x) & 3)^3) | (((x) & 3) <<14) )
68c9252fa8Sveego
69c9252fa8Sveego #define vgario(ba, reg) \
708247f5f1She *(((volatile char *)ba) + ( ByteAccessIO(reg) ))
71c9252fa8Sveego
72c9252fa8Sveego #define vgawio(ba, reg, val) \
73c9252fa8Sveego do { \
74f31e12d6Sis if (!cv3d_zorroIII) { \
758247f5f1She *(((volatile char *)cv3d_vcode_switch_base) + \
768247f5f1She 0x04) = (0x01 & 0xffff); \
775f1c88d7Sperry __asm volatile ("nop"); \
78c9252fa8Sveego } \
798247f5f1She *(((volatile char *)cv3d_special_register_base) + \
808247f5f1She ( ByteAccessIO(reg) & 0xffff )) = ((val) & 0xff); \
81f31e12d6Sis if (!cv3d_zorroIII) { \
828247f5f1She *(((volatile char *)cv3d_vcode_switch_base) + \
838247f5f1She 0x04) = (0x02 & 0xffff); \
845f1c88d7Sperry __asm volatile ("nop"); \
85c9252fa8Sveego } \
86c9252fa8Sveego } while (0)
87c9252fa8Sveego
88c9252fa8Sveego /* read 32 Bit VGA register */
898247f5f1She #define vgar32(ba, reg) \
908247f5f1She *((volatile unsigned long *) (((volatile char *)ba)+reg))
91c9252fa8Sveego
92c9252fa8Sveego /* write 32 Bit VGA register */
93c9252fa8Sveego #define vgaw32(ba, reg, val) \
948247f5f1She *((volatile unsigned long *) (((volatile char *)ba)+reg)) = val
95c9252fa8Sveego
96c9252fa8Sveego /* read 16 Bit VGA register */
978247f5f1She #define vgar16(ba, reg) \
988247f5f1She *((volatile unsigned short *) (((volatile char *)ba)+reg))
99c9252fa8Sveego
100c9252fa8Sveego /* write 16 Bit VGA register */
101c9252fa8Sveego #define vgaw16(ba, reg, val) \
1028247f5f1She *((volatile unsigned short *) (((volatile char *)ba)+reg)) = val
103c9252fa8Sveego
1046352bbdbSveego #define Select_Zorro2_FrameBuffer(flag) \
1056352bbdbSveego do { \
1068247f5f1She *(((volatile char *)cv3d_vcode_switch_base) + \
1078247f5f1She 0x08) = ((flag * 0x40) & 0xffff); \
1085f1c88d7Sperry __asm volatile ("nop"); \
1096352bbdbSveego } while (0)
1106352bbdbSveego
1119382c873Saymeric int grfcv3d_cnprobe(void);
1129382c873Saymeric void grfcv3d_iteinit(struct grf_softc *);
11353524e44Schristos static inline void GfxBusyWait(volatile void *);
11453524e44Schristos static inline void GfxFifoWait(volatile void *);
11553524e44Schristos static inline unsigned char RAttr(volatile void *, short);
11653524e44Schristos static inline unsigned char RSeq(volatile void *, short);
11753524e44Schristos static inline unsigned char RCrt(volatile void *, short);
11853524e44Schristos static inline unsigned char RGfx(volatile void *, short);
119c9252fa8Sveego
120c9252fa8Sveego
121c9252fa8Sveego /*
122c9252fa8Sveego * defines for the used register addresses (mw)
123c9252fa8Sveego *
124c9252fa8Sveego * NOTE: there are some registers that have different addresses when
125c9252fa8Sveego * in mono or color mode. We only support color mode, and thus
126c9252fa8Sveego * some addresses won't work in mono-mode!
127c9252fa8Sveego *
128c9252fa8Sveego * General and VGA-registers taken from retina driver. Fixed a few
129c9252fa8Sveego * bugs in it. (SR and GR read address is Port + 1, NOT Port)
130c9252fa8Sveego *
131c9252fa8Sveego */
132c9252fa8Sveego
133c9252fa8Sveego /* General Registers: */
134c9252fa8Sveego #define GREG_MISC_OUTPUT_R 0x03CC
135c9252fa8Sveego #define GREG_MISC_OUTPUT_W 0x03C2
136c9252fa8Sveego #define GREG_FEATURE_CONTROL_R 0x03CA
137c9252fa8Sveego #define GREG_FEATURE_CONTROL_W 0x03DA
138c9252fa8Sveego #define GREG_INPUT_STATUS0_R 0x03C2
139c9252fa8Sveego #define GREG_INPUT_STATUS1_R 0x03DA
140c9252fa8Sveego
141c9252fa8Sveego /* Setup Registers: */
142c9252fa8Sveego #define SREG_OPTION_SELECT 0x0102
143c9252fa8Sveego #define SREG_VIDEO_SUBS_ENABLE 0x03C3 /* Trio64: 0x46E8 */
144c9252fa8Sveego
145c9252fa8Sveego /* Attribute Controller: */
146c9252fa8Sveego #define ACT_ADDRESS 0x03C0
147c9252fa8Sveego #define ACT_ADDRESS_R 0x03C1
148c9252fa8Sveego #define ACT_ADDRESS_W 0x03C0
149c9252fa8Sveego #define ACT_ADDRESS_RESET 0x03DA
150c9252fa8Sveego #define ACT_ID_PALETTE0 0x00
151c9252fa8Sveego #define ACT_ID_PALETTE1 0x01
152c9252fa8Sveego #define ACT_ID_PALETTE2 0x02
153c9252fa8Sveego #define ACT_ID_PALETTE3 0x03
154c9252fa8Sveego #define ACT_ID_PALETTE4 0x04
155c9252fa8Sveego #define ACT_ID_PALETTE5 0x05
156c9252fa8Sveego #define ACT_ID_PALETTE6 0x06
157c9252fa8Sveego #define ACT_ID_PALETTE7 0x07
158c9252fa8Sveego #define ACT_ID_PALETTE8 0x08
159c9252fa8Sveego #define ACT_ID_PALETTE9 0x09
160c9252fa8Sveego #define ACT_ID_PALETTE10 0x0A
161c9252fa8Sveego #define ACT_ID_PALETTE11 0x0B
162c9252fa8Sveego #define ACT_ID_PALETTE12 0x0C
163c9252fa8Sveego #define ACT_ID_PALETTE13 0x0D
164c9252fa8Sveego #define ACT_ID_PALETTE14 0x0E
165c9252fa8Sveego #define ACT_ID_PALETTE15 0x0F
166c9252fa8Sveego #define ACT_ID_ATTR_MODE_CNTL 0x10
167c9252fa8Sveego #define ACT_ID_OVERSCAN_COLOR 0x11
168c9252fa8Sveego #define ACT_ID_COLOR_PLANE_ENA 0x12
169c9252fa8Sveego #define ACT_ID_HOR_PEL_PANNING 0x13
1706352bbdbSveego #define ACT_ID_COLOR_SELECT 0x14 /* ACT_ID_PIXEL_PADDING */
171c9252fa8Sveego
172c9252fa8Sveego /* Graphics Controller: */
173c9252fa8Sveego #define GCT_ADDRESS 0x03CE
174c9252fa8Sveego #define GCT_ADDRESS_R 0x03CF
175c9252fa8Sveego #define GCT_ADDRESS_W 0x03CF
176c9252fa8Sveego #define GCT_ID_SET_RESET 0x00
177c9252fa8Sveego #define GCT_ID_ENABLE_SET_RESET 0x01
178c9252fa8Sveego #define GCT_ID_COLOR_COMPARE 0x02
179c9252fa8Sveego #define GCT_ID_DATA_ROTATE 0x03
180c9252fa8Sveego #define GCT_ID_READ_MAP_SELECT 0x04
181c9252fa8Sveego #define GCT_ID_GRAPHICS_MODE 0x05
182c9252fa8Sveego #define GCT_ID_MISC 0x06
183c9252fa8Sveego #define GCT_ID_COLOR_XCARE 0x07
184c9252fa8Sveego #define GCT_ID_BITMASK 0x08
185c9252fa8Sveego
186c9252fa8Sveego /* Sequencer: */
187c9252fa8Sveego #define SEQ_ADDRESS 0x03C4
188c9252fa8Sveego #define SEQ_ADDRESS_R 0x03C5
189c9252fa8Sveego #define SEQ_ADDRESS_W 0x03C5
190c9252fa8Sveego #define SEQ_ID_RESET 0x00
191c9252fa8Sveego #define SEQ_ID_CLOCKING_MODE 0x01
192c9252fa8Sveego #define SEQ_ID_MAP_MASK 0x02
193c9252fa8Sveego #define SEQ_ID_CHAR_MAP_SELECT 0x03
194c9252fa8Sveego #define SEQ_ID_MEMORY_MODE 0x04
195c9252fa8Sveego #define SEQ_ID_UNKNOWN1 0x05
196c9252fa8Sveego #define SEQ_ID_UNKNOWN2 0x06
197c9252fa8Sveego #define SEQ_ID_UNKNOWN3 0x07
198c9252fa8Sveego /* S3 extensions */
199c9252fa8Sveego #define SEQ_ID_UNLOCK_EXT 0x08
200c9252fa8Sveego #define SEQ_ID_MMIO_SELECT 0x09 /* Trio64: SEQ_ID_EXT_SEQ_REG9 */
201c9252fa8Sveego #define SEQ_ID_BUS_REQ_CNTL 0x0A
202c9252fa8Sveego #define SEQ_ID_EXT_MISC_SEQ 0x0B
203c9252fa8Sveego #define SEQ_ID_UNKNOWN4 0x0C
204c9252fa8Sveego #define SEQ_ID_EXT_SEQ 0x0D
205c9252fa8Sveego #define SEQ_ID_UNKNOWN5 0x0E
206c9252fa8Sveego #define SEQ_ID_UNKNOWN6 0x0F
207c9252fa8Sveego #define SEQ_ID_MCLK_LO 0x10
208c9252fa8Sveego #define SEQ_ID_MCLK_HI 0x11
209c9252fa8Sveego #define SEQ_ID_DCLK_LO 0x12
210c9252fa8Sveego #define SEQ_ID_DCLK_HI 0x13
211c9252fa8Sveego #define SEQ_ID_CLKSYN_CNTL_1 0x14
212c9252fa8Sveego #define SEQ_ID_CLKSYN_CNTL_2 0x15
213c9252fa8Sveego #define SEQ_ID_CLKSYN_TEST_HI 0x16 /* reserved for S3 testing of the */
214c9252fa8Sveego #define SEQ_ID_CLKSYN_TEST_LO 0x17 /* internal clock synthesizer */
215c9252fa8Sveego #define SEQ_ID_RAMDAC_CNTL 0x18
216c9252fa8Sveego #define SEQ_ID_MORE_MAGIC 0x1A /* not available on the Virge */
217c9252fa8Sveego #define SEQ_ID_SIGNAL_SELECT 0x1C
218c9252fa8Sveego
219c9252fa8Sveego /* CRT Controller: */
220c9252fa8Sveego #define CRT_ADDRESS 0x03D4
221c9252fa8Sveego #define CRT_ADDRESS_R 0x03D5
222c9252fa8Sveego #define CRT_ADDRESS_W 0x03D5
223c9252fa8Sveego #define CRT_ID_HOR_TOTAL 0x00
224c9252fa8Sveego #define CRT_ID_HOR_DISP_ENA_END 0x01
225c9252fa8Sveego #define CRT_ID_START_HOR_BLANK 0x02
226c9252fa8Sveego #define CRT_ID_END_HOR_BLANK 0x03
227c9252fa8Sveego #define CRT_ID_START_HOR_RETR 0x04
228c9252fa8Sveego #define CRT_ID_END_HOR_RETR 0x05
229c9252fa8Sveego #define CRT_ID_VER_TOTAL 0x06
230c9252fa8Sveego #define CRT_ID_OVERFLOW 0x07
231c9252fa8Sveego #define CRT_ID_PRESET_ROW_SCAN 0x08
232c9252fa8Sveego #define CRT_ID_MAX_SCAN_LINE 0x09
233c9252fa8Sveego #define CRT_ID_CURSOR_START 0x0A
234c9252fa8Sveego #define CRT_ID_CURSOR_END 0x0B
235c9252fa8Sveego #define CRT_ID_START_ADDR_HIGH 0x0C
236c9252fa8Sveego #define CRT_ID_START_ADDR_LOW 0x0D
237c9252fa8Sveego #define CRT_ID_CURSOR_LOC_HIGH 0x0E
238c9252fa8Sveego #define CRT_ID_CURSOR_LOC_LOW 0x0F
239c9252fa8Sveego #define CRT_ID_START_VER_RETR 0x10
240c9252fa8Sveego #define CRT_ID_END_VER_RETR 0x11
241c9252fa8Sveego #define CRT_ID_VER_DISP_ENA_END 0x12
242c9252fa8Sveego #define CRT_ID_SCREEN_OFFSET 0x13
243c9252fa8Sveego #define CRT_ID_UNDERLINE_LOC 0x14
244c9252fa8Sveego #define CRT_ID_START_VER_BLANK 0x15
245c9252fa8Sveego #define CRT_ID_END_VER_BLANK 0x16
246c9252fa8Sveego #define CRT_ID_MODE_CONTROL 0x17
247c9252fa8Sveego #define CRT_ID_LINE_COMPARE 0x18
248c9252fa8Sveego #define CRT_ID_GD_LATCH_RBACK 0x22
249c9252fa8Sveego #define CRT_ID_ACT_TOGGLE_RBACK 0x24
250c9252fa8Sveego #define CRT_ID_ACT_INDEX_RBACK 0x26
251c9252fa8Sveego /* S3 extensions: S3 VGA Registers */
252c9252fa8Sveego #define CRT_ID_DEVICE_HIGH 0x2D
253c9252fa8Sveego #define CRT_ID_DEVICE_LOW 0x2E
254c9252fa8Sveego #define CRT_ID_REVISION 0x2F
255c9252fa8Sveego #define CRT_ID_CHIP_ID_REV 0x30
256c9252fa8Sveego #define CRT_ID_MEMORY_CONF 0x31
257c9252fa8Sveego #define CRT_ID_BACKWAD_COMP_1 0x32
258c9252fa8Sveego #define CRT_ID_BACKWAD_COMP_2 0x33
259c9252fa8Sveego #define CRT_ID_BACKWAD_COMP_3 0x34
260c9252fa8Sveego #define CRT_ID_REGISTER_LOCK 0x35
261c9252fa8Sveego #define CRT_ID_CONFIG_1 0x36
262c9252fa8Sveego #define CRT_ID_CONFIG_2 0x37
263c9252fa8Sveego #define CRT_ID_REGISTER_LOCK_1 0x38
264c9252fa8Sveego #define CRT_ID_REGISTER_LOCK_2 0x39
265c9252fa8Sveego #define CRT_ID_MISC_1 0x3A
266c9252fa8Sveego #define CRT_ID_DISPLAY_FIFO 0x3B
267c9252fa8Sveego #define CRT_ID_LACE_RETR_START 0x3C
268c9252fa8Sveego /* S3 extensions: System Control Registers */
269c9252fa8Sveego #define CRT_ID_SYSTEM_CONFIG 0x40
270c9252fa8Sveego #define CRT_ID_BIOS_FLAG 0x41
271c9252fa8Sveego #define CRT_ID_LACE_CONTROL 0x42
272c9252fa8Sveego #define CRT_ID_EXT_MODE 0x43
273c9252fa8Sveego #define CRT_ID_HWGC_MODE 0x45 /* HWGC = Hardware Graphics Cursor */
274c9252fa8Sveego #define CRT_ID_HWGC_ORIGIN_X_HI 0x46
275c9252fa8Sveego #define CRT_ID_HWGC_ORIGIN_X_LO 0x47
276c9252fa8Sveego #define CRT_ID_HWGC_ORIGIN_Y_HI 0x48
277c9252fa8Sveego #define CRT_ID_HWGC_ORIGIN_Y_LO 0x49
278c9252fa8Sveego #define CRT_ID_HWGC_FG_STACK 0x4A
279c9252fa8Sveego #define CRT_ID_HWGC_BG_STACK 0x4B
280c9252fa8Sveego #define CRT_ID_HWGC_START_AD_HI 0x4C
281c9252fa8Sveego #define CRT_ID_HWGC_START_AD_LO 0x4D
282c9252fa8Sveego #define CRT_ID_HWGC_DSTART_X 0x4E
283c9252fa8Sveego #define CRT_ID_HWGC_DSTART_Y 0x4F
284c9252fa8Sveego /* S3 extensions: System Extension Registers */
285c9252fa8Sveego #define CRT_ID_EXT_SYS_CNTL_1 0x50
286c9252fa8Sveego #define CRT_ID_EXT_SYS_CNTL_2 0x51
287c9252fa8Sveego #define CRT_ID_EXT_BIOS_FLAG_1 0x52
288c9252fa8Sveego #define CRT_ID_EXT_MEM_CNTL_1 0x53
289c9252fa8Sveego #define CRT_ID_EXT_MEM_CNTL_2 0x54
290c9252fa8Sveego #define CRT_ID_EXT_DAC_CNTL 0x55
291c9252fa8Sveego #define CRT_ID_EX_SYNC_1 0x56
292c9252fa8Sveego #define CRT_ID_EX_SYNC_2 0x57
293c9252fa8Sveego #define CRT_ID_LAW_CNTL 0x58 /* LAW = Linear Address Window */
294c9252fa8Sveego #define CRT_ID_LAW_POS_HI 0x59
295c9252fa8Sveego #define CRT_ID_LAW_POS_LO 0x5A
296c9252fa8Sveego #define CRT_ID_GOUT_PORT 0x5C
297c9252fa8Sveego #define CRT_ID_EXT_HOR_OVF 0x5D
298c9252fa8Sveego #define CRT_ID_EXT_VER_OVF 0x5E
299c9252fa8Sveego #define CRT_ID_EXT_MEM_CNTL_3 0x60
300c9252fa8Sveego #define CRT_ID_EXT_MEM_CNTL_4 0x61 /* only available on the Virge */
301c9252fa8Sveego #define CRT_ID_EX_SYNC_3 0x63 /* not available on the Virge */
302c9252fa8Sveego #define CRT_ID_EXT_MISC_CNTL 0x65
303c9252fa8Sveego #define CRT_ID_EXT_MISC_CNTL_1 0x66
304c9252fa8Sveego #define CRT_ID_EXT_MISC_CNTL_2 0x67
305c9252fa8Sveego #define CRT_ID_CONFIG_3 0x68
306c9252fa8Sveego #define CRT_ID_EXT_SYS_CNTL_3 0x69
307c9252fa8Sveego #define CRT_ID_EXT_SYS_CNTL_4 0x6A
308c9252fa8Sveego #define CRT_ID_EXT_BIOS_FLAG_3 0x6B
309c9252fa8Sveego #define CRT_ID_EXT_BIOS_FLAG_4 0x6C
310c9252fa8Sveego #define CRT_ID_EXT_BIOS_FLAG_5 0x6D /* only available on the Virge */
311c9252fa8Sveego #define CRT_ID_RAMDAC_SIG_TEST 0x6E /* only available on the Virge */
312c9252fa8Sveego #define CRT_ID_CONFIG_4 0x6F /* only available on the Virge */
313c9252fa8Sveego
314c9252fa8Sveego /* Streams Processor */
315c9252fa8Sveego #define SP_PRIMARY_CONTROL 0x8180
316c9252fa8Sveego #define SP_COLOR_CHROMA_KEY_CONTROL 0x8184
317c9252fa8Sveego #define SP_SECONDARY_CONTROL 0x8190
318c9252fa8Sveego #define SP_CHROMA_KEY_UPPER_BOUND 0x8194
319c9252fa8Sveego #define SP_SECONDARY_CONSTANTS 0x8198
320c9252fa8Sveego #define SP_BLEND_CONTROL 0x81A0
321c9252fa8Sveego #define SP_PRIMARY_ADDRESS_0 0x81C0
322c9252fa8Sveego #define SP_PRIMARY_ADDRESS_1 0x81C4
323c9252fa8Sveego #define SP_PRIMARY_STRIDE 0x81C8
324c9252fa8Sveego #define SP_DOUBLE_BUFFER_LPB_SUPPORT 0x81CC
325c9252fa8Sveego #define SP_SECONDARY_ADDRESS_0 0x81D0
326c9252fa8Sveego #define SP_SECONDARY_ADDRESS_1 0x81D4
327c9252fa8Sveego #define SP_SECONDARY_STRIDE 0x81D8
328c9252fa8Sveego #define SP_OPAQUE_OVERLAY_CONTROL 0x81DC
329c9252fa8Sveego #define SP_K1_VERTICAL_SCALE_FACTOR 0x81E0
330c9252fa8Sveego #define SP_K2_VERTICAL_SCALE_FACTOR 0x81E4
331c9252fa8Sveego #define SP_DDA_VERTICAL_ACCUMULATOR 0x81E8
332c9252fa8Sveego #define SP_FIFO_CONTROL 0x81EC
333c9252fa8Sveego #define SP_PRIMARY_WINDOW_TOP_LEFT 0x81F0
334c9252fa8Sveego #define SP_PRIMARY_WINDOW_SIZE 0x81F4
335c9252fa8Sveego #define SP_SECONDARY_WINDOW_TOP_LEFT 0x81F8
336c9252fa8Sveego #define SP_SECONDARY_WINDOW_SIZE 0x81FC
337c9252fa8Sveego
338c9252fa8Sveego /* Memory Port Controller */
339c9252fa8Sveego #define MPC_FIFO_CONTROL 0x8200
340c9252fa8Sveego #define MPC_MIU_CONTROL 0x8204
341c9252fa8Sveego #define MPC_STREAMS_TIMEOUT 0x8208
342c9252fa8Sveego #define MPC_MISC_TIMEOUT 0x820C
343c9252fa8Sveego #define MPC_DMA_READ_BASE_ADDRESS 0x8220
344c9252fa8Sveego #define MPC_DMA_READ_STRIDE_WIDTH 0x8224
345c9252fa8Sveego
346c9252fa8Sveego /* Miscellaneous Registers */
347c9252fa8Sveego #define MR_SUBSYSTEM_STATUS_CNTL 0x8504
348c9252fa8Sveego #define MR_ADVANCED_FUNCTION_CONTROL 0x850C
349c9252fa8Sveego
350c9252fa8Sveego /* S3d Engine */
351c9252fa8Sveego #define S3D_BIT_BLT_RECT_FILL 0xA400
352c9252fa8Sveego #define S3D_LINE_2D 0xA800
353c9252fa8Sveego #define S3D_POLYGON_2D 0xAC00
354c9252fa8Sveego #define S3D_LINE_3D 0xB000
355c9252fa8Sveego #define S3D_TRIANGLE_3D 0xB400
356c9252fa8Sveego
357c9252fa8Sveego #define BLT_ADDRESS 0xA4D4
358c9252fa8Sveego #define BLT_SOURCE_ADDRESS 0xA4D4
359c9252fa8Sveego #define BLT_DEST_ADDRESS 0xA4D8
360c9252fa8Sveego #define BLT_CLIP_LEFT_RIGHT 0xA4DC
361c9252fa8Sveego #define BLT_CLIP_LEFT BLT_CLIP_LEFT_RIGHT
362c9252fa8Sveego #define BLT_CLIP_RIGHT 0xA4DE
363c9252fa8Sveego #define BLT_CLIP_TOP_BOTTOM 0xA4E0
364c9252fa8Sveego #define BLT_CLIP_BOTTOM BLT_CLIP_TOP_BOTTOM
365c9252fa8Sveego #define BLT_CLIP_TOP 0xA4E2
366c9252fa8Sveego #define BLT_DEST_SOURCE_PITCH 0xA4E4
367c9252fa8Sveego #define BLT_SOURCE_PITCH BLT_DEST_SOURCE_PITCH
368c9252fa8Sveego #define BLT_DEST_PITCH 0xA4E6
369c9252fa8Sveego #define BLT_MONO_PATTERN 0xA4E8
370c9252fa8Sveego #define BLT_MONO_PATTERN_0 BLT_MONO_PATTERN
371c9252fa8Sveego #define BLT_MONO_PATTERN_1 0xA4EC
372c9252fa8Sveego #define BLT_PATTERN_BG_COLOR 0xA4F0
373c9252fa8Sveego #define BLT_PATTERN_BG_COLOR_TRUE_COLOR BLT_PATTERN_BG_COLOR
374c9252fa8Sveego #define BLT_PATTERN_BG_COLOR_ALPHA BLT_PATTERN_BG_COLOR
375c9252fa8Sveego #define BLT_PATTERN_BG_COLOR_RED 0xA4F1
376c9252fa8Sveego #define BLT_PATTERN_BG_COLOR_HI_COLOR 0xA4F2
377c9252fa8Sveego #define BLT_PATTERN_BG_COLOR_GREEN BLT_PATTERN_BG_COLOR_HI_COLOR
378c9252fa8Sveego #define BLT_PATTERN_BG_COLOR_INDEX 0xA4F3
379c9252fa8Sveego #define BLT_PATTERN_BG_COLOR_BLUE BLT_PATTERN_BG_COLOR_INDEX
380c9252fa8Sveego #define BLT_PATTERN_FG_COLOR 0xA4F4
381c9252fa8Sveego #define BLT_PATTERN_FG_COLOR_TRUE_COLOR BLT_PATTERN_FG_COLOR
382c9252fa8Sveego #define BLT_PATTERN_FG_COLOR_ALPHA BLT_PATTERN_FG_COLOR
383c9252fa8Sveego #define BLT_PATTERN_FG_COLOR_RED 0xA4F5
384c9252fa8Sveego #define BLT_PATTERN_FG_COLOR_HI_COLOR 0xA4F6
385c9252fa8Sveego #define BLT_PATTERN_FG_COLOR_GREEN BLT_PATTERN_FG_COLOR_HI_COLOR
386c9252fa8Sveego #define BLT_PATTERN_FG_COLOR_INDEX 0xA4F7
387c9252fa8Sveego #define BLT_PATTERN_FG_COLOR_BLUE BLT_PATTERN_FG_COLOR_INDEX
388c9252fa8Sveego #define BLT_SOURCE_BG_COLOR 0xA4F8
389c9252fa8Sveego #define BLT_SOURCE_BG_COLOR_TRUE_COLOR BLT_SOURCE_BG_COLOR
390c9252fa8Sveego #define BLT_SOURCE_BG_COLOR_ALPHA BLT_SOURCE_BG_COLOR
391c9252fa8Sveego #define BLT_SOURCE_BG_COLOR_RED 0xA4F9
392c9252fa8Sveego #define BLT_SOURCE_BG_COLOR_HI_COLOR 0xA4FA
393c9252fa8Sveego #define BLT_SOURCE_BG_COLOR_GREEN BLT_SOURCE_BG_COLOR_HI_COLOR
394c9252fa8Sveego #define BLT_SOURCE_BG_COLOR_INDEX 0xA4FB
395c9252fa8Sveego #define BLT_SOURCE_BG_COLOR_BLUE BLT_SOURCE_BG_COLOR_INDEX
396c9252fa8Sveego #define BLT_SOURCE_FG_COLOR 0xA4FC
397c9252fa8Sveego #define BLT_SOURCE_FG_COLOR_TRUE_COLOR BLT_SOURCE_FG_COLOR
398c9252fa8Sveego #define BLT_SOURCE_FG_COLOR_ALPHA BLT_SOURCE_FG_COLOR
399c9252fa8Sveego #define BLT_SOURCE_FG_COLOR_RED 0xA4FD
400c9252fa8Sveego #define BLT_SOURCE_FG_COLOR_HI_COLOR 0xA4FE
401c9252fa8Sveego #define BLT_SOURCE_FG_COLOR_GREEN BLT_SOURCE_FG_COLOR_HI_COLOR
402c9252fa8Sveego #define BLT_SOURCE_FG_COLOR_INDEX 0xA4FF
403c9252fa8Sveego #define BLT_SOURCE_FG_COLOR_BLUE BLT_SOURCE_FG_COLOR_INDEX
404c9252fa8Sveego #define BLT_COMMAND_SET 0xA500
405c9252fa8Sveego #define BLT_WIDTH_HEIGHT 0xA504
406c9252fa8Sveego #define BLT_HEIGHT BLT_WIDTH_HEIGHT
407c9252fa8Sveego #define BLT_WIDTH 0xA506
408c9252fa8Sveego #define BLT_SOURCE_XY 0xA508
409c9252fa8Sveego #define BLT_SOURCE_Y BLT_SOURCE_XY
410c9252fa8Sveego #define BLT_SOURCE_X 0xA50A
411c9252fa8Sveego #define BLT_DESTINATION_XY 0xA50C
412c9252fa8Sveego #define BLT_DESTINATION_Y BLT_DESTINATION_XY
413c9252fa8Sveego #define BLT_DESTINATION_X 0xA50E
414c9252fa8Sveego
415c9252fa8Sveego #define L2D_ADDRESS 0xA8D4
416c9252fa8Sveego #define L2D_SOURCE_ADDRESS 0xA8D4
417c9252fa8Sveego #define L2D_DEST_ADDRESS 0xA8D8
418c9252fa8Sveego #define L2D_CLIP_LEFT_RIGHT 0xA8DC
419c9252fa8Sveego #define L2D_CLIP_LEFT L2D_CLIP_LEFT_RIGHT
420c9252fa8Sveego #define L2D_CLIP_RIGHT 0xA8DE
421c9252fa8Sveego #define L2D_CLIP_TOP_BOTTOM 0xA8E0
422c9252fa8Sveego #define L2D_CLIP_BOTTOM L2D_CLIP_TOP_BOTTOM
423c9252fa8Sveego #define L2D_CLIP_TOP 0xA8E2
424c9252fa8Sveego #define L2D_DEST_SOURCE_PITCH 0xA8E4
425c9252fa8Sveego #define L2D_SOURCE_PITCH L2D_DEST_SOURCE_PITCH
426c9252fa8Sveego #define L2D_DEST_PITCH 0xA8E6
427c9252fa8Sveego #define L2D_PAD_0 0xA8E8
428c9252fa8Sveego #define L2D_PATTERN_FG_COLOR_TRUE_COLOR 0xA8F4
429c9252fa8Sveego #define L2D_PATTERN_FG_COLOR_ALPHA L2D_PATTERN_FG_COLOR_TRUECOLOR
430c9252fa8Sveego #define L2D_PATTERN_FG_COLOR_RED 0xA8F5
431c9252fa8Sveego #define L2D_PATTERN_FG_COLOR_HI_COLOR 0xA8F6
432c9252fa8Sveego #define L2D_PATTERN_FG_COLOR_GREEN L2D_PATTERN_FG_COLOR_HICOLOR
433c9252fa8Sveego #define L2D_PATTERN_FG_COLOR_INDEX 0xA8F7
434c9252fa8Sveego #define L2D_PATTERN_FG_COLOR_BLUE L2D_PATTERN_FG_COLOR_INDEX
435c9252fa8Sveego #define L2D_PAD_1 0xA8F8
436c9252fa8Sveego #define L2D_COMMAND_SET 0xA900
437c9252fa8Sveego #define L2D_PAD_2 0xA904
438c9252fa8Sveego #define L2D_END_0_END_1 0xA96C
439c9252fa8Sveego #define L2D_END_1 L2D_END_0_END_1
440c9252fa8Sveego #define L2D_END_0 0xA96E
441c9252fa8Sveego #define L2D_DX 0xA970
442c9252fa8Sveego #define L2D_X_START 0xA974
443c9252fa8Sveego #define L2D_Y_START 0xA978
444c9252fa8Sveego #define L2D_Y_COUNT 0xA97C
445c9252fa8Sveego
446c9252fa8Sveego #define P2D_ADDRESS 0xACD4
447c9252fa8Sveego #define P2D_SOURCE_ADDRESS 0xACD4
448c9252fa8Sveego #define P2D_DEST_ADDRESS 0xACD8
449c9252fa8Sveego #define P2D_CLIP_LEFT_RIGHT 0xACDC
450c9252fa8Sveego #define P2D_CLIP_LEFT P2D_CLIP_LEFT_RIGHT
451c9252fa8Sveego #define P2D_CLIP_RIGHT 0xACDE
452c9252fa8Sveego #define P2D_CLIP_TOP_BOTTOM 0xACE0
453c9252fa8Sveego #define P2D_CLIP_BOTTOM P2D_CLIP_TOP_BOTTOM
454c9252fa8Sveego #define P2D_CLIP_TOP 0xACE2
455c9252fa8Sveego #define P2D_DEST_SOURCE_PITCH 0xACE4
456c9252fa8Sveego #define P2D_SOURCE_PITCH P2D_DEST_SOURCE_PITCH
457c9252fa8Sveego #define P2D_DEST_PITCH 0xACE6
458c9252fa8Sveego #define P2D_MONO_PATTERN 0xACE8
459c9252fa8Sveego #define P2D_PATTERN_BG_COLOR_TRUE_COLOR 0xACF0
460c9252fa8Sveego #define P2D_PATTERN_BG_COLOR_ALPHA P2D_PATTERN_BG_COLOR_TRUE_COLOR
461c9252fa8Sveego #define P2D_PATTERN_BG_COLOR_RED 0xACF1
462c9252fa8Sveego #define P2D_PATTERN_BG_COLOR_HI_COLOR 0xACF2
463c9252fa8Sveego #define P2D_PATTERN_BG_COLOR_GREEN P2D_PATTERN_BG_COLOR_HI_COLOR
464c9252fa8Sveego #define P2D_PATTERN_BG_COLOR_INDEX 0xACF3
465c9252fa8Sveego #define P2D_PATTERN_BG_COLOR_BLUE P2D_PATTERN_BG_COLOR_INDEX
466c9252fa8Sveego #define P2D_PATTERN_FG_COLOR_TRUE_COLOR 0xACF4
467c9252fa8Sveego #define P2D_PATTERN_FG_COLOR_ALPHA P2D_PATTERN_FG_COLOR_TRUE_COLOR
468c9252fa8Sveego #define P2D_PATTERN_FG_COLOR_RED 0xACF5
469c9252fa8Sveego #define P2D_PATTERN_FG_COLOR_HI_COLOR 0xACF6
470c9252fa8Sveego #define P2D_PATTERN_FG_COLOR_GREEN P2D_PATTERN_FG_COLOR_HI_COLOR
471c9252fa8Sveego #define P2D_PATTERN_FG_COLOR_INDEX 0xACF7
472c9252fa8Sveego #define P2D_PATTERN_FG_COLOR_BLUE P2D_PATTERN_FG_COLOR_INDEX
473c9252fa8Sveego #define P2D_PAD_1 0xACF8
474c9252fa8Sveego #define P2D_COMMAND_SET 0xAD00
475c9252fa8Sveego #define P2D_PAD_2 0xAD04
476c9252fa8Sveego #define P2D_RIGHT_DX 0xAD68
477c9252fa8Sveego #define P2D_RIGHT_X_START 0xAD6C
478c9252fa8Sveego #define P2D_LEFT_DX 0xAD70
479c9252fa8Sveego #define P2D_LEFT_X_START 0xAD74
480c9252fa8Sveego #define P2D_Y_START 0xAD78
481c9252fa8Sveego #define P2D_Y_COUNT 0xAD7C
482c9252fa8Sveego
483c9252fa8Sveego #define CMD_NOP (7 << 27) /* %1111 << 27 */
484c9252fa8Sveego #define CMD_LINE (3 << 27) /* %0011 << 27 */
485c9252fa8Sveego #define CMD_RECT (4 << 27) /* %0010 << 27 */
486c9252fa8Sveego #define CMD_POLYGON (5 << 27) /* %0101 << 27 */
487c9252fa8Sveego #define CMD_BITBLT (0 << 27) /* %0000 << 27 */
488c9252fa8Sveego
489c9252fa8Sveego #define CMD_SKIP_TRANSFER_BYTES_1 (1 << 12) /* %01 << 12 */
490c9252fa8Sveego #define CMD_SKIP_TRANSFER_BYTES_2 (2 << 12) /* %10 << 12 */
491c9252fa8Sveego #define CMD_SKIP_TRANSFER_BYTES_3 (3 << 12) /* %11 << 12 */
492c9252fa8Sveego
493c9252fa8Sveego #define CMD_TRANSFER_ALIGNMENT_BYTE (0 << 10) /* %00 << 10 */
494c9252fa8Sveego #define CMD_TRANSFER_ALIGNMENT_WORD (1 << 10) /* %01 << 10 */
495c9252fa8Sveego #define CMD_TRANSFER_ALIGNMENT_DOUBLEWORD (2 << 10) /* %10 << 10 */
496c9252fa8Sveego
497c9252fa8Sveego #define CMD_CHUNKY (0 << 2) /* %00 << 2 */
498c9252fa8Sveego #define CMD_HI_COLOR (1 << 2) /* %01 << 2 */
499c9252fa8Sveego #define CMD_TRUE_COLOR (2 << 2) /* %10 << 2 */
500c9252fa8Sveego
501c9252fa8Sveego #define ROP_FALSE 0x00
502c9252fa8Sveego #define ROP_NOR 0x10
503c9252fa8Sveego #define ROP_ONLYDST 0x20
504c9252fa8Sveego #define ROP_NOTSRC 0x30
505c9252fa8Sveego #define ROP_ONLYSRC 0x40
506c9252fa8Sveego #define ROP_NOTDST 0x50
507c9252fa8Sveego #define ROP_EOR 0x60
508c9252fa8Sveego #define ROP_NAND 0x70
509c9252fa8Sveego #define ROP_AND 0x80
510c9252fa8Sveego #define ROP_NEOR 0x90
511c9252fa8Sveego #define ROP_DST 0xA0
512c9252fa8Sveego #define ROP_NOTONLYSRC 0xB0
513c9252fa8Sveego #define ROP_SRC 0xC0
514c9252fa8Sveego #define ROP_NOTONLYDST 0xD0
515c9252fa8Sveego #define ROP_OR 0xE0
516c9252fa8Sveego #define ROP_TRUE 0xF0
517c9252fa8Sveego
518c9252fa8Sveego /* Pass-through */
519c9252fa8Sveego #if 0 /* XXX */
520c9252fa8Sveego #define PASS_ADDRESS 0x
521c9252fa8Sveego #define PASS_ADDRESS_W 0x
522c9252fa8Sveego #endif
523c9252fa8Sveego
524c9252fa8Sveego /* Video DAC */
525c9252fa8Sveego #define VDAC_ADDRESS 0x03C8
526c9252fa8Sveego #define VDAC_ADDRESS_W 0x03C8
527c9252fa8Sveego #define VDAC_ADDRESS_R 0x03C7
528c9252fa8Sveego #define VDAC_STATE 0x03C7
529c9252fa8Sveego #define VDAC_DATA 0x03C9
530c9252fa8Sveego #define VDAC_MASK 0x03C6
531c9252fa8Sveego
532c9252fa8Sveego
533c9252fa8Sveego #define WGfx(ba, idx, val) \
534c9252fa8Sveego do { vgaw(ba, GCT_ADDRESS, idx); vgaw(ba, GCT_ADDRESS_W , val); } while (0)
535c9252fa8Sveego
536c9252fa8Sveego #define WSeq(ba, idx, val) \
537c9252fa8Sveego do { vgaw(ba, SEQ_ADDRESS, idx); vgaw(ba, SEQ_ADDRESS_W , val); } while (0)
538c9252fa8Sveego
539c9252fa8Sveego #define WCrt(ba, idx, val) \
540c9252fa8Sveego do { vgaw(ba, CRT_ADDRESS, idx); vgaw(ba, CRT_ADDRESS_W , val); } while (0)
541c9252fa8Sveego
542c9252fa8Sveego #define WAttr(ba, idx, val) \
543c9252fa8Sveego do { \
544c9252fa8Sveego unsigned char tmp;\
545c9252fa8Sveego tmp = vgar(ba, ACT_ADDRESS_RESET);\
54626a64d43Schristos __USE(tmp);\
547c9252fa8Sveego vgaw(ba, ACT_ADDRESS_W, idx);\
548c9252fa8Sveego vgaw(ba, ACT_ADDRESS_W, val);\
549c9252fa8Sveego } while (0)
550c9252fa8Sveego
551c9252fa8Sveego
552c9252fa8Sveego #define SetTextPlane(ba, m) \
553c9252fa8Sveego do { \
554c9252fa8Sveego WGfx(ba, GCT_ID_READ_MAP_SELECT, m & 3 );\
555c9252fa8Sveego WSeq(ba, SEQ_ID_MAP_MASK, (1 << (m & 3)));\
556c9252fa8Sveego } while (0)
557c9252fa8Sveego
558c9252fa8Sveego
559c9252fa8Sveego /* Gfx engine busy wait */
560c9252fa8Sveego
5615f1c88d7Sperry static inline void
GfxBusyWait(volatile void * ba)5621d7f24eaSmatt GfxBusyWait (volatile void *ba)
563c9252fa8Sveego {
564c9252fa8Sveego int test;
565c9252fa8Sveego
566c9252fa8Sveego do {
567c9252fa8Sveego test = vgar32(ba, MR_SUBSYSTEM_STATUS_CNTL);
5685f1c88d7Sperry __asm volatile ("nop");
569c9252fa8Sveego } while (!(test & (1 << 13)));
570c9252fa8Sveego }
571c9252fa8Sveego
572c9252fa8Sveego
5735f1c88d7Sperry static inline void
GfxFifoWait(volatile void * ba)5741d7f24eaSmatt GfxFifoWait(volatile void *ba)
575c9252fa8Sveego {
576c9252fa8Sveego #if 0 /* XXX */
577c9252fa8Sveego int test;
578c9252fa8Sveego
579c9252fa8Sveego do {
580c9252fa8Sveego test = vgar32(ba, MR_SUBSYSTEM_STATUS_CNTL);
581c9252fa8Sveego } while (test & 0x0f);
582c9252fa8Sveego #endif
583c9252fa8Sveego }
584c9252fa8Sveego
585c9252fa8Sveego
586c9252fa8Sveego /* Special wakeup/passthrough registers on graphics boards
587c9252fa8Sveego *
588c9252fa8Sveego * The methods have diverged a bit for each board, so
589c9252fa8Sveego * WPass(P) has been converted into a set of specific
5905f1c88d7Sperry * inline functions.
591c9252fa8Sveego */
592c9252fa8Sveego
5935f1c88d7Sperry static inline unsigned char
RAttr(volatile void * ba,short idx)5941d7f24eaSmatt RAttr(volatile void *ba, short idx)
595c9252fa8Sveego {
596c9252fa8Sveego
597c9252fa8Sveego vgaw(ba, ACT_ADDRESS_W, idx);
598c9252fa8Sveego delay(0);
599c9252fa8Sveego return vgar(ba, ACT_ADDRESS_R);
600c9252fa8Sveego }
601c9252fa8Sveego
6025f1c88d7Sperry static inline unsigned char
RSeq(volatile void * ba,short idx)6031d7f24eaSmatt RSeq(volatile void *ba, short idx)
604c9252fa8Sveego {
605c9252fa8Sveego vgaw(ba, SEQ_ADDRESS, idx);
606c9252fa8Sveego return vgar(ba, SEQ_ADDRESS_R);
607c9252fa8Sveego }
608c9252fa8Sveego
6095f1c88d7Sperry static inline unsigned char
RCrt(volatile void * ba,short idx)6101d7f24eaSmatt RCrt(volatile void *ba, short idx)
611c9252fa8Sveego {
612c9252fa8Sveego vgaw(ba, CRT_ADDRESS, idx);
613c9252fa8Sveego return vgar(ba, CRT_ADDRESS_R);
614c9252fa8Sveego }
615c9252fa8Sveego
6165f1c88d7Sperry static inline unsigned char
RGfx(volatile void * ba,short idx)6171d7f24eaSmatt RGfx(volatile void *ba, short idx)
618c9252fa8Sveego {
619c9252fa8Sveego vgaw(ba, GCT_ADDRESS, idx);
620c9252fa8Sveego return vgar(ba, GCT_ADDRESS_R);
621c9252fa8Sveego }
622c9252fa8Sveego
623c9252fa8Sveego #endif /* _GRF_CV3DREG_H */
624