diff --git a/usb/usb/Usb.cpp b/usb/usb/Usb.cpp index a98eca7b..7b037303 100644 --- a/usb/usb/Usb.cpp +++ b/usb/usb/Usb.cpp @@ -1223,6 +1223,16 @@ static void uevent_event(uint32_t /*epevents*/, struct data *payload) { payload->usb->mPartnerUp = true; pthread_cond_signal(&payload->usb->mPartnerCV); pthread_mutex_unlock(&payload->usb->mPartnerLock); + } else if (std::regex_match(cp, std::regex("(remove)(.*)(-partner)"))) { + string drmDisconnectPath = string(kDisplayPortDrmPath) + "usbc_cable_disconnect"; + + if (payload->usb->mPartnerSupportsDisplayPort) { + ALOGI("displayport partner removed"); + if (!WriteStringToFile("1", drmDisconnectPath)) { + ALOGE("Failed to signal disconnect to drm"); + } + payload->usb->mPartnerSupportsDisplayPort = false; + } } else if (!strncmp(cp, "DEVTYPE=typec_", strlen("DEVTYPE=typec_")) || !strncmp(cp, "DRIVER=max77759tcpc", strlen("DRIVER=max77759tcpc")) || @@ -1389,6 +1399,8 @@ ScopedAStatus Usb::setCallback(const shared_ptr& in_callback) { return ScopedAStatus::ok(); } +/***** DisplayPort Alt Mode Helpers *****/ + Status Usb::getDisplayPortUsbPathHelper(string *path) { DIR *dp; Status result = Status::ERROR; @@ -1805,6 +1817,7 @@ void Usb::setupDisplayPortPoll() { int ret; ALOGI("usbdp: setup: beginning setup for displayport poll thread"); + mPartnerSupportsDisplayPort = true; /* * If thread is currently starting, then it hasn't setup DisplayPort fd's, and we can abandon diff --git a/usb/usb/Usb.h b/usb/usb/Usb.h index 4d9ab538..60064514 100644 --- a/usb/usb/Usb.h +++ b/usb/usb/Usb.h @@ -156,6 +156,11 @@ struct Usb : public BnUsb { * eventfd to monitor whether a connection results in DisplayPort Alt Mode activating. */ int mDisplayPortActivateTimer; + /* + * Indicates whether or not port partner supports DisplayPort, and is used to + * communicate to the drm when the port partner physically disconnects. + */ + bool mPartnerSupportsDisplayPort; private: pthread_t mPoll; diff --git a/usb/usb/android.hardware.usb-service.rc b/usb/usb/android.hardware.usb-service.rc index 7619869a..e710451e 100644 --- a/usb/usb/android.hardware.usb-service.rc +++ b/usb/usb/android.hardware.usb-service.rc @@ -21,6 +21,7 @@ on post-fs chown root system /sys/devices/platform/110f0000.drmdp/drm-displayport/orientation chown root system /sys/devices/platform/110f0000.drmdp/drm-displayport/pin_assignment chown root system /sys/devices/platform/110f0000.drmdp/drm-displayport/link_status + chown root system /sys/devices/platform/110f0000.drmdp/drm-displayport/usbc_cable_disconnect chown root system /sys/devices/platform/11110000.usb/dwc3_exynos_otg_b_sess chown root system /sys/devices/platform/11110000.usb/dwc3_exynos_otg_id chown root system /sys/devices/platform/11110000.usb/usb_data_enabled @@ -44,4 +45,5 @@ on post-fs chmod 664 /sys/devices/platform/110f0000.drmdp/drm-displayport/orientation chmod 664 /sys/devices/platform/110f0000.drmdp/drm-displayport/pin_assignment chmod 664 /sys/devices/platform/110f0000.drmdp/drm-displayport/link_status + chmod 664 /sys/devices/platform/110f0000.drmdp/drm-displayport/usbc_cable_disconnect chmod 664 /sys/devices/platform/google,pogo/enable_usb