diff options
author | Josh Tsai <josh_tsai@compal.corp-partner.google.com> | 2022-09-15 14:43:41 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-11-22 02:36:33 +0000 |
commit | 949477c098b288dec19a69baf5c31e379bb38d98 (patch) | |
tree | 5d51399ab7f1483f41382b3a5a63a0971b2cb820 /common | |
parent | 13673d5a7dec5bfcbea51a7e2012587a69286238 (diff) | |
download | chrome-ec-949477c098b288dec19a69baf5c31e379bb38d98.tar.gz |
common: body_detection: notify host when body status is changed
When body status is changed, EC will send the SCI event
"EC_HOST_EVENT_MODE_CHANGE" to host, the host will use the ACPI
command to get the mode change value.
BRANCH=none
BUG=b:236668095;b:232946420
LOW_COVERAGE_REASON=no unit test for body_detection yet: b/259754018
TEST=zmake build winterhold and test on Whiterun MB.
When shake MB trigger on body, and flat in desk trigger off body.
ec:$ [359.832100 even[359.834200 event clear 0x0000000010000000]
ec:$ [359.837000 ACPI query = 29]
t set 0x0000000010000000]
ec:$ [359.840800 HC 0x0067 err 9]
ec:$ [359.842300 body_detect changed state to: off body]
ec:$ [366.634800 even[366.636600 event clear 0x0000000010000000]
ec:$ [366.639600 ACPI query = 29]
t set 0x0000000010000000]
ec:$ [366.644300 HC 0x0067 err 9]
ec:$ [366.645100 body_detect changed state to: on body]
Signed-off-by: Josh Tsai <josh_tsai@compal.corp-partner.google.com>
Change-Id: Ia42accf551e6a4ea02a573d63389d388309cd3b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3868880
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Reviewed-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/acpi.c | 6 | ||||
-rw-r--r-- | common/body_detection.c | 5 |
2 files changed, 11 insertions, 0 deletions
diff --git a/common/acpi.c b/common/acpi.c index c6fcfce417..6145cbc96a 100644 --- a/common/acpi.c +++ b/common/acpi.c @@ -5,6 +5,7 @@ #include "acpi.h" #include "battery.h" +#include "body_detection.h" #include "common.h" #include "console.h" #include "dptf.h" @@ -235,6 +236,11 @@ int acpi_ap_to_ec(int is_cmd, uint8_t value, uint8_t *resultptr) EC_ACPI_MEM_DDPN_MASK) << EC_ACPI_MEM_DDPN_SHIFT; #endif + +#ifdef CONFIG_BODY_DETECTION_NOTIFY_MODE_CHANGE + if (body_detect_get_state() == BODY_DETECTION_ON_BODY) + result |= BIT(EC_ACPI_MEM_STTB_SHIFT); +#endif break; case EC_ACPI_MEM_DEVICE_FEATURES0: diff --git a/common/body_detection.c b/common/body_detection.c index 848c4f08c1..e6b842ddf1 100644 --- a/common/body_detection.c +++ b/common/body_detection.c @@ -113,6 +113,11 @@ void body_detect_change_state(enum body_detect_states state, bool spoof) /* reset time counting of stationary */ stationary_timeframe = 0; } + +#ifdef CONFIG_BODY_DETECTION_NOTIFY_MODE_CHANGE + host_set_single_event(EC_HOST_EVENT_MODE_CHANGE); +#endif + /* state changing log */ CPRINTS("body_detect changed state to: %s body", motion_state ? "on" : "off"); |