diff --git a/src/clevo_keyboard.h b/src/clevo_keyboard.h index 41002d4..91d938a 100644 --- a/src/clevo_keyboard.h +++ b/src/clevo_keyboard.h @@ -34,19 +34,7 @@ #define KEYBOARD_BRIGHTNESS 0xF4000000 -/* All these COLOR_* macros are never used in the code, don't know why they are - here, maybe for documentation purposes. So won't delete for now */ -#define COLOR_BLACK 0x000000 -#define COLOR_RED 0xFF0000 -#define COLOR_GREEN 0x00FF00 -#define COLOR_BLUE 0x0000FF -#define COLOR_YELLOW 0xFFFF00 -#define COLOR_MAGENTA 0xFF00FF -#define COLOR_CYAN 0x00FFFF -#define COLOR_WHITE 0xFFFFFF - - -#define KB_COLOR_DEFAULT COLOR_WHITE // Default Color: White +#define KB_COLOR_DEFAULT 0xFFFFFF // White #define DEFAULT_BLINKING_PATTERN 0 // Submethod IDs for the CLEVO_GET WMI method @@ -128,7 +116,7 @@ struct blinking_pattern_t { const char *const name; }; -// Param Validators + static int blinking_pattern_id_validator(const char *value, const struct kernel_param *blinking_pattern_param); static const struct kernel_param_ops param_ops_mode_ops = { @@ -136,14 +124,6 @@ static const struct kernel_param_ops param_ops_mode_ops = { .get = param_get_int, }; -static int brightness_validator(const char *val, - const struct kernel_param *brightness_param); -static const struct kernel_param_ops param_ops_brightness_ops = { - .set = brightness_validator, - .get = param_get_int, -}; - -// Module Parameters static uint param_color_left = KB_COLOR_DEFAULT; module_param_named(color_left, param_color_left, uint, S_IRUSR); MODULE_PARM_DESC(color_left, "Color for the Left Region"); @@ -164,11 +144,6 @@ static ushort param_blinking_pattern = DEFAULT_BLINKING_PATTERN; module_param_cb(mode, ¶m_ops_mode_ops, ¶m_blinking_pattern, S_IRUSR); MODULE_PARM_DESC(mode, "Set the keyboard backlight blinking pattern"); -static ushort param_brightness = BRIGHTNESS_DEFAULT; -module_param_cb(brightness, ¶m_ops_brightness_ops, ¶m_brightness, - S_IRUSR); -MODULE_PARM_DESC(brightness, "Set the Keyboard Brightness"); - static bool param_state = true; module_param_named(state, param_state, bool, S_IRUSR); MODULE_PARM_DESC(state, @@ -714,6 +689,7 @@ static int clevo_keyboard_probe(struct platform_device *dev) set_color(REGION_RIGHT, param_color_right); set_blinking_pattern(param_blinking_pattern); + if (param_brightness > BRIGHTNESS_MAX) param_brightness = BRIGHTNESS_DEFAULT; set_brightness(param_brightness); set_enabled(param_state); diff --git a/src/tuxedo_keyboard.c b/src/tuxedo_keyboard.c index 1513cf6..4016539 100644 --- a/src/tuxedo_keyboard.c +++ b/src/tuxedo_keyboard.c @@ -20,13 +20,6 @@ #define pr_fmt(fmt) "tuxedo_keyboard" ": " fmt -#include -#include -#include -#include -#include -#include -#include #include "tuxedo_keyboard_common.h" #include "clevo_keyboard.h" #include "uniwill_keyboard.h" diff --git a/src/tuxedo_keyboard_common.h b/src/tuxedo_keyboard_common.h index 8ba4c00..d19729d 100644 --- a/src/tuxedo_keyboard_common.h +++ b/src/tuxedo_keyboard_common.h @@ -21,6 +21,11 @@ #define TUXEDO_KEYBOARD_COMMON_H #include +#include +#include +#include +#include +#include #include /* :::: Module specific Constants and simple Macros :::: */ @@ -113,4 +118,18 @@ static u32 color_lookup(const struct color_list_t *color_list, const char *color return found_color; } +// Common parameters + +static int brightness_validator(const char *val, + const struct kernel_param *brightness_param); +static const struct kernel_param_ops param_ops_brightness_ops = { + .set = brightness_validator, + .get = param_get_int, +}; + +static ushort param_brightness = 0xffff; // Default unset value (higher than max) +module_param_cb(brightness, ¶m_ops_brightness_ops, ¶m_brightness, + S_IRUSR); +MODULE_PARM_DESC(brightness, "Set the Keyboard Brightness"); + #endif \ No newline at end of file