xref: /netbsd/sys/arch/amiga/dev/grf_rhreg.h (revision bf9ec67e)
1 /*	$NetBSD: grf_rhreg.h,v 1.10 2002/01/26 13:40:55 aymeric Exp $	*/
2 
3 /*
4  * Copyright (c) 1994 Markus Wild
5  * Copyright (c) 1994 Lutz Vieweg
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *      This product includes software developed by Lutz Vieweg.
19  * 4. The name of the author may not be used to endorse or promote products
20  *    derived from this software without specific prior written permission
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 #ifndef _GRF_RHREG_H
34 #define _GRF_RHREG_H
35 
36 #define EMPTY_ALPHA 0x2010 /* this is the char and the attribute
37                               that AlphaErase will fill into the
38                               text-screen  */
39 
40 #define MEMSIZE 4        /* Set this to 1 or 4 (MB), according to the
41                             RAM on your Retina BLT Z3 board */
42 /*
43  * The following definitions are places in the frame-buffer memory
44  * which are used for special purposes. While the displayed screen
45  * itself is always beginning at the start of the frame-buffer
46  * memory, the following special places are located at the end
47  * of the memory to keep free as much space as possible for the
48  * screen - the user might want to use monitor-definitions with
49  * huge logical dimensions (e.g. 2048x2000 ?). This way of defining
50  * special locations in the frame-buffer memory is far from being
51  * elegant - you may want to use you own, real memory-management...
52  * but remember that some routines in RZ3_BSD.cc REALLY NEED those
53  * memory locations to function properly, so if you manage the
54  * frame-buffer memory on your own, make sure to change those
55  * definitions appropriately.
56  */
57 
58 /* reserve some space for one pattern line */
59 #define PAT_MEM_SIZE 16*3
60 #define PAT_MEM_OFF  (MEMSIZE*1024*1024 - PAT_MEM_SIZE)
61 
62 /* reserve some space for the hardware cursor (up to 64x64 pixels) */
63 #define HWC_MEM_SIZE 1024
64 #define HWC_MEM_OFF  ((PAT_MEM_OFF - HWC_MEM_SIZE) & 0xffffff00)
65 
66 /*
67  * The following structure is passed to RZ3Init() and holds the
68  * monitor-definition. You may either use one of the ready-made
69  * definitions in RZ3_monitors.cc or you can define them on your
70  * own, take a look at RZ3_monitors.cc for more information.
71  */
72 struct MonDef {
73 
74 	/* first the general monitor characteristics */
75 
76 	unsigned long  FQ;
77 	unsigned char  FLG;
78 
79 	unsigned short MW;  /* physical screen width in pixels    */
80 	                    /* has to be at least a multiple of 8 */
81 	unsigned short MH;  /* physical screen height in pixels   */
82 
83 	unsigned short HBS;
84 	unsigned short HSS;
85 	unsigned short HSE;
86 	unsigned short HBE;
87 	unsigned short HT;
88 	unsigned short VBS;
89 	unsigned short VSS;
90 	unsigned short VSE;
91 	unsigned short VBE;
92 	unsigned short VT;
93 
94 	unsigned short DEP;  /* Color-depth, 4 enables text-mode  */
95 	                     /* 8 enables 256-color graphics-mode, */
96 	                     /* 16 and 24bit gfx not supported yet */
97 
98 	unsigned char * PAL; /* points to 16*3 byte RGB-palette data   */
99 	                     /* use LoadPalette() to set colors 0..255 */
100 	                     /* in 256-color-gfx mode */
101 
102 	/*
103 	 * all following entries are font-specific in
104 	 * text-mode. Make sure your monitor
105 	 * parameters are calculated for the
106 	 * appropriate font width and height!
107 	 */
108 
109 	unsigned short  TX;     /* Text-mode (DEP=4):          */
110 	                        /* screen-width  in characters */
111 
112 	                        /* Gfx-mode (DEP > 4)          */
113 	                        /* "logical" screen-width,     */
114 	                        /* use values > MW to allow    */
115 	                        /* hardware-panning            */
116 
117 	unsigned short  TY;     /* Text-mode:                  */
118 	                        /* screen-height in characters */
119 
120 	                        /* Gfx-mode: "logical" screen  */
121 	                        /* height for panning          */
122 
123 	/* the following values are currently unused for gfx-mode */
124 
125 	unsigned short  XY;     /* TX*TY (speeds up some calcs.) */
126 
127 	unsigned short  FX;     /* font-width (valid values: 4,7-16) */
128 	unsigned short  FY;     /* font-height (valid range: 1-32) */
129 	unsigned char * FData;  /* pointer to the font-data */
130 
131 	/*
132 	 * The font data is simply an array of bytes defining
133 	 * the chars in ascending order, line by line. If your
134 	 * font is wider than 8 pixel, FData has to be an
135 	 * array of words.
136 	 */
137 
138 	unsigned short  FLo;    /* lowest character defined */
139 	unsigned short  FHi;    /* highest char. defined */
140 
141 };
142 
143 
144 /*
145  * The following are the prototypes for the low-level
146  * routines you may want to call.
147  */
148 
149 #if 0
150 
151 #ifdef __GNUG__
152 
153 /* The prototypes for C++, prototypes for C (with explanations) below */
154 
155 "C" unsigned char * RZ3Init         (volatile void * HardWareAdress, struct MonDef * md);
156 "C" void            RZ3SetCursorPos (unsigned short pos);
157 "C" void            RZ3AlphaErase   (unsigned short xd, unsigned short yd,
158                                             unsigned short  w, unsigned short  h );
159 "C" void            RZ3AlphaCopy    (unsigned short xs, unsigned short ys,
160                                             unsigned short xd, unsigned short yd,
161                                             unsigned short  w, unsigned short  h  );
162 "C" void            RZ3BitBlit      (struct grf_bitblt * gbb );
163 "C" void            RZ3BitBlit16    (struct grf_bitblt * gbb );
164 "C" void            RZ3LoadPalette  (unsigned char * pal, unsigned char firstcol, unsigned char colors);
165 "C" void            RZ3SetPalette   (unsigned char colornum, unsigned char red, unsigned char green, unsigned char blue);
166 "C" void            RZ3SetPanning   (unsigned short xoff, unsigned short yoff);
167 "C" void            RZ3SetupHWC     (unsigned char col1, unsigned col2,
168                                             unsigned char hsx, unsigned char hsy,
169                                             const unsigned long * data);
170 "C" void            RZ3DisableHWC   (void);
171 "C" void            RZ3SetHWCloc    (unsigned short x, unsigned short y);
172 #else
173 
174 /* The prototypes for C */
175 /* with a little explanation */
176 
177 	unsigned char * RZ3Init(volatile void * BoardAdress, struct MonDef * md);
178 
179 /*
180  * This routine initialises the Retina Z3 hardware, opens a
181  * text- or gfx-mode screen, depending on the value of
182  * MonDef.DEP, and sets the cursor to position 0.
183  * It takes as arguments a pointer to the hardware-base
184  * address as it is denoted in the DevConf structure
185  * of the AmigaDOS, and a pointer to a struct MonDef
186  * which describes the screen-mode parameters.
187  *
188  * The routine returns 0 if it was unable to open the screen,
189  * or an unsigned char * to the display memory when it
190  * succeeded.
191  *
192  * The organisation of the display memory in text-mode is a
193  * little strange (Intel-typically...) :
194  *
195  * Byte  00    01    02    03    04     05    06   etc.
196  *     Char0  Attr0  --    --   Char1 Attr1   --   etc.
197  *
198  * You may set a character and its associated attribute byte
199  * with a single word-access, or you may perform to byte writes
200  * for the char and attribute. Each 2. word has no meaning,
201  * and writes to theese locations are ignored.
202  *
203  * The attribute byte for each character has the following
204  * structure:
205  *
206  * Bit  7     6     5     4     3     2     1     0
207  *    BLINK BACK2 BACK1 BACK0 FORE3 FORE2 FORE1 FORE0
208  *
209  * Were FORE is the foreground-color index (0-15) and
210  * BACK is the background color index (0-7). BLINK
211  * enables blinking for the associated character.
212  * The higher 8 colors in the standard palette are
213  * lighter than the lower 8, so you may see FORE3 as
214  * an intensity bit. If FORE == 1 or FORE == 9 and
215  * BACK == 0 the character is underlined. Since I don't
216  * think this looks good, it will probably change in a
217  * future release.
218  *
219  * There's no routine "SetChar" or "SetAttr" provided,
220  * because I think it's so trivial... a function call
221  * would be pure overhead. As an example, a routine
222  * to set the char code and attribute at position x,y:
223  * (assumed the value returned by RZ3Init was stored
224  *  into "DispMem", the actual MonDef struct * is hold
225  *  in "MDef")
226  *
227  * void SetChar(unsigned char chr, unsigned char attr,
228  *              unsigned short x, unsigned short y) {
229  *
230  *    unsigned struct MonDef * md = MDef;
231  *    unsigned char * c = DispMem + x*4 + y*md->TX*4;
232  *
233  *    *c++ = chr;
234  *    *c   = attr;
235  *
236  * }
237  *
238  * In gfx-mode, the memory organisation is rather simple,
239  * 1 byte per pixel in 256-color mode, one pixel after
240  * each other, line by line.
241  *
242  * When 16-bits per pixel are used, each two bytes represent
243  * one pixel. The meaning of the bits is the following:
244  *
245  * Bit       15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
246  * Component g2 g1 g0 b4 b3 b2 b1 b0 r4 r3 r2 r1 r0 g5 g4 g3
247  *
248  * Please note that the memory layout in gfx-mode depends
249  * on the logical screen-size, panning does only affect
250  * the appearance of the physical screen.
251  *
252  * Currently, RZ3Init() disables the Retina Z3 VBLANK IRQ,
253  * but beware: When running the Retina WB-Emu under
254  * AmigaDOS, the VBLANK IRQ is ENABLED...
255  *
256  */
257 
258 	void RZ3LoadPalette(unsigned char * pal, unsigned char firstcol, unsigned char colors);
259 
260 /*
261  * Loads the palette-registers. "pal" points to an array of unsigned char
262  * triplets, for the red, green and blue component. "firstcol" determines the
263  * number of the first palette-register to load (256 available). "colors" is
264  * the number of colors you want to put in the palette registers.
265  */
266 
267 	void RZ3SetPalette(unsigned char colornum, unsigned char red, unsigned char green, unsigned char blue);
268 
269 /*
270  * Allows you to set a single color in the palette, "colornum" is the number
271  * of the palette entry (256 available), "red", "green" and "blue" are the
272  * three components.
273  */
274 
275 	void RZ3SetCursorPos(unsigned short pos);
276 
277 /*
278  * This routine sets the text-mode hardware-cursor position to the screen
279  * location pos. pos can be calculated as (x + y * md->TY).
280  * Text-mode only!
281  */
282 
283 	void RZ3AlphaCopy (unsigned short xs, unsigned short ys,
284                       unsigned short xd, unsigned short yd,
285                       unsigned short  w, unsigned short  h  );
286 
287 /*
288  * This Routine utilizes the blitter to perform fast copies
289  * in the text-display. The paramters are:
290  *  xs - source x-coordinate
291  *  ys - source y-coordinate
292  *  xd - destination x-coordinate
293  *  yd - destination y-coordinate
294  *  w  - the width of the area to copy
295  *  h  - the height of the area to copy
296  * All coordinates are in characters. RZ3AlphaCopy does not
297  * check for boundaries - you've got to make sure that the
298  * parameters have sensible values. Text-mode only!
299  */
300 
301 
302 	void RZ3AlphaErase (unsigned short xd, unsigned short yd,
303                        unsigned short  w, unsigned short  h );
304 
305 /*
306  * RZ3AlphaErase utilizes the blitter to erase portions of
307  * the text-display. The parameters are:
308  *  xd - destination x-coordinate
309  *  yd - destination y-coordinate
310  *  w  - the width of the area to erase
311  *  h  - the height of the area to erase
312  * All coordinates are in characters. RZ3AlphaCopy does not
313  * check for boundaries - you've got to make sure that the
314  * parameters have sensible values. Text-mode only!
315  *
316  * Since the blitter is unable to use a mask-pattern and a
317  * certain fill-value at the same time, this routine uses
318  * a simple trick: RZ3Init() clears a memory area twice as
319  * large as the text-display needs, and RZ3AlphaErase then
320  * simply uses RZ3AlphaCopy to copy the desired area from
321  * the empty text-screen to the actually displayed screen.
322  */
323 
324 	void RZ3BitBlit (struct grf_bitblt * gbb );
325 
326 /*
327  * RZ3BitBlit utilizes the blitter to perform one of 16
328  * available logical operations on the display memory,
329  * among them ordinary fill- and copy operations.
330  * The only parameter is a pointer to a struct grf_bitblt:
331  *
332  * struct grf_bitblt {
333  *   unsigned short op;              see above definitions of GRFBBOPxxx
334  *   unsigned short src_x, src_y;    upper left corner of source-region
335  *   unsigned short dst_x, dst_y;    upper left corner of dest-region
336  *   unsigned short w, h;            width, height of region
337  *   unsigned short mask;            bitmask to apply
338  * };
339  *
340  * All coordinates are in pixels. RZ3BitBlit does not
341  * check for boundaries - you've got to make sure that the
342  * parameters have sensible values. 8 bit gfx-mode only!
343  *
344  * The blitter has a lot more capabilities, which aren't
345  * currently used by theese routines, among them color-expanded
346  * and text-blits, which can speed up GUIs like X11 a lot.
347  * If you've got any idea how to make use of them within
348  * your routines, contact me, and I'll implement the necessary
349  * blit-operations.
350  */
351 
352 	void RZ3BitBlit16( struct grf_bitblt * gbb );
353 
354 /* Does the same as RZ3BitBlit(), but for 16-bit screens */
355 
356 	void RZ3SetPanning(unsigned short xoff, unsigned short yoff);
357 
358 /*
359  * Moves the logical coordinate (xoff, yoff) to the upper left corner
360  * of your screen. Of course, you shouldn't specify excess values that would
361  * show garbage in the lower right area of your screen... SetPanning()
362  * does NOT check for boundaries.
363  * Please read the documentation of RZ3SetHWCloc, too.
364  */
365 
366 	void RZ3SetupHWC (unsigned char col1, unsigned col2,
367                      unsigned char hsx, unsigned char hsy,
368                      const unsigned long * data);
369 
370 /*
371  * Initializes and switches on the hardware-cursor sprite.
372  * The parameters are:
373  * col1     - the first color
374  * col2     - the second color
375  * hsx      - hot-spot location offset x
376  * hsy      - hot-spot location offset y
377  * data     - a pointer to the bitmap data to be used for the sprite
378  *
379  * The organization of the data is - as always with MSDOS related
380  * products - rather strange: The first and the second long-word
381  * represent bitplane0 for the first 64 pixels. The following two
382  * long-words represent bitplane1 for the first 64 pixels. But
383  * the long-words are organized in Intel-fashion, beginning with
384  * the least significant byte, ending with the most significant
385  * one. The most significant bit of each byte is the leftmost,
386  * as one would expect it. Now the weird color-assignments:
387  *
388  * bitplane0 bitplane1       result
389  *     0         0            col2
390  *     0         1            col1
391  *     1         0          transparent
392  *     1         1     background-color XOR 0xff
393  *
394  * The size of the data has to be 64*64*2/8 = 1024 byte,
395  * obviously, the size of the sprite is 64x64 pixels.
396  */
397 
398 
399 	void RZ3DisableHWC (void);
400 
401 /* simply disables the hardware-cursor sprite */
402 
403 	void RZ3SetHWCloc (unsigned short x, unsigned short y);
404 
405 /*
406  * sets the location of the hardwar-cursor sprite to x,y
407  * relative to the logical screen beginning.
408  * IMPORTANT: If you use RZ3SetHWCloc() to set the position
409  * of the hardware-cursor sprite, all necessary panning is
410  * done automatically - you can treat the display without
411  * even knowing about the physical screen size that is
412  * displayed.
413  */
414 
415 #endif
416 
417 #endif /* RZ3_BSD_h */
418 
419 
420 /* -------------- START OF CODE -------------- */
421 
422 /* read VGA register */
423 #define vgar(ba, reg) (*(((volatile unsigned char *)ba)+reg))
424 
425 /* write VGA register */
426 #define vgaw(ba, reg, val) \
427 	*(((volatile unsigned char *)ba)+reg) = val
428 
429 /*
430  * defines for the used register addresses (mw)
431  *
432  * NOTE: there are some registers that have different addresses when
433  *       in mono or color mode. We only support color mode, and thus
434  *       some addresses won't work in mono-mode!
435  */
436 
437 /* General Registers: */
438 #define GREG_STATUS0_R		0x03C2
439 #define GREG_STATUS1_R		0x03DA
440 #define GREG_MISC_OUTPUT_R	0x03CC
441 #define GREG_MISC_OUTPUT_W	0x03C2
442 #define GREG_FEATURE_CONTROL_R	0x03CA
443 #define GREG_FEATURE_CONTROL_W	0x03DA
444 #define GREG_POS		0x0102
445 
446 /* Attribute Controller: */
447 #define ACT_ADDRESS		0x03C0
448 #define ACT_ADDRESS_R		0x03C0
449 #define ACT_ADDRESS_W		0x03C0
450 #define ACT_ADDRESS_RESET	0x03DA
451 #define ACT_ID_PALETTE0		0x00
452 #define ACT_ID_PALETTE1		0x01
453 #define ACT_ID_PALETTE2		0x02
454 #define ACT_ID_PALETTE3		0x03
455 #define ACT_ID_PALETTE4		0x04
456 #define ACT_ID_PALETTE5		0x05
457 #define ACT_ID_PALETTE6		0x06
458 #define ACT_ID_PALETTE7		0x07
459 #define ACT_ID_PALETTE8		0x08
460 #define ACT_ID_PALETTE9		0x09
461 #define ACT_ID_PALETTE10	0x0A
462 #define ACT_ID_PALETTE11	0x0B
463 #define ACT_ID_PALETTE12	0x0C
464 #define ACT_ID_PALETTE13	0x0D
465 #define ACT_ID_PALETTE14	0x0E
466 #define ACT_ID_PALETTE15	0x0F
467 #define ACT_ID_ATTR_MODE_CNTL	0x10
468 #define ACT_ID_OVERSCAN_COLOR	0x11
469 #define ACT_ID_COLOR_PLANE_ENA	0x12
470 #define ACT_ID_HOR_PEL_PANNING	0x13
471 #define ACT_ID_COLOR_SELECT	0x14
472 
473 /* Graphics Controller: */
474 #define GCT_ADDRESS		0x03CE
475 #define GCT_ADDRESS_R		0x03CE
476 #define GCT_ADDRESS_W		0x03CF
477 #define GCT_ID_SET_RESET	0x00
478 #define GCT_ID_ENABLE_SET_RESET	0x01
479 #define GCT_ID_COLOR_COMPARE	0x02
480 #define GCT_ID_DATA_ROTATE	0x03
481 #define GCT_ID_READ_MAP_SELECT	0x04
482 #define GCT_ID_GRAPHICS_MODE	0x05
483 #define GCT_ID_MISC		0x06
484 #define GCT_ID_COLOR_XCARE	0x07
485 #define GCT_ID_BITMASK		0x08
486 
487 /* Sequencer: */
488 #define SEQ_ADDRESS		0x03C4
489 #define SEQ_ADDRESS_R		0x03C4
490 #define SEQ_ADDRESS_W		0x03C5
491 #define SEQ_ID_RESET		0x00
492 #define SEQ_ID_CLOCKING_MODE	0x01
493 #define SEQ_ID_MAP_MASK		0x02
494 #define SEQ_ID_CHAR_MAP_SELECT	0x03
495 #define SEQ_ID_MEMORY_MODE	0x04
496 #define SEQ_ID_EXTENDED_ENABLE	0x05	/* down from here, all seq registers are NCR extensions */
497 #define SEQ_ID_UNKNOWN1         0x06
498 #define SEQ_ID_UNKNOWN2         0x07
499 #define SEQ_ID_CHIP_ID		0x08
500 #define SEQ_ID_UNKNOWN3         0x09
501 #define SEQ_ID_CURSOR_COLOR1	0x0A
502 #define SEQ_ID_CURSOR_COLOR0	0x0B
503 #define SEQ_ID_CURSOR_CONTROL	0x0C
504 #define SEQ_ID_CURSOR_X_LOC_HI	0x0D
505 #define SEQ_ID_CURSOR_X_LOC_LO	0x0E
506 #define SEQ_ID_CURSOR_Y_LOC_HI	0x0F
507 #define SEQ_ID_CURSOR_Y_LOC_LO	0x10
508 #define SEQ_ID_CURSOR_X_INDEX	0x11
509 #define SEQ_ID_CURSOR_Y_INDEX	0x12
510 #define SEQ_ID_CURSOR_STORE_HI	0x13	/* manual still wrong here.. argl! */
511 #define SEQ_ID_CURSOR_STORE_LO	0x14	/* downto 0x16 */
512 #define SEQ_ID_CURSOR_ST_OFF_HI	0x15
513 #define SEQ_ID_CURSOR_ST_OFF_LO	0x16
514 #define SEQ_ID_CURSOR_PIXELMASK	0x17
515 #define SEQ_ID_PRIM_HOST_OFF_HI	0x18
516 #define SEQ_ID_PRIM_HOST_OFF_LO	0x19
517 #define SEQ_ID_LINEAR_0		0x1A
518 #define SEQ_ID_LINEAR_1		0x1B
519 #define SEQ_ID_SEC_HOST_OFF_HI	0x1C
520 #define SEQ_ID_SEC_HOST_OFF_LO	0x1D
521 #define SEQ_ID_EXTENDED_MEM_ENA	0x1E
522 #define SEQ_ID_EXT_CLOCK_MODE	0x1F
523 #define SEQ_ID_EXT_VIDEO_ADDR	0x20
524 #define SEQ_ID_EXT_PIXEL_CNTL	0x21
525 #define SEQ_ID_BUS_WIDTH_FEEDB	0x22
526 #define SEQ_ID_PERF_SELECT	0x23
527 #define SEQ_ID_COLOR_EXP_WFG	0x24
528 #define SEQ_ID_COLOR_EXP_WBG	0x25
529 #define SEQ_ID_EXT_RW_CONTROL	0x26
530 #define SEQ_ID_MISC_FEATURE_SEL	0x27
531 #define SEQ_ID_COLOR_KEY_CNTL	0x28
532 #define SEQ_ID_COLOR_KEY_MATCH0	0x29
533 #define SEQ_ID_COLOR_KEY_MATCH1 0x2A
534 #define SEQ_ID_COLOR_KEY_MATCH2 0x2B
535 #define SEQ_ID_UNKNOWN6         0x2C
536 #define SEQ_ID_CRC_CONTROL	0x2D
537 #define SEQ_ID_CRC_DATA_LOW	0x2E
538 #define SEQ_ID_CRC_DATA_HIGH	0x2F
539 #define SEQ_ID_MEMORY_MAP_CNTL	0x30
540 #define SEQ_ID_ACM_APERTURE_1	0x31
541 #define SEQ_ID_ACM_APERTURE_2	0x32
542 #define SEQ_ID_ACM_APERTURE_3	0x33
543 #define SEQ_ID_BIOS_UTILITY_0	0x3e
544 #define SEQ_ID_BIOS_UTILITY_1	0x3f
545 
546 /* CRT Controller: */
547 #define CRT_ADDRESS		0x03D4
548 #define CRT_ADDRESS_R		0x03D5
549 #define CRT_ADDRESS_W		0x03D5
550 #define CRT_ID_HOR_TOTAL	0x00
551 #define CRT_ID_HOR_DISP_ENA_END	0x01
552 #define CRT_ID_START_HOR_BLANK	0x02
553 #define CRT_ID_END_HOR_BLANK	0x03
554 #define CRT_ID_START_HOR_RETR	0x04
555 #define CRT_ID_END_HOR_RETR	0x05
556 #define CRT_ID_VER_TOTAL	0x06
557 #define CRT_ID_OVERFLOW		0x07
558 #define CRT_ID_PRESET_ROW_SCAN	0x08
559 #define CRT_ID_MAX_SCAN_LINE	0x09
560 #define CRT_ID_CURSOR_START	0x0A
561 #define CRT_ID_CURSOR_END	0x0B
562 #define CRT_ID_START_ADDR_HIGH	0x0C
563 #define CRT_ID_START_ADDR_LOW	0x0D
564 #define CRT_ID_CURSOR_LOC_HIGH	0x0E
565 #define CRT_ID_CURSOR_LOC_LOW	0x0F
566 #define CRT_ID_START_VER_RETR	0x10
567 #define CRT_ID_END_VER_RETR	0x11
568 #define CRT_ID_VER_DISP_ENA_END	0x12
569 #define CRT_ID_OFFSET		0x13
570 #define CRT_ID_UNDERLINE_LOC	0x14
571 #define CRT_ID_START_VER_BLANK	0x15
572 #define CRT_ID_END_VER_BLANK	0x16
573 #define CRT_ID_MODE_CONTROL	0x17
574 #define CRT_ID_LINE_COMPARE	0x18
575 #define CRT_ID_UNKNOWN1         0x19	/* are these register really void ? */
576 #define CRT_ID_UNKNOWN2         0x1A
577 #define CRT_ID_UNKNOWN3         0x1B
578 #define CRT_ID_UNKNOWN4         0x1C
579 #define CRT_ID_UNKNOWN5         0x1D
580 #define CRT_ID_UNKNOWN6         0x1E
581 #define CRT_ID_UNKNOWN7         0x1F
582 #define CRT_ID_UNKNOWN8         0x20
583 #define CRT_ID_UNKNOWN9         0x21
584 #define CRT_ID_UNKNOWN10      	0x22
585 #define CRT_ID_UNKNOWN11      	0x23
586 #define CRT_ID_UNKNOWN12      	0x24
587 #define CRT_ID_UNKNOWN13      	0x25
588 #define CRT_ID_UNKNOWN14      	0x26
589 #define CRT_ID_UNKNOWN15      	0x27
590 #define CRT_ID_UNKNOWN16      	0x28
591 #define CRT_ID_UNKNOWN17      	0x29
592 #define CRT_ID_UNKNOWN18      	0x2A
593 #define CRT_ID_UNKNOWN19      	0x2B
594 #define CRT_ID_UNKNOWN20      	0x2C
595 #define CRT_ID_UNKNOWN21      	0x2D
596 #define CRT_ID_UNKNOWN22      	0x2E
597 #define CRT_ID_UNKNOWN23      	0x2F
598 #define CRT_ID_EXT_HOR_TIMING1	0x30	/* down from here, all crt registers are NCR extensions */
599 #define CRT_ID_EXT_START_ADDR	0x31
600 #define CRT_ID_EXT_HOR_TIMING2	0x32
601 #define CRT_ID_EXT_VER_TIMING	0x33
602 #define CRT_ID_MONITOR_POWER	0x34
603 
604 /* PLL chip  (clock frequency synthesizer) I'm guessing here... */
605 #define PLL_ADDRESS		0x83c8
606 #define PLL_ADDRESS_W		0x83c9
607 
608 
609 /* Video DAC */
610 #define VDAC_ADDRESS		0x03c8
611 #define VDAC_ADDRESS_W		0x03c8
612 #define VDAC_ADDRESS_R		0x03c7
613 #define VDAC_STATE		0x03c7
614 #define VDAC_DATA		0x03c9
615 #define VDAC_MASK		0x03c6
616 
617 
618 /* Accelerator Control Menu (memory mapped registers, includes blitter) */
619 #define ACM_PRIMARY_OFFSET	0x00
620 #define ACM_SECONDARY_OFFSET	0x04
621 #define ACM_MODE_CONTROL	0x08
622 #define ACM_CURSOR_POSITION	0x0c
623 #define ACM_START_STATUS	0x30
624 #define ACM_CONTROL		0x34
625 #define ACM_RASTEROP_ROTATION	0x38
626 #define ACM_BITMAP_DIMENSION	0x3c
627 #define ACM_DESTINATION		0x40
628 #define ACM_SOURCE		0x44
629 #define ACM_PATTERN		0x48
630 #define ACM_FOREGROUND		0x4c
631 #define ACM_BACKGROUND		0x50
632 
633 
634 #define WGfx(ba, idx, val) \
635 	do { vgaw(ba, GCT_ADDRESS, idx); vgaw(ba, GCT_ADDRESS_W , val); } while (0)
636 
637 #define WSeq(ba, idx, val) \
638 	do { vgaw(ba, SEQ_ADDRESS, idx); vgaw(ba, SEQ_ADDRESS_W , val); } while (0)
639 
640 #define WCrt(ba, idx, val) \
641 	do { vgaw(ba, CRT_ADDRESS, idx); vgaw(ba, CRT_ADDRESS_W , val); } while (0)
642 
643 #define WAttr(ba, idx, val) \
644 	do { vgaw(ba, ACT_ADDRESS, idx); vgaw(ba, ACT_ADDRESS_W, val); } while (0)
645 
646 #define Map(m) \
647 	do { WGfx(ba, GCT_ID_READ_MAP_SELECT, m & 3 ); WSeq(ba, SEQ_ID_MAP_MASK, (1 << (m & 3))); } while (0)
648 
649 #define WPLL(ba, idx, val) \
650 	do { 	vgaw(ba, PLL_ADDRESS, idx);\
651 	vgaw(ba, PLL_ADDRESS_W, (val & 0xff));\
652 	vgaw(ba, PLL_ADDRESS_W, (val >> 8)); } while (0)
653 
654 
655 static __inline unsigned char RAttr(volatile void * ba, short idx) {
656 	vgaw (ba, ACT_ADDRESS, idx);
657 	return vgar (ba, ACT_ADDRESS_R);
658 }
659 
660 static __inline unsigned char RSeq(volatile void * ba, short idx) {
661 	vgaw (ba, SEQ_ADDRESS, idx);
662 	return vgar (ba, SEQ_ADDRESS_R);
663 }
664 
665 static __inline unsigned char RCrt(volatile void * ba, short idx) {
666 	vgaw (ba, CRT_ADDRESS, idx);
667 	return vgar (ba, CRT_ADDRESS_R);
668 }
669 
670 static __inline unsigned char RGfx(volatile void * ba, short idx) {
671 	vgaw(ba, GCT_ADDRESS, idx);
672 	return vgar (ba, GCT_ADDRESS_R);
673 }
674 
675 void RZ3DisableHWC(struct grf_softc *gp);
676 void RZ3SetupHWC(struct grf_softc *gp, unsigned char col1, unsigned int col2,
677 			unsigned char hsx, unsigned char hsy,
678 			const long unsigned int *data);
679 void RZ3AlphaErase(struct grf_softc *gp,
680 			short unsigned int xd, short unsigned int yd,
681 			short unsigned int w, short unsigned int h);
682 void RZ3AlphaCopy(struct grf_softc *gp,
683 			short unsigned int xs, short unsigned int ys,
684 			short unsigned int xd, short unsigned int yd,
685 			short unsigned int w, short unsigned int h);
686 void RZ3BitBlit(struct grf_softc *gp, struct grf_bitblt *gbb);
687 void RZ3BitBlit16(struct grf_softc *gp, struct grf_bitblt *gbb);
688 void RZ3BitBlit24(struct grf_softc *gp, struct grf_bitblt *gbb);
689 void RZ3SetCursorPos(struct grf_softc *gp, short unsigned int pos);
690 void RZ3LoadPalette(struct grf_softc *gp, unsigned char *pal,
691 			unsigned char firstcol, unsigned char colors);
692 void RZ3SetPalette(struct grf_softc *gp, unsigned char colornum,
693 			unsigned char red, unsigned char green,
694 			unsigned char blue);
695 void RZ3SetPanning(struct grf_softc *gp,
696 			short unsigned int xoff, short unsigned int yoff);
697 void RZ3SetHWCloc(struct grf_softc *gp,
698 			short unsigned int x, short unsigned int y);
699 int rh_mode(register struct grf_softc *gp, u_long cmd, void *arg,
700 			u_long a2, int a3);
701 int rh_ioctl(register struct grf_softc *gp, u_long cmd, void *data);
702 int rh_getcmap(struct grf_softc *gfp, struct grf_colormap *cmap);
703 int rh_putcmap(struct grf_softc *gfp, struct grf_colormap *cmap);
704 int rh_getspritepos(struct grf_softc *gp, struct grf_position *pos);
705 int rh_setspritepos(struct grf_softc *gp, struct grf_position *pos);
706 int rh_getspriteinfo(struct grf_softc *gp, struct grf_spriteinfo *info);
707 int rh_setspriteinfo(struct grf_softc *gp, struct grf_spriteinfo *info);
708 int rh_getspritemax(struct grf_softc *gp, struct grf_position *pos);
709 int rh_bitblt(struct grf_softc *gp, struct grf_bitblt *bb);
710 int rh_blank(struct grf_softc *, int *);
711 
712 struct ite_softc;
713 void rh_init(struct ite_softc *);
714 void rh_cursor(struct ite_softc *, int);
715 void rh_deinit(struct ite_softc *);
716 void rh_putc(struct ite_softc *, int, int, int, int);
717 void rh_clear(struct ite_softc *, int, int, int, int);
718 void rh_scroll(struct ite_softc *, int, int, int, int);
719 
720 int grfrh_cnprobe(void);
721 void grfrh_iteinit(struct grf_softc *);
722 
723 #endif /* _GRF_RHREG_H */
724