summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@redhat.com>2008-10-12 21:58:30 +1030
committerPeter Hutterer <peter.hutterer@redhat.com>2008-10-16 21:35:27 +1030
commitd936a4235c9625bd41569cef3452dd086284e0d7 (patch)
tree7de9b38ebb62ebe1cfecea5f7f435e355e3ff7c5
parent84ef8ed6fbefd8d6c0aaa3c862879f9804299bd8 (diff)
xfree86: if AllowEmptyInput is true, enable RAW mode on the console.
Usually, the console is set to RAW in the kbd driver. If we hotplug all input devices (i.e. the evdev driver for keyboards) and the console is left as-is. As a result, the evdev driver must put an EVIOCGRAB on the device to avoid characters leaking onto the console. This again breaks many things, amongst them lirc, in-kernel mouse button emulation and HAL. This patch sets the console to RAW if AllowEmptyInput is on. Use-cases: 1. AEI is off 1.1. Only kbd driver is used - behaviour as-is. 1.2. kbd and evdev driver is used: if evdev does not grab the device, duplicate events are generated. 2. AEI is on 2.1. Only evdev driver is used - behaviour as-is, but evdev does not need to grab the device anymore. 2.2. evdev and kbd are used: duplicate key events are generated if evdev does not grab the device. 1.2 is a marginal use-case that can be fixed by adding a "grab" option to the evdev driver (update of xorg.conf is needed). 2.2 is an issue. If we have no ServerLayout section, AEI is on, but devices specified in the xorg.conf are still added [1], resulting in duplicate events. This is a common configuration and needs sorting out. [1] 2eaed4a10fe5bf727579bca4ab8d4a47c8763a7d Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com> Signed-off-by: Adam Jackson <ajax@redhat.com>
-rw-r--r--hw/xfree86/os-support/linux/lnx_init.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index 4c36b7cf4..6f68ba57c 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -53,6 +53,8 @@ static int activeVT = -1;
static int vtPermSave[4];
static char vtname[11];
+static struct termios tty_attr; /* tty state to restore */
+static int tty_mode; /* kbd mode to restore */
static int
saveVtPerms(void)
@@ -272,6 +274,34 @@ xf86OpenConsole(void)
FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed %s\n",
strerror(errno));
+ /* Set the keyboard to RAW mode. If we're using the keyboard
+ * driver, the driver does it for us. If we have AEI on, then
+ * we're expecting the devices to be added (i.e. evdev) and we
+ * have to set it manually.
+ */
+ if (xf86Info.allowEmptyInput)
+ {
+ struct termios nTty;
+
+ tcgetattr(xf86Info.consoleFd, &tty_attr);
+ ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode);
+
+ if (ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW) < 0)
+ FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n",
+ strerror(errno));
+
+ nTty = tty_attr;
+ nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ nTty.c_oflag = 0;
+ nTty.c_cflag = CREAD | CS8;
+ nTty.c_lflag = 0;
+ nTty.c_cc[VTIME]=0;
+ nTty.c_cc[VMIN]=1;
+ cfsetispeed(&nTty, 9600);
+ cfsetospeed(&nTty, 9600);
+ tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
+ }
+
/* we really should have a InitOSInputDevices() function instead
* of Init?$#*&Device(). So I just place it here */
@@ -328,7 +358,10 @@ xf86CloseConsole()
if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT) < 0)
xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n",
strerror(errno));
-
+
+ ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode);
+ tcsetattr(xf86Info.consoleFd, TCSANOW, &tty_attr);
+
if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETMODE failed: %s\n",
strerror(errno));