Wed Apr 24 11:49:58 2024 UTC (16d)
allow userland to switch to 16bit colour


(macallan)
diff -r1.96 -r1.97 src/sys/arch/sparc/dev/cgfourteen.c

cvs diff -r1.96 -r1.97 src/sys/arch/sparc/dev/cgfourteen.c (expand / switch to unified diff)

--- src/sys/arch/sparc/dev/cgfourteen.c 2023/12/20 05:33:18 1.96
+++ src/sys/arch/sparc/dev/cgfourteen.c 2024/04/24 11:49:58 1.97
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cgfourteen.c,v 1.96 2023/12/20 05:33:18 thorpej Exp $ */ 1/* $NetBSD: cgfourteen.c,v 1.97 2024/04/24 11:49:58 macallan Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 4 * Copyright (c) 1996
5 * The President and Fellows of Harvard College. All rights reserved. 5 * The President and Fellows of Harvard College. All rights reserved.
6 * Copyright (c) 1992, 1993 6 * Copyright (c) 1992, 1993
7 * The Regents of the University of California. All rights reserved. 7 * The Regents of the University of California. All rights reserved.
8 * 8 *
9 * This software was developed by the Computer Systems Engineering group 9 * This software was developed by the Computer Systems Engineering group
10 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 10 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
11 * contributed to Berkeley. 11 * contributed to Berkeley.
12 * 12 *
13 * All advertising materials mentioning features or use of this software 13 * All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement: 14 * must display the following acknowledgement:
@@ -1062,42 +1062,48 @@ cg14_set_depth(struct cgfourteen_softc * @@ -1062,42 +1062,48 @@ cg14_set_depth(struct cgfourteen_softc *
1062 sc->sc_mask = 0xffffffff; 1062 sc->sc_mask = 0xffffffff;
1063 sx_write(sc->sc_sx, SX_QUEUED(R_MASK), sc->sc_mask); 1063 sx_write(sc->sc_sx, SX_QUEUED(R_MASK), sc->sc_mask);
1064 } 1064 }
1065 1065
1066 if (sc->sc_depth == depth) 1066 if (sc->sc_depth == depth)
1067 return; 1067 return;
1068 1068
1069 switch (depth) { 1069 switch (depth) {
1070 case 8: 1070 case 8:
1071 bus_space_write_1(sc->sc_bustag, sc->sc_regh, 1071 bus_space_write_1(sc->sc_bustag, sc->sc_regh,
1072 CG14_MCTL, CG14_MCTL_ENABLEVID |  1072 CG14_MCTL, CG14_MCTL_ENABLEVID |
1073 CG14_MCTL_PIXMODE_8 | CG14_MCTL_POWERCTL); 1073 CG14_MCTL_PIXMODE_8 | CG14_MCTL_POWERCTL);
1074 sc->sc_depth = 8; 1074 sc->sc_depth = 8;
1075 /* everything is CLUT1 */ 1075 break;
1076 for (i = 0; i < CG14_CLUT_SIZE; i++) 1076 case 16:
1077 sc->sc_xlut->xlut_lut[i] = 0; 1077 bus_space_write_1(sc->sc_bustag, sc->sc_regh,
 1078 CG14_MCTL, CG14_MCTL_ENABLEVID |
 1079 CG14_MCTL_PIXMODE_16 | CG14_MCTL_POWERCTL);
 1080 sc->sc_depth = 16;
1078 break; 1081 break;
1079 case 32: 1082 case 32:
1080 bus_space_write_1(sc->sc_bustag, sc->sc_regh, 1083 bus_space_write_1(sc->sc_bustag, sc->sc_regh,
1081 CG14_MCTL, CG14_MCTL_ENABLEVID |  1084 CG14_MCTL, CG14_MCTL_ENABLEVID |
1082 CG14_MCTL_PIXMODE_32 | CG14_MCTL_POWERCTL); 1085 CG14_MCTL_PIXMODE_32 | CG14_MCTL_POWERCTL);
1083 sc->sc_depth = 32; 1086 sc->sc_depth = 32;
1084 for (i = 0; i < CG14_CLUT_SIZE; i++) 
1085 sc->sc_xlut->xlut_lut[i] = 0; 
1086 break; 1087 break;
1087 default: 1088 default:
1088 printf("%s: can't change to depth %d\n", 1089 printf("%s: can't change to depth %d\n",
1089 device_xname(sc->sc_dev), depth); 1090 device_xname(sc->sc_dev), depth);
 1091 return;
