diff options
author | Leila Lin <leilacy_lin@compal.corp-partner.google.com> | 2022-11-24 23:40:53 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-12-13 03:01:16 +0000 |
commit | 66bb9ab754a109bdeae44f0376bf1a87a0e1fd10 (patch) | |
tree | 9276f4ed050a0dedd895e49f9cf1e7e658b963a3 | |
parent | d0df4832fef81ce55b9df6e374520c05db76b78c (diff) | |
download | chrome-ec-66bb9ab754a109bdeae44f0376bf1a87a0e1fd10.tar.gz |
hooks: Add HOOK_BODY_DETECT_CHANGE
Add HOOK_BODY_DETECT_CHANGE hook when CONFIG_BODY_DETECTION is
enabled to notify body detection's state is changing.
BRANCH=none
BUG=b:232946420
TEST=zmake build winterhold and confirm that the notification of
the hook has been received.
Change-Id: Ied9afeef41ee14d7f2de1b423d94600d076bb975
Signed-off-by: Leila Lin <leilacy_lin@compal.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4054308
Tested-by: LeilaCY Lin <leilacy_lin@compal.corp-partner.google.com.test-google-a.com>
Reviewed-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Commit-Queue: LeilaCY Lin <leilacy_lin@compal.corp-partner.google.com.test-google-a.com>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rw-r--r-- | common/body_detection.c | 3 | ||||
-rw-r--r-- | common/hooks.c | 3 | ||||
-rw-r--r-- | core/cortex-m/ec.lds.S | 6 | ||||
-rw-r--r-- | core/cortex-m0/ec.lds.S | 6 | ||||
-rw-r--r-- | core/host/host_exe.lds | 4 | ||||
-rw-r--r-- | core/minute-ia/ec.lds.S | 6 | ||||
-rw-r--r-- | core/nds32/ec.lds.S | 6 | ||||
-rw-r--r-- | core/riscv-rv32i/ec.lds.S | 6 | ||||
-rw-r--r-- | include/hooks.h | 9 | ||||
-rw-r--r-- | include/link_defs.h | 4 | ||||
-rw-r--r-- | zephyr/shim/include/hook_types.h | 36 |
11 files changed, 74 insertions, 15 deletions
diff --git a/common/body_detection.c b/common/body_detection.c index e6b842ddf1..819ced4679 100644 --- a/common/body_detection.c +++ b/common/body_detection.c @@ -6,6 +6,7 @@ #include "accelgyro.h" #include "body_detection.h" #include "console.h" +#include "hooks.h" #include "hwtimer.h" #include "lid_switch.h" #include "math_util.h" @@ -118,6 +119,8 @@ void body_detect_change_state(enum body_detect_states state, bool spoof) host_set_single_event(EC_HOST_EVENT_MODE_CHANGE); #endif + hook_notify(HOOK_BODY_DETECT_CHANGE); + /* state changing log */ CPRINTS("body_detect changed state to: %s body", motion_state ? "on" : "off"); diff --git a/common/hooks.c b/common/hooks.c index 3bd9689d64..88a6b93b93 100644 --- a/common/hooks.c +++ b/common/hooks.c @@ -53,6 +53,9 @@ static const struct hook_ptrs hook_list[] = { { __hooks_ac_change, __hooks_ac_change_end }, { __hooks_lid_change, __hooks_lid_change_end }, { __hooks_tablet_mode_change, __hooks_tablet_mode_change_end }, +#ifdef CONFIG_BODY_DETECTION + { __hooks_body_detect_change, __hooks_body_detect_change_end }, +#endif { __hooks_base_attached_change, __hooks_base_attached_change_end }, { __hooks_pwrbtn_change, __hooks_pwrbtn_change_end }, { __hooks_battery_soc_change, __hooks_battery_soc_change_end }, diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S index c11dc8f0a5..b6dc1dd7df 100644 --- a/core/cortex-m/ec.lds.S +++ b/core/cortex-m/ec.lds.S @@ -275,6 +275,12 @@ SECTIONS KEEP(*(.rodata.HOOK_TABLET_MODE_CHANGE)) __hooks_tablet_mode_change_end = .; +#ifdef CONFIG_BODY_DETECTION + __hooks_body_detect_change = .; + KEEP(*(.rodata.HOOK_BODY_DETECT_CHANGE)) + __hooks_body_detect_change_end = .; +#endif + __hooks_base_attached_change = .; KEEP(*(.rodata.HOOK_BASE_ATTACHED_CHANGE)) __hooks_base_attached_change_end = .; diff --git a/core/cortex-m0/ec.lds.S b/core/cortex-m0/ec.lds.S index 3c2076b9e4..c59973ebff 100644 --- a/core/cortex-m0/ec.lds.S +++ b/core/cortex-m0/ec.lds.S @@ -155,6 +155,12 @@ SECTIONS KEEP(*(.rodata.HOOK_TABLET_MODE_CHANGE)) __hooks_tablet_mode_change_end = .; +#ifdef CONFIG_BODY_DETECTION + __hooks_body_detect_change = .; + KEEP(*(.rodata.HOOK_BODY_DETECT_CHANGE)) + __hooks_body_detect_change_end = .; +#endif + __hooks_base_attached_change = .; KEEP(*(.rodata.HOOK_BASE_ATTACHED_CHANGE)) __hooks_base_attached_change_end = .; diff --git a/core/host/host_exe.lds b/core/host/host_exe.lds index b4c94c12ff..05943b408a 100644 --- a/core/host/host_exe.lds +++ b/core/host/host_exe.lds @@ -85,6 +85,10 @@ SECTIONS { KEEP(*(.rodata.HOOK_TABLET_MODE_CHANGE)) __hooks_tablet_mode_change_end = .; + __hooks_body_detect_change = .; + KEEP(*(.rodata.HOOK_BODY_DETECT_CHANGE)) + __hooks_body_detect_change_end = .; + __hooks_base_attached_change = .; KEEP(*(.rodata.HOOK_BASE_ATTACHED_CHANGE)) __hooks_base_attached_change_end = .; diff --git a/core/minute-ia/ec.lds.S b/core/minute-ia/ec.lds.S index be3e0fbf2e..81668fecc7 100644 --- a/core/minute-ia/ec.lds.S +++ b/core/minute-ia/ec.lds.S @@ -122,6 +122,12 @@ SECTIONS KEEP(*(.rodata.HOOK_TABLET_MODE_CHANGE)) __hooks_tablet_mode_change_end = .; +#ifdef CONFIG_BODY_DETECTION + __hooks_body_detect_change = .; + KEEP(*(.rodata.HOOK_BODY_DETECT_CHANGE)) + __hooks_body_detect_change_end = .; +#endif + __hooks_base_attached_change = .; KEEP(*(.rodata.HOOK_BASE_ATTACHED_CHANGE)) __hooks_base_attached_change_end = .; diff --git a/core/nds32/ec.lds.S b/core/nds32/ec.lds.S index 87f6d2041a..b97af1a679 100644 --- a/core/nds32/ec.lds.S +++ b/core/nds32/ec.lds.S @@ -151,6 +151,12 @@ SECTIONS KEEP(*(.rodata.HOOK_TABLET_MODE_CHANGE)) __hooks_tablet_mode_change_end = .; +#ifdef CONFIG_BODY_DETECTION + __hooks_body_detect_change = .; + KEEP(*(.rodata.HOOK_BODY_DETECT_CHANGE)) + __hooks_body_detect_change_end = .; +#endif + __hooks_base_attached_change = .; KEEP(*(.rodata.HOOK_BASE_ATTACHED_CHANGE)) __hooks_base_attached_change_end = .; diff --git a/core/riscv-rv32i/ec.lds.S b/core/riscv-rv32i/ec.lds.S index e62a7d1427..015ed12548 100644 --- a/core/riscv-rv32i/ec.lds.S +++ b/core/riscv-rv32i/ec.lds.S @@ -199,6 +199,12 @@ SECTIONS KEEP(*(.rodata.HOOK_TABLET_MODE_CHANGE)) __hooks_tablet_mode_change_end = .; +#ifdef CONFIG_BODY_DETECTION + __hooks_body_detect_change = .; + KEEP(*(.rodata.HOOK_BODY_DETECT_CHANGE)) + __hooks_body_detect_change_end = .; +#endif + __hooks_base_attached_change = .; KEEP(*(.rodata.HOOK_BASE_ATTACHED_CHANGE)) __hooks_base_attached_change_end = .; diff --git a/include/hooks.h b/include/hooks.h index 1002c7c93d..aebf7a3c7e 100644 --- a/include/hooks.h +++ b/include/hooks.h @@ -197,6 +197,15 @@ enum hook_type { */ HOOK_TABLET_MODE_CHANGE, +#ifdef CONFIG_BODY_DETECTION + /* + * Body dectection mode change. + * + * Hook routines are called from the HOOKS task. + */ + HOOK_BODY_DETECT_CHANGE, +#endif + /* * Detachable device connected to a base. * diff --git a/include/link_defs.h b/include/link_defs.h index ed7e9d1cfe..e54d23d974 100644 --- a/include/link_defs.h +++ b/include/link_defs.h @@ -64,6 +64,10 @@ extern const struct hook_data __hooks_lid_change[]; extern const struct hook_data __hooks_lid_change_end[]; extern const struct hook_data __hooks_tablet_mode_change[]; extern const struct hook_data __hooks_tablet_mode_change_end[]; +#ifdef CONFIG_BODY_DETECTION +extern const struct hook_data __hooks_body_detect_change[]; +extern const struct hook_data __hooks_body_detect_change_end[]; +#endif extern const struct hook_data __hooks_base_attached_change[]; extern const struct hook_data __hooks_base_attached_change_end[]; extern const struct hook_data __hooks_pwrbtn_change[]; diff --git a/zephyr/shim/include/hook_types.h b/zephyr/shim/include/hook_types.h index 004e5a52db..9b11a6c27a 100644 --- a/zephyr/shim/include/hook_types.h +++ b/zephyr/shim/include/hook_types.h @@ -26,27 +26,33 @@ #define HOOK_TYPES_USB_SUSPEND #endif +#if defined(CONFIG_BODY_DETECTION) || defined(_LINKER) +#define HOOK_TYPES_BODY_DETECTION HOOK_BODY_DETECT_CHANGE +#else +#define HOOK_TYPES_BODY_DETECTION +#endif + /* * HOOK_TYPES_LIST is a sequence of tokens that expands to every enabled * `enum hook_type` value. * * If the enum definition is changed, this macro must also be changed. */ -#define HOOK_TYPES_LIST \ - LIST_DROP_EMPTY( \ - HOOK_INIT, HOOK_PRE_FREQ_CHANGE, HOOK_FREQ_CHANGE, \ - HOOK_SYSJUMP, HOOK_CHIPSET_PRE_INIT, HOOK_CHIPSET_STARTUP, \ - HOOK_CHIPSET_RESUME, HOOK_CHIPSET_SUSPEND, \ - IF_ENABLED(CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK, \ - (HOOK_CHIPSET_RESUME_INIT, \ - HOOK_CHIPSET_SUSPEND_COMPLETE, )) \ - HOOK_CHIPSET_SHUTDOWN, \ - HOOK_CHIPSET_SHUTDOWN_COMPLETE, HOOK_CHIPSET_HARD_OFF, \ - HOOK_CHIPSET_RESET, HOOK_AC_CHANGE, HOOK_LID_CHANGE, \ - HOOK_TABLET_MODE_CHANGE, HOOK_BASE_ATTACHED_CHANGE, \ - HOOK_POWER_BUTTON_CHANGE, HOOK_BATTERY_SOC_CHANGE, \ - HOOK_TYPES_USB_SUSPEND, HOOK_TICK, HOOK_SECOND, \ - HOOK_USB_PD_DISCONNECT, HOOK_USB_PD_CONNECT, \ +#define HOOK_TYPES_LIST \ + LIST_DROP_EMPTY( \ + HOOK_INIT, HOOK_PRE_FREQ_CHANGE, HOOK_FREQ_CHANGE, \ + HOOK_SYSJUMP, HOOK_CHIPSET_PRE_INIT, HOOK_CHIPSET_STARTUP, \ + HOOK_CHIPSET_RESUME, HOOK_CHIPSET_SUSPEND, \ + IF_ENABLED(CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK, \ + (HOOK_CHIPSET_RESUME_INIT, \ + HOOK_CHIPSET_SUSPEND_COMPLETE, )) \ + HOOK_CHIPSET_SHUTDOWN, \ + HOOK_CHIPSET_SHUTDOWN_COMPLETE, HOOK_CHIPSET_HARD_OFF, \ + HOOK_CHIPSET_RESET, HOOK_AC_CHANGE, HOOK_LID_CHANGE, \ + HOOK_TABLET_MODE_CHANGE, HOOK_TYPES_BODY_DETECTION, \ + HOOK_BASE_ATTACHED_CHANGE, HOOK_POWER_BUTTON_CHANGE, \ + HOOK_BATTERY_SOC_CHANGE, HOOK_TYPES_USB_SUSPEND, HOOK_TICK, \ + HOOK_SECOND, HOOK_USB_PD_DISCONNECT, HOOK_USB_PD_CONNECT, \ HOOK_POWER_SUPPLY_CHANGE, HOOK_TYPES_TEST_BUILD) #endif |