summaryrefslogtreecommitdiff
path: root/usb/gadget/UsbGadget.cpp
diff options
context:
space:
mode:
authorAvichal Rakesh <arakesh@google.com>2023-01-19 20:10:24 -0800
committerAvichal Rakesh <arakesh@google.com>2023-02-06 21:20:59 +0000
commit72dbe87c4288a908da5f88abb6e04f492358159a (patch)
tree89e3a47c3afadd5ad654cc2283ff1f3b9d7d8f74 /usb/gadget/UsbGadget.cpp
parent5e2f81a254d828744767f2186a02ac734914621c (diff)
downloadgs201-72dbe87c4288a908da5f88abb6e04f492358159a.tar.gz
UsbGadget: Add support for UVC function
UVC is a new USB function supported in Android. This CL adds UVC as a valid function and gives it a new pid of 0x4ee[de]. UVC function is guarded by the property `ro.usb.uvc.enabled`. When this property is set to false, UVC won't be considered as a valid gadget function. Bug: 242344221 Test: Manually tested that the UVC function is successfully configured Change-Id: I7ce1cc192c09b5f3cd7c73405fe54426a1311dfb
Diffstat (limited to 'usb/gadget/UsbGadget.cpp')
-rw-r--r--usb/gadget/UsbGadget.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/usb/gadget/UsbGadget.cpp b/usb/gadget/UsbGadget.cpp
index 7e0b3bd..bccf8a5 100644
--- a/usb/gadget/UsbGadget.cpp
+++ b/usb/gadget/UsbGadget.cpp
@@ -26,6 +26,8 @@
#include <sys/types.h>
#include <unistd.h>
+#include <android-base/properties.h>
+
#include <aidl/android/frameworks/stats/IStats.h>
namespace aidl {
@@ -34,6 +36,9 @@ namespace hardware {
namespace usb {
namespace gadget {
+using ::android::base::GetBoolProperty;
+using ::android::hardware::google::pixel::usb::kUvcEnabled;
+
string enabledPath;
constexpr char kHsi2cPath[] = "/sys/devices/platform/10d60000.hsi2c";
constexpr char kI2CPath[] = "/sys/devices/platform/10d60000.hsi2c/i2c-";
@@ -302,6 +307,28 @@ static Status validateAndSetVidPid(uint64_t functions) {
ret = Status(setVidPid("0x18d1", "0x4eec"));
}
break;
+ case GadgetFunction::UVC:
+ if (!(vendorFunctions == "user" || vendorFunctions == "")) {
+ ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
+ ret = Status::CONFIGURATION_NOT_SUPPORTED;
+ } else if (!GetBoolProperty(kUvcEnabled, false)) {
+ ALOGE("UVC function not enabled by config");
+ ret = Status::CONFIGURATION_NOT_SUPPORTED;
+ } else {
+ ret = Status(setVidPid("0x18d1", "0x4eed"));
+ }
+ break;
+ case GadgetFunction::ADB | GadgetFunction::UVC:
+ if (!(vendorFunctions == "user" || vendorFunctions == "")) {
+ ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
+ ret = Status::CONFIGURATION_NOT_SUPPORTED;
+ } else if (!GetBoolProperty(kUvcEnabled, false)) {
+ ALOGE("UVC function not enabled by config");
+ ret = Status::CONFIGURATION_NOT_SUPPORTED;
+ } else {
+ ret = Status(setVidPid("0x18d1", "0x4eee"));
+ }
+ break;
default:
ALOGE("Combination not supported");
ret = Status::CONFIGURATION_NOT_SUPPORTED;