mirror of
https://github.com/wessel-novacustom/clevo-keyboard.git
synced 2024-11-15 11:43:59 +01:00
Clean-up cl driver state init
- Ensure keyb bl state is initialized from params - Unify state writing (directly from state struct) - Use same state write on resume - Don't attempt to init twice if already initialized (should prevent some double writing and make debugging easier)
This commit is contained in:
parent
c2061a9596
commit
bea182ed6d
|
@ -96,8 +96,6 @@ u32 clevo_keyboard_add_interface(struct clevo_interface_t *new_interface)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
clevo_keyboard_write_state();
|
|
||||||
|
|
||||||
mutex_unlock(&clevo_keyboard_interface_modification_lock);
|
mutex_unlock(&clevo_keyboard_interface_modification_lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -694,24 +692,17 @@ static void clevo_keyboard_init_device_interface(struct platform_device *dev)
|
||||||
("Sysfs attribute file creation failed for brightness\n");
|
("Sysfs attribute file creation failed for brightness\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set state variables
|
|
||||||
kbd_led_state.color.left = param_color_left;
|
|
||||||
kbd_led_state.color.center = param_color_center;
|
|
||||||
kbd_led_state.color.right = param_color_right;
|
|
||||||
kbd_led_state.color.extra = param_color_extra;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void clevo_keyboard_write_state(void)
|
void clevo_keyboard_write_state(void)
|
||||||
{
|
{
|
||||||
// Write state
|
// Note:
|
||||||
set_color(REGION_LEFT, param_color_left);
|
// - set_blinking_pattern also writes colors
|
||||||
set_color(REGION_CENTER, param_color_center);
|
// - set_brightness, set_enabled, set_blinking_pattern
|
||||||
set_color(REGION_RIGHT, param_color_right);
|
// still also update state
|
||||||
|
set_blinking_pattern(kbd_led_state.blinking_pattern);
|
||||||
set_blinking_pattern(param_blinking_pattern);
|
set_brightness(kbd_led_state.brightness);
|
||||||
if (param_brightness > BRIGHTNESS_MAX) param_brightness = BRIGHTNESS_DEFAULT;
|
set_enabled(kbd_led_state.enabled);
|
||||||
set_brightness(param_brightness);
|
|
||||||
set_enabled(param_state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int clevo_keyboard_probe_only_init(struct platform_device *dev)
|
static int clevo_keyboard_probe_only_init(struct platform_device *dev)
|
||||||
|
@ -752,15 +743,7 @@ static int clevo_keyboard_resume(struct platform_device *dev)
|
||||||
{
|
{
|
||||||
clevo_evaluate_method(CLEVO_METHOD_ID_GET_AP, 0, NULL);
|
clevo_evaluate_method(CLEVO_METHOD_ID_GET_AP, 0, NULL);
|
||||||
|
|
||||||
set_color(REGION_LEFT, kbd_led_state.color.left);
|
clevo_keyboard_write_state();
|
||||||
set_color(REGION_CENTER, kbd_led_state.color.center);
|
|
||||||
set_color(REGION_RIGHT, kbd_led_state.color.right);
|
|
||||||
if (kbd_led_state.has_extra)
|
|
||||||
set_color(REGION_EXTRA, kbd_led_state.color.extra);
|
|
||||||
|
|
||||||
set_blinking_pattern(kbd_led_state.blinking_pattern);
|
|
||||||
set_brightness(kbd_led_state.brightness);
|
|
||||||
set_enabled(kbd_led_state.enabled);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -799,7 +782,23 @@ int clevo_keyboard_init(void)
|
||||||
{
|
{
|
||||||
bool performance_profile_set_workaround;
|
bool performance_profile_set_workaround;
|
||||||
|
|
||||||
tuxedo_keyboard_init_driver(&clevo_keyboard_driver_v2);
|
if (IS_ERR_OR_NULL(tuxedo_keyboard_init_driver(&clevo_keyboard_driver_v2)))
|
||||||
|
return -EEXIST;
|
||||||
|
|
||||||
|
// Init state from params
|
||||||
|
kbd_led_state.color.left = param_color_left;
|
||||||
|
kbd_led_state.color.center = param_color_center;
|
||||||
|
kbd_led_state.color.right = param_color_right;
|
||||||
|
kbd_led_state.color.extra = param_color_extra;
|
||||||
|
|
||||||
|
kbd_led_state.blinking_pattern = param_blinking_pattern;
|
||||||
|
|
||||||
|
if (param_brightness > BRIGHTNESS_MAX) param_brightness = BRIGHTNESS_DEFAULT;
|
||||||
|
kbd_led_state.brightness = param_brightness;
|
||||||
|
|
||||||
|
kbd_led_state.enabled = param_state;
|
||||||
|
|
||||||
|
clevo_keyboard_write_state();
|
||||||
|
|
||||||
// Workaround for firmware issue not setting selected performance profile.
|
// Workaround for firmware issue not setting selected performance profile.
|
||||||
// Explicitly set "performance" perf. profile on init regardless of what is chosen
|
// Explicitly set "performance" perf. profile on init regardless of what is chosen
|
||||||
|
|
|
@ -80,6 +80,8 @@ err_free_input_device:
|
||||||
struct platform_device *tuxedo_keyboard_init_driver(struct tuxedo_keyboard_driver *tk_driver)
|
struct platform_device *tuxedo_keyboard_init_driver(struct tuxedo_keyboard_driver *tk_driver)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
struct platform_device *new_platform_device = NULL;
|
||||||
|
|
||||||
TUXEDO_DEBUG("init driver start\n");
|
TUXEDO_DEBUG("init driver start\n");
|
||||||
|
|
||||||
mutex_lock(&tuxedo_keyboard_init_driver_lock);
|
mutex_lock(&tuxedo_keyboard_init_driver_lock);
|
||||||
|
@ -91,9 +93,11 @@ struct platform_device *tuxedo_keyboard_init_driver(struct tuxedo_keyboard_drive
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, attempt to initialize structures
|
// Otherwise, attempt to initialize structures
|
||||||
TUXEDO_DEBUG("create platform bundle\n");
|
TUXEDO_DEBUG("create platform bundle\n");
|
||||||
tuxedo_platform_device = platform_create_bundle(
|
new_platform_device = platform_create_bundle(
|
||||||
tk_driver->platform_driver, tk_driver->probe, NULL, 0, NULL, 0);
|
tk_driver->platform_driver, tk_driver->probe, NULL, 0, NULL, 0);
|
||||||
|
|
||||||
|
tuxedo_platform_device = new_platform_device;
|
||||||
|
|
||||||
if (IS_ERR_OR_NULL(tuxedo_platform_device)) {
|
if (IS_ERR_OR_NULL(tuxedo_platform_device)) {
|
||||||
// Normal case probe failed, no init
|
// Normal case probe failed, no init
|
||||||
goto init_driver_exit;
|
goto init_driver_exit;
|
||||||
|
@ -116,7 +120,7 @@ struct platform_device *tuxedo_keyboard_init_driver(struct tuxedo_keyboard_drive
|
||||||
|
|
||||||
init_driver_exit:
|
init_driver_exit:
|
||||||
mutex_unlock(&tuxedo_keyboard_init_driver_lock);
|
mutex_unlock(&tuxedo_keyboard_init_driver_lock);
|
||||||
return tuxedo_platform_device;
|
return new_platform_device;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(tuxedo_keyboard_init_driver);
|
EXPORT_SYMBOL(tuxedo_keyboard_init_driver);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue