doc, better names: keyboard --> kbd_led_state

This commit is contained in:
Richard Sailer 2019-08-18 05:59:24 +02:00
parent 6e72e954e5
commit efe641bb42

View file

@ -173,7 +173,7 @@ struct kbd_led_state_t {
u8 blinking_pattern; u8 blinking_pattern;
}; };
static struct kbd_led_state_t keyboard = { static struct kbd_led_state_t kbd_led_state = {
.has_extra = 0, .has_extra = 0,
.state = 1, .state = 1,
.color = { .color = {
@ -206,56 +206,56 @@ static struct blinking_pattern blinking_patterns[] = {
static ssize_t show_state_fs(struct device *child, static ssize_t show_state_fs(struct device *child,
struct device_attribute *attr, char *buffer) struct device_attribute *attr, char *buffer)
{ {
return sprintf(buffer, "%d\n", keyboard.state); return sprintf(buffer, "%d\n", kbd_led_state.state);
} }
// Sysfs Interface for the color of the left side (Color as hexvalue) // Sysfs Interface for the color of the left side (Color as hexvalue)
static ssize_t show_color_left_fs(struct device *child, static ssize_t show_color_left_fs(struct device *child,
struct device_attribute *attr, char *buffer) struct device_attribute *attr, char *buffer)
{ {
return sprintf(buffer, "%06x\n", keyboard.color.left); return sprintf(buffer, "%06x\n", kbd_led_state.color.left);
} }
// Sysfs Interface for the color of the center (Color as hexvalue) // Sysfs Interface for the color of the center (Color as hexvalue)
static ssize_t show_color_center_fs(struct device *child, static ssize_t show_color_center_fs(struct device *child,
struct device_attribute *attr, char *buffer) struct device_attribute *attr, char *buffer)
{ {
return sprintf(buffer, "%06x\n", keyboard.color.center); return sprintf(buffer, "%06x\n", kbd_led_state.color.center);
} }
// Sysfs Interface for the color of the right side (Color as hexvalue) // Sysfs Interface for the color of the right side (Color as hexvalue)
static ssize_t show_color_right_fs(struct device *child, static ssize_t show_color_right_fs(struct device *child,
struct device_attribute *attr, char *buffer) struct device_attribute *attr, char *buffer)
{ {
return sprintf(buffer, "%06x\n", keyboard.color.right); return sprintf(buffer, "%06x\n", kbd_led_state.color.right);
} }
// Sysfs Interface for the color of the extra region (Color as hexvalue) // Sysfs Interface for the color of the extra region (Color as hexvalue)
static ssize_t show_color_extra_fs(struct device *child, static ssize_t show_color_extra_fs(struct device *child,
struct device_attribute *attr, char *buffer) struct device_attribute *attr, char *buffer)
{ {
return sprintf(buffer, "%06x\n", keyboard.color.extra); return sprintf(buffer, "%06x\n", kbd_led_state.color.extra);
} }
// Sysfs Interface for the keyboard brightness (unsigned int) // Sysfs Interface for the keyboard brightness (unsigned int)
static ssize_t show_brightness_fs(struct device *child, static ssize_t show_brightness_fs(struct device *child,
struct device_attribute *attr, char *buffer) struct device_attribute *attr, char *buffer)
{ {
return sprintf(buffer, "%d\n", keyboard.brightness); return sprintf(buffer, "%d\n", kbd_led_state.brightness);
} }
// Sysfs Interface for the backlight blinking pattern // Sysfs Interface for the backlight blinking pattern
static ssize_t show_blinking_patterns_fs(struct device *child, struct device_attribute *attr, static ssize_t show_blinking_patterns_fs(struct device *child, struct device_attribute *attr,
char *buffer) char *buffer)
{ {
return sprintf(buffer, "%d\n", keyboard.blinking_pattern); return sprintf(buffer, "%d\n", kbd_led_state.blinking_pattern);
} }
// Sysfs Interface for if the keyboard has extra region // Sysfs Interface for if the keyboard has extra region
static ssize_t show_hasextra_fs(struct device *child, static ssize_t show_hasextra_fs(struct device *child,
struct device_attribute *attr, char *buffer) struct device_attribute *attr, char *buffer)
{ {
return sprintf(buffer, "%d\n", keyboard.has_extra); return sprintf(buffer, "%d\n", kbd_led_state.has_extra);
} }
static int tuxedo_evaluate_wmi_method(u32 method_id, u32 arg, u32 * retval) static int tuxedo_evaluate_wmi_method(u32 method_id, u32 arg, u32 * retval)
@ -304,7 +304,7 @@ static void set_brightness(u8 brightness)
TUXEDO_INFO("Set brightness on %d", brightness); TUXEDO_INFO("Set brightness on %d", brightness);
if (!tuxedo_evaluate_wmi_method if (!tuxedo_evaluate_wmi_method
(SET_KB_LED, 0xF4000000 | brightness, NULL)) { (SET_KB_LED, 0xF4000000 | brightness, NULL)) {
keyboard.brightness = brightness; kbd_led_state.brightness = brightness;
} }
} }
@ -338,7 +338,7 @@ static void set_state(u8 state)
} }
if (!tuxedo_evaluate_wmi_method(SET_KB_LED, cmd, NULL)) { if (!tuxedo_evaluate_wmi_method(SET_KB_LED, cmd, NULL)) {
keyboard.state = state; kbd_led_state.state = state;
} }
} }
@ -385,16 +385,16 @@ static int set_color_region(const char *color_string, size_t size, u32 region)
// depending on which region was changed // depending on which region was changed
switch (region) { switch (region) {
case REGION_LEFT: case REGION_LEFT:
keyboard.color.left = colorcode; kbd_led_state.color.left = colorcode;
break; break;
case REGION_CENTER: case REGION_CENTER:
keyboard.color.center = colorcode; kbd_led_state.color.center = colorcode;
break; break;
case REGION_RIGHT: case REGION_RIGHT:
keyboard.color.right = colorcode; kbd_led_state.color.right = colorcode;
break; break;
case REGION_EXTRA: case REGION_EXTRA:
keyboard.color.extra = colorcode; kbd_led_state.color.extra = colorcode;
break; break;
} }
} }
@ -436,18 +436,18 @@ static void set_blinking_pattern(u8 blinkling_pattern)
if (!tuxedo_evaluate_wmi_method(SET_KB_LED, blinking_patterns[blinkling_pattern].value, NULL)) { if (!tuxedo_evaluate_wmi_method(SET_KB_LED, blinking_patterns[blinkling_pattern].value, NULL)) {
// wmi method was succesfull so update ur internal state struct // wmi method was succesfull so update ur internal state struct
keyboard.blinking_pattern = blinkling_pattern; kbd_led_state.blinking_pattern = blinkling_pattern;
} }
if (blinkling_pattern == 0) { // 0 is the "custom" blinking pattern if (blinkling_pattern == 0) { // 0 is the "custom" blinking pattern
// so just set all regions to the stored colors // so just set all regions to the stored colors
set_color(REGION_LEFT, keyboard.color.left); set_color(REGION_LEFT, kbd_led_state.color.left);
set_color(REGION_CENTER, keyboard.color.center); set_color(REGION_CENTER, kbd_led_state.color.center);
set_color(REGION_RIGHT, keyboard.color.right); set_color(REGION_RIGHT, kbd_led_state.color.right);
if (keyboard.has_extra == 1) { if (kbd_led_state.has_extra == 1) {
set_color(REGION_EXTRA, keyboard.color.extra); set_color(REGION_EXTRA, kbd_led_state.color.extra);
} }
} }
} }
@ -506,32 +506,32 @@ static void tuxedo_wmi_notify(u32 value, void *context)
switch (event) { switch (event) {
case WMI_CODE_DECREASE_BACKLIGHT: case WMI_CODE_DECREASE_BACKLIGHT:
if (keyboard.brightness == BRIGHTNESS_MIN if (kbd_led_state.brightness == BRIGHTNESS_MIN
|| (keyboard.brightness - 25) < BRIGHTNESS_MIN) { || (kbd_led_state.brightness - 25) < BRIGHTNESS_MIN) {
set_brightness(BRIGHTNESS_MIN); set_brightness(BRIGHTNESS_MIN);
} else { } else {
set_brightness(keyboard.brightness - 25); set_brightness(kbd_led_state.brightness - 25);
} }
break; break;
case WMI_CODE_INCREASE_BACKLIGHT: case WMI_CODE_INCREASE_BACKLIGHT:
if (keyboard.brightness == BRIGHTNESS_MAX if (kbd_led_state.brightness == BRIGHTNESS_MAX
|| (keyboard.brightness + 25) > BRIGHTNESS_MAX) { || (kbd_led_state.brightness + 25) > BRIGHTNESS_MAX) {
set_brightness(BRIGHTNESS_MAX); set_brightness(BRIGHTNESS_MAX);
} else { } else {
set_brightness(keyboard.brightness + 25); set_brightness(kbd_led_state.brightness + 25);
} }
break; break;
case WMI_CODE_NEXT_BLINKING_PATTERN: case WMI_CODE_NEXT_BLINKING_PATTERN:
set_blinking_pattern((keyboard.blinking_pattern + 1) > set_blinking_pattern((kbd_led_state.blinking_pattern + 1) >
(ARRAY_SIZE(blinking_patterns) - 1) ? 0 : (keyboard.blinking_pattern + 1)); (ARRAY_SIZE(blinking_patterns) - 1) ? 0 : (kbd_led_state.blinking_pattern + 1));
break; break;
case WMI_CODE_TOGGLE_STATE: case WMI_CODE_TOGGLE_STATE:
set_state(keyboard.state == 0 ? 1 : 0); set_state(kbd_led_state.state == 0 ? 1 : 0);
break; break;
default: default:
@ -687,9 +687,9 @@ static int __init tuxdeo_keyboard_init(void)
if (set_color(REGION_EXTRA, KB_COLOR_DEFAULT) != 0) { if (set_color(REGION_EXTRA, KB_COLOR_DEFAULT) != 0) {
TUXEDO_DEBUG("Keyboard does not support EXTRA Color"); TUXEDO_DEBUG("Keyboard does not support EXTRA Color");
keyboard.has_extra = 0; kbd_led_state.has_extra = 0;
} else { } else {
keyboard.has_extra = 1; kbd_led_state.has_extra = 1;
if (device_create_file if (device_create_file
(&tuxedo_platform_device->dev, (&tuxedo_platform_device->dev,
&dev_attr_color_extra) != 0) { &dev_attr_color_extra) != 0) {
@ -717,10 +717,10 @@ static int __init tuxdeo_keyboard_init(void)
("Sysfs attribute file creation failed for brightness\n"); ("Sysfs attribute file creation failed for brightness\n");
} }
keyboard.color.left = param_color_left; kbd_led_state.color.left = param_color_left;
keyboard.color.center = param_color_center; kbd_led_state.color.center = param_color_center;
keyboard.color.right = param_color_right; kbd_led_state.color.right = param_color_right;
keyboard.color.extra = param_color_extra; kbd_led_state.color.extra = param_color_extra;
set_color(REGION_LEFT, param_color_left); set_color(REGION_LEFT, param_color_left);
set_color(REGION_CENTER, param_color_center); set_color(REGION_CENTER, param_color_center);
@ -746,7 +746,7 @@ static void __exit tuxdeo_keyboard_exit(void)
device_remove_file(&tuxedo_platform_device->dev, &dev_attr_mode); device_remove_file(&tuxedo_platform_device->dev, &dev_attr_mode);
device_remove_file(&tuxedo_platform_device->dev, &dev_attr_brightness); device_remove_file(&tuxedo_platform_device->dev, &dev_attr_brightness);
if (keyboard.has_extra == 1) { if (kbd_led_state.has_extra == 1) {
device_remove_file(&tuxedo_platform_device->dev, device_remove_file(&tuxedo_platform_device->dev,
&dev_attr_color_extra); &dev_attr_color_extra);
} }