0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #ifndef __HIDP_H
0024 #define __HIDP_H
0025
0026 #include <linux/types.h>
0027 #include <linux/hid.h>
0028 #include <linux/kref.h>
0029 #include <net/bluetooth/bluetooth.h>
0030 #include <net/bluetooth/l2cap.h>
0031
0032
0033 #define HIDP_HEADER_TRANS_MASK 0xf0
0034 #define HIDP_HEADER_PARAM_MASK 0x0f
0035
0036
0037 #define HIDP_TRANS_HANDSHAKE 0x00
0038 #define HIDP_TRANS_HID_CONTROL 0x10
0039 #define HIDP_TRANS_GET_REPORT 0x40
0040 #define HIDP_TRANS_SET_REPORT 0x50
0041 #define HIDP_TRANS_GET_PROTOCOL 0x60
0042 #define HIDP_TRANS_SET_PROTOCOL 0x70
0043 #define HIDP_TRANS_GET_IDLE 0x80
0044 #define HIDP_TRANS_SET_IDLE 0x90
0045 #define HIDP_TRANS_DATA 0xa0
0046 #define HIDP_TRANS_DATC 0xb0
0047
0048
0049 #define HIDP_HSHK_SUCCESSFUL 0x00
0050 #define HIDP_HSHK_NOT_READY 0x01
0051 #define HIDP_HSHK_ERR_INVALID_REPORT_ID 0x02
0052 #define HIDP_HSHK_ERR_UNSUPPORTED_REQUEST 0x03
0053 #define HIDP_HSHK_ERR_INVALID_PARAMETER 0x04
0054 #define HIDP_HSHK_ERR_UNKNOWN 0x0e
0055 #define HIDP_HSHK_ERR_FATAL 0x0f
0056
0057
0058 #define HIDP_CTRL_NOP 0x00
0059 #define HIDP_CTRL_HARD_RESET 0x01
0060 #define HIDP_CTRL_SOFT_RESET 0x02
0061 #define HIDP_CTRL_SUSPEND 0x03
0062 #define HIDP_CTRL_EXIT_SUSPEND 0x04
0063 #define HIDP_CTRL_VIRTUAL_CABLE_UNPLUG 0x05
0064
0065
0066 #define HIDP_DATA_RTYPE_MASK 0x03
0067 #define HIDP_DATA_RSRVD_MASK 0x0c
0068 #define HIDP_DATA_RTYPE_OTHER 0x00
0069 #define HIDP_DATA_RTYPE_INPUT 0x01
0070 #define HIDP_DATA_RTYPE_OUPUT 0x02
0071 #define HIDP_DATA_RTYPE_FEATURE 0x03
0072
0073
0074 #define HIDP_PROTO_BOOT 0x00
0075 #define HIDP_PROTO_REPORT 0x01
0076
0077
0078 #define HIDPCONNADD _IOW('H', 200, int)
0079 #define HIDPCONNDEL _IOW('H', 201, int)
0080 #define HIDPGETCONNLIST _IOR('H', 210, int)
0081 #define HIDPGETCONNINFO _IOR('H', 211, int)
0082
0083 #define HIDP_VIRTUAL_CABLE_UNPLUG 0
0084 #define HIDP_BOOT_PROTOCOL_MODE 1
0085 #define HIDP_BLUETOOTH_VENDOR_ID 9
0086 #define HIDP_WAITING_FOR_RETURN 10
0087 #define HIDP_WAITING_FOR_SEND_ACK 11
0088
0089 struct hidp_connadd_req {
0090 int ctrl_sock;
0091 int intr_sock;
0092 __u16 parser;
0093 __u16 rd_size;
0094 __u8 __user *rd_data;
0095 __u8 country;
0096 __u8 subclass;
0097 __u16 vendor;
0098 __u16 product;
0099 __u16 version;
0100 __u32 flags;
0101 __u32 idle_to;
0102 char name[128];
0103 };
0104
0105 struct hidp_conndel_req {
0106 bdaddr_t bdaddr;
0107 __u32 flags;
0108 };
0109
0110 struct hidp_conninfo {
0111 bdaddr_t bdaddr;
0112 __u32 flags;
0113 __u16 state;
0114 __u16 vendor;
0115 __u16 product;
0116 __u16 version;
0117 char name[128];
0118 };
0119
0120 struct hidp_connlist_req {
0121 __u32 cnum;
0122 struct hidp_conninfo __user *ci;
0123 };
0124
0125 int hidp_connection_add(const struct hidp_connadd_req *req, struct socket *ctrl_sock, struct socket *intr_sock);
0126 int hidp_connection_del(struct hidp_conndel_req *req);
0127 int hidp_get_connlist(struct hidp_connlist_req *req);
0128 int hidp_get_conninfo(struct hidp_conninfo *ci);
0129
0130 enum hidp_session_state {
0131 HIDP_SESSION_IDLING,
0132 HIDP_SESSION_PREPARING,
0133 HIDP_SESSION_RUNNING,
0134 };
0135
0136
0137 struct hidp_session {
0138 struct list_head list;
0139 struct kref ref;
0140
0141
0142 atomic_t state;
0143 wait_queue_head_t state_queue;
0144 atomic_t terminate;
0145 struct task_struct *task;
0146 unsigned long flags;
0147
0148
0149 bdaddr_t bdaddr;
0150 struct l2cap_conn *conn;
0151 struct l2cap_user user;
0152 struct socket *ctrl_sock;
0153 struct socket *intr_sock;
0154 struct sk_buff_head ctrl_transmit;
0155 struct sk_buff_head intr_transmit;
0156 uint ctrl_mtu;
0157 uint intr_mtu;
0158 unsigned long idle_to;
0159
0160
0161 struct work_struct dev_init;
0162 struct input_dev *input;
0163 struct hid_device *hid;
0164 struct timer_list timer;
0165
0166
0167 __u8 *rd_data;
0168 uint rd_size;
0169
0170
0171 unsigned char keys[8];
0172 unsigned char leds;
0173
0174
0175 int waiting_report_type;
0176 int waiting_report_number;
0177 struct mutex report_mutex;
0178 struct sk_buff *report_return;
0179 wait_queue_head_t report_queue;
0180
0181
0182 int output_report_success;
0183
0184
0185 u8 input_buf[HID_MAX_BUFFER_SIZE];
0186 };
0187
0188
0189 int __init hidp_init_sockets(void);
0190 void __exit hidp_cleanup_sockets(void);
0191
0192 #endif