From owner-svn-src-user@FreeBSD.ORG Tue Jun 3 20:09:40 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 90174540; Tue, 3 Jun 2014 20:09:40 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7D57324F9; Tue, 3 Jun 2014 20:09:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s53K9efm057897; Tue, 3 Jun 2014 20:09:40 GMT (envelope-from jceel@svn.freebsd.org) Received: (from jceel@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s53K9dHS057892; Tue, 3 Jun 2014 20:09:39 GMT (envelope-from jceel@svn.freebsd.org) Message-Id: <201406032009.s53K9dHS057892@svn.freebsd.org> From: Jakub Wojciech Klama Date: Tue, 3 Jun 2014 20:09:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r267024 - user/jceel/soc2014_evdev/head/sys/dev/evdev X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jun 2014 20:09:40 -0000 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 **);