summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Zang <Aaron.Zang@Sun.COM>2009-08-13 20:39:59 -0700
committerAlan Coopersmith <alan.coopersmith@sun.com>2009-08-13 20:43:07 -0700
commit891d55e759ff6a30f62809081a11c3da20fc0551 (patch)
tree84c7e4e62ddb31f40450cf2b36f0d1207c2b8971
parent8e42e8f0034d89ef4b6cee44148961f808ba0602 (diff)
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>
-rw-r--r--src/sun_kbd.c29
1 files changed, 25 insertions, 4 deletions
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",