From 7544159f1074e43fa8268de8738ae249f4ff0c6f Mon Sep 17 00:00:00 2001 From: Philip Chen Date: Fri, 9 Aug 2019 15:10:24 -0700 Subject: tablet_mode: Update DPTF profile number in hall_sensor_isr For the boards with GMR sensors, if we want to support mode-aware DPTF profiles, we can update DPTF profile number when the common TABLET_MODE ISR (a.k.a. hall_sensor_isr) is called, so we don't need a board-specific ISR to handle this operation. BUG=b:139168228 BRANCH=none TEST=buildall Change-Id: Icdb526c0e5e5ba9626f19a0de9332c0d06e8b0a7 Signed-off-by: Philip Chen Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1747061 Reviewed-by: Furquan Shaikh Commit-Queue: Philip Chen Tested-by: Philip Chen --- common/tablet_mode.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/common/tablet_mode.c b/common/tablet_mode.c index efd2252b97..7773ba84d6 100644 --- a/common/tablet_mode.c +++ b/common/tablet_mode.c @@ -3,6 +3,7 @@ * found in the LICENSE file. */ +#include "acpi.h" #include "console.h" #include "gpio.h" #include "hooks.h" @@ -70,12 +71,26 @@ void tablet_disable(void) #ifndef HALL_SENSOR_GPIO_L #error HALL_SENSOR_GPIO_L must be defined #endif +#ifdef CONFIG_DPTF_MOTION_LID_NO_HALL_SENSOR +#error The board has GMR sensor +#endif static void hall_sensor_interrupt_debounce(void) { hall_sensor_at_360 = IS_ENABLED(CONFIG_HALL_SENSOR_CUSTOM) ? board_sensor_at_360() : !gpio_get_level(HALL_SENSOR_GPIO_L); + /* + * DPTF table is updated only when the board enters/exits completely + * flipped tablet mode. If the board has no GMR sensor, we determine + * if the board is in completely-flipped tablet mode by lid angle + * calculation and update DPTF table when lid angle > 300 degrees. + */ + if (IS_ENABLED(CONFIG_HOSTCMD_X86) && IS_ENABLED(CONFIG_DPTF)) { + acpi_dptf_set_profile_num(hall_sensor_at_360 ? + DPTF_PROFILE_FLIPPED_360_MODE : + DPTF_PROFILE_CLAMSHELL); + } /* * 1. Peripherals are disabled only when lid reaches 360 position (It's * probably already disabled by motion_sense task). We deliberately do -- cgit v1.2.1