grfvar.h revision 1.22 1 /* $NetBSD: grfvar.h,v 1.22 1998/08/12 02:36:37 scottr Exp $ */
2
3 /*
4 * Copyright (c) 1988 University of Utah.
5 * Copyright (c) 1990 The Regents of the University of California.
6 * 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. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by the University of
23 * California, Berkeley and its contributors.
24 * 4. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
39 *
40 * from: Utah $Hdr: grfvar.h 1.9 91/01/21$
41 *
42 * @(#)grfvar.h 7.3 (Berkeley) 5/7/91
43 */
44
45 #define CARD_NAME_LEN 64
46
47 /*
48 * State info, per hardware instance.
49 */
50 struct grfbus_softc {
51 struct device sc_dev;
52 nubus_slot sc_slot;
53
54 bus_addr_t sc_basepa; /* base of video space */
55 bus_addr_t sc_fbofs; /* offset to framebuffer */
56
57 bus_space_tag_t sc_tag;
58 bus_space_handle_t sc_handle;
59 bus_space_handle_t sc_regh;
60
61 struct grfmode curr_mode; /* hardware desc(for ioctl) */
62 u_int32_t card_id; /* DrHW value for nubus cards */
63 bus_size_t cli_offset; /* Offset to clear interrupt */
64 /* for cards where that's suff. */
65 u_int32_t cli_value; /* Value to write at cli_offset */
66 nubus_dir board_dir; /* Nubus dir for curr board */
67 };
68
69 /*
70 * State info, per grf instance.
71 */
72 struct grf_softc {
73 struct device sc_dev; /* device glue */
74
75 bus_space_tag_t sc_tag;
76 bus_space_handle_t sc_handle;
77
78 int sc_flags; /* driver flags */
79 u_long sc_phys; /* PA of framebuffer */
80
81 struct grfmode *sc_grfmode; /* forwarded ... */
82 nubus_slot *sc_slot;
83 /* mode-change on/off/mode function */
84 int (*sc_mode) __P((struct grf_softc *, int, void *));
85 /* find framebuffer physical addr */
86 };
87
88 /*
89 * Attach grf and ite semantics to Mac video hardware.
90 */
91 struct grfbus_attach_args {
92 char *ga_name; /* name of semantics to attach */
93 bus_space_tag_t ga_tag; /* forwarded ... */
94 bus_space_handle_t ga_handle;
95 struct grfmode *ga_grfmode;
96 nubus_slot *ga_slot;
97 bus_addr_t ga_phys;
98 int (*ga_mode) __P((struct grf_softc *, int, void *));
99 };
100
101 typedef caddr_t (*grf_phys_t) __P((struct grf_softc *gp, vm_offset_t addr));
102
103 /* flags */
104 #define GF_ALIVE 0x01
105 #define GF_OPEN 0x02
106 #define GF_EXCLUDE 0x04
107 #define GF_WANTED 0x08
108 #define GF_BSDOPEN 0x10
109 #define GF_HPUXOPEN 0x20
110
111 /* requests to mode routine */
112 #define GM_GRFON 1
113 #define GM_GRFOFF 2
114 #define GM_CURRMODE 3
115 #define GM_LISTMODES 4
116 #define GM_NEWMODE 5
117
118 /* minor device interpretation */
119 #define GRFUNIT(d) ((d) & 0x7)
120
121 /*
122 * Nubus image data structure. This is the equivalent of a PixMap in
123 * MacOS programming parlance. One of these structures exists for each
124 * video mode that a quickdraw compatible card can fit in.
125 */
126 struct image_data {
127 u_int32_t size;
128 u_int32_t offset;
129 u_int16_t rowbytes;
130 u_int16_t top;
131 u_int16_t left;
132 u_int16_t bottom;
133 u_int16_t right;
134 u_int16_t version;
135 u_int16_t packType;
136 u_int32_t packSize;
137 u_int32_t hRes;
138 u_int32_t vRes;
139 u_int16_t pixelType;
140 u_int16_t pixelSize;
141 u_int16_t cmpCount;
142 u_int16_t cmpSize;
143 u_int32_t planeBytes;
144 };
145
146 #define VID_PARAMS 1
147 #define VID_TABLE_OFFSET 2
148 #define VID_PAGE_CNT 3
149 #define VID_DEV_TYPE 4
150
151 int grfopen __P((dev_t dev, int flag, int mode, struct proc *p));
152 int grfclose __P((dev_t dev, int flag, int mode, struct proc *p));
153 int grfioctl __P((dev_t, int, caddr_t, int, struct proc *p));
154 int grfpoll __P((dev_t dev, int events, struct proc *p));
155 int grfmmap __P((dev_t dev, int off, int prot));
156 int grfon __P((dev_t dev));
157 int grfoff __P((dev_t dev));
158 int grfaddr __P((struct grf_softc *gp, register int off));
159 int grfmap __P((dev_t dev, caddr_t *addrp, struct proc *p));
160 int grfunmap __P((dev_t dev, caddr_t addr, struct proc *p));
161
162 void grf_establish __P((struct grfbus_softc *, nubus_slot *,
163 int (*)(struct grf_softc *, int, void *)));
164 int grfbusprint __P((void *, const char *));
165