Author: cfinck
Date: Sat Aug 16 07:20:18 2008
New Revision: 35387
URL:
http://svn.reactos.org/svn/reactos?rev=35387&view=rev
Log:
Restructure the keyboard & mouse detection code:
- Truly separate i8042BasicDetect from i8042DetectKeyboard and i8042DetectMouse: It now
only does the CTRL_SELF_TEST, any other specific detections are done in their respective
functions
- Only set KEYBOARD_PRESENT and MOUSE_PRESENT, when all respective detections completed
successfully
Might fix bug #3550
Modified:
trunk/reactos/drivers/input/i8042prt/pnp.c
Modified: trunk/reactos/drivers/input/i8042prt/pnp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/input/i8042prt/pnp…
==============================================================================
--- trunk/reactos/drivers/input/i8042prt/pnp.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/input/i8042prt/pnp.c [iso-8859-1] Sat Aug 16 07:20:18 2008
@@ -85,6 +85,7 @@
i8042Flush(DeviceExtension);
+ /* Issue a CTRL_SELF_TEST command to check if this is really an i8042 controller */
ResendIterations = DeviceExtension->Settings.ResendIterations + 1;
while (ResendIterations--)
{
@@ -118,53 +119,42 @@
}
}
+ return STATUS_SUCCESS;
+}
+
+static VOID
+i8042DetectKeyboard(
+ IN PPORT_DEVICE_EXTENSION DeviceExtension)
+{
+ NTSTATUS Status;
+
+ /* Set LEDs (that is not fatal if some error occurs) */
+ Status = i8042SynchWritePort(DeviceExtension, 0, KBD_CMD_SET_LEDS, TRUE);
+ if (NT_SUCCESS(Status))
+ {
+ Status = i8042SynchWritePort(DeviceExtension, 0, 0, TRUE);
+ if (!NT_SUCCESS(Status))
+ {
+ WARN_(I8042PRT, "Can't finish SET_LEDS (0x%08lx)\n", Status);
+ return;
+ }
+ }
+ else
+ {
+ WARN_(I8042PRT, "Warning: can't write SET_LEDS (0x%08lx)\n", Status);
+ }
+
+ /* Turn on translation and SF (Some machines don't reboot if SF is not set, see
ReactOS bug #1842) */
+ if (!i8042ChangeMode(DeviceExtension, 0, CCB_TRANSLATE | CCB_SYSTEM_FLAG))
+ return;
+
/*
- * We used to send a KBD_LINE_TEST (0xAB) command here, but on at least HP
+ * We used to send a KBD_LINE_TEST (0xAB) command, but on at least HP
* Pavilion notebooks the response to that command was incorrect.
* So now we just assume that a keyboard is attached.
*/
DeviceExtension->Flags |= KEYBOARD_PRESENT;
- if (i8042Write(DeviceExtension, DeviceExtension->ControlPort, MOUSE_LINE_TEST))
- {
- Status = i8042ReadDataWait(DeviceExtension, &Value);
- if (NT_SUCCESS(Status) && Value == 0)
- DeviceExtension->Flags |= MOUSE_PRESENT;
- }
-
- if (IsFirstStageSetup())
- /* Ignore the mouse */
- DeviceExtension->Flags &= ~MOUSE_PRESENT;
-
- return STATUS_SUCCESS;
-}
-
-static VOID
-i8042DetectKeyboard(
- IN PPORT_DEVICE_EXTENSION DeviceExtension)
-{
- NTSTATUS Status;
-
- /* Set LEDs (that is not fatal if some error occurs) */
- Status = i8042SynchWritePort(DeviceExtension, 0, KBD_CMD_SET_LEDS, TRUE);
- if (NT_SUCCESS(Status))
- {
- Status = i8042SynchWritePort(DeviceExtension, 0, 0, TRUE);
- if (!NT_SUCCESS(Status))
- {
- WARN_(I8042PRT, "Can't finish SET_LEDS (0x%08lx)\n", Status);
- return;
- }
- }
- else
- {
- WARN_(I8042PRT, "Warning: can't write SET_LEDS (0x%08lx)\n", Status);
- }
-
- /* Turn on translation and SF (Some machines don't reboot if SF is not set, see
ReactOS bug #1842) */
- if (!i8042ChangeMode(DeviceExtension, 0, CCB_TRANSLATE | CCB_SYSTEM_FLAG))
- return;
-
INFO_(I8042PRT, "Keyboard detected\n");
}
@@ -177,6 +167,19 @@
UCHAR ExpectedReply[] = { MOUSE_ACK, 0xAA };
UCHAR ReplyByte;
+ /* First do a mouse line test */
+ if (i8042Write(DeviceExtension, DeviceExtension->ControlPort, MOUSE_LINE_TEST))
+ {
+ Status = i8042ReadDataWait(DeviceExtension, &Value);
+
+ if (!NT_SUCCESS(Status) || Value != 0)
+ {
+ WARN_(I8042PRT, "Mouse line test failed\n");
+ goto failure;
+ }
+ }
+
+ /* Now reset the mouse */
i8042Flush(DeviceExtension);
if(!i8042IsrWritePort(DeviceExtension, MOU_CMD_RESET, CTRL_WRITE_MOUSE))
@@ -240,6 +243,7 @@
goto failure;
}
+ DeviceExtension->Flags |= MOUSE_PRESENT;
INFO_(I8042PRT, "Mouse detected\n");
return;
@@ -415,9 +419,14 @@
}
/* First detect the mouse and then the keyboard!
- If we do it the other way round, some systems throw away settings like the keyboard
translation, when detecting the mouse. */
- TRACE_(I8042PRT, "Detecting mouse\n");
- i8042DetectMouse(DeviceExtension);
+ If we do it the other way round, some systems throw away settings like the keyboard
translation, when detecting the mouse.
+
+ Don't detect the mouse if we're in 1st stage setup! */
+ if(!IsFirstStageSetup())
+ {
+ TRACE_(I8042PRT, "Detecting mouse\n");
+ i8042DetectMouse(DeviceExtension);
+ }
TRACE_(I8042PRT, "Detecting keyboard\n");
i8042DetectKeyboard(DeviceExtension);