]>
Commit | Line | Data |
---|---|---|
8e87d142 | 1 | /* |
1da177e4 LT |
2 | HIDP implementation for Linux Bluetooth stack (BlueZ). |
3 | Copyright (C) 2003-2004 Marcel Holtmann <marcel@holtmann.org> | |
4 | ||
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License version 2 as | |
7 | published by the Free Software Foundation; | |
8 | ||
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
10 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
11 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. | |
12 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY | |
8e87d142 YH |
13 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES |
14 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
1da177e4 LT |
16 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
17 | ||
8e87d142 YH |
18 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, |
19 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS | |
1da177e4 LT |
20 | SOFTWARE IS DISCLAIMED. |
21 | */ | |
22 | ||
23 | #ifndef __HIDP_H | |
24 | #define __HIDP_H | |
25 | ||
26 | #include <linux/types.h> | |
b4f34d8d | 27 | #include <linux/kref.h> |
1da177e4 | 28 | #include <net/bluetooth/bluetooth.h> |
b4f34d8d | 29 | #include <net/bluetooth/l2cap.h> |
1da177e4 LT |
30 | |
31 | /* HIDP header masks */ | |
32 | #define HIDP_HEADER_TRANS_MASK 0xf0 | |
33 | #define HIDP_HEADER_PARAM_MASK 0x0f | |
34 | ||
35 | /* HIDP transaction types */ | |
36 | #define HIDP_TRANS_HANDSHAKE 0x00 | |
37 | #define HIDP_TRANS_HID_CONTROL 0x10 | |
38 | #define HIDP_TRANS_GET_REPORT 0x40 | |
39 | #define HIDP_TRANS_SET_REPORT 0x50 | |
40 | #define HIDP_TRANS_GET_PROTOCOL 0x60 | |
41 | #define HIDP_TRANS_SET_PROTOCOL 0x70 | |
42 | #define HIDP_TRANS_GET_IDLE 0x80 | |
43 | #define HIDP_TRANS_SET_IDLE 0x90 | |
44 | #define HIDP_TRANS_DATA 0xa0 | |
45 | #define HIDP_TRANS_DATC 0xb0 | |
46 | ||
47 | /* HIDP handshake results */ | |
48 | #define HIDP_HSHK_SUCCESSFUL 0x00 | |
49 | #define HIDP_HSHK_NOT_READY 0x01 | |
50 | #define HIDP_HSHK_ERR_INVALID_REPORT_ID 0x02 | |
51 | #define HIDP_HSHK_ERR_UNSUPPORTED_REQUEST 0x03 | |
52 | #define HIDP_HSHK_ERR_INVALID_PARAMETER 0x04 | |
53 | #define HIDP_HSHK_ERR_UNKNOWN 0x0e | |
54 | #define HIDP_HSHK_ERR_FATAL 0x0f | |
55 | ||
56 | /* HIDP control operation parameters */ | |
57 | #define HIDP_CTRL_NOP 0x00 | |
58 | #define HIDP_CTRL_HARD_RESET 0x01 | |
59 | #define HIDP_CTRL_SOFT_RESET 0x02 | |
60 | #define HIDP_CTRL_SUSPEND 0x03 | |
61 | #define HIDP_CTRL_EXIT_SUSPEND 0x04 | |
62 | #define HIDP_CTRL_VIRTUAL_CABLE_UNPLUG 0x05 | |
63 | ||
64 | /* HIDP data transaction headers */ | |
65 | #define HIDP_DATA_RTYPE_MASK 0x03 | |
66 | #define HIDP_DATA_RSRVD_MASK 0x0c | |
67 | #define HIDP_DATA_RTYPE_OTHER 0x00 | |
68 | #define HIDP_DATA_RTYPE_INPUT 0x01 | |
69 | #define HIDP_DATA_RTYPE_OUPUT 0x02 | |
70 | #define HIDP_DATA_RTYPE_FEATURE 0x03 | |
71 | ||
72 | /* HIDP protocol header parameters */ | |
73 | #define HIDP_PROTO_BOOT 0x00 | |
74 | #define HIDP_PROTO_REPORT 0x01 | |
75 | ||
76 | /* HIDP ioctl defines */ | |
77 | #define HIDPCONNADD _IOW('H', 200, int) | |
78 | #define HIDPCONNDEL _IOW('H', 201, int) | |
79 | #define HIDPGETCONNLIST _IOR('H', 210, int) | |
80 | #define HIDPGETCONNINFO _IOR('H', 211, int) | |
81 | ||
82 | #define HIDP_VIRTUAL_CABLE_UNPLUG 0 | |
83 | #define HIDP_BOOT_PROTOCOL_MODE 1 | |
84 | #define HIDP_BLUETOOTH_VENDOR_ID 9 | |
6d67c110 | 85 | #define HIDP_WAITING_FOR_RETURN 10 |
0825411a | 86 | #define HIDP_WAITING_FOR_SEND_ACK 11 |
1da177e4 LT |
87 | |
88 | struct hidp_connadd_req { | |
17f09a7e SJ |
89 | int ctrl_sock; /* Connected control socket */ |
90 | int intr_sock; /* Connected interrupt socket */ | |
1da177e4 LT |
91 | __u16 parser; |
92 | __u16 rd_size; | |
55e74744 | 93 | __u8 __user *rd_data; |
1da177e4 LT |
94 | __u8 country; |
95 | __u8 subclass; | |
96 | __u16 vendor; | |
97 | __u16 product; | |
98 | __u16 version; | |
99 | __u32 flags; | |
100 | __u32 idle_to; | |
101 | char name[128]; | |
102 | }; | |
103 | ||
104 | struct hidp_conndel_req { | |
105 | bdaddr_t bdaddr; | |
106 | __u32 flags; | |
107 | }; | |
108 | ||
109 | struct hidp_conninfo { | |
110 | bdaddr_t bdaddr; | |
111 | __u32 flags; | |
112 | __u16 state; | |
113 | __u16 vendor; | |
114 | __u16 product; | |
115 | __u16 version; | |
116 | char name[128]; | |
117 | }; | |
118 | ||
119 | struct hidp_connlist_req { | |
120 | __u32 cnum; | |
121 | struct hidp_conninfo __user *ci; | |
122 | }; | |
123 | ||
b4f34d8d DH |
124 | int hidp_connection_add(struct hidp_connadd_req *req, struct socket *ctrl_sock, struct socket *intr_sock); |
125 | int hidp_connection_del(struct hidp_conndel_req *req); | |
1da177e4 LT |
126 | int hidp_get_connlist(struct hidp_connlist_req *req); |
127 | int hidp_get_conninfo(struct hidp_conninfo *ci); | |
128 | ||
b4f34d8d DH |
129 | enum hidp_session_state { |
130 | HIDP_SESSION_IDLING, | |
4e713cdf | 131 | HIDP_SESSION_PREPARING, |
b4f34d8d DH |
132 | HIDP_SESSION_RUNNING, |
133 | }; | |
134 | ||
1da177e4 LT |
135 | /* HIDP session defines */ |
136 | struct hidp_session { | |
137 | struct list_head list; | |
b4f34d8d | 138 | struct kref ref; |
1da177e4 | 139 | |
b4f34d8d DH |
140 | /* runtime management */ |
141 | atomic_t state; | |
142 | wait_queue_head_t state_queue; | |
143 | atomic_t terminate; | |
144 | struct task_struct *task; | |
145 | unsigned long flags; | |
edad6388 | 146 | |
b4f34d8d DH |
147 | /* connection management */ |
148 | bdaddr_t bdaddr; | |
b4f34d8d DH |
149 | struct l2cap_conn *conn; |
150 | struct l2cap_user user; | |
1da177e4 LT |
151 | struct socket *ctrl_sock; |
152 | struct socket *intr_sock; | |
b4f34d8d DH |
153 | struct sk_buff_head ctrl_transmit; |
154 | struct sk_buff_head intr_transmit; | |
1da177e4 LT |
155 | uint ctrl_mtu; |
156 | uint intr_mtu; | |
b4f34d8d | 157 | unsigned long idle_to; |
1da177e4 | 158 | |
b4f34d8d | 159 | /* device management */ |
4e713cdf | 160 | struct work_struct dev_init; |
1da177e4 | 161 | struct input_dev *input; |
e1aaadd4 | 162 | struct hid_device *hid; |
1da177e4 LT |
163 | struct timer_list timer; |
164 | ||
b4f34d8d DH |
165 | /* Report descriptor */ |
166 | __u8 *rd_data; | |
167 | uint rd_size; | |
168 | ||
169 | /* session data */ | |
170 | unsigned char keys[8]; | |
171 | unsigned char leds; | |
c500c971 | 172 | |
0ff1731a AO |
173 | /* Used in hidp_get_raw_report() */ |
174 | int waiting_report_type; /* HIDP_DATA_RTYPE_* */ | |
175 | int waiting_report_number; /* -1 for not numbered */ | |
176 | struct mutex report_mutex; | |
177 | struct sk_buff *report_return; | |
178 | wait_queue_head_t report_queue; | |
179 | ||
0825411a AO |
180 | /* Used in hidp_output_raw_report() */ |
181 | int output_report_success; /* boolean */ | |
1da177e4 LT |
182 | }; |
183 | ||
1da177e4 LT |
184 | /* HIDP init defines */ |
185 | extern int __init hidp_init_sockets(void); | |
186 | extern void __exit hidp_cleanup_sockets(void); | |
187 | ||
188 | #endif /* __HIDP_H */ |