Changeset af7b85b in mainline for uspace/drv/hid/ps2mouse/ps2mouse.c


Ignore:
Timestamp:
2019-01-06T09:34:14Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
063a3647
Parents:
f2d88f3
Message:

ps2mouse needs to deal with pre-enabled reporting

Grub 2 enables ps2 mouse reporting which can get in the way of
ps2 mouse initialization where we expect a certain response.
What we need to do is first disable reporting, then drain the
input buffer, then initialize the mouse.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/hid/ps2mouse/ps2mouse.c

    rf2d88f3 raf7b85b  
    4949#define PS2_MOUSE_SET_SAMPLE_RATE   0xf3
    5050#define PS2_MOUSE_ENABLE_DATA_REPORT   0xf4
     51#define PS2_MOUSE_DISABLE_DATA_REPORT   0xf5
    5152#define PS2_MOUSE_ACK   0xfa
    5253
     
    165166        }
    166167
     168        /* Disable mouse data reporting. */
     169        uint8_t report = PS2_MOUSE_ENABLE_DATA_REPORT;
     170        size_t nwr;
     171        rc = chardev_write(mouse->chardev, &report, 1, &nwr);
     172        if (rc != EOK) {
     173                ddf_msg(LVL_ERROR, "Failed to enable data reporting.");
     174                rc = EIO;
     175                goto error;
     176        }
     177
     178        /* Drain input buffer */
     179        size_t nread;
     180        uint8_t b;
     181        do {
     182                rc = chardev_read(mouse->chardev, &b, 1, &nread, chardev_f_nonblock);
     183                if (rc != EOK) {
     184                        ddf_msg(LVL_ERROR, "Failed to drain input buffer.\n");
     185                        rc = EIO;
     186                        goto error;
     187                }
     188        } while (nread > 0);
     189
    167190        /* Probe IntelliMouse extensions. */
    168191        errno_t (*polling_f)(void *) = polling_ps2;
     
    175198
    176199        /* Enable mouse data reporting. */
    177         uint8_t report = PS2_MOUSE_ENABLE_DATA_REPORT;
    178         size_t nwr;
     200        report = PS2_MOUSE_ENABLE_DATA_REPORT;
    179201        rc = chardev_write(mouse->chardev, &report, 1, &nwr);
    180202        if (rc != EOK) {
     
    184206        }
    185207
    186         size_t nread;
    187208        rc = chardev_read(mouse->chardev, &report, 1, &nread, chardev_f_none);
    188209        if (rc != EOK || report != PS2_MOUSE_ACK) {
Note: See TracChangeset for help on using the changeset viewer.