summaryrefslogtreecommitdiff
path: root/xserver
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2007-05-25 19:10:44 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2007-05-25 19:10:44 +0000
commit9115084396538615472d09ba93bfc94c21cf95f3 (patch)
treee75fd417e13d69b0eab528d1ba6b103f3499b12c /xserver
parentf2880f188bbe1583ee0e10026511fb6ec7182d74 (diff)
Start filling the holes.
Diffstat (limited to 'xserver')
-rw-r--r--xserver/hw/kdrive/openbsd/openbsd.c34
-rw-r--r--xserver/hw/kdrive/wscons/Makefile.in2
-rw-r--r--xserver/hw/kdrive/wscons/keyboard.c25
-rw-r--r--xserver/hw/kdrive/wscons/mouse.c87
-rw-r--r--xserver/hw/kdrive/wscons/wsfb.c31
-rw-r--r--xserver/hw/kdrive/wscons/wsinit.c8
6 files changed, 152 insertions, 35 deletions
diff --git a/xserver/hw/kdrive/openbsd/openbsd.c b/xserver/hw/kdrive/openbsd/openbsd.c
index 44df7456c..9d1bf6d04 100644
--- a/xserver/hw/kdrive/openbsd/openbsd.c
+++ b/xserver/hw/kdrive/openbsd/openbsd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: openbsd.c,v 1.1 2007/05/25 15:33:32 matthieu Exp $ */
+/* $OpenBSD: openbsd.c,v 1.2 2007/05/25 19:10:43 matthieu Exp $ */
/*
* Copyright (c) 2007 Matthieu Herrb <matthieu@openbsd.org>
*
@@ -21,6 +21,11 @@
#define XK_PUBLISHING
#include <X11/keysym.h>
#include <X11/Xdefs.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <dev/wscons/wsconsio.h>
+
#include "kdrive.h"
#include "kopenbsd.h"
@@ -30,31 +35,50 @@ int OpenBSDApmFd = -1;
static int activeVT;
static Bool enabled;
+#define WSCONS_DEV "/dev/ttyC0"
+
+#define DBG(x) ErrorF x
+
static int
OpenBSDInit(void)
{
- WsconsConsoleFd = -1;
+ DBG(("OpenBSDInit\n"));
+ WsconsConsoleFd = open(WSCONS_DEV, O_RDWR);
+
+ if (WsconsConsoleFd == -1) {
+ FatalError("OpenBSDInit: error opening %s (%d)\n",
+ WSCONS_DEV, errno);
+ }
return 1;
}
Bool
OpenBSDFindPci(CARD16 vendor, CARD16 device, CARD32 count, KdCardAttr *attr)
{
+ DBG(("OpenBSDFindPci %04hx %04hx\n", vendor, device));
/* Find a PCI device matching vendor/device */
/* return KdCardAttr */
- return FALSE;
+ /* XXX */
+ attr->bus = 0;
+ attr->slot = 0;
+ attr->func = 0;
+
+ return TRUE;
}
unsigned char *
OpenBSDGetPciCfg(KdCardAttr *attr)
{
/* Get Config registers for card at attr */
+ DBG(("OpenBSDGetPciCfg %d:%d:%d\n",
+ attr->bus, attr->slot, attr->func));
return NULL;
}
static void
OpenBSDEnable(void)
{
+ DBG(("OpenBSDEnable\n"));
if (enabled)
return;
if (kdSwitchPending) {
@@ -70,6 +94,7 @@ OpenBSDEnable(void)
static Bool
OpenBSDSpecialKey(KeySym sym)
{
+ DBG(("OpenBSDSpecialKey\n"));
/* Initiate VT switch if needed */
return FALSE;
}
@@ -77,6 +102,7 @@ OpenBSDSpecialKey(KeySym sym)
static void
OpenBSDDisable(void)
{
+ DBG(("OpenBSDDisable\n"));
enabled = FALSE;
/* Back to text mode */
/* Remove apm hooks */
@@ -85,6 +111,7 @@ OpenBSDDisable(void)
static void
OpenBSDFini(void)
{
+ DBG(("OpenBSDFini\n"));
if (WsconsConsoleFd < 0)
return;
/* switch back to initial VT */
@@ -102,5 +129,6 @@ KdOsFuncs OpenBSDFuncs = {
void
OsVendorInit(void)
{
+ DBG(("OsVendorInit\n"));
KdOsInit(&OpenBSDFuncs);
}
diff --git a/xserver/hw/kdrive/wscons/Makefile.in b/xserver/hw/kdrive/wscons/Makefile.in
index 47726d0fb..01778a99a 100644
--- a/xserver/hw/kdrive/wscons/Makefile.in
+++ b/xserver/hw/kdrive/wscons/Makefile.in
@@ -14,7 +14,7 @@
@SET_MAKE@
-# $OpenBSD: Makefile.in,v 1.1 2007/05/25 16:46:59 matthieu Exp $
+# $OpenBSD: Makefile.in,v 1.2 2007/05/25 19:10:43 matthieu Exp $
srcdir = @srcdir@
diff --git a/xserver/hw/kdrive/wscons/keyboard.c b/xserver/hw/kdrive/wscons/keyboard.c
index 7a97a0f4e..eed8c4e02 100644
--- a/xserver/hw/kdrive/wscons/keyboard.c
+++ b/xserver/hw/kdrive/wscons/keyboard.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: keyboard.c,v 1.1 2007/05/25 15:33:32 matthieu Exp $ */
+/* $OpenBSD: keyboard.c,v 1.2 2007/05/25 19:10:43 matthieu Exp $ */
/*
* Copyright (c) 2007 Matthieu Herrb <matthieu@openbsd.org>
*
@@ -22,6 +22,9 @@
#include <X11/keysym.h>
+#include <errno.h>
+#include <dev/wscons/wsconsio.h>
+
extern int WsconsConsoleFd;
static int WsconsKbdType;
@@ -40,16 +43,26 @@ WsconsKeyboardRead(int fd, void *closure)
KdEnqueueKeyboardEvent(b & 0x7f, b & 0x80);
}
-static void
+static int
WsconsKeyboardEnable(int fd, void *closure)
{
+ int option = WSKBD_RAW;
+
/* Switch to X mode */
+ if (ioctl(fd, WSKBDIO_SETMODE, &option) == -1) {
+ ErrorF("WsconsKeyboardEnable: WSKBDIO_SETMODE: %d\n", errno);
+ return -1;
+ }
+ return fd;
}
static void
WsconsKeyboardDisable(int fd, void *closure)
{
+ int option = WSKBD_TRANSLATED;
+
/* Back to console mode */
+ ioctl(fd, WSKBDIO_SETMODE, &option);
}
static int
@@ -74,11 +87,19 @@ WsconsKeyboardFini(void)
static void
WsconsKeyboardLeds(int leds)
{
+ ioctl(WsconsConsoleFd, WSKBDIO_SETLEDS, &leds);
}
static void
WsconsKeyboardBell(int volume, int pitch, int duration)
{
+ struct wskbd_bell_data wsb;
+
+ wsb.which = WSKBD_BELL_DOALL;
+ wsb.pitch = pitch;
+ wsb.period = duration;
+ wsb.volume = volume;
+ ioctl(WsconsConsoleFd, WSKBDIO_COMPLEXBELL, &wsb);
}
KdKeyboardFuncs WsconsKeyboardFuncs = {
diff --git a/xserver/hw/kdrive/wscons/mouse.c b/xserver/hw/kdrive/wscons/mouse.c
index 597f1875b..033804997 100644
--- a/xserver/hw/kdrive/wscons/mouse.c
+++ b/xserver/hw/kdrive/wscons/mouse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mouse.c,v 1.1 2007/05/25 15:33:32 matthieu Exp $ */
+/* $OpenBSD: mouse.c,v 1.2 2007/05/25 19:10:43 matthieu Exp $ */
/*
* Copyright (c) 2007 Matthieu Herrb <matthieu@openbsd.org>
*
@@ -23,42 +23,84 @@
#include <termios.h>
#include <X11/X.h>
#include <X11/Xproto.h>
+#include <dev/wscons/wsconsio.h>
+
#include "inputstr.h"
#include "scrnintstr.h"
#include "kdrive.h"
+#define NUMEVENTS 64
+
+static unsigned long kdbuttons[] = {
+ KD_BUTTON_1,
+ KD_BUTTON_2,
+ KD_BUTTON_3
+};
+
static void
MouseRead(int mousePort, void *closure)
{
+ static struct wscons_event eventList[NUMEVENTS];
+ struct wscons_event *event = eventList;
KdMouseInfo *mi;
- int dx, dy;
- unsigned long flags;
+ int n;
- /* flags:
- KD_MOUSE_DELTA
- KD_BUTTON_{1,2,3} */
- /* Read and post mouse events */
- KdEnqueueMouseEvent(mi, flags, dx, dy);
-
+ n = read(mousePort, &eventList,
+ NUMEVENTS * sizeof(struct wscons_event));
+ if (n <= 0)
+ return;
+ n /= sizeof(struct wscons_event);
+ while (n--) {
+ int dx = 0, dy = 0;
+ unsigned long flags = 0;
+
+ switch(event->type) {
+ case WSCONS_EVENT_MOUSE_UP:
+ flags &= ~kdbuttons[event->value];
+ break;
+ case WSCONS_EVENT_MOUSE_DOWN:
+ flags |= kdbuttons[1<<event->value];
+ break;
+ case WSCONS_EVENT_MOUSE_DELTA_X:
+ dx = event->value;
+ flags |= KD_MOUSE_DELTA;
+ break;
+ case WSCONS_EVENT_MOUSE_DELTA_Y:
+ dy = event->value;
+ flags |= KD_MOUSE_DELTA;
+ break;
+ case WSCONS_EVENT_MOUSE_ABSOLUTE_X:
+ dx = event->value;
+ break;
+ case WSCONS_EVENT_MOUSE_ABSOLUTE_Y:
+ dy = event->value;
+ break;
+ default:
+ ErrorF("MouseRead: bad wsmouse event type=%d\n",
+ event->type);
+ continue;
+ } /* case */
+ KdEnqueueMouseEvent(mi, flags, dx, dy);
+ }
}
int MouseInputType;
-char *kdefaultMouse[] = {
- "/dev/wsmouse",
- "/dev/wsmouse0",
- "/dev/tty00",
- "/dev/tty01"
-};
-
-#define NUM_DEFAULT_MOUSE (sizeof (kdefaultMouse) / sizeof (kdefaultMouse[0]))
static Bool
MouseInit(void)
{
+ char *device = "/dev/wsmouse";
+ int port;
+
if (!MouseInputType)
MouseInputType = KdAllocInputType();
- return TRUE;
+ port = open(device, O_RDWR | O_NONBLOCK);
+ if (port == -1) {
+ ErrorF("MouseInit: couldn't open %s (%d)\n", device, errno);
+ return FALSE;
+ }
+ return KdRegisterFd(MouseInputType, port, MouseRead, NULL);
}
static void
@@ -66,14 +108,7 @@ MouseFini(void)
{
KdMouseInfo *mi;
- KdUnregisterFds(MouseInputType, NULL);
- for (mi = kdMouseInfo; mi != NULL; mi = mi->next) {
- if (mi->inputType == MouseInputType) {
- free(mi->driver);
- mi->driver = NULL;
- mi->inputType = 0;
- }
- }
+ KdUnregisterFds(MouseInputType, TRUE);
}
KdMouseFuncs WsconsMouseFuncs = {
diff --git a/xserver/hw/kdrive/wscons/wsfb.c b/xserver/hw/kdrive/wscons/wsfb.c
index 78498dc8b..b82635f02 100644
--- a/xserver/hw/kdrive/wscons/wsfb.c
+++ b/xserver/hw/kdrive/wscons/wsfb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsfb.c,v 1.1 2007/05/25 15:33:32 matthieu Exp $ */
+/* $OpenBSD: wsfb.c,v 1.2 2007/05/25 19:10:43 matthieu Exp $ */
/*
* Copyright (c) 2007 Matthieu Herrb <matthieu@openbsd.org>
*
@@ -25,9 +25,12 @@
#include "wsfb.h"
+#define DBG(x) ErrorF x
+
Bool
wsfbInitialize(KdCardInfo *card, WsfbPriv *priv)
{
+ DBG(("wsfbInitialize\n"));
return TRUE;
}
@@ -36,6 +39,7 @@ wsfbCardInit(KdCardInfo *card)
{
WsfbPriv *priv;
+ DBG(("wsfbCardInit\n"));
priv = (WsfbPriv *)xalloc(sizeof(WsfbPriv));
if (priv == NULL)
return FALSE;
@@ -51,6 +55,7 @@ wsfbCardInit(KdCardInfo *card)
Bool
wsfbScreenInitialize(KdScreenInfo *screen, WsfbScrPriv *scrpriv)
{
+ DBG(("wsfbScreenInitialize\n"));
return TRUE;
}
@@ -59,6 +64,7 @@ wsfbScreenInit(KdScreenInfo *screen)
{
WsfbScrPriv *scrPriv;
+ DBG(("wsfbScreenInit\n"));
scrPriv = (WsfbScrPriv *)xalloc(sizeof(WsfbScrPriv));
if (scrPriv == NULL)
return FALSE;
@@ -75,6 +81,7 @@ wsfbScreenInit(KdScreenInfo *screen)
Bool
wsfbInitScreen(ScreenPtr pScreen)
{
+ DBG(("wsfbInitScreen\n"));
pScreen->CreateColormap = wsfbCreateColormap;
return TRUE;
}
@@ -83,6 +90,7 @@ wsfbInitScreen(ScreenPtr pScreen)
Bool
wsfbFinishInitScreen(ScreenPtr pScreen)
{
+ DBG(("wsfbFinishInitScreen\n"));
if (!shadowSetup(pScreen))
return FALSE;
#ifdef RANDR
@@ -95,40 +103,47 @@ wsfbFinishInitScreen(ScreenPtr pScreen)
Bool
wsfbCreateResources(ScreenPtr pScreen)
{
+ DBG(("wsfbCreateResources\n"));
return wsfbSetShadow(pScreen);
}
void
wsfbPreserve(KdCardInfo *card)
{
+ DBG(("wsfbPreserve\n"));
}
Bool
wsfbEnable(ScreenPtr pScreen)
{
+ DBG(("wsfbEnable\n"));
return TRUE;
}
Bool
wsfbDPMS(ScreenPtr pScreen, int mode)
{
+ DBG(("wsfb DPMS %d\n", mode));
return TRUE;
}
void
wsfbDisable(ScreenPtr pScreen)
{
+ DBG(("wsfbDisable\n"));
}
void
wsfbRestore(KdCardInfo *card)
{
+ DBG(("wsfbRestore\n"));
}
void
wsfbScreenFini(KdScreenInfo *screen)
{
+ DBG(("wsfbScreenFini\n"));
}
void
@@ -136,6 +151,7 @@ wsfbCardFini(KdCardInfo *card)
{
WsfbPriv *priv = card->driver;
+ DBG(("wsfbCardFini\n"));
/* unmap framebuffer */
/* close fd */
xfree(priv);
@@ -144,11 +160,13 @@ wsfbCardFini(KdCardInfo *card)
void
wsfbGetColors(ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
{
+ DBG(("wsfbGetColors %d\n", n));
}
void
wsfbPutColors(ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
{
+ DBG(("wsfbPutColors %d\n", n));
}
Bool
@@ -158,6 +176,7 @@ wsfbMapFramebuffer(KdScreenInfo *screen)
KdMouseMatrix m;
WsfbPriv *priv = screen->card->driver;
+ DBG(("wsfbMapFrameBuffer\n"));
if (scrPriv->randr != RR_Rotate_0)
scrPriv->shadow = TRUE;
else
@@ -171,7 +190,7 @@ wsfbMapFramebuffer(KdScreenInfo *screen)
/* screen->width = priv->var.xres;
screen->height = priv->var.yres; */
screen->memory_base = (CARD8 *)(priv->fb);
- /* screen->memory_size = priv->fix.smem_len; */
+ /* screen->memoryG_size = priv->fix.smem_len; */
if (scrPriv->shadow) {
if (!KdShadowFbAlloc(screen, 0,
@@ -197,17 +216,20 @@ wsfbWindowLinear(ScreenPtr pScreen,
CARD32 *size,
void *closure)
{
+ DBG(("wsfbWindowLinear\n"));
return NULL;
}
void
wsfbSetScreenSizes(ScreenPtr pScreen)
{
+ DBG(("wsfbSetScreenSizes\n"));
}
Bool
wsfbUnmapFramebuffer(KdScreenInfo *screen)
{
+ DBG(("wsfbUnmapFramebuffer\n"));
KdShadowFbFree(screen, 0);
return TRUE;
}
@@ -215,12 +237,14 @@ wsfbUnmapFramebuffer(KdScreenInfo *screen)
Bool
wsfbSetShadow(ScreenPtr pScreen)
{
+ DBG(("wsfbSetShadow\n"));
return TRUE;
}
Bool
wsfbCreateColormap(ColormapPtr pmap)
{
+ DBG(("wsfbCreateColormap\n"));
return TRUE;
}
@@ -228,6 +252,7 @@ wsfbCreateColormap(ColormapPtr pmap)
Bool
wsfbRandRGetInfo(ScreenPtr pScreen, Rotation *rotations)
{
+ DBG(("wsfbRandRGetInfo\n"));
return TRUE;
}
@@ -237,12 +262,14 @@ wsfbRandRSetConfig(ScreenPtr pScreen,
int rate,
RRScreenSizePtr pSize)
{
+ DBG(("wsfbRandRSetConfig\n"));
return TRUE;
}
Bool
wsfbRandRInit(ScreenPtr pScreen)
{
+ DBG(("wsfbRandRInit\n"));
return TRUE;
}
#endif /* RANDR */
diff --git a/xserver/hw/kdrive/wscons/wsinit.c b/xserver/hw/kdrive/wscons/wsinit.c
index e5e8fe424..dc4906f93 100644
--- a/xserver/hw/kdrive/wscons/wsinit.c
+++ b/xserver/hw/kdrive/wscons/wsinit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsinit.c,v 1.1 2007/05/25 15:33:32 matthieu Exp $ */
+/* $OpenBSD: wsinit.c,v 1.2 2007/05/25 19:10:43 matthieu Exp $ */
/*
* Copyright (c) 2007 Matthieu Herrb <matthieu@openbsd.org>
*
@@ -23,23 +23,28 @@
#include "kdrive.h"
#include "wsfb.h"
+#define DBG(x) ErrorF x
+
void
InitCard(char *name)
{
KdCardAttr attr;
+ DBG(("InitCard\n"));
KdCardInfoAdd(&wsfbFuncs, &attr, 0);
}
void
InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
{
+ DBG(("InitOutput\n"));
KdInitOutput(pScreenInfo, argc, argv);
}
void
InitInput(int argc, char **argv)
{
+ DBG(("InitInput\n"));
KdInitInput(&WsconsMouseFuncs, &WsconsKeyboardFuncs);
}
@@ -55,6 +60,7 @@ ddxUseMsg(void)
int
ddxProcessArgument(int argc, char **argv, int i)
{
+ DBG(("ddxProcessArgument\n"));
return KdProcessArgument(argc, argv, i);
}