adb_kbd.c (184299) | adb_kbd.c (185724) |
---|---|
1/*- 2 * Copyright (C) 2008 Nathan Whitehorn 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 8 unchanged lines hidden (view full) --- 17 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 18 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 22 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 23 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * | 1/*- 2 * Copyright (C) 2008 Nathan Whitehorn 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 8 unchanged lines hidden (view full) --- 17 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 18 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 22 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 23 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * |
25 * $FreeBSD: head/sys/dev/adb/adb_kbd.c 184299 2008-10-26 19:37:38Z nwhitehorn $ | 25 * $FreeBSD: head/sys/dev/adb/adb_kbd.c 185724 2008-12-06 23:26:02Z nwhitehorn $ |
26 */ 27 28#include <sys/cdefs.h> 29#include <sys/param.h> 30#include <sys/systm.h> 31#include <sys/module.h> 32#include <sys/bus.h> 33#include <sys/conf.h> --- 232 unchanged lines hidden (view full) --- 266 267#ifdef KBD_INSTALL_CDEV 268 if (kbd_attach(&sc->sc_kbd)) { 269 adb_kbd_detach(dev); 270 return ENXIO; 271 } 272#endif 273 | 26 */ 27 28#include <sys/cdefs.h> 29#include <sys/param.h> 30#include <sys/systm.h> 31#include <sys/module.h> 32#include <sys/bus.h> 33#include <sys/conf.h> --- 232 unchanged lines hidden (view full) --- 266 267#ifdef KBD_INSTALL_CDEV 268 if (kbd_attach(&sc->sc_kbd)) { 269 adb_kbd_detach(dev); 270 return ENXIO; 271 } 272#endif 273 |
274 adb_set_autopoll(dev,1); 275 276 /* Check (asynchronously) if we can read out the LED state from | 274 /* Check if we can read out the LED state from |
277 this keyboard by reading the key state register */ | 275 this keyboard by reading the key state register */ |
278 adb_send_packet(dev,ADB_COMMAND_TALK,2,0,NULL); | 276 if (adb_read_register(dev, 2, NULL) == 2) 277 sc->have_led_control = 1; |
279 | 278 |
279 adb_set_autopoll(dev,1); 280 |
|
280 return (0); 281} 282 283static int 284adb_kbd_detach(device_t dev) 285{ 286 struct adb_kbd_softc *sc; 287 keyboard_t *kbd; --- 30 unchanged lines hidden (view full) --- 318{ 319 struct adb_kbd_softc *sc; 320 321 sc = device_get_softc(dev); 322 323 if (command != ADB_COMMAND_TALK) 324 return 0; 325 | 281 return (0); 282} 283 284static int 285adb_kbd_detach(device_t dev) 286{ 287 struct adb_kbd_softc *sc; 288 keyboard_t *kbd; --- 30 unchanged lines hidden (view full) --- 319{ 320 struct adb_kbd_softc *sc; 321 322 sc = device_get_softc(dev); 323 324 if (command != ADB_COMMAND_TALK) 325 return 0; 326 |
326 if (reg == 2 && len == 2) { 327 sc->have_led_control = 1; 328 return 0; 329 } 330 | |
331 if (reg != 0 || len != 2) 332 return (0); 333 334 mtx_lock(&sc->sc_mutex); 335 if ((data[0] & 0x7f) == 57 && sc->buffers < 7) { 336 /* Fake the down/up cycle for caps lock */ 337 sc->buffer[sc->buffers++] = data[0] & 0x7f; 338 sc->buffer[sc->buffers++] = (data[0] & 0x7f) | (1 << 7); --- 354 unchanged lines hidden --- | 327 if (reg != 0 || len != 2) 328 return (0); 329 330 mtx_lock(&sc->sc_mutex); 331 if ((data[0] & 0x7f) == 57 && sc->buffers < 7) { 332 /* Fake the down/up cycle for caps lock */ 333 sc->buffer[sc->buffers++] = data[0] & 0x7f; 334 sc->buffer[sc->buffers++] = (data[0] & 0x7f) | (1 << 7); --- 354 unchanged lines hidden --- |