UsbGadget: Update SDP enum timeout when gadget is pulled up
Indicate to the kernel that the usb gadget is pulled up by writing to `update_sdp_enum_timeout` sysfs node. Write to this node will inform the kernel that it can lower the SDP timeout alarm value which is used to detect an SDP port vs a DCP. Bug:356685367 Test: Check `update_sdp_enum_timeout` is written into after usb gadget is pulled up. Verify that the alarm timeout lowers. Flag: EXEMPT bugfix Change-Id: Id3ae7e7a20b236cec6604414a7f81860e868bdd0 (ported from commit d8e2a02998fc1db9be00dab69a213378fb3caede) Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
This commit is contained in:
parent
e0f64c3efd
commit
7f688ffd28
4 changed files with 32 additions and 0 deletions
|
@ -49,6 +49,7 @@ constexpr char kTcpcDevName[] = "i2c-max77759tcpc";
|
||||||
constexpr char kI2cClientId[] = "0025";
|
constexpr char kI2cClientId[] = "0025";
|
||||||
constexpr char kAccessoryLimitCurrent[] = "usb_limit_accessory_current";
|
constexpr char kAccessoryLimitCurrent[] = "usb_limit_accessory_current";
|
||||||
constexpr char kAccessoryLimitCurrentEnable[] = "usb_limit_accessory_enable";
|
constexpr char kAccessoryLimitCurrentEnable[] = "usb_limit_accessory_enable";
|
||||||
|
constexpr char kUpdateSdpEnumTimeout[] = "update_sdp_enum_timeout";
|
||||||
|
|
||||||
UsbGadget::UsbGadget() : mGadgetIrqPath(""),
|
UsbGadget::UsbGadget() : mGadgetIrqPath(""),
|
||||||
mI2cClientPath("") {
|
mI2cClientPath("") {
|
||||||
|
@ -103,6 +104,7 @@ Status UsbGadget::getUsbGadgetIrqPath() {
|
||||||
void currentFunctionsAppliedCallback(bool functionsApplied, void *payload) {
|
void currentFunctionsAppliedCallback(bool functionsApplied, void *payload) {
|
||||||
UsbGadget *gadget = (UsbGadget *)payload;
|
UsbGadget *gadget = (UsbGadget *)payload;
|
||||||
gadget->mCurrentUsbFunctionsApplied = functionsApplied;
|
gadget->mCurrentUsbFunctionsApplied = functionsApplied;
|
||||||
|
gadget->updateSdpEnumTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedAStatus UsbGadget::getCurrentUsbFunctions(const shared_ptr<IUsbGadgetCallback> &callback,
|
ScopedAStatus UsbGadget::getCurrentUsbFunctions(const shared_ptr<IUsbGadgetCallback> &callback,
|
||||||
|
@ -369,6 +371,28 @@ ScopedAStatus UsbGadget::reset(const shared_ptr<IUsbGadgetCallback> &callback,
|
||||||
return ScopedAStatus::ok();
|
return ScopedAStatus::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UsbGadget::updateSdpEnumTimeout() {
|
||||||
|
string update_sdp_enum_timeout_path;
|
||||||
|
|
||||||
|
if (mI2cClientPath.empty()) {
|
||||||
|
for (int i = 0; i < NUM_HSI2C_PATHS; ++i) {
|
||||||
|
mI2cClientPath = getI2cClientPath(kHsi2cPaths[i], kTcpcDevName, kI2cClientId);
|
||||||
|
if (mI2cClientPath.empty()) {
|
||||||
|
ALOGE("%s: Unable to locate i2c bus node", __func__);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
update_sdp_enum_timeout_path = mI2cClientPath + kUpdateSdpEnumTimeout;
|
||||||
|
if (!WriteStringToFile("1", update_sdp_enum_timeout_path)) {
|
||||||
|
ALOGE("%s: Unable to write to %s.", __func__, update_sdp_enum_timeout_path.c_str());
|
||||||
|
} else {
|
||||||
|
ALOGI("%s: Updated SDP enumeration timeout value.", __func__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Status UsbGadget::setupFunctions(long functions,
|
Status UsbGadget::setupFunctions(long functions,
|
||||||
const shared_ptr<IUsbGadgetCallback> &callback, uint64_t timeout,
|
const shared_ptr<IUsbGadgetCallback> &callback, uint64_t timeout,
|
||||||
int64_t in_transactionId) {
|
int64_t in_transactionId) {
|
||||||
|
@ -427,6 +451,7 @@ Status UsbGadget::setupFunctions(long functions,
|
||||||
mCurrentUsbFunctionsApplied = true;
|
mCurrentUsbFunctionsApplied = true;
|
||||||
if (callback)
|
if (callback)
|
||||||
callback->setCurrentUsbFunctionsCb(functions, Status::SUCCESS, in_transactionId);
|
callback->setCurrentUsbFunctionsCb(functions, Status::SUCCESS, in_transactionId);
|
||||||
|
updateSdpEnumTimeout();
|
||||||
return Status::SUCCESS;
|
return Status::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,9 @@ struct UsbGadget : public BnUsbGadget {
|
||||||
|
|
||||||
ScopedAStatus setVidPid(const char *vid,const char *pid);
|
ScopedAStatus setVidPid(const char *vid,const char *pid);
|
||||||
|
|
||||||
|
// Indicates to the kernel that the gadget service is ready and the kernel can
|
||||||
|
// set SDP timeout to a lower value.
|
||||||
|
void updateSdpEnumTimeout();
|
||||||
std::string mI2cClientPath;
|
std::string mI2cClientPath;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -15,6 +15,7 @@ on post-fs
|
||||||
chown root system /sys/devices/platform/10cb0000.hsi2c/i2c-11/11-0025/usb_limit_sink_current
|
chown root system /sys/devices/platform/10cb0000.hsi2c/i2c-11/11-0025/usb_limit_sink_current
|
||||||
chown root system /sys/devices/platform/10cb0000.hsi2c/i2c-11/11-0025/usb_limit_sink_enable
|
chown root system /sys/devices/platform/10cb0000.hsi2c/i2c-11/11-0025/usb_limit_sink_enable
|
||||||
chown root system /sys/devices/platform/10cb0000.hsi2c/i2c-11/11-0025/usb_limit_source_enable
|
chown root system /sys/devices/platform/10cb0000.hsi2c/i2c-11/11-0025/usb_limit_source_enable
|
||||||
|
chown root system /sys/devices/platform/10cb0000.hsi2c/i2c-11/11-0025/update_sdp_enum_timeout
|
||||||
chown root graphics /sys/devices/platform/110f0000.drmdp/drm-displayport/dp_hotplug_error_code
|
chown root graphics /sys/devices/platform/110f0000.drmdp/drm-displayport/dp_hotplug_error_code
|
||||||
chown root system /sys/devices/platform/110f0000.drmdp/drm-displayport/hpd
|
chown root system /sys/devices/platform/110f0000.drmdp/drm-displayport/hpd
|
||||||
chown root system /sys/devices/platform/110f0000.drmdp/drm-displayport/irq_hpd
|
chown root system /sys/devices/platform/110f0000.drmdp/drm-displayport/irq_hpd
|
||||||
|
@ -39,6 +40,7 @@ on post-fs
|
||||||
chmod 664 /sys/devices/platform/10cb0000.hsi2c/i2c-11/11-0025/usb_limit_sink_current
|
chmod 664 /sys/devices/platform/10cb0000.hsi2c/i2c-11/11-0025/usb_limit_sink_current
|
||||||
chmod 664 /sys/devices/platform/10cb0000.hsi2c/i2c-11/11-0025/usb_limit_sink_enable
|
chmod 664 /sys/devices/platform/10cb0000.hsi2c/i2c-11/11-0025/usb_limit_sink_enable
|
||||||
chmod 664 /sys/devices/platform/10cb0000.hsi2c/i2c-11/11-0025/usb_limit_source_enable
|
chmod 664 /sys/devices/platform/10cb0000.hsi2c/i2c-11/11-0025/usb_limit_source_enable
|
||||||
|
chmod 664 /sys/devices/platform/10cb0000.hsi2c/i2c-11/11-0025/update_sdp_enum_timeout
|
||||||
chmod 664 /sys/devices/platform/110f0000.drmdp/drm-displayport/dp_hotplug_error_code
|
chmod 664 /sys/devices/platform/110f0000.drmdp/drm-displayport/dp_hotplug_error_code
|
||||||
chmod 664 /sys/devices/platform/110f0000.drmdp/drm-displayport/hpd
|
chmod 664 /sys/devices/platform/110f0000.drmdp/drm-displayport/hpd
|
||||||
chmod 664 /sys/devices/platform/110f0000.drmdp/drm-displayport/irq_hpd
|
chmod 664 /sys/devices/platform/110f0000.drmdp/drm-displayport/irq_hpd
|
||||||
|
|
|
@ -15,6 +15,7 @@ on post-fs
|
||||||
chown root system /sys/devices/platform/108d0000.hsi2c/i2c-6/6-0025/usb_limit_sink_current
|
chown root system /sys/devices/platform/108d0000.hsi2c/i2c-6/6-0025/usb_limit_sink_current
|
||||||
chown root system /sys/devices/platform/108d0000.hsi2c/i2c-6/6-0025/usb_limit_sink_enable
|
chown root system /sys/devices/platform/108d0000.hsi2c/i2c-6/6-0025/usb_limit_sink_enable
|
||||||
chown root system /sys/devices/platform/108d0000.hsi2c/i2c-6/6-0025/usb_limit_source_enable
|
chown root system /sys/devices/platform/108d0000.hsi2c/i2c-6/6-0025/usb_limit_source_enable
|
||||||
|
chown root system /sys/devices/platform/108d0000.hsi2c/i2c-6/6-0025/update_sdp_enum_timeout
|
||||||
chown root graphics /sys/devices/platform/110f0000.drmdp/drm-displayport/dp_hotplug_error_code
|
chown root graphics /sys/devices/platform/110f0000.drmdp/drm-displayport/dp_hotplug_error_code
|
||||||
chown root system /sys/devices/platform/110f0000.drmdp/drm-displayport/hpd
|
chown root system /sys/devices/platform/110f0000.drmdp/drm-displayport/hpd
|
||||||
chown root system /sys/devices/platform/110f0000.drmdp/drm-displayport/irq_hpd
|
chown root system /sys/devices/platform/110f0000.drmdp/drm-displayport/irq_hpd
|
||||||
|
@ -39,6 +40,7 @@ on post-fs
|
||||||
chmod 664 /sys/devices/platform/108d0000.hsi2c/i2c-6/6-0025/usb_limit_sink_current
|
chmod 664 /sys/devices/platform/108d0000.hsi2c/i2c-6/6-0025/usb_limit_sink_current
|
||||||
chmod 664 /sys/devices/platform/108d0000.hsi2c/i2c-6/6-0025/usb_limit_sink_enable
|
chmod 664 /sys/devices/platform/108d0000.hsi2c/i2c-6/6-0025/usb_limit_sink_enable
|
||||||
chmod 664 /sys/devices/platform/108d0000.hsi2c/i2c-6/6-0025/usb_limit_source_enable
|
chmod 664 /sys/devices/platform/108d0000.hsi2c/i2c-6/6-0025/usb_limit_source_enable
|
||||||
|
chmod 664 /sys/devices/platform/108d0000.hsi2c/i2c-6/6-0025/update_sdp_enum_timeout
|
||||||
chmod 664 /sys/devices/platform/110f0000.drmdp/drm-displayport/dp_hotplug_error_code
|
chmod 664 /sys/devices/platform/110f0000.drmdp/drm-displayport/dp_hotplug_error_code
|
||||||
chmod 664 /sys/devices/platform/110f0000.drmdp/drm-displayport/hpd
|
chmod 664 /sys/devices/platform/110f0000.drmdp/drm-displayport/hpd
|
||||||
chmod 664 /sys/devices/platform/110f0000.drmdp/drm-displayport/irq_hpd
|
chmod 664 /sys/devices/platform/110f0000.drmdp/drm-displayport/irq_hpd
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue