Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Jun 2014 20:09:39 +0000 (UTC)
From:      Jakub Wojciech Klama <jceel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r267024 - user/jceel/soc2014_evdev/head/sys/dev/evdev
Message-ID:  <201406032009.s53K9dHS057892@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jceel
Date: Tue Jun  3 20:09:39 2014
New Revision: 267024
URL: http://svnweb.freebsd.org/changeset/base/267024

Log:
  Add support for EVIOCGABS and EVIOCSABS ioctls.

Modified:
  user/jceel/soc2014_evdev/head/sys/dev/evdev/cdev.c
  user/jceel/soc2014_evdev/head/sys/dev/evdev/evdev.c
  user/jceel/soc2014_evdev/head/sys/dev/evdev/evdev.h

Modified: user/jceel/soc2014_evdev/head/sys/dev/evdev/cdev.c
==============================================================================
--- user/jceel/soc2014_evdev/head/sys/dev/evdev/cdev.c	Tue Jun  3 19:45:08 2014	(r267023)
+++ user/jceel/soc2014_evdev/head/sys/dev/evdev/cdev.c	Tue Jun  3 20:09:39 2014	(r267024)
@@ -73,6 +73,7 @@ static struct cdevsw evdev_cdevsw = {
 	.d_poll = evdev_poll,
 	.d_kqfilter = evdev_kqfilter,
 	.d_name = "evdev",
+	.d_flags = D_TRACKCLOSE
 };
 
 static struct filterops evdev_cdev_filterops = {
@@ -293,6 +294,7 @@ evdev_ioctl(struct cdev *dev, u_long cmd
 {
 	struct evdev_cdev_softc *sc = dev->si_drv1;
 	struct evdev_dev *evdev = sc->ecs_evdev;
+	//struct input_id id;
 	int len, num, limit;
 
 	len = IOCPARM_LEN(cmd);
@@ -341,7 +343,8 @@ evdev_ioctl(struct cdev *dev, u_long cmd
 		break;
 
 	case EVIOCGPROP(0):
-		memcpy(data, evdev->ev_type_flags, len);
+		limit = MIN(len, howmany(EV_CNT, 8));
+		memcpy(data, evdev->ev_type_flags, limit);
 		break;
 
 	case EVIOCGKEY(0):
@@ -378,6 +381,18 @@ evdev_ioctl(struct cdev *dev, u_long cmd
 		return (evdev_ioctl_eviocgbit(evdev, type_num, len, data));
 	}
 
+	/* Handle EVIOCGABS variants */
+	if (num >= IOCNUM(EVIOCGABS(0)) && num < IOCNUM(EVIOCGABS(ABS_CNT))) {
+		int index = num - IOCNUM(EVIOCGABS(0));
+		memcpy(data, &evdev->ev_absinfo[index], len);
+	}
+
+	/* Handle EVIOCSABS variants */
+	if (num >= IOCNUM(EVIOCSABS(0)) && num < IOCNUM(EVIOCSABS(ABS_CNT))) {
+		int index = num - IOCNUM(EVIOCSABS(0));
+		memcpy(&evdev->ev_absinfo[index], data, len);
+	}
+
 	return (0);
 }
 

Modified: user/jceel/soc2014_evdev/head/sys/dev/evdev/evdev.c
==============================================================================
--- user/jceel/soc2014_evdev/head/sys/dev/evdev/evdev.c	Tue Jun  3 19:45:08 2014	(r267023)
+++ user/jceel/soc2014_evdev/head/sys/dev/evdev/evdev.c	Tue Jun  3 20:09:39 2014	(r267024)
@@ -182,6 +182,14 @@ evdev_support_sw(struct evdev_dev *evdev
 	setbit(&evdev->ev_sw_flags, code);
 }
 
+inline void
+evdev_set_absinfo(struct evdev_dev *evdev, uint16_t axis,
+    struct input_absinfo *absinfo)
+{
+
+	memcpy(&evdev->ev_absinfo[axis], absinfo, sizeof(struct input_absinfo));
+}
+
 int
 evdev_push_event(struct evdev_dev *evdev, uint16_t type, uint16_t code,
     int32_t value)
@@ -204,6 +212,10 @@ evdev_push_event(struct evdev_dev *evdev
 	if (type == EV_SW)
 		changebit(evdev->ev_sw_states, code, value);
 
+	/* For EV_ABS, save last value in absinfo */
+	if (type == EV_ABS)
+		evdev->ev_absinfo[code].value = value;
+
 	/* Propagate event through all clients */
 	LIST_FOREACH(client, &evdev->ev_clients, ec_link) {
 		evdev_client_push(client, type, code, value);

Modified: user/jceel/soc2014_evdev/head/sys/dev/evdev/evdev.h
==============================================================================
--- user/jceel/soc2014_evdev/head/sys/dev/evdev/evdev.h	Tue Jun  3 19:45:08 2014	(r267023)
+++ user/jceel/soc2014_evdev/head/sys/dev/evdev/evdev.h	Tue Jun  3 20:09:39 2014	(r267024)
@@ -70,7 +70,7 @@ struct evdev_dev
 	uint32_t		ev_led_flags[howmany(LED_CNT, 32)];
 	uint32_t		ev_snd_flags[howmany(SND_CNT, 32)];
 	uint32_t		ev_sw_flags[howmany(SW_CNT, 32)];
-	struct input_absinfo *	ev_abs_info;
+	struct input_absinfo	ev_absinfo[ABS_CNT];
 
 	/* State: */
 	uint32_t		ev_key_states[howmany(KEY_CNT, 32)];
@@ -131,6 +131,7 @@ void evdev_support_msc(struct evdev_dev 
 void evdev_support_led(struct evdev_dev *, uint16_t);
 void evdev_support_snd(struct evdev_dev *, uint16_t);
 void evdev_support_sw(struct evdev_dev *, uint16_t);
+void evdev_set_absinfo(struct evdev_dev *, uint16_t, struct input_absinfo *);
 
 /* Client interface: */
 int evdev_register_client(struct evdev_dev *, struct evdev_client **);



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