agten.c revision 1.6.6.4 1 1.6.6.4 joerg /* $NetBSD: agten.c,v 1.6.6.4 2007/10/26 15:47:28 joerg Exp $ */
2 1.6.6.2 jmcneill
3 1.6.6.2 jmcneill /*-
4 1.6.6.2 jmcneill * Copyright (c) 2007 Michael Lorenz
5 1.6.6.2 jmcneill * All rights reserved.
6 1.6.6.2 jmcneill *
7 1.6.6.2 jmcneill * Redistribution and use in source and binary forms, with or without
8 1.6.6.2 jmcneill * modification, are permitted provided that the following conditions
9 1.6.6.2 jmcneill * are met:
10 1.6.6.2 jmcneill * 1. Redistributions of source code must retain the above copyright
11 1.6.6.2 jmcneill * notice, this list of conditions and the following disclaimer.
12 1.6.6.2 jmcneill * 2. Redistributions in binary form must reproduce the above copyright
13 1.6.6.2 jmcneill * notice, this list of conditions and the following disclaimer in the
14 1.6.6.2 jmcneill * documentation and/or other materials provided with the distribution.
15 1.6.6.2 jmcneill * 3. Neither the name of The NetBSD Foundation nor the names of its
16 1.6.6.2 jmcneill * contributors may be used to endorse or promote products derived
17 1.6.6.2 jmcneill * from this software without specific prior written permission.
18 1.6.6.2 jmcneill *
19 1.6.6.2 jmcneill * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.6.6.2 jmcneill * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.6.6.2 jmcneill * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.6.6.2 jmcneill * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.6.6.2 jmcneill * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.6.6.2 jmcneill * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.6.6.2 jmcneill * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.6.6.2 jmcneill * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.6.6.2 jmcneill * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.6.6.2 jmcneill * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.6.6.2 jmcneill * POSSIBILITY OF SUCH DAMAGE.
30 1.6.6.2 jmcneill */
31 1.6.6.2 jmcneill
32 1.6.6.2 jmcneill #include <sys/cdefs.h>
33 1.6.6.4 joerg __KERNEL_RCSID(0, "$NetBSD: agten.c,v 1.6.6.4 2007/10/26 15:47:28 joerg Exp $");
34 1.6.6.2 jmcneill
35 1.6.6.2 jmcneill /*
36 1.6.6.2 jmcneill * a driver for the Fujitsu AG-10e SBus framebuffer
37 1.6.6.2 jmcneill *
38 1.6.6.2 jmcneill * this thing is Frankenstein's Monster among graphics boards.
39 1.6.6.2 jmcneill * it contains three graphics chips:
40 1.6.6.2 jmcneill * a GLint - 24bit stuff, double-buffered
41 1.6.6.2 jmcneill * an Imagine 128 which provides an 8bit overlay
42 1.6.6.2 jmcneill * a Weitek P9100 which provides WIDs
43 1.6.6.2 jmcneill * so here we need to mess only with the P9100 and the I128 - for X we just
44 1.6.6.2 jmcneill * hide the overlay and let the Xserver mess with the GLint
45 1.6.6.2 jmcneill */
46 1.6.6.2 jmcneill
47 1.6.6.2 jmcneill #include <sys/param.h>
48 1.6.6.2 jmcneill #include <sys/systm.h>
49 1.6.6.2 jmcneill #include <sys/kernel.h>
50 1.6.6.2 jmcneill #include <sys/device.h>
51 1.6.6.2 jmcneill #include <sys/proc.h>
52 1.6.6.2 jmcneill #include <sys/mutex.h>
53 1.6.6.2 jmcneill #include <sys/ioctl.h>
54 1.6.6.2 jmcneill #include <sys/kernel.h>
55 1.6.6.2 jmcneill #include <sys/systm.h>
56 1.6.6.2 jmcneill #include <sys/conf.h>
57 1.6.6.2 jmcneill
58 1.6.6.2 jmcneill #include <dev/sun/fbio.h>
59 1.6.6.2 jmcneill #include <dev/sun/fbvar.h>
60 1.6.6.2 jmcneill #include <dev/sun/btreg.h>
61 1.6.6.2 jmcneill #include <dev/sun/btvar.h>
62 1.6.6.2 jmcneill
63 1.6.6.4 joerg #include <sys/bus.h>
64 1.6.6.2 jmcneill #include <machine/autoconf.h>
65 1.6.6.2 jmcneill
66 1.6.6.2 jmcneill #include <dev/sbus/sbusvar.h>
67 1.6.6.2 jmcneill
68 1.6.6.2 jmcneill #include <dev/wscons/wsconsio.h>
69 1.6.6.2 jmcneill #include <dev/wscons/wsdisplayvar.h>
70 1.6.6.2 jmcneill #include <dev/rasops/rasops.h>
71 1.6.6.2 jmcneill #include <dev/wsfont/wsfont.h>
72 1.6.6.2 jmcneill
73 1.6.6.2 jmcneill #include <dev/wscons/wsdisplay_vconsvar.h>
74 1.6.6.2 jmcneill
75 1.6.6.2 jmcneill #include <dev/sbus/p9100reg.h>
76 1.6.6.2 jmcneill #include <dev/ic/ibm561reg.h>
77 1.6.6.2 jmcneill #include <dev/ic/i128reg.h>
78 1.6.6.2 jmcneill #include <dev/ic/i128var.h>
79 1.6.6.2 jmcneill
80 1.6.6.2 jmcneill #include "opt_agten.h"
81 1.6.6.2 jmcneill
82 1.6.6.2 jmcneill static int agten_match(struct device *, struct cfdata *, void *);
83 1.6.6.2 jmcneill static void agten_attach(struct device *, struct device *, void *);
84 1.6.6.2 jmcneill
85 1.6.6.2 jmcneill static int agten_ioctl(void *, void *, u_long, void *, int, struct lwp *);
86 1.6.6.2 jmcneill static paddr_t agten_mmap(void *, void *, off_t, int);
87 1.6.6.2 jmcneill static void agten_init_screen(void *, struct vcons_screen *, int, long *);
88 1.6.6.2 jmcneill
89 1.6.6.2 jmcneill struct agten_softc {
90 1.6.6.2 jmcneill struct device sc_dev; /* base device */
91 1.6.6.2 jmcneill struct sbusdev sc_sd; /* sbus device */
92 1.6.6.2 jmcneill struct fbdevice sc_fb; /* frame buffer device */
93 1.6.6.2 jmcneill
94 1.6.6.2 jmcneill struct vcons_screen sc_console_screen;
95 1.6.6.2 jmcneill struct wsscreen_descr sc_defaultscreen_descr;
96 1.6.6.2 jmcneill const struct wsscreen_descr *sc_screens[1];
97 1.6.6.2 jmcneill struct wsscreen_list sc_screenlist;
98 1.6.6.2 jmcneill
99 1.6.6.2 jmcneill bus_space_tag_t sc_bustag;
100 1.6.6.2 jmcneill
101 1.6.6.2 jmcneill bus_space_handle_t sc_i128_fbh;
102 1.6.6.2 jmcneill bus_size_t sc_i128_fbsz;
103 1.6.6.2 jmcneill bus_space_handle_t sc_i128_regh;
104 1.6.6.2 jmcneill bus_space_handle_t sc_p9100_regh;
105 1.6.6.2 jmcneill bus_addr_t sc_glint_fb;
106 1.6.6.2 jmcneill bus_addr_t sc_glint_regs;
107 1.6.6.2 jmcneill uint32_t sc_glint_fbsz;
108 1.6.6.2 jmcneill
109 1.6.6.2 jmcneill uint32_t sc_width;
110 1.6.6.2 jmcneill uint32_t sc_height; /* panel width / height */
111 1.6.6.2 jmcneill uint32_t sc_stride;
112 1.6.6.2 jmcneill uint32_t sc_depth;
113 1.6.6.2 jmcneill
114 1.6.6.2 jmcneill int sc_cursor_x;
115 1.6.6.2 jmcneill int sc_cursor_y;
116 1.6.6.2 jmcneill int sc_video; /* video output enabled */
117 1.6.6.2 jmcneill
118 1.6.6.2 jmcneill /* some /dev/fb* stuff */
119 1.6.6.2 jmcneill int sc_fb_is_open;
120 1.6.6.2 jmcneill
121 1.6.6.2 jmcneill union bt_cmap sc_cmap; /* Brooktree color map */
122 1.6.6.2 jmcneill
123 1.6.6.2 jmcneill int sc_mode;
124 1.6.6.2 jmcneill uint32_t sc_bg;
125 1.6.6.2 jmcneill struct vcons_data vd;
126 1.6.6.2 jmcneill };
127 1.6.6.2 jmcneill
128 1.6.6.2 jmcneill CFATTACH_DECL(agten, sizeof(struct agten_softc),
129 1.6.6.2 jmcneill agten_match, agten_attach, NULL, NULL);
130 1.6.6.2 jmcneill
131 1.6.6.2 jmcneill
132 1.6.6.2 jmcneill static int agten_putcmap(struct agten_softc *, struct wsdisplay_cmap *);
133 1.6.6.2 jmcneill static int agten_getcmap(struct agten_softc *, struct wsdisplay_cmap *);
134 1.6.6.2 jmcneill static int agten_putpalreg(struct agten_softc *, uint8_t, uint8_t,
135 1.6.6.2 jmcneill uint8_t, uint8_t);
136 1.6.6.2 jmcneill static void agten_init(struct agten_softc *);
137 1.6.6.2 jmcneill static void agten_gfx(struct agten_softc *);
138 1.6.6.2 jmcneill static void agten_set_video(struct agten_softc *, int);
139 1.6.6.2 jmcneill static int agten_get_video(struct agten_softc *);
140 1.6.6.2 jmcneill
141 1.6.6.2 jmcneill static void agten_copycols(void *, int, int, int, int);
142 1.6.6.2 jmcneill static void agten_erasecols(void *, int, int, int, long);
143 1.6.6.2 jmcneill static void agten_copyrows(void *, int, int, int);
144 1.6.6.2 jmcneill static void agten_eraserows(void *, int, int, long);
145 1.6.6.2 jmcneill
146 1.6.6.2 jmcneill static void agten_move_cursor(struct agten_softc *, int, int);
147 1.6.6.2 jmcneill static int agten_do_cursor(struct agten_softc *sc,
148 1.6.6.2 jmcneill struct wsdisplay_cursor *);
149 1.6.6.2 jmcneill static int agten_do_sun_cursor(struct agten_softc *sc,
150 1.6.6.2 jmcneill struct fbcursor *);
151 1.6.6.2 jmcneill
152 1.6.6.2 jmcneill static uint16_t util_interleave(uint8_t, uint8_t);
153 1.6.6.2 jmcneill static uint16_t util_interleave_lin(uint8_t, uint8_t);
154 1.6.6.2 jmcneill
155 1.6.6.2 jmcneill extern const u_char rasops_cmap[768];
156 1.6.6.2 jmcneill
157 1.6.6.2 jmcneill struct wsdisplay_accessops agten_accessops = {
158 1.6.6.2 jmcneill agten_ioctl,
159 1.6.6.2 jmcneill agten_mmap,
160 1.6.6.2 jmcneill NULL, /* alloc_screen */
161 1.6.6.2 jmcneill NULL, /* free_screen */
162 1.6.6.2 jmcneill NULL, /* show_screen */
163 1.6.6.2 jmcneill NULL, /* load_font */
164 1.6.6.2 jmcneill NULL, /* pollc */
165 1.6.6.2 jmcneill NULL /* scroll */
166 1.6.6.2 jmcneill };
167 1.6.6.2 jmcneill
168 1.6.6.2 jmcneill /* /dev/fb* stuff */
169 1.6.6.2 jmcneill extern struct cfdriver agten_cd;
170 1.6.6.2 jmcneill
171 1.6.6.2 jmcneill static int agten_fb_open(dev_t, int, int, struct lwp *);
172 1.6.6.2 jmcneill static int agten_fb_close(dev_t, int, int, struct lwp *);
173 1.6.6.2 jmcneill static int agten_fb_ioctl(dev_t, u_long, void *, int, struct lwp *);
174 1.6.6.2 jmcneill static paddr_t agten_fb_mmap(dev_t, off_t, int);
175 1.6.6.2 jmcneill static void agten_fb_unblank(struct device *);
176 1.6.6.2 jmcneill
177 1.6.6.2 jmcneill static struct fbdriver agtenfbdriver = {
178 1.6.6.2 jmcneill agten_fb_unblank, agten_fb_open, agten_fb_close, agten_fb_ioctl,
179 1.6.6.2 jmcneill nopoll, agten_fb_mmap, nokqfilter
180 1.6.6.2 jmcneill };
181 1.6.6.2 jmcneill
182 1.6.6.2 jmcneill static inline void
183 1.6.6.2 jmcneill agten_write_dac(struct agten_softc *sc, int reg, uint8_t val)
184 1.6.6.2 jmcneill {
185 1.6.6.2 jmcneill bus_space_write_4(sc->sc_bustag, sc->sc_p9100_regh,
186 1.6.6.2 jmcneill 0x200 + (reg << 2), (uint32_t)val << 16);
187 1.6.6.2 jmcneill }
188 1.6.6.2 jmcneill
189 1.6.6.2 jmcneill static inline void
190 1.6.6.2 jmcneill agten_write_idx(struct agten_softc *sc, int offset)
191 1.6.6.2 jmcneill {
192 1.6.6.2 jmcneill bus_space_write_4(sc->sc_bustag, sc->sc_p9100_regh,
193 1.6.6.2 jmcneill 0x200 + (IBM561_ADDR_LOW << 2), (offset & 0xff) << 16);
194 1.6.6.2 jmcneill bus_space_write_4(sc->sc_bustag, sc->sc_p9100_regh,
195 1.6.6.2 jmcneill 0x200 + (IBM561_ADDR_HIGH << 2), ((offset >> 8) & 0xff) << 16);
196 1.6.6.2 jmcneill }
197 1.6.6.2 jmcneill
198 1.6.6.2 jmcneill static inline void
199 1.6.6.2 jmcneill agten_write_dac_10(struct agten_softc *sc, int reg, uint16_t val)
200 1.6.6.2 jmcneill {
201 1.6.6.2 jmcneill agten_write_dac(sc, reg, (val >> 2) & 0xff);
202 1.6.6.2 jmcneill agten_write_dac(sc, reg, (val & 0x3) << 6);
203 1.6.6.2 jmcneill }
204 1.6.6.2 jmcneill
205 1.6.6.2 jmcneill static int
206 1.6.6.2 jmcneill agten_match(struct device *dev, struct cfdata *cf, void *aux)
207 1.6.6.2 jmcneill {
208 1.6.6.2 jmcneill struct sbus_attach_args *sa = aux;
209 1.6.6.2 jmcneill
210 1.6.6.2 jmcneill if (strcmp("PFU,aga", sa->sa_name) == 0)
211 1.6.6.2 jmcneill return 100;
212 1.6.6.2 jmcneill return 0;
213 1.6.6.2 jmcneill }
214 1.6.6.2 jmcneill
215 1.6.6.2 jmcneill static void
216 1.6.6.2 jmcneill agten_attach(struct device *parent, struct device *dev, void *aux)
217 1.6.6.2 jmcneill {
218 1.6.6.2 jmcneill struct agten_softc *sc = (struct agten_softc *)dev;
219 1.6.6.2 jmcneill struct sbus_attach_args *sa = aux;
220 1.6.6.2 jmcneill struct fbdevice *fb = &sc->sc_fb;
221 1.6.6.2 jmcneill struct wsemuldisplaydev_attach_args aa;
222 1.6.6.2 jmcneill struct rasops_info *ri;
223 1.6.6.2 jmcneill long defattr;
224 1.6.6.2 jmcneill uint32_t reg;
225 1.6.6.2 jmcneill int node = sa->sa_node;
226 1.6.6.2 jmcneill int console;
227 1.6.6.2 jmcneill
228 1.6.6.2 jmcneill sc->sc_defaultscreen_descr = (struct wsscreen_descr){
229 1.6.6.2 jmcneill "default",
230 1.6.6.2 jmcneill 0, 0,
231 1.6.6.2 jmcneill NULL,
232 1.6.6.2 jmcneill 8, 16,
233 1.6.6.2 jmcneill WSSCREEN_WSCOLORS | WSSCREEN_HILIT,
234 1.6.6.2 jmcneill NULL
235 1.6.6.2 jmcneill };
236 1.6.6.2 jmcneill sc->sc_screens[0] = &sc->sc_defaultscreen_descr;
237 1.6.6.2 jmcneill sc->sc_screenlist = (struct wsscreen_list){1, sc->sc_screens};
238 1.6.6.2 jmcneill sc->sc_mode = WSDISPLAYIO_MODE_EMUL;
239 1.6.6.2 jmcneill sc->sc_fb_is_open = 0;
240 1.6.6.2 jmcneill sc->sc_video = -1;
241 1.6.6.2 jmcneill sc->sc_bustag = sa->sa_bustag;
242 1.6.6.2 jmcneill
243 1.6.6.2 jmcneill reg = prom_getpropint(node, "i128_fb_physaddr", -1);
244 1.6.6.2 jmcneill sc->sc_i128_fbsz = prom_getpropint(node, "i128_fb_size", -1);
245 1.6.6.2 jmcneill if (sbus_bus_map(sc->sc_bustag,
246 1.6.6.2 jmcneill sa->sa_reg[0].oa_space, sa->sa_reg[0].oa_base + reg,
247 1.6.6.2 jmcneill sc->sc_i128_fbsz, BUS_SPACE_MAP_LINEAR, &sc->sc_i128_fbh) != 0) {
248 1.6.6.2 jmcneill
249 1.6.6.2 jmcneill aprint_error("%s: unable to map the framebuffer\n",
250 1.6.6.2 jmcneill dev->dv_xname);
251 1.6.6.2 jmcneill return;
252 1.6.6.2 jmcneill }
253 1.6.6.2 jmcneill fb->fb_pixels = bus_space_vaddr(sc->sc_bustag, sc->sc_i128_fbh);
254 1.6.6.2 jmcneill
255 1.6.6.2 jmcneill reg = prom_getpropint(node, "i128_reg_physaddr", -1);
256 1.6.6.2 jmcneill if (sbus_bus_map(sc->sc_bustag,
257 1.6.6.2 jmcneill sa->sa_reg[0].oa_space, sa->sa_reg[0].oa_base + reg,
258 1.6.6.2 jmcneill 0x10000, 0, &sc->sc_i128_regh) != 0) {
259 1.6.6.2 jmcneill
260 1.6.6.2 jmcneill aprint_error("%s: unable to map I128 registers\n",
261 1.6.6.2 jmcneill dev->dv_xname);
262 1.6.6.2 jmcneill return;
263 1.6.6.2 jmcneill }
264 1.6.6.2 jmcneill
265 1.6.6.2 jmcneill reg = prom_getpropint(node, "p9100_reg_physaddr", -1);
266 1.6.6.2 jmcneill if (sbus_bus_map(sc->sc_bustag,
267 1.6.6.2 jmcneill sa->sa_reg[0].oa_space, sa->sa_reg[0].oa_base + reg,
268 1.6.6.2 jmcneill 0x8000, 0, &sc->sc_p9100_regh) != 0) {
269 1.6.6.2 jmcneill
270 1.6.6.2 jmcneill aprint_error("%s: unable to map P9100 registers\n",
271 1.6.6.2 jmcneill dev->dv_xname);
272 1.6.6.2 jmcneill return;
273 1.6.6.2 jmcneill }
274 1.6.6.2 jmcneill
275 1.6.6.2 jmcneill reg = prom_getpropint(node, "glint_fb0_physaddr", -1);
276 1.6.6.2 jmcneill sc->sc_glint_fb = sbus_bus_addr(sc->sc_bustag,
277 1.6.6.2 jmcneill sa->sa_reg[0].oa_space, sa->sa_reg[0].oa_base + reg);
278 1.6.6.3 joerg sc->sc_glint_fbsz = prom_getpropint(node, "glint_lb_size", -1);
279 1.6.6.2 jmcneill reg = prom_getpropint(node, "glint_reg_physaddr", -1);
280 1.6.6.2 jmcneill sc->sc_glint_regs = sbus_bus_addr(sc->sc_bustag,
281 1.6.6.2 jmcneill sa->sa_reg[0].oa_space, sa->sa_reg[0].oa_base + reg);
282 1.6.6.2 jmcneill
283 1.6.6.2 jmcneill sbus_establish(&sc->sc_sd, &sc->sc_dev);
284 1.6.6.3 joerg
285 1.6.6.2 jmcneill #if 0
286 1.6.6.2 jmcneill bus_intr_establish(sc->sc_bustag, sa->sa_pri, IPL_BIO,
287 1.6.6.2 jmcneill agten_intr, sc);
288 1.6.6.2 jmcneill #endif
289 1.6.6.2 jmcneill
290 1.6.6.3 joerg sc->sc_width = prom_getpropint(node, "ffb_width", 1152);
291 1.6.6.3 joerg sc->sc_height = prom_getpropint(node, "ffb_height", 900);
292 1.6.6.2 jmcneill sc->sc_depth = prom_getpropint(node, "ffb_depth", 8);
293 1.6.6.2 jmcneill sc->sc_stride = sc->sc_width * (sc->sc_depth >> 3);
294 1.6.6.2 jmcneill
295 1.6.6.3 joerg printf(": %dx%d\n", sc->sc_width, sc->sc_height);
296 1.6.6.2 jmcneill agten_init(sc);
297 1.6.6.2 jmcneill
298 1.6.6.2 jmcneill console = fb_is_console(node);
299 1.6.6.2 jmcneill
300 1.6.6.2 jmcneill vcons_init(&sc->vd, sc, &sc->sc_defaultscreen_descr,
301 1.6.6.2 jmcneill &agten_accessops);
302 1.6.6.2 jmcneill sc->vd.init_screen = agten_init_screen;
303 1.6.6.2 jmcneill
304 1.6.6.2 jmcneill ri = &sc->sc_console_screen.scr_ri;
305 1.6.6.2 jmcneill
306 1.6.6.2 jmcneill if (console) {
307 1.6.6.2 jmcneill vcons_init_screen(&sc->vd, &sc->sc_console_screen, 1,
308 1.6.6.2 jmcneill &defattr);
309 1.6.6.2 jmcneill sc->sc_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
310 1.6.6.2 jmcneill
311 1.6.6.2 jmcneill sc->sc_defaultscreen_descr.textops = &ri->ri_ops;
312 1.6.6.2 jmcneill sc->sc_defaultscreen_descr.capabilities = ri->ri_caps;
313 1.6.6.2 jmcneill sc->sc_defaultscreen_descr.nrows = ri->ri_rows;
314 1.6.6.2 jmcneill sc->sc_defaultscreen_descr.ncols = ri->ri_cols;
315 1.6.6.2 jmcneill wsdisplay_cnattach(&sc->sc_defaultscreen_descr, ri, 0, 0,
316 1.6.6.2 jmcneill defattr);
317 1.6.6.2 jmcneill i128_rectfill(sc->sc_bustag, sc->sc_i128_regh, 0, 0,
318 1.6.6.2 jmcneill sc->sc_width, sc->sc_height,
319 1.6.6.2 jmcneill ri->ri_devcmap[(defattr >> 16) & 0xff]);
320 1.6.6.2 jmcneill } else {
321 1.6.6.2 jmcneill /*
322 1.6.6.2 jmcneill * since we're not the console we can postpone the rest
323 1.6.6.2 jmcneill * until someone actually allocates a screen for us
324 1.6.6.2 jmcneill */
325 1.6.6.2 jmcneill }
326 1.6.6.2 jmcneill
327 1.6.6.2 jmcneill /* Initialize the default color map. */
328 1.6.6.2 jmcneill
329 1.6.6.2 jmcneill aa.console = console;
330 1.6.6.2 jmcneill aa.scrdata = &sc->sc_screenlist;
331 1.6.6.2 jmcneill aa.accessops = &agten_accessops;
332 1.6.6.2 jmcneill aa.accesscookie = &sc->vd;
333 1.6.6.2 jmcneill
334 1.6.6.2 jmcneill config_found(&sc->sc_dev, &aa, wsemuldisplaydevprint);
335 1.6.6.2 jmcneill
336 1.6.6.2 jmcneill fb->fb_driver = &agtenfbdriver;
337 1.6.6.2 jmcneill fb->fb_device = &sc->sc_dev;
338 1.6.6.2 jmcneill fb->fb_flags = device_cfdata(&sc->sc_dev)->cf_flags & FB_USERMASK;
339 1.6.6.2 jmcneill fb->fb_type.fb_type = FBTYPE_AG10E;
340 1.6.6.2 jmcneill fb->fb_type.fb_cmsize = 256; /* doesn't matter, we're always 24bit */
341 1.6.6.2 jmcneill fb->fb_type.fb_size = sc->sc_glint_fbsz;
342 1.6.6.2 jmcneill fb->fb_type.fb_width = sc->sc_width;
343 1.6.6.2 jmcneill fb->fb_type.fb_height = sc->sc_height;
344 1.6.6.2 jmcneill fb->fb_type.fb_depth = 32;
345 1.6.6.2 jmcneill fb->fb_linebytes = sc->sc_stride;
346 1.6.6.2 jmcneill fb_attach(fb, console);
347 1.6.6.2 jmcneill agten_set_video(sc, 1); /* make sure video's on */
348 1.6.6.2 jmcneill }
349 1.6.6.2 jmcneill
350 1.6.6.2 jmcneill static int
351 1.6.6.2 jmcneill agten_ioctl(void *v, void *vs, u_long cmd, void *data, int flag,
352 1.6.6.2 jmcneill struct lwp *l)
353 1.6.6.2 jmcneill {
354 1.6.6.2 jmcneill struct vcons_data *vd = v;
355 1.6.6.2 jmcneill struct agten_softc *sc = vd->cookie;
356 1.6.6.2 jmcneill struct wsdisplay_fbinfo *wdf;
357 1.6.6.2 jmcneill struct vcons_screen *ms = vd->active;
358 1.6.6.2 jmcneill
359 1.6.6.2 jmcneill switch (cmd) {
360 1.6.6.2 jmcneill
361 1.6.6.2 jmcneill case WSDISPLAYIO_GTYPE:
362 1.6.6.2 jmcneill *(u_int *)data = WSDISPLAY_TYPE_AG10;
363 1.6.6.2 jmcneill return 0;
364 1.6.6.2 jmcneill
365 1.6.6.2 jmcneill case WSDISPLAYIO_GINFO:
366 1.6.6.2 jmcneill if (ms == NULL)
367 1.6.6.2 jmcneill return ENODEV;
368 1.6.6.2 jmcneill wdf = (void *)data;
369 1.6.6.2 jmcneill wdf->height = ms->scr_ri.ri_height;
370 1.6.6.2 jmcneill wdf->width = ms->scr_ri.ri_width;
371 1.6.6.2 jmcneill wdf->depth = 32;
372 1.6.6.2 jmcneill wdf->cmsize = 256;
373 1.6.6.2 jmcneill return 0;
374 1.6.6.2 jmcneill
375 1.6.6.2 jmcneill case WSDISPLAYIO_GVIDEO:
376 1.6.6.2 jmcneill *(int *)data = sc->sc_video;
377 1.6.6.2 jmcneill return 0;
378 1.6.6.2 jmcneill
379 1.6.6.2 jmcneill case WSDISPLAYIO_SVIDEO:
380 1.6.6.2 jmcneill agten_set_video(sc, *(int *)data);
381 1.6.6.2 jmcneill return 0;
382 1.6.6.2 jmcneill
383 1.6.6.2 jmcneill case WSDISPLAYIO_GETCMAP:
384 1.6.6.2 jmcneill return agten_getcmap(sc,
385 1.6.6.2 jmcneill (struct wsdisplay_cmap *)data);
386 1.6.6.2 jmcneill
387 1.6.6.2 jmcneill case WSDISPLAYIO_PUTCMAP:
388 1.6.6.2 jmcneill return agten_putcmap(sc,
389 1.6.6.2 jmcneill (struct wsdisplay_cmap *)data);
390 1.6.6.2 jmcneill
391 1.6.6.2 jmcneill case WSDISPLAYIO_LINEBYTES:
392 1.6.6.2 jmcneill *(u_int *)data = sc->sc_stride << 2;
393 1.6.6.2 jmcneill return 0;
394 1.6.6.2 jmcneill
395 1.6.6.2 jmcneill case WSDISPLAYIO_SMODE:
396 1.6.6.2 jmcneill {
397 1.6.6.2 jmcneill int new_mode = *(int*)data;
398 1.6.6.2 jmcneill if (new_mode != sc->sc_mode) {
399 1.6.6.2 jmcneill sc->sc_mode = new_mode;
400 1.6.6.2 jmcneill if(new_mode == WSDISPLAYIO_MODE_EMUL) {
401 1.6.6.2 jmcneill agten_init(sc);
402 1.6.6.2 jmcneill vcons_redraw_screen(ms);
403 1.6.6.2 jmcneill } else {
404 1.6.6.2 jmcneill agten_gfx(sc);
405 1.6.6.2 jmcneill }
406 1.6.6.2 jmcneill }
407 1.6.6.2 jmcneill }
408 1.6.6.2 jmcneill return 0;
409 1.6.6.2 jmcneill
410 1.6.6.2 jmcneill case WSDISPLAYIO_GCURPOS:
411 1.6.6.2 jmcneill {
412 1.6.6.2 jmcneill struct wsdisplay_curpos *cp = (void *)data;
413 1.6.6.2 jmcneill
414 1.6.6.2 jmcneill cp->x = sc->sc_cursor_x;
415 1.6.6.2 jmcneill cp->y = sc->sc_cursor_y;
416 1.6.6.2 jmcneill }
417 1.6.6.2 jmcneill return 0;
418 1.6.6.2 jmcneill
419 1.6.6.2 jmcneill case WSDISPLAYIO_SCURPOS:
420 1.6.6.2 jmcneill {
421 1.6.6.2 jmcneill struct wsdisplay_curpos *cp = (void *)data;
422 1.6.6.2 jmcneill
423 1.6.6.2 jmcneill agten_move_cursor(sc, cp->x, cp->y);
424 1.6.6.2 jmcneill }
425 1.6.6.2 jmcneill return 0;
426 1.6.6.2 jmcneill
427 1.6.6.2 jmcneill case WSDISPLAYIO_GCURMAX:
428 1.6.6.2 jmcneill {
429 1.6.6.2 jmcneill struct wsdisplay_curpos *cp = (void *)data;
430 1.6.6.2 jmcneill
431 1.6.6.2 jmcneill cp->x = 64;
432 1.6.6.2 jmcneill cp->y = 64;
433 1.6.6.2 jmcneill }
434 1.6.6.2 jmcneill return 0;
435 1.6.6.2 jmcneill
436 1.6.6.2 jmcneill case WSDISPLAYIO_SCURSOR:
437 1.6.6.2 jmcneill {
438 1.6.6.2 jmcneill struct wsdisplay_cursor *cursor = (void *)data;
439 1.6.6.2 jmcneill
440 1.6.6.2 jmcneill return agten_do_cursor(sc, cursor);
441 1.6.6.2 jmcneill }
442 1.6.6.2 jmcneill }
443 1.6.6.2 jmcneill return EPASSTHROUGH;
444 1.6.6.2 jmcneill }
445 1.6.6.2 jmcneill
446 1.6.6.2 jmcneill static paddr_t
447 1.6.6.2 jmcneill agten_mmap(void *v, void *vs, off_t offset, int prot)
448 1.6.6.2 jmcneill {
449 1.6.6.2 jmcneill struct vcons_data *vd = v;
450 1.6.6.2 jmcneill struct agten_softc *sc = vd->cookie;
451 1.6.6.2 jmcneill
452 1.6.6.2 jmcneill if (offset < sc->sc_glint_fbsz)
453 1.6.6.2 jmcneill return bus_space_mmap(sc->sc_bustag, sc->sc_glint_fb, offset,
454 1.6.6.2 jmcneill prot, BUS_SPACE_MAP_LINEAR);
455 1.6.6.2 jmcneill return -1;
456 1.6.6.2 jmcneill }
457 1.6.6.2 jmcneill
458 1.6.6.2 jmcneill static void
459 1.6.6.2 jmcneill agten_init_screen(void *cookie, struct vcons_screen *scr,
460 1.6.6.2 jmcneill int existing, long *defattr)
461 1.6.6.2 jmcneill {
462 1.6.6.2 jmcneill struct agten_softc *sc = cookie;
463 1.6.6.2 jmcneill struct rasops_info *ri = &scr->scr_ri;
464 1.6.6.2 jmcneill
465 1.6.6.2 jmcneill ri->ri_depth = sc->sc_depth;
466 1.6.6.2 jmcneill ri->ri_width = sc->sc_width;
467 1.6.6.2 jmcneill ri->ri_height = sc->sc_height;
468 1.6.6.2 jmcneill ri->ri_stride = sc->sc_stride;
469 1.6.6.2 jmcneill ri->ri_flg = RI_CENTER | RI_FULLCLEAR;
470 1.6.6.2 jmcneill
471 1.6.6.2 jmcneill ri->ri_bits = (char *)sc->sc_fb.fb_pixels;
472 1.6.6.2 jmcneill
473 1.6.6.2 jmcneill if (existing) {
474 1.6.6.2 jmcneill ri->ri_flg |= RI_CLEAR;
475 1.6.6.2 jmcneill }
476 1.6.6.2 jmcneill
477 1.6.6.2 jmcneill rasops_init(ri, sc->sc_height / 8, sc->sc_width / 8);
478 1.6.6.2 jmcneill ri->ri_caps = WSSCREEN_WSCOLORS;
479 1.6.6.2 jmcneill
480 1.6.6.2 jmcneill rasops_reconfig(ri, sc->sc_height / ri->ri_font->fontheight,
481 1.6.6.2 jmcneill sc->sc_width / ri->ri_font->fontwidth);
482 1.6.6.2 jmcneill
483 1.6.6.2 jmcneill ri->ri_hw = scr;
484 1.6.6.2 jmcneill ri->ri_ops.copyrows = agten_copyrows;
485 1.6.6.2 jmcneill ri->ri_ops.eraserows = agten_eraserows;
486 1.6.6.2 jmcneill ri->ri_ops.copycols = agten_copycols;
487 1.6.6.2 jmcneill ri->ri_ops.erasecols = agten_erasecols;
488 1.6.6.2 jmcneill
489 1.6.6.2 jmcneill }
490 1.6.6.2 jmcneill
491 1.6.6.2 jmcneill static int
492 1.6.6.2 jmcneill agten_putcmap(struct agten_softc *sc, struct wsdisplay_cmap *cm)
493 1.6.6.2 jmcneill {
494 1.6.6.2 jmcneill u_int index = cm->index;
495 1.6.6.2 jmcneill u_int count = cm->count;
496 1.6.6.2 jmcneill int i, error;
497 1.6.6.2 jmcneill u_char rbuf[256], gbuf[256], bbuf[256];
498 1.6.6.2 jmcneill u_char *r, *g, *b;
499 1.6.6.2 jmcneill
500 1.6.6.2 jmcneill if (cm->index >= 256 || cm->count > 256 ||
501 1.6.6.2 jmcneill (cm->index + cm->count) > 256)
502 1.6.6.2 jmcneill return EINVAL;
503 1.6.6.2 jmcneill error = copyin(cm->red, &rbuf[index], count);
504 1.6.6.2 jmcneill if (error)
505 1.6.6.2 jmcneill return error;
506 1.6.6.2 jmcneill error = copyin(cm->green, &gbuf[index], count);
507 1.6.6.2 jmcneill if (error)
508 1.6.6.2 jmcneill return error;
509 1.6.6.2 jmcneill error = copyin(cm->blue, &bbuf[index], count);
510 1.6.6.2 jmcneill if (error)
511 1.6.6.2 jmcneill return error;
512 1.6.6.2 jmcneill
513 1.6.6.2 jmcneill r = &rbuf[index];
514 1.6.6.2 jmcneill g = &gbuf[index];
515 1.6.6.2 jmcneill b = &bbuf[index];
516 1.6.6.2 jmcneill
517 1.6.6.2 jmcneill for (i = 0; i < count; i++) {
518 1.6.6.2 jmcneill agten_putpalreg(sc, index, *r, *g, *b);
519 1.6.6.2 jmcneill index++;
520 1.6.6.2 jmcneill r++, g++, b++;
521 1.6.6.2 jmcneill }
522 1.6.6.2 jmcneill return 0;
523 1.6.6.2 jmcneill }
524 1.6.6.2 jmcneill
525 1.6.6.2 jmcneill static int
526 1.6.6.2 jmcneill agten_getcmap(struct agten_softc *sc, struct wsdisplay_cmap *cm)
527 1.6.6.2 jmcneill {
528 1.6.6.2 jmcneill u_int index = cm->index;
529 1.6.6.2 jmcneill u_int count = cm->count;
530 1.6.6.2 jmcneill int error, i;
531 1.6.6.2 jmcneill uint8_t red[256], green[256], blue[256];
532 1.6.6.2 jmcneill
533 1.6.6.2 jmcneill if (index >= 255 || count > 256 || index + count > 256)
534 1.6.6.2 jmcneill return EINVAL;
535 1.6.6.2 jmcneill
536 1.6.6.2 jmcneill i = index;
537 1.6.6.2 jmcneill while (i < (index + count)) {
538 1.6.6.2 jmcneill red[i] = sc->sc_cmap.cm_map[i][0];
539 1.6.6.2 jmcneill green[i] = sc->sc_cmap.cm_map[i][1];
540 1.6.6.2 jmcneill blue[i] = sc->sc_cmap.cm_map[i][2];
541 1.6.6.2 jmcneill i++;
542 1.6.6.2 jmcneill }
543 1.6.6.2 jmcneill error = copyout(&red[index], cm->red, count);
544 1.6.6.2 jmcneill if (error)
545 1.6.6.2 jmcneill return error;
546 1.6.6.2 jmcneill error = copyout(&green[index], cm->green, count);
547 1.6.6.2 jmcneill if (error)
548 1.6.6.2 jmcneill return error;
549 1.6.6.2 jmcneill error = copyout(&blue[index], cm->blue, count);
550 1.6.6.2 jmcneill if (error)
551 1.6.6.2 jmcneill return error;
552 1.6.6.2 jmcneill
553 1.6.6.2 jmcneill return 0;
554 1.6.6.2 jmcneill }
555 1.6.6.2 jmcneill
556 1.6.6.2 jmcneill static int
557 1.6.6.2 jmcneill agten_putpalreg(struct agten_softc *sc, uint8_t idx, uint8_t r, uint8_t g,
558 1.6.6.2 jmcneill uint8_t b)
559 1.6.6.2 jmcneill {
560 1.6.6.2 jmcneill
561 1.6.6.2 jmcneill sc->sc_cmap.cm_map[idx][0] = r;
562 1.6.6.2 jmcneill sc->sc_cmap.cm_map[idx][1] = g;
563 1.6.6.2 jmcneill sc->sc_cmap.cm_map[idx][2] = b;
564 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_CMAP_TABLE + idx);
565 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD_CMAP, r);
566 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD_CMAP, g);
567 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD_CMAP, b);
568 1.6.6.2 jmcneill return 0;
569 1.6.6.2 jmcneill }
570 1.6.6.2 jmcneill
571 1.6.6.2 jmcneill static void
572 1.6.6.2 jmcneill agten_init(struct agten_softc *sc)
573 1.6.6.2 jmcneill {
574 1.6.6.2 jmcneill int i, j;
575 1.6.6.2 jmcneill uint32_t src, srcw;
576 1.6.6.2 jmcneill volatile uint32_t junk;
577 1.6.6.2 jmcneill
578 1.6.6.2 jmcneill /* first we set up the colour map */
579 1.6.6.2 jmcneill j = 0;
580 1.6.6.2 jmcneill for (i = 0; i < 256; i++) {
581 1.6.6.2 jmcneill
582 1.6.6.2 jmcneill agten_putpalreg(sc, i, rasops_cmap[j], rasops_cmap[j + 1],
583 1.6.6.2 jmcneill rasops_cmap[j + 2]);
584 1.6.6.2 jmcneill j += 3;
585 1.6.6.2 jmcneill }
586 1.6.6.2 jmcneill
587 1.6.6.2 jmcneill /* then we set up a linear LUT for 24bit colour */
588 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_CMAP_TABLE + 256);
589 1.6.6.2 jmcneill for (i = 0; i < 256; i++) {
590 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD_CMAP, i);
591 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD_CMAP, i);
592 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD_CMAP, i);
593 1.6.6.2 jmcneill }
594 1.6.6.2 jmcneill
595 1.6.6.2 jmcneill /* and the linear gamma maps */
596 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_RED_GAMMA_TABLE);
597 1.6.6.2 jmcneill for (i = 0; i < 0x3ff; i+= 4)
598 1.6.6.2 jmcneill agten_write_dac_10(sc, IBM561_CMD_GAMMA, i);
599 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_GREEN_GAMMA_TABLE);
600 1.6.6.2 jmcneill for (i = 0; i < 0x3ff; i+= 4)
601 1.6.6.2 jmcneill agten_write_dac_10(sc, IBM561_CMD_GAMMA, i);
602 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_BLUE_GAMMA_TABLE);
603 1.6.6.2 jmcneill for (i = 0; i < 0x3ff; i+= 4)
604 1.6.6.2 jmcneill agten_write_dac_10(sc, IBM561_CMD_GAMMA, i);
605 1.6.6.2 jmcneill
606 1.6.6.2 jmcneill /* enable outouts, RGB mode */
607 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_CONFIG_REG3);
608 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD, 0x41);
609 1.6.6.2 jmcneill
610 1.6.6.2 jmcneill /* MUX 4:1 basic, 8bit overlay, 8bit WIDs */
611 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_CONFIG_REG1);
612 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD, 0x2c);
613 1.6.6.2 jmcneill
614 1.6.6.2 jmcneill /* use internal PLL, enable video output */
615 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_CONFIG_REG2);
616 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD, CR2_ENABLE_CLC | CR2_PLL_REF_SELECT |
617 1.6.6.2 jmcneill CR2_PIXEL_CLOCK_SELECT | CR2_ENABLE_RGB_OUTPUT);
618 1.6.6.2 jmcneill
619 1.6.6.2 jmcneill /* now set up some window attributes */
620 1.6.6.2 jmcneill
621 1.6.6.2 jmcneill /*
622 1.6.6.2 jmcneill * direct colour, 24 bit, transparency off, LUT from 0x100
623 1.6.6.2 jmcneill * we need to use direct colour and a linear LUT because for some
624 1.6.6.2 jmcneill * reason true color mode gives messed up colours
625 1.6.6.2 jmcneill */
626 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_FB_WINTYPE);
627 1.6.6.2 jmcneill agten_write_dac_10(sc, IBM561_CMD_FB_WAT, 0x134);
628 1.6.6.2 jmcneill
629 1.6.6.2 jmcneill /* use gamma LUTs, no crosshair, 0 is transparent */
630 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_AUXFB_WINTYPE);
631 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD_FB_WAT, 0x0);
632 1.6.6.2 jmcneill
633 1.6.6.2 jmcneill /* overlay is 8 bit, opaque */
634 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_OL_WINTYPE);
635 1.6.6.2 jmcneill agten_write_dac_10(sc, IBM561_CMD_FB_WAT, 0x00);
636 1.6.6.2 jmcneill
637 1.6.6.2 jmcneill /* now we fill the WID fb with zeroes */
638 1.6.6.2 jmcneill src = 0;
639 1.6.6.2 jmcneill srcw = sc->sc_width << 16 | sc->sc_height;
640 1.6.6.2 jmcneill bus_space_write_4(sc->sc_bustag, sc->sc_p9100_regh, FOREGROUND_COLOR,
641 1.6.6.2 jmcneill 0x0);
642 1.6.6.2 jmcneill bus_space_write_4(sc->sc_bustag, sc->sc_p9100_regh, BACKGROUND_COLOR,
643 1.6.6.2 jmcneill 0x0);
644 1.6.6.2 jmcneill bus_space_write_4(sc->sc_bustag, sc->sc_p9100_regh, RASTER_OP, ROP_PAT);
645 1.6.6.2 jmcneill bus_space_write_4(sc->sc_bustag, sc->sc_p9100_regh, COORD_INDEX, 0);
646 1.6.6.2 jmcneill bus_space_write_4(sc->sc_bustag, sc->sc_p9100_regh, RECT_RTW_XY, src);
647 1.6.6.2 jmcneill bus_space_write_4(sc->sc_bustag, sc->sc_p9100_regh, RECT_RTW_XY, srcw);
648 1.6.6.2 jmcneill junk = bus_space_read_4(sc->sc_bustag, sc->sc_p9100_regh, COMMAND_QUAD);
649 1.6.6.2 jmcneill
650 1.6.6.2 jmcneill /* initialize the cursor registers */
651 1.6.6.2 jmcneill
652 1.6.6.2 jmcneill /* initialize the Imagine 128 */
653 1.6.6.2 jmcneill i128_init(sc->sc_bustag, sc->sc_i128_regh, sc->sc_stride, 8);
654 1.6.6.2 jmcneill }
655 1.6.6.2 jmcneill
656 1.6.6.2 jmcneill static void
657 1.6.6.2 jmcneill agten_gfx(struct agten_softc *sc)
658 1.6.6.2 jmcneill {
659 1.6.6.2 jmcneill /* enable overlay transparency on colour 0x00 */
660 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_OL_WINTYPE);
661 1.6.6.2 jmcneill agten_write_dac_10(sc, IBM561_CMD_FB_WAT, 0x01);
662 1.6.6.2 jmcneill
663 1.6.6.2 jmcneill /* then blit the overlay full of 0x00 */
664 1.6.6.2 jmcneill i128_rectfill(sc->sc_bustag, sc->sc_i128_regh, 0, 0, sc->sc_width,
665 1.6.6.2 jmcneill sc->sc_height, 0);
666 1.6.6.2 jmcneill
667 1.6.6.2 jmcneill /* ... so we can see the 24bit framebuffer */
668 1.6.6.2 jmcneill }
669 1.6.6.2 jmcneill
670 1.6.6.2 jmcneill static void
671 1.6.6.2 jmcneill agten_set_video(struct agten_softc *sc, int flag)
672 1.6.6.2 jmcneill {
673 1.6.6.2 jmcneill uint8_t reg =
674 1.6.6.2 jmcneill CR2_ENABLE_CLC | CR2_PLL_REF_SELECT | CR2_PIXEL_CLOCK_SELECT;
675 1.6.6.2 jmcneill
676 1.6.6.2 jmcneill if (flag == sc->sc_video)
677 1.6.6.2 jmcneill return;
678 1.6.6.2 jmcneill
679 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_CONFIG_REG2);
680 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD, flag ? reg | CR2_ENABLE_RGB_OUTPUT :
681 1.6.6.2 jmcneill reg);
682 1.6.6.2 jmcneill
683 1.6.6.2 jmcneill sc->sc_video = flag;
684 1.6.6.2 jmcneill }
685 1.6.6.2 jmcneill
686 1.6.6.2 jmcneill static int
687 1.6.6.2 jmcneill agten_get_video(struct agten_softc *sc)
688 1.6.6.2 jmcneill {
689 1.6.6.2 jmcneill
690 1.6.6.2 jmcneill return sc->sc_video;
691 1.6.6.2 jmcneill }
692 1.6.6.2 jmcneill
693 1.6.6.2 jmcneill static void
694 1.6.6.2 jmcneill agten_copycols(void *cookie, int row, int srccol, int dstcol, int ncols)
695 1.6.6.2 jmcneill {
696 1.6.6.2 jmcneill struct rasops_info *ri = cookie;
697 1.6.6.2 jmcneill struct vcons_screen *scr = ri->ri_hw;
698 1.6.6.2 jmcneill struct agten_softc *sc = scr->scr_cookie;
699 1.6.6.2 jmcneill int32_t xs, xd, y, width, height;
700 1.6.6.2 jmcneill
701 1.6.6.2 jmcneill xs = ri->ri_xorigin + ri->ri_font->fontwidth * srccol;
702 1.6.6.2 jmcneill xd = ri->ri_xorigin + ri->ri_font->fontwidth * dstcol;
703 1.6.6.2 jmcneill y = ri->ri_yorigin + ri->ri_font->fontheight * row;
704 1.6.6.2 jmcneill width = ri->ri_font->fontwidth * ncols;
705 1.6.6.2 jmcneill height = ri->ri_font->fontheight;
706 1.6.6.2 jmcneill i128_bitblt(sc->sc_bustag, sc->sc_i128_regh, xs, y, xd, y, width,
707 1.6.6.2 jmcneill height, CR_COPY);
708 1.6.6.2 jmcneill }
709 1.6.6.2 jmcneill
710 1.6.6.2 jmcneill static void
711 1.6.6.2 jmcneill agten_erasecols(void *cookie, int row, int startcol, int ncols, long fillattr)
712 1.6.6.2 jmcneill {
713 1.6.6.2 jmcneill struct rasops_info *ri = cookie;
714 1.6.6.2 jmcneill struct vcons_screen *scr = ri->ri_hw;
715 1.6.6.2 jmcneill struct agten_softc *sc = scr->scr_cookie;
716 1.6.6.2 jmcneill int32_t x, y, width, height, bg;
717 1.6.6.2 jmcneill
718 1.6.6.2 jmcneill x = ri->ri_xorigin + ri->ri_font->fontwidth * startcol;
719 1.6.6.2 jmcneill y = ri->ri_yorigin + ri->ri_font->fontheight * row;
720 1.6.6.2 jmcneill width = ri->ri_font->fontwidth * ncols;
721 1.6.6.2 jmcneill height = ri->ri_font->fontheight;
722 1.6.6.2 jmcneill bg = (uint32_t)ri->ri_devcmap[(fillattr >> 16) & 0xff];
723 1.6.6.2 jmcneill i128_rectfill(sc->sc_bustag, sc->sc_i128_regh, x, y, width, height, bg);
724 1.6.6.2 jmcneill }
725 1.6.6.2 jmcneill
726 1.6.6.2 jmcneill static void
727 1.6.6.2 jmcneill agten_copyrows(void *cookie, int srcrow, int dstrow, int nrows)
728 1.6.6.2 jmcneill {
729 1.6.6.2 jmcneill struct rasops_info *ri = cookie;
730 1.6.6.2 jmcneill struct vcons_screen *scr = ri->ri_hw;
731 1.6.6.2 jmcneill struct agten_softc *sc = scr->scr_cookie;
732 1.6.6.2 jmcneill int32_t x, ys, yd, width, height;
733 1.6.6.2 jmcneill
734 1.6.6.2 jmcneill x = ri->ri_xorigin;
735 1.6.6.2 jmcneill ys = ri->ri_yorigin + ri->ri_font->fontheight * srcrow;
736 1.6.6.2 jmcneill yd = ri->ri_yorigin + ri->ri_font->fontheight * dstrow;
737 1.6.6.2 jmcneill width = ri->ri_emuwidth;
738 1.6.6.2 jmcneill height = ri->ri_font->fontheight * nrows;
739 1.6.6.2 jmcneill i128_bitblt(sc->sc_bustag, sc->sc_i128_regh, x, ys, x, yd, width,
740 1.6.6.2 jmcneill height, CR_COPY);
741 1.6.6.2 jmcneill }
742 1.6.6.2 jmcneill
743 1.6.6.2 jmcneill static void
744 1.6.6.2 jmcneill agten_eraserows(void *cookie, int row, int nrows, long fillattr)
745 1.6.6.2 jmcneill {
746 1.6.6.2 jmcneill struct rasops_info *ri = cookie;
747 1.6.6.2 jmcneill struct vcons_screen *scr = ri->ri_hw;
748 1.6.6.2 jmcneill struct agten_softc *sc = scr->scr_cookie;
749 1.6.6.2 jmcneill int32_t x, y, width, height, bg;
750 1.6.6.2 jmcneill
751 1.6.6.2 jmcneill if ((row == 0) && (nrows == ri->ri_rows)) {
752 1.6.6.2 jmcneill x = y = 0;
753 1.6.6.2 jmcneill width = ri->ri_width;
754 1.6.6.2 jmcneill height = ri->ri_height;
755 1.6.6.2 jmcneill } else {
756 1.6.6.2 jmcneill x = ri->ri_xorigin;
757 1.6.6.2 jmcneill y = ri->ri_yorigin + ri->ri_font->fontheight * row;
758 1.6.6.2 jmcneill width = ri->ri_emuwidth;
759 1.6.6.2 jmcneill height = ri->ri_font->fontheight * nrows;
760 1.6.6.2 jmcneill }
761 1.6.6.2 jmcneill bg = (uint32_t)ri->ri_devcmap[(fillattr >> 16) & 0xff];
762 1.6.6.2 jmcneill i128_rectfill(sc->sc_bustag, sc->sc_i128_regh, x, y, width, height, bg);
763 1.6.6.2 jmcneill }
764 1.6.6.2 jmcneill
765 1.6.6.2 jmcneill static void
766 1.6.6.2 jmcneill agten_move_cursor(struct agten_softc *sc, int x, int y)
767 1.6.6.2 jmcneill {
768 1.6.6.2 jmcneill
769 1.6.6.2 jmcneill sc->sc_cursor_x = x;
770 1.6.6.2 jmcneill sc->sc_cursor_y = y;
771 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_CURSOR_X_REG);
772 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD, x & 0xff);
773 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD, (x >> 8) & 0xff);
774 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD, y & 0xff);
775 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD, (y >> 8) & 0xff);
776 1.6.6.2 jmcneill }
777 1.6.6.2 jmcneill
778 1.6.6.2 jmcneill static int
779 1.6.6.2 jmcneill agten_do_cursor(struct agten_softc *sc, struct wsdisplay_cursor *cur)
780 1.6.6.2 jmcneill {
781 1.6.6.2 jmcneill if (cur->which & WSDISPLAY_CURSOR_DOCUR) {
782 1.6.6.2 jmcneill
783 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_CURS_CNTL_REG);
784 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD, cur->enable ?
785 1.6.6.2 jmcneill CURS_ENABLE : 0);
786 1.6.6.2 jmcneill }
787 1.6.6.2 jmcneill if (cur->which & WSDISPLAY_CURSOR_DOHOT) {
788 1.6.6.2 jmcneill
789 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_HOTSPOT_X_REG);
790 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD, cur->hot.x);
791 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD, cur->hot.y);
792 1.6.6.2 jmcneill }
793 1.6.6.2 jmcneill if (cur->which & WSDISPLAY_CURSOR_DOPOS) {
794 1.6.6.2 jmcneill
795 1.6.6.2 jmcneill agten_move_cursor(sc, cur->pos.x, cur->pos.y);
796 1.6.6.2 jmcneill }
797 1.6.6.2 jmcneill if (cur->which & WSDISPLAY_CURSOR_DOCMAP) {
798 1.6.6.2 jmcneill int i;
799 1.6.6.2 jmcneill
800 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_CURSOR_LUT + cur->cmap.index + 2);
801 1.6.6.2 jmcneill for (i = 0; i < cur->cmap.count; i++) {
802 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD_CMAP, cur->cmap.red[i]);
803 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD_CMAP, cur->cmap.green[i]);
804 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD_CMAP, cur->cmap.blue[i]);
805 1.6.6.2 jmcneill }
806 1.6.6.2 jmcneill }
807 1.6.6.2 jmcneill if (cur->which & WSDISPLAY_CURSOR_DOSHAPE) {
808 1.6.6.2 jmcneill int i;
809 1.6.6.2 jmcneill uint16_t tmp;
810 1.6.6.2 jmcneill
811 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_CURSOR_BITMAP);
812 1.6.6.2 jmcneill for (i = 0; i < 512; i++) {
813 1.6.6.2 jmcneill tmp = util_interleave(cur->mask[i], cur->image[i]);
814 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD, (tmp >> 8) & 0xff);
815 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD, tmp & 0xff);
816 1.6.6.2 jmcneill }
817 1.6.6.2 jmcneill }
818 1.6.6.2 jmcneill return 0;
819 1.6.6.2 jmcneill }
820 1.6.6.2 jmcneill
821 1.6.6.2 jmcneill static int
822 1.6.6.2 jmcneill agten_do_sun_cursor(struct agten_softc *sc, struct fbcursor *cur)
823 1.6.6.2 jmcneill {
824 1.6.6.2 jmcneill if (cur->set & FB_CUR_SETCUR) {
825 1.6.6.2 jmcneill
826 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_CURS_CNTL_REG);
827 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD, cur->enable ?
828 1.6.6.2 jmcneill CURS_ENABLE : 0);
829 1.6.6.2 jmcneill }
830 1.6.6.2 jmcneill if (cur->set & FB_CUR_SETHOT) {
831 1.6.6.2 jmcneill
832 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_HOTSPOT_X_REG);
833 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD, cur->hot.x);
834 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD, cur->hot.y);
835 1.6.6.2 jmcneill }
836 1.6.6.2 jmcneill if (cur->set & FB_CUR_SETPOS) {
837 1.6.6.2 jmcneill
838 1.6.6.2 jmcneill agten_move_cursor(sc, cur->pos.x, cur->pos.y);
839 1.6.6.2 jmcneill }
840 1.6.6.2 jmcneill if (cur->set & FB_CUR_SETCMAP) {
841 1.6.6.2 jmcneill int i;
842 1.6.6.2 jmcneill
843 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_CURSOR_LUT + cur->cmap.index + 2);
844 1.6.6.2 jmcneill for (i = 0; i < cur->cmap.count; i++) {
845 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD_CMAP, cur->cmap.red[i]);
846 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD_CMAP, cur->cmap.green[i]);
847 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD_CMAP, cur->cmap.blue[i]);
848 1.6.6.2 jmcneill }
849 1.6.6.2 jmcneill }
850 1.6.6.2 jmcneill if (cur->set & FB_CUR_SETSHAPE) {
851 1.6.6.2 jmcneill int i;
852 1.6.6.2 jmcneill uint16_t tmp;
853 1.6.6.2 jmcneill
854 1.6.6.2 jmcneill agten_write_idx(sc, IBM561_CURSOR_BITMAP);
855 1.6.6.2 jmcneill for (i = 0; i < 512; i++) {
856 1.6.6.2 jmcneill tmp = util_interleave_lin(cur->mask[i], cur->image[i]);
857 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD, (tmp >> 8) & 0xff);
858 1.6.6.2 jmcneill agten_write_dac(sc, IBM561_CMD, tmp & 0xff);
859 1.6.6.2 jmcneill }
860 1.6.6.2 jmcneill }
861 1.6.6.2 jmcneill return 0;
862 1.6.6.2 jmcneill }
863 1.6.6.2 jmcneill
864 1.6.6.2 jmcneill uint16_t
865 1.6.6.2 jmcneill util_interleave(uint8_t b1, uint8_t b2)
866 1.6.6.2 jmcneill {
867 1.6.6.2 jmcneill int i;
868 1.6.6.2 jmcneill uint16_t ret = 0;
869 1.6.6.2 jmcneill uint16_t mask = 0x8000;
870 1.6.6.2 jmcneill uint8_t mask8 = 0x01;
871 1.6.6.2 jmcneill
872 1.6.6.2 jmcneill for (i = 0; i < 8; i++) {
873 1.6.6.2 jmcneill if (b1 & mask8)
874 1.6.6.2 jmcneill ret |= mask;
875 1.6.6.2 jmcneill mask = mask >> 1;
876 1.6.6.2 jmcneill if (b2 & mask8)
877 1.6.6.2 jmcneill ret |= mask;
878 1.6.6.2 jmcneill mask = mask >> 1;
879 1.6.6.2 jmcneill mask8 = mask8 << 1;
880 1.6.6.2 jmcneill }
881 1.6.6.2 jmcneill return ret;
882 1.6.6.2 jmcneill }
883 1.6.6.2 jmcneill
884 1.6.6.2 jmcneill uint16_t
885 1.6.6.2 jmcneill util_interleave_lin(uint8_t b1, uint8_t b2)
886 1.6.6.2 jmcneill {
887 1.6.6.2 jmcneill int i;
888 1.6.6.2 jmcneill uint16_t ret = 0;
889 1.6.6.2 jmcneill uint16_t mask = 0x8000;
890 1.6.6.2 jmcneill uint8_t mask8 = 0x80;
891 1.6.6.2 jmcneill
892 1.6.6.2 jmcneill for (i = 0; i < 8; i++) {
893 1.6.6.2 jmcneill if (b1 & mask8)
894 1.6.6.2 jmcneill ret |= mask;
895 1.6.6.2 jmcneill mask = mask >> 1;
896 1.6.6.2 jmcneill if (b2 & mask8)
897 1.6.6.2 jmcneill ret |= mask;
898 1.6.6.2 jmcneill mask = mask >> 1;
899 1.6.6.2 jmcneill mask8 = mask8 >> 1;
900 1.6.6.2 jmcneill }
901 1.6.6.2 jmcneill return ret;
902 1.6.6.2 jmcneill }
903 1.6.6.2 jmcneill
904 1.6.6.2 jmcneill /* and now the /dev/fb* stuff */
905 1.6.6.2 jmcneill static void
906 1.6.6.2 jmcneill agten_fb_unblank(struct device *dev)
907 1.6.6.2 jmcneill {
908 1.6.6.2 jmcneill struct agten_softc *sc = (void *)dev;
909 1.6.6.2 jmcneill
910 1.6.6.2 jmcneill agten_init(sc);
911 1.6.6.2 jmcneill agten_set_video(sc, 1);
912 1.6.6.2 jmcneill }
913 1.6.6.2 jmcneill
914 1.6.6.2 jmcneill static int
915 1.6.6.2 jmcneill agten_fb_open(dev_t dev, int flags, int mode, struct lwp *l)
916 1.6.6.2 jmcneill {
917 1.6.6.2 jmcneill struct agten_softc *sc = agten_cd.cd_devs[minor(dev)];
918 1.6.6.2 jmcneill int unit = minor(dev);
919 1.6.6.2 jmcneill
920 1.6.6.2 jmcneill if (unit >= agten_cd.cd_ndevs || agten_cd.cd_devs[unit] == NULL)
921 1.6.6.2 jmcneill return (ENXIO);
922 1.6.6.2 jmcneill if (sc->sc_fb_is_open)
923 1.6.6.2 jmcneill return 0;
924 1.6.6.2 jmcneill
925 1.6.6.2 jmcneill sc->sc_fb_is_open++;
926 1.6.6.2 jmcneill agten_gfx(sc);
927 1.6.6.2 jmcneill
928 1.6.6.2 jmcneill return (0);
929 1.6.6.2 jmcneill }
930 1.6.6.2 jmcneill
931 1.6.6.2 jmcneill static int
932 1.6.6.2 jmcneill agten_fb_close(dev_t dev, int flags, int mode, struct lwp *l)
933 1.6.6.2 jmcneill {
934 1.6.6.2 jmcneill struct agten_softc *sc = agten_cd.cd_devs[minor(dev)];
935 1.6.6.2 jmcneill
936 1.6.6.2 jmcneill sc->sc_fb_is_open--;
937 1.6.6.2 jmcneill if (sc->sc_fb_is_open < 0)
938 1.6.6.2 jmcneill sc->sc_fb_is_open = 0;
939 1.6.6.2 jmcneill
940 1.6.6.2 jmcneill if (sc->sc_fb_is_open == 0) {
941 1.6.6.2 jmcneill agten_init(sc);
942 1.6.6.2 jmcneill vcons_redraw_screen(sc->vd.active);
943 1.6.6.2 jmcneill }
944 1.6.6.2 jmcneill
945 1.6.6.2 jmcneill return (0);
946 1.6.6.2 jmcneill }
947 1.6.6.2 jmcneill
948 1.6.6.2 jmcneill static int
949 1.6.6.2 jmcneill agten_fb_ioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *l)
950 1.6.6.2 jmcneill {
951 1.6.6.2 jmcneill struct agten_softc *sc = agten_cd.cd_devs[minor(dev)];
952 1.6.6.2 jmcneill struct fbgattr *fba;
953 1.6.6.2 jmcneill int error;
954 1.6.6.2 jmcneill
955 1.6.6.2 jmcneill switch (cmd) {
956 1.6.6.2 jmcneill
957 1.6.6.2 jmcneill case FBIOGTYPE:
958 1.6.6.2 jmcneill *(struct fbtype *)data = sc->sc_fb.fb_type;
959 1.6.6.2 jmcneill break;
960 1.6.6.2 jmcneill
961 1.6.6.2 jmcneill case FBIOGATTR:
962 1.6.6.2 jmcneill fba = (struct fbgattr *)data;
963 1.6.6.2 jmcneill fba->real_type = sc->sc_fb.fb_type.fb_type;
964 1.6.6.2 jmcneill fba->owner = 0; /* XXX ??? */
965 1.6.6.2 jmcneill fba->fbtype = sc->sc_fb.fb_type;
966 1.6.6.2 jmcneill fba->sattr.flags = 0;
967 1.6.6.2 jmcneill fba->sattr.emu_type = sc->sc_fb.fb_type.fb_type;
968 1.6.6.2 jmcneill fba->sattr.dev_specific[0] = -1;
969 1.6.6.2 jmcneill fba->emu_types[0] = sc->sc_fb.fb_type.fb_type;
970 1.6.6.2 jmcneill fba->emu_types[1] = -1;
971 1.6.6.2 jmcneill break;
972 1.6.6.2 jmcneill
973 1.6.6.2 jmcneill case FBIOGETCMAP:
974 1.6.6.2 jmcneill #define p ((struct fbcmap *)data)
975 1.6.6.2 jmcneill return (bt_getcmap(p, &sc->sc_cmap, 256, 1));
976 1.6.6.2 jmcneill
977 1.6.6.2 jmcneill case FBIOPUTCMAP:
978 1.6.6.2 jmcneill /* copy to software map */
979 1.6.6.2 jmcneill error = bt_putcmap(p, &sc->sc_cmap, 256, 1);
980 1.6.6.2 jmcneill if (error)
981 1.6.6.2 jmcneill return (error);
982 1.6.6.2 jmcneill /* now blast them into the chip */
983 1.6.6.2 jmcneill /* don't bother - we're 24bit */
984 1.6.6.2 jmcneill #undef p
985 1.6.6.2 jmcneill break;
986 1.6.6.2 jmcneill
987 1.6.6.2 jmcneill case FBIOGVIDEO:
988 1.6.6.2 jmcneill *(int *)data = agten_get_video(sc);
989 1.6.6.2 jmcneill break;
990 1.6.6.2 jmcneill
991 1.6.6.2 jmcneill case FBIOSVIDEO:
992 1.6.6.2 jmcneill agten_set_video(sc, *(int *)data);
993 1.6.6.2 jmcneill break;
994 1.6.6.2 jmcneill
995 1.6.6.2 jmcneill /* these are for both FBIOSCURSOR and FBIOGCURSOR */
996 1.6.6.2 jmcneill #define p ((struct fbcursor *)data)
997 1.6.6.2 jmcneill #define pc (&sc->sc_cursor)
998 1.6.6.2 jmcneill
999 1.6.6.2 jmcneill case FBIOGCURSOR:
1000 1.6.6.2 jmcneill /* does anyone use this ioctl?! */
1001 1.6.6.2 jmcneill p->set = FB_CUR_SETALL; /* close enough, anyway */
1002 1.6.6.2 jmcneill p->enable = 1;
1003 1.6.6.2 jmcneill p->pos.x = sc->sc_cursor_x;
1004 1.6.6.2 jmcneill p->pos.y = sc->sc_cursor_y;
1005 1.6.6.2 jmcneill p->size.x = 64;
1006 1.6.6.2 jmcneill p->size.y = 64;
1007 1.6.6.2 jmcneill break;
1008 1.6.6.2 jmcneill
1009 1.6.6.2 jmcneill case FBIOSCURSOR:
1010 1.6.6.2 jmcneill agten_do_sun_cursor(sc, p);
1011 1.6.6.2 jmcneill break;
1012 1.6.6.2 jmcneill
1013 1.6.6.2 jmcneill #undef p
1014 1.6.6.2 jmcneill #undef cc
1015 1.6.6.2 jmcneill
1016 1.6.6.2 jmcneill case FBIOGCURPOS:
1017 1.6.6.2 jmcneill {
1018 1.6.6.2 jmcneill struct fbcurpos *cp = (struct fbcurpos *)data;
1019 1.6.6.2 jmcneill cp->x = sc->sc_cursor_x;
1020 1.6.6.2 jmcneill cp->y = sc->sc_cursor_y;
1021 1.6.6.2 jmcneill }
1022 1.6.6.2 jmcneill break;
1023 1.6.6.2 jmcneill
1024 1.6.6.2 jmcneill case FBIOSCURPOS:
1025 1.6.6.2 jmcneill {
1026 1.6.6.2 jmcneill struct fbcurpos *cp = (struct fbcurpos *)data;
1027 1.6.6.2 jmcneill agten_move_cursor(sc, cp->x, cp->y);
1028 1.6.6.2 jmcneill }
1029 1.6.6.2 jmcneill break;
1030 1.6.6.2 jmcneill
1031 1.6.6.2 jmcneill case FBIOGCURMAX:
1032 1.6.6.2 jmcneill /* max cursor size is 64x64 */
1033 1.6.6.2 jmcneill ((struct fbcurpos *)data)->x = 64;
1034 1.6.6.2 jmcneill ((struct fbcurpos *)data)->y = 64;
1035 1.6.6.2 jmcneill break;
1036 1.6.6.2 jmcneill
1037 1.6.6.2 jmcneill default:
1038 1.6.6.2 jmcneill return (ENOTTY);
1039 1.6.6.2 jmcneill }
1040 1.6.6.2 jmcneill return (0);
1041 1.6.6.2 jmcneill }
1042 1.6.6.2 jmcneill
1043 1.6.6.2 jmcneill static paddr_t
1044 1.6.6.2 jmcneill agten_fb_mmap(dev_t dev, off_t off, int prot)
1045 1.6.6.2 jmcneill {
1046 1.6.6.2 jmcneill struct agten_softc *sc = agten_cd.cd_devs[minor(dev)];
1047 1.6.6.2 jmcneill
1048 1.6.6.2 jmcneill /*
1049 1.6.6.2 jmcneill * mappings are subject to change
1050 1.6.6.2 jmcneill * for now we put the framebuffer at offset 0 and the GLint registers
1051 1.6.6.2 jmcneill * right after that. We may want to expose more register ranges and
1052 1.6.6.2 jmcneill * probably will want to map the 2nd framebuffer as well
1053 1.6.6.2 jmcneill */
1054 1.6.6.2 jmcneill
1055 1.6.6.2 jmcneill if (off < 0)
1056 1.6.6.2 jmcneill return EINVAL;
1057 1.6.6.2 jmcneill
1058 1.6.6.2 jmcneill if (off >= sc->sc_glint_fbsz + 0x10000)
1059 1.6.6.2 jmcneill return EINVAL;
1060 1.6.6.2 jmcneill
1061 1.6.6.2 jmcneill if (off < sc->sc_glint_fbsz) {
1062 1.6.6.2 jmcneill return (bus_space_mmap(sc->sc_bustag,
1063 1.6.6.2 jmcneill sc->sc_glint_fb,
1064 1.6.6.2 jmcneill off,
1065 1.6.6.2 jmcneill prot,
1066 1.6.6.2 jmcneill BUS_SPACE_MAP_LINEAR));
1067 1.6.6.2 jmcneill }
1068 1.6.6.2 jmcneill
1069 1.6.6.2 jmcneill off -= sc->sc_glint_fbsz;
1070 1.6.6.2 jmcneill if (off < 0x10000) {
1071 1.6.6.2 jmcneill return (bus_space_mmap(sc->sc_bustag,
1072 1.6.6.2 jmcneill sc->sc_glint_regs,
1073 1.6.6.2 jmcneill off,
1074 1.6.6.2 jmcneill prot,
1075 1.6.6.2 jmcneill BUS_SPACE_MAP_LINEAR));
1076 1.6.6.2 jmcneill }
1077 1.6.6.2 jmcneill return EINVAL;
1078 1.6.6.2 jmcneill }
1079