types.hal revision 2f162ef128b74bfed5b913f04980009db31b96c7
1/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package android.hardware.usb@1.0;
17
18
19enum Status : uint32_t {
20    SUCCESS = 0,
21
22    /*
23     * error value when the HAL operation fails for reasons not listed here.
24     */
25    ERROR = 1,
26
27    /*
28     * error value returned when input argument is invalid.
29     */
30    INVALID_ARGUMENT = 2,
31
32    /*
33     * error value returned when role string is unrecognized.
34     */
35    UNRECOGNIZED_ROLE = 3,
36};
37
38/*
39 * Denotes the Port role type.
40 * Passed as an argument for functions used to query or change port roles.
41 */
42enum PortRoleType : uint32_t {
43    /*
44     * Denotes the data role of the port.
45     * The port can either be a "host" or a "device" for data.
46     * This maps to the PortDataRole enum.
47     */
48    DATA_ROLE = 0,
49
50    /*
51     * Denotes the power role of the port.
52     * The port can either be a "source" or "sink" for power.
53     * This maps to PortPowerRole enum.
54     */
55    POWER_ROLE = 1,
56
57    /*
58     * USB ports can be a pure DFP port which can only act
59     * as a host. A UFP port which can only act as a device.
60     * Or a dual role ports which can either can as a host or
61     * a device. This property is used to mention them.
62     */
63    MODE = 2,
64};
65
66@export
67enum PortDataRole : uint32_t {
68    /*
69     * Indicates that the port does not have a data role.
70     * In case of DRP, the current data role of the port is only resolved
71     * when the type-c handshake happens.
72     */
73    NONE = 0,
74
75    /*
76     * Indicates that the port is acting as a host for data.
77     */
78    HOST = 1,
79
80    /*
81     * Indicated that the port is acting as a device for data.
82     */
83    DEVICE = 2,
84
85    NUM_DATA_ROLES = 3,
86};
87
88@export
89enum PortPowerRole : uint32_t {
90    /*
91     * Indicates that the port does not have a power role.
92     * In case of DRP, the current power role of the port is only resolved
93     * when the type-c handshake happens.
94     */
95    NONE = 0,
96
97    /*
98     * Indicates that the port is supplying power to the other port.
99     */
100    SOURCE = 1,
101
102    /*
103     * Indicates that the port is sinking power from the other port.
104     */
105    SINK = 2,
106
107    NUM_POWER_ROLES = 3,
108};
109
110@export
111enum PortMode : uint32_t {
112    /*
113     * Indicates that the port does not have a mode.
114     * In case of DRP, the current mode of the port is only resolved
115     * when the type-c handshake happens.
116     */
117    NONE = 0,
118    /*
119     * Indicates that port can only act as device for data and sink for power.
120     */
121    UFP = 1,
122
123    /*
124     * Indicates the port can only act as host for data and source for power.
125     */
126    DFP = 2,
127
128    /*
129     * Indicates can either act as UFP or DFP at a given point of time.
130     */
131    DRP = 3,
132
133    NUM_MODES = 4,
134};
135
136/*
137 * Used as a container to send port role information.
138 */
139struct PortRole {
140    /*
141     * Indicates the type of Port Role.
142     * Maps to the PortRoleType enum.
143     */
144    PortRoleType type;
145
146    /*
147     * when type is HAL_USB_DATA_ROLE pass values from enum PortDataRole.
148     * when type is HAL_USB_POWER_ROLE pass values from enum PortPowerRole.
149     * when type is HAL_USB_MODE pass values from enum PortMode.
150     */
151    uint32_t role;
152};
153
154/*
155 * Used as the container to report data back to the caller.
156 * Represents the current connection status of a single USB port.
157 */
158struct PortStatus {
159     /*
160      * Name of the port.
161      * Used as the port's id by the caller.
162      */
163     string portName;
164
165     /*
166      * Data role of the port.
167      */
168     PortDataRole currentDataRole;
169
170     /*
171      * Power Role of thte port.
172      */
173     PortPowerRole currentPowerRole;
174
175     /*
176      * Mode in which the port is connected.
177      * Can be UFP or DFP.
178      */
179     PortMode currentMode;
180
181     /*
182      * True indicates that the port's mode can
183      * be changed. False otherwise.
184      */
185     bool canChangeMode;
186
187     /*
188      * True indicates that the port's data role
189      * can be changed. False otherwise.
190      * For example, true if Type-C PD PD_SWAP
191      * is supported.
192      */
193     bool canChangeDataRole;
194
195     /*
196      * True indicates that the port's power role
197      * can be changed. False otherwise.
198      * For example, true if Type-C PD PR_SWAP
199      * is supported.
200      */
201     bool canChangePowerRole;
202
203     /*
204      * Identifies the type of the local port.
205      *
206      * UFP - Indicates that port can only act as device for
207      *       data and sink for power.
208      * DFP - Indicates the port can only act as host for data
209      *       and source for power.
210      * DRP - Indicates can either act as UFP or DFP at a
211      *       given point of time.
212      */
213      PortMode supportedModes;
214};
215