[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xserver-xorg-input-keyboard: Changes to 'upstream-unstable'



 .gitignore       |    4 
 README           |   20 ++
 configure.ac     |   15 -
 man/.gitignore   |    2 
 man/kbd.man      |   19 +-
 src/.gitignore   |    6 
 src/bsd_kbd.c    |   47 -----
 src/hurd_kbd.c   |    2 
 src/kbd.c        |  470 +++++++------------------------------------------------
 src/lnx_kbd.c    |  239 ---------------------------
 src/sco_kbd.c    |   60 -------
 src/sun_kbd.c    |  168 ++++++++++++++++---
 src/sun_kbd.h    |    1 
 src/sun_kbdMap.c |   10 -
 src/xf86Keymap.h |    3 
 src/xf86OSKbd.h  |   11 -
 16 files changed, 253 insertions(+), 824 deletions(-)

New commits:
commit c66f4f9fcc7450f2c1378f6117bda4442d2af8ae
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Oct 7 10:53:14 2009 +1000

    keyboard 1.4.0
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/configure.ac b/configure.ac
index cbcb0be..c26e402 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
 
 AC_PREREQ(2.57)
 AC_INIT([xf86-input-keyboard],
-        1.3.99.1,
+        1.4.0,
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         xf86-input-keyboard)
 

commit 0c75afb4895b60aa08209ccfee9dfad4e4495f4d
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Oct 6 17:02:33 2009 +1000

    Remove now un-used autorepeat field.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>

diff --git a/src/kbd.c b/src/kbd.c
index b2e858f..556d594 100644
--- a/src/kbd.c
+++ b/src/kbd.c
@@ -307,7 +307,6 @@ KbdCtrl( DeviceIntPtr device, KeybdCtrl *ctrl)
    leds = ctrl->leds & ~(XCAPS | XNUM | XSCR); /* ??? */
    pKbd->leds = leds;
   pKbd->SetLeds(pInfo, pKbd->leds);
-  pKbd->autoRepeat = ctrl->autoRepeat;
 }
 
 static void
diff --git a/src/xf86OSKbd.h b/src/xf86OSKbd.h
index 2732649..daeabf1 100644
--- a/src/xf86OSKbd.h
+++ b/src/xf86OSKbd.h
@@ -69,7 +69,6 @@ typedef struct {
 
     int			bell_pitch;
     int			bell_duration;
-    Bool		autoRepeat;
     unsigned long	leds;
     unsigned long	xledsMask;
     unsigned long	keyLeds;

commit adc1048980113b329d97ebf5b974ca4a50fc86ba
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Oct 6 17:00:58 2009 +1000

    Don't use XKB_DFLT_RULES from the server.
    
    On Linux, the server uses default rules of "evdev" which doesn't apply for
    this driver. For all other cases, the server uses "base", so let's just
    hardcode it here too.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>

diff --git a/src/kbd.c b/src/kbd.c
index c86c2fc..b2e858f 100644
--- a/src/kbd.c
+++ b/src/kbd.c
@@ -113,12 +113,6 @@ static const OptionInfoRec KeyboardOptions[] = {
     { -1,			NULL,		  OPTV_NONE,	{0}, FALSE }
 };
 
-/* Xorg 1.6 and earlier put the default XKB rules file in __XKBDEFRULES__
-   in xorg-server.h, later versions switched to XKB_DFLT_RULES */
-#if !defined(XKB_DFLT_RULES) && defined(__XKBDEFRULES__)
-# define XKB_DFLT_RULES __XKBDEFRULES__
-#endif
-
 static const char *kbdDefaults[] = {
 #ifdef XQUEUE 
     "Protocol",		"Xqueue",
@@ -126,7 +120,7 @@ static const char *kbdDefaults[] = {
     "Protocol",		"standard",
 #endif
     "AutoRepeat",	"500 30",
-    "XkbRules",		XKB_DFLT_RULES,
+    "XkbRules",		"base",
     "XkbModel",		"pc105",
     "XkbLayout",	"us",
     "CustomKeycodes",	"off",

commit ecd34ebd43d5a8c0db0a6dd132b61a4c663c7fd8
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Oct 6 17:05:56 2009 +1000

    Require macros 1.3 for XORG_DEFAULT_OPTIONS
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/configure.ac b/configure.ac
index 9b41f79..cbcb0be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,10 +26,9 @@ AC_INIT([xf86-input-keyboard],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         xf86-input-keyboard)
 
-# Require xorg-macros version 1.2 or newer for XORG_CWARNFLAGS and
-# XORG_CHANGELOG macros
-m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.2.1 or later before running autoconf/autogen])])
-XORG_MACROS_VERSION(1.2.1)
+# Require xorg-macros version 1.3 or newer for XORG_DEFAULT_OPTIONS
+m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.3 or later before running autoconf/autogen])])
+XORG_MACROS_VERSION(1.3)
 
 AC_CONFIG_SRCDIR([Makefile.am])
 AC_CONFIG_AUX_DIR(.)
