summaryrefslogtreecommitdiff
path: root/common/keyboard_scan.c
Commit message (Collapse)AuthorAgeFilesLines
* common/keyboard_scan: Enable the SEARCH key in the default maskRajat Jain2020-03-031-1/+1
| | | | | | | | | | | | | | The SEARCH key on Row-3, Col-0 is now standard on Chromeos keyboards. Lets enable it by default. BUG=b:148488560,b:146501925 TEST=Build BRANCH=firmware-hatch-12672.B Signed-off-by: Rajat Jain <rajatja@google.com> Change-Id: I9164a7e2894d70599a2c2eb25ecb2408e3b1eebe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2080599 Reviewed-by: Scott Collyer <scollyer@chromium.org>
* keyboard_scan: detect inconsistent state in read_matrixTing Shen2019-12-121-17/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current read_matrix() function didn't handle keyboard state change during the scanning loop. For example, consider keys J(c6r4), L(c9r4), H(c6r1) and F9(c9r1), and the following sequence: - User presses and holds J - Key scan task reads col 6, got state[6] = 0x10 (J) - User presses H+J+L, ghost key F9 is also "pressed" at this point. - Key scan task reads col 9, got state[9] = 0x12 (L+F9) - state[6] and state[9] has only one common bit, so it passes has_ghosting check. - EC thinks J+L+F9 clicked. Implemented a simple heuristic to detect this case, and update state[] array to something likely to be the state after the key press. With this change, we will no longer distinguish J -> H+J+L and J->F9+J+L. The latter used to be accepted but it'll be rejected by this change. BUG=b:145405136 TEST=hold J and L, press H repeatedly, make sure F9 never triggered. BRANCH=kukui,hatch TEST=make run-kb_scan (uncomment kb_scan in test/build.mk). TEST=The average wait_time is reduced about 100 usec on Nami: 1746 msec (old) v.s. 1636 msec (new). Change-Id: Ia20d5a283639d291530e5983254f6163f5c3537f Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1955105 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org>
* Cleanup: Correct GPIO alternate function parameterVijay Hiremath2019-11-011-1/+2
| | | | | | | | | | | | | | | Added code to correct the GPIO alternate function parameter at Chipset level. Optionally board level functions can cleanup the code in additional change lists. BUG=b:139427854 BRANCH=none TEST=make buildall -j Change-Id: I1171ca36a703291070fc89f972f84414adcf04fc Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1880974 Reviewed-by: Keith Short <keithshort@chromium.org>
* printf: Convert %T to %pTEvan Green2019-10-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | In order to be more compliant to standards, and ultimately turn on compile-time printf format validation, switch the non-standard %T into %pT, which takes a pointer to a 64-bit timestamp as an argument. For convenience, define PRINTF_TIMESTAMP_NOW, which will use the current time as the timestamp value, rather than forcing everyone to pass a pointer to get_time().val. For a couple of instances, simply use CPRINTS instead. BUG=chromium:984041 TEST=make -j buildall BRANCH=None Cq-Depend:chrome-internal:1473305 Change-Id: I83e45b55a95ea27256dc147544ae3f7e39acc5dd Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704216 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* host_command: Change host command return value to enum ec_statusTom Hughes2019-10-021-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the host command handler callback function returns an int, it's easy to accidentally mix up the enum ec_error_list and enum ec_status types. The host commands always expect an enum ec_status type, so we change the return value to be of that explicit type. Compilation will then fail if you accidentally try to return an enum ec_error_list value. Ran the following commands and then manually fixed up a few remaining instances that were not caught: git grep --name-only 'static int .*(struct host_cmd_handler_args \*args)' |\ xargs sed -i 's#static int \(.*\)(struct host_cmd_handler_args \*args)#\ static enum ec_status \1(struct host_cmd_handler_args \*args)##' git grep --name-only 'int .*(struct host_cmd_handler_args \*args)' |\ xargs sed -i 's#int \(.*\)(struct host_cmd_handler_args \*args)#\ enum ec_status \1(struct host_cmd_handler_args \*args)##' BRANCH=none BUG=chromium:1004831 TEST=make buildall -j Cq-Depend: chrome-internal:1872675 Change-Id: Id93df9387ac53d016a1594dba86c6642babbfd1e Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1816865 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* include: Move RESET_FLAG_* into ec_commands.h as EC_RESET_FLAG_*You-Cheng Syu2019-08-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | RESET_FLAGS_* are used when setting/reading the field ec_reset_flags of struct ec_response_uptime_info, which is defined in ec_commands.h. So it might be better to put those macros there. To be consistent with the other macros in the file, add "EC_" prefixes to them. BUG=b:109900671,b:118654976 BRANCH=none TEST=make buildall -j Cq-Depend: chrome-internal:1054910, chrome-internal:1054911, chrome-internal:1045539 Change-Id: If72ec25f1b34d8d46b74479fb4cd09252102aafa Signed-off-by: You-Cheng Syu <youcheng@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1520574 Tested-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Ready: Yu-Ping Wu <yupingso@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* PoC: tablet-mode: Disable tablet mode in recovery bootDaisuke Nojiri2019-07-291-0/+11
| | | | | | | | | | | | | | | | | | | | | | | 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>
* ec: Remove extraneous new line as the end of CPRINTS stringsNicolas Boichat2019-06-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | CPRINTS already prints a new line, no need to add another one. Spotted during boot on kukui, and then realized there are many more instances: "" [3.689239 Module 7 is not supported for clock disable ] "" BRANCH=none BUG=none TEST=make buildall -j TEST=`git grep CPRINTS | grep "\\\\n\""` shows nothing of interest. Change-Id: I4d2bbbc65a91fa56c6e6115aa5c353bfd2b384a1 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1660519 Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* LICENSE: remove unnecessary (c) after CopyrightTom Hughes2019-06-191-1/+1
| | | | | | | | | | | | | | | | Ran the following command: git grep -l 'Copyright (c)' | \ xargs sed -i 's/Copyright (c)/Copyright/g' BRANCH=none BUG=none TEST=make buildall -j Change-Id: I6cc4a0f7e8b30d5b5f97d53c031c299f3e164ca7 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1663262 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* keyboard_scan: Send kb events at start of debouncing period.Jes Klinke2019-06-111-40/+27
| | | | | | | | | | | | | | | | | | | | Current behavior is to start a timer upon first detecting a transition of any one cell of the keyboard matrix, and then generate a keyboard event (press or release) only after that timer has expired. Due to the fact that the release timer has a longer period than the press timer, in some cases, e.g. releasing the shift key right before depressing another key, events could end up getting re-ordered. BUG=chromium:547131 BRANCH=master TEST=make run-kb_scan Signed-off-by: Jes Klinke <jbk@google.com> Change-Id: If3de2e629dc9df4325d8c17590d6624a41e27187 Bug: 547131 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1579905 Tested-by: Jes Klinke <jbk@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jes Klinke <jbk@chromium.org>
* common: bit change 1 << constants with BIT(constants)Gwendal Grignou2019-03-261-5/+5
| | | | | | | | | | | | | | | | | Mechanical replacement of bit operation where operand is a constant. More bit operation exist, but prone to errors. Reveal a bug in npcx: chip/npcx/system-npcx7.c:114:54: error: conversion from 'long unsigned int' to 'uint8_t' {aka 'volatile unsigned char'} changes value from '16777215' to '255' [-Werror=overflow] BUG=None BRANCH=None TEST=None Change-Id: I006614026143fa180702ac0d1cc2ceb1b3c6eeb0 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1518660 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* Keyboard: Consolidate keyboard factory testsDaisuke Nojiri2018-12-171-0/+63
| | | | | | | | | | | | | | | | | This patch consolidates keyboard factory tests, which are currently duplicated under the chip directories. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=none TEST=buildall Change-Id: I1ab8bc96808e1c284d991d3c2f1f82a37329676e Reviewed-on: https://chromium-review.googlesource.com/1378654 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* Keyboard: Allow keyboard size to be set at run timeDaisuke Nojiri2018-10-191-24/+29
| | | | | | | | | | | | | | | | | | | | | | | Currently, the keyboard size (i.e. number of columns) is static. This patch allows it to be configured at run time. It's required to support a keyboard with/without keypad in a single image. KEYBOARD_COLS_MAX has the build time col size. It's used to allocate exact spaces for arrays. Actual keyboard scanning is done using keyboard_cols, which holds a runtime col size. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:117126568 BRANCH=none TEST=Verify keyboard functionality on Sona and Veyron. Change-Id: I4b3552be0b4b315c3fe5a6884cf25e10aba8be7c Reviewed-on: https://chromium-review.googlesource.com/1285292 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* keyboard: Ignore refresh button at bootDaisuke Nojiri2018-09-071-2/+0
| | | | | | | | | | | | | | | | | | | | | | | Any buttons except esc, left-shift, and down-arrow are considered as 'other key' and can cancel recovery mode entry if it's pressed at boot. On some chromebooks (e.g. Grunt, Nami), the refresh key is not scanned early enough (i.e. before the power button is released). Thus, the refresh key unintentionally cancels recovery mode entry. This change makes the EC ignore the refresh key at boot. This is already done for Grunt using CONFIG_KEYBOARD_IGNORE_REFRESH_BOOT_KEY. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:114134666 BRANCH=none TEST=Put Akali in recovery mode without holding power button long. Change-Id: I57d7cb8fb320a4960125cd96d4d3ae84687a74df Reviewed-on: https://chromium-review.googlesource.com/1208229 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* reset: Log the reason for AP resets.Jonathan Brandmeyer2018-07-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Provides a new EC host command 'uptime info' which gathers up some information which may be useful for debugging spurious resets on the AP (was the EC reset recently? Why was the EC reset? If the EC reset the AP, why did it do so?, etc.). Provide ectool support for the same. Example results of `ectool uptimeinfo`: ``` localhost ~ # ectool uptimeinfo EC uptime: 475.368 seconds AP resets since EC boot: 2 Most recent AP reset causes: 315.903: reset: console command 363.507: reset: keyboard warm reboot EC reset flags at last EC boot: reset-pin | sysjump ``` BRANCH=none TEST=Perform some `apreset` commands from the EC console and observe their side-effects via the `ectool uptimeinfo` command on the AP side. Test sequences include no-resets through 5 resets, observing that the ring buffer handling was correct. BUG=b:110788201, b:79529789 Signed-off-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Change-Id: I0bf29d69de471c64f905ee8aa070b15b4f34f2ba Reviewed-on: https://chromium-review.googlesource.com/1139028 Commit-Ready: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Tested-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* ec/google: Add command to fetch keyboard ID from ECparis_yeh2018-06-201-0/+21
| | | | | | | | | | | | | | | | | Sort k-prefix host commands and descriptions in alphabetical order BRANCH=master BUG=b:80168723 TEST=Check 'ectool kbid' on a reworked DUT using keyboard samples Change-Id: If2ad654e5ef269d03365db7c3286c2281aa9d9ef Signed-off-by: paris_yeh <pyeh@google.com> Reviewed-on: https://chromium-review.googlesource.com/1097997 Commit-Ready: Paris Yeh <pyeh@chromium.org> Tested-by: Paris Yeh <pyeh@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Paris Yeh <pyeh@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* keyboard_scan: Add "ksstate force" to always scan KB matrixNicolas Boichat2018-06-081-3/+9
| | | | | | | | | | | | | | | | | | | | For early bringup, or failure analysis, it is sometimes useful to be able to force enable the keyboard matrix scanning, even though other signals (lid close, usb off) would normally disable it. The only way to disable the scanning again is to wait for an lid/USB event, or reboot the board, which is ok as this is for debugging purpose only. BRANCH=none BUG=b:109743721 TEST=Provide power to whiskers via servo only. ksstate force => key presses are shown Change-Id: I3eaa9552ea52f7e3df45fdb6c8d0aa88c7b164b3 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1090350 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* keyboard_scan: Add option to support keyboards with language IDparis_yeh2018-05-301-0/+37
| | | | | | | | | | | | | | | | | | | | | | | ID pins are considered additional KSOs while keycode scanning works for the existing KSI0 ~ KSI7. While diriving ID pins, the state of interconnection between ID pins and KSI pins could be used for identifiers to tell keyboard itself. (e.g. US, Japan,and UK keyboard) BRANCH=master BUG=b:80168723 TEST="make -j buildall" TEST=Verified 5 distinct keyboard samples w/ different Language ID values on the same reworked Coral, which VOL_UP and VOL_DOWN were reworked for ID pins. crrev.com/c/1053617 is my experimental patch on top of this for further verification Change-Id: I1d6e647df74c50d60bc1264c045b2587d0bf23d8 Signed-off-by: paris_yeh <pyeh@google.com> Reviewed-on: https://chromium-review.googlesource.com/1068951 Commit-Ready: Paris Yeh <pyeh@chromium.org> Tested-by: Paris Yeh <pyeh@chromium.org> Reviewed-by: Paris Yeh <pyeh@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* keyboard_scan: Add refresh and power button boot key optionsEdward Hill2018-05-161-6/+10
| | | | | | | | | | | | | | | | | | | | | | | Make Esc+Refresh+Power on Grunt enter Recovery Mode. If Power is released fast: [0.045303 KB init state: -- 02 08 -- -- -- -- -- -- -- -- -- --] Add CONFIG_KEYBOARD_IGNORE_REFRESH_BOOT_KEY to handle this case. If Power is held longer: [0.045448 KB init state: 08 0a 08 08 08 -- 08 -- 08 08 -- 08 08] Add CONFIG_KEYBOARD_PWRBTN_ASSERTS_KSI3 to handle this case. BUG=b:79758966 BRANCH=none TEST=Esc+Refresh+Power gives recovery screen on Grunt Change-Id: I43a7d485535ff7b0d9bfce59f28c0049ee989818 Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1063032 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
* Code cleanup: Remove cold reset logicVijay Hiremath2018-04-031-1/+1
| | | | | | | | | | | | | | | | | | | | | Majority of the chipsets do not have a dedicated GPIO to trigger AP cold reset. Current code either ignores cold reset or does a warm reset instead or have a work around to put AP in S5 and then bring back to S0. In order to avoid the confusion, removed the cold reset logic and only apreset is used hence forth. BUG=b:72426192 BRANCH=none TEST=make buildall -j Manually tested on GLKRVP, apreset EC command can reset AP. Change-Id: Ie32d34f2f327ff1b61b32a4d874250dce024cf35 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/991052 Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* keyboard_scan: Disable when USB is suspended without wakeNicolas Boichat2018-02-051-0/+16
| | | | | | | | | | | | | | | | Keyboard matrix scanning can be disabled when the USB interface is disabled without setting the remote wake feature (USB_REQ_FEATURE_DEVICE_REMOTE_WAKEUP), as events would be ignored anyway. BRANCH=none BUG=b:72683995 TEST=keyboard matrix scanning is disabled when lid is closed. Change-Id: I0b2346cc3426b9ef51127424f9953fd5c20ecd49 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/897068 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Fix inconsistent task function declarationsStefan Reinauer2017-08-081-1/+1
| | | | | | | | | | | | | | | Tasks are defined inconsistently across the code base. Signed-off-by: Stefan Reinauer <reinauer@google.com> BRANCH=none TEST=make buildall -j, also verify kevin boots to OS BUG=none Change-Id: I19a076395a9a8ee1e457e67a89d80d2f70277c97 Reviewed-on: https://chromium-review.googlesource.com/602739 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* keyboard_scan: Add option to not handle boot key combinationsNicolas Boichat2017-05-081-0/+8
| | | | | | | | | | | | | | | | | | On some boards, the boot key combinations do not make a lot of sense, so we can just not process them and save a little bit of code space. BRANCH=none BUG=b:37422577 TEST=Flash hammer TEST=make newsizes shows we save 156 bytes in hammer RW. Change-Id: Ic96d7ed1dbee10f44f8b08568ab70b2f20961842 Reviewed-on: https://chromium-review.googlesource.com/495968 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* keyboard_scan: Add option to not handle special key combinationsNicolas Boichat2017-05-081-0/+4
| | | | | | | | | | | | | | | | | On some boards, the special alt-volup-r/h combinations do not make a lot of sense, so we can just not process them and save a little bit of code space. BRANCH=none BUG=b:37422577 TEST=Flash hammer, alt-volup-r/h does not do anything special TEST=make newsizes shows we save 124 bytes in hammer RW. Change-Id: I92770fd6b8ff90780162a6b1de428a550bb44e9b Reviewed-on: https://chromium-review.googlesource.com/495967 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* keyboard: Clear typematic when disabling keyboardDaisuke Nojiri2017-05-031-2/+4
| | | | | | | | | | | | | | | | This patch clears the typematic buffer when disabling keyboard scan. When the device goes to tablet mode with a key being pressed, this should prevent keyboard_protocol_task from sending scan codes to the host. BUG=b:35585725 BRANCH=none TEST=make buildall. Tested on Electro. Change-Id: I73e9d2948b472458814967307412aebeb410ff2e Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/425075 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* keyboard: Always call keyboard_state_changedNicolas Boichat2016-11-171-3/+5
| | | | | | | | | | | | | | | 8042 and USB HID keyboard will both use that function. Let's just make it a no-op in the MKBP case. BRANCH=none BUG=chrome-os-partner:59083 TEST=make buildall -j Change-Id: Iaee1bf2c6edff3db28f3db89fc292f9d1064483b Reviewed-on: https://chromium-review.googlesource.com/411602 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* include/host_command: Conditionally define host event functionsNicolas Boichat2016-11-161-0/+2
| | | | | | | | | | | | | | | | | | | Some functions are only defined if CONFIG_HOSTCMD_EVENTS is set, leading to link-time failures. In particular, do not call these functions from keyboard_scan, and do not define PD host event commands if the configuration option is not set. BRANCH=none BUG=chrome-os-partner:59083 TEST=make buildall -j Change-Id: I0da31cdec08f86f148aa883698a44f462de46d8e Reviewed-on: https://chromium-review.googlesource.com/410923 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* common: Add new recovery mode button combinationFurquan Shaikh2016-11-081-36/+45
| | | | | | | | | | | | | | | | | | This adds new key combination (Left_Shift+Esc+Refresh+Power) that triggers recovery mode by setting a new host event EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT. This host event can be used whenever user wants to request entry into recovery mode by reinitializing all the hardware state (e.g. memory retraining). BUG=chrome-os-partner:56643,chrome-os-partner:59352 BRANCH=None TEST=Verified that device retrains memory in recovery mode with (Left_Shift+Esc+Refresh+Power) on reef. Change-Id: I2e08997acfd9e22270b8ce7a5b589cd5630645f8 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/407827 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Use CONFIG_KEYBOARD_DEBUG for keyboard debug printfGwendal Grignou2016-10-081-3/+11
| | | | | | | | | | | | Remove keyboard printk like: KB wait/poll when not debugging keyboard. BUG=none BRANCH=none TEST=compile. Change-Id: I9743eab4597d2b661ae7b21c0aab4e1ffdcdb9a4 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/394068
* cleanup: DECLARE_CONSOLE_COMMAND only needs 4 argsBill Richardson2016-08-241-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Since pretty much always, we've declared console commands to take a "longhelp" argument with detailed explanations of what the command does. But since almost as long, we've never actually used that argument for anything - we just silently throw it away in the macro. There's only one command (usbchargemode) that even thinks it defines that argument. We're never going to use this, let's just get rid of it. BUG=none BRANCH=none CQ-DEPEND=CL:*279060 CQ-DEPEND=CL:*279158 CQ-DEPEND=CL:*279037 TEST=make buildall; tested on Cr50 hardware Everything builds. Since we never used this arg anyway, there had better not be any difference in the result. Change-Id: Id3f71a53d02e3dc625cfcc12aa71ecb50e35eb9f Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/374163 Reviewed-by: Myles Watson <mylesgw@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* keyboard_scan: Support boot key recognition with stuck KSI2Shawn Nematbakhsh2016-06-301-0/+15
| | | | | | | | | | | | | | | | | For certain board configurations, KSI2 will be stuck asserted for all scan columns if the power button is held. We must be aware of this case in order to correctly handle recovery mode key combinations. BUG=chrome-os-partner:54602 BRANCH=None TEST=Manual on gru. Do three-key salute, verify EC detects recovery mode. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I03d76e1121107484f79520745858388f6cae096c Reviewed-on: https://chromium-review.googlesource.com/357590 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* lid_switch: disable keyboard scan based on the initial lid stateKevin K Wong2016-06-131-0/+1
| | | | | | | | | | | | | | | | | If the lid is initially closed, keyboard scan should be disabled. BUG=chrome-os-partner:53566 BRANCH=none TEST=Check ESC+Refresh+PwrBtn is detected. Check keyscan is enabled if lid is open. Check keyscan is disabled if lid is closed. Check power button is functional if lid is opened. Check power button is masked if lid is closed. Change-Id: I2354a657d8bf0c13207517cc789547a68befd240 Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com> Reviewed-on: https://chromium-review.googlesource.com/351534 Reviewed-by: Shawn N <shawnn@chromium.org>
* ectool: Support keyboard factory scanningDevn Lu2016-04-011-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | This is keyboard test mechanism request for "multiple key press test", we can thru the testing to scan out kso ksi pins shortting or keyboard has multiple key pressing, below was the testing steps: 1. Turn off internal keyboard scan function. 2. Set all scan & sense pins to input and internal push up. 3. Set start one pin to output low. 4. check other pins status if any sense low level. 5. repeat step 3~4 for all keyboard KSO/KSI pins. 6. Turn on internal keyboard scan function. BUG=chrome-os-partner:49235 BRANCH=ToT TEST=manual Short any KSO or KSI pins and excute "ectool kbfactorytest", it shows failed. if no pins short together, it shows passed. Change-Id: Id2c4310d45e892aebc6d2c0795db22eba5a30641 Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Reviewed-on: https://chromium-review.googlesource.com/332322 Reviewed-by: Shawn N <shawnn@chromium.org>
* keyboard: Fix kbpress after recent keyboard changeDouglas Anderson2016-01-041-1/+11
| | | | | | | | | | | | | | | After commit 98ab7484d331 ("keyboard: prevent races enabling/disabling kb scanning") kbpress was totally broken, which wasn't so good for FAFT. Fix it by making sure we go into polling mode for simulated keyboard presses. BUG=chrome-os-partner:48849 TEST=kbpress works Change-Id: Icd663c2ee7a184e6af4438368595087b35724a4f Signed-off-by: Douglas Anderson <dianders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/319586 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* keyboard: prevent races enabling/disabling kb scanningDouglas Anderson2015-12-141-26/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | keyboard_scan_enable() is called from several contexts. From a skim of the code I found: * keyboard_lid_change(), which is called from HOOK_LID_CHANGE * enable_keyboard(), which is called from HOOK_CHIPSET_RESUME * lidangle_keyscan_update(), which is called from motion_sense_task. * check_for_power_off_event() which is called from power_handle_state() which is called from chipset_task. * power_button_interrupt(), which is an interrupt * power_button_change_deferred(), which is a deferred function So, ummm, it's probably not a good idea to do a read-modify-write of a variable without any locking. ...and then to act on the resultant state in various different contexts. It's presumed that's just what happened to poor Julius. Julius found himself in the unfortunate situation where he resumed his device (with the power button, I believe) and that everything worked (including reading the battery state and including the accelerometer) but the keyboard didn't work. Now, it should be noted that Julius is a little strange. Well, maybe he's not strange and maybe just the way he uses his laptop is strange. He uses his veyron_minnie device as a smart keyboard/trackpad. Said another way: it is in tablet mode but is docked to an HDMI monitor, the screen is face flat on his table, and he uses the builtin keyboard and trackpad. Nobody else that I know does this. It's pretty darn cool, but I just don't think anyone else would think of it. Anyway, that might have something to do with how he reproduced this. ...or it might not. He does that a lot and hasn't seen the problem before now. Anyway, I managed to reproduce a number of problems similar to what poor Julius saw by adding a 200ms sleep in keyboard_scan_enable() after we read disable_scanning_mask but before we did anything to it (I skipped the sleep if this happened to be one of those people who was calling from interrupt). Since there appears to be no spin_lock_irqsave() in the EC, let's just have the EC use atomic operations to mess with its masks. Then we'll leave all heavy lifting to the task. This requires thinking through the task code a bit. Conflicts: common/keyboard_scan.c ...due to commit 6112f20679df ("common: keyboard_scan: Add items to .bss.slow.") in ToT. BRANCH=ToT BUG=chrome-os-partner:48470 TEST=Poke a lot with power button and lid; NTF. Change-Id: I61b906505100186b0ca2c48e7b1a7ffaaa8a7d3e Signed-off-by: Douglas Anderson <dianders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/317896 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit 98ab7484d331a78fced870b58b4d82e79e2e0f4e) Reviewed-on: https://chromium-review.googlesource.com/318292
* common: keyboard_scan: Add items to .bss.slow.Aseda Aboagye2015-11-111-12/+19
| | | | | | | | | | | | | | | | | | | | | BUG=chrome-os-partner:46056 BUG=chrome-os-partner:46063 BRANCH=None TEST=Enable CONFIG_REPLACE_LOADER_WITH_BSS_SLOW on GLaDOS. Build, flash, and verify that AP and EC boot. Perform typing test with no jank or other oddities. TEST='sysjump rw' and repeat the typing test. TEST=Hold down arrow down and issue 'reboot' command. TEST=make -j buildall tests CQ-DEPEND=CL:311209 Change-Id: I35911862af2a4e9feb795b2a9a2aafa97687e2f2 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/311411 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Keyboard: Add a macro to conditionally compile the console commandsVijay Hiremath2015-08-281-1/+2
| | | | | | | | | | | | | | | | | | | | Added macros to conditionally compile the keyboard test console commands to save the memory. These macros can be enabled/disabled in the board specific files. BUG=none TEST=make buildall -j BRANCH=none Change-Id: I3ad190f1f3c9310e4f706b3b23cb8ca8755e49ef Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/295942 Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com> Commit-Ready: Divya Jyothi <divya.jyothi@intel.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Tested-by: Divya Jyothi <divya.jyothi@intel.com> Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Shawn N <shawnn@chromium.org>
* samus: change charge override hot keys to ctrl+search+0|1|2Alec Berg2015-01-241-36/+32
| | | | | | | | | | | | | | Change the charge override hot keys to ctrol+search+0|1|2 BUG=none BRANCH=samus TEST=use the hot keys and verify that the PD console shows charge override host command Change-Id: I5551190743ea064a967164b9d95143cc966662e1 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/242832 Reviewed-by: Shawn N <shawnn@chromium.org>
* samus: add hot keys alt+voldown+0|1|2 to set charging portstabilize-6662.BAlec Berg2015-01-071-0/+45
| | | | | | | | | | | | | | | | | | | | Add hot key detection for alt + volume down + 0|1|2 to set the charging port by sending the charge override command to PD MCU. This should be removed once hot-keys (or some other UI) is added to higher layers. BUG=chrome-os-partner:34850 BRANCH=samus TEST=load onto samus and connect to another samus. use hot keys and see that charge override command gets set appropriately on PD MCU. Change-Id: I7e72d597a02b7aca3326911796d20003f6697077 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/238226 Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Add cprints() and ccprints()Vic Yang2014-05-211-6/+7
| | | | | | | | | | | | | | | | | | | | | Our code base contains a lot of debug messages in this pattern: CPRINTF("[%T xxx]\n") or ccprintf("[%T xxx]\n") The strings are taking up spaces in the EC binaries, so let's refactor this by adding cprints() and ccprints(). cprints() is just like cprintf(), except that it adds the brackets and the timestamp. ccprints() is equivalent to cprints(CC_CONSOLE, ...) This saves us hundreds of bytes in EC binaries. BUG=chromium:374575 TEST=Build and check flash size BRANCH=None Change-Id: Ifafe8dc1b80e698b28ed42b70518c7917b49ee51 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200490 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* cleanup: add square brackets to make test parser easierLouis Yung-Chieh Lo2014-05-071-1/+2
| | | | | | | | | | | | | | | | This may not contain all. I filtered out possible code by the following command: find . -name "*.h*" -o -name "*.c*" | xargs grep -n CPRINTF | \ grep -v "\[" | grep -v define | less BUG=none BRANCH=none TEST=make buildall tuntests Change-Id: I674f84f5966b34aeb8d4321d22629b450627a120 Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/197997
* Refactored keyboard scan enable flag to allow for multiple disable reasonsAlec Berg2014-04-111-31/+33
| | | | | | | | | | | | | | | | | | | | | | Refactored keyboard scan enable/disable flag such that it is a mask of potential disable sources. When all disable sources are off, scanning is enabled, otherwise scanning is disabled. This fixes a recently introduced bug in which enabling/disabling keyboard scanning due to lid angle in S3 was interfering with enabling/disabling keyboard scanning due to power button. This also allows for easy expansion for future causes for disabling keyboard scanning. BUG=chrome-os-partner:27851 BRANCH=rambi TEST=Manual tests with a glimmer. Used the ksstate console command to check state of keyboard scanning under all permutations of power button pressed/unpressed, lid switch open/closed, and lid angle in tablet position vs. laptop positon. Change-Id: Ied4c5ebb94510b1078cd81d71373c0f1bd0d6678 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/194287 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* rambi: glimmer: Disable key scanning in suspend when lid is openAlec Berg2014-03-271-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Added ability to disable the keyboard to wake from suspend when the lid is outside a certain angle range. This has been added to glimmer by defining CONFIG_LID_ANGLE_KEY_SCAN in its board.h. Also modified the lid angle calculation to include a reliability flag which can be used to tell when the hinge aligns too closely with gravity and the lid angle value is unreliable. BUG=none BRANCH=rambi TEST=Tested on a glimmer: In S3, verified that when the lid is open past ~180 deg, the keyboard does not wake the machine. Also verified that if you align hinge with gravity, the keyboard enabled/disabled status remains the same (since we can't actually trust the lid angle value). Change-Id: I45b2c7c3c4bbcae61d3a0f8b5baa461ab8dabfb0 Original-Change-Id: If1a1592d259902d38941936961854b81b3a75b95 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/190061 Reviewed-on: https://chromium-review.googlesource.com/191612 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Fix watchdog in keyboard scan if key outside mask pressedtest-5394.BRandall Spangler2014-01-291-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If a key is pressed which is not in actual_key_mask, this triggers the keyboard scan interrupt. But read_matrix() would use the key mask to decide that no *real* keys were pressed. So it would immediately drop out of scan mode back to interrupt mode. Which would again be triggered. Lather, rinse, repeat, watchdog. The fix is to use the unmasked key matrix to decide whether to stay in scan mode. This way, the keyboard task sleeps between scans, and the watchdog isn't triggered. (Note that the only way you can hit this bug in real life is to have a keyboard attached which can trigger keys not in actual_key_mask. Which is hard to do, unless you've got a new prototype keyboard with extra keys, or you've spilled lemon juice on your Chromebook...) BUG=chrome-os-partner:25333 BRANCH=rambi TEST=Zero out actual_key_mask in keyboard_scan.c. Press a key. Should not trigger a watchdog. Change-Id: I8c2fbc3e06fa12dfae5c06614814af8f04e24a8a Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/184323 Reviewed-by: Dave Parker <dparker@chromium.org> Tested-by: Dave Parker <dparker@chromium.org>
* Add F13 to 8042 keyboard scan matrixDave Parker2014-01-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | F13 is used to trigger the lock/password screen for users logged into Chromium OS. F13 is already used for this purpose on the USB Chrome keyboard. BUG=chrome-os-partner:24376 BRANCH=clapper,glimmer TEST=Run "kbpress 9 3 1" to simulate keypress. Verify lock screen is entered in Chromium OS. Set1: Run evtest. Verify KEY_F13 scan code, value=5d Set2: Add kernel parameter "i8042.direct=1" to use RAW mode. Run evtest. Verify KEY_F13 scan code, value=2f Change-Id: I71200810681f683c17e30b383e1221784deae0cd Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/182289
* keyboard: Improve kbpress reliability for automationDoug Anderson2013-12-101-6/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The "kbpress" command had a few issues if you wanted to reliably use it for automation. Specifically it was not possible to guarantee how much time would pass between the press of a key and the release of a key. Sometimes you might press and release before the key was officially "there" and sometimes you might get a press and hold of a key. Fix this: 1. Make it so that kbpress with no press/release parameter gives a press and release (and guarantees that the press / release will actually take effect). 2. Make it so that kbpress guarantees that when it finishes that the key has actually been pressed or released. BRANCH=pit BUG=chrome-os-partner:24249 TEST=kbtype is (https://chromium-review.googlesource.com/178680) reliable TEST=make -j32 BOARD=bds tests && make BOARD=bds runtests TEST=Pick Ibe00a796bde7d06416889b621359671a2f68e162 and test. Change-Id: Ia213ab2e8d8da273e3ac4876d97d5452df88f47d Signed-off-by: Doug Anderson <dianders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/178983 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit 247650ecc90385417f5dcb2d60bb6ae1e5cfa32f) Reviewed-on: https://chromium-review.googlesource.com/179325 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* cleanup: Assorted TODO commentsRandall Spangler2013-10-311-6/+1
| | | | | | | | | | | | | | | Remove comments if no longer applicable, or assign bug numbers if they still are. Tidy some debug output. No code changes other than the debug output. BUG=chrome-os-partner:18343 BRANCH=none TEST=build all platforms, pass unit tests Change-Id: I2277e73fbf8cc93f3b1b35ee115e0f2f52eb8cf9 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/175215 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Enforce a minimum number of clocks between keyboard scansRandall Spangler2013-10-141-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | When the EC CPU is running at a decreased clock frequency, frequent keyboard scans can starve other EC tasks of CPU and lead to dropped data or watchdog timeouts. Enforce a minimum number of EC clocks between keyboard scans to prevent this from happening. The default chosen (16000 clocks) is equal to the shortest post-scan delay (1 ms) of any current board when the AP is in S0, so this should have no effect when the AP is in S0. When the AP is in S3 or S5, we don't need to scan the keyboard as frequently anyway. This can be overridden on a per-board basis for future boards if needed. BUG=chrome-os-partner:23247 BRANCH=pit TEST=apshutdown, then hold down a key for 10 seconds. Should not see a watchdog reset. Change-Id: I228f53a32ad4769f6a137a9ab06903111bea115d Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/172895 Reviewed-by: Vic Yang <victoryang@chromium.org>
* Wake keyboard task when lid opensRandall Spangler2013-09-301-0/+13
| | | | | | | | | | | | | | | | | | If keyboard scanning is active when the lid closes, it will disable scanning put the scan task to sleep. We need a corresponding task wake when the lid opens, or scanning will be stuck off (until something else happens, like poking the power button). BUG=chrome-os-partner:22190 BRANCH=peppy TEST=Hold down a key. Use a magnet to trigger the lid switch. Scanning should stop while the lid is "closed", and restart when the magnet is moved to "open" the lid again. Change-Id: I0a900f17f65b75cbdb45950cea7f50190d2bf9b1 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/170993 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Update keyboard scanmatrix for Japanese keyboards.Dave Parker2013-08-301-1/+1
| | | | | | | | | | | | | BUG=chrome-os-partner:21798 BRANCH=peppy TEST=Run evtest. Push every key. Verify correct key code reported. Signed-off-by: Dave Parker <dparker@chromium.org> Change-Id: Ic6e4a38608f4bc8c66f487998912a7921ddb03cb Reviewed-on: https://chromium-review.googlesource.com/65623 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Yung-chieh Lo <yjlou@chromium.org>