2018-06-08 11:56:32 +02:00
|
|
|
/*
|
|
|
|
* tuxedo_keyboard.c
|
|
|
|
*
|
2018-06-27 09:13:41 +02:00
|
|
|
* Copyright (C) 2018 TUXEDO Computers GmbH <tux@tuxedocomputers.com>
|
2018-06-08 11:56:32 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2019-08-04 01:28:08 +02:00
|
|
|
#define DRIVER_NAME "tuxedo_keyboard"
|
|
|
|
#define pr_fmt(fmt) DRIVER_NAME ": " fmt
|
|
|
|
|
2018-06-08 11:56:32 +02:00
|
|
|
#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>
|
|
|
|
|
2019-05-31 18:30:47 +02:00
|
|
|
MODULE_AUTHOR
|
|
|
|
("Christian Loritz / TUXEDO Computer GmbH <tux@tuxedocomputers.com>");
|
2018-06-08 11:56:32 +02:00
|
|
|
MODULE_DESCRIPTION("TUXEDO Computer Keyboard Backlight Driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_VERSION("1.0.0");
|
|
|
|
|
2019-08-04 01:14:59 +02:00
|
|
|
/* :::: Module specific Constants and simple Macros :::: */
|
|
|
|
|
|
|
|
#define __TUXEDO_PR(lvl, fmt, ...) do { pr_##lvl(fmt, ##__VA_ARGS__); } while (0)
|
|
|
|
#define TUXEDO_INFO(fmt, ...) __TUXEDO_PR(info, fmt, ##__VA_ARGS__)
|
|
|
|
#define TUXEDO_ERROR(fmt, ...) __TUXEDO_PR(err, fmt, ##__VA_ARGS__)
|
|
|
|
#define TUXEDO_DEBUG(fmt, ...) __TUXEDO_PR(debug, "[%s:%u] " fmt, __func__, __LINE__, ##__VA_ARGS__)
|
|
|
|
|
|
|
|
#define BRIGHTNESS_MIN 0
|
|
|
|
#define BRIGHTNESS_MAX 255
|
|
|
|
#define BRIGHTNESS_DEFAULT BRIGHTNESS_MAX
|
|
|
|
|
|
|
|
#define CLEVO_EVENT_GUID "ABBC0F6B-8EA1-11D1-00A0-C90629100000"
|
|
|
|
#define CLEVO_EMAIL_GUID "ABBC0F6C-8EA1-11D1-00A0-C90629100000"
|
|
|
|
#define CLEVO_GET_GUID "ABBC0F6D-8EA1-11D1-00A0-C90629100000"
|
|
|
|
|
|
|
|
#define REGION_LEFT 0xF0000000
|
|
|
|
#define REGION_CENTER 0xF1000000
|
|
|
|
#define REGION_RIGHT 0xF2000000
|
|
|
|
#define REGION_EXTRA 0xF3000000
|
|
|
|
|
|
|
|
#define KEYBOARD_BRIGHTNESS 0xF4000000
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
2019-08-06 01:53:36 +02:00
|
|
|
struct color_t {
|
|
|
|
u32 code;
|
|
|
|
char* name;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct color_list_t {
|
|
|
|
uint size;
|
|
|
|
struct color_t colors[];
|
|
|
|
};
|
|
|
|
|
2019-08-18 06:03:47 +02:00
|
|
|
// Keyboard struct
|
|
|
|
struct kbd_led_state_t {
|
|
|
|
u8 has_extra;
|
2019-08-18 06:09:03 +02:00
|
|
|
u8 enabled;
|
2019-08-18 06:03:47 +02:00
|
|
|
|
|
|
|
struct {
|
|
|
|
u32 left;
|
|
|
|
u32 center;
|
|
|
|
u32 right;
|
|
|
|
u32 extra;
|
|
|
|
} color;
|
|
|
|
|
|
|
|
u8 brightness;
|
|
|
|
u8 blinking_pattern;
|
2019-08-19 05:28:46 +02:00
|
|
|
u8 whole_kbd_color;
|
2019-08-18 06:03:47 +02:00
|
|
|
};
|
|
|
|
|
2019-08-18 06:12:11 +02:00
|
|
|
struct blinking_pattern_t {
|
2019-08-18 06:03:47 +02:00
|
|
|
u8 key;
|
|
|
|
u32 value;
|
|
|
|
const char *const name;
|
|
|
|
};
|
|
|
|
|
2019-08-06 01:53:36 +02:00
|
|
|
|
|
|
|
|
2019-08-04 01:14:59 +02:00
|
|
|
#define KB_COLOR_DEFAULT COLOR_WHITE // Default Color White
|
2019-08-04 02:33:29 +02:00
|
|
|
#define DEFAULT_BLINKING_PATTERN 0
|
2019-08-04 01:14:59 +02:00
|
|
|
|
|
|
|
// Method IDs for CLEVO_GET
|
|
|
|
#define GET_EVENT 0x01
|
|
|
|
#define GET_AP 0x46
|
|
|
|
#define SET_KB_LED 0x67
|
|
|
|
|
|
|
|
// WMI Codes
|
|
|
|
#define WMI_CODE_DECREASE_BACKLIGHT 0x81
|
|
|
|
#define WMI_CODE_INCREASE_BACKLIGHT 0x82
|
2019-08-04 02:33:29 +02:00
|
|
|
#define WMI_CODE_NEXT_BLINKING_PATTERN 0x83
|
2019-08-04 01:14:59 +02:00
|
|
|
#define WMI_CODE_TOGGLE_STATE 0x9F
|
|
|
|
|
|
|
|
#define STEP_BRIGHTNESS_STEP 25
|
|
|
|
|
|
|
|
|
2019-05-31 21:24:48 +02:00
|
|
|
struct platform_device *tuxedo_platform_device;
|
|
|
|
static struct input_dev *tuxedo_input_device;
|
|
|
|
|
2019-05-31 21:50:52 +02:00
|
|
|
// Param Validators
|
2019-08-18 05:49:12 +02:00
|
|
|
static int blinking_pattern_id_validator(const char *value,
|
|
|
|
const struct kernel_param *blinking_pattern_param);
|
2019-05-31 21:50:52 +02:00
|
|
|
static const struct kernel_param_ops param_ops_mode_ops = {
|
2019-06-06 15:48:59 +02:00
|
|
|
.set = blinking_pattern_id_validator,
|
2019-05-31 21:50:52 +02:00
|
|
|
.get = param_get_int,
|
|
|
|
};
|
|
|
|
|
2019-08-18 05:49:12 +02:00
|
|
|
static int brightness_validator(const char *val,
|
|
|
|
const struct kernel_param *brightness_param);
|
2019-05-31 21:50:52 +02:00
|
|
|
static const struct kernel_param_ops param_ops_brightness_ops = {
|
|
|
|
.set = brightness_validator,
|
|
|
|
.get = param_get_int,
|
|
|
|
};
|
|
|
|
|
2019-06-04 21:55:56 +02:00
|
|
|
// Module Parameters
|
2019-05-31 21:50:52 +02:00
|
|
|
static uint param_color_left = KB_COLOR_DEFAULT;
|
|
|
|
module_param_named(color_left, param_color_left, uint, S_IRUSR);
|
2019-08-12 22:26:58 +02:00
|
|
|
MODULE_PARM_DESC(color_left, "Color for the Left Region");
|
2019-05-31 21:50:52 +02:00
|
|
|
|
|
|
|
static uint param_color_center = KB_COLOR_DEFAULT;
|
|
|
|
module_param_named(color_center, param_color_center, uint, S_IRUSR);
|
2019-08-12 22:26:58 +02:00
|
|
|
MODULE_PARM_DESC(color_center, "Color for the Center Region");
|
2019-05-31 21:50:52 +02:00
|
|
|
|
|
|
|
static uint param_color_right = KB_COLOR_DEFAULT;
|
|
|
|
module_param_named(color_right, param_color_right, uint, S_IRUSR);
|
2019-08-12 22:26:58 +02:00
|
|
|
MODULE_PARM_DESC(color_right, "Color for the Right Region");
|
2019-05-31 21:50:52 +02:00
|
|
|
|
|
|
|
static uint param_color_extra = KB_COLOR_DEFAULT;
|
|
|
|
module_param_named(color_extra, param_color_extra, uint, S_IRUSR);
|
2019-08-12 22:26:58 +02:00
|
|
|
MODULE_PARM_DESC(color_extra, "Color for the Extra Region");
|
2019-05-31 21:50:52 +02:00
|
|
|
|
2019-08-04 02:33:29 +02:00
|
|
|
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");
|
2019-05-31 21:50:52 +02:00
|
|
|
|
|
|
|
static ushort param_brightness = BRIGHTNESS_DEFAULT;
|
|
|
|
module_param_cb(brightness, ¶m_ops_brightness_ops, ¶m_brightness,
|
2019-06-04 19:32:30 +02:00
|
|
|
S_IRUSR);
|
2019-05-31 21:50:52 +02:00
|
|
|
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,
|
2019-06-04 19:32:30 +02:00
|
|
|
"Set the State of the Keyboard TRUE = ON | FALSE = OFF");
|
2019-05-31 21:50:52 +02:00
|
|
|
|
2019-08-18 05:59:24 +02:00
|
|
|
static struct kbd_led_state_t kbd_led_state = {
|
2019-08-04 02:33:29 +02:00
|
|
|
.has_extra = 0,
|
|
|
|
.state = 1,
|
2019-06-04 21:55:56 +02:00
|
|
|
.color = {
|
|
|
|
.left = KB_COLOR_DEFAULT, .center = KB_COLOR_DEFAULT,
|
|
|
|
.right = KB_COLOR_DEFAULT, .extra = KB_COLOR_DEFAULT
|
2019-08-04 02:33:29 +02:00
|
|
|
},
|
|
|
|
.brightness = BRIGHTNESS_DEFAULT,
|
2019-08-19 05:28:46 +02:00
|
|
|
.blinking_pattern = DEFAULT_BLINKING_PATTERN,
|
|
|
|
.whole_kbd_color = 7
|
2019-05-31 21:24:48 +02:00
|
|
|
};
|
|
|
|
|
2019-08-18 06:28:06 +02:00
|
|
|
static struct color_list_t color_list = {
|
|
|
|
.size = 8,
|
|
|
|
.colors = {
|
|
|
|
{ .name = "BLACK", .code = 0x000000 }, // 0
|
|
|
|
{ .name = "RED", .code = 0xFF0000 }, // 1
|
|
|
|
{ .name = "GREEN", .code = 0x00FF00 }, // 2
|
|
|
|
{ .name = "BLUE", .code = 0x0000FF }, // 3
|
|
|
|
{ .name = "YELLOW", .code = 0xFFFF00 }, // 4
|
|
|
|
{ .name = "MAGENTA", .code = 0xFF00FF }, // 5
|
|
|
|
{ .name = "CYAN", .code = 0x00FFFF }, // 6
|
|
|
|
{ .name = "WHITE", .code = 0xFFFFFF }, // 7
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-08-18 06:12:11 +02:00
|
|
|
static struct blinking_pattern_t blinking_patterns[] = {
|
2019-06-04 21:55:56 +02:00
|
|
|
{ .key = 0,.value = 0,.name = "CUSTOM"},
|
|
|
|
{ .key = 1,.value = 0x1002a000,.name = "BREATHE"},
|
|
|
|
{ .key = 2,.value = 0x33010000,.name = "CYCLE"},
|
|
|
|
{ .key = 3,.value = 0x80000000,.name = "DANCE"},
|
|
|
|
{ .key = 4,.value = 0xA0000000,.name = "FLASH"},
|
|
|
|
{ .key = 5,.value = 0x70000000,.name = "RANDOM_COLOR"},
|
|
|
|
{ .key = 6,.value = 0x90000000,.name = "TEMPO"},
|
|
|
|
{ .key = 7,.value = 0xB0000000,.name = "WAVE"}
|
2019-05-31 21:24:48 +02:00
|
|
|
};
|
2019-05-31 21:16:10 +02:00
|
|
|
|
2019-05-31 19:39:20 +02:00
|
|
|
// Sysfs Interface Methods
|
2018-06-08 11:56:32 +02:00
|
|
|
// Sysfs Interface for the keyboard state (ON / OFF)
|
2019-06-04 19:32:30 +02:00
|
|
|
static ssize_t show_state_fs(struct device *child,
|
|
|
|
struct device_attribute *attr, char *buffer)
|
2018-06-08 11:56:32 +02:00
|
|
|
{
|
2019-08-18 06:09:03 +02:00
|
|
|
return sprintf(buffer, "%d\n", kbd_led_state.enabled);
|
2018-06-08 11:56:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sysfs Interface for the color of the left side (Color as hexvalue)
|
2019-06-04 19:32:30 +02:00
|
|
|
static ssize_t show_color_left_fs(struct device *child,
|
|
|
|
struct device_attribute *attr, char *buffer)
|
2018-06-08 11:56:32 +02:00
|
|
|
{
|
2019-08-18 05:59:24 +02:00
|
|
|
return sprintf(buffer, "%06x\n", kbd_led_state.color.left);
|
2018-06-08 11:56:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sysfs Interface for the color of the center (Color as hexvalue)
|
2019-06-04 19:32:30 +02:00
|
|
|
static ssize_t show_color_center_fs(struct device *child,
|
|
|
|
struct device_attribute *attr, char *buffer)
|
2018-06-08 11:56:32 +02:00
|
|
|
{
|
2019-08-18 05:59:24 +02:00
|
|
|
return sprintf(buffer, "%06x\n", kbd_led_state.color.center);
|
2018-06-08 11:56:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sysfs Interface for the color of the right side (Color as hexvalue)
|
2019-06-04 19:32:30 +02:00
|
|
|
static ssize_t show_color_right_fs(struct device *child,
|
|
|
|
struct device_attribute *attr, char *buffer)
|
2018-06-08 11:56:32 +02:00
|
|
|
{
|
2019-08-18 05:59:24 +02:00
|
|
|
return sprintf(buffer, "%06x\n", kbd_led_state.color.right);
|
2018-06-08 11:56:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sysfs Interface for the color of the extra region (Color as hexvalue)
|
2019-06-04 19:32:30 +02:00
|
|
|
static ssize_t show_color_extra_fs(struct device *child,
|
|
|
|
struct device_attribute *attr, char *buffer)
|
2018-06-08 11:56:32 +02:00
|
|
|
{
|
2019-08-18 05:59:24 +02:00
|
|
|
return sprintf(buffer, "%06x\n", kbd_led_state.color.extra);
|
2018-06-08 11:56:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sysfs Interface for the keyboard brightness (unsigned int)
|
2019-06-04 19:32:30 +02:00
|
|
|
static ssize_t show_brightness_fs(struct device *child,
|
|
|
|
struct device_attribute *attr, char *buffer)
|
2018-06-08 11:56:32 +02:00
|
|
|
{
|
2019-08-18 05:59:24 +02:00
|
|
|
return sprintf(buffer, "%d\n", kbd_led_state.brightness);
|
2018-06-08 11:56:32 +02:00
|
|
|
}
|
|
|
|
|
2019-08-04 02:33:29 +02:00
|
|
|
// Sysfs Interface for the backlight blinking pattern
|
2019-06-06 15:48:59 +02:00
|
|
|
static ssize_t show_blinking_patterns_fs(struct device *child, struct device_attribute *attr,
|
|
|
|
char *buffer)
|
2018-06-08 11:56:32 +02:00
|
|
|
{
|
2019-08-18 05:59:24 +02:00
|
|
|
return sprintf(buffer, "%d\n", kbd_led_state.blinking_pattern);
|
2018-06-08 11:56:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sysfs Interface for if the keyboard has extra region
|
2019-06-04 19:32:30 +02:00
|
|
|
static ssize_t show_hasextra_fs(struct device *child,
|
|
|
|
struct device_attribute *attr, char *buffer)
|
2018-06-08 11:56:32 +02:00
|
|
|
{
|
2019-08-18 05:59:24 +02:00
|
|
|
return sprintf(buffer, "%d\n", kbd_led_state.has_extra);
|
2018-06-08 11:56:32 +02:00
|
|
|
}
|
|
|
|
|
2019-06-04 19:32:30 +02:00
|
|
|
static int tuxedo_evaluate_wmi_method(u32 method_id, u32 arg, u32 * retval)
|
2018-06-08 11:56:32 +02:00
|
|
|
{
|
2019-08-04 02:58:15 +02:00
|
|
|
struct acpi_buffer acpi_input = { (acpi_size) sizeof(arg), &arg };
|
|
|
|
struct acpi_buffer acpi_output = { ACPI_ALLOCATE_BUFFER, NULL };
|
2019-05-31 20:30:00 +02:00
|
|
|
union acpi_object *obj;
|
|
|
|
acpi_status status;
|
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
TUXEDO_DEBUG("evaluate method: %0#4x IN : %0#6x\n", method_id, arg);
|
2019-05-31 18:30:47 +02:00
|
|
|
|
2019-08-04 02:58:15 +02:00
|
|
|
status = wmi_evaluate_method(CLEVO_GET_GUID, 0x00, method_id,
|
|
|
|
&acpi_input, &acpi_output);
|
2019-05-31 18:30:47 +02:00
|
|
|
|
|
|
|
if (unlikely(ACPI_FAILURE(status))) {
|
2019-05-31 20:30:00 +02:00
|
|
|
TUXEDO_ERROR("evaluate method error");
|
|
|
|
goto exit;
|
2019-05-31 18:30:47 +02:00
|
|
|
}
|
2018-06-08 11:56:32 +02:00
|
|
|
|
2019-08-04 02:58:15 +02:00
|
|
|
obj = (union acpi_object *)acpi_output.pointer;
|
2019-05-31 20:30:00 +02:00
|
|
|
if (obj && obj->type == ACPI_TYPE_INTEGER) {
|
|
|
|
tmp = (u32) obj->integer.value;
|
|
|
|
} else {
|
|
|
|
tmp = 0;
|
2019-05-31 18:30:47 +02:00
|
|
|
}
|
2018-06-08 11:56:32 +02:00
|
|
|
|
2019-05-31 20:30:00 +02:00
|
|
|
TUXEDO_DEBUG("%0#4x OUT: %0#6x (IN: %0#6x)\n", method_id, tmp, arg);
|
2019-05-31 18:30:47 +02:00
|
|
|
|
2019-05-31 20:30:00 +02:00
|
|
|
if (likely(retval)) {
|
|
|
|
*retval = tmp;
|
2019-05-31 18:30:47 +02:00
|
|
|
}
|
|
|
|
|
2019-05-31 20:30:00 +02:00
|
|
|
kfree(obj);
|
2019-05-31 18:30:47 +02:00
|
|
|
|
2019-06-04 19:32:30 +02:00
|
|
|
exit:
|
2019-05-31 20:30:00 +02:00
|
|
|
if (unlikely(ACPI_FAILURE(status))) {
|
|
|
|
return -EIO;
|
2019-05-31 18:30:47 +02:00
|
|
|
}
|
2019-05-31 20:30:00 +02:00
|
|
|
|
|
|
|
return 0;
|
2018-06-08 11:56:32 +02:00
|
|
|
}
|
|
|
|
|
2019-06-04 19:32:30 +02:00
|
|
|
static void set_brightness(u8 brightness)
|
2018-06-08 11:56:32 +02:00
|
|
|
{
|
2019-05-31 18:30:47 +02:00
|
|
|
TUXEDO_INFO("Set brightness on %d", brightness);
|
2019-06-04 19:32:30 +02:00
|
|
|
if (!tuxedo_evaluate_wmi_method
|
|
|
|
(SET_KB_LED, 0xF4000000 | brightness, NULL)) {
|
2019-08-18 05:59:24 +02:00
|
|
|
kbd_led_state.brightness = brightness;
|
2018-06-08 11:56:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-04 21:55:56 +02:00
|
|
|
static ssize_t set_brightness_fs(struct device *child,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buffer, size_t size)
|
|
|
|
{
|
|
|
|
unsigned int val;
|
|
|
|
// hier unsigned?
|
|
|
|
|
2019-08-04 04:10:59 +02:00
|
|
|
int err = kstrtouint(buffer, 0, &val);
|
|
|
|
if (err) {
|
|
|
|
return err;
|
2019-06-04 21:55:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
val = clamp_t(u8, val, BRIGHTNESS_MIN, BRIGHTNESS_MAX);
|
|
|
|
set_brightness(val);
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2019-06-04 19:32:30 +02:00
|
|
|
static void set_state(u8 state)
|
2018-06-08 11:56:32 +02:00
|
|
|
{
|
2019-05-31 18:30:47 +02:00
|
|
|
u32 cmd = 0xE0000000;
|
|
|
|
TUXEDO_INFO("Set keyboard state on: %d\n", state);
|
|
|
|
|
|
|
|
if (state == 0) {
|
|
|
|
cmd |= 0x003001;
|
|
|
|
} else {
|
|
|
|
cmd |= 0x07F001;
|
|
|
|
}
|
|
|
|
|
2019-06-04 19:18:06 +02:00
|
|
|
if (!tuxedo_evaluate_wmi_method(SET_KB_LED, cmd, NULL)) {
|
2019-08-18 06:09:03 +02:00
|
|
|
kbd_led_state.enabled = state;
|
2019-05-31 18:30:47 +02:00
|
|
|
}
|
2018-06-08 11:56:32 +02:00
|
|
|
}
|
|
|
|
|
2019-06-04 19:32:30 +02:00
|
|
|
static ssize_t set_state_fs(struct device *child, struct device_attribute *attr,
|
|
|
|
const char *buffer, size_t size)
|
2018-06-08 11:56:32 +02:00
|
|
|
{
|
2019-08-04 06:11:06 +02:00
|
|
|
unsigned int state;
|
2019-05-31 18:30:47 +02:00
|
|
|
|
2019-08-04 06:11:06 +02:00
|
|
|
int err = kstrtouint(buffer, 0, &state);
|
2019-08-04 04:10:59 +02:00
|
|
|
if (err) {
|
|
|
|
return err;
|
2019-05-31 18:30:47 +02:00
|
|
|
}
|
|
|
|
|
2019-08-04 06:11:06 +02:00
|
|
|
state = clamp_t(u8, state, 0, 1);
|
2019-05-31 18:30:47 +02:00
|
|
|
|
2019-08-04 06:11:06 +02:00
|
|
|
set_state(state);
|
2019-05-31 18:30:47 +02:00
|
|
|
|
2019-05-31 20:30:00 +02:00
|
|
|
return size;
|
2018-06-08 11:56:32 +02:00
|
|
|
}
|
|
|
|
|
2019-06-04 19:32:30 +02:00
|
|
|
static int set_color(u32 region, u32 color)
|
2018-06-08 11:56:32 +02:00
|
|
|
{
|
2019-05-31 18:30:47 +02:00
|
|
|
u32 cset =
|
|
|
|
((color & 0x0000FF) << 16) | ((color & 0xFF0000) >> 8) |
|
|
|
|
((color & 0x00FF00) >> 8);
|
|
|
|
u32 cmd = region | cset;
|
2018-06-08 11:56:32 +02:00
|
|
|
|
2019-05-31 18:30:47 +02:00
|
|
|
TUXEDO_DEBUG("Set Color '%08x' for region '%08x'", color, region);
|
2018-06-08 11:56:32 +02:00
|
|
|
|
2019-06-04 19:18:06 +02:00
|
|
|
return tuxedo_evaluate_wmi_method(SET_KB_LED, cmd, NULL);
|
2018-06-08 11:56:32 +02:00
|
|
|
}
|
|
|
|
|
2019-08-19 05:29:54 +02:00
|
|
|
static int set_color_string_region(const char *color_string, size_t size, u32 region)
|
2018-06-08 11:56:32 +02:00
|
|
|
{
|
2019-08-04 04:33:00 +02:00
|
|
|
u32 colorcode;
|
|
|
|
int err = kstrtouint(color_string, 0, &colorcode);
|
2019-05-31 18:30:47 +02:00
|
|
|
|
2019-08-04 04:10:59 +02:00
|
|
|
if (err) {
|
|
|
|
return err;
|
2019-05-31 18:30:47 +02:00
|
|
|
}
|
|
|
|
|
2019-08-04 04:33:00 +02:00
|
|
|
if (!set_color(region, colorcode)) {
|
2019-08-04 06:11:06 +02:00
|
|
|
// after succesfully setting color, update our state struct
|
|
|
|
// depending on which region was changed
|
2019-05-31 18:30:47 +02:00
|
|
|
switch (region) {
|
|
|
|
case REGION_LEFT:
|
2019-08-18 05:59:24 +02:00
|
|
|
kbd_led_state.color.left = colorcode;
|
2019-05-31 18:30:47 +02:00
|
|
|
break;
|
|
|
|
case REGION_CENTER:
|
2019-08-18 05:59:24 +02:00
|
|
|
kbd_led_state.color.center = colorcode;
|
2019-05-31 18:30:47 +02:00
|
|
|
break;
|
|
|
|
case REGION_RIGHT:
|
2019-08-18 05:59:24 +02:00
|
|
|
kbd_led_state.color.right = colorcode;
|
2019-05-31 18:30:47 +02:00
|
|
|
break;
|
|
|
|
case REGION_EXTRA:
|
2019-08-18 05:59:24 +02:00
|
|
|
kbd_led_state.color.extra = colorcode;
|
2019-05-31 18:30:47 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return size;
|
2018-06-08 11:56:32 +02:00
|
|
|
}
|
|
|
|
|
2019-06-04 19:32:30 +02:00
|
|
|
static ssize_t set_color_left_fs(struct device *child,
|
|
|
|
struct device_attribute *attr,
|
2019-08-12 18:34:41 +02:00
|
|
|
const char *color_string, size_t size)
|
2019-05-31 20:30:00 +02:00
|
|
|
{
|
2019-08-19 05:29:54 +02:00
|
|
|
return set_color_string_region(color_string, size, REGION_LEFT);
|
2019-05-31 20:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-06-04 19:32:30 +02:00
|
|
|
static ssize_t set_color_center_fs(struct device *child,
|
|
|
|
struct device_attribute *attr,
|
2019-08-12 18:34:41 +02:00
|
|
|
const char *color_string, size_t size)
|
2019-05-31 20:30:00 +02:00
|
|
|
{
|
2019-08-19 05:29:54 +02:00
|
|
|
return set_color_string_region(color_string, size, REGION_CENTER);
|
2019-05-31 20:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-06-04 19:32:30 +02:00
|
|
|
static ssize_t set_color_right_fs(struct device *child,
|
|
|
|
struct device_attribute *attr,
|
2019-08-12 18:34:41 +02:00
|
|
|
const char *color_string, size_t size)
|
2019-05-31 20:30:00 +02:00
|
|
|
{
|
2019-08-19 05:29:54 +02:00
|
|
|
return set_color_string_region(color_string, size, REGION_RIGHT);
|
2019-05-31 20:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-06-04 19:32:30 +02:00
|
|
|
static ssize_t set_color_extra_fs(struct device *child,
|
|
|
|
struct device_attribute *attr,
|
2019-08-12 18:34:41 +02:00
|
|
|
const char *color_string, size_t size)
|
2019-05-31 20:30:00 +02:00
|
|
|
{
|
2019-08-19 05:29:54 +02:00
|
|
|
return set_color_string_region(color_string, size, REGION_EXTRA);
|
2019-05-31 20:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-08-04 02:33:29 +02:00
|
|
|
static void set_blinking_pattern(u8 blinkling_pattern)
|
2019-05-31 20:30:00 +02:00
|
|
|
{
|
2019-08-04 02:33:29 +02:00
|
|
|
TUXEDO_INFO("set_mode on %s", blinking_patterns[blinkling_pattern].name);
|
2019-05-31 20:30:00 +02:00
|
|
|
|
2019-08-04 02:33:29 +02:00
|
|
|
if (!tuxedo_evaluate_wmi_method(SET_KB_LED, blinking_patterns[blinkling_pattern].value, NULL)) {
|
2019-08-04 04:33:28 +02:00
|
|
|
// wmi method was succesfull so update ur internal state struct
|
2019-08-18 05:59:24 +02:00
|
|
|
kbd_led_state.blinking_pattern = blinkling_pattern;
|
2019-05-31 20:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-08-04 04:33:28 +02:00
|
|
|
if (blinkling_pattern == 0) { // 0 is the "custom" blinking pattern
|
|
|
|
|
|
|
|
// so just set all regions to the stored colors
|
2019-08-18 05:59:24 +02:00
|
|
|
set_color(REGION_LEFT, kbd_led_state.color.left);
|
|
|
|
set_color(REGION_CENTER, kbd_led_state.color.center);
|
|
|
|
set_color(REGION_RIGHT, kbd_led_state.color.right);
|
2019-05-31 20:30:00 +02:00
|
|
|
|
2019-08-18 05:59:24 +02:00
|
|
|
if (kbd_led_state.has_extra == 1) {
|
|
|
|
set_color(REGION_EXTRA, kbd_led_state.color.extra);
|
2019-05-31 20:30:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-06 15:48:59 +02:00
|
|
|
static ssize_t set_blinking_pattern_fs(struct device *child,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buffer, size_t size)
|
2019-05-31 20:30:00 +02:00
|
|
|
{
|
2019-08-04 06:11:06 +02:00
|
|
|
unsigned int blinking_pattern;
|
2019-05-31 20:30:00 +02:00
|
|
|
|
2019-08-04 06:11:06 +02:00
|
|
|
int err = kstrtouint(buffer, 0, &blinking_pattern);
|
2019-08-04 04:10:59 +02:00
|
|
|
if (err) {
|
|
|
|
return err;
|
2019-05-31 20:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-08-04 06:11:06 +02:00
|
|
|
blinking_pattern = clamp_t(u8, blinking_pattern, 0, ARRAY_SIZE(blinking_patterns) - 1);
|
|
|
|
set_blinking_pattern(blinking_pattern);
|
2019-05-31 20:30:00 +02:00
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2019-08-18 05:49:12 +02:00
|
|
|
static int blinking_pattern_id_validator(const char *value,
|
|
|
|
const struct kernel_param *blinking_pattern_param)
|
2018-06-08 11:56:32 +02:00
|
|
|
{
|
2019-08-04 02:33:29 +02:00
|
|
|
int blinking_pattern = 0;
|
2018-06-08 11:56:32 +02:00
|
|
|
|
2019-08-18 05:49:12 +02:00
|
|
|
if (kstrtoint(value, 10, &blinking_pattern) != 0
|
2019-08-04 02:33:29 +02:00
|
|
|
|| blinking_pattern < 0
|
|
|
|
|| blinking_pattern > (ARRAY_SIZE(blinking_patterns) - 1)) {
|
2019-05-31 18:30:47 +02:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2018-06-08 11:56:32 +02:00
|
|
|
|
2019-08-18 05:49:12 +02:00
|
|
|
return param_set_int(value, blinking_pattern_param);
|
2018-06-08 11:56:32 +02:00
|
|
|
}
|
|
|
|
|
2019-08-18 05:49:12 +02:00
|
|
|
static int brightness_validator(const char *value,
|
|
|
|
const struct kernel_param *brightness_param)
|
2018-06-08 11:56:32 +02:00
|
|
|
{
|
2019-05-31 18:30:47 +02:00
|
|
|
int brightness = 0;
|
2018-06-08 11:56:32 +02:00
|
|
|
|
2019-08-18 05:49:12 +02:00
|
|
|
if (kstrtoint(value, 10, &brightness) != 0
|
2019-06-04 21:55:56 +02:00
|
|
|
|| brightness < BRIGHTNESS_MIN
|
2019-05-31 18:30:47 +02:00
|
|
|
|| brightness > BRIGHTNESS_MAX) {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2018-06-08 11:56:32 +02:00
|
|
|
|
2019-08-18 05:49:12 +02:00
|
|
|
return param_set_int(value, brightness_param);
|
2018-06-08 11:56:32 +02:00
|
|
|
}
|
|
|
|
|
2019-06-04 19:32:30 +02:00
|
|
|
static void tuxedo_wmi_notify(u32 value, void *context)
|
2019-05-31 20:30:00 +02:00
|
|
|
{
|
|
|
|
u32 event;
|
|
|
|
|
2019-06-04 19:18:06 +02:00
|
|
|
tuxedo_evaluate_wmi_method(GET_EVENT, 0, &event);
|
2019-05-31 20:30:00 +02:00
|
|
|
TUXEDO_DEBUG("WMI event (%0#6x)\n", event);
|
|
|
|
|
|
|
|
switch (event) {
|
|
|
|
case WMI_CODE_DECREASE_BACKLIGHT:
|
2019-08-18 05:59:24 +02:00
|
|
|
if (kbd_led_state.brightness == BRIGHTNESS_MIN
|
|
|
|
|| (kbd_led_state.brightness - 25) < BRIGHTNESS_MIN) {
|
2019-05-31 20:30:00 +02:00
|
|
|
set_brightness(BRIGHTNESS_MIN);
|
|
|
|
} else {
|
2019-08-18 05:59:24 +02:00
|
|
|
set_brightness(kbd_led_state.brightness - 25);
|
2019-05-31 20:30:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WMI_CODE_INCREASE_BACKLIGHT:
|
2019-08-18 05:59:24 +02:00
|
|
|
if (kbd_led_state.brightness == BRIGHTNESS_MAX
|
|
|
|
|| (kbd_led_state.brightness + 25) > BRIGHTNESS_MAX) {
|
2019-05-31 20:30:00 +02:00
|
|
|
set_brightness(BRIGHTNESS_MAX);
|
|
|
|
} else {
|
2019-08-18 05:59:24 +02:00
|
|
|
set_brightness(kbd_led_state.brightness + 25);
|
2019-05-31 20:30:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2019-08-04 02:33:29 +02:00
|
|
|
case WMI_CODE_NEXT_BLINKING_PATTERN:
|
2019-08-18 05:59:24 +02:00
|
|
|
set_blinking_pattern((kbd_led_state.blinking_pattern + 1) >
|
|
|
|
(ARRAY_SIZE(blinking_patterns) - 1) ? 0 : (kbd_led_state.blinking_pattern + 1));
|
2019-05-31 20:30:00 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WMI_CODE_TOGGLE_STATE:
|
2019-08-18 06:09:03 +02:00
|
|
|
set_state(kbd_led_state.enabled == 0 ? 1 : 0);
|
2019-05-31 20:30:00 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-04 19:32:30 +02:00
|
|
|
static int tuxedo_wmi_probe(struct platform_device *dev)
|
2019-05-31 20:30:00 +02:00
|
|
|
{
|
2019-08-04 04:33:28 +02:00
|
|
|
int status = wmi_install_notify_handler(CLEVO_EVENT_GUID, tuxedo_wmi_notify, NULL);
|
2019-05-31 20:30:00 +02:00
|
|
|
|
|
|
|
// neuer name?
|
|
|
|
TUXEDO_DEBUG("clevo_xsm_wmi_probe status: (%0#6x)", status);
|
|
|
|
|
|
|
|
if (unlikely(ACPI_FAILURE(status))) {
|
2019-08-04 04:33:28 +02:00
|
|
|
TUXEDO_ERROR("Could not register WMI notify handler (%0#6x)\n", status);
|
2019-05-31 20:30:00 +02:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2019-06-04 19:18:06 +02:00
|
|
|
tuxedo_evaluate_wmi_method(GET_AP, 0, NULL);
|
2019-05-31 20:30:00 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-06-04 19:32:30 +02:00
|
|
|
static int tuxedo_wmi_remove(struct platform_device *dev)
|
2019-05-31 20:30:00 +02:00
|
|
|
{
|
|
|
|
wmi_remove_notify_handler(CLEVO_EVENT_GUID);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-06-04 19:32:30 +02:00
|
|
|
static int tuxedo_wmi_resume(struct platform_device *dev)
|
2019-05-31 20:30:00 +02:00
|
|
|
{
|
2019-06-04 19:18:06 +02:00
|
|
|
tuxedo_evaluate_wmi_method(GET_AP, 0, NULL);
|
2019-05-31 20:30:00 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver tuxedo_platform_driver = {
|
|
|
|
.remove = tuxedo_wmi_remove,
|
|
|
|
.resume = tuxedo_wmi_resume,
|
|
|
|
.driver = {
|
2019-06-04 19:32:30 +02:00
|
|
|
.name = DRIVER_NAME,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
2019-05-31 20:30:00 +02:00
|
|
|
};
|
|
|
|
|
2019-08-04 03:30:06 +02:00
|
|
|
// Sysfs attribute file permissions and method linking
|
2019-05-31 19:39:20 +02:00
|
|
|
static DEVICE_ATTR(state, 0644, show_state_fs, set_state_fs);
|
|
|
|
static DEVICE_ATTR(color_left, 0644, show_color_left_fs, set_color_left_fs);
|
|
|
|
static DEVICE_ATTR(color_center, 0644, show_color_center_fs,
|
2019-06-04 19:32:30 +02:00
|
|
|
set_color_center_fs);
|
2019-05-31 19:39:20 +02:00
|
|
|
static DEVICE_ATTR(color_right, 0644, show_color_right_fs, set_color_right_fs);
|
|
|
|
static DEVICE_ATTR(color_extra, 0644, show_color_extra_fs, set_color_extra_fs);
|
|
|
|
static DEVICE_ATTR(brightness, 0644, show_brightness_fs, set_brightness_fs);
|
2019-06-06 15:48:59 +02:00
|
|
|
static DEVICE_ATTR(mode, 0644, show_blinking_patterns_fs, set_blinking_pattern_fs);
|
2019-05-31 19:39:20 +02:00
|
|
|
static DEVICE_ATTR(extra, 0444, show_hasextra_fs, NULL);
|
|
|
|
|
2019-06-04 19:32:30 +02:00
|
|
|
static int __init tuxedo_input_init(void)
|
2019-05-31 19:39:20 +02:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
tuxedo_input_device = input_allocate_device();
|
|
|
|
if (unlikely(!tuxedo_input_device)) {
|
|
|
|
TUXEDO_ERROR("Error allocating input device\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
tuxedo_input_device->name = "TUXEDO Keyboard";
|
|
|
|
tuxedo_input_device->phys = DRIVER_NAME "/input0";
|
|
|
|
tuxedo_input_device->id.bustype = BUS_HOST;
|
|
|
|
tuxedo_input_device->dev.parent = &tuxedo_platform_device->dev;
|
|
|
|
|
|
|
|
set_bit(EV_KEY, tuxedo_input_device->evbit);
|
|
|
|
|
|
|
|
err = input_register_device(tuxedo_input_device);
|
|
|
|
if (unlikely(err)) {
|
|
|
|
TUXEDO_ERROR("Error registering input device\n");
|
|
|
|
goto err_free_input_device;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2019-06-04 19:32:30 +02:00
|
|
|
err_free_input_device:
|
2019-05-31 19:39:20 +02:00
|
|
|
input_free_device(tuxedo_input_device);
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2019-06-04 19:32:30 +02:00
|
|
|
static void __exit tuxedo_input_exit(void)
|
2019-05-31 19:39:20 +02:00
|
|
|
{
|
|
|
|
if (unlikely(!tuxedo_input_device)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
input_unregister_device(tuxedo_input_device);
|
|
|
|
{
|
|
|
|
tuxedo_input_device = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-04 19:32:30 +02:00
|
|
|
static int __init tuxdeo_keyboard_init(void)
|
2019-05-31 19:39:20 +02:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!wmi_has_guid(CLEVO_EVENT_GUID)) {
|
|
|
|
TUXEDO_ERROR("No known WMI event notification GUID found\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!wmi_has_guid(CLEVO_GET_GUID)) {
|
|
|
|
TUXEDO_ERROR("No known WMI control method GUID found\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
TUXEDO_INFO("Model '%s' found\n",
|
2019-06-04 19:32:30 +02:00
|
|
|
dmi_get_system_info(DMI_PRODUCT_NAME));
|
2019-05-31 19:39:20 +02:00
|
|
|
|
|
|
|
tuxedo_platform_device =
|
|
|
|
platform_create_bundle(&tuxedo_platform_driver, tuxedo_wmi_probe,
|
2019-06-04 19:32:30 +02:00
|
|
|
NULL, 0, NULL, 0);
|
2019-08-04 02:58:15 +02:00
|
|
|
|
2019-05-31 19:39:20 +02:00
|
|
|
if (unlikely(IS_ERR(tuxedo_platform_device))) {
|
|
|
|
TUXEDO_ERROR("Can not init Platform driver");
|
|
|
|
return PTR_ERR(tuxedo_platform_device);
|
|
|
|
}
|
|
|
|
|
|
|
|
err = tuxedo_input_init();
|
|
|
|
if (unlikely(err)) {
|
|
|
|
TUXEDO_ERROR("Could not register input device\n");
|
|
|
|
}
|
|
|
|
|
2019-08-04 02:58:15 +02:00
|
|
|
if (device_create_file(&tuxedo_platform_device->dev, &dev_attr_state) != 0) {
|
2019-08-04 03:30:06 +02:00
|
|
|
TUXEDO_ERROR("Sysfs attribute file creation failed for state\n");
|
2019-05-31 19:39:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (device_create_file
|
|
|
|
(&tuxedo_platform_device->dev, &dev_attr_color_left) != 0) {
|
|
|
|
TUXEDO_ERROR
|
2019-08-04 03:30:06 +02:00
|
|
|
("Sysfs attribute file creation failed for color left\n");
|
2019-05-31 19:39:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (device_create_file
|
|
|
|
(&tuxedo_platform_device->dev, &dev_attr_color_center) != 0) {
|
|
|
|
TUXEDO_ERROR
|
2019-08-04 03:30:06 +02:00
|
|
|
("Sysfs attribute file creation failed for color center\n");
|
2019-05-31 19:39:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (device_create_file
|
|
|
|
(&tuxedo_platform_device->dev, &dev_attr_color_right) != 0) {
|
|
|
|
TUXEDO_ERROR
|
2019-08-04 03:30:06 +02:00
|
|
|
("Sysfs attribute file creation failed for color right\n");
|
2019-05-31 19:39:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (set_color(REGION_EXTRA, KB_COLOR_DEFAULT) != 0) {
|
|
|
|
TUXEDO_DEBUG("Keyboard does not support EXTRA Color");
|
2019-08-18 05:59:24 +02:00
|
|
|
kbd_led_state.has_extra = 0;
|
2019-05-31 19:39:20 +02:00
|
|
|
} else {
|
2019-08-18 05:59:24 +02:00
|
|
|
kbd_led_state.has_extra = 1;
|
2019-05-31 19:39:20 +02:00
|
|
|
if (device_create_file
|
|
|
|
(&tuxedo_platform_device->dev,
|
|
|
|
&dev_attr_color_extra) != 0) {
|
|
|
|
TUXEDO_ERROR
|
2019-08-04 03:30:06 +02:00
|
|
|
("Sysfs attribute file creation failed for color extra\n");
|
2019-05-31 19:39:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
set_color(REGION_EXTRA, param_color_extra);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (device_create_file(&tuxedo_platform_device->dev, &dev_attr_extra) !=
|
|
|
|
0) {
|
|
|
|
TUXEDO_ERROR
|
2019-08-04 03:30:06 +02:00
|
|
|
("Sysfs attribute file creation failed for extra information flag\n");
|
2019-05-31 19:39:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (device_create_file(&tuxedo_platform_device->dev, &dev_attr_mode) !=
|
|
|
|
0) {
|
2019-08-04 03:30:06 +02:00
|
|
|
TUXEDO_ERROR("Sysfs attribute file creation failed for blinking pattern\n");
|
2019-05-31 19:39:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (device_create_file
|
|
|
|
(&tuxedo_platform_device->dev, &dev_attr_brightness) != 0) {
|
|
|
|
TUXEDO_ERROR
|
2019-08-04 03:30:06 +02:00
|
|
|
("Sysfs attribute file creation failed for brightness\n");
|
2019-05-31 19:39:20 +02:00
|
|
|
}
|
|
|
|
|
2019-08-18 05:59:24 +02:00
|
|
|
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;
|
2019-05-31 19:39:20 +02:00
|
|
|
|
|
|
|
set_color(REGION_LEFT, param_color_left);
|
|
|
|
set_color(REGION_CENTER, param_color_center);
|
|
|
|
set_color(REGION_RIGHT, param_color_right);
|
|
|
|
|
2019-08-04 02:33:29 +02:00
|
|
|
set_blinking_pattern(param_blinking_pattern);
|
2019-05-31 19:39:20 +02:00
|
|
|
set_brightness(param_brightness);
|
2019-06-04 19:18:06 +02:00
|
|
|
set_state(param_state);
|
2019-05-31 19:39:20 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-06-04 19:32:30 +02:00
|
|
|
static void __exit tuxdeo_keyboard_exit(void)
|
2019-05-31 19:39:20 +02:00
|
|
|
{
|
|
|
|
tuxedo_input_exit();
|
|
|
|
|
|
|
|
device_remove_file(&tuxedo_platform_device->dev, &dev_attr_state);
|
|
|
|
device_remove_file(&tuxedo_platform_device->dev, &dev_attr_color_left);
|
|
|
|
device_remove_file(&tuxedo_platform_device->dev,
|
2019-06-04 19:32:30 +02:00
|
|
|
&dev_attr_color_center);
|
2019-05-31 19:39:20 +02:00
|
|
|
device_remove_file(&tuxedo_platform_device->dev, &dev_attr_color_right);
|
|
|
|
device_remove_file(&tuxedo_platform_device->dev, &dev_attr_extra);
|
|
|
|
device_remove_file(&tuxedo_platform_device->dev, &dev_attr_mode);
|
|
|
|
device_remove_file(&tuxedo_platform_device->dev, &dev_attr_brightness);
|
|
|
|
|
2019-08-18 05:59:24 +02:00
|
|
|
if (kbd_led_state.has_extra == 1) {
|
2019-05-31 19:39:20 +02:00
|
|
|
device_remove_file(&tuxedo_platform_device->dev,
|
2019-06-04 19:32:30 +02:00
|
|
|
&dev_attr_color_extra);
|
2019-05-31 19:39:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
platform_device_unregister(tuxedo_platform_device);
|
|
|
|
|
|
|
|
platform_driver_unregister(&tuxedo_platform_driver);
|
|
|
|
|
|
|
|
TUXEDO_DEBUG("exit");
|
|
|
|
}
|
|
|
|
|
2018-06-08 11:56:32 +02:00
|
|
|
module_init(tuxdeo_keyboard_init);
|
|
|
|
module_exit(tuxdeo_keyboard_exit);
|