diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2007-05-25 15:33:33 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2007-05-25 15:33:33 +0000 |
commit | ee0eb82d3f507e1f9804c386c44fcd09b652638d (patch) | |
tree | ffdda753dae1ea0028dc4bbaa82fd5b8f396e8de /xserver | |
parent | 4365e278c0984c45d3034ee70dbec61b317cd9f5 (diff) |
Add skeleton implentation of Xwscons a kdrive based X server for
wscons's dumb framebuffer mode. This is an empty shell for now.
Diffstat (limited to 'xserver')
-rw-r--r-- | xserver/hw/kdrive/openbsd/Makefile.am | 24 | ||||
-rw-r--r-- | xserver/hw/kdrive/openbsd/kopenbsd.h | 24 | ||||
-rw-r--r-- | xserver/hw/kdrive/openbsd/openbsd.c | 106 | ||||
-rw-r--r-- | xserver/hw/kdrive/wscons/Makefile.am | 26 | ||||
-rw-r--r-- | xserver/hw/kdrive/wscons/keyboard.c | 91 | ||||
-rw-r--r-- | xserver/hw/kdrive/wscons/mouse.c | 82 | ||||
-rw-r--r-- | xserver/hw/kdrive/wscons/wsfb.c | 248 | ||||
-rw-r--r-- | xserver/hw/kdrive/wscons/wsinit.c | 85 |
8 files changed, 686 insertions, 0 deletions
diff --git a/xserver/hw/kdrive/openbsd/Makefile.am b/xserver/hw/kdrive/openbsd/Makefile.am new file mode 100644 index 000000000..30befeb31 --- /dev/null +++ b/xserver/hw/kdrive/openbsd/Makefile.am @@ -0,0 +1,24 @@ +# $OpenBSD: Makefile.am,v 1.1 2007/05/25 15:33:32 matthieu Exp $ + +INCLUDES = \ + @KDRIVE_INCS@ \ + @KDRIVE_CFLAGS@ + +AM_CFLAGS = -DHAVE_DIX_CONFIG_H + +noinst_LIBRARIES =libopenbsd.a + +if KDRIVE_HW +KDRIVE_HW_SOURCES = \ + agp.c \ + agp.h \ + openbsd.c +endif + +libopenbsd_a_SOURCES = \ + kopenbsd.h \ + $(KDRIVE_HW_SOURCES) + +libopenbsd_a_DEPENDENCIES = \ + agp.c \ + openbsd.c diff --git a/xserver/hw/kdrive/openbsd/kopenbsd.h b/xserver/hw/kdrive/openbsd/kopenbsd.h new file mode 100644 index 000000000..ca55ce170 --- /dev/null +++ b/xserver/hw/kdrive/openbsd/kopenbsd.h @@ -0,0 +1,24 @@ +/* $OpenBSD: kopenbsd.h,v 1.1 2007/05/25 15:33:32 matthieu Exp $ */ +/* + * Copyright (c) 2007 Matthieu Herrb <matthieu.herrb@laas.fr> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _KOpenBSD_H +#define _KOpenBSD_H + +Bool OpenBSDFindPCI(CARD16, CARD16, CARD32 , KdCardAttr *); +unsigned char *OpenBSDGetPciCfg(KdCardAttr *); + +#endif /* _KOpenBSD_H */ diff --git a/xserver/hw/kdrive/openbsd/openbsd.c b/xserver/hw/kdrive/openbsd/openbsd.c new file mode 100644 index 000000000..44df7456c --- /dev/null +++ b/xserver/hw/kdrive/openbsd/openbsd.c @@ -0,0 +1,106 @@ +/* $OpenBSD: openbsd.c,v 1.1 2007/05/25 15:33:32 matthieu Exp $ */ +/* + * Copyright (c) 2007 Matthieu Herrb <matthieu@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include <kdrive-config.h> +#endif +#define XK_PUBLISHING +#include <X11/keysym.h> +#include <X11/Xdefs.h> +#include "kdrive.h" +#include "kopenbsd.h" + +static int vtno; +int WsconsConsoleFd; +int OpenBSDApmFd = -1; +static int activeVT; +static Bool enabled; + +static int +OpenBSDInit(void) +{ + WsconsConsoleFd = -1; + return 1; +} + +Bool +OpenBSDFindPci(CARD16 vendor, CARD16 device, CARD32 count, KdCardAttr *attr) +{ + /* Find a PCI device matching vendor/device */ + /* return KdCardAttr */ + return FALSE; +} + +unsigned char * +OpenBSDGetPciCfg(KdCardAttr *attr) +{ + /* Get Config registers for card at attr */ + return NULL; +} + +static void +OpenBSDEnable(void) +{ + if (enabled) + return; + if (kdSwitchPending) { + kdSwitchPending = FALSE; + } + /* Open / init APM */ + /* Get a VT */ + /* Switch to graphics mode */ + enabled = TRUE; +} + + +static Bool +OpenBSDSpecialKey(KeySym sym) +{ + /* Initiate VT switch if needed */ + return FALSE; +} + +static void +OpenBSDDisable(void) +{ + enabled = FALSE; + /* Back to text mode */ + /* Remove apm hooks */ +} + +static void +OpenBSDFini(void) +{ + if (WsconsConsoleFd < 0) + return; + /* switch back to initial VT */ +} + +KdOsFuncs OpenBSDFuncs = { + OpenBSDInit, + OpenBSDEnable, + OpenBSDSpecialKey, + OpenBSDDisable, + OpenBSDFini, + 0 +}; + +void +OsVendorInit(void) +{ + KdOsInit(&OpenBSDFuncs); +} diff --git a/xserver/hw/kdrive/wscons/Makefile.am b/xserver/hw/kdrive/wscons/Makefile.am new file mode 100644 index 000000000..fa18bc499 --- /dev/null +++ b/xserver/hw/kdrive/wscons/Makefile.am @@ -0,0 +1,26 @@ +# $OpenBSD: Makefile.am,v 1.1 2007/05/25 15:33:32 matthieu Exp $ + +INCLUDES = \ + @KDRIVE_INCS@ \ + @KDRIVE_CFLAGS@ + +noinst_LIBRARIES = libwscons.a + +bin_PROGRAMS = Xwscons + +libwscons_a_SOURCES = \ + keyboard.c \ + mouse.c \ + wsfb.c \ + wsfb.h + +Xwscons_SOURCES = \ + wsinit.c + +Xwscons_LDADD = \ + libwscons.a \ + @KDRIVE_LIBS@ \ + @XSERVER_LIBS@ + +Xwscons_DEPENDENCIES = \ + libwscons.a diff --git a/xserver/hw/kdrive/wscons/keyboard.c b/xserver/hw/kdrive/wscons/keyboard.c new file mode 100644 index 000000000..7a97a0f4e --- /dev/null +++ b/xserver/hw/kdrive/wscons/keyboard.c @@ -0,0 +1,91 @@ +/* $OpenBSD: keyboard.c,v 1.1 2007/05/25 15:33:32 matthieu Exp $ */ +/* + * Copyright (c) 2007 Matthieu Herrb <matthieu@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include <kdrive-config.h> +#endif +#include "kdrive.h" + +#include <X11/keysym.h> + +extern int WsconsConsoleFd; +static int WsconsKbdType; + +static void +WsconsKeyboardLoad(void) +{ + /* Read kernel Mapping */ +} + +static void +WsconsKeyboardRead(int fd, void *closure) +{ + unsigned char b; + + /* read and enqueue events */ + KdEnqueueKeyboardEvent(b & 0x7f, b & 0x80); +} + +static void +WsconsKeyboardEnable(int fd, void *closure) +{ + /* Switch to X mode */ +} + +static void +WsconsKeyboardDisable(int fd, void *closure) +{ + /* Back to console mode */ +} + +static int +WsconsKeyboardInit(void) +{ + if (!WsconsKbdType) + WsconsKbdType = KdAllocInputType(); + KdRegisterFd(WsconsKbdType, WsconsConsoleFd, WsconsKeyboardRead, 0); + WsconsKeyboardEnable(WsconsConsoleFd, 0); + KdRegisterFdEnableDisable(WsconsConsoleFd, + WsconsKeyboardEnable, WsconsKeyboardDisable); + return 1; +} + +static void +WsconsKeyboardFini(void) +{ + WsconsKeyboardDisable(WsconsConsoleFd, 0); + KdUnregisterFds(WsconsKbdType, FALSE); +} + +static void +WsconsKeyboardLeds(int leds) +{ +} + +static void +WsconsKeyboardBell(int volume, int pitch, int duration) +{ +} + +KdKeyboardFuncs WsconsKeyboardFuncs = { + WsconsKeyboardLoad, + WsconsKeyboardInit, + WsconsKeyboardLeds, + WsconsKeyboardBell, + WsconsKeyboardFini, + 3, +}; diff --git a/xserver/hw/kdrive/wscons/mouse.c b/xserver/hw/kdrive/wscons/mouse.c new file mode 100644 index 000000000..597f1875b --- /dev/null +++ b/xserver/hw/kdrive/wscons/mouse.c @@ -0,0 +1,82 @@ +/* $OpenBSD: mouse.c,v 1.1 2007/05/25 15:33:32 matthieu Exp $ */ +/* + * Copyright (c) 2007 Matthieu Herrb <matthieu@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include <kdrive-config.h> +#endif +#define NEED_EVENTS +#include <errno.h> +#include <termios.h> +#include <X11/X.h> +#include <X11/Xproto.h> +#include "inputstr.h" +#include "scrnintstr.h" +#include "kdrive.h" + +static void +MouseRead(int mousePort, void *closure) +{ + KdMouseInfo *mi; + int dx, dy; + unsigned long flags; + + /* flags: + KD_MOUSE_DELTA + KD_BUTTON_{1,2,3} */ + /* Read and post mouse events */ + 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) +{ + if (!MouseInputType) + MouseInputType = KdAllocInputType(); + + return TRUE; +} + +static void +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; + } + } +} + +KdMouseFuncs WsconsMouseFuncs = { + MouseInit, + MouseFini +}; diff --git a/xserver/hw/kdrive/wscons/wsfb.c b/xserver/hw/kdrive/wscons/wsfb.c new file mode 100644 index 000000000..78498dc8b --- /dev/null +++ b/xserver/hw/kdrive/wscons/wsfb.c @@ -0,0 +1,248 @@ +/* $OpenBSD: wsfb.c,v 1.1 2007/05/25 15:33:32 matthieu Exp $ */ +/* + * Copyright (c) 2007 Matthieu Herrb <matthieu@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include <kdrive-config.h> +#endif +#include <dev/wscons/wsconsio.h> + +#include <X11/X.h> +#include <X11/Xdefs.h> + +#include "wsfb.h" + +Bool +wsfbInitialize(KdCardInfo *card, WsfbPriv *priv) +{ + return TRUE; +} + +Bool +wsfbCardInit(KdCardInfo *card) +{ + WsfbPriv *priv; + + priv = (WsfbPriv *)xalloc(sizeof(WsfbPriv)); + if (priv == NULL) + return FALSE; + if (!wsfbInitialize(card, priv)) { + xfree(priv); + return FALSE; + } + card->driver = priv; + + return TRUE; +} + +Bool +wsfbScreenInitialize(KdScreenInfo *screen, WsfbScrPriv *scrpriv) +{ + return TRUE; +} + +Bool +wsfbScreenInit(KdScreenInfo *screen) +{ + WsfbScrPriv *scrPriv; + + scrPriv = (WsfbScrPriv *)xalloc(sizeof(WsfbScrPriv)); + if (scrPriv == NULL) + return FALSE; + bzero(scrPriv, sizeof(WsfbScrPriv)); + screen->driver = scrPriv; + if (!wsfbScreenInitialize(screen, scrPriv)) { + screen->driver = NULL; + xfree(scrPriv); + return FALSE; + } + return TRUE; +} + +Bool +wsfbInitScreen(ScreenPtr pScreen) +{ + pScreen->CreateColormap = wsfbCreateColormap; + return TRUE; +} + + +Bool +wsfbFinishInitScreen(ScreenPtr pScreen) +{ + if (!shadowSetup(pScreen)) + return FALSE; +#ifdef RANDR + if (!wsfbRandRInit(pScreen)) + return FALSE; +#endif + return TRUE; +} + +Bool +wsfbCreateResources(ScreenPtr pScreen) +{ + return wsfbSetShadow(pScreen); +} + +void +wsfbPreserve(KdCardInfo *card) +{ +} + + +Bool +wsfbEnable(ScreenPtr pScreen) +{ + return TRUE; +} + +Bool +wsfbDPMS(ScreenPtr pScreen, int mode) +{ + return TRUE; +} + +void +wsfbDisable(ScreenPtr pScreen) +{ +} + +void +wsfbRestore(KdCardInfo *card) +{ +} + +void +wsfbScreenFini(KdScreenInfo *screen) +{ +} + +void +wsfbCardFini(KdCardInfo *card) +{ + WsfbPriv *priv = card->driver; + + /* unmap framebuffer */ + /* close fd */ + xfree(priv); +} + +void +wsfbGetColors(ScreenPtr pScreen, int fb, int n, xColorItem *pdefs) +{ +} + +void +wsfbPutColors(ScreenPtr pScreen, int fb, int n, xColorItem *pdefs) +{ +} + +Bool +wsfbMapFramebuffer(KdScreenInfo *screen) +{ + WsfbScrPriv *scrPriv = screen->driver; + KdMouseMatrix m; + WsfbPriv *priv = screen->card->driver; + + if (scrPriv->randr != RR_Rotate_0) + scrPriv->shadow = TRUE; + else + scrPriv->shadow = FALSE; + + KdComputeMouseMatrix(&m, scrPriv->randr, + screen->width, screen->height); + KdSetMouseMatrix(&m); + + /* ?? */ + /* screen->width = priv->var.xres; + screen->height = priv->var.yres; */ + screen->memory_base = (CARD8 *)(priv->fb); + /* screen->memory_size = priv->fix.smem_len; */ + + if (scrPriv->shadow) { + if (!KdShadowFbAlloc(screen, 0, + scrPriv->randr & (RR_Rotate_90|RR_Rotate_270))) + return FALSE; + screen->off_screen_base = screen->memory_size; + } else { + /* screen->fb[0].byteStride = priv->fix.line_length; + screen->fb[0].pixelStride = (prif->fix.line_length * 8 / + priv->var.bits_per_pixel); */ + screen->fb[0].frameBuffer = (CARD8 *)(priv->fb); + screen->off_screen_base = + screen->fb[0].byteStride * screen->height; + } + return TRUE; +} + +void * +wsfbWindowLinear(ScreenPtr pScreen, + CARD32 row, + CARD32 offset, + int mode, + CARD32 *size, + void *closure) +{ + return NULL; +} + +void +wsfbSetScreenSizes(ScreenPtr pScreen) +{ +} + +Bool +wsfbUnmapFramebuffer(KdScreenInfo *screen) +{ + KdShadowFbFree(screen, 0); + return TRUE; +} + +Bool +wsfbSetShadow(ScreenPtr pScreen) +{ + return TRUE; +} + +Bool +wsfbCreateColormap(ColormapPtr pmap) +{ + return TRUE; +} + +#ifdef RANDR +Bool +wsfbRandRGetInfo(ScreenPtr pScreen, Rotation *rotations) +{ + return TRUE; +} + +Bool +wsfbRandRSetConfig(ScreenPtr pScreen, + Rotation randr, + int rate, + RRScreenSizePtr pSize) +{ + return TRUE; +} + +Bool +wsfbRandRInit(ScreenPtr pScreen) +{ + return TRUE; +} +#endif /* RANDR */ diff --git a/xserver/hw/kdrive/wscons/wsinit.c b/xserver/hw/kdrive/wscons/wsinit.c new file mode 100644 index 000000000..e5e8fe424 --- /dev/null +++ b/xserver/hw/kdrive/wscons/wsinit.c @@ -0,0 +1,85 @@ +/* $OpenBSD: wsinit.c,v 1.1 2007/05/25 15:33:32 matthieu Exp $ */ +/* + * Copyright (c) 2007 Matthieu Herrb <matthieu@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include <kdrive-config.h> +#endif +#include <dev/wscons/wsconsio.h> + +#include "kdrive.h" +#include "wsfb.h" + +void +InitCard(char *name) +{ + KdCardAttr attr; + + KdCardInfoAdd(&wsfbFuncs, &attr, 0); +} + +void +InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) +{ + KdInitOutput(pScreenInfo, argc, argv); +} + +void +InitInput(int argc, char **argv) +{ + KdInitInput(&WsconsMouseFuncs, &WsconsKeyboardFuncs); +} + +void +ddxUseMsg(void) +{ + KdUseMsg(); + ErrorF("\nXwsfb device Usage:\n"); + ErrorF("-foo bar\n"); + ErrorF("\n"); +} + +int +ddxProcessArgument(int argc, char **argv, int i) +{ + return KdProcessArgument(argc, argv, i); +} + +KdCardFuncs wsfbFuncs = { + wsfbCardInit, + wsfbScreenInit, + wsfbInitScreen, + wsfbFinishInitScreen, + wsfbCreateResources, + wsfbPreserve, + wsfbEnable, + wsfbDPMS, + wsfbDisable, + wsfbRestore, + wsfbScreenFini, + wsfbCardFini, + 0, /* initCursor */ + 0, /* enableCursor */ + 0, /* disqbleCursor */ + 0, /* finiCursor */ + 0, /* recolorCursor */ + 0, /* initAccel */ + 0, /* enableAccel */ + 0, /* disableAccel */ + 0, /* finiAccel */ + wsfbGetColors, + wsfbPutColors, +}; |