Merge "Update USB Gadget HAL to V1.1 implementation" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
8afb0fd239
@@ -17,12 +17,17 @@ cc_binary {
|
||||
name: "android.hardware.usb@1.2-service.bramble",
|
||||
relative_install_path: "hw",
|
||||
init_rc: ["android.hardware.usb@1.2-service.bramble.rc"],
|
||||
vintf_fragments: [
|
||||
"android.hardware.usb@1.2-service.bramble.xml",
|
||||
"android.hardware.usb.gadget@1.1-service.bramble.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",
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "android.hardware.usb.gadget@1.0-service.bramble"
|
||||
#define LOG_TAG "android.hardware.usb.gadget@1.1-service.bramble"
|
||||
|
||||
#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
|
||||
|
||||
@@ -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
|
||||
|
||||
11
usb/android.hardware.usb.gadget@1.1-service.bramble.xml
Normal file
11
usb/android.hardware.usb.gadget@1.1-service.bramble.xml
Normal file
@@ -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>
|
||||
12
usb/android.hardware.usb@1.2-service.bramble.xml
Normal file
12
usb/android.hardware.usb@1.2-service.bramble.xml
Normal file
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user