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:
parent
f5d5a442b8
commit
31c533d926
@ -140,36 +140,52 @@ ps2_setup_active_multiplexing(bool *enabled)
|
|||||||
res = ps2_command(0xd3, &out, 1, &in, 1);
|
res = ps2_command(0xd3, &out, 1, &in, 1);
|
||||||
if (res)
|
if (res)
|
||||||
return 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;
|
out = 0x56;
|
||||||
res = ps2_command(0xd3, &out, 1, &in, 1);
|
res = ps2_command(0xd3, &out, 1, &in, 1);
|
||||||
if (res)
|
if (res)
|
||||||
return res;
|
return res;
|
||||||
|
// Step 2, if controller is good, in does match out.
|
||||||
|
if (in != out)
|
||||||
|
goto no_support;
|
||||||
|
|
||||||
out = 0xa4;
|
out = 0xa4;
|
||||||
res = ps2_command(0xd3, &out, 1, &in, 1);
|
res = ps2_command(0xd3, &out, 1, &in, 1);
|
||||||
if (res)
|
if (res)
|
||||||
return res;
|
return res;
|
||||||
|
// Step 3, if the controller doesn't support active multiplexing,
|
||||||
// If the controller doesn't support active multiplexing,
|
// then in data does match out data (0xa4), else it's version number.
|
||||||
// in data is 0xa4 (or 0xac on some broken USB legacy emulation)
|
if (in == out)
|
||||||
|
goto no_support;
|
||||||
|
|
||||||
if (in != 0xa4 && in != 0xac) {
|
// With some broken USB legacy emulation, it's 0xac, and with
|
||||||
dprintf("ps2: active multiplexing v%d.%d enabled\n", (in >> 4), in & 0xf);
|
// MS Virtual PC, it's 0xa6. Since current active multiplexing
|
||||||
*enabled = true;
|
// specification version is 1.1 (0x11), we validate the data.
|
||||||
ps2_command(0xa8, NULL, 0, NULL, 0);
|
if (in > 0x9f) {
|
||||||
ps2_command(0x90, NULL, 0, NULL, 0);
|
dprintf("ps2: active multiplexing v%d.%d detected, but ignored!\n", (in >> 4), in & 0xf);
|
||||||
ps2_command(0xa8, NULL, 0, NULL, 0);
|
goto no_support;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,6 @@
|
|||||||
* byte, on the second the X offset, and on the 3rd the Y offset.
|
* byte, on the second the X offset, and on the 3rd the Y offset.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <Drivers.h>
|
#include <Drivers.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
@ -88,7 +87,7 @@ typedef struct
|
|||||||
uint8 packet_buffer[PS2_MAX_PACKET_SIZE];
|
uint8 packet_buffer[PS2_MAX_PACKET_SIZE];
|
||||||
|
|
||||||
} mouse_cookie;
|
} mouse_cookie;
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
ps2_reset_mouse(mouse_cookie *cookie)
|
ps2_reset_mouse(mouse_cookie *cookie)
|
||||||
@ -113,29 +112,17 @@ ps2_reset_mouse(mouse_cookie *cookie)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Set sampling rate of the ps2 port.
|
/** Set sampling rate of the ps2 port.
|
||||||
*/
|
*/
|
||||||
|
static inline status_t
|
||||||
static status_t
|
|
||||||
ps2_set_sample_rate(mouse_cookie *cookie, uint8 rate)
|
ps2_set_sample_rate(mouse_cookie *cookie, uint8 rate)
|
||||||
{
|
{
|
||||||
int32 tries = 5;
|
return ps2_dev_command(cookie->dev, PS2_CMD_SET_SAMPLE_RATE, &rate, 1, NULL, 0);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Converts a packet received by the mouse to a "movement".
|
/** Converts a packet received by the mouse to a "movement".
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ps2_packet_to_movement(mouse_cookie *cookie, uint8 packet[], mouse_movement *pos)
|
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.
|
/** Read a mouse event from the mouse events chain buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
mouse_read_event(mouse_cookie *cookie, mouse_movement *userMovement)
|
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.
|
/** Enables or disables mouse reporting for the PS/2 port.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
set_mouse_enabled(mouse_cookie *cookie, bool enable)
|
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
|
* by read() operations. The full data is obtained using 3 consecutive
|
||||||
* calls to the handler, each holds a different byte on the data port.
|
* calls to the handler, each holds a different byte on the data port.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int32
|
int32
|
||||||
mouse_handle_int(ps2_dev *dev, uint8 data)
|
mouse_handle_int(ps2_dev *dev, uint8 data)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user