@@ -112,7 +111,7 @@ XORG_DRIVER_CHECK_EXT(XKB, kbproto)
 PKG_CHECK_MODULES(XORG, [xorg-server >= 1.2.99.0] xproto $REQUIRED_MODULES)
 sdkdir=$(pkg-config --variable=sdkdir xorg-server)
 
-XORG_CWARNFLAGS
+XORG_DEFAULT_OPTIONS
 XORG_CFLAGS="$CWARNFLAGS $XORG_CFLAGS"
 AC_SUBST([XORG_CFLAGS])
 
@@ -121,8 +120,4 @@ AC_SUBST([XORG_CFLAGS])
 # Checks for header files.
 AC_HEADER_STDC
 
-XORG_MANPAGE_SECTIONS
-XORG_RELEASE_VERSION
-XORG_CHANGELOG
-
 AC_OUTPUT([Makefile src/Makefile man/Makefile])

commit 5427034948fd4d59d5d2d50f9188376f23119a72
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Sep 9 11:48:43 2009 +1000

    keyboard 1.3.99.1
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/configure.ac b/configure.ac
index aab639c..9b41f79 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
 
 AC_PREREQ(2.57)
 AC_INIT([xf86-input-keyboard],
-        1.3.2,
+        1.3.99.1,
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         xf86-input-keyboard)
 

commit 158d33c15df60696946031a0319e2bd2ec8b9541
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Wed Aug 19 18:56:05 2009 -0700

    sun_kbd: Check if streams module is already on the stack before pushing it
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>

