summaryrefslogtreecommitdiff
path: root/usb
diff options
context:
space:
mode:
authorHoward Yen <howardyen@google.com>2019-08-08 18:20:06 +0800
committerCyan_Hsieh <cyanhsieh@google.com>2020-05-29 21:22:25 +0800
commit31b4aa302c408a312b0dfb19cff7cf07dee39198 (patch)
tree9fc7454d7f8b73f7fe4f933de0be6b85275f8354 /usb
parent1d8d3a2925b37f7dcd89b74f823eed545812b0e0 (diff)
downloadredfin-31b4aa302c408a312b0dfb19cff7cf07dee39198.tar.gz
Update USB Gadget HAL to V1.1 implementation
Bug: 138702846 Test: build pass, function works Change-Id: I82a74d31f4339e4b4b8c59d879871550b943a36e
Diffstat (limited to 'usb')
-rw-r--r--usb/Android.bp5
-rw-r--r--usb/UsbGadget.cpp24
-rw-r--r--usb/UsbGadget.h25
-rw-r--r--usb/android.hardware.usb.gadget@1.1-service.redfin.xml11
-rw-r--r--usb/android.hardware.usb@1.2-service.redfin.xml12
-rw-r--r--usb/service.cpp4
6 files changed, 65 insertions, 16 deletions
diff --git a/usb/Android.bp b/usb/Android.bp
index c6566d7..2cd690f 100644
--- a/usb/Android.bp
+++ b/usb/Android.bp
@@ -17,12 +17,17 @@ cc_binary {
name: "android.hardware.usb@1.2-service.redfin",
relative_install_path: "hw",
init_rc: ["android.hardware.usb@1.2-service.redfin.rc"],
+ vintf_fragments: [
+ "android.hardware.usb@1.2-service.redfin.xml",
+ "android.hardware.usb.gadget@1.1-service.redfin.xml",
+ ],
srcs: ["service.cpp", "Usb.cpp", "UsbGadget.cpp"],
shared_libs: [
"android.hardware.usb@1.0",
"android.hardware.usb@1.1",
"android.hardware.usb@1.2",
"android.hardware.usb.gadget@1.0",
+ "android.hardware.usb.gadget@1.1",
"libbase",
"libcutils",
"libhardware",
diff --git a/usb/UsbGadget.cpp b/usb/UsbGadget.cpp
index 661e7b1..97535f0 100644
--- a/usb/UsbGadget.cpp
+++ b/usb/UsbGadget.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define LOG_TAG "android.hardware.usb.gadget@1.0-service.redfin"
+#define LOG_TAG "android.hardware.usb.gadget@1.1-service.redfin"
#include "UsbGadget.h"
#include <dirent.h>
@@ -30,7 +30,7 @@ namespace android {
namespace hardware {
namespace usb {
namespace gadget {
-namespace V1_0 {
+namespace V1_1 {
namespace implementation {
UsbGadget::UsbGadget() {
@@ -218,6 +218,24 @@ static V1_0::Status validateAndSetVidPid(uint64_t functions) {
return ret;
}
+Return<Status> UsbGadget::reset() {
+ ALOGI("USB Gadget reset");
+
+ if (!WriteStringToFile("none", PULLUP_PATH)) {
+ ALOGI("Gadget cannot be pulled down");
+ return Status::ERROR;
+ }
+
+ usleep(kDisconnectWaitUs);
+
+ if (!WriteStringToFile(kGadgetName, PULLUP_PATH)) {
+ ALOGI("Gadget cannot be pulled up");
+ return Status::ERROR;
+ }
+
+ return Status::SUCCESS;
+}
+
V1_0::Status UsbGadget::setupFunctions(uint64_t functions,
const sp<V1_0::IUsbGadgetCallback> &callback,
uint64_t timeout) {
@@ -339,7 +357,7 @@ error:
return Void();
}
} // namespace implementation
-} // namespace V1_0
+} // namespace V1_1
} // namespace gadget
} // namespace usb
} // namespace hardware
diff --git a/usb/UsbGadget.h b/usb/UsbGadget.h
index 1ffb188..93c7d66 100644
--- a/usb/UsbGadget.h
+++ b/usb/UsbGadget.h
@@ -14,13 +14,12 @@
* limitations under the License.
*/
-#ifndef ANDROID_HARDWARE_USB_GADGET_V1_0_USBGADGET_H
-#define ANDROID_HARDWARE_USB_GADGET_V1_0_USBGADGET_H
+#pragma once
#include <android-base/file.h>
#include <android-base/properties.h>
#include <android-base/unique_fd.h>
-#include <android/hardware/usb/gadget/1.0/IUsbGadget.h>
+#include <android/hardware/usb/gadget/1.1/IUsbGadget.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <pixelusb/UsbGadgetCommon.h>
@@ -37,7 +36,7 @@ namespace android {
namespace hardware {
namespace usb {
namespace gadget {
-namespace V1_0 {
+namespace V1_1 {
namespace implementation {
using ::android::sp;
@@ -61,6 +60,9 @@ using ::android::hardware::google::pixel::usb::MonitorFfs;
using ::android::hardware::google::pixel::usb::resetGadget;
using ::android::hardware::google::pixel::usb::setVidPid;
using ::android::hardware::google::pixel::usb::unlinkFunctions;
+using ::android::hardware::usb::gadget::V1_0::GadgetFunction;
+using ::android::hardware::usb::gadget::V1_0::Status;
+using ::android::hardware::usb::gadget::V1_1::IUsbGadget;
using ::std::string;
constexpr char kGadgetName[] = "a600000.dwc3";
@@ -74,22 +76,23 @@ struct UsbGadget : public IUsbGadget {
uint64_t mCurrentUsbFunctions;
bool mCurrentUsbFunctionsApplied;
- Return<void> setCurrentUsbFunctions(uint64_t functions, const sp<IUsbGadgetCallback> &callback,
+ Return<void> setCurrentUsbFunctions(uint64_t functions,
+ const sp<V1_0::IUsbGadgetCallback> &callback,
uint64_t timeout) override;
- Return<void> getCurrentUsbFunctions(const sp<IUsbGadgetCallback> &callback) override;
+ Return<void> getCurrentUsbFunctions(const sp<V1_0::IUsbGadgetCallback> &callback) override;
- private:
+ Return<Status> reset() override;
+
+private:
Status tearDownGadget();
- Status setupFunctions(uint64_t functions, const sp<IUsbGadgetCallback> &callback,
+ Status setupFunctions(uint64_t functions, const sp<V1_0::IUsbGadgetCallback> &callback,
uint64_t timeout);
};
} // namespace implementation
-} // namespace V1_0
+} // namespace V1_1
} // namespace gadget
} // namespace usb
} // namespace hardware
} // namespace android
-
-#endif // ANDROID_HARDWARE_USB_V1_2_USBGADGET_H
diff --git a/usb/android.hardware.usb.gadget@1.1-service.redfin.xml b/usb/android.hardware.usb.gadget@1.1-service.redfin.xml
new file mode 100644
index 0000000..a6f9a1f
--- /dev/null
+++ b/usb/android.hardware.usb.gadget@1.1-service.redfin.xml
@@ -0,0 +1,11 @@
+<manifest version="1.0" type="device">
+ <hal format="hidl">
+ <name>android.hardware.usb.gadget</name>
+ <transport>hwbinder</transport>
+ <version>1.1</version>
+ <interface>
+ <name>IUsbGadget</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+</manifest>
diff --git a/usb/android.hardware.usb@1.2-service.redfin.xml b/usb/android.hardware.usb@1.2-service.redfin.xml
new file mode 100644
index 0000000..25ecf65
--- /dev/null
+++ b/usb/android.hardware.usb@1.2-service.redfin.xml
@@ -0,0 +1,12 @@
+<manifest version="1.0" type="device">
+ <hal format="hidl">
+ <name>android.hardware.usb</name>
+ <transport>hwbinder</transport>
+ <version>1.2</version>
+ <interface>
+ <name>IUsb</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+</manifest>
+
diff --git a/usb/service.cpp b/usb/service.cpp
index c6768fe..33ffe74 100644
--- a/usb/service.cpp
+++ b/usb/service.cpp
@@ -27,8 +27,8 @@ using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
// Generated HIDL files
-using android::hardware::usb::gadget::V1_0::IUsbGadget;
-using android::hardware::usb::gadget::V1_0::implementation::UsbGadget;
+using android::hardware::usb::gadget::V1_1::IUsbGadget;
+using android::hardware::usb::gadget::V1_1::implementation::UsbGadget;
using android::hardware::usb::V1_2::IUsb;
using android::hardware::usb::V1_2::implementation::Usb;