From 216643ab5694bfe68bc51a47d9da3eb1353bece5 Mon Sep 17 00:00:00 2001 From: wangshuo18 Date: Mon, 21 Jun 2021 16:06:12 +0800 Subject: [PATCH] cam: add wakelock for the actuator noise reduction. -Sometimes system will suspend during the delaywork. so add wakelock to ensure system is awake. -port from 1984717 Change-Id: Ie081d6d3e6642c7d6f77b2a1f3eb9a3d82c9f69c Signed-off-by: wangshuo18 Reviewed-on: https://gerrit.mot.com/1985991 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Zhenxin Xi Reviewed-by: Long Cheng Reviewed-by: Zhuoran Xu Reviewed-by: Bolei Shang Reviewed-by: Shuo Wang Reviewed-by: Yongqin Wan Reviewed-by: Zhilong Wang Reviewed-by: Quanlin Zhu Submit-Approved: Jira Key --- drivers/cam_sensor_module/cam_actuator/mot_actuator.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/cam_sensor_module/cam_actuator/mot_actuator.c b/drivers/cam_sensor_module/cam_actuator/mot_actuator.c index 2e3788154aa2..6483f6976a28 100644 --- a/drivers/cam_sensor_module/cam_actuator/mot_actuator.c +++ b/drivers/cam_sensor_module/cam_actuator/mot_actuator.c @@ -27,6 +27,8 @@ #include "mot_actuator_policy.h" #include "cam_sensor_io.h" #include "cam_req_mgr_dev.h" +#include "linux/pm_wakeup.h" + /*=================ACTUATOR HW INFO====================*/ #define DEVICE_NAME_LEN 32 #define MAX_ACTUATOR_NUM 3 @@ -314,6 +316,7 @@ struct mot_actuator_ctrl_t { struct workqueue_struct *mot_actuator_wq; struct delayed_work delay_work; struct mutex actuator_lock; + struct wakeup_source actuator_wakelock; }; enum mot_actuator_state_e { @@ -686,6 +689,7 @@ int mot_actuator_on_vibrate_start(void) bool is_exiting = false; ktime_t start,end,duration; start = ktime_get(); + __pm_stay_awake(&mot_actuator_fctrl.actuator_wakelock); cancel_delayed_work(&mot_actuator_fctrl.delay_work); if (mutex_is_locked(&mot_actuator_fctrl.actuator_lock)) { is_exiting = true; @@ -907,6 +911,7 @@ static void mot_actuator_delayed_process(struct work_struct *work) } mot_actuator_state = MOT_ACTUATOR_RELEASED; mutex_unlock(&actuator_fctrl->actuator_lock); + __pm_relax(&actuator_fctrl->actuator_wakelock); } static inline ssize_t msm_actuator_show(struct device *dev, @@ -1097,6 +1102,9 @@ static int mot_actuator_init_subdev(struct mot_actuator_ctrl_t *f_ctrl) INIT_DELAYED_WORK(&f_ctrl->delay_work, mot_actuator_delayed_process); mutex_init(&f_ctrl->actuator_lock); + memset(&f_ctrl->actuator_wakelock, 0, sizeof(f_ctrl->actuator_wakelock)); + f_ctrl->actuator_wakelock.name = "actuator_hold_wl"; + wakeup_source_add(&f_ctrl->actuator_wakelock); {//Debug/tuning interfaces int i; @@ -1133,6 +1141,8 @@ void mot_actuator_driver_exit(void) mot_actuator_fctrl.mot_actuator_wq = NULL; } cam_unregister_subdev(&mot_actuator_fctrl.v4l2_dev_str); + __pm_relax(&mot_actuator_fctrl.actuator_wakelock); + wakeup_source_remove(&mot_actuator_fctrl.actuator_wakelock); } MODULE_DESCRIPTION("MOT ACTUATOR");