mirror of
https://github.com/wessel-novacustom/clevo-keyboard.git
synced 2024-11-15 03:34:01 +01:00
Change use of uw if read/write to new ones
- For uniwill_keyboard part - Remove now unused uw_io.h
This commit is contained in:
parent
931d3c7f30
commit
64c47a6943
|
@ -26,7 +26,6 @@
|
||||||
#include <linux/leds.h>
|
#include <linux/leds.h>
|
||||||
#include <linux/string.h>
|
#include <linux/string.h>
|
||||||
#include <linux/version.h>
|
#include <linux/version.h>
|
||||||
#include "uw_io.h"
|
|
||||||
#include "uniwill_interfaces.h"
|
#include "uniwill_interfaces.h"
|
||||||
|
|
||||||
#define UNIWILL_WMI_MGMT_GUID_BA "ABBC0F6D-8EA1-11D1-00A0-C90629100000"
|
#define UNIWILL_WMI_MGMT_GUID_BA "ABBC0F6D-8EA1-11D1-00A0-C90629100000"
|
||||||
|
@ -216,11 +215,11 @@ static struct notifier_block keyboard_notifier_block = {
|
||||||
|
|
||||||
static u8 uniwill_read_kbd_bl_enabled(void)
|
static u8 uniwill_read_kbd_bl_enabled(void)
|
||||||
{
|
{
|
||||||
union uw_ec_read_return reg_read_return;
|
u8 backlight_data;
|
||||||
u8 enabled = 0xff;
|
u8 enabled = 0xff;
|
||||||
|
|
||||||
__uw_ec_read_addr(0x8c, 0x07, ®_read_return);
|
uniwill_read_ec_ram(0x078c, &backlight_data);
|
||||||
enabled = (reg_read_return.bytes.data_low >> 1) & 0x01;
|
enabled = (backlight_data >> 1) & 0x01;
|
||||||
enabled = !enabled;
|
enabled = !enabled;
|
||||||
|
|
||||||
return enabled;
|
return enabled;
|
||||||
|
@ -228,24 +227,22 @@ static u8 uniwill_read_kbd_bl_enabled(void)
|
||||||
|
|
||||||
static void uniwill_write_kbd_bl_enable(u8 enable)
|
static void uniwill_write_kbd_bl_enable(u8 enable)
|
||||||
{
|
{
|
||||||
union uw_ec_read_return reg_read_return;
|
u8 backlight_data;
|
||||||
union uw_ec_write_return reg_write_return;
|
|
||||||
u8 write_value = 0;
|
|
||||||
enable = enable & 0x01;
|
enable = enable & 0x01;
|
||||||
|
|
||||||
__uw_ec_read_addr(0x8c, 0x07, ®_read_return);
|
uniwill_read_ec_ram(0x078c, &backlight_data);
|
||||||
write_value = reg_read_return.bytes.data_low & ~(1 << 1);
|
backlight_data = backlight_data & ~(1 << 1);
|
||||||
write_value |= (!enable << 1);
|
backlight_data |= (!enable << 1);
|
||||||
__uw_ec_write_addr(0x8c, 0x07, write_value, 0x00, ®_write_return);
|
uniwill_write_ec_ram(0x078c, backlight_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static u32 uniwill_read_kbd_bl_br_state(u8 *brightness_state)
|
/*static u32 uniwill_read_kbd_bl_br_state(u8 *brightness_state)
|
||||||
{
|
{
|
||||||
union uw_ec_read_return reg_read_return;
|
u8 backlight_data;
|
||||||
u32 result;
|
u32 result;
|
||||||
|
|
||||||
__uw_ec_read_addr(0x8c, 0x07, ®_read_return);
|
uniwill_read_ec_ram(0x078c, &backlight_data);
|
||||||
*brightness_state = (reg_read_return.bytes.data_low & 0xf0) >> 4;
|
*brightness_state = (backlight_data & 0xf0) >> 4;
|
||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -253,15 +250,12 @@ static void uniwill_write_kbd_bl_enable(u8 enable)
|
||||||
|
|
||||||
static u32 uniwill_read_kbd_bl_rgb(u8 *red, u8 *green, u8 *blue)
|
static u32 uniwill_read_kbd_bl_rgb(u8 *red, u8 *green, u8 *blue)
|
||||||
{
|
{
|
||||||
union uw_ec_read_return reg_read_return;
|
|
||||||
u32 result;
|
u32 result;
|
||||||
|
|
||||||
__uw_ec_read_addr(0x03, 0x18, ®_read_return);
|
uniwill_read_ec_ram(0x1803, red);
|
||||||
*red = reg_read_return.bytes.data_low;
|
uniwill_read_ec_ram(0x1805, green);
|
||||||
__uw_ec_read_addr(0x05, 0x18, ®_read_return);
|
uniwill_read_ec_ram(0x1808, blue);
|
||||||
*green = reg_read_return.bytes.data_low;
|
|
||||||
__uw_ec_read_addr(0x08, 0x18, ®_read_return);
|
|
||||||
*blue = reg_read_return.bytes.data_low;
|
|
||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -269,16 +263,13 @@ static u32 uniwill_read_kbd_bl_rgb(u8 *red, u8 *green, u8 *blue)
|
||||||
|
|
||||||
static void uniwill_write_kbd_bl_rgb(u8 red, u8 green, u8 blue)
|
static void uniwill_write_kbd_bl_rgb(u8 red, u8 green, u8 blue)
|
||||||
{
|
{
|
||||||
union uw_ec_write_return reg_write_return;
|
|
||||||
|
|
||||||
// Write the colors
|
|
||||||
if (red > 0xc8) red = 0xc8;
|
if (red > 0xc8) red = 0xc8;
|
||||||
if (green > 0xc8) green = 0xc8;
|
if (green > 0xc8) green = 0xc8;
|
||||||
if (blue > 0xc8) blue = 0xc8;
|
if (blue > 0xc8) blue = 0xc8;
|
||||||
__uw_ec_write_addr(0x03, 0x18, red, 0x00, ®_write_return);
|
uniwill_write_ec_ram(0x1803, red);
|
||||||
__uw_ec_write_addr(0x05, 0x18, green, 0x00, ®_write_return);
|
uniwill_write_ec_ram(0x1805, green);
|
||||||
__uw_ec_write_addr(0x08, 0x18, blue, 0x00, ®_write_return);
|
uniwill_write_ec_ram(0x1808, blue);
|
||||||
TUXEDO_DEBUG("Wrote color [%0#4x, %0#4x, %0#4x]\n", red, green, blue);
|
TUXEDO_DEBUG("Wrote kbd color [%0#4x, %0#4x, %0#4x]\n", red, green, blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void uniwill_write_kbd_bl_state(void) {
|
static void uniwill_write_kbd_bl_state(void) {
|
||||||
|
@ -304,9 +295,7 @@ static void uniwill_write_kbd_bl_state(void) {
|
||||||
|
|
||||||
static void uniwill_write_kbd_bl_reset(void)
|
static void uniwill_write_kbd_bl_reset(void)
|
||||||
{
|
{
|
||||||
union uw_ec_write_return reg_write_return;
|
uniwill_write_ec_ram(0x078c, 0x10);
|
||||||
|
|
||||||
__uw_ec_write_addr(0x8c, 0x07, 0x10, 0x00, ®_write_return);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void uniwill_event_callb(u32 code)
|
void uniwill_event_callb(u32 code)
|
||||||
|
@ -604,105 +593,49 @@ static int uw_kbd_bl_init(struct platform_device *dev)
|
||||||
|
|
||||||
static void uniwill_write_lightbar_rgb(u8 red, u8 green, u8 blue)
|
static void uniwill_write_lightbar_rgb(u8 red, u8 green, u8 blue)
|
||||||
{
|
{
|
||||||
union uw_ec_write_return reg_write_return;
|
|
||||||
|
|
||||||
uw_ec_write_func *__uw_ec_write_addr;
|
|
||||||
|
|
||||||
__uw_ec_write_addr = symbol_get(uw_ec_write_addr);
|
|
||||||
|
|
||||||
if (__uw_ec_write_addr) {
|
|
||||||
if (red <= UNIWILL_LIGHTBAR_LED_MAX_BRIGHTNESS) {
|
if (red <= UNIWILL_LIGHTBAR_LED_MAX_BRIGHTNESS) {
|
||||||
__uw_ec_write_addr(0x49, 0x07, red, 0x00, ®_write_return);
|
uniwill_write_ec_ram(0x0749, red);
|
||||||
}
|
}
|
||||||
if (green <= UNIWILL_LIGHTBAR_LED_MAX_BRIGHTNESS) {
|
if (green <= UNIWILL_LIGHTBAR_LED_MAX_BRIGHTNESS) {
|
||||||
__uw_ec_write_addr(0x4a, 0x07, green, 0x00, ®_write_return);
|
uniwill_write_ec_ram(0x074a, green);
|
||||||
}
|
}
|
||||||
if (blue <= UNIWILL_LIGHTBAR_LED_MAX_BRIGHTNESS) {
|
if (blue <= UNIWILL_LIGHTBAR_LED_MAX_BRIGHTNESS) {
|
||||||
__uw_ec_write_addr(0x4b, 0x07, blue, 0x00, ®_write_return);
|
uniwill_write_ec_ram(0x074b, blue);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
TUXEDO_DEBUG("tuxedo-cc-wmi symbols not found\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (__uw_ec_write_addr) symbol_put(uw_ec_write_addr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int uniwill_read_lightbar_rgb(u8 *red, u8 *green, u8 *blue)
|
static int uniwill_read_lightbar_rgb(u8 *red, u8 *green, u8 *blue)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
union uw_ec_read_return reg_read_return;
|
|
||||||
|
|
||||||
uw_ec_read_func *__uw_ec_read_addr;
|
uniwill_read_ec_ram(0x0749, red);
|
||||||
|
uniwill_read_ec_ram(0x074a, green);
|
||||||
__uw_ec_read_addr = symbol_get(uw_ec_read_addr);
|
uniwill_read_ec_ram(0x074b, blue);
|
||||||
|
|
||||||
if (__uw_ec_read_addr) {
|
|
||||||
__uw_ec_read_addr(0x49, 0x07, ®_read_return);
|
|
||||||
*red = reg_read_return.bytes.data_low;
|
|
||||||
__uw_ec_read_addr(0x4a, 0x07, ®_read_return);
|
|
||||||
*green = reg_read_return.bytes.data_low;
|
|
||||||
__uw_ec_read_addr(0x4b, 0x07, ®_read_return);
|
|
||||||
*blue = reg_read_return.bytes.data_low;
|
|
||||||
status = 0;
|
status = 0;
|
||||||
} else {
|
|
||||||
status = -EIO;
|
|
||||||
TUXEDO_DEBUG("tuxedo-cc-wmi symbols not found\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (__uw_ec_read_addr) symbol_put(uw_ec_read_addr);
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void uniwill_write_lightbar_animation(bool animation_status)
|
static void uniwill_write_lightbar_animation(bool animation_status)
|
||||||
{
|
{
|
||||||
union uw_ec_write_return reg_write_return;
|
|
||||||
union uw_ec_read_return reg_read_return;
|
|
||||||
|
|
||||||
u8 value;
|
u8 value;
|
||||||
|
|
||||||
uw_ec_write_func *__uw_ec_write_addr;
|
uniwill_read_ec_ram(0x0748, &value);
|
||||||
uw_ec_read_func *__uw_ec_read_addr;
|
|
||||||
|
|
||||||
__uw_ec_write_addr = symbol_get(uw_ec_write_addr);
|
|
||||||
__uw_ec_read_addr = symbol_get(uw_ec_read_addr);
|
|
||||||
|
|
||||||
if (__uw_ec_write_addr && __uw_ec_read_addr) {
|
|
||||||
__uw_ec_read_addr(0x48, 0x07, ®_read_return);
|
|
||||||
value = reg_read_return.bytes.data_low;
|
|
||||||
if (animation_status) {
|
if (animation_status) {
|
||||||
value |= 0x80;
|
value |= 0x80;
|
||||||
} else {
|
} else {
|
||||||
value &= ~0x80;
|
value &= ~0x80;
|
||||||
}
|
}
|
||||||
__uw_ec_write_addr(0x48, 0x07, value, 0x00, ®_write_return);
|
uniwill_write_ec_ram(0x0748, value);
|
||||||
} else {
|
|
||||||
TUXEDO_DEBUG("tuxedo-cc-wmi symbols not found\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (__uw_ec_write_addr) symbol_put(uw_ec_write_addr);
|
|
||||||
if (__uw_ec_read_addr) symbol_put(uw_ec_read_addr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int uniwill_read_lightbar_animation(bool *animation_status)
|
static int uniwill_read_lightbar_animation(bool *animation_status)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
union uw_ec_read_return reg_read_return;
|
u8 lightbar_animation_data;
|
||||||
|
|
||||||
uw_ec_read_func *__uw_ec_read_addr;
|
status = uniwill_read_ec_ram(0x0748, &lightbar_animation_data);
|
||||||
|
*animation_status = (lightbar_animation_data & 0x80) > 0;
|
||||||
__uw_ec_read_addr = symbol_get(uw_ec_read_addr);
|
|
||||||
|
|
||||||
if (__uw_ec_read_addr) {
|
|
||||||
__uw_ec_read_addr(0x48, 0x07, ®_read_return);
|
|
||||||
*animation_status = (reg_read_return.bytes.data_low & 0x80) > 0;
|
|
||||||
status = 0;
|
|
||||||
} else {
|
|
||||||
status = -EIO;
|
|
||||||
TUXEDO_DEBUG("tuxedo-cc-wmi symbols not found\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (__uw_ec_read_addr) symbol_put(uw_ec_read_addr);
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
101
src/uw_io.h
101
src/uw_io.h
|
@ -1,101 +0,0 @@
|
||||||
/*!
|
|
||||||
* Copyright (c) 2020 TUXEDO Computers GmbH <tux@tuxedocomputers.com>
|
|
||||||
*
|
|
||||||
* This file is part of tuxedo-keyboard.
|
|
||||||
*
|
|
||||||
* tuxedo-keyboard 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 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This software 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 software. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#ifndef UW_IO_H
|
|
||||||
#define UW_IO_H
|
|
||||||
|
|
||||||
#include <linux/kernel.h>
|
|
||||||
#include <linux/module.h>
|
|
||||||
|
|
||||||
union uw_ec_read_return {
|
|
||||||
u32 dword;
|
|
||||||
struct {
|
|
||||||
u8 data_low;
|
|
||||||
u8 data_high;
|
|
||||||
} bytes;
|
|
||||||
};
|
|
||||||
|
|
||||||
union uw_ec_write_return {
|
|
||||||
u32 dword;
|
|
||||||
struct {
|
|
||||||
u8 addr_low;
|
|
||||||
u8 addr_high;
|
|
||||||
u8 data_low;
|
|
||||||
u8 data_high;
|
|
||||||
} bytes;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef u32 (uw_ec_read_func)(u8, u8, union uw_ec_read_return *);
|
|
||||||
typedef u32 (uw_ec_write_func)(u8, u8, u8, u8, union uw_ec_write_return *);
|
|
||||||
|
|
||||||
extern uw_ec_read_func uw_ec_read_addr;
|
|
||||||
extern uw_ec_write_func uw_ec_write_addr;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* uw ec read from tccwmi for now stuffed in this wrapper for simplification
|
|
||||||
*
|
|
||||||
* @returns The result of the tccwmi function, or -ENOENT
|
|
||||||
* if tccwmi symbol is not accessible
|
|
||||||
*/
|
|
||||||
static u32 __uw_ec_read_addr(u8 addr_low, u8 addr_high,
|
|
||||||
union uw_ec_read_return *output)
|
|
||||||
{
|
|
||||||
uw_ec_read_func *symbol_uw_ec_read_addr;
|
|
||||||
u32 result = 0;
|
|
||||||
symbol_uw_ec_read_addr = symbol_get(uw_ec_read_addr);
|
|
||||||
if (symbol_uw_ec_read_addr) {
|
|
||||||
result = symbol_uw_ec_read_addr(addr_low, addr_high, output);
|
|
||||||
} else {
|
|
||||||
pr_debug("tuxedo-cc-wmi symbols not found\n");
|
|
||||||
result = -ENOENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (symbol_uw_ec_read_addr)
|
|
||||||
symbol_put(uw_ec_read_addr);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* uw ec write from tccwmi for now stuffed in this wrapper for simplification
|
|
||||||
*
|
|
||||||
* @returns The result of the tccwmi function, or -ENOENT
|
|
||||||
* if tccwmi symbol is not accessible
|
|
||||||
*/
|
|
||||||
static u32 __uw_ec_write_addr(u8 addr_low, u8 addr_high, u8 data_low,
|
|
||||||
u8 data_high, union uw_ec_write_return *output)
|
|
||||||
{
|
|
||||||
uw_ec_write_func *symbol_uw_ec_write_addr;
|
|
||||||
u32 result = 0;
|
|
||||||
symbol_uw_ec_write_addr = symbol_get(uw_ec_write_addr);
|
|
||||||
|
|
||||||
if (symbol_uw_ec_write_addr) {
|
|
||||||
result = symbol_uw_ec_write_addr(addr_low, addr_high, data_low,
|
|
||||||
data_high, output);
|
|
||||||
} else {
|
|
||||||
pr_debug("tuxedo-cc-wmi symbols not found\n");
|
|
||||||
result = -ENOENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (symbol_uw_ec_write_addr)
|
|
||||||
symbol_put(uw_ec_write_addr);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in a new issue