diff options
author | Ben Chen <ben.chen2@quanta.corp-partner.google.com> | 2020-09-25 16:54:54 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-09-29 22:58:54 +0000 |
commit | 133c6096ffd81cf5e7d62334ccc12d67e14e7830 (patch) | |
tree | bcba788b4c644fd9ed2125edb337bfaf70089319 | |
parent | f366710eb8076fb45609ca4a3878cf6f7796c1e5 (diff) | |
download | chrome-ec-133c6096ffd81cf5e7d62334ccc12d67e14e7830.tar.gz |
button: presss volume button detected by adc
supports volume up/dwon pressed by adc buttons config
BUG=b:167319238
BRANCH=master
TEST=make buildall pass
Change-Id: Ide3522b4af3c92df906bafb1f944f138a822280a
Signed-off-by: Ben Chen <ben.chen2@quanta.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2431310
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | common/button.c | 8 | ||||
-rw-r--r-- | include/button.h | 14 | ||||
-rw-r--r-- | include/config.h | 6 |
3 files changed, 27 insertions, 1 deletions
diff --git a/common/button.c b/common/button.c index 1dcebae3bd..42d08c9baf 100644 --- a/common/button.c +++ b/common/button.c @@ -73,8 +73,14 @@ static int raw_button_pressed(const struct button_config *button) int physical_value = 0; int simulated_value = 0; if (!(button->flags & BUTTON_FLAG_DISABLED)) { - physical_value = (!!gpio_get_level(button->gpio) == + if (IS_ENABLED(CONFIG_ADC_BUTTONS) && + button_is_adc_detected(button->gpio)) { + physical_value = + adc_to_physical_value(button->gpio); + } else { + physical_value = (!!gpio_get_level(button->gpio) == !!(button->flags & BUTTON_FLAG_ACTIVE_HIGH)); + } #ifdef CONFIG_SIMULATED_BUTTON simulated_value = simulated_button_pressed(button); #endif diff --git a/include/button.h b/include/button.h index 381e650550..ec0a7afdc2 100644 --- a/include/button.h +++ b/include/button.h @@ -87,4 +87,18 @@ int button_disable_gpio(enum button button_type); */ void button_interrupt(enum gpio_signal signal); +/* + * determined which buttons connected ADC + * + * @param signal Signal which triggered the interrupt. + */ +int button_is_adc_detected(enum gpio_signal gpio); + +/* + * distinct which buttons determined by ADC voltage + * + * @param signal Signal which triggered the interrupt. + */ +int adc_to_physical_value(enum gpio_signal gpio); + #endif /* __CROS_EC_BUTTON_H */ diff --git a/include/config.h b/include/config.h index c80636f33d..0d5d10ac90 100644 --- a/include/config.h +++ b/include/config.h @@ -771,6 +771,12 @@ #undef CONFIG_VOLUME_BUTTONS /* + * The board has volume up and volume down buttons, that are connected to ADC + * pins which pressed and released values are determined by the analog voltage + */ +#undef CONFIG_ADC_BUTTONS + +/* * Allow runtime configuration of the buttons[] array */ #undef CONFIG_BUTTONS_RUNTIME_CONFIG |