David Herrmann | 487e27e | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 1 | #ifndef __UHID_H_ |
| 2 | #define __UHID_H_ |
| 3 | |
| 4 | /* |
| 5 | * User-space I/O driver support for HID subsystem |
| 6 | * Copyright (c) 2012 David Herrmann |
| 7 | */ |
| 8 | |
| 9 | /* |
| 10 | * This program is free software; you can redistribute it and/or modify it |
| 11 | * under the terms of the GNU General Public License as published by the Free |
| 12 | * Software Foundation; either version 2 of the License, or (at your option) |
| 13 | * any later version. |
| 14 | */ |
| 15 | |
| 16 | /* |
| 17 | * Public header for user-space communication. We try to keep every structure |
| 18 | * aligned but to be safe we also use __attribute__((__packed__)). Therefore, |
| 19 | * the communication should be ABI compatible even between architectures. |
| 20 | */ |
| 21 | |
| 22 | #include <linux/input.h> |
| 23 | #include <linux/types.h> |
| 24 | |
| 25 | enum uhid_event_type { |
David Herrmann | 9b9a379 | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 26 | UHID_CREATE, |
| 27 | UHID_DESTROY, |
David Herrmann | ba5c313 | 2012-06-10 15:16:21 +0200 | [diff] [blame] | 28 | UHID_START, |
| 29 | UHID_STOP, |
David Herrmann | 8fbb877 | 2012-06-10 15:16:22 +0200 | [diff] [blame] | 30 | UHID_OPEN, |
| 31 | UHID_CLOSE, |
David Herrmann | 845d8fc | 2012-06-10 15:16:24 +0200 | [diff] [blame^] | 32 | UHID_OUTPUT, |
David Herrmann | 9db7c63 | 2012-06-10 15:16:23 +0200 | [diff] [blame] | 33 | UHID_OUTPUT_EV, |
David Herrmann | 5f80722 | 2012-06-10 15:16:19 +0200 | [diff] [blame] | 34 | UHID_INPUT, |
David Herrmann | 487e27e | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 35 | }; |
| 36 | |
David Herrmann | 9b9a379 | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 37 | struct uhid_create_req { |
| 38 | __u8 name[128]; |
| 39 | __u8 phys[64]; |
| 40 | __u8 uniq[64]; |
| 41 | __u8 __user *rd_data; |
| 42 | __u16 rd_size; |
| 43 | |
| 44 | __u16 bus; |
| 45 | __u32 vendor; |
| 46 | __u32 product; |
| 47 | __u32 version; |
| 48 | __u32 country; |
| 49 | } __attribute__((__packed__)); |
| 50 | |
David Herrmann | 5f80722 | 2012-06-10 15:16:19 +0200 | [diff] [blame] | 51 | #define UHID_DATA_MAX 4096 |
| 52 | |
David Herrmann | 845d8fc | 2012-06-10 15:16:24 +0200 | [diff] [blame^] | 53 | enum uhid_report_type { |
| 54 | UHID_FEATURE_REPORT, |
| 55 | UHID_OUTPUT_REPORT, |
| 56 | UHID_INPUT_REPORT, |
| 57 | }; |
| 58 | |
David Herrmann | 5f80722 | 2012-06-10 15:16:19 +0200 | [diff] [blame] | 59 | struct uhid_input_req { |
| 60 | __u8 data[UHID_DATA_MAX]; |
| 61 | __u16 size; |
| 62 | } __attribute__((__packed__)); |
| 63 | |
David Herrmann | 845d8fc | 2012-06-10 15:16:24 +0200 | [diff] [blame^] | 64 | struct uhid_output_req { |
| 65 | __u8 data[UHID_DATA_MAX]; |
| 66 | __u16 size; |
| 67 | __u8 rtype; |
| 68 | } __attribute__((__packed__)); |
| 69 | |
David Herrmann | 9db7c63 | 2012-06-10 15:16:23 +0200 | [diff] [blame] | 70 | struct uhid_output_ev_req { |
| 71 | __u16 type; |
| 72 | __u16 code; |
| 73 | __s32 value; |
| 74 | } __attribute__((__packed__)); |
| 75 | |
David Herrmann | 487e27e | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 76 | struct uhid_event { |
| 77 | __u32 type; |
David Herrmann | 9b9a379 | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 78 | |
| 79 | union { |
| 80 | struct uhid_create_req create; |
David Herrmann | 5f80722 | 2012-06-10 15:16:19 +0200 | [diff] [blame] | 81 | struct uhid_input_req input; |
David Herrmann | 845d8fc | 2012-06-10 15:16:24 +0200 | [diff] [blame^] | 82 | struct uhid_output_req output; |
David Herrmann | 9db7c63 | 2012-06-10 15:16:23 +0200 | [diff] [blame] | 83 | struct uhid_output_ev_req output_ev; |
David Herrmann | 9b9a379 | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 84 | } u; |
David Herrmann | 487e27e | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 85 | } __attribute__((__packed__)); |
| 86 | |
| 87 | #endif /* __UHID_H_ */ |