exynos9610: USB HAL: Use 1.1 IUsb intead of 1.0 IUsb
[GitHub/moto-9609/android_device_motorola_exynos9610-common.git] / hidl / usb / Usb.h
CommitLineData
89b64b29
BJS
1#ifndef ANDROID_HARDWARE_USB_V1_1_USB_H
2#define ANDROID_HARDWARE_USB_V1_1_USB_H
9550981c 3
89b64b29
BJS
4#include <android/hardware/usb/1.1/IUsb.h>
5#include <android/hardware/usb/1.1/types.h>
6#include <android/hardware/usb/1.1/IUsbCallback.h>
9550981c
BJS
7#include <hidl/Status.h>
8#include <utils/Log.h>
9
9550981c 10#define UEVENT_MSG_LEN 2048
80fa0c82
BJS
11// The type-c stack waits for 4.5 - 5.5 secs before declaring a port non-pd.
12// The -partner directory would not be created until this is done.
13// Having a margin of ~3 secs for the directory and other related bookeeping
14// structures created and uvent fired.
15#define PORT_TYPE_TIMEOUT 8
9550981c
BJS
16
17namespace android {
18namespace hardware {
19namespace usb {
89b64b29 20namespace V1_1 {
9550981c
BJS
21namespace implementation {
22
9550981c 23using ::android::hardware::usb::V1_0::PortRole;
89b64b29
BJS
24using ::android::hardware::usb::V1_0::PortRoleType;
25using ::android::hardware::usb::V1_0::PortDataRole;
26using ::android::hardware::usb::V1_0::PortPowerRole;
27using ::android::hardware::usb::V1_0::Status;
2e24c4d3 28using ::android::hardware::usb::V1_1::IUsb;
89b64b29
BJS
29using ::android::hardware::usb::V1_1::IUsbCallback;
30using ::android::hardware::usb::V1_1::PortMode_1_1;
31using ::android::hardware::usb::V1_1::PortStatus_1_1;
32using ::android::hidl::base::V1_0::DebugInfo;
9550981c
BJS
33using ::android::hidl::base::V1_0::IBase;
34using ::android::hardware::hidl_array;
35using ::android::hardware::hidl_memory;
36using ::android::hardware::hidl_string;
37using ::android::hardware::hidl_vec;
38using ::android::hardware::Return;
39using ::android::hardware::Void;
40using ::android::sp;
41
42struct Usb : public IUsb {
43 Return<void> switchRole(const hidl_string& portName, const PortRole& role) override;
80fa0c82 44 Return<void> setCallback(const sp<V1_0::IUsbCallback>& callback) override;
9550981c
BJS
45 Return<void> queryPortStatus() override;
46
89b64b29 47
80fa0c82
BJS
48 sp<V1_0::IUsbCallback> mCallback_1_0;
49 // Protects mCallback variable
9550981c 50 pthread_mutex_t mLock = PTHREAD_MUTEX_INITIALIZER;
80fa0c82
BJS
51 // Protects roleSwitch operation
52 pthread_mutex_t mRoleSwitchLock = PTHREAD_MUTEX_INITIALIZER;
53 // Threads waiting for the partner to come back wait here
54 pthread_cond_t mPartnerCV = PTHREAD_COND_INITIALIZER;
55 // lock protecting mPartnerCV
56 pthread_mutex_t mPartnerLock = PTHREAD_MUTEX_INITIALIZER;
57 // Variable to signal partner coming back online after type switch
58 bool mPartnerUp;
9550981c
BJS
59
60 private:
61 pthread_t mPoll;
62};
63
64} // namespace implementation
65} // namespace V1_0
66} // namespace usb
67} // namespace hardware
68} // namespace android
69
89b64b29 70#endif // ANDROID_HARDWARE_USB_V1_1_USB_H