Caprip: add wakelock for the actuator noise reduction.

Sometimes system will suspend during the delaywork.
so add wakelock to ensure system is awake.

Change-Id: I7e4db27bf2cebb96faee219ba161b10fdc14ccc9
Signed-off-by: huangdra <huangdra@motorola.com>
Reviewed-on: https://gerrit.mot.com/1984717
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Zhilong Wang <wangzl30@motorola.com>
Reviewed-by: Wang Wang <wangwang1@lenovo.com>
Submit-Approved: Jira Key
This commit is contained in:
huangdra authored and Carlos Pinho committed 2023-05-31 16:59:32 -03:00
1 parent e8e1335e7c
commit 1a779204ec
1 file changed
+9 -1
@@ -26,6 +26,7 @@
#include "cam_cci_dev.h"
#include "mot_actuator.h"
#include "mot_actuator_policy.h"
#include "linux/pm_wakeup.h"
/*=================ACTUATOR HW INFO====================*/
#define DEVICE_NAME_LEN 32
@@ -206,6 +207,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 {
@@ -494,6 +496,7 @@ int mot_actuator_on_vibrate_start(void)
{
ktime_t start,end,duration;
start = ktime_get();
__pm_stay_awake(&mot_actuator_fctrl.actuator_wakelock);
cancel_delayed_work(&mot_actuator_fctrl.delay_work);
mutex_lock(&mot_actuator_fctrl.actuator_lock);
mot_actuator_vib_move_lens(0);
@@ -525,7 +528,6 @@ static int32_t mot_actuator_handle_exit(uint32_t arg)
return rc;
}
static int32_t mot_actuator_handle_write(uint32_t arg)
{
int rc = 0;
@@ -708,6 +710,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,
@@ -898,6 +901,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;
@@ -934,6 +940,8 @@ static void __exit mot_actuator_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_init(mot_actuator_init);