diofbvar.h revision 1.3 1 /* $NetBSD: diofbvar.h,v 1.3 2011/02/12 16:40:29 tsutsui Exp $ */
2 /* $OpenBSD: diofbvar.h,v 1.10 2006/08/11 18:33:13 miod Exp $ */
3
4 /*
5 * Copyright (c) 2005, Miodrag Vallat
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28 /*
29 * Copyright (c) 1988 University of Utah.
30 * Copyright (c) 1990, 1993
31 * The Regents of the University of California. All rights reserved.
32 *
33 * This code is derived from software contributed to Berkeley by
34 * the Systems Programming Group of the University of Utah Computer
35 * Science Department.
36 *
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
39 * are met:
40 * 1. Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * 2. Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in the
44 * documentation and/or other materials provided with the distribution.
45 * 3. Neither the name of the University nor the names of its contributors
46 * may be used to endorse or promote products derived from this software
47 * without specific prior written permission.
48 *
49 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
50 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
51 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
52 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
53 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
54 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
55 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
56 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 * SUCH DAMAGE.
60 *
61 * from: Utah $Hdr: grfvar.h 1.11 93/08/13$
62 *
63 * @(#)grfvar.h 8.2 (Berkeley) 9/9/93
64 */
65
66 #ifdef _KERNEL
67
68 struct diocmap {
69 uint8_t r[256], g[256], b[256];
70 };
71
72 /*
73 * Minimal frame buffer state structure.
74 */
75 struct diofb {
76 uint8_t *regkva; /* KVA of registers */
77 uint8_t *fbkva; /* KVA of framebuffer */
78
79 uint8_t *regaddr; /* control registers physaddr */
80 uint8_t *fbaddr; /* frame buffer physaddr */
81
82 u_int fbsize; /* frame buffer size */
83 u_int fbwidth; /* frame buffer width */
84 u_int fbheight; /* frame buffer height */
85 u_int dwidth; /* displayed part width */
86 u_int dheight; /* displayed part height */
87
88 u_int planes; /* number of planes */
89 u_int planemask; /* and related mask */
90
91 /* rasops information */
92 struct rasops_info ri;
93
94 /* color information */
95 struct diocmap cmap;
96
97 /* wsdisplay information */
98 char wsdname[32];
99 struct wsscreen_descr wsd;
100 struct wsscreen_list wsl;
101 struct wsscreen_descr *scrlist[1];
102 int nscreens;
103 u_int mapmode;
104
105 /* blockmove routine */
106 int (*bmv)(struct diofb *, uint16_t, uint16_t, uint16_t,
107 uint16_t, uint16_t, uint16_t, int16_t, int16_t);
108 };
109
110 /* Replacement Rules (rops) */
111 #define RR_CLEAR 0x0
112 #define RR_COPY 0x3
113 #define RR_XOR 0x6
114 #define RR_INVERT 0xa
115 #define RR_COPYINVERTED 0xc
116
117 void diofb_cnattach(struct diofb *);
118 void diofb_end_attach(device_t, struct wsdisplay_accessops *, struct diofb *,
119 int, const char *);
120 int diofb_fbinquire(struct diofb *, int, struct diofbreg *);
121 void diofb_fbsetup(struct diofb *);
122 int diofb_getcmap(struct diofb *, struct wsdisplay_cmap *);
123 void diofb_resetcmap(struct diofb *);
124
125 int diofb_alloc_attr(void *, int, int, int, long *);
126 int diofb_alloc_screen(void *, const struct wsscreen_descr *, void **,
127 int *, int *, long *);
128 void diofb_free_screen(void *, void *);
129 paddr_t diofb_mmap(void *, void *, off_t, int);
130 int diofb_show_screen(void *, void *, int, void (*)(void *, int, int),
131 void *);
132
133 int diofb_mono_windowmove(struct diofb *, uint16_t, uint16_t, uint16_t,
134 uint16_t, uint16_t, uint16_t, int16_t, int16_t);
135
136 /* Console support */
137 int dvboxcnattach(bus_space_tag_t, bus_addr_t, int);
138 int gboxcnattach(bus_space_tag_t, bus_addr_t, int);
139 int hypercnattach(bus_space_tag_t, bus_addr_t, int);
140 int rboxcnattach(bus_space_tag_t, bus_addr_t, int);
141 int topcatcnattach(bus_space_tag_t, bus_addr_t, int);
142 int tvrxcnattach(bus_space_tag_t, bus_addr_t, int);
143 int gendiofbcnattach(bus_space_tag_t, bus_addr_t, int);
144 extern struct diofb diofb_cn; /* struct diofb for console device */
145
146 #endif
147
148 /*
149 * In mapped mode, mmap() will provide the following layout:
150 * 0 - (DIOFB_REGSPACE - 1) frame buffer registers
151 * DIOFB_REGSPACE onwards frame buffer memory
152 */
153 #define DIOFB_REGSPACE 0x020000
154