Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Katana GF76-11UC, 17L2EMS1.108 #139

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ec_memory_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,18 @@ struct msi_ec_fan_mode_conf {
struct msi_ec_mode modes[5]; // fixed size for easier hard coding
};

#define FAN_PARSE_STRATEGY_NORMAL 0
// When fan speed specified in reverse order
// 0xff - minimal speed, 0x01 - maximum and 0x00 - stopped.
#define FAN_PARSE_STRATEGY_REVERSE 1
struct msi_ec_cpu_conf {
int rt_temp_address;
int rt_fan_speed_address; // realtime
int rt_fan_speed_base_min;
int rt_fan_speed_base_max;
// For special fan speed parsing cases
// Optional parameter. Defaults to FAN_PARSE_STRATEGY_NORMAL.
int rt_fan_parse_strategy;
int bs_fan_speed_address; // basic
int bs_fan_speed_base_min;
int bs_fan_speed_base_max;
Expand Down
34 changes: 26 additions & 8 deletions msi-ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ static struct msi_ec_conf CONF13 __initdata = {
};

static const char *ALLOWED_FW_14[] __initconst = {
"17L2EMS1.108", // Katana 17 B11UCX
"17L2EMS1.108", // Katana 17 B11UCX, Katana GF76-11UC
NULL
};

Expand Down Expand Up @@ -1228,8 +1228,9 @@ static struct msi_ec_conf CONF14 __initdata = {
.cpu = {
.rt_temp_address = 0x68,
.rt_fan_speed_address = 0xc9,
.rt_fan_speed_base_min = 0x00, // ?
.rt_fan_speed_base_max = 0x96, // ?
.rt_fan_speed_base_min = 0xff,
.rt_fan_speed_base_max = 0x4a,
.rt_fan_parse_strategy = FAN_PARSE_STRATEGY_REVERSE,
.bs_fan_speed_address = MSI_EC_ADDR_UNSUPP,
.bs_fan_speed_base_min = 0x00, // ?
.bs_fan_speed_base_max = 0x0f, // ?
Expand Down Expand Up @@ -2736,14 +2737,26 @@ static ssize_t cpu_realtime_fan_speed_show(struct device *device,
if (result < 0)
return result;

if ((rdata < conf.cpu.rt_fan_speed_base_min ||
rdata > conf.cpu.rt_fan_speed_base_max))
if (rdata == 0)
return sysfs_emit(buf, "%i\n", 0);

int fan_speed = rdata;
int fan_speed_max = conf.cpu.rt_fan_speed_base_max;
int fan_speed_min = conf.cpu.rt_fan_speed_base_min;
if (conf.cpu.rt_fan_parse_strategy == FAN_PARSE_STRATEGY_REVERSE) {
fan_speed *= -1;
fan_speed_max *= -1;
fan_speed_min *= -1;
}

if ((fan_speed < fan_speed_min ||
fan_speed > fan_speed_max))
return -EINVAL;

return sysfs_emit(buf, "%i\n",
100 * (rdata - conf.cpu.rt_fan_speed_base_min) /
(conf.cpu.rt_fan_speed_base_max -
conf.cpu.rt_fan_speed_base_min));
100 * (fan_speed - fan_speed_min) /
(fan_speed_max -
fan_speed_min));
}

static ssize_t cpu_basic_fan_speed_show(struct device *device,
Expand Down Expand Up @@ -3222,6 +3235,11 @@ static enum led_brightness kbd_bl_sysfs_get(struct led_classdev *led_cdev)
static int kbd_bl_sysfs_set(struct led_classdev *led_cdev,
enum led_brightness brightness)
{
// By default, on an unregister event,
// kernel triggers the setter with 0 brightness.
if (led_cdev->flags & LED_UNREGISTERING)
return 0;

u8 wdata;
if (brightness < 0 || brightness > 3)
return -1;
Expand Down