From df80f43c0f2fd930385893c1b3f236c1a2627647 Mon Sep 17 00:00:00 2001 From: Ankur Bakshi Date: Fri, 15 Dec 2023 00:54:54 +0000 Subject: [PATCH 01/37] Update felix SVN to 38 Bug: 313797924 Change-Id: I27e8700b3e44f927aee6830cd5206280694ed5d8 --- device-felix.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-felix.mk b/device-felix.mk index b1a0caa..c4f9544 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -211,7 +211,7 @@ PRODUCT_SOONG_NAMESPACES += \ # Increment the SVN for any official public releases PRODUCT_VENDOR_PROPERTIES += \ - ro.vendor.build.svn=37 + ro.vendor.build.svn=38 # Vibrator HAL PRODUCT_VENDOR_PROPERTIES +=\ From 421a372bfd4d29f656fba2b354b9c394dde9df59 Mon Sep 17 00:00:00 2001 From: Ankur Bakshi Date: Fri, 15 Dec 2023 00:55:40 +0000 Subject: [PATCH 02/37] Update felix SVN to 39 Bug: 313797924 Change-Id: If5f601f238645b6c6589053a27bd4248d83f26e1 --- device-felix.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-felix.mk b/device-felix.mk index c4f9544..d1b3f39 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -211,7 +211,7 @@ PRODUCT_SOONG_NAMESPACES += \ # Increment the SVN for any official public releases PRODUCT_VENDOR_PROPERTIES += \ - ro.vendor.build.svn=38 + ro.vendor.build.svn=39 # Vibrator HAL PRODUCT_VENDOR_PROPERTIES +=\ From 3d00dd5ffa49179fe9c4ad0a2356a8dbedadf434 Mon Sep 17 00:00:00 2001 From: Shawn Lin Date: Thu, 21 Dec 2023 12:58:21 +0000 Subject: [PATCH 03/37] Enable hide cutout emulations Bug: 317143921 Test: make Flag: NONE Change-Id: I9f263bcdd33bfd61ba0241c1e7c4a90ccf4a8b1d --- device-felix.mk | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/device-felix.mk b/device-felix.mk index d1b3f39..fdf8bad 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -395,3 +395,12 @@ PRODUCT_VENDOR_PROPERTIES += \ PRODUCT_PRODUCT_PROPERTIES += \ ro.quick_start.oem_id=00e0 \ ro.quick_start.device_id=felix + +# Set support hide display cutout feature +PRODUCT_PRODUCT_PROPERTIES += \ + ro.support_hide_display_cutout=true + +PRODUCT_PACKAGES += \ + NoCutoutOverlay \ + AvoidAppsInCutoutOverlay + From f06a83f64da70f95781718b036a51c833d609d3a Mon Sep 17 00:00:00 2001 From: Isaac Chiou Date: Thu, 21 Dec 2023 17:15:59 +0800 Subject: [PATCH 04/37] wifi: Enable fast scan Enable fast scan and set the channel cache number to 10 Bug: 317012208 Test: Manual Change-Id: Iee3ae9bc63eacf4f19dcde2dee8e1feae72014cd --- rro_overlays/WifiOverlay/res/values/config.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rro_overlays/WifiOverlay/res/values/config.xml b/rro_overlays/WifiOverlay/res/values/config.xml index 94f377b..8079614 100644 --- a/rro_overlays/WifiOverlay/res/values/config.xml +++ b/rro_overlays/WifiOverlay/res/values/config.xml @@ -167,4 +167,12 @@ regulatory approval (for example, FCC pre-approval is required according to "594280 D01 Software Configuration Control v02r01").--> true + + + true + + + 3 + From 081b412c77f96efa7f68860de854cef208c1a7d0 Mon Sep 17 00:00:00 2001 From: Carter Hsu Date: Tue, 26 Dec 2023 18:59:31 +0800 Subject: [PATCH 05/37] audio: support incall capture dl/ul concurrent recording Bug: 317726514 Test: Verified by test build Change-Id: I35ad2c38eacbe0b7b7fe468bd80534a44342bc3c Signed-off-by: Carter Hsu --- audio/felix/config/audio_policy_configuration.xml | 2 +- .../config/audio_policy_configuration_a2dp_offload_disabled.xml | 2 +- .../config/audio_policy_configuration_bluetooth_legacy_hal.xml | 2 +- .../config/audio_policy_configuration_le_offload_disabled.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/audio/felix/config/audio_policy_configuration.xml b/audio/felix/config/audio_policy_configuration.xml index 1b44390..94e9d3f 100644 --- a/audio/felix/config/audio_policy_configuration.xml +++ b/audio/felix/config/audio_policy_configuration.xml @@ -93,7 +93,7 @@ samplingRates="8000 11025 12000 16000 22050 24000 32000 44100 48000" channelMasks="AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO"/> - + diff --git a/audio/felix/config/audio_policy_configuration_a2dp_offload_disabled.xml b/audio/felix/config/audio_policy_configuration_a2dp_offload_disabled.xml index eb8560c..da6c7a7 100644 --- a/audio/felix/config/audio_policy_configuration_a2dp_offload_disabled.xml +++ b/audio/felix/config/audio_policy_configuration_a2dp_offload_disabled.xml @@ -92,7 +92,7 @@ samplingRates="8000 11025 12000 16000 22050 24000 32000 44100 48000" channelMasks="AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO"/> - + diff --git a/audio/felix/config/audio_policy_configuration_bluetooth_legacy_hal.xml b/audio/felix/config/audio_policy_configuration_bluetooth_legacy_hal.xml index 1863d5a..416d4ab 100644 --- a/audio/felix/config/audio_policy_configuration_bluetooth_legacy_hal.xml +++ b/audio/felix/config/audio_policy_configuration_bluetooth_legacy_hal.xml @@ -88,7 +88,7 @@ samplingRates="8000 11025 12000 16000 22050 24000 32000 44100 48000" channelMasks="AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO"/> - + diff --git a/audio/felix/config/audio_policy_configuration_le_offload_disabled.xml b/audio/felix/config/audio_policy_configuration_le_offload_disabled.xml index bf54670..0745b2f 100644 --- a/audio/felix/config/audio_policy_configuration_le_offload_disabled.xml +++ b/audio/felix/config/audio_policy_configuration_le_offload_disabled.xml @@ -93,7 +93,7 @@ samplingRates="8000 11025 12000 16000 22050 24000 32000 44100 48000" channelMasks="AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO"/> - + From 0df253660aba11dde005995ac889c728404da9c2 Mon Sep 17 00:00:00 2001 From: Aaron Ding Date: Wed, 27 Dec 2023 00:50:37 +0800 Subject: [PATCH 06/37] felix: control the kernel by release configuration Bug: 317784824 Change-Id: I4f7fdc1ba449c270f7379d0a43b0143963b47685 Signed-off-by: Aaron Ding --- device-felix.mk | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/device-felix.mk b/device-felix.mk index fdf8bad..c04c02a 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -21,6 +21,15 @@ TARGET_KERNEL_DIR ?= device/google/felix-kernel TARGET_BOARD_KERNEL_HEADERS := device/google/felix-kernel/kernel-headers TARGET_RECOVERY_DEFAULT_ROTATION := ROTATION_RIGHT +ifdef RELEASE_GOOGLE_FELIX_KERNEL_VERSION +TARGET_LINUX_KERNEL_VERSION := $(RELEASE_GOOGLE_FELIX_KERNEL_VERSION) +endif + +ifdef RELEASE_GOOGLE_FELIX_KERNEL_DIR +TARGET_KERNEL_DIR := $(RELEASE_GOOGLE_FELIX_KERNEL_DIR) +TARGET_BOARD_KERNEL_HEADERS := $(RELEASE_GOOGLE_FELIX_KERNEL_DIR)/kernel-headers +endif + $(call inherit-product-if-exists, vendor/google_devices/felix/prebuilts/device-vendor-felix.mk) $(call inherit-product-if-exists, vendor/google_devices/gs201/prebuilts/device-vendor.mk) $(call inherit-product-if-exists, vendor/google_devices/gs201/proprietary/device-vendor.mk) From 97ba43cc4516db770fcf26e6e8e7c8fcc79abd23 Mon Sep 17 00:00:00 2001 From: Xin Li Date: Thu, 4 Jan 2024 08:59:25 -0800 Subject: [PATCH 07/37] Remove PixelQualifiedNetworksService for AOSP builds. Bug: 309712809 Test: https://android-build.corp.google.com/builds/abtd/run/L26400030001089366 Change-Id: Idbf5efc7da759ef264cbe5829519a94171a0401f --- self-extractors/extract-lists.txt | 1 - .../google_devices/staging/Android.mk.template | 16 ---------------- .../google_devices/staging/device-partial.mk | 1 - 3 files changed, 18 deletions(-) diff --git a/self-extractors/extract-lists.txt b/self-extractors/extract-lists.txt index 9fc0800..c783a92 100644 --- a/self-extractors/extract-lists.txt +++ b/self-extractors/extract-lists.txt @@ -11,7 +11,6 @@ system_ext/lib64/libmediaadaptor.so \ system_ext/priv-app/ShannonRcs/ShannonRcs.apk \ system_ext/priv-app/ShannonIms/ShannonIms.apk \ - system_ext/priv-app/PixelQualifiedNetworksService/PixelQualifiedNetworksService.apk \ system_ext/priv-app/UwbVendorService/UwbVendorService.apk \ " ;; diff --git a/self-extractors/google_devices/staging/Android.mk.template b/self-extractors/google_devices/staging/Android.mk.template index 01369bf..f1eb6b1 100644 --- a/self-extractors/google_devices/staging/Android.mk.template +++ b/self-extractors/google_devices/staging/Android.mk.template @@ -22,22 +22,6 @@ ifneq ($(filter felix,$(TARGET_DEVICE)),) endif ifneq ($(filter felix,$(TARGET_DEVICE)),) -include $(CLEAR_VARS) -LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX) -LOCAL_MODULE := PixelQualifiedNetworksService -LOCAL_MODULE_TAGS := optional -LOCAL_BUILT_MODULE_STEM := package.apk -LOCAL_SYSTEM_EXT_MODULE := true -LOCAL_PRIVILEGED_MODULE := true -LOCAL_MODULE_OWNER := samsung -LOCAL_MODULE_CLASS := APPS -LOCAL_SRC_FILES := $(LOCAL_MODULE).apk -LOCAL_CERTIFICATE := platform -LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 -LOCAL_LICENSE_CONDITIONS := notice -LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../COPYRIGHT $(LOCAL_PATH)/../LICENSE -include $(BUILD_PREBUILT) - include $(CLEAR_VARS) LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX) LOCAL_MODULE := ShannonIms diff --git a/self-extractors/google_devices/staging/device-partial.mk b/self-extractors/google_devices/staging/device-partial.mk index 9c4717f..42c43e7 100644 --- a/self-extractors/google_devices/staging/device-partial.mk +++ b/self-extractors/google_devices/staging/device-partial.mk @@ -17,7 +17,6 @@ PRODUCT_SOONG_NAMESPACES += \ # AOSP packages required by the blobs PRODUCT_PACKAGES := \ - PixelQualifiedNetworksService \ ShannonIms \ ShannonRcs \ UwbVendorService \ From 31ce8317f1ae6f6c9638860b3c67cefe01a115fc Mon Sep 17 00:00:00 2001 From: Ankur Bakshi Date: Fri, 15 Dec 2023 00:54:54 +0000 Subject: [PATCH 08/37] Update felix SVN to 38 Bug: 313797924 Change-Id: I27e8700b3e44f927aee6830cd5206280694ed5d8 (cherry picked from commit df80f43c0f2fd930385893c1b3f236c1a2627647) Merged-In: I27e8700b3e44f927aee6830cd5206280694ed5d8 --- device-felix.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-felix.mk b/device-felix.mk index 4ea3595..6781f2c 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -205,7 +205,7 @@ PRODUCT_SOONG_NAMESPACES += \ # Increment the SVN for any official public releases PRODUCT_VENDOR_PROPERTIES += \ - ro.vendor.build.svn=37 + ro.vendor.build.svn=38 # Vibrator HAL PRODUCT_VENDOR_PROPERTIES +=\ From 51968120ce91bdd44805fc8ead791f936ba6bdbc Mon Sep 17 00:00:00 2001 From: Cheng Chang Date: Tue, 9 Jan 2024 05:57:55 +0000 Subject: [PATCH 09/37] gps: Update the aiding interval Bug: 309119807 Test: Verification at b/309119807#comment44 Change-Id: I7dfc91c353a375de9e3490f839ece9b11646181c --- location/gps.xml.f10 | 4 +++- location/gps_user.xml.f10 | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/location/gps.xml.f10 b/location/gps.xml.f10 index e2cd884..a47afb2 100644 --- a/location/gps.xml.f10 +++ b/location/gps.xml.f10 @@ -60,7 +60,7 @@ CpLppeUseAgnssLocForEmptyDbh="true" CpLppHighAccuracyShapeMode="1" ReAidingOnHotStart="false" - ReAidingIntervalSec="1200" + ReAidingIntervalSec="3600" RuntimeSwLteFilterEnable="true" PpsDevice="/sys/class/pps/pps0/assert_elapsed" SensorsMask="0x244" @@ -93,6 +93,8 @@ MinGpsWeekNumber="2216" OnChipAccMask="50" EnableB1C="false" + + RTICacheTimeoutSec="3600" /> Date: Fri, 15 Dec 2023 00:55:40 +0000 Subject: [PATCH 10/37] Update felix SVN to 39 Bug: 313797924 Change-Id: If5f601f238645b6c6589053a27bd4248d83f26e1 (cherry picked from commit 421a372bfd4d29f656fba2b354b9c394dde9df59) Merged-In: If5f601f238645b6c6589053a27bd4248d83f26e1 --- device-felix.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-felix.mk b/device-felix.mk index 6781f2c..a9e2f70 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -205,7 +205,7 @@ PRODUCT_SOONG_NAMESPACES += \ # Increment the SVN for any official public releases PRODUCT_VENDOR_PROPERTIES += \ - ro.vendor.build.svn=38 + ro.vendor.build.svn=39 # Vibrator HAL PRODUCT_VENDOR_PROPERTIES +=\ From 69a33e25cb084a4026a13f4e66f18d488d9a04f7 Mon Sep 17 00:00:00 2001 From: Midas Chien Date: Wed, 17 Jan 2024 07:54:36 +0000 Subject: [PATCH 11/37] display: allow hwcomposer to access allow_wakeup_by_state_change Bug: 311495944 Test: check permission Change-Id: I42f2c0bff855f59a9fbd514e4309561867edfb84 --- conf/init.felix.rc | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/init.felix.rc b/conf/init.felix.rc index ed12a3c..47475e3 100644 --- a/conf/init.felix.rc +++ b/conf/init.felix.rc @@ -18,6 +18,7 @@ on fs chown system system /sys/class/backlight/panel1-backlight/dimming_on chown system system /sys/class/backlight/panel1-backlight/hbm_mode chown system system /sys/class/backlight/panel1-backlight/local_hbm_mode + chown system system /sys/class/backlight/panel1-backlight/allow_wakeup_by_state_change chown system system /sys/devices/platform/exynos-drm/secondary-panel/gamma chown system system /sys/devices/platform/exynos-drm/secondary-panel/min_vrefresh chown system system /sys/devices/platform/exynos-drm/secondary-panel/idle_delay_ms From 2056632361b90d10062284f9f2e0735b4a66a02b Mon Sep 17 00:00:00 2001 From: paulsu Date: Fri, 19 Jan 2024 06:35:12 +0000 Subject: [PATCH 12/37] Disable PMU at the start of camera launch Follow ag/20075269, ag/25261942 has caused regression in GCA launch time due to activation of PMU at the camera launch time, and capping the CPU frequency. This CL prevents PMU activation for as long as we are in powerhints or power-boosts related to camera launch (LAUNCH, CAMERA_LAUNCH, CAMERA_LAUNCH_EXTENDED). Bug: 321164832 Test: perfetto trace Change-Id: I54cb50259adc145847c96e75e2dd79f3eb3b3231 Signed-off-by: paulsu --- powerhint.json | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/powerhint.json b/powerhint.json index fbcc819..9e3a9cb 100644 --- a/powerhint.json +++ b/powerhint.json @@ -784,6 +784,17 @@ "Type": "DoHint", "Value": "LAUNCH_EXTEND" }, + { + "PowerHint": "LAUNCH", + "Type": "DoHint", + "Value": "LAUNCH_PMU" + }, + { + "PowerHint": "LAUNCH_PMU", + "Node": "PMU_POLL", + "Duration": 3000, + "Value": "0" + }, { "PowerHint": "LAUNCH_EXTEND", "Node": "CPUBigClusterMaxFreq", @@ -939,6 +950,12 @@ "Duration": 1000, "Value": "4-7" }, + { + "PowerHint": "CAMERA_LAUNCH", + "Node": "PMU_POLL", + "Duration": 1000, + "Value": "0" + }, { "PowerHint": "CAMERA_LAUNCH_EXTENDED", "Node": "CPUBigClusterMaxFreq", @@ -963,6 +980,12 @@ "Duration": 2000, "Value": "0" }, + { + "PowerHint": "CAMERA_LAUNCH_EXTENDED", + "Node": "PMU_POLL", + "Duration": 2000, + "Value": "0" + }, { "PowerHint": "CAMERA_THERMAL_CPU_THROTTLE", "Node": "CPUBigClusterMaxFreq", From e1ab132994795e6fb7d2cec0092a90c58b24cc07 Mon Sep 17 00:00:00 2001 From: Chris Paulo Date: Fri, 19 Jan 2024 14:29:57 -0800 Subject: [PATCH 13/37] vibrator/cs40l26: Update ff_effect duration Update the ff_effect duration to pass in 0 for compositions and RAM indices. This will allow firmware to take control of the playback duration, as well as apply SVC braking as required. This will also help avoid ending the effect early which can cause ringing. Bug: 317280093 Test: Verified perception and plotted acceleration Change-Id: I048b2bbda04af2a627aa8993aafc1f55ccf8fe13 Signed-off-by: Chris Paulo --- vibrator/cs40l26/Hardware.h | 2 +- vibrator/cs40l26/Vibrator.cpp | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/vibrator/cs40l26/Hardware.h b/vibrator/cs40l26/Hardware.h index 7ad4017..22667c9 100644 --- a/vibrator/cs40l26/Hardware.h +++ b/vibrator/cs40l26/Hardware.h @@ -110,7 +110,7 @@ class HwApi : public Vibrator::HwApi, private HwApiBase { return true; } bool setFFEffect(int fd, struct ff_effect *effect, uint16_t timeoutMs) override { - if (((*effect).replay.length != timeoutMs) || (ioctl(fd, EVIOCSFF, effect) < 0)) { + if (ioctl(fd, EVIOCSFF, effect) < 0) { ALOGE("setFFEffect fail"); return false; } else { diff --git a/vibrator/cs40l26/Vibrator.cpp b/vibrator/cs40l26/Vibrator.cpp index 7d5227e..bfb7cf1 100644 --- a/vibrator/cs40l26/Vibrator.cpp +++ b/vibrator/cs40l26/Vibrator.cpp @@ -363,7 +363,8 @@ Vibrator::Vibrator(std::unique_ptr hwApiDefault, std::unique_ptr h mFfEffects[effectIndex] = { .type = FF_PERIODIC, .id = -1, - .replay.length = static_cast(mEffectDurations[effectIndex]), + // Length == 0 to allow firmware control of the duration + .replay.length = 0, .u.periodic.waveform = FF_CUSTOM, .u.periodic.custom_data = new int16_t[2]{RAM_WVFRM_BANK, effectIndex}, .u.periodic.custom_len = FF_CUSTOM_DATA_LEN, @@ -371,9 +372,11 @@ Vibrator::Vibrator(std::unique_ptr hwApiDefault, std::unique_ptr h // Bypass the waveform update due to different input name if ((strstr(inputEventName, "cs40l26") != nullptr) || (strstr(inputEventName, "cs40l26_dual_input") != nullptr)) { + // Let the firmware control the playback duration to avoid + // cutting any effect that is played short if (!mHwApiDef->setFFEffect( mInputFd, &mFfEffects[effectIndex], - static_cast(mFfEffects[effectIndex].replay.length))) { + mEffectDurations[effectIndex])) { ALOGE("Failed upload effect %d (%d): %s", effectIndex, errno, strerror(errno)); } } @@ -403,7 +406,8 @@ Vibrator::Vibrator(std::unique_ptr hwApiDefault, std::unique_ptr h mFfEffectsDual[effectIndex] = { .type = FF_PERIODIC, .id = -1, - .replay.length = static_cast(mEffectDurations[effectIndex]), + // Length == 0 to allow firmware control of the duration + .replay.length = 0, .u.periodic.waveform = FF_CUSTOM, .u.periodic.custom_data = new int16_t[2]{RAM_WVFRM_BANK, effectIndex}, .u.periodic.custom_len = FF_CUSTOM_DATA_LEN, @@ -411,9 +415,11 @@ Vibrator::Vibrator(std::unique_ptr hwApiDefault, std::unique_ptr h // Bypass the waveform update due to different input name if ((strstr(inputEventName, "cs40l26") != nullptr) || (strstr(inputEventName, "cs40l26_dual_input") != nullptr)) { + // Let the firmware control the playback duration to avoid + // cutting any effect that is played short if (!mHwApiDual->setFFEffect( mInputFdDual, &mFfEffectsDual[effectIndex], - static_cast(mFfEffectsDual[effectIndex].replay.length))) { + mEffectDurations[effectIndex])) { ALOGE("Failed upload flip's effect %d (%d): %s", effectIndex, errno, strerror(errno)); } @@ -795,9 +801,10 @@ ndk::ScopedAStatus Vibrator::compose(const std::vector &composi if (header_count == dspmem_chunk_bytes(ch)) { return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } else { - mFfEffects[WAVEFORM_COMPOSE].replay.length = totalDuration; + // Composition duration should be 0 to allow firmware to play the whole effect + mFfEffects[WAVEFORM_COMPOSE].replay.length = 0; if (mIsDual) { - mFfEffectsDual[WAVEFORM_COMPOSE].replay.length = totalDuration; + mFfEffectsDual[WAVEFORM_COMPOSE].replay.length = 0; } return performEffect(WAVEFORM_MAX_INDEX /*ignored*/, VOLTAGE_SCALE_MAX /*ignored*/, ch, callback); @@ -1501,9 +1508,10 @@ ndk::ScopedAStatus Vibrator::getCompoundDetails(Effect effect, EffectStrength st } *outTimeMs = timeMs; - mFfEffects[WAVEFORM_COMPOSE].replay.length = static_cast(timeMs); + // Compositions should have 0 duration + mFfEffects[WAVEFORM_COMPOSE].replay.length = 0; if (mIsDual) { - mFfEffectsDual[WAVEFORM_COMPOSE].replay.length = static_cast(timeMs); + mFfEffectsDual[WAVEFORM_COMPOSE].replay.length = 0; } return ndk::ScopedAStatus::ok(); From d53fe60449cc601cb7feac390a26635292e3028a Mon Sep 17 00:00:00 2001 From: Pointer Kung Date: Fri, 19 Jan 2024 08:47:01 +0000 Subject: [PATCH 14/37] Camera: Adjust to improve camera launch and capture performance Because F10 enabled PMU and EM for 30fps, it also needs to sync ag/19286153 and ag/20084677 to enable CDPreferIdle for CAMERA_STREAMING_STANDARD and disable PMU and EM during the capture time (also increase the boost duration from 1000ms to 2500ms) to avoid performance impact. Bug: 321164832 Test: Build pass, gca_smoke_test, CTS Change-Id: I5e40662f7e49bd381891f705621209a41ddc96d7 --- powerhint.json | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/powerhint.json b/powerhint.json index fbcc819..c89bfd5 100644 --- a/powerhint.json +++ b/powerhint.json @@ -984,21 +984,33 @@ { "PowerHint": "CAMERA_CAPTURE_CPU_THROTTLE", "Node": "CPUBigClusterMaxFreq", - "Duration": 1000, + "Duration": 2500, "Value": "1826000" }, { "PowerHint": "CAMERA_CAPTURE_CPU_THROTTLE", "Node": "CPUMidClusterMaxFreq", - "Duration": 1000, + "Duration": 2500, "Value": "1491000" }, { "PowerHint": "CAMERA_CAPTURE_CPU_THROTTLE", "Node": "CPULittleClusterMaxFreq", - "Duration": 1000, + "Duration": 2500, "Value": "1401000" }, + { + "PowerHint": "CAMERA_CAPTURE_CPU_THROTTLE", + "Node": "PMU_POLL", + "Duration": 2500, + "Value": "0" + }, + { + "PowerHint": "CAMERA_CAPTURE_CPU_THROTTLE", + "Node": "EM_Profile", + "Duration": 2500, + "Value": "default" + }, { "PowerHint": "CAMERA_SHOT", "Node": "MemFreq", @@ -1467,12 +1479,6 @@ "Duration": 0, "Value": "1" }, - { - "PowerHint": "CAMERA_STREAMING_STANDARD", - "Node": "CDPreferIdle", - "Duration": 0, - "Value": "0" - }, { "PowerHint": "CAMERA_STREAMING_STANDARD", "Node": "PMU_POLL", From dbd42fcb788fb940b8db9358df1aa48fe78a9e56 Mon Sep 17 00:00:00 2001 From: Darren Hsu Date: Fri, 26 Jan 2024 17:52:52 +0800 Subject: [PATCH 15/37] powerstats: use display MRR state residency data provider Bug: 322458289 Test: vts-tradefed run vts -m VtsHalPowerStatsTargetTest Change-Id: Icba2a7da9c9480ce609b3cd07bd79ff2533c9ba4 Signed-off-by: Darren Hsu --- powerstats/felix/service.cpp | 66 ++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 26 deletions(-) diff --git a/powerstats/felix/service.cpp b/powerstats/felix/service.cpp index 2de3797..dd10ef1 100644 --- a/powerstats/felix/service.cpp +++ b/powerstats/felix/service.cpp @@ -38,36 +38,50 @@ using aidl::android::hardware::power::stats::PowerStatsEnergyConsumer; void addDisplay(std::shared_ptr p) { // Add display residency stats for inner display - std::vector inner_states = { - "Off", - "LP: 1840x2208@1", - "LP: 1840x2208@30", - "On: 1840x2208@1", - "On: 1840x2208@10", - "On: 1840x2208@60", - "On: 1840x2208@120", - "HBM: 1840x2208@60", - "HBM: 1840x2208@120"}; + struct stat primaryBuffer; + if (!stat("/sys/class/drm/card0/device/primary-panel/time_in_state", &primaryBuffer)) { + // time_in_state exists + addDisplayMrrByEntity(p, "Inner Display", "/sys/class/drm/card0/device/primary-panel/"); + } else { + // time_in_state doesn't exist + std::vector inner_states = { + "Off", + "LP: 1840x2208@1", + "LP: 1840x2208@30", + "On: 1840x2208@1", + "On: 1840x2208@10", + "On: 1840x2208@60", + "On: 1840x2208@120", + "HBM: 1840x2208@60", + "HBM: 1840x2208@120"}; - p->addStateResidencyDataProvider(std::make_unique( - "Inner Display", - "/sys/class/backlight/panel0-backlight/state", - inner_states)); + p->addStateResidencyDataProvider(std::make_unique( + "Inner Display", + "/sys/class/backlight/panel0-backlight/state", + inner_states)); + } // Add display residency stats for outer display - std::vector outer_states = { - "Off", - "LP: 1080x2092@30", - "On: 1080x2092@10", - "On: 1080x2092@60", - "On: 1080x2092@120", - "HBM: 1080x2092@60", - "HBM: 1080x2092@120"}; + struct stat secondaryBuffer; + if (!stat("/sys/class/drm/card0/device/secondary-panel/time_in_state", &secondaryBuffer)) { + // time_in_state exists + addDisplayMrrByEntity(p, "Outer Display", "/sys/class/drm/card0/device/secondary-panel/"); + } else { + // time_in_state doesn't exist + std::vector outer_states = { + "Off", + "LP: 1080x2092@30", + "On: 1080x2092@10", + "On: 1080x2092@60", + "On: 1080x2092@120", + "HBM: 1080x2092@60", + "HBM: 1080x2092@120"}; - p->addStateResidencyDataProvider(std::make_unique( - "Outer Display", - "/sys/class/backlight/panel1-backlight/state", - outer_states)); + p->addStateResidencyDataProvider(std::make_unique( + "Outer Display", + "/sys/class/backlight/panel1-backlight/state", + outer_states)); + } // Add display energy consumer p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterConsumer( From 65e09ef3772256a63102d930e732dde6f8ada72b Mon Sep 17 00:00:00 2001 From: Ankur Bakshi Date: Wed, 10 Jan 2024 05:58:37 +0000 Subject: [PATCH 16/37] Update felix SVN to 40 Bug: 313797924 Change-Id: Iadcea8bc65170edbc73b3f825f473d4b6bddb376 --- device-felix.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-felix.mk b/device-felix.mk index a9e2f70..50b7beb 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -205,7 +205,7 @@ PRODUCT_SOONG_NAMESPACES += \ # Increment the SVN for any official public releases PRODUCT_VENDOR_PROPERTIES += \ - ro.vendor.build.svn=39 + ro.vendor.build.svn=40 # Vibrator HAL PRODUCT_VENDOR_PROPERTIES +=\ From 8ee4be5ce262b2ff2e3d4378ca2b7cf1a017740c Mon Sep 17 00:00:00 2001 From: Ankur Bakshi Date: Fri, 26 Jan 2024 22:40:53 +0000 Subject: [PATCH 17/37] Update felix SVN to 41 Bug: 313797924 Change-Id: Idc5c9995bde014e20ad6006d97c8b295d22be1b5 --- device-felix.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-felix.mk b/device-felix.mk index 50b7beb..14c6c29 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -205,7 +205,7 @@ PRODUCT_SOONG_NAMESPACES += \ # Increment the SVN for any official public releases PRODUCT_VENDOR_PROPERTIES += \ - ro.vendor.build.svn=40 + ro.vendor.build.svn=41 # Vibrator HAL PRODUCT_VENDOR_PROPERTIES +=\ From 679a1686b2e91c77a79c9fe0b38239ba5d960f76 Mon Sep 17 00:00:00 2001 From: Ankur Bakshi Date: Sun, 28 Jan 2024 00:42:55 +0000 Subject: [PATCH 18/37] Update felix SVN to 42 Bug: 313797924 Change-Id: I831101a977dc0752fc1a21b52fe8c9f8f396ce23 --- device-felix.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-felix.mk b/device-felix.mk index 6db098c..e2489f4 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -220,7 +220,7 @@ PRODUCT_SOONG_NAMESPACES += \ # Increment the SVN for any official public releases PRODUCT_VENDOR_PROPERTIES += \ - ro.vendor.build.svn=41 + ro.vendor.build.svn=42 # Vibrator HAL PRODUCT_VENDOR_PROPERTIES +=\ From dbd48e97c0f8412424be08bf478276c09518532c Mon Sep 17 00:00:00 2001 From: Kimi Hsu Date: Thu, 1 Feb 2024 02:44:52 +0000 Subject: [PATCH 19/37] Add face sensor configs Bug: 323116566 Test: make Flag: NONE Change-Id: I8a883602b791fcdf38df9310f14bc88467b0b182 --- .../base/packages/SystemUI/res/values/config.xml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/felix/overlay/frameworks/base/packages/SystemUI/res/values/config.xml b/felix/overlay/frameworks/base/packages/SystemUI/res/values/config.xml index 16d2bb7..9d91e32 100644 --- a/felix/overlay/frameworks/base/packages/SystemUI/res/values/config.xml +++ b/felix/overlay/frameworks/base/packages/SystemUI/res/values/config.xml @@ -78,8 +78,17 @@ m 589.2,66.53 a 49.5,49.5 0 0 1 -49.5,49.5 49.5,49.5 0 0 1 -49.5,-49.5 49.5,49.5 0 0 1 49.5,-49.5 49.5,49.5 0 0 1 49.5,49.5 z - + 1 + + 5 + + + + 540 + 66 + 50 + From 331b140babe62318835a7923f00f11b09c454ebd Mon Sep 17 00:00:00 2001 From: Jacky Liu Date: Tue, 6 Feb 2024 19:47:18 +0800 Subject: [PATCH 20/37] Update i2c device paths Update i2c device paths with static bus numbers. Bug: 323447554 Test: Boot to home Change-Id: Id98eda794ef6c14e832dc3b40350f76adcb60ad8 --- powerstats/felix/service.cpp | 10 +--- ...rdware.vibrator-service.cs40l26-private.rc | 48 ++++++++++--------- 2 files changed, 26 insertions(+), 32 deletions(-) diff --git a/powerstats/felix/service.cpp b/powerstats/felix/service.cpp index dd10ef1..0194a54 100644 --- a/powerstats/felix/service.cpp +++ b/powerstats/felix/service.cpp @@ -156,15 +156,7 @@ void addGPU(std::shared_ptr p) { } std::string getNfcPath() { - struct stat buffer; - int size = 128; - char path[size]; - for (int i = 0; i < 10; i++) { - std::snprintf(path, size, - "/sys/devices/platform/10970000.hsi2c/i2c-%d/i2c-st21nfc/power_stats", i); - if (!stat(path, &buffer)) break; - } - return std::string(path); + return std::string("/sys/devices/platform/10970000.hsi2c/i2c-8/8-0008/power_stats"); } int main() { diff --git a/vibrator/cs40l26/android.hardware.vibrator-service.cs40l26-private.rc b/vibrator/cs40l26/android.hardware.vibrator-service.cs40l26-private.rc index 2799cdc..e45356e 100644 --- a/vibrator/cs40l26/android.hardware.vibrator-service.cs40l26-private.rc +++ b/vibrator/cs40l26/android.hardware.vibrator-service.cs40l26-private.rc @@ -1,5 +1,5 @@ on property:vendor.all.modules.ready=1 - wait /sys/bus/i2c/devices/i2c-cs40l26a/calibration/redc_cal_time_ms + wait /sys/bus/i2c/devices/15-0043/calibration/redc_cal_time_ms mkdir /mnt/vendor/persist/haptics 0770 system system chmod 770 /mnt/vendor/persist/haptics @@ -9,26 +9,28 @@ on property:vendor.all.modules.ready=1 chown system system /mnt/vendor/persist/haptics/cs40l26.cal chown system system /mnt/vendor/persist/haptics/cs40l26_dual.cal - chown system system /sys/bus/i2c/devices/i2c-cs40l26a/calibration/f0_stored - chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/calibration/f0_stored - chown system system /sys/bus/i2c/devices/i2c-cs40l26a/calibration/q_stored - chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/calibration/q_stored - chown system system /sys/bus/i2c/devices/i2c-cs40l26a/calibration/redc_stored - chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/calibration/redc_stored - chown system system /sys/bus/i2c/devices/i2c-cs40l26a/default/vibe_state - chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/vibe_state - chown system system /sys/bus/i2c/devices/i2c-cs40l26a/default/num_waves - chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/num_waves - chown system system /sys/bus/i2c/devices/i2c-cs40l26a/default/f0_offset - chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/f0_offset - chown system system /sys/bus/i2c/devices/i2c-cs40l26a/default/owt_free_space - chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/owt_free_space - chown system system /sys/bus/i2c/devices/i2c-cs40l26a/default/f0_comp_enable - chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/f0_comp_enable - chown system system /sys/bus/i2c/devices/i2c-cs40l26a/default/redc_comp_enable - chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/redc_comp_enable - chown system system /sys/bus/i2c/devices/i2c-cs40l26a/default/delay_before_stop_playback_us - chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/delay_before_stop_playback_us + chown system system /sys/bus/i2c/devices/15-0043/calibration/f0_stored + chown system system /sys/bus/i2c/devices/15-0043/calibration/q_stored + chown system system /sys/bus/i2c/devices/15-0043/calibration/redc_stored + chown system system /sys/bus/i2c/devices/15-0043/default/vibe_state + chown system system /sys/bus/i2c/devices/15-0043/default/num_waves + chown system system /sys/bus/i2c/devices/15-0043/default/f0_offset + chown system system /sys/bus/i2c/devices/15-0043/default/owt_free_space + chown system system /sys/bus/i2c/devices/15-0043/default/f0_comp_enable + chown system system /sys/bus/i2c/devices/15-0043/default/redc_comp_enable + chown system system /sys/bus/i2c/devices/15-0043/default/delay_before_stop_playback_us + + chown system system /sys/bus/i2c/devices/15-0042/calibration/f0_stored + chown system system /sys/bus/i2c/devices/15-0042/calibration/q_stored + chown system system /sys/bus/i2c/devices/15-0042/calibration/redc_stored + chown system system /sys/bus/i2c/devices/15-0042/default/vibe_state + chown system system /sys/bus/i2c/devices/15-0042/default/num_waves + chown system system /sys/bus/i2c/devices/15-0042/default/f0_offset + chown system system /sys/bus/i2c/devices/15-0042/default/owt_free_space + chown system system /sys/bus/i2c/devices/15-0042/default/f0_comp_enable + chown system system /sys/bus/i2c/devices/15-0042/default/redc_comp_enable + chown system system /sys/bus/i2c/devices/15-0042/default/delay_before_stop_playback_us + chown system system /dev/gpiochip44 enable vendor.vibrator.cs40l26 @@ -46,8 +48,8 @@ service vendor.vibrator.cs40l26 /vendor/bin/hw/android.hardware.vibrator-service setenv CALIBRATION_FILEPATH /mnt/vendor/persist/haptics/cs40l26.cal setenv CALIBRATION_FILEPATH_DUAL /mnt/vendor/persist/haptics/cs40l26_dual.cal - setenv HWAPI_PATH_PREFIX /sys/bus/i2c/devices/i2c-cs40l26a/ - setenv HWAPI_PATH_PREFIX_DUAL /sys/bus/i2c/devices/i2c-cs40l26a-dual/ + setenv HWAPI_PATH_PREFIX /sys/bus/i2c/devices/15-0043/ + setenv HWAPI_PATH_PREFIX_DUAL /sys/bus/i2c/devices/15-0042/ setenv HWAPI_DEBUG_PATHS " calibration/f0_stored calibration/redc_stored From 6d85c6b9972f4473e6fea7b2d730600fb3909e61 Mon Sep 17 00:00:00 2001 From: Alice Kuo Date: Wed, 31 Jan 2024 22:36:05 +0000 Subject: [PATCH 21/37] Extend LE Audio allow list candidate device Bug: 323247113 Test: tester manual test result via b/322564783 Change-Id: Ibdc9d7f3bde60fc59af3a47e8c646a780a6f11a1 --- device-felix.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-felix.mk b/device-felix.mk index e2489f4..135051a 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -390,7 +390,7 @@ PRODUCT_COPY_FILES += \ # LE Audio Unicast Allowlist PRODUCT_PRODUCT_PROPERTIES += \ - persist.bluetooth.leaudio.allow_list=SM-R510 + persist.bluetooth.leaudio.allow_list=SM-R510,WF-1000XM5 # Bluetooth EWP test tool PRODUCT_PACKAGES_DEBUG += \ From 84d454c0ecbec52c5d6408a249ce79f1caef0b6c Mon Sep 17 00:00:00 2001 From: Ankur Bakshi Date: Wed, 14 Feb 2024 00:12:21 +0000 Subject: [PATCH 22/37] Update felix SVN to 43 Bug: 313797924 Change-Id: Ibbf7ca80f79eb5d46c3213b18ce1a056cf932825 --- device-felix.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-felix.mk b/device-felix.mk index e2489f4..7929017 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -220,7 +220,7 @@ PRODUCT_SOONG_NAMESPACES += \ # Increment the SVN for any official public releases PRODUCT_VENDOR_PROPERTIES += \ - ro.vendor.build.svn=42 + ro.vendor.build.svn=43 # Vibrator HAL PRODUCT_VENDOR_PROPERTIES +=\ From d2bc8e7dc0c075ee0f76660b84feea1825179600 Mon Sep 17 00:00:00 2001 From: George Chang Date: Mon, 19 Feb 2024 06:54:47 +0000 Subject: [PATCH 23/37] Enable NFC firmware logging Enable NFC firmware logging by default for better debuggability. Bug: 307999188 Bug: 325604333 Test: manual Change-Id: I1a6265b5e041cc06e4c23e328059663ea6f81c63 --- nfc/libnfc-hal-st.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nfc/libnfc-hal-st.conf b/nfc/libnfc-hal-st.conf index b7599c7..7300e21 100644 --- a/nfc/libnfc-hal-st.conf +++ b/nfc/libnfc-hal-st.conf @@ -8,7 +8,7 @@ NFC_DEBUG_ENABLED=0 ############################################################################### # Vendor specific mode to enable FW (RF & SWP) traces. -STNFC_FW_DEBUG_ENABLED=0 +STNFC_FW_DEBUG_ENABLED=1 ############################################################################### # File used for NFA storage From d9fc654578ff0265bd3a29b7bae6387653bab870 Mon Sep 17 00:00:00 2001 From: Cyan_Hsieh Date: Tue, 27 Feb 2024 16:48:05 +0800 Subject: [PATCH 24/37] Initial Bootloader prebuilt for AP3% build Bug: 326002225 Change-Id: I2ee8eef6d76ad14f544a04bfba060f6b77ad4303 --- device-felix.mk | 2 +- felix/BoardConfig.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/device-felix.mk b/device-felix.mk index e2489f4..447d3e8 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -266,7 +266,7 @@ PRODUCT_PACKAGES += \ PRODUCT_SOONG_NAMESPACES += vendor/google_devices/felix/prebuilts ifneq (,$(filter AP1%,$(RELEASE_PLATFORM_VERSION))) PRODUCT_SOONG_NAMESPACES += vendor/google_devices/felix/prebuilts/trusty/24Q1 -else ifneq (,$(filter AP2%,$(RELEASE_PLATFORM_VERSION))) +else ifneq (,$(filter AP2% AP3%,$(RELEASE_PLATFORM_VERSION))) PRODUCT_SOONG_NAMESPACES += vendor/google_devices/felix/prebuilts/trusty/24Q2 else PRODUCT_SOONG_NAMESPACES += vendor/google_devices/felix/prebuilts/trusty/trunk diff --git a/felix/BoardConfig.mk b/felix/BoardConfig.mk index 1aaac33..a1ed5db 100644 --- a/felix/BoardConfig.mk +++ b/felix/BoardConfig.mk @@ -23,7 +23,7 @@ BOARD_KERNEL_CMDLINE += swiotlb=noforce RELEASE_GOOGLE_PRODUCT_RADIO_DIR := $(RELEASE_GOOGLE_FELIX_RADIO_DIR) ifneq (,$(filter AP1%,$(RELEASE_PLATFORM_VERSION))) RELEASE_GOOGLE_PRODUCT_BOOTLOADER_DIR := bootloader/24Q1 -else ifneq (,$(filter AP2%,$(RELEASE_PLATFORM_VERSION))) +else ifneq (,$(filter AP2% AP3%,$(RELEASE_PLATFORM_VERSION))) RELEASE_GOOGLE_PRODUCT_BOOTLOADER_DIR := bootloader/24Q2 else RELEASE_GOOGLE_PRODUCT_BOOTLOADER_DIR := bootloader/trunk From 6438a6b0b50fabf45ef3d2310e29a06fcb7e27fe Mon Sep 17 00:00:00 2001 From: Alice Kuo Date: Thu, 29 Feb 2024 08:32:10 +0000 Subject: [PATCH 25/37] Revert "Extend LE Audio allow list candidate device" This reverts commit 6d85c6b9972f4473e6fea7b2d730600fb3909e61. Reason for revert: no in plan for 24Q2 Bug: 327554841 Test: build Change-Id: I090aba7e994ffb31738a2e330b9c387c7bb52421 --- device-felix.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-felix.mk b/device-felix.mk index 135051a..e2489f4 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -390,7 +390,7 @@ PRODUCT_COPY_FILES += \ # LE Audio Unicast Allowlist PRODUCT_PRODUCT_PROPERTIES += \ - persist.bluetooth.leaudio.allow_list=SM-R510,WF-1000XM5 + persist.bluetooth.leaudio.allow_list=SM-R510 # Bluetooth EWP test tool PRODUCT_PACKAGES_DEBUG += \ From 5c4d4da8e8f139a2084ca7c07f48aa86fdfd1654 Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Thu, 29 Feb 2024 15:28:39 +0000 Subject: [PATCH 26/37] Enabling Observe mode Bug: 327601464 Test: Tested on local device Change-Id: Iac265af75b5fbb9bf6b34448ff3d2d4413ae3959 --- rro_overlays/NfcOverlay/res/values/config.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/rro_overlays/NfcOverlay/res/values/config.xml b/rro_overlays/NfcOverlay/res/values/config.xml index 5e89b28..135ed8a 100644 --- a/rro_overlays/NfcOverlay/res/values/config.xml +++ b/rro_overlays/NfcOverlay/res/values/config.xml @@ -32,4 +32,5 @@ 103 103 + true From 0e465792b0f7e4537197216948d00c4ef841cb4f Mon Sep 17 00:00:00 2001 From: Ravi Jain Date: Mon, 26 Feb 2024 08:42:35 +0000 Subject: [PATCH 27/37] cs40l26: Align Felix Hal with common HAL Pull DSPMemChunk related CLs from common HAL. ag/22087481, ag/22093662 Bug: 322648133 Test: idlcli compose commands Test: adb shell cmd vibrator_manager synced prebaked 1 Test: adb shell idlcli vibrator composePwle -b \ a 0.1 300.0 0.1 30.0 1000 \ a 0.1 30.0 0.1 300.0 500 Test: atest PtsVibratorHalTestSuite \ PtsHapticsTestCases \ VibratorHalCs40l26TestSuite \ VtsHalVibratorManagerTargetTest \ VtsHalVibratorTargetTest \ android.os.cts.VibratorTest \ android.os.cts.VibratorManagerTest \ android.os.cts.VibrationEffectTest \ android.os.cts.VibrationAttributesTest \ android.os.cts.CombinedVibrationTest (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:85299be2adc9e3dec373dc48f321c4fa1930e260) Merged-In: I32258500ec02c2a8cbfc6d0b37aaea2c83c7c8b4 Change-Id: I32258500ec02c2a8cbfc6d0b37aaea2c83c7c8b4 --- vibrator/cs40l26/Hardware.h | 6 +- vibrator/cs40l26/Vibrator.cpp | 462 ++++++++++++++++++--------------- vibrator/cs40l26/Vibrator.h | 8 +- vibrator/cs40l26/tests/mocks.h | 2 +- 4 files changed, 268 insertions(+), 210 deletions(-) diff --git a/vibrator/cs40l26/Hardware.h b/vibrator/cs40l26/Hardware.h index 22667c9..af8d120 100644 --- a/vibrator/cs40l26/Hardware.h +++ b/vibrator/cs40l26/Hardware.h @@ -184,7 +184,7 @@ class HwApi : public Vibrator::HwApi, private HwApiBase { *haptic_pcm = NULL; return false; } - bool uploadOwtEffect(int fd, uint8_t *owtData, uint32_t numBytes, struct ff_effect *effect, + bool uploadOwtEffect(int fd, const uint8_t *owtData, const uint32_t numBytes, struct ff_effect *effect, uint32_t *outEffectIndex, int *status) override { (*effect).u.periodic.custom_len = numBytes / sizeof(uint16_t); delete[] ((*effect).u.periodic.custom_data); @@ -225,6 +225,10 @@ class HwApi : public Vibrator::HwApi, private HwApiBase { ALOGE("Invalid waveform index for OWT erase: %d", effectIndex); return false; } + if (effect == nullptr || (*effect).empty()) { + ALOGE("Invalid argument effect"); + return false; + } // Turn off the waiting time for SVC init phase to complete since chip // should already under STOP state setMinOnOffInterval(0); diff --git a/vibrator/cs40l26/Vibrator.cpp b/vibrator/cs40l26/Vibrator.cpp index bfb7cf1..2abe72e 100644 --- a/vibrator/cs40l26/Vibrator.cpp +++ b/vibrator/cs40l26/Vibrator.cpp @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #ifndef ARRAY_SIZE @@ -85,7 +87,7 @@ static constexpr uint8_t PWLE_AMP_REG_BIT = 0x2; static constexpr float PWLE_LEVEL_MIN = 0.0; static constexpr float PWLE_LEVEL_MAX = 1.0; -static constexpr float CS40L26_PWLE_LEVEL_MIX = -1.0; +static constexpr float CS40L26_PWLE_LEVEL_MIN = -1.0; static constexpr float CS40L26_PWLE_LEVEL_MAX = 0.9995118; static constexpr float PWLE_FREQUENCY_RESOLUTION_HZ = 1.00; static constexpr float PWLE_FREQUENCY_MIN_HZ = 1.00; @@ -157,79 +159,210 @@ enum vibe_state { VIBE_STATE_ASP, }; -static int min(int x, int y) { - return x < y ? x : y; -} +class DspMemChunk { + private: + std::unique_ptr head; + size_t bytes = 0; + uint8_t waveformType; + uint8_t *_current; + const uint8_t *_max; + uint32_t _cache = 0; + int _cachebits = 0; -static int floatToUint16(float input, uint16_t *output, float scale, float min, float max) { - if (input < min || input > max) - return -ERANGE; + bool isEnd() const { return _current == _max; } + int min(int x, int y) { return x < y ? x : y; } - *output = roundf(input * scale); - return 0; -} + int write(int nbits, uint32_t val) { + int nwrite, i; -struct dspmem_chunk { - uint8_t *head; - uint8_t *current; - uint8_t *max; - int bytes; + nwrite = min(24 - _cachebits, nbits); + _cache <<= nwrite; + _cache |= val >> (nbits - nwrite); + _cachebits += nwrite; + nbits -= nwrite; - uint32_t cache; - int cachebits; -}; + if (_cachebits == 24) { + if (isEnd()) + return -ENOSPC; -static dspmem_chunk *dspmem_chunk_create(void *data, int size) { - auto ch = new dspmem_chunk{ - .head = reinterpret_cast(data), - .current = reinterpret_cast(data), - .max = reinterpret_cast(data) + size, - }; + _cache &= 0xFFFFFF; + for (i = 0; i < sizeof(_cache); i++, _cache <<= 8) + *_current++ = (_cache & 0xFF000000) >> 24; - return ch; -} + bytes += sizeof(_cache); + _cachebits = 0; + } -static bool dspmem_chunk_end(struct dspmem_chunk *ch) { - return ch->current == ch->max; -} + if (nbits) + return write(nbits, val); -static int dspmem_chunk_bytes(struct dspmem_chunk *ch) { - return ch->bytes; -} - -static int dspmem_chunk_write(struct dspmem_chunk *ch, int nbits, uint32_t val) { - int nwrite, i; - - nwrite = min(24 - ch->cachebits, nbits); - ch->cache <<= nwrite; - ch->cache |= val >> (nbits - nwrite); - ch->cachebits += nwrite; - nbits -= nwrite; - - if (ch->cachebits == 24) { - if (dspmem_chunk_end(ch)) - return -ENOSPC; - - ch->cache &= 0xFFFFFF; - for (i = 0; i < sizeof(ch->cache); i++, ch->cache <<= 8) - *ch->current++ = (ch->cache & 0xFF000000) >> 24; - - ch->bytes += sizeof(ch->cache); - ch->cachebits = 0; + return 0; } - if (nbits) - return dspmem_chunk_write(ch, nbits, val); + int fToU16(float input, uint16_t *output, float scale, float min, float max) { + if (input < min || input > max) + return -ERANGE; - return 0; -} - -static int dspmem_chunk_flush(struct dspmem_chunk *ch) { - if (!ch->cachebits) + *output = roundf(input * scale); return 0; + } - return dspmem_chunk_write(ch, 24 - ch->cachebits, 0); -} + void constructPwleSegment(uint16_t delay, uint16_t amplitude, uint16_t frequency, uint8_t flags, + uint32_t vbemfTarget = 0) { + write(16, delay); + write(12, amplitude); + write(12, frequency); + /* feature flags to control the chirp, CLAB braking, back EMF amplitude regulation */ + write(8, (flags | 1) << 4); + if (flags & PWLE_AMP_REG_BIT) { + write(24, vbemfTarget); /* target back EMF voltage */ + } + } + + public: + uint8_t *front() const { return head.get(); } + uint8_t type() const { return waveformType; } + size_t size() const { return bytes; } + + DspMemChunk(uint8_t type, size_t size) : head(new uint8_t[size]{0x00}) { + waveformType = type; + _current = head.get(); + _max = _current + size; + + if (waveformType == WAVEFORM_COMPOSE) { + write(8, 0); /* Padding */ + write(8, 0); /* nsections placeholder */ + write(8, 0); /* repeat */ + } else if (waveformType == WAVEFORM_PWLE) { + write(24, 0); /* Waveform length placeholder */ + write(8, 0); /* Repeat */ + write(12, 0); /* Wait time between repeats */ + write(8, 0); /* nsections placeholder */ + } else { + ALOGE("%s: Invalid type: %u", __func__, waveformType); + } + } + + int flush() { + if (!_cachebits) + return 0; + + return write(24 - _cachebits, 0); + } + + int constructComposeSegment(uint32_t effectVolLevel, uint32_t effectIndex, uint8_t repeat, + uint8_t flags, uint16_t nextEffectDelay) { + if (waveformType != WAVEFORM_COMPOSE) { + ALOGE("%s: Invalid type: %d", __func__, waveformType); + return -EDOM; + } + if (effectVolLevel > 100 || effectIndex > WAVEFORM_MAX_PHYSICAL_INDEX) { + ALOGE("%s: Invalid argument: %u, %u", __func__, effectVolLevel, effectIndex); + return -EINVAL; + } + write(8, effectVolLevel); /* amplitude */ + write(8, effectIndex); /* index */ + write(8, repeat); /* repeat */ + write(8, flags); /* flags */ + write(16, nextEffectDelay); /* delay */ + return 0; + } + + int constructActiveSegment(int duration, float amplitude, float frequency, bool chirp) { + uint16_t delay = 0; + uint16_t amp = 0; + uint16_t freq = 0; + uint8_t flags = 0x0; + if (waveformType != WAVEFORM_PWLE) { + ALOGE("%s: Invalid type: %d", __func__, waveformType); + return -EDOM; + } + if ((fToU16(duration, &delay, 4, 0.0f, COMPOSE_PWLE_PRIMITIVE_DURATION_MAX_MS) < 0) || + (fToU16(amplitude, &, 2048, CS40L26_PWLE_LEVEL_MIN, CS40L26_PWLE_LEVEL_MAX) < 0) || + (fToU16(frequency, &freq, 4, PWLE_FREQUENCY_MIN_HZ, PWLE_FREQUENCY_MAX_HZ) < 0)) { + ALOGE("%s: Invalid argument: %d, %f, %f", __func__, duration, amplitude, frequency); + return -ERANGE; + } + if (chirp) { + flags |= PWLE_CHIRP_BIT; + } + constructPwleSegment(delay, amp, freq, flags, 0 /*ignored*/); + return 0; + } + + int constructBrakingSegment(int duration, Braking brakingType) { + uint16_t delay = 0; + uint16_t freq = 0; + uint8_t flags = 0x00; + if (waveformType != WAVEFORM_PWLE) { + ALOGE("%s: Invalid type: %d", __func__, waveformType); + return -EDOM; + } + if (fToU16(duration, &delay, 4, 0.0f, COMPOSE_PWLE_PRIMITIVE_DURATION_MAX_MS) < 0) { + ALOGE("%s: Invalid argument: %d", __func__, duration); + return -ERANGE; + } + fToU16(PWLE_FREQUENCY_MIN_HZ, &freq, 4, PWLE_FREQUENCY_MIN_HZ, PWLE_FREQUENCY_MAX_HZ); + if (static_cast::type>(brakingType)) { + flags |= PWLE_BRAKE_BIT; + } + + constructPwleSegment(delay, 0 /*ignored*/, freq, flags, 0 /*ignored*/); + return 0; + } + + int updateWLength(uint32_t totalDuration) { + uint8_t *f = front(); + if (f == nullptr) { + ALOGE("%s: head does not exist!", __func__); + return -ENOMEM; + } + if (waveformType != WAVEFORM_PWLE) { + ALOGE("%s: Invalid type: %d", __func__, waveformType); + return -EDOM; + } + if (totalDuration > 0x7FFFF) { + ALOGE("%s: Invalid argument: %u", __func__, totalDuration); + return -EINVAL; + } + totalDuration *= 8; /* Unit: 0.125 ms (since wlength played @ 8kHz). */ + totalDuration |= + WT_LEN_CALCD; /* Bit 23 is for WT_LEN_CALCD; Bit 22 is for WT_INDEFINITE. */ + *(f + 0) = (totalDuration >> 24) & 0xFF; + *(f + 1) = (totalDuration >> 16) & 0xFF; + *(f + 2) = (totalDuration >> 8) & 0xFF; + *(f + 3) = totalDuration & 0xFF; + return 0; + } + + int updateNSection(int segmentIdx) { + uint8_t *f = front(); + if (f == nullptr) { + ALOGE("%s: head does not exist!", __func__); + return -ENOMEM; + } + + if (waveformType == WAVEFORM_COMPOSE) { + if (segmentIdx > COMPOSE_SIZE_MAX + 1 /*1st effect may have a delay*/) { + ALOGE("%s: Invalid argument: %d", __func__, segmentIdx); + return -EINVAL; + } + *(f + 2) = (0xFF & segmentIdx); + } else if (waveformType == WAVEFORM_PWLE) { + if (segmentIdx > COMPOSE_PWLE_SIZE_MAX_DEFAULT) { + ALOGE("%s: Invalid argument: %d", __func__, segmentIdx); + return -EINVAL; + } + *(f + 7) |= (0xF0 & segmentIdx) >> 4; /* Bit 4 to 7 */ + *(f + 9) |= (0x0F & segmentIdx) << 4; /* Bit 3 to 0 */ + } else { + ALOGE("%s: Invalid type: %d", __func__, waveformType); + return -EDOM; + } + + return 0; + } +}; Vibrator::Vibrator(std::unique_ptr hwApiDefault, std::unique_ptr hwCalDefault, std::unique_ptr hwApiDual, std::unique_ptr hwCalDual, @@ -718,9 +851,6 @@ ndk::ScopedAStatus Vibrator::compose(const std::vector &composi uint16_t nextEffectDelay; uint16_t totalDuration = 0; - auto ch = dspmem_chunk_create(new uint8_t[FF_CUSTOM_DATA_LEN_MAX_COMP]{0x00}, - FF_CUSTOM_DATA_LEN_MAX_COMP); - if (composite.size() > COMPOSE_SIZE_MAX || composite.empty()) { return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } @@ -736,15 +866,13 @@ ndk::ScopedAStatus Vibrator::compose(const std::vector &composi size = composite.size(); } - dspmem_chunk_write(ch, 8, 0); /* Padding */ - dspmem_chunk_write(ch, 8, (uint8_t)(0xFF & size)); /* nsections */ - dspmem_chunk_write(ch, 8, 0); /* repeat */ - uint8_t header_count = dspmem_chunk_bytes(ch); + DspMemChunk ch(WAVEFORM_COMPOSE, FF_CUSTOM_DATA_LEN_MAX_COMP); + const uint8_t header_count = ch.size(); /* Insert 1 section for a wait before the first effect. */ if (nextEffectDelay) { - dspmem_chunk_write(ch, 32, 0); /* amplitude, index, repeat & flags */ - dspmem_chunk_write(ch, 16, (uint16_t)(0xFFFF & nextEffectDelay)); /* delay */ + ch.constructComposeSegment(0 /*amplitude*/, 0 /*index*/, 0 /*repeat*/, 0 /*flags*/, + nextEffectDelay /*delay*/); } for (uint32_t i_curr = 0, i_next = 1; i_curr < composite.size(); i_curr++, i_next++) { @@ -791,14 +919,16 @@ ndk::ScopedAStatus Vibrator::compose(const std::vector &composi return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } - dspmem_chunk_write(ch, 8, (uint8_t)(0xFF & effectVolLevel)); /* amplitude */ - dspmem_chunk_write(ch, 8, (uint8_t)(0xFF & effectIndex)); /* index */ - dspmem_chunk_write(ch, 8, 0); /* repeat */ - dspmem_chunk_write(ch, 8, 0); /* flags */ - dspmem_chunk_write(ch, 16, (uint16_t)(0xFFFF & nextEffectDelay)); /* delay */ + ch.constructComposeSegment(effectVolLevel, effectIndex, 0 /*repeat*/, 0 /*flags*/, + nextEffectDelay /*delay*/); } - dspmem_chunk_flush(ch); - if (header_count == dspmem_chunk_bytes(ch)) { + + ch.flush(); + if (ch.updateNSection(size) < 0) { + ALOGE("%s: Failed to update the section count", __func__); + return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); + } + if (header_count == ch.size()) { return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } else { // Composition duration should be 0 to allow firmware to play the whole effect @@ -806,12 +936,12 @@ ndk::ScopedAStatus Vibrator::compose(const std::vector &composi if (mIsDual) { mFfEffectsDual[WAVEFORM_COMPOSE].replay.length = 0; } - return performEffect(WAVEFORM_MAX_INDEX /*ignored*/, VOLTAGE_SCALE_MAX /*ignored*/, ch, + return performEffect(WAVEFORM_MAX_INDEX /*ignored*/, VOLTAGE_SCALE_MAX /*ignored*/, &ch, callback); } } -ndk::ScopedAStatus Vibrator::on(uint32_t timeoutMs, uint32_t effectIndex, dspmem_chunk *ch, +ndk::ScopedAStatus Vibrator::on(uint32_t timeoutMs, uint32_t effectIndex, const DspMemChunk *ch, const std::shared_ptr &callback) { ndk::ScopedAStatus status = ndk::ScopedAStatus::ok(); @@ -826,28 +956,28 @@ ndk::ScopedAStatus Vibrator::on(uint32_t timeoutMs, uint32_t effectIndex, dspmem if (ch) { /* Upload OWT effect. */ - if (ch->head == nullptr) { + if (ch->front() == nullptr) { ALOGE("Invalid OWT bank"); - delete ch; return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } - bool isPwle = (*reinterpret_cast(ch->head) != 0x0000); - effectIndex = isPwle ? WAVEFORM_PWLE : WAVEFORM_COMPOSE; + + if (ch->type() != WAVEFORM_PWLE && ch->type() != WAVEFORM_COMPOSE) { + ALOGE("Invalid OWT type"); + return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); + } + effectIndex = ch->type(); uint32_t freeBytes; mHwApiDef->getOwtFreeSpace(&freeBytes); - if (dspmem_chunk_bytes(ch) > freeBytes) { - ALOGE("Invalid OWT length: Effect %d: %d > %d!", effectIndex, dspmem_chunk_bytes(ch), - freeBytes); - delete ch; + if (ch->size() > freeBytes) { + ALOGE("Invalid OWT length: Effect %d: %zu > %d!", effectIndex, ch->size(), freeBytes); return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } if (mIsDual) { mHwApiDual->getOwtFreeSpace(&freeBytes); - if (dspmem_chunk_bytes(ch) > freeBytes) { + if (ch-> size() > freeBytes) { ALOGE("Invalid OWT length in flip: Effect %d: %d > %d!", effectIndex, - dspmem_chunk_bytes(ch), freeBytes); - delete ch; + ch-> size(), freeBytes); return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } } @@ -860,20 +990,17 @@ ndk::ScopedAStatus Vibrator::on(uint32_t timeoutMs, uint32_t effectIndex, dspmem ALOGD("Not dual haptics HAL and GPIO status fail"); } - if (!mHwApiDef->uploadOwtEffect(mInputFd, ch->head, dspmem_chunk_bytes(ch), - &mFfEffects[effectIndex], &effectIndex, &errorStatus)) { - delete ch; + if (!mHwApiDef->uploadOwtEffect(mInputFd, ch->front(), ch->size(), &mFfEffects[effectIndex], + &effectIndex, &errorStatus)) { ALOGE("Invalid uploadOwtEffect"); return ndk::ScopedAStatus::fromExceptionCode(errorStatus); } - if (mIsDual && !mHwApiDual->uploadOwtEffect(mInputFdDual, ch->head, dspmem_chunk_bytes(ch), + if (mIsDual && !mHwApiDual->uploadOwtEffect(mInputFdDual, ch->front(), ch->size(), &mFfEffectsDual[effectIndex], &effectIndex, &errorStatus)) { - delete ch; ALOGE("Invalid uploadOwtEffect in flip"); return ndk::ScopedAStatus::fromExceptionCode(errorStatus); } - delete ch; } else if (effectIndex == WAVEFORM_SHORT_VIBRATION_EFFECT_INDEX || effectIndex == WAVEFORM_LONG_VIBRATION_EFFECT_INDEX) { @@ -1090,69 +1217,6 @@ static void incrementIndex(int *index) { *index += 1; } -static void constructPwleSegment(dspmem_chunk *ch, uint16_t delay, uint16_t amplitude, - uint16_t frequency, uint8_t flags, uint32_t vbemfTarget = 0) { - dspmem_chunk_write(ch, 16, delay); - dspmem_chunk_write(ch, 12, amplitude); - dspmem_chunk_write(ch, 12, frequency); - /* feature flags to control the chirp, CLAB braking, back EMF amplitude regulation */ - dspmem_chunk_write(ch, 8, (flags | 1) << 4); - if (flags & PWLE_AMP_REG_BIT) { - dspmem_chunk_write(ch, 24, vbemfTarget); /* target back EMF voltage */ - } -} - -static int constructActiveSegment(dspmem_chunk *ch, int duration, float amplitude, float frequency, - bool chirp) { - uint16_t delay = 0; - uint16_t amp = 0; - uint16_t freq = 0; - uint8_t flags = 0x0; - if ((floatToUint16(duration, &delay, 4, 0.0f, COMPOSE_PWLE_PRIMITIVE_DURATION_MAX_MS) < 0) || - (floatToUint16(amplitude, &, 2048, CS40L26_PWLE_LEVEL_MIX, CS40L26_PWLE_LEVEL_MAX) < - 0) || - (floatToUint16(frequency, &freq, 4, PWLE_FREQUENCY_MIN_HZ, PWLE_FREQUENCY_MAX_HZ) < 0)) { - ALOGE("Invalid argument: %d, %f, %f", duration, amplitude, frequency); - return -ERANGE; - } - if (chirp) { - flags |= PWLE_CHIRP_BIT; - } - constructPwleSegment(ch, delay, amp, freq, flags, 0 /*ignored*/); - return 0; -} - -static int constructBrakingSegment(dspmem_chunk *ch, int duration, Braking brakingType) { - uint16_t delay = 0; - uint16_t freq = 0; - uint8_t flags = 0x00; - if (floatToUint16(duration, &delay, 4, 0.0f, COMPOSE_PWLE_PRIMITIVE_DURATION_MAX_MS) < 0) { - ALOGE("Invalid argument: %d", duration); - return -ERANGE; - } - floatToUint16(PWLE_FREQUENCY_MIN_HZ, &freq, 4, PWLE_FREQUENCY_MIN_HZ, PWLE_FREQUENCY_MAX_HZ); - if (static_cast::type>(brakingType)) { - flags |= PWLE_BRAKE_BIT; - } - - constructPwleSegment(ch, delay, 0 /*ignored*/, freq, flags, 0 /*ignored*/); - return 0; -} - -static void updateWLength(dspmem_chunk *ch, uint32_t totalDuration) { - totalDuration *= 8; /* Unit: 0.125 ms (since wlength played @ 8kHz). */ - totalDuration |= WT_LEN_CALCD; /* Bit 23 is for WT_LEN_CALCD; Bit 22 is for WT_INDEFINITE. */ - *(ch->head + 0) = (totalDuration >> 24) & 0xFF; - *(ch->head + 1) = (totalDuration >> 16) & 0xFF; - *(ch->head + 2) = (totalDuration >> 8) & 0xFF; - *(ch->head + 3) = totalDuration & 0xFF; -} - -static void updateNSection(dspmem_chunk *ch, int segmentIdx) { - *(ch->head + 7) |= (0xF0 & segmentIdx) >> 4; /* Bit 4 to 7 */ - *(ch->head + 9) |= (0x0F & segmentIdx) << 4; /* Bit 3 to 0 */ -} - ndk::ScopedAStatus Vibrator::composePwle(const std::vector &composite, const std::shared_ptr &callback) { ATRACE_NAME("Vibrator::composePwle"); @@ -1177,15 +1241,9 @@ ndk::ScopedAStatus Vibrator::composePwle(const std::vector &compo float prevEndAmplitude; float prevEndFrequency; resetPreviousEndAmplitudeEndFrequency(&prevEndAmplitude, &prevEndFrequency); - auto ch = dspmem_chunk_create(new uint8_t[FF_CUSTOM_DATA_LEN_MAX_PWLE]{0x00}, - FF_CUSTOM_DATA_LEN_MAX_PWLE); + DspMemChunk ch(WAVEFORM_PWLE, FF_CUSTOM_DATA_LEN_MAX_PWLE); bool chirp = false; - dspmem_chunk_write(ch, 24, 0x000000); /* Waveform length placeholder */ - dspmem_chunk_write(ch, 8, 0); /* Repeat */ - dspmem_chunk_write(ch, 12, 0); /* Wait time between repeats */ - dspmem_chunk_write(ch, 8, 0x00); /* nsections placeholder */ - for (auto &e : composite) { switch (e.getTag()) { case PrimitivePwle::active: { @@ -1215,8 +1273,8 @@ ndk::ScopedAStatus Vibrator::composePwle(const std::vector &compo if (!((active.startAmplitude == prevEndAmplitude) && (active.startFrequency == prevEndFrequency))) { - if (constructActiveSegment(ch, 0, active.startAmplitude, active.startFrequency, - false) < 0) { + if (ch.constructActiveSegment(0, active.startAmplitude, active.startFrequency, + false) < 0) { return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } incrementIndex(&segmentIdx); @@ -1225,8 +1283,8 @@ ndk::ScopedAStatus Vibrator::composePwle(const std::vector &compo if (active.startFrequency != active.endFrequency) { chirp = true; } - if (constructActiveSegment(ch, active.duration, active.endAmplitude, - active.endFrequency, chirp) < 0) { + if (ch.constructActiveSegment(active.duration, active.endAmplitude, + active.endFrequency, chirp) < 0) { return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } incrementIndex(&segmentIdx); @@ -1249,12 +1307,12 @@ ndk::ScopedAStatus Vibrator::composePwle(const std::vector &compo return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } - if (constructBrakingSegment(ch, 0, braking.braking) < 0) { + if (ch.constructBrakingSegment(0, braking.braking) < 0) { return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } incrementIndex(&segmentIdx); - if (constructBrakingSegment(ch, braking.duration, braking.braking) < 0) { + if (ch.constructBrakingSegment(braking.duration, braking.braking) < 0) { return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } incrementIndex(&segmentIdx); @@ -1270,7 +1328,7 @@ ndk::ScopedAStatus Vibrator::composePwle(const std::vector &compo return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } } - dspmem_chunk_flush(ch); + ch.flush(); /* Update wlength */ totalDuration += MAX_COLD_START_LATENCY_MS; @@ -1278,12 +1336,19 @@ ndk::ScopedAStatus Vibrator::composePwle(const std::vector &compo ALOGE("Total duration is too long (%d)!", totalDuration); return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } - updateWLength(ch, totalDuration); + + if (ch.updateWLength(totalDuration) < 0) { + ALOGE("%s: Failed to update the waveform length length", __func__); + return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); + } /* Update nsections */ - updateNSection(ch, segmentIdx); + if (ch.updateNSection(segmentIdx) < 0) { + ALOGE("%s: Failed to update the section count", __func__); + return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); + } - return performEffect(WAVEFORM_MAX_INDEX /*ignored*/, VOLTAGE_SCALE_MAX /*ignored*/, ch, + return performEffect(WAVEFORM_MAX_INDEX /*ignored*/, VOLTAGE_SCALE_MAX /*ignored*/, &ch, callback); } @@ -1460,7 +1525,7 @@ ndk::ScopedAStatus Vibrator::getSimpleDetails(Effect effect, EffectStrength stre } ndk::ScopedAStatus Vibrator::getCompoundDetails(Effect effect, EffectStrength strength, - uint32_t *outTimeMs, dspmem_chunk *outCh) { + uint32_t *outTimeMs, DspMemChunk *outCh) { ndk::ScopedAStatus status; uint32_t timeMs = 0; uint32_t thisEffectIndex; @@ -1468,23 +1533,14 @@ ndk::ScopedAStatus Vibrator::getCompoundDetails(Effect effect, EffectStrength st uint32_t thisVolLevel; switch (effect) { case Effect::DOUBLE_CLICK: - dspmem_chunk_write(outCh, 8, 0); /* Padding */ - dspmem_chunk_write(outCh, 8, 2); /* nsections */ - dspmem_chunk_write(outCh, 8, 0); /* repeat */ - status = getSimpleDetails(Effect::CLICK, strength, &thisEffectIndex, &thisTimeMs, &thisVolLevel); if (!status.isOk()) { return status; } timeMs += thisTimeMs; - - dspmem_chunk_write(outCh, 8, (uint8_t)(0xFF & thisVolLevel)); /* amplitude */ - dspmem_chunk_write(outCh, 8, (uint8_t)(0xFF & thisEffectIndex)); /* index */ - dspmem_chunk_write(outCh, 8, 0); /* repeat */ - dspmem_chunk_write(outCh, 8, 0); /* flags */ - dspmem_chunk_write(outCh, 16, - (uint16_t)(0xFFFF & WAVEFORM_DOUBLE_CLICK_SILENCE_MS)); /* delay */ + outCh->constructComposeSegment(thisVolLevel, thisEffectIndex, 0 /*repeat*/, 0 /*flags*/, + WAVEFORM_DOUBLE_CLICK_SILENCE_MS); timeMs += WAVEFORM_DOUBLE_CLICK_SILENCE_MS + MAX_PAUSE_TIMING_ERROR_MS; @@ -1495,12 +1551,13 @@ ndk::ScopedAStatus Vibrator::getCompoundDetails(Effect effect, EffectStrength st } timeMs += thisTimeMs; - dspmem_chunk_write(outCh, 8, (uint8_t)(0xFF & thisVolLevel)); /* amplitude */ - dspmem_chunk_write(outCh, 8, (uint8_t)(0xFF & thisEffectIndex)); /* index */ - dspmem_chunk_write(outCh, 8, 0); /* repeat */ - dspmem_chunk_write(outCh, 8, 0); /* flags */ - dspmem_chunk_write(outCh, 16, 0); /* delay */ - dspmem_chunk_flush(outCh); + outCh->constructComposeSegment(thisVolLevel, thisEffectIndex, 0 /*repeat*/, 0 /*flags*/, + 0 /*delay*/); + outCh->flush(); + if (outCh->updateNSection(2) < 0) { + ALOGE("%s: Failed to update the section count", __func__); + return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); + } break; default: @@ -1568,7 +1625,7 @@ ndk::ScopedAStatus Vibrator::performEffect(Effect effect, EffectStrength strengt uint32_t effectIndex; uint32_t timeMs = 0; uint32_t volLevel; - dspmem_chunk *ch = nullptr; + std::optional maybeCh; switch (effect) { case Effect::TEXTURE_TICK: // fall-through @@ -1580,28 +1637,25 @@ ndk::ScopedAStatus Vibrator::performEffect(Effect effect, EffectStrength strengt status = getSimpleDetails(effect, strength, &effectIndex, &timeMs, &volLevel); break; case Effect::DOUBLE_CLICK: - ch = dspmem_chunk_create(new uint8_t[FF_CUSTOM_DATA_LEN_MAX_COMP]{0x00}, - FF_CUSTOM_DATA_LEN_MAX_COMP); - status = getCompoundDetails(effect, strength, &timeMs, ch); + maybeCh.emplace(WAVEFORM_COMPOSE, FF_CUSTOM_DATA_LEN_MAX_COMP); + status = getCompoundDetails(effect, strength, &timeMs, &*maybeCh); volLevel = VOLTAGE_SCALE_MAX; break; default: status = ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); break; } - if (!status.isOk()) { - goto exit; + if (status.isOk()) { + DspMemChunk *ch = maybeCh ? &*maybeCh : nullptr; + status = performEffect(effectIndex, volLevel, ch, callback); } - status = performEffect(effectIndex, volLevel, ch, callback); - -exit: *outTimeMs = timeMs; return status; } ndk::ScopedAStatus Vibrator::performEffect(uint32_t effectIndex, uint32_t volLevel, - dspmem_chunk *ch, + const DspMemChunk *ch, const std::shared_ptr &callback) { setEffectAmplitude(volLevel, VOLTAGE_SCALE_MAX); diff --git a/vibrator/cs40l26/Vibrator.h b/vibrator/cs40l26/Vibrator.h index 5b1ff90..06bd6e5 100644 --- a/vibrator/cs40l26/Vibrator.h +++ b/vibrator/cs40l26/Vibrator.h @@ -89,7 +89,7 @@ class Vibrator : public BnVibrator { virtual bool setHapticPcmAmp(struct pcm **haptic_pcm, bool enable, int card, int device) = 0; // Set OWT waveform for compose or compose PWLE request - virtual bool uploadOwtEffect(int fd, uint8_t *owtData, uint32_t numBytes, + virtual bool uploadOwtEffect(int fd, const uint8_t *owtData, const uint32_t numBytes, struct ff_effect *effect, uint32_t *outEffectIndex, int *status) = 0; // Erase OWT waveform @@ -178,7 +178,7 @@ class Vibrator : public BnVibrator { static constexpr uint32_t MIN_ON_OFF_INTERVAL_US = 8500; // SVC initialization time private: - ndk::ScopedAStatus on(uint32_t timeoutMs, uint32_t effectIndex, struct dspmem_chunk *ch, + ndk::ScopedAStatus on(uint32_t timeoutMs, uint32_t effectIndex, const class DspMemChunk *ch, const std::shared_ptr &callback); // set 'amplitude' based on an arbitrary scale determined by 'maximum' ndk::ScopedAStatus setEffectAmplitude(float amplitude, float maximum); @@ -189,13 +189,13 @@ class Vibrator : public BnVibrator { uint32_t *outVolLevel); // 'compound' effects are those composed by stringing multiple 'simple' effects ndk::ScopedAStatus getCompoundDetails(Effect effect, EffectStrength strength, - uint32_t *outTimeMs, struct dspmem_chunk *outCh); + uint32_t *outTimeMs, class DspMemChunk *outCh); ndk::ScopedAStatus getPrimitiveDetails(CompositePrimitive primitive, uint32_t *outEffectIndex); ndk::ScopedAStatus performEffect(Effect effect, EffectStrength strength, const std::shared_ptr &callback, int32_t *outTimeMs); ndk::ScopedAStatus performEffect(uint32_t effectIndex, uint32_t volLevel, - struct dspmem_chunk *ch, + const class DspMemChunk *ch, const std::shared_ptr &callback); ndk::ScopedAStatus setPwle(const std::string &pwleQueue); bool isUnderExternalControl(); diff --git a/vibrator/cs40l26/tests/mocks.h b/vibrator/cs40l26/tests/mocks.h index c85b0b5..641aba8 100644 --- a/vibrator/cs40l26/tests/mocks.h +++ b/vibrator/cs40l26/tests/mocks.h @@ -51,7 +51,7 @@ class MockApi : public ::aidl::android::hardware::vibrator::Vibrator::HwApi { MOCK_METHOD2(getHapticAlsaDevice, bool(int *card, int *device)); MOCK_METHOD4(setHapticPcmAmp, bool(struct pcm **haptic_pcm, bool enable, int card, int device)); MOCK_METHOD6(uploadOwtEffect, - bool(int fd, uint8_t *owtData, uint32_t numBytes, struct ff_effect *effect, + bool(int fd, const uint8_t *owtData, const uint32_t numBytes, struct ff_effect *effect, uint32_t *outEffectIndex, int *status)); MOCK_METHOD3(eraseOwtEffect, bool(int fd, int8_t effectIndex, std::vector *effect)); MOCK_METHOD1(debug, void(int fd)); From 620aafc025f9cf44fcf281f70e8145ef8dd40bc5 Mon Sep 17 00:00:00 2001 From: Cheng Chang Date: Fri, 26 Jan 2024 05:52:08 +0000 Subject: [PATCH 28/37] gps: Disable Vzw SUPL OTDOA Bug: 322404137 Test: OTDOA test in b/322404137 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:06b419a5788399df5e4cf5721e8e487a6c052121) Merged-In: Id0fb2286c594f335349b3219953043f7f7830a03 Change-Id: Id0fb2286c594f335349b3219953043f7f7830a03 --- location/gps.xml.f10 | 2 +- location/gps_user.xml.f10 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/location/gps.xml.f10 b/location/gps.xml.f10 index a47afb2..bda9cf9 100644 --- a/location/gps.xml.f10 +++ b/location/gps.xml.f10 @@ -35,7 +35,7 @@ SuplVersion="2" SuplMinorVersion="0" SuplOtdoaCapable="true" - SuplOtdoaCapable2="true" + SuplOtdoaCapable2="false" SuplGlonassCapable = "true" SuplGalileoCapable = "true" SuplBdsCapable = "true" diff --git a/location/gps_user.xml.f10 b/location/gps_user.xml.f10 index 19842ca..b92b252 100644 --- a/location/gps_user.xml.f10 +++ b/location/gps_user.xml.f10 @@ -34,7 +34,7 @@ SuplVersion="2" SuplMinorVersion="0" SuplOtdoaCapable="true" - SuplOtdoaCapable2="true" + SuplOtdoaCapable2="false" SuplGlonassCapable = "true" SuplGalileoCapable = "true" SuplBdsCapable = "true" From 74ea4be15405d97f50c0ba636d21ff9941006a74 Mon Sep 17 00:00:00 2001 From: Ankur Bakshi Date: Thu, 15 Feb 2024 02:05:19 +0000 Subject: [PATCH 29/37] Update felix SVN to 44 Bug: 325156176 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:e30274d4c9f0f7138a665f3092c99fb767607c95) Merged-In: Id9052a3303fc7c2c1842f3db9b52a2adf1ba164e Change-Id: Id9052a3303fc7c2c1842f3db9b52a2adf1ba164e --- device-felix.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-felix.mk b/device-felix.mk index 1166a1f..d3cead9 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -220,7 +220,7 @@ PRODUCT_SOONG_NAMESPACES += \ # Increment the SVN for any official public releases PRODUCT_VENDOR_PROPERTIES += \ - ro.vendor.build.svn=43 + ro.vendor.build.svn=44 # Vibrator HAL PRODUCT_VENDOR_PROPERTIES +=\ From 94385458477f3f76bbefdb7e1c779bef5726b547 Mon Sep 17 00:00:00 2001 From: Ankur Bakshi Date: Thu, 15 Feb 2024 02:08:07 +0000 Subject: [PATCH 30/37] Update felix SVN to 45 Bug: 325156176 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:abb540718bb58da443eb970b65e63de85704eef1) Merged-In: I5ebc65fcd00c7d5c593f8a56c8ccdfd424551005 Change-Id: I5ebc65fcd00c7d5c593f8a56c8ccdfd424551005 --- device-felix.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-felix.mk b/device-felix.mk index d3cead9..505da03 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -220,7 +220,7 @@ PRODUCT_SOONG_NAMESPACES += \ # Increment the SVN for any official public releases PRODUCT_VENDOR_PROPERTIES += \ - ro.vendor.build.svn=44 + ro.vendor.build.svn=45 # Vibrator HAL PRODUCT_VENDOR_PROPERTIES +=\ From ad8c399053cc7816168ed9621165c7bec3ae5cd9 Mon Sep 17 00:00:00 2001 From: Ankur Bakshi Date: Thu, 15 Feb 2024 02:09:11 +0000 Subject: [PATCH 31/37] Update felix SVN to 46 Bug: 325156176 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:bc701d8d613ee962e0a2702a527dd5955e8e38eb) Merged-In: I84212cd2b6e36d162d6f6624a21f393e0ec0d070 Change-Id: I84212cd2b6e36d162d6f6624a21f393e0ec0d070 --- device-felix.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-felix.mk b/device-felix.mk index 505da03..1af3c76 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -220,7 +220,7 @@ PRODUCT_SOONG_NAMESPACES += \ # Increment the SVN for any official public releases PRODUCT_VENDOR_PROPERTIES += \ - ro.vendor.build.svn=45 + ro.vendor.build.svn=46 # Vibrator HAL PRODUCT_VENDOR_PROPERTIES +=\ From 0eb1a04ba57f4fa0eae449e78dd31d4cdf6e34bd Mon Sep 17 00:00:00 2001 From: Ankur Bakshi Date: Wed, 6 Mar 2024 00:28:13 +0000 Subject: [PATCH 32/37] Update felix SVN to 47 Bug: 325156176 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:0771df9996399b0dedc54365019ee465293cf386) Merged-In: I80ca14c7073707ef69dd3feef8f7731afbe09582 Change-Id: I80ca14c7073707ef69dd3feef8f7731afbe09582 --- device-felix.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-felix.mk b/device-felix.mk index 1af3c76..394d6c3 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -220,7 +220,7 @@ PRODUCT_SOONG_NAMESPACES += \ # Increment the SVN for any official public releases PRODUCT_VENDOR_PROPERTIES += \ - ro.vendor.build.svn=46 + ro.vendor.build.svn=47 # Vibrator HAL PRODUCT_VENDOR_PROPERTIES +=\ From cf3571dadb47a75124cbfe2095b36c613c5b26f9 Mon Sep 17 00:00:00 2001 From: Ankur Bakshi Date: Thu, 21 Mar 2024 21:45:27 +0000 Subject: [PATCH 33/37] Update felix SVN to 48 Bug: 325156176 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:662666134fbc1977fb83a555ffaa5c7c816d62e0) Merged-In: Ifd4c3df67510d9f7cf5a88b9269614572b5eb0bc Change-Id: Ifd4c3df67510d9f7cf5a88b9269614572b5eb0bc --- device-felix.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-felix.mk b/device-felix.mk index 394d6c3..bc7189e 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -220,7 +220,7 @@ PRODUCT_SOONG_NAMESPACES += \ # Increment the SVN for any official public releases PRODUCT_VENDOR_PROPERTIES += \ - ro.vendor.build.svn=47 + ro.vendor.build.svn=48 # Vibrator HAL PRODUCT_VENDOR_PROPERTIES +=\ From ecc275fbeb2d16841f2eccd32f0c6908f67c03f1 Mon Sep 17 00:00:00 2001 From: Ravi Jain Date: Thu, 21 Mar 2024 15:16:14 +0000 Subject: [PATCH 34/37] cs40l26: Align Felix Hal with common HAL Pull ag/22589260 to replace new/delete by using vector from the common HAL. Bug: 322648133 Test: idlcli compose commands Test: adb shell cmd vibrator_manager synced prebaked 1 Test: adb shell idlcli vibrator compose 0 8 1.0; \ sleep 1; adb shell idlcli vibrator compose 0 7 1.0; Test: atest PtsVibratorHalTestSuite \ PtsHapticsTestCases \ VibratorHalCs40l26TestSuitePrivate \ VtsHalVibratorManagerTargetTest \ VtsHalVibratorTargetTest \ android.os.cts.VibratorTest \ android.os.cts.VibratorManagerTest \ android.os.cts.VibrationEffectTest \ android.os.cts.VibrationAttributesTest \ android.os.cts.CombinedVibrationTest (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:75d87040c7284b0d0ef2f20e5edd2e2d384d943c) Merged-In: Ia6e9111c47f27089521f05a68b538bbefb235d6b Change-Id: Ia6e9111c47f27089521f05a68b538bbefb235d6b --- vibrator/cs40l26/Hardware.h | 25 +++++++++++++++++-------- vibrator/cs40l26/Vibrator.cpp | 28 +++++++++++++++++++++------- vibrator/cs40l26/Vibrator.h | 2 ++ 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/vibrator/cs40l26/Hardware.h b/vibrator/cs40l26/Hardware.h index af8d120..69cf9ae 100644 --- a/vibrator/cs40l26/Hardware.h +++ b/vibrator/cs40l26/Hardware.h @@ -104,18 +104,25 @@ class HwApi : public Vibrator::HwApi, private HwApiBase { .code = FF_GAIN, .value = value, }; + if (value > 100) { + ALOGE("Invalid gain"); + return false; + } if (write(fd, (const void *)&gain, sizeof(gain)) != sizeof(gain)) { return false; } return true; } bool setFFEffect(int fd, struct ff_effect *effect, uint16_t timeoutMs) override { + if (effect == nullptr) { + ALOGE("Invalid ff_effect"); + return false; + } if (ioctl(fd, EVIOCSFF, effect) < 0) { ALOGE("setFFEffect fail"); return false; - } else { - return true; } + return true; } bool setFFPlay(int fd, int8_t index, bool value) override { struct input_event play = { @@ -186,14 +193,17 @@ class HwApi : public Vibrator::HwApi, private HwApiBase { } bool uploadOwtEffect(int fd, const uint8_t *owtData, const uint32_t numBytes, struct ff_effect *effect, uint32_t *outEffectIndex, int *status) override { - (*effect).u.periodic.custom_len = numBytes / sizeof(uint16_t); - delete[] ((*effect).u.periodic.custom_data); - (*effect).u.periodic.custom_data = new int16_t[(*effect).u.periodic.custom_len]{0x0000}; - if ((*effect).u.periodic.custom_data == nullptr) { - ALOGE("Failed to allocate memory for custom data\n"); + if (owtData == nullptr || effect == nullptr || outEffectIndex == nullptr) { + ALOGE("Invalid argument owtData, ff_effect or outEffectIndex"); *status = EX_NULL_POINTER; return false; } + if (status == nullptr) { + ALOGE("Invalid argument status"); + return false; + } + + (*effect).u.periodic.custom_len = numBytes / sizeof(uint16_t); memcpy((*effect).u.periodic.custom_data, owtData, numBytes); if ((*effect).id != -1) { @@ -204,7 +214,6 @@ class HwApi : public Vibrator::HwApi, private HwApiBase { (*effect).id = -1; if (ioctl(fd, EVIOCSFF, effect) < 0) { ALOGE("Failed to upload effect %d (%d): %s", *outEffectIndex, errno, strerror(errno)); - delete[] ((*effect).u.periodic.custom_data); *status = EX_ILLEGAL_STATE; return false; } diff --git a/vibrator/cs40l26/Vibrator.cpp b/vibrator/cs40l26/Vibrator.cpp index 2abe72e..b3ce88e 100644 --- a/vibrator/cs40l26/Vibrator.cpp +++ b/vibrator/cs40l26/Vibrator.cpp @@ -44,7 +44,6 @@ namespace aidl { namespace android { namespace hardware { namespace vibrator { -static constexpr uint8_t FF_CUSTOM_DATA_LEN = 2; static constexpr uint16_t FF_CUSTOM_DATA_LEN_MAX_COMP = 2044; // (COMPOSE_SIZE_MAX + 1) * 8 + 4 static constexpr uint16_t FF_CUSTOM_DATA_LEN_MAX_PWLE = 2302; @@ -488,19 +487,23 @@ Vibrator::Vibrator(std::unique_ptr hwApiDefault, std::unique_ptr h mEffectDurations = { 1000, 100, 12, 1000, 300, 130, 150, 500, 100, 5, 12, 1000, 1000, 1000, }; /* 11+3 waveforms. The duration must < UINT16_MAX */ + mEffectCustomData.reserve(WAVEFORM_MAX_INDEX); uint8_t effectIndex; + uint16_t numBytes = 0; for (effectIndex = 0; effectIndex < WAVEFORM_MAX_INDEX; effectIndex++) { if (effectIndex < WAVEFORM_MAX_PHYSICAL_INDEX) { /* Initialize physical waveforms. */ + mEffectCustomData.push_back({RAM_WVFRM_BANK, effectIndex}); mFfEffects[effectIndex] = { .type = FF_PERIODIC, .id = -1, // Length == 0 to allow firmware control of the duration .replay.length = 0, .u.periodic.waveform = FF_CUSTOM, - .u.periodic.custom_data = new int16_t[2]{RAM_WVFRM_BANK, effectIndex}, - .u.periodic.custom_len = FF_CUSTOM_DATA_LEN, + .u.periodic.custom_data = mEffectCustomData[effectIndex].data(), + .u.periodic.custom_len = + static_cast(mEffectCustomData[effectIndex].size()), }; // Bypass the waveform update due to different input name if ((strstr(inputEventName, "cs40l26") != nullptr) || @@ -518,12 +521,16 @@ Vibrator::Vibrator(std::unique_ptr hwApiDefault, std::unique_ptr h } } else { /* Initiate placeholders for OWT effects. */ + numBytes = effectIndex == WAVEFORM_COMPOSE ? FF_CUSTOM_DATA_LEN_MAX_COMP + : FF_CUSTOM_DATA_LEN_MAX_PWLE; + std::vector tempVec(numBytes, 0); + mEffectCustomData.push_back(std::move(tempVec)); mFfEffects[effectIndex] = { .type = FF_PERIODIC, .id = -1, .replay.length = 0, .u.periodic.waveform = FF_CUSTOM, - .u.periodic.custom_data = nullptr, + .u.periodic.custom_data = mEffectCustomData[effectIndex].data(), .u.periodic.custom_len = 0, }; } @@ -532,18 +539,21 @@ Vibrator::Vibrator(std::unique_ptr hwApiDefault, std::unique_ptr h // ====================HAL internal effect table== Flip ================================== if (mIsDual) { mFfEffectsDual.resize(WAVEFORM_MAX_INDEX); + mEffectCustomDataDual.reserve(WAVEFORM_MAX_INDEX); for (effectIndex = 0; effectIndex < WAVEFORM_MAX_INDEX; effectIndex++) { if (effectIndex < WAVEFORM_MAX_PHYSICAL_INDEX) { /* Initialize physical waveforms. */ + mEffectCustomDataDual.push_back({RAM_WVFRM_BANK, effectIndex}); mFfEffectsDual[effectIndex] = { .type = FF_PERIODIC, .id = -1, // Length == 0 to allow firmware control of the duration .replay.length = 0, .u.periodic.waveform = FF_CUSTOM, - .u.periodic.custom_data = new int16_t[2]{RAM_WVFRM_BANK, effectIndex}, - .u.periodic.custom_len = FF_CUSTOM_DATA_LEN, + .u.periodic.custom_data = mEffectCustomDataDual[effectIndex].data(), + .u.periodic.custom_len = + static_cast(mEffectCustomDataDual[effectIndex].size()), }; // Bypass the waveform update due to different input name if ((strstr(inputEventName, "cs40l26") != nullptr) || @@ -563,12 +573,16 @@ Vibrator::Vibrator(std::unique_ptr hwApiDefault, std::unique_ptr h } } else { /* Initiate placeholders for OWT effects. */ + numBytes = effectIndex == WAVEFORM_COMPOSE ? FF_CUSTOM_DATA_LEN_MAX_COMP + : FF_CUSTOM_DATA_LEN_MAX_PWLE; + std::vector tempVec(numBytes, 0); + mEffectCustomDataDual.push_back(std::move(tempVec)); mFfEffectsDual[effectIndex] = { .type = FF_PERIODIC, .id = -1, .replay.length = 0, .u.periodic.waveform = FF_CUSTOM, - .u.periodic.custom_data = nullptr, + .u.periodic.custom_data = mEffectCustomDataDual[effectIndex].data(), .u.periodic.custom_len = 0, }; } diff --git a/vibrator/cs40l26/Vibrator.h b/vibrator/cs40l26/Vibrator.h index 06bd6e5..8f89713 100644 --- a/vibrator/cs40l26/Vibrator.h +++ b/vibrator/cs40l26/Vibrator.h @@ -218,6 +218,8 @@ class Vibrator : public BnVibrator { std::vector mFfEffects; std::vector mFfEffectsDual; std::vector mEffectDurations; + std::vector> mEffectCustomData; + std::vector> mEffectCustomDataDual; std::future mAsyncHandle; ::android::base::unique_fd mInputFd; ::android::base::unique_fd mInputFdDual; From b979856d65f6e1479b767e0536a37b9eeed74be7 Mon Sep 17 00:00:00 2001 From: Ankur Bakshi Date: Thu, 28 Mar 2024 15:34:45 +0000 Subject: [PATCH 35/37] Update felix SVN to 49 Bug: 330382848 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:f4e79e0825e6520e1d801f8b238ee87d22003341) Merged-In: I4adff31a3d552c862fab43cba73c0cb074904be8 Change-Id: I4adff31a3d552c862fab43cba73c0cb074904be8 --- device-felix.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-felix.mk b/device-felix.mk index bc7189e..17ec024 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -220,7 +220,7 @@ PRODUCT_SOONG_NAMESPACES += \ # Increment the SVN for any official public releases PRODUCT_VENDOR_PROPERTIES += \ - ro.vendor.build.svn=48 + ro.vendor.build.svn=49 # Vibrator HAL PRODUCT_VENDOR_PROPERTIES +=\ From d87c7b793538d3f4a001ddb274cbe415efebfd3a Mon Sep 17 00:00:00 2001 From: Ankur Bakshi Date: Wed, 3 Apr 2024 23:17:02 +0000 Subject: [PATCH 36/37] Update felix SVN to 50 Bug: 330382848 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:73220aeecf69ad2c7a04be657263379aa4406b24) Merged-In: Ic4cb9fec016661b45d7af9a1075e5912bd435b9e Change-Id: Ic4cb9fec016661b45d7af9a1075e5912bd435b9e --- device-felix.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-felix.mk b/device-felix.mk index 17ec024..b11d813 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -220,7 +220,7 @@ PRODUCT_SOONG_NAMESPACES += \ # Increment the SVN for any official public releases PRODUCT_VENDOR_PROPERTIES += \ - ro.vendor.build.svn=49 + ro.vendor.build.svn=50 # Vibrator HAL PRODUCT_VENDOR_PROPERTIES +=\ From 3f3a05ab872b41e90f17050c8ac14067026c6202 Mon Sep 17 00:00:00 2001 From: Ankur Bakshi Date: Wed, 24 Apr 2024 19:47:53 +0000 Subject: [PATCH 37/37] Update felix SVN to 51 Bug: 336526332 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:e222c307125a3c038eb3c5376453c70d9c47040c) Merged-In: I0b4bea1a97004139cc18129eeeab302aa557ca05 Change-Id: I0b4bea1a97004139cc18129eeeab302aa557ca05 --- device-felix.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-felix.mk b/device-felix.mk index b11d813..44f35b1 100644 --- a/device-felix.mk +++ b/device-felix.mk @@ -220,7 +220,7 @@ PRODUCT_SOONG_NAMESPACES += \ # Increment the SVN for any official public releases PRODUCT_VENDOR_PROPERTIES += \ - ro.vendor.build.svn=50 + ro.vendor.build.svn=51 # Vibrator HAL PRODUCT_VENDOR_PROPERTIES +=\