This should fix mouse problems that occured with MS Virtual PC.

The test for active multiplexing support now validates all data.
Cleanup of ps2_set_sample_rate, retrying isn't needed. 


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16692 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Marcus Overhagen 2006-03-10 22:03:30 +00:00
parent f5d5a442b8
commit 31c533d926
2 changed files with 38 additions and 38 deletions

View File

@ -140,36 +140,52 @@ ps2_setup_active_multiplexing(bool *enabled)
res = ps2_command(0xd3, &out, 1, &in, 1);
if (res)
return res;
// Step 1, if controller is good, in does match out.
// This test failes with MS Virtual PC.
if (in != out)
goto no_support;
out = 0x56;
res = ps2_command(0xd3, &out, 1, &in, 1);
if (res)
return res;
// Step 2, if controller is good, in does match out.
if (in != out)
goto no_support;
out = 0xa4;
res = ps2_command(0xd3, &out, 1, &in, 1);
if (res)
return res;
// If the controller doesn't support active multiplexing,
// in data is 0xa4 (or 0xac on some broken USB legacy emulation)
// Step 3, if the controller doesn't support active multiplexing,
// then in data does match out data (0xa4), else it's version number.
if (in == out)
goto no_support;
if (in != 0xa4 && in != 0xac) {
dprintf("ps2: active multiplexing v%d.%d enabled\n", (in >> 4), in & 0xf);
*enabled = true;
ps2_command(0xa8, NULL, 0, NULL, 0);
ps2_command(0x90, NULL, 0, NULL, 0);
ps2_command(0xa8, NULL, 0, NULL, 0);
ps2_command(0x91, NULL, 0, NULL, 0);
ps2_command(0xa8, NULL, 0, NULL, 0);
ps2_command(0x92, NULL, 0, NULL, 0);
ps2_command(0xa8, NULL, 0, NULL, 0);
ps2_command(0x93, NULL, 0, NULL, 0);
ps2_command(0xa8, NULL, 0, NULL, 0);
} else {
dprintf("ps2: active multiplexing not supported\n");
*enabled = false;
// With some broken USB legacy emulation, it's 0xac, and with
// MS Virtual PC, it's 0xa6. Since current active multiplexing
// specification version is 1.1 (0x11), we validate the data.
if (in > 0x9f) {
dprintf("ps2: active multiplexing v%d.%d detected, but ignored!\n", (in >> 4), in & 0xf);
goto no_support;
}
dprintf("ps2: active multiplexing v%d.%d enabled\n", (in >> 4), in & 0xf);
ps2_command(0xa8, NULL, 0, NULL, 0);
ps2_command(0x90, NULL, 0, NULL, 0);
ps2_command(0xa8, NULL, 0, NULL, 0);
ps2_command(0x91, NULL, 0, NULL, 0);
ps2_command(0xa8, NULL, 0, NULL, 0);
ps2_command(0x92, NULL, 0, NULL, 0);
ps2_command(0xa8, NULL, 0, NULL, 0);
ps2_command(0x93, NULL, 0, NULL, 0);
ps2_command(0xa8, NULL, 0, NULL, 0);
*enabled = true;
return B_OK;
no_support:
dprintf("ps2: active multiplexing not supported\n");
*enabled = false;
return B_OK;
}

View File

@ -58,7 +58,6 @@
* byte, on the second the X offset, and on the 3rd the Y offset.
*/
#include <Drivers.h>
#include <string.h>
#include <malloc.h>
@ -88,7 +87,7 @@ typedef struct
uint8 packet_buffer[PS2_MAX_PACKET_SIZE];
} mouse_cookie;
static status_t
ps2_reset_mouse(mouse_cookie *cookie)
@ -113,29 +112,17 @@ ps2_reset_mouse(mouse_cookie *cookie)
}
/** Set sampling rate of the ps2 port.
*/
static status_t
static inline status_t
ps2_set_sample_rate(mouse_cookie *cookie, uint8 rate)
{
int32 tries = 5;
while (--tries > 0) {
status_t status = ps2_dev_command(cookie->dev, PS2_CMD_SET_SAMPLE_RATE, &rate, 1, NULL, 0);
if (status == B_OK)
return B_OK;
}
return B_ERROR;
return ps2_dev_command(cookie->dev, PS2_CMD_SET_SAMPLE_RATE, &rate, 1, NULL, 0);
}
/** Converts a packet received by the mouse to a "movement".
*/
*/
static void
ps2_packet_to_movement(mouse_cookie *cookie, uint8 packet[], mouse_movement *pos)
{
@ -187,7 +174,6 @@ ps2_packet_to_movement(mouse_cookie *cookie, uint8 packet[], mouse_movement *pos
/** Read a mouse event from the mouse events chain buffer.
*/
static status_t
mouse_read_event(mouse_cookie *cookie, mouse_movement *userMovement)
{
@ -216,7 +202,6 @@ mouse_read_event(mouse_cookie *cookie, mouse_movement *userMovement)
/** Enables or disables mouse reporting for the PS/2 port.
*/
static status_t
set_mouse_enabled(mouse_cookie *cookie, bool enable)
{
@ -240,7 +225,6 @@ set_mouse_enabled(mouse_cookie *cookie, bool enable)
* by read() operations. The full data is obtained using 3 consecutive
* calls to the handler, each holds a different byte on the data port.
*/
int32
mouse_handle_int(ps2_dev *dev, uint8 data)
{