summaryrefslogtreecommitdiff
path: root/hw/xfree86/os-support/solaris
diff options
context:
space:
mode:
Diffstat (limited to 'hw/xfree86/os-support/solaris')
-rw-r--r--hw/xfree86/os-support/solaris/sun_bios.c6
-rw-r--r--hw/xfree86/os-support/solaris/sun_init.c21
-rw-r--r--hw/xfree86/os-support/solaris/sun_inout.s2
-rw-r--r--hw/xfree86/os-support/solaris/sun_io.c2
-rw-r--r--hw/xfree86/os-support/solaris/sun_kbd.c25
-rw-r--r--hw/xfree86/os-support/solaris/sun_mouse.c243
-rw-r--r--hw/xfree86/os-support/solaris/sun_vid.c2
7 files changed, 279 insertions, 22 deletions
diff --git a/hw/xfree86/os-support/solaris/sun_bios.c b/hw/xfree86/os-support/solaris/sun_bios.c
index d1c79888b..dc984bd4b 100644
--- a/hw/xfree86/os-support/solaris/sun_bios.c
+++ b/hw/xfree86/os-support/solaris/sun_bios.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_bios.c,v 1.2 2001/10/28 03:34:02 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_bios.c,v 1.2tsi Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
@@ -71,7 +71,7 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
{
if (!xf86LinearVidMem())
FatalError("xf86ReadBIOS: Could not mmap BIOS"
- " [a=%x]\n", Base);
+ " [a=%lx]\n", Base);
sprintf(solx86_vtname, apertureDevName);
}
@@ -86,7 +86,7 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
if (ptr == MAP_FAILED)
{
xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed "
- "[0x%05x, 0x%04x]\n",
+ "[0x%08lx, 0x%04x]\n",
solx86_vtname, Base, mlen);
close(fd);
return -1;
diff --git a/hw/xfree86/os-support/solaris/sun_init.c b/hw/xfree86/os-support/solaris/sun_init.c
index b08529a00..c7382e0e1 100644
--- a/hw/xfree86/os-support/solaris/sun_init.c
+++ b/hw/xfree86/os-support/solaris/sun_init.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c,v 1.6 2002/06/06 13:49:34 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c,v 1.5 2001/11/25 13:51:24 tsi Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
@@ -26,6 +26,9 @@
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
+#ifdef __i386
+# include <sys/kd.h>
+#endif
static Bool KeepTty = FALSE;
static Bool Protect0 = FALSE;
@@ -34,7 +37,11 @@ static int VTnum = -1;
static int xf86StartVT = -1;
#endif
+#if defined(__SOL8__) || !defined(__i386)
+static char fb_dev[PATH_MAX] = "/dev/fb";
+#else
static char fb_dev[PATH_MAX] = "/dev/console";
+#endif
void
xf86OpenConsole(void)
@@ -162,12 +169,15 @@ xf86OpenConsole(void)
if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
-
+#endif
+#ifdef __i386
if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
+#endif
}
else /* serverGeneration != 1 */
{
+#ifdef HAS_USL_VTS
/*
* Now re-get the VT
*/
@@ -245,6 +255,11 @@ xf86CloseConsole(void)
#endif
+#ifdef __i386
+ /* Reset the display back to text mode */
+ ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT);
+#endif
+
#ifdef HAS_USL_VTS
/*
@@ -261,8 +276,6 @@ xf86CloseConsole(void)
* Did the whole thing similarly to the way linux does it
*/
- /* Reset the display back to text mode */
- ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT);
if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
{
VT.mode = VT_AUTO; /* Set default vt handling */
diff --git a/hw/xfree86/os-support/solaris/sun_inout.s b/hw/xfree86/os-support/solaris/sun_inout.s
index e8f03d0e8..5c0b23ef6 100644
--- a/hw/xfree86/os-support/solaris/sun_inout.s
+++ b/hw/xfree86/os-support/solaris/sun_inout.s
@@ -1,4 +1,4 @@
-/ $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_inout.s,v 1.1 2001/05/28 02:42:31 tsi Exp $
+/ $XFree86$
/
/ Copyright 1994-2001 The XFree86 Project, Inc. All Rights Reserved.
/
diff --git a/hw/xfree86/os-support/solaris/sun_io.c b/hw/xfree86/os-support/solaris/sun_io.c
index 27996d312..9f3a235e5 100644
--- a/hw/xfree86/os-support/solaris/sun_io.c
+++ b/hw/xfree86/os-support/solaris/sun_io.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_io.c,v 1.3 2003/02/17 15:12:00 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_io.c,v 1.2 2002/10/11 01:40:37 dawes Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
* Copyright 1993 by David Dawes <dawes@xfree86.org>
diff --git a/hw/xfree86/os-support/solaris/sun_kbd.c b/hw/xfree86/os-support/solaris/sun_kbd.c
index 7e4998817..a48b7f176 100644
--- a/hw/xfree86/os-support/solaris/sun_kbd.c
+++ b/hw/xfree86/os-support/solaris/sun_kbd.c
@@ -23,12 +23,15 @@
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+/* $XdotOrg:$ */
+#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
static int sun_otranslation = -1;
static int sun_odirect = -1;
+int sun_ktype;
int
xf86GetKbdLeds()
@@ -53,7 +56,8 @@ xf86SetKbdRepeat(char rad)
void
xf86KbdInit()
{
- int ktype, klayout;
+ int klayout;
+ const char *ktype_name;
if (xf86Info.kbdFd < 0) {
xf86Info.kbdFd = open("/dev/kbd", O_RDWR|O_NONBLOCK);
@@ -62,11 +66,11 @@ xf86KbdInit()
}
/*
- * None of the followin should ever fail. If it does, something is
+ * None of the following should ever fail. If it does, something is
* broken (IMO) - DWH 8/21/99
*/
- if (ioctl(xf86Info.kbdFd, KIOCTYPE, &ktype) < 0)
+ if (ioctl(xf86Info.kbdFd, KIOCTYPE, &sun_ktype) < 0)
FatalError("Unable to determine keyboard type: %d\n", errno);
if (ioctl(xf86Info.kbdFd, KIOCLAYOUT, &klayout) < 0)
@@ -77,6 +81,21 @@ xf86KbdInit()
if (ioctl(xf86Info.kbdFd, KIOCGDIRECT, &sun_odirect) < 0)
FatalError("Unable to determine keyboard direct setting\n");
+
+ switch (sun_ktype) {
+ case KB_SUN3:
+ ktype_name = "Sun Type 3"; break;
+ case KB_SUN4:
+ ktype_name = "Sun Type 4/5/6"; break;
+ case KB_USB:
+ ktype_name = "USB"; break;
+ case KB_PC:
+ ktype_name = "PC"; break;
+ default:
+ ktype_name = "Unknown"; break;
+ }
+ xf86Msg(X_PROBED, "Keyboard type: %s (%d)\n", ktype_name, sun_ktype);
+ xf86Msg(X_PROBED, "Keyboard layout: %d\n", klayout);
}
int
diff --git a/hw/xfree86/os-support/solaris/sun_mouse.c b/hw/xfree86/os-support/solaris/sun_mouse.c
index 2e9cee2b1..09f73c410 100644
--- a/hw/xfree86/os-support/solaris/sun_mouse.c
+++ b/hw/xfree86/os-support/solaris/sun_mouse.c
@@ -1,4 +1,5 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c,v 1.4 2002/01/25 21:56:21 tsi Exp $ */
+/* $XdotOrg$ */
/*
* Copyright 1999-2001 The XFree86 Project, Inc. All Rights Reserved.
*
@@ -24,16 +25,53 @@
* dealings in this Software without prior written authorization from the
* XFree86 Project.
*/
+/* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * 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.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
#include "xf86.h"
#include "xf86_OSlib.h"
#include "xf86OSmouse.h"
-#if defined(__SOL8__) || !defined(i386)
+#if defined(__SOL8__) || !defined(__i386)
#include "xisb.h"
#include "mipointer.h"
+#include <sys/stropts.h>
#include <sys/vuid_event.h>
+#include <sys/msio.h>
+
+/* Wheel mouse support in VUID drivers in Solaris 9 updates & Solaris 10 */
+#ifdef WHEEL_DEVID /* Defined in vuid_event.h if VUID wheel support present */
+# define HAVE_VUID_WHEEL
+#endif
+#ifdef HAVE_VUID_WHEEL
+# include <sys/vuid_wheel.h>
+#endif
/* Names of protocols that are handled internally here. */
@@ -42,21 +80,71 @@ static const char *internalNames[] = {
NULL
};
+static const char *solarisMouseDevs[] = {
+ /* Device file: Protocol: */
+ "/dev/mouse", "VUID", /* USB or SPARC */
+#ifdef __i386
+ "/dev/kdmouse", "PS/2", /* PS/2 */
+#endif
+ NULL
+};
+
typedef struct _VuidMseRec {
Firm_event event;
unsigned char *buffer;
+ char *strmod;
} VuidMseRec, *VuidMsePtr;
static int vuidMouseProc(DeviceIntPtr pPointer, int what);
static void vuidReadInput(InputInfoPtr pInfo);
+/*
+ * Initialize and enable the mouse wheel, if present.
+ *
+ * Returns 1 if mouse wheel was successfully enabled.
+ * Returns 0 if an error occurred or if there is no mouse wheel.
+ */
+static int
+vuidMouseWheelInit(InputInfoPtr pInfo)
+{
+#ifdef HAVE_VUID_WHEEL
+ wheel_state wstate;
+ int nwheel = -1;
+
+ wstate.vers = VUID_WHEEL_STATE_VERS;
+ wstate.id = 0;
+ wstate.stateflags = -1;
+
+ if (ioctl(pInfo->fd, VUIDGWHEELCOUNT, &nwheel) != 0)
+ return (0);
+
+ if (ioctl(pInfo->fd, VUIDGWHEELSTATE, &wstate) != 0) {
+ xf86Msg(X_WARNING, "%s: couldn't get wheel state\n", pInfo->name);
+ return (0);
+ }
+
+ wstate.stateflags |= VUID_WHEEL_STATE_ENABLED;
+
+ if (ioctl(pInfo->fd, VUIDSWHEELSTATE, &wstate) != 0) {
+ xf86Msg(X_WARNING, "%s: couldn't enable wheel\n", pInfo->name);
+ return (0);
+ }
+
+ return (1);
+#else
+ return (0);
+#endif
+}
+
+
/* This function is called when the protocol is "VUID". */
static Bool
vuidPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
{
MouseDevPtr pMse = pInfo->private;
VuidMsePtr pVuidMse;
+ int buttons;
pVuidMse = xalloc(sizeof(VuidMseRec));
if (pVuidMse == NULL) {
@@ -84,7 +172,40 @@ vuidPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
return FALSE;
}
}
+
pVuidMse->buffer = (unsigned char *)&pVuidMse->event;
+
+ pVuidMse->strmod = xf86SetStrOption(pInfo->options, "StreamsModule", NULL);
+ if (pVuidMse->strmod &&
+ (ioctl(pInfo->fd, I_PUSH, pVuidMse->strmod) == -1)) {
+ xf86Msg(X_ERROR,
+ "%s: cannot push module '%s' onto mouse device: %s\n",
+ pInfo->name, pVuidMse->strmod, strerror(errno));
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+ xfree(pVuidMse);
+ xfree(pMse);
+ return FALSE;
+ }
+
+ buttons = xf86SetIntOption(pInfo->options, "Buttons", 0);
+ if (buttons == 0) {
+ if(ioctl(pInfo->fd, MSIOBUTTONS, &buttons) == 0) {
+ pInfo->conf_idev->commonOptions =
+ xf86ReplaceIntOption(pInfo->conf_idev->commonOptions,
+ "Buttons", buttons);
+ xf86Msg(X_INFO, "%s: Setting Buttons option to \"%d\"\n",
+ pInfo->name, buttons);
+ }
+ }
+
+ if (pVuidMse->strmod &&
+ (ioctl(pInfo->fd, I_POP, pVuidMse->strmod) == -1)) {
+ xf86Msg(X_WARNING,
+ "%s: cannot pop module '%s' off mouse device: %s\n",
+ pInfo->name, pVuidMse->strmod, strerror(errno));
+ }
+
xf86CloseSerial(pInfo->fd);
pInfo->fd = -1;
@@ -112,6 +233,7 @@ vuidReadInput(InputInfoPtr pInfo)
unsigned int n;
int c;
unsigned char *pBuf;
+ int wmask;
pMse = pInfo->private;
pVuidMse = pMse->mousePriv;
@@ -154,7 +276,15 @@ vuidReadInput(InputInfoPtr pInfo)
dy -= delta;
break;
}
+ }
+#ifdef HAVE_VUID_WHEEL
+ else if (vuid_in_range(VUID_WHEEL, pVuidMse->event.id)) {
+ if (vuid_id_offset(pVuidMse->event.id) == 0)
+ dz -= VUID_WHEEL_GETDELTA(pVuidMse->event.value);
+ else
+ dw -= VUID_WHEEL_GETDELTA(pVuidMse->event.value);
}
+#endif
n = 0;
if ((c = XisbRead(pMse->buffer)) >= 0) {
@@ -219,9 +349,20 @@ vuidMouseProc(DeviceIntPtr pPointer, int what)
pInfo->fd = -1;
} else {
int fmt = VUID_FIRM_EVENT;
- ioctl(pInfo->fd, VUIDSFORMAT, &fmt);
- xf86FlushInput(pInfo->fd);
- AddEnabledDevice(pInfo->fd);
+
+ if (pVuidMse->strmod &&
+ (ioctl(pInfo->fd, I_PUSH, pVuidMse->strmod) == -1)) {
+ xf86Msg(X_ERROR,
+ "%s: cannot push module '%s' onto mouse device: %s\n",
+ pInfo->name, pVuidMse->strmod, strerror(errno));
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+ } else {
+ ioctl(pInfo->fd, VUIDSFORMAT, &fmt);
+ vuidMouseWheelInit(pInfo);
+ xf86FlushInput(pInfo->fd);
+ AddEnabledDevice(pInfo->fd);
+ }
}
}
pMse->lastButtons = 0;
@@ -237,6 +378,12 @@ vuidMouseProc(DeviceIntPtr pPointer, int what)
XisbFree(pMse->buffer);
pMse->buffer = NULL;
}
+ if (pVuidMse->strmod &&
+ (ioctl(pInfo->fd, I_POP, pVuidMse->strmod) == -1)) {
+ xf86Msg(X_WARNING,
+ "%s: cannot pop module '%s' off mouse device: %s\n",
+ pInfo->name, pVuidMse->strmod, strerror(errno));
+ }
xf86CloseSerial(pInfo->fd);
pInfo->fd = -1;
}
@@ -278,21 +425,98 @@ CheckProtocol(const char *protocol)
static const char *
DefaultProtocol(void)
{
- return "VUID";
+ return "Auto";
+}
+
+static Bool
+solarisMouseAutoProbe(InputInfoPtr pInfo, const char **protocol,
+ const char **device)
+{
+ const char **pdev, **pproto, *dev = NULL;
+ int fd = -1;
+ Bool found;
+
+ for (pdev = solarisMouseDevs; *pdev; pdev += 2) {
+ pproto = pdev + 1;
+ if ((*protocol != NULL) && (strcmp(*protocol, "Auto") != 0) &&
+ (*pproto != NULL) && (strcmp(*pproto, *protocol) != 0)) {
+ continue;
+ }
+ if ((*device != NULL) && (strcmp(*device, *pdev) != 0)) {
+ continue;
+ }
+ SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK));
+ if (fd == -1) {
+#ifdef DEBUG
+ ErrorF("Cannot open %s (%s)\n", pdev, strerror(errno));
+#endif
+ } else {
+ found = TRUE;
+ if ((*pproto != NULL) && (strcmp(*pproto, "VUID") == 0)) {
+ int i;
+ if (ioctl(fd, VUIDGFORMAT, &i) < 0) {
+ found = FALSE;
+ }
+ }
+ close(fd);
+ if (found == TRUE) {
+ if (*pproto != NULL) {
+ *protocol = *pproto;
+ }
+ *device = *pdev;
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
}
static const char *
SetupAuto(InputInfoPtr pInfo, int *protoPara)
{
- return DefaultProtocol();
+ const char *pdev = NULL;
+ const char *pproto = NULL;
+ MouseDevPtr pMse = pInfo->private;
+
+ if (pInfo->fd == -1) {
+ /* probe to find device/protocol to use */
+ if (solarisMouseAutoProbe(pInfo, &pproto, &pdev) != FALSE) {
+ /* 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);
+ }
+ } else if (pMse->protocolID == PROT_AUTO) {
+ pdev = xf86CheckStrOption(pInfo->conf_idev->commonOptions,
+ "Device", NULL);
+ solarisMouseAutoProbe(pInfo, &pproto, &pdev);
+ }
+ return pproto;
+}
+
+static const char *
+FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+ const char *pdev = NULL;
+ const char *pproto = protocol;
+
+ if (solarisMouseAutoProbe(pInfo, &pproto, &pdev) != FALSE) {
+ /* 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;
}
-#else /* __SOL8__ || !i386 */
+#else /* __SOL8__ || !__i386 */
#undef MSE_MISC
#define MSE_MISC 0
-#endif /* !__SOL8__ && i386 */
+#endif /* !__SOL8__ && __i386 */
static int
SupportedInterfaces(void)
@@ -310,12 +534,13 @@ xf86OSMouseInit(int flags)
if (!p)
return NULL;
p->SupportedInterfaces = SupportedInterfaces;
-#if defined(__SOL8__) || !defined(i386)
+#if defined(__SOL8__) || !defined(__i386)
p->BuiltinNames = BuiltinNames;
p->CheckProtocol = CheckProtocol;
p->PreInit = sunMousePreInit;
p->DefaultProtocol = DefaultProtocol;
p->SetupAuto = SetupAuto;
+ p->FindDevice = FindDevice;
#endif
return p;
}
diff --git a/hw/xfree86/os-support/solaris/sun_vid.c b/hw/xfree86/os-support/solaris/sun_vid.c
index 2f4b84e99..02883f054 100644
--- a/hw/xfree86/os-support/solaris/sun_vid.c
+++ b/hw/xfree86/os-support/solaris/sun_vid.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c,v 1.3 2002/10/03 02:04:19 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c,v 1.2 2001/10/28 03:34:03 tsi Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
* Copyright 1993 by David Wexelblat <dwex@goblin.org>