usb: Log for retry on role switch

Add a log for the retry. Also define the sleep time in the header file.

Bug: 341996696
Change-Id: Ib3cc0c6ad576e7cda26b7f50cdc61d52e6349c78
Signed-off-by: Kyle Tso <kyletso@google.com>
This commit is contained in:
Kyle Tso 2024-06-13 16:54:37 +08:00
parent a9b7137ea9
commit d17fdff5f8
2 changed files with 3 additions and 1 deletions

View file

@ -603,7 +603,8 @@ ScopedAStatus Usb::switchRole(const string& in_portName, const PortRole& in_role
if (fp != NULL) { if (fp != NULL) {
int ret = fputs(convertRoletoString(in_role).c_str(), fp); int ret = fputs(convertRoletoString(in_role).c_str(), fp);
if (ret == EAGAIN) { if (ret == EAGAIN) {
std::this_thread::sleep_for(std::chrono::milliseconds(700)); ALOGI("role switch busy, retry in %d ms", ROLE_SWAP_RETRY_MS);
std::this_thread::sleep_for(std::chrono::milliseconds(ROLE_SWAP_RETRY_MS));
ret = fputs(convertRoletoString(in_role).c_str(), fp); ret = fputs(convertRoletoString(in_role).c_str(), fp);
} }
fclose(fp); fclose(fp);

View file

@ -79,6 +79,7 @@ constexpr char kGadgetName[] = "11210000.dwc3";
#define DISPLAYPORT_IRQ_HPD_COUNT_CHECK 3 #define DISPLAYPORT_IRQ_HPD_COUNT_CHECK 3
#define DISPLAYPORT_POLL_WAIT_MS 100 #define DISPLAYPORT_POLL_WAIT_MS 100
#define ROLE_SWAP_RETRY_MS 700
#define SVID_DISPLAYPORT "ff01" #define SVID_DISPLAYPORT "ff01"
#define SVID_THUNDERBOLT "8087" #define SVID_THUNDERBOLT "8087"