lcg.c revision 1.1 1 1.1 jklos /* $NetBSD: lcg.c,v 1.1 2014/12/16 11:34:17 jklos Exp $ */
2 1.1 jklos /*
3 1.1 jklos * LCG accelerated framebuffer driver
4 1.1 jklos * Copyright (c) 2003, 2004 Blaz Antonic
5 1.1 jklos * All rights reserved.
6 1.1 jklos *
7 1.1 jklos * Redistribution and use in source and binary forms, with or without
8 1.1 jklos * modification, are permitted provided that the following conditions
9 1.1 jklos * are met:
10 1.1 jklos * 1. Redistributions of source code must retain the above copyright
11 1.1 jklos * notice, this list of conditions and the following disclaimer.
12 1.1 jklos * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 jklos * notice, this list of conditions and the following disclaimer in the
14 1.1 jklos * documentation and/or other materials provided with the distribution.
15 1.1 jklos * 3. All advertising materials mentioning features or use of this software
16 1.1 jklos * must display the abovementioned copyrights
17 1.1 jklos * 4. The name of the author may not be used to endorse or promote products
18 1.1 jklos * derived from this software without specific prior written permission
19 1.1 jklos *
20 1.1 jklos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 1.1 jklos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 1.1 jklos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 1.1 jklos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 1.1 jklos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 1.1 jklos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 1.1 jklos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 1.1 jklos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 1.1 jklos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 1.1 jklos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.1 jklos */
31 1.1 jklos /*
32 1.1 jklos * Resurrection and dumb framebuffer mode by Bjrn Johannesson
33 1.1 jklos * rherdware (at) yahoo.com in December 2014
34 1.1 jklos */
35 1.1 jklos
36 1.1 jklos #include <sys/cdefs.h>
37 1.1 jklos __KERNEL_RCSID(0, "$NetBSD: lcg.c,v 1.1 2014/12/16 11:34:17 jklos Exp $");
38 1.1 jklos
39 1.1 jklos #define LCG_NO_ACCEL
40 1.1 jklos
41 1.1 jklos #include <sys/param.h>
42 1.1 jklos #include <sys/device.h>
43 1.1 jklos #include <sys/systm.h>
44 1.1 jklos #include <sys/callout.h>
45 1.1 jklos #include <sys/time.h>
46 1.1 jklos #include <sys/malloc.h>
47 1.1 jklos #include <sys/conf.h>
48 1.1 jklos #include <sys/kernel.h>
49 1.1 jklos #include <sys/systm.h>
50 1.1 jklos
51 1.1 jklos #include <machine/vsbus.h>
52 1.1 jklos #include <machine/sid.h>
53 1.1 jklos #include <machine/cpu.h>
54 1.1 jklos #include <machine/lcgreg.h>
55 1.1 jklos
56 1.1 jklos #include <dev/cons.h>
57 1.1 jklos
58 1.1 jklos #include <dev/dec/dzreg.h>
59 1.1 jklos #include <dev/dec/dzvar.h>
60 1.1 jklos #include <dev/dec/dzkbdvar.h>
61 1.1 jklos
62 1.1 jklos #include <dev/wscons/wsdisplayvar.h>
63 1.1 jklos #include <dev/wscons/wsconsio.h>
64 1.1 jklos #include <dev/wscons/wscons_callbacks.h>
65 1.1 jklos #include <dev/wsfont/wsfont.h>
66 1.1 jklos
67 1.1 jklos #include "machine/scb.h"
68 1.1 jklos
69 1.1 jklos #include "dzkbd.h"
70 1.1 jklos
71 1.1 jklos /* Screen hardware defs */
72 1.1 jklos
73 1.1 jklos #define LCG_FB_ADDR 0x21801000 /* Frame buffer */
74 1.1 jklos
75 1.1 jklos /* FIFO defines */
76 1.1 jklos #define LCG_FIFO_SIZE 0x10000 /* 64 KB */
77 1.1 jklos #define LCG_FIFO_WIN_ADDR 0x20180000
78 1.1 jklos #define LCG_FIFO_WIN_SIZE VAX_NBPG
79 1.1 jklos #define LCG_FIFO_ALIGN 0x10000
80 1.1 jklos
81 1.1 jklos /* font rendering defines */
82 1.1 jklos #define LCG_FONT_ADDR (LCG_FB_ADDR + lcg_fb_size)
83 1.1 jklos #define LCG_FONT_STORAGE_SIZE 0x40000 /* 16 KB, enough to accomodate 16x32 font bitmaps */
84 1.1 jklos
85 1.1 jklos /* register space defines */
86 1.1 jklos #define LCG_REG_ADDR 0x20100000 /* LCG registers */
87 1.1 jklos #define LCG_REG_SIZE 0x4000 /* 16384 bytes */
88 1.1 jklos #define LCG_REG(reg) regaddr[(reg / 4)]
89 1.1 jklos
90 1.1 jklos /* LUT defines */
91 1.1 jklos #define LCG_LUT_ADDR 0x21800800 /* LUT right before onscreen FB */
92 1.1 jklos #define LCG_LUT_OFFSET 0x00000800
93 1.1 jklos #define LCG_LUT_SIZE 0x800 /* 2048 bytes */
94 1.1 jklos
95 1.1 jklos #define LCG_BG_COLOR WSCOL_BLACK
96 1.1 jklos #define LCG_FG_COLOR WSCOL_WHITE
97 1.1 jklos
98 1.1 jklos #define LCG_CONFIG 0x200f0010 /* LCG model information */
99 1.1 jklos
100 1.1 jklos /* implement sanity checks at certain points to ensure safer operation */
101 1.1 jklos #define LCG_SAFE
102 1.1 jklos //#define LCG_DEBUG
103 1.1 jklos
104 1.1 jklos static int lcg_match(struct device *, struct cfdata *, void *);
105 1.1 jklos static void lcg_attach(struct device *, struct device *, void *);
106 1.1 jklos
107 1.1 jklos struct lcg_softc {
108 1.1 jklos struct device ss_dev;
109 1.1 jklos bus_dmamap_t sc_dm;
110 1.1 jklos };
111 1.1 jklos
112 1.1 jklos CFATTACH_DECL_NEW(lcg, sizeof(struct lcg_softc),
113 1.1 jklos lcg_match, lcg_attach, NULL, NULL);
114 1.1 jklos
115 1.1 jklos static void lcg_cursor(void *, int, int, int);
116 1.1 jklos static int lcg_mapchar(void *, int, unsigned int *);
117 1.1 jklos static void lcg_putchar(void *, int, int, u_int, long);
118 1.1 jklos static void lcg_copycols(void *, int, int, int,int);
119 1.1 jklos static void lcg_erasecols(void *, int, int, int, long);
120 1.1 jklos static void lcg_copyrows(void *, int, int, int);
121 1.1 jklos static void lcg_eraserows(void *, int, int, long);
122 1.1 jklos static int lcg_allocattr(void *, int, int, int, long *);
123 1.1 jklos static int lcg_get_cmap(struct wsdisplay_cmap *);
124 1.1 jklos static int lcg_set_cmap(struct wsdisplay_cmap *);
125 1.1 jklos static void lcg_init_common(struct device *, struct vsbus_attach_args *);
126 1.1 jklos
127 1.1 jklos const struct wsdisplay_emulops lcg_emulops = {
128 1.1 jklos lcg_cursor,
129 1.1 jklos lcg_mapchar,
130 1.1 jklos lcg_putchar,
131 1.1 jklos lcg_copycols,
132 1.1 jklos lcg_erasecols,
133 1.1 jklos lcg_copyrows,
134 1.1 jklos lcg_eraserows,
135 1.1 jklos lcg_allocattr
136 1.1 jklos };
137 1.1 jklos
138 1.1 jklos static char lcg_stdscreen_name[10] = "160x68";
139 1.1 jklos struct wsscreen_descr lcg_stdscreen = {
140 1.1 jklos lcg_stdscreen_name, 160, 68, /* dynamically set */
141 1.1 jklos &lcg_emulops,
142 1.1 jklos 8, 15, /* dynamically set */
143 1.1 jklos WSSCREEN_UNDERLINE|WSSCREEN_REVERSE|WSSCREEN_WSCOLORS,
144 1.1 jklos };
145 1.1 jklos
146 1.1 jklos const struct wsscreen_descr *_lcg_scrlist[] = {
147 1.1 jklos &lcg_stdscreen,
148 1.1 jklos };
149 1.1 jklos
150 1.1 jklos const struct wsscreen_list lcg_screenlist = {
151 1.1 jklos sizeof(_lcg_scrlist) / sizeof(struct wsscreen_descr *),
152 1.1 jklos _lcg_scrlist,
153 1.1 jklos };
154 1.1 jklos
155 1.1 jklos static char *lcgaddr;
156 1.1 jklos static char *lutaddr;
157 1.1 jklos static volatile long *regaddr;
158 1.1 jklos static volatile long *fifoaddr;
159 1.1 jklos #ifndef LCG_NO_ACCEL
160 1.1 jklos static char *fontaddr;
161 1.1 jklos #endif
162 1.1 jklos
163 1.1 jklos static int lcg_xsize;
164 1.1 jklos static int lcg_ysize;
165 1.1 jklos static int lcg_depth;
166 1.1 jklos static int lcg_cols;
167 1.1 jklos static int lcg_rows;
168 1.1 jklos static int lcg_onerow;
169 1.1 jklos static int lcg_fb_size;
170 1.1 jklos static int lcg_glyph_size; /* bitmap size in bits */
171 1.1 jklos
172 1.1 jklos static char *cursor;
173 1.1 jklos
174 1.1 jklos static int cur_on;
175 1.1 jklos
176 1.1 jklos static int cur_fg, cur_bg;
177 1.1 jklos
178 1.1 jklos
179 1.1 jklos /* Our current hardware colormap */
180 1.1 jklos static struct hwcmap256 {
181 1.1 jklos #define CMAP_SIZE 256 /* 256 R/G/B entries */
182 1.1 jklos u_int8_t r[CMAP_SIZE];
183 1.1 jklos u_int8_t g[CMAP_SIZE];
184 1.1 jklos u_int8_t b[CMAP_SIZE];
185 1.1 jklos } lcg_cmap;
186 1.1 jklos
187 1.1 jklos /* The default colormap */
188 1.1 jklos static struct {
189 1.1 jklos u_int8_t r[8];
190 1.1 jklos u_int8_t g[8];
191 1.1 jklos u_int8_t b[8];
192 1.1 jklos } lcg_default_cmap = {
193 1.1 jklos { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff },
194 1.1 jklos { 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0xff, 0xff },
195 1.1 jklos { 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff }
196 1.1 jklos };
197 1.1 jklos
198 1.1 jklos struct wsdisplay_font lcg_font;
199 1.1 jklos static u_char *qf;
200 1.1 jklos static u_short *qf2;
201 1.1 jklos
202 1.1 jklos #define QCHAR(c) (c < lcg_font.firstchar ? 0 : \
203 1.1 jklos (c >= (lcg_font.firstchar + lcg_font.numchars) ? 0 : c - lcg_font.firstchar))
204 1.1 jklos #define QFONT(c,line) ((lcg_font.stride == 2 ? \
205 1.1 jklos qf2[QCHAR(c) * lcg_font.fontheight + line] : \
206 1.1 jklos qf[QCHAR(c) * lcg_font.fontheight + line]))
207 1.1 jklos #define LCG_ADDR(row, col, line, dot) \
208 1.1 jklos lcgaddr[((col) * lcg_font.fontwidth) + ((row) * lcg_font.fontheight * lcg_xsize) + \
209 1.1 jklos (line) * lcg_xsize + dot]
210 1.1 jklos
211 1.1 jklos
212 1.1 jklos static int lcg_ioctl(void *, void *, u_long, void *, int, struct lwp *);
213 1.1 jklos static paddr_t lcg_mmap(void *, void *, off_t, int);
214 1.1 jklos static int lcg_alloc_screen(void *, const struct wsscreen_descr *,
215 1.1 jklos void **, int *, int *, long *);
216 1.1 jklos static void lcg_free_screen(void *, void *);
217 1.1 jklos static int lcg_show_screen(void *, void *, int,
218 1.1 jklos void (*) (void *, int, int), void *);
219 1.1 jklos static void lcg_crsr_blink(void *);
220 1.1 jklos
221 1.1 jklos /* LCG HW accel functions */
222 1.1 jklos #ifndef LCG_NO_ACCEL
223 1.1 jklos static void fifo_put(long data);
224 1.1 jklos static int fifo_fill(int iterations);
225 1.1 jklos static u_char fifo_counter = 0;
226 1.1 jklos
227 1.1 jklos static void blkcpy(long source, long dest, int xdim, int ydim);
228 1.1 jklos static void blkset(long dest, int xdim, int ydim, char color);
229 1.1 jklos static void renderchar(long source, long dest, int xdim, int ydim, char fg, char bg);
230 1.1 jklos #endif /* LCG_NO_ACCEL */
231 1.1 jklos
232 1.1 jklos const struct wsdisplay_accessops lcg_accessops = {
233 1.1 jklos lcg_ioctl,
234 1.1 jklos lcg_mmap,
235 1.1 jklos lcg_alloc_screen,
236 1.1 jklos lcg_free_screen,
237 1.1 jklos lcg_show_screen,
238 1.1 jklos 0 /* load_font */
239 1.1 jklos };
240 1.1 jklos
241 1.1 jklos /* TODO allocate ss_image dynamically for consoles beyond first one */
242 1.1 jklos struct lcg_screen {
243 1.1 jklos int ss_curx;
244 1.1 jklos int ss_cury;
245 1.1 jklos int ss_cur_fg;
246 1.1 jklos int ss_cur_bg;
247 1.1 jklos struct {
248 1.1 jklos u_char data; /* Image character */
249 1.1 jklos u_char attr; /* Attribute: 80/70/08/07 */
250 1.1 jklos } ss_image[160 * 128]; /* allow for maximum possible cell matrix */
251 1.1 jklos };
252 1.1 jklos #define LCG_ATTR_UNDERLINE 0x80
253 1.1 jklos #define LCG_BG_MASK 0x70
254 1.1 jklos #define LCG_ATTR_REVERSE 0x08
255 1.1 jklos #define LCG_FG_MASK 0x07
256 1.1 jklos
257 1.1 jklos static struct lcg_screen lcg_conscreen;
258 1.1 jklos static struct lcg_screen *curscr;
259 1.1 jklos static struct lcg_screen *savescr;
260 1.1 jklos
261 1.1 jklos static callout_t lcg_cursor_ch;
262 1.1 jklos
263 1.1 jklos #ifndef LCG_NO_ACCEL
264 1.1 jklos void fifo_put(long data)
265 1.1 jklos {
266 1.1 jklos fifo_counter &= 0x3;
267 1.1 jklos fifoaddr[fifo_counter] = data;
268 1.1 jklos fifo_counter++;
269 1.1 jklos }
270 1.1 jklos
271 1.1 jklos int fifo_fill(int iterations)
272 1.1 jklos {
273 1.1 jklos long status;
274 1.1 jklos int counter = 0;;
275 1.1 jklos
276 1.1 jklos while (fifo_counter % 4)
277 1.1 jklos fifo_put(0);
278 1.1 jklos
279 1.1 jklos #ifdef LCG_SAFE
280 1.1 jklos status = LCG_REG(LCG_REG_GRAPHICS_SUB_STATUS);
281 1.1 jklos while ((counter < iterations) && ((status & 0x80000000) == 0x80000000)) {
282 1.1 jklos delay(1000);
283 1.1 jklos status = LCG_REG(LCG_REG_GRAPHICS_SUB_STATUS);
284 1.1 jklos counter++;
285 1.1 jklos }
286 1.1 jklos #endif
287 1.1 jklos
288 1.1 jklos if (counter == 0)
289 1.1 jklos return 0;
290 1.1 jklos else
291 1.1 jklos return 1;
292 1.1 jklos }
293 1.1 jklos
294 1.1 jklos void blkcpy(long source, long dest, int xdim, int ydim)
295 1.1 jklos {
296 1.1 jklos int err;
297 1.1 jklos
298 1.1 jklos #ifdef LCG_SAFE
299 1.1 jklos if ((source < LCG_FB_ADDR) || (source > LCG_FB_ADDR + lcg_fb_size)) {
300 1.1 jklos printf("lcg: blkcpy: invalid source 0x%lx\n", source);
301 1.1 jklos return;
302 1.1 jklos }
303 1.1 jklos if ((dest < LCG_FB_ADDR) || (dest > LCG_FB_ADDR + lcg_fb_size)) {
304 1.1 jklos printf("lcg: blkcpy: invalid destination 0x%lx\n", dest);
305 1.1 jklos return;
306 1.1 jklos }
307 1.1 jklos #endif
308 1.1 jklos
309 1.1 jklos #ifdef LCG_SAFE
310 1.1 jklos fifo_put(0x0c010000 | (cur_fg & 0xff));
311 1.1 jklos #endif
312 1.1 jklos fifo_put(0x01020006);
313 1.1 jklos
314 1.1 jklos fifo_put(0x06800000);
315 1.1 jklos fifo_put(source);
316 1.1 jklos fifo_put(lcg_xsize);
317 1.1 jklos
318 1.1 jklos fifo_put(0x05800000);
319 1.1 jklos fifo_put(dest);
320 1.1 jklos fifo_put(lcg_xsize);
321 1.1 jklos
322 1.1 jklos fifo_put(0x03400000);
323 1.1 jklos fifo_put(0xff);
324 1.1 jklos
325 1.1 jklos fifo_put(0x02000003);
326 1.1 jklos
327 1.1 jklos #ifdef LCG_SAFE
328 1.1 jklos fifo_put(0x04c00000);
329 1.1 jklos fifo_put(0);
330 1.1 jklos fifo_put(lcg_xsize);
331 1.1 jklos fifo_put(lcg_fb_size - (dest - LCG_FB_ADDR));
332 1.1 jklos #endif
333 1.1 jklos
334 1.1 jklos fifo_put(0x09c00000);
335 1.1 jklos fifo_put(((ydim & 0xffff) << 16) | xdim);
336 1.1 jklos fifo_put(0);
337 1.1 jklos fifo_put(0);
338 1.1 jklos
339 1.1 jklos err = fifo_fill(200);
340 1.1 jklos if (err)
341 1.1 jklos printf("lcg: AG still busy after 200 msec\n");
342 1.1 jklos }
343 1.1 jklos
344 1.1 jklos void blkset(long dest, int xdim, int ydim, char color)
345 1.1 jklos {
346 1.1 jklos int err;
347 1.1 jklos
348 1.1 jklos #ifdef LCG_SAFE
349 1.1 jklos if ((dest < LCG_FB_ADDR) || (dest > LCG_FB_ADDR + lcg_fb_size)) {
350 1.1 jklos printf("lcg: blkset: invalid destination 0x%lx\n", dest);
351 1.1 jklos return;
352 1.1 jklos }
353 1.1 jklos #endif
354 1.1 jklos
355 1.1 jklos fifo_put(0x0c010000 | (color & 0xff));
356 1.1 jklos
357 1.1 jklos fifo_put(0x01000000);
358 1.1 jklos
359 1.1 jklos fifo_put(0x05800000);
360 1.1 jklos fifo_put(dest);
361 1.1 jklos fifo_put(lcg_xsize);
362 1.1 jklos
363 1.1 jklos fifo_put(0x03400000);
364 1.1 jklos fifo_put(0xff);
365 1.1 jklos
366 1.1 jklos fifo_put(0x02000003);
367 1.1 jklos
368 1.1 jklos #ifdef LCG_SAFE
369 1.1 jklos fifo_put(0x04c00000);
370 1.1 jklos fifo_put(0);
371 1.1 jklos fifo_put(lcg_xsize);
372 1.1 jklos fifo_put(lcg_fb_size - (dest - LCG_FB_ADDR));
373 1.1 jklos #endif
374 1.1 jklos
375 1.1 jklos fifo_put(0x09c00000);
376 1.1 jklos fifo_put(((ydim & 0xffff) << 16) | xdim);
377 1.1 jklos fifo_put(0);
378 1.1 jklos fifo_put(0);
379 1.1 jklos
380 1.1 jklos err = fifo_fill(200);
381 1.1 jklos if (err)
382 1.1 jklos printf("lcg: AG still busy after 200 msec\n");
383 1.1 jklos }
384 1.1 jklos
385 1.1 jklos void renderchar(long source, long dest, int xdim, int ydim, char fg, char bg)
386 1.1 jklos {
387 1.1 jklos int err;
388 1.1 jklos #ifdef LCG_SAFE
389 1.1 jklos if ((dest < LCG_FB_ADDR) || (dest > LCG_FB_ADDR + lcg_fb_size)) {
390 1.1 jklos printf("lcg: blkset: invalid destination 0x%lx\n", dest);
391 1.1 jklos return;
392 1.1 jklos }
393 1.1 jklos #endif
394 1.1 jklos
395 1.1 jklos fifo_put(0x0c050000 | (bg & 0xff));
396 1.1 jklos fifo_put(0x0c010000 | (fg & 0xff));
397 1.1 jklos
398 1.1 jklos fifo_put(0x01030008);
399 1.1 jklos
400 1.1 jklos fifo_put(0x06800000);
401 1.1 jklos fifo_put(source);
402 1.1 jklos //fifo_put(lcg_xsize);
403 1.1 jklos fifo_put(lcg_font.stride);
404 1.1 jklos
405 1.1 jklos fifo_put(0x05800000);
406 1.1 jklos fifo_put(dest);
407 1.1 jklos fifo_put(lcg_xsize);
408 1.1 jklos
409 1.1 jklos fifo_put(0x03400000);
410 1.1 jklos fifo_put(0xff);
411 1.1 jklos
412 1.1 jklos fifo_put(0x02000003);
413 1.1 jklos
414 1.1 jklos #ifdef LCG_SAFE
415 1.1 jklos fifo_put(0x04c00000);
416 1.1 jklos fifo_put(0);
417 1.1 jklos fifo_put(lcg_xsize);
418 1.1 jklos fifo_put(lcg_fb_size - (dest - LCG_FB_ADDR));
419 1.1 jklos #endif
420 1.1 jklos
421 1.1 jklos fifo_put(0x09c00000);
422 1.1 jklos fifo_put(((ydim & 0xffff) << 16) | (xdim & 0xffff));
423 1.1 jklos fifo_put(0);
424 1.1 jklos fifo_put(0);
425 1.1 jklos
426 1.1 jklos err = fifo_fill(200);
427 1.1 jklos if (err)
428 1.1 jklos printf("lcg: AG still busy after 200 msec\n");
429 1.1 jklos }
430 1.1 jklos #endif /* LCG_NO_ACCEL */
431 1.1 jklos
432 1.1 jklos int
433 1.1 jklos lcg_match(struct device *parent, struct cfdata *match, void *aux)
434 1.1 jklos {
435 1.1 jklos struct vsbus_softc *sc = device_private(parent);
436 1.1 jklos struct vsbus_attach_args *va = aux;
437 1.1 jklos char *ch = (char *)va->va_addr;
438 1.1 jklos
439 1.1 jklos if ((vax_boardtype != VAX_BTYP_46) && (vax_boardtype != VAX_BTYP_48))
440 1.1 jklos return 0;
441 1.1 jklos
442 1.1 jklos *ch = 1;
443 1.1 jklos if ((*ch & 1) == 0)
444 1.1 jklos return 0;
445 1.1 jklos *ch = 0;
446 1.1 jklos if ((*ch & 1) != 0)
447 1.1 jklos return 0;
448 1.1 jklos
449 1.1 jklos /* XXX use vertical interrupt? */
450 1.1 jklos sc->sc_mask = 0x04; /* XXX - should be generated */
451 1.1 jklos scb_fake(0x120, 0x15);
452 1.1 jklos return 20;
453 1.1 jklos }
454 1.1 jklos
455 1.1 jklos void
456 1.1 jklos lcg_attach(struct device *parent, struct device *self, void *aux)
457 1.1 jklos {
458 1.1 jklos struct vsbus_attach_args *va = aux;
459 1.1 jklos struct wsemuldisplaydev_attach_args aa;
460 1.1 jklos
461 1.1 jklos printf("\n");
462 1.1 jklos aa.console = lcgaddr != NULL;
463 1.1 jklos
464 1.1 jklos lcg_init_common(self, va);
465 1.1 jklos
466 1.1 jklos curscr = &lcg_conscreen;
467 1.1 jklos
468 1.1 jklos aa.scrdata = &lcg_screenlist;
469 1.1 jklos aa.accessops = &lcg_accessops;
470 1.1 jklos
471 1.1 jklos /* enable software cursor */
472 1.1 jklos callout_init(&lcg_cursor_ch, 0);
473 1.1 jklos callout_reset(&lcg_cursor_ch, hz / 2, lcg_crsr_blink, NULL);
474 1.1 jklos
475 1.1 jklos config_found(self, &aa, wsemuldisplaydevprint);
476 1.1 jklos }
477 1.1 jklos
478 1.1 jklos static void
479 1.1 jklos lcg_crsr_blink(void *arg)
480 1.1 jklos {
481 1.1 jklos int dot;
482 1.1 jklos
483 1.1 jklos if (cur_on && curscr != NULL)
484 1.1 jklos for (dot = 0; dot < lcg_font.fontwidth; dot++)
485 1.1 jklos cursor[dot] = ((cursor[dot] & 0x0f) == cur_fg) ? cur_bg : cur_fg;
486 1.1 jklos
487 1.1 jklos callout_reset(&lcg_cursor_ch, hz / 2, lcg_crsr_blink, NULL);
488 1.1 jklos }
489 1.1 jklos
490 1.1 jklos void
491 1.1 jklos lcg_cursor(void *id, int on, int row, int col)
492 1.1 jklos {
493 1.1 jklos struct lcg_screen *ss = id;
494 1.1 jklos int dot, attr;
495 1.1 jklos
496 1.1 jklos attr = ss->ss_image[row * lcg_cols + col].attr;
497 1.1 jklos if (ss == curscr) {
498 1.1 jklos if (cursor != NULL) {
499 1.1 jklos int ch = QFONT(ss->ss_image[ss->ss_cury * lcg_cols +
500 1.1 jklos ss->ss_curx].data, lcg_font.fontheight - 1);
501 1.1 jklos attr = ss->ss_image[ss->ss_cury * lcg_cols +
502 1.1 jklos ss->ss_curx].attr;
503 1.1 jklos
504 1.1 jklos if (attr & LCG_ATTR_REVERSE) {
505 1.1 jklos cur_bg = attr & LCG_FG_MASK;
506 1.1 jklos cur_fg = (attr & LCG_BG_MASK) >> 4;
507 1.1 jklos } else {
508 1.1 jklos cur_fg = attr & LCG_FG_MASK;
509 1.1 jklos cur_bg = (attr & LCG_BG_MASK) >> 4;
510 1.1 jklos }
511 1.1 jklos for (dot = 0; dot < lcg_font.fontwidth; dot++)
512 1.1 jklos cursor[dot] = (ch & (1 << dot)) ?
513 1.1 jklos cur_fg : cur_bg;
514 1.1 jklos }
515 1.1 jklos
516 1.1 jklos cursor = &LCG_ADDR(row, col, lcg_font.fontheight - 1, 0);
517 1.1 jklos cur_on = on;
518 1.1 jklos if (attr & LCG_ATTR_REVERSE) {
519 1.1 jklos cur_bg = attr & LCG_FG_MASK;
520 1.1 jklos cur_fg = (attr & LCG_BG_MASK) >> 4;
521 1.1 jklos } else {
522 1.1 jklos cur_fg = attr & LCG_FG_MASK;
523 1.1 jklos cur_bg = (attr & LCG_BG_MASK) >> 4;
524 1.1 jklos }
525 1.1 jklos }
526 1.1 jklos ss->ss_curx = col;
527 1.1 jklos ss->ss_cury = row;
528 1.1 jklos if (attr & LCG_ATTR_REVERSE) {
529 1.1 jklos ss->ss_cur_bg = attr & LCG_FG_MASK;
530 1.1 jklos ss->ss_cur_fg = (attr & LCG_BG_MASK) >> 4;
531 1.1 jklos } else {
532 1.1 jklos ss->ss_cur_fg = attr & LCG_FG_MASK;
533 1.1 jklos ss->ss_cur_bg = (attr & LCG_BG_MASK) >> 4;
534 1.1 jklos }
535 1.1 jklos }
536 1.1 jklos
537 1.1 jklos int
538 1.1 jklos lcg_mapchar(void *id, int uni, unsigned int *index)
539 1.1 jklos {
540 1.1 jklos if (uni < 256) {
541 1.1 jklos *index = uni;
542 1.1 jklos return (5);
543 1.1 jklos }
544 1.1 jklos *index = ' ';
545 1.1 jklos return (0);
546 1.1 jklos }
547 1.1 jklos
548 1.1 jklos static void
549 1.1 jklos lcg_putchar(void *id, int row, int col, u_int c, long attr)
550 1.1 jklos {
551 1.1 jklos struct lcg_screen *ss = id;
552 1.1 jklos int i;
553 1.1 jklos char dot_fg, dot_bg;
554 1.1 jklos
555 1.1 jklos c &= 0xff;
556 1.1 jklos
557 1.1 jklos ss->ss_image[row * lcg_cols + col].data = c;
558 1.1 jklos ss->ss_image[row * lcg_cols + col].attr = attr;
559 1.1 jklos if (ss != curscr)
560 1.1 jklos return;
561 1.1 jklos
562 1.1 jklos dot_fg = attr & LCG_FG_MASK;
563 1.1 jklos dot_bg = (attr & LCG_BG_MASK) >> 4;
564 1.1 jklos if (attr & LCG_ATTR_REVERSE) {
565 1.1 jklos dot_fg = (attr & LCG_BG_MASK) >> 4;
566 1.1 jklos dot_bg = attr & LCG_FG_MASK;
567 1.1 jklos }
568 1.1 jklos
569 1.1 jklos #ifndef LCG_NO_ACCEL
570 1.1 jklos renderchar(LCG_FONT_ADDR + (c * lcg_glyph_size),
571 1.1 jklos LCG_FB_ADDR + (row * lcg_onerow) + (col * lcg_font.fontwidth),
572 1.1 jklos lcg_font.fontwidth, lcg_font.fontheight, dot_fg, dot_bg);
573 1.1 jklos #else
574 1.1 jklos for (i = 0; i < lcg_font.fontheight; i++) {
575 1.1 jklos unsigned char ch = QFONT(c,i);
576 1.1 jklos for (int j = 0; j < lcg_font.fontwidth; j++) {
577 1.1 jklos LCG_ADDR(row, col, i, j) = ((ch >> j) & 1) ? dot_fg : dot_bg;
578 1.1 jklos }
579 1.1 jklos }
580 1.1 jklos #endif /* LCG_NO_ACCEL */
581 1.1 jklos if (attr & LCG_ATTR_UNDERLINE) {
582 1.1 jklos char *p = &LCG_ADDR(row, col, lcg_font.fontheight - 1, 0);
583 1.1 jklos for (i = 0; i < lcg_font.fontwidth; i++)
584 1.1 jklos p[i] = ~p[i];
585 1.1 jklos }
586 1.1 jklos }
587 1.1 jklos
588 1.1 jklos
589 1.1 jklos
590 1.1 jklos /*
591 1.1 jklos * copies columns inside a row.
592 1.1 jklos */
593 1.1 jklos static void
594 1.1 jklos lcg_copycols(void *id, int row, int srccol, int dstcol, int ncols)
595 1.1 jklos {
596 1.1 jklos struct lcg_screen *ss = id;
597 1.1 jklos #ifdef LCG_NO_ACCEL
598 1.1 jklos int i = 0;
599 1.1 jklos #endif
600 1.1 jklos
601 1.1 jklos bcopy(&ss->ss_image[row * lcg_cols + srccol], &ss->ss_image[row *
602 1.1 jklos lcg_cols + dstcol], ncols * sizeof(ss->ss_image[0]));
603 1.1 jklos if (ss != curscr)
604 1.1 jklos return;
605 1.1 jklos #ifdef LCG_NO_ACCEL
606 1.1 jklos for (i = 0; i < lcg_font.fontheight; i++)
607 1.1 jklos memcpy(&LCG_ADDR(row, dstcol, i, 0),
608 1.1 jklos &LCG_ADDR(row,srccol, i, 0), ncols * lcg_font.fontwidth);
609 1.1 jklos
610 1.1 jklos #else
611 1.1 jklos blkcpy(LCG_FB_ADDR + (row * lcg_onerow) + (srccol * lcg_font.fontwidth),
612 1.1 jklos LCG_FB_ADDR + (row * lcg_onerow) + (dstcol * lcg_font.fontwidth),
613 1.1 jklos (ncols * lcg_font.fontwidth), lcg_font.fontheight);
614 1.1 jklos #endif
615 1.1 jklos }
616 1.1 jklos
617 1.1 jklos /*
618 1.1 jklos * Erases a bunch of chars inside one row.
619 1.1 jklos */
620 1.1 jklos static void
621 1.1 jklos lcg_erasecols(void *id, int row, int startcol, int ncols, long fillattr)
622 1.1 jklos {
623 1.1 jklos struct lcg_screen *ss = id;
624 1.1 jklos int i;
625 1.1 jklos
626 1.1 jklos bzero(&ss->ss_image[row * lcg_cols + startcol], ncols * sizeof(ss->ss_image[0]));
627 1.1 jklos for (i = row * lcg_cols + startcol; i < row * lcg_cols + startcol + ncols; ++i)
628 1.1 jklos ss->ss_image[i].attr = fillattr;
629 1.1 jklos if (ss != curscr)
630 1.1 jklos return;
631 1.1 jklos #ifdef LCG_NO_ACCEL
632 1.1 jklos for (i = 0; i < lcg_font.fontheight; i++)
633 1.1 jklos memset(&LCG_ADDR(row, startcol, i, 0), 0, ncols * lcg_font.fontwidth);
634 1.1 jklos #else
635 1.1 jklos blkset(LCG_FB_ADDR + (row * lcg_onerow) + (startcol * lcg_font.fontwidth),
636 1.1 jklos (ncols * lcg_font.fontwidth), lcg_font.fontheight, (fillattr & LCG_BG_MASK) >> 4);
637 1.1 jklos #endif
638 1.1 jklos }
639 1.1 jklos
640 1.1 jklos static void
641 1.1 jklos lcg_copyrows(void *id, int srcrow, int dstrow, int nrows)
642 1.1 jklos {
643 1.1 jklos struct lcg_screen *ss = id;
644 1.1 jklos
645 1.1 jklos bcopy(&ss->ss_image[srcrow * lcg_cols], &ss->ss_image[dstrow * lcg_cols],
646 1.1 jklos nrows * lcg_cols * sizeof(ss->ss_image[0]));
647 1.1 jklos if (ss != curscr)
648 1.1 jklos return;
649 1.1 jklos #ifdef LCG_NO_ACCEL
650 1.1 jklos memcpy(&lcgaddr[dstrow * lcg_onerow],
651 1.1 jklos &lcgaddr[srcrow * lcg_onerow], nrows * lcg_onerow);
652 1.1 jklos #else
653 1.1 jklos blkcpy(LCG_FB_ADDR + (srcrow * lcg_onerow), LCG_FB_ADDR + (dstrow * lcg_onerow),
654 1.1 jklos (lcg_cols * lcg_font.fontwidth), (nrows * lcg_font.fontheight));
655 1.1 jklos #endif
656 1.1 jklos }
657 1.1 jklos
658 1.1 jklos static void
659 1.1 jklos lcg_eraserows(void *id, int startrow, int nrows, long fillattr)
660 1.1 jklos {
661 1.1 jklos struct lcg_screen *ss = id;
662 1.1 jklos int i;
663 1.1 jklos
664 1.1 jklos bzero(&ss->ss_image[startrow * lcg_cols], nrows * lcg_cols *
665 1.1 jklos sizeof(ss->ss_image[0]));
666 1.1 jklos for (i = startrow * lcg_cols; i < (startrow + nrows) * lcg_cols; ++i)
667 1.1 jklos ss->ss_image[i].attr = fillattr;
668 1.1 jklos if (ss != curscr)
669 1.1 jklos return;
670 1.1 jklos #ifdef LCG_NO_ACCEL
671 1.1 jklos memset(&lcgaddr[startrow * lcg_onerow], 0, nrows * lcg_onerow);
672 1.1 jklos #else
673 1.1 jklos blkset(LCG_FB_ADDR + (startrow * lcg_onerow), (lcg_cols * lcg_font.fontwidth),
674 1.1 jklos (nrows * lcg_font.fontheight), (fillattr & LCG_BG_MASK) >> 4);
675 1.1 jklos #endif
676 1.1 jklos }
677 1.1 jklos
678 1.1 jklos static int
679 1.1 jklos lcg_allocattr(void *id, int fg, int bg, int flags, long *attrp)
680 1.1 jklos {
681 1.1 jklos long myattr;
682 1.1 jklos
683 1.1 jklos if (flags & WSATTR_WSCOLORS)
684 1.1 jklos myattr = (fg & LCG_FG_MASK) | ((bg << 4) & LCG_BG_MASK);
685 1.1 jklos else
686 1.1 jklos myattr = WSCOL_WHITE << 4; /* XXXX */
687 1.1 jklos if (flags & WSATTR_REVERSE)
688 1.1 jklos myattr |= LCG_ATTR_REVERSE;
689 1.1 jklos if (flags & WSATTR_UNDERLINE)
690 1.1 jklos myattr |= LCG_ATTR_UNDERLINE;
691 1.1 jklos *attrp = myattr;
692 1.1 jklos return 0;
693 1.1 jklos }
694 1.1 jklos
695 1.1 jklos static int
696 1.1 jklos lcg_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, struct lwp *l)
697 1.1 jklos {
698 1.1 jklos struct wsdisplay_fbinfo *fb = (void *)data;
699 1.1 jklos int i;
700 1.1 jklos
701 1.1 jklos switch (cmd) {
702 1.1 jklos case WSDISPLAYIO_GTYPE:
703 1.1 jklos *(u_int *)data = WSDISPLAY_TYPE_LCG;
704 1.1 jklos break;
705 1.1 jklos
706 1.1 jklos case WSDISPLAYIO_GINFO:
707 1.1 jklos fb->height = lcg_ysize;
708 1.1 jklos fb->width = lcg_xsize;
709 1.1 jklos fb->depth = lcg_depth;
710 1.1 jklos fb->cmsize = 1 << lcg_depth;
711 1.1 jklos break;
712 1.1 jklos
713 1.1 jklos case WSDISPLAYIO_GETCMAP:
714 1.1 jklos return lcg_get_cmap((struct wsdisplay_cmap *)data);
715 1.1 jklos
716 1.1 jklos case WSDISPLAYIO_PUTCMAP:
717 1.1 jklos return lcg_set_cmap((struct wsdisplay_cmap *)data);
718 1.1 jklos
719 1.1 jklos case WSDISPLAYIO_GMODE:
720 1.1 jklos return EPASSTHROUGH;
721 1.1 jklos
722 1.1 jklos case WSDISPLAYIO_SMODE:
723 1.1 jklos /* if setting WSDISPLAYIO_MODE_EMUL, restore console cmap, current screen */
724 1.1 jklos if (*(u_int *)data == WSDISPLAYIO_MODE_EMUL) {
725 1.1 jklos /* FIXME: if this is meant to reset palette LUT reload has to be triggered too */
726 1.1 jklos bzero(lutaddr, LCG_LUT_SIZE);
727 1.1 jklos for (i = 0; i < 8; ++i) {
728 1.1 jklos lcg_cmap.r[i] = lcg_default_cmap.r[i];
729 1.1 jklos lcg_cmap.g[i] = lcg_default_cmap.g[i];
730 1.1 jklos lcg_cmap.b[i] = lcg_default_cmap.b[i];
731 1.1 jklos lutaddr[i * 8 + 1] = i;
732 1.1 jklos lutaddr[i * 8 + 2] = 1;
733 1.1 jklos lutaddr[i * 8 + 3] = lcg_cmap.r[i] >> (lcg_depth & 7);
734 1.1 jklos lutaddr[i * 8 + 4] = 1;
735 1.1 jklos lutaddr[i * 8 + 5] = lcg_cmap.g[i] >> (lcg_depth & 7);
736 1.1 jklos lutaddr[i * 8 + 6] = 1;
737 1.1 jklos lutaddr[i * 8 + 7] = lcg_cmap.b[i] >> (lcg_depth & 7);
738 1.1 jklos }
739 1.1 jklos if (savescr != NULL)
740 1.1 jklos lcg_show_screen(NULL, savescr, 0, NULL, NULL);
741 1.1 jklos savescr = NULL;
742 1.1 jklos } else { /* WSDISPLAYIO_MODE_MAPPED */
743 1.1 jklos savescr = curscr;
744 1.1 jklos curscr = NULL;
745 1.1 jklos /* clear screen? */
746 1.1 jklos }
747 1.1 jklos
748 1.1 jklos return EPASSTHROUGH;
749 1.1 jklos #if 0
750 1.1 jklos case WSDISPLAYIO_SVIDEO:
751 1.1 jklos if (*(u_int *)data == WSDISPLAYIO_VIDEO_ON) {
752 1.1 jklos curcmd = curc;
753 1.1 jklos } else {
754 1.1 jklos curc = curcmd;
755 1.1 jklos curcmd &= ~(CUR_CMD_FOPA|CUR_CMD_ENPA);
756 1.1 jklos curcmd |= CUR_CMD_FOPB;
757 1.1 jklos }
758 1.1 jklos WRITECUR(CUR_CMD, curcmd);
759 1.1 jklos break;
760 1.1 jklos
761 1.1 jklos case WSDISPLAYIO_GVIDEO:
762 1.1 jklos *(u_int *)data = (curcmd & CUR_CMD_FOPB ?
763 1.1 jklos WSDISPLAYIO_VIDEO_OFF : WSDISPLAYIO_VIDEO_ON);
764 1.1 jklos break;
765 1.1 jklos
766 1.1 jklos #endif
767 1.1 jklos default:
768 1.1 jklos return EPASSTHROUGH;
769 1.1 jklos }
770 1.1 jklos return 0;
771 1.1 jklos }
772 1.1 jklos
773 1.1 jklos static paddr_t
774 1.1 jklos lcg_mmap(void *v, void *vs, off_t offset, int prot)
775 1.1 jklos {
776 1.1 jklos if (offset >= lcg_fb_size || offset < 0)
777 1.1 jklos return -1;
778 1.1 jklos return (LCG_FB_ADDR + offset) >> PGSHIFT;
779 1.1 jklos }
780 1.1 jklos
781 1.1 jklos int
782 1.1 jklos lcg_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
783 1.1 jklos int *curxp, int *curyp, long *defattrp)
784 1.1 jklos {
785 1.1 jklos int i;
786 1.1 jklos struct lcg_screen *ss;
787 1.1 jklos
788 1.1 jklos *cookiep = malloc(sizeof(struct lcg_screen), M_DEVBUF, M_WAITOK);
789 1.1 jklos bzero(*cookiep, sizeof(struct lcg_screen));
790 1.1 jklos *curxp = *curyp = 0;
791 1.1 jklos *defattrp = (LCG_BG_COLOR << 4) | LCG_FG_COLOR;
792 1.1 jklos ss = *cookiep;
793 1.1 jklos for (i = 0; i < lcg_cols * lcg_rows; ++i)
794 1.1 jklos ss->ss_image[i].attr = (LCG_BG_COLOR << 4) | LCG_FG_COLOR;
795 1.1 jklos return 0;
796 1.1 jklos }
797 1.1 jklos
798 1.1 jklos void
799 1.1 jklos lcg_free_screen(void *v, void *cookie)
800 1.1 jklos {
801 1.1 jklos }
802 1.1 jklos
803 1.1 jklos int
804 1.1 jklos lcg_show_screen(void *v, void *cookie, int waitok,
805 1.1 jklos void (*cb)(void *, int, int), void *cbarg)
806 1.1 jklos {
807 1.1 jklos struct lcg_screen *ss = cookie;
808 1.1 jklos int row, col, dot_fg, dot_bg, j, attr;
809 1.1 jklos #ifdef LCG_NO_ACCEL
810 1.1 jklos int iter, jter;
811 1.1 jklos unsigned char ch;
812 1.1 jklos #endif
813 1.1 jklos
814 1.1 jklos if (ss == curscr)
815 1.1 jklos return (0);
816 1.1 jklos #ifdef LCG_NO_ACCEL
817 1.1 jklos memset(lcgaddr, LCG_BG_COLOR, lcg_xsize * lcg_ysize);
818 1.1 jklos #endif
819 1.1 jklos
820 1.1 jklos for (row = 0; row < lcg_rows; row++)
821 1.1 jklos for (col = 0; col < lcg_cols; col++) {
822 1.1 jklos attr = ss->ss_image[row * lcg_cols + col].attr;
823 1.1 jklos if (attr & LCG_ATTR_REVERSE) {
824 1.1 jklos dot_fg = (attr & LCG_BG_MASK) >> 4;
825 1.1 jklos dot_bg = attr & LCG_FG_MASK;
826 1.1 jklos } else {
827 1.1 jklos dot_fg = attr & LCG_FG_MASK;
828 1.1 jklos dot_bg = (attr & LCG_BG_MASK) >> 4;
829 1.1 jklos }
830 1.1 jklos u_char c = ss->ss_image[row * lcg_cols + col].data;
831 1.1 jklos
832 1.1 jklos if (c < 32)
833 1.1 jklos c = 32;
834 1.1 jklos #ifndef LCG_NO_ACCEL
835 1.1 jklos renderchar(LCG_FONT_ADDR + (c * lcg_glyph_size),
836 1.1 jklos LCG_FB_ADDR + (row * lcg_onerow) + (col * lcg_font.fontwidth),
837 1.1 jklos lcg_font.fontwidth, lcg_font.fontheight, dot_fg, dot_bg);
838 1.1 jklos #else
839 1.1 jklos for (iter = 0; iter < lcg_font.fontheight; iter++) {
840 1.1 jklos ch = QFONT(c,iter);
841 1.1 jklos for (jter = 0; jter < lcg_font.fontwidth; jter++) {
842 1.1 jklos LCG_ADDR(row, col, iter, jter) = ((ch >> jter) & 1) ? dot_fg : dot_bg;
843 1.1 jklos }
844 1.1 jklos }
845 1.1 jklos #endif
846 1.1 jklos if (attr & LCG_ATTR_UNDERLINE)
847 1.1 jklos for (j = 0; j < lcg_font.fontwidth; j++)
848 1.1 jklos LCG_ADDR(row, col,
849 1.1 jklos lcg_font.fontheight - 1, j) = dot_fg;
850 1.1 jklos }
851 1.1 jklos
852 1.1 jklos cursor = &lcgaddr[(ss->ss_cury * lcg_onerow) +
853 1.1 jklos ((lcg_font.fontheight - 1) * lcg_xsize) +
854 1.1 jklos (ss->ss_curx * lcg_font.fontwidth)];
855 1.1 jklos cur_fg = ss->ss_cur_fg;
856 1.1 jklos cur_bg = ss->ss_cur_bg;
857 1.1 jklos
858 1.1 jklos curscr = ss;
859 1.1 jklos return (0);
860 1.1 jklos }
861 1.1 jklos
862 1.1 jklos static int
863 1.1 jklos lcg_get_cmap(struct wsdisplay_cmap *p)
864 1.1 jklos {
865 1.1 jklos u_int index = p->index, count = p->count;
866 1.1 jklos int error;
867 1.1 jklos
868 1.1 jklos if (index >= (1 << lcg_depth) || count > (1 << lcg_depth) - index)
869 1.1 jklos return (EINVAL);
870 1.1 jklos
871 1.1 jklos error = copyout(&lcg_cmap.r[index], p->red, count);
872 1.1 jklos if (error)
873 1.1 jklos return error;
874 1.1 jklos error = copyout(&lcg_cmap.g[index], p->green, count);
875 1.1 jklos if (error)
876 1.1 jklos return error;
877 1.1 jklos error = copyout(&lcg_cmap.b[index], p->blue, count);
878 1.1 jklos return error;
879 1.1 jklos }
880 1.1 jklos
881 1.1 jklos static int
882 1.1 jklos lcg_set_cmap(struct wsdisplay_cmap *p)
883 1.1 jklos {
884 1.1 jklos u_int index = p->index, count = p->count;
885 1.1 jklos int error, s;
886 1.1 jklos
887 1.1 jklos if (index >= (1 << lcg_depth) || count > (1 << lcg_depth) - index)
888 1.1 jklos return (EINVAL);
889 1.1 jklos
890 1.1 jklos error = copyin(p->red, &lcg_cmap.r[index], count);
891 1.1 jklos if (error)
892 1.1 jklos return error;
893 1.1 jklos error = copyin(p->green, &lcg_cmap.g[index], count);
894 1.1 jklos if (error)
895 1.1 jklos return error;
896 1.1 jklos error = copyin(p->blue, &lcg_cmap.b[index], count);
897 1.1 jklos if (error)
898 1.1 jklos return error;
899 1.1 jklos
900 1.1 jklos s = spltty();
901 1.1 jklos /* FIXME: if this is meant to set palette LUT reload has to be triggered too */
902 1.1 jklos while (count-- > 0) {
903 1.1 jklos lutaddr[index * 8 + 0] = 0;
904 1.1 jklos lutaddr[index * 8 + 1] = index;
905 1.1 jklos lutaddr[index * 8 + 2] = 1;
906 1.1 jklos lutaddr[index * 8 + 3] = lcg_cmap.r[index] >> (lcg_depth & 7);
907 1.1 jklos lutaddr[index * 8 + 4] = 1;
908 1.1 jklos lutaddr[index * 8 + 5] = lcg_cmap.g[index] >> (lcg_depth & 7);
909 1.1 jklos lutaddr[index * 8 + 6] = 1;
910 1.1 jklos lutaddr[index * 8 + 7] = lcg_cmap.b[index] >> (lcg_depth & 7);
911 1.1 jklos ++index;
912 1.1 jklos }
913 1.1 jklos splx(s);
914 1.1 jklos return (0);
915 1.1 jklos }
916 1.1 jklos
917 1.1 jklos cons_decl(lcg);
918 1.1 jklos
919 1.1 jklos void
920 1.1 jklos lcgcninit(struct consdev *cndev)
921 1.1 jklos {
922 1.1 jklos int i;
923 1.1 jklos /* Clear screen */
924 1.1 jklos memset(lcgaddr, LCG_BG_COLOR, lcg_xsize * lcg_ysize);
925 1.1 jklos
926 1.1 jklos curscr = &lcg_conscreen;
927 1.1 jklos for (i = 0; i < lcg_cols * lcg_rows; ++i)
928 1.1 jklos lcg_conscreen.ss_image[i].attr =
929 1.1 jklos (LCG_BG_COLOR << 4) | LCG_FG_COLOR;
930 1.1 jklos wsdisplay_cnattach(&lcg_stdscreen, &lcg_conscreen, 0, 0,
931 1.1 jklos (LCG_BG_COLOR << 4) | LCG_FG_COLOR);
932 1.1 jklos cn_tab->cn_pri = CN_INTERNAL;
933 1.1 jklos
934 1.1 jklos
935 1.1 jklos #if NDZKBD > 0
936 1.1 jklos dzkbd_cnattach(0); /* Connect keyboard and screen together */
937 1.1 jklos #endif
938 1.1 jklos }
939 1.1 jklos
940 1.1 jklos /*
941 1.1 jklos * Called very early to setup the glass tty as console.
942 1.1 jklos * Because it's called before the VM system is inited, virtual memory
943 1.1 jklos * for the framebuffer can be stolen directly without disturbing anything.
944 1.1 jklos */
945 1.1 jklos void
946 1.1 jklos lcgcnprobe(struct consdev *cndev)
947 1.1 jklos {
948 1.1 jklos extern const struct cdevsw wsdisplay_cdevsw;
949 1.1 jklos
950 1.1 jklos if ((vax_boardtype != VAX_BTYP_46) && (vax_boardtype != VAX_BTYP_48))
951 1.1 jklos return; /* Only for VS 4000/60 and VLC */
952 1.1 jklos
953 1.1 jklos if (vax_confdata & 0x100)
954 1.1 jklos return; /* Diagnostic console */
955 1.1 jklos
956 1.1 jklos lcg_init_common(NULL, NULL);
957 1.1 jklos
958 1.1 jklos /* Set up default LUT */
959 1.1 jklos
960 1.1 jklos cndev->cn_pri = CN_INTERNAL;
961 1.1 jklos cndev->cn_dev = makedev(cdevsw_lookup_major(&wsdisplay_cdevsw), 0);
962 1.1 jklos }
963 1.1 jklos
964 1.1 jklos void
965 1.1 jklos lcg_init_common(struct device *self, struct vsbus_attach_args *va)
966 1.1 jklos {
967 1.1 jklos u_int magic, *lcg_config;
968 1.1 jklos int i;
969 1.1 jklos extern vaddr_t virtual_avail;
970 1.1 jklos long video_conf;
971 1.1 jklos int cookie;
972 1.1 jklos struct wsdisplay_font *wf;
973 1.1 jklos
974 1.1 jklos struct lcg_softc *sc = (void *)self;
975 1.1 jklos bus_dma_segment_t seg;
976 1.1 jklos int rseg, err;
977 1.1 jklos void *fifo_mem_vaddr;
978 1.1 jklos #ifndef LCG_NO_ACCEL
979 1.1 jklos u_char line;
980 1.1 jklos u_int ch, temp;
981 1.1 jklos #endif
982 1.1 jklos
983 1.1 jklos if (regaddr != NULL)
984 1.1 jklos return;
985 1.1 jklos
986 1.1 jklos /* map LCG registers first */
987 1.1 jklos if (self != NULL) {
988 1.1 jklos regaddr = (long*)vax_map_physmem(LCG_REG_ADDR, (LCG_REG_SIZE/VAX_NBPG));
989 1.1 jklos if (regaddr == 0) {
990 1.1 jklos printf("%s: Couldn't allocate register memory.\n", self->dv_xname);
991 1.1 jklos return;
992 1.1 jklos }
993 1.1 jklos } else {
994 1.1 jklos regaddr = (long*)virtual_avail;
995 1.1 jklos virtual_avail += LCG_REG_SIZE;
996 1.1 jklos ioaccess((vaddr_t)regaddr, LCG_REG_ADDR, (LCG_REG_SIZE/VAX_NBPG));
997 1.1 jklos }
998 1.1 jklos
999 1.1 jklos /*
1000 1.1 jklos * v = *0x200f0010 & VLC ? 0x07 : 0xf0;
1001 1.1 jklos * switch(v) {
1002 1.1 jklos * 0x05: 1280x1024
1003 1.1 jklos * 0x06: conf & 0x80 ? 1024x768 : 640x480
1004 1.1 jklos * 0x07: conf & 0x80 ? 1024x768 ? 1024x864
1005 1.1 jklos * 0x20: 1024x864
1006 1.1 jklos * 0x40: 1024x768
1007 1.1 jklos * 0x60: 1024x864
1008 1.1 jklos * 0x80: 1280x1024 4BPN
1009 1.1 jklos * 0x90: 1280x1024 8BPN
1010 1.1 jklos * 0xb0: 1280x1024 8BPN 2HD
1011 1.1 jklos */
1012 1.1 jklos if (self != NULL) {
1013 1.1 jklos lcg_config = (u_int *)vax_map_physmem(LCG_CONFIG, 1);
1014 1.1 jklos } else {
1015 1.1 jklos lcg_config = (u_int *)virtual_avail;
1016 1.1 jklos ioaccess((vaddr_t)lcg_config, LCG_CONFIG, 1);
1017 1.1 jklos }
1018 1.1 jklos magic = *lcg_config & (vax_boardtype == VAX_BTYP_46 ? 0xf0 : 0x07);
1019 1.1 jklos if (self != NULL) {
1020 1.1 jklos vax_unmap_physmem((vaddr_t)lcg_config, 1);
1021 1.1 jklos } else {
1022 1.1 jklos iounaccess((vaddr_t)lcg_config, 1);
1023 1.1 jklos }
1024 1.1 jklos lcg_depth = 8;
1025 1.1 jklos switch(magic) {
1026 1.1 jklos case 0x80: /* KA46 HR 1280x1024 4BPLN */
1027 1.1 jklos lcg_depth = 4;
1028 1.1 jklos case 0x05: /* KA48 HR 1280x1024 8BPLN */
1029 1.1 jklos case 0x90: /* KA46 HR 1280x1024 8BPLN */
1030 1.1 jklos case 0xb0: /* KA46 HR 1280x1024 8BPLN 2HD */
1031 1.1 jklos lcg_xsize = 1280;
1032 1.1 jklos lcg_ysize = 1024;
1033 1.1 jklos break;
1034 1.1 jklos case 0x06: /* KA48 1024x768 or 640x480 */
1035 1.1 jklos if (vax_confdata & 0x80) {
1036 1.1 jklos lcg_xsize = 1024;
1037 1.1 jklos lcg_ysize = 768;
1038 1.1 jklos } else {
1039 1.1 jklos lcg_xsize = 640;
1040 1.1 jklos lcg_ysize = 480;
1041 1.1 jklos }
1042 1.1 jklos break;
1043 1.1 jklos case 0x07: /* KA48 1024x768 or 1024x864 */
1044 1.1 jklos lcg_xsize = 1024;
1045 1.1 jklos lcg_ysize = (vax_confdata & 0x80) ? 768 : 864;
1046 1.1 jklos break;
1047 1.1 jklos case 0x20: /* KA46 1024x864 */
1048 1.1 jklos case 0x60: /* KA46 1024x864 */
1049 1.1 jklos lcg_xsize = 1024;
1050 1.1 jklos lcg_ysize = 864;
1051 1.1 jklos break;
1052 1.1 jklos case 0x40: /* KA46 1024x768 */
1053 1.1 jklos lcg_xsize = 1024;
1054 1.1 jklos lcg_ysize = 768;
1055 1.1 jklos break;
1056 1.1 jklos default:
1057 1.1 jklos panic("LCG model not supported");
1058 1.1 jklos }
1059 1.1 jklos if (self != NULL)
1060 1.1 jklos aprint_normal("%s: framebuffer size %dx%d, depth %d (magic 0x%x)\n",
1061 1.1 jklos self->dv_xname, lcg_xsize, lcg_ysize, lcg_depth, magic);
1062 1.1 jklos
1063 1.1 jklos wsfont_init();
1064 1.1 jklos cookie = wsfont_find(NULL, 12, 22, 0, WSDISPLAY_FONTORDER_R2L,
1065 1.1 jklos WSDISPLAY_FONTORDER_L2R, WSFONT_FIND_BITMAP);
1066 1.1 jklos if (cookie == -1)
1067 1.1 jklos cookie = wsfont_find(NULL, 8, 0, 0, WSDISPLAY_FONTORDER_R2L, 0,
1068 1.1 jklos WSFONT_FIND_BITMAP);
1069 1.1 jklos if (cookie == -1)
1070 1.1 jklos cookie = wsfont_find(NULL, 0, 0, 0, WSDISPLAY_FONTORDER_R2L,
1071 1.1 jklos WSDISPLAY_FONTORDER_L2R, WSFONT_FIND_BITMAP);
1072 1.1 jklos if (cookie == -1 || wsfont_lock(cookie, &wf))
1073 1.1 jklos panic("lcg_common_init: can't load console font");
1074 1.1 jklos lcg_font = *wf;
1075 1.1 jklos lcg_cols = lcg_xsize / lcg_font.fontwidth;
1076 1.1 jklos lcg_rows = lcg_ysize / lcg_font.fontheight;
1077 1.1 jklos if (self != NULL) {
1078 1.1 jklos aprint_normal("%s: using font %s (%dx%d), ", self->dv_xname, lcg_font.name,
1079 1.1 jklos lcg_font.fontwidth, lcg_font.fontheight);
1080 1.1 jklos aprint_normal("console size: %dx%d\n", lcg_cols, lcg_rows);
1081 1.1 jklos }
1082 1.1 jklos lcg_onerow = lcg_xsize * lcg_font.fontheight;
1083 1.1 jklos lcg_fb_size = lcg_xsize * lcg_ysize;
1084 1.1 jklos lcg_stdscreen.ncols = lcg_cols;
1085 1.1 jklos lcg_stdscreen.nrows = lcg_rows;
1086 1.1 jklos lcg_stdscreen.fontwidth = lcg_font.fontwidth;
1087 1.1 jklos lcg_stdscreen.fontheight = lcg_font.fontheight;
1088 1.1 jklos lcg_glyph_size = lcg_font.stride * lcg_font.fontheight;
1089 1.1 jklos snprintf(lcg_stdscreen_name, sizeof(lcg_stdscreen_name), "%dx%d", lcg_cols, lcg_rows);
1090 1.1 jklos qf = lcg_font.data;
1091 1.1 jklos qf2 = (u_short *)lcg_font.data;
1092 1.1 jklos
1093 1.1 jklos if (self != NULL) {
1094 1.1 jklos lcgaddr = (void *)vax_map_physmem(va->va_paddr,
1095 1.1 jklos ((lcg_fb_size + LCG_FONT_STORAGE_SIZE)/VAX_NBPG));
1096 1.1 jklos if (lcgaddr == 0) {
1097 1.1 jklos printf("%s: unable to allocate framebuffer memory.\n", self->dv_xname);
1098 1.1 jklos return;
1099 1.1 jklos }
1100 1.1 jklos #ifndef LCG_NO_ACCEL
1101 1.1 jklos fontaddr = lcgaddr + lcg_fb_size;
1102 1.1 jklos
1103 1.1 jklos /* copy font bitmaps */
1104 1.1 jklos for (ch = 0; ch < 256; ch++)
1105 1.1 jklos for (line = 0; line < lcg_font.fontheight; line++) {
1106 1.1 jklos temp = QFONT(ch, line);
1107 1.1 jklos if (lcg_font.stride == 1)
1108 1.1 jklos fontaddr[(ch * lcg_font.fontheight) + line] = temp;
1109 1.1 jklos else {
1110 1.1 jklos /* stride == 2 */
1111 1.1 jklos fontaddr[(ch * lcg_font.stride * lcg_font.fontheight) + line] = temp & 0xff;
1112 1.1 jklos fontaddr[(ch * lcg_font.stride * lcg_font.fontheight) + line + 1] = (temp >> 16) & 0xff;
1113 1.1 jklos }
1114 1.1 jklos }
1115 1.1 jklos #endif
1116 1.1 jklos
1117 1.1 jklos lutaddr = (void *)vax_map_physmem(LCG_LUT_ADDR, (LCG_LUT_SIZE/VAX_NBPG));
1118 1.1 jklos if (lutaddr == 0) {
1119 1.1 jklos printf("%s: unable to allocate LUT memory.\n", self->dv_xname);
1120 1.1 jklos return;
1121 1.1 jklos }
1122 1.1 jklos fifoaddr = (long*)vax_map_physmem(LCG_FIFO_WIN_ADDR, (LCG_FIFO_WIN_SIZE/VAX_NBPG));
1123 1.1 jklos if (regaddr == 0) {
1124 1.1 jklos printf("%s: unable to map FIFO window\n", self->dv_xname);
1125 1.1 jklos return;
1126 1.1 jklos }
1127 1.1 jklos
1128 1.1 jklos /* allocate contiguous physical memory block for FIFO */
1129 1.1 jklos err = bus_dmamem_alloc(va->va_dmat, LCG_FIFO_SIZE,
1130 1.1 jklos LCG_FIFO_ALIGN, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT);
1131 1.1 jklos if (err) {
1132 1.1 jklos printf("%s: unable to allocate FIFO memory block, err = %d\n",
1133 1.1 jklos self->dv_xname, err);
1134 1.1 jklos return;
1135 1.1 jklos }
1136 1.1 jklos
1137 1.1 jklos err = bus_dmamem_map(va->va_dmat, &seg, rseg, LCG_FIFO_SIZE,
1138 1.1 jklos &fifo_mem_vaddr, BUS_DMA_NOWAIT);
1139 1.1 jklos if (err) {
1140 1.1 jklos printf("%s: unable to map FIFO memory block, err = %d\n",
1141 1.1 jklos self->dv_xname, err);
1142 1.1 jklos bus_dmamem_free(va->va_dmat, &seg, rseg);
1143 1.1 jklos return;
1144 1.1 jklos }
1145 1.1 jklos
1146 1.1 jklos err = bus_dmamap_create(va->va_dmat, LCG_FIFO_SIZE, rseg,
1147 1.1 jklos LCG_FIFO_SIZE, 0, BUS_DMA_NOWAIT, &sc->sc_dm);
1148 1.1 jklos if (err) {
1149 1.1 jklos printf("%s: unable to create DMA map, err = %d\n", self->dv_xname, err);
1150 1.1 jklos bus_dmamem_unmap(va->va_dmat, fifo_mem_vaddr, LCG_FIFO_SIZE);
1151 1.1 jklos bus_dmamem_free(va->va_dmat, &seg, rseg);
1152 1.1 jklos return;
1153 1.1 jklos }
1154 1.1 jklos
1155 1.1 jklos err = bus_dmamap_load(va->va_dmat, sc->sc_dm, fifo_mem_vaddr,
1156 1.1 jklos LCG_FIFO_SIZE, NULL, BUS_DMA_NOWAIT);
1157 1.1 jklos if (err) {
1158 1.1 jklos printf("%s: unable to load DMA map, err = %d\n", self->dv_xname, err);
1159 1.1 jklos bus_dmamap_destroy(va->va_dmat, sc->sc_dm);
1160 1.1 jklos bus_dmamem_unmap(va->va_dmat, fifo_mem_vaddr, LCG_FIFO_SIZE);
1161 1.1 jklos bus_dmamem_free(va->va_dmat, &seg, rseg);
1162 1.1 jklos return;
1163 1.1 jklos }
1164 1.1 jklos
1165 1.1 jklos /* initialize LCG hardware */
1166 1.1 jklos LCG_REG(LCG_REG_GRAPHICS_CONTROL) = 0xd8000000; /* gfx reset, FIFO and AG enable */
1167 1.1 jklos // LCG_REG(LCG_REG_WRITE_PROTECT_LOW_HIGH) = (((LCG_FB_ADDR + lcg_fb_size) & 0xffff0000) | (LCG_FB_ADDR >> 16));
1168 1.1 jklos LCG_REG(LCG_REG_WRITE_PROTECT_LOW_HIGH) = 0xffff0000;
1169 1.1 jklos LCG_REG(LCG_REG_FIFO_BASE) = sc->sc_dm->dm_segs[0].ds_addr;
1170 1.1 jklos LCG_REG(LCG_REG_FIFO_BASE2) = sc->sc_dm->dm_segs[0].ds_addr;
1171 1.1 jklos LCG_REG(LCG_REG_FIFO_MASKS) = 0xffff;
1172 1.1 jklos LCG_REG(LCG_REG_FIFO_SAVE_HEAD_OFFSET) = sc->sc_dm->dm_segs[0].ds_addr;
1173 1.1 jklos // LCG_REG(LCG_REG_GRAPHICS_INT_STATUS) = 0;
1174 1.1 jklos // LCG_REG(LCG_REG_GRAPHICS_CONTROL) = 0x50000000; /* FIFO and AG enable */
1175 1.1 jklos LCG_REG(LCG_REG_GRAPHICS_INT_STATUS) = 0xffffffff;
1176 1.1 jklos LCG_REG(LCG_REG_GRAPHICS_INT_SET_ENABLE) = 0;
1177 1.1 jklos LCG_REG(LCG_REG_GRAPHICS_INT_CLR_ENABLE) = 0xffffffff;
1178 1.1 jklos LCG_REG(LCG_REG_LCG_GO) = 3; /* FIFO and AG go */
1179 1.1 jklos // LCG_REG(LCG_REG_BREAKPT_ADDRESS) = 0x2fffffff;
1180 1.1 jklos
1181 1.1 jklos } else {
1182 1.1 jklos lcgaddr = (void *)virtual_avail;
1183 1.1 jklos virtual_avail += lcg_fb_size + LCG_FONT_STORAGE_SIZE;
1184 1.1 jklos ioaccess((vaddr_t)lcgaddr, LCG_FB_ADDR, (lcg_fb_size/VAX_NBPG));
1185 1.1 jklos
1186 1.1 jklos lutaddr = (void *)virtual_avail;
1187 1.1 jklos virtual_avail += LCG_LUT_SIZE;
1188 1.1 jklos ioaccess((vaddr_t)lutaddr, LCG_LUT_ADDR, (LCG_LUT_SIZE/VAX_NBPG));
1189 1.1 jklos
1190 1.1 jklos fifoaddr = (long*)virtual_avail;
1191 1.1 jklos virtual_avail += LCG_FIFO_WIN_SIZE;
1192 1.1 jklos ioaccess((vaddr_t)fifoaddr, LCG_FIFO_WIN_ADDR, (LCG_FIFO_WIN_SIZE/VAX_NBPG));
1193 1.1 jklos }
1194 1.1 jklos
1195 1.1 jklos bzero(lutaddr, LCG_LUT_SIZE);
1196 1.1 jklos for (i = 0; i < 8; ++i) {
1197 1.1 jklos lcg_cmap.r[i] = lcg_default_cmap.r[i];
1198 1.1 jklos lcg_cmap.g[i] = lcg_default_cmap.g[i];
1199 1.1 jklos lcg_cmap.b[i] = lcg_default_cmap.b[i];
1200 1.1 jklos lutaddr[i * 8 + 1] = i;
1201 1.1 jklos lutaddr[i * 8 + 2] = 1;
1202 1.1 jklos lutaddr[i * 8 + 3] = lcg_cmap.r[i] >> (lcg_depth & 7);
1203 1.1 jklos lutaddr[i * 8 + 4] = 1;
1204 1.1 jklos lutaddr[i * 8 + 5] = lcg_cmap.g[i] >> (lcg_depth & 7);
1205 1.1 jklos lutaddr[i * 8 + 6] = 1;
1206 1.1 jklos lutaddr[i * 8 + 7] = lcg_cmap.b[i] >> (lcg_depth & 7);
1207 1.1 jklos }
1208 1.1 jklos
1209 1.1 jklos /*
1210 1.1 jklos * 0xf100165b 4000/60
1211 1.1 jklos * 1111 0001 0000 0000 0001 0110 0101 1011
1212 1.1 jklos * vvvv vvvv vvvv vvvv vvvv vvvv vvvv vvvv
1213 1.1 jklos * 3322 2222 2222 1111 1111 11
1214 1.1 jklos * 1098 7654 3210 9876 5432 1098 7654 3210
1215 1.1 jklos *
1216 1.1 jklos * 0xf1001d7b 4000/VLC
1217 1.1 jklos * 1111 0001 0000 0000 0001 1101 0111 1011
1218 1.1 jklos * vvvv vvvv vvvv vvvv vvvv vvvv vvvv vvvv
1219 1.1 jklos * 3322 2222 2222 1111 1111 11
1220 1.1 jklos * 1098 7654 3210 9876 5432 1098 7654 3210
1221 1.1 jklos *
1222 1.1 jklos * 31-30 11 Vertical state
1223 1.1 jklos * 29-38 11 Horizontal state
1224 1.1 jklos * 27-26 00
1225 1.1 jklos * 25 0 console LUT select
1226 1.1 jklos * 24 1 control LUT select
1227 1.1 jklos * 23 0
1228 1.1 jklos * 22 0 cursor active
1229 1.1 jklos * 21-16 000000
1230 1.1 jklos * 15 0 video subsystem reset
1231 1.1 jklos * 14 0
1232 1.1 jklos * 13 0 LUT load size 2KB
1233 1.1 jklos * 12 1 enable H sync
1234 1.1 jklos * 11 0 Full LUT load 1
1235 1.1 jklos * 10 1 video clock select
1236 1.1 jklos * 9- 8 10 memory refresh rate 01
1237 1.1 jklos * 7- 6 01 video refresh rate
1238 1.1 jklos * 5 0 load select 1
1239 1.1 jklos * 4 1 read cursor output
1240 1.1 jklos * 3 1 LUT load enable
1241 1.1 jklos * 2 0 cursor enable
1242 1.1 jklos * 1 1 video enable
1243 1.1 jklos * 0 1 refresh clock enable
1244 1.1 jklos */
1245 1.1 jklos /* prepare video_config reg for LUT relaod */
1246 1.1 jklos video_conf
1247 1.1 jklos = (3 << 30) /* vertical state */
1248 1.1 jklos | (3 << 28) /* horizontal state */
1249 1.1 jklos | (0 << 26) /* unused */
1250 1.1 jklos | (0 << 25) /* console LUT select */
1251 1.1 jklos | (0 << 24) /* control LUT select */
1252 1.1 jklos | (0 << 23) /* unused */
1253 1.1 jklos | (0 << 22) /* cursor active */
1254 1.1 jklos | (0 << 16) /* current cursor scanline showing */
1255 1.1 jklos | (0 << 15) /* video subsystem reset */
1256 1.1 jklos | (0 << 14) /* unused */
1257 1.1 jklos | (1 << 13) /* LUT load size 2 KB */
1258 1.1 jklos | (1 << 12) /* enable horizontal sync */
1259 1.1 jklos | (1 << 10) /* video clock select */
1260 1.1 jklos | (1 << 6) /* video refresh select */
1261 1.1 jklos | (1 << 4) /* read curosr output */
1262 1.1 jklos | (1 << 3) /* LUT load enable */
1263 1.1 jklos | (0 << 2) /* cursor enable */
1264 1.1 jklos | (1 << 1) /* video enable */
1265 1.1 jklos | (1 << 0); /* refresh clock enable */
1266 1.1 jklos /* FIXME needs updating for all supported models */
1267 1.1 jklos if (lcg_xsize == 1280) { /* 4000/60 HR 4PLN */
1268 1.1 jklos video_conf |= (0 << 11); /* split LUT load */
1269 1.1 jklos video_conf |= (2 << 8); /* memory refresh select */
1270 1.1 jklos video_conf |= (0 << 5); /* split shift register load */
1271 1.1 jklos } else { /* 4000/VLC LR 8PLN */
1272 1.1 jklos video_conf |= (1 << 11); /* Full LUT load */
1273 1.1 jklos video_conf |= (1 << 8); /* memory refresh select */
1274 1.1 jklos video_conf |= (1 << 5); /* split shift register load */
1275 1.1 jklos }
1276 1.1 jklos
1277 1.1 jklos LCG_REG(LCG_REG_VIDEO_CONFIG) = video_conf;
1278 1.1 jklos /* vital !!! */
1279 1.1 jklos LCG_REG(LCG_REG_LUT_CONSOLE_SEL) = 1;
1280 1.1 jklos LCG_REG(LCG_REG_LUT_COLOR_BASE_W) = LCG_LUT_OFFSET;
1281 1.1 jklos
1282 1.1 jklos delay(1000);
1283 1.1 jklos LCG_REG(LCG_REG_LUT_CONSOLE_SEL) = 0;
1284 1.1 jklos
1285 1.1 jklos #ifdef LCG_DEBUG
1286 1.1 jklos if (self != NULL)
1287 1.1 jklos printf("%s: video config register set 0x%08lx\n", video_conf, self->dv_xname);
1288 1.1 jklos #endif
1289 1.1 jklos }
1290