diff --git a/BoardConfig-common.mk b/BoardConfig-common.mk index 864a3858..3d11fc03 100644 --- a/BoardConfig-common.mk +++ b/BoardConfig-common.mk @@ -32,7 +32,6 @@ TARGET_CPU_ABI := arm64-v8a TARGET_CPU_VARIANT := cortex-a55 TARGET_CPU_VARIANT_RUNTIME := cortex-a55 -BOARD_KERNEL_CMDLINE += dyndbg=\"func alloc_contig_dump_pages +p\" BOARD_KERNEL_CMDLINE += earlycon=exynos4210,0x10870000 console=ttySAC0,115200 androidboot.console=ttySAC0 printk.devkmsg=on BOARD_KERNEL_CMDLINE += cma_sysfs.experimental=Y BOARD_KERNEL_CMDLINE += cgroup_disable=memory @@ -152,6 +151,10 @@ BOARD_AVB_VBMETA_SYSTEM_ALGORITHM := SHA256_RSA2048 BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP) BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION := 1 +ifneq ($(PRODUCT_BUILD_PVMFW_IMAGE),false) +BOARD_AVB_VBMETA_SYSTEM += pvmfw +endif + # Enable chained vbmeta for boot images BOARD_AVB_BOOT_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem BOARD_AVB_BOOT_ALGORITHM := SHA256_RSA2048 diff --git a/OWNERS b/OWNERS new file mode 100644 index 00000000..1cbf9196 --- /dev/null +++ b/OWNERS @@ -0,0 +1,2 @@ +# per-file for Pixel device makefiles, see go/pixel-device-mk-owner-checklist for details. +per-file *.mk=file:device/google/gs-common:master:/OWNERS diff --git a/conf/init.zuma.rc b/conf/init.zuma.rc index 3415838e..0b98cce2 100644 --- a/conf/init.zuma.rc +++ b/conf/init.zuma.rc @@ -105,6 +105,9 @@ on init write /sys/block/zram0/comp_algorithm lz77eh write /proc/sys/vm/page-cluster 0 + # Adjust watermark level + write /proc/sys/vm/watermark_scale_factor 200 + # Some user code relies on ro.boot.hardware.revision setprop ro.boot.hardware.revision ${ro.revision} @@ -119,7 +122,7 @@ on init symlink /data/app /factory # Apply network parameters for high data performance. - write /proc/sys/net/core/rmem_default 327680 + write /proc/sys/net/core/rmem_default 1310720 write /proc/sys/net/core/rmem_max 8388608 write /proc/sys/net/core/wmem_default 327680 write /proc/sys/net/core/wmem_max 8388608 @@ -375,6 +378,9 @@ on post-fs-data # Modem SIM log folder mkdir /data/vendor/radio/sim 0771 radio system + # Modem OTA UECap folder + mkdir /data/vendor/radio/ota_uecap 0773 radio system + # Unzipped modem images folder mkdir /data/vendor/radio/image 0771 radio system @@ -719,6 +725,9 @@ on property:sys.boot_completed=1 # Enable UFS powersaving write /dev/sys/block/bootdevice/clkgate_enable 1 + # Cancel boot devfreq + write /sys/devices/platform/17000010.devfreq_mif/devfreq/17000010.devfreq_mif/exynos_data/cancel_boot_freq 1 + # Setup final cpuset write /dev/cpuset/top-app/cpus 0-8 write /dev/cpuset/foreground/cpus 0-7 @@ -814,9 +823,12 @@ on property:sys.boot_completed=1 # Disable GPU firmware logging write /sys/devices/platform/1f000000.mali/firmware_config/Log\ verbosity/cur 0 -#Enable SICD + # Enable SICD write /sys/devices/system/cpu/cpupm/cpupm/sicd 1 +on property:sys.boot_completed=1 && property:persist.sys.device_provisioned=1 && property:ro.boot.flash.locked=1 + write /sys/class/power_supply/battery/first_usage_date 0 + # IMS WiFi Calling service charonservice /system/vendor/bin/charon class main diff --git a/conf/init.zuma.usb.rc b/conf/init.zuma.usb.rc index 0f5d22c9..7b4ef192 100644 --- a/conf/init.zuma.usb.rc +++ b/conf/init.zuma.usb.rc @@ -192,3 +192,9 @@ on property:sys.usb.config=charger && property:sys.usb.configfs=1 on property:ro.bootmode=usbuwb setprop persist.vendor.usb.usbradio.config uwb_acm + +on property:persist.vendor.usb.displayport.enabled=1 + write /sys/class/typec/port0/port0.0/mode1/active "yes" + +on property:persist.vendor.usb.displayport.enabled=0 + write /sys/class/typec/port0/port0.0/mode1/active "no" diff --git a/conf/ueventd.zuma.rc b/conf/ueventd.zuma.rc index ac58f04d..7483184a 100644 --- a/conf/ueventd.zuma.rc +++ b/conf/ueventd.zuma.rc @@ -212,6 +212,7 @@ /dev/dma_heap/farawimg-secure 0444 system graphics /dev/dma_heap/tui-secure 0444 system graphics /dev/dma_heap/vframe-secure 0444 system drmrpc +/dev/dma_heap/framebuffer-secure 0444 system drmrpc /dev/dma_heap/vscaler-secure 0444 system graphics /dev/dma_heap/vstream-secure 0444 system drmrpc /dev/dma_heap/sensor_direct_heap 0444 system graphics diff --git a/default-permissions.xml b/default-permissions.xml index 8a0f653c..49ae87b4 100644 --- a/default-permissions.xml +++ b/default-permissions.xml @@ -47,6 +47,8 @@ + + diff --git a/device-common.mk b/device-common.mk index 95cbd19c..67fb2335 100644 --- a/device-common.mk +++ b/device-common.mk @@ -30,7 +30,7 @@ PRODUCT_COPY_FILES += \ # Set system properties identifying the chipset PRODUCT_VENDOR_PROPERTIES += ro.soc.manufacturer=Google -PRODUCT_VENDOR_PROPERTIES += ro.soc.model=ZUMA +TARGET_VENDOR_PROP += device/google/zuma/vendor.prop PRODUCT_PRODUCT_PROPERTIES += \ persist.vendor.testing_battery_profile=2 diff --git a/device.mk b/device.mk index 0fcfe7e5..05389a73 100644 --- a/device.mk +++ b/device.mk @@ -196,6 +196,14 @@ PRODUCT_PROPERTY_OVERRIDES += \ PRODUCT_PROPERTY_OVERRIDES += \ telephony.active_modems.max_count=2 +ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT))) +PRODUCT_PROPERTY_OVERRIDES += \ + persist.vendor.usb.displayport.enabled=1 +else +PRODUCT_PROPERTY_OVERRIDES += \ + persist.vendor.usb.displayport.enabled=0 +endif + USE_LASSEN_OEMHOOK := true # Use for GRIL @@ -260,8 +268,8 @@ PRODUCT_COPY_FILES += \ frameworks/native/data/etc/android.hardware.vulkan.version-1_3.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.version.xml \ frameworks/native/data/etc/android.hardware.vulkan.level-1.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.level.xml \ frameworks/native/data/etc/android.hardware.vulkan.compute-0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.compute.xml \ - frameworks/native/data/etc/android.software.vulkan.deqp.level-2021-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.vulkan.deqp.level.xml \ - frameworks/native/data/etc/android.software.opengles.deqp.level-2021-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.opengles.deqp.level.xml + frameworks/native/data/etc/android.software.vulkan.deqp.level-2023-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.vulkan.deqp.level.xml \ + frameworks/native/data/etc/android.software.opengles.deqp.level-2023-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.opengles.deqp.level.xml #endif @@ -515,7 +523,7 @@ PRODUCT_PACKAGES += \ android.hardware.graphics.allocator-V1-service PRODUCT_PACKAGES += \ - memtrack.$(TARGET_BOARD_PLATFORM) \ + android.hardware.memtrack-service.pixel \ libion_exynos \ libion diff --git a/health/android.hardware.health-service.zuma.xml b/health/android.hardware.health-service.zuma.xml index 98026cbd..1fe9b8d2 100644 --- a/health/android.hardware.health-service.zuma.xml +++ b/health/android.hardware.health-service.zuma.xml @@ -1,7 +1,7 @@ android.hardware.health - 1 + 2 IHealth/default diff --git a/media_codecs_bo_c2.xml b/media_codecs_bo_c2.xml index 9ada7280..099fb57a 100644 --- a/media_codecs_bo_c2.xml +++ b/media_codecs_bo_c2.xml @@ -15,6 +15,7 @@ --> + diff --git a/media_codecs_performance_c2.xml b/media_codecs_performance_c2.xml index 2c6663e9..d81c0157 100644 --- a/media_codecs_performance_c2.xml +++ b/media_codecs_performance_c2.xml @@ -112,8 +112,8 @@ - - + + @@ -138,8 +138,9 @@ - - + + + @@ -183,6 +184,12 @@ + + + + + + @@ -242,38 +249,65 @@ + + + + + + + + + + - - + + - - - - - - - - + + + + + + + + - - + + - - + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modem_ml/modem_ml_models_user.conf b/modem_ml/modem_ml_models_user.conf index 88ab2bc7..b606ee97 100644 --- a/modem_ml/modem_ml_models_user.conf +++ b/modem_ml/modem_ml_models_user.conf @@ -1,3 +1,3 @@ #name,version,ml_type,compute_enable,compute_timer,train_enable,train_timer,monitor_enable_monitor_timer,execution_type,execution_timer -sample_linear_reg,0,LEGACY,true,5000,false,0,false,0,SYNCHRONOUS_REGULAR,5000 -sample_fully_conn,0,LEGACY,true,5000,false,0,false,0,SYNCHRONOUS_REGULAR,5000 +sample_linear_reg,0,LEGACY,false,0,false,0,false,0,SYNCHRONOUS_REGULAR,5000 +sample_fully_conn,0,LEGACY,false,0,false,0,false,0,SYNCHRONOUS_REGULAR,5000 diff --git a/modem_ml/modem_ml_models_userdebug.conf b/modem_ml/modem_ml_models_userdebug.conf index 640bfeb1..b606ee97 100644 --- a/modem_ml/modem_ml_models_userdebug.conf +++ b/modem_ml/modem_ml_models_userdebug.conf @@ -1,3 +1,3 @@ #name,version,ml_type,compute_enable,compute_timer,train_enable,train_timer,monitor_enable_monitor_timer,execution_type,execution_timer -sample_linear_reg,0,LEGACY,true,5000,true,5000,true,5000,SYNCHRONOUS_REGULAR,5000 -sample_fully_conn,0,LEGACY,true,5000,true,5000,true,5000,SYNCHRONOUS_REGULAR,5000 +sample_linear_reg,0,LEGACY,false,0,false,0,false,0,SYNCHRONOUS_REGULAR,5000 +sample_fully_conn,0,LEGACY,false,0,false,0,false,0,SYNCHRONOUS_REGULAR,5000 diff --git a/pixelstats/service.cpp b/pixelstats/service.cpp index ca151a16..cd09dc1b 100644 --- a/pixelstats/service.cpp +++ b/pixelstats/service.cpp @@ -59,6 +59,14 @@ const struct SysfsCollector::SysfsPaths sysfs_paths = { UFS_ERR_PATH(auto_hibern8_err_count) }, .AmsRatePath = "/sys/devices/platform/audiometrics/ams_rate_read_once", + .ThermalStatsPaths = { + "/sys/devices/platform/100a0000.BIG/trip_counter", + "/sys/devices/platform/100a0000.MID/trip_counter", + "/sys/devices/platform/100a0000.LITTLE/trip_counter", + "/sys/devices/platform/100b0000.G3D/trip_counter", + "/sys/devices/platform/100b0000.TPU/trip_counter", + "/sys/devices/platform/100b0000.AUR/trip_counter", + }, .ResumeLatencyMetricsPath = "/sys/kernel/metrics/resume_latency/resume_latency_metrics", .LongIRQMetricsPath = "/sys/kernel/metrics/irq/long_irq_metrics", .TempResidencyPaths = { diff --git a/radio/config/default.nprf b/radio/config/default.nprf index 34afa509..527094d7 100644 Binary files a/radio/config/default.nprf and b/radio/config/default.nprf differ diff --git a/usb/usb/Android.bp b/usb/usb/Android.bp index 5a73f9a4..b1e0a9ea 100644 --- a/usb/usb/Android.bp +++ b/usb/usb/Android.bp @@ -46,7 +46,7 @@ cc_binary { "android.hardware.thermal@2.0", "android.hardware.thermal-V1-ndk", "android.hardware.usb.gadget@1.0", - "android.hardware.usb-V1-ndk", + "android.hardware.usb-V2-ndk", "android.hardware.usb.gadget-V1-ndk", "libcutils", "android.frameworks.stats-V1-ndk", diff --git a/usb/usb/Usb.cpp b/usb/usb/Usb.cpp index c574c913..19454049 100644 --- a/usb/usb/Usb.cpp +++ b/usb/usb/Usb.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -44,6 +45,8 @@ using aidl::android::frameworks::stats::IStats; using android::base::GetProperty; +using android::base::Join; +using android::base::Tokenize; using android::base::Trim; using android::hardware::google::pixel::getStatsService; using android::hardware::google::pixel::PixelAtoms::VendorUsbPortOverheat; @@ -55,11 +58,14 @@ namespace hardware { namespace usb { // Set by the signal handler to destroy the thread volatile bool destroyThread; +volatile bool destroyDisplayPortThread; string enabledPath; constexpr char kHsi2cPath[] = "/sys/devices/platform/10cb0000.hsi2c"; constexpr char kI2CPath[] = "/sys/devices/platform/10cb0000.hsi2c/i2c-"; constexpr char kContaminantDetectionPath[] = "-0025/contaminant_detection"; +constexpr char kDisplayPortDrmPath[] = "/sys/devices/platform/110f0000.drmdp/drm-displayport/"; +constexpr char kDisplayPortUsbPath[] = "/sys/class/typec/port0-partner/"; constexpr char kStatusPath[] = "-0025/contaminant_detection_status"; constexpr char kSinkLimitEnable[] = "-0025/usb_limit_sink_enable"; constexpr char kSourceLimitEnable[] = "-0025/usb_limit_source_enable"; @@ -395,7 +401,8 @@ Usb::Usb() ThrottlingSeverity::NONE), ZoneInfo(TemperatureType::UNKNOWN, kThermalZoneForTempReadSecondary2, ThrottlingSeverity::NONE)}, kSamplingIntervalSec), - mUsbDataEnabled(true) { + mUsbDataEnabled(true), + mDisplayPortLock(PTHREAD_MUTEX_INITIALIZER) { pthread_condattr_t attr; if (pthread_condattr_init(&attr)) { ALOGE("pthread_condattr_init failed: %s", strerror(errno)); @@ -413,6 +420,11 @@ Usb::Usb() ALOGE("pthread_condattr_destroy failed: %s", strerror(errno)); abort(); } + mDisplayPortShutdown = eventfd(0, EFD_NONBLOCK); + if (mDisplayPortShutdown == -1) { + ALOGE("mDisplayPortShutdown eventfd failed: %s", strerror(errno)); + abort(); + } } ScopedAStatus Usb::switchRole(const string& in_portName, const PortRole& in_role, @@ -850,10 +862,22 @@ struct data { ::aidl::android::hardware::usb::Usb *usb; }; +enum UeventType { UNKNOWN, BIND, CHANGE }; + +enum UeventType matchUeventType(char* str) { + if (!strncmp(str, "ACTION=bind", strlen("ACTION=bind"))) { + return UeventType::BIND; + } else if (!strncmp(str, "ACTION=change", strlen("ACTION=change"))) { + return UeventType::CHANGE; + } + return UeventType::UNKNOWN; +} + static void uevent_event(uint32_t /*epevents*/, struct data *payload) { char msg[UEVENT_MSG_LEN + 2]; char *cp; int n; + enum UeventType uevent_type = UeventType::UNKNOWN; n = uevent_kernel_multicast_recv(payload->uevent_fd, msg, UEVENT_MSG_LEN); if (n <= 0) @@ -897,10 +921,25 @@ static void uevent_event(uint32_t /*epevents*/, struct data *payload) { } pthread_mutex_unlock(&payload->usb->mRoleSwitchLock); } - break; + if (!!strncmp(cp, "DEVTYPE=typec_alternate_mode", strlen("DEVTYPE=typec_alternate_mode"))) { + break; + } } else if (!strncmp(cp, kOverheatStatsDev, strlen(kOverheatStatsDev))) { ALOGV("Overheat Cooling device suez update"); report_overheat_event(payload->usb); + } else if (!(strncmp(cp, "ACTION=", strlen("ACTION=")))) { + uevent_type = matchUeventType(cp); + } else if (!strncmp(cp, "DRIVER=typec_displayport", strlen("DRIVER=typec_displayport"))) { + if (uevent_type == UeventType::BIND) { + pthread_mutex_lock(&payload->usb->mDisplayPortLock); + payload->usb->setupDisplayPortPoll(); + pthread_mutex_unlock(&payload->usb->mDisplayPortLock); + } else if (uevent_type == UeventType::CHANGE) { + pthread_mutex_lock(&payload->usb->mDisplayPortLock); + payload->usb->shutdownDisplayPortPoll(); + pthread_mutex_unlock(&payload->usb->mDisplayPortLock); + } + break; } /* advance to after the next \0 */ while (*cp++) { @@ -1016,6 +1055,304 @@ ScopedAStatus Usb::setCallback(const shared_ptr& in_callback) { return ScopedAStatus::ok(); } +Status Usb::getDisplayPortUsbPathHelper(string *path) { + DIR *dp; + Status result = Status::ERROR; + + dp = opendir(kDisplayPortUsbPath); + if (dp != NULL) { + struct dirent *ep; + // Iterate through all alt mode directories to find displayport driver + while ((ep = readdir(dp))) { + if (ep->d_type == DT_DIR) { + DIR *displayPortDp; + string portPartnerPath = string(kDisplayPortUsbPath) + string(ep->d_name) + + "/displayport/"; + displayPortDp = opendir(portPartnerPath.c_str()); + if (displayPortDp != NULL) { + *path = portPartnerPath; + closedir(displayPortDp); + result = Status::SUCCESS; + break; + } + } + } + closedir(dp); + } + return result; +} + +Status Usb::writeDisplayPortAttributeOverride(string attribute, string value) { + string attrDrmPath; + + // Get Drm Path + attrDrmPath = string(kDisplayPortDrmPath) + attribute; + + // Write to drm + if(!WriteStringToFile(value, attrDrmPath)) { + ALOGE("usbdp: Failed to write attribute %s to drm: %s", attribute.c_str(), value.c_str()); + return Status::ERROR; + } + ALOGI("usbdp: Successfully wrote attribute %s: %s to drm.", attribute.c_str(), value.c_str()); + return Status::SUCCESS; +} + +Status Usb::writeDisplayPortAttribute(string attribute, string usb_path) { + string attrUsb, attrDrm, attrDrmPath; + + // Get Drm Path + attrDrmPath = string(kDisplayPortDrmPath) + attribute; + + // Read Attribute + if(!ReadFileToString(usb_path, &attrUsb)) { + ALOGE("usbdp: Failed to open or read Type-C attribute %s", attribute.c_str()); + return Status::ERROR; + } + + // Separate Logic for hpd and pin_assignment + if (!strncmp(attribute.c_str(), "hpd", strlen("hpd"))) { + if (!strncmp(attrUsb.c_str(), "0", strlen("0"))) { + // Read DRM attribute to compare + if(!ReadFileToString(attrDrmPath, &attrDrm)) { + ALOGE("usbdp: Failed to open or read hpd from drm"); + return Status::ERROR; + } + if (!strncmp(attrDrm.c_str(), "0", strlen("0"))) { + ALOGI("usbdp: Skipping hpd write when drm and usb both equal 0"); + return Status::SUCCESS; + } + } + } else if (!strncmp(attribute.c_str(), "pin_assignment", strlen("pin_assignment"))) { + size_t pos = attrUsb.find("["); + if (pos != string::npos) { + ALOGI("usbdp: Modifying Pin Config from %s", attrUsb.c_str()); + attrUsb = attrUsb.substr(pos+1, 1); + } else { + // Don't write anything + ALOGI("usbdp: Pin config not yet chosen, nothing written."); + return Status::SUCCESS; + } + } + + // Write to drm + if(!WriteStringToFile(attrUsb, attrDrmPath)) { + ALOGE("usbdp: Failed to write attribute %s to drm: %s", attribute.c_str(), attrUsb.c_str()); + return Status::ERROR; + } + ALOGI("usbdp: Successfully wrote attribute %s: %s to drm.", attribute.c_str(), attrUsb.c_str()); + return Status::SUCCESS; +} + +bool Usb::determineDisplayPortRetry(string linkPath, string hpdPath) { + string linkStatus, hpd; + + if(ReadFileToString(linkPath, &linkStatus) && ReadFileToString(hpdPath, &hpd)) { + if (!strncmp(linkStatus.c_str(), "2", strlen("2")) && + !strncmp(hpd.c_str(), "1", strlen("1"))) { + return true; + } + } + + return false; +} + +static int displayPortPollOpenFileHelper(const char *file, int flags) { + int fd = open(file, flags); + if (fd == -1) { + ALOGE("usbdp: open at %s failed; errno=%d", file, errno); + } + return fd; +} + +void *displayPortPollWork(void *param) { + int epoll_fd; + struct epoll_event ev_hpd, ev_pin, ev_orientation, ev_eventfd, ev_link; + int nevents = 0; + int numRetries = 0; + int hpd_fd, pin_fd, orientation_fd, link_fd; + int file_flags = O_RDONLY; + int epoll_flags; + bool orientationSet = false; + bool pinSet = false; + string displayPortUsbPath; + string hpdPath, pinAssignmentPath, orientationPath, linkPath; + ::aidl::android::hardware::usb::Usb *usb = (::aidl::android::hardware::usb::Usb *)param; + + if (usb->getDisplayPortUsbPathHelper(&displayPortUsbPath) == Status::ERROR) { + ALOGE("usbdp: could not locate usb displayport directory"); + goto usb_path_error; + } + ALOGI("usbdp: displayport usb path located at %s", displayPortUsbPath.c_str()); + hpdPath = displayPortUsbPath + "hpd"; + pinAssignmentPath = displayPortUsbPath + "pin_assignment"; + orientationPath = "/sys/class/typec/port0/orientation"; + linkPath = string(kDisplayPortDrmPath) + "link_status"; + + epoll_fd = epoll_create(64); + if (epoll_fd == -1) { + ALOGE("usbdp: epoll_create failed; errno=%d", errno); + goto epoll_fd_error; + } + + if ((hpd_fd = displayPortPollOpenFileHelper(hpdPath.c_str(), file_flags)) == -1){ + goto hpd_fd_error; + } + if ((pin_fd = displayPortPollOpenFileHelper(pinAssignmentPath.c_str(), file_flags)) == -1){ + goto pin_fd_error; + } + if ((orientation_fd = displayPortPollOpenFileHelper(orientationPath.c_str(), file_flags)) + == -1){ + goto orientation_fd_error; + } + if ((link_fd = displayPortPollOpenFileHelper(linkPath.c_str(), file_flags)) == -1){ + goto link_fd_error; + } + + // Set epoll_event events and flags + epoll_flags = EPOLLIN | EPOLLET; + ev_hpd.events = epoll_flags; + ev_pin.events = epoll_flags; + ev_orientation.events = epoll_flags; + ev_eventfd.events = epoll_flags; + ev_link.events = epoll_flags; + ev_hpd.data.fd = hpd_fd; + ev_pin.data.fd = pin_fd; + ev_orientation.data.fd = orientation_fd; + ev_eventfd.data.fd = usb->mDisplayPortShutdown; + ev_link.data.fd = link_fd; + + if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, hpd_fd, &ev_hpd) == -1) { + ALOGE("usbdp: epoll_ctl failed to add hpd; errno=%d", errno); + goto error; + } + if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, pin_fd, &ev_pin) == -1) { + ALOGE("usbdp: epoll_ctl failed to add pin; errno=%d", errno); + goto error; + } + if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, orientation_fd, &ev_orientation) == -1) { + ALOGE("usbdp: epoll_ctl failed to add orientation; errno=%d", errno); + goto error; + } + if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, link_fd, &ev_link) == -1) { + ALOGE("usbdp: epoll_ctl failed to add link status; errno=%d", errno); + goto error; + } + if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, usb->mDisplayPortShutdown, &ev_eventfd) == -1) { + ALOGE("usbdp: epoll_ctl failed to add orientation; errno=%d", errno); + goto error; + } + + while (!destroyDisplayPortThread) { + struct epoll_event events[64]; + + nevents = epoll_wait(epoll_fd, events, 64, -1); + if (nevents == -1) { + if (errno == EINTR) + continue; + ALOGE("usbdp: epoll_wait failed; errno=%d", errno); + break; + } + + for (int n = 0; n < nevents; n++) { + if (events[n].data.fd == hpd_fd) { + if (!pinSet || !orientationSet) { + ALOGW("usbdp: HPD may be set before pin_assignment and orientation"); + } + usb->writeDisplayPortAttribute("hpd", hpdPath); + } else if (events[n].data.fd == pin_fd) { + usb->writeDisplayPortAttribute("pin_assignment", pinAssignmentPath); + pinSet = true; + } else if (events[n].data.fd == orientation_fd) { + usb->writeDisplayPortAttribute("orientation", orientationPath); + orientationSet = true; + } else if (events[n].data.fd == link_fd) { + if (usb->determineDisplayPortRetry(linkPath, hpdPath) && numRetries < 3) { + ALOGW("usbdp: Link Training Failed, rewriting hpd to trigger retry."); + usb->writeDisplayPortAttributeOverride("hpd", "1"); + numRetries++; + } + } else if (events[n].data.fd == usb->mDisplayPortShutdown) { + uint64_t flag = 0; + if (!read(usb->mDisplayPortShutdown, &flag, sizeof(flag))) { + if (errno == EAGAIN) + continue; + ALOGI("usbdp: Shutdown eventfd read error"); + goto error; + } + if (flag == DISPLAYPORT_SHUTDOWN_SET) { + ALOGI("usbdp: Shutdown eventfd triggered"); + destroyDisplayPortThread = true; + break; + } + } + } + } + +error: + close(link_fd); +link_fd_error: + close(orientation_fd); +orientation_fd_error: + close(pin_fd); +pin_fd_error: + close(hpd_fd); +hpd_fd_error: + epoll_ctl(epoll_fd, EPOLL_CTL_DEL, usb->mDisplayPortShutdown, &ev_eventfd); + close(epoll_fd); +epoll_fd_error: +usb_path_error: + ALOGI("usbdp: Exiting worker thread"); + return NULL; +} + +void Usb::setupDisplayPortPoll() { + uint64_t flag = DISPLAYPORT_SHUTDOWN_CLEAR; + + write(mDisplayPortShutdown, &flag, sizeof(flag)); + destroyDisplayPortThread = false; + + /* + * Create a background thread to poll DisplayPort system files + */ + if (pthread_create(&mDisplayPortPoll, NULL, displayPortPollWork, this)) { + ALOGE("usbdp: failed to create displayport poll thread %d", errno); + } + ALOGI("usbdp: successfully started DisplayPort poll thread"); + return; +} + +void Usb::shutdownDisplayPortPollHelper() { + pthread_join(mDisplayPortPoll, NULL); +} + +void *shutdownDisplayPortPollWork(void *param) { + ::aidl::android::hardware::usb::Usb *usb = (::aidl::android::hardware::usb::Usb *)param; + + usb->shutdownDisplayPortPollHelper(); + ALOGI("usbdp: DisplayPort Thread Shutdown"); + return NULL; +} + +void Usb::shutdownDisplayPortPoll() { + uint64_t flag = DISPLAYPORT_SHUTDOWN_SET; + string displayPortUsbPath; + + // Determine if should shutdown thread + // getDisplayPortUsbPathHelper locates a DisplayPort directory, no need to double check + // directory. + if (getDisplayPortUsbPathHelper(&displayPortUsbPath) == Status::SUCCESS) { + return; + } + + // Shutdown thread, make sure to rewrite hpd because file no longer exists. + write(mDisplayPortShutdown, &flag, sizeof(flag)); + if (pthread_create(&mDisplayPortShutdownHelper, NULL, shutdownDisplayPortPollWork, this)) { + ALOGE("pthread creation failed %d", errno); + } + writeDisplayPortAttributeOverride("hpd", "0"); + destroyDisplayPortThread = false; +} + } // namespace usb } // namespace hardware } // namespace android diff --git a/usb/usb/Usb.h b/usb/usb/Usb.h index d8d6d001..8a1a663e 100644 --- a/usb/usb/Usb.h +++ b/usb/usb/Usb.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #define UEVENT_MSG_LEN 2048 @@ -38,6 +39,7 @@ using ::aidl::android::hardware::usb::IUsbCallback; using ::aidl::android::hardware::usb::PortRole; using ::android::base::ReadFileToString; using ::android::base::WriteStringToFile; +using ::android::base::unique_fd; using ::android::hardware::google::pixel::usb::UsbOverheatEvent; using ::android::hardware::google::pixel::usb::ZoneInfo; using ::android::hardware::thermal::V2_0::TemperatureType; @@ -46,6 +48,7 @@ using ::android::sp; using ::ndk::ScopedAStatus; using ::std::shared_ptr; using ::std::string; +using ::std::thread; constexpr char kGadgetName[] = "11210000.dwc3"; #define NEW_UDC_PATH "/sys/devices/platform/11210000.usb/" @@ -54,6 +57,9 @@ constexpr char kGadgetName[] = "11210000.dwc3"; #define VBUS_PATH NEW_UDC_PATH "dwc3_exynos_otg_b_sess" #define USB_DATA_PATH NEW_UDC_PATH "usb_data_enabled" +#define DISPLAYPORT_SHUTDOWN_CLEAR 0 +#define DISPLAYPORT_SHUTDOWN_SET 1 + struct Usb : public BnUsb { Usb(); @@ -71,6 +77,14 @@ struct Usb : public BnUsb { int64_t in_transactionId) override; ScopedAStatus resetUsbPort(const string& in_portName, int64_t in_transactionId) override; + Status getDisplayPortUsbPathHelper(string *path); + Status writeDisplayPortAttributeOverride(string attribute, string value); + Status writeDisplayPortAttribute(string attribute, string usb_path); + bool determineDisplayPortRetry(string linkPath, string hpdPath); + void setupDisplayPortPoll(); + void shutdownDisplayPortPollHelper(); + void shutdownDisplayPortPoll(); + std::shared_ptr<::aidl::android::hardware::usb::IUsbCallback> mCallback; // Protects mCallback variable pthread_mutex_t mLock; @@ -89,8 +103,16 @@ struct Usb : public BnUsb { float mPluggedTemperatureCelsius; // Usb Data status bool mUsbDataEnabled; + + // Protects writeDisplayPortToExynos(), setupDisplayPortPoll(), and + // shutdownDisplayPortPoll() + pthread_mutex_t mDisplayPortLock; + // eventfd to signal DisplayPort thread + int mDisplayPortShutdown; private: pthread_t mPoll; + pthread_t mDisplayPortPoll; + pthread_t mDisplayPortShutdownHelper; }; } // namespace usb diff --git a/usb/usb/android.hardware.usb-service.rc b/usb/usb/android.hardware.usb-service.rc index 84c8d785..d34eca80 100644 --- a/usb/usb/android.hardware.usb-service.rc +++ b/usb/usb/android.hardware.usb-service.rc @@ -68,6 +68,10 @@ on post-fs chown root system /sys/devices/platform/10cb0000.hsi2c/i2c-7/7-0025/usb_limit_source_enable chown root system /sys/devices/platform/10cb0000.hsi2c/i2c-8/8-0025/usb_limit_source_enable chown root system /sys/devices/platform/10cb0000.hsi2c/i2c-9/9-0025/usb_limit_source_enable + chown root system /sys/devices/platform/110f0000.drmdp/drm-displayport/hpd + 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/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 @@ -138,4 +142,8 @@ on post-fs chmod 664 /sys/devices/platform/10cb0000.hsi2c/i2c-7/7-0025/usb_limit_source_enable chmod 664 /sys/devices/platform/10cb0000.hsi2c/i2c-8/8-0025/usb_limit_source_enable chmod 664 /sys/devices/platform/10cb0000.hsi2c/i2c-9/9-0025/usb_limit_source_enable + chmod 664 /sys/devices/platform/110f0000.drmdp/drm-displayport/hpd + 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/google,pogo/enable_usb diff --git a/usb/usb/android.hardware.usb-service.xml b/usb/usb/android.hardware.usb-service.xml index 60881948..c3f07f52 100644 --- a/usb/usb/android.hardware.usb-service.xml +++ b/usb/usb/android.hardware.usb-service.xml @@ -1,7 +1,7 @@ android.hardware.usb - 1 + 2 IUsb default diff --git a/vendor.prop b/vendor.prop new file mode 100644 index 00000000..586a168a --- /dev/null +++ b/vendor.prop @@ -0,0 +1 @@ +ro.soc.model=Tensor G3 diff --git a/widevine/device.mk b/widevine/device.mk index c4872939..f91de716 100644 --- a/widevine/device.mk +++ b/widevine/device.mk @@ -1,4 +1,6 @@ PRODUCT_PACKAGES += \ - android.hardware.drm-service.clearkey \ - android.hardware.drm-service.widevine + android.hardware.drm-service.clearkey + +-include vendor/widevine/libwvdrmengine/apex/device/device.mk + BOARD_VENDOR_SEPOLICY_DIRS += device/google/zuma-sepolicy/widevine