diff --git a/src/sun_kbd.c b/src/sun_kbd.c
index f6d99f3..614835e 100644
--- a/src/sun_kbd.c
+++ b/src/sun_kbd.c
@@ -184,12 +184,18 @@ KbdOn(InputInfoPtr pInfo, int what)
     }
 
     if (priv->strmod) {
-	SYSCALL(i = ioctl(pInfo->fd, I_PUSH, priv->strmod));
-	if (i < 0) {
-	    xf86Msg(X_ERROR,
-		    "%s: cannot push module '%s' onto keyboard device: %s\n",
-		    pInfo->name, priv->strmod, strerror(errno));
+	/* Check to see if module is already pushed */
+	SYSCALL(i = ioctl(pInfo->fd, I_FIND, priv->strmod));
+
+	if (i == 0) { /* Not already pushed */
+	    SYSCALL(i = ioctl(pInfo->fd, I_PUSH, priv->strmod));
+	    if (i < 0) {
+		xf86Msg(X_ERROR, "%s: cannot push module '%s' onto "
+			"keyboard device: %s\n",
+			pInfo->name, priv->strmod, strerror(errno));
+	    }
 	}
+
 #ifdef HIDIOCKMSDIRECT
 	if (strcmp(priv->strmod, "usbkbm") == 0) {
 	    io_get_direct = HIDIOCKMGDIRECT;

commit 891d55e759ff6a30f62809081a11c3da20fc0551
Author: Aaron Zang <Aaron.Zang@Sun.COM>
Date:   Thu Aug 13 20:39:59 2009 -0700

    sun_kbd: Use HID ioctl variants to get/set direct mode on usbhid devices
    
    When opening a usb hid* device node directly (instead of via the
    /dev/kbd virtual/coalescing device node), use the HIDIOCKMGDIRECT
    and HIDIOCKMSDIRECT ioctls instead of the KIO* versions.   When
    closing the device, always reset back to direct mode, no matter
    what state we found it in.
    
    Signed-off-by: Aaron Zang <Aaron.Zang@Sun.COM>
    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>

diff --git a/src/sun_kbd.c b/src/sun_kbd.c
index bb831c1..f6d99f3 100644
--- a/src/sun_kbd.c
+++ b/src/sun_kbd.c
@@ -63,6 +63,8 @@
 #include <sys/stropts.h>
 #include <sys/vuid_event.h>
 #include <sys/kbd.h>
+#include <sys/note.h>	/* needed before including older versions of hid.h */
+#include <sys/usb/clients/hid/hid.h>
 
 static int KbdOn(InputInfoPtr pInfo, int what);
 static Bool OpenKeyboard(InputInfoPtr pInfo);
@@ -168,6 +170,8 @@ KbdOn(InputInfoPtr pInfo, int what)
     sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
 
     int	ktrans, kdirect, i;
+    int io_get_direct = KIOCGDIRECT;
+    int io_set_direct = KIOCSDIRECT;
 
     if (priv->kbdActive) {
 	return Success;
@@ -186,9 +190,15 @@ KbdOn(InputInfoPtr pInfo, int what)
 		    "%s: cannot push module '%s' onto keyboard device: %s\n",
 		    pInfo->name, priv->strmod, strerror(errno));
 	}
+#ifdef HIDIOCKMSDIRECT
+	if (strcmp(priv->strmod, "usbkbm") == 0) {
+	    io_get_direct = HIDIOCKMGDIRECT;
+	    io_set_direct = HIDIOCKMSDIRECT;
+	}
+#endif
     }
 
-    SYSCALL(i = ioctl(pInfo->fd, KIOCGDIRECT, &kdirect));
+    SYSCALL(i = ioctl(pInfo->fd, io_get_direct, &kdirect));
     if (i < 0) {
 	xf86Msg(X_ERROR, 
 		"%s: Unable to determine keyboard direct setting: %s\n", 
@@ -199,7 +209,7 @@ KbdOn(InputInfoPtr pInfo, int what)
     priv->odirect = kdirect;
     kdirect = 1;
 
-    SYSCALL(i = ioctl(pInfo->fd, KIOCSDIRECT, &kdirect));
+    SYSCALL(i = ioctl(pInfo->fd, io_set_direct, &kdirect));
     if (i < 0) {
 	xf86Msg(X_ERROR, "%s: Failed turning keyboard direct mode on: %s\n",
 			pInfo->name, strerror(errno));
@@ -243,6 +253,7 @@ KbdOff(InputInfoPtr pInfo, int what)
     sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
 
     int i;
+    int io_set_direct, kdirect;
 
     if (priv->remove_timer) {
 	TimerFree(priv->remove_timer);
@@ -276,8 +287,18 @@ KbdOff(InputInfoPtr pInfo, int what)
 	priv->otranslation = -1;
     }
 
-    if (priv->odirect != -1) {
-        SYSCALL(i = ioctl(pInfo->fd, KIOCSDIRECT, &priv->odirect));
+    io_set_direct = KIOCSDIRECT;
+    kdirect = priv->odirect;
+
+#ifdef HIDIOCKMSDIRECT
+    if ((priv->strmod != NULL) && (strcmp(priv->strmod, "usbkbm") == 0)) {
+	io_set_direct = HIDIOCKMSDIRECT;
+	kdirect = 0;
+    }
+#endif
+
+    if (kdirect != -1) {
+	SYSCALL(i = ioctl(pInfo->fd, io_set_direct, &kdirect));
 	if (i < 0) {
 	    xf86Msg(X_ERROR,
 		    "%s: Unable to restore keyboard direct setting: %s\n",

commit 8e42e8f0034d89ef4b6cee44148961f808ba0602
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Wed Aug 5 15:03:43 2009 -0700

    sun_kbd: re-open keyboard if needed in KbdOn
    
    If we closed keyboard in KbdOff, we need to reopen it in KbdOn, or
    will not be able to type after VT switch.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>

diff --git a/src/sun_kbd.c b/src/sun_kbd.c
index 1c87a24..bb831c1 100644
--- a/src/sun_kbd.c
+++ b/src/sun_kbd.c
@@ -65,6 +65,7 @@
 #include <sys/kbd.h>
 
 static int KbdOn(InputInfoPtr pInfo, int what);
+static Bool OpenKeyboard(InputInfoPtr pInfo);
 static void CloseKeyboard(InputInfoPtr pInfo);
 
 static void
@@ -172,6 +173,12 @@ KbdOn(InputInfoPtr pInfo, int what)
 	return Success;
     }
 
+    if (pInfo->fd == -1) {
+	if (!OpenKeyboard(pInfo)) {
+	    return BadImplementation;
+	}
+    }
+
     if (priv->strmod) {
 	SYSCALL(i = ioctl(pInfo->fd, I_PUSH, priv->strmod));
 	if (i < 0) {

commit bba90b4e87be3ae5a13d69f6d9c60aa97761c8d5
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Tue Aug 4 21:31:23 2009 -0700

    Sun bug 6852921: Recycling Xorg runs out of file descriptors in kbd driver
    
    http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6852921
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>

diff --git a/src/sun_kbd.c b/src/sun_kbd.c
index b4ebc57..1c87a24 100644
--- a/src/sun_kbd.c
+++ b/src/sun_kbd.c
@@ -65,6 +65,7 @@
 #include <sys/kbd.h>
 
 static int KbdOn(InputInfoPtr pInfo, int what);
+static void CloseKeyboard(InputInfoPtr pInfo);
 
 static void
 sunKbdSetLeds(InputInfoPtr pInfo, int leds)
@@ -236,6 +237,11 @@ KbdOff(InputInfoPtr pInfo, int what)
 
     int i;
 
+    if (priv->remove_timer) {
+	TimerFree(priv->remove_timer);
+	priv->remove_timer = NULL;
+    }
+
     if (!priv->kbdActive) {
 	return Success;
     }
@@ -245,11 +251,6 @@ KbdOff(InputInfoPtr pInfo, int what)
 	return Success;
     }
 
-    if (priv->remove_timer) {
-	TimerFree(priv->remove_timer);
-	priv->remove_timer = NULL;
-    }
-
     /* restore original state */
 
     if (priv->oleds != -1) {
@@ -288,7 +289,7 @@ KbdOff(InputInfoPtr pInfo, int what)
 	}
     }
 
-    priv->kbdActive = FALSE;
+    CloseKeyboard(pInfo);
     return Success;
 }
 
@@ -385,20 +386,26 @@ SetKbdRepeat(InputInfoPtr pInfo, char rad)
     /* Nothing to do */
 }
 
-/* Called from OsTimer callback, since removing a device from the device
-   list or changing pInfo->fd while xf86Wakeup is looping through the list
-   causes server crashes */
-static CARD32
-RemoveKeyboard(OsTimerPtr timer, CARD32 time, pointer arg)
+static void
+CloseKeyboard(InputInfoPtr pInfo)
 {
-    InputInfoPtr pInfo = (InputInfoPtr) arg;
     KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
     sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
 
     close(pInfo->fd);
     pInfo->fd = -1;
     priv->kbdActive = FALSE;
+}
+
+/* Called from OsTimer callback, since removing a device from the device
+   list or changing pInfo->fd while xf86Wakeup is looping through the list
+   causes server crashes */
+static CARD32
+RemoveKeyboard(OsTimerPtr timer, CARD32 time, pointer arg)
+{
+    InputInfoPtr pInfo = (InputInfoPtr) arg;
 
+    CloseKeyboard(pInfo);
     xf86DisableDevice(pInfo->dev, TRUE);
 
     return 0;  /* All done, don't set to run again */

commit 352aa83c416a78e59be4dfa7d8442e5eec50130a
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Tue Aug 4 21:04:24 2009 -0700

    Stop checking for #ifdef __SOL8__ - assume Solaris is at least Solaris 8
    
    If you want to run a pre-1999 kernel, you'll need a pre-2009 X server
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>

diff --git a/src/xf86Keymap.h b/src/xf86Keymap.h
index 2bd2205..5f6a792 100644
--- a/src/xf86Keymap.h
+++ b/src/xf86Keymap.h
@@ -173,8 +173,7 @@ static KeySym map[NUM_KEYCODES * GLYPHS_PER_KEY] = {
     !defined(linux) && \
     !defined(CSRG_BASED) && \
     !defined(__CYGWIN__) && \
-    !defined(__SOL8__) && \
-    (!defined(sun) || defined(i386))
+    !defined(sun)
 
 static KeySym map84[NUM_KEYCODES * GLYPHS_PER_KEY] = {
     /* 0x00 */  NoSymbol,       NoSymbol,	NoSymbol,	NoSymbol,

commit fe8d1f70fc7edce4f030766159aebae8f8a89ffc
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Sat May 30 21:12:34 2009 +1000

    Remove ModuleInfoRec.
    
    This struct was removed with 2107becb0ce2ffda001be65728c53563496d8d50 from
    the server.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/kbd.c b/src/kbd.c
index 1afa560..c86c2fc 100644
--- a/src/kbd.c
+++ b/src/kbd.c
@@ -153,13 +153,6 @@ static char *xkb_layout;
 static char *xkb_variant;
 static char *xkb_options;
 
-/*ARGSUSED*/
-static const OptionInfoRec *
-KeyboardAvailableOptions(void *unused)
-{
-    return (KeyboardOptions);
-}
-
 static void
 SetXkbOption(InputInfoPtr pInfo, char *name, char **option)
 {
@@ -534,14 +527,6 @@ PostKbdEvent(InputInfoPtr pInfo, unsigned int scanCode, Bool down)
   xf86PostKeyboardEvent(device, scanCode + MIN_KEYCODE, down);
 }
 
-ModuleInfoRec KbdInfo = {
-    1,
-    "KBD",
-    NULL,
-    0,
-    KeyboardAvailableOptions,
-};
-
 static void
 xf86KbdUnplug(pointer	p)
 {

commit 29f075db9f86aa7e5e01688a5fd5e0081210e16b
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon May 11 15:30:23 2009 +1000

    Return BadValue if the server failed to init the keyboard. (#21278)
    
    If keyboard init failed, we don't have a useful keymap and thus can't
    continue.
    This is essentially 0e15697b53c9448ce9911aa6499b2ea0bda92af6 from
    xserver ported over here.
    
    X.Org Bug 21278 <http://bugs.freedesktop.org/show_bug.cgi?id=21278>
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/kbd.c b/src/kbd.c
index 767ff6b..1afa560 100644
--- a/src/kbd.c
+++ b/src/kbd.c
@@ -424,7 +424,14 @@ KbdProc(DeviceIntPtr device, int what)
              rmlvo.variant = xkb_variant;
              rmlvo.options = xkb_options;
 
-             InitKeyboardDeviceStruct(device, &rmlvo, KbdBell, KbdCtrl);
+             if (!InitKeyboardDeviceStruct(device, &rmlvo, KbdBell, KbdCtrl))
+             {
+                 xf86Msg(X_ERROR, "%s: Keyboard initialization failed. This "
+                         "could be a missing or incorrect setup of "
+                         "xkeyboard-config.\n", device->name);
+
+                 return BadValue;
+             }
          }
 #else
          {

commit 7a4d6f396597c4b96e1402dadfcd2c0e5b7b0579
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Fri May 1 14:47:59 2009 -0700

    Override HKTG & BSlash2 keycodes on Solaris
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>

diff --git a/src/sun_kbdMap.c b/src/sun_kbdMap.c
index 0b4b99c..50d7585 100644
--- a/src/sun_kbdMap.c
+++ b/src/sun_kbdMap.c
@@ -36,10 +36,17 @@
 
 /* Map the Solaris keycodes to the "XFree86" keycodes. */
 
-/* Additional Sun Japanese Keyboard Keys not defined in common/atKeynames.h */
+/* Additional Sun Japanese Keyboard Keys not defined in atKeynames.h */
 #define KEY_Kanji	0x82
 #define KEY_Execute	0x83
 
+/* Override atKeynames.h values with unique keycodes, so we can distinguish
+   KEY_F15 from KEY_HKTG & KEY_KP_DEC from KEY_BSlash2 */
+#undef KEY_HKTG
+#define KEY_HKTG         /* Hirugana/Katakana tog 0xC8  */  200 /* was 112 */
+#undef KEY_BSlash2
+#define KEY_BSlash2      /* \           _         0xCB  */  203 /* was 115 */
+
 static unsigned char sunmap[256] = {
 #if defined(i386) || defined(__i386) || defined(__i386__) || defined(__x86)
 	KEY_NOTUSED,		/*   0 */

commit 2bc18590e6b7b403dcec22a09820010748c48972
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Thu Apr 30 16:26:23 2009 -0700

    Solaris keyboard fixes for HAL hotplugging support
    
    - Handle hot-unplug by checking for ENODEV on read and removing device
    - Make sure to re-push streams module on resume
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>

diff --git a/src/sun_kbd.c b/src/sun_kbd.c
index a222d38..b4ebc57 100644
--- a/src/sun_kbd.c
+++ b/src/sun_kbd.c
@@ -22,7 +22,7 @@
  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
-/* Copyright 2004-2007 Sun Microsystems, Inc.  All rights reserved.
+/* Copyright 2004-2009 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
@@ -64,6 +64,8 @@
 #include <sys/vuid_event.h>
 #include <sys/kbd.h>
 
+static int KbdOn(InputInfoPtr pInfo, int what);
+
 static void
 sunKbdSetLeds(InputInfoPtr pInfo, int leds)
 {
@@ -105,6 +107,7 @@ KbdInit(InputInfoPtr pInfo, int what)
     int	ktype, klayout, i;
     const char *ktype_name;
 
+    priv->kbdActive	= FALSE;
     priv->otranslation 	= -1;
     priv->odirect 	= -1;
 
@@ -114,15 +117,11 @@ KbdInit(InputInfoPtr pInfo, int what)
 	priv->strmod 		= NULL;
     }
 
-    if (priv->strmod) {
-	SYSCALL(i = ioctl(pInfo->fd, I_PUSH, priv->strmod));
-	if (i < 0) {
-	    xf86Msg(X_ERROR,
-		    "%s: cannot push module '%s' onto keyboard device: %s\n",
-		    pInfo->name, priv->strmod, strerror(errno));
-	}
+    i = KbdOn(pInfo, DEVICE_INIT);
+    if (i != Success) {
+	return i;
     }
-    
+
     SYSCALL(i = ioctl(pInfo->fd, KIOCTYPE, &ktype));
     if (i < 0) {
 	xf86Msg(X_ERROR, "%s: Unable to determine keyboard type: %s\n", 
@@ -155,7 +154,6 @@ KbdInit(InputInfoPtr pInfo, int what)
     xf86Msg(X_PROBED, "%s: Keyboard layout: %d\n", pInfo->name, klayout);
 
     priv->ktype 	= ktype;
-    priv->oleds 	= sunKbdGetLeds(pInfo);
 
     return Success;
 }
@@ -169,6 +167,19 @@ KbdOn(InputInfoPtr pInfo, int what)
 
     int	ktrans, kdirect, i;
 
+    if (priv->kbdActive) {
+	return Success;
+    }
+
+    if (priv->strmod) {
+	SYSCALL(i = ioctl(pInfo->fd, I_PUSH, priv->strmod));
+	if (i < 0) {
+	    xf86Msg(X_ERROR,
+		    "%s: cannot push module '%s' onto keyboard device: %s\n",
+		    pInfo->name, priv->strmod, strerror(errno));
+	}
+    }
+
     SYSCALL(i = ioctl(pInfo->fd, KIOCGDIRECT, &kdirect));
     if (i < 0) {
 	xf86Msg(X_ERROR, 
@@ -207,6 +218,13 @@ KbdOn(InputInfoPtr pInfo, int what)
 	return BadImplementation;
     }
 
+    priv->oleds	= sunKbdGetLeds(pInfo);
+
+    /* Allocate here so we don't alloc in ReadInput which may be called
+       from SIGIO handler. */
+    priv->remove_timer = TimerSet(priv->remove_timer, 0, 0, NULL, NULL);
+
+    priv->kbdActive = TRUE;
     return Success;
 }
 
@@ -218,6 +236,20 @@ KbdOff(InputInfoPtr pInfo, int what)
 
     int i;
 
+    if (!priv->kbdActive) {
+	return Success;
+    }
+
+    if (pInfo->fd == -1) {
+	priv->kbdActive = FALSE;
+	return Success;
+    }
+
+    if (priv->remove_timer) {
+	TimerFree(priv->remove_timer);
+	priv->remove_timer = NULL;
+    }
+
     /* restore original state */
 
     if (priv->oleds != -1) {
@@ -254,9 +286,9 @@ KbdOff(InputInfoPtr pInfo, int what)
 		    "%s: cannot pop module '%s' off keyboard device: %s\n",
 		    pInfo->name, priv->strmod, strerror(errno));
 	}
-	priv->strmod = NULL;
     }
 
+    priv->kbdActive = FALSE;
     return Success;
 }
 
@@ -353,20 +385,66 @@ SetKbdRepeat(InputInfoPtr pInfo, char rad)
     /* Nothing to do */
 }
 
+/* Called from OsTimer callback, since removing a device from the device
+   list or changing pInfo->fd while xf86Wakeup is looping through the list
+   causes server crashes */
+static CARD32
+RemoveKeyboard(OsTimerPtr timer, CARD32 time, pointer arg)
+{
+    InputInfoPtr pInfo = (InputInfoPtr) arg;
+    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+    sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+
+    close(pInfo->fd);
+    pInfo->fd = -1;
+    priv->kbdActive = FALSE;
+
+    xf86DisableDevice(pInfo->dev, TRUE);
+
+    return 0;  /* All done, don't set to run again */
+}
+
 static void
 ReadInput(InputInfoPtr pInfo)
 {
     KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+    sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
     Firm_event event[64];
     int        nBytes, i;
 
-    /* I certainly hope its not possible to read partial events */
-
-    if ((nBytes = read(pInfo->fd, (char *)event, sizeof(event))) > 0)
-    {
-        for (i = 0; i < (nBytes / sizeof(Firm_event)); i++) {
-	    pKbd->PostEvent(pInfo, event[i].id & 0xFF,
-			    event[i].value == VKEY_DOWN ? TRUE : FALSE);
+    while (TRUE) {
+	/* I certainly hope it's not possible to read partial events */
+	nBytes = read(pInfo->fd, (char *)event, sizeof(event));
+	if (nBytes > 0) {
+	    for (i = 0; i < (nBytes / sizeof(Firm_event)); i++) {
+		pKbd->PostEvent(pInfo, event[i].id & 0xFF,
+				event[i].value == VKEY_DOWN ? TRUE : FALSE);
+	    }
+	} else if (nBytes == -1) {
+	    switch (errno) {
+		case EAGAIN: /* Nothing to read now */
+		    return;
+		case EINTR:  /* Interrupted, try again */
+		    break;
+		case ENODEV: /* May happen when USB kbd is unplugged */
+		    /* We use X_NONE here because it doesn't alloc since we
+		       may be called from SIGIO handler */
+		    xf86MsgVerb(X_NONE, 0,
+				"%s: Device no longer present - removing.\n",
+				pInfo->name);
+		    xf86RemoveEnabledDevice(pInfo);
+		    priv->remove_timer = TimerSet(priv->remove_timer, 0, 1,
+						  RemoveKeyboard, pInfo);
+		    return;
+		default:     /* All other errors */
+		    /* We use X_NONE here because it doesn't alloc since we
+		       may be called from SIGIO handler */
+		    xf86MsgVerb(X_NONE, 0, "%s: Read error: %s\n", pInfo->name,
+				strerror(errno));
+		    return;
+	    }
+	} else { /* nBytes == 0, so nothing more to read */
+	    return;
 	}
     }
 }
diff --git a/src/sun_kbd.h b/src/sun_kbd.h
index a73e201..080cbb5 100644
--- a/src/sun_kbd.h
+++ b/src/sun_kbd.h
@@ -36,6 +36,7 @@ typedef struct {
     int 		odirect;	/* Original "direct" mode setting */
     int			oleds;		/* Original LED state */
     const char *	strmod;		/* Streams module pushed on kbd device */
+    OsTimerPtr		remove_timer;	/* Callback for removal on ENODEV */
 } sunKbdPrivRec, *sunKbdPrivPtr;
 
 /* sun_kbdMap.c */

commit 810fe3a4afd7e77a645c312f9475e75c2f7e925c
Author: Alan Curry <pacman@kosh.dhis.org>
Date:   Sat Feb 28 00:53:10 2009 -0500

    KDGETLED needs a char, not an int.
    
    KDGETLED actually only stores a single byte at the address indicated by
    &real_leds, which on big-endian systems means the kernel's led state is put
    into the most-significant byte of real_leds. The LED_CAP LED_NUM LED_SCR
    macros then extract some bits from the least-significant byte, which still
    contains stack garbage since real_leds hasn't been initialized.
    
    Don't believe what the console_ioctl(4) man page says. It's wrong. Go read
    drivers/char/vt_ioctl.c in the kernel source.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/lnx_kbd.c b/src/lnx_kbd.c
index cfe35a3..9144464 100644
--- a/src/lnx_kbd.c
+++ b/src/lnx_kbd.c
@@ -73,7 +73,8 @@ SetKbdLeds(InputInfoPtr pInfo, int leds)
 static int
 GetKbdLeds(InputInfoPtr pInfo)
 {
-    int real_leds, leds = 0;
+    char real_leds;
+    int leds = 0;
 
     ioctl(pInfo->fd, KDGETLED, &real_leds);
 

commit 0fafdc024624d27ddffdcc4ff0047dec59ef33e2
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Thu Apr 2 16:53:53 2009 -0700

    Remove Initialised static variable (not used since xf86AddModuleInfo removal)
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>

diff --git a/src/kbd.c b/src/kbd.c
index d596cf6..767ff6b 100644
--- a/src/kbd.c
+++ b/src/kbd.c
@@ -546,11 +546,6 @@ xf86KbdPlug(pointer	module,
 	    int		*errmaj,
 	    int		*errmin)
 {
-    static Bool Initialised = FALSE;
-
-    if (!Initialised)
-	Initialised = TRUE;
-
     xf86AddInputDriver(&KBD, module, 0);
 
     return module;

commit 7b64df0a988674454522e353ea2b56485474af6e
Author: David Miller <davem@davemloft.net>
Date:   Tue Feb 24 16:50:22 2009 -0800

    Fix xf86-input-keyboard build on Linux/sparc
    
    lnx_kbd.c: Fix Sparc build.
    
    Signed-off-by: David S. Miller <davem@davemloft.net>

diff --git a/src/lnx_kbd.c b/src/lnx_kbd.c
index d599df7..cfe35a3 100644
--- a/src/lnx_kbd.c
+++ b/src/lnx_kbd.c
@@ -57,17 +57,6 @@ SetKbdLeds(InputInfoPtr pInfo, int leds)
 {
     int real_leds = 0;
 
-#if defined (__sparc__)
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    if (pKbd->sunKbd) {
-  	if (leds & 0x08) real_leds |= XLED1;
-  	if (leds & 0x04) real_leds |= XLED3;
-  	if (leds & 0x02) real_leds |= XLED4;
-  	if (leds & 0x01) real_leds |= XLED2;
-        leds = real_leds;
-        real_leds = 0;
-    }
-#endif /* defined (__sparc__) */
 #ifdef LED_CAP
     if (leds & XLED1)  real_leds |= LED_CAP;
     if (leds & XLED2)  real_leds |= LED_NUM;

commit 62e663e7b107207b474713f22b6fec72f811dd86
Author: Daniel Stone <daniel@fooishbar.org>
Date:   Tue Feb 10 17:24:21 2009 +1000

    Switch to new XKB API
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/kbd.c b/src/kbd.c
index e89392b..d596cf6 100644
--- a/src/kbd.c
+++ b/src/kbd.c
@@ -38,9 +38,8 @@
 #include "xf86OSKbd.h"
 #include "compiler.h"
 
-#include <X11/extensions/XKB.h>
-#include <X11/extensions/XKBstr.h>
-#include <X11/extensions/XKBsrv.h>
+#include "xkbstr.h"
+#include "xkbsrv.h"
 
 #define CAPSFLAG	1
 #define NUMFLAG		2
@@ -88,12 +87,6 @@ typedef enum {
     OPTION_PROTOCOL,
     OPTION_AUTOREPEAT,
     OPTION_XLEDS,
-    OPTION_XKB_KEYMAP,
-    OPTION_XKB_KEYCODES,
-    OPTION_XKB_TYPES,
-    OPTION_XKB_COMPAT,
-    OPTION_XKB_SYMBOLS,
-    OPTION_XKB_GEOMETRY,
     OPTION_XKB_RULES,
     OPTION_XKB_MODEL,
     OPTION_XKB_LAYOUT,
@@ -111,12 +104,6 @@ static const OptionInfoRec KeyboardOptions[] = {
     { OPTION_PROTOCOL,		"Protocol",	  OPTV_STRING,	{0}, FALSE },
     { OPTION_AUTOREPEAT,	"AutoRepeat",	  OPTV_STRING,	{0}, FALSE },
     { OPTION_XLEDS,		"XLeds",	  OPTV_STRING,	{0}, FALSE },
-    { OPTION_XKB_KEYMAP,	"XkbKeymap",	  OPTV_STRING,	{0}, FALSE },
-    { OPTION_XKB_KEYCODES,	"XkbKeycodes",	  OPTV_STRING,	{0}, FALSE },
-    { OPTION_XKB_TYPES,		"XkbTypes",	  OPTV_STRING,	{0}, FALSE },
-    { OPTION_XKB_COMPAT,	"XkbCompat",	  OPTV_STRING,	{0}, FALSE },
-    { OPTION_XKB_SYMBOLS,	"XkbSymbols",	  OPTV_STRING,	{0}, FALSE },
-    { OPTION_XKB_GEOMETRY,	"XkbGeometry",	  OPTV_STRING,	{0}, FALSE },
     { OPTION_XKB_RULES,		"XkbRules",	  OPTV_STRING,	{0}, FALSE },
     { OPTION_XKB_MODEL,		"XkbModel",	  OPTV_STRING,	{0}, FALSE },
     { OPTION_XKB_LAYOUT,	"XkbLayout",	  OPTV_STRING,	{0}, FALSE },
@@ -166,8 +153,6 @@ static char *xkb_layout;
 static char *xkb_variant;
 static char *xkb_options;
 
-static XkbComponentNamesRec xkbnames;
-
 /*ARGSUSED*/
 static const OptionInfoRec *
 KeyboardAvailableOptions(void *unused)
@@ -258,24 +243,11 @@ KbdPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
         xfree(s);
     }
 
-  SetXkbOption(pInfo, "XkbKeymap", &xkbnames.keymap);
-  if (xkbnames.keymap) {
-      xf86Msg(X_CONFIG, "%s: XkbKeymap overrides all other XKB settings\n",
-              pInfo->name);
-  } else {
-      SetXkbOption(pInfo, "XkbRules", &xkb_rules);
-      SetXkbOption(pInfo, "XkbModel", &xkb_model);
-      SetXkbOption(pInfo, "XkbLayout", &xkb_layout);
-      SetXkbOption(pInfo, "XkbVariant", &xkb_variant);
-      SetXkbOption(pInfo, "XkbOptions", &xkb_options);
-
-      SetXkbOption(pInfo, "XkbKeycodes", &xkbnames.keycodes);
-      SetXkbOption(pInfo, "XkbTypes", &xkbnames.types);
-      SetXkbOption(pInfo, "XkbCompat", &xkbnames.compat);
-      SetXkbOption(pInfo, "XkbSymbols", &xkbnames.symbols);
-      SetXkbOption(pInfo, "XkbGeometry", &xkbnames.geometry);
-  }
-
+    SetXkbOption(pInfo, "XkbRules", &xkb_rules);
+    SetXkbOption(pInfo, "XkbModel", &xkb_model);
+    SetXkbOption(pInfo, "XkbLayout", &xkb_layout);
+    SetXkbOption(pInfo, "XkbVariant", &xkb_variant);
+    SetXkbOption(pInfo, "XkbOptions", &xkb_options);
 
   pKbd->CustomKeycodes = FALSE;
   from = X_DEFAULT; 
@@ -443,16 +415,28 @@ KbdProc(DeviceIntPtr device, int what)
          pKbd->KbdGetMapping(pInfo, &keySyms, modMap);
 
          device->public.on = FALSE;
-         if (xkbnames.keymap)
-             xkb_rules = NULL;
-         XkbSetRulesDflts(xkb_rules, xkb_model, xkb_layout,
-                 xkb_variant, xkb_options);
-         XkbInitKeyboardDeviceStruct(device,
-                 &xkbnames,
-                 &keySyms,
-                 modMap,
-                 KbdBell,
-                 (KbdCtrlProcPtr)KbdCtrl);
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 5
+         {
+             XkbRMLVOSet rmlvo;
+             rmlvo.rules = xkb_rules;
+             rmlvo.model = xkb_model;
+             rmlvo.layout = xkb_layout;
+             rmlvo.variant = xkb_variant;
+             rmlvo.options = xkb_options;
+


Reply to: