From d934151ef36808b1cf926b9bc123092e1e2c3b71 Mon Sep 17 00:00:00 2001 From: daniml3 Date: Sun, 22 Aug 2021 16:34:00 +0200 Subject: [PATCH] sweet: override the SetRefreshRate HWC builtin display function * This function causes the refresh rate to change randomly, and produces flickering on the display * Override the original function by renaming the symbol so linker uses the symbol from the shim instead of the original library's symbol Signed-off-by: daniml3 Change-Id: I2fa6b3f834df79c32d22f5a057da2108cc9cacab --- device.mk | 3 +++ display/Android.bp | 8 ++++++++ display/Android.mk | 24 ++++++++++++++++++++++++ display/display_builtin.cpp | 3 +++ 4 files changed, 38 insertions(+) create mode 100644 display/Android.bp create mode 100644 display/Android.mk create mode 100644 display/display_builtin.cpp diff --git a/device.mk b/device.mk index 28e0fe9..2f6b5f7 100644 --- a/device.mk +++ b/device.mk @@ -39,6 +39,9 @@ PRODUCT_PACKAGES += \ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/configs/display/qdcm_calib_data_xiaomi_k6_38_0c_0a_fhd_dsc_video_dsi_panel.xml:$(TARGET_COPY_OUT_VENDOR)/etc/qdcm_calib_data_xiaomi_k6_38_0c_0a_fhd_dsc_video_dsi_panel.xml +PRODUCT_PACKAGES += \ + libsdmcore-shim + # Fstab PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/rootdir/etc/fstab.qcom:$(TARGET_COPY_OUT_RAMDISK)/fstab.qcom \ diff --git a/display/Android.bp b/display/Android.bp new file mode 100644 index 0000000..4362db8 --- /dev/null +++ b/display/Android.bp @@ -0,0 +1,8 @@ +cc_library_shared { + name: "libsdmcore-shim", + srcs: [ + "display_builtin.cpp" + ], + required: ["libsdmcore-patch"], + vendor: true, +} diff --git a/display/Android.mk b/display/Android.mk new file mode 100644 index 0000000..34f67dd --- /dev/null +++ b/display/Android.mk @@ -0,0 +1,24 @@ +LOCAL_PATH := $(call my-dir) + +HWC := hwcomposer.$(TARGET_BOARD_PLATFORM) +LIBSDMCORE := $(TARGET_OUT_VENDOR)/lib64/libsdmcore.so +HWCOMPOSER := $(TARGET_OUT_VENDOR)/lib64/hw/$(HWC).so + +ORIGINAL_SYMBOL := _ZN3sdm14DisplayBuiltIn14SetRefreshRateEjb +CUSTOM_SYMBOL := _ZN3sdm14DisplayBuiltIn14SetRefreshCustEjb + +include $(CLEAR_VARS) +LOCAL_MODULE := libsdmcore-patch +LOCAL_PREBUILT_MODULE_FILE := /dev/null +LOCAL_MODULE_CLASS := ETC +LOCAL_VENDOR_MODULE := true +LOCAL_REQUIRED_MODULES := $(HWC) libsdmcore + +LOCAL_POST_INSTALL_CMD := \ + cp $(PRODUCT_OUT)/symbols/vendor/lib64/libsdmcore.so $(LIBSDMCORE) && \ + cp $(PRODUCT_OUT)/symbols/vendor/lib64/hw/$(HWC).so $(HWCOMPOSER) && \ + sed -i s/$(ORIGINAL_SYMBOL)/$(CUSTOM_SYMBOL)/g $(LIBSDMCORE) && \ + sed -i s/libdisplaydebug/libsdmcore-shim/g $(HWCOMPOSER) && \ + rm $(TARGET_OUT_VENDOR)/etc/$(LOCAL_MODULE) + +include $(BUILD_PREBUILT) diff --git a/display/display_builtin.cpp b/display/display_builtin.cpp new file mode 100644 index 0000000..9588293 --- /dev/null +++ b/display/display_builtin.cpp @@ -0,0 +1,3 @@ +#include + +extern "C" void _ZN3sdm14DisplayBuiltIn14SetRefreshCustEjb(uint32_t, bool) {}