Move brightness parameter in preparation for common use

This commit is contained in:
Christoffer Sandberg 2020-07-28 11:25:29 +02:00
parent a85ccf9a4e
commit f90c513aad
No known key found for this signature in database
GPG key ID: BF563F71B6C7A96D
3 changed files with 22 additions and 34 deletions

View file

@ -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, &param_ops_mode_ops, &param_blinking_pattern, S_IRUSR);
MODULE_PARM_DESC(mode, "Set the keyboard backlight blinking pattern");
static ushort param_brightness = BRIGHTNESS_DEFAULT;
module_param_cb(brightness, &param_ops_brightness_ops, &param_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);

View file

@ -20,13 +20,6 @@
#define pr_fmt(fmt) "tuxedo_keyboard" ": " fmt
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/acpi.h>
#include <linux/dmi.h>
#include <linux/platform_device.h>
#include <linux/input.h>
#include <linux/input/sparse-keymap.h>
#include "tuxedo_keyboard_common.h"
#include "clevo_keyboard.h"
#include "uniwill_keyboard.h"

View file

@ -21,6 +21,11 @@
#define TUXEDO_KEYBOARD_COMMON_H
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/acpi.h>
#include <linux/dmi.h>
#include <linux/platform_device.h>
#include <linux/input.h>
#include <linux/input/sparse-keymap.h>
/* :::: 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, &param_ops_brightness_ops, &param_brightness,
S_IRUSR);
MODULE_PARM_DESC(brightness, "Set the Keyboard Brightness");
#endif