hrev47471 adds 1 changeset to branch 'master' old head: 7a28891db4b5f41f104b83a87c165bb19b02dcfb new head: 819b454750bfac97f44c156e7e0fdb9683406ab8 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=819b454+%5E7a28891 ---------------------------------------------------------------------------- 819b454: PS/2 bus manager: style fixes only [ John Scipione <jscipione@xxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev47471 Commit: 819b454750bfac97f44c156e7e0fdb9683406ab8 URL: http://cgit.haiku-os.org/haiku/commit/?id=819b454 Author: John Scipione <jscipione@xxxxxxxxx> Date: Mon Jul 7 21:38:55 2014 UTC ---------------------------------------------------------------------------- 4 files changed, 111 insertions(+), 102 deletions(-) src/add-ons/kernel/bus_managers/ps2/ps2_dev.cpp | 53 +++++----- src/add-ons/kernel/bus_managers/ps2/ps2_dev.h | 22 ++-- .../bus_managers/ps2/ps2_standard_mouse.cpp | 103 ++++++++++--------- .../kernel/bus_managers/ps2/ps2_standard_mouse.h | 35 +++---- ---------------------------------------------------------------------------- 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 b625320..455ca5f 100644 --- a/src/add-ons/kernel/bus_managers/ps2/ps2_dev.cpp +++ b/src/add-ons/kernel/bus_managers/ps2/ps2_dev.cpp @@ -1,15 +1,15 @@ /* - * Copyright 2005-2007 Haiku, Inc. + * Copyright 2005-2014 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * - * PS/2 bus manager - * * Authors (in chronological order): * Marcus Overhagen (marcus@xxxxxxxxxxxx) * Clemens Zeidler (haiku@xxxxxxxxxxxxxxxxxx) */ +/*! PS/2 bus manager */ + #include "ps2_dev.h" #include "ps2_service.h" @@ -28,7 +28,7 @@ ps2_dev ps2_device[PS2_DEVICE_COUNT]; status_t -ps2_reset_mouse(ps2_dev *dev) +ps2_reset_mouse(ps2_dev* dev) { uint8 data[2]; status_t status; @@ -40,8 +40,8 @@ ps2_reset_mouse(ps2_dev *dev) if (status == B_OK && data[0] == 0xFE && data[1] == 0xAA) { // workaround for HP/Compaq KBCs timeout condition. #2867 #3594 #4315 TRACE("ps2: KBC has timed out the mouse reset request. " - "Response was: 0x%02x 0x%02x. Requesting the answer data.\n", - data[0], data[1]); + "Response was: 0x%02x 0x%02x. Requesting the answer data.\n", + data[0], data[1]); status = ps2_dev_command(dev, PS2_CMD_RESEND, NULL, 0, data, 2); } @@ -60,7 +60,7 @@ ps2_reset_mouse(ps2_dev *dev) status_t -ps2_dev_detect_pointing(ps2_dev *dev, device_hooks **hooks) +ps2_dev_detect_pointing(ps2_dev* dev, device_hooks** hooks) { status_t status = ps2_reset_mouse(dev); if (status != B_OK) { @@ -161,14 +161,16 @@ ps2_dev_init(void) int i; for (i = 0; i < PS2_DEVICE_COUNT; i++) { - ps2_dev *dev = &ps2_device[i]; + ps2_dev* dev = &ps2_device[i]; dev->result_sem = create_sem(0, "ps2 result"); if (dev->result_sem < 0) goto err; } return B_OK; + err: ps2_dev_exit(); + return B_ERROR; } @@ -176,9 +178,8 @@ err: void ps2_dev_exit(void) { - int i; - for (i = 0; i < PS2_DEVICE_COUNT; i++) { - ps2_dev *dev = &ps2_device[i]; + for (int i = 0; i < PS2_DEVICE_COUNT; i++) { + ps2_dev* dev = &ps2_device[i]; if (dev->result_sem >= 0) { delete_sem(dev->result_sem); dev->result_sem = -1; @@ -188,7 +189,7 @@ ps2_dev_exit(void) void -ps2_dev_publish(ps2_dev *dev) +ps2_dev_publish(ps2_dev* dev) { status_t status = B_OK; TRACE("ps2: ps2_dev_publish %s\n", dev->name); @@ -218,7 +219,7 @@ ps2_dev_publish(ps2_dev *dev) } if (status == B_OK) { - device_hooks *hooks; + device_hooks* hooks; status = ps2_dev_detect_pointing(dev, &hooks); if (status == B_OK) { status = devfs_publish_device(dev->name, hooks); @@ -234,7 +235,7 @@ ps2_dev_publish(ps2_dev *dev) void -ps2_dev_unpublish(ps2_dev *dev) +ps2_dev_unpublish(ps2_dev* dev) { status_t status; TRACE("ps2: ps2_dev_unpublish %s\n", dev->name); @@ -255,7 +256,7 @@ ps2_dev_unpublish(ps2_dev *dev) int32 -ps2_dev_handle_int(ps2_dev *dev) +ps2_dev_handle_int(ps2_dev* dev) { const uint8 data = dev->history[0].data; uint32 flags; @@ -365,8 +366,8 @@ pass_to_handler: status_t -standard_command_timeout(ps2_dev *dev, uint8 cmd, const uint8 *out, - int out_count, uint8 *in, int in_count, bigtime_t timeout) +standard_command_timeout(ps2_dev* dev, uint8 cmd, const uint8* out, + int out_count, uint8* in, int in_count, bigtime_t timeout) { status_t res; bigtime_t start; @@ -484,8 +485,8 @@ standard_command_timeout(ps2_dev *dev, uint8 cmd, const uint8 *out, status_t -ps2_dev_command(ps2_dev *dev, uint8 cmd, const uint8 *out, int out_count, - uint8 *in, int in_count) +ps2_dev_command(ps2_dev* dev, uint8 cmd, const uint8* out, int out_count, + uint8* in, int in_count) { return ps2_dev_command_timeout(dev, cmd, out, out_count, in, in_count, 4000000); @@ -493,29 +494,35 @@ ps2_dev_command(ps2_dev *dev, uint8 cmd, const uint8 *out, int out_count, status_t -ps2_dev_command_timeout(ps2_dev *dev, uint8 cmd, const uint8 *out, - int out_count, uint8 *in, int in_count, bigtime_t timeout) +ps2_dev_command_timeout(ps2_dev* dev, uint8 cmd, const uint8* out, + int out_count, uint8* in, int in_count, bigtime_t timeout) { return dev->command(dev, cmd, out, out_count, in, in_count, timeout); } status_t -ps2_dev_sliced_command(ps2_dev *dev, uint8 cmd) +ps2_dev_sliced_command(ps2_dev* dev, uint8 cmd) { + uint8 val; if (ps2_dev_command(dev, PS2_CMD_MOUSE_SET_SCALE11) != B_OK) return B_ERROR; - uint8 val = (cmd >> 6) & 3; + + val = (cmd >> 6) & 3; if (ps2_dev_command(dev, PS2_CMD_MOUSE_SET_RES, &val, 1) != B_OK) return B_ERROR; + val = (cmd >> 4) & 3; if (ps2_dev_command(dev, PS2_CMD_MOUSE_SET_RES, &val, 1) != B_OK) return B_ERROR; + val = (cmd >> 2) & 3; if (ps2_dev_command(dev, PS2_CMD_MOUSE_SET_RES, &val, 1) != B_OK) return B_ERROR; + val = cmd & 3; if (ps2_dev_command(dev, PS2_CMD_MOUSE_SET_RES, &val, 1) != B_OK) return B_ERROR; + return B_OK; } diff --git a/src/add-ons/kernel/bus_managers/ps2/ps2_dev.h b/src/add-ons/kernel/bus_managers/ps2/ps2_dev.h index 98c8c45..556a526 100644 --- a/src/add-ons/kernel/bus_managers/ps2/ps2_dev.h +++ b/src/add-ons/kernel/bus_managers/ps2/ps2_dev.h @@ -1,11 +1,10 @@ /* - * Copyright 2005-2010 Haiku, Inc. + * Copyright 2005-2014 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * - * PS/2 bus manager - * * Authors (in chronological order): * Marcus Overhagen (marcus@xxxxxxxxxxxx) + * Clemens Zeidler (haiku@xxxxxxxxxxxxxxxxxx) */ #ifndef __PS2_DEV_H #define __PS2_DEV_H @@ -24,24 +23,24 @@ typedef struct { } data_history; struct ps2_dev { - const char * name; + const char* name; bool active; uint8 idx; sem_id result_sem; int32 flags; - uint8 * result_buf; + uint8* result_buf; int result_buf_idx; int result_buf_cnt; - void * cookie; + void* cookie; data_history history[2]; - ps2_dev * parent_dev; + ps2_dev* parent_dev; size_t packet_size; // functions - void (*disconnect)(ps2_dev *); - int32 (*handle_int)(ps2_dev *); - status_t (*command)(ps2_dev *dev, uint8 cmd, const uint8 *out, - int out_count, uint8 *in, int in_count, bigtime_t timeout); + void (*disconnect)(ps2_dev *); + int32 (*handle_int)(ps2_dev *); + status_t (*command)(ps2_dev *dev, uint8 cmd, const uint8 *out, + int out_count, uint8 *in, int in_count, bigtime_t timeout); }; #define PS2_DEVICE_COUNT 6 @@ -82,7 +81,6 @@ status_t ps2_dev_command_timeout(ps2_dev *dev, uint8 cmd, const uint8 *out, int out_count, uint8 *in, int in_count, bigtime_t timeout); status_t ps2_dev_sliced_command(ps2_dev *dev, uint8 cmd); - status_t ps2_reset_mouse(ps2_dev *dev); void ps2_dev_publish(ps2_dev *dev); diff --git a/src/add-ons/kernel/bus_managers/ps2/ps2_standard_mouse.cpp b/src/add-ons/kernel/bus_managers/ps2/ps2_standard_mouse.cpp index e9082af..65c1c78 100644 --- a/src/add-ons/kernel/bus_managers/ps2/ps2_standard_mouse.cpp +++ b/src/add-ons/kernel/bus_managers/ps2/ps2_standard_mouse.cpp @@ -1,13 +1,14 @@ /* - * Copyright 2001-2010 Haiku, Inc. + * Copyright 2001-2014 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors (in chronological order): - * Elad Lahav (elad@xxxxxxxxxxxxxx) - * Stefano Ceccherini (burton666@xxxxxxxxx) + * Elad Lahav, elad@xxxxxxxxxxxxxx + * Stefano Ceccherini, burton666@xxxxxxxxx * Axel Dörfler, axeld@xxxxxxxxxxxxxxxx - * Marcus Overhagen <marcus@xxxxxxxxxxxx> - * Clemens Zeidler <czeidler@xxxxxx> + * Marcus Overhagen, marcus@xxxxxxxxxxxx + * Clemens Zeidler, czeidler@xxxxxx + * John Scipione, jscipione@xxxxxxxxx */ @@ -69,6 +70,7 @@ const char* kStandardMousePath[4] = { "input/mouse/ps2/standard_2", "input/mouse/ps2/standard_3" }; + const char* kIntelliMousePath[4] = { "input/mouse/ps2/intelli_0", "input/mouse/ps2/intelli_1", @@ -77,20 +79,18 @@ const char* kIntelliMousePath[4] = { }; -/*! Set sampling rate of the ps2 port. -*/ +//! Set sampling rate of the ps2 port. static inline status_t -ps2_set_sample_rate(ps2_dev *dev, uint8 rate) +ps2_set_sample_rate(ps2_dev* dev, uint8 rate) { return ps2_dev_command(dev, PS2_CMD_SET_SAMPLE_RATE, &rate, 1, NULL, 0); } -/*! Converts a packet received by the mouse to a "movement". -*/ +//! Converts a packet received by the mouse to a "movement". static void -ps2_packet_to_movement(standard_mouse_cookie *cookie, uint8 packet[], - mouse_movement *pos) +ps2_packet_to_movement(standard_mouse_cookie* cookie, uint8 packet[], + mouse_movement* pos) { int buttons = packet[0] & 7; int xDelta = ((packet[0] & 0x10) ? ~0xff : 0) | packet[1]; @@ -115,7 +115,7 @@ ps2_packet_to_movement(standard_mouse_cookie *cookie, uint8 packet[], if (packet[3] & 0x08) yDeltaWheel |= ~0x07; } -/* +#if 0 if (cookie->flags & F_MOUSE_TYPE_2WHEELS) { switch (packet[3] & 0x0F) { case 0x01: yDeltaWheel = +1; break; // wheel 1 down @@ -124,14 +124,16 @@ ps2_packet_to_movement(standard_mouse_cookie *cookie, uint8 packet[], case 0x0E: xDeltaWheel = -1; break; // wheel 2 up } } -*/ +#endif -// TRACE("packet: %02x %02x %02x %02x: xd %d, yd %d, 0x%x (%d), w-xd %d, " -// "w-yd %d\n", packet[0], packet[1], packet[2], packet[3], -// xDelta, yDelta, buttons, cookie->click_count, xDeltaWheel, -// yDeltaWheel); +#if 0 + TRACE("packet: %02x %02x %02x %02x: xd %d, yd %d, 0x%x (%d), w-xd %d, " + "w-yd %d\n", packet[0], packet[1], packet[2], packet[3], + xDelta, yDelta, buttons, cookie->click_count, xDeltaWheel, + yDeltaWheel); +#endif - if (pos) { + if (pos != NULL) { pos->xdelta = xDelta; pos->ydelta = yDelta; pos->buttons = buttons; @@ -148,11 +150,10 @@ ps2_packet_to_movement(standard_mouse_cookie *cookie, uint8 packet[], } -/*! Read a mouse event from the mouse events chain buffer. -*/ +//! Read a mouse event from the mouse events chain buffer. static status_t -standard_mouse_read_event(standard_mouse_cookie *cookie, - mouse_movement *movement) +standard_mouse_read_event(standard_mouse_cookie* cookie, + mouse_movement* movement) { uint8 packet[PS2_MAX_PACKET_SIZE]; status_t status; @@ -184,16 +185,16 @@ standard_mouse_read_event(standard_mouse_cookie *cookie, } -// #pragma mark - +// #pragma mark - Interrupt handler functions void -standard_mouse_disconnect(ps2_dev *dev) +standard_mouse_disconnect(ps2_dev* dev) { // the mouse device might not be opened at this point INFO("ps2: ps2_standard_mouse_disconnect %s\n", dev->name); if (dev->flags & PS2_FLAG_OPEN) - release_sem(((standard_mouse_cookie *)dev->cookie)->standard_mouse_sem); + release_sem(((standard_mouse_cookie*)dev->cookie)->standard_mouse_sem); } @@ -204,27 +205,28 @@ standard_mouse_disconnect(ps2_dev *dev) calls to the handler, each holds a different byte on the data port. */ int32 -standard_mouse_handle_int(ps2_dev *dev) +standard_mouse_handle_int(ps2_dev* dev) { - standard_mouse_cookie *cookie = (standard_mouse_cookie*)dev->cookie; + standard_mouse_cookie* cookie = (standard_mouse_cookie*)dev->cookie; const uint8 data = dev->history[0].data; TRACE("ps2: standard mouse: %1x\t%1x\t%1x\t%1x\t%1x\t%1x\t%1x\t%1x\n", - data >> 7 & 1, data >> 6 & 1, data >> 5 & 1, - data >> 4 & 1, data >> 3 & 1, data >> 2 & 1, - data >> 1 & 1, data >> 0 & 1); + data >> 7 & 1, data >> 6 & 1, data >> 5 & 1, + data >> 4 & 1, data >> 3 & 1, data >> 2 & 1, + data >> 1 & 1, data >> 0 & 1); - if (cookie->packet_index == 0 && !(data & 8)) { + if (cookie->packet_index == 0 && (data & 8) == 0) { INFO("ps2: bad mouse data, trying resync\n"); return B_HANDLED_INTERRUPT; } // Workarounds for active multiplexing keyboard controllers // that lose data or send them to the wrong port. - if (cookie->packet_index == 0 && (data & 0xc0)) { + if (cookie->packet_index == 0 && (data & 0xc0) != 0) { INFO("ps2: strange mouse data, x/y overflow, trying resync\n"); return B_HANDLED_INTERRUPT; } + if (cookie->packet_index == 1) { int xDelta = ((cookie->buffer[0] & 0x10) ? 0xFFFFFF00 : 0) | data; @@ -263,15 +265,16 @@ standard_mouse_handle_int(ps2_dev *dev) } release_sem_etc(cookie->standard_mouse_sem, 1, B_DO_NOT_RESCHEDULE); + return B_INVOKE_SCHEDULER; } -// #pragma mark - +// #pragma mark - probe_standard_mouse() status_t -probe_standard_mouse(ps2_dev * dev) +probe_standard_mouse(ps2_dev* dev) { status_t status; uint8 deviceId = 0; @@ -323,11 +326,11 @@ probe_standard_mouse(ps2_dev * dev) status_t -standard_mouse_open(const char *name, uint32 flags, void **_cookie) +standard_mouse_open(const char* name, uint32 flags, void** _cookie) { - standard_mouse_cookie *cookie; + standard_mouse_cookie* cookie; status_t status; - ps2_dev *dev = NULL; + ps2_dev* dev = NULL; int i; TRACE("ps2: standard_mouse_open %s\n", name); @@ -337,11 +340,13 @@ standard_mouse_open(const char *name, uint32 flags, void **_cookie) dev = &ps2_device[i]; break; } - /*if (0 == strcmp(g_passthrough_dev.name, name)) { +#if 0 + if (0 == strcmp(g_passthrough_dev.name, name)) { dev = &g_passthrough_dev; isSynapticsPTDevice = true; break; - }*/ + } +#endif } if (dev == NULL) { @@ -412,9 +417,9 @@ err1: status_t -standard_mouse_close(void *_cookie) +standard_mouse_close(void* _cookie) { - standard_mouse_cookie *cookie = (standard_mouse_cookie*)_cookie; + standard_mouse_cookie* cookie = (standard_mouse_cookie*)_cookie; TRACE("ps2: standard_mouse_close %s enter\n", cookie->dev->name); @@ -433,16 +438,16 @@ standard_mouse_close(void *_cookie) status_t -standard_mouse_freecookie(void *_cookie) +standard_mouse_freecookie(void* _cookie) { - standard_mouse_cookie *cookie = (standard_mouse_cookie*)_cookie; + standard_mouse_cookie* cookie = (standard_mouse_cookie*)_cookie; free(cookie); return B_OK; } static status_t -standard_mouse_read(void *cookie, off_t pos, void *buffer, size_t *_length) +standard_mouse_read(void* cookie, off_t pos, void* buffer, size_t* _length) { *_length = 0; return B_NOT_ALLOWED; @@ -450,8 +455,8 @@ standard_mouse_read(void *cookie, off_t pos, void *buffer, size_t *_length) static status_t -standard_mouse_write(void *cookie, off_t pos, const void *buffer, - size_t *_length) +standard_mouse_write(void* cookie, off_t pos, const void* buffer, + size_t* _length) { *_length = 0; return B_NOT_ALLOWED; @@ -459,9 +464,9 @@ standard_mouse_write(void *cookie, off_t pos, const void *buffer, status_t -standard_mouse_ioctl(void *_cookie, uint32 op, void *buffer, size_t length) +standard_mouse_ioctl(void* _cookie, uint32 op, void* buffer, size_t length) { - standard_mouse_cookie *cookie = (standard_mouse_cookie*)_cookie; + standard_mouse_cookie* cookie = (standard_mouse_cookie*)_cookie; switch (op) { case MS_NUM_EVENTS: diff --git a/src/add-ons/kernel/bus_managers/ps2/ps2_standard_mouse.h b/src/add-ons/kernel/bus_managers/ps2/ps2_standard_mouse.h index 0de867c..53e08ce 100644 --- a/src/add-ons/kernel/bus_managers/ps2/ps2_standard_mouse.h +++ b/src/add-ons/kernel/bus_managers/ps2/ps2_standard_mouse.h @@ -1,15 +1,14 @@ /* - * Copyright 2001-2010 Haiku, Inc. + * Copyright 2001-2014 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * - * PS/2 mouse device driver - * * Authors (in chronological order): - * Elad Lahav (elad@xxxxxxxxxxxxxx) - * Stefano Ceccherini (burton666@xxxxxxxxx) + * Elad Lahav, elad@xxxxxxxxxxxxxx + * Stefano Ceccherini, burton666@xxxxxxxxx * Axel Dörfler, axeld@xxxxxxxxxxxxxxxx - * Marcus Overhagen <marcus@xxxxxxxxxxxx> - * Clemens Zeidler <czeidler@xxxxxx> + * Marcus Overhagen, marcus@xxxxxxxxxxxx + * Clemens Zeidler, czeidler@xxxxxx + * John Scipione, jscipione@xxxxxxxxx */ #ifndef __PS2_STANDARD_MOUSE_H #define __PS2_STANDARD_MOUSE_H @@ -27,17 +26,17 @@ #define F_MOUSE_TYPE_INTELLIMOUSE 0x2 typedef struct { - ps2_dev* dev; - - sem_id standard_mouse_sem; -struct packet_buffer* standard_mouse_buffer; - bigtime_t click_last_time; - bigtime_t click_speed; - int click_count; - int buttons_state; - int flags; - size_t packet_index; - uint8 buffer[PS2_MAX_PACKET_SIZE]; + ps2_dev* dev; + + sem_id standard_mouse_sem; + struct packet_buffer* standard_mouse_buffer; + bigtime_t click_last_time; + bigtime_t click_speed; + int click_count; + int buttons_state; + int flags; + size_t packet_index; + uint8 buffer[PS2_MAX_PACKET_SIZE]; } standard_mouse_cookie;