Adapt OpenBSD/wscons kdrive drivers to changes in xserver 1.4.

Still not working but at least building again.
This commit is contained in:
matthieu 2007-12-23 14:28:10 +00:00
parent d99925b594
commit 067fedef2d
7 changed files with 123 additions and 82 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kopenbsd.h,v 1.1 2007/05/25 15:33:32 matthieu Exp $ */
/* $OpenBSD: kopenbsd.h,v 1.2 2007/12/23 14:28:10 matthieu Exp $ */
/*
* Copyright (c) 2007 Matthieu Herrb <matthieu.herrb@laas.fr>
*
@ -18,7 +18,7 @@
#ifndef _KOpenBSD_H
#define _KOpenBSD_H
Bool OpenBSDFindPCI(CARD16, CARD16, CARD32 , KdCardAttr *);
Bool OpenBSDFindPci(CARD16, CARD16, CARD32 , KdCardAttr *);
unsigned char *OpenBSDGetPciCfg(KdCardAttr *);
#endif /* _KOpenBSD_H */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: openbsd.c,v 1.3 2007/05/27 00:53:47 matthieu Exp $ */
/* $OpenBSD: openbsd.c,v 1.4 2007/12/23 14:28:10 matthieu Exp $ */
/*
* Copyright (c) 2007 Matthieu Herrb <matthieu@openbsd.org>
*
@ -24,15 +24,15 @@
#include <errno.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <dev/wscons/wsconsio.h>
#include "kdrive.h"
#include "kopenbsd.h"
static int vtno;
int WsconsConsoleFd;
int OpenBSDApmFd = -1;
static int activeVT;
static Bool enabled;
#define WSCONS_DEV "/dev/ttyC0"
@ -123,13 +123,28 @@ OpenBSDFini(void)
}
}
static void
OpenBSDBell(int volume, int pitch, int duration)
{
struct wskbd_bell_data wsb;
DBG(("OpenBSDBell volume %d pictch %d duration %d\n",
volume, pitch, duration));
wsb.which = WSKBD_BELL_DOALL;
wsb.pitch = pitch;
wsb.period = duration;
wsb.volume = volume;
if (ioctl(WsconsConsoleFd, WSKBDIO_COMPLEXBELL, &wsb) == -1)
ErrorF("WsconsKeyboardBell: %s\n", strerror(errno));
}
KdOsFuncs OpenBSDFuncs = {
OpenBSDInit,
OpenBSDEnable,
OpenBSDSpecialKey,
OpenBSDDisable,
OpenBSDFini,
0
OpenBSDBell,
};
void

View File

@ -891,8 +891,8 @@ extern KdPointerDriver VxWorksMouseDriver;
extern KdKeyboardDriver VxWorksKeyboardDriver;
extern KdOsFuncs VxWorksFuncs;
extern KdMouseFuncs WsconsMouseFuncs;
extern KdKeyboardFuncs WsconsKeyboardFuncs;
extern KdPointerDriver WsconsMouseDriver;
extern KdKeyboardDriver WsconsKeyboardDriver;
extern KdOsFuncs OpenBSDFuncs;
/* kmap.c */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: keyboard.c,v 1.3 2007/05/27 05:17:06 matthieu Exp $ */
/* $OpenBSD: keyboard.c,v 1.4 2007/12/23 14:28:10 matthieu Exp $ */
/*
* Copyright (c) 2007 Matthieu Herrb <matthieu@openbsd.org>
*
@ -23,12 +23,12 @@
#include <X11/keysym.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <dev/wscons/wsconsio.h>
#define DBG(x) ErrorF x
extern int WsconsConsoleFd;
static int WsconsKbdType;
static void
wskbdLoad(void)
@ -45,17 +45,17 @@ wskbdRead(int fd, void *closure)
{
struct wscons_event events[NUM_EVENTS];
int i, n, type;
unsigned char b;
DBG(("wskbdRead\n"));
if ((n = read(WsconsConsoleFd, events, sizeof(events))) > 0) {
if ((n = read(fd, events, sizeof(events))) > 0) {
n /= sizeof(struct wscons_event);
for (i = 0; i < n; i++) {
type = events[i].type;
if (type == WSCONS_EVENT_KEY_UP ||
type == WSCONS_EVENT_KEY_DOWN) {
KdEnqueueKeyboardEvent(events[i].value,
KdEnqueueKeyboardEvent(closure,
events[i].value,
type == WSCONS_EVENT_KEY_DOWN ?
TRUE : FALSE);
}
@ -64,79 +64,73 @@ wskbdRead(int fd, void *closure)
}
static int
wskbdEnable(int fd, void *closure)
wskbdEnable(KdKeyboardInfo *ki)
{
int option = WSKBD_RAW;
int fd = WsconsConsoleFd;
DBG(("wskbdEnable\n"));
if (ki == NULL)
return !Success;
ki->driverPrivate = (void *)fd;
/* Switch to X mode */
if (ioctl(fd, WSKBDIO_SETMODE, &option) == -1) {
ErrorF("wskbdEnable: WSKBDIO_SETMODE: %d\n", errno);
return -1;
}
return fd;
KdRegisterFd (fd, wskbdRead, ki);
return Success;
}
static void
wskbdDisable(int fd, void *closure)
wskbdDisable(KdKeyboardInfo *ki)
{
int option = WSKBD_TRANSLATED;
int fd;
DBG(("wskbdDisable\n"));
if (ki == NULL)
return;
fd = (int)ki->driverPrivate;
/* Back to console mode */
ioctl(fd, WSKBDIO_SETMODE, &option);
}
static int
wskbdInit(void)
wskbdInit(KdKeyboardInfo *ki)
{
DBG(("wskbdInit\n"));
if (!WsconsKbdType)
WsconsKbdType = KdAllocInputType();
KdRegisterFd(WsconsKbdType, WsconsConsoleFd, wskbdRead, 0);
wskbdEnable(WsconsConsoleFd, 0);
KdRegisterFdEnableDisable(WsconsConsoleFd,
wskbdEnable, wskbdDisable);
return 1;
if (!ki)
return !Success;
if (ki->path)
xfree(ki->path);
ki->path = KdSaveString("console");
if (ki->name)
xfree(ki->name);
ki->name = KdSaveString("Wscons keyboard");
wskbdLoad();
return Success;
}
static void
wskbdFini(void)
{
DBG(("wskbdFini\n"));
wskbdDisable(WsconsConsoleFd, 0);
KdUnregisterFds(WsconsKbdType, FALSE);
}
static void
wskbdLeds(int leds)
wskbdLeds(KdKeyboardInfo *ki, int leds)
{
DBG(("wskbdLeds %d\n", leds));
if (!ki)
return;
if (ioctl(WsconsConsoleFd, WSKBDIO_SETLEDS, &leds) == -1)
ErrorF("wskbd WSKBDIO_SETLEDS: %s\n",
strerror(errno));
}
static void
wskbdBell(int volume, int pitch, int duration)
{
struct wskbd_bell_data wsb;
DBG(("wskbdBell volume %d pictch %d duration %d\n",
volume, pitch, duration));
wsb.which = WSKBD_BELL_DOALL;
wsb.pitch = pitch;
wsb.period = duration;
wsb.volume = volume;
if (ioctl(WsconsConsoleFd, WSKBDIO_COMPLEXBELL, &wsb) == -1)
ErrorF("WsconsKeyboardBell: %s\n", strerror(errno));
}
KdKeyboardFuncs WsconsKeyboardFuncs = {
wskbdLoad,
wskbdInit,
wskbdLeds,
wskbdBell,
wskbdFini,
3,
KdKeyboardDriver WsconsKeyboardDriver = {
"keyboard",
.Init = wskbdInit,
.Enable = wskbdEnable,
.Leds = wskbdLeds,
.Disable = wskbdDisable
};

View File

@ -1,4 +1,4 @@
/* $OpenBSD: mouse.c,v 1.4 2007/05/27 05:17:06 matthieu Exp $ */
/* $OpenBSD: mouse.c,v 1.5 2007/12/23 14:28:10 matthieu Exp $ */
/*
* Copyright (c) 2007 Matthieu Herrb <matthieu@openbsd.org>
*
@ -42,6 +42,7 @@ static unsigned long kdbuttons[] = {
static void
wsmouseRead(int mousePort, void *closure)
{
KdPointerInfo *pi = closure;
static struct wscons_event eventList[NUMEVENTS];
struct wscons_event *event = eventList;
int n;
@ -81,41 +82,67 @@ wsmouseRead(int mousePort, void *closure)
event->type);
continue;
} /* case */
KdEnqueueMouseEvent(kdMouseInfo, flags, dx, dy);
KdEnqueuePointerEvent(pi, flags, dx, dy, 0);
}
}
int MouseInputType;
static Bool
wsmouseInit(void)
static Status
wsmouseInit(KdPointerInfo *pi)
{
char *device = "/dev/wsmouse";
int port;
DBG(("wsmouseInit\n"));
if (!MouseInputType)
MouseInputType = KdAllocInputType();
if (pi->path == NULL)
pi->path = KdSaveString(device);
port = open(device, O_RDWR | O_NONBLOCK);
if (port == -1) {
ErrorF("wsmouseInit: couldn't open %s (%d)\n", device, errno);
return FALSE;
if (pi->name == NULL)
pi->name = KdSaveString("Wscons mouse");
return Success;
}
static Status
wsmouseEnable(KdPointerInfo *pi)
{
int fd;
DBG(("wsmouseEnable\n"));
if (pi == NULL || pi->driverPrivate == NULL || pi->path == NULL)
return BadImplementation;
fd = open(pi->path, O_RDWR | O_NONBLOCK);
if (fd < 0)
return BadMatch;
if (!KdRegisterFd(fd, wsmouseRead, pi)) {
close(fd);
return BadAlloc;
}
return KdRegisterFd(MouseInputType, port, wsmouseRead, NULL);
pi->driverPrivate = (void *)fd;
return Success;
}
static void
wsmouseDisable(KdPointerInfo *pi)
{
DBG(("wsmouseDisable\n"));
KdUnregisterFd(pi, (int)pi->driverPrivate, TRUE);
}
static void
wsmouseFini(void)
wsmouseFini(KdPointerInfo *pi)
{
KdMouseInfo *mi;
DBG(("wsmouseFini\n"));
KdUnregisterFds(MouseInputType, TRUE);
}
KdMouseFuncs WsconsMouseFuncs = {
KdPointerDriver WsconsMouseDriver = {
"mouse",
wsmouseInit,
wsmouseFini
wsmouseEnable,
wsmouseDisable,
wsmouseFini,
NULL,
};

View File

@ -1,4 +1,4 @@
/* $OpenBSD: wsfb.c,v 1.4 2007/05/29 20:14:43 matthieu Exp $ */
/* $OpenBSD: wsfb.c,v 1.5 2007/12/23 14:28:10 matthieu Exp $ */
/*
* Copyright (c) 2007 Matthieu Herrb <matthieu@openbsd.org>
*
@ -39,6 +39,7 @@
#include <kdrive-config.h>
#endif
#include <dev/wscons/wsconsio.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <errno.h>
@ -80,7 +81,7 @@ Bool
wsfbMapFramebuffer(KdScreenInfo *screen)
{
WsfbScrPriv *scrPriv = screen->driver;
KdMouseMatrix m;
KdPointerMatrix m;
WsfbPriv *priv = screen->card->driver;
size_t len;
@ -93,9 +94,9 @@ wsfbMapFramebuffer(KdScreenInfo *screen)
else
scrPriv->shadow = FALSE;
KdComputeMouseMatrix(&m, scrPriv->randr,
KdComputePointerMatrix(&m, scrPriv->randr,
screen->width, screen->height);
KdSetMouseMatrix(&m);
KdSetPointerMatrix(&m);
DBG(("screen->width %d\n", screen->width));
DBG(("screen->height %d\n", screen->height));
@ -171,7 +172,7 @@ wsfbScreenInitialize(KdScreenInfo *screen, WsfbScrPriv *scrpriv)
{
struct wsdisplay_gfx_mode gfxmode;
WsfbPriv *priv;
int depth, bpp;
int depth = 24;
priv = screen->card->driver;
@ -301,8 +302,6 @@ wsfbEnable(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
WsfbPriv *priv = pScreenPriv->card->driver;
size_t len;
int wsmode = WSDISPLAYIO_MODE_DUMBFB;
DBG(("wsfbEnable\n"));
@ -354,7 +353,6 @@ wsfbRestore(KdCardInfo *card)
void
wsfbScreenFini(KdScreenInfo *screen)
{
int mode = WSDISPLAYIO_MODE_EMUL;
DBG(("wsfbScreenFini\n"));
wsfbUnmapFramebuffer(screen);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: wsinit.c,v 1.2 2007/05/25 19:10:43 matthieu Exp $ */
/* $OpenBSD: wsinit.c,v 1.3 2007/12/23 14:28:10 matthieu Exp $ */
/*
* Copyright (c) 2007 Matthieu Herrb <matthieu@openbsd.org>
*
@ -44,8 +44,15 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
void
InitInput(int argc, char **argv)
{
KdKeyboardInfo *ki;
DBG(("InitInput\n"));
KdInitInput(&WsconsMouseFuncs, &WsconsKeyboardFuncs);
KdAddKeyboardDriver(&WsconsKeyboardDriver);
KdAddPointerDriver(&WsconsMouseDriver);
ki = KdParseKeyboard("keybd");
KdAddKeyboard(ki);
KdInitInput();
}
void