diff options
Diffstat (limited to 'hw/xfree86/os-support/linux')
-rw-r--r-- | hw/xfree86/os-support/linux/lnxResource.c | 15 | ||||
-rw-r--r-- | hw/xfree86/os-support/linux/lnx_KbdMap.c | 6 | ||||
-rw-r--r-- | hw/xfree86/os-support/linux/lnx_agp.c | 2 | ||||
-rw-r--r-- | hw/xfree86/os-support/linux/lnx_apm.c | 2 | ||||
-rw-r--r-- | hw/xfree86/os-support/linux/lnx_axp.c | 4 | ||||
-rw-r--r-- | hw/xfree86/os-support/linux/lnx_ev56.c | 4 | ||||
-rw-r--r-- | hw/xfree86/os-support/linux/lnx_font.c | 4 | ||||
-rw-r--r-- | hw/xfree86/os-support/linux/lnx_init.c | 6 | ||||
-rw-r--r-- | hw/xfree86/os-support/linux/lnx_io.c | 2 | ||||
-rw-r--r-- | hw/xfree86/os-support/linux/lnx_kbd.c | 2 | ||||
-rw-r--r-- | hw/xfree86/os-support/linux/lnx_mouse.c | 177 | ||||
-rw-r--r-- | hw/xfree86/os-support/linux/lnx_pci.c | 4 | ||||
-rw-r--r-- | hw/xfree86/os-support/linux/lnx_video.c | 2 |
13 files changed, 202 insertions, 28 deletions
diff --git a/hw/xfree86/os-support/linux/lnxResource.c b/hw/xfree86/os-support/linux/lnxResource.c index 04e2f07c0..3b29618aa 100644 --- a/hw/xfree86/os-support/linux/lnxResource.c +++ b/hw/xfree86/os-support/linux/lnxResource.c @@ -2,7 +2,7 @@ /* Resource information code */ -#include "X.h" +#include <X11/X.h> #include "xf86.h" #include "xf86Priv.h" #include "xf86Privstr.h" @@ -190,7 +190,8 @@ xf86AccResFromOS(resPtr ret) defined(__s390__) || \ defined(__hppa__) - /* XXX this isn't exactly correct but it will get the server working + /* + * XXX this isn't exactly correct but it will get the server working * for now until we get something better. */ @@ -203,7 +204,7 @@ xf86BusAccWindowsFromOS(void) RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock); ret = xf86AddResToList(ret, &range, -1); -#ifdef __sparc__ +#if defined(__sparc__) || defined(__powerpc__) RANGE(range, 0x00000000, 0x00ffffff, ResExcIoBlock); #else RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock); @@ -221,7 +222,7 @@ xf86PciBusAccWindowsFromOS(void) RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock); ret = xf86AddResToList(ret, &range, -1); -#ifdef __sparc__ +#if defined(__sparc__) || defined(__powerpc__) RANGE(range, 0x00000000, 0x00ffffff, ResExcIoBlock); #else RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock); @@ -230,7 +231,7 @@ xf86PciBusAccWindowsFromOS(void) return ret; } -#ifdef INCLUDE_UNUSED */ +#ifdef INCLUDE_UNUSED resPtr xf86IsaBusAccWindowsFromOS(void) @@ -241,7 +242,7 @@ xf86IsaBusAccWindowsFromOS(void) RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock); ret = xf86AddResToList(ret, &range, -1); -#ifdef __sparc__ +#if defined(__sparc__) || defined(__powerpc__) RANGE(range, 0x00000000, 0x00ffffff, ResExcIoBlock); #else RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock); @@ -267,7 +268,7 @@ xf86AccResFromOS(resPtr ret) ret = xf86AddResToList(ret, &range, -1); RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock); ret = xf86AddResToList(ret, &range, -1); -#ifdef __sparc__ +#if defined(__sparc__) || defined(__powerpc__) RANGE(range, 0x00ffffff, 0x00ffffff, ResExcIoBlock); #else RANGE(range, 0x0000ffff, 0x0000ffff, ResExcIoBlock); diff --git a/hw/xfree86/os-support/linux/lnx_KbdMap.c b/hw/xfree86/os-support/linux/lnx_KbdMap.c index 25639d72d..61b2e12b5 100644 --- a/hw/xfree86/os-support/linux/lnx_KbdMap.c +++ b/hw/xfree86/os-support/linux/lnx_KbdMap.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_KbdMap.c,v 1.1 2002/10/11 01:40:35 dawes Exp $ */ +/* $XFree86$ */ /* * Slightly modified xf86KbdLnx.c which is @@ -6,8 +6,8 @@ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. */ -#include "X.h" -#include "Xmd.h" +#include <X11/X.h> +#include <X11/Xmd.h> #include "input.h" #include "scrnintstr.h" diff --git a/hw/xfree86/os-support/linux/lnx_agp.c b/hw/xfree86/os-support/linux/lnx_agp.c index 381973dd0..316d4ecb2 100644 --- a/hw/xfree86/os-support/linux/lnx_agp.c +++ b/hw/xfree86/os-support/linux/lnx_agp.c @@ -9,7 +9,7 @@ /* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_agp.c,v 3.11 2003/04/03 22:47:42 dawes Exp $ */ -#include "X.h" +#include <X11/X.h> #include "xf86.h" #include "xf86Priv.h" #include "xf86_OSlib.h" diff --git a/hw/xfree86/os-support/linux/lnx_apm.c b/hw/xfree86/os-support/linux/lnx_apm.c index fae2e2108..b16d51cf9 100644 --- a/hw/xfree86/os-support/linux/lnx_apm.c +++ b/hw/xfree86/os-support/linux/lnx_apm.c @@ -1,6 +1,6 @@ /* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c,v 3.12 2001/12/24 22:54:31 dawes Exp $ */ -#include "X.h" +#include <X11/X.h> #include "os.h" #include "xf86.h" #include "xf86Priv.h" diff --git a/hw/xfree86/os-support/linux/lnx_axp.c b/hw/xfree86/os-support/linux/lnx_axp.c index 5813ef4e9..c96e7a118 100644 --- a/hw/xfree86/os-support/linux/lnx_axp.c +++ b/hw/xfree86/os-support/linux/lnx_axp.c @@ -1,7 +1,7 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_axp.c,v 1.5 2002/11/25 14:05:04 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_axp.c,v 1.3 2001/02/15 11:03:56 alanh Exp $ */ #include <stdio.h> -#include "X.h" +#include <X11/X.h> #include "os.h" #include "xf86.h" #include "xf86Priv.h" diff --git a/hw/xfree86/os-support/linux/lnx_ev56.c b/hw/xfree86/os-support/linux/lnx_ev56.c index bfcb0d70f..05c1dd097 100644 --- a/hw/xfree86/os-support/linux/lnx_ev56.c +++ b/hw/xfree86/os-support/linux/lnx_ev56.c @@ -1,6 +1,6 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_ev56.c,v 3.7 2002/11/25 14:05:04 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_ev56.c,v 3.5 2000/02/17 13:45:49 dawes Exp $ */ -#include "X.h" +#include <X11/X.h> #include "input.h" #include "scrnintstr.h" #include "compiler.h" diff --git a/hw/xfree86/os-support/linux/lnx_font.c b/hw/xfree86/os-support/linux/lnx_font.c index 05bf7da67..d809f97af 100644 --- a/hw/xfree86/os-support/linux/lnx_font.c +++ b/hw/xfree86/os-support/linux/lnx_font.c @@ -23,8 +23,8 @@ *ings in this Software without prior written authorization from Egbert Eich. * */ -#include "X.h" -#include "Xmd.h" +#include <X11/X.h> +#include <X11/Xmd.h> #include "compiler.h" diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c index 4246e86eb..1a4442547 100644 --- a/hw/xfree86/os-support/linux/lnx_init.c +++ b/hw/xfree86/os-support/linux/lnx_init.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c,v 1.3 2005/01/14 18:42:26 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c,v 1.4 2005/01/28 16:12:59 eich Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c,v 3.14 2001/10/31 22:50:30 tsi Exp $ */ /* * Copyright 1992 by Orest Zborowski <obz@Kodak.com> @@ -26,8 +26,8 @@ */ /* $XConsortium: lnx_init.c /main/7 1996/10/23 18:46:30 kaleb $ */ -#include "X.h" -#include "Xmd.h" +#include <X11/X.h> +#include <X11/Xmd.h> #include "compiler.h" diff --git a/hw/xfree86/os-support/linux/lnx_io.c b/hw/xfree86/os-support/linux/lnx_io.c index 1eebc757a..5de501ae8 100644 --- a/hw/xfree86/os-support/linux/lnx_io.c +++ b/hw/xfree86/os-support/linux/lnx_io.c @@ -26,7 +26,7 @@ /* $XConsortium: lnx_io.c /main/8 1996/10/19 18:06:28 kaleb $ */ #define NEED_EVENTS -#include "X.h" +#include <X11/X.h> #include "compiler.h" diff --git a/hw/xfree86/os-support/linux/lnx_kbd.c b/hw/xfree86/os-support/linux/lnx_kbd.c index 18eff7fe6..aa959b927 100644 --- a/hw/xfree86/os-support/linux/lnx_kbd.c +++ b/hw/xfree86/os-support/linux/lnx_kbd.c @@ -10,7 +10,7 @@ */ #define NEED_EVENTS -#include "X.h" +#include <X11/X.h> #include "compiler.h" diff --git a/hw/xfree86/os-support/linux/lnx_mouse.c b/hw/xfree86/os-support/linux/lnx_mouse.c index 8bc7e6331..a03e2f747 100644 --- a/hw/xfree86/os-support/linux/lnx_mouse.c +++ b/hw/xfree86/os-support/linux/lnx_mouse.c @@ -1,13 +1,17 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_mouse.c,v 1.1 1999/05/17 13:17:18 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_mouse.c,v 1.2 2003/10/08 14:58:30 dawes Exp $ */ /* * Copyright 1999 by The XFree86 Project, Inc. */ -#include "X.h" +#include <X11/X.h> #include "xf86.h" #include "xf86Xinput.h" #include "xf86OSmouse.h" +#include "xf86_OSlib.h" +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> static int SupportedInterfaces(void) @@ -15,6 +19,172 @@ SupportedInterfaces(void) return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_XPS2 | MSE_AUTO; } +static const char * +DefaultProtocol(void) +{ + return "Auto"; +} + +#define DEFAULT_MOUSE_DEV "/dev/mouse" +#define DEFAULT_PS2_DEV "/dev/psaux" +#define DEFAULT_GPM_DATA_DEV "/dev/gpmdata" +#define DEFAULT_GPM_CTL_DEV "/dev/gpmdata" + +static const char *mouseDevs[] = { + DEFAULT_MOUSE_DEV, + DEFAULT_PS2_DEV, + DEFAULT_GPM_DATA_DEV, + NULL +}; + +typedef enum { + MOUSE_PROTO_UNKNOWN = 0, + MOUSE_PROTO_SERIAL, + MOUSE_PROTO_PS2, + MOUSE_PROTO_MSC, + MOUSE_PROTO_GPM +} protocolTypes; + +static struct { + protocolTypes proto; + const char *name; +} devproto[] = { + { MOUSE_PROTO_UNKNOWN, NULL }, + { MOUSE_PROTO_PS2, "PS/2" }, + { MOUSE_PROTO_MSC, "MouseSystems" }, + { MOUSE_PROTO_GPM, "GPM" } +}; + +static const char * +FindDevice(InputInfoPtr pInfo, const char *protocol, int flags) +{ + int fd = -1; + const char **pdev; + + for (pdev = mouseDevs; *pdev; pdev++) { + SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK | O_EXCL)); + if (fd == -1) { +#ifdef DEBUG + ErrorF("Cannot open %s (%s)\n", *pdev, strerror(errno)); +#endif + } else + break; + } + + if (*pdev) { + close(fd); + /* Set the Device option. */ + pInfo->conf_idev->commonOptions = + xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", *pdev); + xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n", + pInfo->name, *pdev); + } + + return *pdev; +} + +static const char * +GuessProtocol(InputInfoPtr pInfo, int flags) +{ + int fd = -1; + const char *dev; + char *realdev; + struct stat sbuf; + int i; + int proto = MOUSE_PROTO_UNKNOWN; + + dev = xf86SetStrOption(pInfo->conf_idev->commonOptions, "Device", NULL); + if (!dev) { +#ifdef DEBUG + ErrorF("xf86SetStrOption failed to return the device name\n"); +#endif + return NULL; + } + /* Look at the device name to guess the protocol. */ + realdev = NULL; + if (strcmp(dev, DEFAULT_MOUSE_DEV) == 0) { + if (lstat(dev, &sbuf) != 0) { +#ifdef DEBUG + ErrorF("lstat failed for %s (%s)\n", dev, strerror(errno)); +#endif + return NULL; + } + if (S_ISLNK(sbuf.st_mode)) { + realdev = xnfalloc(PATH_MAX + 1); + i = readlink(dev, realdev, PATH_MAX); + if (i <= 0) { +#ifdef DEBUG + ErrorF("readlink failed for %s (%s)\n", dev, strerror(errno)); +#endif + xfree(realdev); + return NULL; + } + realdev[i] = '\0'; + } + } + if (!realdev) + realdev = xnfstrdup(dev); + else { + /* If realdev doesn't contain a '/' then prepend "/dev/" */ + if (!strchr(realdev, '/')) { + char *tmp = xnfalloc(strlen(realdev) + 5 + 1); + sprintf(tmp, "/dev/%s", realdev); + xfree(realdev); + realdev = tmp; + } + } + + if (strcmp(realdev, DEFAULT_PS2_DEV) == 0) + proto = MOUSE_PROTO_PS2; + else if (strcmp(realdev, DEFAULT_GPM_DATA_DEV) == 0) + proto = MOUSE_PROTO_MSC; + else if (strcmp(realdev, DEFAULT_GPM_CTL_DEV) == 0) + proto = MOUSE_PROTO_GPM; + xfree(realdev); + /* + * If the protocol can't be guessed from the device name, + * try to characterise it. + */ + if (proto == MOUSE_PROTO_UNKNOWN) { + SYSCALL (fd = open(dev, O_RDWR | O_NONBLOCK | O_EXCL)); + if (isatty(fd)) { + /* Serial PnP has already failed, so give up. */ + } else { + if (fstat(fd, &sbuf) != 0) { +#ifdef DEBUG + ErrorF("fstat failed for %s (%s)\n", dev, strerror(errno)); +#endif + close(fd); + return NULL; + } + if (S_ISFIFO(sbuf.st_mode)) { + /* Assume GPM data in MSC format. */ + proto = MOUSE_PROTO_MSC; + } else { + /* Default to PS/2 */ + proto = MOUSE_PROTO_PS2; + } + } + close(fd); + } + if (proto == MOUSE_PROTO_UNKNOWN) { + xf86Msg(X_ERROR, "%s: GuessProtocol: Cannot find mouse protocol.\n", + pInfo->name); + return NULL; + } else { + for (i = 0; i < sizeof(devproto)/sizeof(devproto[0]); i++) { + if (devproto[i].proto == proto) { + xf86Msg(X_INFO, + "%s: GuessProtocol: " + "setting mouse protocol to \"%s\"\n", + pInfo->name, devproto[i].name); + return devproto[i].name; + } + } + } + return NULL; +} + OSMouseInfoPtr xf86OSMouseInit(int flags) { @@ -24,6 +194,9 @@ xf86OSMouseInit(int flags) if (!p) return NULL; p->SupportedInterfaces = SupportedInterfaces; + p->DefaultProtocol = DefaultProtocol; + p->FindDevice = FindDevice; + p->GuessProtocol = GuessProtocol; return p; } diff --git a/hw/xfree86/os-support/linux/lnx_pci.c b/hw/xfree86/os-support/linux/lnx_pci.c index 5477b9130..074a9d7f7 100644 --- a/hw/xfree86/os-support/linux/lnx_pci.c +++ b/hw/xfree86/os-support/linux/lnx_pci.c @@ -1,7 +1,7 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_pci.c,v 3.9 2003/02/17 15:29:22 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_pci.c,v 3.8 2002/04/09 15:59:37 tsi Exp $ */ #include <stdio.h> -#include "X.h" +#include <X11/X.h> #include "os.h" #include "xf86.h" #include "xf86Priv.h" diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c index 65f216bd6..74163fdb7 100644 --- a/hw/xfree86/os-support/linux/lnx_video.c +++ b/hw/xfree86/os-support/linux/lnx_video.c @@ -25,7 +25,7 @@ */ /* $XConsortium: lnx_video.c /main/9 1996/10/19 18:06:34 kaleb $ */ -#include "X.h" +#include <X11/X.h> #include "input.h" #include "scrnintstr.h" |