From e8f6467d65f086a16ec33cb3cfd724086595d2f1 Mon Sep 17 00:00:00 2001 From: Wai-Hong Tam Date: Wed, 21 Jul 2021 15:11:59 -0700 Subject: tablet_mode: Fix the race condition of setting the tablet mode There are 2 tablet mode triggers: * Lid: when the lid angle close to 360 degree, either detected by a GMR sensor or by the angle computed by 2 motion sensors. * Base: when the detachable base is detached. These 2 triggers set the tablet mode status, which as a boolean, resulting a race condition. This CL fixes the race condition. Each trigger updates its own bit. The final tablet mode status is the OR of all bits. BRANCH=Trogdor BUG=b:193873098 TEST=Attached the base, checked tablet_mode enabled; detached the base, checked tablet_mode disabled; flip base to 360 degree, checked tablet_mode disabled; move the base out of the lid, checked tablet_mode disabled. Change-Id: Ia9d9d2d66c194796c1039cc8b746c8d1f28a4496 Signed-off-by: Wai-Hong Tam Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3044414 Reviewed-by: Ting Shen --- common/motion_lid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common/motion_lid.c') diff --git a/common/motion_lid.c b/common/motion_lid.c index 1d84c17eff..eb0297aefa 100644 --- a/common/motion_lid.c +++ b/common/motion_lid.c @@ -176,7 +176,7 @@ static void motion_lid_set_tablet_mode(int reliable) /* Alright, we're convinced. */ tablet_mode_debounce_cnt = TABLET_MODE_DEBOUNCE_COUNT; - tablet_set_mode(new_mode); + tablet_set_mode(new_mode, TABLET_TRIGGER_LID); return; } tablet_mode_debounce_cnt--; -- cgit v1.2.1