ite_cc.c revision 1.1 1 1.1 mw #include "ite.h"
2 1.1 mw #if NITE > 0
3 1.1 mw
4 1.1 mw #include "param.h"
5 1.1 mw #include "conf.h"
6 1.1 mw #include "proc.h"
7 1.1 mw #include "ioctl.h"
8 1.1 mw #include "tty.h"
9 1.1 mw #include "systm.h"
10 1.1 mw
11 1.1 mw #include "itevar.h"
12 1.1 mw
13 1.1 mw #include "machine/cpu.h"
14 1.1 mw
15 1.1 mw /* XXX */
16 1.1 mw #include "grfioctl.h"
17 1.1 mw #include "grfvar.h"
18 1.1 mw #include "grf_ccreg.h"
19 1.1 mw
20 1.1 mw extern unsigned char kernel_font_width, kernel_font_height;
21 1.1 mw extern unsigned char kernel_font_lo, kernel_font_hi;
22 1.1 mw extern unsigned char kernel_font[], kernel_cursor[];
23 1.1 mw
24 1.1 mw
25 1.1 mw customc_init(ip)
26 1.1 mw register struct ite_softc *ip;
27 1.1 mw {
28 1.1 mw struct ccfb *fb;
29 1.1 mw int fboff, fbsize;
30 1.1 mw
31 1.1 mw if (ip->grf == 0)
32 1.1 mw ip->grf = &grf_softc[ip - ite_softc];
33 1.1 mw
34 1.1 mw ip->priv = ip->grf->g_display.gd_regaddr;
35 1.1 mw fb = (struct ccfb *) ip->priv;
36 1.1 mw fbsize = ip->grf->g_display.gd_fbsize;
37 1.1 mw
38 1.1 mw #if 0
39 1.1 mw /* already done in the grf layer */
40 1.1 mw
41 1.1 mw /* clear the display. bzero only likes regions up to 64k, so call multiple times */
42 1.1 mw for (fboff = 0; fboff < fbsize; fboff += 64*1024)
43 1.1 mw bzero (fb->fb + fboff, fbsize - fboff > 64*1024 ? 64*1024 : fbsize - fboff);
44 1.1 mw #endif
45 1.1 mw
46 1.1 mw /* this is a dreadful font, but I don't have an alternative at the moment.. */
47 1.1 mw ip->font = kernel_font;
48 1.1 mw ip->font_lo = kernel_font_lo;
49 1.1 mw ip->font_hi = kernel_font_hi;
50 1.1 mw ip->ftwidth = kernel_font_width;
51 1.1 mw ip->ftheight = kernel_font_height;
52 1.1 mw ip->cursor = kernel_cursor;
53 1.1 mw
54 1.1 mw ip->rows = fb->disp_height / ip->ftheight;
55 1.1 mw ip->cols = fb->disp_width / ip->ftwidth;
56 1.1 mw
57 1.1 mw
58 1.1 mw #if 0
59 1.1 mw printf ("font@%x, cursor@%x\n", ip->font, ip->cursor);
60 1.1 mw dump_copperlist (fb->cop1);
61 1.1 mw dump_copperlist (fb->cop2);
62 1.1 mw #endif
63 1.1 mw }
64 1.1 mw
65 1.1 mw customc_deinit(ip)
66 1.1 mw struct ite_softc *ip;
67 1.1 mw {
68 1.1 mw ip->flags &= ~ITE_INITED;
69 1.1 mw }
70 1.1 mw
71 1.1 mw
72 1.1 mw void static inline
73 1.1 mw customc_windowmove (src, srcx, srcy, srcmod,
74 1.1 mw dst, dstx, dsty, dstmod, h, w, op)
75 1.1 mw unsigned char *src, *dst;
76 1.1 mw unsigned short srcx, srcy, srcmod;
77 1.1 mw unsigned short dstx, dsty, dstmod;
78 1.1 mw unsigned short h, w;
79 1.1 mw unsigned char op;
80 1.1 mw {
81 1.1 mw int i;
82 1.1 mw
83 1.1 mw src += srcmod*srcy + (srcx >> 3);
84 1.1 mw dst += dstmod*dsty + (dstx >> 3);
85 1.1 mw
86 1.1 mw #if 0
87 1.1 mw printf("ccwm: %x-%x-%x-%x-%c\n", src, dst, h, w,
88 1.1 mw op == RR_XOR ? '^' : op == RR_COPY ? '|' : op == RR_CLEAR ? 'C' : 'I');
89 1.1 mw #endif
90 1.1 mw
91 1.1 mw /* currently, only drawing to byte slots is supported... */
92 1.1 mw if ((srcx & 07) || (dstx & 07) || (w & 07))
93 1.1 mw panic ("customc_windowmove: odd offset");
94 1.1 mw
95 1.1 mw w >>= 3;
96 1.1 mw while (h--)
97 1.1 mw {
98 1.1 mw if (src > dst)
99 1.1 mw for (i = 0; i < w; i++)
100 1.1 mw switch (op)
101 1.1 mw {
102 1.1 mw case RR_COPY:
103 1.1 mw dst[i] = src[i];
104 1.1 mw break;
105 1.1 mw
106 1.1 mw case RR_CLEAR:
107 1.1 mw dst[i] = 0;
108 1.1 mw break;
109 1.1 mw
110 1.1 mw case RR_XOR:
111 1.1 mw dst[i] ^= src[i];
112 1.1 mw break;
113 1.1 mw
114 1.1 mw case RR_COPYINVERTED:
115 1.1 mw dst[i] = ~src[i];
116 1.1 mw break;
117 1.1 mw }
118 1.1 mw else
119 1.1 mw for (i = w - 1; i >= 0; i--)
120 1.1 mw switch (op)
121 1.1 mw {
122 1.1 mw case RR_COPY:
123 1.1 mw dst[i] = src[i];
124 1.1 mw break;
125 1.1 mw
126 1.1 mw case RR_CLEAR:
127 1.1 mw dst[i] = 0;
128 1.1 mw break;
129 1.1 mw
130 1.1 mw case RR_XOR:
131 1.1 mw dst[i] ^= src[i];
132 1.1 mw break;
133 1.1 mw
134 1.1 mw case RR_COPYINVERTED:
135 1.1 mw dst[i] = ~src[i];
136 1.1 mw break;
137 1.1 mw }
138 1.1 mw
139 1.1 mw
140 1.1 mw src += srcmod;
141 1.1 mw dst += dstmod;
142 1.1 mw }
143 1.1 mw
144 1.1 mw }
145 1.1 mw
146 1.1 mw
147 1.1 mw customc_putc(ip, c, dy, dx, mode)
148 1.1 mw register struct ite_softc *ip;
149 1.1 mw register int dy, dx;
150 1.1 mw int c, mode;
151 1.1 mw {
152 1.1 mw register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY);
153 1.1 mw struct ccfb *fb = (struct ccfb *) ip->priv;
154 1.1 mw
155 1.1 mw if (c >= ip->font_lo && c <= ip->font_hi)
156 1.1 mw {
157 1.1 mw c -= ip->font_lo;
158 1.1 mw
159 1.1 mw customc_windowmove (ip->font, 0, c * ip->ftheight, 1,
160 1.1 mw fb->fb, fb->fb_x + dx * ip->ftwidth,
161 1.1 mw fb->fb_y + dy * ip->ftheight,
162 1.1 mw fb->fb_width >> 3,
163 1.1 mw ip->ftheight, ip->ftwidth, wrr);
164 1.1 mw }
165 1.1 mw }
166 1.1 mw
167 1.1 mw customc_cursor(ip, flag)
168 1.1 mw register struct ite_softc *ip;
169 1.1 mw register int flag;
170 1.1 mw {
171 1.1 mw struct ccfb *fb = (struct ccfb *) ip->priv;
172 1.1 mw
173 1.1 mw if (flag != DRAW_CURSOR)
174 1.1 mw {
175 1.1 mw /* erase it */
176 1.1 mw customc_windowmove (ip->cursor, 0, 0, 1,
177 1.1 mw fb->fb, fb->fb_x + ip->cursorx * ip->ftwidth,
178 1.1 mw fb->fb_y + ip->cursory * ip->ftheight,
179 1.1 mw fb->fb_width >> 3,
180 1.1 mw ip->ftheight, ip->ftwidth, RR_XOR);
181 1.1 mw }
182 1.1 mw if (flag == DRAW_CURSOR || flag == MOVE_CURSOR)
183 1.1 mw {
184 1.1 mw /* draw it */
185 1.1 mw customc_windowmove (ip->cursor, 0, 0, 1,
186 1.1 mw fb->fb, fb->fb_x + ip->curx * ip->ftwidth,
187 1.1 mw fb->fb_y + ip->cury * ip->ftheight,
188 1.1 mw fb->fb_width >> 3,
189 1.1 mw ip->ftheight, ip->ftwidth, RR_XOR);
190 1.1 mw ip->cursorx = ip->curx;
191 1.1 mw ip->cursory = ip->cury;
192 1.1 mw }
193 1.1 mw }
194 1.1 mw
195 1.1 mw customc_clear(ip, sy, sx, h, w)
196 1.1 mw struct ite_softc *ip;
197 1.1 mw register int sy, sx, h, w;
198 1.1 mw {
199 1.1 mw struct ccfb *fb = (struct ccfb *) ip->priv;
200 1.1 mw
201 1.1 mw customc_windowmove (0, 0, 0, 0,
202 1.1 mw fb->fb, fb->fb_x + sx * ip->ftwidth,
203 1.1 mw fb->fb_y + sy * ip->ftheight,
204 1.1 mw fb->fb_width >> 3,
205 1.1 mw h * ip->ftheight, w * ip->ftwidth, RR_CLEAR);
206 1.1 mw }
207 1.1 mw
208 1.1 mw customc_blockmove(ip, sy, sx, dy, dx, h, w)
209 1.1 mw register struct ite_softc *ip;
210 1.1 mw int sy, sx, dy, dx, h, w;
211 1.1 mw {
212 1.1 mw struct ccfb *fb = (struct ccfb *) ip->priv;
213 1.1 mw
214 1.1 mw customc_windowmove(fb->fb, fb->fb_x + sx * ip->ftwidth,
215 1.1 mw fb->fb_y + sy * ip->ftheight,
216 1.1 mw fb->fb_width >> 3,
217 1.1 mw fb->fb, fb->fb_x + dx * ip->ftwidth,
218 1.1 mw fb->fb_y + dy * ip->ftheight,
219 1.1 mw fb->fb_width >> 3,
220 1.1 mw h * ip->ftheight, w * ip->ftwidth, RR_COPY);
221 1.1 mw }
222 1.1 mw
223 1.1 mw customc_scroll(ip, sy, sx, count, dir)
224 1.1 mw register struct ite_softc *ip;
225 1.1 mw register int sy;
226 1.1 mw int dir, sx, count;
227 1.1 mw {
228 1.1 mw register int height, dy, i;
229 1.1 mw
230 1.1 mw customc_cursor(ip, ERASE_CURSOR);
231 1.1 mw
232 1.1 mw if (dir == SCROLL_UP)
233 1.1 mw {
234 1.1 mw dy = sy - count;
235 1.1 mw height = ip->bottom_margin - sy + 1;
236 1.1 mw for (i = 0; i < height; i++)
237 1.1 mw customc_blockmove(ip, sy + i, sx, dy + i, 0, 1, ip->cols);
238 1.1 mw }
239 1.1 mw else if (dir == SCROLL_DOWN)
240 1.1 mw {
241 1.1 mw dy = sy + count;
242 1.1 mw height = ip->bottom_margin - dy + 1;
243 1.1 mw for (i = (height - 1); i >= 0; i--)
244 1.1 mw customc_blockmove(ip, sy + i, sx, dy + i, 0, 1, ip->cols);
245 1.1 mw }
246 1.1 mw else if (dir == SCROLL_RIGHT)
247 1.1 mw {
248 1.1 mw customc_blockmove(ip, sy, sx, sy, sx + count, 1, ip->cols - (sx + count));
249 1.1 mw }
250 1.1 mw else
251 1.1 mw {
252 1.1 mw customc_blockmove(ip, sy, sx, sy, sx - count, 1, ip->cols - sx);
253 1.1 mw }
254 1.1 mw }
255 1.1 mw
256 1.1 mw #endif
257