summaryrefslogtreecommitdiff
path: root/common/tablet_mode.c
Commit message (Collapse)AuthorAgeFilesLines
* tablet_mode: Console command to print the current tablet modeWai-Hong Tam2021-02-111-1/+11
| | | | | | | | | | | | | | The console command is useful to show the current tablet mode if no argument given. BRANCH=None BUG=b:158130073 TEST=Type the "tabletmode" command and check the output. Change-Id: I9dfe08a6a42ae9104d82587ee0688c8998d48cba Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2685408 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* tablet_mode: ensure that tablet mode is always initializedJett Rink2019-10-301-47/+54
| | | | | | | | | | | | | | | | | The board init should ensure that tablet_mode is always set so the rest of the subsystems can rely on this. We assume notebook mode if we don't have any input from the GSR 360 hall sensor. That matches the default up in AP firmware as well. BRANCH=none BUG=b:141494453,chromium:1010343 TEST=put arcada at 200 degrees and see that tablet mode it initialized correctly. Change-Id: I4e23d3ba149f9add84f9667a5af676803cf50da5 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1845779 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* tablet_mode: Renaming for GMR sensorPhilip Chen2019-09-191-28/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GMR sensors can be used to (1) detect clamshell/tablet mode (2) detect lid open/closed But hall sensors can only do (2). Therefore the naming related to "hall sensor" for tablet mode application is incorrect. This patch performs the following renaming to better reflect the reality: config: CONFIG_HALL_SENSOR -> CONFIG_GMR_TABLET_MODE CONFIG_HALL_SENSOR_CUSTOM -> CONFIG_GMR_TABLET_MODE_CUSTOM CONFIG_DPTF_MOTION_LID_NO_HALL_SENSOR -> CONFIG_DPTF_MOTION_LID_NO_GMR_SENSOR GPIO: HALL_SENSOR_GPIO_L -> GMR_TABLET_MODE_GPIO_L functions: hall_sensor_disable() -> gmr_tablet_switch_disable() hall_sensor_isr() -> gmr_tablet_switch_isr() hall_sensor_int() -> gmr_tablet_switch_init() variable: hall_sensor_at_360 -> gmr_sensor_at_360 BUG=b:139378190 BRANCH=none TEST=make buildall Change-Id: I28393d056ddd128d8ffafc16a1f9fefee5455ccc Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1757275 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* tablet_mode: expose console command.Ravi Chandra Sadineni2019-09-121-0/+37
| | | | | | | | | | | | | | Expose console command to force tablet mode. This helps in testing whether a given device wakes on tablet mode switch. BUG=b:133262012 BRANCH=None TEST=Deploy on hatch and play with the command. Change-Id: Id6ffbf5226590e10a0758a07761f78024d57bb58 Signed-off-by: Ravi Chandra Sadineni <ravisadineni@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1797370 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* tablet_mode: Update DPTF profile number in hall_sensor_isrPhilip Chen2019-09-071-0/+15
| | | | | | | | | | | | | | | | | | 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 <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1747061 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* PoC: tablet-mode: Disable tablet mode in recovery bootDaisuke Nojiri2019-07-291-2/+7
| | | | | | | | | | | | | | | | | | | | | | | In recovery boot, keyboard could be unintentionally disabled due to unstable accels, which are not calibrated. This patch disables tablet mode in recovery boot. We get the same effect if motion sensors or a motion sense task are disabled in RO. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=chromium:984086,b/137251616 BRANCH=none TEST=buildall Change-Id: Idcf53ad119edbd8ff9362523ec7a72f438ae4401 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1696914 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* tabletmode: ignore lid angle if hall sensor activeJett Rink2019-05-181-15/+27
| | | | | | | | | | | | | | | | | | | | If the 360 degree hall sensor is active, then we should remain in tablet mode even if the lid angle says we are 1 degree since an angle of 360 could wrap around to 1 degree. Also ensure that tablet mode always gets initialized to the correct state at startup (by setting initial value to -1) BRANCH=R75 BUG=b:131785573,b:132178305 TEST=NB_MODE# on arcada does not flutter when the device is at 360 degrees with CL stack. Change-Id: I962a9c23205766080a65d741c6c425452d9de608 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1597189 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* tablet_mode: Set EC_HOST_EVENT_MODE_CHANGE in tablet_set_mode()Edward Hill2019-03-141-0/+9
| | | | | | | | | | | | | | Move setting of EC_HOST_EVENT_MODE_CHANGE out of dptf.c so it works on devices that don't use DPTF. BUG=b:124132058 BRANCH=grunt TEST=evtest shows tablet mode events Change-Id: Ie880dfb49838e9f564f755cb18872c9832a3aa91 Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1524621 Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* tablet_mode: Introduce hall sensor specific handlingFurquan Shaikh2018-11-291-23/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change performs the following renaming: 1. CONFIG_TABLET_SWITCH -> CONFIG_HALL_SENSOR Indicates if a device has hall sensor 2. TABLET_MODE_GPIO_L -> HALL_SENSOR_GPIO_L Provides the interrupt line from hall sensor to EC. 3. tablet_mode_isr -> hall_sensor_isr Interrupt routine that gets control on hall sensor interrupt. 4. tablet_mode_init -> hall_sensor_init Init routine for initializing hall sensor interrupt. 5. tablet_switch_disable -> hall_sensor_disable Disable hall sensor interrupt and tablet mode sub-system. This is done to separate hall sensor interrupt from tablet mode handling. It is another step towards aligning tablet mode detection on EC with Chrome. Hall sensor interrupt occurs when the lid is in 360-degree flipped mode. If tablet mode is not already triggered by lid motion driver, then hall_sensor_isr will set tablet mode and take necessary actions to disable input peripherals. CQ-DEPEND=CL:1351518 BUG=b:120050761 BRANCH=octopus TEST=make -j buildall Change-Id: I5841f6875d538a624cb888bc048f252397ab457c Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/1350469 Commit-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* tablet-mode: add disable functionJett Rink2018-09-041-0/+20
| | | | | | | | | | | | | | | | For clamshell SKUs, we do not want to ever enable tablet mode. Since the firmware is shared between convertibles and clamshells, we need to compile in the tablet mode switch support but have a way to disable it at run-time BRANCH=none BUG=b:113837268 TEST=verify that a clamshell SKU does not go into tablet mode when a free magnet gets close to the sensor (with CL stack) Change-Id: Icc0f72253014f05598d658601eb8437bfe0ff488 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1204451
* whiskers: Expose a switch for tablet modeNicolas Boichat2018-06-061-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | With this, whiskers exposes a tablet mode switch to inform the lid when the base is flipped around. We take this opportunity to clean up a bit whiskers/keyboard code: - Use tablet mode switch instead of lid switch - Refactor usb_hid_keyboard.c to accept either assistant key or tablet mode switch, or both. - Remove bit-field usage in HID report struct, and instead, generalize with an "extra" field that can be used for additional key/switches. BRANCH=none BUG=b:73133611 TEST=Flash whiskers, see that tablet mode events are sent when a magnet approaches the hall sensor. Change-Id: Ibf43bb04fdc867d18d9f318388d1ebd17b49d47f Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1077915 Reviewed-by: Wei-Han Chen <stimim@chromium.org>
* common: drop unnecessary line endingVadim Bendebury2018-05-161-1/+1
| | | | | | | | | | | | | | CPRINTS() macro is already adding the newline character, no need to include it explicitly. BRANCH=none BUG=none TEST=vefied that Coral EC does not print this newline any more Change-Id: I1f6b1fcb90818a8d4a2d18cf5060669fc46d38a7 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1062588 Reviewed-by: Jett Rink <jettrink@chromium.org>
* tablet_mode: Define common interrupt handler for tablet switchDaisuke Nojiri2018-05-091-5/+51
| | | | | | | | | | | | | | | | | | | | This patch adds an interrupt handler for a tablet switch and an init hook to enable the interrupt. The handler does the typical tasks for convertible devices: 1. sets tablet mode then 2. disables peripherals if tablet mode is on. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:77298177 BRANCH=none TEST=buildall. Verify on Nami. Change-Id: If7fb5ea15f388d2b6084d800d2bc05efafd1945e Reviewed-on: https://chromium-review.googlesource.com/1043057 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* motion: Disable tablet mode if one accel is brokenGwendal Grignou2017-01-041-1/+6
| | | | | | | | | | | | | | | | We need 2 accelerometer for tablet mode. If one of them is not working, disable tablet mode. We will stay in clamshell mode, lid angle will be always unreliable. BUG=chrome-os-partner:61141 TEST=On kevin with a single sensor. Check we are in clamshell mode when rebooting the EC. BRANCH=kevin Change-Id: I7bf6cdc9d85370fce20e5183622b4bc18f4f5f99 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/424184 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* common: Add tablet_mode APIGwendal Grignou2016-11-081-0/+18
Simple API to set/get the tablet mode. It can be set via lid angle calculation or if a board has a dedicated HAL sensor/GPIO. Merged from glados branch, add MKBP switch support. BUG=chromium:606718 BRANCH=gru TEST=Check with Cave that both mode works. Reviewed-on: https://chromium-review.googlesource.com/402089 Reviewed-by: Shawn N <shawnn@chromium.org> (cherry picked from commit c940f36ceabcf2425284001298f03ebdb4c3079e) Change-Id: I2ee5130f3e0a1307ec3ea543f7a32d66bc32b31d Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/404915 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>