From f50eeaac07128013758bb3a8ef3aa83115b2c192 Mon Sep 17 00:00:00 2001 From: Werner Sembach Date: Thu, 18 Aug 2022 14:04:25 +0200 Subject: [PATCH] Add dummy leds interface for 3 zone keyboard --- src/clevo_keyboard.h | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/clevo_keyboard.h b/src/clevo_keyboard.h index 353abc2..683db6e 100644 --- a/src/clevo_keyboard.h +++ b/src/clevo_keyboard.h @@ -698,7 +698,23 @@ enum led_brightness ledcdev_get(struct led_classdev *led_cdev) { return kbd_led_state.brightness; } -struct led_classdev cdev_brightness = { +struct led_classdev cdev_kb_1 = { + .name = KBUILD_MODNAME "::kbd_backlight", + .max_brightness = BRIGHTNESS_MAX, + .brightness_set_blocking = &ledcdev_set_blocking, + .brightness_get = &ledcdev_get, + .brightness = BRIGHTNESS_DEFAULT, +}; + +struct led_classdev cdev_kb_2 = { + .name = KBUILD_MODNAME "::kbd_backlight", + .max_brightness = BRIGHTNESS_MAX, + .brightness_set_blocking = &ledcdev_set_blocking, + .brightness_get = &ledcdev_get, + .brightness = BRIGHTNESS_DEFAULT, +}; + +struct led_classdev cdev_kb_3 = { .name = KBUILD_MODNAME "::kbd_backlight", .max_brightness = BRIGHTNESS_MAX, .brightness_set_blocking = &ledcdev_set_blocking, @@ -815,13 +831,19 @@ static void clevo_keyboard_init_device_interface(struct platform_device *dev) } } - if (device_create_file - (&dev->dev, &dev_attr_brightness) != 0) { - TUXEDO_ERROR - ("Sysfs attribute file creation failed for brightness\n"); + if (kb_backlight_type == CLEVO_KB_BACKLIGHT_TYPE_FIXED_COLOR) { + led_classdev_register(&dev->dev, &cdev_kb_1); } - led_classdev_register(&dev->dev, &cdev_brightness); + if (kb_backlight_type == CLEVO_KB_BACKLIGHT_TYPE_1_ZONE_RGB) { + led_classdev_register(&dev->dev, &cdev_kb_1); + } + + if (kb_backlight_type == CLEVO_KB_BACKLIGHT_TYPE_3_ZONE_RGB) { + led_classdev_register(&dev->dev, &cdev_kb_1); + led_classdev_register(&dev->dev, &cdev_kb_2); + led_classdev_register(&dev->dev, &cdev_kb_3); + } } void clevo_keyboard_write_state(void)