Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * User level driver support for input subsystem |
| 3 | * |
| 4 | * Heavily based on evdev.c by Vojtech Pavlik |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | * |
| 20 | * Author: Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org> |
Dmitry Torokhov | 221979a | 2006-02-19 00:22:36 -0500 | [diff] [blame] | 21 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | * Changes/Revisions: |
Benjamin Tissoires | 052876f8e | 2015-12-18 17:20:09 -0800 | [diff] [blame] | 23 | * 0.5 08/13/2015 (David Herrmann <dh.herrmann@gmail.com> & |
| 24 | * Benjamin Tissoires <benjamin.tissoires@redhat.com>) |
| 25 | * - add UI_DEV_SETUP ioctl |
| 26 | * - add UI_ABS_SETUP ioctl |
| 27 | * - add UI_GET_VERSION ioctl |
Benjamin Tissoires | e3480a6 | 2014-01-30 17:20:24 -0800 | [diff] [blame] | 28 | * 0.4 01/09/2014 (Benjamin Tissoires <benjamin.tissoires@redhat.com>) |
| 29 | * - add UI_GET_SYSNAME ioctl |
Anssi Hannula | ff46255 | 2006-07-19 01:41:09 -0400 | [diff] [blame] | 30 | * 0.3 24/05/2006 (Anssi Hannula <anssi.hannulagmail.com>) |
| 31 | * - update ff support for the changes in kernel interface |
| 32 | * - add UINPUT_VERSION |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | * 0.2 16/10/2004 (Micah Dowty <micah@navi.cx>) |
| 34 | * - added force feedback support |
| 35 | * - added UI_SET_PHYS |
| 36 | * 0.1 20/06/2002 |
| 37 | * - first public version |
| 38 | */ |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 39 | #ifndef __UINPUT_H_ |
| 40 | #define __UINPUT_H_ |
Anssi Hannula | ff46255 | 2006-07-19 01:41:09 -0400 | [diff] [blame] | 41 | |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 42 | #include <uapi/linux/uinput.h> |
Mike Frysinger | a830df3 | 2007-05-03 00:55:34 -0400 | [diff] [blame] | 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #define UINPUT_NAME "uinput" |
| 45 | #define UINPUT_BUFFER_SIZE 16 |
| 46 | #define UINPUT_NUM_REQUESTS 16 |
| 47 | |
Dmitry Torokhov | 2950641 | 2005-11-20 00:51:22 -0500 | [diff] [blame] | 48 | enum uinput_state { UIST_NEW_DEVICE, UIST_SETUP_COMPLETE, UIST_CREATED }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | struct uinput_request { |
Dmitry Torokhov | c5b3533 | 2012-07-29 22:48:32 -0700 | [diff] [blame] | 51 | unsigned int id; |
| 52 | unsigned int code; /* UI_FF_UPLOAD, UI_FF_ERASE */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
| 54 | int retval; |
Dmitry Torokhov | 0048e60 | 2005-06-30 00:48:14 -0500 | [diff] [blame] | 55 | struct completion done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
| 57 | union { |
Dmitry Torokhov | c5b3533 | 2012-07-29 22:48:32 -0700 | [diff] [blame] | 58 | unsigned int effect_id; |
Anssi Hannula | ff46255 | 2006-07-19 01:41:09 -0400 | [diff] [blame] | 59 | struct { |
| 60 | struct ff_effect *effect; |
| 61 | struct ff_effect *old; |
| 62 | } upload; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | } u; |
| 64 | }; |
| 65 | |
| 66 | struct uinput_device { |
| 67 | struct input_dev *dev; |
Dmitry Torokhov | 221979a | 2006-02-19 00:22:36 -0500 | [diff] [blame] | 68 | struct mutex mutex; |
Dmitry Torokhov | 2950641 | 2005-11-20 00:51:22 -0500 | [diff] [blame] | 69 | enum uinput_state state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | wait_queue_head_t waitq; |
Dmitry Torokhov | 2950641 | 2005-11-20 00:51:22 -0500 | [diff] [blame] | 71 | unsigned char ready; |
| 72 | unsigned char head; |
| 73 | unsigned char tail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | struct input_event buff[UINPUT_BUFFER_SIZE]; |
Dan Carpenter | 05be8b8 | 2011-10-12 21:05:53 -0700 | [diff] [blame] | 75 | unsigned int ff_effects_max; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
| 77 | struct uinput_request *requests[UINPUT_NUM_REQUESTS]; |
| 78 | wait_queue_head_t requests_waitq; |
Dmitry Torokhov | 0048e60 | 2005-06-30 00:48:14 -0500 | [diff] [blame] | 79 | spinlock_t requests_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | #endif /* __UINPUT_H_ */ |