summaryrefslogtreecommitdiff
path: root/common/keyboard_backlight.c
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2022-04-28 23:44:30 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-05-02 16:55:17 +0000
commitcb8b5ccf54ddea0e8f41332168c11482e665c02b (patch)
tree5995e06d8264d14f3321834d328cebf0307d3ab3 /common/keyboard_backlight.c
parentec36c0d8dd87a2fa4c85c65cdcd54b3203967f70 (diff)
downloadchrome-ec-cb8b5ccf54ddea0e8f41332168c11482e665c02b.tar.gz
RGBKBD: Move initialization to keyboard backlight
This patch removes initialization code for RGB keyboard and let keyboard backlight module handle it. This patch also removes RGB keyboard integration from pwm.c since it's not used or needed. BUG=b:226215987, b:228525798, 223465912 BRANCH=None TEST=ectool rgbkbd, pwmsetkblight, pwmgetkblight on Vell & Taniks Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I01fa445f802607106f2f4a0a8e1469ab759c604b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3615851 Reviewed-by: Parth Malkan <parthmalkan@google.com>
Diffstat (limited to 'common/keyboard_backlight.c')
-rw-r--r--common/keyboard_backlight.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/common/keyboard_backlight.c b/common/keyboard_backlight.c
index 4940d9a97e..b1b3671d3d 100644
--- a/common/keyboard_backlight.c
+++ b/common/keyboard_backlight.c
@@ -19,6 +19,7 @@
static struct kblight_conf kblight;
static int current_percent;
+static uint8_t current_enable;
void __attribute__((weak)) board_kblight_init(void)
{ }
@@ -56,14 +57,23 @@ int kblight_get(void)
return current_percent;
}
-int kblight_enable(int enable)
+static void kblight_enable_deferred(void)
{
#ifdef CONFIG_KBLIGHT_ENABLE_PIN
- gpio_set_level(GPIO_EN_KEYBOARD_BACKLIGHT, enable);
+ gpio_set_level(GPIO_EN_KEYBOARD_BACKLIGHT, current_enable);
#endif
if (!kblight.drv || !kblight.drv->enable)
- return -1;
- return kblight.drv->enable(enable);
+ return;
+ kblight.drv->enable(current_enable);
+}
+DECLARE_DEFERRED(kblight_enable_deferred);
+
+int kblight_enable(int enable)
+{
+ current_enable = enable;
+ /* Need to defer i2c in case it's called from an interrupt handler. */
+ hook_call_deferred(&kblight_enable_deferred_data, 0);
+ return EC_SUCCESS;
}
int kblight_get_enabled(void)
@@ -104,6 +114,7 @@ static void keyboard_backlight_init(void)
}
DECLARE_HOOK(HOOK_INIT, keyboard_backlight_init, HOOK_PRIO_DEFAULT);
+#ifdef HAS_TASK_CHIPSET
static void kblight_suspend(void)
{
kblight_enable(0);
@@ -118,12 +129,15 @@ static void kblight_resume(void)
}
}
DECLARE_HOOK(HOOK_CHIPSET_RESUME, kblight_resume, HOOK_PRIO_DEFAULT);
+#endif // HAS_TASK_CHIPSET
+#ifdef CONFIG_LID_SWITCH
static void kblight_lid_change(void)
{
kblight_enable(lid_is_open() && current_percent);
}
DECLARE_HOOK(HOOK_LID_CHANGE, kblight_lid_change, HOOK_PRIO_DEFAULT);
+#endif
/*
* Console and host commands