2 #include "../port/lib.h"
7 #include "../port/error.h"
42 flushmemscreen(Rectangle r)
44 combinerect(&fbscreen.rect, r);
55 attachscreen(Rectangle *r, ulong *chan, int* d, int *width, int *softscreen)
62 *chan = gscreen->chan;
63 *width = gscreen->width;
65 /* make devdraw use gscreen->data */
66 *softscreen = 0xa110c;
69 return gscreen->data->bdata;
73 getcolor(ulong, ulong *, ulong *, ulong *)
78 setcolor(ulong, ulong, ulong, ulong)
96 return !badrect(fbscreen.rect);
103 uchar *sp, *dp, *top;
106 for(sno = 0; sno < NSEG; sno++)
107 if(up->seg[sno] == nil && sno != ESEG)
120 print("flushproc: %s\n", up->errstr);
127 sleep(&fbscreen, isflush, nil);
132 if(badrect(r) || gscreen == nil || rectclip(&r, gscreen->r) == 0){
136 w = sizeof(ulong)*gscreen->width;
137 n = bytesperline(r, gscreen->depth);
138 sp = byteaddr(gscreen, r.min);
139 dp = (uchar*)fbscreen.addr + (sp - &gscreen->data->bdata[gscreen->zero]);
140 top = (uchar*)up->seg[sno]->top;
141 if(dp+(Dy(r)-1)*w+n > top)
142 r.max.y = (top-(uchar*)fbscreen.addr)/w;
145 while(r.min.y < r.max.y) {
160 static Cmdtab fbctlmsg[] = {
167 fbctlwrite(Chan*, void *a, long n, vlong)
181 ct = lookupcmd(cb, fbctlmsg, nelem(fbctlmsg));
184 addr = strtoul(cb->f[1], 0, 0);
186 eqlock(&up->seglock);
187 if((s = seg(up, addr, 0)) == nil || (s->type&SG_RONLY) != 0){
188 qunlock(&up->seglock);
192 qunlock(&up->seglock);
194 if(fbscreen.proc != nil){
195 postnote(fbscreen.proc, 0, "die", NUser);
196 while(fbscreen.proc != nil)
199 fbscreen.addr = addr;
200 kproc("fbflush", flushproc, s);
204 x = strtoul(cb->f[1], &p, 0);
205 if(x == 0 || x > 10240)
209 y = strtoul(p, &p, 0);
210 if(y == 0 || y > 10240)
214 z = strtoul(p, &p, 0);
216 if((chan = strtochan(cb->f[2])) == 0)
217 error("bad channel");
218 if(chantodepth(chan) != z)
219 error("depth, channel do not match");
224 if(memimageinit() < 0){
226 error("memimageinit failed");
229 freememimage(gscreen);
232 gscreen = allocmemimage(Rect(0,0,x,y), chan);
238 error("no framebuffer");
249 fbctlread(Chan*, void *a, long n, vlong offset)
251 char buf[256], chan[32], *p, *e;
257 p = seprint(p, e, "size %dx%dx%d %s\n",
258 Dx(gscreen->r), Dy(gscreen->r), gscreen->depth,
259 chantostr(chan, gscreen->chan));
262 seprint(p, e, "addr %#p\n", fbscreen.addr);
263 return readstr(offset, a, n, buf);