Date: Mon, 26 May 2014 17:06:27 +0000 (UTC) From: Jakub Wojciech Klama <jceel@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r266705 - user/jceel/soc2014_evdev/head/sys/dev/evdev Message-ID: <201405261706.s4QH6RsY055397@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jceel Date: Mon May 26 17:06:27 2014 New Revision: 266705 URL: http://svnweb.freebsd.org/changeset/base/266705 Log: Add early support for EVIOCGKEY, EVIOCGLED, EVIOCGSND and EVIOCGSW ioctls. Modified: user/jceel/soc2014_evdev/head/sys/dev/evdev/cdev.c user/jceel/soc2014_evdev/head/sys/dev/evdev/evdev.c Modified: user/jceel/soc2014_evdev/head/sys/dev/evdev/cdev.c ============================================================================== --- user/jceel/soc2014_evdev/head/sys/dev/evdev/cdev.c Mon May 26 16:01:45 2014 (r266704) +++ user/jceel/soc2014_evdev/head/sys/dev/evdev/cdev.c Mon May 26 17:06:27 2014 (r266705) @@ -293,7 +293,7 @@ evdev_ioctl(struct cdev *dev, u_long cmd { struct evdev_cdev_softc *sc = dev->si_drv1; struct evdev_dev *evdev = sc->ecs_evdev; - int len, num; + int len, num, limit; len = IOCPARM_LEN(cmd); cmd = IOCBASECMD(cmd); @@ -345,16 +345,25 @@ evdev_ioctl(struct cdev *dev, u_long cmd break; case EVIOCGKEY(0): - memcpy(data, evdev->ev_key_flags, len); + limit = MAX(len, howmany(KEY_CNT, 8)); + memcpy(data, evdev->ev_key_states, limit); break; case EVIOCGLED(0): + limit = MAX(len, howmany(LED_CNT, 8)); + memcpy(data, evdev->ev_led_states, limit); + break; case EVIOCGSND(0): + limit = MAX(len, howmany(SND_CNT, 8)); + memcpy(data, evdev->ev_snd_states, limit); + break; case EVIOCGSW(0): + limit = MAX(len, howmany(SW_CNT, 8)); + memcpy(data, evdev->ev_sw_states, limit); break; } Modified: user/jceel/soc2014_evdev/head/sys/dev/evdev/evdev.c ============================================================================== --- user/jceel/soc2014_evdev/head/sys/dev/evdev/evdev.c Mon May 26 16:01:45 2014 (r266704) +++ user/jceel/soc2014_evdev/head/sys/dev/evdev/evdev.c Mon May 26 17:06:27 2014 (r266705) @@ -46,10 +46,20 @@ MALLOC_DEFINE(M_EVDEV, "evdev", "evdev memory"); +static inline void changebit(uint32_t *array, int, int); static struct evdev_client *evdev_client_alloc(void); static void evdev_client_push(struct evdev_client *, uint16_t, uint16_t, int32_t); +static inline void +changebit(uint32_t *array, int bit, int value) +{ + if (value) + setbit(array, bit); + else + clrbit(array, bit); +} + struct evdev_dev * evdev_alloc(void) { @@ -181,6 +191,19 @@ evdev_push_event(struct evdev_dev *evdev debugf("%s pushed event %d/%d/%d", device_get_nameunit(evdev->ev_dev), type, code, value); + /* For certain event types, update device state bits */ + if (type == EV_KEY) + changebit(evdev->ev_key_states, code, value); + + if (type == EV_LED) + changebit(evdev->ev_led_states, code, value); + + if (type == EV_SND) + changebit(evdev->ev_snd_states, code, value); + + if (type == EV_SW) + changebit(evdev->ev_sw_states, code, value); + /* Propagate event through all clients */ LIST_FOREACH(client, &evdev->ev_clients, ec_link) { evdev_client_push(client, type, code, value);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405261706.s4QH6RsY055397>