xref: /netbsd-src/sys/arch/amiga/dev/grf_clreg.h (revision bf3440b26a3298c6f6f0feecd95063b4ce499e6a)
1*bf3440b2Smhitch /*	$NetBSD: grf_clreg.h,v 1.10 2008/12/18 05:04:22 mhitch Exp $	*/
235bb9b1fSchopps 
335bb9b1fSchopps /*
435bb9b1fSchopps  * Copyright (c) 1995 Ezra Story
535bb9b1fSchopps  * Copyright (c) 1995 Kari Mettinen
635bb9b1fSchopps  * Copyright (c) 1994 Markus Wild
735bb9b1fSchopps  * Copyright (c) 1994 Lutz Vieweg
835bb9b1fSchopps  * All rights reserved.
935bb9b1fSchopps  *
1035bb9b1fSchopps  * Redistribution and use in source and binary forms, with or without
1135bb9b1fSchopps  * modification, are permitted provided that the following conditions
1235bb9b1fSchopps  * are met:
1335bb9b1fSchopps  * 1. Redistributions of source code must retain the above copyright
1435bb9b1fSchopps  *    notice, this list of conditions and the following disclaimer.
1535bb9b1fSchopps  * 2. Redistributions in binary form must reproduce the above copyright
1635bb9b1fSchopps  *    notice, this list of conditions and the following disclaimer in the
1735bb9b1fSchopps  *    documentation and/or other materials provided with the distribution.
1835bb9b1fSchopps  * 3. All advertising materials mentioning features or use of this software
1935bb9b1fSchopps  *    must display the following acknowledgement:
2035bb9b1fSchopps  *      This product includes software developed by Lutz Vieweg.
2135bb9b1fSchopps  * 4. The name of the author may not be used to endorse or promote products
2235bb9b1fSchopps  *    derived from this software without specific prior written permission
2335bb9b1fSchopps  *
2435bb9b1fSchopps  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2535bb9b1fSchopps  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2635bb9b1fSchopps  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2735bb9b1fSchopps  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2835bb9b1fSchopps  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2935bb9b1fSchopps  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3035bb9b1fSchopps  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3135bb9b1fSchopps  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3235bb9b1fSchopps  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3335bb9b1fSchopps  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3435bb9b1fSchopps  */
3535bb9b1fSchopps 
3635bb9b1fSchopps #ifndef _GRF_CLREG_H
3735bb9b1fSchopps #define _GRF_CLREG_H
3835bb9b1fSchopps 
3935bb9b1fSchopps /*
4035bb9b1fSchopps  * Written & Copyright by Kari Mettinen, Ezra Story.
4135bb9b1fSchopps  *
4235bb9b1fSchopps  * This is derived from retina driver source
4335bb9b1fSchopps  */
4435bb9b1fSchopps 
4535bb9b1fSchopps /* Extension to grfvideo_mode to support text modes.
4635bb9b1fSchopps  * This can be passed to both text & gfx functions
4735bb9b1fSchopps  * without worry.  If gv.depth == 4, then the extended
4835bb9b1fSchopps  * fields for a text mode are present.
4935bb9b1fSchopps  */
5035bb9b1fSchopps struct grfcltext_mode {
5135bb9b1fSchopps     	struct grfvideo_mode gv;
5235bb9b1fSchopps     	unsigned short	fx; 	    /* font x dimension */
5335bb9b1fSchopps     	unsigned short	fy; 	    /* font y dimension */
5435bb9b1fSchopps     	unsigned short  cols;       /* screen dimensions */
5535bb9b1fSchopps     	unsigned short	rows;
5635bb9b1fSchopps     	void	    	*fdata;     /* font data */
5735bb9b1fSchopps     	unsigned short	fdstart;
5835bb9b1fSchopps     	unsigned short	fdend;
5935bb9b1fSchopps };
6035bb9b1fSchopps 
6135bb9b1fSchopps 
6235bb9b1fSchopps /* 5426 boards types, stored in  cltype in grf_cl.c .
6335bb9b1fSchopps  * used to decide how to handle SR7 and Pass-through
6435bb9b1fSchopps  */
6535bb9b1fSchopps 
6635bb9b1fSchopps #define PICASSO		2167
6735bb9b1fSchopps #define SPECTRUM 	2193
6835bb9b1fSchopps #define PICCOLO		2195
6935bb9b1fSchopps 
7035bb9b1fSchopps /* read VGA register */
7135bb9b1fSchopps #define vgar(ba, reg) (*(((volatile unsigned char *)ba)+reg))
7235bb9b1fSchopps 
7335bb9b1fSchopps /* write VGA register */
7435bb9b1fSchopps #define vgaw(ba, reg, val) \
7535bb9b1fSchopps 	*(((volatile unsigned char *)ba)+reg) = ((val) & 0xff)
7635bb9b1fSchopps 
7735bb9b1fSchopps /*
7835bb9b1fSchopps  * defines for the used register addresses (mw)
7935bb9b1fSchopps  *
8035bb9b1fSchopps  * NOTE: there are some registers that have different addresses when
8135bb9b1fSchopps  *       in mono or color mode. We only support color mode, and thus
8235bb9b1fSchopps  *       some addresses won't work in mono-mode!
8335bb9b1fSchopps  *
8435bb9b1fSchopps  * General and VGA-registers taken from retina driver. Fixed a few
8535bb9b1fSchopps  * bugs in it. (SR and GR read address is Port + 1, NOT Port)
8635bb9b1fSchopps  *
8735bb9b1fSchopps  */
8835bb9b1fSchopps 
8935bb9b1fSchopps 
9035bb9b1fSchopps 
9135bb9b1fSchopps 
9235bb9b1fSchopps /* General Registers: */
9335bb9b1fSchopps #define GREG_STATUS0_R		0x03C2
9435bb9b1fSchopps #define GREG_STATUS1_R		0x03DA
9535bb9b1fSchopps #define GREG_MISC_OUTPUT_R	0x03CC
9635bb9b1fSchopps #define GREG_MISC_OUTPUT_W	0x03C2
9735bb9b1fSchopps #define GREG_FEATURE_CONTROL_R	0x03CA
9835bb9b1fSchopps #define GREG_FEATURE_CONTROL_W	0x03DA
9935bb9b1fSchopps #define GREG_POS		0x0102
10035bb9b1fSchopps 
10135bb9b1fSchopps /* Attribute Controller: */
10235bb9b1fSchopps #define ACT_ADDRESS		0x03C0
10335bb9b1fSchopps #define ACT_ADDRESS_R		0x03C1
10435bb9b1fSchopps #define ACT_ADDRESS_W		0x03C0
10535bb9b1fSchopps #define ACT_ADDRESS_RESET	0x03DA
10635bb9b1fSchopps #define ACT_ID_PALETTE0		0x00
10735bb9b1fSchopps #define ACT_ID_PALETTE1		0x01
10835bb9b1fSchopps #define ACT_ID_PALETTE2		0x02
10935bb9b1fSchopps #define ACT_ID_PALETTE3		0x03
11035bb9b1fSchopps #define ACT_ID_PALETTE4		0x04
11135bb9b1fSchopps #define ACT_ID_PALETTE5		0x05
11235bb9b1fSchopps #define ACT_ID_PALETTE6		0x06
11335bb9b1fSchopps #define ACT_ID_PALETTE7		0x07
11435bb9b1fSchopps #define ACT_ID_PALETTE8		0x08
11535bb9b1fSchopps #define ACT_ID_PALETTE9		0x09
11635bb9b1fSchopps #define ACT_ID_PALETTE10	0x0A
11735bb9b1fSchopps #define ACT_ID_PALETTE11	0x0B
11835bb9b1fSchopps #define ACT_ID_PALETTE12	0x0C
11935bb9b1fSchopps #define ACT_ID_PALETTE13	0x0D
12035bb9b1fSchopps #define ACT_ID_PALETTE14	0x0E
12135bb9b1fSchopps #define ACT_ID_PALETTE15	0x0F
12235bb9b1fSchopps #define ACT_ID_ATTR_MODE_CNTL	0x10
12335bb9b1fSchopps #define ACT_ID_OVERSCAN_COLOR	0x11
12435bb9b1fSchopps #define ACT_ID_COLOR_PLANE_ENA	0x12
12535bb9b1fSchopps #define ACT_ID_HOR_PEL_PANNING	0x13
12635bb9b1fSchopps #define ACT_ID_COLOR_SELECT	0x14
12735bb9b1fSchopps 
12835bb9b1fSchopps /* Graphics Controller: */
12935bb9b1fSchopps #define GCT_ADDRESS		0x03CE
13035bb9b1fSchopps #define GCT_ADDRESS_R		0x03CF
13135bb9b1fSchopps #define GCT_ADDRESS_W		0x03CF
13235bb9b1fSchopps #define GCT_ID_SET_RESET	0x00
13335bb9b1fSchopps #define GCT_WR5_BG_EXT		0x00
13435bb9b1fSchopps #define GCT_ID_ENABLE_SET_RESET	0x01
13535bb9b1fSchopps #define GCT_ID_WR45_FG_EXT	0x01
13635bb9b1fSchopps #define GCT_ID_COLOR_COMPARE	0x02
13735bb9b1fSchopps #define GCT_ID_DATA_ROTATE	0x03
13835bb9b1fSchopps #define GCT_ID_READ_MAP_SELECT	0x04
13935bb9b1fSchopps #define GCT_ID_GRAPHICS_MODE	0x05
14035bb9b1fSchopps #define GCT_ID_MISC		0x06
14135bb9b1fSchopps #define GCT_ID_COLOR_XCARE	0x07
14235bb9b1fSchopps #define GCT_ID_BITMASK		0x08
14335bb9b1fSchopps #define GCT_ID_OFFSET_0		0x09
14435bb9b1fSchopps #define GCT_ID_OFFSET_1		0x0A
14535bb9b1fSchopps #define GCT_ID_MODE_EXT	0x0B
14635bb9b1fSchopps #define GCT_ID_COLOR_KEY	0x0C
14735bb9b1fSchopps #define GCT_ID_COLOR_KEY_MASK	0x0D
14835bb9b1fSchopps #define GCT_ID_MISC_CNTL	0x0E
14935bb9b1fSchopps #define GCT_ID_16BIT_BG_HIGH	0x10
15035bb9b1fSchopps #define GCT_ID_16BIT_FG_HIGH	0x11
15135bb9b1fSchopps #define GCT_ID_BLT_WIDTH_LOW	0x20
15235bb9b1fSchopps #define GCT_ID_BLT_WIDTH_HIGH	0x21
15335bb9b1fSchopps #define GCT_ID_BLT_HEIGHT_LOW	0x22
15435bb9b1fSchopps #define GCT_ID_BLT_HEIGHT_HIGH	0x23
15535bb9b1fSchopps #define GCT_ID_DST_PITCH_LOW	0x24
15635bb9b1fSchopps #define GCT_ID_DST_PITCH_HIGH	0x25
15735bb9b1fSchopps #define GCT_ID_SRC_PITCH_LOW	0x26
15835bb9b1fSchopps #define GCT_ID_SRC_PITCH_HIGH	0x27
15935bb9b1fSchopps #define GCT_ID_DST_START_LOW	0x28
16035bb9b1fSchopps #define GCT_ID_DST_START_MID	0x29
16135bb9b1fSchopps #define GCT_ID_DST_START_HIGH	0x2A
16235bb9b1fSchopps #define GCT_ID_SRC_START_LOW	0x2C
16335bb9b1fSchopps #define GCT_ID_SRC_START_MID	0x2D
16435bb9b1fSchopps #define GCT_ID_SRC_START_HIGH	0x2E
16535bb9b1fSchopps #define GCT_ID_BLT_MODE		0x30
16635bb9b1fSchopps #define GCT_ID_BLT_STAT_START	0x31
16735bb9b1fSchopps #define GCT_ID_BLT_ROP		0x32
1687212a830Sveego #define GCT_ID_RESERVED		0x33
16935bb9b1fSchopps #define GCT_ID_TRP_COL_LOW	0x34	/* transparent color */
17035bb9b1fSchopps #define GCT_ID_TRP_COL_HIGH	0x35
17135bb9b1fSchopps #define GCT_ID_TRP_MASK_LOW	0x38
17235bb9b1fSchopps #define GCT_ID_TRP_MASK_HIGH	0x39
17335bb9b1fSchopps 
17435bb9b1fSchopps 
17535bb9b1fSchopps /* Sequencer: */
17635bb9b1fSchopps #define SEQ_ADDRESS		0x03C4
17735bb9b1fSchopps #define SEQ_ADDRESS_R		0x03C5
17835bb9b1fSchopps #define SEQ_ADDRESS_W		0x03C5
17935bb9b1fSchopps #define SEQ_ID_RESET		0x00
18035bb9b1fSchopps #define SEQ_ID_CLOCKING_MODE	0x01
18135bb9b1fSchopps #define SEQ_ID_MAP_MASK		0x02
18235bb9b1fSchopps #define SEQ_ID_CHAR_MAP_SELECT	0x03
18335bb9b1fSchopps 
18435bb9b1fSchopps #define TEXT_PLANE_CHAR	    0x01
18535bb9b1fSchopps #define TEXT_PLANE_ATTR	    0x02
18635bb9b1fSchopps #define TEXT_PLANE_FONT	    0x04
18735bb9b1fSchopps 
18835bb9b1fSchopps #define SEQ_ID_MEMORY_MODE	0x04
18935bb9b1fSchopps #define SEQ_ID_UNLOCK_EXT	0x06	/* down from here, all seq registers are Cirrus extensions */
19035bb9b1fSchopps #define SEQ_ID_EXT_SEQ_MODE     0x07
19135bb9b1fSchopps #define SEQ_ID_EEPROM_CNTL	0x08
19235bb9b1fSchopps #define SEQ_ID_SCRATCH_0        0x09
19335bb9b1fSchopps #define SEQ_ID_SCRATCH_1	0x0A
19435bb9b1fSchopps #define SEQ_ID_VCLK_0_NUM	0x0B
19535bb9b1fSchopps #define SEQ_ID_VCLK_1_NUM	0x0C
19635bb9b1fSchopps #define SEQ_ID_VCLK_2_NUM	0x0D
19735bb9b1fSchopps #define SEQ_ID_VCLK_3_NUM	0x0E
19835bb9b1fSchopps #define SEQ_ID_DRAM_CNTL	0x0F
19935bb9b1fSchopps #define SEQ_ID_CURSOR_X		0x10	/* Cursor position can't be set with WSeq
20035bb9b1fSchopps */
20135bb9b1fSchopps #define SEQ_ID_CURSOR_Y		0x11
20235bb9b1fSchopps #define SEQ_ID_CURSOR_ATTR	0x12
20335bb9b1fSchopps #define SEQ_ID_CURSOR_STORE	0x13
20435bb9b1fSchopps #define SEQ_ID_SCRATCH_2	0x14
20535bb9b1fSchopps #define SEQ_ID_SCRATCH_3	0x15
20635bb9b1fSchopps #define SEQ_ID_PERF_TUNE	0x16
20735bb9b1fSchopps #define SEQ_ID_CONF_RBACK	0x17
20835bb9b1fSchopps #define SEQ_ID_SIG_CNTL		0x18
20935bb9b1fSchopps #define SEQ_ID_SIG_RES_LOW	0x19
21035bb9b1fSchopps #define SEQ_ID_SIG_RES_HIGH	0x1A
21135bb9b1fSchopps #define SEQ_ID_VCLK_0_DENOM	0x1B
21235bb9b1fSchopps #define SEQ_ID_VCLK_1_DENOM	0x1C
21335bb9b1fSchopps #define SEQ_ID_VCLK_2_DENOM	0x1D
21435bb9b1fSchopps #define SEQ_ID_VCLK_3_DENOM	0x1E
21535bb9b1fSchopps #define SEQ_ID_MCLK_SELECT	0x1F
21635bb9b1fSchopps 
21735bb9b1fSchopps /* CRT Controller: */
21835bb9b1fSchopps #define CRT_ADDRESS		0x03D4
21935bb9b1fSchopps #define CRT_ADDRESS_R		0x03D5
22035bb9b1fSchopps #define CRT_ADDRESS_W		0x03D5
22135bb9b1fSchopps #define CRT_ID_HOR_TOTAL	0x00
22235bb9b1fSchopps #define CRT_ID_HOR_DISP_ENA_END	0x01
22335bb9b1fSchopps #define CRT_ID_START_HOR_BLANK	0x02
22435bb9b1fSchopps #define CRT_ID_END_HOR_BLANK	0x03
22535bb9b1fSchopps #define CRT_ID_START_HOR_RETR	0x04
22635bb9b1fSchopps #define CRT_ID_END_HOR_RETR	0x05
22735bb9b1fSchopps #define CRT_ID_VER_TOTAL	0x06
22835bb9b1fSchopps #define CRT_ID_OVERFLOW		0x07
22935bb9b1fSchopps #define CRT_ID_PRESET_ROW_SCAN	0x08
23035bb9b1fSchopps #define CRT_ID_CHAR_HEIGHT	0x09	/* was MAX_SCANLINES on retina, weird, eh? */
23135bb9b1fSchopps #define CRT_ID_CURSOR_START	0x0A
23235bb9b1fSchopps #define CRT_ID_CURSOR_END	0x0B
23335bb9b1fSchopps #define CRT_ID_START_ADDR_HIGH	0x0C
23435bb9b1fSchopps #define CRT_ID_START_ADDR_LOW	0x0D
23535bb9b1fSchopps #define CRT_ID_CURSOR_LOC_HIGH	0x0E
23635bb9b1fSchopps #define CRT_ID_CURSOR_LOC_LOW	0x0F
23735bb9b1fSchopps #define CRT_ID_START_VER_RETR	0x10
23835bb9b1fSchopps #define CRT_ID_END_VER_RETR	0x11
23935bb9b1fSchopps #define CRT_ID_VER_DISP_ENA_END	0x12
24035bb9b1fSchopps #define CRT_ID_OFFSET		0x13
24135bb9b1fSchopps #define CRT_ID_UNDERLINE_LOC	0x14
24235bb9b1fSchopps #define CRT_ID_START_VER_BLANK	0x15
24335bb9b1fSchopps #define CRT_ID_END_VER_BLANK	0x16
24435bb9b1fSchopps #define CRT_ID_MODE_CONTROL	0x17
24535bb9b1fSchopps #define CRT_ID_LINE_COMPARE	0x18
24635bb9b1fSchopps #define CRT_ID_LACE_END         0x19
24735bb9b1fSchopps #define CRT_ID_LACE_CNTL        0x1A
24835bb9b1fSchopps #define CRT_ID_EXT_DISP_CNTL    0x1B
2497212a830Sveego #define CRT_ID_SYNC_ADJ_GENLOCK 0x1C
2507212a830Sveego #define CRT_ID_OVERLAY_EXT_CTRL_REG    0x1D
25135bb9b1fSchopps 
25235bb9b1fSchopps #define CRT_ID_GD_LATCH_RBACK	0x22
25335bb9b1fSchopps 
25435bb9b1fSchopps #define CRT_ID_ACT_TOGGLE_RBACK	0x24
25535bb9b1fSchopps #define CRT_ID_ACT_INDEX_RBACK 	0x26
25635bb9b1fSchopps 
25735bb9b1fSchopps /* Pass-through */
25835bb9b1fSchopps #define PASS_ADDRESS		0x8000
25935bb9b1fSchopps #define PASS_ADDRESS_W		0x8000
26035bb9b1fSchopps /* Special Picasso Address */
26135bb9b1fSchopps #define PASS_ADDRESS_WP		0x9000
26235bb9b1fSchopps 
26335bb9b1fSchopps /* Video DAC */
26435bb9b1fSchopps #define VDAC_ADDRESS	0x03c8
26535bb9b1fSchopps #define VDAC_ADDRESS_W	0x03c8
266d34943dcSveego #define VDAC_ADDRESS_R	(((cltype==PICASSO)&&(cl_64bit==0))?0x03c7+0xfff:0x3c7)
26735bb9b1fSchopps #define VDAC_STATE	0x03c7
268d34943dcSveego #define VDAC_DATA	(((cltype==PICASSO)&&(cl_64bit==0))?0x03c9+0xfff:0x3c9)
26935bb9b1fSchopps #define VDAC_MASK       0x03c6
27035bb9b1fSchopps #define HDR	        0x03c6	/* Hidden DAC register, 4 reads to access */
27135bb9b1fSchopps 
27235bb9b1fSchopps 
27335bb9b1fSchopps #define WGfx(ba, idx, val) \
274d498950fSthorpej 	do { \
275d498950fSthorpej 		vgaw(ba, GCT_ADDRESS, idx); \
276d498950fSthorpej 		vgaw(ba, GCT_ADDRESS_W , val); \
277d498950fSthorpej 	} while (0)
27835bb9b1fSchopps 
27935bb9b1fSchopps #define WSeq(ba, idx, val) \
280d498950fSthorpej 	do { \
281d498950fSthorpej 		vgaw(ba, SEQ_ADDRESS, idx); \
282d498950fSthorpej 		vgaw(ba, SEQ_ADDRESS_W , val); \
283d498950fSthorpej 	} while (0) \
284d498950fSthorpej 
2852d65de24Sperry /*		__asm volatile ("nop"); \ */
28635bb9b1fSchopps 
28735bb9b1fSchopps #define WCrt(ba, idx, val) \
288d498950fSthorpej 	do { \
289d498950fSthorpej 		vgaw(ba, CRT_ADDRESS, idx); \
290d498950fSthorpej 		vgaw(ba, CRT_ADDRESS_W , val); \
291d498950fSthorpej 	} while (0)
29235bb9b1fSchopps 
29335bb9b1fSchopps #define WAttr(ba, idx, val) \
29435bb9b1fSchopps 	do {	\
2953020e66dSis 		vgar(ba, ACT_ADDRESS_RESET); \
29635bb9b1fSchopps 		vgaw(ba, ACT_ADDRESS_W, idx); \
29735bb9b1fSchopps 		vgaw(ba, ACT_ADDRESS_W, val); \
29835bb9b1fSchopps 	} while (0)
29935bb9b1fSchopps 
30035bb9b1fSchopps #define SetTextPlane(ba, m) \
30135bb9b1fSchopps 	do { \
30235bb9b1fSchopps 		WGfx(ba, GCT_ID_READ_MAP_SELECT, m & 3 ); \
30335bb9b1fSchopps 		WSeq(ba, SEQ_ID_MAP_MASK, (1 << (m & 3))); \
30435bb9b1fSchopps 	} while (0)
30535bb9b1fSchopps 
306*bf3440b2Smhitch #ifdef _KERNEL
3079382c873Saymeric int cl_mode(register struct grf_softc *gp, u_long cmd, void *arg,
3089382c873Saymeric 			u_long a2, int a3);
3099382c873Saymeric int cl_load_mon(struct grf_softc *gp, struct grfcltext_mode *gv);
3109382c873Saymeric int grfcl_cnprobe(void);
3119382c873Saymeric void grfcl_iteinit(struct grf_softc *gp);
312*bf3440b2Smhitch #endif
31335bb9b1fSchopps 
31435bb9b1fSchopps #endif /* _GRF_RHREG_H */
315