xref: /original-bsd/sys/pmax/dev/fbreg.h (revision e05100ce)
1 /*-
2  * Copyright (c) 1992, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Ralph Campbell and Rick Macklem.
7  *
8  * %sccs.include.redist.c%
9  *
10  *	@(#)fbreg.h	8.1 (Berkeley) 06/10/93
11  */
12 
13 /*
14  * Data for fb.c generic frame buffer routines that are called by the
15  * various frame buffer drivers.
16  */
17 struct fbuaccess {
18 	PM_Info		scrInfo;
19 	pmEvent		events[PM_MAXEVQ];
20 	pmTimeCoord	tcs[MOTION_BUFFER_SIZE];
21 };
22 
23 struct pmax_fb {
24 	int	GraphicsOpen;		/* Open yet? */
25 	int	initialized;		/* Set up yet? */
26 	int	isMono;			/* Monochrome fb? */
27 	int	row, col;		/* Screen pos for glass tty */
28 	struct	fbuaccess *fbu;		/* X event stuff */
29 	char	*fr_addr;		/* Frame buffer address */
30 	size_t	fr_size;		/* Frame buffer size */
31 	char	*fr_chipaddr;		/* Base address for chips */
32 	void	(*posCursor)();		/* Position cursor func */
33 	void	(*KBDPutc)();		/* Send char to keyboard func */
34 	dev_t	kbddev;			/* Device for KBDPutc */
35 	struct	selinfo selp;		/* Select structure */
36 };
37 
38 /*
39  * Definitions for the Keyboard and mouse.
40  */
41 /*
42  * Special key values.
43  */
44 #define	KEY_R_SHIFT	0xab
45 #define KEY_SHIFT	0xae
46 #define KEY_CONTROL	0xaf
47 #define	KEY_R_ALT	0xb2
48 #define KEY_UP		0xb3
49 #define KEY_REPEAT	0xb4
50 #define KEY_F1		0x56
51 #define KEY_COMMAND	KEY_F1
52 
53 /*
54  * Lk201/301 keyboard
55  */
56 #define LK_UPDOWN	0x86		/* bits for setting lk201 modes */
57 #define LK_AUTODOWN	0x82
58 #define LK_DOWN		0x80
59 #define LK_DEFAULTS	0xd3		/* reset mode settings          */
60 #define LK_AR_ENABLE	0xe3		/* global auto repeat enable	*/
61 #define LK_CL_ENABLE	0x1b		/* keyclick enable		*/
62 #define LK_KBD_ENABLE	0x8b		/* keyboard enable		*/
63 #define LK_BELL_ENABLE	0x23		/* the bell			*/
64 #define LK_LED_ENABLE	0x13		/* light led			*/
65 #define LK_LED_DISABLE	0x11		/* turn off led			*/
66 #define LK_RING_BELL	0xa7		/* ring keyboard bell		*/
67 #define LED_1		0x81		/* led bits			*/
68 #define LED_2		0x82
69 #define LED_3		0x84
70 #define LED_4		0x88
71 #define LED_ALL		0x8f
72 #define LK_HELP		0x7c		/* help key			*/
73 #define LK_DO		0x7d		/* do key			*/
74 #define LK_KDOWN_ERROR	0x3d		/* key down on powerup error	*/
75 #define LK_POWER_ERROR	0x3e		/* keyboard failure on pwrup tst*/
76 #define LK_OUTPUT_ERROR 0xb5		/* keystrokes lost during inhbt */
77 #define LK_INPUT_ERROR	0xb6		/* garbage command to keyboard	*/
78 #define LK_LOWEST	0x56		/* lowest significant keycode	*/
79 
80 /* max volume is 0, lowest is 0x7 */
81 #define	LK_PARAM_VOLUME(v)		(0x80|((v)&0x7))
82 
83 /* mode command details */
84 #define	LK_CMD_MODE(m,div)		((m)|((div)<<3))
85 
86 /*
87  * Command characters for the mouse.
88  */
89 #define MOUSE_SELF_TEST		'T'
90 #define MOUSE_INCREMENTAL	'R'
91 
92 /*
93  * Mouse output bits.
94  *
95  *     	MOUSE_START_FRAME	Start of report frame bit.
96  *	MOUSE_X_SIGN		Sign bit for X.
97  *	MOUSE_Y_SIGN		Sign bit for Y.
98  *	MOUSE_X_OFFSET		X offset to start cursor at.
99  *	MOUSE_Y_OFFSET		Y offset to start cursor at.
100  */
101 #define MOUSE_START_FRAME	0x80
102 #define MOUSE_X_SIGN		0x10
103 #define MOUSE_Y_SIGN		0x08
104 
105 /*
106  * Definitions for mouse buttons
107  */
108 #define EVENT_LEFT_BUTTON	0x01
109 #define EVENT_MIDDLE_BUTTON	0x02
110 #define EVENT_RIGHT_BUTTON	0x03
111 #define RIGHT_BUTTON		0x01
112 #define MIDDLE_BUTTON		0x02
113 #define LEFT_BUTTON		0x04
114 
115 /*
116  * Mouse report structure definition
117  */
118 typedef struct {
119 	char state;			/* buttons and sign bits	*/
120 	short dx;			/* delta X since last change	*/
121 	short dy;			/* delta Y since last change	*/
122 	char byteCount;			/* mouse report byte count	*/
123 } MouseReport;
124 
125 /*
126  * Macro to translate from a time struct to milliseconds.
127  */
128 #define TO_MS(tv) ((tv.tv_sec * 1000) + (tv.tv_usec / 1000))
129 
130 extern void fbKbdEvent __P((int, struct pmax_fb *));
131 extern void fbMouseEvent __P((MouseReport *, struct pmax_fb *));
132 extern void fbMouseButtons __P((MouseReport *, struct pmax_fb *));
133 extern void fbScroll __P((struct pmax_fb *));
134 extern void fbPutc __P((dev_t, int));
135 extern void fbBlitc __P((int, struct pmax_fb *));
136 extern void fbBlitc __P((int, struct pmax_fb *));
137 extern int kbdMapChar __P((int));
138 extern void KBDReset __P((dev_t, void (*)(dev_t, int)));
139 extern void MouseInit __P((dev_t, void (*)(dev_t, int), int (*)(dev_t)));
140 extern int KBDGetc __P((void));
141 extern int tb_kbdmouseconfig __P((struct pmax_fb *));
142 extern int fbmmap __P((struct pmax_fb *, dev_t, caddr_t, struct proc *));
143