Module Name: src
Committed By: jmcneill
Date: Fri Dec 30 11:06:18 UTC 2011
Modified Files:
src/sys/arch/usermode/dev: vncfb.c
src/sys/arch/usermode/usermode: thunk.c
Log Message:
use O_ASYNC + SIGIO instead of polling for input
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/dev/vncfb.c
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/usermode/usermode/thunk.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/usermode/dev/vncfb.c
diff -u src/sys/arch/usermode/dev/vncfb.c:1.3 src/sys/arch/usermode/dev/vncfb.c:1.4
--- src/sys/arch/usermode/dev/vncfb.c:1.3 Fri Dec 30 09:31:44 2011
+++ src/sys/arch/usermode/dev/vncfb.c Fri Dec 30 11:06:18 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: vncfb.c,v 1.3 2011/12/30 09:31:44 jmcneill Exp $ */
+/* $NetBSD: vncfb.c,v 1.4 2011/12/30 11:06:18 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <[email protected]>
@@ -35,7 +35,7 @@
#include "opt_wsemul.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vncfb.c,v 1.3 2011/12/30 09:31:44 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vncfb.c,v 1.4 2011/12/30 11:06:18 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -80,7 +80,7 @@ struct vncfb_softc {
int sc_kbd_enable;
- callout_t sc_callout;
+ void *sc_ih;
void *sc_sih;
};
@@ -103,7 +103,7 @@ static paddr_t vncfb_mmap(void *, void *
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_poll(void *);
+static int vncfb_intr(void *);
static void vncfb_softintr(void *);
static int vncfb_kbd_enable(void *, int);
@@ -188,9 +188,6 @@ vncfb_attach(device_t parent, device_t s
(sc->sc_depth / 8), KM_SLEEP);
KASSERT(sc->sc_framebuf != NULL);
- callout_init(&sc->sc_callout, 0);
- callout_setfunc(&sc->sc_callout, vncfb_poll, sc);
-
aprint_naive("\n");
aprint_normal(": %ux%u %ubpp (port %u)\n",
sc->sc_width, sc->sc_height, sc->sc_depth, taa->u.vnc.port);
@@ -208,7 +205,7 @@ vncfb_attach(device_t parent, device_t s
panic("couldn't open rfb server");
sc->sc_sih = softint_establish(SOFTINT_SERIAL, vncfb_softintr, sc);
- callout_schedule(&sc->sc_callout, 1);
+ sc->sc_ih = sigio_intr_establish(vncfb_intr, sc);
vcons_init(&sc->sc_vd, sc, &vncfb_defaultscreen, &vncfb_accessops);
sc->sc_vd.init_screen = vncfb_init_screen;
@@ -455,14 +452,17 @@ static void
vncfb_update(struct vncfb_softc *sc, int x, int y, int w, int h)
{
thunk_rfb_update(&sc->sc_rfb, x, y, w, h);
+ softint_schedule(sc->sc_sih);
}
-static void
-vncfb_poll(void *priv)
+static int
+vncfb_intr(void *priv)
{
struct vncfb_softc *sc = priv;
softint_schedule(sc->sc_sih);
+
+ return 0;
}
static void
@@ -486,8 +486,6 @@ vncfb_softintr(void *priv)
break;
}
}
-
- callout_schedule(&sc->sc_callout, 1);
}
static int
Index: src/sys/arch/usermode/usermode/thunk.c
diff -u src/sys/arch/usermode/usermode/thunk.c:1.59 src/sys/arch/usermode/usermode/thunk.c:1.60
--- src/sys/arch/usermode/usermode/thunk.c:1.59 Fri Dec 30 11:05:07 2011
+++ src/sys/arch/usermode/usermode/thunk.c Fri Dec 30 11:06:18 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.59 2011/12/30 11:05:07 reinoud Exp $ */
+/* $NetBSD: thunk.c,v 1.60 2011/12/30 11:06:18 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <[email protected]>
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifdef __NetBSD__
-__RCSID("$NetBSD: thunk.c,v 1.59 2011/12/30 11:05:07 reinoud Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.60 2011/12/30 11:06:18 jmcneill Exp $");
#endif
#include <sys/types.h>
@@ -1077,6 +1077,7 @@ thunk_rfb_poll(thunk_rfb_t *rfb, thunk_r
struct sockaddr_in sin;
struct pollfd fds[1];
socklen_t sinlen;
+ int flags;
/* poll for connections */
fds[0].fd = rfb->sockfd;
@@ -1103,6 +1104,19 @@ thunk_rfb_poll(thunk_rfb_t *rfb, thunk_r
}
rfb->connected = true;
+
+ /* enable sigio on input */
+ flags = fcntl(rfb->clientfd, F_GETFL, 0);
+ fcntl(rfb->clientfd, F_SETFL, flags | O_ASYNC);
+ error = fcntl(rfb->clientfd, F_SETOWN, getpid());
+ if (error) {
+ fprintf(stdout, "rfb: setown failed: %s\n",
+ strerror(errno));
+ close(rfb->clientfd);
+ rfb->clientfd = -1;
+ return -1;
+ }
+
rfb->nupdates = 0;
thunk_rfb_update(rfb, 0, 0, rfb->width, rfb->height);
}