This should fix hanging keyboards when no ps2 mouse is connected. We also stop publishing devices we didn't explicitly find. This disables the questionable hot-plug support but keeps the input_server from stalling the keyboard by probing the non-present mouse.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14349 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -54,6 +54,7 @@ sem_id gDeviceOpenSemaphore;
|
||||
static int32 sInitialized = 0;
|
||||
static uint8 sCommandByte = 0;
|
||||
static bool sKeyboardDetected = false;
|
||||
static bool sMouseDetected = false;
|
||||
|
||||
static sem_id sResultSemaphore;
|
||||
static sem_id sResultOwnerSemaphore;
|
||||
@@ -77,7 +78,7 @@ wait_for_status(int32 bits, bool set)
|
||||
|
||||
while (tries-- > 0) {
|
||||
read = gIsa->read_io_8(PS2_PORT_CTRL);
|
||||
if (((read & bits) != 0) == set)
|
||||
if (((read & bits) == bits) == set)
|
||||
return B_OK;
|
||||
|
||||
spin(100);
|
||||
@@ -299,14 +300,15 @@ const char **
|
||||
publish_devices(void)
|
||||
{
|
||||
static char *kDevices[3];
|
||||
|
||||
kDevices[0] = DEVICE_MOUSE_NAME;
|
||||
int index = 0;
|
||||
|
||||
if (sKeyboardDetected) {
|
||||
kDevices[1] = DEVICE_KEYBOARD_NAME;
|
||||
kDevices[2] = NULL;
|
||||
} else
|
||||
kDevices[1] = NULL;
|
||||
if (sMouseDetected)
|
||||
kDevices[index++] = DEVICE_MOUSE_NAME;
|
||||
|
||||
if (sKeyboardDetected)
|
||||
kDevices[index++] = DEVICE_KEYBOARD_NAME;
|
||||
|
||||
kDevices[index++] = NULL;
|
||||
|
||||
return (const char **)kDevices;
|
||||
}
|
||||
@@ -335,14 +337,23 @@ init_driver(void)
|
||||
return status;
|
||||
}
|
||||
|
||||
// If there is no keyboard or mouse, we don't need to publish ourselves
|
||||
// Try to probe for the mouse first, as this can hang the keyboard if no
|
||||
// mouse is found.
|
||||
// Probing the mouse first and initializing the keyboard later appearantly
|
||||
// clears the keyboard stall.
|
||||
|
||||
if (probe_mouse() == B_OK)
|
||||
sMouseDetected = true;
|
||||
else
|
||||
dprintf("ps2_hid: no mouse detected!\n");
|
||||
|
||||
if (probe_keyboard() == B_OK)
|
||||
sKeyboardDetected = true;
|
||||
else
|
||||
dprintf("ps2_hid: no keyboard detected!\n");
|
||||
|
||||
if (!sKeyboardDetected && probe_mouse() != B_OK) {
|
||||
// If there is no keyboard or mouse, we don't need to publish ourselves
|
||||
if (!sKeyboardDetected && !sMouseDetected) {
|
||||
put_module(B_ISA_MODULE_NAME);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ enable_keyboard(void)
|
||||
status_t
|
||||
probe_keyboard(void)
|
||||
{
|
||||
uint32 tries;
|
||||
int32 tries;
|
||||
|
||||
// ToDo: for now there just is a keyboard ready to be used...
|
||||
|
||||
@@ -271,8 +271,10 @@ probe_keyboard(void)
|
||||
if (ps2_read_data(&acknowledged) == B_OK && acknowledged == PS2_REPLY_ACK)
|
||||
break;
|
||||
}
|
||||
if (tries < 0)
|
||||
return B_ERROR;
|
||||
|
||||
// This selftest appears to fail quite frequently we'll just disable it
|
||||
/*if (tries < 0)
|
||||
return B_ERROR;*/
|
||||
|
||||
// Activate keyboard
|
||||
|
||||
|
||||
@@ -320,7 +320,6 @@ probe_mouse(void)
|
||||
TRACE(("Extended PS/2 mouse found\n"));
|
||||
} else {
|
||||
// Something's wrong. Better quit
|
||||
dprintf("ps2_hid: No mouse found\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user