Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/usermode add a barrier before copyrows(), and add a...



details:   https://anonhg.NetBSD.org/src/rev/ddc8b09dfcca
branches:  trunk
changeset: 772345:ddc8b09dfcca
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Fri Dec 30 14:20:33 2011 +0000

description:
add a barrier before copyrows(), and add an RRE based fillrect functino,
use it for eraserows and erasecols

diffstat:

 sys/arch/usermode/dev/vncfb.c      |  29 ++++++++++++++----
 sys/arch/usermode/include/thunk.h  |   5 +-
 sys/arch/usermode/usermode/thunk.c |  58 ++++++++++++++++++++++++++++++++++++-
 3 files changed, 80 insertions(+), 12 deletions(-)

diffs (224 lines):

diff -r 9fd1fd33c480 -r ddc8b09dfcca sys/arch/usermode/dev/vncfb.c
--- a/sys/arch/usermode/dev/vncfb.c     Fri Dec 30 14:12:15 2011 +0000
+++ b/sys/arch/usermode/dev/vncfb.c     Fri Dec 30 14:20:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vncfb.c,v 1.6 2011/12/30 13:08:30 reinoud Exp $ */
+/* $NetBSD: vncfb.c,v 1.7 2011/12/30 14:20:33 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -35,7 +35,7 @@
 #include "opt_wsemul.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vncfb.c,v 1.6 2011/12/30 13:08:30 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vncfb.c,v 1.7 2011/12/30 14:20:33 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -103,7 +103,8 @@
 static void    vncfb_init_screen(void *, struct vcons_screen *, int, long *);
 
 static void    vncfb_update(struct vncfb_softc *, int, int, int, int);
-static void    vncfb_copyrect(struct vncfb_softc *sc, int, int, int, int, int, int);
+static void    vncfb_copyrect(struct vncfb_softc *, int, int, int, int, int, int);
+static void    vncfb_fillrect(struct vncfb_softc *, int, int, int, int, uint32_t);
 static int     vncfb_intr(void *);
 static void    vncfb_softintr(void *);
 
@@ -331,7 +332,7 @@
        struct vcons_screen *scr = ri->ri_hw;
        struct vncfb_softc *sc = scr->scr_cookie;
        struct vncfb_fbops *ops = &sc->sc_ops;
-       int x, y, w, h;
+       int x, y, w, h, c;
 
        ops->erasecols(ri, row, startcol, ncols, fillattr);
 
@@ -339,8 +340,9 @@
        h = ri->ri_font->fontheight;
        x = ri->ri_xorigin + (startcol * ri->ri_font->fontwidth);
        w = ncols * ri->ri_font->fontwidth;
+       c = ri->ri_devcmap[(fillattr >> 16) & 0xf] & 0xffffff;
 
-       vncfb_update(sc, x, y, w, h);
+       vncfb_fillrect(sc, x, y, w, h, c);
 }
 
 static void
@@ -353,6 +355,10 @@
        int x, y, w, h, srcx, srcy;
        int fontheight;
 
+       /* barrier */
+       while (sc->sc_rfb.nupdates > 0)
+               thunk_rfb_poll(&sc->sc_rfb, NULL);
+
        ops->copyrows(ri, srcrow, dstrow, nrows);
 
        fontheight = ri->ri_font->fontheight;
@@ -374,7 +380,7 @@
        struct vcons_screen *scr = ri->ri_hw;
        struct vncfb_softc *sc = scr->scr_cookie;
        struct vncfb_fbops *ops = &sc->sc_ops;
-       int x, y, w, h;
+       int x, y, w, h, c;
 
        ops->eraserows(ri, row, nrows, fillattr);
 
@@ -382,8 +388,9 @@
        h = nrows * ri->ri_font->fontheight;
        x = ri->ri_xorigin;
        w = ri->ri_width;
+       c = ri->ri_devcmap[(fillattr >> 16) & 0xf] & 0xffffff;
 
-       vncfb_update(sc, x, y, w, h);
+       vncfb_fillrect(sc, x, y, w, h, c);
 }
 
 static void
@@ -465,6 +472,14 @@
        softint_schedule(sc->sc_sih);
 }
 
+static void
+vncfb_fillrect(struct vncfb_softc *sc, int x, int y, int w, int h, uint32_t c)
+{
+
+       thunk_rfb_fillrect(&sc->sc_rfb, x, y, w, h, (uint8_t *)&c);
+       softint_schedule(sc->sc_sih);
+}
+
 static int
 vncfb_intr(void *priv)
 {
diff -r 9fd1fd33c480 -r ddc8b09dfcca sys/arch/usermode/include/thunk.h
--- a/sys/arch/usermode/include/thunk.h Fri Dec 30 14:12:15 2011 +0000
+++ b/sys/arch/usermode/include/thunk.h Fri Dec 30 14:20:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.51 2011/12/30 12:54:41 jmcneill Exp $ */
+/* $NetBSD: thunk.h,v 1.52 2011/12/30 14:20:34 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -195,7 +195,7 @@
        uint8_t                 enc;
        uint16_t                x, y, w, h;
        uint16_t                srcx, srcy;
-       uint32_t                colour;         /* for RRE clear */
+       uint8_t                 pixel[4];
 } thunk_rfb_update_t;
 #define THUNK_RFB_TYPE_RAW     0
 #define THUNK_RFB_TYPE_COPYRECT        1
