From nobody Sat Dec 24 08:37:07 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NfHTw3G6dz1HSq4; Sat, 24 Dec 2022 08:37:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NfHTw0hRdz3PY2; Sat, 24 Dec 2022 08:37:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1671871028; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0g9TH+2ZrwzGzD2+O9ce6Cl1yMSKNM4D5tPgnKUAPDw=; b=EmJcp2PBuAKUz+4ap7kS6TLml4Imljly5dTqzbs0JMHI/vtNIAXtmE0OkivdwtXhOZwV8o j8V+cFrnkcDRvCzEIDYpEZIlFFKdTLD8rRJS/18IC6X/hCjvice+jHVCv3z7flAxYGT8Mh C0aXiZrNHBkEklC2ubMXoGX+nZCAWS0xO8OPd1FvD/gTrYVYEo15JYr63VRaXBLELcCXXr nAgnSo8dZ/08z4MscdcsSt1laBehTrOxCDK4k9JVZuHwRUMO0Cmw1ruSqf/zlnJSZXSwp4 +oXy6kFsIgfa6mnSq7kNIhP8JTGKiRzrCbOtf04rM47RdnuKc4WlfLwH7XHxEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1671871028; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0g9TH+2ZrwzGzD2+O9ce6Cl1yMSKNM4D5tPgnKUAPDw=; b=Tcj6yJHq6S7DcFze/XtspBsGfrg7a6ewX3fOozFyZuGoG+I5GdrIgmk8F4KHx1TJWbLblj ro0hXnEgf00b/5O/Y5c8IcnV/ZIQVXoI4lM2l86A0LGH4Ez6rgf3iVOENcZEykGZNe7b4a FgaEpYxmsRrQN71505buAgyd0M9DLgkRu4AoRtXMjqE+tff3hs2d21Rh0orVOzO4fyhyVh cduJzm14TPA0C8C1T5BbiLraocQfRMmUoD8UuUC33BoVSX1MnWR/r/Oe5eZqZtsyRV5PM9 bXgCXijqPVh6obkHQnk0NvyWVznGRUDYpzNd35cAPQZZCP4ftpWw3IPijBDA1g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1671871028; a=rsa-sha256; cv=none; b=gpKCIruUcudAkXKHnb3rOualxEOPsPf2n5m24Hewp+iPRJ+evr/qWRE0nI3/3zYBTTDu6p 6woe5JLdTtYTY11A7hS9EhyoFOcNIpfx9brlzng2BZ5YA82EMIQKnD1hn38EnhN9ugj7iQ OTyGB/LJ6z/i5F7l3F5cNxNr2pyvQZYqjoyzWwAo+43RGHQBrh3I8wBGOA5LzFcu8GBLZs DiCP4IaEZ2ESINO/v0OChPTLwp2C623GUlETqbeekRXgx4E4gBVYCFtibJYYzdPhTXijl0 KyalO7gc48RM+UqoQmYp94BAR5l0sFMdJVZk5PjvAdbiGbaFSc23YwXQ5prGYA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NfHTv6hcPz15pf; Sat, 24 Dec 2022 08:37:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2BO8b7s9083609; Sat, 24 Dec 2022 08:37:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2BO8b7JA083608; Sat, 24 Dec 2022 08:37:07 GMT (envelope-from git) Date: Sat, 24 Dec 2022 08:37:07 GMT Message-Id: <202212240837.2BO8b7JA083608@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 9aca77c20c93 - stable/13 - evdev: Extend EVIOCGRAB ioctl scope to cover sysmouse interface List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9aca77c20c938494101b463e1323ac6980c80335 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=9aca77c20c938494101b463e1323ac6980c80335 commit 9aca77c20c938494101b463e1323ac6980c80335 Author: Vladimir Kondratyev AuthorDate: 2022-11-17 21:48:42 +0000 Commit: Vladimir Kondratyev CommitDate: 2022-12-24 08:33:27 +0000 evdev: Extend EVIOCGRAB ioctl scope to cover sysmouse interface of psm(4), ums(4) and sysmouse(4) drivers. EVIOCGRAB ioctl execution on /dev/input/event# device node gains exclusive access to this device to caller. It is used mostly for development purposes and remote control software. See e.g. https://reviews.freebsd.org/D30020 which is the reason of creation of this change. (cherry picked from commit 4a0db5e2920c0e0df52d6888bdd732df95706dfc) --- sys/dev/atkbdc/psm.c | 12 ++++++++---- sys/dev/evdev/evdev.c | 11 +++++++++++ sys/dev/evdev/evdev.h | 1 + sys/dev/syscons/sysmouse.c | 2 ++ sys/dev/usb/input/ums.c | 4 ++++ sys/dev/vt/vt_sysmouse.c | 2 ++ 6 files changed, 28 insertions(+), 4 deletions(-) diff --git a/sys/dev/atkbdc/psm.c b/sys/dev/atkbdc/psm.c index 9b47a7a6b0c5..438315ec9629 100644 --- a/sys/dev/atkbdc/psm.c +++ b/sys/dev/atkbdc/psm.c @@ -5133,6 +5133,10 @@ psmsoftintr(void *arg) break; } + /* Store last packet for reinjection if it has not been set already */ + if (timevalisset(&sc->idletimeout) && sc->idlepacket.inputbytes == 0) + sc->idlepacket = *pb; + #ifdef EVDEV_SUPPORT if (evdev_rcpt_mask & EVDEV_RCPT_HW_MOUSE && sc->hw.model != MOUSE_MODEL_ELANTECH && @@ -5166,6 +5170,10 @@ psmsoftintr(void *arg) evdev_push_mouse_btn(sc->evdev_r, ms.button); evdev_sync(sc->evdev_r); } + + if ((sc->evdev_a != NULL && evdev_is_grabbed(sc->evdev_a)) || + (sc->evdev_r != NULL && evdev_is_grabbed(sc->evdev_r))) + goto next; #endif /* scale values */ @@ -5186,10 +5194,6 @@ psmsoftintr(void *arg) } } - /* Store last packet for reinjection if it has not been set already */ - if (timevalisset(&sc->idletimeout) && sc->idlepacket.inputbytes == 0) - sc->idlepacket = *pb; - ms.dx = x; ms.dy = y; ms.dz = z; diff --git a/sys/dev/evdev/evdev.c b/sys/dev/evdev/evdev.c index 2fd7c2e201ea..a0a039f0b691 100644 --- a/sys/dev/evdev/evdev.c +++ b/sys/dev/evdev/evdev.c @@ -1094,6 +1094,17 @@ evdev_release_client(struct evdev_dev *evdev, struct evdev_client *client) return (0); } +bool +evdev_is_grabbed(struct evdev_dev *evdev) +{ + /* + * The function is intended to be called from evdev-unrelated parts of + * code like syscons-compatible parts of mouse and keyboard drivers. + * That makes unlocked read-only access acceptable. + */ + return (evdev->ev_grabber != NULL); +} + static void evdev_repeat_callout(void *arg) { diff --git a/sys/dev/evdev/evdev.h b/sys/dev/evdev/evdev.h index 71cadc0dcef3..103e76f16858 100644 --- a/sys/dev/evdev/evdev.h +++ b/sys/dev/evdev/evdev.h @@ -154,6 +154,7 @@ void evdev_set_repeat_params(struct evdev_dev *, uint16_t, int); int evdev_set_report_size(struct evdev_dev *, size_t); void evdev_set_flag(struct evdev_dev *, uint16_t); void *evdev_get_softc(struct evdev_dev *); +bool evdev_is_grabbed(struct evdev_dev *); /* Multitouch related functions: */ int evdev_get_mt_slot_by_tracking_id(struct evdev_dev *, int32_t); diff --git a/sys/dev/syscons/sysmouse.c b/sys/dev/syscons/sysmouse.c index ef851058a6ef..73167bdb34f8 100644 --- a/sys/dev/syscons/sysmouse.c +++ b/sys/dev/syscons/sysmouse.c @@ -295,6 +295,8 @@ sysmouse_event(mouse_info_t *info) #ifdef EVDEV_SUPPORT smdev_evdev_write(x, y, z, mouse_status.button); + if (evdev_is_grabbed(sysmouse_evdev)) + goto done; #endif if (!tty_opened(sysmouse_tty)) diff --git a/sys/dev/usb/input/ums.c b/sys/dev/usb/input/ums.c index cce1831287e4..ced905609437 100644 --- a/sys/dev/usb/input/ums.c +++ b/sys/dev/usb/input/ums.c @@ -875,6 +875,10 @@ ums_put_queue(struct ums_softc *sc, int32_t dx, int32_t dy, { uint8_t buf[8]; +#ifdef EVDEV_SUPPORT + if (evdev_is_grabbed(sc->sc_evdev)) + return; +#endif if (1) { if (dx > 254) dx = 254; diff --git a/sys/dev/vt/vt_sysmouse.c b/sys/dev/vt/vt_sysmouse.c index e10ac829abf3..c6426f3a8f17 100644 --- a/sys/dev/vt/vt_sysmouse.c +++ b/sys/dev/vt/vt_sysmouse.c @@ -249,6 +249,8 @@ sysmouse_process_event(mouse_info_t *mi) #ifdef EVDEV_SUPPORT sysmouse_evdev_store(x, y, z, sysmouse_status.button); + if (evdev_is_grabbed(sysmouse_evdev)) + goto done; #endif /* The first five bytes are compatible with MouseSystems. */