Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Dec 2017 21:12:05 +0000 (UTC)
From:      Vladimir Kondratyev <wulf@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r326543 - in stable/11/sys/dev: evdev syscons vt
Message-ID:  <201712042112.vB4LC5d2005247@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: wulf
Date: Mon Dec  4 21:12:05 2017
New Revision: 326543
URL: https://svnweb.freebsd.org/changeset/base/326543

Log:
  MFC r325295:
  
  evdev: Lock Giant around keyboard ioctls
  This fixes turning ukbd(4) LEDs on/off with evdev interface as well
  
  MFC r325296:
  
  evdev: Take driver's lock in cdev write handler if necessary
  
  MFC r325297:
  
  sysmouse(4): Fix ums(4)-style T-axis reporting via evdev protocol
  
  - Do not report T-axis wheel events as button presses
  - Reverse T-axis to match Linux
  - Remove wrong comment. T-axis buttons state should be checked by level not
      by edge to allow continuous wheel tilt reporting
  
  MFC r325298:
  
  evdev: Disable value normalization and state filtering for SND events.
  
  Some events can take sound pitch as a value so can not be represented
  as binary on/off events. Tracking for on/off state is left in place
  as it is a part of the evdev API.
  
  MFC r325299:
  
  evdev: Do not start/stop softrepeat callout if no clients attached
  
  Approved by:	gonzo (mentor)

Modified:
  stable/11/sys/dev/evdev/evdev.c
  stable/11/sys/dev/evdev/evdev.h
  stable/11/sys/dev/evdev/evdev_utils.c
  stable/11/sys/dev/syscons/sysmouse.c
  stable/11/sys/dev/vt/vt_sysmouse.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/evdev/evdev.c
