|
21 | 21 |
|
22 | 22 | #define PS2_CMD_SETSCALE11 0x00e6
|
23 | 23 | #define PS2_CMD_SETRES 0x10e8
|
| 24 | +#define PS2_CMD_EX_SETLEDS 0x20eb |
| 25 | +#define PS2_CMD_SETLEDS 0x10ed |
24 | 26 | #define PS2_CMD_GETID 0x02f2
|
| 27 | +#define PS2_CMD_SETREP 0x10f3 /* Set repeat rate/set report rate */ |
25 | 28 | #define PS2_CMD_RESET_BAT 0x02ff
|
26 | 29 |
|
27 | 30 | #define PS2_RET_BAT 0xaa
|
|
35 | 38 | #define PS2_FLAG_CMD1 BIT(2) /* Waiting for the first byte of command response */
|
36 | 39 | #define PS2_FLAG_WAITID BIT(3) /* Command executing is GET ID */
|
37 | 40 | #define PS2_FLAG_NAK BIT(4) /* Last transmission was NAKed */
|
| 41 | +#define PS2_FLAG_PASS_NOACK BIT(5) /* Pass non-ACK byte to receive handler */ |
38 | 42 |
|
39 | 43 | static int ps2_do_sendbyte(struct ps2dev *ps2dev, u8 byte,
|
40 | 44 | unsigned int timeout, unsigned int max_attempts)
|
@@ -281,9 +285,28 @@ int __ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command)
|
281 | 285 |
|
282 | 286 | serio_pause_rx(ps2dev->serio);
|
283 | 287 |
|
284 |
| - /* Some mice do not ACK the "get ID" command, prepare to handle this. */ |
285 |
| - ps2dev->flags = command == PS2_CMD_GETID ? PS2_FLAG_WAITID : 0; |
286 | 288 | ps2dev->cmdcnt = receive;
|
| 289 | + |
| 290 | + switch (command) { |
| 291 | + case PS2_CMD_GETID: |
| 292 | + /* |
| 293 | + * Some mice do not ACK the "get ID" command, prepare to |
| 294 | + * handle this. |
| 295 | + */ |
| 296 | + ps2dev->flags = PS2_FLAG_WAITID; |
| 297 | + break; |
| 298 | + |
| 299 | + case PS2_CMD_SETLEDS: |
| 300 | + case PS2_CMD_EX_SETLEDS: |
| 301 | + case PS2_CMD_SETREP: |
| 302 | + ps2dev->flags = PS2_FLAG_PASS_NOACK; |
| 303 | + break; |
| 304 | + |
| 305 | + default: |
| 306 | + ps2dev->flags = 0; |
| 307 | + break; |
| 308 | + } |
| 309 | + |
287 | 310 | if (receive) {
|
288 | 311 | /* Indicate that we expect response to the command. */
|
289 | 312 | ps2dev->flags |= PS2_FLAG_CMD | PS2_FLAG_CMD1;
|
@@ -512,14 +535,19 @@ static void ps2_handle_ack(struct ps2dev *ps2dev, u8 data)
|
512 | 535 | * Do not signal errors if we get unexpected reply while
|
513 | 536 | * waiting for an ACK to the initial (first) command byte:
|
514 | 537 | * the device might not be quiesced yet and continue
|
515 |
| - * delivering data. |
| 538 | + * delivering data. For certain commands (such as set leds and |
| 539 | + * set repeat rate) that can be used during normal device |
| 540 | + * operation, we even pass this data byte to the normal receive |
| 541 | + * handler. |
516 | 542 | * Note that we reset PS2_FLAG_WAITID flag, so the workaround
|
517 | 543 | * for mice not acknowledging the Get ID command only triggers
|
518 | 544 | * on the 1st byte; if device spews data we really want to see
|
519 | 545 | * a real ACK from it.
|
520 | 546 | */
|
521 | 547 | dev_dbg(&ps2dev->serio->dev, "unexpected %#02x\n", data);
|
522 |
| - ps2dev->flags &= ~PS2_FLAG_WAITID; |
| 548 | + if (ps2dev->flags & PS2_FLAG_PASS_NOACK) |
| 549 | + ps2dev->receive_handler(ps2dev, data); |
| 550 | + ps2dev->flags &= ~(PS2_FLAG_WAITID | PS2_FLAG_PASS_NOACK); |
523 | 551 | return;
|
524 | 552 | }
|
525 | 553 |
|
|
0 commit comments