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 #include <linux/hid.h> 25 26 enum uhid_event_type { 27 UHID_CREATE, 28 UHID_DESTROY, 29 UHID_START, 30 UHID_STOP, 31 UHID_OPEN, 32 UHID_CLOSE, 33 UHID_OUTPUT, 34 UHID_OUTPUT_EV, /* obsolete! */ 35 UHID_INPUT, 36 UHID_FEATURE, /* obsolete! use UHID_GET_REPORT */ 37 UHID_GET_REPORT = UHID_FEATURE, 38 UHID_FEATURE_ANSWER, /* obsolete! use UHID_GET_REPORT_REPLY */ 39 UHID_GET_REPORT_REPLY = UHID_FEATURE_ANSWER, 40 UHID_CREATE2, 41 UHID_INPUT2, 42 }; 43 44 struct uhid_create_req { 45 __u8 name[128]; 46 __u8 phys[64]; 47 __u8 uniq[64]; 48 __u8 __user *rd_data; 49 __u16 rd_size; 50 51 __u16 bus; 52 __u32 vendor; 53 __u32 product; 54 __u32 version; 55 __u32 country; 56 } __attribute__((__packed__)); 57 58 struct uhid_create2_req { 59 __u8 name[128]; 60 __u8 phys[64]; 61 __u8 uniq[64]; 62 __u16 rd_size; 63 __u16 bus; 64 __u32 vendor; 65 __u32 product; 66 __u32 version; 67 __u32 country; 68 __u8 rd_data[HID_MAX_DESCRIPTOR_SIZE]; 69 } __attribute__((__packed__)); 70 71 #define UHID_DATA_MAX 4096 72 73 enum uhid_report_type { 74 UHID_FEATURE_REPORT, 75 UHID_OUTPUT_REPORT, 76 UHID_INPUT_REPORT, 77 }; 78 79 struct uhid_input_req { 80 __u8 data[UHID_DATA_MAX]; 81 __u16 size; 82 } __attribute__((__packed__)); 83 84 struct uhid_input2_req { 85 __u16 size; 86 __u8 data[UHID_DATA_MAX]; 87 } __attribute__((__packed__)); 88 89 struct uhid_output_req { 90 __u8 data[UHID_DATA_MAX]; 91 __u16 size; 92 __u8 rtype; 93 } __attribute__((__packed__)); 94 95 /* Obsolete! Newer kernels will no longer send these events but instead convert 96 * it into raw output reports via UHID_OUTPUT. */ 97 struct uhid_output_ev_req { 98 __u16 type; 99 __u16 code; 100 __s32 value; 101 } __attribute__((__packed__)); 102 103 /* Obsolete! Kernel uses ABI compatible UHID_GET_REPORT. */ 104 struct uhid_feature_req { 105 __u32 id; 106 __u8 rnum; 107 __u8 rtype; 108 } __attribute__((__packed__)); 109 110 struct uhid_get_report_req { 111 __u32 id; 112 __u8 rnum; 113 __u8 rtype; 114 } __attribute__((__packed__)); 115 116 /* Obsolete! Use ABI compatible UHID_GET_REPORT_REPLY. */ 117 struct uhid_feature_answer_req { 118 __u32 id; 119 __u16 err; 120 __u16 size; 121 __u8 data[UHID_DATA_MAX]; 122 } __attribute__((__packed__)); 123 124 struct uhid_get_report_reply_req { 125 __u32 id; 126 __u16 err; 127 __u16 size; 128 __u8 data[UHID_DATA_MAX]; 129 } __attribute__((__packed__)); 130 131 struct uhid_event { 132 __u32 type; 133 134 union { 135 struct uhid_create_req create; 136 struct uhid_input_req input; 137 struct uhid_output_req output; 138 struct uhid_output_ev_req output_ev; 139 struct uhid_feature_req feature; 140 struct uhid_get_report_req get_report; 141 struct uhid_feature_answer_req feature_answer; 142 struct uhid_get_report_reply_req get_report_reply; 143 struct uhid_create2_req create2; 144 struct uhid_input2_req input2; 145 } u; 146 } __attribute__((__packed__)); 147 148 #endif /* __UHID_H_ */ 149