| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: wsmouse.c,v 1.72 2022/07/17 11:44:30 riastradh Exp $ */ | | 1 | /* $NetBSD: wsmouse.c,v 1.73 2023/07/30 10:45:11 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Julio M. Merino Vidal. | | 8 | * by Julio M. Merino Vidal. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -94,27 +94,27 @@ | | | @@ -94,27 +94,27 @@ |
94 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 94 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
95 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 95 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
96 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 96 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
97 | * SUCH DAMAGE. | | 97 | * SUCH DAMAGE. |
98 | * | | 98 | * |
99 | * @(#)ms.c 8.1 (Berkeley) 6/11/93 | | 99 | * @(#)ms.c 8.1 (Berkeley) 6/11/93 |
100 | */ | | 100 | */ |
101 | | | 101 | |
102 | /* | | 102 | /* |
103 | * Mouse driver. | | 103 | * Mouse driver. |
104 | */ | | 104 | */ |
105 | | | 105 | |
106 | #include <sys/cdefs.h> | | 106 | #include <sys/cdefs.h> |
107 | __KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.72 2022/07/17 11:44:30 riastradh Exp $"); | | 107 | __KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.73 2023/07/30 10:45:11 riastradh Exp $"); |
108 | | | 108 | |
109 | #include "wsmouse.h" | | 109 | #include "wsmouse.h" |
110 | #include "wsdisplay.h" | | 110 | #include "wsdisplay.h" |
111 | #include "wsmux.h" | | 111 | #include "wsmux.h" |
112 | | | 112 | |
113 | #include <sys/param.h> | | 113 | #include <sys/param.h> |
114 | #include <sys/conf.h> | | 114 | #include <sys/conf.h> |
115 | #include <sys/ioctl.h> | | 115 | #include <sys/ioctl.h> |
116 | #include <sys/poll.h> | | 116 | #include <sys/poll.h> |
117 | #include <sys/fcntl.h> | | 117 | #include <sys/fcntl.h> |
118 | #include <sys/kernel.h> | | 118 | #include <sys/kernel.h> |
119 | #include <sys/proc.h> | | 119 | #include <sys/proc.h> |
120 | #include <sys/syslog.h> | | 120 | #include <sys/syslog.h> |
| @@ -362,37 +362,39 @@ wsmouse_detach(device_t self, int flags) | | | @@ -362,37 +362,39 @@ wsmouse_detach(device_t self, int flags) |
362 | return (0); | | 362 | return (0); |
363 | } | | 363 | } |
364 | | | 364 | |
365 | void | | 365 | void |
366 | wsmouse_input(device_t wsmousedev, u_int btns /* 0 is up */, | | 366 | wsmouse_input(device_t wsmousedev, u_int btns /* 0 is up */, |
367 | int x, int y, int z, int w, u_int flags) | | 367 | int x, int y, int z, int w, u_int flags) |
368 | { | | 368 | { |
369 | struct wsmouse_softc *sc = device_private(wsmousedev); | | 369 | struct wsmouse_softc *sc = device_private(wsmousedev); |
370 | struct wseventvar *evar; | | 370 | struct wseventvar *evar; |
371 | int mb, ub, d, nevents; | | 371 | int mb, ub, d, nevents; |
372 | /* one for each dimension (4) + a bit for each button */ | | 372 | /* one for each dimension (4) + a bit for each button */ |
373 | struct wscons_event events[4 + sizeof(d) * 8]; | | 373 | struct wscons_event events[4 + sizeof(d) * 8]; |
374 | | | 374 | |
| | | 375 | KERNEL_LOCK(1, NULL); |
| | | 376 | |
375 | /* | | 377 | /* |
376 | * Discard input if not open. | | 378 | * Discard input if not open. |
377 | */ | | 379 | */ |
378 | evar = sc->sc_base.me_evp; | | 380 | evar = sc->sc_base.me_evp; |
379 | if (evar == NULL) | | 381 | if (evar == NULL) |
380 | return; | | 382 | goto out; |
381 | | | 383 | |
382 | #ifdef DIAGNOSTIC | | 384 | #ifdef DIAGNOSTIC |
383 | if (evar->q == NULL) { | | 385 | if (evar->q == NULL) { |
384 | printf("wsmouse_input: evar->q=NULL\n"); | | 386 | printf("wsmouse_input: evar->q=NULL\n"); |
385 | return; | | 387 | goto out; |
386 | } | | 388 | } |
387 | #endif | | 389 | #endif |
388 | | | 390 | |
389 | #if NWSMUX > 0 | | 391 | #if NWSMUX > 0 |
390 | DPRINTFN(5,("wsmouse_input: %s mux=%p, evar=%p\n", | | 392 | DPRINTFN(5,("wsmouse_input: %s mux=%p, evar=%p\n", |
391 | device_xname(sc->sc_base.me_dv), | | 393 | device_xname(sc->sc_base.me_dv), |
392 | sc->sc_base.me_parent, evar)); | | 394 | sc->sc_base.me_parent, evar)); |
393 | #endif | | 395 | #endif |
394 | | | 396 | |
395 | sc->sc_mb = btns; | | 397 | sc->sc_mb = btns; |
396 | if (!(flags & WSMOUSE_INPUT_ABSOLUTE_X)) | | 398 | if (!(flags & WSMOUSE_INPUT_ABSOLUTE_X)) |
397 | sc->sc_dx += x; | | 399 | sc->sc_dx += x; |
398 | if (!(flags & WSMOUSE_INPUT_ABSOLUTE_Y)) | | 400 | if (!(flags & WSMOUSE_INPUT_ABSOLUTE_Y)) |
| @@ -518,26 +520,28 @@ wsmouse_input(device_t wsmousedev, u_int | | | @@ -518,26 +520,28 @@ wsmouse_input(device_t wsmousedev, u_int |
518 | /* All events were correctly injected into the queue. | | 520 | /* All events were correctly injected into the queue. |
519 | * Synchronize the mouse's status with what the user | | 521 | * Synchronize the mouse's status with what the user |
520 | * has received. */ | | 522 | * has received. */ |
521 | sc->sc_x = x; sc->sc_dx = 0; | | 523 | sc->sc_x = x; sc->sc_dx = 0; |
522 | sc->sc_y = y; sc->sc_dy = 0; | | 524 | sc->sc_y = y; sc->sc_dy = 0; |
523 | sc->sc_z = z; sc->sc_dz = 0; | | 525 | sc->sc_z = z; sc->sc_dz = 0; |
524 | sc->sc_w = w; sc->sc_dw = 0; | | 526 | sc->sc_w = w; sc->sc_dw = 0; |
525 | sc->sc_ub = ub; | | 527 | sc->sc_ub = ub; |
526 | #if NWSMUX > 0 | | 528 | #if NWSMUX > 0 |
527 | DPRINTFN(5,("wsmouse_input: %s wakeup evar=%p\n", | | 529 | DPRINTFN(5,("wsmouse_input: %s wakeup evar=%p\n", |
528 | device_xname(sc->sc_base.me_dv), evar)); | | 530 | device_xname(sc->sc_base.me_dv), evar)); |
529 | #endif | | 531 | #endif |
530 | } | | 532 | } |
| | | 533 | |
| | | 534 | out: KERNEL_UNLOCK_ONE(NULL); |
531 | } | | 535 | } |
532 | | | 536 | |
533 | void | | 537 | void |
534 | wsmouse_precision_scroll(device_t wsmousedev, int x, int y) | | 538 | wsmouse_precision_scroll(device_t wsmousedev, int x, int y) |
535 | { | | 539 | { |
536 | struct wsmouse_softc *sc = device_private(wsmousedev); | | 540 | struct wsmouse_softc *sc = device_private(wsmousedev); |
537 | struct wseventvar *evar; | | 541 | struct wseventvar *evar; |
538 | struct wscons_event events[2]; | | 542 | struct wscons_event events[2]; |
539 | int nevents = 0; | | 543 | int nevents = 0; |
540 | | | 544 | |
541 | evar = sc->sc_base.me_evp; | | 545 | evar = sc->sc_base.me_evp; |
542 | if (evar == NULL) | | 546 | if (evar == NULL) |
543 | return; | | 547 | return; |