Home | History | Annotate | Line # | Download | only in common
      1 /*	$NetBSD: itevar.h,v 1.18 2025/05/30 19:19:26 tsutsui Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1988 University of Utah.
      5  * Copyright (c) 1990, 1993
      6  *	The Regents of the University of California.  All rights reserved.
      7  *
      8  * This code is derived from software contributed to Berkeley by
      9  * the Systems Programming Group of the University of Utah Computer
     10  * Science Department.
     11  *
     12  * Redistribution and use in source and binary forms, with or without
     13  * modification, are permitted provided that the following conditions
     14  * are met:
     15  * 1. Redistributions of source code must retain the above copyright
     16  *    notice, this list of conditions and the following disclaimer.
     17  * 2. Redistributions in binary form must reproduce the above copyright
     18  *    notice, this list of conditions and the following disclaimer in the
     19  *    documentation and/or other materials provided with the distribution.
     20  * 3. Neither the name of the University nor the names of its contributors
     21  *    may be used to endorse or promote products derived from this software
     22  *    without specific prior written permission.
     23  *
     24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34  * SUCH DAMAGE.
     35  *
     36  * from: Utah $Hdr: itevar.h 1.15 92/12/20$
     37  *
     38  *	@(#)itevar.h	8.1 (Berkeley) 6/10/93
     39  */
     40 
     41 /*
     42  * Standalone version of hp300 ITE.
     43  */
     44 
     45 #define getbyte(ip, offset) \
     46 	*(((u_char *)(ip)->regbase) + (offset))
     47 
     48 #define getword(ip, offset) \
     49 	((getbyte(ip, offset) << 8) | getbyte(ip, (offset) + 2))
     50 
     51 struct ite_data;
     52 
     53 typedef	void (*ite_windowmover)(struct ite_data *, int, int, int, int, int,
     54 	    int, int);
     55 
     56 struct ite_data {
     57 	int	alive;
     58 	int	scode;			/* DIO selectcode or SGC slot # */
     59 	const struct itesw *isw;
     60 	void 	*regbase, *fbbase;
     61 	short	curx, cury;
     62 	short   cursorx, cursory;
     63 	short   cblankx, cblanky;
     64 	short	rows, cols;
     65 	short   cpl;
     66 	short	dheight, dwidth;
     67 	short	fbheight, fbwidth;
     68 	short	ftheight, ftwidth;
     69 	short	fontx, fonty;
     70 	short	planemask;
     71 	ite_windowmover bmv;
     72 };
     73 
     74 struct itesw {
     75 	int	ite_hwid;
     76 	int	(*ite_probe)(struct ite_data *);
     77 	void	(*ite_init)(struct ite_data *);
     78 	void	(*ite_clear)(struct ite_data *, int, int, int, int);
     79 	void	(*ite_putc)(struct ite_data *, int, int, int);
     80 	void	(*ite_cursor)(struct ite_data *, int);
     81 	void	(*ite_scroll)(struct ite_data *);
     82 };
     83 
     84 /*
     85  * X and Y location of character 'c' in the framebuffer, in pixels.
     86  */
     87 #define	charX(ip,c)	\
     88 	(((c) % (ip)->cpl) * (ip)->ftwidth + (ip)->fontx)
     89 
     90 #define charX1bpp(ip,c) \
     91 	(((c) % (ip)->cpl) * ((((ip)->ftwidth + 7) / 8) * 8) + (ip)->fontx)
     92 
     93 #define	charY(ip,c)	\
     94 	(((c) / (ip)->cpl) * (ip)->ftheight + (ip)->fonty)
     95 
     96 /* Replacement Rules */
     97 #define RR_CLEAR		0x0
     98 #define RR_COPY			0x3
     99 #define RR_XOR			0x6
    100 #define RR_COPYINVERTED  	0xc
    101 
    102 #define DRAW_CURSOR	0x05
    103 #define ERASE_CURSOR    0x06
    104 #define MOVE_CURSOR	0x07
    105 
    106 #define KBD_SSHIFT	4		/* bits to shift status */
    107 #define KBD_CHARMASK	0x7F
    108 
    109 /* keyboard status */
    110 #define KBD_SMASK	0xF		/* service request status mask */
    111 #define KBD_CTRLSHIFT	0x8		/* key + CTRL + SHIFT */
    112 #define KBD_CTRL	0x9		/* key + CTRL */
    113 #define KBD_SHIFT	0xA		/* key + SHIFT */
    114 #define KBD_KEY		0xB		/* key only */
    115 
    116 /*
    117  * Prototypes.
    118  */
    119 void ite_fontinfo(struct ite_data *);
    120 void ite_fontinit1bpp(struct ite_data *);
    121 void ite_fontinit8bpp(struct ite_data *);
    122 void ite_dio_clear(struct ite_data *, int, int, int, int);
    123 void ite_dio_cursor(struct ite_data *, int);
    124 void ite_dio_putc1bpp(struct ite_data *, int, int, int);
    125 void ite_dio_putc8bpp(struct ite_data *, int, int, int);
    126 void ite_dio_scroll(struct ite_data *);
    127 void ite_dio_windowmove1bpp(struct ite_data *, int, int, int, int,
    128     int, int, int);
    129 
    130 /*
    131  * Framebuffer-specific ITE prototypes.
    132  */
    133 void topcat_init(struct ite_data *);
    134 void gbox_init(struct ite_data *);
    135 void gbox_scroll(struct ite_data *);
    136 void rbox_init(struct ite_data *);
    137 void dvbox_init(struct ite_data *);
    138 void hyper_init(struct ite_data *);
    139 void tvrx_init(struct ite_data *);
    140 
    141 int  sti_dio_probe(struct ite_data *);
    142 void sti_iteinit_dio(struct ite_data *);
    143 void sti_iteinit_sgc(struct ite_data *);
    144 void sti_cursor(struct ite_data *, int);
    145 void sti_putc(struct ite_data *, int, int, int);
    146 void sti_clear(struct ite_data *, int, int, int, int);
    147 void sti_scroll(struct ite_data *);
    148