==============================================================================
--- stable/11/sys/dev/evdev/evdev.c	Mon Dec  4 20:45:15 2017	(r326542)
+++ stable/11/sys/dev/evdev/evdev.c	Mon Dec  4 21:12:05 2017	(r326543)
@@ -582,7 +582,8 @@ evdev_modify_event(struct evdev_dev *evdev, uint16_t t
 				*value = KEY_EVENT_REPEAT;
 		} else {
 			/* Start/stop callout for evdev repeats */
-			if (bit_test(evdev->ev_key_states, code) == !*value) {
+			if (bit_test(evdev->ev_key_states, code) == !*value &&
+			    !LIST_EMPTY(&evdev->ev_clients)) {
 				if (*value == KEY_EVENT_DOWN)
 					evdev_start_repeat(evdev, code);
 				else
@@ -637,8 +638,6 @@ evdev_sparse_event(struct evdev_dev *evdev, uint16_t t
 		break;
 
 	case EV_SND:
-		if (bit_test(evdev->ev_snd_states, code) == value)
-			return (EV_SKIP_EVENT);
 		bit_change(evdev->ev_snd_states, code, value);
 		break;
 
@@ -816,7 +815,11 @@ evdev_inject_event(struct evdev_dev *evdev, uint16_t t
 	case EV_ABS:
 	case EV_SW:
 push:
+		if (evdev->ev_lock_type != EV_LOCK_INTERNAL)
+			EVDEV_LOCK(evdev);
 		ret = evdev_push_event(evdev, type,  code, value);
+		if (evdev->ev_lock_type != EV_LOCK_INTERNAL)
+			EVDEV_UNLOCK(evdev);
 		break;
 
 	default:

Modified: stable/11/sys/dev/evdev/evdev.h
==============================================================================
--- stable/11/sys/dev/evdev/evdev.h	Mon Dec  4 20:45:15 2017	(r326542)
+++ stable/11/sys/dev/evdev/evdev.h	Mon Dec  4 21:12:05 2017	(r326543)
@@ -197,7 +197,7 @@ static __inline int
 evdev_push_snd(struct evdev_dev *evdev, uint16_t code, int32_t value)
 {
 
-	return (evdev_push_event(evdev, EV_SND, code, value != 0));
+	return (evdev_push_event(evdev, EV_SND, code, value));
 }
 
 static __inline int

Modified: stable/11/sys/dev/evdev/evdev_utils.c
==============================================================================
--- stable/11/sys/dev/evdev/evdev_utils.c	Mon Dec  4 20:45:15 2017	(r326542)
+++ stable/11/sys/dev/evdev/evdev_utils.c	Mon Dec  4 21:12:05 2017	(r326543)
@@ -32,7 +32,9 @@
 #include <sys/conf.h>
 #include <sys/kbio.h>
 #include <sys/kernel.h>
+#include <sys/lock.h>
 #include <sys/malloc.h>
+#include <sys/mutex.h>
 #include <sys/systm.h>
 
 #include <dev/evdev/evdev.h>
@@ -314,19 +316,26 @@ evdev_ev_kbd_event(struct evdev_dev *evdev, void *soft
 					leds |= 1 << i;
 				else
 					leds &= ~(1 << i);
-				if (leds != oleds)
+				if (leds != oleds) {
+					mtx_lock(&Giant);
 					kbdd_ioctl(kbd, KDSETLED,
 					    (caddr_t)&leds);
+					mtx_unlock(&Giant);
+				}
 				break;
 			}
 		}
 	} else if (type == EV_REP && code == REP_DELAY) {
 		delay[0] = value;
 		delay[1] = kbd->kb_delay2;
+		mtx_lock(&Giant);
 		kbdd_ioctl(kbd, KDSETREPEAT, (caddr_t)delay);
+		mtx_unlock(&Giant);
 	} else if (type == EV_REP && code == REP_PERIOD) {
 		delay[0] = kbd->kb_delay1;
 		delay[1] = value;
+		mtx_lock(&Giant);
 		kbdd_ioctl(kbd, KDSETREPEAT, (caddr_t)delay);
+		mtx_unlock(&Giant);
 	}
 }

Modified: stable/11/sys/dev/syscons/sysmouse.c
==============================================================================
--- stable/11/sys/dev/syscons/sysmouse.c	Mon Dec  4 20:45:15 2017	(r326542)
+++ stable/11/sys/dev/syscons/sysmouse.c	Mon Dec  4 21:12:05 2017	(r326543)
@@ -107,11 +107,11 @@ smdev_evdev_write(int x, int y, int z, int buttons)
 		}
 		break;
 	case EVDEV_SYSMOUSE_T_AXIS_UMS:
-		/* XXX: Edge triggering should be used here */
-		if (buttons & (1 << 5))
+		if (buttons & (1 << 6))
 			evdev_push_rel(sysmouse_evdev, REL_HWHEEL, 1);
-		else if (buttons & (1 << 6))
+		else if (buttons & (1 << 5))
 			evdev_push_rel(sysmouse_evdev, REL_HWHEEL, -1);
+		buttons &= ~((1 << 5)|(1 << 6));
 		/* PASSTHROUGH */
 	case EVDEV_SYSMOUSE_T_AXIS_NONE:
 	default:

Modified: stable/11/sys/dev/vt/vt_sysmouse.c
==============================================================================
--- stable/11/sys/dev/vt/vt_sysmouse.c	Mon Dec  4 20:45:15 2017	(r326542)
+++ stable/11/sys/dev/vt/vt_sysmouse.c	Mon Dec  4 21:12:05 2017	(r326543)
@@ -139,11 +139,11 @@ sysmouse_evdev_store(int x, int y, int z, int buttons)
 		}
 		break;
 	case EVDEV_SYSMOUSE_T_AXIS_UMS:
-		/* XXX: Edge triggering should be used here */
-		if (buttons & (1 << 5))
+		if (buttons & (1 << 6))
 			evdev_push_rel(sysmouse_evdev, REL_HWHEEL, 1);
-		else if (buttons & (1 << 6))
+		else if (buttons & (1 << 5))
 			evdev_push_rel(sysmouse_evdev, REL_HWHEEL, -1);
+		buttons &= ~((1 << 5)|(1 << 6));
 		/* PASSTHROUGH */
 	case EVDEV_SYSMOUSE_T_AXIS_NONE:
 	default:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201712042112.vB4LC5d2005247>