The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
Jakub Pawlowski | 5b790fe | 2017-09-18 09:00:20 -0700 | [diff] [blame] | 3 | * Copyright 2002-2012 Broadcom Corporation |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at: |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | * |
| 17 | ******************************************************************************/ |
| 18 | |
| 19 | /****************************************************************************** |
| 20 | * |
| 21 | * This file contains HID protocol definitions |
| 22 | * |
| 23 | ******************************************************************************/ |
| 24 | |
| 25 | #ifndef HIDDEFS_H |
| 26 | #define HIDDEFS_H |
| 27 | |
| 28 | #include "sdp_api.h" |
| 29 | /* |
Myles Watson | ee96a3c | 2016-11-23 14:49:54 -0800 | [diff] [blame] | 30 | * tHID_STATUS: HID result codes, returned by HID and device and host functions. |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 31 | */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 32 | enum { |
| 33 | HID_SUCCESS, |
| 34 | HID_ERR_NOT_REGISTERED, |
| 35 | HID_ERR_ALREADY_REGISTERED, |
| 36 | HID_ERR_NO_RESOURCES, |
| 37 | HID_ERR_NO_CONNECTION, |
| 38 | HID_ERR_INVALID_PARAM, |
| 39 | HID_ERR_UNSUPPORTED, |
| 40 | HID_ERR_UNKNOWN_COMMAND, |
| 41 | HID_ERR_CONGESTED, |
| 42 | HID_ERR_CONN_IN_PROCESS, |
| 43 | HID_ERR_ALREADY_CONN, |
| 44 | HID_ERR_DISCONNECTING, |
| 45 | HID_ERR_SET_CONNABLE_FAIL, |
| 46 | /* Device specific error codes */ |
| 47 | HID_ERR_HOST_UNKNOWN, |
| 48 | HID_ERR_L2CAP_FAILED, |
| 49 | HID_ERR_AUTH_FAILED, |
| 50 | HID_ERR_SDP_BUSY, |
| 51 | HID_ERR_GATT, |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 52 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 53 | HID_ERR_INVALID = 0xFF |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 54 | }; |
| 55 | |
Marie Janssen | d19e078 | 2016-07-15 12:48:27 -0700 | [diff] [blame] | 56 | typedef uint8_t tHID_STATUS; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 57 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 58 | #define HID_L2CAP_CONN_FAIL \ |
| 59 | (0x0100) /* Connection Attempt was made but failed */ |
| 60 | #define HID_L2CAP_REQ_FAIL (0x0200) /* L2CAP_ConnectReq API failed */ |
| 61 | #define HID_L2CAP_CFG_FAIL \ |
| 62 | (0x0400) /* L2CAP Configuration was rejected by peer */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 63 | |
| 64 | /* Define the HID transaction types |
| 65 | */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 66 | #define HID_TRANS_HANDSHAKE (0) |
| 67 | #define HID_TRANS_CONTROL (1) |
| 68 | #define HID_TRANS_GET_REPORT (4) |
| 69 | #define HID_TRANS_SET_REPORT (5) |
| 70 | #define HID_TRANS_GET_PROTOCOL (6) |
| 71 | #define HID_TRANS_SET_PROTOCOL (7) |
| 72 | #define HID_TRANS_GET_IDLE (8) |
| 73 | #define HID_TRANS_SET_IDLE (9) |
| 74 | #define HID_TRANS_DATA (10) |
| 75 | #define HID_TRANS_DATAC (11) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 76 | |
Chih-Hung Hsieh | 63b0519 | 2016-05-20 10:29:31 -0700 | [diff] [blame] | 77 | #define HID_GET_TRANS_FROM_HDR(x) (((x) >> 4) & 0x0f) |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 78 | #define HID_GET_PARAM_FROM_HDR(x) ((x)&0x0f) |
| 79 | #define HID_BUILD_HDR(t, p) (uint8_t)(((t) << 4) | ((p)&0x0f)) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 80 | |
| 81 | /* Parameters for Handshake |
| 82 | */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 83 | #define HID_PAR_HANDSHAKE_RSP_SUCCESS (0) |
| 84 | #define HID_PAR_HANDSHAKE_RSP_NOT_READY (1) |
| 85 | #define HID_PAR_HANDSHAKE_RSP_ERR_INVALID_REP_ID (2) |
| 86 | #define HID_PAR_HANDSHAKE_RSP_ERR_UNSUPPORTED_REQ (3) |
| 87 | #define HID_PAR_HANDSHAKE_RSP_ERR_INVALID_PARAM (4) |
| 88 | #define HID_PAR_HANDSHAKE_RSP_ERR_UNKNOWN (14) |
| 89 | #define HID_PAR_HANDSHAKE_RSP_ERR_FATAL (15) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 90 | |
| 91 | /* Parameters for Control |
| 92 | */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 93 | #define HID_PAR_CONTROL_NOP (0) |
| 94 | #define HID_PAR_CONTROL_HARD_RESET (1) |
| 95 | #define HID_PAR_CONTROL_SOFT_RESET (2) |
| 96 | #define HID_PAR_CONTROL_SUSPEND (3) |
| 97 | #define HID_PAR_CONTROL_EXIT_SUSPEND (4) |
| 98 | #define HID_PAR_CONTROL_VIRTUAL_CABLE_UNPLUG (5) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 99 | |
| 100 | /* Different report types in get, set, data |
| 101 | */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 102 | #define HID_PAR_REP_TYPE_MASK (0x03) |
| 103 | #define HID_PAR_REP_TYPE_OTHER (0x00) |
| 104 | #define HID_PAR_REP_TYPE_INPUT (0x01) |
| 105 | #define HID_PAR_REP_TYPE_OUTPUT (0x02) |
| 106 | #define HID_PAR_REP_TYPE_FEATURE (0x03) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 107 | |
| 108 | /* Parameters for Get Report |
| 109 | */ |
| 110 | |
| 111 | /* Buffer size in two bytes after Report ID */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 112 | #define HID_PAR_GET_REP_BUFSIZE_FOLLOWS (0x08) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 113 | |
| 114 | /* Parameters for Protocol Type |
| 115 | */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 116 | #define HID_PAR_PROTOCOL_MASK (0x01) |
| 117 | #define HID_PAR_PROTOCOL_REPORT (0x01) |
| 118 | #define HID_PAR_PROTOCOL_BOOT_MODE (0x00) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 119 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 120 | #define HID_PAR_REP_TYPE_MASK (0x03) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 121 | |
| 122 | /* Descriptor types in the SDP record |
| 123 | */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 124 | #define HID_SDP_DESCRIPTOR_REPORT (0x22) |
| 125 | #define HID_SDP_DESCRIPTOR_PHYSICAL (0x23) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 126 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 127 | typedef struct desc_info { |
| 128 | uint16_t dl_len; |
| 129 | uint8_t* dsc_list; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 130 | } tHID_DEV_DSCP_INFO; |
| 131 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 132 | #define HID_SSR_PARAM_INVALID 0xffff |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 133 | |
Hansong Zhang | 734d641 | 2018-10-02 16:26:38 -0700 | [diff] [blame] | 134 | #define HIDD_APP_DESCRIPTOR_LEN 2048 |
| 135 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 136 | typedef struct sdp_info { |
| 137 | char svc_name[HID_MAX_SVC_NAME_LEN]; /*Service Name */ |
| 138 | char svc_descr[HID_MAX_SVC_DESCR_LEN]; /*Service Description*/ |
| 139 | char prov_name[HID_MAX_PROV_NAME_LEN]; /*Provider Name.*/ |
| 140 | uint16_t rel_num; /*Release Number */ |
| 141 | uint16_t hpars_ver; /*HID Parser Version.*/ |
| 142 | uint16_t ssr_max_latency; /* HIDSSRHostMaxLatency value, if |
| 143 | HID_SSR_PARAM_INVALID not used*/ |
| 144 | uint16_t |
| 145 | ssr_min_tout; /* HIDSSRHostMinTimeout value, if HID_SSR_PARAM_INVALID not |
| 146 | used* */ |
| 147 | uint8_t sub_class; /*Device Subclass.*/ |
| 148 | uint8_t ctry_code; /*Country Code.*/ |
| 149 | uint16_t sup_timeout; /* Supervisory Timeout */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 150 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 151 | tHID_DEV_DSCP_INFO dscp_info; /* Descriptor list and Report list to be set in |
| 152 | the SDP record. |
| 153 | This parameter is used if |
| 154 | HID_DEV_USE_GLB_SDP_REC is set to false.*/ |
| 155 | tSDP_DISC_REC* p_sdp_layer_rec; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 156 | } tHID_DEV_SDP_INFO; |
| 157 | |
| 158 | #endif |