[haiku-commits] Change in haiku[master]: ps2: workaround for non-working active multiplexing support

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 19 Jun 2022 14:22:50 +0000

From Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>:

Adrien Destugues has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/5388 ;)


Change subject: ps2: workaround for non-working active multiplexing support
......................................................................

ps2: workaround for non-working active multiplexing support

On my machine nothing is wired to the mouse port, but the controller
still pretends to support active multiplexing. Trying to send
multiplexed commands confuses the keyboard, which eventually resets (and
loses the LED status and typematic rate settings).

Fixes #17806

Change-Id: Ia6a2b031550c845fa305df5b5f4d513d5c7931d6
---
M src/add-ons/kernel/bus_managers/ps2/ps2_common.cpp
M src/add-ons/kernel/bus_managers/ps2/ps2_defs.h
M src/add-ons/kernel/bus_managers/ps2/ps2_dev.cpp
3 files changed, 23 insertions(+), 9 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/88/5388/1

diff --git a/src/add-ons/kernel/bus_managers/ps2/ps2_common.cpp 
b/src/add-ons/kernel/bus_managers/ps2/ps2_common.cpp
index 5b7e6f8..965fab1 100644
--- a/src/add-ons/kernel/bus_managers/ps2/ps2_common.cpp
+++ b/src/add-ons/kernel/bus_managers/ps2/ps2_common.cpp
@@ -205,6 +205,19 @@
        }
 
        INFO("ps2: active multiplexing v%d.%d enabled\n", (in >> 4), in & 0xf);
+
+       // Workaround for non-working multiplexing on Fujitsu Lifebook U7311. 
On this machine the
+       // multiplexed commands get to the keyboard instead of the mouse port. 
Check if we get a
+       // resend response from the keyboard, and in that case, don't use 
multiplexing.
+       // Fixes #17806
+       out = PS2_CMD_MOUSE_SET_SCALE11;
+       res = ps2_command(PS2_CTRL_WRITE_MUX, &out, 1, &in, 1);
+
+       if (res == B_OK && in == PS2_CMD_RESEND) {
+               INFO("ps2: active multiplexing not working, not enabling it\n");
+               goto done;
+       }
+
        *enabled = true;
        goto done;

@@ -403,9 +416,9 @@

        if (gActiveMultiplexingEnabled) {
                // The multiplexing spec recommends to leave device 0 
unconnected because it saves some
-               // confusion with the use of the D3 command which appears as if 
the replied data was
-               // coming from device 0. So we enable it only if it really 
looks like there is a device
-               // connected there.
+               // confusion with the use of the AUX LOOPBACK command which 
appears as if the echoed
+               // data was coming from device 0. So we enable it only if it 
really looks like there is
+               // a device connected there.
                if (ps2_dev_command_timeout(&ps2_device[PS2_DEVICE_MOUSE],
                                PS2_CMD_MOUSE_SET_SCALE11, NULL, 0, NULL, 0, 
100000) == B_TIMED_OUT) {
                        INFO("ps2: accessing multiplexed mouse port 0 timed 
out, ignoring it!\n");
@@ -416,12 +429,12 @@
                for (int idx = 1; idx < 3; idx++) {
                        
ps2_service_notify_device_added(&ps2_device[PS2_DEVICE_MOUSE + idx]);
                }
-               ps2_service_notify_device_added(&ps2_device[PS2_DEVICE_KEYB]);
        } else {
                ps2_service_notify_device_added(&ps2_device[PS2_DEVICE_MOUSE]);
-               ps2_service_notify_device_added(&ps2_device[PS2_DEVICE_KEYB]);
        }

+       ps2_service_notify_device_added(&ps2_device[PS2_DEVICE_KEYB]);
+
        TRACE("ps2: init done!\n");
        return B_OK;

diff --git a/src/add-ons/kernel/bus_managers/ps2/ps2_defs.h 
b/src/add-ons/kernel/bus_managers/ps2/ps2_defs.h
index b5aaacd..d712133 100644
--- a/src/add-ons/kernel/bus_managers/ps2/ps2_defs.h
+++ b/src/add-ons/kernel/bus_managers/ps2/ps2_defs.h
@@ -28,8 +28,7 @@
 // control words
 #define PS2_CTRL_READ_CMD                              0x20
 #define PS2_CTRL_WRITE_CMD                             0x60
-#define PS2_CTRL_AUX_LOOPBACK                  0xd3
-#define PS2_CTRL_WRITE_AUX                             0xd4
+#define PS2_CTRL_WRITE_MUX                             0x90
 #define PS2_CTRL_MOUSE_DISABLE                 0xa7
 #define PS2_CTRL_MOUSE_ENABLE                  0xa8
 #define PS2_CTRL_MOUSE_TEST                            0xa9
@@ -37,6 +36,8 @@
 #define PS2_CTRL_KEYBOARD_TEST                 0xab
 #define PS2_CTRL_KEYBOARD_DISABLE              0xad
 #define PS2_CTRL_KEYBOARD_ENABLE               0xae
+#define PS2_CTRL_AUX_LOOPBACK                  0xd3
+#define PS2_CTRL_WRITE_AUX                             0xd4

 // command bytes
 #define PS2_CMD_DEV_INIT                               0x43
diff --git a/src/add-ons/kernel/bus_managers/ps2/ps2_dev.cpp 
b/src/add-ons/kernel/bus_managers/ps2/ps2_dev.cpp
index 5f2b7ba..04153c0 100644
--- a/src/add-ons/kernel/bus_managers/ps2/ps2_dev.cpp
+++ b/src/add-ons/kernel/bus_managers/ps2/ps2_dev.cpp
@@ -412,9 +412,9 @@
                if (!(atomic_get(&dev->flags) & PS2_FLAG_KEYB)) {
                        uint8 prefix_cmd;
                        if (gActiveMultiplexingEnabled)
-                               prefix_cmd = 0x90 + dev->idx;
+                               prefix_cmd = PS2_CTRL_WRITE_MUX + dev->idx;
                        else
-                               prefix_cmd = 0xd4;
+                               prefix_cmd = PS2_CTRL_WRITE_AUX;
                        res = ps2_wait_write();
                        if (res == B_OK)
                                ps2_write_ctrl(prefix_cmd);

--
To view, visit https://review.haiku-os.org/c/haiku/+/5388
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: Ia6a2b031550c845fa305df5b5f4d513d5c7931d6
Gerrit-Change-Number: 5388
Gerrit-PatchSet: 1
Gerrit-Owner: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: ps2: workaround for non-working active multiplexing support - Gerrit