|
95 | 95 |
|
96 | 96 | #ifdef HID_DEBUG
|
97 | 97 | static int hkbd_debug = 0;
|
| 98 | +#endif |
98 | 99 | static int hkbd_no_leds = 0;
|
99 | 100 |
|
100 | 101 | static SYSCTL_NODE(_hw_hid, OID_AUTO, hkbd, CTLFLAG_RW, 0, "USB keyboard");
|
| 102 | +#ifdef HID_DEBUG |
101 | 103 | SYSCTL_INT(_hw_hid_hkbd, OID_AUTO, debug, CTLFLAG_RWTUN,
|
102 | 104 | &hkbd_debug, 0, "Debug level");
|
| 105 | +#endif |
103 | 106 | SYSCTL_INT(_hw_hid_hkbd, OID_AUTO, no_leds, CTLFLAG_RWTUN,
|
104 | 107 | &hkbd_no_leds, 0, "Disables setting of keyboard leds");
|
105 |
| -#endif |
106 | 108 |
|
107 | 109 | #define INPUT_EPOCH global_epoch_preempt
|
108 | 110 |
|
@@ -1596,8 +1598,16 @@ hkbd_ioctl_locked(keyboard_t *kbd, u_long cmd, caddr_t arg)
|
1596 | 1598 | sc->sc_state &= ~LOCK_MASK;
|
1597 | 1599 | sc->sc_state |= *(int *)arg;
|
1598 | 1600 |
|
1599 |
| - /* set LEDs and quit */ |
1600 |
| - return (hkbd_ioctl_locked(kbd, KDSETLED, arg)); |
| 1601 | + /* |
| 1602 | + * Attempt to set the keyboard LEDs; ignore the return value |
| 1603 | + * intentionally. Note: Some hypervisors/emulators (e.g., QEMU, |
| 1604 | + * Parallels—at least as of the time of writing) may fail when |
| 1605 | + * setting LEDs. This can prevent kbdmux from attaching the |
| 1606 | + * keyboard, which in turn may block the console from accessing |
| 1607 | + * it. |
| 1608 | + */ |
| 1609 | + (void)hkbd_ioctl_locked(kbd, KDSETLED, arg); |
| 1610 | + return (0); |
1601 | 1611 |
|
1602 | 1612 | case KDSETREPEAT: /* set keyboard repeat rate (new
|
1603 | 1613 | * interface) */
|
@@ -1766,10 +1776,8 @@ hkbd_set_leds(struct hkbd_softc *sc, uint8_t leds)
|
1766 | 1776 | SYSCONS_LOCK_ASSERT();
|
1767 | 1777 | DPRINTF("leds=0x%02x\n", leds);
|
1768 | 1778 |
|
1769 |
| -#ifdef HID_DEBUG |
1770 | 1779 | if (hkbd_no_leds)
|
1771 | 1780 | return (0);
|
1772 |
| -#endif |
1773 | 1781 |
|
1774 | 1782 | memset(sc->sc_buffer, 0, HKBD_BUFFER_SIZE);
|
1775 | 1783 |
|
@@ -1820,6 +1828,7 @@ hkbd_set_leds(struct hkbd_softc *sc, uint8_t leds)
|
1820 | 1828 | SYSCONS_UNLOCK();
|
1821 | 1829 | error = hid_write(sc->sc_dev, buf, len);
|
1822 | 1830 | SYSCONS_LOCK();
|
| 1831 | + DPRINTF(("error %d", error)); |
1823 | 1832 |
|
1824 | 1833 | return (error);
|
1825 | 1834 | }
|
|
0 commit comments