David Herrmann | ace3d86 | 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> |
Petri Gynther | 4522643 | 2014-03-24 13:50:01 -0700 | [diff] [blame^] | 24 | #include <linux/hid.h> |
David Herrmann | ace3d86 | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 25 | |
| 26 | enum uhid_event_type { |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 27 | UHID_CREATE, |
| 28 | UHID_DESTROY, |
David Herrmann | ec4b7de | 2012-06-10 15:16:21 +0200 | [diff] [blame] | 29 | UHID_START, |
| 30 | UHID_STOP, |
David Herrmann | e719147 | 2012-06-10 15:16:22 +0200 | [diff] [blame] | 31 | UHID_OPEN, |
| 32 | UHID_CLOSE, |
David Herrmann | 3b3baa8 | 2012-06-10 15:16:24 +0200 | [diff] [blame] | 33 | UHID_OUTPUT, |
David Herrmann | bdb829e | 2013-07-15 19:10:15 +0200 | [diff] [blame] | 34 | UHID_OUTPUT_EV, /* obsolete! */ |
David Herrmann | 5e87a36 | 2012-06-10 15:16:19 +0200 | [diff] [blame] | 35 | UHID_INPUT, |
David Herrmann | fcfcf0d | 2012-06-10 15:16:25 +0200 | [diff] [blame] | 36 | UHID_FEATURE, |
| 37 | UHID_FEATURE_ANSWER, |
Petri Gynther | 4522643 | 2014-03-24 13:50:01 -0700 | [diff] [blame^] | 38 | UHID_CREATE2, |
| 39 | UHID_INPUT2, |
David Herrmann | ace3d86 | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 40 | }; |
| 41 | |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 42 | struct uhid_create_req { |
| 43 | __u8 name[128]; |
| 44 | __u8 phys[64]; |
| 45 | __u8 uniq[64]; |
| 46 | __u8 __user *rd_data; |
| 47 | __u16 rd_size; |
| 48 | |
| 49 | __u16 bus; |
| 50 | __u32 vendor; |
| 51 | __u32 product; |
| 52 | __u32 version; |
| 53 | __u32 country; |
| 54 | } __attribute__((__packed__)); |
| 55 | |
Petri Gynther | 4522643 | 2014-03-24 13:50:01 -0700 | [diff] [blame^] | 56 | struct uhid_create2_req { |
| 57 | __u8 name[128]; |
| 58 | __u8 phys[64]; |
| 59 | __u8 uniq[64]; |
| 60 | __u16 rd_size; |
| 61 | __u16 bus; |
| 62 | __u32 vendor; |
| 63 | __u32 product; |
| 64 | __u32 version; |
| 65 | __u32 country; |
| 66 | __u8 rd_data[HID_MAX_DESCRIPTOR_SIZE]; |
| 67 | } __attribute__((__packed__)); |
| 68 | |
David Herrmann | 5e87a36 | 2012-06-10 15:16:19 +0200 | [diff] [blame] | 69 | #define UHID_DATA_MAX 4096 |
| 70 | |
David Herrmann | 3b3baa8 | 2012-06-10 15:16:24 +0200 | [diff] [blame] | 71 | enum uhid_report_type { |
| 72 | UHID_FEATURE_REPORT, |
| 73 | UHID_OUTPUT_REPORT, |
| 74 | UHID_INPUT_REPORT, |
| 75 | }; |
| 76 | |
David Herrmann | 5e87a36 | 2012-06-10 15:16:19 +0200 | [diff] [blame] | 77 | struct uhid_input_req { |
| 78 | __u8 data[UHID_DATA_MAX]; |
| 79 | __u16 size; |
| 80 | } __attribute__((__packed__)); |
| 81 | |
Petri Gynther | 4522643 | 2014-03-24 13:50:01 -0700 | [diff] [blame^] | 82 | struct uhid_input2_req { |
| 83 | __u16 size; |
| 84 | __u8 data[UHID_DATA_MAX]; |
| 85 | } __attribute__((__packed__)); |
| 86 | |
David Herrmann | 3b3baa8 | 2012-06-10 15:16:24 +0200 | [diff] [blame] | 87 | struct uhid_output_req { |
| 88 | __u8 data[UHID_DATA_MAX]; |
| 89 | __u16 size; |
| 90 | __u8 rtype; |
| 91 | } __attribute__((__packed__)); |
| 92 | |
David Herrmann | bdb829e | 2013-07-15 19:10:15 +0200 | [diff] [blame] | 93 | /* Obsolete! Newer kernels will no longer send these events but instead convert |
| 94 | * it into raw output reports via UHID_OUTPUT. */ |
David Herrmann | f80e136 | 2012-06-10 15:16:23 +0200 | [diff] [blame] | 95 | struct uhid_output_ev_req { |
| 96 | __u16 type; |
| 97 | __u16 code; |
| 98 | __s32 value; |
| 99 | } __attribute__((__packed__)); |
| 100 | |
David Herrmann | fcfcf0d | 2012-06-10 15:16:25 +0200 | [diff] [blame] | 101 | struct uhid_feature_req { |
| 102 | __u32 id; |
| 103 | __u8 rnum; |
| 104 | __u8 rtype; |
| 105 | } __attribute__((__packed__)); |
| 106 | |
| 107 | struct uhid_feature_answer_req { |
| 108 | __u32 id; |
| 109 | __u16 err; |
| 110 | __u16 size; |
| 111 | __u8 data[UHID_DATA_MAX]; |
David Herrmann | fee5dfe | 2012-12-17 13:20:43 +0100 | [diff] [blame] | 112 | } __attribute__((__packed__)); |
David Herrmann | fcfcf0d | 2012-06-10 15:16:25 +0200 | [diff] [blame] | 113 | |
David Herrmann | ace3d86 | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 114 | struct uhid_event { |
| 115 | __u32 type; |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 116 | |
| 117 | union { |
| 118 | struct uhid_create_req create; |
David Herrmann | 5e87a36 | 2012-06-10 15:16:19 +0200 | [diff] [blame] | 119 | struct uhid_input_req input; |
David Herrmann | 3b3baa8 | 2012-06-10 15:16:24 +0200 | [diff] [blame] | 120 | struct uhid_output_req output; |
David Herrmann | f80e136 | 2012-06-10 15:16:23 +0200 | [diff] [blame] | 121 | struct uhid_output_ev_req output_ev; |
David Herrmann | fcfcf0d | 2012-06-10 15:16:25 +0200 | [diff] [blame] | 122 | struct uhid_feature_req feature; |
| 123 | struct uhid_feature_answer_req feature_answer; |
Petri Gynther | 4522643 | 2014-03-24 13:50:01 -0700 | [diff] [blame^] | 124 | struct uhid_create2_req create2; |
| 125 | struct uhid_input2_req input2; |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 126 | } u; |
David Herrmann | ace3d86 | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 127 | } __attribute__((__packed__)); |
| 128 | |
| 129 | #endif /* __UHID_H_ */ |