@@ -227,5 +227,6 @@
 void   thunk_rfb_bell(thunk_rfb_t *);
 void   thunk_rfb_update(thunk_rfb_t *, int, int, int, int);
 void   thunk_rfb_copyrect(thunk_rfb_t *, int, int, int, int, int, int);
+void   thunk_rfb_fillrect(thunk_rfb_t *, int, int, int, int, uint8_t *);
 
 #endif /* !_ARCH_USERMODE_INCLUDE_THUNK_H */
diff -r 9fd1fd33c480 -r ddc8b09dfcca sys/arch/usermode/usermode/thunk.c
--- a/sys/arch/usermode/usermode/thunk.c        Fri Dec 30 14:12:15 2011 +0000
+++ b/sys/arch/usermode/usermode/thunk.c        Fri Dec 30 14:20:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.65 2011/12/30 13:08:30 reinoud Exp $ */
+/* $NetBSD: thunk.c,v 1.66 2011/12/30 14:20:34 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifdef __NetBSD__
-__RCSID("$NetBSD: thunk.c,v 1.65 2011/12/30 13:08:30 reinoud Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.66 2011/12/30 14:20:34 jmcneill Exp $");
 #endif
 
 #include <sys/types.h>
@@ -1003,6 +1003,7 @@
        /* If we have too many updates queued, just send a single update */
        if (rfb->nupdates >= __arraycount(rfb->update)) {
                rfb->nupdates = 1;
+               rfb->update[0].enc = THUNK_RFB_TYPE_RAW;
                rfb->update[0].x = 0;
                rfb->update[0].y = 0;
                rfb->update[0].w = rfb->width;
@@ -1039,6 +1040,10 @@
                if (update->enc == THUNK_RFB_TYPE_COPYRECT)
                        fprintf(stdout, " from [%d, %d]",
                            update->srcx, update->srcy);
+               if (update->enc == THUNK_RFB_TYPE_RRE)
+                       fprintf(stdout, " pixel [%02x %02x %02x %02x]",
+                           update->pixel[0], update->pixel[1],
+                           update->pixel[2], update->pixel[3]);
                fprintf(stdout, "\n");
 #endif
 
@@ -1055,6 +1060,24 @@
                                goto disco;
                }
 
+               if (update->enc == THUNK_RFB_TYPE_RRE) {
+                       p = buf;
+
+                       /* header */
+                       *(uint32_t *)p = htonl(1);              p += 4;
+                       memcpy(p, update->pixel, 4);            p += 4;
+                       /* subrectangle */
+                       memcpy(p, update->pixel, 4);            p += 4;
+                       *(uint16_t *)p = htons(update->x);      p += 2;
+                       *(uint16_t *)p = htons(update->y);      p += 2;
+                       *(uint16_t *)p = htons(update->w);      p += 2;
+                       *(uint16_t *)p = htons(update->h);      p += 2;
+                       /* send it */
+                       len = safe_send(rfb->clientfd, buf, 20);
+                       if (len < 0)
+                               goto disco;
+               }
+
                if (update->enc == THUNK_RFB_TYPE_RAW) {
                        p = rfb->framebuf + (update->y * stride)
                                + (update->x * bytes_per_pixel);
@@ -1146,6 +1169,9 @@
        if (rfb->clientfd == -1)
                return -1;
 
+       if (event == NULL)
+               return 0;
+
        if (rfb->schedule_bell) {
                uint8_t msg_type = 2;   /* bell */
                safe_send(rfb->clientfd, &msg_type, sizeof(msg_type));
@@ -1277,5 +1303,31 @@
        update->srcx = srcx;
        update->srcy = srcy;
 
-       rfb->first_mergable = rfb->nupdates+1;
+       rfb->first_mergable = rfb->nupdates;
 }
+
+void
+thunk_rfb_fillrect(thunk_rfb_t *rfb, int x, int y, int w, int h, uint8_t *pixel)
+{
+       thunk_rfb_update_t *update = NULL;
+
+       /* if the queue is full, just return */
+       if (rfb->nupdates >= __arraycount(rfb->update))
+               return;
+
+#ifdef RFB_DEBUG
+       fprintf(stdout, "rfb: fillrect queue slot %d, x=%d y=%d w=%d h=%d\n",
+           rfb->nupdates, x, y, w, h);
+#endif
+
+       /* add the update request to the queue */
+       update = &rfb->update[rfb->nupdates++];
+       update->enc = THUNK_RFB_TYPE_RRE;
+       update->x = x;
+       update->y = y;
+       update->w = w;
+       update->h = h;
+       memcpy(update->pixel, pixel, 4);
+
+       rfb->first_mergable = rfb->nupdates;
+}



Home | Main Index | Thread Index | Old Index