1090 } 1092 }
 1093 /* everything is CLUT1 */
 1094 for (i = 0; i < CG14_CLUT_SIZE; i++)
 1095 sc->sc_xlut->xlut_lut[i] = 0;
 1096
1091} 1097}
1092 1098
1093static void 1099static void
1094cg14_move_cursor(struct cgfourteen_softc *sc, int x, int y) 1100cg14_move_cursor(struct cgfourteen_softc *sc, int x, int y)
1095{ 1101{
1096 uint32_t pos; 1102 uint32_t pos;
1097 1103
1098 sc->sc_cursor.cc_pos.x = x; 1104 sc->sc_cursor.cc_pos.x = x;
1099 sc->sc_cursor.cc_pos.y = y; 1105 sc->sc_cursor.cc_pos.y = y;
1100 pos = ((sc->sc_cursor.cc_pos.x - sc->sc_cursor.cc_hot.x ) << 16) | 1106 pos = ((sc->sc_cursor.cc_pos.x - sc->sc_cursor.cc_hot.x ) << 16) |
1101 ((sc->sc_cursor.cc_pos.y - sc->sc_cursor.cc_hot.y ) & 0xffff); 1107 ((sc->sc_cursor.cc_pos.y - sc->sc_cursor.cc_hot.y ) & 0xffff);
1102 bus_space_write_4(sc->sc_bustag, sc->sc_regh, CG14_CURSOR_X, pos); 1108 bus_space_write_4(sc->sc_bustag, sc->sc_regh, CG14_CURSOR_X, pos);
1103} 1109}
@@ -1422,27 +1428,27 @@ cg14_bitblt(void *cookie, int xs, int ys @@ -1422,27 +1428,27 @@ cg14_bitblt(void *cookie, int xs, int ys
1422 */ 1428 */
1423static void 1429static void
1424cg14_bitblt_gc(void *cookie, int xs, int ys, int xd, int yd, 1430cg14_bitblt_gc(void *cookie, int xs, int ys, int xd, int yd,
1425 int wi, int he, int rop) 1431 int wi, int he, int rop)
1426{ 1432{
1427 struct cgfourteen_softc *sc = cookie; 1433 struct cgfourteen_softc *sc = cookie;
1428 uint32_t saddr, daddr; 1434 uint32_t saddr, daddr;
1429 int line, cnt = wi, stride = sc->sc_fb.fb_type.fb_width; 1435 int line, cnt = wi, stride = sc->sc_fb.fb_type.fb_width;
1430 int dreg = 8, swi = wi, dd; 1436 int dreg = 8, swi = wi, dd;
1431 int in = 0, q = 0, out = 0, r; 1437 int in = 0, q = 0, out = 0, r;
1432 1438
1433 saddr = sc->sc_fb_paddr + xs + stride * ys; 1439 saddr = sc->sc_fb_paddr + xs + stride * ys;
1434 daddr = sc->sc_fb_paddr + xd + stride * yd; 1440 daddr = sc->sc_fb_paddr + xd + stride * yd;
1435 1441
1436 if (saddr & 3) { 1442 if (saddr & 3) {
1437 swi += saddr & 3; 1443 swi += saddr & 3;
1438 dreg += saddr & 3; 1444 dreg += saddr & 3;
1439 saddr &= ~3; 1445 saddr &= ~3;
1440 } 1446 }
1441 swi = (swi + 3) >> 2; /* round up, number of quads to read */ 1447 swi = (swi + 3) >> 2; /* round up, number of quads to read */
1442  1448
1443 if (daddr & 3) { 1449 if (daddr & 3) {
1444 in = 4 - (daddr & 3); /* pixels to write in byte mode */ 1450 in = 4 - (daddr & 3); /* pixels to write in byte mode */
1445 cnt -= in; 1451 cnt -= in;
1446 } 1452 }
1447 1453
1448 q = cnt >> 2; 1454 q = cnt >> 2;