vidc20config.c revision 1.7 1 /* $NetBSD: vidc20config.c,v 1.7 2002/02/18 12:23:24 bjh21 Exp $ */
2
3 /*
4 * Copyright (c) 2001 Reinoud Zandijk
5 * Copyright (c) 1996 Mark Brinicombe
6 * Copyright (c) 1996 Robert Black
7 * Copyright (c) 1994-1995 Melvyn Tang-Richardson
8 * Copyright (c) 1994-1995 RiscBSD kernel team
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the RiscBSD kernel team
22 * 4. The name of the company nor the name of the author may be used to
23 * endorse or promote products derived from this software without specific
24 * prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE RISCBSD TEAM ``AS IS'' AND ANY EXPRESS
27 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
36 * THE POSSIBILITY OF SUCH DAMAGE.
37 *
38 * NetBSD kernel project
39 *
40 * vidcvideo.c
41 *
42 * This file is the lower basis of the wscons driver for VIDC based ARM machines.
43 * It features the initialisation and all VIDC writing and keeps in internal state
44 * copy.
45 * Its currenly set up as a library file and not as a device; it could be named
46 * vidcvideo0 eventually.
47 */
48
49 #include <sys/cdefs.h>
50
51 __RCSID("$NetBSD: vidc20config.c,v 1.7 2002/02/18 12:23:24 bjh21 Exp $");
52
53 #include <sys/types.h>
54 #include <sys/param.h>
55 #include <arm/iomd/vidc.h>
56 #include <arm/arm32/katelib.h>
57 #include <machine/bootconfig.h>
58 #include <machine/intr.h>
59
60 #include <sys/systm.h>
61 #include <sys/device.h>
62 #include <uvm/uvm_extern.h>
63
64 #include <arm/iomd/iomdreg.h>
65 #include <arm/iomd/iomdvar.h>
66 #include <arm/iomd/vidc20config.h>
67
68 /*
69 * A structure containing ALL the information required to restore
70 * the VIDC20 to any given state. ALL vidc transactions should
71 * go through these procedures, which record the vidc's state.
72 * it may be an idea to set the permissions of the vidc base address
73 * so we get a fault, so the fault routine can record the state but
74 * I guess that's not really necessary for the time being, since we
75 * can make the kernel more secure later on. Also, it is possible
76 * to write a routine to allow 'reading' of the vidc registers.
77 */
78
79 static struct vidc_state vidc_lookup = {
80 { 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,
81 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,
82 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,
83 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,
84 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,
85 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,
86 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,
87 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0
88 },
89
90 VIDC_PALREG,
91 VIDC_BCOL,
92 VIDC_CP1 ,
93 VIDC_CP2,
94 VIDC_CP3,
95 VIDC_HCR,
96 VIDC_HSWR,
97 VIDC_HBSR,
98 VIDC_HDSR,
99 VIDC_HDER,
100 VIDC_HBER,
101 VIDC_HCSR,
102 VIDC_HIR,
103 VIDC_VCR,
104 VIDC_VSWR,
105 VIDC_VBSR,
106 VIDC_VDSR,
107 VIDC_VDER,
108 VIDC_VBER,
109 VIDC_VCSR,
110 VIDC_VCER,
111 VIDC_EREG,
112 VIDC_FSYNREG,
113 VIDC_CONREG,
114 VIDC_DCTL
115 };
116
117 struct vidc_state vidc_current[1];
118
119
120 /*
121 * XXX global display variables XXX ... should be a structure
122 */
123 static int cold_init = 0; /* flags initialisation */
124 extern videomemory_t videomemory;
125
126 static struct vidc_mode vidc_initialmode;
127 static struct vidc_mode *vidc_currentmode;
128
129 unsigned int dispstart;
130 unsigned int dispsize;
131 unsigned int dispbase;
132 unsigned int dispend;
133 unsigned int ptov;
134 unsigned int vmem_base;
135 unsigned int phys_base;
136 unsigned int transfersize;
137
138
139 /* cursor stuff */
140 char *cursor_normal;
141 char *cursor_transparent;
142 int p_cursor_normal;
143 int p_cursor_transparent;
144 int cursor_width;
145 int cursor_height;
146
147
148 /*
149 * VIDC mode definitions
150 * generated from RISC OS mode definition file by an `awk' script
151 */
152 extern struct vidc_mode vidcmodes[];
153
154
155 /*
156 * configuration printing
157 *
158 */
159
160 void
161 vidcvideo_printdetails(void)
162 {
163 printf(": refclk=%dMHz %dKB %s ", (vidc_fref / 1000000),
164 videomemory.vidm_size / 1024,
165 (videomemory.vidm_type == VIDEOMEM_TYPE_VRAM) ? "VRAM" : "DRAM");
166 }
167
168 /*
169 * Common functions to directly access VIDC registers
170 */
171 int
172 vidcvideo_write(reg, value)
173 u_int reg;
174 int value;
175 {
176 int counter;
177
178 int *current;
179 int *tab;
180
181 tab = (int *)&vidc_lookup;
182 current = (int *)vidc_current;
183
184
185 /*
186 * OK, the VIDC_PALETTE register is handled differently
187 * to the others on the VIDC, so take that into account here
188 */
189 if (reg==VIDC_PALREG) {
190 vidc_current->palreg = 0;
191 WriteWord(vidc_base, reg | value);
192 return 0;
193 }
194
195 if (reg==VIDC_PALETTE) {
196 WriteWord(vidc_base, reg | value);
197 vidc_current->palette[vidc_current->palreg] = value;
198 vidc_current->palreg++;
199 vidc_current->palreg = vidc_current->palreg & 0xff;
200 return 0;
201 }
202
203 /*
204 * Undefine SAFER if you wish to speed things up (a little)
205 * although this means the function will assume things abou
206 * the structure of vidc_state. i.e. the first 256 words are
207 * the palette array
208 */
209
210 #define SAFER
211
212 #ifdef SAFER
213 #define INITVALUE 0
214 #else
215 #define INITVALUE 256
216 #endif
217
218 for ( counter=INITVALUE; counter<= sizeof(struct vidc_state); counter++ ) {
219 if ( reg==tab[counter] ) {
220 WriteWord ( vidc_base, reg | value );
221 current[counter] = value;
222 return 0;
223 }
224 }
225 return -1;
226 }
227
228
229 void
230 vidcvideo_setpalette(vidc)
231 struct vidc_state *vidc;
232 {
233 int counter = 0;
234
235 vidcvideo_write(VIDC_PALREG, 0x00000000);
236 for (counter = 0; counter < 255; counter++)
237 vidcvideo_write(VIDC_PALETTE, vidc->palette[counter]);
238 }
239
240
241 void
242 vidcvideo_setstate(vidc)
243 struct vidc_state *vidc;
244 {
245 vidcvideo_write ( VIDC_PALREG, vidc->palreg );
246 vidcvideo_write ( VIDC_BCOL, vidc->bcol );
247 vidcvideo_write ( VIDC_CP1, vidc->cp1 );
248 vidcvideo_write ( VIDC_CP2, vidc->cp2 );
249 vidcvideo_write ( VIDC_CP3, vidc->cp3 );
250 vidcvideo_write ( VIDC_HCR, vidc->hcr );
251 vidcvideo_write ( VIDC_HSWR, vidc->hswr );
252 vidcvideo_write ( VIDC_HBSR, vidc->hbsr );
253 vidcvideo_write ( VIDC_HDSR, vidc->hdsr );
254 vidcvideo_write ( VIDC_HDER, vidc->hder );
255 vidcvideo_write ( VIDC_HBER, vidc->hber );
256 vidcvideo_write ( VIDC_HCSR, vidc->hcsr );
257 vidcvideo_write ( VIDC_HIR, vidc->hir );
258 vidcvideo_write ( VIDC_VCR, vidc->vcr );
259 vidcvideo_write ( VIDC_VSWR, vidc->vswr );
260 vidcvideo_write ( VIDC_VBSR, vidc->vbsr );
261 vidcvideo_write ( VIDC_VDSR, vidc->vdsr );
262 vidcvideo_write ( VIDC_VDER, vidc->vder );
263 vidcvideo_write ( VIDC_VBER, vidc->vber );
264 vidcvideo_write ( VIDC_VCSR, vidc->vcsr );
265 vidcvideo_write ( VIDC_VCER, vidc->vcer );
266 /*
267 * Right, dunno what to set these to yet, but let's keep RiscOS's
268 * ones for now, until the time is right to finish this code
269 */
270
271 /* vidcvideo_write ( VIDC_EREG, vidc->ereg ); */
272 /* vidcvideo_write ( VIDC_FSYNREG, vidc->fsynreg ); */
273 /* vidcvideo_write ( VIDC_CONREG, vidc->conreg ); */
274 /* vidcvideo_write ( VIDC_DCTL, vidc->dctl ); */
275
276 }
277
278
279 void
280 vidcvideo_getstate(vidc)
281 struct vidc_state *vidc;
282 {
283 *vidc = *vidc_current;
284 }
285
286
287 void
288 vidcvideo_getmode(mode)
289 struct vidc_mode *mode;
290 {
291 *mode = *vidc_currentmode;
292 }
293
294
295 void
296 vidcvideo_stdpalette()
297 {
298 WriteWord(vidc_base, VIDC_PALREG | 0x00000000);
299 WriteWord(vidc_base, VIDC_PALETTE | VIDC_COL( 0, 0, 0));
300 WriteWord(vidc_base, VIDC_PALETTE | VIDC_COL(255, 0, 0));
301 WriteWord(vidc_base, VIDC_PALETTE | VIDC_COL( 0, 255, 0));
302 WriteWord(vidc_base, VIDC_PALETTE | VIDC_COL(255, 255, 0));
303 WriteWord(vidc_base, VIDC_PALETTE | VIDC_COL( 0, 0, 255));
304 WriteWord(vidc_base, VIDC_PALETTE | VIDC_COL(255, 0, 255));
305 WriteWord(vidc_base, VIDC_PALETTE | VIDC_COL( 0, 255, 255));
306 WriteWord(vidc_base, VIDC_PALETTE | VIDC_COL(255, 255, 255));
307 WriteWord(vidc_base, VIDC_PALETTE | VIDC_COL(128, 128, 128));
308 WriteWord(vidc_base, VIDC_PALETTE | VIDC_COL(255, 128, 128));
309 WriteWord(vidc_base, VIDC_PALETTE | VIDC_COL(128, 255, 128));
310 WriteWord(vidc_base, VIDC_PALETTE | VIDC_COL(255, 255, 128));
311 WriteWord(vidc_base, VIDC_PALETTE | VIDC_COL(128, 128, 255));
312 WriteWord(vidc_base, VIDC_PALETTE | VIDC_COL(255, 128, 255));
313 WriteWord(vidc_base, VIDC_PALETTE | VIDC_COL(128, 255, 255));
314 WriteWord(vidc_base, VIDC_PALETTE | VIDC_COL(255, 255, 255));
315 }
316
317
318 static int
319 vidcvideo_coldinit(void)
320 {
321 int found;
322 int loop;
323
324 /* Blank out the cursor */
325
326 vidcvideo_write(VIDC_CP1, 0x0);
327 vidcvideo_write(VIDC_CP2, 0x0);
328 vidcvideo_write(VIDC_CP3, 0x0);
329
330 /* Try to determine the current mode */
331 vidc_initialmode.hder = bootconfig.width+1;
332 vidc_initialmode.vder = bootconfig.height+1;
333 vidc_initialmode.log2_bpp = bootconfig.log2_bpp;
334
335 dispbase = vmem_base = dispstart = videomemory.vidm_vbase;
336 phys_base = videomemory.vidm_pbase;
337
338 /* Nut - should be using videomemory.vidm_size - mark */
339 if (videomemory.vidm_type == VIDEOMEM_TYPE_DRAM) {
340 dispsize = videomemory.vidm_size;
341 transfersize = 16;
342 } else {
343 dispsize = bootconfig.vram[0].pages * NBPG;
344 transfersize = dispsize >> 10;
345 };
346
347 ptov = dispbase - phys_base;
348
349 dispend = dispstart+dispsize;
350
351 /* try to find the current mode from the bootloader in my table */
352 vidc_currentmode = &vidcmodes[0];
353 loop = 0;
354 found = 0;
355 while (vidcmodes[loop].pixel_rate != 0) {
356 if (vidcmodes[loop].hder == (bootconfig.width + 1)
357 && vidcmodes[loop].vder == (bootconfig.height + 1)
358 && vidcmodes[loop].frame_rate == bootconfig.framerate) {
359 vidc_currentmode = &vidcmodes[loop];
360 found = 1;
361 }
362 ++loop;
363 }
364
365 /* if not found choose first mode but dont be picky on the framerate */
366 if (!found) {
367 vidc_currentmode = &vidcmodes[0];
368 loop = 0;
369 found = 0;
370
371 while (vidcmodes[loop].pixel_rate != 0) {
372 if (vidcmodes[loop].hder == (bootconfig.width + 1)
373 && vidcmodes[loop].vder == (bootconfig.height + 1)) {
374 vidc_currentmode = &vidcmodes[loop];
375 found = 1;
376 }
377 ++loop;
378 }
379 }
380
381 vidc_currentmode->log2_bpp = bootconfig.log2_bpp;
382
383 dispstart = dispbase;
384 dispend = dispstart+dispsize;
385
386 IOMD_WRITE_WORD(IOMD_VIDINIT, dispstart-ptov);
387 IOMD_WRITE_WORD(IOMD_VIDSTART, dispstart-ptov);
388 IOMD_WRITE_WORD(IOMD_VIDEND, (dispend-transfersize)-ptov);
389 return 0;
390 }
391
392
393 /* simple function to abstract vidc variables ; returns virt start address of screen */
394 /* XXX asumption that video memory is mapped in twice */
395 void *vidcvideo_hwscroll(int bytes) {
396 dispstart += bytes;
397 if (dispstart >= dispbase + dispsize) dispstart -= dispsize;
398 if (dispstart < dispbase) dispstart += dispsize;
399 dispend = dispstart+dispsize;
400
401 /* return the start of the bit map of the screen (left top) */
402 return (void *) dispstart;
403 }
404
405
406 /* reset the HW scroll to be at the start for the benefit of f.e. X */
407 void *vidcvideo_hwscroll_reset(void) {
408 void *cookie = (void *) dispstart;
409
410 dispstart = dispbase;
411 dispend = dispstart + dispsize;
412 return cookie;
413 }
414
415
416 /* put HW scroll back to where it was */
417 void *vidcvideo_hwscroll_back(void *cookie) {
418 dispstart = (int) cookie;
419 dispend = dispstart + dispsize;
420 return cookie;
421 }
422
423
424 /* this function is to be called at vsync */
425 void vidcvideo_progr_scroll(void) {
426 IOMD_WRITE_WORD(IOMD_VIDINIT, dispstart-ptov);
427 IOMD_WRITE_WORD(IOMD_VIDSTART, dispstart-ptov);
428 IOMD_WRITE_WORD(IOMD_VIDEND, (dispend-transfersize)-ptov);
429 }
430
431
432 /*
433 * Select a new mode by reprogramming the VIDC chip
434 * XXX this part is known not to work for 32bpp
435 */
436
437 struct vidc_mode newmode;
438
439 static const int bpp_mask_table[] = {
440 0, /* 1bpp */
441 1, /* 2bpp */
442 2, /* 4bpp */
443 3, /* 8bpp */
444 4, /* 16bpp */
445 6 /* 32bpp */
446 };
447
448
449 void
450 vidcvideo_setmode(struct vidc_mode *mode)
451 {
452 register int acc;
453 int bpp_mask;
454 int ereg;
455 int best_r, best_v;
456 int least_error;
457 int r, v, f;
458
459 /*
460 * Find out what bit mask we need to or with the vidc20 control register
461 * in order to generate the desired number of bits per pixel.
462 * log_bpp is log base 2 of the number of bits per pixel.
463 */
464
465 bpp_mask = bpp_mask_table[mode->log2_bpp];
466
467 newmode = *mode;
468 vidc_currentmode = &newmode;
469
470 least_error = INT_MAX;
471 best_r = 0; best_v = 0;
472
473 for (v = 63; v > 0; v--) {
474 for (r = 63; r > 0; r--) {
475 f = ((v * vidc_fref) /1000) / r;
476 if (least_error >=
477 abs(f - vidc_currentmode->pixel_rate)) {
478 least_error =
479 abs(f - vidc_currentmode->pixel_rate);
480 best_r = r;
481 best_v = v;
482 }
483 }
484 }
485
486 if (best_r > 63) best_r=63;
487 if (best_v > 63) best_v=63;
488 if (best_r < 1) best_r= 1;
489 if (best_v < 1) best_v= 1;
490
491 vidcvideo_write(VIDC_FSYNREG, (best_v-1)<<8 | (best_r-1)<<0);
492
493 acc=0;
494 acc+=vidc_currentmode->hswr; vidcvideo_write(VIDC_HSWR, (acc - 8 ) & (~1));
495 acc+=vidc_currentmode->hbsr; vidcvideo_write(VIDC_HBSR, (acc - 12) & (~1));
496 acc+=vidc_currentmode->hdsr; vidcvideo_write(VIDC_HDSR, (acc - 18) & (~1));
497 acc+=vidc_currentmode->hder; vidcvideo_write(VIDC_HDER, (acc - 18) & (~1));
498 acc+=vidc_currentmode->hber; vidcvideo_write(VIDC_HBER, (acc - 12) & (~1));
499 acc+=vidc_currentmode->hcr; vidcvideo_write(VIDC_HCR, (acc - 8 ) & (~3));
500
501 acc=0;
502 acc+=vidc_currentmode->vswr; vidcvideo_write(VIDC_VSWR, (acc - 1));
503 acc+=vidc_currentmode->vbsr; vidcvideo_write(VIDC_VBSR, (acc - 1));
504 acc+=vidc_currentmode->vdsr; vidcvideo_write(VIDC_VDSR, (acc - 1));
505 acc+=vidc_currentmode->vder; vidcvideo_write(VIDC_VDER, (acc - 1));
506 acc+=vidc_currentmode->vber; vidcvideo_write(VIDC_VBER, (acc - 1));
507 acc+=vidc_currentmode->vcr; vidcvideo_write(VIDC_VCR, (acc - 1));
508
509 IOMD_WRITE_WORD(IOMD_FSIZE, vidc_currentmode->vcr
510 + vidc_currentmode->vswr
511 + vidc_currentmode->vber
512 + vidc_currentmode->vbsr - 1);
513
514 if (dispsize <= 1024*1024)
515 vidcvideo_write(VIDC_DCTL, vidc_currentmode->hder>>2 | 1<<16 | 1<<12);
516 else
517 vidcvideo_write(VIDC_DCTL, vidc_currentmode->hder>>2 | 3<<16 | 1<<12);
518
519 ereg = 1<<12;
520 if (vidc_currentmode->sync_pol & 0x01)
521 ereg |= 1<<16;
522 if (vidc_currentmode->sync_pol & 0x02)
523 ereg |= 1<<18;
524 vidcvideo_write(VIDC_EREG, ereg);
525 if (dispsize > 1024*1024) {
526 if (vidc_currentmode->hder >= 800)
527 vidcvideo_write(VIDC_CONREG, 7<<8 | bpp_mask<<5);
528 else
529 vidcvideo_write(VIDC_CONREG, 6<<8 | bpp_mask<<5);
530 } else {
531 vidcvideo_write(VIDC_CONREG, 7<<8 | bpp_mask<<5);
532 }
533 }
534
535
536 #if 0
537 /* not used for now */
538 void
539 vidcvideo_set_display_base(base)
540 u_int base;
541 {
542 dispstart = dispstart-dispbase + base;
543 dispbase = vmem_base = base;
544 dispend = base + dispsize;
545 ptov = dispbase - phys_base;
546 }
547 #endif
548
549
550 /*
551 * Main initialisation routine for now
552 */
553
554 static int cursor_init = 0;
555
556 int
557 vidcvideo_init(void)
558 {
559 vidcvideo_coldinit();
560 if (cold_init && (cursor_init == 0))
561 /* vidcvideo_flash_go() */;
562
563 /* setting a mode goes wrong in 32 bpp ... 8 and 16 seem OK */
564 vidcvideo_setmode(vidc_currentmode);
565 vidcvideo_blank(0); /* display on */
566
567 vidcvideo_textpalette();
568
569 if (cold_init == 0) {
570 vidcvideo_write(VIDC_CP1, 0x0);
571 vidcvideo_write(VIDC_CP2, 0x0);
572 vidcvideo_write(VIDC_CP3, 0x0);
573 } else {
574 vidcvideo_cursor_init(CURSOR_MAX_WIDTH, CURSOR_MAX_HEIGHT);
575 };
576
577 cold_init=1;
578 return 0;
579 }
580
581
582 /* reinitialise the vidcvideo */
583 void
584 vidcvideo_reinit()
585 {
586 vidcvideo_coldinit();
587 vidcvideo_setmode(vidc_currentmode);
588 }
589
590
591 int
592 vidcvideo_cursor_init(int width, int height)
593 {
594 static char *cursor_data = NULL;
595 int counter;
596 int line;
597 paddr_t pa;
598
599 cursor_width = width;
600 cursor_height = height;
601
602 if (!cursor_data) {
603 /* Allocate cursor memory first time round */
604 cursor_data = (char *)uvm_km_zalloc(kernel_map, NBPG);
605 if (!cursor_data)
606 panic("Cannot allocate memory for hardware cursor\n");
607 (void) pmap_extract(pmap_kernel(), (vaddr_t)cursor_data, &pa);
608 IOMD_WRITE_WORD(IOMD_CURSINIT, pa);
609 }
610
611 /* Blank the cursor while initialising it's sprite */
612
613 vidcvideo_write ( VIDC_CP1, 0x0 );
614 vidcvideo_write ( VIDC_CP2, 0x0 );
615 vidcvideo_write ( VIDC_CP3, 0x0 );
616
617 cursor_normal = cursor_data;
618 cursor_transparent = cursor_data + (height * width);
619
620 cursor_transparent += 32; /* ALIGN */
621 cursor_transparent = (char *)((int)cursor_transparent & (~31) );
622
623 for ( line = 0; line<height; ++ line )
624 {
625 for ( counter=0; counter<width/4;counter++ )
626 cursor_normal[line * width + counter]=0x55; /* why 0x55 ? */
627 for ( ; counter<8; counter++ )
628 cursor_normal[line * width + counter]=0;
629 }
630
631 for ( line = 0; line<height; ++ line )
632 {
633 for ( counter=0; counter<width/4;counter++ )
634 cursor_transparent[line * width + counter]=0x00;
635 for ( ; counter<8; counter++ )
636 cursor_transparent[line * width + counter]=0;
637 }
638
639
640 (void) pmap_extract(pmap_kernel(), (vaddr_t)cursor_normal,
641 (paddr_t *)&p_cursor_normal);
642 (void) pmap_extract(pmap_kernel(), (vaddr_t)cursor_transparent,
643 (paddr_t *)&p_cursor_transparent);
644
645 memset ( cursor_normal, 0x55, width*height ); /* white? */
646 memset ( cursor_transparent, 0x00, width*height ); /* to see the diffence */
647
648 /* Ok, now program the cursor; should be blank */
649 vidcvideo_enablecursor(0);
650
651 return 0;
652 }
653
654
655 void
656 vidcvideo_updatecursor(xcur, ycur)
657 int xcur, ycur;
658 {
659 int frontporch = vidc_currentmode->hswr + vidc_currentmode->hbsr + vidc_currentmode->hdsr;
660 int topporch = vidc_currentmode->vswr + vidc_currentmode->vbsr + vidc_currentmode->vdsr;
661
662 vidcvideo_write(VIDC_HCSR, frontporch -17 + xcur);
663 vidcvideo_write(VIDC_VCSR, topporch -2 + (ycur+1)-2 + 3 - cursor_height);
664 vidcvideo_write(VIDC_VCER, topporch -2 + (ycur+3)+2 + 3 );
665 return;
666 }
667
668
669 void
670 vidcvideo_enablecursor(on)
671 int on;
672 {
673 if (on) {
674 IOMD_WRITE_WORD(IOMD_CURSINIT,p_cursor_normal);
675 } else {
676 IOMD_WRITE_WORD(IOMD_CURSINIT,p_cursor_transparent);
677 };
678 vidcvideo_write ( VIDC_CP1, 0xffffff ); /* enable */
679
680 return;
681 }
682
683
684 int
685 vidcvideo_textpalette()
686 {
687 vidcvideo_write(VIDC_PALREG, 0x00000000);
688 vidcvideo_write(VIDC_PALETTE, VIDC_COL( 0, 0, 0));
689 vidcvideo_write(VIDC_PALETTE, VIDC_COL(255, 0, 0));
690 vidcvideo_write(VIDC_PALETTE, VIDC_COL( 0, 255, 0));
691 vidcvideo_write(VIDC_PALETTE, VIDC_COL(255, 255, 0));
692 vidcvideo_write(VIDC_PALETTE, VIDC_COL( 0, 0, 255));
693 vidcvideo_write(VIDC_PALETTE, VIDC_COL(255, 0, 255));
694 vidcvideo_write(VIDC_PALETTE, VIDC_COL( 0, 255, 255));
695 vidcvideo_write(VIDC_PALETTE, VIDC_COL(255, 255, 255));
696 vidcvideo_write(VIDC_PALETTE, VIDC_COL(128, 128, 128));
697 vidcvideo_write(VIDC_PALETTE, VIDC_COL(255, 128, 128));
698 vidcvideo_write(VIDC_PALETTE, VIDC_COL(128, 255, 128));
699 vidcvideo_write(VIDC_PALETTE, VIDC_COL(255, 255, 128));
700 vidcvideo_write(VIDC_PALETTE, VIDC_COL(128, 128, 255));
701 vidcvideo_write(VIDC_PALETTE, VIDC_COL(255, 128, 255));
702 vidcvideo_write(VIDC_PALETTE, VIDC_COL(255, 255, 255));
703
704 return 0;
705 }
706
707 int
708 vidcvideo_blank(video_off)
709 int video_off;
710 {
711 int ereg;
712
713 ereg = 1<<12;
714 if (vidc_currentmode->sync_pol & 0x01)
715 ereg |= 1<<16;
716 if (vidc_currentmode->sync_pol & 0x02)
717 ereg |= 1<<18;
718
719 if (!video_off) {
720 vidcvideo_write(VIDC_EREG, ereg);
721 } else {
722 vidcvideo_write(VIDC_EREG, 0);
723 };
724 return 0;
725 }
726
727 /* end of vidc20config.c */
728