1/*
2 * Copyright (C) 2018 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 */
16
17package android.hardware.usb@1.2;
18
19import android.hardware.usb@1.1::PortStatus_1_1;
20import android.hardware.usb@1.0::Status;
21
22enum Status : @1.0::Status {
23    /**
24     * Error value returned when the operation is not supported.
25     */
26    NOT_SUPPORTED = 4,
27};
28
29@export
30enum ContaminantDetectionStatus : uint32_t {
31    /**
32     * Contaminant presence detection is not supported.
33     */
34    NOT_SUPPORTED = 0,
35
36    /**
37     * Contaminant presence detection is supported but disabled.
38     */
39    DISABLED = 1,
40
41    /**
42     * Contaminant presence detection is enabled and contaminant not detected.
43     */
44    NOT_DETECTED = 2,
45
46    /**
47     * Contaminant presence detection is enabled and contaminant detected.
48     */
49    DETECTED = 3,
50};
51
52@export
53enum ContaminantProtectionMode : uint32_t {
54    /**
55     * No action performed upon detection of contaminant presence.
56     */
57    NONE = 0,
58
59    /**
60     * Upon detection of contaminant presence, Port is forced to sink only
61     * mode where a port shall only detect chargers until contaminant presence
62     * is no longer detected.
63     */
64    FORCE_SINK = 1 << 0,
65
66    /**
67     * Upon detection of contaminant presence, Port is forced to source only
68     * mode where a port shall only detect usb accessories such as headsets
69     * until contaminant presence is no longer detected.
70     */
71    FORCE_SOURCE = 1 << 1,
72
73    /**
74     * Upon detection of contaminant presence, port is disabled until contaminant
75     * presence is no longer detected. In the disabled state port will
76     * not respond to connection of chargers or usb accessories.
77     */
78    FORCE_DISABLE = 1 << 2,
79};
80
81@export
82enum ContaminantProtectionStatus : ContaminantProtectionMode {
83    /**
84     * Client disabled cotaminant protection by calling
85     * enableContaminantPresencePortProtection set to false. Low level drivers should
86     * not autmomously take any corrective action when contaminant presence is detected.
87     */
88    DISABLED = 1 << 3,
89};
90
91struct PortStatus {
92    PortStatus_1_1 status_1_1;
93
94    /**
95     * Contaminant presence protection modes supported by the port.
96     */
97    bitfield<ContaminantProtectionMode> supportedContaminantProtectionModes;
98
99    /**
100     * Client can enable/disable contaminant presence protection through
101     * enableContaminantPresenceProtection when true.
102     */
103    bool supportsEnableContaminantPresenceProtection;
104
105    /**
106     * Contaminant presence protection modes currently active for the port.
107     */
108    ContaminantProtectionStatus contaminantProtectionStatus;
109
110    /**
111     * Client can enable/disable contaminant presence detection through
112     * enableContaminantPresenceDetection when true.
113     */
114    bool supportsEnableContaminantPresenceDetection;
115
116    /**
117     * Current status of contaminant detection algorithm.
118     */
119    ContaminantDetectionStatus contaminantDetectionStatus;
120};
121