summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPixelBot AutoMerger <android-nexus-securitybot@system.gserviceaccount.com>2022-06-12 19:56:09 -0700
committerSecurityBot <android-nexus-securitybot@system.gserviceaccount.com>2022-06-12 19:56:09 -0700
commit9ef64cbf14e1e7818e3b11e028c5f955f98f4ff2 (patch)
treeba65ef2e5c00d2703e88bc42a1c72699bbfb52b2
parentf0901b4739008f2697601ae5648d7daf5c647f37 (diff)
parent1dcf4405cceab9a3701a9d4f4822628502a5322e (diff)
downloadamplifiers-9ef64cbf14e1e7818e3b11e028c5f955f98f4ff2.tar.gz
Merge android13-gs-pixel-5.10-tm-d1 into android13-gs-pixel-5.10-tm-qpr1
SBMerger: 442815275 Change-Id: I92be419165768b6f0778b7b32ce633bb8923e968 Signed-off-by: SecurityBot <android-nexus-securitybot@system.gserviceaccount.com>
-rw-r--r--cs40l26/cs40l26.c22
-rw-r--r--cs40l26/cs40l26.h4
2 files changed, 26 insertions, 0 deletions
diff --git a/cs40l26/cs40l26.c b/cs40l26/cs40l26.c
index 93fe669..9ac8e87 100644
--- a/cs40l26/cs40l26.c
+++ b/cs40l26/cs40l26.c
@@ -708,6 +708,7 @@ static int cs40l26_handle_mbox_buffer(struct cs40l26_private *cs40l26)
switch (val) {
case CS40L26_DSP_MBOX_COMPLETE_MBOX:
dev_dbg(dev, "Mailbox: COMPLETE_MBOX\n");
+ complete_all(&cs40l26->erase_cont);
cs40l26_vibe_state_update(cs40l26,
CS40L26_VIBE_STATE_EVENT_MBOX_COMPLETE);
break;
@@ -1943,6 +1944,8 @@ static void cs40l26_vibe_start_worker(struct work_struct *work)
if (!cs40l26->vibe_state_reporting)
cs40l26_vibe_state_update(cs40l26,
CS40L26_VIBE_STATE_EVENT_MBOX_PLAYBACK);
+
+ reinit_completion(&cs40l26->erase_cont);
err_mutex:
mutex_unlock(&cs40l26->lock);
pm_runtime_mark_last_busy(dev);
@@ -2957,6 +2960,7 @@ static void cs40l26_erase_worker(struct work_struct *work)
struct cs40l26_private, erase_work);
int ret = 0;
int effect_id;
+ u16 duration;
u32 index;
ret = pm_runtime_get_sync(cs40l26->dev);
@@ -2967,6 +2971,22 @@ static void cs40l26_erase_worker(struct work_struct *work)
effect_id = cs40l26->erase_effect->id;
index = cs40l26->trigger_indices[effect_id];
+ duration = (cs40l26->erase_effect->replay.length == 0) ?
+ CS40L26_OWT_DURATION_MS : cs40l26->erase_effect->replay.length;
+
+ /* Check if effect playing is the one to be deleted. */
+ if (cs40l26->vibe_state == CS40L26_VIBE_STATE_HAPTIC &&
+ cs40l26->trigger_effect->id == effect_id) {
+ /* Wait for effect to complete. */
+ mutex_unlock(&cs40l26->lock);
+ if (!wait_for_completion_timeout(&cs40l26->erase_cont,
+ msecs_to_jiffies(duration + CS40L26_ERASE_WAIT_MS))) {
+ dev_err(cs40l26->dev, "Failed to erase effect in-flight\n");
+ ret = -ETIME;
+ goto pm_err;
+ }
+ mutex_lock(&cs40l26->lock);
+ }
dev_dbg(cs40l26->dev, "%s: effect ID = %d\n", __func__, effect_id);
@@ -2992,6 +3012,7 @@ static void cs40l26_erase_worker(struct work_struct *work)
out_mutex:
mutex_unlock(&cs40l26->lock);
+pm_err:
pm_runtime_mark_last_busy(cs40l26->dev);
pm_runtime_put_autosuspend(cs40l26->dev);
@@ -4798,6 +4819,7 @@ int cs40l26_probe(struct cs40l26_private *cs40l26,
cs40l26->pm_ready = false;
init_completion(&cs40l26->i2s_cont);
+ init_completion(&cs40l26->erase_cont);
if (!cs40l26->fw_defer) {
ret = cs40l26_fw_upload(cs40l26);
diff --git a/cs40l26/cs40l26.h b/cs40l26/cs40l26.h
index 639c309..463afef 100644
--- a/cs40l26/cs40l26.h
+++ b/cs40l26/cs40l26.h
@@ -927,6 +927,9 @@
#define CS40L26_AMP_VOL_PCM_MAX 0x07FF
+#define CS40L26_ERASE_WAIT_MS 500
+#define CS40L26_OWT_DURATION_MS 10000
+
/* GPI Triggering */
#define CS40L26_GPIO1 1
#define CS40L26_EVENT_MAP_INDEX_MASK GENMASK(8, 0)
@@ -1513,6 +1516,7 @@ struct cs40l26_private {
bool comp_enable_redc;
bool comp_enable_f0;
struct completion i2s_cont;
+ struct completion erase_cont;
u8 vpbr_thld;
};