kevin知识库
首页 / MTK 平台 / /mtk/motor-driver-config/
整理中 创建 2026/06/06 更新 2026/06/06

mediateksample/aiot8391p264bsp/ProjectConfig.mk

#mtk #发现路径不对 #define

[MTK]马达驱动配置

在device下添加vibr服务

mediateksample/aiot8391p2_64_bsp/ProjectConfig.mk
+CUSTOM_KERNEL_VIBRATOR = vibrator

mediateksample/aiot8391p2_64_bsp/ko_order_table.csv
regulator-vibrator.ko,/../kernel_device_modules-6.1/drivers/leds/regulator-vibrator.ko,ramdisk,Y,Y,user/userdebug/eng

vendor下修改hal层

查看log是否加载了驱动,测试是否有马达震动功能,如果加载驱动没有震动功能请用adb进行测试打开。

cd sys/class/leds/vibrator/
aiot8391p2_64_bsp:/sys/class/leds/vibrator # ls
activate  brightness  device  duration  max_brightness  power  state  subsystem  trigger  uevent
aiot8391p2_64_bsp:/sys/class/leds/vibrator # echo 255 > brightness
aiot8391p2_64_bsp:/sys/class/leds/vibrator # echo 0 > brightness

如果adb测试有马达功能,那就是hal上层问题

#发现路径不对

--- a/mediatek/proprietary/hardware/libvibrator/aidl/default/Vibrator.cpp
+++ b/mediatek/proprietary/hardware/libvibrator/aidl/default/Vibrator.cpp
@@ -51,7 +51,7 @@ static constexpr int32_t WAVEFORM_HEAVY_CLICK_EFFECT = 90;

 #define TIMEOUT_STR_LEN         20

-static const char THE_DEVICE[] = "/sys/class/timed_output/vibrator/enable";
+static const char THE_DEVICE[] = "/sys/class/leds/vibrator/brightness";

 static bool device_exists(const char *file) {
     int fd = -1;
@@ -103,13 +103,19 @@ static int write_value(const char *file, const char *value)

 static int sendit(unsigned int timeout_ms)
 {
-    char value[TIMEOUT_STR_LEN]; /* large enough for millions of years */
+    char value[TIMEOUT_STR_LEN];

-    int bytes = snprintf(value, sizeof(value), "%u", timeout_ms);
+    int bytes;
+    if (timeout_ms > 0) {
+        bytes = snprintf(value, sizeof(value), "255");
+    } else {
+        bytes = snprintf(value, sizeof(value), "0");
+    }
     if (bytes >= sizeof(value)) return -EINVAL;
     return write_value(THE_DEVICE, value);
 }

测试APK

附件:app-release.apk(1).1